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

Diff of /trunk/obj/demande.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 907 by nhaye, Thu Nov 29 15:24:25 2012 UTC revision 1246 by nhaye, Wed Feb 13 10:19:51 2013 UTC
# Line 16  class demande extends demande_gen { Line 16  class demande extends demande_gen {
16      function demande($id,&$db,$debug) {      function demande($id,&$db,$debug) {
17          $this->constructeur($id,$db,$debug);          $this->constructeur($id,$db,$debug);
18      }// fin constructeur      }// fin constructeur
19    
20        function setValF($val) {
21            parent::setValF($val);
22            // Récupération des id demandeurs postés
23            $this->getPostedValues();
24            //$this->valIdDemandeur=$this->postedIdDemandeur;
25        }
26    
27        /**
28         * Méthode permettant de récupérer les valeurs du dossier d'autorisation
29         * correspondant à la nouvelle demande
30         */
31        function getValFromDossier($dossier_autorisation) {
32            include "../sql/pgsql/demande.form.inc.php";
33            $sql=str_replace("<idx>",$this->getParameter("idx_dossier"),
34                        $sql_infos_dossier);
35            $res = $this->db->query($sql);
36            $this->addToLog("demande -> getValFromDossier() : ".$sql);
37            $this->f->isDatabaseError();
38            $row = & $res->fetchRow(DB_FETCHMODE_ASSOC);
39            return $row;
40        }
41            
42       /*       /*
43      * La date du jour par défaut dans le champs date_demande      * La date du jour par défaut dans le champs date_demande
# Line 23  class demande extends demande_gen { Line 45  class demande extends demande_gen {
45      */      */
46      function setVal(&$form, $maj, $validation, &$db) {      function setVal(&$form, $maj, $validation, &$db) {
47          if($maj == 0) {          if($maj == 0) {
48               $form->setVal("date_demande",date('d/m/Y'));              $form->setVal("date_demande",date('d/m/Y'));
49    
50                // Récupération des valeurs du dossier d'autorisation correspondant
51                if($this->getParameter("idx_dossier") != "") {
52                    $val_autorisation = $this->getValFromDossier(
53                                                $this->getParameter("idx_dossier"));
54                    foreach($val_autorisation as $champ => $value) {
55                        $form->setVal($champ,$value);
56                    }
57                }
58          }          }
59      }      }
60            
# Line 32  class demande extends demande_gen { Line 63  class demande extends demande_gen {
63       */       */
64      function verifier($val, &$db, $DEBUG) {      function verifier($val, &$db, $DEBUG) {
65          parent::verifier($val, $db, $DEBUG);          parent::verifier($val, $db, $DEBUG);
         $this->getPostedValues();  
66          if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR          if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR
67             empty($this->postedIdDemandeur["petitionnaire_principal"])) {             empty($this->postedIdDemandeur["petitionnaire_principal"])) {
68              $this->correct = false;              $this->correct = false;
69              $this->addToMessage("La saisie d'un petitionnaire principal est obligatoire.");              $this->addToMessage("La saisie d'un petitionnaire principal est obligatoire.");
             $this->valIdDemandeur=$this->postedIdDemandeur;  
70          }          }
71      }      }
72      /*      /*
# Line 47  class demande extends demande_gen { Line 76  class demande extends demande_gen {
76      function setLayout(&$form, $maj){      function setLayout(&$form, $maj){
77          if ( $maj < 2 OR $maj == 3 ) {          if ( $maj < 2 OR $maj == 3 ) {
78                            
79              //Champs sur lequel s'ouvre le fieldset              /*Champ sur lequel s'ouvre le bloc 1 */
80              $form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8");              $form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8");
81                
82                  $form->setFieldset('dossier_autorisation_type_detaille','D'                  $form->setFieldset('dossier_autorisation_type_detaille','D'
83                                     ,_('Type de dossier/demande'));                                     ,_('Type de dossier/demande'));
84                  $form->setFieldset('demande_type','F','');                  $form->setFieldset('demande_type','F','');
85                            
86              $form->setBloc('demande_type','F');              $form->setBloc('demande_type','F');
87                /*Fin bloc 1*/
88                            
89                /*Champ sur lequel s'ouvre le bloc 2 */
90              $form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc");              $form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc");
91                  $form->setFieldset('date_demande','D',_('Date de la demande'));                  $form->setFieldset('date_demande','D',_('Date de la demande'));
92                  $form->setFieldset('date_demande','F','');                  $form->setFieldset('date_demande','F','');
93              $form->setBloc('date_demande','F');              $form->setBloc('date_demande','F');
94                /*Fin bloc 2*/
95                            
96                /*Champ sur lequel s'ouvre le bloc 3 */
97              $form->setBloc('terrain_references_cadastrales','D',"",              $form->setBloc('terrain_references_cadastrales','D',"",
98                             "localisation col_12 demande_hidden_bloc");                             "localisation col_12 demande_hidden_bloc");
99                  $form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain'));                  $form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain'));
100                  $form->setFieldset('terrain_superficie','F','');                  $form->setFieldset('terrain_superficie','F','');
101              $form->setBloc('terrain_superficie','F');              $form->setBloc('terrain_superficie','F');
102                /*Fin bloc 4*/
103                            
             $form->setBloc('nombre_lots','D',"","lots col_12 demande_hidden_bloc");  
                 $form->setFieldset('nombre_lots','D',_('Nombre de lots'));  
                 $form->setFieldset('nombre_lots','F','');  
             $form->setBloc('nombre_lots','F');  
