15 |
const STATUS_ARCHIVED = 'archived'; |
const STATUS_ARCHIVED = 'archived'; |
16 |
|
|
17 |
/** |
/** |
18 |
|
* Liste des types de tâche concernant les services instructeurs |
19 |
|
*/ |
20 |
|
const TASK_TYPE_SI = array( |
21 |
|
'creation_DA', |
22 |
|
'creation_DI', |
23 |
|
'depot_DI', |
24 |
|
'modification_DI', |
25 |
|
'qualification_DI', |
26 |
|
'decision_DI', |
27 |
|
'incompletude_DI', |
28 |
|
'completude_DI', |
29 |
|
'ajout_piece', |
30 |
|
'add_piece', |
31 |
|
'creation_consultation', |
32 |
|
'modification_DA', |
33 |
|
'create_DI', |
34 |
|
); |
35 |
|
|
36 |
|
/** |
37 |
|
* Liste des types de tâche concernant les services consultés |
38 |
|
*/ |
39 |
|
const TASK_TYPE_SC = array( |
40 |
|
'create_DI_for_consultation', |
41 |
|
'avis_consultation', |
42 |
|
'pec_metier_consultation', |
43 |
|
); |
44 |
|
|
45 |
|
/** |
46 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
47 |
* |
* |
48 |
* @return void |
* @return void |
208 |
"idx" => $form->val['dossier'], |
"idx" => $form->val['dossier'], |
209 |
)); |
)); |
210 |
|
|
211 |
if($form->val['type'] == "creation_DA"){ |
if($form->val['type'] == "creation_DA" |
212 |
|
|| $form->val['type'] == "modification_DA"){ |
213 |
|
// |
214 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
215 |
} else { |
} else { |
216 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
332 |
} |
} |
333 |
|
|
334 |
// présence d'un moyen d'identifier la collectivité/le service |
// présence d'un moyen d'identifier la collectivité/le service |
335 |
if (! isset($json_payload['dossier']['acteur']) && |
if (! isset($json_payload['external_uids']['acteur']) && |
336 |
! isset($json_payload['dossier']['om_collectivite'])) { |
! isset($json_payload['dossier']['om_collectivite'])) { |
337 |
$this->correct = false; |
$this->correct = false; |
338 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
339 |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
340 |
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
341 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
342 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
343 |
)); |
)); |
380 |
return $ret && $this->correct; |
return $ret && $this->correct; |
381 |
} |
} |
382 |
|
|
383 |
protected function task_exists(string $type, string $object_id) { |
/** |
384 |
|
* [task_exists description] |
385 |
|
* @param string $type [description] |
386 |
|
* @param string $object_id [description] |
387 |
|
* @return [type] [description] |
388 |
|
*/ |
389 |
|
public function task_exists(string $type, string $object_id) { |
390 |
$query = sprintf(' |
$query = sprintf(' |
391 |
SELECT task |
SELECT task |
392 |
FROM %1$stask |
FROM %1$stask |
430 |
! empty($json_payload['dossier']['dossier'])) { |
! empty($json_payload['dossier']['dossier'])) { |
431 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
432 |
} |
} |
|
|
|
|
/** |
|
|
* Puisque le dossier n'a potentiellement pas encore été créé |
|
|
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
|
|
* à partir de l'external_uids (en passant par la table de liens) |
|
|
// sinon si la tâche possède une clé external_uids/dossier |
|
|
elseif(isset($json_payload['external_uids']['dossier']) && |
|
|
! empty($json_payload['external_uids']['dossier'])) { |
|
|
|
|
|
// instancie l'objet lien_id_interne_uid_externe |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"idx" => ']', |
|
|
)); |
|
|
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
|
|
$json_payload['external_uids']['dossier'])){ |
|
|
$error_msg = sprintf( |
|
|
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
|
|
$json_payload['external_uids']['dossier']); |
|
|
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
|
|
$this->addToMessage($error_msg); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
|
$this->valF["dossier"] = $dossier; |
|
|
}*/ |
|
433 |
} |
} |
434 |
} |
} |
435 |
|
|
445 |
|
|
446 |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
447 |
// seulement pour les tasks output |
// seulement pour les tasks output |
448 |
$task_types_si = array( |
$task_types_si = self::TASK_TYPE_SI; |
449 |
'creation_DA', |
$task_types_sc = self::TASK_TYPE_SC; |
|
'creation_DI', |
|
|
'depot_DI', |
|
|
'modification_DI', |
|
|
'qualification_DI', |
|
|
'decision_DI', |
|
|
'incompletude_DI', |
|
|
'completude_DI', |
|
|
'ajout_piece', |
|
|
'add_piece', |
|
|
); |
|
|
$task_types_sc = array( |
|
|
'create_DI_for_consultation', |
|
|
'avis_consultation', |
|
|
'pec_metier_consultation', |
|
|
); |
|
450 |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
451 |
if ($stream === 'output' |
if ($stream === 'output' |
452 |
&& isset($params['val']['type']) === true |
&& isset($params['val']['type']) === true |
470 |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
471 |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
472 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
473 |
&& $params['val']['type'] == "add_piece" |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
474 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
475 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
476 |
// |
// |
477 |
$json_payload = json_decode($params['val']['json_payload'], true); |
$json_payload = json_decode($params['val']['json_payload'], true); |
478 |
$document_numerise = $json_payload['document_numerise']; |
if (json_last_error() !== JSON_ERROR_NONE) { |
479 |
$file_content = base64_decode($document_numerise["file_content"]); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
|
if ($file_content === false){ |
|
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
|
480 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
481 |
} |
} |
482 |
$metadata = array( |
if (isset($json_payload['document_numerise']) === true |
483 |
"filename" => $document_numerise['nom_fichier'], |
&& empty($json_payload['document_numerise']) === false) { |
484 |
"size" => strlen($file_content), |
// |
485 |
"mimetype" => $document_numerise['file_content_type'], |
$document_numerise = $json_payload['document_numerise']; |
486 |
"date_creation" => $document_numerise['date_creation'], |
$file_content = base64_decode($document_numerise["file_content"]); |
487 |
); |
if ($file_content === false){ |
488 |
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
489 |
if ($uid_fichier === OP_FAILURE) { |
return $this->end_treatment(__METHOD__, false); |
490 |
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
} |
491 |
return $this->end_treatment(__METHOD__, false); |
$metadata = array( |
492 |
|
"filename" => $document_numerise['nom_fichier'], |
493 |
|
"size" => strlen($file_content), |
494 |
|
"mimetype" => $document_numerise['file_content_type'], |
495 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
496 |
|
); |
497 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
498 |
|
if ($uid_fichier === OP_FAILURE) { |
499 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
500 |
|
return $this->end_treatment(__METHOD__, false); |
501 |
|
} |
502 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
503 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
504 |
|
unset($json_payload["document_numerise"]["file_content"]); |
505 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
506 |
} |
} |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
|
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
|
|
unset($json_payload["document_numerise"]["file_content"]); |
|
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
507 |
} |
} |
508 |
|
|
509 |
// Mise à jour du DI |
// Mise à jour du DI |
526 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
527 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
528 |
} |
} |
529 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
530 |
|
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
531 |
|
} |
532 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
533 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
534 |
"obj" => "task", |
"obj" => "task", |
656 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
657 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
658 |
$task['dossier'] = $task['dossier']; |
$task['dossier'] = $task['dossier']; |
659 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
660 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
661 |
} |
} |
662 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
803 |
return $val_dt; |
return $val_dt; |
804 |
} |
} |
805 |
|
|
806 |
|
/** |
807 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
808 |
|
* entre identifiants internes et identifiants externes. |
809 |
|
* |
810 |
|
* @return array |
811 |
|
*/ |
812 |
|
protected function get_list_distinct_objects_external_link() { |
813 |
|
$query = sprintf(' |
814 |
|
SELECT |
815 |
|
DISTINCT(object) |
816 |
|
FROM %1$slien_id_interne_uid_externe |
817 |
|
ORDER BY object ASC |
818 |
|
', |
819 |
|
DB_PREFIXE |
820 |
|
); |
821 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
822 |
|
if ($res['code'] === 'KO') { |
823 |
|
return array(); |
824 |
|
} |
825 |
|
$result = array(); |
826 |
|
foreach ($res['result'] as $object) { |
827 |
|
$result[] = $object['object']; |
828 |
|
} |
829 |
|
return $result; |
830 |
|
} |
831 |
|
|
832 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
833 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
834 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
840 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
841 |
} |
} |
842 |
|
|
843 |
protected function get_all_external_uids($fk_idx) { |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
844 |
$link_objects = array( |
if (count($link_objects) == 0) { |
845 |
'dossier_autorisation', |
$link_objects = $this->get_list_distinct_objects_external_link(); |
846 |
'dossier', |
} |
|
'consultation', |
|
|
'document_numerise', |
|
|
); |
|
847 |
$val_external_uid = array(); |
$val_external_uid = array(); |
848 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
849 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
1017 |
)); |
)); |
1018 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1019 |
$val_ad = array(); |
$val_ad = array(); |
1020 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
if ($ad !== null) { |
1021 |
"obj" => "avis_decision", |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1022 |
"idx" => $ad, |
"obj" => "avis_decision", |
1023 |
)); |
"idx" => $ad, |
1024 |
$val_ad = $inst_ad->get_json_data(); |
)); |
1025 |
$val_ad['txAvis'] = "Voir document joint"; |
$val_ad = $inst_ad->get_json_data(); |
1026 |
if (isset($val_ad['tacite']) === true |
$val_ad['txAvis'] = "Voir document joint"; |
1027 |
&& $val_ad['tacite'] === 't') { |
if (isset($val_ad['tacite']) === true |
1028 |
// |
&& $val_ad['tacite'] === 't') { |
1029 |
$val_ad['txAvis'] = "Sans objet"; |
// |
1030 |
|
$val_ad['txAvis'] = "Sans objet"; |
1031 |
|
} |
1032 |
} |
} |
1033 |
return $val_ad; |
return $val_ad; |
1034 |
} |
} |
1045 |
return $val_sa; |
return $val_sa; |
1046 |
} |
} |
1047 |
|
|
1048 |
|
// XXX WIP |
1049 |
|
protected function get_consultation_data(string $consultation) { |
1050 |
|
$val_consultation = array(); |
1051 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1052 |
|
"obj" => "consultation", |
1053 |
|
"idx" => $consultation, |
1054 |
|
)); |
1055 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1056 |
|
if (isset($val_consultation['fichier']) === true |
1057 |
|
&& $val_consultation['fichier'] !== '') { |
1058 |
|
// |
1059 |
|
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
1060 |
|
} |
1061 |
|
if (isset($val_consultation['om_fichier_consultation']) === true |
1062 |
|
&& $val_consultation['om_fichier_consultation'] !== '') { |
1063 |
|
// |
1064 |
|
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
1065 |
|
} |
1066 |
|
return $val_consultation; |
1067 |
|
} |
1068 |
|
|
1069 |
|
// XXX WIP |
1070 |
|
protected function get_service_data(string $service) { |
1071 |
|
$val_service = array(); |
1072 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1073 |
|
"obj" => "service", |
1074 |
|
"idx" => $service, |
1075 |
|
)); |
1076 |
|
$val_service = $inst_service->get_json_data(); |
1077 |
|
return $val_service; |
1078 |
|
} |
1079 |
|
|
1080 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1081 |
// |
// |
1082 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1083 |
|
&& $this->getVal('state') !== self::STATUS_DRAFT) { |
1084 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1085 |
$val = array(); |
$val = array(); |
1086 |
// |
// |
1091 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1092 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1093 |
// |
// |
1094 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1095 |
|
|| $this->getVal('type') === 'modification_DA') { |
1096 |
|
// |
1097 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1098 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
1099 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
1119 |
} |
} |
1120 |
// |
// |
1121 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1122 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1123 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1124 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1125 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1169 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1170 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1171 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1172 |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1173 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1174 |
} |
} |
1175 |
// |
// |
1183 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1184 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1185 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1186 |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1187 |
|
$val['external_uids'] = $val_external_uid; |
1188 |
|
} |
1189 |
|
// XXX WIP |
1190 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1191 |
|
// |
1192 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1193 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1194 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1195 |
|
$val_external_uid = array(); |
1196 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1197 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1198 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1199 |
} |
} |
1200 |
|
|
1209 |
|
|
1210 |
function post_update_task() { |
function post_update_task() { |
1211 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1212 |
// |
|
1213 |
$params = array( |
// Modification de l'état de la tâche |
1214 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
1215 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
1216 |
), |
'val' => array( |
1217 |
); |
'state' => $this->f->get_submitted_post_value('state') |
1218 |
$update = $this->update_task($params); |
), |
|
$message_class = "valid"; |
|
|
$message = $this->msg; |
|
|
if ($update === false) { |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
// |
|
|
if ($this->f->get_submitted_post_value('external_uid') !== null |
|
|
&& $this->f->get_submitted_post_value('external_uid') != "") { |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"idx" => ']', |
|
|
)); |
|
|
$valF = array( |
|
|
'lien_id_interne_uid_externe' => '', |
|
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
|
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
1219 |
); |
); |
1220 |
$add = $inst_lien->ajouter($valF); |
$update = $this->update_task($params); |
1221 |
$message_class = "valid"; |
$message_class = "valid"; |
1222 |
$message = $inst_lien->msg; |
$message = $this->msg; |
1223 |
if ($add === false) { |
if ($update === false) { |
1224 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1225 |
$message_class = "error"; |
$message_class = "error"; |
1226 |
$message = sprintf( |
$message = sprintf( |
1227 |
'%s %s', |
'%s %s', |
1228 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
__('Impossible de mettre à jour la tâche.'), |
1229 |
__('Veuillez contacter votre administrateur.') |
__('Veuillez contacter votre administrateur.') |
1230 |
); |
); |
1231 |
} |
} |
1232 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1233 |
} |
} |
1234 |
|
|
1235 |
|
// Sauvegarde de l'uid externe retourné |
1236 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1237 |
|
// |
1238 |
|
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1239 |
|
foreach ($objects as $object) { |
1240 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1241 |
|
"obj" => "lien_id_interne_uid_externe", |
1242 |
|
"idx" => ']', |
1243 |
|
)); |
1244 |
|
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1245 |
|
$valF = array( |
1246 |
|
'lien_id_interne_uid_externe' => '', |
1247 |
|
'object' => $object, |
1248 |
|
'object_id' => $this->getVal('object_id'), |
1249 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1250 |
|
'dossier' => $this->getVal('dossier'), |
1251 |
|
); |
1252 |
|
$add = $inst_lien->ajouter($valF); |
1253 |
|
$message_class = "valid"; |
1254 |
|
$message = $inst_lien->msg; |
1255 |
|
if ($add === false) { |
1256 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1257 |
|
$message_class = "error"; |
1258 |
|
$message = sprintf( |
1259 |
|
'%s %s', |
1260 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1261 |
|
__('Veuillez contacter votre administrateur.') |
1262 |
|
); |
1263 |
|
} |
1264 |
|
$this->f->displayMessage($message_class, $message); |
1265 |
|
} |
1266 |
|
} |
1267 |
|
} |
1268 |
} |
} |
1269 |
|
|
1270 |
function post_add_task() { |
function post_add_task() { |
1276 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
1277 |
) |
) |
1278 |
)); |
)); |
1279 |
$message = $this->msg; |
$message = sprintf( |
1280 |
|
__("Tâche %s ajoutée avec succès"), |
1281 |
|
$this->getVal($this->clePrimaire)). |
1282 |
|
'<br/><br/>'. |
1283 |
|
$this->msg; |
1284 |
$message_class = "valid"; |
$message_class = "valid"; |
1285 |
if ($result === false){ |
if ($result === false){ |
1286 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1294 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1295 |
} |
} |
1296 |
|
|
|
function get_lien_objet_by_type($type) { |
|
|
// |
|
|
$objet = ''; |
|
|
if ($type === 'creation_DA') { |
|
|
$objet = 'dossier_autorisation'; |
|
|
} |
|
|
if ($type === 'creation_DI' |
|
|
|| $type === 'create_DI_for_consultation' |
|
|
|| $type === 'depot_DI' |
|
|
|| $type === 'modification_DI' |
|
|
|| $type === 'qualification_DI') { |
|
|
// |
|
|
$objet = 'dossier'; |
|
|
} |
|
|
if ($type === 'pec_metier_consultation' |
|
|
|| $type === 'decision_DI' |
|
|
|| $type === 'avis_consultation' |
|
|
|| $type === 'incompletude_DI' |
|
|
|| $type === 'completude_DI') { |
|
|
// |
|
|
$objet = 'instruction'; |
|
|
} |
|
|
if ($type === 'ajout_piece') { |
|
|
$objet = 'document_numerise'; |
|
|
} |
|
|
// La tâche entrante se nomme add_piece |
|
|
if ($type === 'add_piece') { |
|
|
$objet = 'piece'; |
|
|
} |
|
|
return $objet; |
|
|
} |
|
|
|
|
1297 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1298 |
|
|
1299 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1308 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1309 |
} |
} |
1310 |
|
|
1311 |
|
/** |
1312 |
|
* [get_objects_by_task_type description] |
1313 |
|
* @param [type] $type [description] |
1314 |
|
* @return [type] [description] |
1315 |
|
*/ |
1316 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1317 |
|
$objects = array(); |
1318 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1319 |
|
$objects = array('dossier_autorisation', ); |
1320 |
|
} |
1321 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1322 |
|
$objects = array('dossier', ); |
1323 |
|
} |
1324 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1325 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1326 |
|
} |
1327 |
|
if (in_array($type, array('create_DI', )) === true |
1328 |
|
&& $stream === 'input') { |
1329 |
|
$objects = array('dossier', 'dossier_autorisation', ); |
1330 |
|
} |
1331 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1332 |
|
$objects = array('instruction', ); |
1333 |
|
} |
1334 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1335 |
|
&& $stream === 'output') { |
1336 |
|
$objects = array('pec_dossier_consultation', ); |
1337 |
|
} |
1338 |
|
if (in_array($type, array('avis_consultation', )) === true |
1339 |
|
&& $stream === 'output') { |
1340 |
|
$objects = array('avis_dossier_consultation', ); |
1341 |
|
} |
1342 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1343 |
|
$objects = array('piece', ); |
1344 |
|
} |
1345 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1346 |
|
$objects = array('consultation', ); |
1347 |
|
} |
1348 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1349 |
|
&& $stream === 'input') { |
1350 |
|
$objects = array('pec_metier_consultation', ); |
1351 |
|
} |
1352 |
|
if (in_array($type, array('avis_consultation', )) === true |
1353 |
|
&& $stream === 'input') { |
1354 |
|
$objects = array('avis_consultation', ); |
1355 |
|
} |
1356 |
|
return $objects; |
1357 |
|
} |
1358 |
|
|
1359 |
} |
} |