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. |
61 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
62 |
'object_id' => $params['val']['object_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); |
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') === 'creation_DA') { |
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('object_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('object_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_external_uid = array(); |
$val_da = json_decode($inst_da->get_json_data(), true); |
206 |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
return $val_da; |
207 |
"obj" => "lien_id_interne_uid_externe", |
} |
208 |
"fk_field" => 'object_id', |
|
209 |
"fk_idx" => $inst_da->getVal($this->clePrimaire), |
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
210 |
"fk_field_2" => 'object', |
$val_dt = array(); |
211 |
"fk_idx_2" => 'dossier_autorisation', |
$inst_dt = $this->f->get_inst__by_other_idx(array( |
212 |
)); |
"obj" => "donnees_techniques", |
213 |
$val_external_uid['dossier_autorisation'] = $inst_external_uid_da->getVal('external_uid'); |
"fk_field" => $fk_field, |
214 |
} |
"fk_idx" => $fk_idx, |
215 |
// |
)); |
216 |
if ($this->getVal('type') === 'creation_DI' |
$val_dt = array( |
217 |
|| $this->getVal('type') === 'modification_DI') { |
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
218 |
// |
'cerfa' => $inst_dt->getVal('cerfa'), |
219 |
$inst_di = $this->f->get_inst__om_dbform(array( |
); |
220 |
"obj" => "dossier", |
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
221 |
"idx" => $this->getVal('object_id'), |
if (isset($val_dt['am_exist_date']) === true) { |
222 |
)); |
$val_dt['am_exist_date_num'] = ''; |
223 |
$val_di = array_combine($inst_di->champs, $inst_di->val); |
if (is_numeric($val_dt['am_exist_date']) === true) { |
224 |
unset($val_di['initial_dt']); |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
|
unset($val_di['log_instructions']); |
|
|
$val['dossier'] = $val_di; |
|
|
$inst_dt_di = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "donnees_techniques", |
|
|
"fk_field" => 'dossier_instruction', |
|
|
"fk_idx" => $this->getVal('object_id'), |
|
|
)); |
|
|
$val_dt_di = array( |
|
|
'donnees_techniques' => $inst_dt_di->getVal($inst_dt_di->clePrimaire), |
|
|
'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']; |
|
|
} |
|
|
$val['demandeur'] = $val_demandeur; |
|
|
$val_architecte = array(); |
|
|
if ($inst_dt_di->getVal('architecte') !== null |
|
|
&& $inst_dt_di->getVal('architecte') !== '') { |
|
|
// |
|
|
$inst_architecte = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "architecte", |
|
|
"idx" => $inst_dt_di->getVal('architecte'), |
|
|
)); |
|
|
$val_architecte = array_combine($inst_architecte->champs, $inst_architecte->val); |
|
225 |
} |
} |
|
// var_dump($inst_dt_di); |
|
|
$val['architecte'] = $val_architecte; |
|
|
// |
|
|
$val_external_uid = array(); |
|
|
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"fk_field" => 'object_id', |
|
|
"fk_idx" => $inst_di->getVal('dossier_autorisation'), |
|
|
"fk_field_2" => 'object', |
|
|
"fk_idx_2" => 'dossier_autorisation', |
|
|
)); |
|
|
$val_external_uid['dossier_autorisation'] = $inst_external_uid_da->getVal('external_uid'); |
|
|
$inst_external_uid_di = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"fk_field" => 'object_id', |
|
|
"fk_idx" => $inst_di->getVal($inst_di->clePrimaire), |
|
|
"fk_field_2" => 'object', |
|
|
"fk_idx_2" => 'dossier', |
|
|
)); |
|
|
$val_external_uid['dossier'] = $inst_external_uid_di->getVal('external_uid'); |
|
|
$val['external_uid'] = $val_external_uid; |
|
226 |
} |
} |
227 |
// |
return $val_dt; |
228 |
if ($this->getVal('type') === 'qualification_DI') { |
} |
229 |
$inst_di = $this->f->get_inst__om_dbform(array( |
|
230 |
"obj" => "dossier", |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
231 |
"idx" => $this->getVal('object_id'), |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
232 |
)); |
"obj" => "lien_id_interne_uid_externe", |
233 |
$val_di = array_combine($inst_di->champs, $inst_di->val); |
"fk_field" => 'object_id', |
234 |
unset($val_di['initial_dt']); |
"fk_idx" => $fk_idx, |
235 |
unset($val_di['log_instructions']); |
"fk_field_2" => 'object', |
236 |
$val['dossier'] = $val_di; |
"fk_idx_2" => $fk_idx_2, |
237 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
)); |
238 |
"obj" => "instruction", |
return $inst_external_uid_da->getVal('external_uid'); |
239 |
"idx" => $inst_di->get_last_instruction_decision(), |
} |
240 |
)); |
|
241 |
$val_instruction = array(); |
protected function get_demandeurs_data(string $dossier) { |
242 |
if (count($inst_instruction->val) > 0) { |
$val_demandeur = array(); |
243 |
$val_instruction = array_combine($inst_instruction->champs, $inst_instruction->val); |
$inst_di = $this->f->get_inst__om_dbform(array( |
244 |
} |
"obj" => "dossier", |
245 |
$val['instruction'] = $val_instruction; |
"idx" => $dossier, |
246 |
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
)); |
247 |
"obj" => "lien_id_interne_uid_externe", |
$list_demandeurs = $inst_di->get_demandeurs(); |
248 |
"fk_field" => 'object_id', |
foreach ($list_demandeurs as $demandeur) { |
249 |
"fk_idx" => $inst_di->getVal('dossier_autorisation'), |
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
250 |
"fk_field_2" => 'object', |
"obj" => "demandeur", |
251 |
"fk_idx_2" => 'dossier_autorisation', |
"idx" => $demandeur['demandeur'], |
|
)); |
|
|
$val_external_uid['dossier_autorisation'] = $inst_external_uid_da->getVal('external_uid'); |
|
|
$inst_external_uid_di = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"fk_field" => 'object_id', |
|
|
"fk_idx" => $inst_di->getVal($inst_di->clePrimaire), |
|
|
"fk_field_2" => 'object', |
|
|
"fk_idx_2" => 'dossier', |
|
252 |
)); |
)); |
253 |
$val_external_uid['dossier'] = $inst_external_uid_di->getVal('external_uid'); |
$val_demandeur[$demandeur['demandeur']] = json_decode($inst_demandeur->get_json_data(), true); |
254 |
$val['external_uid'] = $val_external_uid; |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
255 |
} |
} |
256 |
// |
return $val_demandeur; |
257 |
if ($this->getVal('type') === 'ajout_piece') { |
} |
258 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
|
259 |
"obj" => "document_numerise", |
protected function get_architecte_data($architecte = null) { |
260 |
"idx" => $this->getVal('object_id'), |
$val_architecte = array(); |
261 |
)); |
if ($architecte !== null |
262 |
$val_dn = array_combine($inst_dn->champs, $inst_dn->val); |
&& $architecte !== '') { |
263 |
$val['document_numerise'] = $val_dn; |
// |
264 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_architecte = $this->f->get_inst__om_dbform(array( |
265 |
"obj" => "dossier", |
"obj" => "architecte", |
266 |
"idx" => $inst_dn->getVal('dossier'), |
"idx" => $architecte, |
|
)); |
|
|
$val_di = array_combine($inst_di->champs, $inst_di->val); |
|
|
unset($val_di['initial_dt']); |
|
|
unset($val_di['log_instructions']); |
|
|
$val['dossier'] = $val_di; |
|
|
$inst_external_uid_da = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"fk_field" => 'object_id', |
|
|
"fk_idx" => $inst_di->getVal('dossier_autorisation'), |
|
|
"fk_field_2" => 'object', |
|
|
"fk_idx_2" => 'dossier_autorisation', |
|
|
)); |
|
|
$val_external_uid['dossier_autorisation'] = $inst_external_uid_da->getVal('external_uid'); |
|
|
$inst_external_uid_di = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"fk_field" => 'object_id', |
|
|
"fk_idx" => $inst_di->getVal($inst_di->clePrimaire), |
|
|
"fk_field_2" => 'object', |
|
|
"fk_idx_2" => 'dossier', |
|
|
)); |
|
|
$val_external_uid['dossier'] = $inst_external_uid_di->getVal('external_uid'); |
|
|
$inst_external_uid_dn = $this->f->get_inst__by_other_idx(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"fk_field" => 'object_id', |
|
|
"fk_idx" => $inst_dn->getVal($inst_dn->clePrimaire), |
|
|
"fk_field_2" => 'object', |
|
|
"fk_idx_2" => 'document_numerise', |
|
267 |
)); |
)); |
268 |
// var_dump($inst_external_uid_dn); |
$val_architecte = json_decode($inst_architecte->get_json_data(), true); |
|
$val_external_uid['document_numerise'] = $inst_external_uid_dn->getVal('external_uid'); |
|
|
$val['external_uid'] = $val_external_uid; |
|
269 |
} |
} |
270 |
|
return $val_architecte; |
271 |
|
} |
272 |
|
|
273 |
// Liste des valeurs affichée en JSON |
protected function get_instruction_data(string $dossier) { |
274 |
if ($this->f->get_submitted_get_value('valid') !== 'true') { |
$val_instruction = array(); |
275 |
printf(json_encode($val)); |
$inst_di = $this->f->get_inst__om_dbform(array( |
276 |
|
"obj" => "dossier", |
277 |
|
"idx" => $dossier, |
278 |
|
)); |
279 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
280 |
|
"obj" => "instruction", |
281 |
|
"idx" => $inst_di->get_last_instruction_decision(), |
282 |
|
)); |
283 |
|
if (count($inst_instruction->val) > 0) { |
284 |
|
$val_instruction = json_decode($inst_instruction->get_json_data(), true); |
285 |
} |
} |
286 |
|
return $val_instruction; |
287 |
|
} |
288 |
|
|
289 |
// |
protected function get_document_numerise_data(string $dn) { |
290 |
|
$val_dn = array(); |
291 |
|
$inst_dn = $this->f->get_inst__om_dbform(array( |
292 |
|
"obj" => "document_numerise", |
293 |
|
"idx" => $dn, |
294 |
|
)); |
295 |
|
$val_dn = json_decode($inst_dn->get_json_data(), true); |
296 |
|
$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')); |
297 |
|
return $val_dn; |
298 |
|
} |
299 |
|
|
300 |
|
protected function get_parcelles_data(string $object, string $idx) { |
301 |
|
$val_dp = array(); |
302 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
303 |
|
"obj" => $object, |
304 |
|
"idx" => $idx, |
305 |
|
)); |
306 |
|
$list_parcelles = $inst_di->get_parcelles(); |
307 |
|
$no_ordre = 1; |
308 |
|
foreach ($list_parcelles as $parcelle) { |
309 |
|
$val_dp[$parcelle[$object.'_parcelle']] = array( |
310 |
|
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
311 |
|
'libelle' => $parcelle['libelle'], |
312 |
|
'no_ordre' => $no_ordre, |
313 |
|
); |
314 |
|
$no_ordre++; |
315 |
|
} |
316 |
|
return $val_dp; |
317 |
|
} |
318 |
|
|
319 |
|
protected function view_form_json() { |
320 |
|
// Mise à jour des valeurs |
321 |
if ($this->f->get_submitted_get_value('valid') === 'true' |
if ($this->f->get_submitted_get_value('valid') === 'true' |
322 |
&& $this->f->get_submitted_get_value('state') !== null) { |
&& $this->f->get_submitted_get_value('state') !== null) { |
323 |
// |
// |
340 |
} |
} |
341 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
342 |
} |
} |
343 |
|
// |
344 |
if ($this->f->get_submitted_get_value('valid') === 'true' |
if ($this->f->get_submitted_get_value('valid') === 'true' |
345 |
&& $this->f->get_submitted_get_value('external_uid') !== null) { |
&& $this->f->get_submitted_get_value('external_uid') !== null) { |
346 |
// |
// |
368 |
} |
} |
369 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
370 |
} |
} |
371 |
|
|
372 |
|
// Liste des valeurs à afficher |
373 |
|
$val = array(); |
374 |
|
// |
375 |
|
$val_task = array_combine($this->champs, $this->val); |
376 |
|
$val['task'] = $val_task; |
377 |
|
// |
378 |
|
if ($this->getVal('type') === 'creation_DA') { |
379 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
380 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
381 |
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
382 |
|
$val_external_uid = array(); |
383 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
384 |
|
$val['external_uid'] = $val_external_uid; |
385 |
|
} |
386 |
|
// |
387 |
|
if ($this->getVal('type') === 'creation_DI' |
388 |
|
|| $this->getVal('type') === 'modification_DI') { |
389 |
|
// |
390 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
391 |
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
392 |
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
393 |
|
$val['architecte'] = $this->get_architecte_data($val['donnees_techniques']['architecte']); |
394 |
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
395 |
|
$val_external_uid = array(); |
396 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
397 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
398 |
|
$val['external_uid'] = $val_external_uid; |
399 |
|
} |
400 |
|
// |
401 |
|
if ($this->getVal('type') === 'qualification_DI') { |
402 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
403 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
404 |
|
$val_external_uid = array(); |
405 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
406 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
407 |
|
$val['external_uid'] = $val_external_uid; |
408 |
|
} |
409 |
|
// |
410 |
|
if ($this->getVal('type') === 'ajout_piece') { |
411 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
412 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
413 |
|
$val_external_uid = array(); |
414 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
415 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
416 |
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
417 |
|
$val['external_uid'] = $val_external_uid; |
418 |
|
} |
419 |
|
|
420 |
|
// Liste des valeurs affichée en JSON |
421 |
|
printf(json_encode($val)); |
422 |
} |
} |
423 |
|
|
424 |
protected function get_lien_objet_by_type($type) { |
protected function get_lien_objet_by_type($type) { |