/[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 1097 by nhaye, Tue Dec 18 14:35:15 2012 UTC revision 1606 by nhaye, Tue Apr 2 17:25:20 2013 UTC
# Line 13  class demande extends demande_gen { Line 13  class demande extends demande_gen {
13                                  "delegataire" => "",                                  "delegataire" => "",
14                                  "petitionnaire" => array());                                  "petitionnaire" => array());
15    
16        var $autreDossierEnCour;
17    
18      function demande($id,&$db,$debug) {      function demande($id,&$db,$debug) {
19          $this->constructeur($id,$db,$debug);          $this->constructeur($id,$db,$debug);
20      }// fin constructeur      }// fin constructeur
# Line 57  class demande extends demande_gen { Line 59  class demande extends demande_gen {
59              }              }
60          }          }
61      }      }
62        function getDataSubmit() {
63    
64            $datasubmit = parent::getDataSubmit();
65            if($this->getParameter("idx_dossier") != "") {
66                $datasubmit .= "&idx_dossier=".$this->getParameter("idx_dossier");
67            }
68            return $datasubmit;
69        }
70            
71      /**      /**
72       * Méthode de verification du contenu       * Méthode de verification du contenu
# Line 69  class demande extends demande_gen { Line 79  class demande extends demande_gen {
79              $this->addToMessage("La saisie d'un petitionnaire principal est obligatoire.");              $this->addToMessage("La saisie d'un petitionnaire principal est obligatoire.");
80          }          }
81      }      }
82    
83        /**
84         * Configuration des select
85         */
86        function setSelect(&$form, $maj,&$db,$debug) {
87            parent::setSelect($form, $maj,$db,$debug);
88    
89            if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
90                include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
91            elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))
92                include ("../sql/".$db->phptype."/".$this->table.".form.inc");
93    
94            //Récupération de paramètre pour le rechargement ajax du select
95            $idx_dossier = $this->getParameter("idx_dossier");
96            $datd = $this->getParameter("datd");
97    
98            $contenu = array();
99    
100            // Ajout de filtre sur la requête (initial)
101            if(isset($idx_dossier) AND $idx_dossier != "") {
102                $sql_demande_type .= " WHERE demande_type.demande_nature = 2 ";
103    
104                // ajout du numéro de dossier existant pour tester l'état du DA
105                $sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' ";
106            } else {
107                $sql_demande_type .= " WHERE demande_type.demande_nature = 1 ";
108            }
109            if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") {
110                $datd = $_POST["dossier_autorisation_type_detaille"];
111            }
112            // Ajout de filtre sur la requête (dossier_autorisation_type_detaille)
113            if(isset($datd) AND $datd != "") {
114                $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;
115            } else {
116                $datd = $this->getVal("dossier_autorisation_type_detaille");
117                if ($datd != "") {
118                    $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;
119                }
120            }
121    
122            $res = $db->query($sql_demande_type);
123    
124            // logger
125            $this->addToLog("setSelect()[gen/obj]: db->query(\"".$sql_demande_type."\");",
126                            VERBOSE_MODE);
127            $this->f->isDatabaseError($res);
128    
129            $contenu[0][0] = '';
130            $contenu[1][0] = _('choisir')." "._("demande_type");
131    
132            $k=1;
133            while($row =& $res->fetchRow()){
134    
135                $contenu[0][$k] = $row[0];
136                $contenu[1][$k] = $row[1];
137                $k++;
138            }
139    
140            $form->setSelect("demande_type", $contenu);
141    
142        }
143      /*      /*
144      * Ajout du fielset      * Ajout du fielset
145      * Add fieldset      * Add fieldset
# Line 101  class demande extends demande_gen { Line 172  class demande extends demande_gen {
172              $form->setBloc('terrain_superficie','F');              $form->setBloc('terrain_superficie','F');
173              /*Fin bloc 4*/              /*Fin bloc 4*/
174                            
             /*Champ sur lequel s'ouvre le bloc 4 */  
             $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');  
             /*Fin bloc 5*/  
