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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1005 - (show annotations)
Thu Dec 6 15:48:07 2012 UTC (12 years, 2 months ago) by fmichon
File size: 61282 byte(s)
Merge de la branche 3.2.x pour la reprise du développement dans le trunk

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26