1 |
<?php |
<?php |
2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
6 |
|
|
7 |
class task extends task_gen { |
class task extends task_gen { |
8 |
|
|
9 |
|
const STATUS_DRAFT = 'draft'; |
10 |
|
const STATUS_NEW = 'new'; |
11 |
|
const STATUS_PENDING = 'pending'; |
12 |
|
const STATUS_DONE = 'done'; |
13 |
|
const STATUS_ERROR = 'error'; |
14 |
|
const STATUS_DEBUG = 'debug'; |
15 |
|
const STATUS_ARCHIVED = 'archived'; |
16 |
|
|
17 |
|
/** |
18 |
|
* Liste des types de tâche concernant les services instructeurs |
19 |
|
*/ |
20 |
|
const TASK_TYPE_SI = array( |
21 |
|
'creation_DA', |
22 |
|
'creation_DI', |
23 |
|
'depot_DI', |
24 |
|
'modification_DI', |
25 |
|
'qualification_DI', |
26 |
|
'decision_DI', |
27 |
|
'incompletude_DI', |
28 |
|
'completude_DI', |
29 |
|
'ajout_piece', |
30 |
|
'add_piece', |
31 |
|
'creation_consultation', |
32 |
|
'modification_DA', |
33 |
|
'create_DI', |
34 |
|
); |
35 |
|
|
36 |
|
/** |
37 |
|
* Liste des types de tâche concernant les services consultés |
38 |
|
*/ |
39 |
|
const TASK_TYPE_SC = array( |
40 |
|
'create_DI_for_consultation', |
41 |
|
'avis_consultation', |
42 |
|
'pec_metier_consultation', |
43 |
|
'create_message', |
44 |
|
); |
45 |
|
|
46 |
/** |
/** |
47 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
48 |
* |
* |
56 |
"view" => "view_json_data", |
"view" => "view_json_data", |
57 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
58 |
); |
); |
59 |
|
$this->class_actions[997] = array( |
60 |
|
"identifier" => "json_data", |
61 |
|
"view" => "post_update_task", |
62 |
|
"permission_suffix" => "modifier", |
63 |
|
); |
64 |
|
$this->class_actions[996] = array( |
65 |
|
"identifier" => "json_data", |
66 |
|
"view" => "post_add_task", |
67 |
|
"permission_suffix" => "ajouter", |
68 |
|
); |
69 |
|
} |
70 |
|
|
71 |
|
public function setvalF($val = array()) { |
72 |
|
|
73 |
|
// // les guillets doubles sont remplacés automatiquement par des simples |
74 |
|
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
75 |
|
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
76 |
|
// // ceci est un hack sale temporaire en attendant résolution du ticket |
77 |
|
// foreach(array('json_payload', 'timestamp_log') as $key) { |
78 |
|
// if (isset($val[$key]) && ! empty($val[$key]) && |
79 |
|
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
80 |
|
// $submited_payload = $_POST[$key]; |
81 |
|
// if (! empty($submited_payload)) { |
82 |
|
// $new_payload = str_replace("'", '"', $val[$key]); |
83 |
|
// if ($new_payload == $submited_payload || |
84 |
|
// strpos($submited_payload, '"') === false) { |
85 |
|
// $val[$key] = $new_payload; |
86 |
|
// } |
87 |
|
// else { |
88 |
|
// $error_msg = sprintf( |
89 |
|
// __("La convertion des guillemets de la payload JSON '%s' ". |
90 |
|
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
91 |
|
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
92 |
|
// var_export($new_payload, true)); |
93 |
|
// $this->correct = false; |
94 |
|
// $this->addToMessage($error_msg); |
95 |
|
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
96 |
|
// return false; |
97 |
|
// } |
98 |
|
// } |
99 |
|
// } |
100 |
|
// } |
101 |
|
|
102 |
|
parent::setvalF($val); |
103 |
|
|
104 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
105 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
106 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
107 |
|
} |
108 |
|
|
109 |
|
// récupération de l'ID de l'objet existant |
110 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
111 |
|
if(isset($val[$this->clePrimaire])) { |
112 |
|
$id = $val[$this->clePrimaire]; |
113 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
114 |
|
$id = $this->valF[$this->clePrimaire]; |
115 |
|
} |
116 |
|
|
117 |
|
// MODE MODIFIER |
118 |
|
if (! empty($id)) { |
119 |
|
|
120 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
121 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
122 |
|
|
123 |
|
// récupère l'objet existant |
124 |
|
$existing = $this->f->findObjectById(get_class($this), $id); |
125 |
|
if (! empty($existing)) { |
126 |
|
|
127 |
|
// récupère la payload de l'objet |
128 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
129 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
130 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
131 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
132 |
|
} |
133 |
|
} |
134 |
|
} |
135 |
|
} |
136 |
|
|
137 |
|
/** |
138 |
|
* |
139 |
|
* @return array |
140 |
|
*/ |
141 |
|
function get_var_sql_forminc__champs() { |
142 |
|
return array( |
143 |
|
"task", |
144 |
|
"type", |
145 |
|
"state", |
146 |
|
"object_id", |
147 |
|
"dossier", |
148 |
|
"stream", |
149 |
|
"json_payload", |
150 |
|
"timestamp_log", |
151 |
|
); |
152 |
|
} |
153 |
|
|
154 |
|
function setType(&$form, $maj) { |
155 |
|
parent::setType($form, $maj); |
156 |
|
|
157 |
|
// Récupération du mode de l'action |
158 |
|
$crud = $this->get_action_crud($maj); |
159 |
|
|
160 |
|
// MODE CREER |
161 |
|
if ($maj == 0 || $crud == 'create') { |
162 |
|
$form->setType("state", "select"); |
163 |
|
$form->setType("stream", "select"); |
164 |
|
$form->setType("json_payload", "textarea"); |
165 |
|
} |
166 |
|
// MDOE MODIFIER |
167 |
|
if ($maj == 1 || $crud == 'update') { |
168 |
|
$form->setType("state", "select"); |
169 |
|
$form->setType("stream", "select"); |
170 |
|
$form->setType("json_payload", "jsonprettyprint"); |
171 |
|
} |
172 |
|
// MODE CONSULTER |
173 |
|
if ($maj == 3 || $crud == 'read') { |
174 |
|
$form->setType('dossier', 'link'); |
175 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
176 |
|
} |
177 |
|
|
178 |
|
} |
179 |
|
|
180 |
|
/** |
181 |
|
* |
182 |
|
*/ |
183 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
184 |
|
if($maj < 2) { |
185 |
|
|
186 |
|
$contenu = array(); |
187 |
|
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
188 |
|
$const_name = 'STATUS_'.$key; |
189 |
|
$const_value = constant("self::$const_name"); |
190 |
|
$contenu[0][] = $const_value; |
191 |
|
$contenu[1][] = __($const_value); |
192 |
|
} |
193 |
|
|
194 |
|
$form->setSelect("state", $contenu); |
195 |
|
|
196 |
|
$contenu_stream =array(); |
197 |
|
$contenu_stream[0][0]="input"; |
198 |
|
$contenu_stream[1][0]=_('input'); |
199 |
|
$contenu_stream[0][1]="output"; |
200 |
|
$contenu_stream[1][1]=_('output'); |
201 |
|
$form->setSelect("stream", $contenu_stream); |
202 |
|
|
203 |
|
} |
204 |
|
|
205 |
|
if ($maj == 3) { |
206 |
|
if ($this->getVal('stream') == 'output') { |
207 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
208 |
|
"obj" => "dossier", |
209 |
|
"idx" => $form->val['dossier'], |
210 |
|
)); |
211 |
|
|
212 |
|
if($form->val['type'] == "creation_DA" |
213 |
|
|| $form->val['type'] == "modification_DA"){ |
214 |
|
// |
215 |
|
$obj_link = 'dossier_autorisation'; |
216 |
|
} else { |
217 |
|
$obj_link = 'dossier_instruction'; |
218 |
|
} |
219 |
|
|
220 |
|
$params = array(); |
221 |
|
$params['obj'] = $obj_link; |
222 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
223 |
|
$params['title'] = "Consulter le dossier"; |
224 |
|
$params['idx'] = $form->val['dossier']; |
225 |
|
$form->setSelect("dossier", $params); |
226 |
|
} |
227 |
|
} |
228 |
|
} |
229 |
|
|
230 |
|
/** |
231 |
|
* SETTER_FORM - setVal (setVal). |
232 |
|
* |
233 |
|
* @return void |
234 |
|
*/ |
235 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
236 |
|
// parent::setVal($form, $maj, $validation); |
237 |
|
// |
238 |
|
if ($this->getVal('stream') == "output") { |
239 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
240 |
|
} else { |
241 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
242 |
|
} |
243 |
|
} |
244 |
|
|
245 |
|
function setLib(&$form, $maj) { |
246 |
|
parent::setLib($form, $maj); |
247 |
|
|
248 |
|
// Récupération du mode de l'action |
249 |
|
$crud = $this->get_action_crud($maj); |
250 |
|
|
251 |
|
// MODE different de CREER |
252 |
|
if ($maj != 0 || $crud != 'create') { |
253 |
|
$form->setLib('json_payload', ''); |
254 |
|
} |
255 |
|
} |
256 |
|
|
257 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
258 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
259 |
|
|
260 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
261 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
262 |
|
if (isset($this->valF['type']) === false) { |
263 |
|
$this->correct = false; |
264 |
|
$this->addToMessage(sprintf( |
265 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
266 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
267 |
|
)); |
268 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
269 |
|
} |
270 |
|
if (isset($this->valF['json_payload']) === false) { |
271 |
|
$this->correct = false; |
272 |
|
$this->addToMessage(sprintf( |
273 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
274 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
275 |
|
)); |
276 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
277 |
|
} |
278 |
|
} |
279 |
|
|
280 |
|
// les JSONs doivent être décodables |
281 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
282 |
|
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
283 |
|
is_array(json_decode($this->valF[$key], true)) === false |
284 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
285 |
|
$this->correct = false; |
286 |
|
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
287 |
|
$this->addToMessage(sprintf( |
288 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
289 |
|
"<p>%s valF:</br><pre>%s</pre></p>". |
290 |
|
"<p>%s val:</br><pre>%s</pre></p>". |
291 |
|
"<p>%s POST:</br><pre>%s</pre></p>". |
292 |
|
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
293 |
|
$champ_text, |
294 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
295 |
|
$champ_text, |
296 |
|
$this->valF[$key], |
297 |
|
$champ_text, |
298 |
|
$val[$key], |
299 |
|
$champ_text, |
300 |
|
isset($_POST[$key]) ? $_POST[$key] : '', |
301 |
|
$champ_text, |
302 |
|
$this->f->get_submitted_post_value($key) |
303 |
|
)); |
304 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
305 |
|
} |
306 |
|
} |
307 |
|
|
308 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
309 |
|
if ($this->correct && (isset($this->valF['stream']) === false || |
310 |
|
$this->valF['stream'] == 'input')) { |
311 |
|
|
312 |
|
// décode la payload JSON |
313 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
314 |
|
|
315 |
|
// défini une liste de chemin de clés requises |
316 |
|
$paths = array( |
317 |
|
'external_uids/dossier' |
318 |
|
); |
319 |
|
|
320 |
|
// tâche de type création de DI/DA |
321 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
322 |
|
|
323 |
|
$paths = array_merge($paths, array( |
324 |
|
'dossier/dossier', |
325 |
|
'dossier/dossier_autorisation_type_detaille_code', |
326 |
|
'dossier/date_demande', |
327 |
|
'dossier/depot_electronique', |
328 |
|
)); |
329 |
|
|
330 |
|
// si l'option commune est activée (mode MC) |
331 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
332 |
|
$paths[] = 'dossier/insee'; |
333 |
|
} |
334 |
|
|
335 |
|
// présence d'un moyen d'identifier la collectivité/le service |
336 |
|
if (! isset($json_payload['external_uids']['acteur']) && |
337 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
338 |
|
$this->correct = false; |
339 |
|
$this->addToMessage(sprintf( |
340 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
341 |
|
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
342 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
343 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
344 |
|
)); |
345 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
346 |
|
} |
347 |
|
} |
348 |
|
|
349 |
|
// pas d'erreur déjà trouvée |
350 |
|
if($this->correct) { |
351 |
|
|
352 |
|
// pour chaque chemin |
353 |
|
foreach($paths as $path) { |
354 |
|
|
355 |
|
// décompose le chemin |
356 |
|
$tokens = explode('/', $path); |
357 |
|
$cur_depth = $json_payload; |
358 |
|
|
359 |
|
// descend au et à mesure dans l'arborescence du chemin |
360 |
|
foreach($tokens as $token) { |
361 |
|
|
362 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
363 |
|
if (isset($cur_depth[$token]) === false) { |
364 |
|
|
365 |
|
// sinon on produit une erreur |
366 |
|
$this->correct = false; |
367 |
|
$this->addToMessage(sprintf( |
368 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
369 |
|
sprintf('<span class="bold">%s</span>', $path), |
370 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
371 |
|
)); |
372 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
373 |
|
break 2; |
374 |
|
} |
375 |
|
$cur_depth = $cur_depth[$token]; |
376 |
|
} |
377 |
|
} |
378 |
|
} |
379 |
|
} |
380 |
|
|
381 |
|
return $ret && $this->correct; |
382 |
} |
} |
383 |
|
|
384 |
protected function task_exists(string $type, string $object_id) { |
/** |
385 |
|
* [task_exists description] |
386 |
|
* @param string $type [description] |
387 |
|
* @param string $object_id [description] |
388 |
|
* @param bool $is_not_done [description] |
389 |
|
* @return [type] [description] |
390 |
|
*/ |
391 |
|
public function task_exists(string $type, string $object_id, bool $is_not_done = true) { |
392 |
$query = sprintf(' |
$query = sprintf(' |
393 |
SELECT task |
SELECT task |
394 |
FROM %1$stask |
FROM %1$stask |
395 |
WHERE state != \'%2$s\' |
WHERE %2$s |
396 |
AND type = \'%3$s\' |
type = \'%3$s\' |
397 |
AND object_id = \'%4$s\' |
AND object_id = \'%4$s\' |
398 |
', |
', |
399 |
DB_PREFIXE, |
DB_PREFIXE, |
400 |
'done', |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
401 |
$type, |
$type, |
402 |
$object_id |
$object_id |
403 |
); |
); |
409 |
} |
} |
410 |
|
|
411 |
/** |
/** |
412 |
|
* TRIGGER - triggerajouter. |
413 |
|
* |
414 |
|
* @param string $id |
415 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
416 |
|
* @param array $val Tableau des valeurs brutes. |
417 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
418 |
|
* |
419 |
|
* @return boolean |
420 |
|
*/ |
421 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
422 |
|
|
423 |
|
// tâche entrante |
424 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
425 |
|
|
426 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
427 |
|
// en tant que métadonnées de la tâche |
428 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
429 |
|
|
430 |
|
// si la tâche possède déjà une clé dossier |
431 |
|
if (isset($json_payload['dossier']['dossier']) && |
432 |
|
! empty($json_payload['dossier']['dossier'])) { |
433 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
434 |
|
} |
435 |
|
} |
436 |
|
} |
437 |
|
|
438 |
|
/** |
439 |
* TREATMENT - add_task |
* TREATMENT - add_task |
440 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
441 |
* |
* |
444 |
*/ |
*/ |
445 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
446 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
447 |
|
|
448 |
|
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
449 |
|
// seulement pour les tasks output |
450 |
|
$task_types_si = self::TASK_TYPE_SI; |
451 |
|
$task_types_sc = self::TASK_TYPE_SC; |
452 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
453 |
|
if ($stream === 'output' |
454 |
|
&& isset($params['val']['type']) === true |
455 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
456 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
457 |
|
// |
458 |
|
return $this->end_treatment(__METHOD__, true); |
459 |
|
} |
460 |
|
if ($stream === 'output' |
461 |
|
&& isset($params['val']['type']) === true |
462 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
463 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
464 |
|
// |
465 |
|
return $this->end_treatment(__METHOD__, true); |
466 |
|
} |
467 |
|
|
468 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
469 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
470 |
)); |
)); |
471 |
|
|
472 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
473 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
474 |
|
if (isset($params['val']['type']) |
475 |
|
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
476 |
|
&& isset($params['val']['stream']) |
477 |
|
&& $params['val']['stream'] == "input" ) { |
478 |
|
// |
479 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
480 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
481 |
|
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
482 |
|
return $this->end_treatment(__METHOD__, false); |
483 |
|
} |
484 |
|
if (isset($json_payload['document_numerise']) === true |
485 |
|
&& empty($json_payload['document_numerise']) === false) { |
486 |
|
// |
487 |
|
$document_numerise = $json_payload['document_numerise']; |
488 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
489 |
|
if ($file_content === false){ |
490 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
491 |
|
return $this->end_treatment(__METHOD__, false); |
492 |
|
} |
493 |
|
$metadata = array( |
494 |
|
"filename" => $document_numerise['nom_fichier'], |
495 |
|
"size" => strlen($file_content), |
496 |
|
"mimetype" => $document_numerise['file_content_type'], |
497 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
498 |
|
); |
499 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
500 |
|
if ($uid_fichier === OP_FAILURE) { |
501 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
502 |
|
return $this->end_treatment(__METHOD__, false); |
503 |
|
} |
504 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
505 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
506 |
|
unset($json_payload["document_numerise"]["file_content"]); |
507 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
508 |
|
} |
509 |
|
} |
510 |
|
|
511 |
// Mise à jour du DI |
// Mise à jour du DI |
512 |
$valF = array( |
$valF = array( |
513 |
'task' => '', |
'task' => '', |
514 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
515 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
516 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
517 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
518 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
519 |
|
'stream' => $stream, |
520 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
521 |
); |
); |
522 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
523 |
if ($task_exists !== false) { |
// tâche sortante |
524 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if($valF["stream"] == "output"){ |
525 |
"obj" => "task", |
|
526 |
"idx" => $task_exists, |
// TODO expliquer ce code |
527 |
)); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
528 |
$update_params = array( |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
529 |
'val' => array( |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
530 |
'state' => $inst_task->getVal('state'), |
} |
531 |
), |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
532 |
); |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
533 |
return $inst_task->update_task($update_params); |
} |
534 |
|
if ($task_exists !== false) { |
535 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
536 |
|
"obj" => "task", |
537 |
|
"idx" => $task_exists, |
538 |
|
)); |
539 |
|
$update_state = $inst_task->getVal('state'); |
540 |
|
if (isset($params['update_val']['state']) === true) { |
541 |
|
$update_state = $params['update_val']['state']; |
542 |
|
} |
543 |
|
$update_params = array( |
544 |
|
'val' => array( |
545 |
|
'state' => $update_state, |
546 |
|
), |
547 |
|
); |
548 |
|
return $inst_task->update_task($update_params); |
549 |
|
} |
550 |
} |
} |
551 |
|
|
552 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
553 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
554 |
if ($add === false) { |
if ($add === false) { |
555 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
556 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
557 |
} |
} |
558 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
569 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
570 |
$timestamp_log = $this->get_timestamp_log(); |
$timestamp_log = $this->get_timestamp_log(); |
571 |
if ($timestamp_log === false) { |
if ($timestamp_log === false) { |
572 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
573 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
574 |
} |
} |
575 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
583 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
584 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
585 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
586 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true && $this->getVal('type') == 'create_DI' ? $params['object_id'] : $this->getVal('object_id'), |
587 |
|
'stream' => $this->getVal('stream'), |
588 |
|
'dossier' => $this->getVal('dossier'), |
589 |
|
'json_payload' => $this->getVal('json_payload'), |
590 |
); |
); |
591 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
592 |
if ($update === false) { |
if ($update === false) { |
599 |
/** |
/** |
600 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
601 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
602 |
* |
* |
603 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
604 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
605 |
*/ |
*/ |
645 |
* |
* |
646 |
FROM %1$stask |
FROM %1$stask |
647 |
%2$s |
%2$s |
648 |
|
ORDER BY task ASC |
649 |
', |
', |
650 |
DB_PREFIXE, |
DB_PREFIXE, |
651 |
$where |
$where |
656 |
} |
} |
657 |
$list_tasks = array(); |
$list_tasks = array(); |
658 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
659 |
|
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
660 |
|
$task['dossier'] = $task['dossier']; |
661 |
|
if ($task['type'] === 'ajout_piece') { |
662 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
663 |
|
} |
664 |
|
if ($task['stream'] === 'output') { |
665 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
666 |
|
} |
667 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
668 |
} |
} |
669 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
675 |
"obj" => "dossier", |
"obj" => "dossier", |
676 |
"idx" => $dossier, |
"idx" => $dossier, |
677 |
)); |
)); |
678 |
$val_di = json_decode($inst_di->get_json_data(), true); |
$val_di = $inst_di->get_json_data(); |
679 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
680 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
681 |
} |
} |
690 |
"obj" => "dossier_autorisation", |
"obj" => "dossier_autorisation", |
691 |
"idx" => $da, |
"idx" => $da, |
692 |
)); |
)); |
693 |
$val_da = json_decode($inst_da->get_json_data(), true); |
$val_da = $inst_da->get_json_data(); |
694 |
return $val_da; |
return $val_da; |
695 |
} |
} |
696 |
|
|
712 |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
713 |
} |
} |
714 |
} |
} |
715 |
|
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
716 |
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
717 |
|
// |
718 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
719 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
720 |
|
foreach ($fields_tab_surf_dest as $field) { |
721 |
|
if (isset($val_dt[$field]) === true) { |
722 |
|
unset($val_dt[$field]); |
723 |
|
} |
724 |
|
} |
725 |
|
} else { |
726 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
727 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
728 |
|
if (isset($val_dt[$field]) === true) { |
729 |
|
unset($val_dt[$field]); |
730 |
|
} |
731 |
|
} |
732 |
|
} |
733 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
734 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
735 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
736 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
737 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
738 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
739 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
740 |
|
// |
741 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
742 |
|
} |
743 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
744 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
745 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
746 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
747 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
748 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
749 |
|
// |
750 |
|
$val_dt['tax_su_non_habit_surf_stat8'] = intval($val_dt['tax_su_non_habit_surf_stat2']) + intval($val_dt['tax_su_non_habit_surf_stat3']); |
751 |
|
} |
752 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
753 |
|
$particular_case = false; |
754 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
755 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
756 |
|
if (isset($val_dt[$field]) === false |
757 |
|
|| (isset($val_dt[$field]) === true |
758 |
|
&& ($val_dt[$field] === null |
759 |
|
|| $val_dt[$field] === ''))) { |
760 |
|
// |
761 |
|
$particular_case = true; |
762 |
|
} |
763 |
|
} |
764 |
|
if ($particular_case === true) { |
765 |
|
if (isset($val_dt['tax_ext_pret']) === true |
766 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
767 |
|
// |
768 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
769 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
770 |
|
} |
771 |
|
if (isset($val_dt['tax_ext_pret']) === true |
772 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
773 |
|
// |
774 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
775 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
776 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
777 |
|
// |
778 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
779 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
780 |
|
} |
781 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
782 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
783 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
784 |
|
// } |
785 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
786 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
787 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
788 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
789 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
790 |
|
// // |
791 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
792 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
793 |
|
// } |
794 |
|
} |
795 |
|
} |
796 |
|
} |
797 |
|
// Cas particulier de la surface taxable démolie |
798 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
799 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
800 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
801 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
802 |
|
// |
803 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
804 |
|
} |
805 |
return $val_dt; |
return $val_dt; |
806 |
} |
} |
807 |
|
|
808 |
|
/** |
809 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
810 |
|
* entre identifiants internes et identifiants externes. |
811 |
|
* |
812 |
|
* @return array |
813 |
|
*/ |
814 |
|
protected function get_list_distinct_objects_external_link() { |
815 |
|
$query = sprintf(' |
816 |
|
SELECT |
817 |
|
DISTINCT(object) |
818 |
|
FROM %1$slien_id_interne_uid_externe |
819 |
|
ORDER BY object ASC |
820 |
|
', |
821 |
|
DB_PREFIXE |
822 |
|
); |
823 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
824 |
|
if ($res['code'] === 'KO') { |
825 |
|
return array(); |
826 |
|
} |
827 |
|
$result = array(); |
828 |
|
foreach ($res['result'] as $object) { |
829 |
|
$result[] = $object['object']; |
830 |
|
} |
831 |
|
return $result; |
832 |
|
} |
833 |
|
|
834 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
835 |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
836 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
837 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
838 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
839 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
840 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
841 |
)); |
)); |
842 |
return $inst_external_uid_da->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
843 |
|
} |
844 |
|
|
845 |
|
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
846 |
|
if (count($link_objects) == 0) { |
847 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
848 |
|
} |
849 |
|
$val_external_uid = array(); |
850 |
|
foreach ($link_objects as $link_object) { |
851 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
852 |
|
if ($external_uid !== '' && $external_uid !== null) { |
853 |
|
$val_external_uid[$link_object] = $external_uid; |
854 |
|
} |
855 |
|
} |
856 |
|
return $val_external_uid; |
857 |
} |
} |
858 |
|
|
859 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
868 |
"obj" => "demandeur", |
"obj" => "demandeur", |
869 |
"idx" => $demandeur['demandeur'], |
"idx" => $demandeur['demandeur'], |
870 |
)); |
)); |
871 |
$val_demandeur[$demandeur['demandeur']] = json_decode($inst_demandeur->get_json_data(), true); |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
872 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
873 |
} |
} |
874 |
return $val_demandeur; |
return $val_demandeur; |
875 |
} |
} |
876 |
|
|
877 |
protected function get_architecte_data($architecte = null) { |
protected function get_architecte_data($architecte = null) { |
878 |
$val_architecte = array(); |
$val_architecte = null; |
879 |
if ($architecte !== null |
if ($architecte !== null |
880 |
&& $architecte !== '') { |
&& $architecte !== '') { |
881 |
// |
// |
883 |
"obj" => "architecte", |
"obj" => "architecte", |
884 |
"idx" => $architecte, |
"idx" => $architecte, |
885 |
)); |
)); |
886 |
$val_architecte = json_decode($inst_architecte->get_json_data(), true); |
$val_architecte = $inst_architecte->get_json_data(); |
887 |
} |
} |
888 |
return $val_architecte; |
return $val_architecte; |
889 |
} |
} |
890 |
|
|
891 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
892 |
$val_instruction = array(); |
$val_instruction = null; |
893 |
|
$instruction_with_doc = null; |
894 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
895 |
"obj" => "dossier", |
"obj" => "dossier", |
896 |
"idx" => $dossier, |
"idx" => $dossier, |
897 |
)); |
)); |
898 |
|
$idx = null; |
899 |
|
if ($type === 'decision') { |
900 |
|
$idx = $inst_di->get_last_instruction_decision(); |
901 |
|
} |
902 |
|
if ($type === 'incompletude') { |
903 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
904 |
|
} |
905 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
906 |
|
if ($type === 'with-id') { |
907 |
|
$idx = $extra_params['with-id']; |
908 |
|
} |
909 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
910 |
"obj" => "instruction", |
"obj" => "instruction", |
911 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
912 |
)); |
)); |
913 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
914 |
$val_instruction = json_decode($inst_instruction->get_json_data(), true); |
$val_instruction = array(); |
915 |
|
$instruction_data = $inst_instruction->get_json_data(); |
916 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
917 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
918 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
919 |
|
// |
920 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
921 |
|
} |
922 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
923 |
|
"obj" => "evenement", |
924 |
|
"idx" => $inst_instruction->getVal('evenement'), |
925 |
|
)); |
926 |
|
if ($inst_ev->getVal('retour') === 't') { |
927 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
928 |
|
foreach ($instructions_related as $instruction) { |
929 |
|
if ($instruction !== null && $instruction !== '') { |
930 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
931 |
|
"obj" => "instruction", |
932 |
|
"idx" => $instruction, |
933 |
|
)); |
934 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
935 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
936 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
937 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
938 |
|
// |
939 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
940 |
|
} |
941 |
|
} |
942 |
|
} |
943 |
|
} |
944 |
|
if ($instruction_with_doc !== null) { |
945 |
|
// |
946 |
|
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
947 |
|
} |
948 |
} |
} |
949 |
return $val_instruction; |
return $val_instruction; |
950 |
} |
} |
951 |
|
|
952 |
|
protected function sort_instruction_data(array $values, array $res) { |
953 |
|
$fields = array( |
954 |
|
"date_evenement", |
955 |
|
"date_envoi_signature", |
956 |
|
"date_retour_signature", |
957 |
|
"date_envoi_rar", |
958 |
|
"date_retour_rar", |
959 |
|
"date_envoi_controle_legalite", |
960 |
|
"date_retour_controle_legalite", |
961 |
|
"signataire_arrete", |
962 |
|
"om_fichier_instruction", |
963 |
|
"tacite", |
964 |
|
"lettretype", |
965 |
|
); |
966 |
|
foreach ($values as $key => $value) { |
967 |
|
if (in_array($key, $fields) === true) { |
968 |
|
if (array_key_exists($key, $res) === false |
969 |
|
&& $value !== null |
970 |
|
&& $value !== '') { |
971 |
|
// |
972 |
|
$res[$key] = $value; |
973 |
|
} elseif ($key === 'tacite' |
974 |
|
&& $value === 't') { |
975 |
|
// |
976 |
|
$res[$key] = $value; |
977 |
|
} |
978 |
|
} |
979 |
|
} |
980 |
|
return $res; |
981 |
|
} |
982 |
|
|
983 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
984 |
$val_dn = array(); |
$val_dn = array(); |
985 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
986 |
"obj" => "document_numerise", |
"obj" => "document_numerise", |
987 |
"idx" => $dn, |
"idx" => $dn, |
988 |
)); |
)); |
989 |
$val_dn = json_decode($inst_dn->get_json_data(), true); |
$val_dn = $inst_dn->get_json_data(); |
990 |
$val_dn['path'] = sprintf('%s/%s&snippet=%s&obj=%s&champ=%s&id=%s', $_SERVER['HTTP_HOST'], 'openads/app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
991 |
|
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
992 |
|
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
993 |
return $val_dn; |
return $val_dn; |
994 |
} |
} |
995 |
|
|
1012 |
return $val_dp; |
return $val_dp; |
1013 |
} |
} |
1014 |
|
|
1015 |
protected function view_form_json() { |
protected function get_avis_decision_data(string $dossier) { |
1016 |
// Mise à jour des valeurs |
$inst_di = $this->f->get_inst__om_dbform(array( |
1017 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
"obj" => "dossier", |
1018 |
&& $this->f->get_submitted_post_value('state') !== null) { |
"idx" => $dossier, |
1019 |
// |
)); |
1020 |
$params = array( |
$ad = $inst_di->getVal('avis_decision'); |
1021 |
'val' => array( |
$val_ad = array(); |
1022 |
'state' => $this->f->get_submitted_post_value('state') |
if ($ad !== null) { |
1023 |
), |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1024 |
); |
"obj" => "avis_decision", |
1025 |
$update = $this->update_task($params); |
"idx" => $ad, |
1026 |
$message_class = "valid"; |
)); |
1027 |
$message = $this->msg; |
$val_ad = $inst_ad->get_json_data(); |
1028 |
if ($update === false) { |
$val_ad['txAvis'] = "Voir document joint"; |
1029 |
$this->addToLog($this->msg, DEBUG_MODE); |
if (isset($val_ad['tacite']) === true |
1030 |
$message_class = "error"; |
&& $val_ad['tacite'] === 't') { |
1031 |
$message = sprintf( |
// |
1032 |
'%s %s', |
$val_ad['txAvis'] = "Sans objet"; |
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
1033 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1034 |
} |
} |
1035 |
// |
return $val_ad; |
1036 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
} |
1037 |
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
1038 |
|
protected function get_signataire_arrete_data(string $sa) { |
1039 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
1040 |
|
"obj" => "signataire_arrete", |
1041 |
|
"idx" => $sa, |
1042 |
|
)); |
1043 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1044 |
|
foreach ($val_sa as $key => $value) { |
1045 |
|
$val_sa[$key] = strip_tags($value); |
1046 |
|
} |
1047 |
|
return $val_sa; |
1048 |
|
} |
1049 |
|
|
1050 |
|
// XXX WIP |
1051 |
|
protected function get_consultation_data(string $consultation) { |
1052 |
|
$val_consultation = array(); |
1053 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1054 |
|
"obj" => "consultation", |
1055 |
|
"idx" => $consultation, |
1056 |
|
)); |
1057 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1058 |
|
if (isset($val_consultation['fichier']) === true |
1059 |
|
&& $val_consultation['fichier'] !== '') { |
1060 |
// |
// |
1061 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
1062 |
"obj" => "lien_id_interne_uid_externe", |
} |
1063 |
"idx" => ']', |
if (isset($val_consultation['om_fichier_consultation']) === true |
1064 |
)); |
&& $val_consultation['om_fichier_consultation'] !== '') { |
1065 |
$valF = array( |
// |
1066 |
'lien_id_interne_uid_externe' => '', |
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
|
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
|
); |
|
|
$add = $inst_lien->ajouter($valF); |
|
|
$message_class = "valid"; |
|
|
$message = $inst_lien->msg; |
|
|
if ($add === false) { |
|
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
1067 |
} |
} |
1068 |
|
return $val_consultation; |
1069 |
|
} |
1070 |
|
|
1071 |
|
// XXX WIP |
1072 |
|
protected function get_service_data(string $service) { |
1073 |
|
$val_service = array(); |
1074 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1075 |
|
"obj" => "service", |
1076 |
|
"idx" => $service, |
1077 |
|
)); |
1078 |
|
$val_service = $inst_service->get_json_data(); |
1079 |
|
return $val_service; |
1080 |
|
} |
1081 |
|
|
1082 |
|
protected function view_form_json($in_field = false) { |
1083 |
// |
// |
1084 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1085 |
|
&& $this->getVal('state') !== self::STATUS_DRAFT) { |
1086 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1087 |
$val = array(); |
$val = array(); |
1088 |
// |
// |
1089 |
$val_task = array_combine($this->champs, $this->val); |
$val_task = array_combine($this->champs, $this->val); |
1090 |
|
foreach ($val_task as $key => $value) { |
1091 |
|
$val_task[$key] = strip_tags($value); |
1092 |
|
} |
1093 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1094 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1095 |
// |
// |
1096 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1097 |
|
|| $this->getVal('type') === 'modification_DA') { |
1098 |
|
// |
1099 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1100 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
1101 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
1102 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1103 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
1104 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1105 |
} |
} |
1106 |
// |
// |
1107 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
1108 |
|| $this->getVal('type') === 'modification_DI') { |
|| $this->getVal('type') === 'modification_DI' |
1109 |
|
|| $this->getVal('type') === 'depot_DI') { |
1110 |
// |
// |
1111 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
1112 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
1113 |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
1114 |
$val['architecte'] = $this->get_architecte_data($val['donnees_techniques']['architecte']); |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
1115 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
1116 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
1117 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1118 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1119 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1120 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1121 |
} |
} |
1122 |
// |
// |
1123 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1124 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
|
1125 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1126 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1127 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1128 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1129 |
} |
} |
1130 |
// |
// |
1131 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
1135 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1136 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1137 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
1138 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1139 |
|
} |
1140 |
|
// |
1141 |
|
if ($this->getVal('type') === 'decision_DI') { |
1142 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1143 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1144 |
|
$val_external_uid = array(); |
1145 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1146 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1147 |
|
$val['external_uids'] = $val_external_uid; |
1148 |
|
} |
1149 |
|
// |
1150 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
1151 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1152 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1153 |
|
$val_external_uid = array(); |
1154 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1155 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1156 |
|
$val['external_uids'] = $val_external_uid; |
1157 |
|
} |
1158 |
|
// |
1159 |
|
if ($this->getVal('type') === 'completude_DI') { |
1160 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1161 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1162 |
|
$val_external_uid = array(); |
1163 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1164 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1165 |
|
$val['external_uids'] = $val_external_uid; |
1166 |
|
} |
1167 |
|
// |
1168 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1169 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1170 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1171 |
|
$val_external_uid = array(); |
1172 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1173 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1174 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1175 |
|
$val['external_uids'] = $val_external_uid; |
1176 |
|
} |
1177 |
|
// |
1178 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1179 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1180 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1181 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1182 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1183 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1184 |
|
} |
1185 |
|
$val_external_uid = array(); |
1186 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1187 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1188 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1189 |
|
$val['external_uids'] = $val_external_uid; |
1190 |
|
} |
1191 |
|
// XXX WIP |
1192 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1193 |
|
// |
1194 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1195 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1196 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1197 |
|
$val_external_uid = array(); |
1198 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1199 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1200 |
|
$val['external_uids'] = $val_external_uid; |
1201 |
} |
} |
1202 |
|
|
1203 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
1204 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1205 |
|
} else { |
1206 |
|
// Liste des valeurs affichée en JSON |
1207 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1208 |
|
} |
1209 |
} |
} |
1210 |
} |
} |
1211 |
|
|
1212 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
1213 |
// |
// Mise à jour des valeurs |
1214 |
$objet = ''; |
|
1215 |
if ($type === 'creation_DA') { |
// Modification de l'état de la tâche |
1216 |
$objet = 'dossier_autorisation'; |
if ($this->f->get_submitted_post_value('state') !== null) { |
1217 |
|
$params = array( |
1218 |
|
'val' => array( |
1219 |
|
'state' => $this->f->get_submitted_post_value('state') |
1220 |
|
), |
1221 |
|
); |
1222 |
|
$update = $this->update_task($params); |
1223 |
|
$message_class = "valid"; |
1224 |
|
$message = $this->msg; |
1225 |
|
if ($update === false) { |
1226 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1227 |
|
$message_class = "error"; |
1228 |
|
$message = sprintf( |
1229 |
|
'%s %s', |
1230 |
|
__('Impossible de mettre à jour la tâche.'), |
1231 |
|
__('Veuillez contacter votre administrateur.') |
1232 |
|
); |
1233 |
|
} |
1234 |
|
$this->f->displayMessage($message_class, $message); |
1235 |
} |
} |
1236 |
if ($type === 'creation_DI' || $type = 'modification_DI') { |
|
1237 |
$objet = 'dossier'; |
// Sauvegarde de l'uid externe retourné |
1238 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1239 |
|
// |
1240 |
|
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1241 |
|
foreach ($objects as $object) { |
1242 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1243 |
|
"obj" => "lien_id_interne_uid_externe", |
1244 |
|
"idx" => ']', |
1245 |
|
)); |
1246 |
|
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1247 |
|
$valF = array( |
1248 |
|
'lien_id_interne_uid_externe' => '', |
1249 |
|
'object' => $object, |
1250 |
|
'object_id' => $this->getVal('object_id'), |
1251 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1252 |
|
'dossier' => $this->getVal('dossier'), |
1253 |
|
); |
1254 |
|
$add = $inst_lien->ajouter($valF); |
1255 |
|
$message_class = "valid"; |
1256 |
|
$message = $inst_lien->msg; |
1257 |
|
if ($add === false) { |
1258 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1259 |
|
$message_class = "error"; |
1260 |
|
$message = sprintf( |
1261 |
|
'%s %s', |
1262 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1263 |
|
__('Veuillez contacter votre administrateur.') |
1264 |
|
); |
1265 |
|
} |
1266 |
|
$this->f->displayMessage($message_class, $message); |
1267 |
|
} |
1268 |
|
} |
1269 |
} |
} |
1270 |
if ($type === 'ajout_piece') { |
} |
1271 |
$objet = 'document_numerise'; |
|
1272 |
|
function post_add_task() { |
1273 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1274 |
|
$result = $this->add_task(array( |
1275 |
|
'val' => array( |
1276 |
|
'stream' => 'input', |
1277 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1278 |
|
'type' => $this->f->get_submitted_post_value('type'), |
1279 |
|
) |
1280 |
|
)); |
1281 |
|
$message = sprintf( |
1282 |
|
__("Tâche %s ajoutée avec succès"), |
1283 |
|
$this->getVal($this->clePrimaire)). |
1284 |
|
'<br/><br/>'. |
1285 |
|
$this->msg; |
1286 |
|
$message_class = "valid"; |
1287 |
|
if ($result === false){ |
1288 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1289 |
|
$message_class = "error"; |
1290 |
|
$message = sprintf( |
1291 |
|
'%s %s', |
1292 |
|
__('Impossible d\'ajouter la tâche.'), |
1293 |
|
__('Veuillez contacter votre administrateur.') |
1294 |
|
); |
1295 |
} |
} |
1296 |
return $objet; |
$this->f->displayMessage($message_class, $message); |
1297 |
} |
} |
1298 |
|
|
1299 |
|
function setLayout(&$form, $maj) { |
1300 |
|
|
1301 |
|
// Récupération du mode de l'action |
1302 |
|
$crud = $this->get_action_crud($maj); |
1303 |
|
|
1304 |
|
// MODE different de CREER |
1305 |
|
if ($maj != 0 || $crud != 'create') { |
1306 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1307 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1308 |
|
$form->setBloc('json_payload', 'F'); |
1309 |
|
} |
1310 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1311 |
|
} |
1312 |
|
|
1313 |
|
/** |
1314 |
|
* [get_objects_by_task_type description] |
1315 |
|
* @param [type] $type [description] |
1316 |
|
* @return [type] [description] |
1317 |
|
*/ |
1318 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1319 |
|
$objects = array(); |
1320 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1321 |
|
$objects = array('dossier_autorisation', ); |
1322 |
|
} |
1323 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1324 |
|
$objects = array('dossier', ); |
1325 |
|
} |
1326 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1327 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1328 |
|
} |
1329 |
|
if (in_array($type, array('create_DI', )) === true |
1330 |
|
&& $stream === 'input') { |
1331 |
|
$objects = array('dossier', 'dossier_autorisation', ); |
1332 |
|
} |
1333 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1334 |
|
$objects = array('instruction', ); |
1335 |
|
} |
1336 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1337 |
|
&& $stream === 'output') { |
1338 |
|
$objects = array('pec_dossier_consultation', ); |
1339 |
|
} |
1340 |
|
if (in_array($type, array('avis_consultation', )) === true |
1341 |
|
&& $stream === 'output') { |
1342 |
|
$objects = array('avis_dossier_consultation', ); |
1343 |
|
} |
1344 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1345 |
|
$objects = array('piece', ); |
1346 |
|
} |
1347 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1348 |
|
$objects = array('consultation', ); |
1349 |
|
} |
1350 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1351 |
|
&& $stream === 'input') { |
1352 |
|
$objects = array('pec_metier_consultation', ); |
1353 |
|
} |
1354 |
|
if (in_array($type, array('avis_consultation', )) === true |
1355 |
|
&& $stream === 'input') { |
1356 |
|
$objects = array('avis_consultation', ); |
1357 |
|
} |
1358 |
|
if (in_array($type, array('create_message', )) === true |
1359 |
|
&& $stream === 'input') { |
1360 |
|
$objects = array('dossier_message', ); |
1361 |
|
} |
1362 |
|
return $objects; |
1363 |
|
} |
1364 |
|
|
1365 |
} |
} |