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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1023 - (show annotations)
Fri Dec 7 17:08:36 2012 UTC (12 years, 1 month ago) by nhaye
File size: 61591 byte(s)
Modification de la recherche sur dossiers existants :
recherche maintenant sur les dossiers d'instruction,
correction de la requète des dossiers d'instruction,
modification de l'entrée de menu.

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 function verifier($val,&$db,$DEBUG){
253 parent::verifier($val,$db,$DEBUG);
254 if($val['parcelle']!="" and $val['sig']!='Oui'){
255 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'])){
256 $this->correct=false;
257 $this->addToMessage("<br>format parcelle incorrect");
258 }
259 }
260 // regles travaux verification
261 if ($this->valF['travaux']!=""){
262 $sql= "select * from ".DB_PREFIXE."regle where id = '".$this->valF['travaux'].
263 "' and controle = 'travaux' order by ordre";
264 $res = $db->query($sql);
265 if (database :: isError($res)) die($res->getMessage().$sql);
266 $this->addToLog("requete ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
267 $regle=0;
268 $msg="";
269 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
270 if(isset($this->valF[$row['champ']]))
271 $champvaleur=$this->valF[$row['champ']];
272 else
273 $champvaleur=0;
274 switch ($row['operateur']) {
275 case ">" :
276 if($row['sens']=="plus"){
277 if($champvaleur > $row['valeur'])
278 $condition = 1;
279 else
280 $condition = 0;
281 if($regle==1 or $condition == 1)
282 $regle=1;
283 else
284 $regle=0;
285 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
286 $champvaleur."]";
287 }else{
288 if($champvaleur > $row['valeur']){
289 $condition = 0;
290 }else{
291 $condition = 1;
292 $regle=0;
293 }
294 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
295 $champvaleur."]";
296 }
297 break;
298 case ">=":
299 if($row['sens']=="plus"){
300 if($champvaleur >= $row['valeur'])
301 $condition = 1;
302 else
303 $condition = 0;
304 if($regle==1 or $condition == 1)
305 $regle=1;
306 else
307 $regle=0;
308 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
309 $champvaleur."]";
310 }else{
311 if($champvaleur >= $row['valeur']){
312 $condition = 0;
313
314 }else{
315 $condition = 1;
316 $regle=0;
317 }
318 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
319 $champvaleur."]";
320 }
321 break;
322 case "<" :
323 if($row['sens']=="plus"){
324 if($champvaleur < $row['valeur'])
325 $condition = 1;
326 else
327 $condition = 0;
328 if($regle==1 or $condition == 1)
329 $regle=1;
330 else
331 $regle=0;
332 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
333 $champvaleur."]";
334 }else{
335 if($champvaleur < $row['valeur']){
336 $condition = 0;
337 }else{
338 $condition = 1;
339 $regle=0;
340 }
341 $msg=$msg."<br> et ".$row['message']." [".$row['champ']." = ".
342 $champvaleur."]";
343 }
344 break;
345 case "==":
346 if($row['sens']=="plus"){
347 if($champvaleur == $row['valeur'])
348 $condition = 1;
349 else
350 $condition = 0;
351 if($regle==1 or $condition == 1)
352 $regle=1;
353 else
354 $regle=0;
355 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
356 $champvaleur."]";
357 }else{
358 if($champvaleur == $row['valeur']){
359 $condition = 0;
360
361 }else{
362 $condition = 1;
363 $regle=0;
364 }
365 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
366 $champvaleur."]";
367 }
368 break;
369 //break;
370 } // switch
371 if($regle==0)
372 $this->addToMessage($msg." <br>");
373 } // while
374 } // travaux
375 }//verifier
376
377
378 function setType(&$form,$maj) {
379 parent::setType($form,$maj);
380 if ($maj < 2) { //ajouter et modifier
381 // cache
382 if($maj==0) $form->setType('dossier', 'hidden');
383 $form->setType('annee', 'hidden');
384 $form->setType('nature', 'select');
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('nature', 'selectstatic');
479 $form->setType('temp1','hidden');
480 $form->setType('temp2','hidden');
481 $form->setType('temp3','hidden');
482 $form->setType('temp4','hidden');
483 $form->setType('temp5','hidden');
484 $form->setType('parcelle_archive','hidden');
485 $form->setType('parcelle_lot_archive','hidden');
486 $form->setType('geom1','hidden');
487 $form->setType('geom','hidden');
488 $form->setType('a_qualifier', 'checkboxstatic');
489 }
490 //
491 if(!$this->f->getParameter('afficher_division') === 'true') {
492 $form->setType('division', 'hidden');
493 }
494 $form->setType('dossier_autorisation', 'hiddenstatic');
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 //$form->setVal('nature', $this->nature);
513
514 $form->setVal('annee', date('y'));
515 $form->setVal('date_demande', date('Y-m-d'));
516 $form->setVal('date_depot', date('Y-m-d'));
517
518 //$form->setVal('demandeur_cp', $dossier_cp);
519 //$form->setVal('demandeur_ville', $dossier_ville);
520
521 //$form->setVal('delegataire_cp', $dossier_cp);
522 //$form->setVal('delegataire_ville', $dossier_ville);
523
524 //$form->setVal('terrain_cp', $dossier_cp);
525 //$form->setVal('terrain_ville', $dossier_ville);
526
527 $form->setVal('accord_tacite', 'Non');
528 $form->setVal('etat', 'initialiser');
529 $form->setVal('types', 'Initial');
530 }
531 }
532 }
533
534 function setSelect(&$form, $maj,&$db,$debug) {
535 parent::setSelect($form, $maj,$db,$debug);
536 //optimisation sur table importante parcelle -> pas d appel methode parent
537 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
538 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
539 if($maj<2){
540 // travaux
541 $contenu=array();
542 // prise en compte du solde en ajout
543 if($maj==0)
544 $sql_travaux = $sql_travaux.
545 " and solde = 'Non' order by libelle";
546 else
547 $sql_travaux = $sql_travaux.
548 " order by libelle";
549 $res = $db->query($sql_travaux);
550 if (database::isError($res)) die($res->getMessage()).$sql_travaux;
551 $this->addToLog(" la requete ".$sql_travaux." est executee", VERBOSE_MODE);
552 $contenu[0][0]="";
553 $contenu[1][0]=_('choisir')." "._('travaux');
554 $k=1;
555 while ($row=& $res->fetchRow()){
556 $contenu[0][$k]=$row[0];
557 $contenu[1][$k]=$row[1];
558 $k++;
559 }
560 $form->setSelect("travaux",$contenu);
561
562 // code et libelle voie
563 $contenu="";
564 $contenu[0][0]="rivoli";// table
565 $contenu[0][1]="rivoli"; // zone origine
566 $contenu[1][0]="libelle";
567 $contenu[1][1]="terrain_adresse";
568 $form->setSelect("rivoli",$contenu);
569 //terrain_adresse
570 $contenu="";
571 $contenu[0][0]="rivoli";// table
572 $contenu[0][1]="libelle"; // zone origine
573 $contenu[1][0]="rivoli";
574 $contenu[1][1]="rivoli";
575 $form->setSelect("terrain_adresse",$contenu);
576 // code et libelle architecte
577 $contenu="";
578 $contenu[0][0]="architecte";// table
579 $contenu[0][1]="architecte"; // zone origine
580 $contenu[1][0]="nom";
581 $contenu[1][1]="architecte_nom";
582 $form->setSelect("architecte",$contenu);
583 $contenu="";
584 $contenu[0][0]="architecte";// table
585 $contenu[0][1]="nom"; // zone origine
586 $contenu[1][0]="architecte";
587 $contenu[1][1]="architecte";
588 $form->setSelect("architecte_nom",$contenu);
589 // parcelle_lot
590 $contenu="";
591 $contenu[0][0]="parcelle_lot";// table
592 $contenu[0][1]="parcelle_lot"; // zone origine
593 $contenu[1][0]="lotissement";
594 $contenu[1][1]="parcelle_lot_lotissement";
595 $form->setSelect("parcelle_lot",$contenu);
596 $contenu="";
597 $contenu[0][0]="parcelle_lot";// table
598 $contenu[0][1]="lotissement"; // zone origine
599 $contenu[1][0]="parcelle_lot";
600 $contenu[1][1]="parcelle_lot";
601 $form->setSelect("parcelle_lot_lotissement",$contenu);
602 // accord tacite
603 $contenu=array();
604 $contenu[0]=array('Non','Oui');
605 $contenu[1]=array('Non','Oui');
606 $form->setSelect("accord_tacite",$contenu);
607 // terrain_numero_complement
608 $contenu=array();
609 $contenu[0]=array('','bis','ter','quater');
610 $contenu[1]=array('','bis','ter','quater');
611 $form->setSelect("terrain_numero_complement",$contenu);
612 // geom *** a voir
613 if($maj==1){ //modification
614 $contenu=array();
615 $contenu[0]=array("dossier",$this->getParameter("idx"));
616 $form->setSelect('geom',$contenu);
617 }
618 // arrondissement recherche anvancée
619 $this->init_select($form, $db, $maj, $debug, "arrondissement",
620 $sql_arrondissement, $sql_arrondissement_by_id, false);
621 // dossier_autorisation_type_detaille recherche anvancée
622 $this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille",
623 $sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false);
624 /*
625 * Affichage de données dans le select de la parcelle
626 * */
627 $contenu=array();
628 $sql="select parcelle from ".DB_PREFIXE."parcelle ";
629 $res = $db->query($sql);
630 if (database::isError($res))
631 die($res->getMessage());
632 $contenu[0][0]="";
633 $contenu[1][0]=_("choisir parcelle");
634 $k=1;
635 while ($row=& $res->fetchRow()){
636 $contenu[0][$k]=$row[0];
637 $contenu[1][$k]=$row[0];
638 $k++;
639 }
640 $form->setSelect("parcelle",$contenu);
641
642 }
643 if($this->f->getParameter('afficher_division')==='true') {
644 // instructeur
645 $this->init_select($form, $db, $maj, $debug, "instructeur",
646 $sql_instructeur_div, $sql_instructeur_div_by_id, false);
647 }
648 }
649
650 function setLib(&$form,$maj) {
651 parent::setLib($form,$maj);
652 $form->setLib('geom','');
653 }
654
655 function setGroupe(&$form,$maj){
656 //If ($maj==0){
657 // $form->setGroupe('date_demande','D');
658 // $form->setGroupe('date_depot','G');
659 // $form->setGroupe('division','F');
660 //}else{
661 // $form->setGroupe('dossier','D');
662 // $form->setGroupe('nature','G');
663 // $form->setGroupe('annee','G');
664 // $form->setGroupe('date_demande','G');
665 // $form->setGroupe('date_depot','G');
666 // $form->setGroupe('division','F');
667 //}
668 $form->setGroupe('demandeur_categorie','D');
669 $form->setGroupe('demandeur_civilite','G');
670 $form->setGroupe('demandeur_nom','F');
671
672 $form->setGroupe('demandeur_societe','D');
673 $form->setGroupe('demandeur_adresse','G');
674 $form->setGroupe('demandeur_adresse_complement','F');
675
676 $form->setGroupe('demandeur_cp','D');
677 $form->setGroupe('demandeur_ville','G');
678 $form->setGroupe('demandeur_pays','F');
679
680 $form->setGroupe('demandeur_email','D');
681 $form->setGroupe('demandeur_telephone','F');
682
683 $form->setGroupe('delegataire','D');
684 $form->setGroupe('delegataire_civilite','G');
685 $form->setGroupe('delegataire_nom','F');
686
687 $form->setGroupe('delegataire_societe','D');
688 $form->setGroupe('delegataire_adresse','G');
689 $form->setGroupe('delegataire_adresse_complement','F');
690 $form->setGroupe('delegataire_cp','D');
691 $form->setGroupe('delegataire_ville','G');
692 $form->setGroupe('delegataire_pays','F');
693
694 $form->setGroupe('delegataire_email','D');
695 $form->setGroupe('delegataire_telephone','F');
696
697 $form->setGroupe('architecte','D');
698 $form->setGroupe('architecte_nom','F');
699 //$form->setGroupe('saisie_architecte','F');
700
701 $form->setGroupe('travaux','D');
702 $form->setGroupe('travaux_complement','F');
703
704 // terrain
705 $form->setGroupe('terrain_numero','D');
706 $form->setGroupe('terrain_numero_complement','G');
707 $form->setGroupe('rivoli','F');
708 $form->setGroupe('terrain_adresse','D');
709 $form->setGroupe('terrain_adresse_complement','F');
710
711 $form->setGroupe('terrain_cp','D');
712 $form->setGroupe('terrain_ville','F');
713
714 // surface
715 $form->setGroupe('terrain_surface','D');
716 $form->setGroupe('terrain_surface_calcul','F');
717
718 // instruction
719 $form->setGroupe('date_complet','D');
720 $form->setGroupe('date_rejet','G');
721 $form->setGroupe('rejet','G');
722 $form->setGroupe('delai','F');
723
724 $form->setGroupe('date_limite','D');
725 $form->setGroupe('date_notification_delai','G');
726 $form->setGroupe('accord_tacite','G');
727 $form->setGroupe('etat','F');
728
729 $form->setGroupe('date_decision','D');
730 $form->setGroupe('avis_decision','G');
731 $form->setGroupe('date_validite','G');
732 $form->setGroupe('types','F');
733
734 $form->setGroupe('date_chantier','D');
735 $form->setGroupe('date_achevement','G');
736 $form->setGroupe('date_conformite','F');
737
738 // localisation
739 $form->setGroupe('parcelle','D');
740 $form->setGroupe('pos','G');
741 if($maj==1){
742 $form->setGroupe('sig','G');
743 $form->setGroupe('geom','F');
744 }else {
745 $form->setGroupe('sig','F');
746 }
747 if($maj==1){
748 $form->setGroupe('sig','G');
749 $form->setGroupe('geom','F');
750 }
751
752 // description
753 $form->setGroupe('batiment_nombre','D');
754 $form->setGroupe('logement_nombre','G');
755 $form->setGroupe('hauteur','G');
756 $form->setGroupe('piece_nombre','F');
757
758 $form->setGroupe('shon','D');
759 $form->setGroupe('shon_calcul','G');
760 $form->setGroupe('shob','G');
761 $form->setGroupe('lot','F');
762
763 $form->setGroupe('amenagement','D');
764 $form->setGroupe('parcelle_lot','G');
765 $form->setGroupe('parcelle_lot_lotissement','F');
766 }
767
768 function setOnchange(&$form,$maj){
769 parent::setOnchange($form,$maj);
770 // mise en majuscule
771 $form->setOnchange("demandeur_nom","this.value=this.value.toUpperCase()");
772 $form->setOnchange("demandeur_societe","this.value=this.value.toUpperCase()");
773 $form->setOnchange("delegataire_nom","this.value=this.value.toUpperCase()");
774 $form->setOnchange("delegataire_societe","this.value=this.value.toUpperCase()");
775 $form->setOnchange("architecte_nom","this.value=this.value.toUpperCase()");
776 $form->setOnchange("terrain_adresse","this.value=this.value.toUpperCase()");
777 $form->setOnchange('shon','VerifNumdec(this)');
778 $form->setOnchange('shob','VerifNumdec(this)');
779 $form->setOnchange('hauteur','VerifNumdec(this)');
780 $form->setOnchange('terrain_surface','VerifNumdec(this)');
781 }
782
783 function setLayout(&$form, $maj) {
784 //
785 $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
786 $form->setBloc('dossier', 'D', '', 'col_9');
787 $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
788 $form->setFieldset('autorite_competente', 'F');
789 $form->setBloc('autorite_competente', 'F');
790 $form->setBloc('date_demande', 'D', '', 'col_3');
791 $form->setFieldset('date_demande', 'D', _("Depot"));
792 $form->setFieldset('date_depot', 'F');
793 $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
794 $form->setFieldset('enjeu_erp', 'F');
795 $form->setBloc('enjeu_erp', 'F');
796 $form->setBloc('enjeu_erp', 'F');
797 //
798 $form->setBloc('objet_dossier', 'D', '', 'col_12');
799 //
800 $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
801 $form->setRegroupe('date_conformite','F','');
802 //
803 $form->setBloc('terrain_superficie', 'F');
804
805 }
806
807 function setRegroupe(&$form,$maj) {
808 //// depot
809 //If ($maj==0){
810 // $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
811 //}
812 //If ($maj==1){
813 // $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
814 // $form->setRegroupe('date_demande','G','');
815 //}
816 //$form->setRegroupe('date_depot','G','');
817 //$form->setRegroupe('division','F','');
818
819 // travaux
820 $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
821 $form->setRegroupe('architecte_nom','G','');
822 $form->setRegroupe('travaux','G','');
823 $form->setRegroupe('travaux_complement','F','');
824
825 //// instruction
826 //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
827 //$form->setRegroupe('date_rejet','G','');
828 //$form->setRegroupe('date_notification_delai','G','');
829 //$form->setRegroupe('delai','G','');
830 //$form->setRegroupe('date_limite','G','Decision ');
831 //$form->setRegroupe('accord_tacite','G','');
832 //$form->setRegroupe('etat','G','');
833 //$form->setRegroupe('date_decision','G','');
834 //$form->setRegroupe('avis_decision','G','');
835 //$form->setRegroupe('date_validite','G','');
836 //$form->setRegroupe('types','G','');
837 //$form->setRegroupe('date_chantier','G','');
838 //$form->setRegroupe('date_achevement','G','');
839 //$form->setRegroupe('date_conformite','F','');
840
841 // demandeur
842 $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
843 $form->setRegroupe('demandeur_civilite','G','');
844 $form->setRegroupe('demandeur_nom','G','');
845 $form->setRegroupe('demandeur_societe','G','');
846 $form->setRegroupe('demandeur_adresse','G','Decision ');
847 $form->setRegroupe('demandeur_cp','G','');
848 $form->setRegroupe('demandeur_ville','G','');
849 $form->setRegroupe('demandeur_pays','G','');
850 $form->setRegroupe('demandeur_email','G','');
851 $form->setRegroupe('demandeur_telephone','F','');
852
853
854 // delegataire
855 $form->setRegroupe('delegataire','D',_('delegataire'), $this->aff_delegataire);
856 $form->setRegroupe('delegataire_civilite','G','');
857 $form->setRegroupe('delegataire_nom','G','');
858 $form->setRegroupe('delegataire_societe','G','');
859 $form->setRegroupe('delegataire_adresse','G','Decision ');
860 $form->setRegroupe('delegataire_cp','G','');
861 $form->setRegroupe('delegataire_ville','G','');
862 $form->setRegroupe('delegataire_pays','G','');
863 $form->setRegroupe('delegataire_email','G','');
864 $form->setRegroupe('delegataire_telephone','F','');
865
866 // terrain
867 $form->setRegroupe('terrain_numero','D',_('terrain'), $this->aff_terrain);
868 $form->setRegroupe('terrain_numero_complement','G','');
869 $form->setRegroupe('rivoli','G','');
870 $form->setRegroupe('terrain_adresse','G','');
871 $form->setRegroupe('terrain_adresse_complement','G','');
872 $form->setRegroupe('terrain_cp','G','');
873 $form->setRegroupe('terrain_ville','G','');
874 $form->setRegroupe('terrain_surface','G',_('surface'),'');// $this->aff_surface);
875 $form->setRegroupe('terrain_surface_calcul','F','');
876
877 // localisation
878 $form->setRegroupe('parcelle','D',_('localisation'), $this->aff_localisation);
879 $form->setRegroupe('pos','G','');
880 $form->setRegroupe('sig','F','');
881 if($maj==1){
882 $form->setRegroupe('sig','G','');
883 $form->setRegroupe('geom','F','');
884 }
885
886 // description
887 $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);
888 $form->setRegroupe('logement_nombre','G','');
889 $form->setRegroupe('hauteur','G','');
890 $form->setRegroupe('piece_nombre','G','');
891 $form->setRegroupe('shon','G','');
892 $form->setRegroupe('shon_calcul','G','');
893 $form->setRegroupe('shob','G','');
894 $form->setRegroupe('lot','F','');
895
896 $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);
897 $form->setRegroupe('servitude','F','');
898
899 // amenagement
900 $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
901 $form->setRegroupe('parcelle_lot','G','');
902 $form->setRegroupe('parcelle_lot_lotissement','F','');
903
904 }
905
906 /* =============================================================
907 * fonction trigger relative a la connexion SIG
908 * $sig = 1 dans dyn/var.inc
909 * utilisé aussi pour envoyer une message au service REST d'ERP
910 * ===============================================================
911 */
912
913 function triggerajouterapres($id,&$db,$val,$DEBUG) {
914 $this->sig_parametre($db);
915 $id=$this->valF['dossier']; // id n est pas valorise en ajout
916 if($this->sig==1 and $val['sig']!='Oui'){
917 if($val['parcelle']!=''or $val['parcelle_lot']!=''){
918
919 $this->sig_interne($id,$db,$val,$DEBUG);
920 }
921 else
922 $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
923
924 }
925
926
927 if ($this->f->getParameter('option_erp') != "") {
928 // envoi du message a ERP en cas d'un depot du dossier dat
929 if ($this->valF['nature'] ==
930 $this->f->getParameter('erp_depot_dossier_dat')) {
931 $msgenque = new MessageEnqueuer();
932 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
933 $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
934 }
935
936 // envoi du message a ERP en cas d'une demande d'ouverture DAT
937 if ($this->valF['nature'] ==
938 $this->f->getParameter('erp_demande_ouverture_dat')) {
939 $msgenque = new MessageEnqueuer();
940 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
941 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
942 }
943
944 if ($this->valF['erp'] === true) {
945 // envoi du message a ERP en cas d'annulation d'une demande
946 if ($this->valF['nature'] ==
947 $this->f->getParameter('erp_annulation_demande')) {
948 $msgenque = new MessageEnqueuer();
949 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
950 $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
951 }
952
953 // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
954 // au dossier DAACT
955 if ($this->valF['nature'] ==
956 $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
957 $msgenque = new MessageEnqueuer();
958 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
959 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
960 }
961 }
962 } // fin de if ($this->f->getParameter('option_erp') != "")
963 }
964
965 /*
966 * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
967 * */
968 function getQuartierArrondissement($parcelle) {
969
970 $parcelle = trim($parcelle);
971 $quartier = '';
972
973 /*Récupère le code impot du quartier dans la parcelle*/
974 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
975
976 if (is_numeric($parcelle[$i]) ){
977
978 $quartier .= $parcelle[$i];
979 }
980 else{
981
982 break;
983 }
984 }
985
986 if ( $quartier !== '' ){
987
988 /*identifiant*/
989 $sql = "SELECT
990 quartier, arrondissement
991 FROM
992 ".DB_PREFIXE."quartier
993 WHERE
994 code_impots='$quartier'";
995
996 $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
997 $res = $this->db->query($sql);
998 if (database :: isError($res))
999 die($res->getMessage()."erreur ".$sql);
1000
1001 if ( $res->numRows() > 0 ){
1002
1003 return $res->fetchRow(DB_FETCHMODE_ASSOC);
1004 }
1005 }
1006
1007 return NULL;
1008 }
1009
1010 /*
1011 * Retourne la section d'une parcelle
1012 * */
1013 function getSection($parcelle){
1014
1015 $parcelle = trim($parcelle);
1016 $section = NULL;
1017
1018 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
1019 if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
1020 $section .= $parcelle[$i];
1021
1022 return $section;
1023 }
1024
1025 /*
1026 * Retourne l'intructeur correspondant le mieux à la parcelle
1027 * */
1028 function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1029
1030 $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1031 $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1032
1033 /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1034 $sql = "
1035 SELECT
1036 dossier_autorisation_type_detaille
1037 FROM
1038 ".DB_PREFIXE."dossier_autorisation
1039 WHERE
1040 dossier_autorisation = '$dossier_autorisation'";
1041
1042 $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1043 $resDATD = $this->db->query($sql);
1044 if (database :: isError($resDATD))
1045 die($resDATD->getMessage()."erreur ".$sql);
1046
1047 if ( $resDATD->numRows() > 0 ){
1048 $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1049
1050 $sql = "
1051 SELECT
1052 instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1053 FROM
1054 ".DB_PREFIXE."affectation_automatique l
1055 WHERE
1056 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1057 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1058 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1059 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1060 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1061 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1062 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1063 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1064 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1065 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1066 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1067 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1068 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1069 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1070 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1071 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1072 ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1073 LIMIT 1
1074 ";
1075
1076 $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1077 $res = $this->db->query($sql);
1078 if (database :: isError($res))
1079 die($res->getMessage()."erreur ".$sql);
1080
1081 if ( $res->numRows() > 0 ){
1082
1083 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1084
1085 $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1086 $res = $this->db->query($sql);
1087 if (database :: isError($res))
1088 die($res->getMessage()."erreur ".$sql);
1089
1090 if ( $res->numRows() > 0 ){
1091
1092 $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1093 $row['division'] = $rowT['division'];
1094 }
1095
1096 return $row;
1097 }
1098 }
1099
1100 return NULL;
1101 }
1102
1103 /* =============================================================
1104 * fonction trigger relative a la connexion SIG
1105 * $sig = 1 dans dyn/var.inc
1106 * ===============================================================
1107 */
1108
1109 function triggerajouter($id,&$db,$val,$DEBUG) {
1110 //
1111 $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
1112
1113 // Initialisation des variables nécessaires à l'affectation automatique
1114 $quartier = NULL;
1115 $arrondissement = NULL;
1116 $section = NULL;
1117 $instructeur = NULL;
1118
1119 // Si la parcelle n'est pas vide alors on récupère la section, le
1120 // quartier et l'arrondissement
1121 if ($val['parcelle'] != '') {
1122 // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
1123 $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
1124 if ( $quartierArrondissement!= NULL ){
1125
1126 $quartier = $quartierArrondissement['quartier'];
1127 $arrondissement = $quartierArrondissement['arrondissement'];
1128 }
1129 // Si il n'y a pas d'arrondissement alors on vide le quartier
1130 if ( strcmp($arrondissement,'') == 0 ) {
1131
1132 $arrondissement = NULL;
1133 $quartier = NULL;
1134 }
1135 // On récupère la section
1136 $section = $this->getSection($val['parcelle']);
1137 }
1138
1139 // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1140 // alors on récupère l'instructeur et la division depuis l'affectation
1141 if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
1142
1143 //
1144 $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1145 if ( $instructeurDivision != NULL ){
1146
1147 $instructeur = $instructeurDivision['instructeur'];
1148 $division = $instructeurDivision['division'];
1149 }
1150
1151 if ( $instructeur != NULL ){
1152
1153 $this->valF['instructeur'] = $instructeur;
1154 $this->valF['division'] = $division;
1155 } else {
1156 if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1157 $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1158 } else {
1159 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1160 }
1161 }
1162 } else {
1163 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1164 }
1165 //
1166 $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
1167 }
1168
1169 function triggermodifierapres($id,&$db,$val,$DEBUG) {
1170 $this->sig_parametre($db);
1171 // si la parcelle est changée
1172 if(($this->sig==1 and $val['sig']!='Oui' and ($val['parcelle']!=$val['parcelle_archive'])
1173 or $val['parcelle_lot']!=$val['parcelle_lot_archive'])){ // parcelle_lot_archive
1174 if($val['parcelle']!='' or $val['parcelle_lot']!='')
1175 $this->sig_interne($this->valF['dossier'],$db,$val,$DEBUG);
1176 else{
1177 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1178 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1179 $res = $db -> query($sql);
1180 $this->addToLog("requete trigger modifier parcelle vide -> maj pos et servitude :".$sql, VERBOSE_MODE);
1181 if (database :: isError($res))
1182 die($res->getMessage()."erreur ".$sql);
1183 }
1184 $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");
1185 }
1186 }
1187
1188 // verification si envoi vers ERP est active
1189 if ($this->f->getParameter('option_erp') != "") {
1190 if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1191 && $this->valF['a_qualifier'] === false) {
1192
1193 // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1194 // de la qualification URBA
1195 if ($this->valF['nature'] ==
1196 $this->f->getParameter('erp_nature_dat')) {
1197 $msgenque = new MessageEnqueuer();
1198 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1199 $msgenque->setCompetence($this->valF['autorite_competente']);
1200 $msgenque->setContraintePlu($this->valF['servitude']);
1201 $msgenque->setReferenceCadastrale(
1202 $this->getReferenceCadastrale($this->valF['dossier']));
1203 $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);
1204 }
1205
1206 // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1207 // qui etait classifie come ERP
1208 if (substr($this->valF['nature'], 0, 2) ==
1209 $this->f->getParameter('erp_dossier_nature_pc')
1210 && $this->valF['erp'] == true) {
1211 $msgenque = new MessageEnqueuer();
1212 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1213 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1214 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1215 }
1216 }
1217 } // fin de if($this->f->getParameter('option_erp'))
1218 }
1219
1220
1221 /**
1222 * Retourne la reference cadastrale de la demande attache a un dossier ERP
1223 * specifique
1224 * @param string $dossier L'identifiant du dossier
1225 * @return string|null La reference cadastrale si elle est trouve,
1226 * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1227 */
1228 function getReferenceCadastrale($dossier) {
1229 $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1230 $res = $this->db->limitquery($sql, 0, 1);
1231 $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1232 str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1233 // Si une erreur survient on die
1234 if (database::isError($res, true)) {
1235 // Appel de la methode de recuperation des erreurs
1236 $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1237 }
1238 // retourne la nature du dossier
1239 while ($row =& $res->fetchRow()) {
1240 return $row[0];
1241 }
1242 // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1243 return NULL;
1244 }
1245
1246
1247 function sig_parametre(&$db){
1248 if (file_exists ("../dyn/var.inc"))
1249 include ("../dyn/var.inc");
1250 if(!isset($sig))
1251 $this->sig=0;
1252 else
1253 $this->sig=1;
1254 if(!isset($auto_pos))
1255 $this->auto_pos=0;
1256 else
1257 $this->auto_pos=$auto_pos;
1258 if(!isset($auto_servitude_surfacique))
1259 $this->auto_servitude_surfacique=0;
1260 else
1261 $this->auto_servitude_surfacique=$auto_servitude_surfacique;
1262 if(!isset($auto_servitude_ligne))
1263 $this->auto_servitude_ligne=0;
1264 else
1265 $this->auto_servitude_ligne=$auto_servitude_ligne;
1266 if(!isset($auto_servitude_point))
1267 $this->auto_servitude_point=0;
1268 else
1269 $this->auto_servitude_point=$auto_servitude_point;
1270 if(!isset($auto_parcelle))
1271 $this->auto_parcelle=0;
1272 else
1273 $this->auto_parcelle=$auto_parcelle;
1274 if(!isset($auto_parcelle_lot))
1275 $this->auto_parcelle_lot=0;
1276 else
1277 $this->auto_parcelle_lot=$auto_parcelle_lot;
1278 $this->addToLog("trigger valeur sig :".$this->sig, VERBOSE_MODE);
1279 $this->addToLog("trigger valeur auto_pos :". $this->auto_pos, VERBOSE_MODE);
1280 $this->addToLog("trigger valeur auto_servitude_surfacique :".$this->auto_servitude_surfacique, VERBOSE_MODE);
1281 $this->addToLog("trigger valeur auto_servitude_ligne :". $this->auto_servitude_ligne, VERBOSE_MODE);
1282 $this->addToLog("trigger valeur auto_servitude_point :".$this->auto_servitude_point, VERBOSE_MODE);
1283 $this->addToLog("trigger valeur auto_parcelle :". $this->auto_parcelle, VERBOSE_MODE);
1284 $this->addToLog("trigger valeur auto_parcelle_lot :".$this->auto_parcelle_lot, VERBOSE_MODE);
1285 }
1286
1287
1288 function sig_interne($id,&$db,$val,$DEBUG){
1289 // Strategy interne dans var.inc
1290 // si la parcelle existe, il est cree un point au milieu de la parcelle
1291 // de maniere automatique
1292 $geom='';
1293 $parcelle=$val["parcelle"];
1294 $projection = $db -> getOne("select srid from geometry_columns where f_table_name='dossier'");
1295 if($this->auto_parcelle==1 and $val["parcelle"]!=''){
1296 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle where parcelle ='".$val["parcelle"]."'";
1297 $this->addToLog("recherche centroid parcelle :".$sql, VERBOSE_MODE);
1298 $geom = $db -> getOne($sql);
1299 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1300 }
1301 if($geom=='' and $this->auto_parcelle_lot==1 and $val["parcelle_lot"]!=''){ // lot
1302 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle_lot where parcelle_lot ='".$val["parcelle_lot"]."'";
1303 $this->addToLog("recherche centroid parcelle lot :".$sql, VERBOSE_MODE);
1304 $geom = $db -> getOne($sql);
1305 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1306 $parcelle=$val["parcelle_lot"]." ".$val["parcelle_lot_lotissement"];
1307 }
1308 if($geom!=''){ // la parcelle est exitante dans la table ou vue parcelle
1309 $sql ="update ".DB_PREFIXE."dossier set geom =geometryfromtext('".$geom."', ".$projection." ) where dossier ='".$id."'";
1310 $this->addToLog("sig_interne maj geom :".$sql, VERBOSE_MODE);
1311 $res = $db -> query($sql);
1312 if (database :: isError($res)) die($res->getMessage()."erreur ".$sql);
1313 $this->addToMessage(""._("centroid de parcelle calcule")." ".$parcelle." ");
1314 if($this->auto_pos==1) // recherche du pos
1315 $this->calcul_auto_pos($id,$db,$geom,$projection);
1316 if($this->auto_servitude_surfacique==1) // recherche de servitude surfacique
1317 $this->calcul_auto_servitude_surfacique($id,$db,$geom,$projection);
1318 if($this->auto_servitude_ligne==1) // recherche de servitude ligne
1319 $this->calcul_auto_servitude_ligne($id,$db,$geom,$projection);
1320 if($this->auto_servitude_point==1) // recherche de servitude point
1321 $this->calcul_auto_servitude_point($id,$db,$geom,$projection);
1322 $temp=strtr($this->servitude,"'"," "); // enleve le '
1323 $sql1 ="update ".DB_PREFIXE."dossier set servitude = '".$temp."' where dossier = '".$id."'";
1324 $res1 = $db -> query($sql1);
1325 $this->addToLog("maj servitudes :".$sql1, VERBOSE_MODE);
1326 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1327 }else{ // parcelle inexistante //***
1328 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1329 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1330 $res = $db -> query($sql);
1331 $this->addToLog("requete sig_interne maj parcelle inexistante :".$sql, VERBOSE_MODE);
1332 if (database :: isError($res))
1333 die($res->getMessage()."erreur ".$sql);
1334 }
1335 //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
1336 }
1337 }
1338
1339 function calcul_auto_pos($id,&$db,$geom,$projection){
1340 // recherche du pos automatique
1341 $sql="select pos from ".DB_PREFIXE."pos WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
1342 $pos = $db -> getOne($sql);
1343 $this->addToLog("recherche auto_pos :".$sql, VERBOSE_MODE);
1344 if($pos!=''){
1345 $sql1 ="update ".DB_PREFIXE."dossier set pos = '".$pos."' where dossier = '".$id."'";
1346 $res1 = $db -> query($sql1);
1347 $this->addToLog("maj auto_pos :".$sql1, VERBOSE_MODE);
1348 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1349 $this->addToMessage("<br>"._("POS/PLU")." : ".$pos."");
1350 }else{
1351 $this->addToMessage("<br>"._("POS/PLU non trouve")." ".$id."");
1352 }
1353 }
1354
1355 function calcul_auto_servitude_surfacique($id,&$db,$geom,$projection){
1356 // recherche servitude surfacique
1357 $sql="select * from ".DB_PREFIXE."servitude_surfacique WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
1358 $res=$db->query($sql);
1359 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1360 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1361 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1362 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1363 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
1364 }
1365 }
1366
1367 function calcul_auto_servitude_ligne($id,&$db,$geom,$projection){
1368 // recherche servitude ligne
1369 $sql="select * from ".DB_PREFIXE."servitude_ligne WHERE ST_contains(ST_buffer(geom, perimetre), geometryfromtext('".$geom."', ".$projection."))";
1370 $res=$db->query($sql);
1371 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1372 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1373 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1374 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1375 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
1376 }
1377 }
1378
1379 function calcul_auto_servitude_point($id,&$db,$geom,$projection){
1380 // recherche servitude point
1381 $sql="select libelle,observation, perimetre, distance(geom, geometryfromtext('".$geom."', ".$projection.")) as distance from ".
1382 DB_PREFIXE."servitude_point WHERE distance(geom, geometryfromtext('".$geom."', ".$projection."))<perimetre";
1383 $res=$db->query($sql);
1384 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1385 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1386 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1387 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']." a ".round($row['distance'],2)." m ");
1388 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
1389 }
1390 }
1391 }// fin classe
1392 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26