/[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 1140 by nhaye, Thu Jan 3 17:19:08 2013 UTC revision 1406 by nhaye, Thu Mar 14 17:05:37 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         * Méthode permettant de vérifier si un autre dossier d'instruction est en cour
85         * pour le même dossier d'autorisation.
86         */
87        function autreDossierEnCour() {
88    
89            $idx_dossier = $this->getParameter("idx_dossier");
90    
91            // Lorsqu'on se trouve sur un dossier existant
92            if(isset($idx_dossier) AND $idx_dossier != "") {
93    
94                // Si on a pas encore défini si un autre dossier est en cours
95                if(!isset($this->autreDossierEnCour)) {
96    
97                    if(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php"))
98                        include ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php");
99                    elseif(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc"))
100                        include ("../sql/".$this->db->phptype."/".$this->table.".form.inc");
101                    $request = str_replace('<idx>', $idx_dossier,
102                                             $sql_autreDossierEnCour);
103    
104                    $nbDossier = $this->db->getOne($request);
105                    $this->f->addToLog("db->getone(\"".$request."\");", VERBOSE_MODE);
106                    $this->f->isDatabaseError($nbDossier);
107                    // Si un dossier est en cour return true
108                    if($nbDossier>0) {
109                        
110                        $this->autreDossierEnCour = true;
111                    } else {
112    
113                        $this->autreDossierEnCour = false;
114                    }
115    
116                }
117            } else {
118                $this->autreDossierEnCour = false;
119            }
120    
121            return $this->autreDossierEnCour;
122        }
123    
124        /**
125         * Configuration des select
126         */
127        function setSelect(&$form, $maj,&$db,$debug) {
128            parent::setSelect($form, $maj,$db,$debug);
129    
130            if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
131                include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
132            elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))
133                include ("../sql/".$db->phptype."/".$this->table.".form.inc");
134    
135            //Récupération de paramètre pour le rechargement ajax du select
136            $idx_dossier = $this->getParameter("idx_dossier");
137            $datd = $this->getParameter("datd");
138    
139            $contenu = array();
140    
141            // Ajout de filtre sur la requête (initial)
142            if(isset($idx_dossier) AND $idx_dossier != "") {
143                $sql_demande_type .= " WHERE demande_nature = 2 ";
144            } else {
145                $sql_demande_type .= " WHERE demande_nature = 1 ";
146            }
147            if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") {
148                $datd = $_POST["dossier_autorisation_type_detaille"];
149            }
150            // Ajout de filtre sur la requête (dossier_autorisation_type_detaille)
151            if(isset($datd) AND $datd != "") {
152                $sql_demande_type .= " AND dossier_autorisation_type_detaille = ".$datd;
153            } else {
154                $sql_demande_type .= " AND dossier_autorisation_type_detaille = ".$this->getVal("dossier_autorisation_type_detaille");
155            }
156    
157            $res = $db->query($sql_demande_type);
158    
159            // logger
160            $this->addToLog("setSelect()[gen/obj]: db->query(\"".$sql_demande_type."\");",
161                            VERBOSE_MODE);
162            $this->f->isDatabaseError($res);
163    
164            $contenu[0][0] = '';
165            $contenu[1][0] = _('choisir')."&nbsp;"._("demande_type");
166    
167            $k=1;
168            while($row =& $res->fetchRow()){
169                $display = true;
170    
171                // Vérification des contraintes
172                if($row[2] != "") {
173                    foreach(explode(";", $row[2]) as $meth) {
174                        if(method_exists($this, $row[2])) {
175                            // Si une des contrainte est validée on affiche pas l'option
176                            if($this->$row[2]() === true) {
177                                $display = false;
178                            }
179                       }
180                    }
181                }
182                // Affichage ou non de l'option
183                if($display) {
184                    $contenu[0][$k] = $row[0];
185                    $contenu[1][$k] = $row[1];
186                    $k++;
187                }
188            }
189    
190            $form->setSelect("demande_type", $contenu);
191    
192        }
193      /*      /*
194      * Ajout du fielset      * Ajout du fielset
195      * Add fieldset      * Add fieldset
# Line 101  class demande extends demande_gen { Line 222  class demande extends demande_gen {
222              $form->setBloc('terrain_superficie','F');              $form->setBloc('terrain_superficie','F');
223              /*Fin bloc 4*/              /*Fin bloc 4*/
224                            
             /*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*/  
