13 |
"delegataire" => "", |
"delegataire" => "", |
14 |
"petitionnaire" => array()); |
"petitionnaire" => array()); |
15 |
|
|
16 |
|
var $autreDossierEnCour; |
17 |
|
|
18 |
function demande($id,&$db,$debug) { |
function demande($id,&$db,$debug) { |
19 |
$this->constructeur($id,$db,$debug); |
$this->constructeur($id,$db,$debug); |
20 |
}// fin constructeur |
}// fin constructeur |
21 |
|
|
22 |
|
function setValF($val) { |
23 |
|
parent::setValF($val); |
24 |
|
// Récupération des id demandeurs postés |
25 |
|
$this->getPostedValues(); |
26 |
|
//$this->valIdDemandeur=$this->postedIdDemandeur; |
27 |
|
} |
28 |
|
|
29 |
|
/** |
30 |
|
* Méthode permettant de récupérer les valeurs du dossier d'autorisation |
31 |
|
* correspondant à la nouvelle demande |
32 |
|
*/ |
33 |
|
function getValFromDossier($dossier_autorisation) { |
34 |
|
include "../sql/pgsql/demande.form.inc.php"; |
35 |
|
$sql=str_replace("<idx>",$this->getParameter("idx_dossier"), |
36 |
|
$sql_infos_dossier); |
37 |
|
$res = $this->db->query($sql); |
38 |
|
$this->f->addToLog("getValFromDossier(): db->query(\"".$sql."\")", VERBOSE_MODE); |
39 |
|
if ( database::isError($res)){ |
40 |
|
die(); |
41 |
|
} |
42 |
|
$row = & $res->fetchRow(DB_FETCHMODE_ASSOC); |
43 |
|
return $row; |
44 |
|
} |
45 |
|
|
46 |
/* |
/* |
47 |
* La date du jour par défaut dans le champs date_demande |
* La date du jour par défaut dans le champs date_demande |
49 |
*/ |
*/ |
50 |
function setVal(&$form, $maj, $validation, &$db) { |
function setVal(&$form, $maj, $validation, &$db) { |
51 |
if($maj == 0) { |
if($maj == 0) { |
52 |
$form->setVal("date_demande",date('d/m/Y')); |
$form->setVal("date_demande",date('d/m/Y')); |
53 |
|
|
54 |
|
// Récupération des valeurs du dossier d'autorisation correspondant |
55 |
|
if($this->getParameter("idx_dossier") != "") { |
56 |
|
$val_autorisation = $this->getValFromDossier( |
57 |
|
$this->getParameter("idx_dossier")); |
58 |
|
foreach($val_autorisation as $champ => $value) { |
59 |
|
$form->setVal($champ,$value); |
60 |
|
} |
61 |
|
} |
62 |
|
} |
63 |
|
} |
64 |
|
function getDataSubmit() { |
65 |
|
|
66 |
|
$datasubmit = parent::getDataSubmit(); |
67 |
|
if($this->getParameter("idx_dossier") != "") { |
68 |
|
$datasubmit .= "&idx_dossier=".$this->getParameter("idx_dossier"); |
69 |
} |
} |
70 |
|
return $datasubmit; |
71 |
} |
} |
72 |
|
|
73 |
/** |
/** |
75 |
*/ |
*/ |
76 |
function verifier($val, &$db, $DEBUG) { |
function verifier($val, &$db, $DEBUG) { |
77 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val, $db, $DEBUG); |
|
$this->getPostedValues(); |
|
78 |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
79 |
empty($this->postedIdDemandeur["petitionnaire_principal"])) { |
empty($this->postedIdDemandeur["petitionnaire_principal"])) { |
80 |
$this->correct = false; |
$this->correct = false; |
81 |
$this->addToMessage("La saisie d'un petitionnaire principal est obligatoire."); |
$this->addToMessage(_("La saisie d'un petitionnaire principal est obligatoire.")); |
|
$this->valIdDemandeur=$this->postedIdDemandeur; |
|
82 |
} |
} |
83 |
} |
} |
84 |
|
|
85 |
|
/** |
86 |
|
* Configuration des select |
87 |
|
*/ |
88 |
|
function setSelect(&$form, $maj,&$db,$debug) { |
89 |
|
parent::setSelect($form, $maj,$db,$debug); |
90 |
|
|
91 |
|
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
92 |
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
93 |
|
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
94 |
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
95 |
|
|
96 |
|
//Récupération de paramètre pour le rechargement ajax du select |
97 |
|
$idx_dossier = $this->getParameter("idx_dossier"); |
98 |
|
$datd = $this->getParameter("datd"); |
99 |
|
|
100 |
|
$contenu = array(); |
101 |
|
|
102 |
|
$sql_demande_type = "SELECT demande_type.demande_type, demande_type.libelle FROM ".DB_PREFIXE."demande_type |
103 |
|
LEFT OUTER JOIN ".DB_PREFIXE."lien_demande_type_etat_dossier_autorisation |
104 |
|
ON lien_demande_type_etat_dossier_autorisation.demande_type=demande_type.demande_type |
105 |
|
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation |
106 |
|
ON lien_demande_type_etat_dossier_autorisation.etat_dossier_autorisation= |
107 |
|
dossier_autorisation.etat_dossier_autorisation |
108 |
|
LEFT OUTER JOIN ".DB_PREFIXE."dossier |
109 |
|
ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation"; |
110 |
|
|
111 |
|
// Ajout de filtre sur la requête (initial) |
112 |
|
if(isset($idx_dossier) AND $idx_dossier != "") { |
113 |
|
$sql_demande_type .= " WHERE demande_type.demande_nature = 2 "; |
114 |
|
|
115 |
|
// ajout du numéro de dossier existant pour tester l'état du DA |
116 |
|
$sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' "; |
117 |
|
} else { |
118 |
|
$sql_demande_type .= " WHERE demande_type.demande_nature = 1 "; |
119 |
|
} |
120 |
|
if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") { |
121 |
|
$datd = $_POST["dossier_autorisation_type_detaille"]; |
122 |
|
} |
123 |
|
// Ajout de filtre sur la requête (dossier_autorisation_type_detaille) |
124 |
|
if(isset($datd) AND $datd != "") { |
125 |
|
$sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd; |
126 |
|
} else { |
127 |
|
$datd = $this->getVal("dossier_autorisation_type_detaille"); |
128 |
|
if ($datd != "") { |
129 |
|
$sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd; |
130 |
|
} |
131 |
|
} |
132 |
|
$sql_demande_type .= " ORDER BY demande_type.libelle"; |
133 |
|
$res = $db->query($sql_demande_type); |
134 |
|
|
135 |
|
// logger |
136 |
|
$this->f->addToLog("setSelect(): db->query(\"".$sql_demande_type."\");", |
137 |
|
VERBOSE_MODE); |
138 |
|
if ( database::isError($res)){ |
139 |
|
die(); |
140 |
|
} |
141 |
|
|
142 |
|
$contenu[0][0] = ''; |
143 |
|
$contenu[1][0] = _('choisir')." "._("demande_type"); |
144 |
|
|
145 |
|
$k=1; |
146 |
|
while($row =& $res->fetchRow()){ |
147 |
|
|
148 |
|
$contenu[0][$k] = $row[0]; |
149 |
|
$contenu[1][$k] = $row[1]; |
150 |
|
$k++; |
151 |
|
} |
152 |
|
|
153 |
|
$form->setSelect("demande_type", $contenu); |
154 |
|
|
155 |
|
} |
156 |
/* |
/* |
157 |
* Ajout du fielset |
* Ajout du fielset |
158 |
* Add fieldset |
* Add fieldset |
160 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
161 |
if ( $maj < 2 OR $maj == 3 ) { |
if ( $maj < 2 OR $maj == 3 ) { |
162 |
|
|
163 |
//Champs sur lequel s'ouvre le fieldset |
/*Champ sur lequel s'ouvre le bloc 1 */ |
164 |
$form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8"); |
$form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8"); |
165 |
|
|
166 |
$form->setFieldset('dossier_autorisation_type_detaille','D' |
$form->setFieldset('dossier_autorisation_type_detaille','D' |
167 |
,_('Type de dossier/demande')); |
,_('Type de dossier/demande')); |
168 |
$form->setFieldset('demande_type','F',''); |
$form->setFieldset('demande_type','F',''); |
169 |
|
|
170 |
$form->setBloc('demande_type','F'); |
$form->setBloc('demande_type','F'); |
171 |
|
/*Fin bloc 1*/ |
172 |
|
|
173 |
|
/*Champ sur lequel s'ouvre le bloc 2 */ |
174 |
$form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc"); |
$form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc"); |
175 |
$form->setFieldset('date_demande','D',_('Date de la demande')); |
$form->setFieldset('date_demande','D',_('Date de la demande')); |
176 |
$form->setFieldset('date_demande','F',''); |
$form->setFieldset('date_demande','F',''); |
177 |
$form->setBloc('date_demande','F'); |
$form->setBloc('date_demande','F'); |
178 |
|
/*Fin bloc 2*/ |
179 |
|
|
180 |
|
/*Champ sur lequel s'ouvre le bloc 3 */ |
181 |
$form->setBloc('terrain_references_cadastrales','D',"", |
$form->setBloc('terrain_references_cadastrales','D',"", |
182 |
"localisation col_12 demande_hidden_bloc"); |
"localisation col_12 demande_hidden_bloc"); |
183 |
$form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain')); |
$form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain')); |
184 |
$form->setFieldset('terrain_superficie','F',''); |
$form->setFieldset('terrain_superficie','F',''); |
185 |
$form->setBloc('terrain_superficie','F'); |
$form->setBloc('terrain_superficie','F'); |
186 |
|
/*Fin bloc 4*/ |
187 |
|
|
|
$form->setBloc('nombre_lots','D',"","lots col_12 demande_hidden_bloc"); |
|
|
$form->setFieldset('nombre_lots','D',_('Nombre de lots')); |
|
|
$form->setFieldset('nombre_lots','F',''); |
|
|
$form->setBloc('nombre_lots','F'); |
|
188 |
} |
} |
189 |
} |
} |
190 |
|
|
197 |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
198 |
$form->setOnchange("demande_type","showFormsDemande();"); |
$form->setOnchange("demande_type","showFormsDemande();"); |
199 |
} |
} |
200 |
|
|
201 |
|
function setLib(&$form,$maj) { |
202 |
|
parent::setLib($form,$maj); |
203 |
|
//libelle des champs |
204 |
|
|
205 |
|
$form->setLib('complement',_('terrain_adresse')); |
206 |
|
} |
207 |
/* |
/* |
208 |
* Cache le champ terrain_references_cadastrales |
* Cache le champ terrain_references_cadastrales |
209 |
* Hide the fiels terrain_references_cadastrales |
* Hide the fiels terrain_references_cadastrales |
213 |
|
|
214 |
$form->setType('dossier_instruction', 'hidden'); |
$form->setType('dossier_instruction', 'hidden'); |
215 |
$form->setType('dossier_autorisation', 'hidden'); |
$form->setType('dossier_autorisation', 'hidden'); |
216 |
|
|
217 |
|
$form->setType('instruction_recepisse', 'hidden'); |
218 |
|
$form->setType('arrondissement', 'hidden'); |
219 |
|
|
220 |
|
// Si il s'agit d'une demande sur dossier existant on desactive tous les champs |
221 |
|
// sauf demande_type |
222 |
|
if(($maj == 0 AND $this-> getParameter("idx_dossier"))) { |
223 |
|
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
224 |
|
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
225 |
|
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
226 |
|
$form->setType('complement', 'hiddenstatic'); |
227 |
|
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
228 |
|
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
229 |
|
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
230 |
|
$form->setType('terrain_adresse_bp', 'hiddenstatic'); |
231 |
|
$form->setType('terrain_adresse_cedex', 'hiddenstatic'); |
232 |
|
$form->setType('terrain_superficie', 'hiddenstatic'); |
233 |
|
} |
234 |
|
if($maj == 1) { |
235 |
|
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
236 |
|
$form->setType('demande_type', 'selecthiddenstatic'); |
237 |
|
} |
238 |
|
if($maj == 3) { |
239 |
|
$form->setType('terrain_references_cadastrales', 'referencescadastralesstatic'); |
240 |
|
} |
241 |
|
|
242 |
} |
} |
243 |
|
|
244 |
/** |
/** |
245 |
* Méthode permettant la création de dossiers |
* Méthode permettant d'ajouter un dossier d'autorisation |
246 |
**/ |
*/ |
247 |
function triggerAjoutDossier($id, &$db, $val, $DEBUG){ |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
248 |
include '../sql/pgsql/demande.form.inc.php'; |
require_once '../obj/dossier_autorisation.class.php'; |
249 |
if($this->valF["demande_type"] != NULL) { |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
250 |
$res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)); |
$id_etat_initial_da = $this->f->getParameter('etat_initial_dossier_autorisation'); |
251 |
$this->f->isDatabaseError(); |
$error = false; |
252 |
$row = $res->fetchRow(DB_FETCHMODE_ASSOC); |
|
253 |
// Création du dossier_autorisation |
// Vérification de l'existance d'un état initial des DA dans la table om_parametre |
254 |
if($row ['dossier_autorisation_type_detaille'] != NULL) { |
// afin d'éviter d'eventuelle erreur de base de données |
255 |
// Création du dossier |
if(isset($id_etat_initial_da)) { |
256 |
$valAuto['dossier_autorisation']=NULL; |
$sql = "SELECT count(*) FROM ".DB_PREFIXE."etat_dossier_autorisation |
257 |
$valAuto['nature']=NULL; |
WHERE etat_dossier_autorisation = ".$id_etat_initial_da; |
258 |
|
$count = $this->db->getOne($sql); |
259 |
|
$this->f->addToLog("ajoutDossierAutorisation() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
260 |
|
if ( database::isError($count)){ |
261 |
|
die(); |
262 |
|
} |
263 |
|
if($count != 1) { |
264 |
|
$error = true; |
265 |
|
} else { |
266 |
|
// La méthode ajouter prend en paramètre un tableau associatif |
267 |
|
// contenant toutes les champs de la classe instanciée, |
268 |
|
// d'où l'initialisation du tableau en bouclant sur la liste des champs du DA |
269 |
|
foreach($dossier_autorisation->champs as $value) { |
270 |
|
$valAuto[$value] = NULL; |
271 |
|
} |
272 |
|
// Définition des valeurs à insérer |
273 |
|
$valAuto['dossier_autorisation']=""; |
274 |
$valAuto['exercice']=NULL; |
$valAuto['exercice']=NULL; |
275 |
$valAuto['insee']=NULL; |
$valAuto['insee']=NULL; |
276 |
$valAuto['arrondissement']=NULL; |
$valAuto['arrondissement']=NULL; |
277 |
$valAuto['etat']=NULL; |
$valAuto['etat_dossier_autorisation']=$this->f->getParameter('etat_initial_dossier_autorisation'); |
278 |
$valAuto['erp_numero_batiment']=NULL; |
$valAuto['erp_numero_batiment']=NULL; |
279 |
$valAuto['erp_ouvert']=NULL; |
$valAuto['erp_ouvert']=NULL; |
280 |
$valAuto['erp_arrete_decision']=NULL; |
$valAuto['erp_arrete_decision']=NULL; |
281 |
$valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille']; |
$valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille']; |
282 |
$valAuto['depot_initial']=$this->valF['date_demande']; |
$valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
283 |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
284 |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
285 |
$valAuto['complement']=$this->valF['complement']; |
$valAuto['complement']=$this->valF['complement']; |
289 |
$valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
$valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
290 |
$valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
$valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
291 |
$valAuto['terrain_superficie']=$this->valF['terrain_superficie']; |
$valAuto['terrain_superficie']=$this->valF['terrain_superficie']; |
292 |
require_once '../obj/dossier_autorisation.class.php'; |
$valAuto['numero_version']=-1; |
293 |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
// Ajout du dossier dans la base |
294 |
$dossier_autorisation->ajouter($valAuto, $db, $DEBUG); |
$dossier_autorisation->ajouter($valAuto, $db, $DEBUG); |
295 |
|
// Liaison du dossier ajouter à la demande |
296 |
$this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation']; |
$this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation']; |
297 |
// Création des liens entre le dossier et les demandeurs |
} |
298 |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
} else { |
299 |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
$error = true; |
300 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
} |
301 |
$res = $db->query($sql); |
// Affichage de l'erreur et stop de l'affichage |
302 |
$this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
if( $error ) { |
303 |
$this->f->isDatabaseError(); |
echo "</div>"; |
304 |
print_r($sql); |
$class = "error"; |
305 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
306 |
$row['lien_dossier_autorisation_demandeur'] = NULL; |
$this->f->displayMessage($class, $message); |
307 |
$row['dossier_autorisation'] = $this->valF['dossier_autorisation']; |
die(); |
308 |
$ldad->ajouter($row, $db, $DEBUG); |
} |
309 |
} |
|
310 |
|
} |
311 |
|
|
312 |
|
function getCodeDemandeType($demande_type){ |
313 |
|
|
314 |
|
$sql = "SELECT |
315 |
|
code |
316 |
|
FROM |
317 |
|
".DB_PREFIXE."demande_type |
318 |
|
WHERE |
319 |
|
demande_type = ".$demande_type; |
320 |
|
$codeDemandeType = $this->db->getOne($sql); |
321 |
|
$this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
322 |
|
|
323 |
|
return $codeDemandeType; |
324 |
|
} |
325 |
|
|
326 |
|
/** |
327 |
|
* Méthode permettant d'ajouter un dossier d'instruction |
328 |
|
*/ |
329 |
|
function ajoutDossierInstruction($id, &$db, $val, $DEBUG, $dossier_instruction_type){ |
330 |
|
require_once '../obj/dossier.class.php'; |
331 |
|
$dossier = new dossier("]",$db,$DEBUG); |
332 |
|
foreach($dossier->champs as $value) { |
333 |
|
$valInstr[$value] = NULL; |
334 |
|
} |
335 |
|
require_once '../obj/dossier_autorisation_type_detaille.class.php'; |
336 |
|
$datd = new dossier_autorisation_type_detaille( |
337 |
|
$this->valF['dossier_autorisation_type_detaille'],$db,$DEBUG); |
338 |
|
|
339 |
|
/*Ajout de la variable dossier_instruction_type à l'objet dossier pour le |
340 |
|
* versionning |
341 |
|
*/ |
342 |
|
$dossier->setDossierInstructionType($dossier_instruction_type); |
343 |
|
|
344 |
|
// Définition des valeurs à entrée dans la table |
345 |
|
$valInstr['dossier_instruction_type']=$dossier_instruction_type; |
346 |
|
$valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']); |
347 |
|
$valInstr['date_dernier_depot']=$this->dateDBToForm($this->valF['date_demande']); |
348 |
|
$valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']); |
349 |
|
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
350 |
|
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
351 |
|
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
352 |
|
$valInstr['complement']=$this->valF['complement']; |
353 |
|
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
354 |
|
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
355 |
|
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
356 |
|
$valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
357 |
|
$valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
358 |
|
$valInstr['terrain_superficie']=$this->valF['terrain_superficie']; |
359 |
|
$valInstr['description']=""; |
360 |
|
$valInstr['dossier_autorisation']=$this->valF['dossier_autorisation']; |
361 |
|
|
362 |
|
/* |
363 |
|
* Gestion de la qualification |
364 |
|
* */ |
365 |
|
//Récupérer le code du type de la demande |
366 |
|
$codeDemandeType = $this->getCodeDemandeType($val['demande_type']); |
367 |
|
|
368 |
|
//Marque le dossier comme à qualifier selon le type de dossier d'instruction |
369 |
|
if ( strcasecmp($codeDemandeType, "DI") == 0 || |
370 |
|
strcasecmp($codeDemandeType, "DT") == 0 || |
371 |
|
strcasecmp($codeDemandeType, "DM") == 0 || |
372 |
|
strcasecmp($codeDemandeType, "DP") == 0 || |
373 |
|
strcasecmp($codeDemandeType, "DTP") == 0 || |
374 |
|
strcasecmp($codeDemandeType, "DAACT") == 0 || |
375 |
|
strcasecmp($codeDemandeType, "DOC") == 0 ){ |
376 |
|
|
377 |
|
$valInstr['a_qualifier'] = TRUE; |
378 |
|
} |
379 |
|
|
380 |
|
// Récupération du cerfa pour le type d'instruction sélectionnée et valide |
381 |
|
$sql = "SELECT |
382 |
|
dossier_instruction_type.cerfa |
383 |
|
FROM |
384 |
|
".DB_PREFIXE."dossier_instruction_type |
385 |
|
JOIN |
386 |
|
".DB_PREFIXE."cerfa |
387 |
|
ON |
388 |
|
dossier_instruction_type.cerfa = cerfa.cerfa |
389 |
|
WHERE |
390 |
|
now()<=om_validite_fin |
391 |
|
AND now()>=om_validite_debut |
392 |
|
AND dossier_instruction_type=".$dossier_instruction_type; |
393 |
|
$valInstr['cerfa'] = $db->getOne($sql); |
394 |
|
$this->f->addToLog("ajoutDossierInstruction() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
395 |
|
if ( database::isError($valInstr['cerfa'])){ |
396 |
|
die(); |
397 |
|
} |
398 |
|
$dossier->ajouter($valInstr, $db, $DEBUG); |
399 |
|
// Liaison du dossier ajouter à la demande |
400 |
|
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
401 |
|
} |
402 |
|
|
403 |
|
/** |
404 |
|
* Méthode permettant d'ajouter les données techniques au dossier d'instruction |
405 |
|
*/ |
406 |
|
function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){ |
407 |
|
|
408 |
|
require_once '../obj/donnees_techniques.class.php'; |
409 |
|
$donnees_techniques = new donnees_techniques("]",$db,$DEBUG); |
410 |
|
|
411 |
|
// Champs tous à NULL car seul le champ concernant le dossier d'instruction sera rempli |
412 |
|
foreach($donnees_techniques->champs as $value) { |
413 |
|
$val[$value] = NULL; |
414 |
|
} |
415 |
|
|
416 |
|
// Ajout du numéro de dossier d'instruction |
417 |
|
$val['dossier_instruction']=$this->valF['dossier_instruction']; |
418 |
|
|
419 |
|
// Ajout des données techniques |
420 |
|
$donnees_techniques->ajouter($val, $db, $DEBUG); |
421 |
|
} |
422 |
|
|
423 |
|
/** |
424 |
|
* Ajout des liens demandeurs / dossier d'autorisation |
425 |
|
**/ |
426 |
|
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
427 |
|
// Création des liens entre le dossier autorisation et les demandeurs |
428 |
|
include '../sql/pgsql/demande.form.inc.php'; |
429 |
|
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
430 |
|
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
431 |
|
// Recupération des demandeurs liés à la demande |
432 |
|
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
433 |
|
$res = $db->query($sql); |
434 |
|
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
435 |
|
if ( database::isError($res)){ |
436 |
|
die(); |
437 |
|
} |
438 |
|
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
439 |
|
$row['lien_dossier_autorisation_demandeur'] = NULL; |
440 |
|
$row['dossier_autorisation'] = $this->valF['dossier_autorisation']; |
441 |
|
$ldad->ajouter($row, $db, $DEBUG); |
442 |
|
} |
443 |
|
} |
444 |
|
|
445 |
|
/** |
446 |
|
* Ajout des liens demandeurs / dossier d'autorisation |
447 |
|
**/ |
448 |
|
function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) { |
449 |
|
// Création des liens entre le dossier instruction et les demandeurs |
450 |
|
include '../sql/pgsql/demande.form.inc.php'; |
451 |
|
require_once '../obj/lien_dossier_demandeur.class.php'; |
452 |
|
$ldd = new lien_dossier_demandeur("]",$db,$DEBUG); |
453 |
|
// Recupération des demandeurs liés à la demande |
454 |
|
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
455 |
|
$res = $db->query($sql); |
456 |
|
$this->f->addToLog("ajoutLiensDossierInstruction() : db->query(\"".$sql."\");", VERBOSE_MODE); |
457 |
|
if ( database::isError($res)){ |
458 |
|
die(); |
459 |
|
} |
460 |
|
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
461 |
|
$row['lien_dossier_demandeur'] = NULL; |
462 |
|
$row['dossier'] = $this->valF['dossier_instruction']; |
463 |
|
$ldd->ajouter($row, $db, $DEBUG); |
464 |
|
} |
465 |
|
} |
466 |
|
|
467 |
|
/* |
468 |
|
* Récupère l'identifiant d'un arrondissement à partir d'un code postal |
469 |
|
*/ |
470 |
|
function getArrondissement($terrain_adresse_code_postal){ |
471 |
|
|
472 |
|
$arrondissement = NULL; |
473 |
|
|
474 |
|
$sql = "SELECT |
475 |
|
arrondissement |
476 |
|
FROM |
477 |
|
".DB_PREFIXE."arrondissement |
478 |
|
WHERE |
479 |
|
code_postal = '$terrain_adresse_code_postal' "; |
480 |
|
$this->addToLog("demande.class.php : ".$sql." execute <br>", EXTRA_VERBOSE_MODE); |
481 |
|
|
482 |
|
$res = $this->db->query($sql); |
483 |
|
$this->f->addToLog("getArrondissement() : db->query(\"".$sql."\")", VERBOSE_MODE); |
484 |
|
if ( database::isError($res)){ |
485 |
|
die(); |
486 |
|
} |
487 |
|
|
488 |
|
if( $res->numrows() > 0 ) { |
489 |
|
|
490 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
491 |
|
$arrondissement = $row['arrondissement']; |
492 |
|
} |
493 |
|
|
494 |
|
return $arrondissement; |
495 |
|
} |
496 |
|
|
497 |
|
/* |
498 |
|
* Récupère l'évènement lié à un type de demande |
499 |
|
*/ |
500 |
|
function getEvenement($demande_type){ |
501 |
|
|
502 |
|
$evenement = NULL; |
503 |
|
|
504 |
|
$sql = |
505 |
|
"SELECT |
506 |
|
evenement |
507 |
|
FROM |
508 |
|
".DB_PREFIXE."demande_type |
509 |
|
WHERE |
510 |
|
demande_type = $demande_type"; |
511 |
|
|
512 |
|
$res = $this->db->query($sql); |
513 |
|
$this->f->addToLog("getEvenement() : db->query(\"".$sql."\")", VERBOSE_MODE); |
514 |
|
if ( database::isError($res)){ |
515 |
|
die(); |
516 |
|
} |
517 |
|
|
518 |
|
if ( $res->numrows() > 0 ){ |
519 |
|
|
520 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
521 |
|
$evenement = $row['evenement']; |
522 |
|
} |
523 |
|
|
524 |
|
return $evenement; |
525 |
|
} |
526 |
|
|
527 |
|
/* |
528 |
|
* Récupère la lettre type lié à un événement |
529 |
|
*/ |
530 |
|
function getLettreType($evenement){ |
531 |
|
|
532 |
|
$lettretype = NULL; |
533 |
|
|
534 |
|
$sql = |
535 |
|
"SELECT |
536 |
|
lettretype |
537 |
|
FROM |
538 |
|
".DB_PREFIXE."evenement |
539 |
|
WHERE |
540 |
|
evenement = $evenement"; |
541 |
|
|
542 |
|
$res = $this->db->query($sql); |
543 |
|
$this->f->addToLog("getLettreType() : db->query(\"".$sql."\")", VERBOSE_MODE); |
544 |
|
if ( database::isError($res)){ |
545 |
|
die(); |
546 |
|
} |
547 |
|
|
548 |
|
if ( $res->numrows() > 0 ){ |
549 |
|
|
550 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
551 |
|
$lettretype = $row['lettretype']; |
552 |
|
} |
553 |
|
|
554 |
|
return $lettretype; |
555 |
|
} |
556 |
|
|
557 |
|
/** |
558 |
|
* Ajout des dossiers |
559 |
|
**/ |
560 |
|
function triggerAjouter($id, &$db, $val, $DEBUG){ |
561 |
|
include '../sql/pgsql/demande.form.inc.php'; |
562 |
|
if($this->valF["demande_type"] != NULL) { |
563 |
|
$res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)); |
564 |
|
$this->f->addToLog("triggerAjouter() : db->query(\"".str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)."\")", VERBOSE_MODE); |
565 |
|
if ( database::isError($res)){ |
566 |
|
die(); |
567 |
|
} |
568 |
|
// Attribut permettant de définir si un dossier a été créé |
569 |
|
$this->ajoutDI = FALSE; |
570 |
|
$dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC); |
571 |
|
// Création du dossier_autorisation |
572 |
|
if($this->valF['dossier_autorisation'] == "") { |
573 |
|
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
574 |
$this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']); |
$this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']); |
575 |
} |
} |
576 |
/* |
// Enregistrement du numéro dossier existant (il sera écrasé si un DI est créé) |
577 |
if($row ['dossier_instruction_type'] != NULL) { |
if ($this->getParameter("idx_dossier") != "") { |
578 |
$valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille']; |
$this->valF['dossier_instruction'] = $this->getParameter("idx_dossier"); |
579 |
|
} |
580 |
$valInstr['depot_initial']=$this->valF['date_demande']; |
// Création du dossier d'instruction |
581 |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
if($dossier_type['dossier_instruction_type'] != NULL) { |
582 |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']); |
583 |
$valInstr['complement']=$this->valF['complement']; |
$this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']); |
584 |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
// Attribut permettant de définir si un dossier a été créé. |
585 |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
$this->ajoutDI = TRUE; |
586 |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
|
587 |
$valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
//Ajout des données techniques au dossier d'instruction |
588 |
$valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
$this->ajoutDonneesTechniques($id, $db, $val, $DEBUG); |
589 |
$valInstr['terrain_superficie']=$this->valF['terrain_superficie']; |
} |
590 |
|
|
591 |
require_once '../obj/dossier.class.php'; |
/*Création du lien de téléchargement de récépissé de demande*/ |
592 |
$dossier_instruction = new dossier("]",$db,$DEBUG); |
if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type']) |
593 |
$dossier_instruction->ajouter($valInstr, $db, $DEBUG); |
&& isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){ |
594 |
$this->valF['dossier_instruction'] = $dossier_instruction->valF['dossier']; |
|
595 |
|
/*Récupérer l'événement lié à ce type de demande*/ |
596 |
|
$evenement = $this->getEvenement($this->valF['demande_type']); |
597 |
|
|
598 |
|
/*Récupération de la lettre type de l'événement*/ |
599 |
|
$lettretype = $this->getLettreType($evenement); |
600 |
|
|
601 |
|
/*Création d'une nouvelle instruction avec cet événement*/ |
602 |
|
/*Données*/ |
603 |
|
$valInstr['instruction']=NULL; |
604 |
|
|
605 |
|
$valInstr['destinataire']=$this->valF['dossier_instruction']; |
606 |
|
$valInstr['dossier']=$this->valF['dossier_instruction']; |
607 |
|
|
608 |
|
$valInstr['date_evenement']=date("d/m/Y"); |
609 |
|
$valInstr['evenement']=$evenement; |
610 |
|
$valInstr['lettretype']=$lettretype; |
611 |
|
$valInstr['complement']=""; |
612 |
|
$valInstr['complement2']=""; |
613 |
|
|
614 |
|
$valInstr['action']="initialisation"; |
615 |
|
$valInstr['delai']="2"; |
616 |
|
$valInstr['etat']="notifier"; |
617 |
|
$valInstr['accord_tacite']="Oui"; |
618 |
|
$valInstr['delai_notification']="1"; |
619 |
|
$valInstr['archive_delai']="0"; |
620 |
|
$valInstr['archive_date_complet']=NULL; |
621 |
|
$valInstr['archive_date_dernier_depot']=NULL; |
622 |
|
$valInstr['archive_date_rejet']=NULL; |
623 |
|
$valInstr['archive_date_limite']=NULL; |
624 |
|
$valInstr['archive_date_notification_delai']=NULL; |
625 |
|
$valInstr['archive_accord_tacite']="Non"; |
626 |
|
$valInstr['archive_etat']="initialiser"; |
627 |
|
$valInstr['archive_date_decision']=NULL; |
628 |
|
$valInstr['archive_avis']=""; |
629 |
|
$valInstr['archive_date_validite']=NULL; |
630 |
|
$valInstr['archive_date_achevement']=NULL; |
631 |
|
$valInstr['archive_date_chantier']=NULL; |
632 |
|
$valInstr['archive_date_conformite']=NULL; |
633 |
|
$valInstr['archive_incompletude']=NULL; |
634 |
|
$valInstr['archive_evenement_suivant_tacite']=""; |
635 |
|
$valInstr['archive_evenement_suivant_tacite_incompletude']=NULL; |
636 |
|
$valInstr['archive_etat_pendant_incompletude']=NULL; |
637 |
|
$valInstr['archive_date_limite_incompletude']=NULL; |
638 |
|
$valInstr['archive_delai_incompletude']=NULL; |
639 |
|
$valInstr['complement3']=""; |
640 |
|
$valInstr['complement4']=""; |
641 |
|
$valInstr['complement5']=""; |
642 |
|
$valInstr['complement6']=""; |
643 |
|
$valInstr['complement7']=""; |
644 |
|
$valInstr['complement8']=""; |
645 |
|
$valInstr['complement9']=""; |
646 |
|
$valInstr['complement10']=""; |
647 |
|
$valInstr['complement11']=""; |
648 |
|
$valInstr['complement12']=""; |
649 |
|
$valInstr['complement13']=""; |
650 |
|
$valInstr['complement14']=""; |
651 |
|
$valInstr['complement15']=""; |
652 |
|
$valInstr['avis_decision']=NULL; |
653 |
|
$valInstr['date_finalisation_courrier']=NULL; |
654 |
|
$valInstr['date_envoi_signature']=NULL; |
655 |
|
$valInstr['date_retour_signature']=NULL; |
656 |
|
$valInstr['date_envoi_rar']=NULL; |
657 |
|
$valInstr['date_retour_rar']=NULL; |
658 |
|
$valInstr['date_envoi_controle_legalite']=NULL; |
659 |
|
$valInstr['date_retour_controle_legalite']=NULL; |
660 |
|
$valInstr['signataire_arrete']=NULL; |
661 |
|
$valInstr['numero_arrete']=NULL; |
662 |
|
$valInstr['code_barres']=NULL; |
663 |
|
|
664 |
|
/*Fichier requis*/ |
665 |
|
require_once '../obj/instruction.class.php'; |
666 |
|
|
667 |
|
/*Création d'un nouveau dossier*/ |
668 |
|
$instruction = new instruction("]",$db,$DEBUG); |
669 |
|
$instruction->valF = ""; |
670 |
|
$instruction->ajouter($valInstr, $db, $DEBUG); |
671 |
|
|
672 |
|
/*Si la création a réussie*/ |
673 |
|
if ( $instruction->valF['instruction'] != "" ){ |
674 |
|
|
675 |
|
/*Affichage du récépissé de la demande*/ |
676 |
|
$this->valF['instruction_recepisse'] = $instruction->valF['instruction']; |
677 |
|
$this -> addToMessage("<br/><a |
678 |
|
class='lien' |
679 |
|
href='../pdf/pdflettretype.php?obj=".$lettretype."&idx=".$instruction->valF['instruction']."' |
680 |
|
target='_blank'> |
681 |
|
<span |
682 |
|
class=\"om-icon om-icon-16 om-icon-fix pdf-16\" |
683 |
|
title=\""._("Telecharger le recepisse de la demande")."\">". |
684 |
|
_("Telecharger le recepisse de la demande"). |
685 |
|
"</span> |
686 |
|
". |
687 |
|
_("Telecharger le recepisse de la demande")." |
688 |
|
</a><br/>"); |
689 |
|
} |
690 |
|
/*Sinon affiche un message d'erreur*/ |
691 |
|
else { |
692 |
|
|
693 |
|
$this -> addToMessage(_("Une erreur s'est produite lors de la creation du recepisse")); |
694 |
|
} |
695 |
|
} |
696 |
|
|
697 |
|
/*Ajout de l'arrondissement à partir du code postal*/ |
698 |
|
if ( !is_null($this->valF["terrain_adresse_code_postal"]) && is_numeric($this->valF["terrain_adresse_code_postal"]) ){ |
699 |
|
|
700 |
|
$this->valF["arrondissement"] = $this->getArrondissement($this->valF["terrain_adresse_code_postal"]); |
701 |
} |
} |
|
*/ |
|
702 |
} |
} |
703 |
} |
} |
704 |
|
|
707 |
**/ |
**/ |
708 |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
709 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
710 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
|
711 |
$this->triggerAjoutDossier($id, $db, $val, $DEBUG); |
// Ajout des lliens entre dossier_autorisation et demandeur |
712 |
|
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) { |
713 |
|
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
714 |
|
} |
715 |
|
// Ajout des lliens entre dossier et demandeur |
716 |
|
if($this->ajoutDI === TRUE) { |
717 |
|
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
718 |
|
} |
719 |
|
|
720 |
|
// Duplication des lots et liaison au nouveau dossier_d'instruction |
721 |
|
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
722 |
|
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
723 |
|
} |
724 |
} |
} |
725 |
|
|
726 |
|
/*Ajout du lien demande / demandeur(s)*/ |
727 |
function triggerModifierApres($id, &$db, $val, $DEBUG){ |
function triggerModifierApres($id, &$db, $val, $DEBUG){ |
728 |
$this->listeDemandeur(); |
$this->listeDemandeur("demande",$this->val[array_search('demande', $this->champs)]); |
729 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
730 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
$this->valIdDemandeur=$this->postedIdDemandeur; |
731 |
|
|
732 |
} |
} |
733 |
|
|
734 |
/** |
/** |
735 |
* Gestion des liens entre la demande et les demendeurs recement ajoutés |
* Gestion des liens entre les lots du DA et le nouveau dossier |
736 |
|
**/ |
737 |
|
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
738 |
|
require_once ("../obj/lot.class.php"); |
739 |
|
$lot = new lot("]", $db, $DEBUG); |
740 |
|
require_once ("../obj/lien_dossier_lot.class.php"); |
741 |
|
$ldl = new lien_dossier_lot("]", $db, $DEBUG); |
742 |
|
require_once ("../obj/lien_lot_demandeur.class.php"); |
743 |
|
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
744 |
|
|
745 |
|
|
746 |
|
$sqlLots = "SELECT * FROM ".DB_PREFIXE."lot |
747 |
|
WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'"; |
748 |
|
$resLot = $db -> query($sqlLots); |
749 |
|
$this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE); |
750 |
|
$this->f->isDatabaseError($resLot); |
751 |
|
while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){ |
752 |
|
// Insertion du nouveau lot |
753 |
|
$valLot['lot'] = ""; |
754 |
|
$valLot['libelle'] = $rowLot['libelle']; |
755 |
|
$valLot['dossier_autorisation'] = NULL; |
756 |
|
$lot -> ajouter($valLot, $db, $DEBUG); |
757 |
|
|
758 |
|
//Insertion du lien entre le lot et le dossier d'instruction |
759 |
|
$valLdl['lien_dossier_lot'] = ""; |
760 |
|
$valLdl['dossier'] = $this->valF['dossier_instruction']; |
761 |
|
$valLdl['lot'] = $lot->valF['lot']; |
762 |
|
$ldl->ajouter($valLdl, $db, $DEBUG); |
763 |
|
|
764 |
|
//Insertion des liens entre dossier et les lots |
765 |
|
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
766 |
|
WHERE lot = ".$rowLot['lot']; |
767 |
|
$res = $db -> query($sqlDemandeurs); |
768 |
|
$this->f->addToLog("lienLotDossierInstruction() : db->query(\"".$sqlDemandeurs."\");", VERBOSE_MODE); |
769 |
|
if ( database::isError($res)){ |
770 |
|
die(); |
771 |
|
} |
772 |
|
|
773 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
774 |
|
$valLld["lien_lot_demandeur"] = ""; |
775 |
|
$valLld["lot"]=$lot->valF['lot']; |
776 |
|
$valLld["demandeur"] = $row['demandeur']; |
777 |
|
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
778 |
|
$lld->ajouter($valLld, $db, $DEBUG); |
779 |
|
} |
780 |
|
} |
781 |
|
} |
782 |
|
|
783 |
|
/** |
784 |
|
* Gestion des liens entre la demande et les demandeurs recemment ajoutés |
785 |
**/ |
**/ |
786 |
function insertLinkDemandeDemandeur($db, $DEBUG) { |
function insertLinkDemandeDemandeur($db, $DEBUG) { |
787 |
// |
// |
788 |
require_once "../obj/lien_demande_demandeur.class.php"; |
require_once "../obj/lien_demande_demandeur.class.php"; |
|
|
|
789 |
// Comparaison de l'id petitionnaire principal |
// Comparaison de l'id petitionnaire principal |
790 |
if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND |
if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND |
791 |
!empty($this->postedIdDemandeur['petitionnaire_principal']) AND |
!empty($this->postedIdDemandeur['petitionnaire_principal']) AND |
857 |
// Execution de la requete de suppression de l'objet |
// Execution de la requete de suppression de l'objet |
858 |
$res = $db->query($sql); |
$res = $db->query($sql); |
859 |
// Logger |
// Logger |
860 |
$this->f->addToLog("supprimer(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("deleteLinkDemandeDemandeur(): db->query(\"".$sql."\");", VERBOSE_MODE); |
861 |
$this->f->isDatabaseError(); |
if ( database::isError($res)){ |
862 |
|
die(); |
863 |
|
} |
864 |
|
|
865 |
} |
} |
866 |
|
|
867 |
|
/* |
868 |
|
* Teste si le lien entre une demande et un demandeur existe |
869 |
|
* */ |
870 |
function isLinkDemandeDemandeurExist($idDemandeur) { |
function isLinkDemandeDemandeurExist($idDemandeur) { |
871 |
$sql = "SELECT count(*) |
$sql = "SELECT count(*) |
872 |
FROM ".DB_PREFIXE."lien_demande_demandeur |
FROM ".DB_PREFIXE."lien_demande_demandeur |
873 |
WHERE demande = ".$this->valF['demande']. |
WHERE demande = ".$this->valF['demande']. |
874 |
"AND demandeur = ".$idDemandeur; |
"AND demandeur = ".$idDemandeur; |
875 |
$count = $this->f->db->getOne($sql); |
$count = $this->f->db->getOne($sql); |
876 |
$this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("isLinkDemandeDemandeurExist() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
877 |
$this->f->isDatabaseError($count); |
if ( database::isError($count)){ |
878 |
|
die(); |
879 |
|
} |
880 |
if ($count === 0) { |
if ($count === 0) { |
881 |
return false; |
return false; |
882 |
} else { |
} else { |
907 |
} |
} |
908 |
} |
} |
909 |
} |
} |
910 |
|
|
911 |
/** |
/** |
912 |
* Méthode permettant de récupérer les id des demandeur lié à la demande |
* Méthode permettant de récupérer les id des demandeurs liés à la table |
913 |
**/ |
* liée passée en paramètre |
914 |
function listeDemandeur() { |
* |
915 |
|
* @param string $from Table liée : "demande", "dossier", dossier_autorisation" |
916 |
|
* @param string $id Identifiant (clé primaire de la table liée en question) |
917 |
|
*/ |
918 |
|
function listeDemandeur($from, $id) { |
919 |
// Récupération des demandeurs de la base |
// Récupération des demandeurs de la base |
920 |
$sql = "SELECT demandeur.demandeur, |
$sql = "SELECT demandeur.demandeur, |
921 |
demandeur.type_demandeur, |
demandeur.type_demandeur, |
922 |
lien_demande_demandeur.petitionnaire_principal |
lien_".$from."_demandeur.petitionnaire_principal |
923 |
FROM ".DB_PREFIXE."lien_demande_demandeur |
FROM ".DB_PREFIXE."lien_".$from."_demandeur |
924 |
INNER JOIN ".DB_PREFIXE."demandeur |
INNER JOIN ".DB_PREFIXE."demandeur |
925 |
ON demandeur.demandeur=lien_demande_demandeur.demandeur |
ON demandeur.demandeur=lien_".$from."_demandeur.demandeur |
926 |
WHERE demande = ".$this->val[array_search('demande', $this->champs)]; |
WHERE ".$from." = '".$id."'"; |
927 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
928 |
$this->f->addToLog("listeDemandeur() : ".$sql); |
$this->f->addToLog("listeDemandeur(): db->query(\"".$sql."\")", VERBOSE_MODE); |
929 |
$this->f->isDatabaseError($res); |
if ( database::isError($res)){ |
930 |
// Stoquage du résultat dans un tableau |
die(); |
931 |
|
} |
932 |
|
// Stockage du résultat dans un tableau |
933 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
934 |
if ($row['petitionnaire_principal'] == 't' AND |
if ($row['petitionnaire_principal'] == 't' AND |
935 |
$row['type_demandeur']=="petitionnaire") { |
$row['type_demandeur']=="petitionnaire") { |
943 |
} |
} |
944 |
} |
} |
945 |
|
|
946 |
|
|
947 |
|
/** |
948 |
|
* Surcharge du bouton retour afin de retourner sur la recherche de dossiers |
949 |
|
* d'instruction existant |
950 |
|
*/ |
951 |
|
function retour($premier = 0, $recherche = "", $tricol = "") { |
952 |
|
|
953 |
|
echo "\n<a class=\"retour\" "; |
954 |
|
echo "href=\""; |
955 |
|
// |
956 |
|
if($this->getParameter("idx_dossier") != "") { |
957 |
|
echo "tab.php?"; |
958 |
|
echo "obj=recherche_dossier"; |
959 |
|
|
960 |
|
} else { |
961 |
|
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
962 |
|
echo "form.php?"; |
963 |
|
} else { |
964 |
|
echo "tab.php?"; |
965 |
|
} |
966 |
|
echo "obj=".get_class($this); |
967 |
|
if($this->getParameter("retour")=="form") { |
968 |
|
echo "&idx=".$this->getParameter("idx"); |
969 |
|
echo "&action=3"; |
970 |
|
} |
971 |
|
} |
972 |
|
echo "&premier=".$this->getParameter("premier"); |
973 |
|
echo "&tricol=".$this->getParameter("tricol"); |
974 |
|
echo "&recherche=".$this->getParameter("recherche"); |
975 |
|
echo "&selectioncol=".$this->getParameter("selectioncol"); |
976 |
|
echo "&advs_id=".$this->getParameter("advs_id"); |
977 |
|
echo "&valide=".$this->getParameter("valide"); |
978 |
|
// |
979 |
|
echo "\""; |
980 |
|
echo ">"; |
981 |
|
// |
982 |
|
echo _("Retour"); |
983 |
|
// |
984 |
|
echo "</a>\n"; |
985 |
|
|
986 |
|
} |
987 |
|
|
988 |
|
|
989 |
/** |
/** |
990 |
* Ajout de la liste des demandeurs |
* Cette méthode permet d'afficher des informations spécifiques dans le |
991 |
|
* formulaire de l'objet |
992 |
|
* |
993 |
|
* @param integer $maj Mode de mise à jour |
994 |
*/ |
*/ |
995 |
function formSpecificContent($maj) { |
function formSpecificContent($maj) { |
996 |
if(!$this->correct AND $maj != 0) { |
|
997 |
$this->listeDemandeur(); |
/** |
998 |
|
* Gestion du bloc des demandeurs |
999 |
|
*/ |
1000 |
|
// Si le mode est (modification ou suppression ou consultation) ET que |
1001 |
|
// le formulaire n'est pas correct (c'est-à-dire que le formulaire est |
1002 |
|
// actif) |
1003 |
|
if (!$this->correct AND $maj != 0) { |
1004 |
|
// Alors on récupère les demandeurs dans la table lien pour |
1005 |
|
// affectation des résultats dans this->valIdDemandeur |
1006 |
|
$this->listeDemandeur("demande", $this->val[array_search('demande', $this->champs)]); |
1007 |
} |
} |
1008 |
if($maj < 2 AND !$this->correct) { |
|
1009 |
|
// Si le mode est (ajout ou modification) ET que le formulaire n'est pas |
1010 |
|
// correct (c'est-à-dire que le formulaire est actif) |
1011 |
|
if ($maj < 2 AND !$this->correct) { |
1012 |
|
// Alors on positionne le marqueur linkable a true qui permet |
1013 |
|
// d'afficher ou non les actions de gestion des demandeurs |
1014 |
$linkable = true; |
$linkable = true; |
1015 |
} else { |
} else { |
1016 |
|
// Sinon on positionne le marqueur linkable a false qui permet |
1017 |
|
// d'afficher ou non les actions de gestion des demandeurs |
1018 |
$linkable = false; |
$linkable = false; |
1019 |
} |
} |
1020 |
|
|
1021 |
|
// Affichage des demandeurs et des actions |
1022 |
// Conteneur de la listes des demandeurs |
// Conteneur de la listes des demandeurs |
1023 |
echo "<div class=\"demande_hidden_bloc col_12\">"; |
echo "<div id=\"liste_demandeur\" class=\"demande_hidden_bloc col_12\">"; |
1024 |
echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">"; |
echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">"; |
1025 |
echo " <legend class=\"ui-corner-all ui-widget-content ui-state-active\">" |
echo " <legend class=\"ui-corner-all ui-widget-content ui-state-active\">" |
1026 |
._("Petitionnaire")."</legend>"; |
._("Petitionnaire")."</legend>"; |
1027 |
// Si des demandeurs sont liés à la demande |
// Si des demandeurs sont liés à la demande |
1028 |
require_once "../obj/petitionnaire.class.php"; |
require_once "../obj/petitionnaire.class.php"; |
1029 |
require_once "../obj/delegataire.class.php"; |
require_once "../obj/delegataire.class.php"; |
1030 |
|
// Affichage du bloc pétitionnaire principal / délégataire |
1031 |
// Affichage du bloc pétitionnaire principal / délégataire |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1032 |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
echo "<div id=\"petitionnaire_principal_delegataire\">"; |
1033 |
echo "<div id=\"petitionnaire_principal_delegataire\">"; |
// Affichage de la synthèse |
1034 |
// Affichage de la synthèse |
if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND |
1035 |
if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND |
!empty($this->valIdDemandeur["petitionnaire_principal"])) { |
1036 |
!empty($this->valIdDemandeur["petitionnaire_principal"])) { |
$demandeur = new petitionnaire( |
1037 |
$demandeur = new petitionnaire( |
$this->valIdDemandeur["petitionnaire_principal"], |
1038 |
$this->valIdDemandeur["petitionnaire_principal"], |
$this->f->db,false); |
1039 |
$this->f->db,false); |
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
1040 |
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
$demandeur -> __destruct(); |
1041 |
$demandeur -> __destruct(); |
} elseif ( isset ($this->postedIdDemandeur["petitionnaire_principal"]) AND |
1042 |
} |
!empty($this->postedIdDemandeur["petitionnaire_principal"]) ) { |
1043 |
// Si en édition de formulaire |
$demandeur = new petitionnaire( |
1044 |
if($maj < 2 AND $this->correct != true) { |
$this->postedIdDemandeur["petitionnaire_principal"], |
1045 |
// Bouton d'ajout du pétitionnaire principal |
$this->f->db,false); |
1046 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
1047 |
echo "<input id=\"add_petitionnaire_principal\" |
$demandeur -> __destruct(); |
1048 |
class=\"ui-button ui-widget ui-state-default ui-corner-all\" |
} |
1049 |
type=\"button\" value=\""._("Saisir le petitionnaire principal")."\"/>"; |
// Si en édition de formulaire |
1050 |
echo " <span class=\"om-icon om-icon-16 om-icon-fix arrow-right-16\">></span> "; |
if($maj < 2) { |
1051 |
// Bouton d'ajout du delegataire |
// Bouton d'ajout du pétitionnaire principal |
1052 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1053 |
echo "<input id=\"add_delegataire\" |
echo "<span id=\"add_petitionnaire_principal\" |
1054 |
class=\"ui-button ui-widget ui-state-default ui-corner-all\" |
class=\"om-form-button add-16\">". |
1055 |
type=\"button\" value=\""._("Saisir le delegataire")."\"/>"; |
_("Saisir le petitionnaire principal"). |
1056 |
} |
"</span>"; |
1057 |
// Affichage de la synthèse |
} |
1058 |
if (isset ($this->valIdDemandeur["delegataire"]) AND |
// Bouton d'ajout du delegataire |
1059 |
!empty($this->valIdDemandeur["delegataire"])) { |
// L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1060 |
$demandeur = new delegataire($this->valIdDemandeur["delegataire"], |
echo "<div id=\"delegataire\">"; |
1061 |
$this->f->db,false); |
// Affichage de la synthèse |
1062 |
$demandeur -> afficherSynthese("delegataire", $linkable); |
if (isset ($this->valIdDemandeur["delegataire"]) AND |
1063 |
|
!empty($this->valIdDemandeur["delegataire"])) { |
1064 |
|
$demandeur = new delegataire($this->valIdDemandeur["delegataire"], |
1065 |
|
$this->f->db,false); |
1066 |
|
$demandeur -> afficherSynthese("delegataire", $linkable); |
1067 |
|
$demandeur -> __destruct(); |
1068 |
|
} elseif ( isset ($this->postedIdDemandeur["delegataire"]) AND |
1069 |
|
!empty($this->postedIdDemandeur["delegataire"]) ) { |
1070 |
|
|
1071 |
|
$demandeur = new delegataire($this->postedIdDemandeur["delegataire"], |
1072 |
|
$this->f->db,false); |
1073 |
|
$demandeur -> afficherSynthese("delegataire", $linkable); |
1074 |
|
$demandeur -> __destruct(); |
1075 |
|
} |
1076 |
|
if($maj < 2) { |
1077 |
|
echo "<span id=\"add_delegataire\" |
1078 |
|
class=\"om-form-button add-16\">". |
1079 |
|
_("Saisir le delegataire"). |
1080 |
|
"</span>"; |
1081 |
|
} |
1082 |
|
echo "</div>"; |
1083 |
|
echo "<div class=\"both\"></div>"; |
1084 |
|
echo "</div>"; |
1085 |
|
// Bloc des pétitionnaires secondaires |
1086 |
|
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1087 |
|
echo "<div id=\"listePetitionnaires\">"; |
1088 |
|
|
1089 |
|
// Affichage de la synthèse |
1090 |
|
if (isset ($this->valIdDemandeur["petitionnaire"]) AND |
1091 |
|
!empty($this->valIdDemandeur["petitionnaire"])) { |
1092 |
|
|
1093 |
|
foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) { |
1094 |
|
$demandeur = new petitionnaire($petitionnaire, |
1095 |
|
$this->f->db,false); |
1096 |
|
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
1097 |
$demandeur -> __destruct(); |
$demandeur -> __destruct(); |
1098 |
} |
} |
1099 |
|
|
1100 |
echo "</div>"; |
} elseif ( isset ($this->postedIdDemandeur["petitionnaire"]) AND |
1101 |
|
!empty($this->postedIdDemandeur["petitionnaire"]) ) { |
1102 |
// Bloc des pétitionnaires secondaires |
foreach ($this->postedIdDemandeur["petitionnaire"] as $petitionnaire) { |
1103 |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
$demandeur = new petitionnaire($petitionnaire, |
1104 |
echo "<div id=\"listePetitionnaires\">"; |
$this->f->db,false); |
1105 |
|
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
1106 |
// Affichage de la synthèse |
$demandeur -> __destruct(); |
|
if (isset ($this->valIdDemandeur["petitionnaire"]) AND |
|
|
!empty($this->valIdDemandeur["petitionnaire"])) { |
|
|
|
|
|
foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) { |
|
|
$demandeur = new petitionnaire($petitionnaire, |
|
|
$this->f->db,false); |
|
|
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
|
|
$demandeur -> __destruct(); |
|
|
} |
|
|
|
|
|
} |
|
|
if ($maj < 2 AND !$this->correct) { |
|
|
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
|
|
echo "<input id=\"add_petitionnaire\" |
|
|
class=\"ui-button ui-widget ui-state-default ui-corner-all\" |
|
|
type=\"button\" value=\""._("Ajouter un petitionnaire")."\"/>"; |
|
1107 |
} |
} |
1108 |
echo "</div>"; |
} |
1109 |
|
if ($maj < 2) { |
1110 |
|
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1111 |
|
echo "<span id=\"add_petitionnaire\" |
1112 |
|
class=\"om-form-button add-16\">". |
1113 |
|
_("Ajouter un petitionnaire") |
1114 |
|
."</span>"; |
1115 |
|
} |
1116 |
|
echo "</div>"; |
1117 |
echo "</fieldset>"; |
echo "</fieldset>"; |
1118 |
echo "</div>"; |
echo "</div>"; |
1119 |
} |
} |
1120 |
|
|
1121 |
|
// {{{ |
1122 |
|
|
1123 |
|
// getter |
1124 |
|
function getValIdDemandeur() { |
1125 |
|
return $this->valIdDemandeur; |
1126 |
|
} |
1127 |
|
// setter |
1128 |
|
function setValIdDemandeur($valIdDemandeur) { |
1129 |
|
$this->valIdDemandeur = $valIdDemandeur; |
1130 |
|
} |
1131 |
|
|
1132 |
|
//Supression du lien entre la demandeur et le(s) demandeur(s) |
1133 |
|
function triggerSupprimer($id, &$db, $val, $DEBUG){ |
1134 |
|
|
1135 |
|
//Création de la requête |
1136 |
|
$sql = "DELETE FROM |
1137 |
|
".DB_PREFIXE."lien_demande_demandeur |
1138 |
|
WHERE |
1139 |
|
demande = $id"; |
1140 |
|
|
1141 |
|
$res = $this->f->db->query($sql); |
1142 |
|
$this->f->addToLog("triggerSupprimer() : db->query(\"".$sql."\")"); |
1143 |
|
if ( database::isError($res)){ |
1144 |
|
die(); |
1145 |
|
} |
1146 |
|
} |
1147 |
|
|
1148 |
|
// }}} |
1149 |
}// fin classe |
}// fin classe |
|
?> |
|
1150 |
|
?> |