13 |
const STATUS_ERROR = 'error'; |
const STATUS_ERROR = 'error'; |
14 |
const STATUS_DEBUG = 'debug'; |
const STATUS_DEBUG = 'debug'; |
15 |
const STATUS_ARCHIVED = 'archived'; |
const STATUS_ARCHIVED = 'archived'; |
16 |
|
const STATUS_CANCELED = 'canceled'; |
17 |
|
|
18 |
/** |
/** |
19 |
* Liste des types de tâche concernant les services instructeurs |
* Liste des types de tâche concernant les services instructeurs |
32 |
'creation_consultation', |
'creation_consultation', |
33 |
'modification_DA', |
'modification_DA', |
34 |
'create_DI', |
'create_DI', |
35 |
|
'envoi_CL', |
36 |
|
'notification_recepisse', |
37 |
|
'notification_instruction', |
38 |
|
'notification_decision', |
39 |
|
'notification_service_consulte', |
40 |
|
'notification_tiers_consulte', |
41 |
|
'notification_depot_demat', |
42 |
|
'notification_commune', |
43 |
|
'notification_signataire', |
44 |
|
'lettre_incompletude', |
45 |
|
'lettre_majoration' |
46 |
); |
); |
47 |
|
|
48 |
/** |
/** |
53 |
'avis_consultation', |
'avis_consultation', |
54 |
'pec_metier_consultation', |
'pec_metier_consultation', |
55 |
'create_message', |
'create_message', |
56 |
|
'notification_recepisse', |
57 |
|
'notification_instruction', |
58 |
|
'notification_decision', |
59 |
|
'notification_service_consulte', |
60 |
|
'notification_tiers_consulte', |
61 |
|
'notification_depot_demat', |
62 |
|
'prescription', |
63 |
); |
); |
64 |
|
|
65 |
/** |
/** |
66 |
|
* Liste des types de tâche pouvant avoir des documents associés |
67 |
|
*/ |
68 |
|
const TASK_WITH_DOCUMENT = array( |
69 |
|
'add_piece', |
70 |
|
'avis_consultation', |
71 |
|
'pec_metier_consultation' |
72 |
|
); |
73 |
|
|
74 |
|
/** |
75 |
|
* Catégorie de la tâche |
76 |
|
*/ |
77 |
|
var $category = PLATAU; |
78 |
|
|
79 |
|
/** |
80 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
81 |
* |
* |
82 |
* @return void |
* @return void |
154 |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
155 |
|
|
156 |
// récupère l'objet existant |
// récupère l'objet existant |
157 |
$existing = $this->f->findObjectById(get_class($this), $id); |
$existing = $this->f->findObjectById('task', $id); |
158 |
if (! empty($existing)) { |
if (! empty($existing)) { |
159 |
|
|
160 |
// récupère la payload de l'objet |
// récupère la payload de l'objet |
165 |
} |
} |
166 |
} |
} |
167 |
} |
} |
168 |
|
|
169 |
|
if (array_key_exists('category', $val) === false |
170 |
|
|| $this->valF['category'] === '' |
171 |
|
|| $this->valF['category'] === null) { |
172 |
|
// |
173 |
|
$this->valF['category'] = $this->category; |
174 |
|
} |
175 |
|
|
176 |
|
// Si last_modification_time est vide, la valeur est remplacée par NULL |
177 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
178 |
|
if ($val['last_modification_time'] == "") { |
179 |
|
$this->valF['last_modification_time'] = NULL; |
180 |
|
} else { |
181 |
|
$this->valF['last_modification_time'] = $val['last_modification_time']; |
182 |
|
} |
183 |
|
|
184 |
|
// Si creation_time est vide, la valeur est remplacée par NULL |
185 |
|
// pour eviter d'avoir une erreur de base de données car le champ est au format time. |
186 |
|
if ($val['creation_time'] == "") { |
187 |
|
$this->valF['creation_time'] = NULL; |
188 |
|
} else { |
189 |
|
$this->valF['creation_time'] = $val['creation_time']; |
190 |
|
} |
191 |
} |
} |
192 |
|
|
193 |
/** |
/** |
202 |
"object_id", |
"object_id", |
203 |
"dossier", |
"dossier", |
204 |
"stream", |
"stream", |
205 |
|
"creation_date", |
206 |
|
"creation_time", |
207 |
|
"CONCAT_WS(' ', to_char(task.creation_date, 'DD/MM/YYYY'), task.creation_time) AS date_creation", |
208 |
|
'last_modification_date', |
209 |
|
'last_modification_time', |
210 |
|
"CONCAT_WS(' ', to_char(task.last_modification_date, 'DD/MM/YYYY'), task.last_modification_time) AS date_modification", |
211 |
|
"comment", |
212 |
"json_payload", |
"json_payload", |
213 |
"timestamp_log", |
"timestamp_log", |
214 |
|
"timestamp_log AS timestamp_log_hidden", |
215 |
|
"category", |
216 |
); |
); |
217 |
} |
} |
218 |
|
|
222 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
223 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
224 |
|
|
225 |
|
// ALL |
226 |
|
$form->setType("category", "hidden"); |
227 |
|
$form->setType("timestamp_log_hidden", "hidden"); |
228 |
|
|
229 |
// MODE CREER |
// MODE CREER |
230 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
231 |
|
$form->setType("type", "select"); |
232 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
233 |
$form->setType("stream", "select"); |
$form->setType("stream", "select"); |
234 |
$form->setType("json_payload", "textarea"); |
$form->setType("json_payload", "textarea"); |
235 |
} |
} |
236 |
// MDOE MODIFIER |
// MODE MODIFIER |
237 |
if ($maj == 1 || $crud == 'update') { |
if ($maj == 1 || $crud == 'update') { |
238 |
|
$form->setType("task", "hiddenstatic"); |
239 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
240 |
$form->setType("stream", "select"); |
$form->setType("stream", "hiddenstatic"); |
241 |
$form->setType("json_payload", "jsonprettyprint"); |
$form->setType("json_payload", "jsonprettyprint"); |
242 |
|
$form->setType("timestamp_log", "jsontotab"); |
243 |
|
$form->setType("type", "hiddenstatic"); |
244 |
|
$form->setType("creation_date", "hidden"); |
245 |
|
$form->setType("creation_time", "hidden"); |
246 |
|
$form->setType("object_id", "hiddenstatic"); |
247 |
|
$form->setType("dossier", "hiddenstatic"); |
248 |
|
$form->setType("date_creation", "hiddenstatic"); |
249 |
|
$form->setType("last_modification_date", "hidden"); |
250 |
|
$form->setType("last_modification_time", "hidden"); |
251 |
|
$form->setType("date_modification", "static"); |
252 |
} |
} |
253 |
// MODE CONSULTER |
// MODE CONSULTER |
254 |
if ($maj == 3 || $crud == 'read') { |
if ($maj == 3 || $crud == 'read') { |
255 |
|
$form->setType("state", "selecthiddenstatic"); |
256 |
|
$form->setType("stream", "selecthiddenstatic"); |
257 |
$form->setType('dossier', 'link'); |
$form->setType('dossier', 'link'); |
258 |
$form->setType('json_payload', 'jsonprettyprint'); |
$form->setType('json_payload', 'jsonprettyprint'); |
259 |
|
$form->setType("type", "selecthiddenstatic"); |
260 |
|
$form->setType("creation_date", "hidden"); |
261 |
|
$form->setType("creation_time", "hidden"); |
262 |
|
$form->setType("date_creation", "static"); |
263 |
|
$form->setType("last_modification_date", "hidden"); |
264 |
|
$form->setType("last_modification_time", "hidden"); |
265 |
|
$form->setType("date_modification", "static"); |
266 |
|
$form->setType("timestamp_log", "jsontotab"); |
267 |
} |
} |
|
|
|
268 |
} |
} |
269 |
|
|
270 |
|
function stateTranslation ($currentState) { |
271 |
|
switch ($currentState){ |
272 |
|
case "draft": |
273 |
|
return __('brouillon'); |
274 |
|
break; |
275 |
|
case "new": |
276 |
|
return __('à traiter'); |
277 |
|
break; |
278 |
|
case "pending": |
279 |
|
return __('en cours'); |
280 |
|
break; |
281 |
|
case "done": |
282 |
|
return __('terminé'); |
283 |
|
break; |
284 |
|
case "archived": |
285 |
|
return __('archivé'); |
286 |
|
break; |
287 |
|
case "error": |
288 |
|
return __('erreur'); |
289 |
|
break; |
290 |
|
case "debug": |
291 |
|
return __('debug'); |
292 |
|
break; |
293 |
|
case "canceled": |
294 |
|
return __('annulé'); |
295 |
|
break; |
296 |
|
} |
297 |
|
} |
298 |
/** |
/** |
299 |
* |
* |
300 |
*/ |
*/ |
301 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
302 |
if($maj < 2) { |
if($maj <= 3) { |
|
|
|
303 |
$contenu = array(); |
$contenu = array(); |
304 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
305 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
306 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
307 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
308 |
$contenu[1][] = __($const_value); |
|
309 |
|
|
310 |
|
$contenu[1][] = $this->stateTranslation($const_value); |
311 |
|
|
312 |
} |
} |
313 |
|
|
314 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
315 |
|
|
316 |
$contenu_stream =array(); |
$contenu_stream =array(); |
317 |
$contenu_stream[0][0]="input"; |
$contenu_stream[0][0]="input"; |
318 |
$contenu_stream[1][0]=_('input'); |
$contenu_stream[1][0]=__('input'); |
319 |
$contenu_stream[0][1]="output"; |
$contenu_stream[0][1]="output"; |
320 |
$contenu_stream[1][1]=_('output'); |
$contenu_stream[1][1]=__('output'); |
321 |
$form->setSelect("stream", $contenu_stream); |
$form->setSelect("stream", $contenu_stream); |
322 |
|
|
323 |
|
$tab_type = array_unique(array_merge(self::TASK_TYPE_SI, self::TASK_TYPE_SC)); |
324 |
|
|
325 |
|
foreach ($tab_type as $type) { |
326 |
|
|
327 |
|
$contenu_type[0][] = $type; |
328 |
|
|
329 |
|
switch ($type) { |
330 |
|
case "creation_DA": |
331 |
|
$value_type = __('Création DA'); |
332 |
|
break; |
333 |
|
case "create_DI": |
334 |
|
$value_type = __('Création demande'); |
335 |
|
break; |
336 |
|
case "creation_DI": |
337 |
|
$value_type = __('Création DI'); |
338 |
|
break; |
339 |
|
case "modification_DA": |
340 |
|
$value_type = __('Modification DA'); |
341 |
|
break; |
342 |
|
case "modification_DI": |
343 |
|
$value_type = __('Modification DI'); |
344 |
|
break; |
345 |
|
case "ajout_piece": |
346 |
|
$value_type = __('Ajout pièce (sortant)'); |
347 |
|
break; |
348 |
|
case "add_piece": |
349 |
|
$value_type = __('Ajout pièce (entrant)'); |
350 |
|
break; |
351 |
|
case "depot_DI": |
352 |
|
$value_type = __('Dépôt DI'); |
353 |
|
break; |
354 |
|
case "qualification_DI": |
355 |
|
$value_type = __('Qualification DI'); |
356 |
|
break; |
357 |
|
case "creation_consultation": |
358 |
|
$value_type = __('Création consultation'); |
359 |
|
break; |
360 |
|
case "decision_DI": |
361 |
|
$value_type = __('Décision DI'); |
362 |
|
break; |
363 |
|
case "envoi_CL": |
364 |
|
$value_type = __('Envoi contrôle de légalité'); |
365 |
|
break; |
366 |
|
case "pec_metier_consultation": |
367 |
|
$value_type = __('PeC consultation'); |
368 |
|
break; |
369 |
|
case "avis_consultation": |
370 |
|
$value_type = __('Avis'); |
371 |
|
break; |
372 |
|
case "prescription": |
373 |
|
$value_type = __('Prescription'); |
374 |
|
break; |
375 |
|
case "create_DI_for_consultation": |
376 |
|
$value_type = __('Création DI pour consultation'); |
377 |
|
break; |
378 |
|
case "create_message": |
379 |
|
$value_type = __('Message'); |
380 |
|
break; |
381 |
|
case "notification_recepisse": |
382 |
|
$value_type = __('Notification récépissé'); |
383 |
|
break; |
384 |
|
case "notification_instruction": |
385 |
|
$value_type = __('Notification instruction'); |
386 |
|
break; |
387 |
|
case "notification_decision": |
388 |
|
$value_type = __('Notification décision'); |
389 |
|
break; |
390 |
|
case "notification_service_consulte": |
391 |
|
$value_type = __('Notification service consulté'); |
392 |
|
break; |
393 |
|
case "notification_tiers_consulte": |
394 |
|
$value_type = __('Notification tiers consulté'); |
395 |
|
break; |
396 |
|
case "notification_signataire": |
397 |
|
$value_type = __('Notification signataire'); |
398 |
|
break; |
399 |
|
case "completude_DI": |
400 |
|
$value_type = __('complétude DI'); |
401 |
|
break; |
402 |
|
case "incompletude_DI": |
403 |
|
$value_type = __('incomplétude DI'); |
404 |
|
break; |
405 |
|
case "lettre_incompletude": |
406 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
407 |
|
break; |
408 |
|
case "lettre_majoration": |
409 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
410 |
|
break; |
411 |
|
} |
412 |
|
|
413 |
|
$contenu_type[1][] = $value_type; |
414 |
|
} |
415 |
|
|
416 |
|
$form->setselect('type', $contenu_type); |
417 |
} |
} |
418 |
|
|
419 |
if ($maj == 3) { |
if ($maj == 3) { |
420 |
if ($this->getVal('stream') == 'output') { |
// Récupération du numéro du dossier si il n'est pas renseigné dans la tâche |
421 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
if ($form->val['dossier'] == '' || $form->val['dossier'] == null) { |
422 |
"obj" => "dossier", |
// Récupération de la payload de la taĉhe. |
423 |
"idx" => $form->val['dossier'], |
// Si la tâche est une tâche input la payload est associée à la tâche. |
424 |
)); |
// Si la tâche est une tâche en output la payload est "calculé" à l'ouverture |
425 |
|
// du formulaire. |
426 |
|
if ($this->getVal('stream') == 'input') { |
427 |
|
$json_payload = json_decode($this->getVal('json_payload'), true); |
428 |
|
} else { |
429 |
|
$json_payload = json_decode($form->val['json_payload'], true); |
430 |
|
} |
431 |
|
// A partir de la payload de la tâche ont récupère les externals uid |
432 |
|
// Si un external uid de DI (dossier) existe ont le récupère et on stocke le numéro |
433 |
|
// pour l'afficher sur le formulaire. |
434 |
|
// Si l'external UID du DI n'existe pas on récupère celui du DA |
435 |
|
$external_uid = ''; |
436 |
|
if (array_key_exists('external_uids', $json_payload) |
437 |
|
&& array_key_exists('dossier', $json_payload['external_uids']) |
438 |
|
) { |
439 |
|
$external_uid = $json_payload['external_uids']['dossier']; |
440 |
|
} elseif (array_key_exists('external_uids', $json_payload) |
441 |
|
&& array_key_exists('demande', $json_payload['external_uids'])) { |
442 |
|
$external_uid = $json_payload['external_uids']['demande']; |
443 |
|
} |
444 |
|
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
445 |
|
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
446 |
|
// du formulaire pour pouvoir l'afficher |
447 |
|
if ($external_uid != '') { |
448 |
|
$qres = $this->f->get_one_result_from_db_query( |
449 |
|
sprintf( |
450 |
|
'SELECT |
451 |
|
lien_id_interne_uid_externe.dossier |
452 |
|
FROM |
453 |
|
%1$slien_id_interne_uid_externe |
454 |
|
WHERE |
455 |
|
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
456 |
|
DB_PREFIXE, |
457 |
|
$this->f->db->escapeSimple($external_uid) |
458 |
|
), |
459 |
|
array( |
460 |
|
"origin" => __METHOD__, |
461 |
|
) |
462 |
|
); |
463 |
|
if (! empty($qres["result"])) { |
464 |
|
$form->val['dossier'] = $qres["result"]; |
465 |
|
} |
466 |
|
} |
467 |
|
} |
468 |
|
|
469 |
if($form->val['type'] == "creation_DA" |
// Vérifie si le numéro de dossier associé à la tâche existe dans la base. |
470 |
|| $form->val['type'] == "modification_DA"){ |
// Si c'est le cas ce numéro sera lié au dossier (DI ou DA) correspondant |
471 |
// |
// TODO : vérifier la liste des tâches lié à des DA |
472 |
|
$obj_link = ''; |
473 |
|
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
474 |
|
// Vérification que le numéro de DA affiché dans le formulaire existe |
475 |
|
$qres = $this->f->get_one_result_from_db_query( |
476 |
|
sprintf( |
477 |
|
'SELECT |
478 |
|
dossier_autorisation.dossier_autorisation |
479 |
|
FROM |
480 |
|
%1$sdossier_autorisation |
481 |
|
WHERE |
482 |
|
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
483 |
|
DB_PREFIXE, |
484 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
485 |
|
), |
486 |
|
array( |
487 |
|
"origin" => __METHOD__, |
488 |
|
) |
489 |
|
); |
490 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
491 |
|
if (! empty($qres["result"])) { |
492 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
493 |
} else { |
} |
494 |
|
} else { |
495 |
|
// Vérification que le numéro de DI affiché dans le formulaire existe |
496 |
|
$qres = $this->f->get_one_result_from_db_query( |
497 |
|
sprintf( |
498 |
|
'SELECT |
499 |
|
dossier.dossier |
500 |
|
FROM |
501 |
|
%1$sdossier |
502 |
|
WHERE |
503 |
|
dossier.dossier = \'%2$s\'', |
504 |
|
DB_PREFIXE, |
505 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
506 |
|
), |
507 |
|
array( |
508 |
|
"origin" => __METHOD__, |
509 |
|
) |
510 |
|
); |
511 |
|
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
512 |
|
if (! empty($qres["result"])) { |
513 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
514 |
} |
} |
|
|
|
|
$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); |
|
515 |
} |
} |
516 |
|
// Pour afficher le lien vers un dossier ont utilise un champ de type "link". |
517 |
|
// Pour paramétrer ce champs on a besoin de savoir : |
518 |
|
// - quel objet est visé par le lien |
519 |
|
// - le label (libellé) du lien |
520 |
|
// - l'identifiant de l'objet qui sera utilisé dans le lien |
521 |
|
// - le titre associé au lien |
522 |
|
// Pour cela on remplit le champs comme un select et les valeurs du select |
523 |
|
// contiennent les informations nécessaire à l'affichage du champs. |
524 |
|
$params = array( |
525 |
|
'obj' => $obj_link, |
526 |
|
'libelle' => $form->val['dossier'], |
527 |
|
'title' => "Consulter le dossier", |
528 |
|
'idx' => $form->val['dossier'] |
529 |
|
); |
530 |
|
$form->setSelect("dossier", $params); |
531 |
} |
} |
532 |
} |
} |
533 |
|
|
539 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
540 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
541 |
// |
// |
542 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
543 |
|
&& ($this->getVal('state') !== self::STATUS_DONE |
544 |
|
|| $this->getVal('json_payload') === "{}")) { |
545 |
|
// |
546 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
547 |
} else { |
} else { |
548 |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
549 |
|
} |
550 |
|
// Gestion du contenu de l'historique |
551 |
|
if ($this->getVal('timestamp_log') !== '' |
552 |
|
&& $this->getVal('timestamp_log') !== null) { |
553 |
|
// |
554 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
555 |
} |
} |
556 |
} |
} |
557 |
|
|
561 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
562 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
563 |
|
|
564 |
|
$form->setLib('date_creation', __("Date de création")); |
565 |
|
$form->setLib('date_modification', __("Date de dernière modification")); |
566 |
|
$form->setLib('comment', __("commentaire")); |
567 |
|
|
568 |
// MODE different de CREER |
// MODE different de CREER |
569 |
if ($maj != 0 || $crud != 'create') { |
if ($maj != 0 || $crud != 'create') { |
570 |
$form->setLib('json_payload', ''); |
$form->setLib('json_payload', ''); |
571 |
|
$form->setLib("task", __("identifiant")); |
572 |
|
$form->setLib("Task_portal", __("task_portal")); |
573 |
|
$form->setLib("type", __("type")); |
574 |
|
$form->setLib("object_id", __("Réf. interne")); |
575 |
|
$form->setLib("stream", __("flux")); |
576 |
|
$form->setLib("timestamp_log", __("Historique")); |
577 |
} |
} |
578 |
} |
} |
579 |
|
|
633 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
634 |
|
|
635 |
// décode la payload JSON |
// décode la payload JSON |
636 |
|
// TODO : COMMENTER |
637 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
638 |
|
|
639 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
640 |
$paths = array( |
$paths = array(); |
641 |
'external_uids/dossier' |
if ($this->valF['category'] === PLATAU) { |
642 |
); |
$paths = array( |
643 |
|
'external_uids/dossier' |
644 |
|
); |
645 |
|
} |
646 |
|
|
647 |
// tâche de type création de DI/DA |
// tâche de type création de DI/DA |
648 |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
715 |
* @param bool $is_not_done [description] |
* @param bool $is_not_done [description] |
716 |
* @return [type] [description] |
* @return [type] [description] |
717 |
*/ |
*/ |
718 |
public function task_exists(string $type, string $object_id, bool $is_not_done = true) { |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
719 |
|
$qres = $this->f->get_one_result_from_db_query( |
720 |
|
sprintf( |
721 |
|
'SELECT |
722 |
|
task |
723 |
|
FROM |
724 |
|
%1$stask |
725 |
|
WHERE |
726 |
|
%2$s |
727 |
|
type = \'%3$s\' |
728 |
|
AND ( |
729 |
|
object_id = \'%4$s\' |
730 |
|
%5$s |
731 |
|
) |
732 |
|
AND state != \'%6$s\'', |
733 |
|
DB_PREFIXE, |
734 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
735 |
|
$type, |
736 |
|
$object_id, |
737 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
738 |
|
self::STATUS_CANCELED |
739 |
|
), |
740 |
|
array( |
741 |
|
"origin" => __METHOD__, |
742 |
|
) |
743 |
|
); |
744 |
|
if ($qres["result"] !== null && $qres["result"] !== "") { |
745 |
|
return $qres["result"]; |
746 |
|
} |
747 |
|
return false; |
748 |
|
} |
749 |
|
|
750 |
|
/** |
751 |
|
* Permet la recherche multi-critères des tasks. |
752 |
|
* |
753 |
|
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
754 |
|
* @return mixed Retourne le résultat de la requête ou false |
755 |
|
*/ |
756 |
|
public function task_exists_multi_search(array $search_values) { |
757 |
$query = sprintf(' |
$query = sprintf(' |
758 |
SELECT task |
SELECT * |
759 |
FROM %1$stask |
FROM %1$stask |
760 |
WHERE %2$s |
%2$s |
761 |
type = \'%3$s\' |
%3$s |
762 |
AND object_id = \'%4$s\' |
ORDER BY task ASC |
763 |
', |
', |
764 |
DB_PREFIXE, |
DB_PREFIXE, |
765 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
766 |
$type, |
implode(' AND ', $search_values) |
767 |
$object_id |
); |
768 |
|
$res = $this->f->get_all_results_from_db_query( |
769 |
|
$query, |
770 |
|
array( |
771 |
|
"origin" => __METHOD__, |
772 |
|
) |
773 |
); |
); |
774 |
$res = $this->f->get_one_result_from_db_query($query); |
if (count($res['result']) > 0) { |
|
if ($res['result'] !== null && $res['result'] !== '') { |
|
775 |
return $res['result']; |
return $res['result']; |
776 |
} |
} |
777 |
return false; |
return false; |
802 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
803 |
} |
} |
804 |
} |
} |
805 |
|
|
806 |
|
// gestion d'une tache de type notification et de category mail |
807 |
|
if (isset($val['type']) |
808 |
|
&& (($val['type'] === 'notification_instruction' || $val['type'] === 'notification_decision') |
809 |
|
&& isset($val['category']) |
810 |
|
&& $val['category'] === 'mail') |
811 |
|
|| $val['type'] === 'notification_service_consulte' |
812 |
|
|| $val['type'] === 'notification_tiers_consulte' |
813 |
|
|| $val['type'] === 'notification_depot_demat' |
814 |
|
|| $val['type'] === 'notification_commune' |
815 |
|
|| $val['type'] === 'notification_signataire' |
816 |
|
) { |
817 |
|
// Récupère la payload de la tache |
818 |
|
$data = array(); |
819 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
820 |
|
$this->valF['category'], |
821 |
|
'with-id', |
822 |
|
array('with-id' => $this->valF['object_id']) |
823 |
|
); |
824 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
825 |
|
|
826 |
|
// Récupère l'instance de la notification |
827 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
828 |
|
"obj" => "instruction_notification", |
829 |
|
"idx" => $val['object_id'], |
830 |
|
)); |
831 |
|
// Envoi le mail et met à jour le suivi |
832 |
|
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
833 |
|
// Passage de la tache à done si elle a réussi et à error |
834 |
|
// si l'envoi a échoué |
835 |
|
$this->valF['state'] = 'done'; |
836 |
|
if ($envoiMail === false) { |
837 |
|
$this->valF['state'] = 'error'; |
838 |
|
} |
839 |
|
} |
840 |
|
} |
841 |
|
|
842 |
|
/** |
843 |
|
* TRIGGER - triggermodifier. |
844 |
|
* |
845 |
|
* @param string $id |
846 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
847 |
|
* @param array $val Tableau des valeurs brutes. |
848 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
849 |
|
* |
850 |
|
* @return boolean |
851 |
|
*/ |
852 |
|
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
853 |
|
parent::triggermodifier($id, $dnu1, $val, $dnu2); |
854 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
855 |
|
|
856 |
|
// Mise à jour des valeurs, notamment du timestamp_log en fonction de plusieurs critères |
857 |
|
$values = array( |
858 |
|
'state' => $this->valF['state'], |
859 |
|
'object_id' => $this->valF['object_id'], |
860 |
|
'comment' => $this->valF['comment'], |
861 |
|
); |
862 |
|
$new_values = $this->set_values_for_update($values); |
863 |
|
if ($new_values === false) { |
864 |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
865 |
|
return false; |
866 |
|
} |
867 |
|
|
868 |
|
// Mise à jour des valeurs |
869 |
|
$this->valF['timestamp_log'] = $new_values['timestamp_log']; |
870 |
|
$this->valF['state'] = $new_values['state']; |
871 |
|
$this->valF['object_id'] = $new_values['object_id']; |
872 |
|
$this->valF['last_modification_date'] = date('Y-m-d'); |
873 |
|
$this->valF['last_modification_time'] = date('H:i:s'); |
874 |
|
if ($val['stream'] === 'output') { |
875 |
|
// Lorsque la task passe d'un état qui n'est pas "done" à l'état "done" |
876 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
877 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
878 |
|
// |
879 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
880 |
|
} |
881 |
|
// Lorsque la task passe d'un état "done" à un état qui n'est pas "done" |
882 |
|
if ($this->getVal("state") === self::STATUS_DONE |
883 |
|
&& $this->valF['state'] !== self::STATUS_DONE) { |
884 |
|
// |
885 |
|
$this->valF['json_payload'] = "{}"; |
886 |
|
} |
887 |
|
} |
888 |
|
|
889 |
|
return true; |
890 |
|
} |
891 |
|
|
892 |
|
|
893 |
|
/** |
894 |
|
* Applique nouvelle valeur après traitement. |
895 |
|
* |
896 |
|
* @param array $params Tableau des valeurs en entrées |
897 |
|
* @return array Tableau des valeurs en sorties |
898 |
|
*/ |
899 |
|
public function set_values_for_update($params = array()) { |
900 |
|
|
901 |
|
// Récupération du timestamp_log existant |
902 |
|
$timestamp_log = $this->get_timestamp_log(); |
903 |
|
if ($timestamp_log === false) { |
904 |
|
return false; |
905 |
|
} |
906 |
|
|
907 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
908 |
|
// l'état CANCELED sur la tâche |
909 |
|
if (isset($params['state']) === true |
910 |
|
&& $params['state'] === self::STATUS_CANCELED) { |
911 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
912 |
|
// trié par ordre décroissant |
913 |
|
$log = $timestamp_log; |
914 |
|
krsort($log); |
915 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
916 |
|
// - vérification de la présence de l'object_id précédent |
917 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
918 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
919 |
|
// - le state n'est pas modifié |
920 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
921 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
922 |
|
foreach ($log as $key => $value) { |
923 |
|
// |
924 |
|
if (isset($value['prev_object_id']) === true |
925 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
926 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
927 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
928 |
|
foreach ($tables as $table) { |
929 |
|
// Vérifie s'il y a un ou aucun résultat |
930 |
|
$qres = $this->f->get_one_result_from_db_query( |
931 |
|
sprintf( |
932 |
|
'SELECT |
933 |
|
COUNT(%2$s) |
934 |
|
FROM |
935 |
|
%1$s%2$s |
936 |
|
WHERE |
937 |
|
%2$s::CHARACTER VARYING = \'%3$s\'', |
938 |
|
DB_PREFIXE, |
939 |
|
$table, |
940 |
|
$value['prev_object_id'] |
941 |
|
), |
942 |
|
array( |
943 |
|
"origin" => __METHOD__, |
944 |
|
"force_return" => true, |
945 |
|
) |
946 |
|
); |
947 |
|
if ($qres["code"] !== "OK") { |
948 |
|
return $this->end_treatment(__METHOD__, false); |
949 |
|
} |
950 |
|
// Affectation des valeurs et sortie de la boucle |
951 |
|
if ($qres["result"] == '1') { |
952 |
|
$params['object_id'] = $value['prev_object_id']; |
953 |
|
$params['state'] = $this->getVal('state'); |
954 |
|
break; |
955 |
|
} |
956 |
|
} |
957 |
|
// Sortie de la boucle si les valeurs sont affectées |
958 |
|
if ($params['object_id'] !== null |
959 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
960 |
|
// |
961 |
|
break; |
962 |
|
} |
963 |
|
} |
964 |
|
} |
965 |
|
} |
966 |
|
|
967 |
|
// Mise à jour du journal d'activité de la tâche |
968 |
|
array_push($timestamp_log, array( |
969 |
|
'modification_date' => date('Y-m-d H:i:s'), |
970 |
|
'object_id' => $params['object_id'] !== null ? $params['object_id'] : $this->getVal('object_id'), |
971 |
|
'prev_object_id' => $this->getVal('object_id'), |
972 |
|
'state' => $params['state'], |
973 |
|
'prev_state' => $this->getVal('state'), |
974 |
|
'comment' => isset($params['comment']) ? $params['comment'] : $this->getVal('comment'), |
975 |
|
)); |
976 |
|
// |
977 |
|
$timestamp_log = json_encode($timestamp_log); |
978 |
|
|
979 |
|
|
980 |
|
// Les nouvelles valeurs après vérification des critères |
981 |
|
$result = array( |
982 |
|
'timestamp_log' => $timestamp_log, |
983 |
|
'object_id' => $params['object_id'], |
984 |
|
'state' => $params['state'], |
985 |
|
'comment' => $params['comment'], |
986 |
|
); |
987 |
|
return $result; |
988 |
|
} |
989 |
|
|
990 |
|
|
991 |
|
/** |
992 |
|
* TRIGGER - triggermodifierapres. |
993 |
|
* |
994 |
|
* @param string $id |
995 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
996 |
|
* @param array $val Tableau des valeurs brutes. |
997 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
998 |
|
* |
999 |
|
* @return boolean |
1000 |
|
*/ |
1001 |
|
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1002 |
|
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
1003 |
|
|
1004 |
|
// Suivi des notificiations |
1005 |
|
// En cas de changement de l'état de la tâche de notification, alors |
1006 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
1007 |
|
if (isset($val['category']) === true |
1008 |
|
&& $val['category'] === PORTAL |
1009 |
|
&& isset($val['type']) === true |
1010 |
|
&& ($val['type'] === 'notification_recepisse' |
1011 |
|
|| $val['type'] === 'notification_instruction' |
1012 |
|
|| $val['type'] === 'notification_decision' |
1013 |
|
|| $val['type'] === 'notification_service_consulte' |
1014 |
|
|| $val['type'] === 'notification_tiers_consulte')) { |
1015 |
|
// |
1016 |
|
if (isset($this->valF['state']) === true |
1017 |
|
&& $this->valF['state'] !== $this->getVal('state') |
1018 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
1019 |
|
// |
1020 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1021 |
|
"obj" => "instruction_notification", |
1022 |
|
"idx" => $val['object_id'], |
1023 |
|
)); |
1024 |
|
$valF_in = array(); |
1025 |
|
foreach ($inst_in->champs as $champ) { |
1026 |
|
$valF_in[$champ] = $inst_in->getVal($champ); |
1027 |
|
} |
1028 |
|
// Par défaut la date d'envoi et la date de premier accès sur |
1029 |
|
// la notification ne sont pas renseignées |
1030 |
|
$valF_in['date_envoi'] = null; |
1031 |
|
$valF_in['date_premier_acces'] = null; |
1032 |
|
// Lorsque la tâche est correctement traitée |
1033 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
1034 |
|
// |
1035 |
|
$valF_in['statut'] = __("envoyé"); |
1036 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
1037 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
1038 |
|
// Si l'instruction possède un document lié, alors ses dates |
1039 |
|
// de suivi sont mises à jour |
1040 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1041 |
|
"obj" => "instruction", |
1042 |
|
"idx" => $inst_in->getVal('instruction'), |
1043 |
|
)); |
1044 |
|
if ($inst_instruction->has_an_edition() === true) { |
1045 |
|
$valF_instruction = array(); |
1046 |
|
foreach ($inst_instruction->champs as $champ) { |
1047 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1048 |
|
} |
1049 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1050 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
1051 |
|
// Action spécifique pour identifier que la modification |
1052 |
|
// est une notification de demandeur |
1053 |
|
$inst_instruction->setParameter('maj', 175); |
1054 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1055 |
|
if ($update_instruction === false) { |
1056 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1057 |
|
return false; |
1058 |
|
} |
1059 |
|
} |
1060 |
|
} |
1061 |
|
// En cas d'erreur lors du traitement de la task |
1062 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
1063 |
|
$valF_in['statut'] = __("échec"); |
1064 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
1065 |
|
} |
1066 |
|
// Met à jour la notification |
1067 |
|
$inst_in->setParameter('maj', 1); |
1068 |
|
$update_in = $inst_in->modifier($valF_in); |
1069 |
|
if ($update_in === false) { |
1070 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
1071 |
|
return false; |
1072 |
|
} |
1073 |
|
} |
1074 |
|
} |
1075 |
|
|
1076 |
|
// Envoi au contrôle de légalité |
1077 |
|
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
1078 |
|
// des dates de l'instruction est effectué |
1079 |
|
if ($val['type'] === 'envoi_CL' |
1080 |
|
&& isset($this->valF['state']) === true |
1081 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
1082 |
|
// |
1083 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1084 |
|
"obj" => "instruction", |
1085 |
|
"idx" => $this->getVal('object_id'), |
1086 |
|
)); |
1087 |
|
if ($inst_instruction->has_an_edition() === true) { |
1088 |
|
$valF_instruction = array(); |
1089 |
|
foreach ($inst_instruction->champs as $champ) { |
1090 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
1091 |
|
} |
1092 |
|
} |
1093 |
|
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
1094 |
|
$inst_instruction->setParameter('maj', 1); |
1095 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1096 |
|
if ($update_instruction === false) { |
1097 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1098 |
|
return false; |
1099 |
|
} |
1100 |
|
} |
1101 |
|
|
1102 |
|
// |
1103 |
|
return true; |
1104 |
} |
} |
1105 |
|
|
1106 |
/** |
/** |
1133 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
1134 |
} |
} |
1135 |
|
|
1136 |
$timestamp_log = json_encode(array( |
// |
1137 |
'creation_date' => date('Y-m-d H:i:s'), |
$timestamp_log = json_encode(array()); |
1138 |
)); |
|
1139 |
|
// |
1140 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
1141 |
|
|
1142 |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
1143 |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
1144 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
1145 |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
&& in_array($params['val']['type'], self::TASK_WITH_DOCUMENT) |
1146 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
1147 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
1148 |
// |
// |
1151 |
$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.")); |
1152 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
1153 |
} |
} |
1154 |
if (isset($json_payload['document_numerise']) === true |
if (isset($json_payload['document_numerise']["file_content"]) === true |
1155 |
&& empty($json_payload['document_numerise']) === false) { |
&& empty($json_payload['document_numerise']["file_content"]) === false) { |
1156 |
// |
// |
1157 |
$document_numerise = $json_payload['document_numerise']; |
$document_numerise = $json_payload['document_numerise']; |
1158 |
$file_content = base64_decode($document_numerise["file_content"]); |
$file_content = base64_decode($document_numerise["file_content"]); |
1178 |
} |
} |
1179 |
} |
} |
1180 |
|
|
1181 |
// Mise à jour du DI |
// Valeurs de la tâche |
1182 |
$valF = array( |
$valF = array( |
1183 |
'task' => '', |
'task' => '', |
1184 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1188 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
1189 |
'stream' => $stream, |
'stream' => $stream, |
1190 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
1191 |
|
'category' => $category, |
1192 |
|
'creation_date' => date('Y-m-d'), |
1193 |
|
'creation_time' => date('H:i:s'), |
1194 |
|
'last_modification_date' => null, |
1195 |
|
'last_modification_time' => null, |
1196 |
|
'comment' => null, |
1197 |
|
); |
1198 |
|
|
1199 |
|
// Gestion de la mise à jour des tâches sortantes |
1200 |
|
$typeNonConcerne = array( |
1201 |
|
'notification_recepisse', |
1202 |
|
'notification_instruction', |
1203 |
|
'notification_decision', |
1204 |
|
'notification_service_consulte', |
1205 |
|
'notification_tiers_consulte', |
1206 |
|
'notification_signataire' |
1207 |
); |
); |
1208 |
|
if ($valF["stream"] == "output" |
1209 |
|
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1210 |
|
// Vérification de l'existance d'une tâche pour l'objet concerné |
1211 |
|
// La vérification diffère en fonction de certains types de tâche |
1212 |
|
$search_values_common = array( |
1213 |
|
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1214 |
|
sprintf('state != \'%s\'', self::STATUS_DONE), |
1215 |
|
); |
1216 |
|
$search_values_others = array( |
1217 |
|
sprintf('type = \'%s\'', $valF['type']), |
1218 |
|
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1219 |
|
); |
1220 |
|
$search_values_specifics = array( |
1221 |
|
sprintf('object_id = \'%s\'', $valF['object_id']), |
1222 |
|
); |
1223 |
|
|
1224 |
// tâche sortante |
// Recherche multi-critères sur les tâches |
1225 |
if($valF["stream"] == "output"){ |
// Si l'object id/dossier à des tâches de type $valF['type'] qui lui est associé |
1226 |
|
// Et que ces tâches ont des statut différents de canceled et done |
1227 |
|
// Alors on récupère ces tâches |
1228 |
|
// Sinon return false |
1229 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1230 |
|
|
1231 |
// TODO expliquer ce code |
// S'il n'existe pas de tâche de type 'modification DI' pour l'object id/dossier |
|
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
1232 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1233 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DI' de l'object id |
1234 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DI'"))); |
1235 |
} |
} |
1236 |
|
// S'il n'existe pas de tâche de type 'modification DA' pour l'object id/dossier |
1237 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
1238 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DA' de l'object id |
1239 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DA'"))); |
1240 |
} |
} |
1241 |
|
if ($valF['type'] === 'ajout_piece') { |
1242 |
|
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1243 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'ajout_piece'"))); |
1244 |
|
} |
1245 |
|
if ($valF['type'] === 'creation_consultation') { |
1246 |
|
// On se réfère à la tâche de type 'creation consultation' de l'object id |
1247 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_consultation'"))); |
1248 |
|
} |
1249 |
|
// S'il existe une tâche pour l'objet concerné, pas d'ajout de nouvelle |
1250 |
|
// tâche mais mise à jour de l'existante |
1251 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1252 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1253 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1254 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1255 |
)); |
"obj" => "task", |
1256 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1257 |
if (isset($params['update_val']['state']) === true) { |
)); |
1258 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1259 |
} |
if (isset($params['update_val']['state']) === true) { |
1260 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1261 |
'val' => array( |
} |
1262 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1263 |
), |
if (!empty($valF['object_id'])) { |
1264 |
); |
$object_id = $valF['object_id']; |
1265 |
return $inst_task->update_task($update_params); |
} |
1266 |
|
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1267 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1268 |
|
&& $update_state === self::STATUS_PENDING |
1269 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1270 |
|
if ($task_pending === false) { |
1271 |
|
$update_params = array( |
1272 |
|
'val' => array( |
1273 |
|
'state' => $update_state, |
1274 |
|
), |
1275 |
|
'object_id' => $object_id, |
1276 |
|
); |
1277 |
|
return $inst_task->update_task($update_params); |
1278 |
|
} |
1279 |
|
} |
1280 |
} |
} |
1281 |
} |
} |
|
|
|
1282 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1283 |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
1284 |
if ($add === false) { |
if ($add === false) { |
1297 |
*/ |
*/ |
1298 |
public function update_task($params = array()) { |
public function update_task($params = array()) { |
1299 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
1300 |
$timestamp_log = $this->get_timestamp_log(); |
|
1301 |
if ($timestamp_log === false) { |
// Mise à jour de la tâche |
|
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
array_push($timestamp_log, array( |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
|
|
'state' => $params['val']['state'], |
|
|
'prev_state' => $this->getVal('state'), |
|
|
)); |
|
|
$timestamp_log = json_encode($timestamp_log); |
|
1302 |
$valF = array( |
$valF = array( |
1303 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
1304 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
1305 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => '[]', |
1306 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
1307 |
'object_id' => isset($params['object_id']) == true && $this->getVal('type') == 'create_DI' ? $params['object_id'] : $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
1308 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
1309 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
1310 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
1311 |
|
'category' => $this->getVal('category'), |
1312 |
|
'creation_date' => $this->getVal('creation_date'), |
1313 |
|
'creation_time' => $this->getVal('creation_time'), |
1314 |
|
'last_modification_date' => date('Y-m-d'), |
1315 |
|
'last_modification_time' => date('H:i:s'), |
1316 |
|
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1317 |
); |
); |
1318 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1319 |
if ($update === false) { |
if ($update === false) { |
1362 |
|
|
1363 |
protected function view_tab_json() { |
protected function view_tab_json() { |
1364 |
$where = ''; |
$where = ''; |
1365 |
if ($this->f->get_submitted_get_value('state') !== null |
$category = null; |
1366 |
&& $this->f->get_submitted_get_value('state') !== '') { |
// Liste des paramètres possibles pour la recherche des tâches |
1367 |
// |
$params = array( |
1368 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
'task', |
1369 |
|
'type', |
1370 |
|
'state', |
1371 |
|
'object_id', |
1372 |
|
'dossier', |
1373 |
|
'stream', |
1374 |
|
'category', |
1375 |
|
'lien_id_interne_uid_externe', |
1376 |
|
'object', |
1377 |
|
'external_uid', |
1378 |
|
); |
1379 |
|
// Pour chaque paramètre possible, vérification de son existance et de sa |
1380 |
|
// valeur pour compléter la requête de recherche |
1381 |
|
foreach ($params as $param) { |
1382 |
|
// |
1383 |
|
if ($this->f->get_submitted_get_value($param) !== null |
1384 |
|
&& $this->f->get_submitted_get_value($param) !== '') { |
1385 |
|
// Condition spécifique au champ 'category' |
1386 |
|
if ($param === 'category') { |
1387 |
|
$category = $this->f->get_submitted_get_value('category'); |
1388 |
|
} |
1389 |
|
// |
1390 |
|
$where_or_and = 'WHERE'; |
1391 |
|
if ($where !== '') { |
1392 |
|
$where_or_and = 'AND'; |
1393 |
|
} |
1394 |
|
$table = 'task'; |
1395 |
|
if ($param === 'lien_id_interne_uid_externe' |
1396 |
|
|| $param === 'object' |
1397 |
|
|| $param === 'external_uid') { |
1398 |
|
// |
1399 |
|
$table = 'lien_id_interne_uid_externe'; |
1400 |
|
} |
1401 |
|
$where .= sprintf(' %s %s.%s = \'%s\' ', $where_or_and, $table, $param, $this->f->get_submitted_get_value($param)); |
1402 |
|
} |
1403 |
} |
} |
1404 |
|
// |
1405 |
$query = sprintf(' |
$query = sprintf(' |
1406 |
SELECT |
SELECT |
1407 |
* |
task.* |
1408 |
FROM %1$stask |
FROM %1$stask |
1409 |
|
LEFT JOIN %1$slien_id_interne_uid_externe |
1410 |
|
ON task.object_id = lien_id_interne_uid_externe.object_id |
1411 |
|
AND task.category = lien_id_interne_uid_externe.category |
1412 |
%2$s |
%2$s |
1413 |
ORDER BY task ASC |
ORDER BY task ASC |
1414 |
', |
', |
1415 |
DB_PREFIXE, |
DB_PREFIXE, |
1416 |
$where |
$where |
1417 |
); |
); |
1418 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1419 |
|
$query, |
1420 |
|
array( |
1421 |
|
"origin" => __METHOD__, |
1422 |
|
"force_return" => true, |
1423 |
|
) |
1424 |
|
); |
1425 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1426 |
return false; |
return false; |
1427 |
} |
} |
1428 |
$list_tasks = array(); |
$list_tasks = array(); |
1429 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
1430 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
unset($task['timestamp_log']); |
1431 |
$task['dossier'] = $task['dossier']; |
unset($task['json_payload']); |
1432 |
if ($task['type'] === 'ajout_piece') { |
if ($task['type'] === 'ajout_piece') { |
1433 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
1434 |
} |
} |
1435 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
1436 |
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
$task['external_uids'] = array_merge( |
1437 |
|
$this->get_all_external_uids($task['dossier'], array(), $category !== null ? $category : $task['category']), |
1438 |
|
$this->get_all_external_uids($task['object_id'], array(), $category !== null ? $category : $task['category']) |
1439 |
|
); |
1440 |
} |
} |
1441 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
1442 |
} |
} |
1443 |
printf(json_encode($list_tasks)); |
echo(json_encode($list_tasks)); |
1444 |
} |
} |
1445 |
|
|
1446 |
protected function get_dossier_data(string $dossier) { |
protected function get_dossier_data(string $dossier) { |
1449 |
"obj" => "dossier", |
"obj" => "dossier", |
1450 |
"idx" => $dossier, |
"idx" => $dossier, |
1451 |
)); |
)); |
1452 |
|
if (empty($inst_di->val) === true) { |
1453 |
|
return $val_di; |
1454 |
|
} |
1455 |
$val_di = $inst_di->get_json_data(); |
$val_di = $inst_di->get_json_data(); |
1456 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
1457 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1542 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1543 |
&& $val_dt['tax_ext_pret'] === 'f') { |
&& $val_dt['tax_ext_pret'] === 'f') { |
1544 |
// |
// |
1545 |
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf1'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1546 |
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat1'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1547 |
} |
} |
1548 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1549 |
&& $val_dt['tax_ext_pret'] === 't') { |
&& $val_dt['tax_ext_pret'] === 't') { |
1552 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
1553 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1554 |
// |
// |
1555 |
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf2'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1556 |
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat2'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1557 |
} |
} |
1558 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1559 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1597 |
', |
', |
1598 |
DB_PREFIXE |
DB_PREFIXE |
1599 |
); |
); |
1600 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1601 |
|
$query, |
1602 |
|
array( |
1603 |
|
"origin" => __METHOD__, |
1604 |
|
"force_return" => true, |
1605 |
|
) |
1606 |
|
); |
1607 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1608 |
return array(); |
return array(); |
1609 |
} |
} |
1614 |
return $result; |
return $result; |
1615 |
} |
} |
1616 |
|
|
1617 |
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') { |
1618 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1619 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1620 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1621 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
1622 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
1623 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
1624 |
|
"fk_field_3" => 'category', |
1625 |
|
"fk_idx_3" => $fk_idx_3, |
1626 |
|
"order_field" => 'lien_id_interne_uid_externe', |
1627 |
|
"order_asc_desc" => $order_asc_desc, |
1628 |
)); |
)); |
1629 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1630 |
} |
} |
1631 |
|
|
1632 |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category=PLATAU) { |
1633 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1634 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1635 |
} |
} |
1636 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1637 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
1638 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object, $category); |
1639 |
if ($external_uid !== '' && $external_uid !== null) { |
if ($external_uid !== '' && $external_uid !== null) { |
1640 |
$val_external_uid[$link_object] = $external_uid; |
$val_external_uid[$link_object] = $external_uid; |
1641 |
} |
} |
1643 |
return $val_external_uid; |
return $val_external_uid; |
1644 |
} |
} |
1645 |
|
|
1646 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data($dossier) { |
1647 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1648 |
|
if ($dossier === null) { |
1649 |
|
return $val_demandeur; |
1650 |
|
} |
1651 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1652 |
"obj" => "dossier", |
"obj" => "dossier", |
1653 |
"idx" => $dossier, |
"idx" => $dossier, |
1678 |
return $val_architecte; |
return $val_architecte; |
1679 |
} |
} |
1680 |
|
|
1681 |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1682 |
$val_instruction = null; |
$val_instruction = null; |
1683 |
|
if ($dossier === null) { |
1684 |
|
return $val_instruction; |
1685 |
|
} |
1686 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1687 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1688 |
"obj" => "dossier", |
"obj" => "dossier", |
1742 |
return $val_instruction; |
return $val_instruction; |
1743 |
} |
} |
1744 |
|
|
1745 |
|
|
1746 |
|
/** |
1747 |
|
* Récupère les informations pour les notifications ayant plusieurs annexe |
1748 |
|
*/ |
1749 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1750 |
|
$val_in = null; |
1751 |
|
|
1752 |
|
$idx = null; |
1753 |
|
if ($type === 'with-id') { |
1754 |
|
$idx = $extra_params['with-id']; |
1755 |
|
} |
1756 |
|
|
1757 |
|
// Récupération du type de notification. Le type est nécessaire pour récupérer |
1758 |
|
// le message et le titre de notification. |
1759 |
|
$typeNotification = $this->getVal('type'); |
1760 |
|
if (isset($this->valF['type'])) { |
1761 |
|
$typeNotification = $this->valF['type']; |
1762 |
|
} |
1763 |
|
|
1764 |
|
// récupére les données à intégrer à la payload |
1765 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1766 |
|
"obj" => "instruction_notification", |
1767 |
|
"idx" => $idx, |
1768 |
|
)); |
1769 |
|
if (count($inst_in->val) > 0) { |
1770 |
|
$val_in = $inst_in->get_json_data(); |
1771 |
|
|
1772 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1773 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1774 |
|
// Récupération du message et du titre |
1775 |
|
if ($category === 'mail') { |
1776 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1777 |
|
"obj" => "instruction", |
1778 |
|
"idx" => $inst_in->getVal('instruction'), |
1779 |
|
)); |
1780 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1781 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id, $typeNotification); |
1782 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1783 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1784 |
|
} |
1785 |
|
|
1786 |
|
if ($typeNotification == 'notification_signataire') { |
1787 |
|
$val_in['lien_page_signature'] = $inst_in->getLienPageSignature($inst_instruction); |
1788 |
|
} |
1789 |
|
else { |
1790 |
|
// Récupération des liens vers les documents et des id et type des annexes |
1791 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
1792 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
1793 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
1794 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1795 |
|
} |
1796 |
|
} |
1797 |
|
return $val_in; |
1798 |
|
} |
1799 |
|
|
1800 |
|
/** |
1801 |
|
* Récupère les informations concernant la lettre au pétitionnaire. |
1802 |
|
* |
1803 |
|
* @param string identifiant du dossier |
1804 |
|
* @param string type de tâche |
1805 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
1806 |
|
* |
1807 |
|
* @return array information concernant la lettre au pétitionnaire |
1808 |
|
*/ |
1809 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
1810 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
1811 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
1812 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
1813 |
|
// Le type de document dépend du type de pièce |
1814 |
|
$nomTypeLettre = ''; |
1815 |
|
$nomTypeDocument = ''; |
1816 |
|
if ($type === 'lettre_incompletude') { |
1817 |
|
$nomTypeLettre = '3'; |
1818 |
|
$nomTypeDocument = '4'; |
1819 |
|
} elseif ($type === 'lettre_majoration') { |
1820 |
|
$nomTypeLettre = '4'; |
1821 |
|
$nomTypeDocument = '6'; |
1822 |
|
} |
1823 |
|
|
1824 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1825 |
|
"obj" => "dossier", |
1826 |
|
"idx" => $dossier, |
1827 |
|
)); |
1828 |
|
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
1829 |
|
$aujourdhui = new DateTime(); |
1830 |
|
if (! $date_limite_notification instanceof DateTime) { |
1831 |
|
$nomTypeLettre = ''; |
1832 |
|
$nomTypeDocument = ''; |
1833 |
|
} elseif ($aujourdhui < $date_limite_notification) { |
1834 |
|
$nomTypeLettre = '1'; |
1835 |
|
$nomTypeDocument = '3'; |
1836 |
|
} |
1837 |
|
|
1838 |
|
return array( |
1839 |
|
'nomEtatLettre' => '3', |
1840 |
|
'nomModaliteNotifMetier' => '4', |
1841 |
|
'nomTypeLettre' => $nomTypeLettre, |
1842 |
|
'nomTypeDocument' => $nomTypeDocument |
1843 |
|
); |
1844 |
|
} |
1845 |
|
|
1846 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1847 |
$fields = array( |
$fields = array( |
1848 |
"date_evenement", |
"date_evenement", |
1856 |
"om_fichier_instruction", |
"om_fichier_instruction", |
1857 |
"tacite", |
"tacite", |
1858 |
"lettretype", |
"lettretype", |
1859 |
|
"commentaire", |
1860 |
|
"complement_om_html", |
1861 |
); |
); |
1862 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
1863 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
1876 |
return $res; |
return $res; |
1877 |
} |
} |
1878 |
|
|
1879 |
|
/** |
1880 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
1881 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1882 |
|
* |
1883 |
|
* @param integer $instruction Identifiant de l'instruction |
1884 |
|
* @return boolean |
1885 |
|
*/ |
1886 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1887 |
|
if ($instruction === null) { |
1888 |
|
return false; |
1889 |
|
} |
1890 |
|
$qres = $this->f->get_one_result_from_db_query( |
1891 |
|
sprintf( |
1892 |
|
'SELECT |
1893 |
|
demande_type.dossier_instruction_type |
1894 |
|
FROM |
1895 |
|
%1$sdemande |
1896 |
|
INNER JOIN %1$sdemande_type |
1897 |
|
ON demande.demande_type = demande_type.demande_type |
1898 |
|
WHERE |
1899 |
|
demande.instruction_recepisse = %2$s', |
1900 |
|
DB_PREFIXE, |
1901 |
|
intval($instruction) |
1902 |
|
), |
1903 |
|
array( |
1904 |
|
"origin" => __METHOD__, |
1905 |
|
"force_return" => true, |
1906 |
|
) |
1907 |
|
); |
1908 |
|
if ($qres["code"] !== "OK") { |
1909 |
|
return null; |
1910 |
|
} |
1911 |
|
if ($qres["result"] === "") { |
1912 |
|
return true; |
1913 |
|
} |
1914 |
|
return false; |
1915 |
|
} |
1916 |
|
|
1917 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
1918 |
$val_dn = array(); |
$val_dn = array(); |
1919 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1953 |
)); |
)); |
1954 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1955 |
$val_ad = array(); |
$val_ad = array(); |
1956 |
if ($ad !== null) { |
if ($ad !== null && trim($ad) !== '') { |
1957 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1958 |
"obj" => "avis_decision", |
"obj" => "avis_decision", |
1959 |
"idx" => $ad, |
"idx" => $ad, |
2015 |
|
|
2016 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
2017 |
// |
// |
2018 |
if ($this->f->get_submitted_post_value('valid') === null |
$check_state = isset($this->valF['state']) === true ? $this->valF['state'] : $this->getVal('state'); |
2019 |
&& $this->getVal('state') !== self::STATUS_DRAFT) { |
if ($check_state !== self::STATUS_CANCELED) { |
2020 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
2021 |
$val = array(); |
$val = array(); |
2022 |
// |
// |
2024 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
2025 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
2026 |
} |
} |
2027 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
2028 |
$val['task'] = $val_task; |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
2029 |
// |
// de référence de la tâche existe. |
2030 |
if ($this->getVal('type') === 'creation_DA' |
$objectRefExist = true; |
2031 |
|| $this->getVal('type') === 'modification_DA') { |
if ($val_task['stream'] === 'output' |
2032 |
// |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2033 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$objectRefExist = $this->does_referenced_object_exist( |
2034 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val_task['object_id'], |
2035 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val_task['type'] |
2036 |
$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['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
|
|
$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_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; |
|
2037 |
} |
} |
2038 |
// |
|
2039 |
if ($this->getVal('type') === 'avis_consultation') { |
// Si l'objet de référence n'existe pas log le numéro de la tâche concerné et |
2040 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
// renvoie une payload contenant le message d'erreur. |
2041 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
// Sinon constitue la payload du json. |
2042 |
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
if (! $objectRefExist) { |
2043 |
if (isset($val['instruction']['signataire_arrete']) === true) { |
$this->f->addToLog( |
2044 |
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
sprintf( |
2045 |
} |
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2046 |
$val_external_uid = array(); |
$val_task['task'] |
2047 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
), |
2048 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
DEBUG_MODE |
2049 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
); |
2050 |
$val['external_uids'] = $val_external_uid; |
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2051 |
} |
} else { |
2052 |
// XXX WIP |
|
2053 |
if ($this->getVal('type') === 'creation_consultation') { |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2054 |
// |
unset($val_task['timestamp_log_hidden']); |
2055 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['task'] = $val_task; |
2056 |
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
// |
2057 |
$val['service'] = $this->get_service_data($val['consultation']['service']); |
if ($this->getVal('type') === 'creation_DA' |
2058 |
$val_external_uid = array(); |
|| $this->getVal('type') === 'modification_DA') { |
2059 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
// |
2060 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2061 |
$val['external_uids'] = $val_external_uid; |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
2062 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
2063 |
|
$val_external_uid = array(); |
2064 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
2065 |
|
$val['external_uids'] = $val_external_uid; |
2066 |
|
} |
2067 |
|
// |
2068 |
|
if ($this->getVal('type') === 'creation_DI' |
2069 |
|
|| $this->getVal('type') === 'modification_DI' |
2070 |
|
|| $this->getVal('type') === 'depot_DI') { |
2071 |
|
// |
2072 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2073 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2074 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2075 |
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2076 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
2077 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2078 |
|
$val_external_uid = array(); |
2079 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2080 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2081 |
|
$val['external_uids'] = $val_external_uid; |
2082 |
|
} |
2083 |
|
// |
2084 |
|
if ($this->getVal('type') === 'qualification_DI') { |
2085 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2086 |
|
$val_external_uid = array(); |
2087 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2088 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2089 |
|
$val['external_uids'] = $val_external_uid; |
2090 |
|
} |
2091 |
|
// |
2092 |
|
if ($this->getVal('type') === 'ajout_piece') { |
2093 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2094 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2095 |
|
$val_external_uid = array(); |
2096 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2097 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2098 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2099 |
|
$val['external_uids'] = $val_external_uid; |
2100 |
|
} |
2101 |
|
// |
2102 |
|
if ($this->getVal('type') === 'decision_DI') { |
2103 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2104 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2105 |
|
$val['instruction']['final'] = 't'; |
2106 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2107 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2108 |
|
} |
2109 |
|
$val_external_uid = array(); |
2110 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2111 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2112 |
|
$val['external_uids'] = $val_external_uid; |
2113 |
|
} |
2114 |
|
// |
2115 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
2116 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2117 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2118 |
|
$val_external_uid = array(); |
2119 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2120 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2121 |
|
$val['external_uids'] = $val_external_uid; |
2122 |
|
} |
2123 |
|
// |
2124 |
|
if ($this->getVal('type') === 'completude_DI') { |
2125 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2126 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2127 |
|
$val_external_uid = array(); |
2128 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2129 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2130 |
|
$val['external_uids'] = $val_external_uid; |
2131 |
|
} |
2132 |
|
// |
2133 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2134 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2135 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2136 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2137 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2138 |
|
$val_external_uid = array(); |
2139 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2140 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2141 |
|
$val['external_uids'] = $val_external_uid; |
2142 |
|
} |
2143 |
|
// |
2144 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2145 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2146 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2147 |
|
$val_external_uid = array(); |
2148 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2149 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2150 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2151 |
|
$val['external_uids'] = $val_external_uid; |
2152 |
|
} |
2153 |
|
// |
2154 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2155 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2156 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2157 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2158 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2159 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2160 |
|
} |
2161 |
|
$val_external_uid = array(); |
2162 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2163 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2164 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2165 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
2166 |
|
$val['external_uids'] = $val_external_uid; |
2167 |
|
} |
2168 |
|
// XXX WIP |
2169 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2170 |
|
// |
2171 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2172 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2173 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2174 |
|
$val_external_uid = array(); |
2175 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2176 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2177 |
|
$val['external_uids'] = $val_external_uid; |
2178 |
|
} |
2179 |
|
// |
2180 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2181 |
|
// |
2182 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2183 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2184 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2185 |
|
$val_external_uid = array(); |
2186 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2187 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
2188 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2189 |
|
if ($val_external_uid['decision'] === '') { |
2190 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2191 |
|
"obj" => "instruction", |
2192 |
|
"idx" => $this->getVal('object_id'), |
2193 |
|
)); |
2194 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2195 |
|
} |
2196 |
|
$val['external_uids'] = $val_external_uid; |
2197 |
|
} |
2198 |
|
if ($this->getVal('type') === 'notification_instruction' |
2199 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2200 |
|
|| $this->getVal('type') === 'notification_decision' |
2201 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2202 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2203 |
|
|| $this->getVal('type') === 'notification_signataire') { |
2204 |
|
// |
2205 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2206 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2207 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2208 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2209 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2210 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
2211 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2212 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2213 |
|
// demande dont le type ne génère pas de dossier |
2214 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2215 |
|
$val['instruction']['final'] = 't'; |
2216 |
|
} |
2217 |
|
$val_external_uid = array(); |
2218 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2219 |
|
$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'); |
2220 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2221 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2222 |
|
$val['external_uids'] = $val_external_uid; |
2223 |
|
} |
2224 |
|
// |
2225 |
|
if ($this->getVal('type') === 'prescription') { |
2226 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2227 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2228 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2229 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2230 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2231 |
|
} |
2232 |
|
$val_external_uid = array(); |
2233 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2234 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2235 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2236 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2237 |
|
$val['external_uids'] = $val_external_uid; |
2238 |
|
} |
2239 |
} |
} |
2240 |
|
|
2241 |
if ($in_field === true) { |
if ($in_field === true) { |
2242 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
2243 |
} else { |
} else { |
2244 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
2245 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
2246 |
} |
} |
2247 |
} |
} |
2248 |
} |
} |
2257 |
'state' => $this->f->get_submitted_post_value('state') |
'state' => $this->f->get_submitted_post_value('state') |
2258 |
), |
), |
2259 |
); |
); |
2260 |
|
if ($this->f->get_submitted_post_value('comment') !== null) { |
2261 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2262 |
|
} |
2263 |
$update = $this->update_task($params); |
$update = $this->update_task($params); |
2264 |
$message_class = "valid"; |
$message_class = "valid"; |
2265 |
$message = $this->msg; |
$message = $this->msg; |
2284 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
2285 |
"idx" => ']', |
"idx" => ']', |
2286 |
)); |
)); |
2287 |
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
$object_id = $this->getVal('object_id'); |
2288 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
2289 |
|
// Dans le cas spécifique de la mise à jour d'une notification |
2290 |
|
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2291 |
|
// l'identifiant de l'objet n'est plus celui de la notification |
2292 |
|
// d'instruction mais celui du dossier d'instruction |
2293 |
|
if ($object === 'demande' |
2294 |
|
&& ($this->getVal('type') === 'notification_recepisse' |
2295 |
|
|| $this->getVal('type') === 'notification_instruction' |
2296 |
|
|| $this->getVal('type') === 'notification_decision' |
2297 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2298 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2299 |
|
|| $this->getVal('type') === 'notification_signataire')) { |
2300 |
|
// |
2301 |
|
$object_id = $this->getVal('dossier'); |
2302 |
|
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2303 |
|
$is_exists = $inst_lien->is_exists($object, $object_id, null, $this->getVal('dossier')); |
2304 |
|
} |
2305 |
|
if ($is_exists === false) { |
2306 |
$valF = array( |
$valF = array( |
2307 |
'lien_id_interne_uid_externe' => '', |
'lien_id_interne_uid_externe' => '', |
2308 |
'object' => $object, |
'object' => $object, |
2309 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $object_id, |
2310 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
2311 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
2312 |
|
'category' => $this->getVal('category'), |
2313 |
); |
); |
2314 |
$add = $inst_lien->ajouter($valF); |
$add = $inst_lien->ajouter($valF); |
2315 |
$message_class = "valid"; |
$message_class = "valid"; |
2334 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2335 |
'val' => array( |
'val' => array( |
2336 |
'stream' => 'input', |
'stream' => 'input', |
2337 |
'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), |
2338 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2339 |
|
'category' => $this->f->get_submitted_post_value('category'), |
2340 |
) |
) |
2341 |
)); |
)); |
2342 |
$message = sprintf( |
$message = sprintf( |
2358 |
} |
} |
2359 |
|
|
2360 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2361 |
|
// |
2362 |
// Récupération du mode de l'action |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2363 |
$crud = $this->get_action_crud($maj); |
$fieldset_title_payload = __("json_payload (calculée)"); |
2364 |
|
if ($this->getVal('json_payload') !== "{}") { |
2365 |
// MODE different de CREER |
$fieldset_title_payload = __("json_payload"); |
2366 |
if ($maj != 0 || $crud != 'create') { |
} |
2367 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setFieldset('json_payload', 'DF', $fieldset_title_payload, "collapsible, startClosed"); |
2368 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
$form->setBloc('json_payload', 'F'); |
2369 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
|
} |
|
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
|
2370 |
} |
} |
2371 |
|
|
2372 |
/** |
/** |
2373 |
* [get_objects_by_task_type description] |
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
2374 |
* @param [type] $type [description] |
* en fonction du type et du stream de la tâche. |
2375 |
* @return [type] [description] |
* |
2376 |
|
* @param string $type Type de la tâche |
2377 |
|
* @param string $stream Stream de la tâche |
2378 |
|
* |
2379 |
|
* @return array |
2380 |
*/ |
*/ |
2381 |
function get_objects_by_task_type($type, $stream = 'all') { |
function get_objects_by_task_type($type, $stream = 'all') { |
2382 |
$objects = array(); |
$objects = array(); |
2391 |
} |
} |
2392 |
if (in_array($type, array('create_DI', )) === true |
if (in_array($type, array('create_DI', )) === true |
2393 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2394 |
$objects = array('dossier', 'dossier_autorisation', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2395 |
} |
} |
2396 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2397 |
|
'decision_DI', |
2398 |
|
'incompletude_DI', |
2399 |
|
'completude_DI', |
2400 |
|
'lettre_incompletude', |
2401 |
|
'lettre_majoration' |
2402 |
|
)) === true) { |
2403 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2404 |
} |
} |
2405 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2406 |
|
$objects = array('instruction_action_cl', ); |
2407 |
|
} |
2408 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2409 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2410 |
$objects = array('pec_dossier_consultation', ); |
$objects = array('pec_dossier_consultation', ); |
2413 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2414 |
$objects = array('avis_dossier_consultation', ); |
$objects = array('avis_dossier_consultation', ); |
2415 |
} |
} |
2416 |
|
if (in_array($type, array('prescription', )) === true |
2417 |
|
&& $stream === 'output') { |
2418 |
|
$objects = array('prescription', ); |
2419 |
|
} |
2420 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2421 |
$objects = array('piece', ); |
$objects = array('piece', ); |
2422 |
} |
} |
2435 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2436 |
$objects = array('dossier_message', ); |
$objects = array('dossier_message', ); |
2437 |
} |
} |
2438 |
|
if (in_array( |
2439 |
|
$type, |
2440 |
|
array( |
2441 |
|
'notification_recepisse', |
2442 |
|
'notification_instruction', |
2443 |
|
'notification_decision', |
2444 |
|
'notification_service_consulte', |
2445 |
|
'notification_tiers_consulte', |
2446 |
|
'notification_signataire', |
2447 |
|
) |
2448 |
|
) === true) { |
2449 |
|
$objects = array('instruction_notification', 'demande', ); |
2450 |
|
} |
2451 |
return $objects; |
return $objects; |
2452 |
} |
} |
2453 |
|
|
2454 |
|
/** |
2455 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
2456 |
|
* par rapport à son type. |
2457 |
|
* |
2458 |
|
* @param string $type Type de la tâche |
2459 |
|
* @param string $stream input ou output |
2460 |
|
* @return array |
2461 |
|
*/ |
2462 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
2463 |
|
$tables = array(); |
2464 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
2465 |
|
$tables = array('dossier_autorisation', ); |
2466 |
|
} |
2467 |
|
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
2468 |
|
$tables = array('dossier', ); |
2469 |
|
} |
2470 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
2471 |
|
$tables = array('instruction', 'dossier', ); |
2472 |
|
} |
2473 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
2474 |
|
$tables = array('dossier', ); |
2475 |
|
} |
2476 |
|
if (in_array($type, array('create_DI', )) === true |
2477 |
|
&& $stream === 'input') { |
2478 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2479 |
|
} |
2480 |
|
if (in_array($type, array( |
2481 |
|
'decision_DI', |
2482 |
|
'incompletude_DI', |
2483 |
|
'completude_DI', |
2484 |
|
'lettre_incompletude', |
2485 |
|
'lettre_majoration' |
2486 |
|
)) === true) { |
2487 |
|
$tables = array('instruction', ); |
2488 |
|
} |
2489 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2490 |
|
$objects = array('instruction', ); |
2491 |
|
} |
2492 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2493 |
|
&& $stream === 'output') { |
2494 |
|
$tables = array('instruction', ); |
2495 |
|
} |
2496 |
|
if (in_array($type, array('avis_consultation', )) === true |
2497 |
|
&& $stream === 'output') { |
2498 |
|
$tables = array('instruction', ); |
2499 |
|
} |
2500 |
|
if (in_array($type, array('prescription', )) === true |
2501 |
|
&& $stream === 'output') { |
2502 |
|
$tables = array('instruction', ); |
2503 |
|
} |
2504 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
2505 |
|
$tables = array('document_numerise', ); |
2506 |
|
} |
2507 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
2508 |
|
$tables = array('consultation', ); |
2509 |
|
} |
2510 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
2511 |
|
&& $stream === 'input') { |
2512 |
|
$tables = array('consultation', ); |
2513 |
|
} |
2514 |
|
if (in_array($type, array('avis_consultation', )) === true |
2515 |
|
&& $stream === 'input') { |
2516 |
|
$tables = array('consultation', ); |
2517 |
|
} |
2518 |
|
if (in_array($type, array('create_message', )) === true |
2519 |
|
&& $stream === 'input') { |
2520 |
|
$tables = array('dossier_message', ); |
2521 |
|
} |
2522 |
|
if (in_array( |
2523 |
|
$type, |
2524 |
|
array( |
2525 |
|
'notification_recepisse', |
2526 |
|
'notification_instruction', |
2527 |
|
'notification_decision', |
2528 |
|
'notification_service_consulte', |
2529 |
|
'notification_tiers_consulte', |
2530 |
|
'notification_signataire' |
2531 |
|
) |
2532 |
|
) === true) { |
2533 |
|
$tables = array('instruction_notification', ); |
2534 |
|
} |
2535 |
|
return $tables; |
2536 |
|
} |
2537 |
|
|
2538 |
|
/** |
2539 |
|
* Vérifie si l'objet référencé par la tâche existe en base de données. |
2540 |
|
* |
2541 |
|
* Récupère la liste des tables de référence associé à la tâche à partir |
2542 |
|
* du type de tâche et de son flux (input ou output). |
2543 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
2544 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
2545 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
2546 |
|
* |
2547 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
2548 |
|
* @param string $taskType : type de la tâche |
2549 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
2550 |
|
* @return boolean |
2551 |
|
*/ |
2552 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
2553 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
2554 |
|
if (empty($refTables) === true) { |
2555 |
|
$this->f->addToLog( |
2556 |
|
sprintf( |
2557 |
|
__("Impossible de vérifier si l'objet de référence existe, car le type de task '%s' n'a pas de correspondance avec une table dans la méthode %s."), |
2558 |
|
$taskType, |
2559 |
|
"get_tables_by_task_type()" |
2560 |
|
), |
2561 |
|
DEBUG_MODE |
2562 |
|
); |
2563 |
|
return true; |
2564 |
|
} |
2565 |
|
foreach ($refTables as $table) { |
2566 |
|
$inst = $this->f->get_inst__om_dbform(array( |
2567 |
|
'obj' => $table, |
2568 |
|
'idx' => $taskObjectId |
2569 |
|
)); |
2570 |
|
if ($inst->exists() === true) { |
2571 |
|
return true; |
2572 |
|
} |
2573 |
|
} |
2574 |
|
return false; |
2575 |
|
} |
2576 |
|
|
2577 |
} |
} |