39 |
'notification_service_consulte', |
'notification_service_consulte', |
40 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
41 |
'notification_depot_demat', |
'notification_depot_demat', |
42 |
'notification_commune' |
'notification_commune', |
43 |
|
'lettre_incompletude', |
44 |
|
'lettre_majoration' |
45 |
); |
); |
46 |
|
|
47 |
/** |
/** |
389 |
case "incompletude_DI": |
case "incompletude_DI": |
390 |
$value_type = __('incomplétude DI'); |
$value_type = __('incomplétude DI'); |
391 |
break; |
break; |
392 |
|
case "lettre_incompletude": |
393 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
394 |
|
break; |
395 |
|
case "lettre_majoration": |
396 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
397 |
|
break; |
398 |
} |
} |
399 |
|
|
400 |
$contenu_type[1][] = $value_type; |
$contenu_type[1][] = $value_type; |
534 |
} else { |
} else { |
535 |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
536 |
} |
} |
537 |
|
// Gestion du contenu de l'historique |
538 |
|
if ($this->getVal('timestamp_log') !== '' |
539 |
|
&& $this->getVal('timestamp_log') !== null) { |
540 |
|
// |
541 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
542 |
|
} |
543 |
} |
} |
544 |
|
|
545 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
746 |
FROM %1$stask |
FROM %1$stask |
747 |
%2$s |
%2$s |
748 |
%3$s |
%3$s |
749 |
|
ORDER BY task ASC |
750 |
', |
', |
751 |
DB_PREFIXE, |
DB_PREFIXE, |
752 |
empty($search_values) === false ? ' WHERE ' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
1164 |
} |
} |
1165 |
} |
} |
1166 |
|
|
1167 |
// Mise à jour du DI |
// Valeurs de la tâche |
1168 |
$valF = array( |
$valF = array( |
1169 |
'task' => '', |
'task' => '', |
1170 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1182 |
'comment' => null, |
'comment' => null, |
1183 |
); |
); |
1184 |
|
|
1185 |
// tâche sortante |
// Gestion de la mise à jour des tâches sortantes |
1186 |
$typeNonConcerne = array( |
$typeNonConcerne = array( |
1187 |
'notification_recepisse', |
'notification_recepisse', |
1188 |
'notification_instruction', |
'notification_instruction', |
1192 |
); |
); |
1193 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1194 |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1195 |
// TODO expliquer ce code |
// Vérification de l'existance d'une tâche pour l'objet concerné |
1196 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
// La vérification diffère en fonction de certains types de tâche |
1197 |
|
$search_values_common = array( |
1198 |
|
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1199 |
|
sprintf('state != \'%s\'', self::STATUS_DONE), |
1200 |
|
); |
1201 |
|
$search_values_others = array( |
1202 |
|
sprintf('type = \'%s\'', $valF['type']), |
1203 |
|
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1204 |
|
); |
1205 |
|
$search_values_specifics = array( |
1206 |
|
sprintf('object_id = \'%s\'', $valF['object_id']), |
1207 |
|
); |
1208 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1209 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1210 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DI'"))); |
1211 |
} |
} |
1212 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
1213 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DA'"))); |
1214 |
} |
} |
1215 |
if ($valF['type'] === 'ajout_piece') { |
if ($valF['type'] === 'ajout_piece') { |
1216 |
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'ajout_piece'"))); |
1217 |
} |
} |
1218 |
if ($valF['type'] === 'creation_consultation') { |
if ($valF['type'] === 'creation_consultation') { |
1219 |
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_consultation'"))); |
1220 |
} |
} |
1221 |
|
// En cas de l'existance d'une tâches pour l'objet concerné, pas d'ajout de nouvelle |
1222 |
|
// tâche mais mise à jour de l'existante |
1223 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1224 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1225 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1226 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1227 |
)); |
"obj" => "task", |
1228 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1229 |
if (isset($params['update_val']['state']) === true) { |
)); |
1230 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1231 |
} |
if (isset($params['update_val']['state']) === true) { |
1232 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1233 |
'val' => array( |
} |
1234 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1235 |
), |
if ($valF['object_id'] !== '') { |
1236 |
'object_id' => $valF['object_id'], |
$object_id = $valF['object_id']; |
1237 |
); |
} |
1238 |
return $inst_task->update_task($update_params); |
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1239 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1240 |
|
&& $update_state === self::STATUS_PENDING |
1241 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1242 |
|
if ($task_pending === false) { |
1243 |
|
$update_params = array( |
1244 |
|
'val' => array( |
1245 |
|
'state' => $update_state, |
1246 |
|
), |
1247 |
|
'object_id' => $object_id, |
1248 |
|
); |
1249 |
|
return $inst_task->update_task($update_params); |
1250 |
|
} |
1251 |
|
} |
1252 |
} |
} |
1253 |
} |
} |
1254 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1285 |
'creation_time' => $this->getVal('creation_time'), |
'creation_time' => $this->getVal('creation_time'), |
1286 |
'last_modification_date' => date('Y-m-d'), |
'last_modification_date' => date('Y-m-d'), |
1287 |
'last_modification_time' => date('H:i:s'), |
'last_modification_time' => date('H:i:s'), |
1288 |
'comment' => $this->getVal('comment'), |
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1289 |
); |
); |
1290 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1291 |
if ($update === false) { |
if ($update === false) { |
1764 |
return $val_in; |
return $val_in; |
1765 |
} |
} |
1766 |
|
|
1767 |
|
/** |
1768 |
|
* Récupère les informations concernant la lettre au pétitionnaire. |
1769 |
|
* |
1770 |
|
* @param string identifiant du dossier |
1771 |
|
* @param string type de tâche |
1772 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
1773 |
|
* |
1774 |
|
* @return array information concernant la lettre au pétitionnaire |
1775 |
|
*/ |
1776 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
1777 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
1778 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
1779 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
1780 |
|
// Le type de document dépend du type de pièce |
1781 |
|
$nomTypeLettre = ''; |
1782 |
|
$nomTypeDocument = ''; |
1783 |
|
if ($type === 'lettre_incompletude') { |
1784 |
|
$nomTypeLettre = '3'; |
1785 |
|
$nomTypeDocument = '4'; |
1786 |
|
} elseif ($type === 'lettre_majoration') { |
1787 |
|
$nomTypeLettre = '4'; |
1788 |
|
$nomTypeDocument = '6'; |
1789 |
|
} |
1790 |
|
|
1791 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1792 |
|
"obj" => "dossier", |
1793 |
|
"idx" => $dossier, |
1794 |
|
)); |
1795 |
|
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
1796 |
|
$aujourdhui = new DateTime(); |
1797 |
|
if (! $date_limite_notification instanceof DateTime) { |
1798 |
|
$nomTypeLettre = ''; |
1799 |
|
$nomTypeDocument = ''; |
1800 |
|
} elseif ($aujourdhui < $date_limite_notification) { |
1801 |
|
$nomTypeLettre = '1'; |
1802 |
|
$nomTypeDocument = '3'; |
1803 |
|
} |
1804 |
|
|
1805 |
|
return array( |
1806 |
|
'nomEtatLettre' => '3', |
1807 |
|
'nomModaliteNotifMetier' => '4', |
1808 |
|
'nomTypeLettre' => $nomTypeLettre, |
1809 |
|
'nomTypeDocument' => $nomTypeDocument |
1810 |
|
); |
1811 |
|
} |
1812 |
|
|
1813 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1814 |
$fields = array( |
$fields = array( |
1815 |
"date_evenement", |
"date_evenement", |
1920 |
)); |
)); |
1921 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1922 |
$val_ad = array(); |
$val_ad = array(); |
1923 |
if ($ad !== null) { |
if ($ad !== null && trim($ad) !== '') { |
1924 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1925 |
"obj" => "avis_decision", |
"obj" => "avis_decision", |
1926 |
"idx" => $ad, |
"idx" => $ad, |
1991 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
1992 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
1993 |
} |
} |
1994 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
1995 |
unset($val_task['timestamp_log_hidden']); |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
1996 |
$val['task'] = $val_task; |
// de référence de la tâche existe. |
1997 |
// |
$objectRefExist = true; |
1998 |
if ($this->getVal('type') === 'creation_DA' |
if ($val_task['stream'] === 'output' |
1999 |
|| $this->getVal('type') === 'modification_DA') { |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2000 |
// |
$objectRefExist = $this->does_referenced_object_exist( |
2001 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val_task['object_id'], |
2002 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val_task['type'] |
2003 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
); |
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DI' |
|
|
|| $this->getVal('type') === 'modification_DI' |
|
|
|| $this->getVal('type') === 'depot_DI') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
|
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
|
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
|
|
$val['architecte'] = $this->get_architecte_data($architecte); |
|
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'qualification_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'ajout_piece') { |
|
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
|
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'decision_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['instruction']['final'] = 't'; |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'incompletude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'completude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'avis_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// XXX WIP |
|
|
if ($this->getVal('type') === 'creation_consultation') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
|
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2004 |
} |
} |
2005 |
// |
|
2006 |
if ($this->getVal('type') === 'envoi_CL') { |
// Si l'objet de référence n'existe pas log le numéro de la tâche concerné et |
2007 |
|
// renvoie une payload contenant le message d'erreur. |
2008 |
|
// Sinon constitue la payload du json. |
2009 |
|
if (! $objectRefExist) { |
2010 |
|
$this->f->addToLog( |
2011 |
|
sprintf( |
2012 |
|
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2013 |
|
$val_task['task'] |
2014 |
|
), |
2015 |
|
DEBUG_MODE |
2016 |
|
); |
2017 |
|
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2018 |
|
} else { |
2019 |
|
|
2020 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2021 |
|
unset($val_task['timestamp_log_hidden']); |
2022 |
|
$val['task'] = $val_task; |
2023 |
// |
// |
2024 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
if ($this->getVal('type') === 'creation_DA' |
2025 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|| $this->getVal('type') === 'modification_DA') { |
2026 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
// |
2027 |
$val_external_uid = array(); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2028 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
2029 |
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
2030 |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
$val_external_uid = array(); |
2031 |
if ($val_external_uid['decision'] === '') { |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
2032 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$val['external_uids'] = $val_external_uid; |
|
"obj" => "instruction", |
|
|
"idx" => $this->getVal('object_id'), |
|
|
)); |
|
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
|
2033 |
} |
} |
2034 |
$val['external_uids'] = $val_external_uid; |
// |
2035 |
} |
if ($this->getVal('type') === 'creation_DI' |
2036 |
if ($this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'modification_DI' |
2037 |
|| $this->getVal('type') === 'notification_recepisse' |
|| $this->getVal('type') === 'depot_DI') { |
2038 |
|| $this->getVal('type') === 'notification_decision' |
// |
2039 |
|| $this->getVal('type') === 'notification_service_consulte' |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2040 |
|| $this->getVal('type') === 'notification_tiers_consulte') { |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2041 |
// |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2042 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2043 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
$val['architecte'] = $this->get_architecte_data($architecte); |
2044 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2045 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
$val_external_uid = array(); |
2046 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2047 |
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2048 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
$val['external_uids'] = $val_external_uid; |
2049 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
} |
2050 |
// demande dont le type ne génère pas de dossier |
// |
2051 |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
if ($this->getVal('type') === 'qualification_DI') { |
2052 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2053 |
|
$val_external_uid = array(); |
2054 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2055 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2056 |
|
$val['external_uids'] = $val_external_uid; |
2057 |
|
} |
2058 |
|
// |
2059 |
|
if ($this->getVal('type') === 'ajout_piece') { |
2060 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2061 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2062 |
|
$val_external_uid = array(); |
2063 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2064 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2065 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2066 |
|
$val['external_uids'] = $val_external_uid; |
2067 |
|
} |
2068 |
|
// |
2069 |
|
if ($this->getVal('type') === 'decision_DI') { |
2070 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2071 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2072 |
$val['instruction']['final'] = 't'; |
$val['instruction']['final'] = 't'; |
2073 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2074 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2075 |
|
} |
2076 |
|
$val_external_uid = array(); |
2077 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2078 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2079 |
|
$val['external_uids'] = $val_external_uid; |
2080 |
|
} |
2081 |
|
// |
2082 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
2083 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2084 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2085 |
|
$val_external_uid = array(); |
2086 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2087 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2088 |
|
$val['external_uids'] = $val_external_uid; |
2089 |
|
} |
2090 |
|
// |
2091 |
|
if ($this->getVal('type') === 'completude_DI') { |
2092 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2093 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2094 |
|
$val_external_uid = array(); |
2095 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2096 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2097 |
|
$val['external_uids'] = $val_external_uid; |
2098 |
|
} |
2099 |
|
// |
2100 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2101 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2102 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2103 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2104 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2105 |
|
$val_external_uid = array(); |
2106 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2107 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2108 |
|
$val['external_uids'] = $val_external_uid; |
2109 |
|
} |
2110 |
|
// |
2111 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2112 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2113 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2114 |
|
$val_external_uid = array(); |
2115 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2116 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2117 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2118 |
|
$val['external_uids'] = $val_external_uid; |
2119 |
|
} |
2120 |
|
// |
2121 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2122 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2123 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2124 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2125 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2126 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2127 |
|
} |
2128 |
|
$val_external_uid = array(); |
2129 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2130 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2131 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2132 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
2133 |
|
$val['external_uids'] = $val_external_uid; |
2134 |
|
} |
2135 |
|
// XXX WIP |
2136 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2137 |
|
// |
2138 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2139 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2140 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2141 |
|
$val_external_uid = array(); |
2142 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2143 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2144 |
|
$val['external_uids'] = $val_external_uid; |
2145 |
|
} |
2146 |
|
// |
2147 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2148 |
|
// |
2149 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2150 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2151 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2152 |
|
$val_external_uid = array(); |
2153 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2154 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
2155 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2156 |
|
if ($val_external_uid['decision'] === '') { |
2157 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2158 |
|
"obj" => "instruction", |
2159 |
|
"idx" => $this->getVal('object_id'), |
2160 |
|
)); |
2161 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2162 |
|
} |
2163 |
|
$val['external_uids'] = $val_external_uid; |
2164 |
|
} |
2165 |
|
if ($this->getVal('type') === 'notification_instruction' |
2166 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2167 |
|
|| $this->getVal('type') === 'notification_decision' |
2168 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2169 |
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
2170 |
|
// |
2171 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2172 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2173 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2174 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2175 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2176 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
2177 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2178 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2179 |
|
// demande dont le type ne génère pas de dossier |
2180 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2181 |
|
$val['instruction']['final'] = 't'; |
2182 |
|
} |
2183 |
|
$val_external_uid = array(); |
2184 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2185 |
|
$val_external_uid['demande'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
2186 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2187 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2188 |
|
$val['external_uids'] = $val_external_uid; |
2189 |
|
} |
2190 |
|
// |
2191 |
|
if ($this->getVal('type') === 'prescription') { |
2192 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2193 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2194 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2195 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2196 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2197 |
|
} |
2198 |
|
$val_external_uid = array(); |
2199 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2200 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2201 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2202 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2203 |
|
$val['external_uids'] = $val_external_uid; |
2204 |
} |
} |
|
$val_external_uid = array(); |
|
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
|
|
$val_external_uid['demande'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
|
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
|
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'prescription') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2205 |
} |
} |
2206 |
|
|
2207 |
if ($in_field === true) { |
if ($in_field === true) { |
2223 |
'state' => $this->f->get_submitted_post_value('state') |
'state' => $this->f->get_submitted_post_value('state') |
2224 |
), |
), |
2225 |
); |
); |
2226 |
|
if ($this->f->get_submitted_post_value('comment') !== null) { |
2227 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2228 |
|
} |
2229 |
$update = $this->update_task($params); |
$update = $this->update_task($params); |
2230 |
$message_class = "valid"; |
$message_class = "valid"; |
2231 |
$message = $this->msg; |
$message = $this->msg; |
2299 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2300 |
'val' => array( |
'val' => array( |
2301 |
'stream' => 'input', |
'stream' => 'input', |
2302 |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401), |
2303 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2304 |
'category' => $this->f->get_submitted_post_value('category'), |
'category' => $this->f->get_submitted_post_value('category'), |
2305 |
) |
) |
2358 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2359 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2360 |
} |
} |
2361 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2362 |
|
'decision_DI', |
2363 |
|
'incompletude_DI', |
2364 |
|
'completude_DI', |
2365 |
|
'lettre_incompletude', |
2366 |
|
'lettre_majoration' |
2367 |
|
)) === true) { |
2368 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2369 |
} |
} |
2370 |
if (in_array($type, array('envoi_CL', )) === true) { |
if (in_array($type, array('envoi_CL', )) === true) { |
2441 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2442 |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2443 |
} |
} |
2444 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2445 |
|
'decision_DI', |
2446 |
|
'incompletude_DI', |
2447 |
|
'completude_DI', |
2448 |
|
'lettre_incompletude', |
2449 |
|
'lettre_majoration' |
2450 |
|
)) === true) { |
2451 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2452 |
} |
} |
2453 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2495 |
return $tables; |
return $tables; |
2496 |
} |
} |
2497 |
|
|
2498 |
|
/** |
2499 |
|
* Vérifie si l'objet référencé par la tâche existe en base de données. |
2500 |
|
* |
2501 |
|
* Récupère la liste des tables de référence associé à la tâche à partir |
2502 |
|
* du type de tâche et de son flux (input ou output). |
2503 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
2504 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
2505 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
2506 |
|
* |
2507 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
2508 |
|
* @param string $taskType : type de la tâche |
2509 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
2510 |
|
* @return boolean |
2511 |
|
*/ |
2512 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
2513 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
2514 |
|
foreach ($refTables as $table) { |
2515 |
|
$inst = $this->f->get_inst__om_dbform(array( |
2516 |
|
'obj' => $table, |
2517 |
|
'idx' => $taskObjectId |
2518 |
|
)); |
2519 |
|
if ($inst->exists() === true) { |
2520 |
|
return true; |
2521 |
|
} |
2522 |
|
} |
2523 |
|
return false; |
2524 |
|
} |
2525 |
|
|
2526 |
} |
} |