Commit b5b487ee authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Correction : ajout et modification du type de document en annexe

Ajout : menu Typage
parent 0c6820ad
......@@ -131,7 +131,7 @@ class FichesController extends AppController
$selectType = '';
if (!empty($typages)) {
$selectType = '<div class="form-group"><label for="typage_'.$last_key_file.'" class="col-md-4 control-label"></label><div class="col-md-8"><select name="data[Fichier][typage_'.$last_key_file.']" id="typage_'.$last_key_file.'" class="form-control">'
$selectType = '<div class="form-group"><label for="typage_tmp_'.$last_key_file.'" class="col-md-4 control-label"></label><div class="col-md-8"><select name="data[Fichier][typage_tmp_'.$last_key_file.']" id="typage_tmp_'.$last_key_file.'" class="form-control">'
. '<option value="">Séléctionnez un type pour le fichier</option>';
foreach ($typages as $val => $typage) {
$selectType = $selectType . '<option value="' . $val . '">' . $typage . '</option>';
......@@ -638,6 +638,8 @@ class FichesController extends AppController
$this->redirect($this->Referers->get());
}
// debug($this->request->data);die;
$success = true;
$this->Fiche->begin();
......@@ -698,6 +700,59 @@ class FichesController extends AppController
$success = $this->WebdpoFiche->saveWithVirtualFields($data, $formulaireFields, $formulaireOptions, $formulaireOLD['Formulaire']['oldformulaire']);
if ($success == true) {
$etatTraitement = $this->EtatFiche->find('first', [
'conditions' => [
'fiche_id' => $id,
'actif' => true
],
'fields' => [
'etat_id'
]
]);
if ($etatTraitement['EtatFiche']['etat_id'] === EtatFiche::MODIFICATION_TRAITEMENT_REGISTRE) {
$texteHistorique = __d('historique', 'historique.modifierTraitementRegistre');
} else {
$texteHistorique = __d('historique', 'historique.modifierTraitement');
}
$this->Historique->create([
'Historique' => [
'content' => $this->Auth->user('nom_complet') . ' ' . $texteHistorique,
'fiche_id' => $id
]
]);
$success = false !== $this->Historique->save(null, ['atomic' => false]) && $success;
if (isset($this->request->data['delfiles']) && !empty($this->request->data['delfiles'])) {
foreach (array_unique($this->request->data['delfiles']) as $val) {
$success = $success && $this->Fichier->deleteFichier($val);
}
}
if (!empty($this->Session->read('Auth.User.uuid'))) {
if ($success == true) {
$useAllExtensionFiles = $this->Formulaire->find('first', [
'condititons' => [
'id' => $form_id['Fiche']['form_id']
],
'fields' => [
'useallextensionfiles'
]
]);
$success = $success && false !== $this->Fichier->transfereSave(
$id,
$useAllExtensionFiles['Formulaire']['useallextensionfiles'],
$this->Session->read('Auth.User.uuid'),
$this->Session->read('Auth.User.id'),
$data['Fichier']
);
}
}
}
if ($success == true &&
empty($this->Fiche->validationErrors) &&
empty($this->WebdpoFiche->validationErrors) &&
......@@ -1999,6 +2054,14 @@ class FichesController extends AppController
]
]);
if (!empty($filesSave)) {
$typageFiles = Hash::extract($filesSave, '{n}.Fichier.typage_id');
foreach ($typageFiles as $key => $typageFile) {
$this->request->data['Fichier']['typage_'.$key] = $typageFile;
}
}
$this->set(compact('filesSave'));
}
......
......@@ -148,6 +148,12 @@ msgstr "Toute la FAQ"
msgid "default.sousTitreMaFAQ"
msgstr "Ma FAQ"
msgid "default.titreTypages"
msgstr "Typages"
msgid "default.sousTitreTypagesAnnexes"
msgstr "Typages des annexes"
msgid "default.titreNormes"
msgstr "Normes"
......
......@@ -187,9 +187,10 @@ class Fichier extends AppModel {
$typeFile = null;
if (!empty($typages)) {
$keyFind = 'typage_'.$key;
if (array_key_exists($keyFind, $typages)) {
$typeFile = $typages[$keyFind];
if (array_key_exists('typage_tmp_'.$key, $typages) === true) {
$typeFile = $typages['typage_tmp_'.$key];
} elseif (array_key_exists('typage_'.$key, $typages) === true) {
$typeFile = $typages['typage_'.$key];
}
}
......
......@@ -66,8 +66,8 @@
<td class="col-md-4 tdleft">
<?php
if (!empty($typages)) {
echo $this->WebcilForm->input('Fichier.typage_' . $key, [
'id' => 'typage_' . $key,
echo $this->WebcilForm->input('Fichier.typage_tmp_' . $key, [
'id' => 'typage_tmp_' . $key,
'label' => [
'text' => ''
],
......@@ -121,7 +121,7 @@
<table class="table">
<tbody>
<?php
foreach ($filesSave as $val) {
foreach ($filesSave as $key => $val) {
?>
<tr id="rowFichier<?php echo $val['Fichier']['id']; ?>">
<td class="col-md-2">
......@@ -135,7 +135,17 @@
<td class="col-md-4 tdleft">
<?php
if (!empty($typages)) {
echo "Type d'annexe : " . $typages[$val['Fichier']['typage_id']];
// echo "Type d'annexe : " . $typages[$val['Fichier']['typage_id']];
echo $this->WebcilForm->input('Fichier.typage_' . $key, [
'id' => 'typage_' . $key,
'label' => [
'text' => ''
],
'options' => $typages,
'empty' => __d('fiche', 'fiche.emptySelectTypeFile'),
'required' => false,
'placeholder' => false
]);
}
?>
</td>
......
......@@ -312,6 +312,16 @@
]
]
],
__d('default', 'default.titreTypages') => [
'disabled' => !($this->Autorisation->authorized(['32'], $this->Session->read('Droit.liste'))),
__d('default', 'default.sousTitreTypagesAnnexes') => [
'class' => 'fa-list-alt',
'url' => [
'controller' => 'typages',
'action' => 'index'
]
]
],
__d('default', 'default.titreNormes') => [
'disabled' => !($this->Autorisation->authorized(['19', '21', '22'], $this->Session->read('Droit.liste'))),
__d('default', 'default.sousTitreLesNormes') => [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment