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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 681 - (show annotations)
Wed Nov 14 07:09:49 2012 UTC (12 years, 2 months ago) by fmichon
File size: 44316 byte(s)
Ajout de la colonne division dans la table dossier

1 <?php
2 //$Id$
3 //gen openMairie le 10/02/2011 20:39
4
5 require_once ("../gen/obj/dossier.class.php");
6
7 class dossier extends dossier_gen {
8
9 var $maj;
10 var $sig;
11 var $servitude="";
12 var $auto_pos;
13 var $auto_servitude_surfacique;
14 var $auto_servitude_ligne;
15 var $auto_servitude_point;
16 var $auto_parcelle;
17 var $auto_parcelle_lot;
18 var $aff_depot = "collapsible";
19 var $aff_travaux = "collapsible";
20 var $aff_instruction = "collapsible";
21 var $aff_demandeur = "startClosed";
22 var $aff_delegataire = "startClosed";
23 var $aff_terrain = "startClosed";
24 var $aff_localisation = "collapsible";
25 var $aff_description = "startClosed";
26 var $aff_amenagement = "startClosed";
27
28 function dossier($id,&$db,$DEBUG) {
29 $this->constructeur($id,$db,$DEBUG);
30 } // fin constructeur
31
32 function setValFAjout($val = array()) {
33 // Cle primaire
34 $lettre=$this->f->collectivite["lettre"];
35 $numero_unique = $this->f->collectivite["numero_unique"];
36 if($numero_unique==1){
37 // numero unique (voir dyn/var.inc)
38 $temp=$this->$db->nextId(DB_PREFIXE.$this->table);
39 }else{
40 // numero suivant nature
41 $temp=$this->db->nextId(DB_PREFIXE."dossier_".$val['nature']);
42 }
43 $temp=str_pad($temp,4,"0", STR_PAD_LEFT);
44 $this->valF['dossier'] = $this->valF['nature'].$this->valF['annee'].
45 $lettre.$temp;
46 }
47
48 function setvalF($val){
49 parent::setvalF($val);
50 // enlever les valeurs a ne pas saisir -> recherche en trigger ajouter et modifier
51 // $sig = 1
52 unset ($this->valF['geom']);
53 unset ($this->valF['geom1']);
54 // valeurs hiddenstatic (calcule)
55 if($this->maj==1){
56 // par defaut
57 unset ($this->valF['etat']);
58 unset ($this->valF['delai']);
59 unset ($this->valF['accord_tacite']);
60 unset ($this->valF['types']);
61 }
62 unset ($this->valF['avis_decision']); // avis + libelle avis
63 unset ($this->valF['terrain_surface_calcul']);
64 unset ($this->valF['shon_calcul']);
65 unset ($this->valF['parcelle_archive']);
66 unset ($this->valF['parcelle_lot_archive']);
67 unset ($this->valF['date_notification_delai']);
68 unset ($this->valF['date_decision']);
69 unset ($this->valF['date_limite']);
70 unset ($this->valF['date_validite']);
71 unset ($this->valF['date_chantier']);
72 unset ($this->valF['date_achevement']);
73 unset ($this->valF['date_conformite']);
74 }
75
76 function verifier($val,&$db,$DEBUG){
77 parent::verifier($val,$db,$DEBUG);
78 if($val['parcelle']!="" and $val['sig']!='Oui'){
79 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'])){
80 $this->correct=false;
81 $this->addToMessage("<br>format parcelle incorrect");
82 }
83 }
84 // regles travaux verification
85 if ($this->valF['travaux']!=""){
86 $sql= "select * from ".DB_PREFIXE."regle where id = '".$this->valF['travaux'].
87 "' and controle = 'travaux' order by ordre";
88 $res = $db->query($sql);
89 if (database :: isError($res)) die($res->getMessage().$sql);
90 $this->addToLog("requete ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
91 $regle=0;
92 $msg="";
93 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
94 if(isset($this->valF[$row['champ']]))
95 $champvaleur=$this->valF[$row['champ']];
96 else
97 $champvaleur=0;
98 switch ($row['operateur']) {
99 case ">" :
100 if($row['sens']=="plus"){
101 if($champvaleur > $row['valeur'])
102 $condition = 1;
103 else
104 $condition = 0;
105 if($regle==1 or $condition == 1)
106 $regle=1;
107 else
108 $regle=0;
109 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
110 $champvaleur."]";
111 }else{
112 if($champvaleur > $row['valeur']){
113 $condition = 0;
114 }else{
115 $condition = 1;
116 $regle=0;
117 }
118 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
119 $champvaleur."]";
120 }
121 break;
122 case ">=":
123 if($row['sens']=="plus"){
124 if($champvaleur >= $row['valeur'])
125 $condition = 1;
126 else
127 $condition = 0;
128 if($regle==1 or $condition == 1)
129 $regle=1;
130 else
131 $regle=0;
132 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
133 $champvaleur."]";
134 }else{
135 if($champvaleur >= $row['valeur']){
136 $condition = 0;
137
138 }else{
139 $condition = 1;
140 $regle=0;
141 }
142 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
143 $champvaleur."]";
144 }
145 break;
146 case "<" :
147 if($row['sens']=="plus"){
148 if($champvaleur < $row['valeur'])
149 $condition = 1;
150 else
151 $condition = 0;
152 if($regle==1 or $condition == 1)
153 $regle=1;
154 else
155 $regle=0;
156 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
157 $champvaleur."]";
158 }else{
159 if($champvaleur < $row['valeur']){
160 $condition = 0;
161 }else{
162 $condition = 1;
163 $regle=0;
164 }
165 $msg=$msg."<br> et ".$row['message']." [".$row['champ']." = ".
166 $champvaleur."]";
167 }
168 break;
169 case "==":
170 if($row['sens']=="plus"){
171 if($champvaleur == $row['valeur'])
172 $condition = 1;
173 else
174 $condition = 0;
175 if($regle==1 or $condition == 1)
176 $regle=1;
177 else
178 $regle=0;
179 $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
180 $champvaleur."]";
181 }else{
182 if($champvaleur == $row['valeur']){
183 $condition = 0;
184
185 }else{
186 $condition = 1;
187 $regle=0;
188 }
189 $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
190 $champvaleur."]";
191 }
192 break;
193 //break;
194 } // switch
195 if($regle==0)
196 $this->addToMessage($msg." <br>");
197 } // while
198 } // travaux
199 }//verifier
200
201
202 function setType(&$form,$maj) {
203 parent::setType($form,$maj);
204 if ($maj < 2) { //ajouter et modifier
205 // cache
206 if($maj==0) $form->setType('dossier', 'hidden');
207 $form->setType('annee', 'hidden');
208 $form->setType('nature', 'select');
209 $form->setType('parcelle_archive','hidden');
210 $form->setType('parcelle_lot_archive','hidden');
211 $form->setType('objet_dossier','hidden'); // PC
212 $form->setType('amenagement','hidden'); // PC
213 $form->setType('parcelle_lot','hidden'); // PC
214 $form->setType('parcelle_lot_lotissement','hidden'); // PC
215
216 $form->setType('geom1', 'hidden');
217 $form->setType('geom', 'geom');
218 $form->setType('servitude', 'hiddenstatic');
219
220 //select
221 $form->setType('terrain_numero_complement','select');
222
223 // combo
224 $form->setType('rivoli','comboD');
225 $form->setType('terrain_adresse','comboG');
226 $form->setType('architecte_nom','comboG');
227 $form->setType('architecte','comboD');
228
229
230 // hiddenstatic
231 if($maj==1) $form->setType('dossier', 'hiddenstatic');
232 $form->setType('etat','hiddenstatic');
233 $form->setType('avis_decision','hiddenstatic');
234 $form->setType('delai','hiddenstatic');
235 $form->setType('terrain_surface_calcul','hiddenstatic');
236 $form->setType('shon_calcul','hiddenstatic');
237
238 $form->setType('accord_tacite','hiddenstatic');
239 $form->setType('types', 'hiddenstatic'); // transfert modificatif
240
241
242 // hiddenstaticdate
243 $form->setType('date_notification_delai','hiddenstaticdate');
244 $form->setType('date_decision','hiddenstaticdate');
245 $form->setType('date_limite','hiddenstaticdate');
246 $form->setType('date_rejet','hiddenstaticdate');
247 $form->setType('date_complet','hiddenstaticdate');
248 $form->setType('date_limite','hiddenstaticdate');
249 $form->setType('date_validite','hiddenstaticdate');
250 $form->setType('date_chantier','hiddenstaticdate');
251 $form->setType('date_achevement','hiddenstaticdate');
252 $form->setType('date_conformite','hiddenstaticdate');
253
254 // checkbox
255 $form->setType('sig','checkbox');
256 $form->setType('delegataire','checkbox');
257
258 // mail
259 $form->setType('delegataire_email','mail');
260 $form->setType('demandeur_email','mail');
261
262 // zones temp et strategysig
263
264
265 // temp
266 if (file_exists ("../dyn/var.inc"))
267 include ("../dyn/var.inc");
268 if(!isset($auto_pos))
269 $auto_pos=0;
270 if($auto_pos==1)
271 $form->setType('pos','hiddenstatic');
272 else
273 $form->setType('pos','select');
274 $form->setType('temp1',$temp1_type);
275 $form->setType('temp2',$temp2_type);
276 $form->setType('temp3',$temp3_type);
277 $form->setType('temp4',$temp4_type);
278 $form->setType('temp5',$temp5_type);
279 }
280 if($maj == 3) {
281 $form->setType('annee', 'hidden');
282 $form->setType('nature', 'selectstatic');
283 $form->setType('temp1','hidden');
284 $form->setType('temp2','hidden');
285 $form->setType('temp3','hidden');
286 $form->setType('temp4','hidden');
287 $form->setType('temp5','hidden');
288 $form->setType('parcelle_archive','hidden');
289 $form->setType('parcelle_lot_archive','hidden');
290 $form->setType('geom1','hidden');
291 $form->setType('geom','hidden');
292 }
293 //if($this->f->getParameter('afficher_division')==='true') {
294 // $form->setType('division','hiddenstatic');
295 //} else {
296 // $form->setType('division','hidden');
297 //}
298
299 /* Gestion des droits pour l'ajout forcé d'un instructeur, si le profil est 5, c'est un administrateur */
300 if ( !$this->f->isAccredited("dossier_modifier_instructeur") )
301 $form->setType('instructeur', 'hidden');
302 }
303
304 function setVal(&$form,$maj,$validation){
305 $this->maj=$maj;
306 if ($validation==0) {
307 if ($maj == 0){
308 //$dossier_cp = $this->f->collectivite["cp"];
309 //$dossier_ville = $this->f->collectivite["ville"];
310 //$form->setVal('nature', $this->nature);
311
312 $form->setVal('annee', date('y'));
313 $form->setVal('date_demande', date('Y-m-d'));
314 $form->setVal('date_depot', date('Y-m-d'));
315
316 //$form->setVal('demandeur_cp', $dossier_cp);
317 //$form->setVal('demandeur_ville', $dossier_ville);
318
319 //$form->setVal('delegataire_cp', $dossier_cp);
320 //$form->setVal('delegataire_ville', $dossier_ville);
321
322 //$form->setVal('terrain_cp', $dossier_cp);
323 //$form->setVal('terrain_ville', $dossier_ville);
324
325 $form->setVal('accord_tacite', 'Non');
326 $form->setVal('etat', 'initialiser');
327 $form->setVal('types', 'Initial');
328 }
329 }
330 }
331
332 function setSelect(&$form, $maj,&$db,$debug) {
333 parent::setSelect($form, $maj,$db,$debug);
334 //optimisation sur table importante parcelle -> pas d appel methode parent
335 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
336 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
337 if($maj<2){
338 // travaux
339 $contenu=array();
340 // prise en compte du solde en ajout
341 if($maj==0)
342 $sql_travaux = $sql_travaux.
343 " and solde = 'Non' order by libelle";
344 else
345 $sql_travaux = $sql_travaux.
346 " order by libelle";
347 $res = $db->query($sql_travaux);
348 if (database::isError($res)) die($res->getMessage()).$sql_travaux;
349 $this->addToLog(" la requete ".$sql_travaux." est executee", VERBOSE_MODE);
350 $contenu[0][0]="";
351 $contenu[1][0]=_('choisir')." "._('travaux');
352 $k=1;
353 while ($row=& $res->fetchRow()){
354 $contenu[0][$k]=$row[0];
355 $contenu[1][$k]=$row[1];
356 $k++;
357 }
358 $form->setSelect("travaux",$contenu);
359
360 // code et libelle voie
361 $contenu="";
362 $contenu[0][0]="rivoli";// table
363 $contenu[0][1]="rivoli"; // zone origine
364 $contenu[1][0]="libelle";
365 $contenu[1][1]="terrain_adresse";
366 $form->setSelect("rivoli",$contenu);
367 //terrain_adresse
368 $contenu="";
369 $contenu[0][0]="rivoli";// table
370 $contenu[0][1]="libelle"; // zone origine
371 $contenu[1][0]="rivoli";
372 $contenu[1][1]="rivoli";
373 $form->setSelect("terrain_adresse",$contenu);
374 // code et libelle architecte
375 $contenu="";
376 $contenu[0][0]="architecte";// table
377 $contenu[0][1]="architecte"; // zone origine
378 $contenu[1][0]="nom";
379 $contenu[1][1]="architecte_nom";
380 $form->setSelect("architecte",$contenu);
381 $contenu="";
382 $contenu[0][0]="architecte";// table
383 $contenu[0][1]="nom"; // zone origine
384 $contenu[1][0]="architecte";
385 $contenu[1][1]="architecte";
386 $form->setSelect("architecte_nom",$contenu);
387 // parcelle_lot
388 $contenu="";
389 $contenu[0][0]="parcelle_lot";// table
390 $contenu[0][1]="parcelle_lot"; // zone origine
391 $contenu[1][0]="lotissement";
392 $contenu[1][1]="parcelle_lot_lotissement";
393 $form->setSelect("parcelle_lot",$contenu);
394 $contenu="";
395 $contenu[0][0]="parcelle_lot";// table
396 $contenu[0][1]="lotissement"; // zone origine
397 $contenu[1][0]="parcelle_lot";
398 $contenu[1][1]="parcelle_lot";
399 $form->setSelect("parcelle_lot_lotissement",$contenu);
400 // accord tacite
401 $contenu=array();
402 $contenu[0]=array('Non','Oui');
403 $contenu[1]=array('Non','Oui');
404 $form->setSelect("accord_tacite",$contenu);
405 // terrain_numero_complement
406 $contenu=array();
407 $contenu[0]=array('','bis','ter','quater');
408 $contenu[1]=array('','bis','ter','quater');
409 $form->setSelect("terrain_numero_complement",$contenu);
410 // geom *** a voir
411 if($maj==1){ //modification
412 $contenu=array();
413 $contenu[0]=array("dossier",$this->getParameter("idx"));
414 $form->setSelect('geom',$contenu);
415 }
416
417 /*
418 * Affichage de données dans le select de la parcelle
419 * */
420 $contenu=array();
421 $sql="select parcelle from ".DB_PREFIXE."parcelle ";
422 $res = $db->query($sql);
423 if (database::isError($res))
424 die($res->getMessage());
425 $contenu[0][0]="";
426 $contenu[1][0]=_("choisir parcelle");
427 $k=1;
428 while ($row=& $res->fetchRow()){
429 $contenu[0][$k]=$row[0];
430 $contenu[1][$k]=$row[0];
431 $k++;
432 }
433 $form->setSelect("parcelle",$contenu);
434
435 }
436 if($this->f->getParameter('afficher_division')==='true') {
437 // instructeur
438 $this->init_select($form, $db, $maj, $debug, "instructeur",
439 $sql_instructeur_div, $sql_instructeur_div_by_id, false);
440 }
441 }
442
443 function setLib(&$form,$maj) {
444 parent::setLib($form,$maj);
445 $form->setLib('geom','');
446 }
447
448 function setGroupe(&$form,$maj){
449 If ($maj==0){
450 $form->setGroupe('date_demande','D');
451 $form->setGroupe('date_depot','G');
452 $form->setGroupe('division','F');
453 }else{
454 $form->setGroupe('dossier','D');
455 $form->setGroupe('nature','G');
456 $form->setGroupe('annee','G');
457 $form->setGroupe('date_demande','G');
458 $form->setGroupe('date_depot','G');
459 $form->setGroupe('division','F');
460 }
461 $form->setGroupe('demandeur_categorie','D');
462 $form->setGroupe('demandeur_civilite','G');
463 $form->setGroupe('demandeur_nom','F');
464
465 $form->setGroupe('demandeur_societe','D');
466 $form->setGroupe('demandeur_adresse','G');
467 $form->setGroupe('demandeur_adresse_complement','F');
468
469 $form->setGroupe('demandeur_cp','D');
470 $form->setGroupe('demandeur_ville','G');
471 $form->setGroupe('demandeur_pays','F');
472
473 $form->setGroupe('demandeur_email','D');
474 $form->setGroupe('demandeur_telephone','F');
475
476 $form->setGroupe('delegataire','D');
477 $form->setGroupe('delegataire_civilite','G');
478 $form->setGroupe('delegataire_nom','F');
479
480 $form->setGroupe('delegataire_societe','D');
481 $form->setGroupe('delegataire_adresse','G');
482 $form->setGroupe('delegataire_adresse_complement','F');
483 $form->setGroupe('delegataire_cp','D');
484 $form->setGroupe('delegataire_ville','G');
485 $form->setGroupe('delegataire_pays','F');
486
487 $form->setGroupe('delegataire_email','D');
488 $form->setGroupe('delegataire_telephone','F');
489
490 $form->setGroupe('architecte','D');
491 $form->setGroupe('architecte_nom','F');
492 //$form->setGroupe('saisie_architecte','F');
493
494 $form->setGroupe('travaux','D');
495 $form->setGroupe('travaux_complement','F');
496
497 // terrain
498 $form->setGroupe('terrain_numero','D');
499 $form->setGroupe('terrain_numero_complement','G');
500 $form->setGroupe('rivoli','F');
501 $form->setGroupe('terrain_adresse','D');
502 $form->setGroupe('terrain_adresse_complement','F');
503
504 $form->setGroupe('terrain_cp','D');
505 $form->setGroupe('terrain_ville','F');
506
507 // surface
508 $form->setGroupe('terrain_surface','D');
509 $form->setGroupe('terrain_surface_calcul','F');
510
511 // instruction
512 $form->setGroupe('date_complet','D');
513 $form->setGroupe('date_rejet','G');
514 $form->setGroupe('rejet','G');
515 $form->setGroupe('delai','F');
516
517 $form->setGroupe('date_limite','D');
518 $form->setGroupe('date_notification_delai','G');
519 $form->setGroupe('accord_tacite','G');
520 $form->setGroupe('etat','F');
521
522 $form->setGroupe('date_decision','D');
523 $form->setGroupe('avis_decision','G');
524 $form->setGroupe('date_validite','G');
525 $form->setGroupe('types','F');
526
527 $form->setGroupe('date_chantier','D');
528 $form->setGroupe('date_achevement','G');
529 $form->setGroupe('date_conformite','F');
530
531 // localisation
532 $form->setGroupe('parcelle','D');
533 $form->setGroupe('pos','G');
534 if($maj==1){
535 $form->setGroupe('sig','G');
536 $form->setGroupe('geom','F');
537 }else {
538 $form->setGroupe('sig','F');
539 }
540 if($maj==1){
541 $form->setGroupe('sig','G');
542 $form->setGroupe('geom','F');
543 }
544
545 // description
546 $form->setGroupe('batiment_nombre','D');
547 $form->setGroupe('logement_nombre','G');
548 $form->setGroupe('hauteur','G');
549 $form->setGroupe('piece_nombre','F');
550
551 $form->setGroupe('shon','D');
552 $form->setGroupe('shon_calcul','G');
553 $form->setGroupe('shob','G');
554 $form->setGroupe('lot','F');
555
556 $form->setGroupe('amenagement','D');
557 $form->setGroupe('parcelle_lot','G');
558 $form->setGroupe('parcelle_lot_lotissement','F');
559 }
560
561 function setOnchange(&$form,$maj){
562 parent::setOnchange($form,$maj);
563 // mise en majuscule
564 $form->setOnchange("demandeur_nom","this.value=this.value.toUpperCase()");
565 $form->setOnchange("demandeur_societe","this.value=this.value.toUpperCase()");
566 $form->setOnchange("delegataire_nom","this.value=this.value.toUpperCase()");
567 $form->setOnchange("delegataire_societe","this.value=this.value.toUpperCase()");
568 $form->setOnchange("architecte_nom","this.value=this.value.toUpperCase()");
569 $form->setOnchange("terrain_adresse","this.value=this.value.toUpperCase()");
570 $form->setOnchange('shon','VerifNumdec(this)');
571 $form->setOnchange('shob','VerifNumdec(this)');
572 $form->setOnchange('hauteur','VerifNumdec(this)');
573 $form->setOnchange('terrain_surface','VerifNumdec(this)');
574 }
575
576 function setLayout(&$form, $maj) {
577 $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
578 $form->setFieldset('division', 'F');
579 }
580
581 function setRegroupe(&$form,$maj) {
582 //// depot
583 //If ($maj==0){
584 // $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
585 //}
586 //If ($maj==1){
587 // $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
588 // $form->setRegroupe('date_demande','G','');
589 //}
590 //$form->setRegroupe('date_depot','G','');
591 //$form->setRegroupe('division','F','');
592
593 // travaux
594 $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
595 $form->setRegroupe('architecte_nom','G','');
596 $form->setRegroupe('travaux','G','');
597 $form->setRegroupe('travaux_complement','F','');
598
599 // instruction
600 $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
601 $form->setRegroupe('date_rejet','G','');
602 $form->setRegroupe('date_notification_delai','G','');
603 $form->setRegroupe('delai','G','');
604 $form->setRegroupe('date_limite','G','Decision ');
605 $form->setRegroupe('accord_tacite','G','');
606 $form->setRegroupe('etat','G','');
607 $form->setRegroupe('date_decision','G','');
608 $form->setRegroupe('avis_decision','G','');
609 $form->setRegroupe('date_validite','G','');
610 $form->setRegroupe('types','G','');
611 $form->setRegroupe('date_chantier','G','');
612 $form->setRegroupe('date_achevement','G','');
613 $form->setRegroupe('date_conformite','F','');
614
615 // demandeur
616 $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
617 $form->setRegroupe('demandeur_civilite','G','');
618 $form->setRegroupe('demandeur_nom','G','');
619 $form->setRegroupe('demandeur_societe','G','');
620 $form->setRegroupe('demandeur_adresse','G','Decision ');
621 $form->setRegroupe('demandeur_cp','G','');
622 $form->setRegroupe('demandeur_ville','G','');
623 $form->setRegroupe('demandeur_pays','G','');
624 $form->setRegroupe('demandeur_email','G','');
625 $form->setRegroupe('demandeur_telephone','F','');
626
627
628 // delegataire
629 $form->setRegroupe('delegataire','D',_('delegataire'), $this->aff_delegataire);
630 $form->setRegroupe('delegataire_civilite','G','');
631 $form->setRegroupe('delegataire_nom','G','');
632 $form->setRegroupe('delegataire_societe','G','');
633 $form->setRegroupe('delegataire_adresse','G','Decision ');
634 $form->setRegroupe('delegataire_cp','G','');
635 $form->setRegroupe('delegataire_ville','G','');
636 $form->setRegroupe('delegataire_pays','G','');
637 $form->setRegroupe('delegataire_email','G','');
638 $form->setRegroupe('delegataire_telephone','F','');
639
640 // terrain
641 $form->setRegroupe('terrain_numero','D',_('terrain'), $this->aff_terrain);
642 $form->setRegroupe('terrain_numero_complement','G','');
643 $form->setRegroupe('rivoli','G','');
644 $form->setRegroupe('terrain_adresse','G','');
645 $form->setRegroupe('terrain_adresse_complement','G','');
646 $form->setRegroupe('terrain_cp','G','');
647 $form->setRegroupe('terrain_ville','G','');
648 $form->setRegroupe('terrain_surface','G',_('surface'),'');// $this->aff_surface);
649 $form->setRegroupe('terrain_surface_calcul','F','');
650
651 // localisation
652 $form->setRegroupe('parcelle','D',_('localisation'), $this->aff_localisation);
653 $form->setRegroupe('pos','G','');
654 $form->setRegroupe('sig','F','');
655 if($maj==1){
656 $form->setRegroupe('sig','G','');
657 $form->setRegroupe('geom','F','');
658 }
659
660 // description
661 $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);
662 $form->setRegroupe('logement_nombre','G','');
663 $form->setRegroupe('hauteur','G','');
664 $form->setRegroupe('piece_nombre','G','');
665 $form->setRegroupe('shon','G','');
666 $form->setRegroupe('shon_calcul','G','');
667 $form->setRegroupe('shob','G','');
668 $form->setRegroupe('lot','F','');
669
670 $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);
671 $form->setRegroupe('servitude','F','');
672
673 // amenagement
674 $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
675 $form->setRegroupe('parcelle_lot','G','');
676 $form->setRegroupe('parcelle_lot_lotissement','F','');
677 }
678
679
680
681 /* =============================================================
682 * fonction trigger relative a la connexion SIG
683 * $sig = 1 dans dyn/var.inc
684 * ===============================================================
685 */
686
687 function triggerajouterapres($id,&$db,$val,$DEBUG) {
688 $this->sig_parametre($db);
689 $id=$this->valF['dossier']; // id n est pas valorise en ajout
690 if($this->sig==1 and $val['sig']!='Oui'){
691 if($val['parcelle']!=''or $val['parcelle_lot']!=''){
692
693 $this->sig_interne($id,$db,$val,$DEBUG);
694 }
695 else
696 $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
697
698 }
699 }
700
701 /*
702 * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
703 * */
704 function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {
705
706 $parcelle = trim($parcelle);
707 $quartier = '';
708
709 /*Code impots*/
710 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
711 if (is_numeric($parcelle[$i]) )
712 $quartier .= $parcelle[$i];
713 else
714 break;
715
716 if ( $quartier !== '' ){
717
718 /*identifiant*/
719 $sql = "SELECT
720 quartier, arrondissement
721 FROM
722 quartier
723 WHERE
724 code_impots='$quartier'";
725
726 $res = $db->query($sql);
727 if (database :: isError($res))
728 die($res->getMessage()."erreur ".$sql);
729
730 if ( $res->numRows() > 0 ){
731
732 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
733
734 $quartier = $row['quartier'];
735 $arrondissement = $row['arrondissement'];
736 }
737 }
738 }
739 }
740
741 /*
742 * Retourne la section d'une parcelle
743 * */
744 function getSection($parcelle){
745
746 $parcelle = trim($parcelle);
747 $section = NULL;
748
749 for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
750 if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
751 $section .= $parcelle[$i];
752
753 return $section;
754 }
755
756 /*
757 * Retourne l'intructeur correspondant le mieux Ă  la parcelle
758 * */
759 function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {
760
761 $sql = "
762 SELECT
763 instructeur, section, quartier, arrondissement, nature
764 FROM
765 lien_localisation_nature l
766 WHERE
767 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
768 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
769 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
770 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
771 ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
772 ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
773 ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
774 ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
775 ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
776 ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
777 ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
778 ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
779 ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
780 ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
781 ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
782 ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
783 ORDER BY section, quartier, arrondissement, nature
784 LIMIT 1
785 ";
786
787 $res = $db->query($sql);
788 if (database :: isError($res))
789 die($res->getMessage()."erreur ".$sql);
790
791 if ( $res->numRows() > 0 ){
792 $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
793 return $row['instructeur'];
794 }
795
796 return NULL;
797 }
798
799 /* =============================================================
800 * fonction trigger relative a la connexion SIG
801 * $sig = 1 dans dyn/var.inc
802 * ===============================================================
803 */
804
805 function triggerajouter($id,&$db,$val,$DEBUG) {
806
807
808 /*Localisation*/
809 $quartier = 'NULL';
810 $arrondissement = 'NULL';
811 $section = 'NULL' ;
812
813 if($val['parcelle']!=''){
814
815 $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);
816
817 if ( strcmp($arrondissement,'NULL') == 0 )
818 $quartier = 'NULL';
819
820 $section = $this->getSection($val['parcelle']);
821
822
823 }
824
825 /*Instructeur*/
826 if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){
827
828 $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);
829
830 if ( $instructeur != NULL )
831 $this->valF['instructeur'] = $instructeur;
832 else {
833 if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )
834 $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
835 else
836 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
837 }
838 }
839
840 else
841 $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
842 }
843
844 function triggermodifierapres($id,&$db,$val,$DEBUG) {
845 $this->sig_parametre($db);
846 // si la parcelle est changée
847 if(($this->sig==1 and $val['sig']!='Oui' and ($val['parcelle']!=$val['parcelle_archive'])
848 or $val['parcelle_lot']!=$val['parcelle_lot_archive'])){ // parcelle_lot_archive
849 if($val['parcelle']!='' or $val['parcelle_lot']!='')
850 $this->sig_interne($this->valF['dossier'],$db,$val,$DEBUG);
851 else{
852 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
853 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
854 $res = $db -> query($sql);
855 $this->addToLog("requete trigger modifier parcelle vide -> maj pos et servitude :".$sql, VERBOSE_MODE);
856 if (database :: isError($res))
857 die($res->getMessage()."erreur ".$sql);
858 }
859 $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");
860 }
861 }
862 }
863
864 function sig_parametre(&$db){
865 if (file_exists ("../dyn/var.inc"))
866 include ("../dyn/var.inc");
867 if(!isset($sig))
868 $this->sig=0;
869 else
870 $this->sig=1;
871 if(!isset($auto_pos))
872 $this->auto_pos=0;
873 else
874 $this->auto_pos=$auto_pos;
875 if(!isset($auto_servitude_surfacique))
876 $this->auto_servitude_surfacique=0;
877 else
878 $this->auto_servitude_surfacique=$auto_servitude_surfacique;
879 if(!isset($auto_servitude_ligne))
880 $this->auto_servitude_ligne=0;
881 else
882 $this->auto_servitude_ligne=$auto_servitude_ligne;
883 if(!isset($auto_servitude_point))
884 $this->auto_servitude_point=0;
885 else
886 $this->auto_servitude_point=$auto_servitude_point;
887 if(!isset($auto_parcelle))
888 $this->auto_parcelle=0;
889 else
890 $this->auto_parcelle=$auto_parcelle;
891 if(!isset($auto_parcelle_lot))
892 $this->auto_parcelle_lot=0;
893 else
894 $this->auto_parcelle_lot=$auto_parcelle_lot;
895 $this->addToLog("trigger valeur sig :".$this->sig, VERBOSE_MODE);
896 $this->addToLog("trigger valeur auto_pos :". $this->auto_pos, VERBOSE_MODE);
897 $this->addToLog("trigger valeur auto_servitude_surfacique :".$this->auto_servitude_surfacique, VERBOSE_MODE);
898 $this->addToLog("trigger valeur auto_servitude_ligne :". $this->auto_servitude_ligne, VERBOSE_MODE);
899 $this->addToLog("trigger valeur auto_servitude_point :".$this->auto_servitude_point, VERBOSE_MODE);
900 $this->addToLog("trigger valeur auto_parcelle :". $this->auto_parcelle, VERBOSE_MODE);
901 $this->addToLog("trigger valeur auto_parcelle_lot :".$this->auto_parcelle_lot, VERBOSE_MODE);
902 }
903
904
905 function sig_interne($id,&$db,$val,$DEBUG){
906 // Strategy interne dans var.inc
907 // si la parcelle existe, il est cree un point au milieu de la parcelle
908 // de maniere automatique
909 $geom='';
910 $parcelle=$val["parcelle"];
911 $projection = $db -> getOne("select srid from geometry_columns where f_table_name='dossier'");
912 if($this->auto_parcelle==1 and $val["parcelle"]!=''){
913 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle where parcelle ='".$val["parcelle"]."'";
914 $this->addToLog("recherche centroid parcelle :".$sql, VERBOSE_MODE);
915 $geom = $db -> getOne($sql);
916 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
917 }
918 if($geom=='' and $this->auto_parcelle_lot==1 and $val["parcelle_lot"]!=''){ // lot
919 $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle_lot where parcelle_lot ='".$val["parcelle_lot"]."'";
920 $this->addToLog("recherche centroid parcelle lot :".$sql, VERBOSE_MODE);
921 $geom = $db -> getOne($sql);
922 if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
923 $parcelle=$val["parcelle_lot"]." ".$val["parcelle_lot_lotissement"];
924 }
925 if($geom!=''){ // la parcelle est exitante dans la table ou vue parcelle
926 $sql ="update ".DB_PREFIXE."dossier set geom =geometryfromtext('".$geom."', ".$projection." ) where dossier ='".$id."'";
927 $this->addToLog("sig_interne maj geom :".$sql, VERBOSE_MODE);
928 $res = $db -> query($sql);
929 if (database :: isError($res)) die($res->getMessage()."erreur ".$sql);
930 $this->addToMessage(""._("centroid de parcelle calcule")." ".$parcelle." ");
931 if($this->auto_pos==1) // recherche du pos
932 $this->calcul_auto_pos($id,$db,$geom,$projection);
933 if($this->auto_servitude_surfacique==1) // recherche de servitude surfacique
934 $this->calcul_auto_servitude_surfacique($id,$db,$geom,$projection);
935 if($this->auto_servitude_ligne==1) // recherche de servitude ligne
936 $this->calcul_auto_servitude_ligne($id,$db,$geom,$projection);
937 if($this->auto_servitude_point==1) // recherche de servitude point
938 $this->calcul_auto_servitude_point($id,$db,$geom,$projection);
939 $temp=strtr($this->servitude,"'"," "); // enleve le '
940 $sql1 ="update ".DB_PREFIXE."dossier set servitude = '".$temp."' where dossier = '".$id."'";
941 $res1 = $db -> query($sql1);
942 $this->addToLog("maj servitudes :".$sql1, VERBOSE_MODE);
943 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
944 }else{ // parcelle inexistante //***
945 if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
946 $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
947 $res = $db -> query($sql);
948 $this->addToLog("requete sig_interne maj parcelle inexistante :".$sql, VERBOSE_MODE);
949 if (database :: isError($res))
950 die($res->getMessage()."erreur ".$sql);
951 }
952 //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
953 }
954 }
955
956 function calcul_auto_pos($id,&$db,$geom,$projection){
957 // recherche du pos automatique
958 $sql="select pos from ".DB_PREFIXE."pos WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
959 $pos = $db -> getOne($sql);
960 $this->addToLog("recherche auto_pos :".$sql, VERBOSE_MODE);
961 if($pos!=''){
962 $sql1 ="update ".DB_PREFIXE."dossier set pos = '".$pos."' where dossier = '".$id."'";
963 $res1 = $db -> query($sql1);
964 $this->addToLog("maj auto_pos :".$sql1, VERBOSE_MODE);
965 if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
966 $this->addToMessage("<br>"._("POS/PLU")." : ".$pos."");
967 }else{
968 $this->addToMessage("<br>"._("POS/PLU non trouve")." ".$id."");
969 }
970 }
971
972 function calcul_auto_servitude_surfacique($id,&$db,$geom,$projection){
973 // recherche servitude surfacique
974 $sql="select * from ".DB_PREFIXE."servitude_surfacique WHERE ST_contains(geom, geometryfromtext('".$geom."', ".$projection."))";
975 $res=$db->query($sql);
976 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
977 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
978 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
979 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
980 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
981 }
982 }
983
984 function calcul_auto_servitude_ligne($id,&$db,$geom,$projection){
985 // recherche servitude ligne
986 $sql="select * from ".DB_PREFIXE."servitude_ligne WHERE ST_contains(ST_buffer(geom, perimetre), geometryfromtext('".$geom."', ".$projection."))";
987 $res=$db->query($sql);
988 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
989 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
990 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
991 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
992 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." - ";
993 }
994 }
995
996 function calcul_auto_servitude_point($id,&$db,$geom,$projection){
997 // recherche servitude point
998 $sql="select libelle,observation, perimetre, distance(geom, geometryfromtext('".$geom."', ".$projection.")) as distance from ".
999 DB_PREFIXE."servitude_point WHERE distance(geom, geometryfromtext('".$geom."', ".$projection."))<perimetre";
1000 $res=$db->query($sql);
1001 if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1002 $this->addToLog("requete :".$sql." executee ", VERBOSE_MODE);
1003 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1004 $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']." a ".round($row['distance'],2)." m ");
1005 $this->servitude.=" [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
1006 }
1007 }
1008 }// fin classe
1009 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26