21 |
); |
); |
22 |
} |
} |
23 |
|
|
24 |
|
protected function task_exists(string $type, string $object_id) { |
25 |
|
$query = sprintf(' |
26 |
|
SELECT task |
27 |
|
FROM %1$stask |
28 |
|
WHERE state != \'%2$s\' |
29 |
|
AND type = \'%3$s\' |
30 |
|
AND object_id = \'%4$s\' |
31 |
|
', |
32 |
|
DB_PREFIXE, |
33 |
|
'done', |
34 |
|
$type, |
35 |
|
$object_id |
36 |
|
); |
37 |
|
$res = $this->f->get_one_result_from_db_query($query); |
38 |
|
if ($res['result'] !== null && $res['result'] !== '') { |
39 |
|
return $res['result']; |
40 |
|
} |
41 |
|
return false; |
42 |
|
} |
43 |
|
|
44 |
/** |
/** |
45 |
* TREATMENT - add_task |
* TREATMENT - add_task |
46 |
* Ajoute un enregistrement. |
* Ajoute un enregistrement. |
58 |
'task' => '', |
'task' => '', |
59 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
60 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
61 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'draft', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
62 |
'id' => $params['val']['id'], |
'object_id' => $params['val']['object_id'], |
63 |
); |
); |
64 |
|
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
65 |
|
if ($task_exists !== false) { |
66 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
67 |
|
"obj" => "task", |
68 |
|
"idx" => $task_exists, |
69 |
|
)); |
70 |
|
$update_params = array( |
71 |
|
'val' => array( |
72 |
|
'state' => $inst_task->getVal('state'), |
73 |
|
), |
74 |
|
); |
75 |
|
return $inst_task->update_task($update_params); |
76 |
|
} |
77 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
78 |
if ($add === false) { |
if ($add === false) { |
79 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
107 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
108 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
109 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
110 |
'id' => $this->getVal('id'), |
'object_id' => $this->getVal('object_id'), |
111 |
); |
); |
112 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
113 |
if ($update === false) { |
if ($update === false) { |
181 |
printf(json_encode($list_tasks)); |
printf(json_encode($list_tasks)); |
182 |
} |
} |
183 |
|
|
184 |
protected function view_form_json() { |
protected function get_dossier_data(string $dossier) { |
185 |
// Liste des valeurs à afficher |
$val_di = array(); |
186 |
$val = array(); |
$inst_di = $this->f->get_inst__om_dbform(array( |
187 |
// |
"obj" => "dossier", |
188 |
$val_task = array_combine($this->champs, $this->val); |
"idx" => $dossier, |
189 |
$val['task'] = $val_task; |
)); |
190 |
// |
$val_di = json_decode($inst_di->get_json_data(), true); |
191 |
if ($this->getVal('type') === 'projetsPOST') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
192 |
$inst_da = $this->f->get_inst__om_dbform(array( |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
193 |
"obj" => "dossier_autorisation", |
} |
194 |
"idx" => $this->getVal('id'), |
unset($val_di['initial_dt']); |
195 |
)); |
unset($val_di['log_instructions']); |
196 |
$val_da = array_combine($inst_da->champs, $inst_da->val); |
return $val_di; |
197 |
$val['dossier_autorisation'] = $val_da; |
} |
198 |
$inst_dt_da = $this->f->get_inst__by_other_idx(array( |
|
199 |
"obj" => "donnees_techniques", |
protected function get_dossier_autorisation_data(string $da) { |
200 |
"fk_field" => 'dossier_autorisation', |
$val_da = array(); |
201 |
"fk_idx" => $this->getVal('id'), |
$inst_da = $this->f->get_inst__om_dbform(array( |
202 |
)); |
"obj" => "dossier_autorisation", |
203 |
$val_dt_da = array_combine($inst_dt_da->champs, $inst_dt_da->val); |
"idx" => $da, |
204 |
$val['donnees_techniques'] = $val_dt_da; |
)); |
205 |
} |
$val_da = json_decode($inst_da->get_json_data(), true); |
206 |
// |
return $val_da; |
207 |
if ($this->getVal('type') === 'dossiersPOST' |
} |
208 |
|| $this->getVal('type') === 'dossiersPUT') { |
|
209 |
// |
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
210 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$val_dt = array(); |
211 |
"obj" => "dossier", |
$inst_dt = $this->f->get_inst__by_other_idx(array( |
212 |
"idx" => $this->getVal('id'), |
"obj" => "donnees_techniques", |
213 |
)); |
"fk_field" => $fk_field, |
214 |
$val_di = array_combine($inst_di->champs, $inst_di->val); |
"fk_idx" => $fk_idx, |
215 |
unset($val_di['initial_dt']); |
)); |
216 |
unset($val_di['log_instructions']); |
$val_dt = array( |
217 |
$val['dossier'] = $val_di; |
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
218 |
$inst_dt_di = $this->f->get_inst__by_other_idx(array( |
'cerfa' => $inst_dt->getVal('cerfa'), |
219 |
"obj" => "donnees_techniques", |
); |
220 |
"fk_field" => 'dossier_instruction', |
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
221 |
"fk_idx" => $this->getVal('id'), |
if (isset($val_dt['am_exist_date']) === true) { |
222 |
)); |
$val_dt['am_exist_date_num'] = ''; |
223 |
$val_dt_di = array( |
if (is_numeric($val_dt['am_exist_date']) === true) { |
224 |
'donnees_techniques' => $inst_dt_di->getVal($inst_dt_di->clePrimaire), |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
|
'cerfa' => $inst_dt_di->getVal('cerfa'), |
|
|
); |
|
|
$val['donnees_techniques'] = array_merge($val_dt_di, $inst_dt_di->get_donnees_techniques_applicables()); |
|
|
$val_demandeur = array(); |
|
|
$list_demandeurs = $inst_di->get_demandeurs(); |
|
|
foreach ($list_demandeurs as $demandeur) { |
|
|
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "demandeur", |
|
|
"idx" => $demandeur['demandeur'], |
|
|
)); |
|
|
$val_demandeur[$demandeur['demandeur']] = array_combine($inst_demandeur->champs, $inst_demandeur->val); |
|
|
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
|
225 |
} |
} |
|
$val['demandeur'] = $val_demandeur; |
|
226 |
} |
} |
227 |
// |
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
228 |
if ($this->getVal('type') === 'dossiersQualificationPUT') { |
$val_dt['tax_statut_info'] = 'Déclaré'; |
229 |
$inst_di = $this->f->get_inst__om_dbform(array( |
return $val_dt; |
230 |
"obj" => "dossier", |
} |
231 |
"idx" => $this->getVal('id'), |
|
232 |
)); |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
233 |
$val_di = array_combine($inst_di->champs, $inst_di->val); |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
234 |
unset($val_di['initial_dt']); |
"obj" => "lien_id_interne_uid_externe", |
235 |
unset($val_di['log_instructions']); |
"fk_field" => 'object_id', |
236 |
$val['dossier'] = $val_di; |
"fk_idx" => $fk_idx, |
237 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
"fk_field_2" => 'object', |
238 |
"obj" => "instruction", |
"fk_idx_2" => $fk_idx_2, |
239 |
"idx" => $inst_di->get_last_instruction_decision(), |
)); |
240 |
|
return $inst_external_uid_da->getVal('external_uid'); |
241 |
|
} |
242 |
|
|
243 |
|
protected function get_demandeurs_data(string $dossier) { |
244 |
|
$val_demandeur = array(); |
245 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
246 |
|
"obj" => "dossier", |
247 |
|
"idx" => $dossier, |
248 |
|
)); |
249 |
|
$list_demandeurs = $inst_di->get_demandeurs(); |
250 |
|
foreach ($list_demandeurs as $demandeur) { |
251 |
|
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
252 |
|
"obj" => "demandeur", |
253 |
|
"idx" => $demandeur['demandeur'], |
254 |
)); |
)); |
255 |
$val_instruction = array(); |
$val_demandeur[$demandeur['demandeur']] = json_decode($inst_demandeur->get_json_data(), true); |
256 |
if (count($inst_instruction->val) > 0) { |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
|
$val_instruction = array_combine($inst_instruction->champs, $inst_instruction->val); |
|
|
} |
|
|
$val['instruction'] = $val_instruction; |
|
257 |
} |
} |
258 |
// |
return $val_demandeur; |
259 |
if ($this->getVal('type') === 'piecesPOST') { |
} |
260 |
$inst_di = $this->f->get_inst__om_dbform(array( |
|
261 |
"obj" => "dossier", |
protected function get_architecte_data($architecte = null) { |
262 |
"idx" => $this->getVal('id'), |
$val_architecte = array(); |
263 |
)); |
if ($architecte !== null |
264 |
$val_di = array_combine($inst_di->champs, $inst_di->val); |
&& $architecte !== '') { |
265 |
unset($val_di['initial_dt']); |
// |
266 |
unset($val_di['log_instructions']); |
$inst_architecte = $this->f->get_inst__om_dbform(array( |
267 |
$val['dossier'] = $val_di; |
"obj" => "architecte", |
268 |
$inst_dn = $this->f->get_inst__by_other_idx(array( |
"idx" => $architecte, |
|
"obj" => "document_numerise", |
|
|
"fk_field" => 'dossier', |
|
|
"fk_idx" => $this->getVal('id'), |
|
269 |
)); |
)); |
270 |
$val_dn = array_combine($inst_dn->champs, $inst_dn->val); |
$val_architecte = json_decode($inst_architecte->get_json_data(), true); |
|
$val['document_numerise'] = $val_dn; |
|
271 |
} |
} |
272 |
|
return $val_architecte; |
273 |
|
} |
274 |
|
|
275 |
// Liste des valeurs affichée en JSON |
protected function get_instruction_data(string $dossier) { |
276 |
if ($this->f->get_submitted_post_value('valid') !== 'true') { |
$val_instruction = array(); |
277 |
printf(json_encode($val)); |
$inst_di = $this->f->get_inst__om_dbform(array( |
278 |
|
"obj" => "dossier", |
279 |
|
"idx" => $dossier, |
280 |
|
)); |
281 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
282 |
|
"obj" => "instruction", |
283 |
|
"idx" => $inst_di->get_last_instruction_decision(), |
284 |
|
)); |
285 |
|
if (count($inst_instruction->val) > 0) { |
286 |
|
$val_instruction = json_decode($inst_instruction->get_json_data(), true); |
287 |
} |
} |
288 |
|
return $val_instruction; |
289 |
|
} |
290 |
|
|
291 |
// |
protected function get_document_numerise_data(string $dn) { |
292 |
|
$val_dn = array(); |
293 |
|
$inst_dn = $this->f->get_inst__om_dbform(array( |
294 |
|
"obj" => "document_numerise", |
295 |
|
"idx" => $dn, |
296 |
|
)); |
297 |
|
$val_dn = json_decode($inst_dn->get_json_data(), true); |
298 |
|
$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')); |
299 |
|
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
300 |
|
$val_dn['nature'] = 'Initiale'; |
301 |
|
return $val_dn; |
302 |
|
} |
303 |
|
|
304 |
|
protected function get_parcelles_data(string $object, string $idx) { |
305 |
|
$val_dp = array(); |
306 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
307 |
|
"obj" => $object, |
308 |
|
"idx" => $idx, |
309 |
|
)); |
310 |
|
$list_parcelles = $inst_di->get_parcelles(); |
311 |
|
$no_ordre = 1; |
312 |
|
foreach ($list_parcelles as $parcelle) { |
313 |
|
$val_dp[$parcelle[$object.'_parcelle']] = array( |
314 |
|
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
315 |
|
'libelle' => $parcelle['libelle'], |
316 |
|
'no_ordre' => $no_ordre, |
317 |
|
); |
318 |
|
$no_ordre++; |
319 |
|
} |
320 |
|
return $val_dp; |
321 |
|
} |
322 |
|
|
323 |
|
protected function view_form_json() { |
324 |
|
// Mise à jour des valeurs |
325 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
if ($this->f->get_submitted_post_value('valid') === 'true' |
326 |
&& $this->f->get_submitted_post_value('state') !== null) { |
&& $this->f->get_submitted_post_value('state') !== null) { |
327 |
// |
// |
344 |
} |
} |
345 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
346 |
} |
} |
347 |
|
// |
348 |
|
if ($this->f->get_submitted_post_value('valid') === 'true' |
349 |
|
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
350 |
|
// |
351 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
352 |
|
"obj" => "lien_id_interne_uid_externe", |
353 |
|
"idx" => ']', |
354 |
|
)); |
355 |
|
$valF = array( |
356 |
|
'lien_id_interne_uid_externe' => '', |
357 |
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
358 |
|
'object_id' => $this->getVal('object_id'), |
359 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
360 |
|
); |
361 |
|
$add = $inst_lien->ajouter($valF); |
362 |
|
$message_class = "valid"; |
363 |
|
$message = $inst_lien->msg; |
364 |
|
if ($add === false) { |
365 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
366 |
|
$message_class = "error"; |
367 |
|
$message = sprintf( |
368 |
|
'%s %s', |
369 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
370 |
|
__('Veuillez contacter votre administrateur.') |
371 |
|
); |
372 |
|
} |
373 |
|
$this->f->displayMessage($message_class, $message); |
374 |
|
} |
375 |
|
|
376 |
|
// |
377 |
|
if ($this->f->get_submitted_post_value('valid') === null) { |
378 |
|
// Liste des valeurs à afficher |
379 |
|
$val = array(); |
380 |
|
// |
381 |
|
$val_task = array_combine($this->champs, $this->val); |
382 |
|
$val['task'] = $val_task; |
383 |
|
// |
384 |
|
if ($this->getVal('type') === 'creation_DA') { |
385 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
386 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
387 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
388 |
|
$val_external_uid = array(); |
389 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
390 |
|
$val['external_uid'] = $val_external_uid; |
391 |
|
} |
392 |
|
// |
393 |
|
if ($this->getVal('type') === 'creation_DI' |
394 |
|
|| $this->getVal('type') === 'modification_DI') { |
395 |
|
// |
396 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
397 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
398 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
399 |
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
400 |
|
$val['architecte'] = $this->get_architecte_data($architecte); |
401 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
402 |
|
$val_external_uid = array(); |
403 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
404 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
405 |
|
$val['external_uid'] = $val_external_uid; |
406 |
|
} |
407 |
|
// |
408 |
|
if ($this->getVal('type') === 'qualification_DI') { |
409 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
410 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
411 |
|
$val_external_uid = array(); |
412 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
413 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
414 |
|
$val['external_uid'] = $val_external_uid; |
415 |
|
} |
416 |
|
// |
417 |
|
if ($this->getVal('type') === 'ajout_piece') { |
418 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
419 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
420 |
|
$val_external_uid = array(); |
421 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
422 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
423 |
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
424 |
|
$val['external_uid'] = $val_external_uid; |
425 |
|
} |
426 |
|
|
427 |
|
// Liste des valeurs affichée en JSON |
428 |
|
printf(json_encode($val)); |
429 |
|
} |
430 |
|
} |
431 |
|
|
432 |
|
protected function get_lien_objet_by_type($type) { |
433 |
|
// |
434 |
|
$objet = ''; |
435 |
|
if ($type === 'creation_DA') { |
436 |
|
$objet = 'dossier_autorisation'; |
437 |
|
} |
438 |
|
if ($type === 'creation_DI' || $type = 'modification_DI') { |
439 |
|
$objet = 'dossier'; |
440 |
|
} |
441 |
|
if ($type === 'ajout_piece') { |
442 |
|
$objet = 'document_numerise'; |
443 |
|
} |
444 |
|
return $objet; |
445 |
} |
} |
446 |
} |
} |