19 |
"view" => "view_json_data", |
"view" => "view_json_data", |
20 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
21 |
); |
); |
22 |
|
$this->class_actions[997] = array( |
23 |
|
"identifier" => "json_data", |
24 |
|
"view" => "post_update_task", |
25 |
|
"permission_suffix" => "modifier", |
26 |
|
); |
27 |
|
$this->class_actions[996] = array( |
28 |
|
"identifier" => "json_data", |
29 |
|
"view" => "post_add_task", |
30 |
|
"permission_suffix" => "ajouter", |
31 |
|
); |
32 |
|
} |
33 |
|
|
34 |
|
public function setvalF($val = array()) { |
35 |
|
parent::setvalF($val); |
36 |
|
// |
37 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
38 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
39 |
|
} |
40 |
|
} |
41 |
|
|
42 |
|
/** |
43 |
|
* |
44 |
|
* @return array |
45 |
|
*/ |
46 |
|
function get_var_sql_forminc__champs() { |
47 |
|
return array( |
48 |
|
"task", |
49 |
|
"type", |
50 |
|
"state", |
51 |
|
"object_id", |
52 |
|
"dossier", |
53 |
|
"stream", |
54 |
|
"json_payload", |
55 |
|
"timestamp_log", |
56 |
|
); |
57 |
|
} |
58 |
|
|
59 |
|
function setType(&$form, $maj) { |
60 |
|
parent::setType($form, $maj); |
61 |
|
// Récupération du mode de l'action |
62 |
|
$crud = $this->get_action_crud($maj); |
63 |
|
|
64 |
|
if ($maj < 2) { |
65 |
|
$form->setType("state", "select"); |
66 |
|
$form->setType("stream", "select"); |
67 |
|
$form->setType("json_payload", "jsonprettyprint"); |
68 |
|
} |
69 |
|
if ($maj == 3){ |
70 |
|
$form->setType('dossier', 'link'); |
71 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
72 |
|
} |
73 |
|
|
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* |
78 |
|
*/ |
79 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
80 |
|
if($maj < 2) { |
81 |
|
$contenu=array(); |
82 |
|
|
83 |
|
$contenu[0][0]="draft"; |
84 |
|
$contenu[1][0]=_('draft'); |
85 |
|
$contenu[0][1]="new"; |
86 |
|
$contenu[1][1]=_('new'); |
87 |
|
$contenu[0][2]="pending"; |
88 |
|
$contenu[1][2]=_('pending'); |
89 |
|
$contenu[0][3]="done"; |
90 |
|
$contenu[1][3]=_('done'); |
91 |
|
$contenu[0][4]="archived"; |
92 |
|
$contenu[1][4]=_('archived'); |
93 |
|
$contenu[0][5]="error"; |
94 |
|
$contenu[1][5]=_('error'); |
95 |
|
$contenu[0][6]="debug"; |
96 |
|
$contenu[1][6]=_('debug'); |
97 |
|
|
98 |
|
$form->setSelect("state", $contenu); |
99 |
|
|
100 |
|
$contenu_stream =array(); |
101 |
|
$contenu_stream[0][0]="input"; |
102 |
|
$contenu_stream[1][0]=_('input'); |
103 |
|
$contenu_stream[0][1]="output"; |
104 |
|
$contenu_stream[1][1]=_('output'); |
105 |
|
$form->setSelect("stream", $contenu_stream); |
106 |
|
|
107 |
|
} |
108 |
|
|
109 |
|
if ($maj == 3) { |
110 |
|
if ($this->getVal('stream') == 'output') { |
111 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
112 |
|
"obj" => "dossier", |
113 |
|
"idx" => $form->val['dossier'], |
114 |
|
)); |
115 |
|
|
116 |
|
if($form->val['type'] == "creation_DA"){ |
117 |
|
$obj_link = 'dossier_autorisation'; |
118 |
|
} else { |
119 |
|
$obj_link = 'dossier_instruction'; |
120 |
|
} |
121 |
|
|
122 |
|
$params = array(); |
123 |
|
$params['obj'] = $obj_link; |
124 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
125 |
|
$params['title'] = "Consulter le dossier"; |
126 |
|
$params['idx'] = $form->val['dossier']; |
127 |
|
$form->setSelect("dossier", $params); |
128 |
|
} |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
|
/** |
133 |
|
* SETTER_FORM - setVal (setVal). |
134 |
|
* |
135 |
|
* @return void |
136 |
|
*/ |
137 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
138 |
|
// parent::setVal($form, $maj, $validation); |
139 |
|
// |
140 |
|
if ($this->getVal('stream') == "output") { |
141 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
142 |
|
} else { |
143 |
|
if ($this->getVal('type') == 'ajout_piece'){ |
144 |
|
// On modifie la valeur du champ "file_content" afin de tronquer le base64 |
145 |
|
$json_payload = json_decode($this->getVal("json_payload"), true); |
146 |
|
$json_payload["document_numerise"]["file_content"] = substr($json_payload["document_numerise"]["file_content"], 0, 64)."[...]"; |
147 |
|
$json_payload_result = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
148 |
|
$form->setVal('json_payload', htmlentities($json_payload_result)); |
149 |
|
} else { |
150 |
|
// |
151 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
152 |
|
} |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
|
function setLib(&$form, $maj) { |
157 |
|
parent::setLib($form, $maj); |
158 |
|
$form->setLib('json_payload', ''); |
159 |
|
} |
160 |
|
|
161 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
162 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
163 |
|
|
164 |
|
if (array_key_exists('timestamp_log', $this->valF) === true |
165 |
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
166 |
|
// |
167 |
|
$this->correct = false; |
168 |
|
$this->addToMessage(sprintf( |
169 |
|
__("Le champ %s doit être dans un format JSON valide."), |
170 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
171 |
|
)); |
172 |
|
} |
173 |
|
|
174 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
175 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
176 |
|
if (isset($this->valF['type']) === false) { |
177 |
|
$this->correct = false; |
178 |
|
$this->addToMessage(sprintf( |
179 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
180 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
181 |
|
)); |
182 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
183 |
|
} |
184 |
|
if (isset($this->valF['json_payload']) === false) { |
185 |
|
$this->correct = false; |
186 |
|
$this->addToMessage(sprintf( |
187 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
188 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
189 |
|
)); |
190 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
191 |
|
} |
192 |
|
} |
193 |
|
|
194 |
|
// le JSON doit être décodable |
195 |
|
if (isset($this->valF['json_payload']) && ! empty($this->valF['json_payload']) && ( |
196 |
|
is_array(json_decode($this->valF['json_payload'], true)) === false |
197 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
198 |
|
$this->correct = false; |
199 |
|
$this->addToMessage(sprintf( |
200 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s)."), |
201 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload'), |
202 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide')) |
203 |
|
)); |
204 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
205 |
|
} |
206 |
|
|
207 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
208 |
|
elseif (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
209 |
|
|
210 |
|
// décode la payload JSON |
211 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
212 |
|
|
213 |
|
// défini une liste de chemin de clés requises |
214 |
|
$paths = array( |
215 |
|
'dossier/dossier' |
216 |
|
); |
217 |
|
|
218 |
|
// tâche de type création de DI/DA |
219 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'creation_DI') { |
220 |
|
|
221 |
|
$paths = array_merge($paths, array( |
222 |
|
'dossier/dossier_autorisation_type_detaille', |
223 |
|
'dossier/date_demande', |
224 |
|
'dossier/depot_electronique', |
225 |
|
)); |
226 |
|
|
227 |
|
// si l'option commune est activée (mode MC) |
228 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
229 |
|
$paths[] = 'dossier/insee'; |
230 |
|
} |
231 |
|
|
232 |
|
// présence d'un moyen d'identifier la collectivité/le service |
233 |
|
if (! isset($json_payload['dossier']['acteur']) && |
234 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
235 |
|
$this->correct = false; |
236 |
|
$this->addToMessage(sprintf( |
237 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
238 |
|
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
239 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
240 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
241 |
|
)); |
242 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
243 |
|
} |
244 |
|
} |
245 |
|
|
246 |
|
// pas d'erreur déjà trouvée |
247 |
|
if($this->correct) { |
248 |
|
|
249 |
|
// pour chaque chemin |
250 |
|
foreach($paths as $path) { |
251 |
|
|
252 |
|
// décompose le chemin |
253 |
|
$tokens = explode('/', $path); |
254 |
|
$cur_depth = $json_payload; |
255 |
|
|
256 |
|
// descend au et à mesure dans l'arborescence du chemin |
257 |
|
foreach($tokens as $token) { |
258 |
|
|
259 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
260 |
|
if (isset($cur_depth[$token]) === false) { |
261 |
|
|
262 |
|
// sinon on produit une erreur |
263 |
|
$this->correct = false; |
264 |
|
$this->addToMessage(sprintf( |
265 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
266 |
|
sprintf('<span class="bold">%s</span>', $path), |
267 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
268 |
|
)); |
269 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
270 |
|
break 2; |
271 |
|
} |
272 |
|
$cur_depth = $cur_depth[$token]; |
273 |
|
} |
274 |
|
} |
275 |
|
} |
276 |
|
} |
277 |
|
|
278 |
|
return $ret && $this->correct; |
279 |
} |
} |
280 |
|
|
281 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
299 |
} |
} |
300 |
|
|
301 |
/** |
/** |
302 |
|
* TRIGGER - triggerajouter. |
303 |
|
* |
304 |
|
* @param string $id |
305 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
306 |
|
* @param array $val Tableau des valeurs brutes. |
307 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
308 |
|
* |
309 |
|
* @return boolean |
310 |
|
*/ |
311 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
312 |
|
|
313 |
|
// tâche entrante |
314 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
315 |
|
|
316 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
317 |
|
// en tant que métadonnées de la tâche |
318 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
319 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
320 |
|
} |
321 |
|
} |
322 |
|
|
323 |
|
/** |
324 |
* TREATMENT - add_task |
* TREATMENT - add_task |
325 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
326 |
* |
* |
332 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
333 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
334 |
)); |
)); |
335 |
|
|
336 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
337 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
338 |
|
if (isset($params['val']['type']) |
339 |
|
&& $params['val']['type'] == "ajout_piece" |
340 |
|
&& isset($params['val']['stream']) |
341 |
|
&& $params['val']['stream'] == "input" ) { |
342 |
|
// |
343 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
344 |
|
$document_numerise = $json_payload['document_numerise']; |
345 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
346 |
|
if ($file_content === false){ |
347 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
348 |
|
return $this->end_treatment(__METHOD__, false); |
349 |
|
} |
350 |
|
$metadata = array( |
351 |
|
"filename" => $document_numerise['nom_fichier'], |
352 |
|
"size" => strlen($file_content), |
353 |
|
"mimetype" => $document_numerise['file_content_type'], |
354 |
|
"date_creation" => $document_numerise['date_creation'], |
355 |
|
); |
356 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
357 |
|
if ($uid_fichier === OP_FAILURE) { |
358 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
359 |
|
return $this->end_treatment(__METHOD__, false); |
360 |
|
} |
361 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
362 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
363 |
|
} |
364 |
|
|
365 |
// Mise à jour du DI |
// Mise à jour du DI |
366 |
$valF = array( |
$valF = array( |
367 |
'task' => '', |
'task' => '', |
368 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
369 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
370 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
371 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
372 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
373 |
|
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
374 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
375 |
); |
); |
376 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
377 |
if ($task_exists !== false) { |
// tâche sortante |
378 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if($valF["stream"] == "output"){ |
379 |
"obj" => "task", |
|
380 |
"idx" => $task_exists, |
// TODO expliquer ce code |
381 |
)); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
382 |
$update_params = array( |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
383 |
'val' => array( |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
384 |
'state' => $inst_task->getVal('state'), |
} |
385 |
), |
if ($task_exists !== false) { |
386 |
); |
$inst_task = $this->f->get_inst__om_dbform(array( |
387 |
return $inst_task->update_task($update_params); |
"obj" => "task", |
388 |
|
"idx" => $task_exists, |
389 |
|
)); |
390 |
|
$update_state = $inst_task->getVal('state'); |
391 |
|
if (isset($params['update_val']['state']) === true) { |
392 |
|
$update_state = $params['update_val']['state']; |
393 |
|
} |
394 |
|
$update_params = array( |
395 |
|
'val' => array( |
396 |
|
'state' => $update_state, |
397 |
|
), |
398 |
|
); |
399 |
|
return $inst_task->update_task($update_params); |
400 |
|
} |
401 |
} |
} |
402 |
|
|
403 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
404 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), DEBUG_MODE); |
405 |
if ($add === false) { |
if ($add === false) { |
406 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
407 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
408 |
} |
} |
409 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
435 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
436 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
437 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
438 |
|
'stream' => $this->getVal('stream'), |
439 |
|
'dossier' => $this->getVal('dossier'), |
440 |
|
'json_payload' => $this->getVal('json_payload'), |
441 |
); |
); |
442 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
443 |
if ($update === false) { |
if ($update === false) { |
496 |
* |
* |
497 |
FROM %1$stask |
FROM %1$stask |
498 |
%2$s |
%2$s |
499 |
|
ORDER BY task ASC |
500 |
', |
', |
501 |
DB_PREFIXE, |
DB_PREFIXE, |
502 |
$where |
$where |
507 |
} |
} |
508 |
$list_tasks = array(); |
$list_tasks = array(); |
509 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
510 |
|
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
511 |
|
$task['dossier'] = $task['object_id']; |
512 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
513 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
514 |
|
$task['dossier'] = $val_dn['dossier']; |
515 |
|
} |
516 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
517 |
} |
} |
518 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
524 |
"obj" => "dossier", |
"obj" => "dossier", |
525 |
"idx" => $dossier, |
"idx" => $dossier, |
526 |
)); |
)); |
527 |
$val_di = json_decode($inst_di->get_json_data(), true); |
$val_di = $inst_di->get_json_data(); |
528 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
529 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
530 |
} |
} |
539 |
"obj" => "dossier_autorisation", |
"obj" => "dossier_autorisation", |
540 |
"idx" => $da, |
"idx" => $da, |
541 |
)); |
)); |
542 |
$val_da = json_decode($inst_da->get_json_data(), true); |
$val_da = $inst_da->get_json_data(); |
543 |
return $val_da; |
return $val_da; |
544 |
} |
} |
545 |
|
|
561 |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
562 |
} |
} |
563 |
} |
} |
564 |
|
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
565 |
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
566 |
|
// |
567 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
568 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
569 |
|
foreach ($fields_tab_surf_dest as $field) { |
570 |
|
if (isset($val_dt[$field]) === true) { |
571 |
|
unset($val_dt[$field]); |
572 |
|
} |
573 |
|
} |
574 |
|
} else { |
575 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
576 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
577 |
|
if (isset($val_dt[$field]) === true) { |
578 |
|
unset($val_dt[$field]); |
579 |
|
} |
580 |
|
} |
581 |
|
} |
582 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
583 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
584 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
585 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
586 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
587 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
588 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
589 |
|
// |
590 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
591 |
|
} |
592 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
593 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
594 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
595 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
596 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
597 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
598 |
|
// |
599 |
|
$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']); |
600 |
|
} |
601 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
602 |
|
$particular_case = false; |
603 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
604 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
605 |
|
if (isset($val_dt[$field]) === false |
606 |
|
|| (isset($val_dt[$field]) === true |
607 |
|
&& ($val_dt[$field] === null |
608 |
|
|| $val_dt[$field] === ''))) { |
609 |
|
// |
610 |
|
$particular_case = true; |
611 |
|
} |
612 |
|
} |
613 |
|
if ($particular_case === true) { |
614 |
|
if (isset($val_dt['tax_ext_pret']) === true |
615 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
616 |
|
// |
617 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
618 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
619 |
|
} |
620 |
|
if (isset($val_dt['tax_ext_pret']) === true |
621 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
622 |
|
// |
623 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
624 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
625 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
626 |
|
// |
627 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
628 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
629 |
|
} |
630 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
631 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
632 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
633 |
|
// } |
634 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
635 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
636 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
637 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
638 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
639 |
|
// // |
640 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
641 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
642 |
|
// } |
643 |
|
} |
644 |
|
} |
645 |
|
} |
646 |
|
// Cas particulier de la surface taxable démolie |
647 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
648 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
649 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
650 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
651 |
|
// |
652 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
653 |
|
} |
654 |
return $val_dt; |
return $val_dt; |
655 |
} |
} |
656 |
|
|
657 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
658 |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
659 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
660 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
661 |
"fk_idx" => $fk_idx, |
"fk_idx" => $fk_idx, |
662 |
"fk_field_2" => 'object', |
"fk_field_2" => 'object', |
663 |
"fk_idx_2" => $fk_idx_2, |
"fk_idx_2" => $fk_idx_2, |
664 |
)); |
)); |
665 |
return $inst_external_uid_da->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
666 |
} |
} |
667 |
|
|
668 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data(string $dossier) { |
677 |
"obj" => "demandeur", |
"obj" => "demandeur", |
678 |
"idx" => $demandeur['demandeur'], |
"idx" => $demandeur['demandeur'], |
679 |
)); |
)); |
680 |
$val_demandeur[$demandeur['demandeur']] = json_decode($inst_demandeur->get_json_data(), true); |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
681 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
682 |
} |
} |
683 |
return $val_demandeur; |
return $val_demandeur; |
684 |
} |
} |
685 |
|
|
686 |
protected function get_architecte_data($architecte = null) { |
protected function get_architecte_data($architecte = null) { |
687 |
$val_architecte = array(); |
$val_architecte = null; |
688 |
if ($architecte !== null |
if ($architecte !== null |
689 |
&& $architecte !== '') { |
&& $architecte !== '') { |
690 |
// |
// |
692 |
"obj" => "architecte", |
"obj" => "architecte", |
693 |
"idx" => $architecte, |
"idx" => $architecte, |
694 |
)); |
)); |
695 |
$val_architecte = json_decode($inst_architecte->get_json_data(), true); |
$val_architecte = $inst_architecte->get_json_data(); |
696 |
} |
} |
697 |
return $val_architecte; |
return $val_architecte; |
698 |
} |
} |
699 |
|
|
700 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
701 |
$val_instruction = array(); |
$val_instruction = null; |
702 |
|
$instruction_with_doc = null; |
703 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
704 |
"obj" => "dossier", |
"obj" => "dossier", |
705 |
"idx" => $dossier, |
"idx" => $dossier, |
706 |
)); |
)); |
707 |
|
$idx = null; |
708 |
|
if ($type === 'decision') { |
709 |
|
$idx = $inst_di->get_last_instruction_decision(); |
710 |
|
} |
711 |
|
if ($type === 'incompletude') { |
712 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
713 |
|
} |
714 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
715 |
"obj" => "instruction", |
"obj" => "instruction", |
716 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
717 |
)); |
)); |
718 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
719 |
$val_instruction = json_decode($inst_instruction->get_json_data(), true); |
$val_instruction = array(); |
720 |
|
$instruction_data = $inst_instruction->get_json_data(); |
721 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
722 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
723 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
724 |
|
// |
725 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
726 |
|
} |
727 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
728 |
|
"obj" => "evenement", |
729 |
|
"idx" => $inst_instruction->getVal('evenement'), |
730 |
|
)); |
731 |
|
if ($inst_ev->getVal('retour') === 't') { |
732 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
733 |
|
foreach ($instructions_related as $instruction) { |
734 |
|
if ($instruction !== null && $instruction !== '') { |
735 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
736 |
|
"obj" => "instruction", |
737 |
|
"idx" => $instruction, |
738 |
|
)); |
739 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
740 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
741 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
742 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
743 |
|
// |
744 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
745 |
|
} |
746 |
|
} |
747 |
|
} |
748 |
|
} |
749 |
|
if ($instruction_with_doc !== null) { |
750 |
|
// |
751 |
|
$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); |
752 |
|
} |
753 |
} |
} |
754 |
return $val_instruction; |
return $val_instruction; |
755 |
} |
} |
756 |
|
|
757 |
|
protected function sort_instruction_data(array $values, array $res) { |
758 |
|
$fields = array( |
759 |
|
"date_envoi_signature", |
760 |
|
"date_retour_signature", |
761 |
|
"date_envoi_rar", |
762 |
|
"date_retour_rar", |
763 |
|
"date_envoi_controle_legalite", |
764 |
|
"date_retour_controle_legalite", |
765 |
|
"signataire_arrete", |
766 |
|
"om_fichier_instruction", |
767 |
|
"tacite", |
768 |
|
"lettretype", |
769 |
|
); |
770 |
|
foreach ($values as $key => $value) { |
771 |
|
if (in_array($key, $fields) === true) { |
772 |
|
if (array_key_exists($key, $res) === false |
773 |
|
&& $value !== null |
774 |
|
&& $value !== '') { |
775 |
|
// |
776 |
|
$res[$key] = $value; |
777 |
|
} elseif ($key === 'tacite' |
778 |
|
&& $value === 't') { |
779 |
|
// |
780 |
|
$res[$key] = $value; |
781 |
|
} |
782 |
|
} |
783 |
|
} |
784 |
|
return $res; |
785 |
|
} |
786 |
|
|
787 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
788 |
$val_dn = array(); |
$val_dn = array(); |
789 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
790 |
"obj" => "document_numerise", |
"obj" => "document_numerise", |
791 |
"idx" => $dn, |
"idx" => $dn, |
792 |
)); |
)); |
793 |
$val_dn = json_decode($inst_dn->get_json_data(), true); |
$val_dn = $inst_dn->get_json_data(); |
794 |
$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')); |
795 |
|
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
796 |
|
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
797 |
return $val_dn; |
return $val_dn; |
798 |
} |
} |
799 |
|
|
816 |
return $val_dp; |
return $val_dp; |
817 |
} |
} |
818 |
|
|
819 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
820 |
// Mise à jour des valeurs |
// |
821 |
if ($this->f->get_submitted_get_value('valid') === 'true' |
if ($this->f->get_submitted_post_value('valid') === null) { |
822 |
&& $this->f->get_submitted_get_value('state') !== null) { |
// Liste des valeurs à afficher |
823 |
|
$val = array(); |
824 |
// |
// |
825 |
$params = array( |
$val_task = array_combine($this->champs, $this->val); |
826 |
'val' => array( |
foreach ($val_task as $key => $value) { |
827 |
'state' => $this->f->get_submitted_get_value('state') |
$val_task[$key] = strip_tags($value); |
|
), |
|
|
); |
|
|
$update = $this->update_task($params); |
|
|
$message_class = "valid"; |
|
|
$message = $this->msg; |
|
|
if ($update === false) { |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
828 |
} |
} |
829 |
$this->f->displayMessage($message_class, $message); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
830 |
} |
$val['task'] = $val_task; |
|
// |
|
|
if ($this->f->get_submitted_get_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_get_value('external_uid') !== null) { |
|
831 |
// |
// |
832 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->getVal('type') === 'creation_DA') { |
833 |
"obj" => "lien_id_interne_uid_externe", |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
834 |
"idx" => ']', |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
835 |
)); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
836 |
$valF = array( |
$val_external_uid = array(); |
837 |
'lien_id_interne_uid_externe' => '', |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
838 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
$val['external_uids'] = $val_external_uid; |
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_get_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.') |
|
|
); |
|
839 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
|
|
|
// Liste des valeurs à afficher |
|
|
$val = array(); |
|
|
// |
|
|
$val_task = array_combine($this->champs, $this->val); |
|
|
$val['task'] = $val_task; |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DA') { |
|
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
|
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val['external_uid'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DI' |
|
|
|| $this->getVal('type') === 'modification_DI') { |
|
840 |
// |
// |
841 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
if ($this->getVal('type') === 'creation_DI' |
842 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
|| $this->getVal('type') === 'modification_DI' |
843 |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
|| $this->getVal('type') === 'depot_DI') { |
844 |
$val['architecte'] = $this->get_architecte_data($val['donnees_techniques']['architecte']); |
// |
845 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
846 |
$val_external_uid = array(); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
847 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
848 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
849 |
$val['external_uid'] = $val_external_uid; |
$val['architecte'] = $this->get_architecte_data($architecte); |
850 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
851 |
|
$val_external_uid = array(); |
852 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
853 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
854 |
|
$val['external_uids'] = $val_external_uid; |
855 |
|
} |
856 |
|
// |
857 |
|
if ($this->getVal('type') === 'qualification_DI') { |
858 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
859 |
|
$val_external_uid = array(); |
860 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
861 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
862 |
|
$val['external_uids'] = $val_external_uid; |
863 |
|
} |
864 |
|
// |
865 |
|
if ($this->getVal('type') === 'ajout_piece') { |
866 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
867 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
868 |
|
$val_external_uid = array(); |
869 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
870 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
871 |
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
872 |
|
$val['external_uids'] = $val_external_uid; |
873 |
|
} |
874 |
|
// |
875 |
|
if ($this->getVal('type') === 'decision_DI') { |
876 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
877 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
878 |
|
$val_external_uid = array(); |
879 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
880 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
881 |
|
$val['external_uids'] = $val_external_uid; |
882 |
|
} |
883 |
|
// |
884 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
885 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
886 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
887 |
|
$val_external_uid = array(); |
888 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
889 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
890 |
|
$val['external_uids'] = $val_external_uid; |
891 |
|
} |
892 |
|
// |
893 |
|
if ($this->getVal('type') === 'completude_DI') { |
894 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
895 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
896 |
|
$val_external_uid = array(); |
897 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
898 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
899 |
|
$val['external_uids'] = $val_external_uid; |
900 |
|
} |
901 |
|
|
902 |
|
if ($in_field === true) { |
903 |
|
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
904 |
|
} else { |
905 |
|
// Liste des valeurs affichée en JSON |
906 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
907 |
|
} |
908 |
} |
} |
909 |
|
} |
910 |
|
|
911 |
|
function post_update_task() { |
912 |
|
// Mise à jour des valeurs |
913 |
// |
// |
914 |
if ($this->getVal('type') === 'qualification_DI') { |
$params = array( |
915 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
'val' => array( |
916 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
'state' => $this->f->get_submitted_post_value('state') |
917 |
$val_external_uid = array(); |
), |
918 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
); |
919 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$update = $this->update_task($params); |
920 |
$val['external_uid'] = $val_external_uid; |
$message_class = "valid"; |
921 |
|
$message = $this->msg; |
922 |
|
if ($update === false) { |
923 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
924 |
|
$message_class = "error"; |
925 |
|
$message = sprintf( |
926 |
|
'%s %s', |
927 |
|
__('Impossible de mettre à jour la tâche.'), |
928 |
|
__('Veuillez contacter votre administrateur.') |
929 |
|
); |
930 |
} |
} |
931 |
|
$this->f->displayMessage($message_class, $message); |
932 |
// |
// |
933 |
if ($this->getVal('type') === 'ajout_piece') { |
$inst_lien = $this->f->get_inst__om_dbform(array( |
934 |
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
"obj" => "lien_id_interne_uid_externe", |
935 |
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
"idx" => ']', |
936 |
$val_external_uid = array(); |
)); |
937 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$valF = array( |
938 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
'lien_id_interne_uid_externe' => '', |
939 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
940 |
$val['external_uid'] = $val_external_uid; |
'object_id' => $this->getVal('object_id'), |
941 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
942 |
|
); |
943 |
|
$add = $inst_lien->ajouter($valF); |
944 |
|
$message_class = "valid"; |
945 |
|
$message = $inst_lien->msg; |
946 |
|
if ($add === false) { |
947 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
948 |
|
$message_class = "error"; |
949 |
|
$message = sprintf( |
950 |
|
'%s %s', |
951 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
952 |
|
__('Veuillez contacter votre administrateur.') |
953 |
|
); |
954 |
} |
} |
955 |
|
$this->f->displayMessage($message_class, $message); |
956 |
|
} |
957 |
|
|
958 |
// Liste des valeurs affichée en JSON |
function post_add_task() { |
959 |
printf(json_encode($val)); |
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
960 |
|
$result = $this->add_task(array( |
961 |
|
'val' => array( |
962 |
|
'stream' => 'input', |
963 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
964 |
|
'type' => $this->f->get_submitted_post_value('type'), |
965 |
|
) |
966 |
|
)); |
967 |
|
$message = $this->msg; |
968 |
|
$message_class = "valid"; |
969 |
|
if ($result === false){ |
970 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
971 |
|
$message_class = "error"; |
972 |
|
$message = sprintf( |
973 |
|
'%s %s', |
974 |
|
__('Impossible d\'ajouter la tâche.'), |
975 |
|
__('Veuillez contacter votre administrateur.') |
976 |
|
); |
977 |
|
} |
978 |
|
$this->f->displayMessage($message_class, $message); |
979 |
} |
} |
980 |
|
|
981 |
protected function get_lien_objet_by_type($type) { |
function get_lien_objet_by_type($type) { |
982 |
// |
// |
983 |
$objet = ''; |
$objet = ''; |
984 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
985 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
986 |
} |
} |
987 |
if ($type === 'creation_DI' || $type = 'modification_DI') { |
if ($type === 'creation_DI' |
988 |
|
|| $type === 'depot_DI' |
989 |
|
|| $type === 'modification_DI' |
990 |
|
|| $type === 'qualification_DI' |
991 |
|
|| $type === 'decision_DI' |
992 |
|
|| $type === 'incompletude_DI' |
993 |
|
|| $type === 'completude_DI') { |
994 |
|
// |
995 |
$objet = 'dossier'; |
$objet = 'dossier'; |
996 |
} |
} |
997 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
999 |
} |
} |
1000 |
return $objet; |
return $objet; |
1001 |
} |
} |
1002 |
|
|
1003 |
|
function setLayout(&$form, $maj) { |
1004 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1005 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1006 |
|
$form->setBloc('json_payload', 'F'); |
1007 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1008 |
|
} |
1009 |
|
|
1010 |
} |
} |