225          }          }
226      }      }
227    
# Line 146  class demande extends demande_gen { Line 261  class demande extends demande_gen {
261              $form->setType('terrain_adresse_bp', 'hiddenstatic');              $form->setType('terrain_adresse_bp', 'hiddenstatic');
262              $form->setType('terrain_adresse_cedex', 'hiddenstatic');              $form->setType('terrain_adresse_cedex', 'hiddenstatic');
263              $form->setType('terrain_superficie', 'hiddenstatic');              $form->setType('terrain_superficie', 'hiddenstatic');
             $form->setType('nombre_lots', 'hiddenstatic');  
264          }          }
265          if($maj == 1) {          if($maj == 1) {
266              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
# Line 169  class demande extends demande_gen { Line 283  class demande extends demande_gen {
283              $valAuto[$value] = NULL;              $valAuto[$value] = NULL;
284          }          }
285          $valAuto['dossier_autorisation']=NULL;          $valAuto['dossier_autorisation']=NULL;
         $valAuto['nature']=NULL;  
286          $valAuto['exercice']=NULL;          $valAuto['exercice']=NULL;
287          $valAuto['insee']=NULL;          $valAuto['insee']=NULL;
288          $valAuto['arrondissement']=NULL;          $valAuto['arrondissement']=NULL;
289          $valAuto['etat']=NULL;          $valAuto['etat_dossier_autorisation']=1;
290          $valAuto['erp_numero_batiment']=NULL;          $valAuto['erp_numero_batiment']=NULL;
291          $valAuto['erp_ouvert']=NULL;          $valAuto['erp_ouvert']=NULL;
292          $valAuto['erp_arrete_decision']=NULL;          $valAuto['erp_arrete_decision']=NULL;
293          $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];          $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
294          $valAuto['depot_initial']=$this->valF['date_demande'];          $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
295          $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];          $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
296          $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];          $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
297          $valAuto['complement']=$this->valF['complement'];          $valAuto['complement']=$this->valF['complement'];
# Line 195  class demande extends demande_gen { Line 308  class demande extends demande_gen {
308          $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];          $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];
309      }      }
310    
311        function getCodeDemandeType($demande_type){
312            
313            $sql = "SELECT
314                        code
315                    FROM
316                        ".DB_PREFIXE."demande_type
317                    WHERE
318                        demande_type = ".$demande_type;
319            $codeDemandeType = $this->db->getOne($sql);
320            $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
321            
322            return $codeDemandeType;
323        }
324    
325      /**      /**
326       * Méthode permettant d'ajouter un dossier d'instruction       * Méthode permettant d'ajouter un dossier d'instruction
327       */       */
# Line 214  class demande extends demande_gen { Line 341  class demande extends demande_gen {
341          $dossier->setDossierInstructionType($dossier_instruction_type);          $dossier->setDossierInstructionType($dossier_instruction_type);
342                    
343          // Définition des valeurs à entrée dans la table          // Définition des valeurs à entrée dans la table
344          $valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];          $valInstr['dossier_instruction_type']=$dossier_instruction_type;
345          $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);
346          $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);
347          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
# Line 229  class demande extends demande_gen { Line 356  class demande extends demande_gen {
356          $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];          $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];
357          $valInstr['description']="";          $valInstr['description']="";
358          $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];          $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];
359    
360            /*
361             * Gestion de la qualification
362             * */
363             //Récupérer le code du type de la demande
364             $codeDemandeType = $this->getCodeDemandeType($val['demande_type']);
365            
366            //Marque le dossier comme à qualifier selon le type de dossier d'instruction
367            if ( strcasecmp($codeDemandeType, "DI") == 0 ||
368                 strcasecmp($codeDemandeType, "DT") == 0 ||
369                 strcasecmp($codeDemandeType, "DM") == 0 ||
370                 strcasecmp($codeDemandeType, "DP") == 0 ||
371                 strcasecmp($codeDemandeType, "DTP") == 0 ||
372                 strcasecmp($codeDemandeType, "DAACT") == 0 ||
373                 strcasecmp($codeDemandeType, "DOC") == 0 ){
374                
375                $valInstr['a_qualifier'] = TRUE;
376            }
377    
378            // Récupération du cerfa pour le type d'instruction sélectionnée et valide
379            $sql = "SELECT
380                        dossier_instruction_type.cerfa
381                    FROM
382                        ".DB_PREFIXE."dossier_instruction_type
383                    JOIN
384                        ".DB_PREFIXE."cerfa
385                    ON
386                        dossier_instruction_type.cerfa = cerfa.cerfa
387                    WHERE
388                        now()<=om_validite_fin
389                        AND now()>=om_validite_debut
390                        AND dossier_instruction_type=".$dossier_instruction_type;
391            $valInstr['cerfa'] = $db->getOne($sql);
392            $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
393    
394          $dossier->ajouter($valInstr, $db, $DEBUG);          $dossier->ajouter($valInstr, $db, $DEBUG);
395          $this->f->isDatabaseError();          $this->f->isDatabaseError();
396          // Liaison du dossier ajouter à la demande          // Liaison du dossier ajouter à la demande
# Line 236  class demande extends demande_gen { Line 398  class demande extends demande_gen {
398      }      }
399    
400      /**      /**
401         * Méthode permettant d'ajouter les données techniques au dossier d'instruction
402         */
403        function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){
404            
405            require_once '../obj/donnees_techniques.class.php';
406            $donnees_techniques = new donnees_techniques("]",$db,$DEBUG);
407            
408            // Champs tous à NULL car seul le champ concernant le dossier d'instruction sera rempli
409            foreach($donnees_techniques->champs as $value) {
410                $val[$value] = NULL;
411            }
412                    
413            // Ajout du numéro de dossier d'instruction
414            $val['dossier_instruction']=$this->valF['dossier_instruction'];
415    
416            // Ajout des données techniques    
417            $donnees_techniques->ajouter($val, $db, $DEBUG);
418            $this->f->isDatabaseError();
419        }
420    
421        /**
422       * Ajout des liens demandeurs / dossier d'autorisation       * Ajout des liens demandeurs / dossier d'autorisation
423       **/       **/
424      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
# Line 374  class demande extends demande_gen { Line 557  class demande extends demande_gen {
557              if($dossier_type['dossier_instruction_type'] != NULL) {              if($dossier_type['dossier_instruction_type'] != NULL) {
558                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
559                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
560                    
561                    //Ajout des données techniques au dossier d'instruction
562                    $this->ajoutDonneesTechniques($id, $db, $val, $DEBUG);
563              }              }
564                            
565              /*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 438  class demande extends demande_gen { Line 624  class demande extends demande_gen {
624                  $valInstr['date_retour_rar']=NULL;                  $valInstr['date_retour_rar']=NULL;
625                  $valInstr['date_envoi_controle_legalite']=NULL;                  $valInstr['date_envoi_controle_legalite']=NULL;
626                  $valInstr['date_retour_controle_legalite']=NULL;                  $valInstr['date_retour_controle_legalite']=NULL;
627                    $valInstr['signataire_arrete']=NULL;
628                    $valInstr['numero_arrete']=NULL;
629                                                                    
630                  /*Fichier requis*/                  /*Fichier requis*/
631                  require_once '../obj/instruction.class.php';                  require_once '../obj/instruction.class.php';
# Line 454  class demande extends demande_gen { Line 642  class demande extends demande_gen {
642                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
643                      $this -> addToMessage("<br/><a                      $this -> addToMessage("<br/><a
644                          class='lien'                          class='lien'
645                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$this->valF['dossier_instruction']."'                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$instruction->valF['instruction']."'
646                          target='_blank'>                          target='_blank'>
647                              <span                              <span
648                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
# Line 494  class demande extends demande_gen { Line 682  class demande extends demande_gen {
682          if(!empty($this->valF['dossier_instruction'])) {          if(!empty($this->valF['dossier_instruction'])) {
683              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
684          }          }
685    
686            // Duplication des lots et liaison au nouveau dossier_d'instruction
687            if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) {
688                $this->lienLotDossierInstruction($id, $db, $val, $DEBUG);
689            }
690      }      }
691            
692      /*Ajout du lien demande / demandeur(s)*/      /*Ajout du lien demande / demandeur(s)*/
# Line 505  class demande extends demande_gen { Line 698  class demande extends demande_gen {
698      }      }
699    
700      /**      /**
701         * Gestion des liens entre les lots du DA et le nouveau dossier
702         **/
703        function lienLotDossierInstruction($id, $db, $val, $DEBUG) {
704            require_once ("../obj/lot.class.php");
705            $lot = new lot("]", $db, $DEBUG);
706            require_once ("../obj/lien_dossier_lot.class.php");
707            $ldl = new lien_dossier_lot("]", $db, $DEBUG);
708            require_once ("../obj/lien_lot_demandeur.class.php");
709            $lld = new lien_lot_demandeur("]", $db, $DEBUG);
710    
711    
712            $sqlLots = "SELECT * FROM ".DB_PREFIXE."lot
713            WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'";
714            $resLot = $db -> query($sqlLots);
715            $this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE);
716            $this->f->isDatabaseError($resLot);
717            while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){
718                // Insertion du nouveau lot
719                $valLot['lot'] = "";
720                $valLot['libelle'] = $rowLot['libelle'];
721                $valLot['dossier_autorisation'] = NULL;
722                $lot -> ajouter($valLot, $db, $DEBUG);
723    
724                //Insertion du lien entre le lot et le dossier d'instruction
725                $valLdl['lien_dossier_lot'] = "";
726                $valLdl['dossier'] = $this->valF['dossier_instruction'];
727                $valLdl['lot'] = $lot->valF['lot'];
728                $ldl->ajouter($valLdl, $db, $DEBUG);
729    
730                //Insertion des liens entre dossier et les lots
731                $sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur
732                WHERE lot = ".$rowLot['lot'];
733                $res = $db -> query($sqlDemandeurs);
734                $this->f->addToLog("db->query(\"".$sqlDemandeurs."\");", VERBOSE_MODE);
735                $this->f->isDatabaseError($res);
736                
737                while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
738                    $valLld["lien_lot_demandeur"] = "";
739                    $valLld["lot"]=$lot->valF['lot'];
740                    $valLld["demandeur"] = $row['demandeur'];
741                    $valLld["petitionnaire_principal"] = $row['petitionnaire_principal'];
742                    $lld->ajouter($valLld, $db, $DEBUG);
743                }
744            }
745        }
746    
747        /**
748       * Gestion des liens entre la demande et les demandeurs recemment ajoutés       * Gestion des liens entre la demande et les demandeurs recemment ajoutés
749       **/       **/
750      function insertLinkDemandeDemandeur($db, $DEBUG) {      function insertLinkDemandeDemandeur($db, $DEBUG) {
# Line 633  class demande extends demande_gen { Line 873  class demande extends demande_gen {
873       **/       **/
874      function listeDemandeur($from, $id) {      function listeDemandeur($from, $id) {
875          // Récupération des demandeurs de la base          // Récupération des demandeurs de la base
876          $sql = "SELECT demandeur.demandeur,          if(isset($this->valF['demande_type']) AND $this->getCodeDemandeType($this->valF['demande_type']) != "DT") {
877                          demandeur.type_demandeur,              $sql = "SELECT demandeur.demandeur,
878                          lien_".$from."_demandeur.petitionnaire_principal                              demandeur.type_demandeur,
879              FROM ".DB_PREFIXE."lien_".$from."_demandeur                              lien_".$from."_demandeur.petitionnaire_principal
880              INNER JOIN ".DB_PREFIXE."demandeur                  FROM ".DB_PREFIXE."lien_".$from."_demandeur
881              ON demandeur.demandeur=lien_".$from."_demandeur.demandeur                  INNER JOIN ".DB_PREFIXE."demandeur
882              WHERE ".$from." = '".$id."'";                  ON demandeur.demandeur=lien_".$from."_demandeur.demandeur
883          $res = $this->f->db->query($sql);                  WHERE ".$from." = '".$id."'";
884          $this->f->addToLog("listeDemandeur() : ".$sql);              $res = $this->f->db->query($sql);
885          $this->f->isDatabaseError($res);              $this->f->addToLog("listeDemandeur() : ".$sql);
886          // Stoquage du résultat dans un tableau              $this->f->isDatabaseError($res);
887          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              // Stoquage du résultat dans un tableau
888              if ($row['petitionnaire_principal'] == 't' AND              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
889                  $row['type_demandeur']=="petitionnaire") {                  if ($row['petitionnaire_principal'] == 't' AND
890                  $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];                      $row['type_demandeur']=="petitionnaire") {
891              } elseif ($row['petitionnaire_principal'] == 'f' AND                      $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];
892                  $row['type_demandeur']=="petitionnaire"){                  } elseif ($row['petitionnaire_principal'] == 'f' AND
893                  $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];                      $row['type_demandeur']=="petitionnaire"){
894              } elseif ($row['type_demandeur']=="delegataire"){                      $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];
895                  $this->valIdDemandeur['delegataire']=$row['demandeur'];                  } elseif ($row['type_demandeur']=="delegataire"){
896                        $this->valIdDemandeur['delegataire']=$row['demandeur'];
897                    }
898              }              }
899          }          }
900      }      }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26