1 |
<?php |
<?php |
2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
|
5 |
require_once "../gen/obj/task.class.php"; |
require_once "../gen/obj/task.class.php"; |
6 |
|
|
7 |
class task extends task_gen { |
class task extends task_gen { |
8 |
|
|
9 |
|
const STATUS_DRAFT = 'draft'; |
10 |
|
const STATUS_NEW = 'new'; |
11 |
|
const STATUS_PENDING = 'pending'; |
12 |
|
const STATUS_DONE = 'done'; |
13 |
|
const STATUS_ERROR = 'error'; |
14 |
|
const STATUS_DEBUG = 'debug'; |
15 |
|
const STATUS_ARCHIVED = 'archived'; |
16 |
|
|
17 |
/** |
/** |
18 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
19 |
* |
* |
27 |
"view" => "view_json_data", |
"view" => "view_json_data", |
28 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
29 |
); |
); |
30 |
|
$this->class_actions[997] = array( |
31 |
|
"identifier" => "json_data", |
32 |
|
"view" => "post_update_task", |
33 |
|
"permission_suffix" => "modifier", |
34 |
|
); |
35 |
|
$this->class_actions[996] = array( |
36 |
|
"identifier" => "json_data", |
37 |
|
"view" => "post_add_task", |
38 |
|
"permission_suffix" => "ajouter", |
39 |
|
); |
40 |
|
} |
41 |
|
|
42 |
|
public function setvalF($val = array()) { |
43 |
|
|
44 |
|
// les guillets doubles sont remplacés automatiquement par des simples |
45 |
|
// dans core/om_formulaire.clasS.php::recupererPostvar() |
46 |
|
// voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
47 |
|
// ceci est un hack sale temporaire en attendant résolution du ticket |
48 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
49 |
|
if (isset($val[$key]) && ! empty($val[$key]) && |
50 |
|
isset($_POST[$key]) && ! empty($_POST[$key])) { |
51 |
|
$submited_payload = $_POST[$key]; |
52 |
|
if (! empty($submited_payload)) { |
53 |
|
$new_payload = str_replace("'", '"', $val[$key]); |
54 |
|
if ($new_payload == $submited_payload || |
55 |
|
strpos($submited_payload, '"') === false) { |
56 |
|
$val[$key] = $new_payload; |
57 |
|
} |
58 |
|
else { |
59 |
|
$error_msg = sprintf( |
60 |
|
__("La convertion des guillemets de la payload JSON '%s' ". |
61 |
|
"n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
62 |
|
$key, var_export($val[$key], true), var_export($submited_payload, true), |
63 |
|
var_export($new_payload, true)); |
64 |
|
$this->correct = false; |
65 |
|
$this->addToMessage($error_msg); |
66 |
|
$this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
67 |
|
return false; |
68 |
|
} |
69 |
|
} |
70 |
|
} |
71 |
|
} |
72 |
|
|
73 |
|
parent::setvalF($val); |
74 |
|
|
75 |
|
// récupération de l'ID de l'objet existant |
76 |
|
$id = property_exists($this, 'id') ? $this->id : null; |
77 |
|
if(isset($val[$this->clePrimaire])) { |
78 |
|
$id = $val[$this->clePrimaire]; |
79 |
|
} elseif(isset($this->valF[$this->clePrimaire])) { |
80 |
|
$id = $this->valF[$this->clePrimaire]; |
81 |
|
} |
82 |
|
|
83 |
|
// MODE MODIFIER |
84 |
|
if (! empty($id)) { |
85 |
|
|
86 |
|
// si aucune payload n'est fourni (devrait toujours être le cas) |
87 |
|
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
88 |
|
|
89 |
|
// récupère l'objet existant |
90 |
|
$existing = $this->f->findObjectById(get_class($this), $id); |
91 |
|
if (! empty($existing)) { |
92 |
|
|
93 |
|
// récupère la payload de l'objet |
94 |
|
$val['json_payload'] = $existing->getVal('json_payload'); |
95 |
|
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
96 |
|
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
97 |
|
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
98 |
|
} |
99 |
|
} |
100 |
|
} |
101 |
|
} |
102 |
|
|
103 |
|
/** |
104 |
|
* |
105 |
|
* @return array |
106 |
|
*/ |
107 |
|
function get_var_sql_forminc__champs() { |
108 |
|
return array( |
109 |
|
"task", |
110 |
|
"type", |
111 |
|
"state", |
112 |
|
"object_id", |
113 |
|
"dossier", |
114 |
|
"stream", |
115 |
|
"json_payload", |
116 |
|
"timestamp_log", |
117 |
|
); |
118 |
|
} |
119 |
|
|
120 |
|
function setType(&$form, $maj) { |
121 |
|
parent::setType($form, $maj); |
122 |
|
|
123 |
|
// Récupération du mode de l'action |
124 |
|
$crud = $this->get_action_crud($maj); |
125 |
|
|
126 |
|
// MODE CREER |
127 |
|
if ($maj == 0 || $crud == 'create') { |
128 |
|
$form->setType("state", "select"); |
129 |
|
$form->setType("stream", "select"); |
130 |
|
$form->setType("json_payload", "textarea"); |
131 |
|
} |
132 |
|
// MDOE MODIFIER |
133 |
|
if ($maj == 1 || $crud == 'update') { |
134 |
|
$form->setType("state", "select"); |
135 |
|
$form->setType("stream", "select"); |
136 |
|
$form->setType("json_payload", "jsonprettyprint"); |
137 |
|
} |
138 |
|
// MODE CONSULTER |
139 |
|
if ($maj == 3 || $crud == 'read') { |
140 |
|
$form->setType('dossier', 'link'); |
141 |
|
$form->setType('json_payload', 'jsonprettyprint'); |
142 |
|
} |
143 |
|
|
144 |
|
} |
145 |
|
|
146 |
|
/** |
147 |
|
* |
148 |
|
*/ |
149 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
150 |
|
if($maj < 2) { |
151 |
|
|
152 |
|
$contenu = array(); |
153 |
|
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
154 |
|
$const_name = 'STATUS_'.$key; |
155 |
|
$const_value = constant("self::$const_name"); |
156 |
|
$contenu[0][] = $const_value; |
157 |
|
$contenu[1][] = __($const_value); |
158 |
|
} |
159 |
|
|
160 |
|
$form->setSelect("state", $contenu); |
161 |
|
|
162 |
|
$contenu_stream =array(); |
163 |
|
$contenu_stream[0][0]="input"; |
164 |
|
$contenu_stream[1][0]=_('input'); |
165 |
|
$contenu_stream[0][1]="output"; |
166 |
|
$contenu_stream[1][1]=_('output'); |
167 |
|
$form->setSelect("stream", $contenu_stream); |
168 |
|
|
169 |
|
} |
170 |
|
|
171 |
|
if ($maj == 3) { |
172 |
|
if ($this->getVal('stream') == 'output') { |
173 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
174 |
|
"obj" => "dossier", |
175 |
|
"idx" => $form->val['dossier'], |
176 |
|
)); |
177 |
|
|
178 |
|
if($form->val['type'] == "creation_DA"){ |
179 |
|
$obj_link = 'dossier_autorisation'; |
180 |
|
} else { |
181 |
|
$obj_link = 'dossier_instruction'; |
182 |
|
} |
183 |
|
|
184 |
|
$params = array(); |
185 |
|
$params['obj'] = $obj_link; |
186 |
|
$params['libelle'] = $inst_dossier->getVal('dossier'); |
187 |
|
$params['title'] = "Consulter le dossier"; |
188 |
|
$params['idx'] = $form->val['dossier']; |
189 |
|
$form->setSelect("dossier", $params); |
190 |
|
} |
191 |
|
} |
192 |
|
} |
193 |
|
|
194 |
|
/** |
195 |
|
* SETTER_FORM - setVal (setVal). |
196 |
|
* |
197 |
|
* @return void |
198 |
|
*/ |
199 |
|
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
200 |
|
// parent::setVal($form, $maj, $validation); |
201 |
|
// |
202 |
|
if ($this->getVal('stream') == "output") { |
203 |
|
$form->setVal('json_payload', $this->view_form_json(true)); |
204 |
|
} else { |
205 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
206 |
|
} |
207 |
|
} |
208 |
|
|
209 |
|
function setLib(&$form, $maj) { |
210 |
|
parent::setLib($form, $maj); |
211 |
|
|
212 |
|
// Récupération du mode de l'action |
213 |
|
$crud = $this->get_action_crud($maj); |
214 |
|
|
215 |
|
// MODE different de CREER |
216 |
|
if ($maj != 0 || $crud != 'create') { |
217 |
|
$form->setLib('json_payload', ''); |
218 |
|
} |
219 |
|
} |
220 |
|
|
221 |
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
222 |
|
$ret = parent::verifier($val, $dnu1, $dnu2); |
223 |
|
|
224 |
|
// une tâche entrante doit avoir un type et une payload non-vide |
225 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
226 |
|
if (isset($this->valF['type']) === false) { |
227 |
|
$this->correct = false; |
228 |
|
$this->addToMessage(sprintf( |
229 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
230 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
231 |
|
)); |
232 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
233 |
|
} |
234 |
|
if (isset($this->valF['json_payload']) === false) { |
235 |
|
$this->correct = false; |
236 |
|
$this->addToMessage(sprintf( |
237 |
|
__("Le champ %s est obligatoire pour une tâche entrante."), |
238 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
239 |
|
)); |
240 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
241 |
|
} |
242 |
|
} |
243 |
|
|
244 |
|
// les JSONs doivent être décodables |
245 |
|
foreach(array('json_payload', 'timestamp_log') as $key) { |
246 |
|
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
247 |
|
is_array(json_decode($this->valF[$key], true)) === false |
248 |
|
|| json_last_error() !== JSON_ERROR_NONE)) { |
249 |
|
$this->correct = false; |
250 |
|
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
251 |
|
$this->addToMessage(sprintf( |
252 |
|
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
253 |
|
"<p>%s valF:</br><pre>%s</pre></p>". |
254 |
|
"<p>%s val:</br><pre>%s</pre></p>". |
255 |
|
"<p>%s POST:</br><pre>%s</pre></p>". |
256 |
|
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
257 |
|
$champ_text, |
258 |
|
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
259 |
|
$champ_text, |
260 |
|
$this->valF[$key], |
261 |
|
$champ_text, |
262 |
|
$val[$key], |
263 |
|
$champ_text, |
264 |
|
isset($_POST[$key]) ? $_POST[$key] : '', |
265 |
|
$champ_text, |
266 |
|
$this->f->get_submitted_post_value($key) |
267 |
|
)); |
268 |
|
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
269 |
|
} |
270 |
|
} |
271 |
|
|
272 |
|
// une tâche entrante doit avoir une payload avec les clés requises |
273 |
|
if ($this->correct && (isset($this->valF['stream']) === false || |
274 |
|
$this->valF['stream'] == 'input')) { |
275 |
|
|
276 |
|
// décode la payload JSON |
277 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
278 |
|
|
279 |
|
// défini une liste de chemin de clés requises |
280 |
|
$paths = array( |
281 |
|
'external_uids/dossier' |
282 |
|
); |
283 |
|
|
284 |
|
// tâche de type création de DI/DA |
285 |
|
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
286 |
|
|
287 |
|
$paths = array_merge($paths, array( |
288 |
|
'dossier/dossier', |
289 |
|
'dossier/dossier_autorisation_type_detaille_code', |
290 |
|
'dossier/date_demande', |
291 |
|
'dossier/depot_electronique', |
292 |
|
)); |
293 |
|
|
294 |
|
// si l'option commune est activée (mode MC) |
295 |
|
if ($this->f->is_option_dossier_commune_enabled()) { |
296 |
|
$paths[] = 'dossier/insee'; |
297 |
|
} |
298 |
|
|
299 |
|
// présence d'un moyen d'identifier la collectivité/le service |
300 |
|
if (! isset($json_payload['dossier']['acteur']) && |
301 |
|
! isset($json_payload['dossier']['om_collectivite'])) { |
302 |
|
$this->correct = false; |
303 |
|
$this->addToMessage(sprintf( |
304 |
|
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
305 |
|
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
306 |
|
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
307 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
308 |
|
)); |
309 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
310 |
|
} |
311 |
|
} |
312 |
|
|
313 |
|
// pas d'erreur déjà trouvée |
314 |
|
if($this->correct) { |
315 |
|
|
316 |
|
// pour chaque chemin |
317 |
|
foreach($paths as $path) { |
318 |
|
|
319 |
|
// décompose le chemin |
320 |
|
$tokens = explode('/', $path); |
321 |
|
$cur_depth = $json_payload; |
322 |
|
|
323 |
|
// descend au et à mesure dans l'arborescence du chemin |
324 |
|
foreach($tokens as $token) { |
325 |
|
|
326 |
|
// en vérifiant que chaque élément du chemin est défini et non-nul |
327 |
|
if (isset($cur_depth[$token]) === false) { |
328 |
|
|
329 |
|
// sinon on produit une erreur |
330 |
|
$this->correct = false; |
331 |
|
$this->addToMessage(sprintf( |
332 |
|
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
333 |
|
sprintf('<span class="bold">%s</span>', $path), |
334 |
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
335 |
|
)); |
336 |
|
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
337 |
|
break 2; |
338 |
|
} |
339 |
|
$cur_depth = $cur_depth[$token]; |
340 |
|
} |
341 |
|
} |
342 |
|
} |
343 |
|
} |
344 |
|
|
345 |
|
return $ret && $this->correct; |
346 |
} |
} |
347 |
|
|
348 |
protected function task_exists(string $type, string $object_id) { |
protected function task_exists(string $type, string $object_id) { |
354 |
AND object_id = \'%4$s\' |
AND object_id = \'%4$s\' |
355 |
', |
', |
356 |
DB_PREFIXE, |
DB_PREFIXE, |
357 |
'done', |
self::STATUS_DONE, |
358 |
$type, |
$type, |
359 |
$object_id |
$object_id |
360 |
); |
); |
366 |
} |
} |
367 |
|
|
368 |
/** |
/** |
369 |
|
* TRIGGER - triggerajouter. |
370 |
|
* |
371 |
|
* @param string $id |
372 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
373 |
|
* @param array $val Tableau des valeurs brutes. |
374 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
375 |
|
* |
376 |
|
* @return boolean |
377 |
|
*/ |
378 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
379 |
|
|
380 |
|
// tâche entrante |
381 |
|
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
382 |
|
|
383 |
|
// décode la paylod JSON pour extraire les données métiers à ajouter |
384 |
|
// en tant que métadonnées de la tâche |
385 |
|
$json_payload = json_decode($this->valF['json_payload'], true); |
386 |
|
|
387 |
|
// si la tâche possède déjà une clé dossier |
388 |
|
if (isset($json_payload['dossier']['dossier']) && |
389 |
|
! empty($json_payload['dossier']['dossier'])) { |
390 |
|
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
391 |
|
} |
392 |
|
|
393 |
|
/** |
394 |
|
* Puisque le dossier n'a potentiellement pas encore été créé |
395 |
|
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
396 |
|
* à partir de l'external_uids (en passant par la table de liens) |
397 |
|
// sinon si la tâche possède une clé external_uids/dossier |
398 |
|
elseif(isset($json_payload['external_uids']['dossier']) && |
399 |
|
! empty($json_payload['external_uids']['dossier'])) { |
400 |
|
|
401 |
|
// instancie l'objet lien_id_interne_uid_externe |
402 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
403 |
|
"obj" => "lien_id_interne_uid_externe", |
404 |
|
"idx" => ']', |
405 |
|
)); |
406 |
|
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
407 |
|
$json_payload['external_uids']['dossier'])){ |
408 |
|
$error_msg = sprintf( |
409 |
|
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
410 |
|
$json_payload['external_uids']['dossier']); |
411 |
|
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
412 |
|
$this->addToMessage($error_msg); |
413 |
|
$this->correct = false; |
414 |
|
return false; |
415 |
|
} |
416 |
|
$this->valF["dossier"] = $dossier; |
417 |
|
}*/ |
418 |
|
} |
419 |
|
} |
420 |
|
|
421 |
|
/** |
422 |
* TREATMENT - add_task |
* TREATMENT - add_task |
423 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
424 |
* |
* |
430 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
431 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
432 |
)); |
)); |
433 |
|
|
434 |
|
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
435 |
|
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
436 |
|
if (isset($params['val']['type']) |
437 |
|
&& $params['val']['type'] == "add_piece" |
438 |
|
&& isset($params['val']['stream']) |
439 |
|
&& $params['val']['stream'] == "input" ) { |
440 |
|
// |
441 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
442 |
|
$document_numerise = $json_payload['document_numerise']; |
443 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
444 |
|
if ($file_content === false){ |
445 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
446 |
|
return $this->end_treatment(__METHOD__, false); |
447 |
|
} |
448 |
|
$metadata = array( |
449 |
|
"filename" => $document_numerise['nom_fichier'], |
450 |
|
"size" => strlen($file_content), |
451 |
|
"mimetype" => $document_numerise['file_content_type'], |
452 |
|
"date_creation" => $document_numerise['date_creation'], |
453 |
|
); |
454 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
455 |
|
if ($uid_fichier === OP_FAILURE) { |
456 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
457 |
|
return $this->end_treatment(__METHOD__, false); |
458 |
|
} |
459 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
460 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
461 |
|
unset($json_payload["document_numerise"]["file_content"]); |
462 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
463 |
|
} |
464 |
|
|
465 |
// Mise à jour du DI |
// Mise à jour du DI |
466 |
$valF = array( |
$valF = array( |
467 |
'task' => '', |
'task' => '', |
468 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
469 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
470 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
471 |
'object_id' => $params['val']['object_id'], |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
472 |
|
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
473 |
|
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
474 |
|
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
475 |
); |
); |
476 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
|
477 |
if ($task_exists !== false) { |
// tâche sortante |
478 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if($valF["stream"] == "output"){ |
479 |
"obj" => "task", |
|
480 |
"idx" => $task_exists, |
// TODO expliquer ce code |
481 |
)); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
482 |
$update_params = array( |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
483 |
'val' => array( |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
484 |
'state' => $inst_task->getVal('state'), |
} |
485 |
), |
if ($task_exists !== false) { |
486 |
); |
$inst_task = $this->f->get_inst__om_dbform(array( |
487 |
return $inst_task->update_task($update_params); |
"obj" => "task", |
488 |
|
"idx" => $task_exists, |
489 |
|
)); |
490 |
|
$update_state = $inst_task->getVal('state'); |
491 |
|
if (isset($params['update_val']['state']) === true) { |
492 |
|
$update_state = $params['update_val']['state']; |
493 |
|
} |
494 |
|
$update_params = array( |
495 |
|
'val' => array( |
496 |
|
'state' => $update_state, |
497 |
|
), |
498 |
|
); |
499 |
|
return $inst_task->update_task($update_params); |
500 |
|
} |
501 |
} |
} |
502 |
|
|
503 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
504 |
|
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
505 |
if ($add === false) { |
if ($add === false) { |
506 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
507 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
508 |
} |
} |
509 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
520 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
521 |
$timestamp_log = $this->get_timestamp_log(); |
$timestamp_log = $this->get_timestamp_log(); |
522 |
if ($timestamp_log === false) { |
if ($timestamp_log === false) { |
523 |
$this->addToLog(__('XXX'), DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
524 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
525 |
} |
} |
526 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
535 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
536 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
537 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
538 |
|
'stream' => $this->getVal('stream'), |
539 |
|
'dossier' => $this->getVal('dossier'), |
540 |
|
'json_payload' => $this->getVal('json_payload'), |
541 |
); |
); |
542 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
543 |
if ($update === false) { |
if ($update === false) { |
550 |
/** |
/** |
551 |
* 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 |
552 |
* l'enregistrement instancié. |
* l'enregistrement instancié. |
553 |
* |
* |
554 |
* @param array $params Tableau des paramètres |
* @param array $params Tableau des paramètres |
555 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
556 |
*/ |
*/ |
596 |
* |
* |
597 |
FROM %1$stask |
FROM %1$stask |
598 |
%2$s |
%2$s |
599 |
|
ORDER BY task ASC |
600 |
', |
', |
601 |
DB_PREFIXE, |
DB_PREFIXE, |
602 |
$where |
$where |
608 |
$list_tasks = array(); |
$list_tasks = array(); |
609 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
610 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
611 |
|
$task['dossier'] = $task['object_id']; |
612 |
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
613 |
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
614 |
|
$task['dossier'] = $val_dn['dossier']; |
615 |
|
} |
616 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
617 |
} |
} |
618 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
663 |
} |
} |
664 |
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
665 |
$val_dt['tax_statut_info'] = 'Déclaré'; |
$val_dt['tax_statut_info'] = 'Déclaré'; |
666 |
|
// |
667 |
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
668 |
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
669 |
|
foreach ($fields_tab_surf_dest as $field) { |
670 |
|
if (isset($val_dt[$field]) === true) { |
671 |
|
unset($val_dt[$field]); |
672 |
|
} |
673 |
|
} |
674 |
|
} else { |
675 |
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
676 |
|
foreach ($fields_tab_surf_ssdest as $field) { |
677 |
|
if (isset($val_dt[$field]) === true) { |
678 |
|
unset($val_dt[$field]); |
679 |
|
} |
680 |
|
} |
681 |
|
} |
682 |
|
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
683 |
|
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
684 |
|
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
685 |
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
686 |
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
687 |
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
688 |
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
689 |
|
// |
690 |
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
691 |
|
} |
692 |
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
693 |
|
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
694 |
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
695 |
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
696 |
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
697 |
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
698 |
|
// |
699 |
|
$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']); |
700 |
|
} |
701 |
|
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
702 |
|
$particular_case = false; |
703 |
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
704 |
|
foreach ($fields_tab_crea_loc_hab as $field) { |
705 |
|
if (isset($val_dt[$field]) === false |
706 |
|
|| (isset($val_dt[$field]) === true |
707 |
|
&& ($val_dt[$field] === null |
708 |
|
|| $val_dt[$field] === ''))) { |
709 |
|
// |
710 |
|
$particular_case = true; |
711 |
|
} |
712 |
|
} |
713 |
|
if ($particular_case === true) { |
714 |
|
if (isset($val_dt['tax_ext_pret']) === true |
715 |
|
&& $val_dt['tax_ext_pret'] === 'f') { |
716 |
|
// |
717 |
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
718 |
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
719 |
|
} |
720 |
|
if (isset($val_dt['tax_ext_pret']) === true |
721 |
|
&& $val_dt['tax_ext_pret'] === 't') { |
722 |
|
// |
723 |
|
if (isset($val_dt['tax_ext_desc']) === true) { |
724 |
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
725 |
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
726 |
|
// |
727 |
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
728 |
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
729 |
|
} |
730 |
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
731 |
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
732 |
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
733 |
|
// } |
734 |
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
735 |
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
736 |
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
737 |
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
738 |
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
739 |
|
// // |
740 |
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
741 |
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
742 |
|
// } |
743 |
|
} |
744 |
|
} |
745 |
|
} |
746 |
|
// Cas particulier de la surface taxable démolie |
747 |
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
748 |
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
749 |
|
&& ($val_dt['tax_surf_tot_demo'] === null |
750 |
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
751 |
|
// |
752 |
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
753 |
|
} |
754 |
return $val_dt; |
return $val_dt; |
755 |
} |
} |
756 |
|
|
779 |
)); |
)); |
780 |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
781 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
|
// Valeur par défaut pour expériementation sequence 1 |
|
|
$val_demandeur[$demandeur['demandeur']]['commerciale'] = 'f'; |
|
782 |
} |
} |
783 |
return $val_demandeur; |
return $val_demandeur; |
784 |
} |
} |
785 |
|
|
786 |
protected function get_architecte_data($architecte = null) { |
protected function get_architecte_data($architecte = null) { |
787 |
$val_architecte = array(); |
$val_architecte = null; |
788 |
if ($architecte !== null |
if ($architecte !== null |
789 |
&& $architecte !== '') { |
&& $architecte !== '') { |
790 |
// |
// |
797 |
return $val_architecte; |
return $val_architecte; |
798 |
} |
} |
799 |
|
|
800 |
protected function get_instruction_data(string $dossier) { |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
801 |
$val_instruction = array(); |
$val_instruction = null; |
802 |
|
$instruction_with_doc = null; |
803 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
804 |
"obj" => "dossier", |
"obj" => "dossier", |
805 |
"idx" => $dossier, |
"idx" => $dossier, |
806 |
)); |
)); |
807 |
|
$idx = null; |
808 |
|
if ($type === 'decision') { |
809 |
|
$idx = $inst_di->get_last_instruction_decision(); |
810 |
|
} |
811 |
|
if ($type === 'incompletude') { |
812 |
|
$idx = $inst_di->get_last_instruction_incompletude(); |
813 |
|
} |
814 |
|
// XXX Permet de récupérer l'instruction par son identifiant |
815 |
|
if ($type === 'with-id') { |
816 |
|
$idx = $extra_params['with-id']; |
817 |
|
} |
818 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
819 |
"obj" => "instruction", |
"obj" => "instruction", |
820 |
"idx" => $inst_di->get_last_instruction_decision(), |
"idx" => $idx, |
821 |
)); |
)); |
822 |
if (count($inst_instruction->val) > 0) { |
if (count($inst_instruction->val) > 0) { |
823 |
$val_instruction = $inst_instruction->get_json_data(); |
$val_instruction = array(); |
824 |
|
$instruction_data = $inst_instruction->get_json_data(); |
825 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
826 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
827 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
828 |
|
// |
829 |
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
830 |
|
} |
831 |
|
$inst_ev = $this->f->get_inst__om_dbform(array( |
832 |
|
"obj" => "evenement", |
833 |
|
"idx" => $inst_instruction->getVal('evenement'), |
834 |
|
)); |
835 |
|
if ($inst_ev->getVal('retour') === 't') { |
836 |
|
$instructions_related = $inst_instruction->get_related_instructions(); |
837 |
|
foreach ($instructions_related as $instruction) { |
838 |
|
if ($instruction !== null && $instruction !== '') { |
839 |
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
840 |
|
"obj" => "instruction", |
841 |
|
"idx" => $instruction, |
842 |
|
)); |
843 |
|
$instruction_data = $inst_related_instruction->get_json_data(); |
844 |
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
845 |
|
if ($instruction_data['om_fichier_instruction'] !== null |
846 |
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
847 |
|
// |
848 |
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
849 |
|
} |
850 |
|
} |
851 |
|
} |
852 |
|
} |
853 |
|
if ($instruction_with_doc !== null) { |
854 |
|
// |
855 |
|
$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); |
856 |
|
} |
857 |
} |
} |
858 |
return $val_instruction; |
return $val_instruction; |
859 |
} |
} |
860 |
|
|
861 |
|
protected function sort_instruction_data(array $values, array $res) { |
862 |
|
$fields = array( |
863 |
|
"date_evenement", |
864 |
|
"date_envoi_signature", |
865 |
|
"date_retour_signature", |
866 |
|
"date_envoi_rar", |
867 |
|
"date_retour_rar", |
868 |
|
"date_envoi_controle_legalite", |
869 |
|
"date_retour_controle_legalite", |
870 |
|
"signataire_arrete", |
871 |
|
"om_fichier_instruction", |
872 |
|
"tacite", |
873 |
|
"lettretype", |
874 |
|
); |
875 |
|
foreach ($values as $key => $value) { |
876 |
|
if (in_array($key, $fields) === true) { |
877 |
|
if (array_key_exists($key, $res) === false |
878 |
|
&& $value !== null |
879 |
|
&& $value !== '') { |
880 |
|
// |
881 |
|
$res[$key] = $value; |
882 |
|
} elseif ($key === 'tacite' |
883 |
|
&& $value === 't') { |
884 |
|
// |
885 |
|
$res[$key] = $value; |
886 |
|
} |
887 |
|
} |
888 |
|
} |
889 |
|
return $res; |
890 |
|
} |
891 |
|
|
892 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
893 |
$val_dn = array(); |
$val_dn = array(); |
894 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
896 |
"idx" => $dn, |
"idx" => $dn, |
897 |
)); |
)); |
898 |
$val_dn = $inst_dn->get_json_data(); |
$val_dn = $inst_dn->get_json_data(); |
899 |
$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')); |
900 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
901 |
$val_dn['nature'] = 'Initiale'; |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
902 |
return $val_dn; |
return $val_dn; |
903 |
} |
} |
904 |
|
|
921 |
return $val_dp; |
return $val_dp; |
922 |
} |
} |
923 |
|
|
924 |
protected function view_form_json() { |
protected function view_form_json($in_field = false) { |
|
// Mise à jour des valeurs |
|
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_post_value('state') !== null) { |
|
|
// |
|
|
$params = array( |
|
|
'val' => array( |
|
|
'state' => $this->f->get_submitted_post_value('state') |
|
|
), |
|
|
); |
|
|
$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.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
} |
|
|
// |
|
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
|
|
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
|
|
// |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"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); |
|
|
} |
|
|
|
|
925 |
// |
// |
926 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null) { |
927 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
940 |
$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']); |
941 |
$val_external_uid = array(); |
$val_external_uid = array(); |
942 |
$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'); |
943 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
944 |
} |
} |
945 |
// |
// |
946 |
if ($this->getVal('type') === 'creation_DI' |
if ($this->getVal('type') === 'creation_DI' |
947 |
|| $this->getVal('type') === 'modification_DI') { |
|| $this->getVal('type') === 'modification_DI' |
948 |
|
|| $this->getVal('type') === 'depot_DI') { |
949 |
// |
// |
950 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
951 |
$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'); |
956 |
$val_external_uid = array(); |
$val_external_uid = array(); |
957 |
$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'); |
958 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
959 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
960 |
} |
} |
961 |
// |
// |
962 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
963 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
|
964 |
$val_external_uid = array(); |
$val_external_uid = array(); |
965 |
$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'); |
966 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
967 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
968 |
} |
} |
969 |
// |
// |
970 |
if ($this->getVal('type') === 'ajout_piece') { |
if ($this->getVal('type') === 'ajout_piece') { |
974 |
$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'); |
975 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
976 |
$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'); |
977 |
$val['external_uid'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
978 |
|
} |
979 |
|
// |
980 |
|
if ($this->getVal('type') === 'decision_DI') { |
981 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
982 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
983 |
|
$val_external_uid = array(); |
984 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
985 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
986 |
|
$val['external_uids'] = $val_external_uid; |
987 |
|
} |
988 |
|
// |
989 |
|
if ($this->getVal('type') === 'incompletude_DI') { |
990 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
991 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
992 |
|
$val_external_uid = array(); |
993 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
994 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
995 |
|
$val['external_uids'] = $val_external_uid; |
996 |
|
} |
997 |
|
// |
998 |
|
if ($this->getVal('type') === 'completude_DI') { |
999 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
1000 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
1001 |
|
$val_external_uid = array(); |
1002 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1003 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1004 |
|
$val['external_uids'] = $val_external_uid; |
1005 |
|
} |
1006 |
|
// |
1007 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
1008 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1009 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1010 |
|
$val_external_uid = array(); |
1011 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1012 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1013 |
|
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
1014 |
|
$val['external_uids'] = $val_external_uid; |
1015 |
} |
} |
1016 |
|
|
1017 |
// Liste des valeurs affichée en JSON |
if ($in_field === true) { |
1018 |
printf(json_encode($val)); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1019 |
|
} else { |
1020 |
|
// Liste des valeurs affichée en JSON |
1021 |
|
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1022 |
|
} |
1023 |
} |
} |
1024 |
} |
} |
1025 |
|
|
1026 |
protected function get_lien_objet_by_type($type) { |
function post_update_task() { |
1027 |
|
// Mise à jour des valeurs |
1028 |
|
// |
1029 |
|
$params = array( |
1030 |
|
'val' => array( |
1031 |
|
'state' => $this->f->get_submitted_post_value('state') |
1032 |
|
), |
1033 |
|
); |
1034 |
|
$update = $this->update_task($params); |
1035 |
|
$message_class = "valid"; |
1036 |
|
$message = $this->msg; |
1037 |
|
if ($update === false) { |
1038 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1039 |
|
$message_class = "error"; |
1040 |
|
$message = sprintf( |
1041 |
|
'%s %s', |
1042 |
|
__('Impossible de mettre à jour la tâche.'), |
1043 |
|
__('Veuillez contacter votre administrateur.') |
1044 |
|
); |
1045 |
|
} |
1046 |
|
$this->f->displayMessage($message_class, $message); |
1047 |
|
// |
1048 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1049 |
|
"obj" => "lien_id_interne_uid_externe", |
1050 |
|
"idx" => ']', |
1051 |
|
)); |
1052 |
|
$valF = array( |
1053 |
|
'lien_id_interne_uid_externe' => '', |
1054 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
1055 |
|
'object_id' => $this->getVal('object_id'), |
1056 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1057 |
|
); |
1058 |
|
$add = $inst_lien->ajouter($valF); |
1059 |
|
$message_class = "valid"; |
1060 |
|
$message = $inst_lien->msg; |
1061 |
|
if ($add === false) { |
1062 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1063 |
|
$message_class = "error"; |
1064 |
|
$message = sprintf( |
1065 |
|
'%s %s', |
1066 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1067 |
|
__('Veuillez contacter votre administrateur.') |
1068 |
|
); |
1069 |
|
} |
1070 |
|
$this->f->displayMessage($message_class, $message); |
1071 |
|
} |
1072 |
|
|
1073 |
|
function post_add_task() { |
1074 |
|
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1075 |
|
$result = $this->add_task(array( |
1076 |
|
'val' => array( |
1077 |
|
'stream' => 'input', |
1078 |
|
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1079 |
|
'type' => $this->f->get_submitted_post_value('type'), |
1080 |
|
) |
1081 |
|
)); |
1082 |
|
$message = $this->msg; |
1083 |
|
$message_class = "valid"; |
1084 |
|
if ($result === false){ |
1085 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1086 |
|
$message_class = "error"; |
1087 |
|
$message = sprintf( |
1088 |
|
'%s %s', |
1089 |
|
__('Impossible d\'ajouter la tâche.'), |
1090 |
|
__('Veuillez contacter votre administrateur.') |
1091 |
|
); |
1092 |
|
} |
1093 |
|
$this->f->displayMessage($message_class, $message); |
1094 |
|
} |
1095 |
|
|
1096 |
|
function get_lien_objet_by_type($type) { |
1097 |
// |
// |
1098 |
$objet = ''; |
$objet = ''; |
1099 |
if ($type === 'creation_DA') { |
if ($type === 'creation_DA') { |
1100 |
$objet = 'dossier_autorisation'; |
$objet = 'dossier_autorisation'; |
1101 |
} |
} |
1102 |
if ($type === 'creation_DI' || $type === 'modification_DI') { |
if ($type === 'creation_DI' |
1103 |
|
|| $type === 'create_DI_for_consultation' |
1104 |
|
|| $type === 'depot_DI' |
1105 |
|
|| $type === 'modification_DI' |
1106 |
|
|| $type === 'qualification_DI' |
1107 |
|
|| $type === 'decision_DI' |
1108 |
|
|| $type === 'incompletude_DI' |
1109 |
|
|| $type === 'completude_DI' |
1110 |
|
|| $type === 'pec_metier_consultation') { |
1111 |
|
// |
1112 |
$objet = 'dossier'; |
$objet = 'dossier'; |
1113 |
} |
} |
1114 |
if ($type === 'ajout_piece') { |
if ($type === 'ajout_piece') { |
1115 |
$objet = 'document_numerise'; |
$objet = 'document_numerise'; |
1116 |
} |
} |
1117 |
|
// La tâche entrante se nomme add_piece |
1118 |
|
if ($type === 'add_piece') { |
1119 |
|
$objet = 'piece'; |
1120 |
|
} |
1121 |
return $objet; |
return $objet; |
1122 |
} |
} |
1123 |
|
|
1124 |
|
function setLayout(&$form, $maj) { |
1125 |
|
|
1126 |
|
// Récupération du mode de l'action |
1127 |
|
$crud = $this->get_action_crud($maj); |
1128 |
|
|
1129 |
|
// MODE different de CREER |
1130 |
|
if ($maj != 0 || $crud != 'create') { |
1131 |
|
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1132 |
|
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1133 |
|
$form->setBloc('json_payload', 'F'); |
1134 |
|
} |
1135 |
|
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1136 |
|
} |
1137 |
|
|
1138 |
} |
} |