104          }          }
105      }      }
106    
# Line 93  class demande extends demande_gen { Line 123  class demande extends demande_gen {
123                    
124          $form->setType('dossier_instruction', 'hidden');          $form->setType('dossier_instruction', 'hidden');
125          $form->setType('dossier_autorisation', 'hidden');          $form->setType('dossier_autorisation', 'hidden');
126    
127            $form->setType('instruction_recepisse', 'hidden');
128            $form->setType('arrondissement', 'hidden');
129    
130            // Si il s'agit d'une demande sur dossier existant on desactive tous les champs
131            // sauf demande_type
132            if(($maj == 0 AND $this-> getParameter("idx_dossier"))) {
133                $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
134                $form->setType('terrain_references_cadastrales', 'hiddenstatic');
135                $form->setType('terrain_adresse_voie_numero', 'hiddenstatic');
136                $form->setType('complement', 'hiddenstatic');
137                $form->setType('terrain_adresse_lieu_dit', 'hiddenstatic');
138                $form->setType('terrain_adresse_localite', 'hiddenstatic');
139                $form->setType('terrain_adresse_code_postal', 'hiddenstatic');
140                $form->setType('terrain_adresse_bp', 'hiddenstatic');
141                $form->setType('terrain_adresse_cedex', 'hiddenstatic');
142                $form->setType('terrain_superficie', 'hiddenstatic');
143            }
144            if($maj == 1) {
145                $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
146                $form->setType('demande_type', 'selecthiddenstatic');
147            }
148            if($maj == 3) {
149                $form->setType('terrain_references_cadastrales', 'referencescadastralesstatic');
150            }
151    
152        }
153    
154        /**
155         * Méthode permettant d'ajouter un dossier d'autorisation
156         */
157        function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){
158            require_once '../obj/dossier_autorisation.class.php';
159            $dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG);
160            // Création du dossier
161            foreach($dossier_autorisation->champs as $value) {
162                $valAuto[$value] = NULL;
163            }
164            $valAuto['dossier_autorisation']=NULL;
165            $valAuto['exercice']=NULL;
166            $valAuto['insee']=NULL;
167            $valAuto['arrondissement']=NULL;
168            $valAuto['etat']=NULL;
169            $valAuto['erp_numero_batiment']=NULL;
170            $valAuto['erp_ouvert']=NULL;
171            $valAuto['erp_arrete_decision']=NULL;
172            $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
173            $valAuto['depot_initial']=$this->valF['date_demande'];
174            $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
175            $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
176            $valAuto['complement']=$this->valF['complement'];
177            $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
178            $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
179            $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
180            $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
181            $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
182            $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];
183            $valAuto['numero_version']=-1;
184            // Ajout du dossier dans la base
185            $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);
186            // Liaison du dossier ajouter à la demande
187            $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];
188        }
189    
190        /**
191         * Méthode permettant d'ajouter un dossier d'instruction
192         */
193        function ajoutDossierInstruction($id, &$db, $val, $DEBUG, $dossier_instruction_type){
194            require_once '../obj/dossier.class.php';
195            $dossier = new dossier("]",$db,$DEBUG);
196            foreach($dossier->champs as $value) {
197                $valInstr[$value] = NULL;
198            }
199            require_once '../obj/dossier_autorisation_type_detaille.class.php';
200            $datd = new dossier_autorisation_type_detaille(
201                    $this->valF['dossier_autorisation_type_detaille'],$db,$DEBUG);
202                    
203            /*Ajout de la variable dossier_instruction_type à l'objet dossier pour le
204             * versionning
205             */
206            $dossier->setDossierInstructionType($dossier_instruction_type);
207            
208            // Définition des valeurs à entrée dans la table
209            $valInstr['dossier_instruction_type']=$dossier_instruction_type;
210            $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);
211            $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);
212            $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
213            $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
214            $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
215            $valInstr['complement']=$this->valF['complement'];
216            $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
217            $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
218            $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
219            $valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
220            $valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
221            $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];
222            $valInstr['description']="";
223            $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];
224            $dossier->ajouter($valInstr, $db, $DEBUG);
225            $this->f->isDatabaseError();
226            // Liaison du dossier ajouter à la demande
227            $this->valF['dossier_instruction'] = $dossier->valF['dossier'];
228      }      }
229    
230      /**      /**
231       * Méthode permettant la création de dossiers       * Ajout des liens demandeurs / dossier d'autorisation
232         **/
233        function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
234            // Création des liens entre le dossier autorisation et les demandeurs
235            include '../sql/pgsql/demande.form.inc.php';
236            require_once '../obj/lien_dossier_autorisation_demandeur.class.php';
237            $ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG);
238            // Recupération des demandeurs liés à la demande
239            $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);
240            $res = $db->query($sql);
241            $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
242            $this->f->isDatabaseError();
243            while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
244                $row['lien_dossier_autorisation_demandeur'] = NULL;
245                $row['dossier_autorisation'] = $this->valF['dossier_autorisation'];
246                $ldad->ajouter($row, $db, $DEBUG);
247            }
248        }
249    
250        /**
251         * Ajout des liens demandeurs / dossier d'autorisation
252         **/
253        function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) {
254            // Création des liens entre le dossier instruction et les demandeurs
255            include '../sql/pgsql/demande.form.inc.php';
256            require_once '../obj/lien_dossier_demandeur.class.php';
257            $ldd = new lien_dossier_demandeur("]",$db,$DEBUG);
258            // Recupération des demandeurs liés à la demande
259            $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);
260            $res = $db->query($sql);
261            $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
262            $this->f->isDatabaseError();
263            while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
264                $row['lien_dossier_demandeur'] = NULL;
265                $row['dossier'] = $this->valF['dossier_instruction'];
266                $ldd->ajouter($row, $db, $DEBUG);
267            }
268        }
269    
270        /*
271         * Récupère l'identifiant d'un arrondissement à partir d'un code postal
272         */
273        function getArrondissement($terrain_adresse_code_postal){
274            
275            $arrondissement = NULL;
276            
277            $sql = "SELECT
278                        arrondissement
279                    FROM
280                        ".DB_PREFIXE."arrondissement
281                    WHERE
282                        code_postal = '$terrain_adresse_code_postal' ";
283            $this->addToLog("demande.class.php : ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
284            
285            $res = $this->db->query($sql);
286            $this->f->isDatabaseError($res);
287            
288            if( $res->numrows() > 0 ) {
289                
290                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
291                $arrondissement = $row['arrondissement'];
292            }
293            
294            return $arrondissement;
295        }
296        
297        /*
298         * Récupère l'évènement lié à un type de demande
299         */
300         function getEvenement($demande_type){
301            
302             $evenement = NULL;
303            
304             $sql =
305                "SELECT
306                    evenement
307                FROM
308                    ".DB_PREFIXE."demande_type
309                WHERE
310                    demande_type = $demande_type";
311                
312            $res = $this->db->query($sql);
313            $this->f->isDatabaseError($res);
314            
315            if ( $res->numrows() > 0 ){
316                    
317                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
318                $evenement = $row['evenement'];
319            }
320            
321            return $evenement;
322         }
323        
324         /*
325         * Récupère la lettre type lié à un événement
326         */
327         function getLettreType($evenement){
328            
329             $lettretype = NULL;
330            
331             $sql =
332                "SELECT
333                    lettretype
334                FROM
335                    ".DB_PREFIXE."evenement
336                WHERE
337                    evenement = $evenement";
338                
339            $res = $this->db->query($sql);
340            $this->f->isDatabaseError($res);
341            
342            if ( $res->numrows() > 0 ){
343                    
344                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
345                $lettretype = $row['lettretype'];
346            }
347            
348            return $lettretype;
349         }
350        
351        /**
352         * Ajout des dossiers
353       **/       **/
354      function triggerAjoutDossier($id, &$db, $val, $DEBUG){      function triggerAjouter($id, &$db, $val, $DEBUG){
355          include '../sql/pgsql/demande.form.inc.php';          include '../sql/pgsql/demande.form.inc.php';
356          if($this->valF["demande_type"] != NULL) {          if($this->valF["demande_type"] != NULL) {
357              $res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id));              $res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id));
358              $this->f->isDatabaseError();              $this->f->isDatabaseError();
359              $row = $res->fetchRow(DB_FETCHMODE_ASSOC);              $dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC);
360              // Création du dossier_autorisation              // Création du dossier_autorisation
361              if($row ['dossier_autorisation_type_detaille'] != NULL) {              if($this->valF['dossier_autorisation'] == "") {
362                  // Création du dossier                  $this->ajoutDossierAutorisation($id, $db, $val, $DEBUG);
                 $valAuto['dossier_autorisation']=NULL;  
                 $valAuto['nature']=NULL;  
                 $valAuto['exercice']=NULL;  
                 $valAuto['insee']=NULL;  
                 $valAuto['arrondissement']=NULL;  
                 $valAuto['etat']=NULL;  
                 $valAuto['erp_numero_batiment']=NULL;  
                 $valAuto['erp_ouvert']=NULL;  
                 $valAuto['erp_arrete_decision']=NULL;  
                 $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];  
                 $valAuto['depot_initial']=$this->valF['date_demande'];  
                 $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];  
                 $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];  
                 $valAuto['complement']=$this->valF['complement'];  
                 $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];  
                 $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];  
                 $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];  
                 $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];  
                 $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];  
                 $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];  
                 require_once '../obj/dossier_autorisation.class.php';  
                 $dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG);  
                 $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);  
                 $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];  
                 // Création des liens entre le dossier et les demandeurs  
                 require_once '../obj/lien_dossier_autorisation_demandeur.class.php';  
                 $ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG);  
                 $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);  
                 $res = $db->query($sql);  
                 $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);  
                 $this->f->isDatabaseError();  
                 print_r($sql);  
                 while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {  
                     $row['lien_dossier_autorisation_demandeur'] = NULL;  
                     $row['dossier_autorisation'] = $this->valF['dossier_autorisation'];  
                     $ldad->ajouter($row, $db, $DEBUG);  
                 }  
