1 |
softime |
9293 |
<?php |
2 |
|
|
//$Id$ |
3 |
|
|
//gen openMairie le 14/04/2020 14:11 |
4 |
|
|
|
5 |
|
|
require_once "../gen/obj/task.class.php"; |
6 |
|
|
|
7 |
|
|
class task extends task_gen { |
8 |
|
|
|
9 |
|
|
/** |
10 |
|
|
* Définition des actions disponibles sur la classe. |
11 |
|
|
* |
12 |
|
|
* @return void |
13 |
|
|
*/ |
14 |
|
|
public function init_class_actions() { |
15 |
|
|
parent::init_class_actions(); |
16 |
|
|
// |
17 |
|
|
$this->class_actions[998] = array( |
18 |
softime |
9330 |
"identifier" => "json_data", |
19 |
|
|
"view" => "view_json_data", |
20 |
softime |
9293 |
"permission_suffix" => "consulter", |
21 |
|
|
); |
22 |
|
|
} |
23 |
|
|
|
24 |
softime |
9482 |
public function setvalF($val = array()) { |
25 |
|
|
parent::setvalF($val); |
26 |
|
|
// |
27 |
|
|
if (array_key_exists('timestamp_log', $val) === true) { |
28 |
|
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
29 |
|
|
} |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
33 |
|
|
parent::verifier($val, $dnu1, $dnu2); |
34 |
|
|
// |
35 |
|
|
if (array_key_exists('timestamp_log', $this->valF) === true |
36 |
|
|
&& is_array(json_decode($this->valF['timestamp_log'], true)) === false) { |
37 |
|
|
// |
38 |
|
|
$this->correct = false; |
39 |
|
|
$this->addToMessage(sprintf( |
40 |
|
|
__("Le champ %s doit être dans un format JSON valide."), |
41 |
|
|
sprintf('<span class="bold">%s</span>', $this->getLibFromField('timestamp_log')) |
42 |
|
|
)); |
43 |
|
|
} |
44 |
|
|
} |
45 |
|
|
|
46 |
softime |
9395 |
protected function task_exists(string $type, string $object_id) { |
47 |
|
|
$query = sprintf(' |
48 |
|
|
SELECT task |
49 |
|
|
FROM %1$stask |
50 |
|
|
WHERE state != \'%2$s\' |
51 |
|
|
AND type = \'%3$s\' |
52 |
|
|
AND object_id = \'%4$s\' |
53 |
|
|
', |
54 |
|
|
DB_PREFIXE, |
55 |
|
|
'done', |
56 |
|
|
$type, |
57 |
|
|
$object_id |
58 |
|
|
); |
59 |
|
|
$res = $this->f->get_one_result_from_db_query($query); |
60 |
|
|
if ($res['result'] !== null && $res['result'] !== '') { |
61 |
|
|
return $res['result']; |
62 |
|
|
} |
63 |
|
|
return false; |
64 |
|
|
} |
65 |
|
|
|
66 |
softime |
9293 |
/** |
67 |
|
|
* TREATMENT - add_task |
68 |
|
|
* Ajoute un enregistrement. |
69 |
|
|
* |
70 |
|
|
* @param array $params Tableau des paramètres |
71 |
|
|
* @return boolean |
72 |
|
|
*/ |
73 |
|
|
public function add_task($params = array()) { |
74 |
|
|
$this->begin_treatment(__METHOD__); |
75 |
|
|
$timestamp_log = json_encode(array( |
76 |
|
|
'creation_date' => date('Y-m-d H:i:s'), |
77 |
|
|
)); |
78 |
|
|
// Mise à jour du DI |
79 |
|
|
$valF = array( |
80 |
|
|
'task' => '', |
81 |
|
|
'type' => $params['val']['type'], |
82 |
|
|
'timestamp_log' => $timestamp_log, |
83 |
softime |
9385 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : 'new', |
84 |
softime |
9389 |
'object_id' => $params['val']['object_id'], |
85 |
softime |
9293 |
); |
86 |
softime |
9395 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
87 |
softime |
9457 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
88 |
|
|
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
89 |
|
|
} |
90 |
softime |
9395 |
if ($task_exists !== false) { |
91 |
|
|
$inst_task = $this->f->get_inst__om_dbform(array( |
92 |
|
|
"obj" => "task", |
93 |
|
|
"idx" => $task_exists, |
94 |
|
|
)); |
95 |
softime |
9414 |
$update_state = $inst_task->getVal('state'); |
96 |
|
|
if (isset($params['update_val']['state']) === true) { |
97 |
|
|
$update_state = $params['update_val']['state']; |
98 |
|
|
} |
99 |
softime |
9395 |
$update_params = array( |
100 |
|
|
'val' => array( |
101 |
softime |
9414 |
'state' => $update_state, |
102 |
softime |
9395 |
), |
103 |
|
|
); |
104 |
|
|
return $inst_task->update_task($update_params); |
105 |
|
|
} |
106 |
softime |
9293 |
$add = $this->ajouter($valF); |
107 |
|
|
if ($add === false) { |
108 |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
109 |
|
|
return $this->end_treatment(__METHOD__, false); |
110 |
|
|
} |
111 |
|
|
return $this->end_treatment(__METHOD__, true); |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
/** |
115 |
|
|
* TREATMENT - update_task |
116 |
|
|
* Met à jour l'enregistrement instancié. |
117 |
|
|
* |
118 |
|
|
* @param array $params Tableau des paramètres |
119 |
|
|
* @return boolean |
120 |
|
|
*/ |
121 |
|
|
public function update_task($params = array()) { |
122 |
|
|
$this->begin_treatment(__METHOD__); |
123 |
|
|
$timestamp_log = $this->get_timestamp_log(); |
124 |
|
|
if ($timestamp_log === false) { |
125 |
|
|
$this->addToLog(__('XXX'), DEBUG_MODE); |
126 |
|
|
return $this->end_treatment(__METHOD__, false); |
127 |
|
|
} |
128 |
|
|
array_push($timestamp_log, array( |
129 |
|
|
'modification_date' => date('Y-m-d H:i:s'), |
130 |
|
|
'state' => $params['val']['state'], |
131 |
|
|
'prev_state' => $this->getVal('state'), |
132 |
|
|
)); |
133 |
|
|
$timestamp_log = json_encode($timestamp_log); |
134 |
|
|
$valF = array( |
135 |
|
|
'task' => $this->getVal($this->clePrimaire), |
136 |
|
|
'type' => $this->getVal('type'), |
137 |
|
|
'timestamp_log' => $timestamp_log, |
138 |
|
|
'state' => $params['val']['state'], |
139 |
softime |
9389 |
'object_id' => $this->getVal('object_id'), |
140 |
softime |
9293 |
); |
141 |
|
|
$update = $this->modifier($valF); |
142 |
|
|
if ($update === false) { |
143 |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
144 |
|
|
return $this->end_treatment(__METHOD__, false); |
145 |
|
|
} |
146 |
|
|
return $this->end_treatment(__METHOD__, true); |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
/** |
150 |
|
|
* Récupère le journal d'horodatage dans le champ timestamp_log de |
151 |
|
|
* l'enregistrement instancié. |
152 |
|
|
* |
153 |
|
|
* @param array $params Tableau des paramètres |
154 |
|
|
* @return array sinon false en cas d'erreur |
155 |
|
|
*/ |
156 |
|
|
protected function get_timestamp_log($params = array()) { |
157 |
|
|
$val = $this->getVal('timestamp_log'); |
158 |
|
|
if ($val === '') { |
159 |
|
|
$val = json_encode(array()); |
160 |
|
|
} |
161 |
|
|
if($this->isJson($val) === false) { |
162 |
|
|
return false; |
163 |
|
|
} |
164 |
|
|
return json_decode($val, true); |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
/** |
168 |
softime |
9330 |
* VIEW - view_json_data |
169 |
softime |
9293 |
* Affiche l'enregistrement dans le format JSON. |
170 |
|
|
* |
171 |
|
|
* @return void |
172 |
|
|
*/ |
173 |
softime |
9330 |
public function view_json_data() { |
174 |
softime |
9293 |
$this->checkAccessibility(); |
175 |
softime |
9330 |
$this->f->disableLog(); |
176 |
softime |
9298 |
if ($this->getParameter('idx') !== ']' |
177 |
|
|
&& $this->getParameter('idx') !== '0') { |
178 |
|
|
// |
179 |
|
|
$this->view_form_json(); |
180 |
|
|
} |
181 |
|
|
else { |
182 |
|
|
$this->view_tab_json(); |
183 |
|
|
} |
184 |
|
|
} |
185 |
|
|
|
186 |
|
|
protected function view_tab_json() { |
187 |
softime |
9304 |
$where = ''; |
188 |
|
|
if ($this->f->get_submitted_get_value('state') !== null |
189 |
|
|
&& $this->f->get_submitted_get_value('state') !== '') { |
190 |
|
|
// |
191 |
|
|
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
192 |
|
|
} |
193 |
softime |
9298 |
$query = sprintf(' |
194 |
|
|
SELECT |
195 |
|
|
* |
196 |
|
|
FROM %1$stask |
197 |
softime |
9304 |
%2$s |
198 |
softime |
9481 |
ORDER BY task ASC |
199 |
softime |
9298 |
', |
200 |
softime |
9304 |
DB_PREFIXE, |
201 |
|
|
$where |
202 |
softime |
9298 |
); |
203 |
|
|
$res = $this->f->get_all_results_from_db_query($query, true); |
204 |
|
|
if ($res['code'] === 'KO') { |
205 |
|
|
return false; |
206 |
|
|
} |
207 |
|
|
$list_tasks = array(); |
208 |
|
|
foreach ($res['result'] as $task) { |
209 |
softime |
9404 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
210 |
softime |
9490 |
$task['dossier'] = $task['object_id']; |
211 |
|
|
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
212 |
|
|
$val_dn = $this->get_document_numerise_data($task['object_id']); |
213 |
|
|
$task['dossier'] = $val_dn['dossier']; |
214 |
|
|
} |
215 |
softime |
9298 |
$list_tasks[$task['task']] = $task; |
216 |
|
|
} |
217 |
|
|
printf(json_encode($list_tasks)); |
218 |
|
|
} |
219 |
|
|
|
220 |
softime |
9395 |
protected function get_dossier_data(string $dossier) { |
221 |
|
|
$val_di = array(); |
222 |
|
|
$inst_di = $this->f->get_inst__om_dbform(array( |
223 |
|
|
"obj" => "dossier", |
224 |
|
|
"idx" => $dossier, |
225 |
|
|
)); |
226 |
softime |
9404 |
$val_di = $inst_di->get_json_data(); |
227 |
softime |
9396 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
228 |
|
|
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
229 |
|
|
} |
230 |
softime |
9395 |
unset($val_di['initial_dt']); |
231 |
|
|
unset($val_di['log_instructions']); |
232 |
|
|
return $val_di; |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
protected function get_dossier_autorisation_data(string $da) { |
236 |
|
|
$val_da = array(); |
237 |
|
|
$inst_da = $this->f->get_inst__om_dbform(array( |
238 |
|
|
"obj" => "dossier_autorisation", |
239 |
|
|
"idx" => $da, |
240 |
|
|
)); |
241 |
softime |
9404 |
$val_da = $inst_da->get_json_data(); |
242 |
softime |
9395 |
return $val_da; |
243 |
|
|
} |
244 |
|
|
|
245 |
|
|
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
246 |
|
|
$val_dt = array(); |
247 |
|
|
$inst_dt = $this->f->get_inst__by_other_idx(array( |
248 |
|
|
"obj" => "donnees_techniques", |
249 |
|
|
"fk_field" => $fk_field, |
250 |
|
|
"fk_idx" => $fk_idx, |
251 |
|
|
)); |
252 |
|
|
$val_dt = array( |
253 |
|
|
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
254 |
|
|
'cerfa' => $inst_dt->getVal('cerfa'), |
255 |
|
|
); |
256 |
|
|
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
257 |
softime |
9396 |
if (isset($val_dt['am_exist_date']) === true) { |
258 |
|
|
$val_dt['am_exist_date_num'] = ''; |
259 |
|
|
if (is_numeric($val_dt['am_exist_date']) === true) { |
260 |
|
|
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
261 |
|
|
} |
262 |
|
|
} |
263 |
softime |
9403 |
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
264 |
|
|
$val_dt['tax_statut_info'] = 'Déclaré'; |
265 |
softime |
9407 |
// |
266 |
|
|
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
267 |
|
|
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
268 |
|
|
foreach ($fields_tab_surf_dest as $field) { |
269 |
|
|
if (isset($val_dt[$field]) === true) { |
270 |
|
|
unset($val_dt[$field]); |
271 |
|
|
} |
272 |
|
|
} |
273 |
|
|
} else { |
274 |
|
|
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
275 |
|
|
foreach ($fields_tab_surf_ssdest as $field) { |
276 |
|
|
if (isset($val_dt[$field]) === true) { |
277 |
|
|
unset($val_dt[$field]); |
278 |
|
|
} |
279 |
|
|
} |
280 |
|
|
} |
281 |
softime |
9409 |
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
282 |
softime |
9408 |
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
283 |
softime |
9412 |
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
284 |
|
|
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
285 |
|
|
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
286 |
|
|
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
287 |
|
|
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
288 |
softime |
9408 |
// |
289 |
|
|
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
290 |
|
|
} |
291 |
|
|
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
292 |
softime |
9412 |
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
293 |
|
|
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
294 |
|
|
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
295 |
|
|
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
296 |
|
|
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
297 |
softime |
9408 |
// |
298 |
|
|
$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']); |
299 |
|
|
} |
300 |
softime |
9409 |
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
301 |
|
|
$particular_case = false; |
302 |
|
|
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
303 |
|
|
foreach ($fields_tab_crea_loc_hab as $field) { |
304 |
softime |
9438 |
if (isset($val_dt[$field]) === false |
305 |
|
|
|| (isset($val_dt[$field]) === true |
306 |
|
|
&& ($val_dt[$field] === null |
307 |
|
|
|| $val_dt[$field] === ''))) { |
308 |
softime |
9409 |
// |
309 |
|
|
$particular_case = true; |
310 |
|
|
} |
311 |
|
|
} |
312 |
|
|
if ($particular_case === true) { |
313 |
|
|
if (isset($val_dt['tax_ext_pret']) === true |
314 |
|
|
&& $val_dt['tax_ext_pret'] === 'f') { |
315 |
|
|
// |
316 |
|
|
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
317 |
|
|
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
318 |
|
|
} |
319 |
|
|
if (isset($val_dt['tax_ext_pret']) === true |
320 |
|
|
&& $val_dt['tax_ext_pret'] === 't') { |
321 |
|
|
// |
322 |
|
|
if (isset($val_dt['tax_ext_desc']) === true) { |
323 |
|
|
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
324 |
|
|
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
325 |
|
|
// |
326 |
|
|
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
327 |
|
|
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
328 |
|
|
} |
329 |
|
|
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
330 |
|
|
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
331 |
|
|
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
332 |
|
|
// } |
333 |
|
|
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
334 |
|
|
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
335 |
|
|
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
336 |
|
|
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
337 |
|
|
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
338 |
|
|
// // |
339 |
|
|
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
340 |
|
|
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
341 |
|
|
// } |
342 |
|
|
} |
343 |
|
|
} |
344 |
|
|
} |
345 |
|
|
// Cas particulier de la surface taxable démolie |
346 |
|
|
if (isset($val_dt['tax_surf_tot_demo']) === true |
347 |
|
|
&& isset($val_dt['tax_surf_tax_demo']) === true |
348 |
|
|
&& ($val_dt['tax_surf_tot_demo'] === null |
349 |
|
|
|| $val_dt['tax_surf_tot_demo'] === '')) { |
350 |
|
|
// |
351 |
|
|
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
352 |
|
|
} |
353 |
softime |
9395 |
return $val_dt; |
354 |
|
|
} |
355 |
|
|
|
356 |
|
|
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
357 |
softime |
9404 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
358 |
softime |
9395 |
"obj" => "lien_id_interne_uid_externe", |
359 |
|
|
"fk_field" => 'object_id', |
360 |
|
|
"fk_idx" => $fk_idx, |
361 |
|
|
"fk_field_2" => 'object', |
362 |
|
|
"fk_idx_2" => $fk_idx_2, |
363 |
|
|
)); |
364 |
softime |
9404 |
return $inst_external_uid->getVal('external_uid'); |
365 |
softime |
9395 |
} |
366 |
|
|
|
367 |
|
|
protected function get_demandeurs_data(string $dossier) { |
368 |
|
|
$val_demandeur = array(); |
369 |
|
|
$inst_di = $this->f->get_inst__om_dbform(array( |
370 |
|
|
"obj" => "dossier", |
371 |
|
|
"idx" => $dossier, |
372 |
|
|
)); |
373 |
|
|
$list_demandeurs = $inst_di->get_demandeurs(); |
374 |
|
|
foreach ($list_demandeurs as $demandeur) { |
375 |
|
|
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
376 |
|
|
"obj" => "demandeur", |
377 |
|
|
"idx" => $demandeur['demandeur'], |
378 |
softime |
9334 |
)); |
379 |
softime |
9404 |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
380 |
softime |
9395 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
381 |
softime |
9334 |
} |
382 |
softime |
9395 |
return $val_demandeur; |
383 |
|
|
} |
384 |
|
|
|
385 |
|
|
protected function get_architecte_data($architecte = null) { |
386 |
softime |
9408 |
$val_architecte = null; |
387 |
softime |
9395 |
if ($architecte !== null |
388 |
|
|
&& $architecte !== '') { |
389 |
softime |
9334 |
// |
390 |
softime |
9395 |
$inst_architecte = $this->f->get_inst__om_dbform(array( |
391 |
|
|
"obj" => "architecte", |
392 |
|
|
"idx" => $architecte, |
393 |
softime |
9334 |
)); |
394 |
softime |
9404 |
$val_architecte = $inst_architecte->get_json_data(); |
395 |
softime |
9334 |
} |
396 |
softime |
9395 |
return $val_architecte; |
397 |
|
|
} |
398 |
softime |
9334 |
|
399 |
softime |
9457 |
protected function get_instruction_data(string $dossier, $type = 'decision') { |
400 |
softime |
9414 |
$val_instruction = null; |
401 |
softime |
9416 |
$instruction_with_doc = null; |
402 |
softime |
9395 |
$inst_di = $this->f->get_inst__om_dbform(array( |
403 |
|
|
"obj" => "dossier", |
404 |
|
|
"idx" => $dossier, |
405 |
|
|
)); |
406 |
softime |
9457 |
$idx = null; |
407 |
|
|
if ($type === 'decision') { |
408 |
|
|
$idx = $inst_di->get_last_instruction_decision(); |
409 |
|
|
} |
410 |
|
|
if ($type === 'incompletude') { |
411 |
|
|
$idx = $inst_di->get_last_instruction_incompletude(); |
412 |
|
|
} |
413 |
softime |
9395 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
414 |
|
|
"obj" => "instruction", |
415 |
softime |
9457 |
"idx" => $idx, |
416 |
softime |
9395 |
)); |
417 |
|
|
if (count($inst_instruction->val) > 0) { |
418 |
softime |
9416 |
$val_instruction = array(); |
419 |
|
|
$instruction_data = $inst_instruction->get_json_data(); |
420 |
|
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
421 |
|
|
if ($instruction_data['om_fichier_instruction'] !== null |
422 |
|
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
423 |
|
|
// |
424 |
|
|
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
425 |
|
|
} |
426 |
softime |
9414 |
$inst_ev = $this->f->get_inst__om_dbform(array( |
427 |
|
|
"obj" => "evenement", |
428 |
|
|
"idx" => $inst_instruction->getVal('evenement'), |
429 |
|
|
)); |
430 |
|
|
if ($inst_ev->getVal('retour') === 't') { |
431 |
|
|
$instructions_related = $inst_instruction->get_related_instructions(); |
432 |
|
|
foreach ($instructions_related as $instruction) { |
433 |
softime |
9416 |
if ($instruction !== null && $instruction !== '') { |
434 |
|
|
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
435 |
|
|
"obj" => "instruction", |
436 |
|
|
"idx" => $instruction, |
437 |
|
|
)); |
438 |
|
|
$instruction_data = $inst_related_instruction->get_json_data(); |
439 |
|
|
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
440 |
|
|
if ($instruction_data['om_fichier_instruction'] !== null |
441 |
|
|
&& $instruction_data['om_fichier_instruction'] !== '') { |
442 |
|
|
// |
443 |
|
|
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
444 |
|
|
} |
445 |
|
|
} |
446 |
softime |
9414 |
} |
447 |
|
|
} |
448 |
softime |
9416 |
if ($instruction_with_doc !== null) { |
449 |
|
|
// |
450 |
softime |
9480 |
$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); |
451 |
softime |
9416 |
} |
452 |
softime |
9384 |
} |
453 |
softime |
9395 |
return $val_instruction; |
454 |
|
|
} |
455 |
softime |
9334 |
|
456 |
softime |
9416 |
protected function sort_instruction_data(array $values, array $res) { |
457 |
|
|
$fields = array( |
458 |
|
|
"date_envoi_signature", |
459 |
|
|
"date_retour_signature", |
460 |
|
|
"date_envoi_rar", |
461 |
|
|
"date_retour_rar", |
462 |
|
|
"date_envoi_controle_legalite", |
463 |
|
|
"date_retour_controle_legalite", |
464 |
|
|
"signataire_arrete", |
465 |
|
|
"om_fichier_instruction", |
466 |
|
|
"tacite", |
467 |
|
|
); |
468 |
|
|
foreach ($values as $key => $value) { |
469 |
|
|
if (in_array($key, $fields) === true) { |
470 |
|
|
if (array_key_exists($key, $res) === false |
471 |
|
|
&& $value !== null |
472 |
|
|
&& $value !== '') { |
473 |
|
|
// |
474 |
|
|
$res[$key] = $value; |
475 |
|
|
} elseif ($key === 'tacite' |
476 |
|
|
&& $value === 't') { |
477 |
|
|
// |
478 |
|
|
$res[$key] = $value; |
479 |
|
|
} |
480 |
|
|
} |
481 |
|
|
} |
482 |
|
|
return $res; |
483 |
|
|
} |
484 |
|
|
|
485 |
softime |
9395 |
protected function get_document_numerise_data(string $dn) { |
486 |
|
|
$val_dn = array(); |
487 |
|
|
$inst_dn = $this->f->get_inst__om_dbform(array( |
488 |
|
|
"obj" => "document_numerise", |
489 |
|
|
"idx" => $dn, |
490 |
|
|
)); |
491 |
softime |
9404 |
$val_dn = $inst_dn->get_json_data(); |
492 |
softime |
9480 |
$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')); |
493 |
softime |
9403 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
494 |
softime |
9457 |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
495 |
softime |
9395 |
return $val_dn; |
496 |
|
|
} |
497 |
|
|
|
498 |
softime |
9396 |
protected function get_parcelles_data(string $object, string $idx) { |
499 |
|
|
$val_dp = array(); |
500 |
|
|
$inst_di = $this->f->get_inst__om_dbform(array( |
501 |
|
|
"obj" => $object, |
502 |
|
|
"idx" => $idx, |
503 |
|
|
)); |
504 |
|
|
$list_parcelles = $inst_di->get_parcelles(); |
505 |
|
|
$no_ordre = 1; |
506 |
|
|
foreach ($list_parcelles as $parcelle) { |
507 |
|
|
$val_dp[$parcelle[$object.'_parcelle']] = array( |
508 |
|
|
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
509 |
|
|
'libelle' => $parcelle['libelle'], |
510 |
|
|
'no_ordre' => $no_ordre, |
511 |
|
|
); |
512 |
|
|
$no_ordre++; |
513 |
|
|
} |
514 |
|
|
return $val_dp; |
515 |
|
|
} |
516 |
|
|
|
517 |
softime |
9395 |
protected function view_form_json() { |
518 |
|
|
// Mise à jour des valeurs |
519 |
softime |
9402 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
520 |
|
|
&& $this->f->get_submitted_post_value('state') !== null) { |
521 |
softime |
9293 |
// |
522 |
|
|
$params = array( |
523 |
|
|
'val' => array( |
524 |
softime |
9402 |
'state' => $this->f->get_submitted_post_value('state') |
525 |
softime |
9293 |
), |
526 |
|
|
); |
527 |
|
|
$update = $this->update_task($params); |
528 |
|
|
$message_class = "valid"; |
529 |
|
|
$message = $this->msg; |
530 |
|
|
if ($update === false) { |
531 |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
532 |
|
|
$message_class = "error"; |
533 |
|
|
$message = sprintf( |
534 |
|
|
'%s %s', |
535 |
|
|
__('Impossible de mettre à jour la tâche.'), |
536 |
|
|
__('Veuillez contacter votre administrateur.') |
537 |
|
|
); |
538 |
|
|
} |
539 |
|
|
$this->f->displayMessage($message_class, $message); |
540 |
softime |
9389 |
} |
541 |
softime |
9395 |
// |
542 |
softime |
9402 |
if ($this->f->get_submitted_post_value('valid') === 'true' |
543 |
|
|
&& $this->f->get_submitted_post_value('external_uid') !== null) { |
544 |
softime |
9385 |
// |
545 |
softime |
9389 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
546 |
|
|
"obj" => "lien_id_interne_uid_externe", |
547 |
|
|
"idx" => ']', |
548 |
|
|
)); |
549 |
|
|
$valF = array( |
550 |
|
|
'lien_id_interne_uid_externe' => '', |
551 |
|
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
552 |
|
|
'object_id' => $this->getVal('object_id'), |
553 |
softime |
9402 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
554 |
softime |
9389 |
); |
555 |
|
|
$add = $inst_lien->ajouter($valF); |
556 |
|
|
$message_class = "valid"; |
557 |
|
|
$message = $inst_lien->msg; |
558 |
|
|
if ($add === false) { |
559 |
|
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
560 |
|
|
$message_class = "error"; |
561 |
|
|
$message = sprintf( |
562 |
|
|
'%s %s', |
563 |
|
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
564 |
|
|
__('Veuillez contacter votre administrateur.') |
565 |
softime |
9385 |
); |
566 |
|
|
} |
567 |
softime |
9389 |
$this->f->displayMessage($message_class, $message); |
568 |
softime |
9293 |
} |
569 |
softime |
9395 |
|
570 |
|
|
// |
571 |
softime |
9402 |
if ($this->f->get_submitted_post_value('valid') === null) { |
572 |
|
|
// Liste des valeurs à afficher |
573 |
|
|
$val = array(); |
574 |
softime |
9395 |
// |
575 |
softime |
9402 |
$val_task = array_combine($this->champs, $this->val); |
576 |
softime |
9405 |
foreach ($val_task as $key => $value) { |
577 |
|
|
$val_task[$key] = strip_tags($value); |
578 |
|
|
} |
579 |
softime |
9404 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
580 |
softime |
9402 |
$val['task'] = $val_task; |
581 |
|
|
// |
582 |
|
|
if ($this->getVal('type') === 'creation_DA') { |
583 |
|
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
584 |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
585 |
|
|
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
586 |
|
|
$val_external_uid = array(); |
587 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
588 |
|
|
$val['external_uid'] = $val_external_uid; |
589 |
|
|
} |
590 |
|
|
// |
591 |
|
|
if ($this->getVal('type') === 'creation_DI' |
592 |
softime |
9417 |
|| $this->getVal('type') === 'modification_DI' |
593 |
|
|
|| $this->getVal('type') === 'depot_DI') { |
594 |
softime |
9402 |
// |
595 |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
596 |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
597 |
|
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
598 |
softime |
9403 |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
599 |
|
|
$val['architecte'] = $this->get_architecte_data($architecte); |
600 |
softime |
9402 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
601 |
|
|
$val_external_uid = array(); |
602 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
603 |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
604 |
|
|
$val['external_uid'] = $val_external_uid; |
605 |
|
|
} |
606 |
|
|
// |
607 |
|
|
if ($this->getVal('type') === 'qualification_DI') { |
608 |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
609 |
|
|
$val_external_uid = array(); |
610 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
611 |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
612 |
|
|
$val['external_uid'] = $val_external_uid; |
613 |
|
|
} |
614 |
|
|
// |
615 |
|
|
if ($this->getVal('type') === 'ajout_piece') { |
616 |
|
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
617 |
|
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
618 |
|
|
$val_external_uid = array(); |
619 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
620 |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
621 |
|
|
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
622 |
|
|
$val['external_uid'] = $val_external_uid; |
623 |
|
|
} |
624 |
softime |
9414 |
// |
625 |
|
|
if ($this->getVal('type') === 'decision_DI') { |
626 |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
627 |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
628 |
|
|
$val_external_uid = array(); |
629 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
630 |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
631 |
|
|
$val['external_uid'] = $val_external_uid; |
632 |
|
|
} |
633 |
softime |
9457 |
// |
634 |
|
|
if ($this->getVal('type') === 'incompletude_DI') { |
635 |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
636 |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
637 |
|
|
$val_external_uid = array(); |
638 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
639 |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
640 |
|
|
$val['external_uid'] = $val_external_uid; |
641 |
|
|
} |
642 |
softime |
9479 |
// |
643 |
softime |
9458 |
if ($this->getVal('type') === 'completude_DI') { |
644 |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
645 |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
646 |
|
|
$val_external_uid = array(); |
647 |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
648 |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
649 |
|
|
$val['external_uid'] = $val_external_uid; |
650 |
|
|
} |
651 |
softime |
9402 |
|
652 |
|
|
// Liste des valeurs affichée en JSON |
653 |
softime |
9479 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
654 |
softime |
9395 |
} |
655 |
softime |
9293 |
} |
656 |
softime |
9385 |
|
657 |
|
|
protected function get_lien_objet_by_type($type) { |
658 |
|
|
// |
659 |
|
|
$objet = ''; |
660 |
|
|
if ($type === 'creation_DA') { |
661 |
|
|
$objet = 'dossier_autorisation'; |
662 |
|
|
} |
663 |
softime |
9414 |
if ($type === 'creation_DI' |
664 |
softime |
9417 |
|| $type === 'depot_DI' |
665 |
softime |
9414 |
|| $type === 'modification_DI' |
666 |
|
|
|| $type === 'qualification_DI' |
667 |
softime |
9457 |
|| $type === 'decision_DI' |
668 |
softime |
9458 |
|| $type === 'incompletude_DI' |
669 |
|
|
|| $type === 'completude_DI') { |
670 |
softime |
9414 |
// |
671 |
softime |
9385 |
$objet = 'dossier'; |
672 |
|
|
} |
673 |
|
|
if ($type === 'ajout_piece') { |
674 |
|
|
$objet = 'document_numerise'; |
675 |
|
|
} |
676 |
|
|
return $objet; |
677 |
|
|
} |
678 |
softime |
9293 |
} |