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