/[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 908 by nhaye, Thu Nov 29 15:36:11 2012 UTC revision 1140 by nhaye, Thu Jan 3 17:19:08 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                            
104                /*Champ sur lequel s'ouvre le bloc 4 */
105              $form->setBloc('nombre_lots','D',"","lots col_12 demande_hidden_bloc");              $form->setBloc('nombre_lots','D',"","lots col_12 demande_hidden_bloc");
106                  $form->setFieldset('nombre_lots','D',_('Nombre de lots'));                  $form->setFieldset('nombre_lots','D',_('Nombre de lots'));
107                  $form->setFieldset('nombre_lots','F','');                  $form->setFieldset('nombre_lots','F','');
108              $form->setBloc('nombre_lots','F');              $form->setBloc('nombre_lots','F');
109                /*Fin bloc 5*/
110          }          }
111      }      }
112    
# Line 93  class demande extends demande_gen { Line 129  class demande extends demande_gen {
129                    
130          $form->setType('dossier_instruction', 'hidden');          $form->setType('dossier_instruction', 'hidden');
131          $form->setType('dossier_autorisation', 'hidden');          $form->setType('dossier_autorisation', 'hidden');
132    
133            $form->setType('instruction_recepisse', 'hidden');
134            $form->setType('arrondissement', 'hidden');
135    
136            // Si il s'agit d'une demande sur dossier existant on desactive tous les champs
137            // sauf demande_type
138            if(($maj == 0 AND $this-> getParameter("idx_dossier"))) {
139                $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
140                $form->setType('terrain_references_cadastrales', 'hiddenstatic');
141                $form->setType('terrain_adresse_voie_numero', 'hiddenstatic');
142                $form->setType('complement', 'hiddenstatic');
143                $form->setType('terrain_adresse_lieu_dit', 'hiddenstatic');
144                $form->setType('terrain_adresse_localite', 'hiddenstatic');
145                $form->setType('terrain_adresse_code_postal', 'hiddenstatic');
146                $form->setType('terrain_adresse_bp', 'hiddenstatic');
147                $form->setType('terrain_adresse_cedex', 'hiddenstatic');
148                $form->setType('terrain_superficie', 'hiddenstatic');
149                $form->setType('nombre_lots', 'hiddenstatic');
150            }
151            if($maj == 1) {
152                $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
153                $form->setType('demande_type', 'selecthiddenstatic');
154            }
155            if($maj == 3) {
156                $form->setType('terrain_references_cadastrales', 'referencescadastralesstatic');
157            }
158    
159      }      }
160    
161      /**      /**
162       * Méthode permettant la création de dossiers       * Méthode permettant d'ajouter un dossier d'autorisation
163         */
164        function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){
165            require_once '../obj/dossier_autorisation.class.php';
166            $dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG);
167            // Création du dossier
168            foreach($dossier_autorisation->champs as $value) {
169                $valAuto[$value] = NULL;
170            }
171            $valAuto['dossier_autorisation']=NULL;
172            $valAuto['nature']=NULL;
173            $valAuto['exercice']=NULL;
174            $valAuto['insee']=NULL;
175            $valAuto['arrondissement']=NULL;
176            $valAuto['etat']=NULL;
177            $valAuto['erp_numero_batiment']=NULL;
178            $valAuto['erp_ouvert']=NULL;
179            $valAuto['erp_arrete_decision']=NULL;
180            $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
181            $valAuto['depot_initial']=$this->valF['date_demande'];
182            $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
183            $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
184            $valAuto['complement']=$this->valF['complement'];
185            $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
186            $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
187            $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
188            $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
189            $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
190            $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];
191            $valAuto['numero_version']=-1;
192            // Ajout du dossier dans la base
193            $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);
194            // Liaison du dossier ajouter à la demande
195            $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];
196        }
197    
198        /**
199         * Méthode permettant d'ajouter un dossier d'instruction
200         */
201        function ajoutDossierInstruction($id, &$db, $val, $DEBUG, $dossier_instruction_type){
202            require_once '../obj/dossier.class.php';
203            $dossier = new dossier("]",$db,$DEBUG);
204            foreach($dossier->champs as $value) {
205                $valInstr[$value] = NULL;
206            }
207            require_once '../obj/dossier_autorisation_type_detaille.class.php';
208            $datd = new dossier_autorisation_type_detaille(
209                    $this->valF['dossier_autorisation_type_detaille'],$db,$DEBUG);
210                    
211            /*Ajout de la variable dossier_instruction_type à l'objet dossier pour le
212             * versionning
213             */
214            $dossier->setDossierInstructionType($dossier_instruction_type);
215            
216            // Définition des valeurs à entrée dans la table
217            $valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
218            $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);
219            $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);
220            $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
221            $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
222            $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
223            $valInstr['complement']=$this->valF['complement'];
224            $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
225            $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
226            $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
227            $valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
228            $valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
229            $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];
230            $valInstr['description']="";
231            $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];
232            $dossier->ajouter($valInstr, $db, $DEBUG);
233            $this->f->isDatabaseError();
234            // Liaison du dossier ajouter à la demande
235            $this->valF['dossier_instruction'] = $dossier->valF['dossier'];
236        }
237    
238        /**
239         * Ajout des liens demandeurs / dossier d'autorisation
240       **/       **/
241      function triggerAjoutDossier($id, &$db, $val, $DEBUG){      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
242            // Création des liens entre le dossier autorisation et les demandeurs
243            include '../sql/pgsql/demande.form.inc.php';
244            require_once '../obj/lien_dossier_autorisation_demandeur.class.php';
245            $ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG);
246            // Recupération des demandeurs liés à la demande
247            $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);
248            $res = $db->query($sql);
249            $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
250            $this->f->isDatabaseError();
251            while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
252                $row['lien_dossier_autorisation_demandeur'] = NULL;
253                $row['dossier_autorisation'] = $this->valF['dossier_autorisation'];
254                $ldad->ajouter($row, $db, $DEBUG);
255            }
256        }
257    
258        /**
259         * Ajout des liens demandeurs / dossier d'autorisation
260         **/
261        function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) {
262            // Création des liens entre le dossier instruction et les demandeurs
263            include '../sql/pgsql/demande.form.inc.php';
264            require_once '../obj/lien_dossier_demandeur.class.php';
265            $ldd = new lien_dossier_demandeur("]",$db,$DEBUG);
266            // Recupération des demandeurs liés à la demande
267            $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);
268            $res = $db->query($sql);
269            $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
270            $this->f->isDatabaseError();
271            while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
272                $row['lien_dossier_demandeur'] = NULL;
273                $row['dossier'] = $this->valF['dossier_instruction'];
274                $ldd->ajouter($row, $db, $DEBUG);
275            }
276        }
277    
278        /*
279         * Récupère l'identifiant d'un arrondissement à partir d'un code postal
280         */
281        function getArrondissement($terrain_adresse_code_postal){
282            
283            $arrondissement = NULL;
284            
285            $sql = "SELECT
286                        arrondissement
287                    FROM
288                        ".DB_PREFIXE."arrondissement
289                    WHERE
290                        code_postal = '$terrain_adresse_code_postal' ";
291            $this->addToLog("demande.class.php : ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
292            
293            $res = $this->db->query($sql);
294            $this->f->isDatabaseError($res);
295            
296            if( $res->numrows() > 0 ) {
297                
298                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
299                $arrondissement = $row['arrondissement'];
300            }
301            
302            return $arrondissement;
303        }
304        
305        /*
306         * Récupère l'évènement lié à un type de demande
307         */
308         function getEvenement($demande_type){
309            
310             $evenement = NULL;
311            
312             $sql =
313                "SELECT
314                    evenement
315                FROM
316                    ".DB_PREFIXE."demande_type
317                WHERE
318                    demande_type = $demande_type";
319                
320            $res = $this->db->query($sql);
321            $this->f->isDatabaseError($res);
322            
323            if ( $res->numrows() > 0 ){
324                    
325                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
326                $evenement = $row['evenement'];
327            }
328            
329            return $evenement;
330         }
331        
332         /*
333         * Récupère la lettre type lié à un événement
334         */
335         function getLettreType($evenement){
336            
337             $lettretype = NULL;
338            
339             $sql =
340                "SELECT
341                    lettretype
342                FROM
343                    ".DB_PREFIXE."evenement
344                WHERE
345                    evenement = $evenement";
346                
347            $res = $this->db->query($sql);
348            $this->f->isDatabaseError($res);
349            
350            if ( $res->numrows() > 0 ){
351                    
352                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
353                $lettretype = $row['lettretype'];
354            }
355            
356            return $lettretype;
357         }
358        
359        /**
360         * Ajout des dossiers
361         **/
362        function triggerAjouter($id, &$db, $val, $DEBUG){
363          include '../sql/pgsql/demande.form.inc.php';          include '../sql/pgsql/demande.form.inc.php';
364          if($this->valF["demande_type"] != NULL) {          if($this->valF["demande_type"] != NULL) {
365              $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));
366              $this->f->isDatabaseError();              $this->f->isDatabaseError();
367              $row = $res->fetchRow(DB_FETCHMODE_ASSOC);              $dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC);
368              // Création du dossier_autorisation              // Création du dossier_autorisation
369              if($row ['dossier_autorisation_type_detaille'] != NULL) {              if($this->valF['dossier_autorisation'] == "") {
370                  // 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();  
                 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);  
                 }  
371                  $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);                  $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);
372              }              }
373              /*              // Création du dossier d'instruction
374              if($row ['dossier_instruction_type'] != NULL) {              if($dossier_type['dossier_instruction_type'] != NULL) {
375                  $valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
376                    $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
377                }
378                
379                /*Création du lien de téléchargement de récépissé de demande*/
380                if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type'])
381                    && isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){
382                
383                    /*Récupérer l'événement lié à ce type de demande*/
384                    $evenement = $this->getEvenement($this->valF['demande_type']);
385                                    
386                    /*Récupération de la lettre type de l'événement*/
387                    $lettretype = $this->getLettreType($evenement);
388                    
389                    /*Création d'une nouvelle instruction avec cet événement*/
390                    /*Données*/
391                    $valInstr['instruction']=NULL;
392                    
393                    $valInstr['destinataire']=$this->valF['dossier_instruction'];
394                    $valInstr['dossier']=$this->valF['dossier_instruction'];
395                    
396                    $valInstr['date_evenement']=date("d/m/Y");
397                    $valInstr['evenement']=$evenement;
398                    $valInstr['lettretype']=$lettretype;
399                    $valInstr['complement']="";
400                    $valInstr['complement2']="";
401                                    
402                  $valInstr['depot_initial']=$this->valF['date_demande'];                  $valInstr['action']="initialisation";
403                  $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];                  $valInstr['delai']="2";
404                  $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];                  $valInstr['etat']="notifier";
405                  $valInstr['complement']=$this->valF['complement'];                  $valInstr['accord_tacite']="Oui";
406                  $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];                  $valInstr['delai_notification']="1";
407                  $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];                  $valInstr['archive_delai']="0";
408                  $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];                  $valInstr['archive_date_complet']=NULL;
409                  $valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];                  $valInstr['archive_date_rejet']=NULL;
410                  $valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];                  $valInstr['archive_date_limite']=NULL;
411                  $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];                  $valInstr['archive_date_notification_delai']=NULL;
412                    $valInstr['archive_accord_tacite']="Non";
413                  require_once '../obj/dossier.class.php';                  $valInstr['archive_etat']="initialiser";
414                  $dossier_instruction = new dossier("]",$db,$DEBUG);                  $valInstr['archive_date_decision']=NULL;
415                  $dossier_instruction->ajouter($valInstr, $db, $DEBUG);                  $valInstr['archive_avis']="";
416                  $this->valF['dossier_instruction'] = $dossier_instruction->valF['dossier'];                  $valInstr['archive_date_validite']=NULL;
417                    $valInstr['archive_date_achevement']=NULL;
418                    $valInstr['archive_date_chantier']=NULL;
419                    $valInstr['archive_date_conformite']=NULL;
420                    $valInstr['complement3']="";
421                    $valInstr['complement4']="";
422                    $valInstr['complement5']="";
423                    $valInstr['complement6']="";
424                    $valInstr['complement7']="";
425                    $valInstr['complement8']="";
426                    $valInstr['complement9']="";
427                    $valInstr['complement10']="";
428                    $valInstr['complement11']="";
429                    $valInstr['complement12']="";
430                    $valInstr['complement13']="";
431                    $valInstr['complement14']="";
432                    $valInstr['complement15']="";
433                    $valInstr['avis_decision']=NULL;
434                    $valInstr['date_finalisation_courrier']=NULL;
435                    $valInstr['date_envoi_signature']=NULL;
436                    $valInstr['date_retour_signature']=NULL;
437                    $valInstr['date_envoi_rar']=NULL;
438                    $valInstr['date_retour_rar']=NULL;
439                    $valInstr['date_envoi_controle_legalite']=NULL;
440                    $valInstr['date_retour_controle_legalite']=NULL;
441                                    
442                    /*Fichier requis*/
443                    require_once '../obj/instruction.class.php';
444                    
445                    /*Création d'un nouveau dossier*/
446                    $instruction = new instruction("]",$db,$DEBUG);
447                    $instruction->valF = "";
448                    $instruction->ajouter($valInstr, $db, $DEBUG);
449                    
450                    /*Si la création a réussie*/
451                    if ( $instruction->valF['instruction'] != "" ){
452                        
453                        /*Affichage du récépissé de la demande*/
454                        $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
455                        $this -> addToMessage("<br/><a
456                            class='lien'
457                            href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$this->valF['dossier_instruction']."'
458                            target='_blank'>
459                                <span
460                                class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
461                                title=\""._("Telecharger le recepisse de la demande")."\">".
462                                    _("Telecharger le recepisse de la demande").
463                                "</span>
464                                &nbsp;&nbsp;&nbsp;&nbsp;".
465                                _("Telecharger le recepisse de la demande")."
466                            </a><br/>");
467                    }
468                    /*Sinon affiche un message d'erreur*/
469                    else {
470                        
471                        $this -> addToMessage(_("Une erreur s'est produite lors de la creation du recepisse"));
472                    }
473                }
474    
475                /*Ajout de l'arrondissement à partir du code postal*/
476                if ( !is_null($this->valF["terrain_adresse_code_postal"]) && is_numeric($this->valF["terrain_adresse_code_postal"]) ){
477                    
478                    $this->valF["arrondissement"] = $this->getArrondissement($this->valF["terrain_adresse_code_postal"]);
479              }              }
             */  
