75 |
*/ |
*/ |
76 |
function verifier($val, &$db, $DEBUG) { |
function verifier($val, &$db, $DEBUG) { |
77 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val, $db, $DEBUG); |
78 |
|
|
79 |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
80 |
empty($this->postedIdDemandeur["petitionnaire_principal"])) { |
empty($this->postedIdDemandeur["petitionnaire_principal"]) AND |
81 |
|
!is_null($this->form)) { |
82 |
$this->correct = false; |
$this->correct = false; |
83 |
$this->addToMessage(_("La saisie d'un petitionnaire principal est obligatoire.")); |
$this->addToMessage(_("La saisie d'un petitionnaire principal est obligatoire.")); |
84 |
} |
} |
88 |
* Configuration des select |
* Configuration des select |
89 |
*/ |
*/ |
90 |
function setSelect(&$form, $maj,&$db,$debug) { |
function setSelect(&$form, $maj,&$db,$debug) { |
|
parent::setSelect($form, $maj,$db,$debug); |
|
91 |
|
|
92 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
93 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
94 |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
95 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
96 |
|
|
97 |
|
// |
98 |
|
$form->setSelect('demande_type', $this->loadSelectDemandeType($form, $maj, $db, $debug, "dossier_autorisation_type_detaille")); |
99 |
|
|
100 |
//Récupération de paramètre pour le rechargement ajax du select |
// arrondissement |
101 |
$idx_dossier = $this->getParameter("idx_dossier"); |
$this->init_select($form, $db, $maj, $debug, "arrondissement", |
102 |
$datd = $this->getParameter("datd"); |
$sql_arrondissement, $sql_arrondissement_by_id, false); |
103 |
|
|
104 |
|
// dossier_autorisation_type_detaille |
105 |
|
$this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille", |
106 |
|
$sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false); |
107 |
|
|
108 |
$contenu = array(); |
} |
109 |
|
|
110 |
$sql_demande_type = "SELECT demande_type.demande_type, demande_type.libelle FROM ".DB_PREFIXE."demande_type |
/** |
111 |
LEFT OUTER JOIN ".DB_PREFIXE."lien_demande_type_etat_dossier_autorisation |
* Charge le select du champ type de demande |
112 |
ON lien_demande_type_etat_dossier_autorisation.demande_type=demande_type.demande_type |
* @param object $form Formulaire |
113 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation |
* @param int $maj Mode d'insertion |
114 |
ON lien_demande_type_etat_dossier_autorisation.etat_dossier_autorisation= |
* @param object $db Database |
115 |
dossier_autorisation.etat_dossier_autorisation |
* @param bool $debug Debug active ou pas |
116 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier |
* @param string $champ champ activant le filtre |
117 |
ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation"; |
* @return array Contenu du select |
118 |
|
*/ |
119 |
// Ajout de filtre sur la requête (initial) |
function loadSelectDemandeType(&$form, $maj, &$db, $debug, $champ) { |
|
if(isset($idx_dossier) AND $idx_dossier != "") { |
|
|
$sql_demande_type .= " WHERE demande_type.demande_nature = 2 "; |
|
120 |
|
|
121 |
// ajout du numéro de dossier existant pour tester l'état du DA |
// |
122 |
$sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' "; |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
123 |
} else { |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
124 |
$sql_demande_type .= " WHERE demande_type.demande_nature = 1 "; |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
125 |
} |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
|
if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") { |
|
|
$datd = $_POST["dossier_autorisation_type_detaille"]; |
|
|
} |
|
|
// Ajout de filtre sur la requête (dossier_autorisation_type_detaille) |
|
|
if(isset($datd) AND $datd != "") { |
|
|
$sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd; |
|
|
} else { |
|
|
$datd = $this->getVal("dossier_autorisation_type_detaille"); |
|
|
if ($datd != "") { |
|
|
$sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd; |
|
|
} |
|
|
} |
|
|
$sql_demande_type .= " ORDER BY demande_type.libelle"; |
|
|
$res = $db->query($sql_demande_type); |
|
126 |
|
|
127 |
// logger |
// Contenu de la liste à choix |
128 |
$this->f->addToLog("setSelect(): db->query(\"".$sql_demande_type."\");", |
$contenu=array(); |
129 |
VERBOSE_MODE); |
$contenu[0][0]=''; |
130 |
if ( database::isError($res)){ |
$contenu[1][0]=_('choisir')." "._("demande_type"); |
131 |
die(); |
|
132 |
|
//Récupère l'id du type de dossier d'autorisation détaillé |
133 |
|
$id_dossier_autorisation_type_detaille = ""; |
134 |
|
if (isset($_POST[$champ])) { |
135 |
|
$id_dossier_autorisation_type_detaille = $_POST[$champ]; |
136 |
|
} elseif($this->getParameter($champ) != "") { |
137 |
|
$id_dossier_autorisation_type_detaille = $this->getParameter($champ); |
138 |
|
} elseif(isset($form->val[$champ])) { |
139 |
|
$id_dossier_autorisation_type_detaille = $form->val[$champ]; |
140 |
} |
} |
141 |
|
|
142 |
$contenu[0][0] = ''; |
// Récupération de paramètre pour le rechargement ajax du select |
143 |
$contenu[1][0] = _('choisir')." "._("demande_type"); |
$idx_dossier = $this->getParameter("idx_dossier"); |
144 |
|
|
145 |
$k=1; |
// Récupère l'id de la nature de la demande |
146 |
while($row =& $res->fetchRow()){ |
$id_demande_nature = "1"; |
147 |
|
if (isset($idx_dossier) AND $idx_dossier != "") { |
148 |
|
$id_demande_nature = '2'; |
149 |
|
} |
150 |
|
|
151 |
$contenu[0][$k] = $row[0]; |
// Ajout de condition pour la requête |
152 |
$contenu[1][$k] = $row[1]; |
$ajout_condition_requête = ""; |
153 |
$k++; |
if ($id_demande_nature == '2') { |
154 |
|
$ajout_condition_requête = " AND dossier.dossier = '".$idx_dossier."'"; |
155 |
} |
} |
156 |
|
|
157 |
$form->setSelect("demande_type", $contenu); |
// |
158 |
|
if ($id_dossier_autorisation_type_detaille != "") { |
159 |
|
//Si l'id du type de dossier d'autorisation détaillé est renseigné |
160 |
|
$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); |
161 |
|
// Ajoute une condition sur la nature de la demande |
162 |
|
$sql_demande_type_by_dossier_autorisation_type_detaille = str_replace('<idx_demande_nature>', $id_demande_nature, $sql_demande_type_by_dossier_autorisation_type_detaille); |
163 |
|
// Permet d'ajouter une condition |
164 |
|
$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); |
165 |
|
$res = $this->db->query($sql_demande_type_by_dossier_autorisation_type_detaille); |
166 |
|
$this->addToLog("db->query(\"".$sql_demande_type_by_dossier_autorisation_type_detaille."\");", VERBOSE_MODE); |
167 |
|
$this->f->isDatabaseError($res); |
168 |
|
//Les résultats de la requête sont stocké dans le tableau contenu |
169 |
|
$k=1; |
170 |
|
while ($row=& $res->fetchRow()){ |
171 |
|
$contenu[0][$k]=$row[0]; |
172 |
|
$contenu[1][$k]=$row[1]; |
173 |
|
$k++; |
174 |
|
} |
175 |
|
} |
176 |
|
|
177 |
|
// Retourne le contenu de la liste |
178 |
|
return $contenu; |
179 |
} |
} |
180 |
|
|
181 |
/* |
/* |
182 |
* Ajout du fielset |
* Ajout du fielset |
183 |
* Add fieldset |
* Add fieldset |
219 |
*/ |
*/ |
220 |
function setOnchange(&$form,$maj){ |
function setOnchange(&$form,$maj){ |
221 |
parent::setOnchange($form,$maj); |
parent::setOnchange($form,$maj); |
222 |
|
|
223 |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
224 |
$form->setOnchange("demande_type","showFormsDemande();"); |
$form->setOnchange("demande_type","showFormsDemande();"); |
225 |
} |
} |
228 |
parent::setLib($form,$maj); |
parent::setLib($form,$maj); |
229 |
//libelle des champs |
//libelle des champs |
230 |
|
|
231 |
$form->setLib('complement',_('terrain_adresse')); |
$form->setLib('terrain_adresse_voie',_('terrain_adresse')); |
232 |
} |
} |
233 |
/* |
/* |
234 |
* Cache le champ terrain_references_cadastrales |
* Cache le champ terrain_references_cadastrales |
249 |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
250 |
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
251 |
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
252 |
$form->setType('complement', 'hiddenstatic'); |
$form->setType('terrain_adresse_voie', 'hiddenstatic'); |
253 |
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
254 |
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
255 |
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
273 |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
274 |
require_once '../obj/dossier_autorisation.class.php'; |
require_once '../obj/dossier_autorisation.class.php'; |
275 |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
276 |
$id_etat_initial_da = $this->f->getParameter('etat_initial_dossier_autorisation'); |
$id_etat_initial_da = $this->f->getParameter('id_etat_initial_dossier_autorisation'); |
277 |
$error = false; |
$error = false; |
278 |
|
|
279 |
// Vérification de l'existance d'un état initial des DA dans la table om_parametre |
// Vérification de l'existance d'un état initial des DA dans la table om_parametre |
300 |
$valAuto['exercice']=NULL; |
$valAuto['exercice']=NULL; |
301 |
$valAuto['insee']=NULL; |
$valAuto['insee']=NULL; |
302 |
$valAuto['arrondissement']=NULL; |
$valAuto['arrondissement']=NULL; |
303 |
$valAuto['etat_dossier_autorisation']=$this->f->getParameter('etat_initial_dossier_autorisation'); |
$valAuto['etat_dossier_autorisation']=$this->f->getParameter('id_etat_initial_dossier_autorisation'); |
304 |
$valAuto['erp_numero_batiment']=NULL; |
$valAuto['erp_numero_batiment']=NULL; |
305 |
$valAuto['erp_ouvert']=NULL; |
$valAuto['erp_ouvert']=NULL; |
306 |
$valAuto['erp_arrete_decision']=NULL; |
$valAuto['erp_arrete_decision']=NULL; |
308 |
$valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
$valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
309 |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
310 |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
311 |
$valAuto['complement']=$this->valF['complement']; |
$valAuto['terrain_adresse_voie']=$this->valF['terrain_adresse_voie']; |
312 |
$valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
$valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
313 |
$valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
$valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
314 |
$valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
$valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
335 |
|
|
336 |
} |
} |
337 |
|
|
|
function getCodeDemandeType($demande_type){ |
|
|
|
|
|
$sql = "SELECT |
|
|
code |
|
|
FROM |
|
|
".DB_PREFIXE."demande_type |
|
|
WHERE |
|
|
demande_type = ".$demande_type; |
|
|
$codeDemandeType = $this->db->getOne($sql); |
|
|
$this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
|
|
|
return $codeDemandeType; |
|
|
} |
|
|
|
|
338 |
/** |
/** |
339 |
* Méthode permettant d'ajouter un dossier d'instruction |
* Méthode permettant d'ajouter un dossier d'instruction |
340 |
*/ |
*/ |
361 |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
362 |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
363 |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
364 |
$valInstr['complement']=$this->valF['complement']; |
$valInstr['terrain_adresse_voie']=$this->valF['terrain_adresse_voie']; |
365 |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
366 |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
367 |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
374 |
/* |
/* |
375 |
* Gestion de la qualification |
* Gestion de la qualification |
376 |
* */ |
* */ |
377 |
//Récupérer le code du type de la demande |
// Initialise le champ à false |
378 |
$codeDemandeType = $this->getCodeDemandeType($val['demande_type']); |
$valInstr['a_qualifier'] = false; |
379 |
|
|
380 |
//Marque le dossier comme à qualifier selon le type de dossier d'instruction |
// Récupère l'information depuis le type de la demande |
381 |
if ( strcasecmp($codeDemandeType, "DI") == 0 || |
$qualification = $this->get_qualification($val['demande_type']); |
382 |
strcasecmp($codeDemandeType, "DT") == 0 || |
|
383 |
strcasecmp($codeDemandeType, "DM") == 0 || |
// Si le dossier doit être à qualifier |
384 |
strcasecmp($codeDemandeType, "DP") == 0 || |
if ($qualification === 't') { |
385 |
strcasecmp($codeDemandeType, "DTP") == 0 || |
// Met le champ à true |
386 |
strcasecmp($codeDemandeType, "DAACT") == 0 || |
$valInstr['a_qualifier'] = true; |
|
strcasecmp($codeDemandeType, "DOC") == 0 ){ |
|
|
|
|
|
$valInstr['a_qualifier'] = TRUE; |
|
387 |
} |
} |
388 |
|
|
389 |
// Récupération du cerfa pour le type d'instruction sélectionnée et valide |
// Récupération du cerfa pour le type d'instruction sélectionnée et valide |
390 |
$sql = "SELECT |
$sql = "SELECT |
391 |
dossier_instruction_type.cerfa |
dossier_autorisation_type_detaille.cerfa |
392 |
FROM |
FROM |
393 |
".DB_PREFIXE."dossier_instruction_type |
".DB_PREFIXE."dossier_autorisation_type_detaille |
394 |
JOIN |
JOIN |
395 |
".DB_PREFIXE."cerfa |
".DB_PREFIXE."cerfa |
396 |
ON |
ON |
397 |
dossier_instruction_type.cerfa = cerfa.cerfa |
dossier_autorisation_type_detaille.cerfa = cerfa.cerfa |
398 |
WHERE |
WHERE |
399 |
now()<=om_validite_fin |
now()<=om_validite_fin |
400 |
AND now()>=om_validite_debut |
AND now()>=om_validite_debut |
401 |
AND dossier_instruction_type=".$dossier_instruction_type; |
AND dossier_autorisation_type_detaille=".$this->valF['dossier_autorisation_type_detaille']; |
402 |
$valInstr['cerfa'] = $db->getOne($sql); |
$valInstr['cerfa'] = $db->getOne($sql); |
403 |
$this->f->addToLog("ajoutDossierInstruction() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("ajoutDossierInstruction() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
404 |
if ( database::isError($valInstr['cerfa'])){ |
if ( database::isError($valInstr['cerfa'])){ |
405 |
die(); |
die(); |
406 |
} |
} |
407 |
$dossier->ajouter($valInstr, $db, $DEBUG); |
$dossier->ajouter($valInstr, $db, $DEBUG); |
408 |
|
|
409 |
|
//Affichage de message à l'utilisateur concernant un problème lors de |
410 |
|
//l'affectation de l'instructeur au dossier d'instruction |
411 |
|
if ($dossier->valF['dossier_autorisation'] === '' && |
412 |
|
$dossier->valF['instructeur'] === NULL){ |
413 |
|
$this->addToMessage(_("Aucun instructeur compatible avec ce dossier, contactez votre administrateur afin d'en assigner un a ce dossier.")); |
414 |
|
} |
415 |
|
elseif ( $dossier->valF['instructeur'] === NULL ){ |
416 |
|
if ($this->f->isAccredited("dossier_modifier_instructeur")) { |
417 |
|
$this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")); |
418 |
|
} else { |
419 |
|
$this->addToMessage(_("Aucun instructeur compatible avec ce dossier, contactez votre administrateur afin d'en assigner un a ce dossier.")); |
420 |
|
} |
421 |
|
} |
422 |
|
|
423 |
// Liaison du dossier ajouter à la demande |
// Liaison du dossier ajouter à la demande |
424 |
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
425 |
} |
} |
426 |
|
|
427 |
/** |
/** |
428 |
* Méthode permettant d'ajouter les données techniques au dossier d'instruction |
* Méthode permettant d'ajouter les données techniques au dossier d'autorisation |
429 |
*/ |
*/ |
430 |
function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){ |
function ajoutDonneesTechniquesDA($id, &$db, $val, $DEBUG){ |
431 |
|
|
432 |
require_once '../obj/donnees_techniques.class.php'; |
require_once '../obj/donnees_techniques.class.php'; |
433 |
$donnees_techniques = new donnees_techniques("]",$db,$DEBUG); |
$donnees_techniques = new donnees_techniques("]",$db,$DEBUG); |
434 |
|
|
435 |
// Champs tous à NULL car seul le champ concernant le dossier d'instruction sera rempli |
// Champs tous à NULL car seul le champ concernant le dossier d'autorisation sera rempli |
436 |
foreach($donnees_techniques->champs as $value) { |
foreach($donnees_techniques->champs as $value) { |
437 |
$val[$value] = NULL; |
$val[$value] = NULL; |
438 |
} |
} |
439 |
|
|
440 |
// Ajout du numéro de dossier d'instruction |
// Ajout du numéro de dossier d'instruction |
441 |
$val['dossier_instruction']=$this->valF['dossier_instruction']; |
$val['dossier_autorisation']=$this->valF['dossier_autorisation']; |
442 |
|
|
443 |
// Ajout des données techniques |
// Ajout des données techniques |
444 |
$donnees_techniques->ajouter($val, $db, $DEBUG); |
$donnees_techniques->ajouter($val, $db, $DEBUG); |
445 |
} |
} |
446 |
|
|
447 |
/** |
/** |
448 |
* Ajout des liens demandeurs / dossier d'autorisation |
* Méthode permettant d'ajouter les données techniques au dossier d'autorisation |
449 |
|
*/ |
450 |
|
function ajoutDonneesTechniquesDI($id, &$db, $val, $DEBUG){ |
451 |
|
|
452 |
|
// Requête permettant de récupérer le dernier enregistrement en base des données techniques |
453 |
|
// liées au dossier d'autorisationdu dossier d'instruction en cours de création |
454 |
|
$sql_dt_from_da = "SELECT donnees_techniques |
455 |
|
FROM ".DB_PREFIXE."donnees_techniques |
456 |
|
WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."' |
457 |
|
ORDER BY donnees_techniques DESC"; |
458 |
|
// Récupération de l'id |
459 |
|
$id_da = $this->db->getOne($sql_dt_from_da); |
460 |
|
if ( database::isError($id_da)){ |
461 |
|
// affiche l'erreur pour l'utilisateur et dans le log |
462 |
|
$this->addToErrors("", |
463 |
|
_("Erreur lors de la recuperation des donnees techniques en cours de validite"), |
464 |
|
_("Erreur lors de la recuperation des donnees techniques en cours de validite")); |
465 |
|
return false; |
466 |
|
} |
467 |
|
require_once '../obj/donnees_techniques.class.php'; |
468 |
|
$donnees_techniques = new donnees_techniques($id_da,$db,$DEBUG); |
469 |
|
|
470 |
|
// Récupération des données du DA |
471 |
|
foreach($donnees_techniques->champs as $value) { |
472 |
|
$val[$value] = $donnees_techniques->getVal($value); |
473 |
|
} |
474 |
|
|
475 |
|
// Ajout du numéro de dossier d'instruction |
476 |
|
$val['dossier_instruction'] = $this->valF['dossier_instruction']; |
477 |
|
// Suppression du numéro de dossier d'autorisation |
478 |
|
$val['dossier_autorisation'] = NULL; |
479 |
|
|
480 |
|
// Ajout des données techniques |
481 |
|
$donnees_techniques->ajouter($val, $db, $DEBUG); |
482 |
|
} |
483 |
|
|
484 |
|
/** |
485 |
|
* Ajout des liens demandeurs / dossier d'autorisation s'ils n'y sont pas déjà |
486 |
**/ |
**/ |
487 |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
488 |
// Création des liens entre le dossier autorisation et les demandeurs |
// Création des liens entre le dossier autorisation et les demandeurs |
490 |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
491 |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
492 |
// Recupération des demandeurs liés à la demande |
// Recupération des demandeurs liés à la demande |
493 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur. |
494 |
|
" AND lien_demande_demandeur.demandeur NOT IN ( |
495 |
|
SELECT lien_dossier_autorisation_demandeur.demandeur |
496 |
|
FROM ".DB_PREFIXE."lien_dossier_autorisation_demandeur |
497 |
|
WHERE lien_dossier_autorisation_demandeur.dossier_autorisation = |
498 |
|
'".$this->valF['dossier_autorisation']."' |
499 |
|
)"); |
500 |
$res = $db->query($sql); |
$res = $db->query($sql); |
501 |
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
502 |
if ( database::isError($res)){ |
if ( database::isError($res)){ |
591 |
return $evenement; |
return $evenement; |
592 |
} |
} |
593 |
|
|
594 |
/* |
|
595 |
* Récupère la lettre type lié à un événement |
|
596 |
|
/** |
597 |
|
* Retourne le libellé du dossier d'autorisation |
598 |
|
* @param string $dossier_autorisation Identifiant du dossier d'autorisation |
599 |
|
* @return string Libellé dossier d'autorisation |
600 |
*/ |
*/ |
601 |
function getLettreType($evenement){ |
function get_dossier_autorisation_libelle($dossier_autorisation) { |
602 |
|
|
603 |
$lettretype = NULL; |
$dossier_autorisation_libelle = ""; |
604 |
|
|
605 |
$sql = |
// Requête SQL |
606 |
"SELECT |
$sql = "SELECT |
607 |
lettretype |
dossier_autorisation_libelle |
608 |
FROM |
FROM |
609 |
".DB_PREFIXE."evenement |
".DB_PREFIXE."dossier_autorisation |
610 |
WHERE |
WHERE |
611 |
evenement = $evenement"; |
dossier_autorisation = '$dossier_autorisation'"; |
612 |
|
|
613 |
$res = $this->db->query($sql); |
$dossier_autorisation_libelle = $this->db->getOne($sql); |
614 |
$this->f->addToLog("getLettreType() : db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("get_dossier_autorisation_libelle(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
615 |
if ( database::isError($res)){ |
database::isError($dossier_autorisation_libelle); |
|
die(); |
|
|
} |
|
616 |
|
|
617 |
if ( $res->numrows() > 0 ){ |
// Retourne le résultat |
618 |
|
return $dossier_autorisation_libelle; |
619 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
} |
620 |
$lettretype = $row['lettretype']; |
|
621 |
} |
/** |
622 |
|
* Retourne le libellé du dossier d'autorisation |
623 |
|
* @param string $dossier_autorisation Identifiant du dossier d'autorisation |
624 |
|
* @return string Libellé dossier d'autorisation |
625 |
|
*/ |
626 |
|
function get_dossier_libelle($dossier) { |
627 |
|
|
628 |
|
$dossier_libelle = ""; |
629 |
|
|
630 |
|
// Requête SQL |
631 |
|
$sql = "SELECT |
632 |
|
dossier_libelle |
633 |
|
FROM |
634 |
|
".DB_PREFIXE."dossier |
635 |
|
WHERE |
636 |
|
dossier = '$dossier'"; |
637 |
|
|
638 |
|
$dossier_libelle = $this->db->getOne($sql); |
639 |
|
$this->addToLog("get_dossier_libelle(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
640 |
|
database::isError($dossier_libelle); |
641 |
|
|
642 |
return $lettretype; |
// Retourne le résultat |
643 |
} |
return $dossier_libelle; |
644 |
|
} |
645 |
|
|
646 |
/** |
/** |
647 |
* Ajout des dossiers |
* Ajout des dossiers |
648 |
**/ |
**/ |
649 |
function triggerAjouter($id, &$db, $val, $DEBUG){ |
function triggerAjouter($id, &$db, $val, $DEBUG){ |
650 |
|
|
651 |
include '../sql/pgsql/demande.form.inc.php'; |
include '../sql/pgsql/demande.form.inc.php'; |
652 |
|
|
653 |
if($this->valF["demande_type"] != NULL) { |
if($this->valF["demande_type"] != NULL) { |
654 |
$res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)); |
$res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)); |
655 |
$this->f->addToLog("triggerAjouter() : db->query(\"".str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)."\")", VERBOSE_MODE); |
$this->f->addToLog("triggerAjouter() : db->query(\"".str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)."\")", VERBOSE_MODE); |
662 |
// Création du dossier_autorisation |
// Création du dossier_autorisation |
663 |
if($this->valF['dossier_autorisation'] == "") { |
if($this->valF['dossier_autorisation'] == "") { |
664 |
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
665 |
$this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']); |
$this -> addToMessage(_("Creation du dossier d'autorisation no").$this->get_dossier_autorisation_libelle($this->valF['dossier_autorisation'])); |
666 |
|
//Ajout des données techniques au dossier d'autorisation |
667 |
|
$this->ajoutDonneesTechniquesDA($id, $db, $val, $DEBUG); |
668 |
} |
} |
669 |
// Enregistrement du numéro dossier existant (il sera écrasé si un DI est créé) |
// Enregistrement du numéro dossier existant (il sera écrasé si un DI est créé) |
670 |
if ($this->getParameter("idx_dossier") != "") { |
if ($this->getParameter("idx_dossier") != "") { |
673 |
// Création du dossier d'instruction |
// Création du dossier d'instruction |
674 |
if($dossier_type['dossier_instruction_type'] != NULL) { |
if($dossier_type['dossier_instruction_type'] != NULL) { |
675 |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']); |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']); |
676 |
$this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']); |
$this -> addToMessage(_("Creation du dossier d'instruction no").$this->get_dossier_libelle($this->valF['dossier_instruction'])); |
677 |
// Attribut permettant de définir si un dossier a été créé. |
// Attribut permettant de définir si un dossier a été créé. |
678 |
$this->ajoutDI = TRUE; |
$this->ajoutDI = TRUE; |
679 |
|
|
680 |
//Ajout des données techniques au dossier d'instruction |
//Ajout des données techniques au dossier d'instruction |
681 |
$this->ajoutDonneesTechniques($id, $db, $val, $DEBUG); |
$this->ajoutDonneesTechniquesDI($id, $db, $val, $DEBUG); |
682 |
|
} |
683 |
|
|
684 |
|
// Si le dossier_instruction existe |
685 |
|
if (isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ) { |
686 |
|
|
687 |
|
// Récupère les informations nécessaire pour créer le répertoire de numérisation |
688 |
|
$getInfosForFoldername = $this->getInfosForFoldername($this->valF['dossier_instruction']); |
689 |
|
|
690 |
|
// Création du répertoire pour la numérisation |
691 |
|
$createFolder = $this->createFolder($getInfosForFoldername['dossier_autorisation'], $getInfosForFoldername['code'], $getInfosForFoldername['version']); |
692 |
|
|
693 |
|
// Si la création a échouée |
694 |
|
if ($createFolder === false) { |
695 |
|
|
696 |
|
// Annule la validation |
697 |
|
$this->correct = false; |
698 |
|
// arrête le traitement entier |
699 |
|
return false; |
700 |
|
|
701 |
|
// |
702 |
|
} else { |
703 |
|
|
704 |
|
// |
705 |
|
$this->addToLog("createFolder() : Success", VERBOSE_MODE); |
706 |
|
} |
707 |
} |
} |
708 |
|
|
709 |
/*Création du lien de téléchargement de récépissé de demande*/ |
/*Création du lien de téléchargement de récépissé de demande*/ |
714 |
$evenement = $this->getEvenement($this->valF['demande_type']); |
$evenement = $this->getEvenement($this->valF['demande_type']); |
715 |
|
|
716 |
/*Récupération de la lettre type de l'événement*/ |
/*Récupération de la lettre type de l'événement*/ |
717 |
$lettretype = $this->getLettreType($evenement); |
$lettretype = $this->f->getLettreType($evenement); |
718 |
|
|
719 |
/*Création d'une nouvelle instruction avec cet événement*/ |
/*Création d'une nouvelle instruction avec cet événement*/ |
720 |
/*Données*/ |
/*Données*/ |
722 |
|
|
723 |
$valInstr['destinataire']=$this->valF['dossier_instruction']; |
$valInstr['destinataire']=$this->valF['dossier_instruction']; |
724 |
$valInstr['dossier']=$this->valF['dossier_instruction']; |
$valInstr['dossier']=$this->valF['dossier_instruction']; |
725 |
|
// Récupère la date de la demande |
726 |
$valInstr['date_evenement']=date("d/m/Y"); |
$valInstr['date_evenement']=$this->dateDBToForm($this->valF['date_demande']); |
727 |
$valInstr['evenement']=$evenement; |
$valInstr['evenement']=$evenement; |
728 |
$valInstr['lettretype']=$lettretype; |
$valInstr['lettretype']=$lettretype; |
729 |
$valInstr['complement']=""; |
$valInstr['complement_om_html']=""; |
730 |
$valInstr['complement2']=""; |
$valInstr['complement2_om_html']=""; |
731 |
|
|
732 |
$valInstr['action']="initialisation"; |
$valInstr['action']="initialisation"; |
733 |
$valInstr['delai']="2"; |
$valInstr['delai']="2"; |
754 |
$valInstr['archive_etat_pendant_incompletude']=NULL; |
$valInstr['archive_etat_pendant_incompletude']=NULL; |
755 |
$valInstr['archive_date_limite_incompletude']=NULL; |
$valInstr['archive_date_limite_incompletude']=NULL; |
756 |
$valInstr['archive_delai_incompletude']=NULL; |
$valInstr['archive_delai_incompletude']=NULL; |
757 |
$valInstr['complement3']=""; |
$valInstr['archive_autorite_competente']=NULL; |
758 |
$valInstr['complement4']=""; |
$valInstr['complement3_om_html']=""; |
759 |
$valInstr['complement5']=""; |
$valInstr['complement4_om_html']=""; |
760 |
$valInstr['complement6']=""; |
$valInstr['complement5_om_html']=""; |
761 |
$valInstr['complement7']=""; |
$valInstr['complement6_om_html']=""; |
762 |
$valInstr['complement8']=""; |
$valInstr['complement7_om_html']=""; |
763 |
$valInstr['complement9']=""; |
$valInstr['complement8_om_html']=""; |
764 |
$valInstr['complement10']=""; |
$valInstr['complement9_om_html']=""; |
765 |
$valInstr['complement11']=""; |
$valInstr['complement10_om_html']=""; |
766 |
$valInstr['complement12']=""; |
$valInstr['complement11_om_html']=""; |
767 |
$valInstr['complement13']=""; |
$valInstr['complement12_om_html']=""; |
768 |
$valInstr['complement14']=""; |
$valInstr['complement13_om_html']=""; |
769 |
$valInstr['complement15']=""; |
$valInstr['complement14_om_html']=""; |
770 |
|
$valInstr['complement15_om_html']=""; |
771 |
$valInstr['avis_decision']=NULL; |
$valInstr['avis_decision']=NULL; |
772 |
$valInstr['date_finalisation_courrier']=NULL; |
$valInstr['date_finalisation_courrier']=NULL; |
773 |
$valInstr['date_envoi_signature']=NULL; |
$valInstr['date_envoi_signature']=NULL; |
781 |
$valInstr['code_barres']=NULL; |
$valInstr['code_barres']=NULL; |
782 |
$valInstr['om_fichier_instruction']=NULL; |
$valInstr['om_fichier_instruction']=NULL; |
783 |
$valInstr['om_final_instruction']=NULL; |
$valInstr['om_final_instruction']=NULL; |
784 |
$valInstr['document_arrete']=NULL; |
$valInstr['document_numerise']=NULL; |
785 |
|
$valInstr['autorite_competente']=NULL; |
786 |
|
$valInstr['duree_validite_parametrage']="0"; |
787 |
|
$valInstr['duree_validite']="0"; |
788 |
|
|
789 |
|
//Récupération des champs archive si cette demande a créée un dossier |
790 |
|
//d'instruction mais pas un P0 |
791 |
|
if (!is_null($this->valF['dossier_instruction']) && |
792 |
|
$this->valF['dossier_instruction'] !== "" ){ |
793 |
|
|
794 |
|
//Requête |
795 |
|
$sql = "SELECT dossier_instruction_type.code |
796 |
|
FROM ".DB_PREFIXE."demande_type |
797 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
798 |
|
ON demande_type.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
799 |
|
WHERE demande_type.demande_type = ".$this->valF['demande_type']; |
800 |
|
$res = $db->getOne($sql); |
801 |
|
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
802 |
|
if (database::isError($res)) { |
803 |
|
die($res->getMessage()); |
804 |
|
} |
805 |
|
|
806 |
|
//On vérifie que ce n'est pas un P0 |
807 |
|
if ( strcmp($res, "P") !== 0 ){ |
808 |
|
|
809 |
|
$res = $this->getArchiveInstruction($this->valF['dossier_instruction']); |
810 |
|
|
811 |
|
if (isset($res['archive_delai'])) { |
812 |
|
$valInstr['archive_delai']=$res["archive_delai"]; |
813 |
|
} |
814 |
|
if (isset($res['archive_date_complet'])) { |
815 |
|
$valInstr['archive_date_complet']=$res["archive_date_complet"]; |
816 |
|
} |
817 |
|
if (isset($res['archive_date_dernier_depot'])) { |
818 |
|
$valInstr['archive_date_dernier_depot']=$res["archive_date_dernier_depot"]; |
819 |
|
} |
820 |
|
if (isset($res['archive_date_rejet'])) { |
821 |
|
$valInstr['archive_date_rejet']=$res["archive_date_rejet"]; |
822 |
|
} |
823 |
|
if (isset($res['archive_date_limite'])) { |
824 |
|
$valInstr['archive_date_limite']=$res["archive_date_limite"]; |
825 |
|
} |
826 |
|
if (isset($res['archive_date_notification_delai'])) { |
827 |
|
$valInstr['archive_date_notification_delai']=$res["archive_date_notification_delai"]; |
828 |
|
} |
829 |
|
if (isset($res['archive_accord_tacite'])) { |
830 |
|
$valInstr['archive_accord_tacite']=$res["archive_accord_tacite"]; |
831 |
|
} |
832 |
|
if (isset($res['archive_etat'])) { |
833 |
|
$valInstr['archive_etat']=$res["archive_etat"]; |
834 |
|
} |
835 |
|
if (isset($res['archive_date_decision'])) { |
836 |
|
$valInstr['archive_date_decision']=$res["archive_date_decision"]; |
837 |
|
} |
838 |
|
if (isset($res['archive_avis'])) { |
839 |
|
$valInstr['archive_avis']=$res["archive_avis"]; |
840 |
|
} |
841 |
|
if (isset($res['archive_date_validite'])) { |
842 |
|
$valInstr['archive_date_validite']=$res["archive_date_validite"]; |
843 |
|
} |
844 |
|
if (isset($res['archive_date_achevement'])) { |
845 |
|
$valInstr['archive_date_achevement']=$res["archive_date_achevement"]; |
846 |
|
} |
847 |
|
if (isset($res['archive_date_chantier'])) { |
848 |
|
$valInstr['archive_date_chantier']=$res["archive_date_chantier"]; |
849 |
|
} |
850 |
|
if (isset($res['archive_date_conformite'])) { |
851 |
|
$valInstr['archive_date_conformite']=$res["archive_date_conformite"]; |
852 |
|
} |
853 |
|
if (isset($res['archive_incompletude'])) { |
854 |
|
$valInstr['archive_incompletude']=$res["archive_incompletude"]; |
855 |
|
} |
856 |
|
if (isset($res['archive_evenement_suivant_tacite'])) { |
857 |
|
$valInstr['archive_evenement_suivant_tacite']=$res["archive_evenement_suivant_tacite"]; |
858 |
|
} |
859 |
|
if (isset($res['archive_evenement_suivant_tacite_incompletude'])) { |
860 |
|
$valInstr['archive_evenement_suivant_tacite_incompletude']=$res["archive_evenement_suivant_tacite_incompletude"]; |
861 |
|
} |
862 |
|
if (isset($res['archive_etat_pendant_incompletude'])) { |
863 |
|
$valInstr['archive_etat_pendant_incompletude']=$res["archive_etat_pendant_incompletude"]; |
864 |
|
} |
865 |
|
if (isset($res['archive_date_limite_incompletude'])) { |
866 |
|
$valInstr['archive_date_limite_incompletude']=$res["archive_date_limite_incompletude"]; |
867 |
|
} |
868 |
|
if (isset($res['archive_delai_incompletude'])) { |
869 |
|
$valInstr['archive_delai_incompletude']=$res["archive_delai_incompletude"]; |
870 |
|
} |
871 |
|
if (isset($res['archive_autorite_competente'])) { |
872 |
|
$valInstr['archive_autorite_competente']=$res["archive_autorite_competente"]; |
873 |
|
} |
874 |
|
} |
875 |
|
} |
876 |
|
|
877 |
/*Fichier requis*/ |
/*Fichier requis*/ |
878 |
require_once '../obj/instruction.class.php'; |
require_once '../obj/instruction.class.php'; |
885 |
//Finalisation du document |
//Finalisation du document |
886 |
$_GET['obj']='instruction'; |
$_GET['obj']='instruction'; |
887 |
$_GET['idx']=$instruction->valF[$instruction->clePrimaire]; |
$_GET['idx']=$instruction->valF[$instruction->clePrimaire]; |
888 |
$instruction = new instruction($_GET['idx'],$db,$DEBUG); |
$instruction_final = new instruction($_GET['idx'],$db,$DEBUG); |
889 |
$res = $instruction->finaliser('', 1, ''); |
if($instruction_final->getVal('lettretype') != "") { |
890 |
|
$res = $instruction_final->finaliser('', 1, '', ''); |
891 |
|
} |
892 |
|
|
893 |
/*Si la création a réussie*/ |
/*Si la création de l'instruction a réussie*/ |
894 |
if ( $instruction->valF['instruction'] != "" ){ |
if ( $instruction->valF['instruction'] != "" ){ |
895 |
|
|
896 |
/*Affichage du récépissé de la demande*/ |
/*Affichage du récépissé de la demande*/ |
929 |
* Ajout des délégataires et pétitionnaires |
* Ajout des délégataires et pétitionnaires |
930 |
**/ |
**/ |
931 |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
932 |
|
|
933 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
934 |
|
|
935 |
// Ajout des lliens entre dossier_autorisation et demandeur |
// Ajout des lliens entre dossier_autorisation et demandeur |
936 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) { |
if(!empty($this->valF['dossier_autorisation'])) { |
937 |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
938 |
} |
} |
939 |
// Ajout des lliens entre dossier et demandeur |
// Ajout des lliens entre dossier et demandeur |
941 |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
942 |
} |
} |
943 |
|
|
944 |
// Duplication des lots et liaison au nouveau dossier_d'instruction |
// Duplication des lots (et leurs données techniques) et |
945 |
|
// liaison au nouveau dossier_d'instruction |
946 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
947 |
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
948 |
} |
} |
962 |
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
963 |
require_once ("../obj/lot.class.php"); |
require_once ("../obj/lot.class.php"); |
964 |
$lot = new lot("]", $db, $DEBUG); |
$lot = new lot("]", $db, $DEBUG); |
|
require_once ("../obj/lien_dossier_lot.class.php"); |
|
|
$ldl = new lien_dossier_lot("]", $db, $DEBUG); |
|
965 |
require_once ("../obj/lien_lot_demandeur.class.php"); |
require_once ("../obj/lien_lot_demandeur.class.php"); |
966 |
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
967 |
|
|
976 |
$valLot['lot'] = ""; |
$valLot['lot'] = ""; |
977 |
$valLot['libelle'] = $rowLot['libelle']; |
$valLot['libelle'] = $rowLot['libelle']; |
978 |
$valLot['dossier_autorisation'] = NULL; |
$valLot['dossier_autorisation'] = NULL; |
979 |
|
$valLot['dossier'] = $this->valF['dossier_instruction']; |
980 |
$lot -> ajouter($valLot, $db, $DEBUG); |
$lot -> ajouter($valLot, $db, $DEBUG); |
981 |
|
|
|
//Insertion du lien entre le lot et le dossier d'instruction |
|
|
$valLdl['lien_dossier_lot'] = ""; |
|
|
$valLdl['dossier'] = $this->valF['dossier_instruction']; |
|
|
$valLdl['lot'] = $lot->valF['lot']; |
|
|
$ldl->ajouter($valLdl, $db, $DEBUG); |
|
|
|
|
982 |
//Insertion des liens entre dossier et les lots |
//Insertion des liens entre dossier et les lots |
983 |
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
984 |
WHERE lot = ".$rowLot['lot']; |
WHERE lot = ".$rowLot['lot']; |
995 |
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
996 |
$lld->ajouter($valLld, $db, $DEBUG); |
$lld->ajouter($valLld, $db, $DEBUG); |
997 |
} |
} |
998 |
|
|
999 |
|
// Récupération des données techniques du nouveau lots |
1000 |
|
$this->ajoutDonneesTechniquesLots($id, $db, $val, $DEBUG, $rowLot['lot'], $lot->valF['lot']); |
1001 |
|
|
1002 |
|
} |
1003 |
|
} |
1004 |
|
|
1005 |
|
|
1006 |
|
/** |
1007 |
|
* Méthode permettant d'ajouter les données techniques aux lots |
1008 |
|
*/ |
1009 |
|
function ajoutDonneesTechniquesLots($id, &$db, $val, $DEBUG, $lotInit, $lotDest){ |
1010 |
|
// Requete permettant de recupérer les données techniques du lot passé en paramètre ($lotInit) |
1011 |
|
$sql_get_dt = "SELECT donnees_techniques FROM ".DB_PREFIXE."donnees_techniques WHERE lot=".$lotInit; |
1012 |
|
$id_dt = $this->f->db->getOne($sql_get_dt); |
1013 |
|
// Si des données techniques sont liées au lots on les "copie" et on les lies au lot passé en paramètre (lotDest) |
1014 |
|
if(isset($id_dt) AND !empty($id_dt)) { |
1015 |
|
$this->f->addToLog("ajoutDonneesTechniquesLots() : db->getone(\"".$sql_get_dt."\");", VERBOSE_MODE); |
1016 |
|
if ( database::isError($id_dt)){ |
1017 |
|
// Appel de la methode de recuperation des erreurs |
1018 |
|
$this->erreur_db($id_dt->getDebugInfo(), $id_dt->getMessage(), ''); |
1019 |
|
return false; |
1020 |
|
} |
1021 |
|
require_once '../obj/donnees_techniques.class.php'; |
1022 |
|
$donnees_techniques = new donnees_techniques($id_dt,$db,$DEBUG); |
1023 |
|
|
1024 |
|
// Récupération des données dans le tableau des valeurs à insérer |
1025 |
|
foreach($donnees_techniques->champs as $value) { |
1026 |
|
$val[$value] = $donnees_techniques->getVal($value); |
1027 |
|
} |
1028 |
|
// Modification du lien vers le nouveau lot |
1029 |
|
$val["lot"] = $lotDest; |
1030 |
|
// Ajout des données techniques |
1031 |
|
$donnees_techniques->ajouter($val, $db, $DEBUG); |
1032 |
} |
} |
1033 |
} |
} |
1034 |
|
|
1218 |
echo "obj=".get_class($this); |
echo "obj=".get_class($this); |
1219 |
if($this->getParameter("retour")=="form") { |
if($this->getParameter("retour")=="form") { |
1220 |
echo "&idx=".$this->getParameter("idx"); |
echo "&idx=".$this->getParameter("idx"); |
1221 |
|
echo "&idz=".$this->getParameter("idz"); |
1222 |
echo "&action=3"; |
echo "&action=3"; |
1223 |
} |
} |
1224 |
} |
} |
1368 |
} |
} |
1369 |
echo "</div>"; |
echo "</div>"; |
1370 |
echo "</fieldset>"; |
echo "</fieldset>"; |
1371 |
|
// Champ flag permettant de récupérer la valeur de l'option sig pour |
1372 |
|
// l'utiliser en javascript, notamment lors du chargement de l'interface |
1373 |
|
// pour les références cadastrales |
1374 |
|
// XXX Si un widget pour les références cadastrales existait, il n'y |
1375 |
|
// aurait pas besoin de faire cela |
1376 |
|
echo "<input id='option_sig' type='hidden' value='".$this->f->getParameter("option_sig")."' name='option_sig'>"; |
1377 |
echo "</div>"; |
echo "</div>"; |
1378 |
} |
} |
1379 |
|
|
1405 |
} |
} |
1406 |
|
|
1407 |
// }}} |
// }}} |
1408 |
|
|
1409 |
|
|
1410 |
|
/** |
1411 |
|
* Cette fonction permet de récupérer les informations nécessaires |
1412 |
|
* à la génération du nom du répertoire |
1413 |
|
* @param string $dossier Identifiant du dossier |
1414 |
|
* @return array Tableau des résultats |
1415 |
|
*/ |
1416 |
|
private function getInfosForFoldername($dossier) { |
1417 |
|
|
1418 |
|
//Requête SQL |
1419 |
|
$sql = "SELECT dossier.dossier_autorisation, dossier_instruction_type.code, dossier.version |
1420 |
|
FROM ".DB_PREFIXE."dossier |
1421 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1422 |
|
ON dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
1423 |
|
WHERE dossier.dossier = '".$dossier."'"; |
1424 |
|
$res = $this->f->db->query($sql); |
1425 |
|
$this->addToLog("getInfosForFoldername() : db->query(".$sql.")", VERBOSE_MODE); |
1426 |
|
database::isError($res); |
1427 |
|
|
1428 |
|
// tableau des résultats |
1429 |
|
$row = $res->fetchRow(DB_FETCHMODE_ASSOC); |
1430 |
|
|
1431 |
|
//Formatage du numéro de version |
1432 |
|
require_once '../obj/dossier.class.php'; |
1433 |
|
$dossier = new dossier($dossier,$this->db,DEBUG); |
1434 |
|
$row['version'] = $dossier->getNumeroVersionDossierInstructionType($dossier->getVal('dossier_autorisation'), $dossier->getVal('dossier_instruction_type'), $row['version'], false); |
1435 |
|
|
1436 |
|
// retourne le tableau des résultats |
1437 |
|
return $row; |
1438 |
|
} |
1439 |
|
|
1440 |
|
/** |
1441 |
|
* Cette fonction permet la création du répertoire dans le dossier de numérisation |
1442 |
|
* @param string $dossier_autorisation Identifiant dossier d'autorisation |
1443 |
|
* @param string $code Type du dossier d'instruction |
1444 |
|
* @param int $version Numéro de version du dossier |
1445 |
|
* @return boolean Vrai ou Faux |
1446 |
|
*/ |
1447 |
|
private function createFolder($dossier_autorisation, $code, $version) { |
1448 |
|
|
1449 |
|
// Nom du répertoire |
1450 |
|
$foldername = $dossier_autorisation.".".$code.$version; |
1451 |
|
|
1452 |
|
// Vérifie le paramètrage du répertoire de numérisation |
1453 |
|
if (isset($this->f->config["path_scan"])) { |
1454 |
|
|
1455 |
|
// Vérifie que le répertoire existe |
1456 |
|
if (is_dir($this->f->config["path_scan"])) { |
1457 |
|
|
1458 |
|
// Répertoire des "à traiter" |
1459 |
|
$dir = $this->f->config["path_scan"]."Todo/"; |
1460 |
|
|
1461 |
|
// Si le répertore existe déjà le répertoire n'est pas crée |
1462 |
|
if (file_exists($dir.$foldername)) { |
1463 |
|
|
1464 |
|
// |
1465 |
|
return true; |
1466 |
|
} |
1467 |
|
|
1468 |
|
// Vérifie que le répêrtoire des "à traiter" existe |
1469 |
|
if (is_dir($dir)) { |
1470 |
|
|
1471 |
|
// Création du répertoire |
1472 |
|
mkdir($dir.$foldername, 0777); |
1473 |
|
// |
1474 |
|
return true; |
1475 |
|
} |
1476 |
|
|
1477 |
|
// Message d'erreur |
1478 |
|
$this->msg = ""; |
1479 |
|
$this->addToErrors ('', _("Le repertoire Todo n'existe pas.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1480 |
|
// |
1481 |
|
return false; |
1482 |
|
|
1483 |
|
} |
1484 |
|
|
1485 |
|
// Message d'erreur |
1486 |
|
$this->msg = ""; |
1487 |
|
$this->addToErrors ('', _("Le repertoire de numerisation configure n'existe pas.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1488 |
|
// |
1489 |
|
return false; |
1490 |
|
|
1491 |
|
} |
1492 |
|
|
1493 |
|
// Message d'erreur |
1494 |
|
$this->msg = ""; |
1495 |
|
$this->addToErrors ('', _("Le repertoire de numerisation n'a pas ete configure.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1496 |
|
// |
1497 |
|
return false; |
1498 |
|
} |
1499 |
|
|
1500 |
|
/** |
1501 |
|
* Récupère le champ "qualification" du type de la demande |
1502 |
|
* @param integer $demande_type Identifiant du type de la demande |
1503 |
|
* @return boolean |
1504 |
|
*/ |
1505 |
|
function get_qualification($demande_type) { |
1506 |
|
|
1507 |
|
// Initialise le résultat |
1508 |
|
$qualification = ""; |
1509 |
|
|
1510 |
|
// Si la condition existe |
1511 |
|
if (is_numeric($demande_type)) { |
1512 |
|
|
1513 |
|
// Requête SQL |
1514 |
|
$sql = "SELECT qualification |
1515 |
|
FROM ".DB_PREFIXE."demande_type |
1516 |
|
WHERE demande_type = $demande_type"; |
1517 |
|
$qualification = $this->db->getOne($sql); |
1518 |
|
$this->f->addToLog("get_qualification() : db->getOne(\"".$sql."\")", |
1519 |
|
VERBOSE_MODE); |
1520 |
|
$this->f->isDatabaseError($qualification); |
1521 |
|
} |
1522 |
|
|
1523 |
|
// Retourne le résultat |
1524 |
|
return $qualification; |
1525 |
|
} |
1526 |
|
|
1527 |
|
/** |
1528 |
|
* Récupère les champs archive_* d'une instruction |
1529 |
|
* @param string $dossier L'identifiant du dossier d'instruction |
1530 |
|
*/ |
1531 |
|
public function getArchiveInstruction($dossierID){ |
1532 |
|
|
1533 |
|
//On récupère les données du dernier DI accordé |
1534 |
|
$sql = "SELECT dossier.delai, dossier.accord_tacite, dossier.etat, |
1535 |
|
dossier.avis_decision, |
1536 |
|
to_char(dossier.date_complet, 'DD/MM/YYYY') as date_complet, |
1537 |
|
to_char(dossier.date_dernier_depot, 'DD/MM/YYYY') as date_dernier_depot, |
1538 |
|
to_char(dossier.date_rejet, 'DD/MM/YYYY') as date_rejet, |
1539 |
|
to_char(dossier.date_limite, 'DD/MM/YYYY') as date_limite, |
1540 |
|
to_char(dossier.date_notification_delai, 'DD/MM/YYYY') as date_notification_delai, |
1541 |
|
to_char(dossier.date_decision, 'DD/MM/YYYY') as date_decision, |
1542 |
|
to_char(dossier.date_validite, 'DD/MM/YYYY') as date_validite, |
1543 |
|
to_char(dossier.date_achevement, 'DD/MM/YYYY') as date_achevement, |
1544 |
|
to_char(dossier.date_chantier, 'DD/MM/YYYY') as date_chantier, |
1545 |
|
to_char(dossier.date_conformite, 'DD/MM/YYYY') as date_conformite, |
1546 |
|
dossier.incompletude, |
1547 |
|
dossier.evenement_suivant_tacite, dossier.evenement_suivant_tacite_incompletude, |
1548 |
|
dossier.etat_pendant_incompletude, |
1549 |
|
to_char(dossier.date_limite_incompletude, 'DD/MM/YYYY') as date_limite_incompletude, |
1550 |
|
dossier.delai_incompletude, dossier.autorite_competente, dossier.duree_validite |
1551 |
|
,dossier.dossier |
1552 |
|
FROM ".DB_PREFIXE."dossier |
1553 |
|
LEFT JOIN ".DB_PREFIXE."avis_decision |
1554 |
|
ON dossier.avis_decision = avis_decision.avis_decision |
1555 |
|
WHERE dossier.avis_decision IS NOT NULL AND avis_decision.typeavis = 'F' |
1556 |
|
AND dossier.dossier_autorisation = ( |
1557 |
|
SELECT dossier_autorisation.dossier_autorisation |
1558 |
|
FROM ".DB_PREFIXE."dossier_autorisation |
1559 |
|
LEFT JOIN ".DB_PREFIXE."dossier |
1560 |
|
ON dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1561 |
|
WHERE dossier = '".$dossierID."') |
1562 |
|
ORDER BY dossier.version DESC"; |
1563 |
|
|
1564 |
|
$res = $this->db->query($sql); |
1565 |
|
$this->addToLog("updateArchiveInstruction(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1566 |
|
if (database::isError($res)) { |
1567 |
|
die($res->getMessage()); |
1568 |
|
} |
1569 |
|
|
1570 |
|
//Un des dosssiers d'instruction a été accordé, on récupère ses données |
1571 |
|
if ( $res->numrows() != 0 ){ |
1572 |
|
|
1573 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1574 |
|
require_once "../obj/instruction.class.php"; |
1575 |
|
$instruction = new instruction("]",$this->db,DEBUG); |
1576 |
|
|
1577 |
|
$instruction->setParameter("maj", 1); |
1578 |
|
$instruction->updateArchiveData($row); |
1579 |
|
return $instruction->valF; |
1580 |
|
} |
1581 |
|
//Sinon, on prend les données du P0, si ce n'est pas un P0 |
1582 |
|
else { |
1583 |
|
$sql = "SELECT dossier.delai, dossier.accord_tacite, dossier.etat, |
1584 |
|
dossier.avis_decision, dossier.date_complet, dossier.date_dernier_depot, |
1585 |
|
dossier.date_rejet, dossier.date_limite, dossier.date_notification_delai, |
1586 |
|
dossier.date_decision, dossier.date_validite, dossier.date_achevement, |
1587 |
|
dossier.date_chantier, dossier.date_conformite, dossier.incompletude, |
1588 |
|
dossier.evenement_suivant_tacite, dossier.evenement_suivant_tacite_incompletude, |
1589 |
|
dossier.etat_pendant_incompletude, dossier.date_limite_incompletude, |
1590 |
|
dossier.delai_incompletude, dossier.autorite_competente, dossier.duree_validite |
1591 |
|
,dossier.dossier |
1592 |
|
FROM ".DB_PREFIXE."dossier |
1593 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1594 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1595 |
|
WHERE dossier.dossier_autorisation = ( |
1596 |
|
SELECT dossier_autorisation.dossier_autorisation |
1597 |
|
FROM ".DB_PREFIXE."dossier_autorisation |
1598 |
|
LEFT JOIN ".DB_PREFIXE."dossier |
1599 |
|
ON dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1600 |
|
WHERE dossier = '".$dossierID."') |
1601 |
|
AND dossier_instruction_type.code = 'P' |
1602 |
|
ORDER BY dossier.version DESC"; |
1603 |
|
$res = $this->db->query($sql); |
1604 |
|
$this->addToLog("updateArchiveInstruction(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1605 |
|
if (database::isError($res)) { |
1606 |
|
die($res->getMessage()); |
1607 |
|
} |
1608 |
|
|
1609 |
|
//On est pas dans le cas d'un dépôt d'un P0 |
1610 |
|
if ( $res->numrows() != 0 ){ |
1611 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1612 |
|
require_once "../obj/instruction.class.php"; |
1613 |
|
$instruction = new instruction("]",$this->db,DEBUG); |
1614 |
|
$instruction->setParameter("maj", 1); |
1615 |
|
$instruction->updateArchiveData($row); |
1616 |
|
return $instruction->valF; |
1617 |
|
} |
1618 |
|
} |
1619 |
|
} |
1620 |
}// fin classe |
}// fin classe |
1621 |
?> |
?> |