302 |
} |
} |
303 |
|
|
304 |
// présence d'un moyen d'identifier la collectivité/le service |
// présence d'un moyen d'identifier la collectivité/le service |
305 |
if (! isset($json_payload['dossier']['acteur']) && |
if (! isset($json_payload['external_uids']['acteur']) && |
306 |
! isset($json_payload['dossier']['om_collectivite'])) { |
! isset($json_payload['dossier']['om_collectivite'])) { |
307 |
$this->correct = false; |
$this->correct = false; |
308 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
309 |
__("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."), |
310 |
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
311 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
312 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
313 |
)); |
)); |
394 |
! empty($json_payload['dossier']['dossier'])) { |
! empty($json_payload['dossier']['dossier'])) { |
395 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
396 |
} |
} |
|
|
|
|
/** |
|
|
* 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; |
|
|
}*/ |
|
397 |
} |
} |
398 |
} |
} |
399 |
|
|
454 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
455 |
// |
// |
456 |
$json_payload = json_decode($params['val']['json_payload'], true); |
$json_payload = json_decode($params['val']['json_payload'], true); |
457 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
458 |
|
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
459 |
|
return $this->end_treatment(__METHOD__, false); |
460 |
|
} |
461 |
$document_numerise = $json_payload['document_numerise']; |
$document_numerise = $json_payload['document_numerise']; |
462 |
$file_content = base64_decode($document_numerise["file_content"]); |
$file_content = base64_decode($document_numerise["file_content"]); |
463 |
if ($file_content === false){ |
if ($file_content === false){ |
628 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
629 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
630 |
$task['dossier'] = $task['dossier']; |
$task['dossier'] = $task['dossier']; |
631 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
632 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
633 |
} |
} |
634 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
775 |
return $val_dt; |
return $val_dt; |
776 |
} |
} |
777 |
|
|
778 |
|
/** |
779 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
780 |
|
* entre identifiants internes et identifiants externes. |
781 |
|
* |
782 |
|
* @return array |
783 |
|
*/ |
784 |
|
protected function get_list_distinct_objects_external_link() { |
785 |
|
$query = sprintf(' |
786 |
|
SELECT |
787 |
|
DISTINCT(object) |
788 |
|
FROM %1$slien_id_interne_uid_externe |
789 |
|
ORDER BY object ASC |
790 |
|
', |
791 |
|
DB_PREFIXE |
792 |
|
); |
793 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
794 |
|
if ($res['code'] === 'KO') { |
795 |
|
return array(); |
796 |
|
} |
797 |
|
$result = array(); |
798 |
|
foreach ($res['result'] as $object) { |
799 |
|
$result[] = $object['object']; |
800 |
|
} |
801 |
|
return $result; |
802 |
|
} |
803 |
|
|
804 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
805 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
806 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
812 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
813 |
} |
} |
814 |
|
|
815 |
protected function get_all_external_uids($fk_idx) { |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
816 |
$link_objects = array( |
if (count($link_objects) == 0) { |
817 |
'dossier_autorisation', |
$link_objects = $this->get_list_distinct_objects_external_link(); |
818 |
'dossier', |
} |
|
'consultation', |
|
|
'document_numerise', |
|
|
); |
|
819 |
$val_external_uid = array(); |
$val_external_uid = array(); |
820 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
821 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
1104 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1105 |
$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'); |
1106 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1107 |
$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'); |
1108 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1109 |
} |
} |
1110 |
// |
// |
1118 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1119 |
$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'); |
1120 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1121 |
$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'); |
1122 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1123 |
} |
} |
1124 |
|
|
1133 |
|
|
1134 |
function post_update_task() { |
function post_update_task() { |
1135 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1136 |
// |
|
1137 |
$params = array( |
// Modification de l'état de la tâche |
1138 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
1139 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
1140 |
), |
'val' => array( |
1141 |
); |
'state' => $this->f->get_submitted_post_value('state') |
1142 |
$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'), |
|
1143 |
); |
); |
1144 |
$add = $inst_lien->ajouter($valF); |
$update = $this->update_task($params); |
1145 |
$message_class = "valid"; |
$message_class = "valid"; |
1146 |
$message = $inst_lien->msg; |
$message = $this->msg; |
1147 |
if ($add === false) { |
if ($update === false) { |
1148 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1149 |
$message_class = "error"; |
$message_class = "error"; |
1150 |
$message = sprintf( |
$message = sprintf( |
1151 |
'%s %s', |
'%s %s', |
1152 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
__('Impossible de mettre à jour la tâche.'), |
1153 |
__('Veuillez contacter votre administrateur.') |
__('Veuillez contacter votre administrateur.') |
1154 |
); |
); |
1155 |
} |
} |
1156 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1157 |
} |
} |
1158 |
|
|
1159 |
|
// Sauvegarde de l'uid externe retourné |
1160 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1161 |
|
// |
1162 |
|
$objects = $this->get_objects_by_task_type($this->getVal('type')); |
1163 |
|
foreach ($objects as $object) { |
1164 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1165 |
|
"obj" => "lien_id_interne_uid_externe", |
1166 |
|
"idx" => ']', |
1167 |
|
)); |
1168 |
|
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1169 |
|
$valF = array( |
1170 |
|
'lien_id_interne_uid_externe' => '', |
1171 |
|
'object' => $object, |
1172 |
|
'object_id' => $this->getVal('object_id'), |
1173 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1174 |
|
'dossier' => $this->getVal('dossier'), |
1175 |
|
); |
1176 |
|
$add = $inst_lien->ajouter($valF); |
1177 |
|
$message_class = "valid"; |
1178 |
|
$message = $inst_lien->msg; |
1179 |
|
if ($add === false) { |
1180 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1181 |
|
$message_class = "error"; |
1182 |
|
$message = sprintf( |
1183 |
|
'%s %s', |
1184 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1185 |
|
__('Veuillez contacter votre administrateur.') |
1186 |
|
); |
1187 |
|
} |
1188 |
|
$this->f->displayMessage($message_class, $message); |
1189 |
|
} |
1190 |
|
} |
1191 |
|
} |
1192 |
} |
} |
1193 |
|
|
1194 |
function post_add_task() { |
function post_add_task() { |
1200 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
1201 |
) |
) |
1202 |
)); |
)); |
1203 |
$message = $this->msg; |
$message = sprintf( |
1204 |
|
__("Tâche %s ajoutée avec succès"), |
1205 |
|
$this->getVal($this->clePrimaire)). |
1206 |
|
'<br/><br/>'. |
1207 |
|
$this->msg; |
1208 |
$message_class = "valid"; |
$message_class = "valid"; |
1209 |
if ($result === false){ |
if ($result === false){ |
1210 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1218 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1219 |
} |
} |
1220 |
|
|
|
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; |
|
|
} |
|
|
|
|
1221 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1222 |
|
|
1223 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1232 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1233 |
} |
} |
1234 |
|
|
1235 |
|
/** |
1236 |
|
* [get_objects_by_task_type description] |
1237 |
|
* @param [type] $type [description] |
1238 |
|
* @return [type] [description] |
1239 |
|
*/ |
1240 |
|
function get_objects_by_task_type($type) { |
1241 |
|
$objects = array(); |
1242 |
|
if (in_array($type, array('creation_DA', )) === true) { |
1243 |
|
$objects = array('dossier_autorisation', ); |
1244 |
|
} |
1245 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1246 |
|
$objects = array('dossier', ); |
1247 |
|
} |
1248 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1249 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1250 |
|
} |
1251 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1252 |
|
$objects = array('instruction', ); |
1253 |
|
} |
1254 |
|
if (in_array($type, array('pec_metier_consultation', )) === true) { |
1255 |
|
$objects = array('pec_dossier_consultation', ); |
1256 |
|
} |
1257 |
|
if (in_array($type, array('avis_consultation', )) === true) { |
1258 |
|
$objects = array('avis_dossier_consultation', ); |
1259 |
|
} |
1260 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1261 |
|
$objects = array('piece', ); |
1262 |
|
} |
1263 |
|
return $objects; |
1264 |
|
} |
1265 |
|
|
1266 |
} |
} |