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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1371 - (show annotations)
Tue Mar 12 09:47:14 2013 UTC (11 years, 10 months ago) by nhaye
File size: 53883 byte(s)
Modification des scripts suite à la suppression de champs

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
400
401 // hiddenstatic
402 if($maj==1) $form->setType('dossier', 'hiddenstatic');
403 $form->setType('etat','hiddenstatic');
404 $form->setType('avis_decision','hiddenstatic');
405 $form->setType('delai','hiddenstatic');
406 $form->setType('terrain_surface_calcul','hiddenstatic');
407 $form->setType('shon_calcul','hiddenstatic');
408
409 $form->setType('accord_tacite','hiddenstatic');
410 $form->setType('types', 'hiddenstatic'); // transfert modificatif
411
412
413 // hiddenstaticdate
414 $form->setType('date_notification_delai','hiddenstaticdate');
415 $form->setType('date_decision','hiddenstaticdate');
416 $form->setType('date_limite','hiddenstaticdate');
417 $form->setType('date_rejet','hiddenstaticdate');
418 $form->setType('date_complet','hiddenstaticdate');
419 $form->setType('date_limite','hiddenstaticdate');
420 $form->setType('date_validite','hiddenstaticdate');
421 $form->setType('date_chantier','hiddenstaticdate');
422 $form->setType('date_achevement','hiddenstaticdate');
423 $form->setType('date_conformite','hiddenstaticdate');
424
425 // checkbox
426 $form->setType('sig','checkbox');
427
428 // zones temp et strategysig
429
430
431 // temp
432 if (file_exists ("../dyn/var.inc"))
433 include ("../dyn/var.inc");
434 if(!isset($auto_pos))
435 $auto_pos=0;
436 if($auto_pos==1)
437 $form->setType('pos','hiddenstatic');
438 else
439 $form->setType('pos','select');
440 $form->setType('temp1',$temp1_type);
441 $form->setType('temp2',$temp2_type);
442 $form->setType('temp3',$temp3_type);
443 $form->setType('temp4',$temp4_type);
444 $form->setType('temp5',$temp5_type);
445 $form->setType('a_qualifier', 'checkbox');
446 }
447 if ($maj == 1) {
448 //
449 if ($this->f->isAccredited("dossier_modifier_instructeur")) {
450 $form->setType('instructeur', 'select');
451 } else {
452 $form->setType('instructeur', 'selecthiddenstatic');
453 }
454 //
455 if($this->f->getParameter('afficher_division') === 'true') {
456 //
457 if ($this->f->isAccredited("dossier_modifier_division")) {
458 $form->setType('division', 'select');
459 } else {
460 $form->setType('division', 'selecthiddenstatic');
461 }
462 } else {
463 $form->setType('division', 'hidden');
464 }
465 }
466 if($maj == 3) {
467 $form->setType('annee', 'hidden');
468 $form->setType('temp1','hidden');
469 $form->setType('temp2','hidden');
470 $form->setType('temp3','hidden');
471 $form->setType('temp4','hidden');
472 $form->setType('temp5','hidden');
473 $form->setType('parcelle_archive','hidden');
474 $form->setType('parcelle_lot_archive','hidden');
475 $form->setType('geom1','hidden');
476 $form->setType('geom','hidden');
477 $form->setType('a_qualifier', 'checkboxstatic');
478 }
479 //
480 if(!$this->f->getParameter('afficher_division') === 'true') {
481 $form->setType('division', 'hidden');
482 }
483 $form->setType('dossier_autorisation', 'hiddenstatic');
484 $form->setType('dossier_instruction_type', 'selecthiddenstatic');
485 //
486 if ($maj == 0) {
487 $form->setType('dossier_autorisation', 'select');
488 }
489 // On cache enjeu_ERP si l'option n'est pas activée
490 if($this->f->getParameter('option_ERP') != 'true') {
491 $form->setType('erp', 'hidden');
492 $form->setType('enjeu_erp', 'hidden');
493 }
494 }
495
496 function setVal(&$form,$maj,$validation){
497 $this->maj=$maj;
498 if ($validation==0) {
499 if ($maj == 0){
500 //$dossier_cp = $this->f->collectivite["cp"];
501 //$dossier_ville = $this->f->collectivite["ville"];
502
503 $form->setVal('annee', date('y'));
504 $form->setVal('date_demande', date('Y-m-d'));
505 $form->setVal('date_depot', date('Y-m-d'));
506
507 //$form->setVal('demandeur_cp', $dossier_cp);
508 //$form->setVal('demandeur_ville', $dossier_ville);
509
510 //$form->setVal('delegataire_cp', $dossier_cp);
511 //$form->setVal('delegataire_ville', $dossier_ville);
512
513 //$form->setVal('terrain_cp', $dossier_cp);
514 //$form->setVal('terrain_ville', $dossier_ville);
515
516 $form->setVal('accord_tacite', 'Non');
517 $form->setVal('etat', 'initialiser');
518 $form->setVal('types', 'Initial');
519 }
520 }
521 }
522
523 function setSelect(&$form, $maj,&$db,$debug) {
524 parent::setSelect($form, $maj,$db,$debug);
525 //optimisation sur table importante parcelle -> pas d appel methode parent
526 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
527 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
528 if($maj<2){
529 // parcelle_lot
530 $contenu="";
531 $contenu[0][0]="parcelle_lot";// table
532 $contenu[0][1]="parcelle_lot"; // zone origine
533 $contenu[1][0]="lotissement";
534 $contenu[1][1]="parcelle_lot_lotissement";
535 $form->setSelect("parcelle_lot",$contenu);
536 $contenu="";
537 $contenu[0][0]="parcelle_lot";// table
538 $contenu[0][1]="lotissement"; // zone origine
539 $contenu[1][0]="parcelle_lot";
540 $contenu[1][1]="parcelle_lot";
541 $form->setSelect("parcelle_lot_lotissement",$contenu);
542 // accord tacite
543 $contenu=array();
544 $contenu[0]=array('Non','Oui');
545 $contenu[1]=array('Non','Oui');
546 $form->setSelect("accord_tacite",$contenu);
547 // terrain_numero_complement
548 $contenu=array();
549 $contenu[0]=array('','bis','ter','quater');
550 $contenu[1]=array('','bis','ter','quater');
551 $form->setSelect("terrain_numero_complement",$contenu);
552 // geom *** a voir
553 if($maj==1){ //modification
554 $contenu=array();
555 $contenu[0]=array("dossier",$this->getParameter("idx"));
556 $form->setSelect('geom',$contenu);
557 }
558 // arrondissement recherche anvancée
559 $this->init_select($form, $db, $maj, $debug, "arrondissement",
560 $sql_arrondissement, $sql_arrondissement_by_id, false);
561 // dossier_autorisation_type_detaille recherche anvancée
562 $this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille",
563 $sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false);
564 /*
565 * Affichage de données dans le select de la parcelle
566 * */
567 $contenu=array();
568 $sql="select parcelle from ".DB_PREFIXE."parcelle ";
569 $res = $db->query($sql);
570 if (database::isError($res))
571 die($res->getMessage());
572 $contenu[0][0]="";
573 $contenu[1][0]=_("choisir parcelle");
574 $k=1;
575 while ($row=& $res->fetchRow()){
576 $contenu[0][$k]=$row[0];
577 $contenu[1][$k]=$row[0];
578 $k++;
579 }
580 $form->setSelect("parcelle",$contenu);
581
582 }
583 if($this->f->getParameter('afficher_division')==='true') {
584 // instructeur
585 $this->init_select($form, $db, $maj, $debug, "instructeur",
586 $sql_instructeur_div, $sql_instructeur_div_by_id, false);
587 }
588 }
589
590 function setLib(&$form,$maj) {
591 parent::setLib($form,$maj);
592 $form->setLib('geom','');
593 }
594
595 function setGroupe(&$form,$maj){
596 // instruction
597 $form->setGroupe('date_complet','D');
598 $form->setGroupe('date_rejet','G');
599 $form->setGroupe('rejet','G');
600 $form->setGroupe('delai','F');
601
602 $form->setGroupe('date_limite','D');
603 $form->setGroupe('date_notification_delai','G');
604 $form->setGroupe('accord_tacite','G');
605 $form->setGroupe('etat','F');
606
607 $form->setGroupe('date_decision','D');
608 $form->setGroupe('avis_decision','G');
609 $form->setGroupe('date_validite','G');
610 $form->setGroupe('types','F');
611
612 $form->setGroupe('date_chantier','D');
613 $form->setGroupe('date_achevement','G');
614 $form->setGroupe('date_conformite','F');
615
616 // localisation
617 $form->setGroupe('parcelle','D');
618 $form->setGroupe('pos','G');
619 if($maj==1){
620 $form->setGroupe('sig','G');
621 $form->setGroupe('geom','F');
622 }else {
623 $form->setGroupe('sig','F');
624 }
625 if($maj==1){
626 $form->setGroupe('sig','G');
627 $form->setGroupe('geom','F');
628 }
629
630 // description
631 $form->setGroupe('batiment_nombre','D');
632 $form->setGroupe('logement_nombre','G');
633 $form->setGroupe('hauteur','G');
634 $form->setGroupe('piece_nombre','F');
635
636 $form->setGroupe('shon','D');
637 $form->setGroupe('shon_calcul','G');
638 $form->setGroupe('shob','G');
639 $form->setGroupe('lot','F');
640
641 $form->setGroupe('amenagement','D');
642 $form->setGroupe('parcelle_lot','G');
643 $form->setGroupe('parcelle_lot_lotissement','F');
644 }
645
646 function setOnchange(&$form,$maj){
647 parent::setOnchange($form,$maj);
648 // mise en majuscule
649 $form->setOnchange("demandeur_nom","this.value=this.value.toUpperCase()");
650 $form->setOnchange("demandeur_societe","this.value=this.value.toUpperCase()");
651 $form->setOnchange("delegataire_nom","this.value=this.value.toUpperCase()");
652 $form->setOnchange("delegataire_societe","this.value=this.value.toUpperCase()");
653 $form->setOnchange("architecte_nom","this.value=this.value.toUpperCase()");
654 $form->setOnchange("terrain_adresse","this.value=this.value.toUpperCase()");
655 $form->setOnchange('shon','VerifNumdec(this)');
656 $form->setOnchange('shob','VerifNumdec(this)');
657 $form->setOnchange('hauteur','VerifNumdec(this)');
658 $form->setOnchange('terrain_surface','VerifNumdec(this)');
659 }
660
661 function setLayout(&$form, $maj) {
662 //
663 $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
664 $form->setBloc('dossier', 'D', '', 'col_9');
665 $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
666 $form->setFieldset('autorite_competente', 'F');
667 $form->setBloc('autorite_competente', 'F');
668 $form->setBloc('date_demande', 'D', '', 'col_3');
669 $form->setFieldset('date_demande', 'D', _("Depot"));
670 $form->setFieldset('date_depot', 'F');
671 $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
672 $form->setFieldset('enjeu_erp', 'F');
673 $form->setBloc('enjeu_erp', 'F');
674 $form->setBloc('enjeu_erp', 'F');
675 //
676 $form->setBloc('objet_dossier', 'D', '', 'col_12');
677 //
678 $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
679 $form->setRegroupe('date_conformite','F','');
680 //
681 $form->setBloc('terrain_superficie', 'F');
682
683 }
684
685 function setRegroupe(&$form,$maj) {
686 //// depot
687 //If ($maj==0){
688 // $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
689 //}
690 //If ($maj==1){
691 // $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
692 // $form->setRegroupe('date_demande','G','');
693 //}
694 //$form->setRegroupe('date_depot','G','');
695 //$form->setRegroupe('division','F','');
696
697
698
699 $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);
700 $form->setRegroupe('servitude','F','');
701
702 // amenagement
703 $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
704 $form->setRegroupe('parcelle_lot','G','');
705 $form->setRegroupe('parcelle_lot_lotissement','F','');
706
707 }
708
709 /* =============================================================
710 * fonction trigger relative a la connexion SIG
711 * $sig = 1 dans dyn/var.inc
712 * utilisé aussi pour envoyer une message au service REST d'ERP
713 * ===============================================================
714 */
715
716 function triggerajouterapres($id,&$db,$val,$DEBUG) {
717 $this->sig_parametre($db);
718 $id=$this->valF['dossier']; // id n est pas valorise en ajout
719 if($this->sig==1 and $val['sig']!='Oui'){
720 if($val['parcelle']!=''or $val['parcelle_lot']!=''){
721
722 $this->sig_interne($id,$db,$val,$DEBUG);
723 }
724 else
725 $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
726
727 }
728
729
730 if ($this->f->getParameter('option_erp') != "") {
731 // envoi du message a ERP en cas d'un depot du dossier dat
732 if ($this->getDATDCode($this->valF['dossier']) ==
733 $this->f->getParameter('erp_depot_dossier_dat')) {
734 $msgenque = new MessageEnqueuer();
735 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
736 $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
737 }
738
739 // envoi du message a ERP en cas d'une demande d'ouverture DAT
740 if ($this->getDATDCode($this->valF['dossier']) ==
741 $this->f->getParameter('erp_demande_ouverture_dat')) {
742 $msgenque = new MessageEnqueuer();
743 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
744 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
745 }
746
747 if ($this->valF['erp'] === true) {
748 // envoi du message a ERP en cas d'annulation d'une demande
749 if ($this->getDATDCode($this->valF['dossier']) ==
750 $this->f->getParameter('erp_annulation_demande')) {
751 $msgenque = new MessageEnqueuer();
752 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
753 $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
754 }
755
756 // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
757 // au dossier DAACT
758 if ($this->getDATDCode($this->valF['dossier']) ==
759 $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
760 $msgenque = new MessageEnqueuer();
761 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
762 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
763 }
764 }
765 } // fin de if ($this->f->getParameter('option_erp') != "")
766 }
767
768 /*
769 * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
770 * */
771 function getQuartierArrondissement($parcelle) {
772
773 $parcelle = trim($parcelle);
774 $quartier = '';
775
776 /*Récupère le code impot du quartier dans la parcelle*/
777 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
778
779 if (is_numeric($parcelle[$i]) ){
780
781 $quartier .= $parcelle[$i];
782 }
783 else{
784
785 break;
786 }
787 }
788
789 if ( $quartier !== '' ){
790
791 /*identifiant*/
792 $sql = "SELECT
793 quartier, arrondissement
794 FROM
795 ".DB_PREFIXE."quartier
796 WHERE
797 code_impots='$quartier'";
798
799 $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
800 $res = $this->db->query($sql);
801 if (database :: isError($res))
802 die($res->getMessage()."erreur ".$sql);
803
804 if ( $res->numRows() > 0 ){
805
806 return $res->fetchRow(DB_FETCHMODE_ASSOC);
807 }
808 }
809
810 return NULL;
811 }
812
813 /*
814 * Retourne la section d'une parcelle
815 * */
816 function getSection($parcelle){
817
818 $parcelle = trim($parcelle);
819 $section = NULL;
820
821 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
822 if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
823 $section .= $parcelle[$i];
824
825 return $section;
826 }
827
828 /*
829 * Retourne l'intructeur correspondant le mieux à la parcelle
830 * */
831 function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
832
833 $quartier = ( $quartier == NULL ) ? -1 : $quartier;
834 $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
835
836 /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
837 $sql = "
838 SELECT
839 dossier_autorisation_type_detaille
840 FROM
841 ".DB_PREFIXE."dossier_autorisation
842 WHERE
843 dossier_autorisation = '$dossier_autorisation'";
844
845 $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
846 $resDATD = $this->db->query($sql);
847 if (database :: isError($resDATD))
848 die($resDATD->getMessage()."erreur ".$sql);
849
850 if ( $resDATD->numRows() > 0 ){
851 $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
852
853 $sql = "
854 SELECT
855 instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
856 FROM
857 ".DB_PREFIXE."affectation_automatique l
858 WHERE
859 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
860 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
861 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
862 ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
863 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
864 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
865 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
866 ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
867 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
868 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
869 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
870 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
871 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
872 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
873 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
874 ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
875 ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
876 LIMIT 1
877 ";
878
879 $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
880 $res = $this->db->query($sql);
881 if (database :: isError($res))
882 die($res->getMessage()."erreur ".$sql);
883
884 if ( $res->numRows() > 0 ){
885
886 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
887
888 $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
889 $res = $this->db->query($sql);
890 if (database :: isError($res))
891 die($res->getMessage()."erreur ".$sql);
892
893 if ( $res->numRows() > 0 ){
894
895 $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
896 $row['division'] = $rowT['division'];
897 }
898
899 return $row;
900 }
901 }
902
903 return NULL;
904 }
905
906 /* =============================================================
907 * fonction trigger relative a la connexion SIG
908 * $sig = 1 dans dyn/var.inc
909 * ===============================================================
910 */
911
912 function triggerajouter($id,&$db,$val,$DEBUG) {
913 //
914 $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
915
916 // Initialisation des variables nécessaires à l'affectation automatique
917 $quartier = NULL;
918 $arrondissement = NULL;
919 $section = NULL;
920 $instructeur = NULL;
921
922 // Si la parcelle n'est pas vide alors on récupère la section, le
923 // quartier et l'arrondissement
924 if ($val['parcelle'] != '') {
925 // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
926 $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
927 if ( $quartierArrondissement!= NULL ){
928
929 $quartier = $quartierArrondissement['quartier'];
930 $arrondissement = $quartierArrondissement['arrondissement'];
931 }
932 // Si il n'y a pas d'arrondissement alors on vide le quartier
933 if ( strcmp($arrondissement,'') == 0 ) {
934
935 $arrondissement = NULL;
936 $quartier = NULL;
937 }
938 // On récupère la section
939 $section = $this->getSection($val['parcelle']);
940 }
941
942 // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
943 // alors on récupère l'instructeur et la division depuis l'affectation
944 if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
945
946 //
947 $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
948 if ( $instructeurDivision != NULL ){
949
950 $instructeur = $instructeurDivision['instructeur'];
951 $division = $instructeurDivision['division'];
952 }
953
954 if ( $instructeur != NULL ){
955
956 $this->valF['instructeur'] = $instructeur;
957 $this->valF['division'] = $division;
958 } else {
959 if ($this->f->isAccredited("dossier_modifier_instructeur")) {
960 $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
961 } else {
962 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
963 }
964 }
965 } else {
966 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
967 }
968 //
969 $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
970 }
971
972 function triggermodifierapres($id,&$db,$val,$DEBUG) {
973 $this->sig_parametre($db);
974 // si la parcelle est changée
975 if(($this->sig==1 and $val['sig']!='Oui' and ($val['parcelle']!=$val['parcelle_archive'])
976 or $val['parcelle_lot']!=$val['parcelle_lot_archive'])){ // parcelle_lot_archive
977 if($val['parcelle']!='' or $val['parcelle_lot']!='')
978 $this->sig_interne($this->valF['dossier'],$db,$val,$DEBUG);
979 else{
980 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
981 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
982 $res = $db -> query($sql);
983 $this->addToLog("requete trigger modifier parcelle vide -> maj pos et servitude :".$sql, VERBOSE_MODE);
984 if (database :: isError($res))
985 die($res->getMessage()."erreur ".$sql);
986 }
987 $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");
988 }
989 }
990
991 // verification si envoi vers ERP est active
992 if ($this->f->getParameter('option_erp') != "") {
993 if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
994 && $this->valF['a_qualifier'] === false) {
995
996 // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
997 // de la qualification URBA
998 if ($this->getDATDCode($this->valF['dossier']) ==
999 $this->f->getParameter('erp_nature_dat')) {
1000 $msgenque = new MessageEnqueuer();
1001 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1002 $msgenque->setCompetence($this->valF['autorite_competente']);
1003 $msgenque->setContraintePlu($this->valF['servitude']);
1004 $msgenque->setReferenceCadastrale(
1005 $this->getReferenceCadastrale($this->valF['dossier']));
1006 $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);
1007 }
1008
1009 // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1010 // qui etait classifie come ERP
1011 if ($this->getDATDCode($this->valF['dossier']) ==
1012 $this->f->getParameter('erp_dossier_nature_pc')
1013 && $this->valF['erp'] == true) {
1014 $msgenque = new MessageEnqueuer();
1015 $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1016 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1017 $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1018 }
1019 }
1020 } // fin de if($this->f->getParameter('option_erp'))
1021 }
1022
1023 /**
1024 * Retourne le type de dossier d'autorisation du dossier courant :
1025 * - dossier_autorisation_type_detaille.code
1026 **/
1027 function getDATDCode($idxDossier) {
1028 $sql = "SELECT dossier_autorisation_type_detaille.code
1029 FROM ".DB_PREFIXE."dossier_autorisation_type_detaille
1030 INNER JOIN ".DB_PREFIXE."dossier_autorisation
1031 ON dossier_autorisation_type_detaille.dossier_autorisation_type_detaille =
1032 dossier_autorisation.dossier_autorisation_type_detaille
1033 INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1034 WHERE dossier.dossier = '".$idxDossier."'";
1035 $res = $this -> db -> getOne($sql);
1036 $this->f->isDatabaseError();
1037 $this->addToLog($sql);
1038 return $res;
1039 }
1040
1041
1042 /**
1043 * Retourne la reference cadastrale de la demande attache a un dossier ERP
1044 * specifique
1045 * @param string $dossier L'identifiant du dossier
1046 * @return string|null La reference cadastrale si elle est trouve,
1047 * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1048 */
1049 function getReferenceCadastrale($dossier) {
1050 $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1051 $res = $this->db->limitquery($sql, 0, 1);
1052 $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1053 str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1054 // Si une erreur survient on die
1055 if (database::isError($res, true)) {
1056 // Appel de la methode de recuperation des erreurs
1057 $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1058 }
1059 // retourne la nature du dossier
1060 while ($row =& $res->fetchRow()) {
1061 return $row[0];
1062 }
1063 // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1064 return NULL;
1065 }
1066
1067
1068 function sig_parametre(&$db){
1069 if (file_exists ("../dyn/var.inc"))
1070 include ("../dyn/var.inc");
1071 if(!isset($sig))
1072 $this->sig=0;
1073 else
1074 $this->sig=1;
1075 if(!isset($auto_pos))
1076 $this->auto_pos=0;
1077 else
1078 $this->auto_pos=$auto_pos;
1079 if(!isset($auto_servitude_surfacique))
1080 $this->auto_servitude_surfacique=0;
1081 else
1082 $this->auto_servitude_surfacique=$auto_servitude_surfacique;
1083 if(!isset($auto_servitude_ligne))
1084 $this->auto_servitude_ligne=0;
1085 else
1086 $this->auto_servitude_ligne=$auto_servitude_ligne;
1087 if(!isset($auto_servitude_point))
1088 $this->auto_servitude_point=0;
1089 else
1090 $this->auto_servitude_point=$auto_servitude_point;
1091 if(!isset($auto_parcelle))
1092 $this->auto_parcelle=0;
1093 else
1094 $this->auto_parcelle=$auto_parcelle;
1095 if(!isset($auto_parcelle_lot))
1096 $this->auto_parcelle_lot=0;
1097 else
1098 $this->auto_parcelle_lot=$auto_parcelle_lot;
1099 $this->addToLog("trigger valeur sig :".$this->sig, VERBOSE_MODE);
1100 $this->addToLog("trigger valeur auto_pos :". $this->auto_pos, VERBOSE_MODE);
1101 $this->addToLog("trigger valeur auto_servitude_surfacique :".$this->auto_servitude_surfacique, VERBOSE_MODE);
1102 $this->addToLog("trigger valeur auto_servitude_ligne :". $this->auto_servitude_ligne, VERBOSE_MODE);
1103 $this->addToLog("trigger valeur auto_servitude_point :".$this->auto_servitude_point, VERBOSE_MODE);
1104 $this->addToLog("trigger valeur auto_parcelle :". $this->auto_parcelle, VERBOSE_MODE);
1105 $this->addToLog("trigger valeur auto_parcelle_lot :".$this->auto_parcelle_lot, VERBOSE_MODE);
1106 }
1107
1108
1109 function sig_interne($id,&$db,$val,$DEBUG){
1110 // Strategy interne dans var.inc
1111 // si la parcelle existe, il est cree un point au milieu de la parcelle
1112 // de maniere automatique
1113 $geom='';
1114 $parcelle=$val["parcelle"];
1115 $projection = $db -> getOne("select srid from geometry_columns where f_table_name='dossier'");
1116 if($this->auto_parcelle==1 and $val["parcelle"]!=''){
1117 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle where parcelle ='".$val["parcelle"]."'";
1118 $this->addToLog("recherche centroid parcelle :".$sql, VERBOSE_MODE);
1119 $geom = $db -> getOne($sql);
1120 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1121 }
1122 if($geom=='' and $this->auto_parcelle_lot==1 and $val["parcelle_lot"]!=''){ // lot
1123 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle_lot where parcelle_lot ='".$val["parcelle_lot"]."'";
1124 $this->addToLog("recherche centroid parcelle lot :".$sql, VERBOSE_MODE);
1125 $geom = $db -> getOne($sql);
1126 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1127 $parcelle=$val["parcelle_lot"]." ".$val["parcelle_lot_lotissement"];
1128 }
1129 if($geom!=''){ // la parcelle est exitante dans la table ou vue parcelle
1130 $sql ="update ".DB_PREFIXE."dossier set geom =geometryfromtext('".$geom."', ".$projection." ) where dossier ='".$id."'";
1131 $this->addToLog("sig_interne maj geom :".$sql, VERBOSE_MODE);
1132 $res = $db -> query($sql);
1133 if (database :: isError($res)) die($res->getMessage()."erreur ".$sql);
1134 $this->addToMessage(""._("centroid de parcelle calcule")." ".$parcelle." ");
1135 if($this->auto_pos==1) // recherche du pos
1136 $this->calcul_auto_pos($id,$db,$geom,$projection);
1137 if($this->auto_servitude_surfacique==1) // recherche de servitude surfacique
1138 $this->calcul_auto_servitude_surfacique($id,$db,$geom,$projection);
1139 if($this->auto_servitude_ligne==1) // recherche de servitude ligne
1140 $this->calcul_auto_servitude_ligne($id,$db,$geom,$projection);
1141 if($this->auto_servitude_point==1) // recherche de servitude point
1142 $this->calcul_auto_servitude_point($id,$db,$geom,$projection);
1143 $temp=strtr($this->servitude,"'"," "); // enleve le '
1144 $sql1 ="update ".DB_PREFIXE."dossier set servitude = '".$temp."' where dossier = '".$id."'";
1145 $res1 = $db -> query($sql1);
1146 $this->addToLog("maj servitudes :".$sql1, VERBOSE_MODE);
1147 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1148 }else{ // parcelle inexistante //***
1149 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1150 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1151 $res = $db -> query($sql);
1152 $this->addToLog("requete sig_interne maj parcelle inexistante :".$sql, VERBOSE_MODE);
1153 if (database :: isError($res))
1154 die($res->getMessage()."erreur ".$sql);
1155 }
1156 //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
1157 }
1158 }
1159
1160 function calcul_auto_pos($id,&$db,$geom,$projection){
1161 // recherche du pos automatique
1162 $sql="select pos from ".DB_PREFIXE."pos WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
1163 $pos = $db -> getOne($sql);
1164 $this->addToLog("recherche auto_pos :".$sql, VERBOSE_MODE);
1165 if($pos!=''){
1166 $sql1 ="update ".DB_PREFIXE."dossier set pos = '".$pos."' where dossier = '".$id."'";
1167 $res1 = $db -> query($sql1);
1168 $this->addToLog("maj auto_pos :".$sql1, VERBOSE_MODE);
1169 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1170 $this->addToMessage("<br>"._("POS/PLU")." : ".$pos."");
1171 }else{
1172 $this->addToMessage("<br>"._("POS/PLU non trouve")." ".$id."");
1173 }
1174 }
1175
1176 function calcul_auto_servitude_surfacique($id,&$db,$geom,$projection){
1177 // recherche servitude surfacique
1178 $sql="select * from ".DB_PREFIXE."servitude_surfacique WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
1179 $res=$db->query($sql);
1180 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1181 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1182 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1183 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1184 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
1185 }
1186 }
1187
1188 function calcul_auto_servitude_ligne($id,&$db,$geom,$projection){
1189 // recherche servitude ligne
1190 $sql="select * from ".DB_PREFIXE."servitude_ligne WHERE ST_contains(ST_buffer(geom, perimetre), geometryfromtext('".$geom."', ".$projection."))";
1191 $res=$db->query($sql);
1192 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1193 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1194 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1195 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1196 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
1197 }
1198 }
1199
1200 function calcul_auto_servitude_point($id,&$db,$geom,$projection){
1201 // recherche servitude point
1202 $sql="select libelle,observation, perimetre, distance(geom, geometryfromtext('".$geom."', ".$projection.")) as distance from ".
1203 DB_PREFIXE."servitude_point WHERE distance(geom, geometryfromtext('".$geom."', ".$projection."))<perimetre";
1204 $res=$db->query($sql);
1205 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1206 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1207 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1208 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']." a ".round($row['distance'],2)." m ");
1209 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
1210 }
1211 }
1212 }// fin classe
1213 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26