1 |
vpihour |
632 |
<?php |
2 |
|
|
//$Id$ |
3 |
|
|
//gen openMairie le 08/11/2012 14:00 |
4 |
|
|
|
5 |
|
|
require_once ("../gen/obj/demande.class.php"); |
6 |
|
|
|
7 |
|
|
class demande extends demande_gen { |
8 |
|
|
|
9 |
nhaye |
838 |
var $valIdDemandeur = array("petitionnaire_principal" => "", |
10 |
|
|
"delegataire" => "", |
11 |
|
|
"petitionnaire" => array()); |
12 |
|
|
var $postedIdDemandeur = array("petitionnaire_principal" => "", |
13 |
|
|
"delegataire" => "", |
14 |
|
|
"petitionnaire" => array()); |
15 |
nhaye |
807 |
|
16 |
nhaye |
1333 |
var $autreDossierEnCour; |
17 |
|
|
|
18 |
nhaye |
2976 |
var $cerfa = null; |
19 |
|
|
|
20 |
vpihour |
632 |
function demande($id,&$db,$debug) { |
21 |
|
|
$this->constructeur($id,$db,$debug); |
22 |
|
|
}// fin constructeur |
23 |
fmichon |
1005 |
|
24 |
|
|
function setValF($val) { |
25 |
|
|
parent::setValF($val); |
26 |
|
|
// Récupération des id demandeurs postés |
27 |
|
|
$this->getPostedValues(); |
28 |
nhaye |
1020 |
//$this->valIdDemandeur=$this->postedIdDemandeur; |
29 |
fmichon |
1005 |
} |
30 |
|
|
|
31 |
|
|
/** |
32 |
|
|
* Méthode permettant de récupérer les valeurs du dossier d'autorisation |
33 |
vpihour |
1058 |
* correspondant à la nouvelle demande |
34 |
fmichon |
1005 |
*/ |
35 |
nhaye |
1039 |
function getValFromDossier($dossier_autorisation) { |
36 |
fmichon |
1005 |
include "../sql/pgsql/demande.form.inc.php"; |
37 |
|
|
$sql=str_replace("<idx>",$this->getParameter("idx_dossier"), |
38 |
nhaye |
1053 |
$sql_infos_dossier); |
39 |
fmichon |
1005 |
$res = $this->db->query($sql); |
40 |
vpihour |
1777 |
$this->f->addToLog("getValFromDossier(): db->query(\"".$sql."\")", VERBOSE_MODE); |
41 |
|
|
if ( database::isError($res)){ |
42 |
|
|
die(); |
43 |
|
|
} |
44 |
fmichon |
1005 |
$row = & $res->fetchRow(DB_FETCHMODE_ASSOC); |
45 |
|
|
return $row; |
46 |
|
|
} |
47 |
vpihour |
651 |
|
48 |
vpihour |
799 |
/* |
49 |
|
|
* La date du jour par défaut dans le champs date_demande |
50 |
|
|
* Put the date of the day by default into the field date_demande |
51 |
|
|
*/ |
52 |
vpihour |
635 |
function setVal(&$form, $maj, $validation, &$db) { |
53 |
|
|
if($maj == 0) { |
54 |
fmichon |
1005 |
$form->setVal("date_demande",date('d/m/Y')); |
55 |
|
|
|
56 |
|
|
// Récupération des valeurs du dossier d'autorisation correspondant |
57 |
|
|
if($this->getParameter("idx_dossier") != "") { |
58 |
nhaye |
1039 |
$val_autorisation = $this->getValFromDossier( |
59 |
fmichon |
1005 |
$this->getParameter("idx_dossier")); |
60 |
|
|
foreach($val_autorisation as $champ => $value) { |
61 |
|
|
$form->setVal($champ,$value); |
62 |
|
|
} |
63 |
|
|
} |
64 |
vpihour |
635 |
} |
65 |
|
|
} |
66 |
nhaye |
1404 |
function getDataSubmit() { |
67 |
|
|
|
68 |
|
|
$datasubmit = parent::getDataSubmit(); |
69 |
|
|
if($this->getParameter("idx_dossier") != "") { |
70 |
|
|
$datasubmit .= "&idx_dossier=".$this->getParameter("idx_dossier"); |
71 |
|
|
} |
72 |
|
|
return $datasubmit; |
73 |
|
|
} |
74 |
vpihour |
635 |
|
75 |
nhaye |
838 |
/** |
76 |
|
|
* Méthode de verification du contenu |
77 |
|
|
*/ |
78 |
|
|
function verifier($val, &$db, $DEBUG) { |
79 |
|
|
parent::verifier($val, $db, $DEBUG); |
80 |
vpihour |
2606 |
|
81 |
nhaye |
838 |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
82 |
vpihour |
2606 |
empty($this->postedIdDemandeur["petitionnaire_principal"]) AND |
83 |
|
|
!is_null($this->form)) { |
84 |
nhaye |
838 |
$this->correct = false; |
85 |
fmichon |
1725 |
$this->addToMessage(_("La saisie d'un petitionnaire principal est obligatoire.")); |
86 |
nhaye |
838 |
} |
87 |
|
|
} |
88 |
nhaye |
1333 |
|
89 |
|
|
/** |
90 |
|
|
* Configuration des select |
91 |
|
|
*/ |
92 |
|
|
function setSelect(&$form, $maj,&$db,$debug) { |
93 |
|
|
|
94 |
|
|
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
95 |
|
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
96 |
|
|
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
97 |
|
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
98 |
softime |
2503 |
|
99 |
softime |
3054 |
// Méthode de récupération des valeurs du select "demande_type" |
100 |
|
|
if ($maj < 2 |
101 |
|
|
&& ((isset($_GET['obj']) && $_GET['obj'] != "demande") |
102 |
|
|
OR (!isset($_GET['obj'])))) { |
103 |
|
|
// demande_type |
104 |
nhaye |
3039 |
$form->setSelect('demande_type', $this->loadSelectDemandeType($form, $maj, $db, $debug, "dossier_autorisation_type_detaille")); |
105 |
|
|
} else { |
106 |
|
|
// demande_type |
107 |
|
|
$this->init_select($form, $db, $maj, $debug, "demande_type", |
108 |
|
|
$sql_demande_type, $sql_demande_type_by_id, false); |
109 |
|
|
} |
110 |
atreal |
2730 |
// arrondissement |
111 |
|
|
$this->init_select($form, $db, $maj, $debug, "arrondissement", |
112 |
|
|
$sql_arrondissement, $sql_arrondissement_by_id, false); |
113 |
|
|
|
114 |
|
|
// dossier_autorisation_type_detaille |
115 |
|
|
$this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille", |
116 |
|
|
$sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false); |
117 |
|
|
|
118 |
softime |
2503 |
} |
119 |
nhaye |
1333 |
|
120 |
softime |
2503 |
/** |
121 |
|
|
* Charge le select du champ type de demande |
122 |
|
|
* @param object $form Formulaire |
123 |
|
|
* @param int $maj Mode d'insertion |
124 |
|
|
* @param object $db Database |
125 |
|
|
* @param bool $debug Debug active ou pas |
126 |
|
|
* @param string $champ champ activant le filtre |
127 |
|
|
* @return array Contenu du select |
128 |
|
|
*/ |
129 |
|
|
function loadSelectDemandeType(&$form, $maj, &$db, $debug, $champ) { |
130 |
nhaye |
1333 |
|
131 |
softime |
2503 |
// |
132 |
|
|
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
133 |
|
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
134 |
|
|
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
135 |
|
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
136 |
nhaye |
1333 |
|
137 |
softime |
2503 |
// Contenu de la liste à choix |
138 |
|
|
$contenu=array(); |
139 |
|
|
$contenu[0][0]=''; |
140 |
|
|
$contenu[1][0]=_('choisir')." "._("demande_type"); |
141 |
nhaye |
1857 |
|
142 |
softime |
2503 |
//Récupère l'id du type de dossier d'autorisation détaillé |
143 |
|
|
$id_dossier_autorisation_type_detaille = ""; |
144 |
|
|
if (isset($_POST[$champ])) { |
145 |
|
|
$id_dossier_autorisation_type_detaille = $_POST[$champ]; |
146 |
|
|
} elseif($this->getParameter($champ) != "") { |
147 |
|
|
$id_dossier_autorisation_type_detaille = $this->getParameter($champ); |
148 |
|
|
} elseif(isset($form->val[$champ])) { |
149 |
|
|
$id_dossier_autorisation_type_detaille = $form->val[$champ]; |
150 |
|
|
} |
151 |
nhaye |
1580 |
|
152 |
softime |
2503 |
// Récupération de paramètre pour le rechargement ajax du select |
153 |
|
|
$idx_dossier = $this->getParameter("idx_dossier"); |
154 |
softime |
1997 |
|
155 |
softime |
2503 |
// Récupère l'id de la nature de la demande |
156 |
|
|
$id_demande_nature = "1"; |
157 |
|
|
if (isset($idx_dossier) AND $idx_dossier != "") { |
158 |
|
|
$id_demande_nature = '2'; |
159 |
|
|
} |
160 |
nhaye |
1333 |
|
161 |
softime |
2503 |
// Ajout de condition pour la requête |
162 |
|
|
$ajout_condition_requête = ""; |
163 |
|
|
if ($id_demande_nature == '2') { |
164 |
vpihour |
3015 |
|
165 |
|
|
//On récupère le dossier d'autorisation |
166 |
|
|
$sql = "SELECT dossier_autorisation |
167 |
|
|
FROM ".DB_PREFIXE."dossier |
168 |
|
|
WHERE dossier = '".$idx_dossier."'"; |
169 |
|
|
$dossier_autorisation = $this->db->getOne($sql); |
170 |
|
|
|
171 |
|
|
$this->f->addToLog( |
172 |
|
|
"loadSelectDemandeType() : db->getone(\"".$sql."\");", |
173 |
|
|
VERBOSE_MODE |
174 |
|
|
); |
175 |
|
|
if ( database::isError($dossier_autorisation)){ |
176 |
|
|
return false; |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
//On récupère l'état du dernier dossier d'instruction |
180 |
|
|
$sql = "SELECT etat |
181 |
|
|
FROM ".DB_PREFIXE."dossier |
182 |
|
|
WHERE dossier_autorisation = '".$dossier_autorisation."' AND |
183 |
|
|
version = (SELECT max(version) FROM ".DB_PREFIXE."dossier |
184 |
|
|
WHERE dossier_autorisation = '".$dossier_autorisation."' )"; |
185 |
|
|
$etatDernierDi = $this->db->getOne($sql); |
186 |
|
|
$this->f->addToLog( |
187 |
|
|
"loadSelectDemandeType() : db->getone(\"".$sql."\");", |
188 |
|
|
VERBOSE_MODE |
189 |
|
|
); |
190 |
|
|
if ( database::isError($etatDernierDi)){ |
191 |
|
|
return false; |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
$ajout_condition_requête = " AND etat.etat = '".$etatDernierDi."'"; |
195 |
softime |
2503 |
} |
196 |
nhaye |
1333 |
|
197 |
softime |
2503 |
// |
198 |
|
|
if ($id_dossier_autorisation_type_detaille != "") { |
199 |
|
|
//Si l'id du type de dossier d'autorisation détaillé est renseigné |
200 |
|
|
$sql_demande_type_by_dossier_autorisation_type_detaille = str_replace('<idx_dossier_autorisation_type_detaille>', $id_dossier_autorisation_type_detaille, $sql_demande_type_by_dossier_autorisation_type_detaille); |
201 |
|
|
// Ajoute une condition sur la nature de la demande |
202 |
|
|
$sql_demande_type_by_dossier_autorisation_type_detaille = str_replace('<idx_demande_nature>', $id_demande_nature, $sql_demande_type_by_dossier_autorisation_type_detaille); |
203 |
|
|
// Permet d'ajouter une condition |
204 |
|
|
$sql_demande_type_by_dossier_autorisation_type_detaille = str_replace('<ajout_condition_requête>', $ajout_condition_requête, $sql_demande_type_by_dossier_autorisation_type_detaille); |
205 |
|
|
$res = $this->db->query($sql_demande_type_by_dossier_autorisation_type_detaille); |
206 |
|
|
$this->addToLog("db->query(\"".$sql_demande_type_by_dossier_autorisation_type_detaille."\");", VERBOSE_MODE); |
207 |
|
|
$this->f->isDatabaseError($res); |
208 |
|
|
//Les résultats de la requête sont stocké dans le tableau contenu |
209 |
softime |
1997 |
$k=1; |
210 |
softime |
2503 |
while ($row=& $res->fetchRow()){ |
211 |
|
|
$contenu[0][$k]=$row[0]; |
212 |
|
|
$contenu[1][$k]=$row[1]; |
213 |
softime |
1997 |
$k++; |
214 |
softime |
2503 |
} |
215 |
|
|
} |
216 |
softime |
1997 |
|
217 |
softime |
2503 |
// Retourne le contenu de la liste |
218 |
|
|
return $contenu; |
219 |
nhaye |
1333 |
} |
220 |
softime |
2503 |
|
221 |
vpihour |
799 |
/* |
222 |
|
|
* Ajout du fielset |
223 |
|
|
* Add fieldset |
224 |
|
|
*/ |
225 |
vpihour |
635 |
function setLayout(&$form, $maj){ |
226 |
|
|
if ( $maj < 2 OR $maj == 3 ) { |
227 |
|
|
|
228 |
vpihour |
1058 |
/*Champ sur lequel s'ouvre le bloc 1 */ |
229 |
nhaye |
807 |
$form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8"); |
230 |
vpihour |
1058 |
|
231 |
nhaye |
807 |
$form->setFieldset('dossier_autorisation_type_detaille','D' |
232 |
|
|
,_('Type de dossier/demande')); |
233 |
|
|
$form->setFieldset('demande_type','F',''); |
234 |
|
|
|
235 |
|
|
$form->setBloc('demande_type','F'); |
236 |
vpihour |
1058 |
/*Fin bloc 1*/ |
237 |
softime |
3006 |
|
238 |
|
|
// Affichage de l'état du dossier d'instruction |
239 |
|
|
$form->setBloc('etat','D',"","col_4 demande_etat_hidden_bloc"); |
240 |
|
|
$form->setFieldset('etat','D',_('etat du dossier_instruction')); |
241 |
|
|
$form->setFieldset('etat','F',''); |
242 |
|
|
$form->setBloc('etat','F'); |
243 |
nhaye |
807 |
|
244 |
vpihour |
1058 |
/*Champ sur lequel s'ouvre le bloc 2 */ |
245 |
nhaye |
807 |
$form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc"); |
246 |
|
|
$form->setFieldset('date_demande','D',_('Date de la demande')); |
247 |
|
|
$form->setFieldset('date_demande','F',''); |
248 |
vpihour |
635 |
$form->setBloc('date_demande','F'); |
249 |
vpihour |
1058 |
/*Fin bloc 2*/ |
250 |
vpihour |
635 |
|
251 |
vpihour |
1058 |
/*Champ sur lequel s'ouvre le bloc 3 */ |
252 |
nhaye |
807 |
$form->setBloc('terrain_references_cadastrales','D',"", |
253 |
|
|
"localisation col_12 demande_hidden_bloc"); |
254 |
vpihour |
693 |
$form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain')); |
255 |
|
|
$form->setFieldset('terrain_superficie','F',''); |
256 |
vpihour |
635 |
$form->setBloc('terrain_superficie','F'); |
257 |
vpihour |
1058 |
/*Fin bloc 4*/ |
258 |
vpihour |
676 |
|
259 |
vpihour |
635 |
} |
260 |
|
|
} |
261 |
vpihour |
641 |
|
262 |
vpihour |
799 |
/* |
263 |
|
|
* Ajoute des actions sur les deux premiers select |
264 |
|
|
* Add actions on the two first select |
265 |
|
|
*/ |
266 |
vpihour |
641 |
function setOnchange(&$form,$maj){ |
267 |
|
|
parent::setOnchange($form,$maj); |
268 |
softime |
1997 |
|
269 |
vpihour |
641 |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
270 |
|
|
$form->setOnchange("demande_type","showFormsDemande();"); |
271 |
|
|
} |
272 |
nhaye |
1442 |
|
273 |
|
|
function setLib(&$form,$maj) { |
274 |
|
|
parent::setLib($form,$maj); |
275 |
|
|
//libelle des champs |
276 |
|
|
|
277 |
softime |
2061 |
$form->setLib('terrain_adresse_voie',_('terrain_adresse')); |
278 |
nhaye |
1442 |
} |
279 |
vpihour |
799 |
/* |
280 |
|
|
* Cache le champ terrain_references_cadastrales |
281 |
|
|
* Hide the fiels terrain_references_cadastrales |
282 |
|
|
*/ |
283 |
vpihour |
651 |
function setType(&$form,$maj) { |
284 |
|
|
parent::setType($form,$maj); |
285 |
|
|
|
286 |
vpihour |
689 |
$form->setType('dossier_instruction', 'hidden'); |
287 |
|
|
$form->setType('dossier_autorisation', 'hidden'); |
288 |
fmichon |
1005 |
|
289 |
|
|
$form->setType('instruction_recepisse', 'hidden'); |
290 |
|
|
$form->setType('arrondissement', 'hidden'); |
291 |
|
|
|
292 |
softime |
3006 |
$form->setType('etat', 'hidden'); |
293 |
|
|
|
294 |
fmichon |
1005 |
// Si il s'agit d'une demande sur dossier existant on desactive tous les champs |
295 |
|
|
// sauf demande_type |
296 |
nhaye |
1100 |
if(($maj == 0 AND $this-> getParameter("idx_dossier"))) { |
297 |
nhaye |
1053 |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
298 |
softime |
3006 |
$form->setType('etat', 'hiddenstatic'); |
299 |
nhaye |
1676 |
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
300 |
nhaye |
1053 |
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
301 |
softime |
2061 |
$form->setType('terrain_adresse_voie', 'hiddenstatic'); |
302 |
nhaye |
1053 |
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
303 |
|
|
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
304 |
|
|
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
305 |
|
|
$form->setType('terrain_adresse_bp', 'hiddenstatic'); |
306 |
|
|
$form->setType('terrain_adresse_cedex', 'hiddenstatic'); |
307 |
|
|
$form->setType('terrain_superficie', 'hiddenstatic'); |
308 |
fmichon |
1005 |
} |
309 |
nhaye |
1100 |
if($maj == 1) { |
310 |
|
|
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
311 |
nhaye |
1095 |
$form->setType('demande_type', 'selecthiddenstatic'); |
312 |
|
|
} |
313 |
nhaye |
1100 |
if($maj == 3) { |
314 |
nhaye |
1101 |
$form->setType('terrain_references_cadastrales', 'referencescadastralesstatic'); |
315 |
nhaye |
1100 |
} |
316 |
|
|
|
317 |
vpihour |
651 |
} |
318 |
vpihour |
676 |
|
319 |
nhaye |
807 |
/** |
320 |
nhaye |
2976 |
* Permet de recupérer l'identifiant du cerfa du DATD séléctionné |
321 |
|
|
* par l'utilisateur. |
322 |
|
|
* |
323 |
|
|
* @return integer identifiant du cerfa |
324 |
nhaye |
920 |
*/ |
325 |
nhaye |
2976 |
function getIdCerfa() { |
326 |
|
|
if($this->cerfa != null) { |
327 |
|
|
return $this->cerfa; |
328 |
|
|
} |
329 |
|
|
// Récupération du cerfa pour le type d'instruction sélectionnée et valide |
330 |
|
|
$sql = "SELECT |
331 |
|
|
dossier_autorisation_type_detaille.cerfa |
332 |
|
|
FROM |
333 |
|
|
".DB_PREFIXE."dossier_autorisation_type_detaille |
334 |
|
|
JOIN |
335 |
|
|
".DB_PREFIXE."cerfa |
336 |
|
|
ON |
337 |
|
|
dossier_autorisation_type_detaille.cerfa = cerfa.cerfa |
338 |
|
|
WHERE |
339 |
|
|
now()<=om_validite_fin |
340 |
|
|
AND now()>=om_validite_debut |
341 |
|
|
AND dossier_autorisation_type_detaille=". |
342 |
|
|
$this->valF['dossier_autorisation_type_detaille']; |
343 |
|
|
$this->cerfa = $this->db->getOne($sql); |
344 |
|
|
$this->f->addToLog( |
345 |
|
|
"ajoutDossierInstruction() : db->getone(\"".$sql."\");", |
346 |
|
|
VERBOSE_MODE |
347 |
|
|
); |
348 |
|
|
if ( database::isError($this->cerfa)){ |
349 |
|
|
return false; |
350 |
|
|
} |
351 |
|
|
return $this->cerfa; |
352 |
|
|
} |
353 |
|
|
|
354 |
|
|
|
355 |
|
|
/** |
356 |
|
|
* Méthode permettant d'ajouter un dossier d'autorisation. |
357 |
|
|
* |
358 |
|
|
* @param integer $id identifiant de la demande |
359 |
|
|
* @param database &$db handler de la base de donnée |
360 |
|
|
* @param array $val tableau de valeurs postées via le formulaire |
361 |
|
|
* @param boolean $DEBUG debug |
362 |
|
|
* |
363 |
|
|
* @return boolean false si erreur |
364 |
|
|
*/ |
365 |
|
|
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG) { |
366 |
nhaye |
920 |
require_once '../obj/dossier_autorisation.class.php'; |
367 |
nhaye |
2976 |
$dossier_autorisation = new dossier_autorisation("]", $db, $DEBUG); |
368 |
|
|
$id_etat_initial_da = |
369 |
|
|
$this->f->getParameter('id_etat_initial_dossier_autorisation'); |
370 |
nhaye |
1619 |
|
371 |
nhaye |
2976 |
// Vérification de l'existance d'un état initial des DA dans la table |
372 |
|
|
// om_parametre afin d'éviter d'eventuelle erreur de base de données |
373 |
nhaye |
1606 |
if(isset($id_etat_initial_da)) { |
374 |
|
|
$sql = "SELECT count(*) FROM ".DB_PREFIXE."etat_dossier_autorisation |
375 |
|
|
WHERE etat_dossier_autorisation = ".$id_etat_initial_da; |
376 |
|
|
$count = $this->db->getOne($sql); |
377 |
nhaye |
2976 |
$this->f->addToLog( |
378 |
|
|
"ajoutDossierAutorisation() : db->getOne(\"".$sql."\")", |
379 |
|
|
VERBOSE_MODE |
380 |
|
|
); |
381 |
vpihour |
1777 |
if ( database::isError($count)){ |
382 |
nhaye |
2976 |
return false; |
383 |
vpihour |
1777 |
} |
384 |
nhaye |
1606 |
if($count != 1) { |
385 |
nhaye |
2976 |
return false; |
386 |
nhaye |
1606 |
} else { |
387 |
nhaye |
1619 |
// La méthode ajouter prend en paramètre un tableau associatif |
388 |
|
|
// contenant toutes les champs de la classe instanciée, |
389 |
nhaye |
2976 |
// d'où l'initialisation du tableau en bouclant sur la liste des |
390 |
|
|
// champs du DA |
391 |
nhaye |
1606 |
foreach($dossier_autorisation->champs as $value) { |
392 |
nhaye |
2976 |
$valAuto[$value] = null; |
393 |
nhaye |
1606 |
} |
394 |
nhaye |
1619 |
// Définition des valeurs à insérer |
395 |
nhaye |
1606 |
$valAuto['dossier_autorisation']=""; |
396 |
nhaye |
2976 |
$valAuto['exercice']=null; |
397 |
softime |
2986 |
$valAuto['insee']= $this->f->getParameter("insee"); |
398 |
nhaye |
2976 |
$valAuto['arrondissement']=null; |
399 |
|
|
$valAuto['etat_dossier_autorisation']= |
400 |
|
|
$this->f->getParameter('id_etat_initial_dossier_autorisation'); |
401 |
|
|
$valAuto['erp_numero_batiment']=null; |
402 |
|
|
$valAuto['erp_ouvert']=null; |
403 |
|
|
$valAuto['erp_arrete_decision']=null; |
404 |
|
|
$valAuto['dossier_autorisation_type_detaille']= |
405 |
|
|
$this->valF['dossier_autorisation_type_detaille']; |
406 |
|
|
$valAuto['depot_initial']= |
407 |
|
|
$this->dateDBToForm($this->valF['date_demande']); |
408 |
|
|
$valAuto['terrain_references_cadastrales']= |
409 |
|
|
$this->valF['terrain_references_cadastrales']; |
410 |
|
|
$valAuto['terrain_adresse_voie_numero']= |
411 |
|
|
$this->valF['terrain_adresse_voie_numero']; |
412 |
softime |
2061 |
$valAuto['terrain_adresse_voie']=$this->valF['terrain_adresse_voie']; |
413 |
nhaye |
2976 |
$valAuto['terrain_adresse_lieu_dit']= |
414 |
|
|
$this->valF['terrain_adresse_lieu_dit']; |
415 |
|
|
$valAuto['terrain_adresse_localite']= |
416 |
|
|
$this->valF['terrain_adresse_localite']; |
417 |
|
|
$valAuto['terrain_adresse_code_postal']= |
418 |
|
|
$this->valF['terrain_adresse_code_postal']; |
419 |
nhaye |
1606 |
$valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
420 |
|
|
$valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
421 |
|
|
$valAuto['terrain_superficie']=$this->valF['terrain_superficie']; |
422 |
|
|
$valAuto['numero_version']=-1; |
423 |
|
|
// Ajout du dossier dans la base |
424 |
nhaye |
2976 |
if($dossier_autorisation->ajouter($valAuto, $db, $DEBUG) === false) { |
425 |
|
|
return false; |
426 |
|
|
} |
427 |
nhaye |
1606 |
// Liaison du dossier ajouter à la demande |
428 |
nhaye |
2976 |
$this->valF['dossier_autorisation'] = |
429 |
|
|
$dossier_autorisation->valF['dossier_autorisation']; |
430 |
nhaye |
1606 |
} |
431 |
|
|
} else { |
432 |
nhaye |
2976 |
return false; |
433 |
nhaye |
920 |
} |
434 |
nhaye |
1606 |
|
435 |
nhaye |
920 |
} |
436 |
|
|
|
437 |
|
|
/** |
438 |
nhaye |
2976 |
* Méthode permettant d'ajouter un dossier d'instruction. |
439 |
|
|
* |
440 |
|
|
* @param integer $id identifiant de la demande |
441 |
|
|
* @param database &$db handler de la base de donnée |
442 |
|
|
* @param array $val tableau de valeurs postées via |
443 |
|
|
* le formulaire |
444 |
|
|
* @param boolean $DEBUG debug |
445 |
|
|
* @param integer $dossier_instruction_type identifiant du DI type |
446 |
|
|
* |
447 |
|
|
* @return boolean false si erreur |
448 |
nhaye |
920 |
*/ |
449 |
nhaye |
2976 |
function ajoutDossierInstruction($id, &$db, $val, $DEBUG, $dossier_instruction_type) { |
450 |
nhaye |
920 |
require_once '../obj/dossier.class.php'; |
451 |
nhaye |
2976 |
$dossier = new dossier("]", $db, $DEBUG); |
452 |
nhaye |
920 |
foreach($dossier->champs as $value) { |
453 |
nhaye |
2976 |
$valInstr[$value] = null; |
454 |
nhaye |
920 |
} |
455 |
|
|
require_once '../obj/dossier_autorisation_type_detaille.class.php'; |
456 |
|
|
$datd = new dossier_autorisation_type_detaille( |
457 |
nhaye |
2976 |
$this->valF['dossier_autorisation_type_detaille'], |
458 |
|
|
$db, |
459 |
|
|
$DEBUG |
460 |
|
|
); |
461 |
fmichon |
1005 |
|
462 |
|
|
/*Ajout de la variable dossier_instruction_type à l'objet dossier pour le |
463 |
|
|
* versionning |
464 |
|
|
*/ |
465 |
|
|
$dossier->setDossierInstructionType($dossier_instruction_type); |
466 |
|
|
|
467 |
nhaye |
920 |
// Définition des valeurs à entrée dans la table |
468 |
nhaye |
1186 |
$valInstr['dossier_instruction_type']=$dossier_instruction_type; |
469 |
nhaye |
920 |
$valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']); |
470 |
nhaye |
1571 |
$valInstr['date_dernier_depot']=$this->dateDBToForm($this->valF['date_demande']); |
471 |
nhaye |
1037 |
$valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']); |
472 |
nhaye |
920 |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
473 |
nhaye |
2976 |
$valInstr['terrain_references_cadastrales']= |
474 |
|
|
$this->valF['terrain_references_cadastrales']; |
475 |
|
|
$valInstr['terrain_adresse_voie_numero']= |
476 |
|
|
$this->valF['terrain_adresse_voie_numero']; |
477 |
softime |
2061 |
$valInstr['terrain_adresse_voie']=$this->valF['terrain_adresse_voie']; |
478 |
nhaye |
920 |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
479 |
|
|
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
480 |
nhaye |
2976 |
$valInstr['terrain_adresse_code_postal']= |
481 |
|
|
$this->valF['terrain_adresse_code_postal']; |
482 |
nhaye |
920 |
$valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
483 |
|
|
$valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
484 |
|
|
$valInstr['terrain_superficie']=$this->valF['terrain_superficie']; |
485 |
|
|
$valInstr['description']=""; |
486 |
fmichon |
927 |
$valInstr['dossier_autorisation']=$this->valF['dossier_autorisation']; |
487 |
nhaye |
1262 |
|
488 |
vpihour |
1273 |
/* |
489 |
|
|
* Gestion de la qualification |
490 |
|
|
* */ |
491 |
softime |
2363 |
// Initialise le champ à false |
492 |
|
|
$valInstr['a_qualifier'] = false; |
493 |
|
|
|
494 |
|
|
// Récupère l'information depuis le type de la demande |
495 |
|
|
$qualification = $this->get_qualification($val['demande_type']); |
496 |
|
|
|
497 |
|
|
// Si le dossier doit être à qualifier |
498 |
|
|
if ($qualification === 't') { |
499 |
|
|
// Met le champ à true |
500 |
|
|
$valInstr['a_qualifier'] = true; |
501 |
vpihour |
1273 |
} |
502 |
|
|
|
503 |
nhaye |
2976 |
if($dossier->ajouter($valInstr, $db, $DEBUG) === false) { |
504 |
|
|
return false; |
505 |
vpihour |
1777 |
} |
506 |
vpihour |
2302 |
|
507 |
|
|
//Affichage de message à l'utilisateur concernant un problème lors de |
508 |
vpihour |
2303 |
//l'affectation de l'instructeur au dossier d'instruction |
509 |
vpihour |
2302 |
if ($dossier->valF['dossier_autorisation'] === '' && |
510 |
nhaye |
2976 |
$dossier->valF['instructeur'] === null){ |
511 |
|
|
$this->addToMessage( |
512 |
|
|
_("Aucun instructeur compatible avec ce dossier, contactez votre administrateur afin d'en assigner un a ce dossier.") |
513 |
|
|
); |
514 |
vpihour |
2302 |
} |
515 |
nhaye |
2976 |
elseif ( $dossier->valF['instructeur'] === null ){ |
516 |
vpihour |
2302 |
if ($this->f->isAccredited("dossier_modifier_instructeur")) { |
517 |
nhaye |
2976 |
$this->addToMessage("<br/> ". |
518 |
|
|
_("Pensez a assigner un instructeur a ce dossier.") |
519 |
|
|
); |
520 |
vpihour |
2302 |
} else { |
521 |
nhaye |
2976 |
$this->addToMessage( |
522 |
|
|
_("Aucun instructeur compatible avec ce dossier, contactez votre administrateur afin d'en assigner un a ce dossier.") |
523 |
|
|
); |
524 |
vpihour |
2302 |
} |
525 |
|
|
} |
526 |
|
|
|
527 |
nhaye |
920 |
// Liaison du dossier ajouter à la demande |
528 |
|
|
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
529 |
|
|
} |
530 |
|
|
|
531 |
|
|
/** |
532 |
nhaye |
2976 |
* Méthode permettant d'ajouter les données techniques d'un DA. |
533 |
|
|
* |
534 |
|
|
* @param integer $id identifiant de la demande |
535 |
|
|
* @param database &$db handler de la base de donnée |
536 |
|
|
* @param array $val tableau de valeurs postées via le formulaire |
537 |
|
|
* @param boolean $DEBUG debug |
538 |
|
|
* |
539 |
|
|
* @return boolean false si erreur |
540 |
vpihour |
1374 |
*/ |
541 |
nhaye |
2976 |
function ajoutDonneesTechniquesDA($id, &$db, $val, $DEBUG) { |
542 |
vpihour |
1374 |
|
543 |
|
|
require_once '../obj/donnees_techniques.class.php'; |
544 |
nhaye |
2976 |
$this->DTDA = new donnees_techniques("]", $db, $DEBUG); |
545 |
vpihour |
1374 |
|
546 |
nhaye |
2976 |
// Champs tous à NULL car seul le champ concernant le dossier |
547 |
|
|
// d'autorisation sera rempli |
548 |
|
|
foreach($this->DTDA->champs as $value) { |
549 |
|
|
$val[$value] = null; |
550 |
vpihour |
1374 |
} |
551 |
|
|
// Ajout du numéro de dossier d'instruction |
552 |
nhaye |
2110 |
$val['dossier_autorisation']=$this->valF['dossier_autorisation']; |
553 |
nhaye |
2976 |
// Identifiant du cerfa |
554 |
|
|
$val['cerfa'] = $this->getIdCerfa(); |
555 |
vpihour |
3005 |
|
556 |
|
|
//On vérifie que ce type détaille de dossier d'autorisation a un CERFA |
557 |
|
|
if ( $val['cerfa'] !== "" && is_numeric($val['cerfa'])){ |
558 |
|
|
// Ajout des données techniques |
559 |
|
|
if($this->DTDA->ajouter($val, $db, $DEBUG) === false) { |
560 |
|
|
return false; |
561 |
|
|
} |
562 |
nhaye |
2976 |
} |
563 |
vpihour |
3005 |
else { |
564 |
|
|
//On indique que le dossier d'autorisation n'a pas de données techniques |
565 |
|
|
$this->DTDA = null; |
566 |
|
|
//Aucun CERFA n'est paramétré pour ce type détaillé de dossier d'autorisation |
567 |
|
|
return -1; |
568 |
|
|
} |
569 |
vpihour |
1374 |
} |
570 |
|
|
|
571 |
|
|
/** |
572 |
nhaye |
2976 |
* Méthode permettant d'ajouter les données techniques d'un DI. |
573 |
|
|
* |
574 |
|
|
* @param integer $id identifiant de la demande |
575 |
|
|
* @param database &$db handler de la base de donnée |
576 |
|
|
* @param array $val tableau de valeurs postées via le formulaire |
577 |
|
|
* @param boolean $DEBUG debug |
578 |
|
|
* |
579 |
|
|
* @return boolean false si erreur |
580 |
nhaye |
2110 |
*/ |
581 |
nhaye |
2976 |
function ajoutDonneesTechniquesDI($id, &$db, $val, $DEBUG) { |
582 |
|
|
|
583 |
vpihour |
3005 |
//Si le dossier d'autorisation a des données techniques |
584 |
|
|
if ( !is_null($this->DTDA) && $this->DTDA !== "" ){ |
585 |
|
|
require_once '../obj/donnees_techniques.class.php'; |
586 |
|
|
$this->DTDI = new donnees_techniques(']', $db, $DEBUG); |
587 |
|
|
// Ajout du numéro de dossier d'instruction |
588 |
|
|
$this->DTDA->valF['dossier_instruction'] = $this->valF['dossier_instruction']; |
589 |
|
|
// Suppression du numéro de dossier d'autorisation |
590 |
|
|
$this->DTDA->valF['dossier_autorisation'] = null; |
591 |
|
|
// Identifiant du cerfa |
592 |
|
|
$this->DTDA->valF['cerfa'] = $this->getIdCerfa(); |
593 |
|
|
// Ajout des données techniques |
594 |
|
|
if($this->DTDI->ajouter($this->DTDA->valF, $db, $DEBUG) === false) { |
595 |
|
|
return false; |
596 |
|
|
} |
597 |
nhaye |
2976 |
} |
598 |
vpihour |
3005 |
else { |
599 |
|
|
//Le dossier d'autorisation n'a pas de données techniques |
600 |
|
|
return -1; |
601 |
|
|
} |
602 |
nhaye |
2110 |
} |
603 |
|
|
|
604 |
|
|
/** |
605 |
vpihour |
2038 |
* Ajout des liens demandeurs / dossier d'autorisation s'ils n'y sont pas déjà |
606 |
nhaye |
907 |
**/ |
607 |
nhaye |
920 |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
608 |
|
|
// Création des liens entre le dossier autorisation et les demandeurs |
609 |
nhaye |
907 |
include '../sql/pgsql/demande.form.inc.php'; |
610 |
nhaye |
920 |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
611 |
|
|
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
612 |
|
|
// Recupération des demandeurs liés à la demande |
613 |
vpihour |
2038 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur. |
614 |
|
|
" AND lien_demande_demandeur.demandeur NOT IN ( |
615 |
|
|
SELECT lien_dossier_autorisation_demandeur.demandeur |
616 |
|
|
FROM ".DB_PREFIXE."lien_dossier_autorisation_demandeur |
617 |
|
|
WHERE lien_dossier_autorisation_demandeur.dossier_autorisation = |
618 |
|
|
'".$this->valF['dossier_autorisation']."' |
619 |
|
|
)"); |
620 |
nhaye |
920 |
$res = $db->query($sql); |
621 |
vpihour |
1777 |
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
622 |
|
|
if ( database::isError($res)){ |
623 |
|
|
die(); |
624 |
|
|
} |
625 |
nhaye |
920 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
626 |
|
|
$row['lien_dossier_autorisation_demandeur'] = NULL; |
627 |
|
|
$row['dossier_autorisation'] = $this->valF['dossier_autorisation']; |
628 |
|
|
$ldad->ajouter($row, $db, $DEBUG); |
629 |
|
|
} |
630 |
|
|
} |
631 |
|
|
|
632 |
|
|
/** |
633 |
|
|
* Ajout des liens demandeurs / dossier d'autorisation |
634 |
|
|
**/ |
635 |
|
|
function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) { |
636 |
|
|
// Création des liens entre le dossier instruction et les demandeurs |
637 |
|
|
include '../sql/pgsql/demande.form.inc.php'; |
638 |
|
|
require_once '../obj/lien_dossier_demandeur.class.php'; |
639 |
|
|
$ldd = new lien_dossier_demandeur("]",$db,$DEBUG); |
640 |
|
|
// Recupération des demandeurs liés à la demande |
641 |
|
|
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
642 |
|
|
$res = $db->query($sql); |
643 |
vpihour |
1777 |
$this->f->addToLog("ajoutLiensDossierInstruction() : db->query(\"".$sql."\");", VERBOSE_MODE); |
644 |
|
|
if ( database::isError($res)){ |
645 |
|
|
die(); |
646 |
|
|
} |
647 |
nhaye |
920 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
648 |
|
|
$row['lien_dossier_demandeur'] = NULL; |
649 |
|
|
$row['dossier'] = $this->valF['dossier_instruction']; |
650 |
|
|
$ldd->ajouter($row, $db, $DEBUG); |
651 |
|
|
} |
652 |
|
|
} |
653 |
|
|
|
654 |
fmichon |
1005 |
/* |
655 |
|
|
* Récupère l'identifiant d'un arrondissement à partir d'un code postal |
656 |
|
|
*/ |
657 |
|
|
function getArrondissement($terrain_adresse_code_postal){ |
658 |
|
|
|
659 |
|
|
$arrondissement = NULL; |
660 |
|
|
|
661 |
|
|
$sql = "SELECT |
662 |
|
|
arrondissement |
663 |
|
|
FROM |
664 |
|
|
".DB_PREFIXE."arrondissement |
665 |
|
|
WHERE |
666 |
|
|
code_postal = '$terrain_adresse_code_postal' "; |
667 |
|
|
$this->addToLog("demande.class.php : ".$sql." execute <br>", EXTRA_VERBOSE_MODE); |
668 |
|
|
|
669 |
|
|
$res = $this->db->query($sql); |
670 |
vpihour |
1777 |
$this->f->addToLog("getArrondissement() : db->query(\"".$sql."\")", VERBOSE_MODE); |
671 |
|
|
if ( database::isError($res)){ |
672 |
|
|
die(); |
673 |
|
|
} |
674 |
fmichon |
1005 |
|
675 |
|
|
if( $res->numrows() > 0 ) { |
676 |
|
|
|
677 |
|
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
678 |
|
|
$arrondissement = $row['arrondissement']; |
679 |
|
|
} |
680 |
|
|
|
681 |
|
|
return $arrondissement; |
682 |
|
|
} |
683 |
|
|
|
684 |
|
|
/* |
685 |
|
|
* Récupère l'évènement lié à un type de demande |
686 |
|
|
*/ |
687 |
|
|
function getEvenement($demande_type){ |
688 |
|
|
|
689 |
nhaye |
2977 |
$evenement = null; |
690 |
fmichon |
1005 |
|
691 |
|
|
$sql = |
692 |
|
|
"SELECT |
693 |
|
|
evenement |
694 |
|
|
FROM |
695 |
|
|
".DB_PREFIXE."demande_type |
696 |
|
|
WHERE |
697 |
|
|
demande_type = $demande_type"; |
698 |
|
|
|
699 |
|
|
$res = $this->db->query($sql); |
700 |
vpihour |
1777 |
$this->f->addToLog("getEvenement() : db->query(\"".$sql."\")", VERBOSE_MODE); |
701 |
|
|
if ( database::isError($res)){ |
702 |
|
|
die(); |
703 |
|
|
} |
704 |
fmichon |
1005 |
|
705 |
|
|
if ( $res->numrows() > 0 ){ |
706 |
|
|
|
707 |
|
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
708 |
|
|
$evenement = $row['evenement']; |
709 |
|
|
} |
710 |
|
|
|
711 |
|
|
return $evenement; |
712 |
|
|
} |
713 |
|
|
|
714 |
vpihour |
2450 |
|
715 |
softime |
2112 |
|
716 |
|
|
/** |
717 |
|
|
* Retourne le libellé du dossier d'autorisation |
718 |
|
|
* @param string $dossier_autorisation Identifiant du dossier d'autorisation |
719 |
|
|
* @return string Libellé dossier d'autorisation |
720 |
|
|
*/ |
721 |
|
|
function get_dossier_autorisation_libelle($dossier_autorisation) { |
722 |
|
|
|
723 |
|
|
$dossier_autorisation_libelle = ""; |
724 |
|
|
|
725 |
|
|
// Requête SQL |
726 |
|
|
$sql = "SELECT |
727 |
|
|
dossier_autorisation_libelle |
728 |
|
|
FROM |
729 |
|
|
".DB_PREFIXE."dossier_autorisation |
730 |
|
|
WHERE |
731 |
|
|
dossier_autorisation = '$dossier_autorisation'"; |
732 |
|
|
|
733 |
|
|
$dossier_autorisation_libelle = $this->db->getOne($sql); |
734 |
|
|
$this->addToLog("get_dossier_autorisation_libelle(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
735 |
|
|
database::isError($dossier_autorisation_libelle); |
736 |
|
|
|
737 |
|
|
// Retourne le résultat |
738 |
|
|
return $dossier_autorisation_libelle; |
739 |
|
|
} |
740 |
|
|
|
741 |
|
|
/** |
742 |
nhaye |
2977 |
* Retourne le libellé du dossier d'autorisation. |
743 |
|
|
* @param string $dossier Identifiant du dossier d'autorisation |
744 |
|
|
* |
745 |
softime |
2112 |
* @return string Libellé dossier d'autorisation |
746 |
|
|
*/ |
747 |
|
|
function get_dossier_libelle($dossier) { |
748 |
|
|
|
749 |
|
|
$dossier_libelle = ""; |
750 |
|
|
|
751 |
|
|
// Requête SQL |
752 |
|
|
$sql = "SELECT |
753 |
|
|
dossier_libelle |
754 |
|
|
FROM |
755 |
|
|
".DB_PREFIXE."dossier |
756 |
|
|
WHERE |
757 |
|
|
dossier = '$dossier'"; |
758 |
|
|
|
759 |
nhaye |
2977 |
$dossier_libelle = $this->db->getOne($sql); |
760 |
softime |
2112 |
$this->addToLog("get_dossier_libelle(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
761 |
|
|
database::isError($dossier_libelle); |
762 |
|
|
|
763 |
|
|
// Retourne le résultat |
764 |
|
|
return $dossier_libelle; |
765 |
|
|
} |
766 |
fmichon |
1005 |
|
767 |
nhaye |
920 |
/** |
768 |
|
|
* Ajout des dossiers |
769 |
|
|
**/ |
770 |
|
|
function triggerAjouter($id, &$db, $val, $DEBUG){ |
771 |
softime |
2071 |
|
772 |
nhaye |
920 |
include '../sql/pgsql/demande.form.inc.php'; |
773 |
softime |
2071 |
|
774 |
nhaye |
2976 |
if($this->valF["demande_type"] != null) { |
775 |
|
|
$res = $db->query( |
776 |
|
|
str_replace( |
777 |
|
|
'<idx>', |
778 |
|
|
$this->valF['demande_type'], |
779 |
|
|
$sql_demande_type_details_by_id |
780 |
|
|
) |
781 |
|
|
); |
782 |
|
|
$this->f->addToLog( |
783 |
|
|
"triggerAjouter() : db->query(\"". |
784 |
|
|
str_replace( |
785 |
|
|
'<idx>', |
786 |
|
|
$this->valF['demande_type'], |
787 |
|
|
$sql_demande_type_details_by_id |
788 |
|
|
)."\")", |
789 |
|
|
VERBOSE_MODE |
790 |
|
|
); |
791 |
vpihour |
1777 |
if ( database::isError($res)){ |
792 |
|
|
die(); |
793 |
|
|
} |
794 |
nhaye |
1808 |
// Attribut permettant de définir si un dossier a été créé |
795 |
nhaye |
2976 |
$this->ajoutDI = false; |
796 |
nhaye |
920 |
$dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC); |
797 |
nhaye |
907 |
// Création du dossier_autorisation |
798 |
nhaye |
1054 |
if($this->valF['dossier_autorisation'] == "") { |
799 |
nhaye |
2976 |
if($this->ajoutDossierAutorisation($id, $db, $val, $DEBUG) === false) { |
800 |
|
|
$this -> addToMessage( |
801 |
|
|
_("Erreur lors de l'enregistrement de la demande.")." ". |
802 |
|
|
_("Contactez votre administrateur.") |
803 |
|
|
); |
804 |
|
|
$this->correct = false; |
805 |
|
|
return false; |
806 |
|
|
} |
807 |
|
|
$this -> addToMessage( |
808 |
|
|
_("Creation du dossier d'autorisation no"). |
809 |
|
|
$this->get_dossier_autorisation_libelle( |
810 |
|
|
$this->valF['dossier_autorisation'] |
811 |
|
|
) |
812 |
|
|
); |
813 |
nhaye |
2110 |
//Ajout des données techniques au dossier d'autorisation |
814 |
nhaye |
2976 |
if($this->ajoutDonneesTechniquesDA($id, $db, $val, $DEBUG) === false) { |
815 |
|
|
$this -> addToMessage( |
816 |
|
|
_("Erreur lors de l'enregistrement de la demande.")." ". |
817 |
|
|
_("Contactez votre administrateur.") |
818 |
|
|
); |
819 |
|
|
$this->correct = false; |
820 |
|
|
return false; |
821 |
|
|
} |
822 |
nhaye |
2977 |
} else { |
823 |
|
|
$sqlIdDTDA = "SELECT donnees_techniques |
824 |
|
|
FROM ".DB_PREFIXE."donnees_techniques |
825 |
|
|
WHERE dossier_autorisation='". |
826 |
|
|
$this->valF['dossier_autorisation']."'"; |
827 |
|
|
$idDTDA = $this->db->getOne($sqlIdDTDA); |
828 |
|
|
$this->addToLog( |
829 |
|
|
"triggerAjouter(): db->getOne(\"".$sqlIdDTDA."\")", |
830 |
|
|
VERBOSE_MODE |
831 |
|
|
); |
832 |
|
|
database::isError($idDTDA); |
833 |
vpihour |
3005 |
|
834 |
|
|
$this->DTDA = null; |
835 |
|
|
if ($idDTDA==="" && is_numeric($idDTDA)){ |
836 |
|
|
require_once '../obj/donnees_techniques.class.php'; |
837 |
|
|
$this->DTDA = new donnees_techniques( |
838 |
|
|
$idDTDA, |
839 |
|
|
$db, |
840 |
|
|
$DEBUG |
841 |
|
|
); |
842 |
|
|
$this->DTDA->setValFFromVal(); |
843 |
|
|
} |
844 |
nhaye |
907 |
} |
845 |
nhaye |
2976 |
// Enregistrement du numéro dossier existant |
846 |
|
|
// (il sera écrasé si un DI est créé) |
847 |
nhaye |
1808 |
if ($this->getParameter("idx_dossier") != "") { |
848 |
|
|
$this->valF['dossier_instruction'] = $this->getParameter("idx_dossier"); |
849 |
|
|
} |
850 |
nhaye |
920 |
// Création du dossier d'instruction |
851 |
nhaye |
2976 |
if($dossier_type['dossier_instruction_type'] != null) { |
852 |
|
|
if($this->ajoutDossierInstruction( |
853 |
|
|
$id, |
854 |
|
|
$db, |
855 |
|
|
$val, |
856 |
|
|
$DEBUG, |
857 |
|
|
$dossier_type['dossier_instruction_type'] |
858 |
|
|
) === false ) { |
859 |
|
|
$this -> addToMessage( |
860 |
|
|
_("Erreur lors de l'enregistrement de la demande.")." ". |
861 |
|
|
_("Contactez votre administrateur.") |
862 |
|
|
); |
863 |
|
|
$this->correct = false; |
864 |
|
|
return false; |
865 |
|
|
} |
866 |
|
|
$this -> addToMessage( |
867 |
|
|
_("Creation du dossier d'instruction no"). |
868 |
|
|
$this->get_dossier_libelle($this->valF['dossier_instruction']) |
869 |
|
|
); |
870 |
nhaye |
1808 |
// Attribut permettant de définir si un dossier a été créé. |
871 |
nhaye |
2976 |
$this->ajoutDI = true; |
872 |
vpihour |
1374 |
|
873 |
|
|
//Ajout des données techniques au dossier d'instruction |
874 |
nhaye |
2976 |
if($this->ajoutDonneesTechniquesDI($id, $db, $val, $DEBUG) === false){ |
875 |
|
|
|
876 |
|
|
$this -> addToMessage( |
877 |
|
|
_("Erreur lors de l'enregistrement de la demande.")." ". |
878 |
|
|
_("Contactez votre administrateur.") |
879 |
|
|
); |
880 |
|
|
$this->correct = false; |
881 |
|
|
return false; |
882 |
|
|
|
883 |
|
|
} |
884 |
nhaye |
907 |
} |
885 |
softime |
2071 |
|
886 |
|
|
// Si le dossier_instruction existe |
887 |
|
|
if (isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ) { |
888 |
softime |
2369 |
|
889 |
softime |
2071 |
// Récupère les informations nécessaire pour créer le répertoire de numérisation |
890 |
|
|
$getInfosForFoldername = $this->getInfosForFoldername($this->valF['dossier_instruction']); |
891 |
softime |
2369 |
|
892 |
softime |
2071 |
// Création du répertoire pour la numérisation |
893 |
softime |
2369 |
$createFolder = $this->createFolder($getInfosForFoldername['dossier_autorisation'], $getInfosForFoldername['code'], $getInfosForFoldername['version']); |
894 |
|
|
|
895 |
|
|
// Si la création a échouée |
896 |
|
|
if ($createFolder === false) { |
897 |
|
|
|
898 |
|
|
// Annule la validation |
899 |
softime |
2071 |
$this->correct = false; |
900 |
|
|
// arrête le traitement entier |
901 |
|
|
return false; |
902 |
softime |
2369 |
|
903 |
|
|
// |
904 |
|
|
} else { |
905 |
|
|
|
906 |
|
|
// |
907 |
|
|
$this->addToLog("createFolder() : Success", VERBOSE_MODE); |
908 |
softime |
2071 |
} |
909 |
|
|
} |
910 |
fmichon |
1005 |
|
911 |
|
|
/*Ajout de l'arrondissement à partir du code postal*/ |
912 |
|
|
if ( !is_null($this->valF["terrain_adresse_code_postal"]) && is_numeric($this->valF["terrain_adresse_code_postal"]) ){ |
913 |
|
|
|
914 |
|
|
$this->valF["arrondissement"] = $this->getArrondissement($this->valF["terrain_adresse_code_postal"]); |
915 |
|
|
} |
916 |
nhaye |
907 |
} |
917 |
|
|
} |
918 |
|
|
|
919 |
|
|
/** |
920 |
nhaye |
828 |
* Ajout des délégataires et pétitionnaires |
921 |
nhaye |
807 |
**/ |
922 |
nhaye |
828 |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
923 |
softime |
2071 |
|
924 |
nhaye |
828 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
925 |
fmichon |
1005 |
|
926 |
nhaye |
920 |
// Ajout des lliens entre dossier_autorisation et demandeur |
927 |
vpihour |
2038 |
if(!empty($this->valF['dossier_autorisation'])) { |
928 |
nhaye |
920 |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
929 |
|
|
} |
930 |
|
|
// Ajout des lliens entre dossier et demandeur |
931 |
nhaye |
1808 |
if($this->ajoutDI === TRUE) { |
932 |
nhaye |
920 |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
933 |
|
|
} |
934 |
nhaye |
1246 |
|
935 |
nhaye |
2110 |
// Duplication des lots (et leurs données techniques) et |
936 |
|
|
// liaison au nouveau dossier_d'instruction |
937 |
nhaye |
1246 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
938 |
|
|
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
939 |
|
|
} |
940 |
nmeucci |
2889 |
|
941 |
|
|
/*Création du lien de téléchargement de récépissé de demande*/ |
942 |
|
|
if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type']) |
943 |
|
|
&& isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){ |
944 |
|
|
|
945 |
|
|
/*Récupérer l'événement lié à ce type de demande*/ |
946 |
|
|
$evenement = $this->getEvenement($this->valF['demande_type']); |
947 |
|
|
|
948 |
|
|
/*Récupération de la lettre type de l'événement*/ |
949 |
|
|
$lettretype = $this->f->getLettreType($evenement); |
950 |
|
|
|
951 |
|
|
/*Création d'une nouvelle instruction avec cet événement*/ |
952 |
|
|
/*Données*/ |
953 |
|
|
$valInstr['instruction']=NULL; |
954 |
|
|
|
955 |
|
|
$valInstr['destinataire']=$this->valF['dossier_instruction']; |
956 |
|
|
$valInstr['dossier']=$this->valF['dossier_instruction']; |
957 |
|
|
// Récupère la date de la demande |
958 |
|
|
$valInstr['date_evenement']=$this->dateDBToForm($this->valF['date_demande']); |
959 |
|
|
$valInstr['evenement']=$evenement; |
960 |
|
|
$valInstr['lettretype']=$lettretype; |
961 |
|
|
$valInstr['complement_om_html']=""; |
962 |
|
|
$valInstr['complement2_om_html']=""; |
963 |
|
|
|
964 |
|
|
$valInstr['action']="initialisation"; |
965 |
|
|
$valInstr['delai']="2"; |
966 |
|
|
$valInstr['etat']="notifier"; |
967 |
|
|
$valInstr['accord_tacite']="Oui"; |
968 |
|
|
$valInstr['delai_notification']="1"; |
969 |
|
|
$valInstr['archive_delai']="0"; |
970 |
|
|
$valInstr['archive_date_complet']=NULL; |
971 |
|
|
$valInstr['archive_date_dernier_depot']=NULL; |
972 |
|
|
$valInstr['archive_date_rejet']=NULL; |
973 |
|
|
$valInstr['archive_date_limite']=NULL; |
974 |
|
|
$valInstr['archive_date_notification_delai']=NULL; |
975 |
|
|
$valInstr['archive_accord_tacite']="Non"; |
976 |
|
|
$valInstr['archive_etat']="initialiser"; |
977 |
|
|
$valInstr['archive_date_decision']=NULL; |
978 |
|
|
$valInstr['archive_avis']=""; |
979 |
|
|
$valInstr['archive_date_validite']=NULL; |
980 |
|
|
$valInstr['archive_date_achevement']=NULL; |
981 |
|
|
$valInstr['archive_date_chantier']=NULL; |
982 |
|
|
$valInstr['archive_date_conformite']=NULL; |
983 |
|
|
$valInstr['archive_incompletude']=NULL; |
984 |
nhaye |
3059 |
$valInstr['archive_incomplet_notifie']=NULL; |
985 |
nmeucci |
2889 |
$valInstr['archive_evenement_suivant_tacite']=""; |
986 |
|
|
$valInstr['archive_evenement_suivant_tacite_incompletude']=NULL; |
987 |
|
|
$valInstr['archive_etat_pendant_incompletude']=NULL; |
988 |
|
|
$valInstr['archive_date_limite_incompletude']=NULL; |
989 |
|
|
$valInstr['archive_delai_incompletude']=NULL; |
990 |
|
|
$valInstr['archive_autorite_competente']=NULL; |
991 |
|
|
$valInstr['complement3_om_html']=""; |
992 |
|
|
$valInstr['complement4_om_html']=""; |
993 |
|
|
$valInstr['complement5_om_html']=""; |
994 |
|
|
$valInstr['complement6_om_html']=""; |
995 |
|
|
$valInstr['complement7_om_html']=""; |
996 |
|
|
$valInstr['complement8_om_html']=""; |
997 |
|
|
$valInstr['complement9_om_html']=""; |
998 |
|
|
$valInstr['complement10_om_html']=""; |
999 |
|
|
$valInstr['complement11_om_html']=""; |
1000 |
|
|
$valInstr['complement12_om_html']=""; |
1001 |
|
|
$valInstr['complement13_om_html']=""; |
1002 |
|
|
$valInstr['complement14_om_html']=""; |
1003 |
|
|
$valInstr['complement15_om_html']=""; |
1004 |
|
|
$valInstr['avis_decision']=NULL; |
1005 |
|
|
$valInstr['date_finalisation_courrier']=NULL; |
1006 |
|
|
$valInstr['date_envoi_signature']=NULL; |
1007 |
|
|
$valInstr['date_retour_signature']=NULL; |
1008 |
|
|
$valInstr['date_envoi_rar']=NULL; |
1009 |
|
|
$valInstr['date_retour_rar']=NULL; |
1010 |
|
|
$valInstr['date_envoi_controle_legalite']=NULL; |
1011 |
|
|
$valInstr['date_retour_controle_legalite']=NULL; |
1012 |
|
|
$valInstr['signataire_arrete']=NULL; |
1013 |
|
|
$valInstr['numero_arrete']=NULL; |
1014 |
|
|
$valInstr['code_barres']=NULL; |
1015 |
|
|
$valInstr['om_fichier_instruction']=NULL; |
1016 |
|
|
$valInstr['om_final_instruction']=NULL; |
1017 |
|
|
$valInstr['document_numerise']=NULL; |
1018 |
|
|
$valInstr['autorite_competente']=NULL; |
1019 |
|
|
$valInstr['duree_validite_parametrage']="0"; |
1020 |
|
|
$valInstr['duree_validite']="0"; |
1021 |
|
|
|
1022 |
|
|
//Récupération des champs archive si cette demande a créée un dossier |
1023 |
|
|
//d'instruction mais pas un P0 |
1024 |
|
|
if (!is_null($this->valF['dossier_instruction']) && |
1025 |
|
|
$this->valF['dossier_instruction'] !== "" ){ |
1026 |
|
|
|
1027 |
|
|
//Requête |
1028 |
|
|
$sql = "SELECT dossier_instruction_type.code |
1029 |
|
|
FROM ".DB_PREFIXE."demande_type |
1030 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1031 |
|
|
ON demande_type.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1032 |
|
|
WHERE demande_type.demande_type = ".$this->valF['demande_type']; |
1033 |
|
|
$res = $db->getOne($sql); |
1034 |
|
|
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
1035 |
|
|
if (database::isError($res)) { |
1036 |
|
|
die($res->getMessage()); |
1037 |
|
|
} |
1038 |
|
|
|
1039 |
|
|
//On vérifie que ce n'est pas un P0 |
1040 |
|
|
if ( strcmp($res, "P") !== 0 ){ |
1041 |
|
|
|
1042 |
|
|
$res = $this->getArchiveInstruction($this->valF['dossier_instruction']); |
1043 |
|
|
|
1044 |
|
|
if (isset($res['archive_delai'])) { |
1045 |
|
|
$valInstr['archive_delai']=$res["archive_delai"]; |
1046 |
|
|
} |
1047 |
|
|
if (isset($res['archive_date_complet'])) { |
1048 |
|
|
$valInstr['archive_date_complet']=$res["archive_date_complet"]; |
1049 |
|
|
} |
1050 |
|
|
if (isset($res['archive_date_dernier_depot'])) { |
1051 |
|
|
$valInstr['archive_date_dernier_depot']=$res["archive_date_dernier_depot"]; |
1052 |
|
|
} |
1053 |
|
|
if (isset($res['archive_date_rejet'])) { |
1054 |
|
|
$valInstr['archive_date_rejet']=$res["archive_date_rejet"]; |
1055 |
|
|
} |
1056 |
|
|
if (isset($res['archive_date_limite'])) { |
1057 |
|
|
$valInstr['archive_date_limite']=$res["archive_date_limite"]; |
1058 |
|
|
} |
1059 |
|
|
if (isset($res['archive_date_notification_delai'])) { |
1060 |
|
|
$valInstr['archive_date_notification_delai']=$res["archive_date_notification_delai"]; |
1061 |
|
|
} |
1062 |
|
|
if (isset($res['archive_accord_tacite'])) { |
1063 |
|
|
$valInstr['archive_accord_tacite']=$res["archive_accord_tacite"]; |
1064 |
|
|
} |
1065 |
|
|
if (isset($res['archive_etat'])) { |
1066 |
|
|
$valInstr['archive_etat']=$res["archive_etat"]; |
1067 |
|
|
} |
1068 |
|
|
if (isset($res['archive_date_decision'])) { |
1069 |
|
|
$valInstr['archive_date_decision']=$res["archive_date_decision"]; |
1070 |
|
|
} |
1071 |
|
|
if (isset($res['archive_avis'])) { |
1072 |
|
|
$valInstr['archive_avis']=$res["archive_avis"]; |
1073 |
|
|
} |
1074 |
|
|
if (isset($res['archive_date_validite'])) { |
1075 |
|
|
$valInstr['archive_date_validite']=$res["archive_date_validite"]; |
1076 |
|
|
} |
1077 |
|
|
if (isset($res['archive_date_achevement'])) { |
1078 |
|
|
$valInstr['archive_date_achevement']=$res["archive_date_achevement"]; |
1079 |
|
|
} |
1080 |
|
|
if (isset($res['archive_date_chantier'])) { |
1081 |
|
|
$valInstr['archive_date_chantier']=$res["archive_date_chantier"]; |
1082 |
|
|
} |
1083 |
|
|
if (isset($res['archive_date_conformite'])) { |
1084 |
|
|
$valInstr['archive_date_conformite']=$res["archive_date_conformite"]; |
1085 |
|
|
} |
1086 |
|
|
if (isset($res['archive_incompletude'])) { |
1087 |
|
|
$valInstr['archive_incompletude']=$res["archive_incompletude"]; |
1088 |
|
|
} |
1089 |
nhaye |
3059 |
if (isset($res['archive_incomplet_notifie'])) { |
1090 |
|
|
$valInstr['archive_incomplet_notifie']=$res["archive_incomplet_notifie"]; |
1091 |
|
|
} |
1092 |
nmeucci |
2889 |
if (isset($res['archive_evenement_suivant_tacite'])) { |
1093 |
|
|
$valInstr['archive_evenement_suivant_tacite']=$res["archive_evenement_suivant_tacite"]; |
1094 |
|
|
} |
1095 |
|
|
if (isset($res['archive_evenement_suivant_tacite_incompletude'])) { |
1096 |
|
|
$valInstr['archive_evenement_suivant_tacite_incompletude']=$res["archive_evenement_suivant_tacite_incompletude"]; |
1097 |
|
|
} |
1098 |
|
|
if (isset($res['archive_etat_pendant_incompletude'])) { |
1099 |
|
|
$valInstr['archive_etat_pendant_incompletude']=$res["archive_etat_pendant_incompletude"]; |
1100 |
|
|
} |
1101 |
|
|
if (isset($res['archive_date_limite_incompletude'])) { |
1102 |
|
|
$valInstr['archive_date_limite_incompletude']=$res["archive_date_limite_incompletude"]; |
1103 |
|
|
} |
1104 |
|
|
if (isset($res['archive_delai_incompletude'])) { |
1105 |
|
|
$valInstr['archive_delai_incompletude']=$res["archive_delai_incompletude"]; |
1106 |
|
|
} |
1107 |
|
|
if (isset($res['archive_autorite_competente'])) { |
1108 |
|
|
$valInstr['archive_autorite_competente']=$res["archive_autorite_competente"]; |
1109 |
|
|
} |
1110 |
|
|
} |
1111 |
|
|
} |
1112 |
|
|
|
1113 |
|
|
/*Fichier requis*/ |
1114 |
|
|
require_once '../obj/instruction.class.php'; |
1115 |
|
|
|
1116 |
|
|
/*Création d'un nouveau dossier*/ |
1117 |
|
|
$instruction = new instruction("]",$db,$DEBUG); |
1118 |
|
|
$instruction->valF = ""; |
1119 |
|
|
$instruction->ajouter($valInstr, $db, $DEBUG); |
1120 |
|
|
|
1121 |
|
|
//Finalisation du document |
1122 |
|
|
$_GET['obj']='instruction'; |
1123 |
|
|
$_GET['idx']=$instruction->valF[$instruction->clePrimaire]; |
1124 |
|
|
$instruction_final = new instruction($_GET['idx'],$db,$DEBUG); |
1125 |
|
|
if($instruction_final->getVal('lettretype') != "") { |
1126 |
|
|
$res = $instruction_final->finaliser('', 1, '', ''); |
1127 |
|
|
} |
1128 |
|
|
|
1129 |
|
|
/*Si la création de l'instruction a réussie*/ |
1130 |
|
|
if ( $instruction->valF['instruction'] != "" ){ |
1131 |
softime |
3054 |
|
1132 |
|
|
// Mise à jour de la demande |
1133 |
|
|
$this->valF['instruction_recepisse'] = $instruction->valF['instruction']; |
1134 |
|
|
$this->valF['date_demande'] = $this->dateDBToForm($this->valF['date_demande']); |
1135 |
|
|
$demande_instance = new demande($this->valF['demande'], $db, $DEBUG); |
1136 |
|
|
$demande_instance->modifier($this->valF, $db, $DEBUG); |
1137 |
nmeucci |
2889 |
|
1138 |
|
|
/*Affichage du récépissé de la demande*/ |
1139 |
|
|
$this -> addToMessage("<br/><a |
1140 |
|
|
class='lien' |
1141 |
|
|
href='" |
1142 |
|
|
.((isset($res['pdf'])&&$instruction->valF['om_final_instruction'])?$res['pdf']: |
1143 |
|
|
"../pdf/pdflettretype.php?obj=".$lettretype."&idx=".$instruction->valF['instruction'])."' |
1144 |
|
|
target='_blank'> |
1145 |
|
|
<span |
1146 |
|
|
class=\"om-icon om-icon-16 om-icon-fix pdf-16\" |
1147 |
|
|
title=\""._("Telecharger le recepisse de la demande")."\">". |
1148 |
|
|
_("Telecharger le recepisse de la demande"). |
1149 |
|
|
"</span> |
1150 |
|
|
". |
1151 |
|
|
_("Telecharger le recepisse de la demande")." |
1152 |
|
|
</a><br/>"); |
1153 |
|
|
} |
1154 |
|
|
/*Sinon affiche un message d'erreur*/ |
1155 |
|
|
else { |
1156 |
|
|
|
1157 |
|
|
$this -> addToMessage(_("Une erreur s'est produite lors de la creation du recepisse")); |
1158 |
|
|
} |
1159 |
|
|
} |
1160 |
nhaye |
828 |
} |
1161 |
vpihour |
1058 |
|
1162 |
|
|
/*Ajout du lien demande / demandeur(s)*/ |
1163 |
nhaye |
828 |
function triggerModifierApres($id, &$db, $val, $DEBUG){ |
1164 |
nhaye |
1039 |
$this->listeDemandeur("demande",$this->val[array_search('demande', $this->champs)]); |
1165 |
nhaye |
828 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
1166 |
nhaye |
838 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
1167 |
nhaye |
828 |
|
1168 |
|
|
} |
1169 |
|
|
|
1170 |
|
|
/** |
1171 |
nhaye |
1246 |
* Gestion des liens entre les lots du DA et le nouveau dossier |
1172 |
|
|
**/ |
1173 |
|
|
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
1174 |
|
|
require_once ("../obj/lot.class.php"); |
1175 |
|
|
$lot = new lot("]", $db, $DEBUG); |
1176 |
|
|
require_once ("../obj/lien_lot_demandeur.class.php"); |
1177 |
|
|
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
1178 |
|
|
|
1179 |
|
|
|
1180 |
|
|
$sqlLots = "SELECT * FROM ".DB_PREFIXE."lot |
1181 |
|
|
WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'"; |
1182 |
|
|
$resLot = $db -> query($sqlLots); |
1183 |
|
|
$this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE); |
1184 |
|
|
$this->f->isDatabaseError($resLot); |
1185 |
|
|
while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){ |
1186 |
|
|
// Insertion du nouveau lot |
1187 |
|
|
$valLot['lot'] = ""; |
1188 |
|
|
$valLot['libelle'] = $rowLot['libelle']; |
1189 |
nhaye |
2976 |
$valLot['dossier_autorisation'] = null; |
1190 |
nhaye |
2082 |
$valLot['dossier'] = $this->valF['dossier_instruction']; |
1191 |
nhaye |
1246 |
$lot -> ajouter($valLot, $db, $DEBUG); |
1192 |
nhaye |
1247 |
|
1193 |
nhaye |
1246 |
//Insertion des liens entre dossier et les lots |
1194 |
|
|
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
1195 |
|
|
WHERE lot = ".$rowLot['lot']; |
1196 |
|
|
$res = $db -> query($sqlDemandeurs); |
1197 |
nhaye |
2976 |
$this->f->addToLog( |
1198 |
|
|
"lienLotDossierInstruction() : db->query(\"".$sqlDemandeurs."\");", |
1199 |
|
|
VERBOSE_MODE |
1200 |
|
|
); |
1201 |
vpihour |
1777 |
if ( database::isError($res)){ |
1202 |
|
|
die(); |
1203 |
|
|
} |
1204 |
nhaye |
1246 |
|
1205 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
1206 |
|
|
$valLld["lien_lot_demandeur"] = ""; |
1207 |
|
|
$valLld["lot"]=$lot->valF['lot']; |
1208 |
|
|
$valLld["demandeur"] = $row['demandeur']; |
1209 |
|
|
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
1210 |
|
|
$lld->ajouter($valLld, $db, $DEBUG); |
1211 |
|
|
} |
1212 |
nhaye |
2110 |
|
1213 |
|
|
// Récupération des données techniques du nouveau lots |
1214 |
nhaye |
2976 |
if($this->ajoutDonneesTechniquesLots( |
1215 |
|
|
$id, |
1216 |
|
|
$db, |
1217 |
|
|
$val, |
1218 |
|
|
$DEBUG, |
1219 |
|
|
$rowLot['lot'], |
1220 |
|
|
$lot->valF['lot']) === false) { |
1221 |
|
|
$this -> addToMessage( |
1222 |
|
|
_("Erreur lors de l'enregistrement de la demande.")." ". |
1223 |
|
|
_("Contactez votre administrateur.") |
1224 |
|
|
); |
1225 |
|
|
$this->correct = false; |
1226 |
|
|
return false; |
1227 |
|
|
} |
1228 |
nhaye |
2110 |
|
1229 |
nhaye |
1246 |
} |
1230 |
|
|
} |
1231 |
|
|
|
1232 |
nhaye |
2110 |
|
1233 |
nhaye |
1246 |
/** |
1234 |
nhaye |
2976 |
* Méthode permettant d'ajouter les données techniques d'un lot. |
1235 |
|
|
* |
1236 |
|
|
* @param integer $id identifiant de la demande |
1237 |
|
|
* @param database &$db handler de la base de donnée |
1238 |
|
|
* @param array $val tableau de valeurs postées via le formulaire |
1239 |
|
|
* @param boolean $DEBUG debug |
1240 |
|
|
* @param integer $lotInit identifiant de lot initial |
1241 |
|
|
* @param integer $lotDest identifiant du lot qui va recevoir les données |
1242 |
|
|
* |
1243 |
|
|
* @return boolean false si erreur |
1244 |
nhaye |
2110 |
*/ |
1245 |
nhaye |
2976 |
function ajoutDonneesTechniquesLots($id, &$db, $val, $DEBUG, $lotInit, $lotDest) { |
1246 |
|
|
// Requete permettant de recupérer les données techniques du lot passé |
1247 |
|
|
// en paramètre ($lotInit) |
1248 |
|
|
$sql_get_dt = " |
1249 |
|
|
SELECT donnees_techniques |
1250 |
|
|
FROM ".DB_PREFIXE."donnees_techniques |
1251 |
|
|
WHERE lot=".$lotInit; |
1252 |
nhaye |
2110 |
$id_dt = $this->f->db->getOne($sql_get_dt); |
1253 |
nhaye |
2976 |
// Si des données techniques sont liées au lots on les "copie" et |
1254 |
|
|
// on les lies au lot passé en paramètre (lotDest) |
1255 |
|
|
if(isset($id_dt) and !empty($id_dt)) { |
1256 |
|
|
$this->f->addToLog( |
1257 |
|
|
"ajoutDonneesTechniquesLots() : db->getone(\"".$sql_get_dt."\");", |
1258 |
|
|
VERBOSE_MODE |
1259 |
|
|
); |
1260 |
nhaye |
2110 |
if ( database::isError($id_dt)){ |
1261 |
|
|
// Appel de la methode de recuperation des erreurs |
1262 |
|
|
$this->erreur_db($id_dt->getDebugInfo(), $id_dt->getMessage(), ''); |
1263 |
|
|
return false; |
1264 |
|
|
} |
1265 |
|
|
require_once '../obj/donnees_techniques.class.php'; |
1266 |
nhaye |
2976 |
$donnees_techniques = new donnees_techniques($id_dt, $db, $DEBUG); |
1267 |
nhaye |
2110 |
|
1268 |
|
|
// Récupération des données dans le tableau des valeurs à insérer |
1269 |
|
|
foreach($donnees_techniques->champs as $value) { |
1270 |
|
|
$val[$value] = $donnees_techniques->getVal($value); |
1271 |
|
|
} |
1272 |
|
|
// Modification du lien vers le nouveau lot |
1273 |
|
|
$val["lot"] = $lotDest; |
1274 |
nhaye |
2976 |
// Identifiant du cerfa |
1275 |
|
|
$val['cerfa'] = $this->getIdCerfa(); |
1276 |
nhaye |
2110 |
// Ajout des données techniques |
1277 |
nhaye |
2976 |
if($donnees_techniques->ajouter($val, $db, $DEBUG) === false) { |
1278 |
|
|
return false; |
1279 |
|
|
} |
1280 |
nhaye |
2110 |
} |
1281 |
|
|
} |
1282 |
|
|
|
1283 |
|
|
/** |
1284 |
vpihour |
1058 |
* Gestion des liens entre la demande et les demandeurs recemment ajoutés |
1285 |
nhaye |
828 |
**/ |
1286 |
|
|
function insertLinkDemandeDemandeur($db, $DEBUG) { |
1287 |
|
|
// |
1288 |
|
|
require_once "../obj/lien_demande_demandeur.class.php"; |
1289 |
nhaye |
838 |
// Comparaison de l'id petitionnaire principal |
1290 |
|
|
if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND |
1291 |
|
|
!empty($this->postedIdDemandeur['petitionnaire_principal']) AND |
1292 |
|
|
$this->valIdDemandeur['petitionnaire_principal'] != |
1293 |
|
|
$this->postedIdDemandeur['petitionnaire_principal']) { |
1294 |
|
|
// Ajout du nouveau lien |
1295 |
|
|
$this->addLinkDemandeDemandeur($this->postedIdDemandeur['petitionnaire_principal'], true, $db, $DEBUG); |
1296 |
|
|
if(!empty($this->valIdDemandeur['petitionnaire_principal'])) { |
1297 |
|
|
$this->deleteLinkDemandeDemandeur($this->valIdDemandeur['petitionnaire_principal'], $db, $DEBUG); |
1298 |
nhaye |
807 |
} |
1299 |
nhaye |
828 |
} |
1300 |
nhaye |
838 |
|
1301 |
|
|
// Comparaison du delegataire |
1302 |
|
|
if(isset($this->postedIdDemandeur['delegataire']) AND |
1303 |
|
|
!empty($this->postedIdDemandeur['delegataire']) AND |
1304 |
|
|
$this->valIdDemandeur['delegataire'] != |
1305 |
|
|
$this->postedIdDemandeur['delegataire']) { |
1306 |
|
|
// Ajout du nouveau lien |
1307 |
|
|
$this->addLinkDemandeDemandeur($this->postedIdDemandeur['delegataire'], false, $db, $DEBUG); |
1308 |
|
|
if(!empty($this->valIdDemandeur['delegataire'])) { |
1309 |
|
|
$this->deleteLinkDemandeDemandeur($this->valIdDemandeur['delegataire'], $db, $DEBUG); |
1310 |
|
|
} |
1311 |
|
|
} |
1312 |
|
|
|
1313 |
|
|
// Comparaison des different petitionnaires |
1314 |
|
|
if(isset($this->postedIdDemandeur['petitionnaire'])) { |
1315 |
|
|
// Suppression des liens non valides |
1316 |
|
|
foreach ($this->valIdDemandeur['petitionnaire'] as $petitionnaire) { |
1317 |
|
|
if(!in_array($petitionnaire, $this->postedIdDemandeur['petitionnaire'])) { |
1318 |
|
|
$this->deleteLinkDemandeDemandeur($petitionnaire, $db, $DEBUG); |
1319 |
|
|
} |
1320 |
|
|
} |
1321 |
|
|
// Ajout des nouveaux liens |
1322 |
|
|
foreach ($this->postedIdDemandeur['petitionnaire'] as $petitionnaire) { |
1323 |
|
|
if(!in_array($petitionnaire, $this->valIdDemandeur['petitionnaire'])) { |
1324 |
|
|
$this->addLinkDemandeDemandeur($petitionnaire, false, $db, $DEBUG); |
1325 |
|
|
} |
1326 |
|
|
} |
1327 |
|
|
} |
1328 |
|
|
} |
1329 |
|
|
|
1330 |
|
|
|
1331 |
|
|
/** |
1332 |
|
|
* Fonction permettant d'ajouter un lien |
1333 |
|
|
* entre la table demande et demandeur |
1334 |
|
|
**/ |
1335 |
|
|
function addLinkDemandeDemandeur($id, $principal, $db, $DEBUG) { |
1336 |
|
|
$lienAjout = new lien_demande_demandeur( |
1337 |
|
|
"]", |
1338 |
|
|
$db, |
1339 |
|
|
$DEBUG); |
1340 |
|
|
$lien = array('lien_demande_demandeur' => "", |
1341 |
|
|
'petitionnaire_principal' => (($principal)?"t":"f"), |
1342 |
|
|
'demande' => $this->valF['demande'], |
1343 |
|
|
'demandeur' => $id); |
1344 |
|
|
$lienAjout->ajouter($lien, $db, $DEBUG); |
1345 |
|
|
$lienAjout->__destruct(); |
1346 |
|
|
} |
1347 |
|
|
|
1348 |
|
|
/** |
1349 |
|
|
* Fonction permettant de supprimer un lien |
1350 |
|
|
* entre la table demande et demandeur |
1351 |
|
|
**/ |
1352 |
|
|
function deleteLinkDemandeDemandeur($id, $db, $DEBUG) { |
1353 |
|
|
// Suppression |
1354 |
|
|
$sql = "DELETE FROM ".DB_PREFIXE."lien_demande_demandeur ". |
1355 |
|
|
"WHERE demande=".$this->valF['demande']. |
1356 |
|
|
" AND demandeur=".$id; |
1357 |
|
|
// Execution de la requete de suppression de l'objet |
1358 |
|
|
$res = $db->query($sql); |
1359 |
|
|
// Logger |
1360 |
vpihour |
1777 |
$this->f->addToLog("deleteLinkDemandeDemandeur(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1361 |
|
|
if ( database::isError($res)){ |
1362 |
|
|
die(); |
1363 |
|
|
} |
1364 |
nhaye |
838 |
|
1365 |
|
|
} |
1366 |
|
|
|
1367 |
vpihour |
1058 |
/* |
1368 |
|
|
* Teste si le lien entre une demande et un demandeur existe |
1369 |
|
|
* */ |
1370 |
nhaye |
838 |
function isLinkDemandeDemandeurExist($idDemandeur) { |
1371 |
|
|
$sql = "SELECT count(*) |
1372 |
|
|
FROM ".DB_PREFIXE."lien_demande_demandeur |
1373 |
|
|
WHERE demande = ".$this->valF['demande']. |
1374 |
|
|
"AND demandeur = ".$idDemandeur; |
1375 |
|
|
$count = $this->f->db->getOne($sql); |
1376 |
vpihour |
1777 |
$this->f->addToLog("isLinkDemandeDemandeurExist() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
1377 |
|
|
if ( database::isError($count)){ |
1378 |
|
|
die(); |
1379 |
|
|
} |
1380 |
nhaye |
838 |
if ($count === 0) { |
1381 |
|
|
return false; |
1382 |
nhaye |
828 |
} else { |
1383 |
nhaye |
838 |
return true; |
1384 |
nhaye |
828 |
} |
1385 |
nhaye |
838 |
|
1386 |
nhaye |
828 |
} |
1387 |
|
|
|
1388 |
|
|
/** |
1389 |
|
|
* Methode de recupération des valeurs postées |
1390 |
|
|
**/ |
1391 |
|
|
function getPostedValues() { |
1392 |
|
|
// Récupération des demandeurs dans POST |
1393 |
|
|
if (isset($_POST['petitionnaire_principal']) OR |
1394 |
|
|
isset($_POST['delegataire']) OR |
1395 |
|
|
isset($_POST['petitionnaire'])) { |
1396 |
|
|
if( isset($_POST['petitionnaire_principal']) AND |
1397 |
|
|
!empty($_POST['petitionnaire_principal'])) { |
1398 |
nhaye |
838 |
$this->postedIdDemandeur['petitionnaire_principal'] = $_POST['petitionnaire_principal']; |
1399 |
nhaye |
807 |
} |
1400 |
nhaye |
828 |
if( isset($_POST['delegataire']) AND |
1401 |
|
|
!empty($_POST['delegataire'])) { |
1402 |
nhaye |
838 |
$this->postedIdDemandeur['delegataire'] = $_POST['delegataire']; |
1403 |
nhaye |
828 |
} |
1404 |
|
|
if( isset($_POST['petitionnaire']) AND |
1405 |
|
|
!empty($_POST['petitionnaire'])) { |
1406 |
nhaye |
838 |
$this->postedIdDemandeur['petitionnaire'] = $_POST['petitionnaire']; |
1407 |
nhaye |
828 |
} |
1408 |
nhaye |
807 |
} |
1409 |
vpihour |
676 |
} |
1410 |
fmichon |
1713 |
|
1411 |
nhaye |
828 |
/** |
1412 |
fmichon |
1713 |
* Méthode permettant de récupérer les id des demandeurs liés à la table |
1413 |
|
|
* liée passée en paramètre |
1414 |
|
|
* |
1415 |
|
|
* @param string $from Table liée : "demande", "dossier", dossier_autorisation" |
1416 |
|
|
* @param string $id Identifiant (clé primaire de la table liée en question) |
1417 |
|
|
*/ |
1418 |
nhaye |
1039 |
function listeDemandeur($from, $id) { |
1419 |
nhaye |
828 |
// Récupération des demandeurs de la base |
1420 |
fmichon |
1723 |
$sql = "SELECT demandeur.demandeur, |
1421 |
|
|
demandeur.type_demandeur, |
1422 |
|
|
lien_".$from."_demandeur.petitionnaire_principal |
1423 |
|
|
FROM ".DB_PREFIXE."lien_".$from."_demandeur |
1424 |
|
|
INNER JOIN ".DB_PREFIXE."demandeur |
1425 |
|
|
ON demandeur.demandeur=lien_".$from."_demandeur.demandeur |
1426 |
|
|
WHERE ".$from." = '".$id."'"; |
1427 |
|
|
$res = $this->f->db->query($sql); |
1428 |
|
|
$this->f->addToLog("listeDemandeur(): db->query(\"".$sql."\")", VERBOSE_MODE); |
1429 |
vpihour |
1777 |
if ( database::isError($res)){ |
1430 |
|
|
die(); |
1431 |
|
|
} |
1432 |
fmichon |
1723 |
// Stockage du résultat dans un tableau |
1433 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
1434 |
|
|
if ($row['petitionnaire_principal'] == 't' AND |
1435 |
|
|
$row['type_demandeur']=="petitionnaire") { |
1436 |
|
|
$this->valIdDemandeur['petitionnaire_principal']=$row['demandeur']; |
1437 |
|
|
} elseif ($row['petitionnaire_principal'] == 'f' AND |
1438 |
|
|
$row['type_demandeur']=="petitionnaire"){ |
1439 |
|
|
$this->valIdDemandeur['petitionnaire'][]=$row['demandeur']; |
1440 |
|
|
} elseif ($row['type_demandeur']=="delegataire"){ |
1441 |
|
|
$this->valIdDemandeur['delegataire']=$row['demandeur']; |
1442 |
nhaye |
828 |
} |
1443 |
|
|
} |
1444 |
|
|
} |
1445 |
nhaye |
807 |
|
1446 |
nhaye |
1037 |
|
1447 |
nhaye |
807 |
/** |
1448 |
nhaye |
1037 |
* Surcharge du bouton retour afin de retourner sur la recherche de dossiers |
1449 |
|
|
* d'instruction existant |
1450 |
|
|
*/ |
1451 |
|
|
function retour($premier = 0, $recherche = "", $tricol = "") { |
1452 |
|
|
|
1453 |
|
|
echo "\n<a class=\"retour\" "; |
1454 |
|
|
echo "href=\""; |
1455 |
|
|
// |
1456 |
|
|
if($this->getParameter("idx_dossier") != "") { |
1457 |
|
|
echo "tab.php?"; |
1458 |
|
|
echo "obj=recherche_dossier"; |
1459 |
|
|
|
1460 |
|
|
} else { |
1461 |
|
|
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
1462 |
|
|
echo "form.php?"; |
1463 |
|
|
} else { |
1464 |
|
|
echo "tab.php?"; |
1465 |
|
|
} |
1466 |
|
|
echo "obj=".get_class($this); |
1467 |
|
|
if($this->getParameter("retour")=="form") { |
1468 |
|
|
echo "&idx=".$this->getParameter("idx"); |
1469 |
softime |
2093 |
echo "&idz=".$this->getParameter("idz"); |
1470 |
nhaye |
1037 |
echo "&action=3"; |
1471 |
|
|
} |
1472 |
|
|
} |
1473 |
|
|
echo "&premier=".$this->getParameter("premier"); |
1474 |
|
|
echo "&tricol=".$this->getParameter("tricol"); |
1475 |
|
|
echo "&recherche=".$this->getParameter("recherche"); |
1476 |
|
|
echo "&selectioncol=".$this->getParameter("selectioncol"); |
1477 |
|
|
echo "&advs_id=".$this->getParameter("advs_id"); |
1478 |
|
|
echo "&valide=".$this->getParameter("valide"); |
1479 |
|
|
// |
1480 |
|
|
echo "\""; |
1481 |
|
|
echo ">"; |
1482 |
|
|
// |
1483 |
|
|
echo _("Retour"); |
1484 |
|
|
// |
1485 |
|
|
echo "</a>\n"; |
1486 |
|
|
|
1487 |
|
|
} |
1488 |
|
|
|
1489 |
|
|
|
1490 |
|
|
/** |
1491 |
fmichon |
1723 |
* Cette méthode permet d'afficher des informations spécifiques dans le |
1492 |
|
|
* formulaire de l'objet |
1493 |
|
|
* |
1494 |
|
|
* @param integer $maj Mode de mise à jour |
1495 |
nhaye |
807 |
*/ |
1496 |
|
|
function formSpecificContent($maj) { |
1497 |
fmichon |
1723 |
|
1498 |
|
|
/** |
1499 |
|
|
* Gestion du bloc des demandeurs |
1500 |
|
|
*/ |
1501 |
|
|
// Si le mode est (modification ou suppression ou consultation) ET que |
1502 |
|
|
// le formulaire n'est pas correct (c'est-à-dire que le formulaire est |
1503 |
|
|
// actif) |
1504 |
|
|
if (!$this->correct AND $maj != 0) { |
1505 |
|
|
// Alors on récupère les demandeurs dans la table lien pour |
1506 |
|
|
// affectation des résultats dans this->valIdDemandeur |
1507 |
nhaye |
1039 |
$this->listeDemandeur("demande", $this->val[array_search('demande', $this->champs)]); |
1508 |
nhaye |
838 |
} |
1509 |
fmichon |
1723 |
|
1510 |
|
|
// Si le mode est (ajout ou modification) ET que le formulaire n'est pas |
1511 |
|
|
// correct (c'est-à-dire que le formulaire est actif) |
1512 |
|
|
if ($maj < 2 AND !$this->correct) { |
1513 |
|
|
// Alors on positionne le marqueur linkable a true qui permet |
1514 |
|
|
// d'afficher ou non les actions de gestion des demandeurs |
1515 |
nhaye |
838 |
$linkable = true; |
1516 |
|
|
} else { |
1517 |
fmichon |
1723 |
// Sinon on positionne le marqueur linkable a false qui permet |
1518 |
|
|
// d'afficher ou non les actions de gestion des demandeurs |
1519 |
nhaye |
838 |
$linkable = false; |
1520 |
|
|
} |
1521 |
nhaye |
1020 |
|
1522 |
fmichon |
1723 |
// Affichage des demandeurs et des actions |
1523 |
nhaye |
807 |
// Conteneur de la listes des demandeurs |
1524 |
nhaye |
1097 |
echo "<div id=\"liste_demandeur\" class=\"demande_hidden_bloc col_12\">"; |
1525 |
nhaye |
807 |
echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">"; |
1526 |
|
|
echo " <legend class=\"ui-corner-all ui-widget-content ui-state-active\">" |
1527 |
|
|
._("Petitionnaire")."</legend>"; |
1528 |
|
|
// Si des demandeurs sont liés à la demande |
1529 |
nhaye |
828 |
require_once "../obj/petitionnaire.class.php"; |
1530 |
|
|
require_once "../obj/delegataire.class.php"; |
1531 |
nhaye |
1097 |
// Affichage du bloc pétitionnaire principal / délégataire |
1532 |
|
|
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1533 |
nhaye |
1672 |
echo "<div id=\"petitionnaire_principal_delegataire\">"; |
1534 |
nhaye |
1097 |
// Affichage de la synthèse |
1535 |
|
|
if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND |
1536 |
|
|
!empty($this->valIdDemandeur["petitionnaire_principal"])) { |
1537 |
|
|
$demandeur = new petitionnaire( |
1538 |
|
|
$this->valIdDemandeur["petitionnaire_principal"], |
1539 |
|
|
$this->f->db,false); |
1540 |
|
|
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
1541 |
|
|
$demandeur -> __destruct(); |
1542 |
|
|
} elseif ( isset ($this->postedIdDemandeur["petitionnaire_principal"]) AND |
1543 |
|
|
!empty($this->postedIdDemandeur["petitionnaire_principal"]) ) { |
1544 |
|
|
$demandeur = new petitionnaire( |
1545 |
|
|
$this->postedIdDemandeur["petitionnaire_principal"], |
1546 |
|
|
$this->f->db,false); |
1547 |
|
|
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
1548 |
|
|
$demandeur -> __destruct(); |
1549 |
|
|
} |
1550 |
|
|
// Si en édition de formulaire |
1551 |
|
|
if($maj < 2) { |
1552 |
|
|
// Bouton d'ajout du pétitionnaire principal |
1553 |
|
|
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1554 |
|
|
echo "<span id=\"add_petitionnaire_principal\" |
1555 |
|
|
class=\"om-form-button add-16\">". |
1556 |
|
|
_("Saisir le petitionnaire principal"). |
1557 |
|
|
"</span>"; |
1558 |
|
|
} |
1559 |
|
|
// Bouton d'ajout du delegataire |
1560 |
|
|
// L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1561 |
|
|
echo "<div id=\"delegataire\">"; |
1562 |
|
|
// Affichage de la synthèse |
1563 |
|
|
if (isset ($this->valIdDemandeur["delegataire"]) AND |
1564 |
|
|
!empty($this->valIdDemandeur["delegataire"])) { |
1565 |
|
|
$demandeur = new delegataire($this->valIdDemandeur["delegataire"], |
1566 |
|
|
$this->f->db,false); |
1567 |
|
|
$demandeur -> afficherSynthese("delegataire", $linkable); |
1568 |
|
|
$demandeur -> __destruct(); |
1569 |
|
|
} elseif ( isset ($this->postedIdDemandeur["delegataire"]) AND |
1570 |
|
|
!empty($this->postedIdDemandeur["delegataire"]) ) { |
1571 |
nhaye |
807 |
|
1572 |
nhaye |
1097 |
$demandeur = new delegataire($this->postedIdDemandeur["delegataire"], |
1573 |
|
|
$this->f->db,false); |
1574 |
|
|
$demandeur -> afficherSynthese("delegataire", $linkable); |
1575 |
|
|
$demandeur -> __destruct(); |
1576 |
|
|
} |
1577 |
|
|
if($maj < 2) { |
1578 |
|
|
echo "<span id=\"add_delegataire\" |
1579 |
vpihour |
1075 |
class=\"om-form-button add-16\">". |
1580 |
nmeucci |
2846 |
_("Saisir un autre correspondant"). |
1581 |
vpihour |
1051 |
"</span>"; |
1582 |
nhaye |
1097 |
} |
1583 |
|
|
echo "</div>"; |
1584 |
nhaye |
1118 |
echo "<div class=\"both\"></div>"; |
1585 |
nhaye |
1097 |
echo "</div>"; |
1586 |
|
|
// Bloc des pétitionnaires secondaires |
1587 |
|
|
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1588 |
nhaye |
1672 |
echo "<div id=\"listePetitionnaires\">"; |
1589 |
fmichon |
1005 |
|
1590 |
nhaye |
1097 |
// Affichage de la synthèse |
1591 |
|
|
if (isset ($this->valIdDemandeur["petitionnaire"]) AND |
1592 |
|
|
!empty($this->valIdDemandeur["petitionnaire"])) { |
1593 |
|
|
|
1594 |
|
|
foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) { |
1595 |
|
|
$demandeur = new petitionnaire($petitionnaire, |
1596 |
|
|
$this->f->db,false); |
1597 |
|
|
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
1598 |
nhaye |
1065 |
$demandeur -> __destruct(); |
1599 |
|
|
} |
1600 |
|
|
|
1601 |
nhaye |
1097 |
} elseif ( isset ($this->postedIdDemandeur["petitionnaire"]) AND |
1602 |
|
|
!empty($this->postedIdDemandeur["petitionnaire"]) ) { |
1603 |
|
|
foreach ($this->postedIdDemandeur["petitionnaire"] as $petitionnaire) { |
1604 |
|
|
$demandeur = new petitionnaire($petitionnaire, |
1605 |
|
|
$this->f->db,false); |
1606 |
|
|
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
1607 |
|
|
$demandeur -> __destruct(); |
1608 |
nhaye |
828 |
} |
1609 |
nhaye |
1097 |
} |
1610 |
|
|
if ($maj < 2) { |
1611 |
|
|
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1612 |
|
|
echo "<span id=\"add_petitionnaire\" |
1613 |
|
|
class=\"om-form-button add-16\">". |
1614 |
|
|
_("Ajouter un petitionnaire") |
1615 |
|
|
."</span>"; |
1616 |
|
|
} |
1617 |
|
|
echo "</div>"; |
1618 |
nhaye |
807 |
echo "</fieldset>"; |
1619 |
softime |
2313 |
// Champ flag permettant de récupérer la valeur de l'option sig pour |
1620 |
|
|
// l'utiliser en javascript, notamment lors du chargement de l'interface |
1621 |
|
|
// pour les références cadastrales |
1622 |
|
|
// XXX Si un widget pour les références cadastrales existait, il n'y |
1623 |
|
|
// aurait pas besoin de faire cela |
1624 |
|
|
echo "<input id='option_sig' type='hidden' value='".$this->f->getParameter("option_sig")."' name='option_sig'>"; |
1625 |
vpihour |
2364 |
echo "</div>"; |
1626 |
nhaye |
807 |
} |
1627 |
|
|
|
1628 |
nhaye |
1097 |
// {{{ |
1629 |
|
|
|
1630 |
|
|
// getter |
1631 |
|
|
function getValIdDemandeur() { |
1632 |
|
|
return $this->valIdDemandeur; |
1633 |
|
|
} |
1634 |
|
|
// setter |
1635 |
|
|
function setValIdDemandeur($valIdDemandeur) { |
1636 |
|
|
$this->valIdDemandeur = $valIdDemandeur; |
1637 |
|
|
} |
1638 |
vpihour |
1106 |
|
1639 |
|
|
//Supression du lien entre la demandeur et le(s) demandeur(s) |
1640 |
|
|
function triggerSupprimer($id, &$db, $val, $DEBUG){ |
1641 |
|
|
|
1642 |
|
|
//Création de la requête |
1643 |
|
|
$sql = "DELETE FROM |
1644 |
|
|
".DB_PREFIXE."lien_demande_demandeur |
1645 |
|
|
WHERE |
1646 |
|
|
demande = $id"; |
1647 |
|
|
|
1648 |
|
|
$res = $this->f->db->query($sql); |
1649 |
vpihour |
1777 |
$this->f->addToLog("triggerSupprimer() : db->query(\"".$sql."\")"); |
1650 |
|
|
if ( database::isError($res)){ |
1651 |
|
|
die(); |
1652 |
|
|
} |
1653 |
vpihour |
1106 |
} |
1654 |
|
|
|
1655 |
nhaye |
1097 |
// }}} |
1656 |
softime |
2071 |
|
1657 |
|
|
|
1658 |
|
|
/** |
1659 |
|
|
* Cette fonction permet de récupérer les informations nécessaires |
1660 |
|
|
* à la génération du nom du répertoire |
1661 |
|
|
* @param string $dossier Identifiant du dossier |
1662 |
|
|
* @return array Tableau des résultats |
1663 |
|
|
*/ |
1664 |
|
|
private function getInfosForFoldername($dossier) { |
1665 |
|
|
|
1666 |
|
|
//Requête SQL |
1667 |
softime |
2204 |
$sql = "SELECT dossier.dossier_autorisation, dossier_instruction_type.code, dossier.version |
1668 |
softime |
2071 |
FROM ".DB_PREFIXE."dossier |
1669 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1670 |
|
|
ON dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
1671 |
|
|
WHERE dossier.dossier = '".$dossier."'"; |
1672 |
|
|
$res = $this->f->db->query($sql); |
1673 |
|
|
$this->addToLog("getInfosForFoldername() : db->query(".$sql.")", VERBOSE_MODE); |
1674 |
|
|
database::isError($res); |
1675 |
|
|
|
1676 |
|
|
// tableau des résultats |
1677 |
|
|
$row = $res->fetchRow(DB_FETCHMODE_ASSOC); |
1678 |
vpihour |
2119 |
|
1679 |
|
|
//Formatage du numéro de version |
1680 |
vpihour |
2131 |
require_once '../obj/dossier.class.php'; |
1681 |
|
|
$dossier = new dossier($dossier,$this->db,DEBUG); |
1682 |
softime |
2204 |
$row['version'] = $dossier->getNumeroVersionDossierInstructionType($dossier->getVal('dossier_autorisation'), $dossier->getVal('dossier_instruction_type'), $row['version'], false); |
1683 |
vpihour |
2119 |
|
1684 |
softime |
2071 |
// retourne le tableau des résultats |
1685 |
|
|
return $row; |
1686 |
|
|
} |
1687 |
|
|
|
1688 |
|
|
/** |
1689 |
|
|
* Cette fonction permet la création du répertoire dans le dossier de numérisation |
1690 |
|
|
* @param string $dossier_autorisation Identifiant dossier d'autorisation |
1691 |
|
|
* @param string $code Type du dossier d'instruction |
1692 |
|
|
* @param int $version Numéro de version du dossier |
1693 |
|
|
* @return boolean Vrai ou Faux |
1694 |
|
|
*/ |
1695 |
|
|
private function createFolder($dossier_autorisation, $code, $version) { |
1696 |
|
|
|
1697 |
softime |
2369 |
// Nom du répertoire |
1698 |
softime |
2071 |
$foldername = $dossier_autorisation.".".$code.$version; |
1699 |
|
|
|
1700 |
softime |
2369 |
// Vérifie le paramètrage du répertoire de numérisation |
1701 |
softime |
2072 |
if (isset($this->f->config["path_scan"])) { |
1702 |
softime |
2369 |
|
1703 |
|
|
// Vérifie que le répertoire existe |
1704 |
|
|
if (is_dir($this->f->config["path_scan"])) { |
1705 |
|
|
|
1706 |
|
|
// Répertoire des "à traiter" |
1707 |
|
|
$dir = $this->f->config["path_scan"]."Todo/"; |
1708 |
|
|
|
1709 |
|
|
// Si le répertore existe déjà le répertoire n'est pas crée |
1710 |
|
|
if (file_exists($dir.$foldername)) { |
1711 |
|
|
|
1712 |
|
|
// |
1713 |
|
|
return true; |
1714 |
|
|
} |
1715 |
|
|
|
1716 |
|
|
// Vérifie que le répêrtoire des "à traiter" existe |
1717 |
|
|
if (is_dir($dir)) { |
1718 |
|
|
|
1719 |
|
|
// Création du répertoire |
1720 |
|
|
mkdir($dir.$foldername, 0777); |
1721 |
|
|
// |
1722 |
|
|
return true; |
1723 |
|
|
} |
1724 |
|
|
|
1725 |
|
|
// Message d'erreur |
1726 |
|
|
$this->msg = ""; |
1727 |
|
|
$this->addToErrors ('', _("Le repertoire Todo n'existe pas.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1728 |
|
|
// |
1729 |
|
|
return false; |
1730 |
|
|
|
1731 |
softime |
2072 |
} |
1732 |
softime |
2369 |
|
1733 |
|
|
// Message d'erreur |
1734 |
|
|
$this->msg = ""; |
1735 |
|
|
$this->addToErrors ('', _("Le repertoire de numerisation configure n'existe pas.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1736 |
|
|
// |
1737 |
|
|
return false; |
1738 |
|
|
|
1739 |
softime |
2071 |
} |
1740 |
|
|
|
1741 |
softime |
2369 |
// Message d'erreur |
1742 |
|
|
$this->msg = ""; |
1743 |
|
|
$this->addToErrors ('', _("Le repertoire de numerisation n'a pas ete configure.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1744 |
|
|
// |
1745 |
softime |
2071 |
return false; |
1746 |
|
|
} |
1747 |
|
|
|
1748 |
softime |
2363 |
/** |
1749 |
|
|
* Récupère le champ "qualification" du type de la demande |
1750 |
|
|
* @param integer $demande_type Identifiant du type de la demande |
1751 |
|
|
* @return boolean |
1752 |
|
|
*/ |
1753 |
|
|
function get_qualification($demande_type) { |
1754 |
|
|
|
1755 |
|
|
// Initialise le résultat |
1756 |
|
|
$qualification = ""; |
1757 |
|
|
|
1758 |
|
|
// Si la condition existe |
1759 |
softime |
2365 |
if (is_numeric($demande_type)) { |
1760 |
softime |
2363 |
|
1761 |
|
|
// Requête SQL |
1762 |
|
|
$sql = "SELECT qualification |
1763 |
|
|
FROM ".DB_PREFIXE."demande_type |
1764 |
|
|
WHERE demande_type = $demande_type"; |
1765 |
|
|
$qualification = $this->db->getOne($sql); |
1766 |
softime |
2365 |
$this->f->addToLog("get_qualification() : db->getOne(\"".$sql."\")", |
1767 |
|
|
VERBOSE_MODE); |
1768 |
softime |
2363 |
$this->f->isDatabaseError($qualification); |
1769 |
|
|
} |
1770 |
|
|
|
1771 |
|
|
// Retourne le résultat |
1772 |
|
|
return $qualification; |
1773 |
|
|
} |
1774 |
|
|
|
1775 |
vpihour |
2643 |
/** |
1776 |
|
|
* Récupère les champs archive_* d'une instruction |
1777 |
|
|
* @param string $dossier L'identifiant du dossier d'instruction |
1778 |
|
|
*/ |
1779 |
|
|
public function getArchiveInstruction($dossierID){ |
1780 |
|
|
|
1781 |
|
|
//On récupère les données du dernier DI accordé |
1782 |
|
|
$sql = "SELECT dossier.delai, dossier.accord_tacite, dossier.etat, |
1783 |
|
|
dossier.avis_decision, |
1784 |
|
|
to_char(dossier.date_complet, 'DD/MM/YYYY') as date_complet, |
1785 |
|
|
to_char(dossier.date_dernier_depot, 'DD/MM/YYYY') as date_dernier_depot, |
1786 |
|
|
to_char(dossier.date_rejet, 'DD/MM/YYYY') as date_rejet, |
1787 |
|
|
to_char(dossier.date_limite, 'DD/MM/YYYY') as date_limite, |
1788 |
|
|
to_char(dossier.date_notification_delai, 'DD/MM/YYYY') as date_notification_delai, |
1789 |
|
|
to_char(dossier.date_decision, 'DD/MM/YYYY') as date_decision, |
1790 |
|
|
to_char(dossier.date_validite, 'DD/MM/YYYY') as date_validite, |
1791 |
|
|
to_char(dossier.date_achevement, 'DD/MM/YYYY') as date_achevement, |
1792 |
|
|
to_char(dossier.date_chantier, 'DD/MM/YYYY') as date_chantier, |
1793 |
|
|
to_char(dossier.date_conformite, 'DD/MM/YYYY') as date_conformite, |
1794 |
|
|
dossier.incompletude, |
1795 |
|
|
dossier.evenement_suivant_tacite, dossier.evenement_suivant_tacite_incompletude, |
1796 |
|
|
dossier.etat_pendant_incompletude, |
1797 |
|
|
to_char(dossier.date_limite_incompletude, 'DD/MM/YYYY') as date_limite_incompletude, |
1798 |
|
|
dossier.delai_incompletude, dossier.autorite_competente, dossier.duree_validite |
1799 |
nhaye |
3059 |
,dossier.dossier, dossier.incomplet_notifie |
1800 |
vpihour |
2643 |
FROM ".DB_PREFIXE."dossier |
1801 |
|
|
LEFT JOIN ".DB_PREFIXE."avis_decision |
1802 |
|
|
ON dossier.avis_decision = avis_decision.avis_decision |
1803 |
|
|
WHERE dossier.avis_decision IS NOT NULL AND avis_decision.typeavis = 'F' |
1804 |
|
|
AND dossier.dossier_autorisation = ( |
1805 |
|
|
SELECT dossier_autorisation.dossier_autorisation |
1806 |
|
|
FROM ".DB_PREFIXE."dossier_autorisation |
1807 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier |
1808 |
|
|
ON dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1809 |
|
|
WHERE dossier = '".$dossierID."') |
1810 |
|
|
ORDER BY dossier.version DESC"; |
1811 |
|
|
|
1812 |
|
|
$res = $this->db->query($sql); |
1813 |
|
|
$this->addToLog("updateArchiveInstruction(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1814 |
|
|
if (database::isError($res)) { |
1815 |
|
|
die($res->getMessage()); |
1816 |
|
|
} |
1817 |
|
|
|
1818 |
|
|
//Un des dosssiers d'instruction a été accordé, on récupère ses données |
1819 |
|
|
if ( $res->numrows() != 0 ){ |
1820 |
|
|
|
1821 |
|
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1822 |
|
|
require_once "../obj/instruction.class.php"; |
1823 |
|
|
$instruction = new instruction("]",$this->db,DEBUG); |
1824 |
|
|
|
1825 |
|
|
$instruction->setParameter("maj", 1); |
1826 |
|
|
$instruction->updateArchiveData($row); |
1827 |
|
|
return $instruction->valF; |
1828 |
|
|
} |
1829 |
|
|
//Sinon, on prend les données du P0, si ce n'est pas un P0 |
1830 |
|
|
else { |
1831 |
|
|
$sql = "SELECT dossier.delai, dossier.accord_tacite, dossier.etat, |
1832 |
|
|
dossier.avis_decision, dossier.date_complet, dossier.date_dernier_depot, |
1833 |
|
|
dossier.date_rejet, dossier.date_limite, dossier.date_notification_delai, |
1834 |
|
|
dossier.date_decision, dossier.date_validite, dossier.date_achevement, |
1835 |
|
|
dossier.date_chantier, dossier.date_conformite, dossier.incompletude, |
1836 |
|
|
dossier.evenement_suivant_tacite, dossier.evenement_suivant_tacite_incompletude, |
1837 |
|
|
dossier.etat_pendant_incompletude, dossier.date_limite_incompletude, |
1838 |
nhaye |
3059 |
dossier.delai_incompletude, dossier.autorite_competente, dossier.duree_validite, |
1839 |
|
|
dossier.dossier, dossier.incomplet_notifie |
1840 |
vpihour |
2643 |
FROM ".DB_PREFIXE."dossier |
1841 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1842 |
|
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1843 |
|
|
WHERE dossier.dossier_autorisation = ( |
1844 |
|
|
SELECT dossier_autorisation.dossier_autorisation |
1845 |
|
|
FROM ".DB_PREFIXE."dossier_autorisation |
1846 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier |
1847 |
|
|
ON dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1848 |
softime |
2653 |
WHERE dossier = '".$dossierID."') |
1849 |
vpihour |
2643 |
AND dossier_instruction_type.code = 'P' |
1850 |
|
|
ORDER BY dossier.version DESC"; |
1851 |
|
|
$res = $this->db->query($sql); |
1852 |
|
|
$this->addToLog("updateArchiveInstruction(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1853 |
|
|
if (database::isError($res)) { |
1854 |
|
|
die($res->getMessage()); |
1855 |
|
|
} |
1856 |
|
|
|
1857 |
|
|
//On est pas dans le cas d'un dépôt d'un P0 |
1858 |
|
|
if ( $res->numrows() != 0 ){ |
1859 |
|
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1860 |
softime |
2653 |
require_once "../obj/instruction.class.php"; |
1861 |
vpihour |
2643 |
$instruction = new instruction("]",$this->db,DEBUG); |
1862 |
|
|
$instruction->setParameter("maj", 1); |
1863 |
|
|
$instruction->updateArchiveData($row); |
1864 |
|
|
return $instruction->valF; |
1865 |
|
|
} |
1866 |
|
|
} |
1867 |
|
|
} |
1868 |
vpihour |
632 |
}// fin classe |
1869 |
fmichon |
1005 |
?> |