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 |
} |
} |
94 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
95 |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
96 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
97 |
|
|
98 |
|
// |
99 |
|
$form->setSelect('demande_type', $this->loadSelectDemandeType($form, $maj, $db, $debug, "dossier_autorisation_type_detaille")); |
100 |
|
|
101 |
|
} |
102 |
|
|
103 |
//Récupération de paramètre pour le rechargement ajax du select |
/** |
104 |
$idx_dossier = $this->getParameter("idx_dossier"); |
* Charge le select du champ type de demande |
105 |
$datd = $this->getParameter("datd"); |
* @param object $form Formulaire |
106 |
|
* @param int $maj Mode d'insertion |
107 |
$contenu = array(); |
* @param object $db Database |
108 |
|
* @param bool $debug Debug active ou pas |
109 |
$sql_demande_type = "SELECT demande_type.demande_type, demande_type.libelle FROM ".DB_PREFIXE."demande_type |
* @param string $champ champ activant le filtre |
110 |
LEFT OUTER JOIN ".DB_PREFIXE."lien_demande_type_etat_dossier_autorisation |
* @return array Contenu du select |
111 |
ON lien_demande_type_etat_dossier_autorisation.demande_type=demande_type.demande_type |
*/ |
112 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation |
function loadSelectDemandeType(&$form, $maj, &$db, $debug, $champ) { |
|
ON lien_demande_type_etat_dossier_autorisation.etat_dossier_autorisation= |
|
|
dossier_autorisation.etat_dossier_autorisation |
|
|
LEFT OUTER JOIN ".DB_PREFIXE."dossier |
|
|
ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation"; |
|
|
|
|
|
// Ajout de filtre sur la requête (initial) |
|
|
if(isset($idx_dossier) AND $idx_dossier != "") { |
|
|
$sql_demande_type .= " WHERE demande_type.demande_nature = 2 "; |
|
113 |
|
|
114 |
// ajout du numéro de dossier existant pour tester l'état du DA |
// |
115 |
$sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' "; |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
116 |
} else { |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
117 |
$sql_demande_type .= " WHERE demande_type.demande_nature = 1 "; |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
118 |
} |
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); |
|
119 |
|
|
120 |
// logger |
// Contenu de la liste à choix |
121 |
$this->f->addToLog("setSelect(): db->query(\"".$sql_demande_type."\");", |
$contenu=array(); |
122 |
VERBOSE_MODE); |
$contenu[0][0]=''; |
123 |
if ( database::isError($res)){ |
$contenu[1][0]=_('choisir')." "._("demande_type"); |
124 |
die(); |
|
125 |
|
//Récupère l'id du type de dossier d'autorisation détaillé |
126 |
|
$id_dossier_autorisation_type_detaille = ""; |
127 |
|
if (isset($_POST[$champ])) { |
128 |
|
$id_dossier_autorisation_type_detaille = $_POST[$champ]; |
129 |
|
} elseif($this->getParameter($champ) != "") { |
130 |
|
$id_dossier_autorisation_type_detaille = $this->getParameter($champ); |
131 |
|
} elseif(isset($form->val[$champ])) { |
132 |
|
$id_dossier_autorisation_type_detaille = $form->val[$champ]; |
133 |
} |
} |
134 |
|
|
135 |
$contenu[0][0] = ''; |
// Récupération de paramètre pour le rechargement ajax du select |
136 |
$contenu[1][0] = _('choisir')." "._("demande_type"); |
$idx_dossier = $this->getParameter("idx_dossier"); |
137 |
|
|
138 |
$k=1; |
// Récupère l'id de la nature de la demande |
139 |
while($row =& $res->fetchRow()){ |
$id_demande_nature = "1"; |
140 |
|
if (isset($idx_dossier) AND $idx_dossier != "") { |
141 |
|
$id_demande_nature = '2'; |
142 |
|
} |
143 |
|
|
144 |
$contenu[0][$k] = $row[0]; |
// Ajout de condition pour la requête |
145 |
$contenu[1][$k] = $row[1]; |
$ajout_condition_requête = ""; |
146 |
$k++; |
if ($id_demande_nature == '2') { |
147 |
|
$ajout_condition_requête = " AND dossier.dossier = '".$idx_dossier."'"; |
148 |
} |
} |
149 |
|
|
150 |
$form->setSelect("demande_type", $contenu); |
// |
151 |
|
if ($id_dossier_autorisation_type_detaille != "") { |
152 |
|
//Si l'id du type de dossier d'autorisation détaillé est renseigné |
153 |
|
$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); |
154 |
|
// Ajoute une condition sur la nature de la demande |
155 |
|
$sql_demande_type_by_dossier_autorisation_type_detaille = str_replace('<idx_demande_nature>', $id_demande_nature, $sql_demande_type_by_dossier_autorisation_type_detaille); |
156 |
|
// Permet d'ajouter une condition |
157 |
|
$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); |
158 |
|
$res = $this->db->query($sql_demande_type_by_dossier_autorisation_type_detaille); |
159 |
|
$this->addToLog("db->query(\"".$sql_demande_type_by_dossier_autorisation_type_detaille."\");", VERBOSE_MODE); |
160 |
|
$this->f->isDatabaseError($res); |
161 |
|
//Les résultats de la requête sont stocké dans le tableau contenu |
162 |
|
$k=1; |
163 |
|
while ($row=& $res->fetchRow()){ |
164 |
|
$contenu[0][$k]=$row[0]; |
165 |
|
$contenu[1][$k]=$row[1]; |
166 |
|
$k++; |
167 |
|
} |
168 |
|
} |
169 |
|
|
170 |
|
// Retourne le contenu de la liste |
171 |
|
return $contenu; |
172 |
} |
} |
173 |
|
|
174 |
/* |
/* |
175 |
* Ajout du fielset |
* Ajout du fielset |
176 |
* Add fieldset |
* Add fieldset |
212 |
*/ |
*/ |
213 |
function setOnchange(&$form,$maj){ |
function setOnchange(&$form,$maj){ |
214 |
parent::setOnchange($form,$maj); |
parent::setOnchange($form,$maj); |
215 |
|
|
216 |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
217 |
$form->setOnchange("demande_type","showFormsDemande();"); |
$form->setOnchange("demande_type","showFormsDemande();"); |
218 |
} |
} |
221 |
parent::setLib($form,$maj); |
parent::setLib($form,$maj); |
222 |
//libelle des champs |
//libelle des champs |
223 |
|
|
224 |
$form->setLib('complement',_('terrain_adresse')); |
$form->setLib('terrain_adresse_voie',_('terrain_adresse')); |
225 |
} |
} |
226 |
/* |
/* |
227 |
* Cache le champ terrain_references_cadastrales |
* Cache le champ terrain_references_cadastrales |
242 |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
243 |
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
244 |
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
245 |
$form->setType('complement', 'hiddenstatic'); |
$form->setType('terrain_adresse_voie', 'hiddenstatic'); |
246 |
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
247 |
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
248 |
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
266 |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
267 |
require_once '../obj/dossier_autorisation.class.php'; |
require_once '../obj/dossier_autorisation.class.php'; |
268 |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
269 |
$id_etat_initial_da = $this->f->getParameter('etat_initial_dossier_autorisation'); |
$id_etat_initial_da = $this->f->getParameter('id_etat_initial_dossier_autorisation'); |
270 |
$error = false; |
$error = false; |
271 |
|
|
272 |
// 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 |
293 |
$valAuto['exercice']=NULL; |
$valAuto['exercice']=NULL; |
294 |
$valAuto['insee']=NULL; |
$valAuto['insee']=NULL; |
295 |
$valAuto['arrondissement']=NULL; |
$valAuto['arrondissement']=NULL; |
296 |
$valAuto['etat_dossier_autorisation']=$this->f->getParameter('etat_initial_dossier_autorisation'); |
$valAuto['etat_dossier_autorisation']=$this->f->getParameter('id_etat_initial_dossier_autorisation'); |
297 |
$valAuto['erp_numero_batiment']=NULL; |
$valAuto['erp_numero_batiment']=NULL; |
298 |
$valAuto['erp_ouvert']=NULL; |
$valAuto['erp_ouvert']=NULL; |
299 |
$valAuto['erp_arrete_decision']=NULL; |
$valAuto['erp_arrete_decision']=NULL; |
301 |
$valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
$valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
302 |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
303 |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
304 |
$valAuto['complement']=$this->valF['complement']; |
$valAuto['terrain_adresse_voie']=$this->valF['terrain_adresse_voie']; |
305 |
$valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
$valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
306 |
$valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
$valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
307 |
$valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
$valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
328 |
|
|
329 |
} |
} |
330 |
|
|
|
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; |
|
|
} |
|
|
|
|
331 |
/** |
/** |
332 |
* Méthode permettant d'ajouter un dossier d'instruction |
* Méthode permettant d'ajouter un dossier d'instruction |
333 |
*/ |
*/ |
354 |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
355 |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
356 |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
357 |
$valInstr['complement']=$this->valF['complement']; |
$valInstr['terrain_adresse_voie']=$this->valF['terrain_adresse_voie']; |
358 |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
359 |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
360 |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
367 |
/* |
/* |
368 |
* Gestion de la qualification |
* Gestion de la qualification |
369 |
* */ |
* */ |
370 |
//Récupérer le code du type de la demande |
// Initialise le champ à false |
371 |
$codeDemandeType = $this->getCodeDemandeType($val['demande_type']); |
$valInstr['a_qualifier'] = false; |
372 |
|
|
373 |
//Marque le dossier comme à qualifier selon le type de dossier d'instruction |
// Récupère l'information depuis le type de la demande |
374 |
if ( strcasecmp($codeDemandeType, "DI") == 0 || |
$qualification = $this->get_qualification($val['demande_type']); |
375 |
strcasecmp($codeDemandeType, "DT") == 0 || |
|
376 |
strcasecmp($codeDemandeType, "DM") == 0 || |
// Si le dossier doit être à qualifier |
377 |
strcasecmp($codeDemandeType, "DP") == 0 || |
if ($qualification === 't') { |
378 |
strcasecmp($codeDemandeType, "DTP") == 0 || |
// Met le champ à true |
379 |
strcasecmp($codeDemandeType, "DAACT") == 0 || |
$valInstr['a_qualifier'] = true; |
|
strcasecmp($codeDemandeType, "DOC") == 0 ){ |
|
|
|
|
|
$valInstr['a_qualifier'] = TRUE; |
|
380 |
} |
} |
381 |
|
|
382 |
// 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 |
383 |
$sql = "SELECT |
$sql = "SELECT |
384 |
dossier_instruction_type.cerfa |
dossier_autorisation_type_detaille.cerfa |
385 |
FROM |
FROM |
386 |
".DB_PREFIXE."dossier_instruction_type |
".DB_PREFIXE."dossier_autorisation_type_detaille |
387 |
JOIN |
JOIN |
388 |
".DB_PREFIXE."cerfa |
".DB_PREFIXE."cerfa |
389 |
ON |
ON |
390 |
dossier_instruction_type.cerfa = cerfa.cerfa |
dossier_autorisation_type_detaille.cerfa = cerfa.cerfa |
391 |
WHERE |
WHERE |
392 |
now()<=om_validite_fin |
now()<=om_validite_fin |
393 |
AND now()>=om_validite_debut |
AND now()>=om_validite_debut |
394 |
AND dossier_instruction_type=".$dossier_instruction_type; |
AND dossier_autorisation_type_detaille=".$this->valF['dossier_autorisation_type_detaille']; |
395 |
$valInstr['cerfa'] = $db->getOne($sql); |
$valInstr['cerfa'] = $db->getOne($sql); |
396 |
$this->f->addToLog("ajoutDossierInstruction() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("ajoutDossierInstruction() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
397 |
if ( database::isError($valInstr['cerfa'])){ |
if ( database::isError($valInstr['cerfa'])){ |
398 |
die(); |
die(); |
399 |
} |
} |
400 |
$dossier->ajouter($valInstr, $db, $DEBUG); |
$dossier->ajouter($valInstr, $db, $DEBUG); |
401 |
|
|
402 |
|
//Affichage de message à l'utilisateur concernant un problème lors de |
403 |
|
//l'affectation de l'instructeur au dossier d'instruction |
404 |
|
if ($dossier->valF['dossier_autorisation'] === '' && |
405 |
|
$dossier->valF['instructeur'] === NULL){ |
406 |
|
$this->addToMessage(_("Aucun instructeur compatible avec ce dossier, contactez votre administrateur afin d'en assigner un a ce dossier.")); |
407 |
|
} |
408 |
|
elseif ( $dossier->valF['instructeur'] === NULL ){ |
409 |
|
if ($this->f->isAccredited("dossier_modifier_instructeur")) { |
410 |
|
$this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")); |
411 |
|
} else { |
412 |
|
$this->addToMessage(_("Aucun instructeur compatible avec ce dossier, contactez votre administrateur afin d'en assigner un a ce dossier.")); |
413 |
|
} |
414 |
|
} |
415 |
|
|
416 |
// Liaison du dossier ajouter à la demande |
// Liaison du dossier ajouter à la demande |
417 |
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
418 |
} |
} |
419 |
|
|
420 |
/** |
/** |
421 |
* 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 |
422 |
*/ |
*/ |
423 |
function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){ |
function ajoutDonneesTechniquesDA($id, &$db, $val, $DEBUG){ |
424 |
|
|
425 |
require_once '../obj/donnees_techniques.class.php'; |
require_once '../obj/donnees_techniques.class.php'; |
426 |
$donnees_techniques = new donnees_techniques("]",$db,$DEBUG); |
$donnees_techniques = new donnees_techniques("]",$db,$DEBUG); |
427 |
|
|
428 |
// 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 |
429 |
foreach($donnees_techniques->champs as $value) { |
foreach($donnees_techniques->champs as $value) { |
430 |
$val[$value] = NULL; |
$val[$value] = NULL; |
431 |
} |
} |
432 |
|
|
433 |
// Ajout du numéro de dossier d'instruction |
// Ajout du numéro de dossier d'instruction |
434 |
$val['dossier_instruction']=$this->valF['dossier_instruction']; |
$val['dossier_autorisation']=$this->valF['dossier_autorisation']; |
435 |
|
|
436 |
// Ajout des données techniques |
// Ajout des données techniques |
437 |
$donnees_techniques->ajouter($val, $db, $DEBUG); |
$donnees_techniques->ajouter($val, $db, $DEBUG); |
438 |
} |
} |
439 |
|
|
440 |
/** |
/** |
441 |
* Ajout des liens demandeurs / dossier d'autorisation |
* Méthode permettant d'ajouter les données techniques au dossier d'autorisation |
442 |
|
*/ |
443 |
|
function ajoutDonneesTechniquesDI($id, &$db, $val, $DEBUG){ |
444 |
|
|
445 |
|
// Requête permettant de récupérer le dernier enregistrement en base des données techniques |
446 |
|
// liées au dossier d'autorisationdu dossier d'instruction en cours de création |
447 |
|
$sql_dt_from_da = "SELECT donnees_techniques |
448 |
|
FROM ".DB_PREFIXE."donnees_techniques |
449 |
|
WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."' |
450 |
|
ORDER BY donnees_techniques DESC"; |
451 |
|
// Récupération de l'id |
452 |
|
$id_da = $this->db->getOne($sql_dt_from_da); |
453 |
|
if ( database::isError($id_da)){ |
454 |
|
// affiche l'erreur pour l'utilisateur et dans le log |
455 |
|
$this->addToErrors("", |
456 |
|
_("Erreur lors de la recuperation des donnees techniques en cours de validite"), |
457 |
|
_("Erreur lors de la recuperation des donnees techniques en cours de validite")); |
458 |
|
return false; |
459 |
|
} |
460 |
|
require_once '../obj/donnees_techniques.class.php'; |
461 |
|
$donnees_techniques = new donnees_techniques($id_da,$db,$DEBUG); |
462 |
|
|
463 |
|
// Récupération des données du DA |
464 |
|
foreach($donnees_techniques->champs as $value) { |
465 |
|
$val[$value] = $donnees_techniques->getVal($value); |
466 |
|
} |
467 |
|
|
468 |
|
// Ajout du numéro de dossier d'instruction |
469 |
|
$val['dossier_instruction'] = $this->valF['dossier_instruction']; |
470 |
|
// Suppression du numéro de dossier d'autorisation |
471 |
|
$val['dossier_autorisation'] = NULL; |
472 |
|
|
473 |
|
// Ajout des données techniques |
474 |
|
$donnees_techniques->ajouter($val, $db, $DEBUG); |
475 |
|
} |
476 |
|
|
477 |
|
/** |
478 |
|
* Ajout des liens demandeurs / dossier d'autorisation s'ils n'y sont pas déjà |
479 |
**/ |
**/ |
480 |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
481 |
// Création des liens entre le dossier autorisation et les demandeurs |
// Création des liens entre le dossier autorisation et les demandeurs |
483 |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
484 |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
485 |
// Recupération des demandeurs liés à la demande |
// Recupération des demandeurs liés à la demande |
486 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur. |
487 |
|
" AND lien_demande_demandeur.demandeur NOT IN ( |
488 |
|
SELECT lien_dossier_autorisation_demandeur.demandeur |
489 |
|
FROM ".DB_PREFIXE."lien_dossier_autorisation_demandeur |
490 |
|
WHERE lien_dossier_autorisation_demandeur.dossier_autorisation = |
491 |
|
'".$this->valF['dossier_autorisation']."' |
492 |
|
)"); |
493 |
$res = $db->query($sql); |
$res = $db->query($sql); |
494 |
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
495 |
if ( database::isError($res)){ |
if ( database::isError($res)){ |
584 |
return $evenement; |
return $evenement; |
585 |
} |
} |
586 |
|
|
587 |
/* |
|
588 |
* Récupère la lettre type lié à un événement |
|
589 |
|
/** |
590 |
|
* Retourne le libellé du dossier d'autorisation |
591 |
|
* @param string $dossier_autorisation Identifiant du dossier d'autorisation |
592 |
|
* @return string Libellé dossier d'autorisation |
593 |
*/ |
*/ |
594 |
function getLettreType($evenement){ |
function get_dossier_autorisation_libelle($dossier_autorisation) { |
595 |
|
|
596 |
$lettretype = NULL; |
$dossier_autorisation_libelle = ""; |
597 |
|
|
598 |
$sql = |
// Requête SQL |
599 |
"SELECT |
$sql = "SELECT |
600 |
lettretype |
dossier_autorisation_libelle |
601 |
FROM |
FROM |
602 |
".DB_PREFIXE."evenement |
".DB_PREFIXE."dossier_autorisation |
603 |
WHERE |
WHERE |
604 |
evenement = $evenement"; |
dossier_autorisation = '$dossier_autorisation'"; |
605 |
|
|
606 |
$res = $this->db->query($sql); |
$dossier_autorisation_libelle = $this->db->getOne($sql); |
607 |
$this->f->addToLog("getLettreType() : db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("get_dossier_autorisation_libelle(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
608 |
if ( database::isError($res)){ |
database::isError($dossier_autorisation_libelle); |
|
die(); |
|
|
} |
|
609 |
|
|
610 |
if ( $res->numrows() > 0 ){ |
// Retourne le résultat |
611 |
|
return $dossier_autorisation_libelle; |
612 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
} |
613 |
$lettretype = $row['lettretype']; |
|
614 |
} |
/** |
615 |
|
* Retourne le libellé du dossier d'autorisation |
616 |
|
* @param string $dossier_autorisation Identifiant du dossier d'autorisation |
617 |
|
* @return string Libellé dossier d'autorisation |
618 |
|
*/ |
619 |
|
function get_dossier_libelle($dossier) { |
620 |
|
|
621 |
|
$dossier_libelle = ""; |
622 |
|
|
623 |
|
// Requête SQL |
624 |
|
$sql = "SELECT |
625 |
|
dossier_libelle |
626 |
|
FROM |
627 |
|
".DB_PREFIXE."dossier |
628 |
|
WHERE |
629 |
|
dossier = '$dossier'"; |
630 |
|
|
631 |
|
$dossier_libelle = $this->db->getOne($sql); |
632 |
|
$this->addToLog("get_dossier_libelle(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
633 |
|
database::isError($dossier_libelle); |
634 |
|
|
635 |
return $lettretype; |
// Retourne le résultat |
636 |
} |
return $dossier_libelle; |
637 |
|
} |
638 |
|
|
639 |
/** |
/** |
640 |
* Ajout des dossiers |
* Ajout des dossiers |
641 |
**/ |
**/ |
642 |
function triggerAjouter($id, &$db, $val, $DEBUG){ |
function triggerAjouter($id, &$db, $val, $DEBUG){ |
643 |
|
|
644 |
include '../sql/pgsql/demande.form.inc.php'; |
include '../sql/pgsql/demande.form.inc.php'; |
645 |
|
|
646 |
if($this->valF["demande_type"] != NULL) { |
if($this->valF["demande_type"] != NULL) { |
647 |
$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)); |
648 |
$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); |
655 |
// Création du dossier_autorisation |
// Création du dossier_autorisation |
656 |
if($this->valF['dossier_autorisation'] == "") { |
if($this->valF['dossier_autorisation'] == "") { |
657 |
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
658 |
$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'])); |
659 |
|
//Ajout des données techniques au dossier d'autorisation |
660 |
|
$this->ajoutDonneesTechniquesDA($id, $db, $val, $DEBUG); |
661 |
} |
} |
662 |
// 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éé) |
663 |
if ($this->getParameter("idx_dossier") != "") { |
if ($this->getParameter("idx_dossier") != "") { |
666 |
// Création du dossier d'instruction |
// Création du dossier d'instruction |
667 |
if($dossier_type['dossier_instruction_type'] != NULL) { |
if($dossier_type['dossier_instruction_type'] != NULL) { |
668 |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']); |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']); |
669 |
$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'])); |
670 |
// Attribut permettant de définir si un dossier a été créé. |
// Attribut permettant de définir si un dossier a été créé. |
671 |
$this->ajoutDI = TRUE; |
$this->ajoutDI = TRUE; |
672 |
|
|
673 |
//Ajout des données techniques au dossier d'instruction |
//Ajout des données techniques au dossier d'instruction |
674 |
$this->ajoutDonneesTechniques($id, $db, $val, $DEBUG); |
$this->ajoutDonneesTechniquesDI($id, $db, $val, $DEBUG); |
675 |
|
} |
676 |
|
|
677 |
|
// Si le dossier_instruction existe |
678 |
|
if (isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ) { |
679 |
|
|
680 |
|
// Récupère les informations nécessaire pour créer le répertoire de numérisation |
681 |
|
$getInfosForFoldername = $this->getInfosForFoldername($this->valF['dossier_instruction']); |
682 |
|
|
683 |
|
// Création du répertoire pour la numérisation |
684 |
|
$createFolder = $this->createFolder($getInfosForFoldername['dossier_autorisation'], $getInfosForFoldername['code'], $getInfosForFoldername['version']); |
685 |
|
|
686 |
|
// Si la création a échouée |
687 |
|
if ($createFolder === false) { |
688 |
|
|
689 |
|
// Annule la validation |
690 |
|
$this->correct = false; |
691 |
|
// arrête le traitement entier |
692 |
|
return false; |
693 |
|
|
694 |
|
// |
695 |
|
} else { |
696 |
|
|
697 |
|
// |
698 |
|
$this->addToLog("createFolder() : Success", VERBOSE_MODE); |
699 |
|
} |
700 |
} |
} |
701 |
|
|
702 |
/*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*/ |
707 |
$evenement = $this->getEvenement($this->valF['demande_type']); |
$evenement = $this->getEvenement($this->valF['demande_type']); |
708 |
|
|
709 |
/*Récupération de la lettre type de l'événement*/ |
/*Récupération de la lettre type de l'événement*/ |
710 |
$lettretype = $this->getLettreType($evenement); |
$lettretype = $this->f->getLettreType($evenement); |
711 |
|
|
712 |
/*Création d'une nouvelle instruction avec cet événement*/ |
/*Création d'une nouvelle instruction avec cet événement*/ |
713 |
/*Données*/ |
/*Données*/ |
719 |
$valInstr['date_evenement']=date("d/m/Y"); |
$valInstr['date_evenement']=date("d/m/Y"); |
720 |
$valInstr['evenement']=$evenement; |
$valInstr['evenement']=$evenement; |
721 |
$valInstr['lettretype']=$lettretype; |
$valInstr['lettretype']=$lettretype; |
722 |
$valInstr['complement']=""; |
$valInstr['complement_om_html']=""; |
723 |
$valInstr['complement2']=""; |
$valInstr['complement2_om_html']=""; |
724 |
|
|
725 |
$valInstr['action']="initialisation"; |
$valInstr['action']="initialisation"; |
726 |
$valInstr['delai']="2"; |
$valInstr['delai']="2"; |
747 |
$valInstr['archive_etat_pendant_incompletude']=NULL; |
$valInstr['archive_etat_pendant_incompletude']=NULL; |
748 |
$valInstr['archive_date_limite_incompletude']=NULL; |
$valInstr['archive_date_limite_incompletude']=NULL; |
749 |
$valInstr['archive_delai_incompletude']=NULL; |
$valInstr['archive_delai_incompletude']=NULL; |
750 |
$valInstr['complement3']=""; |
$valInstr['archive_autorite_competente']=NULL; |
751 |
$valInstr['complement4']=""; |
$valInstr['complement3_om_html']=""; |
752 |
$valInstr['complement5']=""; |
$valInstr['complement4_om_html']=""; |
753 |
$valInstr['complement6']=""; |
$valInstr['complement5_om_html']=""; |
754 |
$valInstr['complement7']=""; |
$valInstr['complement6_om_html']=""; |
755 |
$valInstr['complement8']=""; |
$valInstr['complement7_om_html']=""; |
756 |
$valInstr['complement9']=""; |
$valInstr['complement8_om_html']=""; |
757 |
$valInstr['complement10']=""; |
$valInstr['complement9_om_html']=""; |
758 |
$valInstr['complement11']=""; |
$valInstr['complement10_om_html']=""; |
759 |
$valInstr['complement12']=""; |
$valInstr['complement11_om_html']=""; |
760 |
$valInstr['complement13']=""; |
$valInstr['complement12_om_html']=""; |
761 |
$valInstr['complement14']=""; |
$valInstr['complement13_om_html']=""; |
762 |
$valInstr['complement15']=""; |
$valInstr['complement14_om_html']=""; |
763 |
|
$valInstr['complement15_om_html']=""; |
764 |
$valInstr['avis_decision']=NULL; |
$valInstr['avis_decision']=NULL; |
765 |
$valInstr['date_finalisation_courrier']=NULL; |
$valInstr['date_finalisation_courrier']=NULL; |
766 |
$valInstr['date_envoi_signature']=NULL; |
$valInstr['date_envoi_signature']=NULL; |
774 |
$valInstr['code_barres']=NULL; |
$valInstr['code_barres']=NULL; |
775 |
$valInstr['om_fichier_instruction']=NULL; |
$valInstr['om_fichier_instruction']=NULL; |
776 |
$valInstr['om_final_instruction']=NULL; |
$valInstr['om_final_instruction']=NULL; |
777 |
$valInstr['document_arrete']=NULL; |
$valInstr['document_numerise']=NULL; |
778 |
|
$valInstr['autorite_competente']=NULL; |
779 |
|
$valInstr['duree_validite_parametrage']="0"; |
780 |
|
$valInstr['duree_validite']="0"; |
781 |
|
|
782 |
|
//Récupération des champs archive si cette demande a créée un dossier |
783 |
|
//d'instruction mais pas un P0 |
784 |
|
if (!is_null($this->valF['dossier_instruction']) && |
785 |
|
$this->valF['dossier_instruction'] !== "" ){ |
786 |
|
|
787 |
|
//Requête |
788 |
|
$sql = "SELECT dossier_instruction_type.code |
789 |
|
FROM ".DB_PREFIXE."demande_type |
790 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
791 |
|
ON demande_type.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
792 |
|
WHERE demande_type.demande_type = ".$this->valF['demande_type']; |
793 |
|
$res = $db->getOne($sql); |
794 |
|
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
795 |
|
if (database::isError($res)) { |
796 |
|
die($res->getMessage()); |
797 |
|
} |
798 |
|
|
799 |
|
//On vérifie que ce n'est pas un P0 |
800 |
|
if ( strcmp($res, "P") !== 0 ){ |
801 |
|
|
802 |
|
$res = $this->getArchiveInstruction($this->valF['dossier_instruction']); |
803 |
|
|
804 |
|
if (isset($res['archive_delai'])) { |
805 |
|
$valInstr['archive_delai']=$res["archive_delai"]; |
806 |
|
} |
807 |
|
if (isset($res['archive_date_complet'])) { |
808 |
|
$valInstr['archive_date_complet']=$res["archive_date_complet"]; |
809 |
|
} |
810 |
|
if (isset($res['archive_date_dernier_depot'])) { |
811 |
|
$valInstr['archive_date_dernier_depot']=$res["archive_date_dernier_depot"]; |
812 |
|
} |
813 |
|
if (isset($res['archive_date_rejet'])) { |
814 |
|
$valInstr['archive_date_rejet']=$res["archive_date_rejet"]; |
815 |
|
} |
816 |
|
if (isset($res['archive_date_limite'])) { |
817 |
|
$valInstr['archive_date_limite']=$res["archive_date_limite"]; |
818 |
|
} |
819 |
|
if (isset($res['archive_date_notification_delai'])) { |
820 |
|
$valInstr['archive_date_notification_delai']=$res["archive_date_notification_delai"]; |
821 |
|
} |
822 |
|
if (isset($res['archive_accord_tacite'])) { |
823 |
|
$valInstr['archive_accord_tacite']=$res["archive_accord_tacite"]; |
824 |
|
} |
825 |
|
if (isset($res['archive_etat'])) { |
826 |
|
$valInstr['archive_etat']=$res["archive_etat"]; |
827 |
|
} |
828 |
|
if (isset($res['archive_date_decision'])) { |
829 |
|
$valInstr['archive_date_decision']=$res["archive_date_decision"]; |
830 |
|
} |
831 |
|
if (isset($res['archive_avis'])) { |
832 |
|
$valInstr['archive_avis']=$res["archive_avis"]; |
833 |
|
} |
834 |
|
if (isset($res['archive_date_validite'])) { |
835 |
|
$valInstr['archive_date_validite']=$res["archive_date_validite"]; |
836 |
|
} |
837 |
|
if (isset($res['archive_date_achevement'])) { |
838 |
|
$valInstr['archive_date_achevement']=$res["archive_date_achevement"]; |
839 |
|
} |
840 |
|
if (isset($res['archive_date_chantier'])) { |
841 |
|
$valInstr['archive_date_chantier']=$res["archive_date_chantier"]; |
842 |
|
} |
843 |
|
if (isset($res['archive_date_conformite'])) { |
844 |
|
$valInstr['archive_date_conformite']=$res["archive_date_conformite"]; |
845 |
|
} |
846 |
|
if (isset($res['archive_incompletude'])) { |
847 |
|
$valInstr['archive_incompletude']=$res["archive_incompletude"]; |
848 |
|
} |
849 |
|
if (isset($res['archive_evenement_suivant_tacite'])) { |
850 |
|
$valInstr['archive_evenement_suivant_tacite']=$res["archive_evenement_suivant_tacite"]; |
851 |
|
} |
852 |
|
if (isset($res['archive_evenement_suivant_tacite_incompletude'])) { |
853 |
|
$valInstr['archive_evenement_suivant_tacite_incompletude']=$res["archive_evenement_suivant_tacite_incompletude"]; |
854 |
|
} |
855 |
|
if (isset($res['archive_etat_pendant_incompletude'])) { |
856 |
|
$valInstr['archive_etat_pendant_incompletude']=$res["archive_etat_pendant_incompletude"]; |
857 |
|
} |
858 |
|
if (isset($res['archive_date_limite_incompletude'])) { |
859 |
|
$valInstr['archive_date_limite_incompletude']=$res["archive_date_limite_incompletude"]; |
860 |
|
} |
861 |
|
if (isset($res['archive_delai_incompletude'])) { |
862 |
|
$valInstr['archive_delai_incompletude']=$res["archive_delai_incompletude"]; |
863 |
|
} |
864 |
|
if (isset($res['archive_autorite_competente'])) { |
865 |
|
$valInstr['archive_autorite_competente']=$res["archive_autorite_competente"]; |
866 |
|
} |
867 |
|
} |
868 |
|
} |
869 |
|
|
870 |
/*Fichier requis*/ |
/*Fichier requis*/ |
871 |
require_once '../obj/instruction.class.php'; |
require_once '../obj/instruction.class.php'; |
879 |
$_GET['obj']='instruction'; |
$_GET['obj']='instruction'; |
880 |
$_GET['idx']=$instruction->valF[$instruction->clePrimaire]; |
$_GET['idx']=$instruction->valF[$instruction->clePrimaire]; |
881 |
$instruction = new instruction($_GET['idx'],$db,$DEBUG); |
$instruction = new instruction($_GET['idx'],$db,$DEBUG); |
882 |
$res = $instruction->finaliser('', 1, ''); |
$res = $instruction->finaliser('', 1, '', ''); |
883 |
|
|
884 |
/*Si la création a réussie*/ |
/*Si la création a réussie*/ |
885 |
if ( $instruction->valF['instruction'] != "" ){ |
if ( $instruction->valF['instruction'] != "" ){ |
920 |
* Ajout des délégataires et pétitionnaires |
* Ajout des délégataires et pétitionnaires |
921 |
**/ |
**/ |
922 |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
923 |
|
|
924 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
925 |
|
|
926 |
// Ajout des lliens entre dossier_autorisation et demandeur |
// Ajout des lliens entre dossier_autorisation et demandeur |
927 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) { |
if(!empty($this->valF['dossier_autorisation'])) { |
928 |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
929 |
} |
} |
930 |
// Ajout des lliens entre dossier et demandeur |
// Ajout des lliens entre dossier et demandeur |
932 |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
933 |
} |
} |
934 |
|
|
935 |
// Duplication des lots et liaison au nouveau dossier_d'instruction |
// Duplication des lots (et leurs données techniques) et |
936 |
|
// liaison au nouveau dossier_d'instruction |
937 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
938 |
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
939 |
} |
} |
953 |
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
954 |
require_once ("../obj/lot.class.php"); |
require_once ("../obj/lot.class.php"); |
955 |
$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); |
|
956 |
require_once ("../obj/lien_lot_demandeur.class.php"); |
require_once ("../obj/lien_lot_demandeur.class.php"); |
957 |
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
958 |
|
|
967 |
$valLot['lot'] = ""; |
$valLot['lot'] = ""; |
968 |
$valLot['libelle'] = $rowLot['libelle']; |
$valLot['libelle'] = $rowLot['libelle']; |
969 |
$valLot['dossier_autorisation'] = NULL; |
$valLot['dossier_autorisation'] = NULL; |
970 |
|
$valLot['dossier'] = $this->valF['dossier_instruction']; |
971 |
$lot -> ajouter($valLot, $db, $DEBUG); |
$lot -> ajouter($valLot, $db, $DEBUG); |
972 |
|
|
|
//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); |
|
|
|
|
973 |
//Insertion des liens entre dossier et les lots |
//Insertion des liens entre dossier et les lots |
974 |
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
975 |
WHERE lot = ".$rowLot['lot']; |
WHERE lot = ".$rowLot['lot']; |
986 |
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
987 |
$lld->ajouter($valLld, $db, $DEBUG); |
$lld->ajouter($valLld, $db, $DEBUG); |
988 |
} |
} |
989 |
|
|
990 |
|
// Récupération des données techniques du nouveau lots |
991 |
|
$this->ajoutDonneesTechniquesLots($id, $db, $val, $DEBUG, $rowLot['lot'], $lot->valF['lot']); |
992 |
|
|
993 |
|
} |
994 |
|
} |
995 |
|
|
996 |
|
|
997 |
|
/** |
998 |
|
* Méthode permettant d'ajouter les données techniques aux lots |
999 |
|
*/ |
1000 |
|
function ajoutDonneesTechniquesLots($id, &$db, $val, $DEBUG, $lotInit, $lotDest){ |
1001 |
|
// Requete permettant de recupérer les données techniques du lot passé en paramètre ($lotInit) |
1002 |
|
$sql_get_dt = "SELECT donnees_techniques FROM ".DB_PREFIXE."donnees_techniques WHERE lot=".$lotInit; |
1003 |
|
$id_dt = $this->f->db->getOne($sql_get_dt); |
1004 |
|
// Si des données techniques sont liées au lots on les "copie" et on les lies au lot passé en paramètre (lotDest) |
1005 |
|
if(isset($id_dt) AND !empty($id_dt)) { |
1006 |
|
$this->f->addToLog("ajoutDonneesTechniquesLots() : db->getone(\"".$sql_get_dt."\");", VERBOSE_MODE); |
1007 |
|
if ( database::isError($id_dt)){ |
1008 |
|
// Appel de la methode de recuperation des erreurs |
1009 |
|
$this->erreur_db($id_dt->getDebugInfo(), $id_dt->getMessage(), ''); |
1010 |
|
return false; |
1011 |
|
} |
1012 |
|
require_once '../obj/donnees_techniques.class.php'; |
1013 |
|
$donnees_techniques = new donnees_techniques($id_dt,$db,$DEBUG); |
1014 |
|
|
1015 |
|
// Récupération des données dans le tableau des valeurs à insérer |
1016 |
|
foreach($donnees_techniques->champs as $value) { |
1017 |
|
$val[$value] = $donnees_techniques->getVal($value); |
1018 |
|
} |
1019 |
|
// Modification du lien vers le nouveau lot |
1020 |
|
$val["lot"] = $lotDest; |
1021 |
|
// Ajout des données techniques |
1022 |
|
$donnees_techniques->ajouter($val, $db, $DEBUG); |
1023 |
} |
} |
1024 |
} |
} |
1025 |
|
|
1209 |
echo "obj=".get_class($this); |
echo "obj=".get_class($this); |
1210 |
if($this->getParameter("retour")=="form") { |
if($this->getParameter("retour")=="form") { |
1211 |
echo "&idx=".$this->getParameter("idx"); |
echo "&idx=".$this->getParameter("idx"); |
1212 |
|
echo "&idz=".$this->getParameter("idz"); |
1213 |
echo "&action=3"; |
echo "&action=3"; |
1214 |
} |
} |
1215 |
} |
} |
1359 |
} |
} |
1360 |
echo "</div>"; |
echo "</div>"; |
1361 |
echo "</fieldset>"; |
echo "</fieldset>"; |
1362 |
|
// Champ flag permettant de récupérer la valeur de l'option sig pour |
1363 |
|
// l'utiliser en javascript, notamment lors du chargement de l'interface |
1364 |
|
// pour les références cadastrales |
1365 |
|
// XXX Si un widget pour les références cadastrales existait, il n'y |
1366 |
|
// aurait pas besoin de faire cela |
1367 |
|
echo "<input id='option_sig' type='hidden' value='".$this->f->getParameter("option_sig")."' name='option_sig'>"; |
1368 |
echo "</div>"; |
echo "</div>"; |
1369 |
} |
} |
1370 |
|
|
1396 |
} |
} |
1397 |
|
|
1398 |
// }}} |
// }}} |
1399 |
|
|
1400 |
|
|
1401 |
|
/** |
1402 |
|
* Cette fonction permet de récupérer les informations nécessaires |
1403 |
|
* à la génération du nom du répertoire |
1404 |
|
* @param string $dossier Identifiant du dossier |
1405 |
|
* @return array Tableau des résultats |
1406 |
|
*/ |
1407 |
|
private function getInfosForFoldername($dossier) { |
1408 |
|
|
1409 |
|
//Requête SQL |
1410 |
|
$sql = "SELECT dossier.dossier_autorisation, dossier_instruction_type.code, dossier.version |
1411 |
|
FROM ".DB_PREFIXE."dossier |
1412 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1413 |
|
ON dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
1414 |
|
WHERE dossier.dossier = '".$dossier."'"; |
1415 |
|
$res = $this->f->db->query($sql); |
1416 |
|
$this->addToLog("getInfosForFoldername() : db->query(".$sql.")", VERBOSE_MODE); |
1417 |
|
database::isError($res); |
1418 |
|
|
1419 |
|
// tableau des résultats |
1420 |
|
$row = $res->fetchRow(DB_FETCHMODE_ASSOC); |
1421 |
|
|
1422 |
|
//Formatage du numéro de version |
1423 |
|
require_once '../obj/dossier.class.php'; |
1424 |
|
$dossier = new dossier($dossier,$this->db,DEBUG); |
1425 |
|
$row['version'] = $dossier->getNumeroVersionDossierInstructionType($dossier->getVal('dossier_autorisation'), $dossier->getVal('dossier_instruction_type'), $row['version'], false); |
1426 |
|
|
1427 |
|
// retourne le tableau des résultats |
1428 |
|
return $row; |
1429 |
|
} |
1430 |
|
|
1431 |
|
/** |
1432 |
|
* Cette fonction permet la création du répertoire dans le dossier de numérisation |
1433 |
|
* @param string $dossier_autorisation Identifiant dossier d'autorisation |
1434 |
|
* @param string $code Type du dossier d'instruction |
1435 |
|
* @param int $version Numéro de version du dossier |
1436 |
|
* @return boolean Vrai ou Faux |
1437 |
|
*/ |
1438 |
|
private function createFolder($dossier_autorisation, $code, $version) { |
1439 |
|
|
1440 |
|
// Nom du répertoire |
1441 |
|
$foldername = $dossier_autorisation.".".$code.$version; |
1442 |
|
|
1443 |
|
// Vérifie le paramètrage du répertoire de numérisation |
1444 |
|
if (isset($this->f->config["path_scan"])) { |
1445 |
|
|
1446 |
|
// Vérifie que le répertoire existe |
1447 |
|
if (is_dir($this->f->config["path_scan"])) { |
1448 |
|
|
1449 |
|
// Répertoire des "à traiter" |
1450 |
|
$dir = $this->f->config["path_scan"]."Todo/"; |
1451 |
|
|
1452 |
|
// Si le répertore existe déjà le répertoire n'est pas crée |
1453 |
|
if (file_exists($dir.$foldername)) { |
1454 |
|
|
1455 |
|
// |
1456 |
|
return true; |
1457 |
|
} |
1458 |
|
|
1459 |
|
// Vérifie que le répêrtoire des "à traiter" existe |
1460 |
|
if (is_dir($dir)) { |
1461 |
|
|
1462 |
|
// Création du répertoire |
1463 |
|
mkdir($dir.$foldername, 0777); |
1464 |
|
// |
1465 |
|
return true; |
1466 |
|
} |
1467 |
|
|
1468 |
|
// Message d'erreur |
1469 |
|
$this->msg = ""; |
1470 |
|
$this->addToErrors ('', _("Le repertoire Todo n'existe pas.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1471 |
|
// |
1472 |
|
return false; |
1473 |
|
|
1474 |
|
} |
1475 |
|
|
1476 |
|
// Message d'erreur |
1477 |
|
$this->msg = ""; |
1478 |
|
$this->addToErrors ('', _("Le repertoire de numerisation configure n'existe pas.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1479 |
|
// |
1480 |
|
return false; |
1481 |
|
|
1482 |
|
} |
1483 |
|
|
1484 |
|
// Message d'erreur |
1485 |
|
$this->msg = ""; |
1486 |
|
$this->addToErrors ('', _("Le repertoire de numerisation n'a pas ete configure.") . " " . _("Veuillez contacter votre administrateur."), "createFolder() : Faillure"); |
1487 |
|
// |
1488 |
|
return false; |
1489 |
|
} |
1490 |
|
|
1491 |
|
/** |
1492 |
|
* Récupère le champ "qualification" du type de la demande |
1493 |
|
* @param integer $demande_type Identifiant du type de la demande |
1494 |
|
* @return boolean |
1495 |
|
*/ |
1496 |
|
function get_qualification($demande_type) { |
1497 |
|
|
1498 |
|
// Initialise le résultat |
1499 |
|
$qualification = ""; |
1500 |
|
|
1501 |
|
// Si la condition existe |
1502 |
|
if (is_numeric($demande_type)) { |
1503 |
|
|
1504 |
|
// Requête SQL |
1505 |
|
$sql = "SELECT qualification |
1506 |
|
FROM ".DB_PREFIXE."demande_type |
1507 |
|
WHERE demande_type = $demande_type"; |
1508 |
|
$qualification = $this->db->getOne($sql); |
1509 |
|
$this->f->addToLog("get_qualification() : db->getOne(\"".$sql."\")", |
1510 |
|
VERBOSE_MODE); |
1511 |
|
$this->f->isDatabaseError($qualification); |
1512 |
|
} |
1513 |
|
|
1514 |
|
// Retourne le résultat |
1515 |
|
return $qualification; |
1516 |
|
} |
1517 |
|
|
1518 |
|
/** |
1519 |
|
* Récupère les champs archive_* d'une instruction |
1520 |
|
* @param string $dossier L'identifiant du dossier d'instruction |
1521 |
|
*/ |
1522 |
|
public function getArchiveInstruction($dossierID){ |
1523 |
|
|
1524 |
|
//On récupère les données du dernier DI accordé |
1525 |
|
$sql = "SELECT dossier.delai, dossier.accord_tacite, dossier.etat, |
1526 |
|
dossier.avis_decision, |
1527 |
|
to_char(dossier.date_complet, 'DD/MM/YYYY') as date_complet, |
1528 |
|
to_char(dossier.date_dernier_depot, 'DD/MM/YYYY') as date_dernier_depot, |
1529 |
|
to_char(dossier.date_rejet, 'DD/MM/YYYY') as date_rejet, |
1530 |
|
to_char(dossier.date_limite, 'DD/MM/YYYY') as date_limite, |
1531 |
|
to_char(dossier.date_notification_delai, 'DD/MM/YYYY') as date_notification_delai, |
1532 |
|
to_char(dossier.date_decision, 'DD/MM/YYYY') as date_decision, |
1533 |
|
to_char(dossier.date_validite, 'DD/MM/YYYY') as date_validite, |
1534 |
|
to_char(dossier.date_achevement, 'DD/MM/YYYY') as date_achevement, |
1535 |
|
to_char(dossier.date_chantier, 'DD/MM/YYYY') as date_chantier, |
1536 |
|
to_char(dossier.date_conformite, 'DD/MM/YYYY') as date_conformite, |
1537 |
|
dossier.incompletude, |
1538 |
|
dossier.evenement_suivant_tacite, dossier.evenement_suivant_tacite_incompletude, |
1539 |
|
dossier.etat_pendant_incompletude, |
1540 |
|
to_char(dossier.date_limite_incompletude, 'DD/MM/YYYY') as date_limite_incompletude, |
1541 |
|
dossier.delai_incompletude, dossier.autorite_competente, dossier.duree_validite |
1542 |
|
,dossier.dossier |
1543 |
|
FROM ".DB_PREFIXE."dossier |
1544 |
|
LEFT JOIN ".DB_PREFIXE."avis_decision |
1545 |
|
ON dossier.avis_decision = avis_decision.avis_decision |
1546 |
|
WHERE dossier.avis_decision IS NOT NULL AND avis_decision.typeavis = 'F' |
1547 |
|
AND dossier.dossier_autorisation = ( |
1548 |
|
SELECT dossier_autorisation.dossier_autorisation |
1549 |
|
FROM ".DB_PREFIXE."dossier_autorisation |
1550 |
|
LEFT JOIN ".DB_PREFIXE."dossier |
1551 |
|
ON dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1552 |
|
WHERE dossier = '".$dossierID."') |
1553 |
|
ORDER BY dossier.version DESC"; |
1554 |
|
|
1555 |
|
$res = $this->db->query($sql); |
1556 |
|
$this->addToLog("updateArchiveInstruction(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1557 |
|
if (database::isError($res)) { |
1558 |
|
die($res->getMessage()); |
1559 |
|
} |
1560 |
|
|
1561 |
|
//Un des dosssiers d'instruction a été accordé, on récupère ses données |
1562 |
|
if ( $res->numrows() != 0 ){ |
1563 |
|
|
1564 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1565 |
|
require_once "../obj/instruction.class.php"; |
1566 |
|
$instruction = new instruction("]",$this->db,DEBUG); |
1567 |
|
|
1568 |
|
$instruction->setParameter("maj", 1); |
1569 |
|
$instruction->updateArchiveData($row); |
1570 |
|
return $instruction->valF; |
1571 |
|
} |
1572 |
|
//Sinon, on prend les données du P0, si ce n'est pas un P0 |
1573 |
|
else { |
1574 |
|
$sql = "SELECT dossier.delai, dossier.accord_tacite, dossier.etat, |
1575 |
|
dossier.avis_decision, dossier.date_complet, dossier.date_dernier_depot, |
1576 |
|
dossier.date_rejet, dossier.date_limite, dossier.date_notification_delai, |
1577 |
|
dossier.date_decision, dossier.date_validite, dossier.date_achevement, |
1578 |
|
dossier.date_chantier, dossier.date_conformite, dossier.incompletude, |
1579 |
|
dossier.evenement_suivant_tacite, dossier.evenement_suivant_tacite_incompletude, |
1580 |
|
dossier.etat_pendant_incompletude, dossier.date_limite_incompletude, |
1581 |
|
dossier.delai_incompletude, dossier.autorite_competente, dossier.duree_validite |
1582 |
|
,dossier.dossier |
1583 |
|
FROM ".DB_PREFIXE."dossier |
1584 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1585 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1586 |
|
WHERE dossier.dossier_autorisation = ( |
1587 |
|
SELECT dossier_autorisation.dossier_autorisation |
1588 |
|
FROM ".DB_PREFIXE."dossier_autorisation |
1589 |
|
LEFT JOIN ".DB_PREFIXE."dossier |
1590 |
|
ON dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
1591 |
|
WHERE dossier = '".$this->valF['dossier']."') |
1592 |
|
AND dossier_instruction_type.code = 'P' |
1593 |
|
ORDER BY dossier.version DESC"; |
1594 |
|
$res = $this->db->query($sql); |
1595 |
|
$this->addToLog("updateArchiveInstruction(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1596 |
|
if (database::isError($res)) { |
1597 |
|
die($res->getMessage()); |
1598 |
|
} |
1599 |
|
|
1600 |
|
//On est pas dans le cas d'un dépôt d'un P0 |
1601 |
|
if ( $res->numrows() != 0 ){ |
1602 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1603 |
|
$instruction = new instruction("]",$this->db,DEBUG); |
1604 |
|
$instruction->setParameter("maj", 1); |
1605 |
|
$instruction->updateArchiveData($row); |
1606 |
|
return $instruction->valF; |
1607 |
|
} |
1608 |
|
} |
1609 |
|
} |
1610 |
}// fin classe |
}// fin classe |
1611 |
?> |
?> |