363                  $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);                  $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);
364              }              }
365              /*              // Création du dossier d'instruction
366              if($row ['dossier_instruction_type'] != NULL) {              if($dossier_type['dossier_instruction_type'] != NULL) {
367                  $valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
368                    $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
369                }
370                
371                /*Création du lien de téléchargement de récépissé de demande*/
372                if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type'])
373                    && isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){
374                
375                    /*Récupérer l'événement lié à ce type de demande*/
376                    $evenement = $this->getEvenement($this->valF['demande_type']);
377                                    
378                    /*Récupération de la lettre type de l'événement*/
379                    $lettretype = $this->getLettreType($evenement);
380                    
381                    /*Création d'une nouvelle instruction avec cet événement*/
382                    /*Données*/
383                    $valInstr['instruction']=NULL;
384                    
385                    $valInstr['destinataire']=$this->valF['dossier_instruction'];
386                    $valInstr['dossier']=$this->valF['dossier_instruction'];
387                    
388                    $valInstr['date_evenement']=date("d/m/Y");
389                    $valInstr['evenement']=$evenement;
390                    $valInstr['lettretype']=$lettretype;
391                    $valInstr['complement']="";
392                    $valInstr['complement2']="";
393                    
394                    $valInstr['action']="initialisation";
395                    $valInstr['delai']="2";
396                    $valInstr['etat']="notifier";
397                    $valInstr['accord_tacite']="Oui";
398                    $valInstr['delai_notification']="1";
399                    $valInstr['archive_delai']="0";
400                    $valInstr['archive_date_complet']=NULL;
401                    $valInstr['archive_date_rejet']=NULL;
402                    $valInstr['archive_date_limite']=NULL;
403                    $valInstr['archive_date_notification_delai']=NULL;
404                    $valInstr['archive_accord_tacite']="Non";
405                    $valInstr['archive_etat']="initialiser";
406                    $valInstr['archive_date_decision']=NULL;
407                    $valInstr['archive_avis']="";
408                    $valInstr['archive_date_validite']=NULL;
409                    $valInstr['archive_date_achevement']=NULL;
410                    $valInstr['archive_date_chantier']=NULL;
411                    $valInstr['archive_date_conformite']=NULL;
412                    $valInstr['complement3']="";
413                    $valInstr['complement4']="";
414                    $valInstr['complement5']="";
415                    $valInstr['complement6']="";
416                    $valInstr['complement7']="";
417                    $valInstr['complement8']="";
418                    $valInstr['complement9']="";
419                    $valInstr['complement10']="";
420                    $valInstr['complement11']="";
421                    $valInstr['complement12']="";
422                    $valInstr['complement13']="";
423                    $valInstr['complement14']="";
424                    $valInstr['complement15']="";
425                    $valInstr['avis_decision']=NULL;
426                    $valInstr['date_finalisation_courrier']=NULL;
427                    $valInstr['date_envoi_signature']=NULL;
428                    $valInstr['date_retour_signature']=NULL;
429                    $valInstr['date_envoi_rar']=NULL;
430                    $valInstr['date_retour_rar']=NULL;
431                    $valInstr['date_envoi_controle_legalite']=NULL;
432                    $valInstr['date_retour_controle_legalite']=NULL;
433                    $valInstr['signataire_arrete']=NULL;
434                                    
435                    /*Fichier requis*/
436                    require_once '../obj/instruction.class.php';
437                    
438                    /*Création d'un nouveau dossier*/
439                    $instruction = new instruction("]",$db,$DEBUG);
440                    $instruction->valF = "";
441                    $instruction->ajouter($valInstr, $db, $DEBUG);
442                    
443                    /*Si la création a réussie*/
444                    if ( $instruction->valF['instruction'] != "" ){
445                        
446                        /*Affichage du récépissé de la demande*/
447                        $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
448                        $this -> addToMessage("<br/><a
449                            class='lien'
450                            href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$this->valF['dossier_instruction']."'
451                            target='_blank'>
452                                <span
453                                class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
454                                title=\""._("Telecharger le recepisse de la demande")."\">".
455                                    _("Telecharger le recepisse de la demande").
456                                "</span>
457                                &nbsp;&nbsp;&nbsp;&nbsp;".
458                                _("Telecharger le recepisse de la demande")."
459                            </a><br/>");
460                    }
461                    /*Sinon affiche un message d'erreur*/
462                    else {
463                        
464                        $this -> addToMessage(_("Une erreur s'est produite lors de la creation du recepisse"));
465                    }
466                }
467    
468                /*Ajout de l'arrondissement à partir du code postal*/
469                if ( !is_null($this->valF["terrain_adresse_code_postal"]) && is_numeric($this->valF["terrain_adresse_code_postal"]) ){
470                                    
471                  $valInstr['depot_initial']=$this->valF['date_demande'];                  $this->valF["arrondissement"] = $this->getArrondissement($this->valF["terrain_adresse_code_postal"]);
                 $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];  
                 $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];  
                 $valInstr['complement']=$this->valF['complement'];  
                 $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];  
                 $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];  
                 $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];  
                 $valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];  
                 $valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];  
                 $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];  
   
                 require_once '../obj/dossier.class.php';  
                 $dossier_instruction = new dossier("]",$db,$DEBUG);  
                 $dossier_instruction->ajouter($valInstr, $db, $DEBUG);  
                 $this->valF['dossier_instruction'] = $dossier_instruction->valF['dossier'];  