175          }          }
176      }      }
177    
# Line 119  class demande extends demande_gen { Line 184  class demande extends demande_gen {
184          $form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();");          $form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();");
185          $form->setOnchange("demande_type","showFormsDemande();");          $form->setOnchange("demande_type","showFormsDemande();");
186      }      }
187          
188        function setLib(&$form,$maj) {
189            parent::setLib($form,$maj);
190            //libelle des champs
191            
192            $form->setLib('complement',_('terrain_adresse'));
193        }
194      /*      /*
195      * Cache le champ terrain_references_cadastrales      * Cache le champ terrain_references_cadastrales
196      * Hide the fiels terrain_references_cadastrales      * Hide the fiels terrain_references_cadastrales
# Line 135  class demande extends demande_gen { Line 206  class demande extends demande_gen {
206    
207          // Si il s'agit d'une demande sur dossier existant on desactive tous les champs          // Si il s'agit d'une demande sur dossier existant on desactive tous les champs
208          // sauf demande_type          // sauf demande_type
209          if(($maj == 0 AND $this-> getParameter("idx_dossier")) OR $maj == 3) {          if(($maj == 0 AND $this-> getParameter("idx_dossier"))) {
210              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
211              $form->setType('terrain_references_cadastrales', 'hiddenstatic');              $form->setType('terrain_references_cadastrales', 'hiddenstatic');
212              $form->setType('terrain_adresse_voie_numero', 'hiddenstatic');              $form->setType('terrain_adresse_voie_numero', 'hiddenstatic');
# Line 146  class demande extends demande_gen { Line 217  class demande extends demande_gen {
217              $form->setType('terrain_adresse_bp', 'hiddenstatic');              $form->setType('terrain_adresse_bp', 'hiddenstatic');
218              $form->setType('terrain_adresse_cedex', 'hiddenstatic');              $form->setType('terrain_adresse_cedex', 'hiddenstatic');
219              $form->setType('terrain_superficie', 'hiddenstatic');              $form->setType('terrain_superficie', 'hiddenstatic');
             $form->setType('nombre_lots', 'hiddenstatic');  
220          }          }
221          if($maj == 3) {          if($maj == 1) {
222                $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
223              $form->setType('demande_type', 'selecthiddenstatic');              $form->setType('demande_type', 'selecthiddenstatic');
224          }          }
225            if($maj == 3) {
226                $form->setType('terrain_references_cadastrales', 'referencescadastralesstatic');
227            }
228    
229      }      }
230    
231      /**      /**
# Line 159  class demande extends demande_gen { Line 234  class demande extends demande_gen {
234      function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){      function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){
235          require_once '../obj/dossier_autorisation.class.php';          require_once '../obj/dossier_autorisation.class.php';
236          $dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG);          $dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG);
237          // Création du dossier          $id_etat_initial_da = $this->getParameter('etat_initial_dossier_autorisation');
238          foreach($dossier_autorisation->champs as $value) {          $error = false;
239              $valAuto[$value] = NULL;          // Vérification de l'existance d'un état initial des DA
240          }          if(isset($id_etat_initial_da)) {
241          $valAuto['dossier_autorisation']=NULL;              $sql = "SELECT count(*) FROM ".DB_PREFIXE."etat_dossier_autorisation
242          $valAuto['nature']=NULL;                      WHERE etat_dossier_autorisation = ".$id_etat_initial_da;
243          $valAuto['exercice']=NULL;              $count = $this->db->getOne($sql);
244          $valAuto['insee']=NULL;              $this->addToLog("ajoutDossierAutorisation() getOne() : ".$sql);
245          $valAuto['arrondissement']=NULL;              $this->f->isDatabaseError($count);
246          $valAuto['etat']=NULL;              if($count != 1) {
247          $valAuto['erp_numero_batiment']=NULL;                  $error = true;
248          $valAuto['erp_ouvert']=NULL;              } else {
249          $valAuto['erp_arrete_decision']=NULL;                  // Création du dossier
250          $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];                  foreach($dossier_autorisation->champs as $value) {
251          $valAuto['depot_initial']=$this->valF['date_demande'];                      $valAuto[$value] = NULL;
252          $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];                  }
253          $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];                  $valAuto['dossier_autorisation']="";
254          $valAuto['complement']=$this->valF['complement'];                  $valAuto['exercice']=NULL;
255          $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];                  $valAuto['insee']=NULL;
256          $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];                  $valAuto['arrondissement']=NULL;
257          $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];                  $valAuto['etat_dossier_autorisation']=$this->getParameter('etat_initial_dossier_autorisation');
258          $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];                  $valAuto['erp_numero_batiment']=NULL;
259          $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];                  $valAuto['erp_ouvert']=NULL;
260          $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];                  $valAuto['erp_arrete_decision']=NULL;
261          $valAuto['numero_version']=-1;                  $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
262          // Ajout du dossier dans la base                  $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
263          $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);                  $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
264          // Liaison du dossier ajouter à la demande                  $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
265          $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];                  $valAuto['complement']=$this->valF['complement'];
266                    $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
267                    $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
268                    $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
269                    $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
270                    $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
271                    $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];
272                    $valAuto['numero_version']=-1;
273                    // Ajout du dossier dans la base
274                    $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);
275                    // Liaison du dossier ajouter à la demande
276                    $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];
277                }
278            } else {
279                $error = true;
280            }
281            // Affichage de l'erreur et stop de l'affichage
282            if( $error ) {
283                echo "</div>";
284                $class = "error";
285                $message = _("Erreur de parametrage. Contactez votre administrateur.");
286                $this->f->displayMessage($class, $message);
287                die();
288            }
289            
290        }
291    
292        function getCodeDemandeType($demande_type){
293            
294            $sql = "SELECT
295                        code
296                    FROM
297                        ".DB_PREFIXE."demande_type
298                    WHERE
299                        demande_type = ".$demande_type;
300            $codeDemandeType = $this->db->getOne($sql);
301            $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
302            
303            return $codeDemandeType;
304      }      }
305    
306      /**      /**
# Line 209  class demande extends demande_gen { Line 322  class demande extends demande_gen {
322          $dossier->setDossierInstructionType($dossier_instruction_type);          $dossier->setDossierInstructionType($dossier_instruction_type);
323                    
324          // Définition des valeurs à entrée dans la table          // Définition des valeurs à entrée dans la table
325          $valInstr['nature']=$datd->val[array_search("code", $datd->champs)];          $valInstr['dossier_instruction_type']=$dossier_instruction_type;
         $valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];  
326          $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);
327            $valInstr['date_dernier_depot']=$this->dateDBToForm($this->valF['date_demande']);
328          $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);
329          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
330          $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];          $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
# Line 225  class demande extends demande_gen { Line 338  class demande extends demande_gen {
338          $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];          $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];
339          $valInstr['description']="";          $valInstr['description']="";
340          $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];          $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];
341    
342            /*
343             * Gestion de la qualification
344             * */
345             //Récupérer le code du type de la demande
346             $codeDemandeType = $this->getCodeDemandeType($val['demande_type']);
347            
348            //Marque le dossier comme à qualifier selon le type de dossier d'instruction
349            if ( strcasecmp($codeDemandeType, "DI") == 0 ||
350                 strcasecmp($codeDemandeType, "DT") == 0 ||
351                 strcasecmp($codeDemandeType, "DM") == 0 ||
352                 strcasecmp($codeDemandeType, "DP") == 0 ||
353                 strcasecmp($codeDemandeType, "DTP") == 0 ||
354                 strcasecmp($codeDemandeType, "DAACT") == 0 ||
355                 strcasecmp($codeDemandeType, "DOC") == 0 ){
356                
357                $valInstr['a_qualifier'] = TRUE;
358            }
359    
360            // Récupération du cerfa pour le type d'instruction sélectionnée et valide
361            $sql = "SELECT
362                        dossier_instruction_type.cerfa
363                    FROM
364                        ".DB_PREFIXE."dossier_instruction_type
365                    JOIN
366                        ".DB_PREFIXE."cerfa
367                    ON
368                        dossier_instruction_type.cerfa = cerfa.cerfa
369                    WHERE
370                        now()<=om_validite_fin
371                        AND now()>=om_validite_debut
372                        AND dossier_instruction_type=".$dossier_instruction_type;
373            $valInstr['cerfa'] = $db->getOne($sql);
374            $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
375    
376          $dossier->ajouter($valInstr, $db, $DEBUG);          $dossier->ajouter($valInstr, $db, $DEBUG);
377          $this->f->isDatabaseError();          $this->f->isDatabaseError();
378          // Liaison du dossier ajouter à la demande          // Liaison du dossier ajouter à la demande
# Line 232  class demande extends demande_gen { Line 380  class demande extends demande_gen {
380      }      }
381    
382      /**      /**
383         * Méthode permettant d'ajouter les données techniques au dossier d'instruction
384         */
385        function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){
386            
387            require_once '../obj/donnees_techniques.class.php';
388            $donnees_techniques = new donnees_techniques("]",$db,$DEBUG);
389            
390            // Champs tous à NULL car seul le champ concernant le dossier d'instruction sera rempli
391            foreach($donnees_techniques->champs as $value) {
392                $val[$value] = NULL;
393            }
394                    
395            // Ajout du numéro de dossier d'instruction
396            $val['dossier_instruction']=$this->valF['dossier_instruction'];
397    
398            // Ajout des données techniques    
399            $donnees_techniques->ajouter($val, $db, $DEBUG);
400            $this->f->isDatabaseError();
401        }
402    
403        /**
404       * Ajout des liens demandeurs / dossier d'autorisation       * Ajout des liens demandeurs / dossier d'autorisation
405       **/       **/
406      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
# Line 370  class demande extends demande_gen { Line 539  class demande extends demande_gen {
539              if($dossier_type['dossier_instruction_type'] != NULL) {              if($dossier_type['dossier_instruction_type'] != NULL) {
540                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
541                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
542                    
543                    //Ajout des données techniques au dossier d'instruction
544                    $this->ajoutDonneesTechniques($id, $db, $val, $DEBUG);
545              }              }
546                            
547              /*Création du lien de téléchargement de récépissé de demande*/              /*Création du lien de téléchargement de récépissé de demande*/
# Line 389  class demande extends demande_gen { Line 561  class demande extends demande_gen {
561                  $valInstr['destinataire']=$this->valF['dossier_instruction'];                  $valInstr['destinataire']=$this->valF['dossier_instruction'];
562                  $valInstr['dossier']=$this->valF['dossier_instruction'];                  $valInstr['dossier']=$this->valF['dossier_instruction'];
563                                    
564                  $valInstr['datecourrier']=date("d/m/Y");                  $valInstr['date_evenement']=date("d/m/Y");
565                  $valInstr['evenement']=$evenement;                  $valInstr['evenement']=$evenement;
566                  $valInstr['lettretype']=$lettretype;                  $valInstr['lettretype']=$lettretype;
567                  $valInstr['complement']="";                  $valInstr['complement']="";
# Line 402  class demande extends demande_gen { Line 574  class demande extends demande_gen {
574                  $valInstr['delai_notification']="1";                  $valInstr['delai_notification']="1";
575                  $valInstr['archive_delai']="0";                  $valInstr['archive_delai']="0";
576                  $valInstr['archive_date_complet']=NULL;                  $valInstr['archive_date_complet']=NULL;
577                    $valInstr['archive_date_dernier_depot']=NULL;
578                  $valInstr['archive_date_rejet']=NULL;                  $valInstr['archive_date_rejet']=NULL;
579                  $valInstr['archive_date_limite']=NULL;                  $valInstr['archive_date_limite']=NULL;
580                  $valInstr['archive_date_notification_delai']=NULL;                  $valInstr['archive_date_notification_delai']=NULL;
# Line 427  class demande extends demande_gen { Line 600  class demande extends demande_gen {
600                  $valInstr['complement14']="";                  $valInstr['complement14']="";
601                  $valInstr['complement15']="";                  $valInstr['complement15']="";
602                  $valInstr['avis_decision']=NULL;                  $valInstr['avis_decision']=NULL;
603                    $valInstr['date_finalisation_courrier']=NULL;
604                    $valInstr['date_envoi_signature']=NULL;
605                    $valInstr['date_retour_signature']=NULL;
606                    $valInstr['date_envoi_rar']=NULL;
607                    $valInstr['date_retour_rar']=NULL;
608                    $valInstr['date_envoi_controle_legalite']=NULL;
609                    $valInstr['date_retour_controle_legalite']=NULL;
610                    $valInstr['signataire_arrete']=NULL;
611                    $valInstr['numero_arrete']=NULL;
612                                                                    
613                  /*Fichier requis*/                  /*Fichier requis*/
614                  require_once '../obj/instruction.class.php';                  require_once '../obj/instruction.class.php';
# Line 443  class demande extends demande_gen { Line 625  class demande extends demande_gen {
625                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
626                      $this -> addToMessage("<br/><a                      $this -> addToMessage("<br/><a
627                          class='lien'                          class='lien'
628                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$this->valF['dossier_instruction']."'                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$instruction->valF['instruction']."'
629                          target='_blank'>                          target='_blank'>
630                              <span                              <span
631                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
# Line 483  class demande extends demande_gen { Line 665  class demande extends demande_gen {
665          if(!empty($this->valF['dossier_instruction'])) {          if(!empty($this->valF['dossier_instruction'])) {
666              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
667          }          }
668    
669            // Duplication des lots et liaison au nouveau dossier_d'instruction
670            if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) {
671                $this->lienLotDossierInstruction($id, $db, $val, $DEBUG);
672            }
673      }      }
674            
675      /*Ajout du lien demande / demandeur(s)*/      /*Ajout du lien demande / demandeur(s)*/
# Line 494  class demande extends demande_gen { Line 681  class demande extends demande_gen {
681      }      }
682    
683      /**      /**
684         * Gestion des liens entre les lots du DA et le nouveau dossier
685         **/
686        function lienLotDossierInstruction($id, $db, $val, $DEBUG) {
687            require_once ("../obj/lot.class.php");
688            $lot = new lot("]", $db, $DEBUG);
689            require_once ("../obj/lien_dossier_lot.class.php");
690            $ldl = new lien_dossier_lot("]", $db, $DEBUG);
691            require_once ("../obj/lien_lot_demandeur.class.php");
692            $lld = new lien_lot_demandeur("]", $db, $DEBUG);
693    
694    
695            $sqlLots = "SELECT * FROM ".DB_PREFIXE."lot
696            WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'";
697            $resLot = $db -> query($sqlLots);
698            $this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE);
699            $this->f->isDatabaseError($resLot);
700            while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){
701                // Insertion du nouveau lot
702                $valLot['lot'] = "";
703                $valLot['libelle'] = $rowLot['libelle'];
704                $valLot['dossier_autorisation'] = NULL;
705                $lot -> ajouter($valLot, $db, $DEBUG);
706    
707                //Insertion du lien entre le lot et le dossier d'instruction
708                $valLdl['lien_dossier_lot'] = "";
709                $valLdl['dossier'] = $this->valF['dossier_instruction'];
710                $valLdl['lot'] = $lot->valF['lot'];
711                $ldl->ajouter($valLdl, $db, $DEBUG);
712    
713                //Insertion des liens entre dossier et les lots
714                $sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur
715                WHERE lot = ".$rowLot['lot'];
716                $res = $db -> query($sqlDemandeurs);
717                $this->f->addToLog("db->query(\"".$sqlDemandeurs."\");", VERBOSE_MODE);
718                $this->f->isDatabaseError($res);
719                
720                while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
721                    $valLld["lien_lot_demandeur"] = "";
722                    $valLld["lot"]=$lot->valF['lot'];
723                    $valLld["demandeur"] = $row['demandeur'];
724                    $valLld["petitionnaire_principal"] = $row['petitionnaire_principal'];
725                    $lld->ajouter($valLld, $db, $DEBUG);
726                }
727            }
728        }
729    
730        /**
731       * Gestion des liens entre la demande et les demandeurs recemment ajoutés       * Gestion des liens entre la demande et les demandeurs recemment ajoutés
732       **/       **/
733      function insertLinkDemandeDemandeur($db, $DEBUG) {      function insertLinkDemandeDemandeur($db, $DEBUG) {
# Line 622  class demande extends demande_gen { Line 856  class demande extends demande_gen {
856       **/       **/
857      function listeDemandeur($from, $id) {      function listeDemandeur($from, $id) {
858          // Récupération des demandeurs de la base          // Récupération des demandeurs de la base
859          $sql = "SELECT demandeur.demandeur,          if(isset($this->valF['demande_type']) AND $this->getCodeDemandeType($this->valF['demande_type']) != "DT") {
860                          demandeur.type_demandeur,              $sql = "SELECT demandeur.demandeur,
861                          lien_".$from."_demandeur.petitionnaire_principal                              demandeur.type_demandeur,
862              FROM ".DB_PREFIXE."lien_".$from."_demandeur                              lien_".$from."_demandeur.petitionnaire_principal
863              INNER JOIN ".DB_PREFIXE."demandeur                  FROM ".DB_PREFIXE."lien_".$from."_demandeur
864              ON demandeur.demandeur=lien_".$from."_demandeur.demandeur                  INNER JOIN ".DB_PREFIXE."demandeur
865              WHERE ".$from." = '".$id."'";                  ON demandeur.demandeur=lien_".$from."_demandeur.demandeur
866          $res = $this->f->db->query($sql);                  WHERE ".$from." = '".$id."'";
867          $this->f->addToLog("listeDemandeur() : ".$sql);              $res = $this->f->db->query($sql);
868          $this->f->isDatabaseError($res);              $this->f->addToLog("listeDemandeur() : ".$sql);
869          // Stoquage du résultat dans un tableau              $this->f->isDatabaseError($res);
870          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              // Stoquage du résultat dans un tableau
871              if ($row['petitionnaire_principal'] == 't' AND              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
872                  $row['type_demandeur']=="petitionnaire") {                  if ($row['petitionnaire_principal'] == 't' AND
873                  $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];                      $row['type_demandeur']=="petitionnaire") {
874              } elseif ($row['petitionnaire_principal'] == 'f' AND                      $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];
875                  $row['type_demandeur']=="petitionnaire"){                  } elseif ($row['petitionnaire_principal'] == 'f' AND
876                  $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];                      $row['type_demandeur']=="petitionnaire"){
877              } elseif ($row['type_demandeur']=="delegataire"){                      $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];
878                  $this->valIdDemandeur['delegataire']=$row['demandeur'];                  } elseif ($row['type_demandeur']=="delegataire"){
879                        $this->valIdDemandeur['delegataire']=$row['demandeur'];
880                    }
881              }              }
882          }          }
883      }      }
# Line 716  class demande extends demande_gen { Line 952  class demande extends demande_gen {
952          require_once "../obj/delegataire.class.php";          require_once "../obj/delegataire.class.php";
953          // Affichage du bloc pétitionnaire principal / délégataire          // Affichage du bloc pétitionnaire principal / délégataire
954          // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS          // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
955          echo "<div id=\"petitionnaire_principal_delegataire\">";          echo "<div id=\"petitionnaire_principal_delegataire col_12\">";
956          // Affichage de la synthèse          // Affichage de la synthèse
957          if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND          if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND
958              !empty($this->valIdDemandeur["petitionnaire_principal"])) {              !empty($this->valIdDemandeur["petitionnaire_principal"])) {
# Line 745  class demande extends demande_gen { Line 981  class demande extends demande_gen {
981          // Bouton d'ajout du delegataire          // Bouton d'ajout du delegataire
982          // L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS          // L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
983          echo "<div id=\"delegataire\">";          echo "<div id=\"delegataire\">";
         if ($maj < 2 OR ($maj == 3 AND !empty($this->valIdDemandeur["delegataire"]))) {  
             echo " <span class=\"om-icon om-icon-16 om-icon-fix arrow-right-16\">  
                     <!-- -->  
                 </span> ";  
         }  
984          // Affichage de la synthèse          // Affichage de la synthèse
985          if (isset ($this->valIdDemandeur["delegataire"]) AND          if (isset ($this->valIdDemandeur["delegataire"]) AND
986              !empty($this->valIdDemandeur["delegataire"])) {              !empty($this->valIdDemandeur["delegataire"])) {
# Line 772  class demande extends demande_gen { Line 1003  class demande extends demande_gen {
1003                  "</span>";                  "</span>";
1004          }          }
1005          echo "</div>";          echo "</div>";
1006                    echo "<div class=\"both\"></div>";
1007          echo "</div>";          echo "</div>";
1008          // Bloc des pétitionnaires secondaires          // Bloc des pétitionnaires secondaires
1009          // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS          // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
1010          echo "<div id=\"listePetitionnaires\">";          echo "<div id=\"listePetitionnaires col_12\">";
1011    
1012           // Affichage de la synthèse           // Affichage de la synthèse
1013          if (isset ($this->valIdDemandeur["petitionnaire"]) AND          if (isset ($this->valIdDemandeur["petitionnaire"]) AND
# Line 820  class demande extends demande_gen { Line 1051  class demande extends demande_gen {
1051      function setValIdDemandeur($valIdDemandeur) {      function setValIdDemandeur($valIdDemandeur) {
1052          $this->valIdDemandeur = $valIdDemandeur;          $this->valIdDemandeur = $valIdDemandeur;
1053      }      }
1054        
1055        //Supression du lien entre la demandeur et le(s) demandeur(s)
1056        function triggerSupprimer($id, &$db, $val, $DEBUG){
1057            
1058            //Création de la requête
1059            $sql = "DELETE FROM
1060                        ".DB_PREFIXE."lien_demande_demandeur
1061                    WHERE
1062                        demande = $id";
1063                  
1064            $res = $this->f->db->query($sql);
1065            $this->f->addToLog("triggerSupprimer() : ".$sql);
1066            $this->f->isDatabaseError($res);
1067        }
1068        
1069      // }}}      // }}}
1070  }// fin classe  }// fin classe
1071  ?>  ?>

Legend:
Removed from v.1097  
changed lines
  Added in v.1606

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26