/[openfoncier]/trunk/obj/dossier.class.php
ViewVC logotype

Contents of /trunk/obj/dossier.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1218 - (show annotations)
Fri Jan 11 15:56:33 2013 UTC (12 years ago) by vpihour
File size: 62483 byte(s)
Gestion du rapport d'instruction

1 <?php
2 //$Id$
3 //gen openMairie le 10/02/2011 20:39
4
5 require_once ("../gen/obj/dossier.class.php");
6 require_once("../services/outgoing/messageenqueuer.php");
7
8 class dossier extends dossier_gen {
9
10 var $maj;
11 var $sig;
12 var $servitude="";
13 var $auto_pos;
14 var $auto_servitude_surfacique;
15 var $auto_servitude_ligne;
16 var $auto_servitude_point;
17 var $auto_parcelle;
18 var $auto_parcelle_lot;
19 var $aff_depot = "collapsible";
20 var $aff_travaux = "collapsible";
21 var $aff_instruction = "collapsible";
22 var $aff_demandeur = "startClosed";
23 var $aff_delegataire = "startClosed";
24 var $aff_terrain = "startClosed";
25 var $aff_localisation = "collapsible";
26 var $aff_description = "startClosed";
27 var $aff_amenagement = "startClosed";
28 var $dossier_instruction_type;
29
30 function dossier($id,&$db,$DEBUG) {
31 $this->constructeur($id,$db,$DEBUG);
32 } // fin constructeur
33
34 /*Mutateur pour ma variable dossier_instruction_type*/
35 public function getDossierInstructionType(){
36 return $this->dossier_instruction_type;
37 }
38 public function setDossierInstructionType($dossier_instruction_type){
39 $this->dossier_instruction_type = $dossier_instruction_type;
40 }
41
42 // {{{ Gestion de la confidentialité des données spécifiques
43
44 /**
45 * Surcharge pour gérer les actions disponibles dans le portlet
46 */
47 function checkAccessibility() {
48 //
49 parent::checkAccessibility();
50 // Si l'utilisateur est un intructeur qui en correspond pas à la
51 // division du dossier
52 if ($this->f->isUserInstructeur()
53 && isset($this->f->om_utilisateur["division"])
54 && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) {
55 //
56 $this->actions_sup = array();
57 $this->setParameter("actions", array());
58 }
59 }
60
61 /**
62 * Cette methode est à surcharger elle permet de tester dans chaque classe
63 * des droits des droits spécifiques en fonction des données
64 */
65 function canAccess() {
66 // Si l'utilisateur est un intructeur qui ne correspond pas à la
67 // division du dossier
68 if ($this->f->isUserInstructeur()
69 && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()
70 && $this->getParameter("maj") != 3) {
71 //
72 return false;
73 }
74 //
75 return true;
76 }
77
78 /**
79 * Cette méthode permet de récupérer la division d'un dossier
80 */
81 function getDivisionFromDossier() {
82 //
83 if (!isset($this->val[array_search("dossier", $this->champs)])) {
84 return NULL;
85 }
86 //
87 $sql = "select division from ".DB_PREFIXE."dossier ";
88 $sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'";
89 //
90 $division = $this->db->getOne($sql);
91 $this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE);
92 database::isError($division);
93 //
94 return $division;
95 }
96
97 // }}}
98 /*
99 * Ajoute un numéro au dossier
100 *
101 */
102 function setValFAjout($val = array()) {
103
104 /*Récupération de la lettre associé au type de dossier d'instruction*/
105 $code = $this->getCode($this->getDossierInstructionType());
106
107 /* Récupération de la valeur du suffixe ce dossier_instruction_type */
108 $suffixe = $this->getSuffixe($this->getDossierInstructionType());
109
110 /*S'il est à TRUE, on récupère le numéro de version du dossier d'autorisation*/
111 $numeroVersion = "";
112 if ( $suffixe == 't' ){
113
114 $numeroVersion = $this->getNumeroVersion($val['dossier_autorisation']);
115
116 /* Incrémentation du numéro de version */
117 if ( is_numeric($numeroVersion) or $numeroVersion == -1 ){
118
119 $this->incrementNumeroVersion($val['dossier_autorisation'], ++$numeroVersion);
120 }
121 }
122
123 /*Création du numéro de dossier*/
124 $this->valF['dossier'] = $val['dossier_autorisation']."$code$numeroVersion";
125 }
126
127 /*Récupère la valeur du suffixe d'un dossier_instruction_type*/
128 function getSuffixe($dossierInstructionType){
129
130 $suffixe = "";
131
132 $sql = "SELECT
133 suffixe
134 FROM
135 ".DB_PREFIXE."dossier_instruction_type
136 WHERE
137 dossier_instruction_type = $dossierInstructionType";
138
139 $this->addToLog("getSuffixe(): db->query(\"".$sql."\")", VERBOSE_MODE);
140 $res = $this->db->query($sql);
141 if (database :: isError($res))
142 die($res->getMessage()."erreur ".$sql);
143
144 if ( $res->numRows() > 0 ){
145
146 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
147 $suffixe = $row['suffixe'];
148 }
149
150 return $suffixe;
151 }
152
153 /*Récupère dans la table de paramètrage la lettre correspondant
154 * au dossier_instruction_type
155 */
156 function getCode($dossierInstructionType){
157
158 $code = "";
159
160 $sql = "SELECT
161 code
162 FROM
163 ".DB_PREFIXE."dossier_instruction_type
164 WHERE
165 dossier_instruction_type = $dossierInstructionType";
166
167 $this->addToLog("getCode(): db->query(\"".$sql."\")", VERBOSE_MODE);
168 $res = $this->db->query($sql);
169 if (database :: isError($res))
170 die($res->getMessage()."erreur ".$sql);
171
172 if ( $res->numRows() > 0 ){
173
174 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
175 $code = $row['code'];
176 }
177
178 return $code;
179 }
180
181 /*Récupère le numéro de version d'un dossier_autorisation*/
182 function getNumeroVersion($dossierAutorisation){
183
184 $numeroVersion = "";
185
186 $sql = "SELECT
187 numero_version
188 FROM
189 ".DB_PREFIXE."dossier_autorisation
190 WHERE
191 dossier_autorisation = '$dossierAutorisation'";
192
193 $this->addToLog("getNumeroVersion(): db->query(\"".$sql."\")", VERBOSE_MODE);
194 $res = $this->db->query($sql);
195 if (database :: isError($res))
196 die($res->getMessage()."erreur ".$sql);
197
198 if ( $res->numRows() > 0 ){
199
200 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
201 $numeroVersion = $row['numero_version'];
202 }
203
204 return $numeroVersion;
205 }
206
207 /*Incrémente le numéro de version du dossier*/
208 function incrementNumeroVersion($dossierAutorisation, $nouveauNumeroVersion) {
209
210 $valF = array (
211 "numero_version" => $nouveauNumeroVersion
212 );
213
214 $res = $this->db->autoExecute(DB_PREFIXE."dossier_autorisation",
215 $valF,
216 DB_AUTOQUERY_UPDATE,
217 "dossier_autorisation = '$dossierAutorisation'");
218
219 if (database :: isError($res))
220 die($res->getMessage()."erreur ".$sql);
221
222 }
223
224 function setvalF($val){
225 parent::setvalF($val);
226 // enlever les valeurs a ne pas saisir -> recherche en trigger ajouter et modifier
227 // $sig = 1
228 unset ($this->valF['geom']);
229 unset ($this->valF['geom1']);
230 // valeurs hiddenstatic (calcule)
231 if($this->maj==1){
232 // par defaut
233 unset ($this->valF['etat']);
234 unset ($this->valF['delai']);
235 unset ($this->valF['accord_tacite']);
236 unset ($this->valF['types']);
237 }
238 unset ($this->valF['avis_decision']); // avis + libelle avis
239 unset ($this->valF['terrain_surface_calcul']);
240 unset ($this->valF['shon_calcul']);
241 unset ($this->valF['parcelle_archive']);
242 unset ($this->valF['parcelle_lot_archive']);
243 unset ($this->valF['date_notification_delai']);
244 unset ($this->valF['date_decision']);
245 unset ($this->valF['date_limite']);
246 unset ($this->valF['date_validite']);
247 unset ($this->valF['date_chantier']);
248 unset ($this->valF['date_achevement']);
249 unset ($this->valF['date_conformite']);
250 }
251
252 /*Vérification des données saisies*/
253 function verifier($val,&$db,$DEBUG){
254 parent::verifier($val,$db,$DEBUG);
255 if($val['parcelle']!="" and $val['sig']!='Oui'){
256 if (!preg_match('/^[0-9]{3} [A-Z]{1,3} [0-9]{1,5}$/', $val['parcelle']) && !preg_match('/^[0-9]{3}[A-Z]{1,3}[0-9]{1,5}$/', $val['parcelle'])){
257 $this->correct=false;
258 $this->addToMessage("<br>format parcelle incorrect");
259 }
260 }
261 // regles travaux verification
262 if ($this->valF['travaux']!=""){
263 $sql= "select * from ".DB_PREFIXE."regle where id = '".$this->valF['travaux'].
264 "' and controle = 'travaux' order by ordre";
265 $res = $db->query($sql);
266 if (database :: isError($res)) die($res->getMessage().$sql);
267 $this->addToLog("requete ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
268 $regle=0;
269 $msg="";
270 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
271 if(isset($this->valF[$row['champ']]))
272 $champvaleur=$this->valF[$row['champ']];
273 else
274 $champvaleur=0;
275 switch ($row['operateur']) {
276 case ">" :
277 if($row['sens']=="plus"){
278 if($champvaleur > $row['valeur'])
279 $condition = 1;
280 else
281 $condition = 0;
282 if($regle==1 or $condition == 1)
283 $regle=1;
284 else
285 $regle=0;
286 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
287 $champvaleur."]";
288 }else{
289 if($champvaleur > $row['valeur']){
290 $condition = 0;
291 }else{
292 $condition = 1;
293 $regle=0;
294 }
295 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
296 $champvaleur."]";
297 }
298 break;
299 case ">=":
300 if($row['sens']=="plus"){
301 if($champvaleur >= $row['valeur'])
302 $condition = 1;
303 else
304 $condition = 0;
305 if($regle==1 or $condition == 1)
306 $regle=1;
307 else
308 $regle=0;
309 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
310 $champvaleur."]";
311 }else{
312 if($champvaleur >= $row['valeur']){
313 $condition = 0;
314
315 }else{
316 $condition = 1;
317 $regle=0;
318 }
319 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
320 $champvaleur."]";
321 }
322 break;
323 case "<" :
324 if($row['sens']=="plus"){
325 if($champvaleur < $row['valeur'])
326 $condition = 1;
327 else
328 $condition = 0;
329 if($regle==1 or $condition == 1)
330 $regle=1;
331 else
332 $regle=0;
333 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
334 $champvaleur."]";
335 }else{
336 if($champvaleur < $row['valeur']){
337 $condition = 0;
338 }else{
339 $condition = 1;
340 $regle=0;
341 }
342 $msg=$msg."<br> et ".$row['message']." [".$row['champ']." = ".
343 $champvaleur."]";
344 }
345 break;
346 case "==":
347 if($row['sens']=="plus"){
348 if($champvaleur == $row['valeur'])
349 $condition = 1;
350 else
351 $condition = 0;
352 if($regle==1 or $condition == 1)
353 $regle=1;
354 else
355 $regle=0;
356 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
357 $champvaleur."]";
358 }else{
359 if($champvaleur == $row['valeur']){
360 $condition = 0;
361
362 }else{
363 $condition = 1;
364 $regle=0;
365 }
366 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
367 $champvaleur."]";
368 }
369 break;
370 //break;
371 } // switch
372 if($regle==0)
373 $this->addToMessage($msg." <br>");
374 } // while
375 } // travaux
376 }//verifier
377
378
379 function setType(&$form,$maj) {
380 parent::setType($form,$maj);
381 if ($maj < 2) { //ajouter et modifier
382 // cache
383 if($maj==0) $form->setType('dossier', 'hidden');
384 $form->setType('annee', 'hidden');
385 $form->setType('parcelle_archive','hidden');
386 $form->setType('parcelle_lot_archive','hidden');
387 $form->setType('objet_dossier','hidden'); // PC
388 $form->setType('amenagement','hidden'); // PC
389 $form->setType('parcelle_lot','hidden'); // PC
390 $form->setType('parcelle_lot_lotissement','hidden'); // PC
391
392 $form->setType('geom1', 'hidden');
393 $form->setType('geom', 'geom');
394 $form->setType('servitude', 'hiddenstatic');
395
396 //select
397 $form->setType('terrain_numero_complement','select');
398
399 // combo
400 $form->setType('rivoli','comboD');
401 $form->setType('terrain_adresse','comboG');
402 $form->setType('architecte_nom','comboG');
403 $form->setType('architecte','comboD');
404
405
406 // hiddenstatic
407 if($maj==1) $form->setType('dossier', 'hiddenstatic');
408 $form->setType('etat','hiddenstatic');
409 $form->setType('avis_decision','hiddenstatic');
410 $form->setType('delai','hiddenstatic');
411 $form->setType('terrain_surface_calcul','hiddenstatic');
412 $form->setType('shon_calcul','hiddenstatic');
413
414 $form->setType('accord_tacite','hiddenstatic');
415 $form->setType('types', 'hiddenstatic'); // transfert modificatif
416
417
418 // hiddenstaticdate
419 $form->setType('date_notification_delai','hiddenstaticdate');
420 $form->setType('date_decision','hiddenstaticdate');
421 $form->setType('date_limite','hiddenstaticdate');
422 $form->setType('date_rejet','hiddenstaticdate');
423 $form->setType('date_complet','hiddenstaticdate');
424 $form->setType('date_limite','hiddenstaticdate');
425 $form->setType('date_validite','hiddenstaticdate');
426 $form->setType('date_chantier','hiddenstaticdate');
427 $form->setType('date_achevement','hiddenstaticdate');
428 $form->setType('date_conformite','hiddenstaticdate');
429
430 // checkbox
431 $form->setType('sig','checkbox');
432 $form->setType('delegataire','checkbox');
433
434 // mail
435 $form->setType('delegataire_email','mail');
436 $form->setType('demandeur_email','mail');
437
438 // zones temp et strategysig
439
440
441 // temp
442 if (file_exists ("../dyn/var.inc"))
443 include ("../dyn/var.inc");
444 if(!isset($auto_pos))
445 $auto_pos=0;
446 if($auto_pos==1)
447 $form->setType('pos','hiddenstatic');
448 else
449 $form->setType('pos','select');
450 $form->setType('temp1',$temp1_type);
451 $form->setType('temp2',$temp2_type);
452 $form->setType('temp3',$temp3_type);
453 $form->setType('temp4',$temp4_type);
454 $form->setType('temp5',$temp5_type);
455 $form->setType('a_qualifier', 'checkbox');
456 }
457 if ($maj == 1) {
458 //
459 if ($this->f->isAccredited("dossier_modifier_instructeur")) {
460 $form->setType('instructeur', 'select');
461 } else {
462 $form->setType('instructeur', 'selecthiddenstatic');
463 }
464 //
465 if($this->f->getParameter('afficher_division') === 'true') {
466 //
467 if ($this->f->isAccredited("dossier_modifier_division")) {
468 $form->setType('division', 'select');
469 } else {
470 $form->setType('division', 'selecthiddenstatic');
471 }
472 } else {
473 $form->setType('division', 'hidden');
474 }
475 }
476 if($maj == 3) {
477 $form->setType('annee', 'hidden');
478 $form->setType('temp1','hidden');
479 $form->setType('temp2','hidden');
480 $form->setType('temp3','hidden');
481 $form->setType('temp4','hidden');
482 $form->setType('temp5','hidden');
483 $form->setType('parcelle_archive','hidden');
484 $form->setType('parcelle_lot_archive','hidden');
485 $form->setType('geom1','hidden');
486 $form->setType('geom','hidden');
487 $form->setType('a_qualifier', 'checkboxstatic');
488 }
489 //
490 if(!$this->f->getParameter('afficher_division') === 'true') {
491 $form->setType('division', 'hidden');
492 }
493 $form->setType('dossier_autorisation', 'hiddenstatic');
494 $form->setType('dossier_instruction_type', 'selectstatic');
495 //
496 if ($maj == 0) {
497 $form->setType('dossier_autorisation', 'select');
498 }
499 // On cache enjeu_ERP si l'option n'est pas activée
500 if($this->f->getParameter('option_ERP') != 'true') {
501 $form->setType('erp', 'hidden');
502 $form->setType('enjeu_erp', 'hidden');
503 }
504 }
505
506 function setVal(&$form,$maj,$validation){
507 $this->maj=$maj;
508 if ($validation==0) {
509 if ($maj == 0){
510 //$dossier_cp = $this->f->collectivite["cp"];
511 //$dossier_ville = $this->f->collectivite["ville"];
512
513 $form->setVal('annee', date('y'));
514 $form->setVal('date_demande', date('Y-m-d'));
515 $form->setVal('date_depot', date('Y-m-d'));
516
517 //$form->setVal('demandeur_cp', $dossier_cp);
518 //$form->setVal('demandeur_ville', $dossier_ville);
519
520 //$form->setVal('delegataire_cp', $dossier_cp);
521 //$form->setVal('delegataire_ville', $dossier_ville);
522
523 //$form->setVal('terrain_cp', $dossier_cp);
524 //$form->setVal('terrain_ville', $dossier_ville);
525
526 $form->setVal('accord_tacite', 'Non');
527 $form->setVal('etat', 'initialiser');
528 $form->setVal('types', 'Initial');
529 }
530 }
531 }
532
533 function setSelect(&$form, $maj,&$db,$debug) {
534 parent::setSelect($form, $maj,$db,$debug);
535 //optimisation sur table importante parcelle -> pas d appel methode parent
536 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
537 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
538 if($maj<2){
539 // travaux
540 $contenu=array();
541 // prise en compte du solde en ajout
542 if($maj==0)
543 $sql_travaux = $sql_travaux.
544 " and solde = 'Non' order by libelle";
545 else
546 $sql_travaux = $sql_travaux.
547 " order by libelle";
548 $res = $db->query($sql_travaux);
549 if (database::isError($res)) die($res->getMessage()).$sql_travaux;
550 $this->addToLog(" la requete ".$sql_travaux." est executee", VERBOSE_MODE);
551 $contenu[0][0]="";
552 $contenu[1][0]=_('choisir')." "._('travaux');
553 $k=1;
554 while ($row=& $res->fetchRow()){
555 $contenu[0][$k]=$row[0];
556 $contenu[1][$k]=$row[1];
557 $k++;
558 }
559 $form->setSelect("travaux",$contenu);
560
561 // code et libelle voie
562 $contenu="";
563 $contenu[0][0]="rivoli";// table
564 $contenu[0][1]="rivoli"; // zone origine
565 $contenu[1][0]="libelle";
566 $contenu[1][1]="terrain_adresse";
567 $form->setSelect("rivoli",$contenu);
568 //terrain_adresse
569 $contenu="";
570 $contenu[0][0]="rivoli";// table
571 $contenu[0][1]="libelle"; // zone origine
572 $contenu[1][0]="rivoli";
573 $contenu[1][1]="rivoli";
574 $form->setSelect("terrain_adresse",$contenu);
575 // code et libelle architecte
576 $contenu="";
577 $contenu[0][0]="architecte";// table
578 $contenu[0][1]="architecte"; // zone origine
579 $contenu[1][0]="nom";
580 $contenu[1][1]="architecte_nom";
581 $form->setSelect("architecte",$contenu);
582 $contenu="";
583 $contenu[0][0]="architecte";// table
584 $contenu[0][1]="nom"; // zone origine
585 $contenu[1][0]="architecte";
586 $contenu[1][1]="architecte";
587 $form->setSelect("architecte_nom",$contenu);
588 // parcelle_lot
589 $contenu="";
590 $contenu[0][0]="parcelle_lot";// table
591 $contenu[0][1]="parcelle_lot"; // zone origine
592 $contenu[1][0]="lotissement";
593 $contenu[1][1]="parcelle_lot_lotissement";
594 $form->setSelect("parcelle_lot",$contenu);
595 $contenu="";
596 $contenu[0][0]="parcelle_lot";// table
597 $contenu[0][1]="lotissement"; // zone origine
598 $contenu[1][0]="parcelle_lot";
599 $contenu[1][1]="parcelle_lot";
600 $form->setSelect("parcelle_lot_lotissement",$contenu);
601 // accord tacite
602 $contenu=array();
603 $contenu[0]=array('Non','Oui');
604 $contenu[1]=array('Non','Oui');
605 $form->setSelect("accord_tacite",$contenu);
606 // terrain_numero_complement
607 $contenu=array();
608 $contenu[0]=array('','bis','ter','quater');
609 $contenu[1]=array('','bis','ter','quater');
610 $form->setSelect("terrain_numero_complement",$contenu);
611 // geom *** a voir
612 if($maj==1){ //modification
613 $contenu=array();
614 $contenu[0]=array("dossier",$this->getParameter("idx"));
615 $form->setSelect('geom',$contenu);
616 }
617 // arrondissement recherche anvancée
618 $this->init_select($form, $db, $maj, $debug, "arrondissement",
619 $sql_arrondissement, $sql_arrondissement_by_id, false);
620 // dossier_autorisation_type_detaille recherche anvancée
621 $this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille",
622 $sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false);
623 /*
624 * Affichage de données dans le select de la parcelle
625 * */
626 $contenu=array();
627 $sql="select parcelle from ".DB_PREFIXE."parcelle ";
628 $res = $db->query($sql);
629 if (database::isError($res))
630 die($res->getMessage());
631 $contenu[0][0]="";
632 $contenu[1][0]=_("choisir parcelle");
633 $k=1;
634 while ($row=& $res->fetchRow()){
635 $contenu[0][$k]=$row[0];
636 $contenu[1][$k]=$row[0];
637 $k++;
638 }
639 $form->setSelect("parcelle",$contenu);
640
641 }
642 if($this->f->getParameter('afficher_division')==='true') {
643 // instructeur
644 $this->init_select($form, $db, $maj, $debug, "instructeur",
645 $sql_instructeur_div, $sql_instructeur_div_by_id, false);
646 }
647 }
648
649 function setLib(&$form,$maj) {
650 parent::setLib($form,$maj);
651 $form->setLib('geom','');
652 }
653
654 function setGroupe(&$form,$maj){
655 //If ($maj==0){
656 // $form->setGroupe('date_demande','D');
657 // $form->setGroupe('date_depot','G');
658 // $form->setGroupe('division','F');
659 //}else{
660 // $form->setGroupe('dossier','D');
661 // $form->setGroupe('annee','G');
662 // $form->setGroupe('date_demande','G');
663 // $form->setGroupe('date_depot','G');
664 // $form->setGroupe('division','F');
665 //}
666 $form->setGroupe('demandeur_categorie','D');
667 $form->setGroupe('demandeur_civilite','G');
668 $form->setGroupe('demandeur_nom','F');
669
670 $form->setGroupe('demandeur_societe','D');
671 $form->setGroupe('demandeur_adresse','G');
672 $form->setGroupe('demandeur_adresse_complement','F');
673
674 $form->setGroupe('demandeur_cp','D');
675 $form->setGroupe('demandeur_ville','G');
676 $form->setGroupe('demandeur_pays','F');
677
678 $form->setGroupe('demandeur_email','D');
679 $form->setGroupe('demandeur_telephone','F');
680
681 $form->setGroupe('delegataire','D');
682 $form->setGroupe('delegataire_civilite','G');
683 $form->setGroupe('delegataire_nom','F');
684
685 $form->setGroupe('delegataire_societe','D');
686 $form->setGroupe('delegataire_adresse','G');
687 $form->setGroupe('delegataire_adresse_complement','F');
688 $form->setGroupe('delegataire_cp','D');
689 $form->setGroupe('delegataire_ville','G');
690 $form->setGroupe('delegataire_pays','F');
691
692 $form->setGroupe('delegataire_email','D');
693 $form->setGroupe('delegataire_telephone','F');
694
695 $form->setGroupe('architecte','D');
696 $form->setGroupe('architecte_nom','F');
697 //$form->setGroupe('saisie_architecte','F');
698
699 $form->setGroupe('travaux','D');
700 $form->setGroupe('travaux_complement','F');
701
702 // terrain
703 $form->setGroupe('terrain_numero','D');
704 $form->setGroupe('terrain_numero_complement','G');
705 $form->setGroupe('rivoli','F');
706 $form->setGroupe('terrain_adresse','D');
707 $form->setGroupe('terrain_adresse_complement','F');
708
709 $form->setGroupe('terrain_cp','D');
710 $form->setGroupe('terrain_ville','F');
711
712 // surface
713 $form->setGroupe('terrain_surface','D');
714 $form->setGroupe('terrain_surface_calcul','F');
715
716 // instruction
717 $form->setGroupe('date_complet','D');
718 $form->setGroupe('date_rejet','G');
719 $form->setGroupe('rejet','G');
720 $form->setGroupe('delai','F');
721
722 $form->setGroupe('date_limite','D');
723 $form->setGroupe('date_notification_delai','G');
724 $form->setGroupe('accord_tacite','G');
725 $form->setGroupe('etat','F');
726
727 $form->setGroupe('date_decision','D');
728 $form->setGroupe('avis_decision','G');
729 $form->setGroupe('date_validite','G');
730 $form->setGroupe('types','F');
731
732 $form->setGroupe('date_chantier','D');
733 $form->setGroupe('date_achevement','G');
734 $form->setGroupe('date_conformite','F');
735
736 // localisation
737 $form->setGroupe('parcelle','D');
738 $form->setGroupe('pos','G');
739 if($maj==1){
740 $form->setGroupe('sig','G');
741 $form->setGroupe('geom','F');
742 }else {
743 $form->setGroupe('sig','F');
744 }
745 if($maj==1){
746 $form->setGroupe('sig','G');
747 $form->setGroupe('geom','F');
748 }
749
750 // description
751 $form->setGroupe('batiment_nombre','D');
752 $form->setGroupe('logement_nombre','G');
753 $form->setGroupe('hauteur','G');
754 $form->setGroupe('piece_nombre','F');
755
756 $form->setGroupe('shon','D');
757 $form->setGroupe('shon_calcul','G');
758 $form->setGroupe('shob','G');
759 $form->setGroupe('lot','F');
760
761 $form->setGroupe('amenagement','D');
762 $form->setGroupe('parcelle_lot','G');
763 $form->setGroupe('parcelle_lot_lotissement','F');
764 }
765
766 function setOnchange(&$form,$maj){
767 parent::setOnchange($form,$maj);
768 // mise en majuscule
769 $form->setOnchange("demandeur_nom","this.value=this.value.toUpperCase()");
770 $form->setOnchange("demandeur_societe","this.value=this.value.toUpperCase()");
771 $form->setOnchange("delegataire_nom","this.value=this.value.toUpperCase()");
772 $form->setOnchange("delegataire_societe","this.value=this.value.toUpperCase()");
773 $form->setOnchange("architecte_nom","this.value=this.value.toUpperCase()");
774 $form->setOnchange("terrain_adresse","this.value=this.value.toUpperCase()");
775 $form->setOnchange('shon','VerifNumdec(this)');
776 $form->setOnchange('shob','VerifNumdec(this)');
777 $form->setOnchange('hauteur','VerifNumdec(this)');
778 $form->setOnchange('terrain_surface','VerifNumdec(this)');
779 }
780
781 function setLayout(&$form, $maj) {
782 //
783 $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
784 $form->setBloc('dossier', 'D', '', 'col_9');
785 $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
786 $form->setFieldset('autorite_competente', 'F');
787 $form->setBloc('autorite_competente', 'F');
788 $form->setBloc('date_demande', 'D', '', 'col_3');
789 $form->setFieldset('date_demande', 'D', _("Depot"));
790 $form->setFieldset('date_depot', 'F');
791 $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
792 $form->setFieldset('enjeu_erp', 'F');
793 $form->setBloc('enjeu_erp', 'F');
794 $form->setBloc('enjeu_erp', 'F');
795 //
796 $form->setBloc('objet_dossier', 'D', '', 'col_12');
797 //
798 $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
799 $form->setRegroupe('date_conformite','F','');
800 //
801 $form->setBloc('terrain_superficie', 'F');
802
803 }
804
805 function setRegroupe(&$form,$maj) {
806 //// depot
807 //If ($maj==0){
808 // $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
809 //}
810 //If ($maj==1){
811 // $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
812 // $form->setRegroupe('date_demande','G','');
813 //}
814 //$form->setRegroupe('date_depot','G','');
815 //$form->setRegroupe('division','F','');
816
817 // travaux
818 $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
819 $form->setRegroupe('architecte_nom','G','');
820 $form->setRegroupe('travaux','G','');
821 $form->setRegroupe('travaux_complement','F','');
822
823 //// instruction
824 //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
825 //$form->setRegroupe('date_rejet','G','');
826 //$form->setRegroupe('date_notification_delai','G','');
827 //$form->setRegroupe('delai','G','');
828 //$form->setRegroupe('date_limite','G','Decision ');
829 //$form->setRegroupe('accord_tacite','G','');
830 //$form->setRegroupe('etat','G','');
831 //$form->setRegroupe('date_decision','G','');
832 //$form->setRegroupe('avis_decision','G','');
833 //$form->setRegroupe('date_validite','G','');
834 //$form->setRegroupe('types','G','');
835 //$form->setRegroupe('date_chantier','G','');
836 //$form->setRegroupe('date_achevement','G','');
837 //$form->setRegroupe('date_conformite','F','');
838
839 // demandeur
840 $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
841 $form->setRegroupe('demandeur_civilite','G','');
842 $form->setRegroupe('demandeur_nom','G','');
843 $form->setRegroupe('demandeur_societe','G','');
844 $form->setRegroupe('demandeur_adresse','G','Decision ');
845 $form->setRegroupe('demandeur_cp','G','');
846 $form->setRegroupe('demandeur_ville','G','');
847 $form->setRegroupe('demandeur_pays','G','');
848 $form->setRegroupe('demandeur_email','G','');
849 $form->setRegroupe('demandeur_telephone','F','');
850
851
852 // delegataire
853 $form->setRegroupe('delegataire','D',_('delegataire'), $this->aff_delegataire);
854 $form->setRegroupe('delegataire_civilite','G','');
855 $form->setRegroupe('delegataire_nom','G','');
856 $form->setRegroupe('delegataire_societe','G','');
857 $form->setRegroupe('delegataire_adresse','G','Decision ');
858 $form->setRegroupe('delegataire_cp','G','');
859 $form->setRegroupe('delegataire_ville','G','');
860 $form->setRegroupe('delegataire_pays','G','');
861 $form->setRegroupe('delegataire_email','G','');
862 $form->setRegroupe('delegataire_telephone','F','');
863
864 // terrain
865 $form->setRegroupe('terrain_numero','D',_('terrain'), $this->aff_terrain);
866 $form->setRegroupe('terrain_numero_complement','G','');
867 $form->setRegroupe('rivoli','G','');
868 $form->setRegroupe('terrain_adresse','G','');
869 $form->setRegroupe('terrain_adresse_complement','G','');
870 $form->setRegroupe('terrain_cp','G','');
871 $form->setRegroupe('terrain_ville','G','');
872 $form->setRegroupe('terrain_surface','G',_('surface'),'');// $this->aff_surface);
873 $form->setRegroupe('terrain_surface_calcul','F','');
874
875 // localisation
876 $form->setRegroupe('parcelle','D',_('localisation'), $this->aff_localisation);
877 $form->setRegroupe('pos','G','');
878 $form->setRegroupe('sig','F','');
879 if($maj==1){
880 $form->setRegroupe('sig','G','');
881 $form->setRegroupe('geom','F','');
882 }
883
884 // description
885 $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);
886 $form->setRegroupe('logement_nombre','G','');
887 $form->setRegroupe('hauteur','G','');
888 $form->setRegroupe('piece_nombre','G','');
889 $form->setRegroupe('shon','G','');
890 $form->setRegroupe('shon_calcul','G','');
891 $form->setRegroupe('shob','G','');
892 $form->setRegroupe('lot','F','');
893
894 $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);
895 $form->setRegroupe('servitude','F','');
896
897 // amenagement
898 $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
899 $form->setRegroupe('parcelle_lot','G','');
900 $form->setRegroupe('parcelle_lot_lotissement','F','');
901
902 }
903
904 /* =============================================================
905 * fonction trigger relative a la connexion SIG
906 * $sig = 1 dans dyn/var.inc
907 * utilisé aussi pour envoyer une message au service REST d'ERP
908 * ===============================================================
909 */
910
911 function triggerajouterapres($id,&$db,$val,$DEBUG) {
912 $this->sig_parametre($db);
913 $id=$this->valF['dossier']; // id n est pas valorise en ajout
914 if($this->sig==1 and $val['sig']!='Oui'){
915 if($val['parcelle']!=''or $val['parcelle_lot']!=''){
916
917 $this->sig_interne($id,$db,$val,$DEBUG);
918 }
919 else
920 $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
921
922 }
923
924
925 if ($this->f->getParameter('option_erp') != "") {
926 // envoi du message a ERP en cas d'un depot du dossier dat
927 if ($this->getDATDCode($this->valF['dossier']) ==
928 $this->f->getParameter('erp_depot_dossier_dat')) {
929 $msgenque = new MessageEnqueuer();
930 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
931 $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
932 }
933
934 // envoi du message a ERP en cas d'une demande d'ouverture DAT
935 if ($this->getDATDCode($this->valF['dossier']) ==
936 $this->f->getParameter('erp_demande_ouverture_dat')) {
937 $msgenque = new MessageEnqueuer();
938 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
939 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
940 }
941
942 if ($this->valF['erp'] === true) {
943 // envoi du message a ERP en cas d'annulation d'une demande
944 if ($this->getDATDCode($this->valF['dossier']) ==
945 $this->f->getParameter('erp_annulation_demande')) {
946 $msgenque = new MessageEnqueuer();
947 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
948 $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
949 }
950
951 // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
952 // au dossier DAACT
953 if ($this->getDATDCode($this->valF['dossier']) ==
954 $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
955 $msgenque = new MessageEnqueuer();
956 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
957 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
958 }
959 }
960 } // fin de if ($this->f->getParameter('option_erp') != "")
961 }
962
963 /*
964 * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
965 * */
966 function getQuartierArrondissement($parcelle) {
967
968 $parcelle = trim($parcelle);
969 $quartier = '';
970
971 /*Récupère le code impot du quartier dans la parcelle*/
972 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
973
974 if (is_numeric($parcelle[$i]) ){
975
976 $quartier .= $parcelle[$i];
977 }
978 else{
979
980 break;
981 }
982 }
983
984 if ( $quartier !== '' ){
985
986 /*identifiant*/
987 $sql = "SELECT
988 quartier, arrondissement
989 FROM
990 ".DB_PREFIXE."quartier
991 WHERE
992 code_impots='$quartier'";
993
994 $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
995 $res = $this->db->query($sql);
996 if (database :: isError($res))
997 die($res->getMessage()."erreur ".$sql);
998
999 if ( $res->numRows() > 0 ){
1000
1001 return $res->fetchRow(DB_FETCHMODE_ASSOC);
1002 }
1003 }
1004
1005 return NULL;
1006 }
1007
1008 /*
1009 * Retourne la section d'une parcelle
1010 * */
1011 function getSection($parcelle){
1012
1013 $parcelle = trim($parcelle);
1014 $section = NULL;
1015
1016 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
1017 if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
1018 $section .= $parcelle[$i];
1019
1020 return $section;
1021 }
1022
1023 /*
1024 * Retourne l'intructeur correspondant le mieux à la parcelle
1025 * */
1026 function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1027
1028 $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1029 $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1030
1031 /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1032 $sql = "
1033 SELECT
1034 dossier_autorisation_type_detaille
1035 FROM
1036 ".DB_PREFIXE."dossier_autorisation
1037 WHERE
1038 dossier_autorisation = '$dossier_autorisation'";
1039
1040 $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1041 $resDATD = $this->db->query($sql);
1042 if (database :: isError($resDATD))
1043 die($resDATD->getMessage()."erreur ".$sql);
1044
1045 if ( $resDATD->numRows() > 0 ){
1046 $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1047
1048 $sql = "
1049 SELECT
1050 instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1051 FROM
1052 ".DB_PREFIXE."affectation_automatique l
1053 WHERE
1054 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1055 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1056 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1057 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1058 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1059 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1060 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1061 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1062 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1063 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1064 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1065 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1066 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1067 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1068 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1069 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1070 ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1071 LIMIT 1
1072 ";
1073
1074 $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1075 $res = $this->db->query($sql);
1076 if (database :: isError($res))
1077 die($res->getMessage()."erreur ".$sql);
1078
1079 if ( $res->numRows() > 0 ){
1080
1081 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1082
1083 $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1084 $res = $this->db->query($sql);
1085 if (database :: isError($res))
1086 die($res->getMessage()."erreur ".$sql);
1087
1088 if ( $res->numRows() > 0 ){
1089
1090 $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1091 $row['division'] = $rowT['division'];
1092 }
1093
1094 return $row;
1095 }
1096 }
1097
1098 return NULL;
1099 }
1100
1101 /* =============================================================
1102 * fonction trigger relative a la connexion SIG
1103 * $sig = 1 dans dyn/var.inc
1104 * ===============================================================
1105 */
1106
1107 function triggerajouter($id,&$db,$val,$DEBUG) {
1108 //
1109 $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
1110
1111 // Initialisation des variables nécessaires à l'affectation automatique
1112 $quartier = NULL;
1113 $arrondissement = NULL;
1114 $section = NULL;
1115 $instructeur = NULL;
1116
1117 // Si la parcelle n'est pas vide alors on récupère la section, le
1118 // quartier et l'arrondissement
1119 if ($val['parcelle'] != '') {
1120 // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
1121 $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
1122 if ( $quartierArrondissement!= NULL ){
1123
1124 $quartier = $quartierArrondissement['quartier'];
1125 $arrondissement = $quartierArrondissement['arrondissement'];
1126 }
1127 // Si il n'y a pas d'arrondissement alors on vide le quartier
1128 if ( strcmp($arrondissement,'') == 0 ) {
1129
1130 $arrondissement = NULL;
1131 $quartier = NULL;
1132 }
1133 // On récupère la section
1134 $section = $this->getSection($val['parcelle']);
1135 }
1136
1137 // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1138 // alors on récupère l'instructeur et la division depuis l'affectation
1139 if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
1140
1141 //
1142 $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1143 if ( $instructeurDivision != NULL ){
1144
1145 $instructeur = $instructeurDivision['instructeur'];
1146 $division = $instructeurDivision['division'];
1147 }
1148
1149 if ( $instructeur != NULL ){
1150
1151 $this->valF['instructeur'] = $instructeur;
1152 $this->valF['division'] = $division;
1153 } else {
1154 if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1155 $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1156 } else {
1157 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1158 }
1159 }
1160 } else {
1161 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1162 }
1163 //
1164 $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
1165 }
1166
1167 function triggermodifierapres($id,&$db,$val,$DEBUG) {
1168 $this->sig_parametre($db);
1169 // si la parcelle est changée
1170 if(($this->sig==1 and $val['sig']!='Oui' and ($val['parcelle']!=$val['parcelle_archive'])
1171 or $val['parcelle_lot']!=$val['parcelle_lot_archive'])){ // parcelle_lot_archive
1172 if($val['parcelle']!='' or $val['parcelle_lot']!='')
1173 $this->sig_interne($this->valF['dossier'],$db,$val,$DEBUG);
1174 else{
1175 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1176 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1177 $res = $db -> query($sql);
1178 $this->addToLog("requete trigger modifier parcelle vide -> maj pos et servitude :".$sql, VERBOSE_MODE);
1179 if (database :: isError($res))
1180 die($res->getMessage()."erreur ".$sql);
1181 }
1182 $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");
1183 }
1184 }
1185
1186 // verification si envoi vers ERP est active
1187 if ($this->f->getParameter('option_erp') != "") {
1188 if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1189 && $this->valF['a_qualifier'] === false) {
1190
1191 // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1192 // de la qualification URBA
1193 if ($this->getDATDCode($this->valF['dossier']) ==
1194 $this->f->getParameter('erp_nature_dat')) {
1195 $msgenque = new MessageEnqueuer();
1196 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1197 $msgenque->setCompetence($this->valF['autorite_competente']);
1198 $msgenque->setContraintePlu($this->valF['servitude']);
1199 $msgenque->setReferenceCadastrale(
1200 $this->getReferenceCadastrale($this->valF['dossier']));
1201 $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);
1202 }
1203
1204 // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1205 // qui etait classifie come ERP
1206 if ($this->getDATDCode($this->valF['dossier']) ==
1207 $this->f->getParameter('erp_dossier_nature_pc')
1208 && $this->valF['erp'] == true) {
1209 $msgenque = new MessageEnqueuer();
1210 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1211 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1212 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1213 }
1214 }
1215 } // fin de if($this->f->getParameter('option_erp'))
1216 }
1217
1218 /**
1219 * Retourne le type de dossier d'autorisation du dossier courant :
1220 * - dossier_autorisation_type_detaille.code
1221 **/
1222 function getDATDCode($idxDossier) {
1223 $sql = "SELECT dossier_autorisation_type_detaille.code
1224 FROM ".DB_PREFIXE."dossier_autorisation_type_detaille
1225 INNER JOIN ".DB_PREFIXE."dossier_autorisation
1226 ON dossier_autorisation_type_detaille.dossier_autorisation_type_detaille =
1227 dossier_autorisation.dossier_autorisation_type_detaille
1228 INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1229 WHERE dossier.dossier = '".$idxDossier."'";
1230 $res = $this -> db -> getOne($sql);
1231 $this->f->isDatabaseError();
1232 $this->addToLog($sql);
1233 return $res;
1234 }
1235
1236
1237 /**
1238 * Retourne la reference cadastrale de la demande attache a un dossier ERP
1239 * specifique
1240 * @param string $dossier L'identifiant du dossier
1241 * @return string|null La reference cadastrale si elle est trouve,
1242 * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1243 */
1244 function getReferenceCadastrale($dossier) {
1245 $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1246 $res = $this->db->limitquery($sql, 0, 1);
1247 $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1248 str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1249 // Si une erreur survient on die
1250 if (database::isError($res, true)) {
1251 // Appel de la methode de recuperation des erreurs
1252 $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1253 }
1254 // retourne la nature du dossier
1255 while ($row =& $res->fetchRow()) {
1256 return $row[0];
1257 }
1258 // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1259 return NULL;
1260 }
1261
1262
1263 function sig_parametre(&$db){
1264 if (file_exists ("../dyn/var.inc"))
1265 include ("../dyn/var.inc");
1266 if(!isset($sig))
1267 $this->sig=0;
1268 else
1269 $this->sig=1;
1270 if(!isset($auto_pos))
1271 $this->auto_pos=0;
1272 else
1273 $this->auto_pos=$auto_pos;
1274 if(!isset($auto_servitude_surfacique))
1275 $this->auto_servitude_surfacique=0;
1276 else
1277 $this->auto_servitude_surfacique=$auto_servitude_surfacique;
1278 if(!isset($auto_servitude_ligne))
1279 $this->auto_servitude_ligne=0;
1280 else
1281 $this->auto_servitude_ligne=$auto_servitude_ligne;
1282 if(!isset($auto_servitude_point))
1283 $this->auto_servitude_point=0;
1284 else
1285 $this->auto_servitude_point=$auto_servitude_point;
1286 if(!isset($auto_parcelle))
1287 $this->auto_parcelle=0;
1288 else
1289 $this->auto_parcelle=$auto_parcelle;
1290 if(!isset($auto_parcelle_lot))
1291 $this->auto_parcelle_lot=0;
1292 else
1293 $this->auto_parcelle_lot=$auto_parcelle_lot;
1294 $this->addToLog("trigger valeur sig :".$this->sig, VERBOSE_MODE);
1295 $this->addToLog("trigger valeur auto_pos :". $this->auto_pos, VERBOSE_MODE);
1296 $this->addToLog("trigger valeur auto_servitude_surfacique :".$this->auto_servitude_surfacique, VERBOSE_MODE);
1297 $this->addToLog("trigger valeur auto_servitude_ligne :". $this->auto_servitude_ligne, VERBOSE_MODE);
1298 $this->addToLog("trigger valeur auto_servitude_point :".$this->auto_servitude_point, VERBOSE_MODE);
1299 $this->addToLog("trigger valeur auto_parcelle :". $this->auto_parcelle, VERBOSE_MODE);
1300 $this->addToLog("trigger valeur auto_parcelle_lot :".$this->auto_parcelle_lot, VERBOSE_MODE);
1301 }
1302
1303
1304 function sig_interne($id,&$db,$val,$DEBUG){
1305 // Strategy interne dans var.inc
1306 // si la parcelle existe, il est cree un point au milieu de la parcelle
1307 // de maniere automatique
1308 $geom='';
1309 $parcelle=$val["parcelle"];
1310 $projection = $db -> getOne("select srid from geometry_columns where f_table_name='dossier'");
1311 if($this->auto_parcelle==1 and $val["parcelle"]!=''){
1312 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle where parcelle ='".$val["parcelle"]."'";
1313 $this->addToLog("recherche centroid parcelle :".$sql, VERBOSE_MODE);
1314 $geom = $db -> getOne($sql);
1315 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1316 }
1317 if($geom=='' and $this->auto_parcelle_lot==1 and $val["parcelle_lot"]!=''){ // lot
1318 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle_lot where parcelle_lot ='".$val["parcelle_lot"]."'";
1319 $this->addToLog("recherche centroid parcelle lot :".$sql, VERBOSE_MODE);
1320 $geom = $db -> getOne($sql);
1321 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1322 $parcelle=$val["parcelle_lot"]." ".$val["parcelle_lot_lotissement"];
1323 }
1324 if($geom!=''){ // la parcelle est exitante dans la table ou vue parcelle
1325 $sql ="update ".DB_PREFIXE."dossier set geom =geometryfromtext('".$geom."', ".$projection." ) where dossier ='".$id."'";
1326 $this->addToLog("sig_interne maj geom :".$sql, VERBOSE_MODE);
1327 $res = $db -> query($sql);
1328 if (database :: isError($res)) die($res->getMessage()."erreur ".$sql);
1329 $this->addToMessage(""._("centroid de parcelle calcule")." ".$parcelle." ");
1330 if($this->auto_pos==1) // recherche du pos
1331 $this->calcul_auto_pos($id,$db,$geom,$projection);
1332 if($this->auto_servitude_surfacique==1) // recherche de servitude surfacique
1333 $this->calcul_auto_servitude_surfacique($id,$db,$geom,$projection);
1334 if($this->auto_servitude_ligne==1) // recherche de servitude ligne
1335 $this->calcul_auto_servitude_ligne($id,$db,$geom,$projection);
1336 if($this->auto_servitude_point==1) // recherche de servitude point
1337 $this->calcul_auto_servitude_point($id,$db,$geom,$projection);
1338 $temp=strtr($this->servitude,"'"," "); // enleve le '
1339 $sql1 ="update ".DB_PREFIXE."dossier set servitude = '".$temp."' where dossier = '".$id."'";
1340 $res1 = $db -> query($sql1);
1341 $this->addToLog("maj servitudes :".$sql1, VERBOSE_MODE);
1342 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1343 }else{ // parcelle inexistante //***
1344 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1345 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1346 $res = $db -> query($sql);
1347 $this->addToLog("requete sig_interne maj parcelle inexistante :".$sql, VERBOSE_MODE);
1348 if (database :: isError($res))
1349 die($res->getMessage()."erreur ".$sql);
1350 }
1351 //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
1352 }
1353 }
1354
1355 function calcul_auto_pos($id,&$db,$geom,$projection){
1356 // recherche du pos automatique
1357 $sql="select pos from ".DB_PREFIXE."pos WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
1358 $pos = $db -> getOne($sql);
1359 $this->addToLog("recherche auto_pos :".$sql, VERBOSE_MODE);
1360 if($pos!=''){
1361 $sql1 ="update ".DB_PREFIXE."dossier set pos = '".$pos."' where dossier = '".$id."'";
1362 $res1 = $db -> query($sql1);
1363 $this->addToLog("maj auto_pos :".$sql1, VERBOSE_MODE);
1364 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1365 $this->addToMessage("<br>"._("POS/PLU")." : ".$pos."");
1366 }else{
1367 $this->addToMessage("<br>"._("POS/PLU non trouve")." ".$id."");
1368 }
1369 }
1370
1371 function calcul_auto_servitude_surfacique($id,&$db,$geom,$projection){
1372 // recherche servitude surfacique
1373 $sql="select * from ".DB_PREFIXE."servitude_surfacique WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
1374 $res=$db->query($sql);
1375 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1376 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1377 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1378 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1379 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
1380 }
1381 }
1382
1383 function calcul_auto_servitude_ligne($id,&$db,$geom,$projection){
1384 // recherche servitude ligne
1385 $sql="select * from ".DB_PREFIXE."servitude_ligne WHERE ST_contains(ST_buffer(geom, perimetre), geometryfromtext('".$geom."', ".$projection."))";
1386 $res=$db->query($sql);
1387 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1388 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1389 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1390 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1391 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
1392 }
1393 }
1394
1395 function calcul_auto_servitude_point($id,&$db,$geom,$projection){
1396 // recherche servitude point
1397 $sql="select libelle,observation, perimetre, distance(geom, geometryfromtext('".$geom."', ".$projection.")) as distance from ".
1398 DB_PREFIXE."servitude_point WHERE distance(geom, geometryfromtext('".$geom."', ".$projection."))<perimetre";
1399 $res=$db->query($sql);
1400 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1401 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1402 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1403 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']." a ".round($row['distance'],2)." m ");
1404 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
1405 }
1406 }
1407 }// fin classe
1408 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26