472              }              }
             */  
473          }          }
474      }      }
475    
# Line 175  class demande extends demande_gen { Line 478  class demande extends demande_gen {
478       **/       **/
479      function triggerAjouterApres($id, &$db, $val, $DEBUG){      function triggerAjouterApres($id, &$db, $val, $DEBUG){
480          $this->insertLinkDemandeDemandeur($db, $DEBUG);          $this->insertLinkDemandeDemandeur($db, $DEBUG);
481          $this->valIdDemandeur=$this->postedIdDemandeur;          
482          $this->triggerAjoutDossier($id, $db, $val, $DEBUG);          // Ajout des lliens entre dossier_autorisation et demandeur
483            if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) {
484                $this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG);
485            }
486            // Ajout des lliens entre dossier et demandeur
487            if(!empty($this->valF['dossier_instruction'])) {
488                $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
489            }
490    
491            // Duplication des lots et liaison au nouveau dossier_d'instruction
492            if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) {
493                $this->lienLotDossierInstruction($id, $db, $val, $DEBUG);
494            }
495      }      }
496        
497        /*Ajout du lien demande / demandeur(s)*/
498      function triggerModifierApres($id, &$db, $val, $DEBUG){      function triggerModifierApres($id, &$db, $val, $DEBUG){
499          $this->listeDemandeur();          $this->listeDemandeur("demande",$this->val[array_search('demande', $this->champs)]);
500          $this->insertLinkDemandeDemandeur($db, $DEBUG);          $this->insertLinkDemandeDemandeur($db, $DEBUG);
501          $this->valIdDemandeur=$this->postedIdDemandeur;          $this->valIdDemandeur=$this->postedIdDemandeur;
502    
503      }      }
504    
505      /**      /**
506       * Gestion des liens entre la demande et les demendeurs recement ajoutés       * Gestion des liens entre les lots du DA et le nouveau dossier
507         **/
508        function lienLotDossierInstruction($id, $db, $val, $DEBUG) {
509            require_once ("../obj/lot.class.php");
510            $lot = new lot("]", $db, $DEBUG);
511            require_once ("../obj/lien_dossier_lot.class.php");
512            $ldl = new lien_dossier_lot("]", $db, $DEBUG);
513            require_once ("../obj/lien_lot_demandeur.class.php");
514            $lld = new lien_lot_demandeur("]", $db, $DEBUG);
515    
516    
517            $sqlLots = "SELECT * FROM ".DB_PREFIXE."lot
518            WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'";
519            $resLot = $db -> query($sqlLots);
520            $this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE);
521            $this->f->isDatabaseError($resLot);
522            while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){
523                // Insertion du nouveau lot
524                $valLot['lot'] = "";
525                $valLot['libelle'] = $rowLot['libelle'];
526                $valLot['dossier_autorisation'] = NULL;
527                $lot -> ajouter($valLot, $db, $DEBUG);
528    print_r($rowLot);
529                //Insertion du lien entre le lot et le dossier d'instruction
530                $valLdl['lien_dossier_lot'] = "";
531                $valLdl['dossier'] = $this->valF['dossier_instruction'];
532                $valLdl['lot'] = $lot->valF['lot'];
533                $ldl->ajouter($valLdl, $db, $DEBUG);
534    
535                //Insertion des liens entre dossier et les lots
536                $sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur
537                WHERE lot = ".$rowLot['lot'];
538                $res = $db -> query($sqlDemandeurs);
539                $this->f->addToLog("db->query(\"".$sqlDemandeurs."\");", VERBOSE_MODE);
540                $this->f->isDatabaseError($res);
541                
542                while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
543                    $valLld["lien_lot_demandeur"] = "";
544                    $valLld["lot"]=$lot->valF['lot'];
545                    $valLld["demandeur"] = $row['demandeur'];
546                    $valLld["petitionnaire_principal"] = $row['petitionnaire_principal'];
547                    $lld->ajouter($valLld, $db, $DEBUG);
548                }
549            }
550        }
551    
552        /**
553         * Gestion des liens entre la demande et les demandeurs recemment ajoutés
554       **/       **/
555      function insertLinkDemandeDemandeur($db, $DEBUG) {      function insertLinkDemandeDemandeur($db, $DEBUG) {
556          //          //
557          require_once "../obj/lien_demande_demandeur.class.php";          require_once "../obj/lien_demande_demandeur.class.php";
   
558          // Comparaison de l'id petitionnaire principal          // Comparaison de l'id petitionnaire principal
559          if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND          if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND
560             !empty($this->postedIdDemandeur['petitionnaire_principal']) AND             !empty($this->postedIdDemandeur['petitionnaire_principal']) AND
# Line 268  class demande extends demande_gen { Line 631  class demande extends demande_gen {
631    
632      }      }
633    
634        /*
635         * Teste si le lien entre une demande et un demandeur existe
636         * */
637      function isLinkDemandeDemandeurExist($idDemandeur) {      function isLinkDemandeDemandeurExist($idDemandeur) {
638          $sql = "SELECT count(*)          $sql = "SELECT count(*)
639                  FROM ".DB_PREFIXE."lien_demande_demandeur                  FROM ".DB_PREFIXE."lien_demande_demandeur
# Line 307  class demande extends demande_gen { Line 673  class demande extends demande_gen {
673          }          }
674      }      }
675      /**      /**
676       * Méthode permettant de récupérer les id des demandeur lié à la demande       * Méthode permettant de récupérer les id des demandeur liés à la demande ou
677         * liés au dossier d'autorisation
678       **/       **/
679      function listeDemandeur() {      function listeDemandeur($from, $id) {
680          // Récupération des demandeurs de la base          // Récupération des demandeurs de la base
681          $sql = "SELECT demandeur.demandeur,          $sql = "SELECT demandeur.demandeur,
682                          demandeur.type_demandeur,                          demandeur.type_demandeur,
683                          lien_demande_demandeur.petitionnaire_principal                          lien_".$from."_demandeur.petitionnaire_principal
684              FROM ".DB_PREFIXE."lien_demande_demandeur              FROM ".DB_PREFIXE."lien_".$from."_demandeur
685              INNER JOIN ".DB_PREFIXE."demandeur              INNER JOIN ".DB_PREFIXE."demandeur
686              ON demandeur.demandeur=lien_demande_demandeur.demandeur              ON demandeur.demandeur=lien_".$from."_demandeur.demandeur
687              WHERE demande = ".$this->val[array_search('demande', $this->champs)];              WHERE ".$from." = '".$id."'";
688          $res = $this->f->db->query($sql);          $res = $this->f->db->query($sql);
689          $this->f->addToLog("listeDemandeur() : ".$sql);          $this->f->addToLog("listeDemandeur() : ".$sql);
690          $this->f->isDatabaseError($res);          $this->f->isDatabaseError($res);
# Line 335  class demande extends demande_gen { Line 702  class demande extends demande_gen {
702          }          }
703      }      }
704    
705    
706        /**
707         * Surcharge du bouton retour afin de retourner sur la recherche de dossiers
708         * d'instruction existant
709         */
710        function retour($premier = 0, $recherche = "", $tricol = "") {
711    
712            echo "\n<a class=\"retour\" ";
713            echo "href=\"";
714            //
715            if($this->getParameter("idx_dossier") != "") {
716                echo "tab.php?";
717                echo "obj=recherche_dossier";
718    
719            } else {
720                if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) {
721                    echo "form.php?";
722                } else {
723                    echo "tab.php?";
724                }
725                echo "obj=".get_class($this);
726                if($this->getParameter("retour")=="form") {
727                    echo "&amp;idx=".$this->getParameter("idx");
728                    echo "&amp;action=3";
729                }
730            }
731            echo "&amp;premier=".$this->getParameter("premier");
732            echo "&amp;tricol=".$this->getParameter("tricol");
733            echo "&amp;recherche=".$this->getParameter("recherche");
734            echo "&amp;selectioncol=".$this->getParameter("selectioncol");
735            echo "&amp;advs_id=".$this->getParameter("advs_id");
736            echo "&amp;valide=".$this->getParameter("valide");
737            //
738            echo "\"";
739            echo ">";
740            //
741            echo _("Retour");
742            //
743            echo "</a>\n";
744    
745        }
746    
747    
748      /**      /**
749       * Ajout de la liste des demandeurs       * Ajout de la liste des demandeurs
750       */       */
751      function formSpecificContent($maj) {      function formSpecificContent($maj) {
752          if(!$this->correct AND $maj != 0) {          if(!$this->correct AND $maj != 0) {
753              $this->listeDemandeur();              $this->listeDemandeur("demande", $this->val[array_search('demande', $this->champs)]);
754            }
755            // Si le paramètre idx_dossier est défini on récupère les demandeurs liés au dossier d'instruction
756            if($this->getParameter("idx_dossier") != "") {
757                $this->listeDemandeur("dossier", $this->getParameter("idx_dossier"));
758          }          }
759          if($maj < 2 AND !$this->correct) {          if($maj < 2 AND !$this->correct) {
760              $linkable = true;              $linkable = true;
761          } else {          } else {
762              $linkable = false;              $linkable = false;
763          }          }
764    
765          // Conteneur de la listes des demandeurs          // Conteneur de la listes des demandeurs
766          echo "<div class=\"demande_hidden_bloc col_12\">";          echo "<div id=\"liste_demandeur\" class=\"demande_hidden_bloc col_12\">";
767          echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">";          echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">";
768          echo "  <legend class=\"ui-corner-all ui-widget-content ui-state-active\">"          echo "  <legend class=\"ui-corner-all ui-widget-content ui-state-active\">"
769                  ._("Petitionnaire")."</legend>";                  ._("Petitionnaire")."</legend>";
770          // Si des demandeurs sont liés à la demande          // Si des demandeurs sont liés à la demande
771          require_once "../obj/petitionnaire.class.php";          require_once "../obj/petitionnaire.class.php";
772          require_once "../obj/delegataire.class.php";          require_once "../obj/delegataire.class.php";
773            // Affichage du bloc pétitionnaire principal / délégataire
774              // Affichage du bloc pétitionnaire principal / délégataire          // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
775              // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS          echo "<div id=\"petitionnaire_principal_delegataire col_12\">";
776              echo "<div id=\"petitionnaire_principal_delegataire\">";          // Affichage de la synthèse
777              // Affichage de la synthèse          if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND
778              if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND              !empty($this->valIdDemandeur["petitionnaire_principal"])) {
779                  !empty($this->valIdDemandeur["petitionnaire_principal"])) {              $demandeur = new petitionnaire(
780                  $demandeur = new petitionnaire(                                  $this->valIdDemandeur["petitionnaire_principal"],
781                                      $this->valIdDemandeur["petitionnaire_principal"],                                  $this->f->db,false);
782                                      $this->f->db,false);              $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);
783                  $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);              $demandeur -> __destruct();
784                  $demandeur -> __destruct();          } elseif ( isset ($this->postedIdDemandeur["petitionnaire_principal"]) AND
785              }              !empty($this->postedIdDemandeur["petitionnaire_principal"]) ) {
786              // Si en édition de formulaire              $demandeur = new petitionnaire(
787              if($maj < 2 AND $this->correct != true) {                                  $this->postedIdDemandeur["petitionnaire_principal"],
788                  // Bouton d'ajout du pétitionnaire principal                                  $this->f->db,false);
789                  // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS              $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);
790                  echo "<input id=\"add_petitionnaire_principal\"              $demandeur -> __destruct();
791                      class=\"ui-button ui-widget ui-state-default ui-corner-all\"          }
792                      type=\"button\" value=\""._("Saisir le petitionnaire principal")."\"/>";          // Si en édition de formulaire
793                  echo " <span class=\"om-icon om-icon-16 om-icon-fix arrow-right-16\">></span> ";          if($maj < 2) {
794                  // Bouton d'ajout du delegataire              // Bouton d'ajout du pétitionnaire principal
795                  // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS              // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
796                  echo "<input id=\"add_delegataire\"              echo "<span id=\"add_petitionnaire_principal\"
797                      class=\"ui-button ui-widget ui-state-default ui-corner-all\"                  class=\"om-form-button add-16\">".
798                      type=\"button\" value=\""._("Saisir le delegataire")."\"/>";                  _("Saisir le petitionnaire principal").
799              }              "</span>";
800              // Affichage de la synthèse          }
801              if (isset ($this->valIdDemandeur["delegataire"]) AND          // Bouton d'ajout du delegataire
802                  !empty($this->valIdDemandeur["delegataire"])) {          // L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
803                  $demandeur = new delegataire($this->valIdDemandeur["delegataire"],          echo "<div id=\"delegataire\">";
804                                             $this->f->db,false);          // Affichage de la synthèse
805                  $demandeur -> afficherSynthese("delegataire", $linkable);          if (isset ($this->valIdDemandeur["delegataire"]) AND
806                !empty($this->valIdDemandeur["delegataire"])) {
807                $demandeur = new delegataire($this->valIdDemandeur["delegataire"],
808                                           $this->f->db,false);
809                $demandeur -> afficherSynthese("delegataire", $linkable);
810                $demandeur -> __destruct();
811            } elseif ( isset ($this->postedIdDemandeur["delegataire"]) AND
812            !empty($this->postedIdDemandeur["delegataire"]) ) {
813    
814                $demandeur = new delegataire($this->postedIdDemandeur["delegataire"],
815                                           $this->f->db,false);
816                $demandeur -> afficherSynthese("delegataire", $linkable);
817                $demandeur -> __destruct();
818            }
819            if($maj < 2) {
820                echo "<span id=\"add_delegataire\"
821                        class=\"om-form-button add-16\">".
822                        _("Saisir le delegataire").
823                    "</span>";
824            }
825            echo "</div>";
826            echo "<div class=\"both\"></div>";
827            echo "</div>";
828            // Bloc des pétitionnaires secondaires
829            // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
830            echo "<div id=\"listePetitionnaires col_12\">";
831    
832             // Affichage de la synthèse
833            if (isset ($this->valIdDemandeur["petitionnaire"]) AND
834                !empty($this->valIdDemandeur["petitionnaire"])) {
835                
836                foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) {
837                    $demandeur = new petitionnaire($petitionnaire,
838                                           $this->f->db,false);
839                    $demandeur -> afficherSynthese("petitionnaire", $linkable);
840                  $demandeur -> __destruct();                  $demandeur -> __destruct();
841              }              }
842                            
843              echo "</div>";          } elseif ( isset ($this->postedIdDemandeur["petitionnaire"]) AND
844                !empty($this->postedIdDemandeur["petitionnaire"]) )  {
845              // Bloc des pétitionnaires secondaires              foreach ($this->postedIdDemandeur["petitionnaire"] as $petitionnaire) {
846              // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS                  $demandeur = new petitionnaire($petitionnaire,
847              echo "<div id=\"listePetitionnaires\">";                                         $this->f->db,false);
848                    $demandeur -> afficherSynthese("petitionnaire", $linkable);
849               // Affichage de la synthèse                  $demandeur -> __destruct();
             if (isset ($this->valIdDemandeur["petitionnaire"]) AND  
                 !empty($this->valIdDemandeur["petitionnaire"])) {  
                   
                 foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) {  
                     $demandeur = new petitionnaire($petitionnaire,  
                                            $this->f->db,false);  
                     $demandeur -> afficherSynthese("petitionnaire", $linkable);  
                     $demandeur -> __destruct();  
                 }  
                   
             }  
             if ($maj < 2 AND !$this->correct) {  
                 // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS  
                 echo "<input id=\"add_petitionnaire\"  
                         class=\"ui-button ui-widget ui-state-default ui-corner-all\"  
                         type=\"button\" value=\""._("Ajouter un petitionnaire")."\"/>";  
850              }              }
851              echo "</div>";          }
852            if ($maj < 2) {
853                // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
854                echo "<span id=\"add_petitionnaire\"
855                        class=\"om-form-button add-16\">".
856                        _("Ajouter un petitionnaire")
857                    ."</span>";
858            }
859            echo "</div>";
860          echo "</fieldset>";          echo "</fieldset>";
861          echo "</div>";          echo "</div>";
862      }      }
863    
864        // {{{
865    
866        // getter
867        function getValIdDemandeur() {
868            return $this->valIdDemandeur;
869        }
870        // setter
871        function setValIdDemandeur($valIdDemandeur) {
872            $this->valIdDemandeur = $valIdDemandeur;
873        }
874        
875        //Supression du lien entre la demandeur et le(s) demandeur(s)
876        function triggerSupprimer($id, &$db, $val, $DEBUG){
877            
878            //Création de la requête
879            $sql = "DELETE FROM
880                        ".DB_PREFIXE."lien_demande_demandeur
881                    WHERE
882                        demande = $id";
883                  
884            $res = $this->f->db->query($sql);
885            $this->f->addToLog("triggerSupprimer() : ".$sql);
886            $this->f->isDatabaseError($res);
887        }
888        
889        // }}}
890  }// fin classe  }// fin classe
 ?>  
891    ?>

Legend:
Removed from v.907  
changed lines
  Added in v.1246

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26