36 |
'notification_recepisse', |
'notification_recepisse', |
37 |
'notification_instruction', |
'notification_instruction', |
38 |
'notification_decision', |
'notification_decision', |
39 |
|
'notification_service_consulte', |
40 |
|
'notification_tiers_consulte', |
41 |
); |
); |
42 |
|
|
43 |
/** |
/** |
51 |
'notification_recepisse', |
'notification_recepisse', |
52 |
'notification_instruction', |
'notification_instruction', |
53 |
'notification_decision', |
'notification_decision', |
54 |
|
'notification_service_consulte', |
55 |
|
'notification_tiers_consulte', |
56 |
'prescription', |
'prescription', |
57 |
); |
); |
58 |
|
|
157 |
// |
// |
158 |
$this->valF['category'] = $this->category; |
$this->valF['category'] = $this->category; |
159 |
} |
} |
160 |
|
|
161 |
|
// Si last_modification_time est vide, la valeur est remplacée par NULL |
162 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
163 |
|
if ($val['last_modification_time'] == "") { |
164 |
|
$this->valF['last_modification_time'] = NULL; |
165 |
|
} else { |
166 |
|
$this->valF['last_modification_time'] = $val['last_modification_time']; |
167 |
|
} |
168 |
|
|
169 |
|
// Si creation_time est vide, la valeur est remplacée par NULL |
170 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
171 |
|
if ($val['creation_time'] == "") { |
172 |
|
$this->valF['creation_time'] = NULL; |
173 |
|
} else { |
174 |
|
$this->valF['creation_time'] = $val['creation_time']; |
175 |
|
} |
176 |
} |
} |
177 |
|
|
178 |
/** |
/** |
187 |
"object_id", |
"object_id", |
188 |
"dossier", |
"dossier", |
189 |
"stream", |
"stream", |
190 |
|
"creation_date", |
191 |
|
"creation_time", |
192 |
|
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
193 |
|
'last_modification_date', |
194 |
|
'last_modification_time', |
195 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
196 |
|
"comment", |
197 |
"json_payload", |
"json_payload", |
198 |
"timestamp_log", |
"timestamp_log", |
199 |
|
"timestamp_log AS timestamp_log_hidden", |
200 |
"category", |
"category", |
201 |
); |
); |
202 |
} |
} |
209 |
|
|
210 |
// ALL |
// ALL |
211 |
$form->setType("category", "hidden"); |
$form->setType("category", "hidden"); |
212 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
213 |
|
|
214 |
// MODE CREER |
// MODE CREER |
215 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
216 |
|
$form->setType("type", "select"); |
217 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
218 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
219 |
$form->setType("json_payload", "textarea"); |
$form->setType("json_payload", "textarea"); |
220 |
} |
} |
221 |
// MDOE MODIFIER |
// MODE MODIFIER |
222 |
if ($maj == 1 || $crud == 'update') { |
if ($maj == 1 || $crud == 'update') { |
223 |
|
$form->setType("task", "hiddenstatic"); |
224 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
225 |
$form->setType("stream", "select"); |
$form->setType("stream", "hiddenstatic"); |
226 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
227 |
|
$form->setType("timestamp_log", "jsontotab"); |
228 |
|
$form->setType("type", "hiddenstatic"); |
229 |
|
$form->setType("creation_date", "hidden"); |
230 |
|
$form->setType("creation_time", "hidden"); |
231 |
|
$form->setType("object_id", "hiddenstatic"); |
232 |
|
$form->setType("dossier", "hiddenstatic"); |
233 |
|
$form->setType("date_creation", "hiddenstatic"); |
234 |
|
$form->setType("last_modification_date", "hidden"); |
235 |
|
$form->setType("last_modification_time", "hidden"); |
236 |
|
$form->setType("date_modification", "static"); |
237 |
} |
} |
238 |
// MODE CONSULTER |
// MODE CONSULTER |
239 |
if ($maj == 3 || $crud == 'read') { |
if ($maj == 3 || $crud == 'read') { |
240 |
|
$form->setType("state", "selecthiddenstatic"); |
241 |
|
$form->setType("stream", "selecthiddenstatic"); |
242 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
243 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
244 |
|
$form->setType("type", "selecthiddenstatic"); |
245 |
|
$form->setType("creation_date", "hidden"); |
246 |
|
$form->setType("creation_time", "hidden"); |
247 |
|
$form->setType("date_creation", "static"); |
248 |
|
$form->setType("last_modification_date", "hidden"); |
249 |
|
$form->setType("last_modification_time", "hidden"); |
250 |
|
$form->setType("date_modification", "static"); |
251 |
|
$form->setType("timestamp_log", "jsontotab"); |
252 |
} |
} |
|
|
|
253 |
} |
} |
254 |
|
|
255 |
|
function stateTranslation ($currentState) { |
256 |
|
switch ($currentState){ |
257 |
|
case "draft": |
258 |
|
return __('brouillon'); |
259 |
|
break; |
260 |
|
case "new": |
261 |
|
return __('à traiter'); |
262 |
|
break; |
263 |
|
case "pending": |
264 |
|
return __('en cours'); |
265 |
|
break; |
266 |
|
case "done": |
267 |
|
return __('terminé'); |
268 |
|
break; |
269 |
|
case "archived": |
270 |
|
return __('archivé'); |
271 |
|
break; |
272 |
|
case "error": |
273 |
|
return __('erreur'); |
274 |
|
break; |
275 |
|
case "debug": |
276 |
|
return __('debug'); |
277 |
|
break; |
278 |
|
case "canceled": |
279 |
|
return __('annulé'); |
280 |
|
break; |
281 |
|
} |
282 |
|
} |
283 |
/** |
/** |
284 |
* |
* |
285 |
*/ |
*/ |
286 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
287 |
if($maj < 2) { |
if($maj <= 3) { |
|
|
|
288 |
$contenu = array(); |
$contenu = array(); |
289 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
290 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
291 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
292 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
293 |
$contenu[1][] = $const_value; |
|
294 |
|
|
295 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
296 |
|
|
297 |
} |
} |
298 |
|
|
299 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
300 |
|
|
301 |
$contenu_stream =array(); |
$contenu_stream =array(); |
302 |
$contenu_stream[0][0]="input"; |
$contenu_stream[0][0]="input"; |
303 |
$contenu_stream[1][0]=_('input'); |
$contenu_stream[1][0]=__('input'); |
304 |
$contenu_stream[0][1]="output"; |
$contenu_stream[0][1]="output"; |
305 |
$contenu_stream[1][1]=_('output'); |
$contenu_stream[1][1]=__('output'); |
306 |
$form->setSelect("stream", $contenu_stream); |
$form->setSelect("stream", $contenu_stream); |
307 |
|
|
308 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
309 |
|
|
310 |
|
foreach ($tab_type as $type) { |
311 |
|
|
312 |
|
$contenu_type[0][] = $type; |
313 |
|
|
314 |
|
switch ($type) { |
315 |
|
case "creation_DA": |
316 |
|
$value_type = __('Création DA'); |
317 |
|
break; |
318 |
|
case "create_DI": |
319 |
|
$value_type = __('Création demande'); |
320 |
|
break; |
321 |
|
case "creation_DI": |
322 |
|
$value_type = __('Création DI'); |
323 |
|
break; |
324 |
|
case "modification_DA": |
325 |
|
$value_type = __('Modification DA'); |
326 |
|
break; |
327 |
|
case "modification_DI": |
328 |
|
$value_type = __('Modification DI'); |
329 |
|
break; |
330 |
|
case "ajout_piece": |
331 |
|
$value_type = __('Ajout pièce (sortant)'); |
332 |
|
break; |
333 |
|
case "add_piece": |
334 |
|
$value_type = __('Ajout pièce (entrant)'); |
335 |
|
break; |
336 |
|
case "depot_DI": |
337 |
|
$value_type = __('Dépôt DI'); |
338 |
|
break; |
339 |
|
case "qualification_DI": |
340 |
|
$value_type = __('Qualification DI'); |
341 |
|
break; |
342 |
|
case "creation_consultation": |
343 |
|
$value_type = __('Création consultation'); |
344 |
|
break; |
345 |
|
case "decision_DI": |
346 |
|
$value_type = __('Décision DI'); |
347 |
|
break; |
348 |
|
case "envoi_CL": |
349 |
|
$value_type = __('Envoi contrôle de légalité'); |
350 |
|
break; |
351 |
|
case "pec_metier_consultation": |
352 |
|
$value_type = __('PeC consultation'); |
353 |
|
break; |
354 |
|
case "avis_consultation": |
355 |
|
$value_type = __('Avis'); |
356 |
|
break; |
357 |
|
case "prescription": |
358 |
|
$value_type = __('Prescription'); |
359 |
|
break; |
360 |
|
case "create_DI_for_consultation": |
361 |
|
$value_type = __('Création DI pour consultation'); |
362 |
|
break; |
363 |
|
case "create_message": |
364 |
|
$value_type = __('Message'); |
365 |
|
break; |
366 |
|
case "notification_recepisse": |
367 |
|
$value_type = __('Notification récépissé'); |
368 |
|
break; |
369 |
|
case "notification_instruction": |
370 |
|
$value_type = __('Notification instruction'); |
371 |
|
break; |
372 |
|
case "notification_decision": |
373 |
|
$value_type = __('Notification décision'); |
374 |
|
break; |
375 |
|
case "notification_service_consulte": |
376 |
|
$value_type = __('Notification service consulté'); |
377 |
|
break; |
378 |
|
case "notification_tiers_consulte": |
379 |
|
$value_type = __('Notification tiers consulté'); |
380 |
|
break; |
381 |
|
case "completude_DI": |
382 |
|
$value_type = __('complétude DI'); |
383 |
|
break; |
384 |
|
case "incompletude_DI": |
385 |
|
$value_type = __('incomplétude DI'); |
386 |
|
break; |
387 |
|
} |
388 |
|
|
389 |
|
$contenu_type[1][] = $value_type; |
390 |
|
} |
391 |
|
|
392 |
|
$form->setselect('type', $contenu_type); |
393 |
} |
} |
394 |
|
|
395 |
if ($maj == 3) { |
if ($maj == 3) { |
396 |
if ($this->getVal('stream') == 'output') { |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
397 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
398 |
"obj" => "dossier", |
// Récupération de la payload de la taĉhe. |
399 |
"idx" => $form->val['dossier'], |
// Si la tâche est une tâche input la payload est associée à la tâche. |
400 |
)); |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
401 |
|
// du formulaire. |
402 |
|
if ($this->getVal('stream') == 'input') { |
403 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
404 |
|
} else { |
405 |
|
$json_payload = json_decode($form->val['json_payload'], true); |
406 |
|
} |
407 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
408 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
409 |
|
// pour l'afficher sur le formulaire. |
410 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
411 |
|
$external_uid = ''; |
412 |
|
if (array_key_exists('external_uids', $json_payload) |
413 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
414 |
|
) { |
415 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
416 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
417 |
|
&& array_key_exists('dossier', $json_payload['external_uids'])) { |
418 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
419 |
|
} |
420 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
421 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
422 |
|
// du formulaire pour pouvoir l'afficher |
423 |
|
if ($external_uid != '') { |
424 |
|
$uid = sprintf( |
425 |
|
'SELECT |
426 |
|
lien_id_interne_uid_externe.dossier |
427 |
|
FROM |
428 |
|
%1$slien_id_interne_uid_externe |
429 |
|
WHERE |
430 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
431 |
|
DB_PREFIXE, |
432 |
|
$external_uid |
433 |
|
); |
434 |
|
$res_external_uid = $this->f->get_one_result_from_db_query($uid); |
435 |
|
if (! empty($res_external_uid['result'])) { |
436 |
|
$form->val['dossier'] = $res_external_uid['result']; |
437 |
|
} |
438 |
|
} |
439 |
|
} |
440 |
|
|
441 |
if($form->val['type'] == "creation_DA" |
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
442 |
|| $form->val['type'] == "modification_DA"){ |
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
443 |
// |
// TODO : vérifier la liste des tâches lié à des DA |
444 |
|
$obj_link = ''; |
445 |
|
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
446 |
|
// Vérification que le numéro de DA affiché dans le formulaire existe |
447 |
|
$idDA = sprintf( |
448 |
|
'SELECT |
449 |
|
dossier_autorisation.dossier_autorisation |
450 |
|
FROM |
451 |
|
%1$sdossier_autorisation |
452 |
|
WHERE |
453 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
454 |
|
DB_PREFIXE, |
455 |
|
$form->val['dossier'] |
456 |
|
); |
457 |
|
$resIdDA=$this->f->get_one_result_from_db_query($idDA); |
458 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
459 |
|
if (! empty($resIdDA['result'])) { |
460 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
461 |
} else { |
} |
462 |
|
} else { |
463 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
464 |
|
$idDI = sprintf( |
465 |
|
'SELECT |
466 |
|
dossier.dossier |
467 |
|
FROM |
468 |
|
%1$sdossier |
469 |
|
WHERE |
470 |
|
dossier.dossier = \'%2$s\'', |
471 |
|
DB_PREFIXE, |
472 |
|
$form->val['dossier'] |
473 |
|
); |
474 |
|
$resDI = $this->f->get_one_result_from_db_query($idDI); |
475 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
476 |
|
if (! empty($resDI['result'])) { |
477 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
478 |
} |
} |
|
|
|
|
$params = array(); |
|
|
$params['obj'] = $obj_link; |
|
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
|
|
$params['title'] = "Consulter le dossier"; |
|
|
$params['idx'] = $form->val['dossier']; |
|
|
$form->setSelect("dossier", $params); |
|
479 |
} |
} |
480 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
481 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
482 |
|
// - quel objet est visé par le lien |
483 |
|
// - le label (libellé) du lien |
484 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
485 |
|
// - le titre associé au lien |
486 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
487 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
488 |
|
$params = array( |
489 |
|
'obj' => $obj_link, |
490 |
|
'libelle' => $form->val['dossier'], |
491 |
|
'title' => "Consulter le dossier", |
492 |
|
'idx' => $form->val['dossier'] |
493 |
|
); |
494 |
|
$form->setSelect("dossier", $params); |
495 |
} |
} |
496 |
} |
} |
497 |
|
|
516 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
517 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
518 |
|
|
519 |
|
$form->setLib('date_creation', __("Date de création")); |
520 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
521 |
|
$form->setLib('comment', __("commentaire")); |
522 |
|
|
523 |
// MODE different de CREER |
// MODE different de CREER |
524 |
if ($maj != 0 || $crud != 'create') { |
if ($maj != 0 || $crud != 'create') { |
525 |
$form->setLib('json_payload', ''); |
$form->setLib('json_payload', ''); |
526 |
|
$form->setLib("task", __("identifiant")); |
527 |
|
$form->setLib("Task_portal", __("task_portal")); |
528 |
|
$form->setLib("type", __("type")); |
529 |
|
$form->setLib("object_id", __("Réf. interne")); |
530 |
|
$form->setLib("stream", __("flux")); |
531 |
|
$form->setLib("timestamp_log", __("Historique")); |
532 |
} |
} |
533 |
} |
} |
534 |
|
|
701 |
*/ |
*/ |
702 |
public function task_exists_multi_search(array $search_values) { |
public function task_exists_multi_search(array $search_values) { |
703 |
$query = sprintf(' |
$query = sprintf(' |
704 |
SELECT task |
SELECT * |
705 |
FROM %1$stask |
FROM %1$stask |
706 |
%2$s |
%2$s |
707 |
%3$s |
%3$s |
745 |
|
|
746 |
// gestion d'une tache de type notification et de category mail |
// gestion d'une tache de type notification et de category mail |
747 |
if (isset($val['type']) |
if (isset($val['type']) |
748 |
&& (//$val['type'] === 'notification_recepisse' |
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
749 |
$val['type'] === 'notification_instruction' |
&& isset($val['category']) |
750 |
|| $val['type'] === 'notification_decision') |
&& $val['category'] === 'mail') |
751 |
&& isset($val['category']) |
|| $val['type'] === 'notification_service_consulte' |
752 |
&& $val['category'] === 'mail') { |
|| $val['type'] === 'notification_tiers_consulte' |
753 |
|
) { |
754 |
// Récupère la payload de la tache |
// Récupère la payload de la tache |
755 |
$data = array(); |
$data = array(); |
756 |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
766 |
"idx" => $val['object_id'], |
"idx" => $val['object_id'], |
767 |
)); |
)); |
768 |
// Envoi le mail et met à jour le suivi |
// Envoi le mail et met à jour le suivi |
769 |
$envoiMail = $inst_notif->send_mail_notification_demandeur($data); |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
770 |
// Passage de la tache à done si elle a réussi et à error |
// Passage de la tache à done si elle a réussi et à error |
771 |
// si l'envoi a échoué |
// si l'envoi a échoué |
772 |
$this->valF['state'] = 'done'; |
$this->valF['state'] = 'done'; |
777 |
} |
} |
778 |
|
|
779 |
/** |
/** |
780 |
|
* TRIGGER - triggermodifier. |
781 |
|
* |
782 |
|
* @param string $id |
783 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
784 |
|
* @param array $val Tableau des valeurs brutes. |
785 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
786 |
|
* |
787 |
|
* @return boolean |
788 |
|
*/ |
789 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
790 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
791 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
792 |
|
|
793 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
794 |
|
$values = array( |
795 |
|
'state' => $this->valF['state'], |
796 |
|
'object_id' => $this->valF['object_id'], |
797 |
|
'comment' => $this->valF['comment'], |
798 |
|
); |
799 |
|
$new_values = $this->set_values_for_update($values); |
800 |
|
if ($new_values === false) { |
801 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
802 |
|
return false; |
803 |
|
} |
804 |
|
|
805 |
|
// Mise à jour des valeurs |
806 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
807 |
|
$this->valF['state'] = $new_values['state']; |
808 |
|
$this->valF['object_id'] = $new_values['object_id']; |
809 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
810 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
811 |
|
|
812 |
|
return true; |
813 |
|
} |
814 |
|
|
815 |
|
|
816 |
|
/** |
817 |
|
* Applique nouvelle valeur après traitement. |
818 |
|
* |
819 |
|
* @param array $params Tableau des valeurs en entrées |
820 |
|
* @return array Tableau des valeurs en sorties |
821 |
|
*/ |
822 |
|
public function set_values_for_update($params = array()) { |
823 |
|
|
824 |
|
// Récupération du timestamp_log existant |
825 |
|
$timestamp_log = $this->get_timestamp_log(); |
826 |
|
if ($timestamp_log === false) { |
827 |
|
return false; |
828 |
|
} |
829 |
|
|
830 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
831 |
|
// l'état CANCELED sur la tâche |
832 |
|
if (isset($params['state']) === true |
833 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
834 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
835 |
|
// trié par ordre décroissant |
836 |
|
$log = $timestamp_log; |
837 |
|
krsort($log); |
838 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
839 |
|
// - vérification de la présence de l'object_id précédent |
840 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
841 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
842 |
|
// - le state n'est pas modifié |
843 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
844 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
845 |
|
foreach ($log as $key => $value) { |
846 |
|
// |
847 |
|
if (isset($value['prev_object_id']) === true |
848 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
849 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
850 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
851 |
|
foreach ($tables as $table) { |
852 |
|
// Vérifie s'il y a un ou aucun résultat |
853 |
|
$query = sprintf(' |
854 |
|
SELECT COUNT(%2$s) |
855 |
|
FROM %1$s%2$s |
856 |
|
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
857 |
|
', |
858 |
|
DB_PREFIXE, |
859 |
|
$table, |
860 |
|
$value['prev_object_id'] |
861 |
|
); |
862 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
863 |
|
if ($res['code'] === 'KO') { |
864 |
|
return $this->end_treatment(__METHOD__, false); |
865 |
|
} |
866 |
|
// Affectation des valeurs et sortie de la boucle |
867 |
|
if ($res['result'] == '1') { |
868 |
|
$params['object_id'] = $value['prev_object_id']; |
869 |
|
$params['state'] = $this->getVal('state'); |
870 |
|
break; |
871 |
|
} |
872 |
|
} |
873 |
|
// Sortie de la boucle si les valeurs sont affectées |
874 |
|
if ($params['object_id'] !== null |
875 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
876 |
|
// |
877 |
|
break; |
878 |
|
} |
879 |
|
} |
880 |
|
} |
881 |
|
} |
882 |
|
|
883 |
|
// Mise à jour du journal d'activité de la tâche |
884 |
|
array_push($timestamp_log, array( |
885 |
|
'modification_date' => date('Y-m-d H:i:s'), |
886 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
887 |
|
'prev_object_id' => $this->getVal('object_id'), |
888 |
|
'state' => $params['state'], |
889 |
|
'prev_state' => $this->getVal('state'), |
890 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
891 |
|
)); |
892 |
|
// |
893 |
|
$timestamp_log = json_encode($timestamp_log); |
894 |
|
|
895 |
|
|
896 |
|
// Les nouvelles valeurs après vérification des critères |
897 |
|
$result = array( |
898 |
|
'timestamp_log' => $timestamp_log, |
899 |
|
'object_id' => $params['object_id'], |
900 |
|
'state' => $params['state'], |
901 |
|
'comment' => $params['comment'], |
902 |
|
); |
903 |
|
return $result; |
904 |
|
} |
905 |
|
|
906 |
|
|
907 |
|
/** |
908 |
* TRIGGER - triggermodifierapres. |
* TRIGGER - triggermodifierapres. |
909 |
* |
* |
910 |
* @param string $id |
* @param string $id |
925 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
926 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
927 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
928 |
|| $val['type'] === 'notification_decision')) { |
|| $val['type'] === 'notification_decision' |
929 |
|
|| $val['type'] === 'notification_service_consulte' |
930 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
931 |
// |
// |
932 |
if (isset($this->valF['state']) === true |
if (isset($this->valF['state']) === true |
933 |
&& $this->valF['state'] !== $this->getVal('state') |
&& $this->valF['state'] !== $this->getVal('state') |
1048 |
} |
} |
1049 |
|
|
1050 |
// |
// |
1051 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array()); |
|
'creation_date' => date('Y-m-d H:i:s'), |
|
|
)); |
|
1052 |
|
|
1053 |
// |
// |
1054 |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
1065 |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
1066 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1067 |
} |
} |
1068 |
if (isset($json_payload['document_numerise']) === true |
if (isset($json_payload['document_numerise']["file_content"]) === true |
1069 |
&& empty($json_payload['document_numerise']) === false) { |
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1070 |
// |
// |
1071 |
$document_numerise = $json_payload['document_numerise']; |
$document_numerise = $json_payload['document_numerise']; |
1072 |
$file_content = base64_decode($document_numerise["file_content"]); |
$file_content = base64_decode($document_numerise["file_content"]); |
1103 |
'stream' => $stream, |
'stream' => $stream, |
1104 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
1105 |
'category' => $category, |
'category' => $category, |
1106 |
|
'creation_date' => date('Y-m-d'), |
1107 |
|
'creation_time' => date('H:i:s'), |
1108 |
|
'last_modification_date' => null, |
1109 |
|
'last_modification_time' => null, |
1110 |
|
'comment' => null, |
1111 |
); |
); |
1112 |
|
|
1113 |
// tâche sortante |
// tâche sortante |
1114 |
|
$typeNonConcerne = array( |
1115 |
|
'notification_recepisse', |
1116 |
|
'notification_instruction', |
1117 |
|
'notification_decision', |
1118 |
|
'notification_service_consulte', |
1119 |
|
'notification_tiers_consulte' |
1120 |
|
); |
1121 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1122 |
&& $valF['type'] !== 'notification_recepisse' |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
|
&& $valF['type'] !== 'notification_instruction' |
|
|
&& $valF['type'] !== 'notification_decision') { |
|
|
|
|
1123 |
// TODO expliquer ce code |
// TODO expliquer ce code |
1124 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
1125 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1170 |
*/ |
*/ |
1171 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1172 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1173 |
$timestamp_log = $this->get_timestamp_log(); |
|
|
if ($timestamp_log === false) { |
|
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
|
|
// l'état CANCELED sur la tâche |
|
|
if (isset($params['val']['state']) === true |
|
|
&& $params['val']['state'] === self::STATUS_CANCELED) { |
|
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
|
|
// trié par ordre décroissant |
|
|
$log = $timestamp_log; |
|
|
unset($log['creation_date']); |
|
|
krsort($log); |
|
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
|
|
// - vérification de la présence de l'object_id précédent |
|
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
|
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
|
|
// - le state n'est pas modifié |
|
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
|
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
|
|
foreach ($log as $key => $value) { |
|
|
// |
|
|
if (isset($value['prev_object_id']) === true |
|
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
|
|
// Récupère la liste des tables potentielles pour un type de tâche |
|
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
|
|
foreach ($tables as $table) { |
|
|
// Vérifie s'il y a un ou aucun résultat |
|
|
$query = sprintf(' |
|
|
SELECT COUNT(%2$s) |
|
|
FROM %1$s%2$s |
|
|
WHERE %2$s = \'%3$s\' |
|
|
', |
|
|
DB_PREFIXE, |
|
|
$table, |
|
|
$value['prev_object_id'] |
|
|
); |
|
|
$res = $this->f->get_one_result_from_db_query($query, true); |
|
|
if ($res['code'] === 'KO') { |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Affectation des valeurs et sortie de la boucle |
|
|
if ($res['result'] == '1') { |
|
|
$params['object_id'] = $value['prev_object_id']; |
|
|
$params['val']['state'] = $this->getVal('state'); |
|
|
break; |
|
|
} |
|
|
} |
|
|
// Sortie de la boucle si les valeurs sont affectées |
|
|
if (isset($params['object_id']) === true |
|
|
&& $params['object_id'] === $value['prev_object_id']) { |
|
|
// |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// Mise à jour du journal d'activité de la tâche |
|
|
array_push($timestamp_log, array( |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
|
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
|
|
'prev_object_id' => $this->getVal('object_id'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1174 |
// Mise à jour de la tâche |
// Mise à jour de la tâche |
1175 |
$valF = array( |
$valF = array( |
1176 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
1177 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1178 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1179 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1180 |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
1181 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
1182 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
1183 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
1184 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
1185 |
|
'creation_date' => $this->getVal('creation_date'), |
1186 |
|
'creation_time' => $this->getVal('creation_time'), |
1187 |
|
'last_modification_date' => date('Y-m-d'), |
1188 |
|
'last_modification_time' => date('H:i:s'), |
1189 |
|
'comment' => $this->getVal('comment'), |
1190 |
); |
); |
1191 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1192 |
if ($update === false) { |
if ($update === false) { |
1235 |
|
|
1236 |
protected function view_tab_json() { |
protected function view_tab_json() { |
1237 |
$where = ''; |
$where = ''; |
1238 |
if ($this->f->get_submitted_get_value('state') !== null |
$category = null; |
1239 |
&& $this->f->get_submitted_get_value('state') !== '') { |
// Liste des paramètres possibles pour la recherche des tâches |
1240 |
// |
$params = array( |
1241 |
$where_or_and = 'WHERE'; |
'task', |
1242 |
if ($where !== '') { |
'type', |
1243 |
$where_or_and = 'AND'; |
'state', |
1244 |
} |
'object_id', |
1245 |
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
'dossier', |
1246 |
} |
'stream', |
1247 |
if ($this->f->get_submitted_get_value('category') !== null |
'category', |
1248 |
&& $this->f->get_submitted_get_value('category') !== '') { |
'lien_id_interne_uid_externe', |
1249 |
// |
'object', |
1250 |
$where_or_and = 'WHERE'; |
'external_uid', |
1251 |
if ($where !== '') { |
); |
1252 |
$where_or_and = 'AND'; |
// Pour chaque paramètre possible, vérification de son existance et de sa |
1253 |
|
// valeur pour compléter la requête de recherche |
1254 |
|
foreach ($params as $param) { |
1255 |
|
// |
1256 |
|
if ($this->f->get_submitted_get_value($param) !== null |
1257 |
|
&& $this->f->get_submitted_get_value($param) !== '') { |
1258 |
|
// Condition spécifique au champ 'category' |
1259 |
|
if ($param === 'category') { |
1260 |
|
$category = $this->f->get_submitted_get_value('category'); |
1261 |
|
} |
1262 |
|
// |
1263 |
|
$where_or_and = 'WHERE'; |
1264 |
|
if ($where !== '') { |
1265 |
|
$where_or_and = 'AND'; |
1266 |
|
} |
1267 |
|
$table = 'task'; |
1268 |
|
if ($param === 'lien_id_interne_uid_externe' |
1269 |
|
|| $param === 'object' |
1270 |
|
|| $param === 'external_uid') { |
1271 |
|
// |
1272 |
|
$table = 'lien_id_interne_uid_externe'; |
1273 |
|
} |
1274 |
|
$where .= sprintf(' %s %s.%s = \'%s\' ', $where_or_and, $table, $param, $this->f->get_submitted_get_value($param)); |
1275 |
} |
} |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
|
1276 |
} |
} |
1277 |
|
// |
1278 |
$query = sprintf(' |
$query = sprintf(' |
1279 |
SELECT |
SELECT |
1280 |
* |
task.* |
1281 |
FROM %1$stask |
FROM %1$stask |
1282 |
|
LEFT JOIN %1$slien_id_interne_uid_externe |
1283 |
|
ON task.object_id = lien_id_interne_uid_externe.object_id |
1284 |
|
AND task.category = lien_id_interne_uid_externe.category |
1285 |
%2$s |
%2$s |
1286 |
ORDER BY task ASC |
ORDER BY task ASC |
1287 |
', |
', |
1294 |
} |
} |
1295 |
$list_tasks = array(); |
$list_tasks = array(); |
1296 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
1297 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
unset($task['timestamp_log']); |
1298 |
$task['dossier'] = $task['dossier']; |
unset($task['json_payload']); |
1299 |
if ($task['type'] === 'ajout_piece') { |
if ($task['type'] === 'ajout_piece') { |
1300 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
1301 |
} |
} |
1302 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
1303 |
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
$task['external_uids'] = array_merge( |
1304 |
|
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1305 |
|
$this->get_all_external_uids($task['object_id'], array(), $category !== null ? $category : $task['category']) |
1306 |
|
); |
1307 |
} |
} |
1308 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
1309 |
} |
} |
1310 |
printf(json_encode($list_tasks)); |
echo(json_encode($list_tasks)); |
1311 |
} |
} |
1312 |
|
|
1313 |
protected function get_dossier_data(string $dossier) { |
protected function get_dossier_data(string $dossier) { |
1475 |
return $result; |
return $result; |
1476 |
} |
} |
1477 |
|
|
1478 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = 'platau', $order_asc_desc = 'DESC') { |
1479 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1480 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1481 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1482 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
1483 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
1484 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
1485 |
|
"fk_field_3" => 'category', |
1486 |
|
"fk_idx_3" => $fk_idx_3, |
1487 |
|
"order_field" => 'lien_id_interne_uid_externe', |
1488 |
|
"order_asc_desc" => $order_asc_desc, |
1489 |
)); |
)); |
1490 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1491 |
} |
} |
1492 |
|
|
1493 |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category='platau') { |
1494 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1495 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1496 |
} |
} |
1497 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1498 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
1499 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object, $category); |
1500 |
if ($external_uid !== '' && $external_uid !== null) { |
if ($external_uid !== '' && $external_uid !== null) { |
1501 |
$val_external_uid[$link_object] = $external_uid; |
$val_external_uid[$link_object] = $external_uid; |
1502 |
} |
} |
1603 |
return $val_instruction; |
return $val_instruction; |
1604 |
} |
} |
1605 |
|
|
1606 |
|
|
1607 |
/** |
/** |
1608 |
* Récupère les informations |
* Récupère les informations pour les notifications ayant plusieurs annexe |
1609 |
*/ |
*/ |
1610 |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1611 |
$val_in = null; |
$val_in = null; |
1615 |
$idx = $extra_params['with-id']; |
$idx = $extra_params['with-id']; |
1616 |
} |
} |
1617 |
|
|
1618 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1619 |
|
// le message et le titre de notification. |
1620 |
|
$typeNotification = $this->getVal('type'); |
1621 |
|
if (isset($this->valF['type'])) { |
1622 |
|
$typeNotification = $this->valF['type']; |
1623 |
|
} |
1624 |
|
|
1625 |
// récupére les données à intégrer à la payload |
// récupére les données à intégrer à la payload |
1626 |
$inst_in = $this->f->get_inst__om_dbform(array( |
$inst_in = $this->f->get_inst__om_dbform(array( |
1627 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
1639 |
"idx" => $inst_in->getVal('instruction'), |
"idx" => $inst_in->getVal('instruction'), |
1640 |
)); |
)); |
1641 |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1642 |
$phrase_type_notification = array(); |
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
|
1643 |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1644 |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1645 |
} |
} |
1646 |
|
|
1647 |
// Récupération des liens vers les documents et de l'id de l'instruction |
// Récupération des liens vers les documents et des id et type des annexes |
|
// de l'annexe |
|
1648 |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
1649 |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1650 |
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
$val_in['annexes'] = $infoDocNotif['annexes']; |
|
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
|
1651 |
} |
} |
|
|
|
1652 |
return $val_in; |
return $val_in; |
1653 |
} |
} |
1654 |
|
|
1829 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
1830 |
} |
} |
1831 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1832 |
|
unset($val_task['timestamp_log_hidden']); |
1833 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1834 |
// |
// |
1835 |
if ($this->getVal('type') === 'creation_DA' |
if ($this->getVal('type') === 'creation_DA' |
1873 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1874 |
$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'); |
1875 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1876 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
1877 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1878 |
} |
} |
1879 |
// |
// |
1929 |
$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'); |
1930 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1931 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1932 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
1933 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1934 |
} |
} |
1935 |
// XXX WIP |
// XXX WIP |
1953 |
$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'); |
1954 |
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
1955 |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
1956 |
if ($val_external_uid['decision'] === null) { |
if ($val_external_uid['decision'] === '') { |
1957 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1958 |
"obj" => "instruction", |
"obj" => "instruction", |
1959 |
"idx" => $this->getVal('object_id'), |
"idx" => $this->getVal('object_id'), |
1962 |
} |
} |
1963 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1964 |
} |
} |
|
// |
|
1965 |
if ($this->getVal('type') === 'notification_instruction' |
if ($this->getVal('type') === 'notification_instruction' |
1966 |
|| $this->getVal('type') === 'notification_recepisse' |
|| $this->getVal('type') === 'notification_recepisse' |
1967 |
|| $this->getVal('type') === 'notification_decision') { |
|| $this->getVal('type') === 'notification_decision' |
1968 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
1969 |
|
|| $this->getVal('type') === 'notification_tiers_consulte') { |
1970 |
// |
// |
1971 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1972 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1973 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1974 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1975 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1976 |
$instruction_annexe = isset($val['instruction_notification']['instruction_annexe']) === true ? $val['instruction_notification']['instruction_annexe'] : null; |
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
1977 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1978 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1979 |
// demande dont le type ne génère pas de dossier |
// demande dont le type ne génère pas de dossier |
1981 |
$val['instruction']['final'] = 't'; |
$val['instruction']['final'] = 't'; |
1982 |
} |
} |
1983 |
// |
// |
1984 |
if ($instruction_annexe != '') { |
if (is_array($instruction_annexes) && $instruction_annexes != array()) { |
1985 |
$val['instruction_annexe'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_annexe)); |
$val['instruction_annexe'] = array(); |
1986 |
|
$numAnnexe = 0; |
1987 |
|
foreach ($instruction_annexes as $annexe) { |
1988 |
|
if ($annexe['document_type'] === 'instruction') { |
1989 |
|
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $annexe['document_id'])); |
1990 |
|
} elseif ($annexe['document_type'] === 'consultation') { |
1991 |
|
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_consultation_data($annexe['document_id']); |
1992 |
|
} |
1993 |
|
} |
1994 |
} |
} |
1995 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1996 |
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1997 |
$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'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
1998 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', 'portal', 'ASC'); |
1999 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', 'portal'); |
2000 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
2001 |
} |
} |
2002 |
// |
// |
2011 |
$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'); |
2012 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2013 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2014 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2015 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
2016 |
} |
} |
2017 |
|
|
2059 |
"idx" => ']', |
"idx" => ']', |
2060 |
)); |
)); |
2061 |
$object_id = $this->getVal('object_id'); |
$object_id = $this->getVal('object_id'); |
2062 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
2063 |
// Dans le cas spécifique de la mise à jour d'une notification |
// Dans le cas spécifique de la mise à jour d'une notification |
2064 |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2065 |
// l'identifiant de l'objet n'est plus celui de la notification |
// l'identifiant de l'objet n'est plus celui de la notification |
2067 |
if ($object === 'demande' |
if ($object === 'demande' |
2068 |
&& ($this->getVal('type') === 'notification_recepisse' |
&& ($this->getVal('type') === 'notification_recepisse' |
2069 |
|| $this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'notification_instruction' |
2070 |
|| $this->getVal('type') === 'notification_decision')) { |
|| $this->getVal('type') === 'notification_decision' |
2071 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2072 |
|
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
2073 |
// |
// |
2074 |
$object_id = $this->getVal('dossier'); |
$object_id = $this->getVal('dossier'); |
2075 |
|
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2076 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, null, $this->getVal('dossier')); |
2077 |
} |
} |
2078 |
if ($inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
if ($is_exists === false) { |
2079 |
$valF = array( |
$valF = array( |
2080 |
'lien_id_interne_uid_externe' => '', |
'lien_id_interne_uid_externe' => '', |
2081 |
'object' => $object, |
'object' => $object, |
2131 |
} |
} |
2132 |
|
|
2133 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2134 |
|
// |
2135 |
// Récupération du mode de l'action |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2136 |
$crud = $this->get_action_crud($maj); |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
2137 |
|
$form->setBloc('json_payload', 'F'); |
2138 |
// MODE different de CREER |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
|
if ($maj != 0 || $crud != 'create') { |
|
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
|
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
|
|
$form->setBloc('json_payload', 'F'); |
|
|
} |
|
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
|
2139 |
} |
} |
2140 |
|
|
2141 |
/** |
/** |
2142 |
* [get_objects_by_task_type description] |
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
2143 |
* @param [type] $type [description] |
* en fonction du type et du stream de la tâche. |
2144 |
* @return [type] [description] |
* |
2145 |
|
* @param string $type Type de la tâche |
2146 |
|
* @param string $stream Stream de la tâche |
2147 |
|
* |
2148 |
|
* @return array |
2149 |
*/ |
*/ |
2150 |
function get_objects_by_task_type($type, $stream = 'all') { |
function get_objects_by_task_type($type, $stream = 'all') { |
2151 |
$objects = array(); |
$objects = array(); |
2162 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2163 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2164 |
} |
} |
2165 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', 'envoi_CL', )) === true) { |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
2166 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2167 |
} |
} |
2168 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2169 |
|
$objects = array('instruction_action_cl', ); |
2170 |
|
} |
2171 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2172 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2173 |
$objects = array('pec_dossier_consultation', ); |
$objects = array('pec_dossier_consultation', ); |
2198 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2199 |
$objects = array('dossier_message', ); |
$objects = array('dossier_message', ); |
2200 |
} |
} |
2201 |
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
if (in_array( |
2202 |
|
$type, |
2203 |
|
array( |
2204 |
|
'notification_recepisse', |
2205 |
|
'notification_instruction', |
2206 |
|
'notification_decision', |
2207 |
|
'notification_service_consulte', |
2208 |
|
'notification_tiers_consulte', |
2209 |
|
) |
2210 |
|
) === true) { |
2211 |
$objects = array('instruction_notification', 'demande', ); |
$objects = array('instruction_notification', 'demande', ); |
2212 |
} |
} |
2213 |
return $objects; |
return $objects; |
2230 |
$tables = array('dossier', ); |
$tables = array('dossier', ); |
2231 |
} |
} |
2232 |
if (in_array($type, array('qualification_DI', )) === true) { |
if (in_array($type, array('qualification_DI', )) === true) { |
2233 |
$tables = array('instruction', ); |
$tables = array('instruction', 'dossier', ); |
2234 |
} |
} |
2235 |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2236 |
$tables = array('dossier', ); |
$tables = array('dossier', ); |
2272 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2273 |
$tables = array('dossier_message', ); |
$tables = array('dossier_message', ); |
2274 |
} |
} |
2275 |
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
if (in_array( |
2276 |
|
$type, |
2277 |
|
array( |
2278 |
|
'notification_recepisse', |
2279 |
|
'notification_instruction', |
2280 |
|
'notification_decision', |
2281 |
|
'notification_service_consulte', |
2282 |
|
'notification_tiers_consulte' |
2283 |
|
) |
2284 |
|
) === true) { |
2285 |
$tables = array('instruction_notification', ); |
$tables = array('instruction_notification', ); |
2286 |
} |
} |
2287 |
return $tables; |
return $tables; |