Commit ce0c5142 authored by Théo GUILLON's avatar Théo GUILLON

Correction : enregistrement service déclarant lorsque le traitement a été recu...

Correction : enregistrement service déclarant lorsque le traitement a été recu en mode initialisation
Correction : génération champ service
parent 57cc1a54
......@@ -765,6 +765,9 @@ class FichesController extends AppController
$this->redirect($this->Referers->get());
}
// debug($this->request->data);
// die;
$success = true;
$this->Fiche->begin();
......@@ -853,13 +856,19 @@ class FichesController extends AppController
$initialisationMode = true;
}
$initialisationRecu = false;
if ($etatFiche['EtatFiche']['etat_id'] === EtatFiche::TRAITEMENT_INITIALISE_RECU) {
$initialisationRecu = true;
}
$success = $this->WebdpoFiche->saveWithVirtualFields(
$data,
$formulaireFields,
$formulaireOptions,
$formulaireOLD['Formulaire']['oldformulaire'],
false,
$initialisationMode
$initialisationMode,
$initialisationRecu
);
if ($success == true) {
......@@ -1058,22 +1067,17 @@ class FichesController extends AppController
$typages = $this->_typages();
$etatFiche = $this->EtatFiche->find('first', [
'conditions' => [
'fiche_id' => $id,
'actif' => true
],
'fields' => [
'etat_id'
]
]);
$initialisationMode = false;
if ($etatFiche['EtatFiche']['etat_id'] === EtatFiche::INITIALISATION_TRAITEMENT) {
if ($etatTraitement['EtatFiche']['etat_id'] === EtatFiche::INITIALISATION_TRAITEMENT) {
$initialisationMode = true;
}
$this->set(compact('formulaireOLD', 'typages', 'initialisationMode'));
$initialisationRecu = false;
if ($etatTraitement['EtatFiche']['etat_id'] === EtatFiche::TRAITEMENT_INITIALISE_RECU) {
$initialisationRecu = true;
}
$this->set(compact('formulaireOLD', 'typages', 'initialisationMode', 'initialisationRecu'));
$this->set('formulaire_id', $fiche['Fiche']['form_id']);
$this->view = 'add';
......
......@@ -395,7 +395,7 @@ class WebdpoFiche extends AppModel {
// ---------------------------------------------------------------------
];
public function saveWithVirtualFields($data, $champs, $formulaireOptions, $formulaireOLD, $actionAdd, $initialisationMode = false)
public function saveWithVirtualFields($data, $champs, $formulaireOptions, $formulaireOLD, $actionAdd, $initialisationMode = false, $initialisationRecu = false)
{
$success = true;
$Fiche = ClassRegistry::init('Fiche');
......@@ -493,11 +493,16 @@ class WebdpoFiche extends AppModel {
if ($actionAdd === false) {
$fieldsToKeep = array_merge ($fieldsToKeep, [
'declarantpersonnenom',
'declarantservice',
'declarantpersonneportable',
'declarantpersonneemail',
'declarantpersonnefix'
]);
if ($initialisationRecu === false) {
$fieldsToKeep = array_merge ($fieldsToKeep, [
'declarantservice',
]);
}
}
$data = $this->cleanupData($data, $champs, $formulaireOLD, $fieldsToKeep);
......
<?php
$initialisationRecu = isset($initialisationRecu) ? $initialisationRecu : false;
$empty = true;
$keySubmit = 'WebdpoFiche.';
$keySubmitService = 'WebdpoFiche.';
if (in_array($this->request->params['action'], ['edit', 'show']) === true) {
$empty = false;
$keySubmit = 'Trash.';
if ($initialisationRecu === true) {
$keySubmitService = 'WebdpoFiche.';
} else {
$keySubmitService = 'Trash.';
}
}
if (!isset($fieldsIsRequired)){
......@@ -38,46 +46,49 @@ if (!isset($fieldsIsRequired)){
'required' => true
]);
$countService = count($this->Session->read('User.service'));
// Champ Service *
if ($countService >= 2 && $fieldsIsRequired === true) {
foreach ($this->Session->read('User.service') as $service) {
$listeUserService[$service] = $service;
}
echo $this->WebcilForm->input($keySubmit.'declarantservice', [
'id' => 'declarantservice',
'label' => [
'text' => __d('fiche', 'fiche.champDeclarantservice')
],
'options' => $listeUserService,
'empty' => __d('fiche', 'fiche.emptySelectionnerServiceDeclarant'),
'required' => true,
'placeholder' => false
]);
} else if ($countService == 0 || $fieldsIsRequired === false) {
echo $this->WebcilForm->input($keySubmit.'declarantservice', [
'id' => 'declarantservice',
'label' => [
'text' => __d('fiche', 'fiche.champDeclarantservice')
],
'readonly' => true,
'required' => true,
'value' => 'Aucun service'
]);
$serviceFieldOptions = [
'id' => 'declarantservice',
'label' => [
'text' => __d('fiche', 'fiche.champDeclarantservice')
],
'required' => true,
];
if (in_array($this->request->params['action'], ['edit', 'show']) !== true ||
$initialisationRecu === true
) {
$countService = count($this->Session->read('User.service'));
if ($countService >= 2 && $fieldsIsRequired === true) {
foreach ($this->Session->read('User.service') as $service) {
$listeUserService[$service] = $service;
}
$serviceFieldOptions += [
'options' => $listeUserService,
'empty' => __d('fiche', 'fiche.emptySelectionnerServiceDeclarant'),
'placeholder' => false
];
} else
if ($countService == 0 || $fieldsIsRequired === false) {
$serviceFieldOptions += [
'readonly' => true,
'value' => 'Aucun service'
];
} else {
$serviceFieldOptions += [
'readonly' => true,
'value' => $this->Session->read('User.service')
];
}
} else {
echo $this->WebcilForm->input($keySubmit.'declarantservice', [
'id' => 'declarantservice',
'label' => [
'text' => __d('fiche', 'fiche.champDeclarantservice')
],
'readonly' => true,
'required' => true,
'value' => $this->Session->read('User.service')
]);
$serviceFieldOptions += [
'readonly' => true
];
}
echo $this->WebcilForm->input($keySubmitService.'declarantservice', $serviceFieldOptions);
echo $this->WebcilForm->input($keySubmit.'declarantpersonneportable', [
'id' => 'declarantpersonneportable',
'label' => [
......
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