480          }          }
481      }      }
482    
# Line 174  class demande extends demande_gen { Line 485  class demande extends demande_gen {
485       **/       **/
486      function triggerAjouterApres($id, &$db, $val, $DEBUG){      function triggerAjouterApres($id, &$db, $val, $DEBUG){
487          $this->insertLinkDemandeDemandeur($db, $DEBUG);          $this->insertLinkDemandeDemandeur($db, $DEBUG);
488          $this->valIdDemandeur=$this->postedIdDemandeur;          
489          $this->triggerAjoutDossier($id, $db, $val, $DEBUG);          // Ajout des lliens entre dossier_autorisation et demandeur
490            if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) {
491                $this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG);
492            }
493            // Ajout des lliens entre dossier et demandeur
494            if(!empty($this->valF['dossier_instruction'])) {
495                $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
496            }
497      }      }
498        
499        /*Ajout du lien demande / demandeur(s)*/
500      function triggerModifierApres($id, &$db, $val, $DEBUG){      function triggerModifierApres($id, &$db, $val, $DEBUG){
501          $this->listeDemandeur();          $this->listeDemandeur("demande",$this->val[array_search('demande', $this->champs)]);
502          $this->insertLinkDemandeDemandeur($db, $DEBUG);          $this->insertLinkDemandeDemandeur($db, $DEBUG);
503          $this->valIdDemandeur=$this->postedIdDemandeur;          $this->valIdDemandeur=$this->postedIdDemandeur;
504    
505      }      }
506    
507      /**      /**
508       * Gestion des liens entre la demande et les demendeurs recement ajoutés       * Gestion des liens entre la demande et les demandeurs recemment ajoutés
509       **/       **/
510      function insertLinkDemandeDemandeur($db, $DEBUG) {      function insertLinkDemandeDemandeur($db, $DEBUG) {
511          //          //
512          require_once "../obj/lien_demande_demandeur.class.php";          require_once "../obj/lien_demande_demandeur.class.php";
   
513          // Comparaison de l'id petitionnaire principal          // Comparaison de l'id petitionnaire principal
514          if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND          if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND
515             !empty($this->postedIdDemandeur['petitionnaire_principal']) AND             !empty($this->postedIdDemandeur['petitionnaire_principal']) AND
# Line 267  class demande extends demande_gen { Line 586  class demande extends demande_gen {
586    
587      }      }
588    
589        /*
590         * Teste si le lien entre une demande et un demandeur existe
591         * */
592      function isLinkDemandeDemandeurExist($idDemandeur) {      function isLinkDemandeDemandeurExist($idDemandeur) {
593          $sql = "SELECT count(*)          $sql = "SELECT count(*)
594                  FROM ".DB_PREFIXE."lien_demande_demandeur                  FROM ".DB_PREFIXE."lien_demande_demandeur
# Line 306  class demande extends demande_gen { Line 628  class demande extends demande_gen {
628          }          }
629      }      }
630      /**      /**
631       * 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
632         * liés au dossier d'autorisation
633       **/       **/
634      function listeDemandeur() {      function listeDemandeur($from, $id) {
635          // Récupération des demandeurs de la base          // Récupération des demandeurs de la base
636          $sql = "SELECT demandeur.demandeur,          $sql = "SELECT demandeur.demandeur,
637                          demandeur.type_demandeur,                          demandeur.type_demandeur,
638                          lien_demande_demandeur.petitionnaire_principal                          lien_".$from."_demandeur.petitionnaire_principal
639              FROM ".DB_PREFIXE."lien_demande_demandeur              FROM ".DB_PREFIXE."lien_".$from."_demandeur
640              INNER JOIN ".DB_PREFIXE."demandeur              INNER JOIN ".DB_PREFIXE."demandeur
641              ON demandeur.demandeur=lien_demande_demandeur.demandeur              ON demandeur.demandeur=lien_".$from."_demandeur.demandeur
642              WHERE demande = ".$this->val[array_search('demande', $this->champs)];              WHERE ".$from." = '".$id."'";
643          $res = $this->f->db->query($sql);          $res = $this->f->db->query($sql);
644          $this->f->addToLog("listeDemandeur() : ".$sql);          $this->f->addToLog("listeDemandeur() : ".$sql);
645          $this->f->isDatabaseError($res);          $this->f->isDatabaseError($res);
# Line 334  class demande extends demande_gen { Line 657  class demande extends demande_gen {
657          }          }
658      }      }
659    
660    
661        /**
662         * Surcharge du bouton retour afin de retourner sur la recherche de dossiers
663         * d'instruction existant
664         */
665        function retour($premier = 0, $recherche = "", $tricol = "") {
666    
667            echo "\n<a class=\"retour\" ";
668            echo "href=\"";
669            //
670            if($this->getParameter("idx_dossier") != "") {
671                echo "tab.php?";
672                echo "obj=recherche_dossier";
673    
674            } else {
675                if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) {
676                    echo "form.php?";
677                } else {
678                    echo "tab.php?";
679                }
680                echo "obj=".get_class($this);
681                if($this->getParameter("retour")=="form") {
682                    echo "&amp;idx=".$this->getParameter("idx");
683                    echo "&amp;action=3";
684                }
685            }
686            echo "&amp;premier=".$this->getParameter("premier");
687            echo "&amp;tricol=".$this->getParameter("tricol");
688            echo "&amp;recherche=".$this->getParameter("recherche");
689            echo "&amp;selectioncol=".$this->getParameter("selectioncol");
690            echo "&amp;advs_id=".$this->getParameter("advs_id");
691            echo "&amp;valide=".$this->getParameter("valide");
692            //
693            echo "\"";
694            echo ">";
695            //
696            echo _("Retour");
697            //
698            echo "</a>\n";
699    
700        }
701    
702    
703      /**      /**
704       * Ajout de la liste des demandeurs       * Ajout de la liste des demandeurs
705       */       */
706      function formSpecificContent($maj) {      function formSpecificContent($maj) {
707          if(!$this->correct AND $maj != 0) {          if(!$this->correct AND $maj != 0) {
708              $this->listeDemandeur();              $this->listeDemandeur("demande", $this->val[array_search('demande', $this->champs)]);
709            }
710            // Si le paramètre idx_dossier est défini on récupère les demandeurs liés au dossier d'instruction
711            if($this->getParameter("idx_dossier") != "") {
712                $this->listeDemandeur("dossier", $this->getParameter("idx_dossier"));
713          }          }
714          if($maj < 2 AND !$this->correct) {          if($maj < 2 AND !$this->correct) {
715              $linkable = true;              $linkable = true;
716          } else {          } else {
717              $linkable = false;              $linkable = false;
718          }          }
719    
720          // Conteneur de la listes des demandeurs          // Conteneur de la listes des demandeurs
721          echo "<div class=\"demande_hidden_bloc col_12\">";          echo "<div id=\"liste_demandeur\" class=\"demande_hidden_bloc col_12\">";
722          echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">";          echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">";
723          echo "  <legend class=\"ui-corner-all ui-widget-content ui-state-active\">"          echo "  <legend class=\"ui-corner-all ui-widget-content ui-state-active\">"
724                  ._("Petitionnaire")."</legend>";                  ._("Petitionnaire")."</legend>";
725          // Si des demandeurs sont liés à la demande          // Si des demandeurs sont liés à la demande
726          require_once "../obj/petitionnaire.class.php";          require_once "../obj/petitionnaire.class.php";
727          require_once "../obj/delegataire.class.php";          require_once "../obj/delegataire.class.php";
728            // Affichage du bloc pétitionnaire principal / délégataire
729              // Affichage du bloc pétitionnaire principal / délégataire          // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
730              // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS          echo "<div id=\"petitionnaire_principal_delegataire col_12\">";
731              echo "<div id=\"petitionnaire_principal_delegataire\">";          // Affichage de la synthèse
732              // Affichage de la synthèse          if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND
733              if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND              !empty($this->valIdDemandeur["petitionnaire_principal"])) {
734                  !empty($this->valIdDemandeur["petitionnaire_principal"])) {              $demandeur = new petitionnaire(
735                  $demandeur = new petitionnaire(                                  $this->valIdDemandeur["petitionnaire_principal"],
736                                      $this->valIdDemandeur["petitionnaire_principal"],                                  $this->f->db,false);
737                                      $this->f->db,false);              $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);
738                  $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);              $demandeur -> __destruct();
739                  $demandeur -> __destruct();          } elseif ( isset ($this->postedIdDemandeur["petitionnaire_principal"]) AND
740              }              !empty($this->postedIdDemandeur["petitionnaire_principal"]) ) {
741              // Si en édition de formulaire              $demandeur = new petitionnaire(
742              if($maj < 2 AND $this->correct != true) {                                  $this->postedIdDemandeur["petitionnaire_principal"],
743                  // Bouton d'ajout du pétitionnaire principal                                  $this->f->db,false);
744                  // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS              $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);
745                  echo "<input id=\"add_petitionnaire_principal\"              $demandeur -> __destruct();
746                      class=\"ui-button ui-widget ui-state-default ui-corner-all\"          }
747                      type=\"button\" value=\""._("Saisir le petitionnaire principal")."\"/>";          // Si en édition de formulaire
748                  echo " <span class=\"om-icon om-icon-16 om-icon-fix arrow-right-16\">></span> ";          if($maj < 2) {
749                  // Bouton d'ajout du delegataire              // Bouton d'ajout du pétitionnaire principal
750                  // 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
751                  echo "<input id=\"add_delegataire\"              echo "<span id=\"add_petitionnaire_principal\"
752                      class=\"ui-button ui-widget ui-state-default ui-corner-all\"                  class=\"om-form-button add-16\">".
753                      type=\"button\" value=\""._("Saisir le delegataire")."\"/>";                  _("Saisir le petitionnaire principal").
754              }              "</span>";
755              // Affichage de la synthèse          }
756              if (isset ($this->valIdDemandeur["delegataire"]) AND          // Bouton d'ajout du delegataire
757                  !empty($this->valIdDemandeur["delegataire"])) {          // L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
758                  $demandeur = new delegataire($this->valIdDemandeur["delegataire"],          echo "<div id=\"delegataire\">";
759                                             $this->f->db,false);          // Affichage de la synthèse
760                  $demandeur -> afficherSynthese("delegataire", $linkable);          if (isset ($this->valIdDemandeur["delegataire"]) AND
761                !empty($this->valIdDemandeur["delegataire"])) {
762                $demandeur = new delegataire($this->valIdDemandeur["delegataire"],
763                                           $this->f->db,false);
764                $demandeur -> afficherSynthese("delegataire", $linkable);
765                $demandeur -> __destruct();
766            } elseif ( isset ($this->postedIdDemandeur["delegataire"]) AND
767            !empty($this->postedIdDemandeur["delegataire"]) ) {
768    
769                $demandeur = new delegataire($this->postedIdDemandeur["delegataire"],
770                                           $this->f->db,false);
771                $demandeur -> afficherSynthese("delegataire", $linkable);
772                $demandeur -> __destruct();
773            }
774            if($maj < 2) {
775                echo "<span id=\"add_delegataire\"
776                        class=\"om-form-button add-16\">".
777                        _("Saisir le delegataire").
778                    "</span>";
779            }
780            echo "</div>";
781            echo "<div class=\"both\"></div>";
782            echo "</div>";
783            // Bloc des pétitionnaires secondaires
784            // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
785            echo "<div id=\"listePetitionnaires col_12\">";
786    
787             // Affichage de la synthèse
788            if (isset ($this->valIdDemandeur["petitionnaire"]) AND
789                !empty($this->valIdDemandeur["petitionnaire"])) {
790                
791                foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) {
792                    $demandeur = new petitionnaire($petitionnaire,
793                                           $this->f->db,false);
794                    $demandeur -> afficherSynthese("petitionnaire", $linkable);
795                  $demandeur -> __destruct();                  $demandeur -> __destruct();
796              }              }
797                            
798              echo "</div>";          } elseif ( isset ($this->postedIdDemandeur["petitionnaire"]) AND
799                !empty($this->postedIdDemandeur["petitionnaire"]) )  {
800              // Bloc des pétitionnaires secondaires              foreach ($this->postedIdDemandeur["petitionnaire"] as $petitionnaire) {
801              // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS                  $demandeur = new petitionnaire($petitionnaire,
802              echo "<div id=\"listePetitionnaires\">";                                         $this->f->db,false);
803                    $demandeur -> afficherSynthese("petitionnaire", $linkable);
804               // 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")."\"/>";  
805              }              }
806              echo "</div>";          }
807            if ($maj < 2) {
808                // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
809                echo "<span id=\"add_petitionnaire\"
810                        class=\"om-form-button add-16\">".
811                        _("Ajouter un petitionnaire")
812                    ."</span>";
813            }
814            echo "</div>";
815          echo "</fieldset>";          echo "</fieldset>";
816          echo "</div>";          echo "</div>";
817      }      }
818    
819        // {{{
820    
821        // getter
822        function getValIdDemandeur() {
823            return $this->valIdDemandeur;
824        }
825        // setter
826        function setValIdDemandeur($valIdDemandeur) {
827            $this->valIdDemandeur = $valIdDemandeur;
828        }
829        
830        //Supression du lien entre la demandeur et le(s) demandeur(s)
831        function triggerSupprimer($id, &$db, $val, $DEBUG){
832            
833            //Création de la requête
834            $sql = "DELETE FROM
835                        ".DB_PREFIXE."lien_demande_demandeur
836                    WHERE
837                        demande = $id";
838                  
839            $res = $this->f->db->query($sql);
840            $this->f->addToLog("triggerSupprimer() : ".$sql);
841            $this->f->isDatabaseError($res);
842        }
843        
844        // }}}
845  }// fin classe  }// fin classe
 ?>  
846    ?>

Legend:
Removed from v.908  
changed lines
  Added in v.1140

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26