/[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 1127 by vpihour, Thu Dec 27 15:07:37 2012 UTC revision 1595 by nhaye, Tue Apr 2 09:04:00 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 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 == 1) {          if($maj == 1) {
222              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
# Line 169  class demande extends demande_gen { Line 239  class demande extends demande_gen {
239              $valAuto[$value] = NULL;              $valAuto[$value] = NULL;
240          }          }
241          $valAuto['dossier_autorisation']=NULL;          $valAuto['dossier_autorisation']=NULL;
         $valAuto['nature']=NULL;  
242          $valAuto['exercice']=NULL;          $valAuto['exercice']=NULL;
243          $valAuto['insee']=NULL;          $valAuto['insee']=NULL;
244          $valAuto['arrondissement']=NULL;          $valAuto['arrondissement']=NULL;
245          $valAuto['etat']=NULL;          $valAuto['etat_dossier_autorisation']=7;
246          $valAuto['erp_numero_batiment']=NULL;          $valAuto['erp_numero_batiment']=NULL;
247          $valAuto['erp_ouvert']=NULL;          $valAuto['erp_ouvert']=NULL;
248          $valAuto['erp_arrete_decision']=NULL;          $valAuto['erp_arrete_decision']=NULL;
249          $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];          $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
250          $valAuto['depot_initial']=$this->valF['date_demande'];          $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
251          $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];          $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
252          $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];          $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
253          $valAuto['complement']=$this->valF['complement'];          $valAuto['complement']=$this->valF['complement'];
# Line 195  class demande extends demande_gen { Line 264  class demande extends demande_gen {
264          $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];          $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];
265      }      }
266    
267        function getCodeDemandeType($demande_type){
268            
269            $sql = "SELECT
270                        code
271                    FROM
272                        ".DB_PREFIXE."demande_type
273                    WHERE
274                        demande_type = ".$demande_type;
275            $codeDemandeType = $this->db->getOne($sql);
276            $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
277            
278            return $codeDemandeType;
279        }
280    
281      /**      /**
282       * Méthode permettant d'ajouter un dossier d'instruction       * Méthode permettant d'ajouter un dossier d'instruction
283       */       */
# Line 214  class demande extends demande_gen { Line 297  class demande extends demande_gen {
297          $dossier->setDossierInstructionType($dossier_instruction_type);          $dossier->setDossierInstructionType($dossier_instruction_type);
298                    
299          // Définition des valeurs à entrée dans la table          // Définition des valeurs à entrée dans la table
300          $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'];  
301          $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);
302            $valInstr['date_dernier_depot']=$this->dateDBToForm($this->valF['date_demande']);
303          $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);
304          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
305          $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];          $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
# Line 230  class demande extends demande_gen { Line 313  class demande extends demande_gen {
313          $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];          $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];
314          $valInstr['description']="";          $valInstr['description']="";
315          $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];          $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];
316    
317            /*
318             * Gestion de la qualification
319             * */
320             //Récupérer le code du type de la demande
321             $codeDemandeType = $this->getCodeDemandeType($val['demande_type']);
322            
323            //Marque le dossier comme à qualifier selon le type de dossier d'instruction
324            if ( strcasecmp($codeDemandeType, "DI") == 0 ||
325                 strcasecmp($codeDemandeType, "DT") == 0 ||
326                 strcasecmp($codeDemandeType, "DM") == 0 ||
327                 strcasecmp($codeDemandeType, "DP") == 0 ||
328                 strcasecmp($codeDemandeType, "DTP") == 0 ||
329                 strcasecmp($codeDemandeType, "DAACT") == 0 ||
330                 strcasecmp($codeDemandeType, "DOC") == 0 ){
331                
332                $valInstr['a_qualifier'] = TRUE;
333            }
334    
335            // Récupération du cerfa pour le type d'instruction sélectionnée et valide
336            $sql = "SELECT
337                        dossier_instruction_type.cerfa
338                    FROM
339                        ".DB_PREFIXE."dossier_instruction_type
340                    JOIN
341                        ".DB_PREFIXE."cerfa
342                    ON
343                        dossier_instruction_type.cerfa = cerfa.cerfa
344                    WHERE
345                        now()<=om_validite_fin
346                        AND now()>=om_validite_debut
347                        AND dossier_instruction_type=".$dossier_instruction_type;
348            $valInstr['cerfa'] = $db->getOne($sql);
349            $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
350    
351          $dossier->ajouter($valInstr, $db, $DEBUG);          $dossier->ajouter($valInstr, $db, $DEBUG);
352          $this->f->isDatabaseError();          $this->f->isDatabaseError();
353          // Liaison du dossier ajouter à la demande          // Liaison du dossier ajouter à la demande
# Line 237  class demande extends demande_gen { Line 355  class demande extends demande_gen {
355      }      }
356    
357      /**      /**
358         * Méthode permettant d'ajouter les données techniques au dossier d'instruction
359         */
360        function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){
361            
362            require_once '../obj/donnees_techniques.class.php';
363            $donnees_techniques = new donnees_techniques("]",$db,$DEBUG);
364            
365            // Champs tous à NULL car seul le champ concernant le dossier d'instruction sera rempli
366            foreach($donnees_techniques->champs as $value) {
367                $val[$value] = NULL;
368            }
369                    
370            // Ajout du numéro de dossier d'instruction
371            $val['dossier_instruction']=$this->valF['dossier_instruction'];
372    
373            // Ajout des données techniques    
374            $donnees_techniques->ajouter($val, $db, $DEBUG);
375            $this->f->isDatabaseError();
376        }
377    
378        /**
379       * Ajout des liens demandeurs / dossier d'autorisation       * Ajout des liens demandeurs / dossier d'autorisation
380       **/       **/
381      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
# Line 375  class demande extends demande_gen { Line 514  class demande extends demande_gen {
514              if($dossier_type['dossier_instruction_type'] != NULL) {              if($dossier_type['dossier_instruction_type'] != NULL) {
515                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
516                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
517                    
518                    //Ajout des données techniques au dossier d'instruction
519                    $this->ajoutDonneesTechniques($id, $db, $val, $DEBUG);
520              }              }
521                            
522              /*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 407  class demande extends demande_gen { Line 549  class demande extends demande_gen {
549                  $valInstr['delai_notification']="1";                  $valInstr['delai_notification']="1";
550                  $valInstr['archive_delai']="0";                  $valInstr['archive_delai']="0";
551                  $valInstr['archive_date_complet']=NULL;                  $valInstr['archive_date_complet']=NULL;
552                    $valInstr['archive_date_dernier_depot']=NULL;
553                  $valInstr['archive_date_rejet']=NULL;                  $valInstr['archive_date_rejet']=NULL;
554                  $valInstr['archive_date_limite']=NULL;                  $valInstr['archive_date_limite']=NULL;
555                  $valInstr['archive_date_notification_delai']=NULL;                  $valInstr['archive_date_notification_delai']=NULL;
# Line 432  class demande extends demande_gen { Line 575  class demande extends demande_gen {
575                  $valInstr['complement14']="";                  $valInstr['complement14']="";
576                  $valInstr['complement15']="";                  $valInstr['complement15']="";
577                  $valInstr['avis_decision']=NULL;                  $valInstr['avis_decision']=NULL;
578                    $valInstr['date_finalisation_courrier']=NULL;
579                    $valInstr['date_envoi_signature']=NULL;
580                    $valInstr['date_retour_signature']=NULL;
581                    $valInstr['date_envoi_rar']=NULL;
582                    $valInstr['date_retour_rar']=NULL;
583                    $valInstr['date_envoi_controle_legalite']=NULL;
584                    $valInstr['date_retour_controle_legalite']=NULL;
585                    $valInstr['signataire_arrete']=NULL;
586                    $valInstr['numero_arrete']=NULL;
587                                                                    
588                  /*Fichier requis*/                  /*Fichier requis*/
589                  require_once '../obj/instruction.class.php';                  require_once '../obj/instruction.class.php';
# Line 448  class demande extends demande_gen { Line 600  class demande extends demande_gen {
600                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
601                      $this -> addToMessage("<br/><a                      $this -> addToMessage("<br/><a
602                          class='lien'                          class='lien'
603                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$this->valF['dossier_instruction']."'                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$instruction->valF['instruction']."'
604                          target='_blank'>                          target='_blank'>
605                              <span                              <span
606                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
# Line 488  class demande extends demande_gen { Line 640  class demande extends demande_gen {
640          if(!empty($this->valF['dossier_instruction'])) {          if(!empty($this->valF['dossier_instruction'])) {
641              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
642          }          }
643    
644            // Duplication des lots et liaison au nouveau dossier_d'instruction
645            if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) {
646                $this->lienLotDossierInstruction($id, $db, $val, $DEBUG);
647            }
648      }      }
649            
650      /*Ajout du lien demande / demandeur(s)*/      /*Ajout du lien demande / demandeur(s)*/
# Line 499  class demande extends demande_gen { Line 656  class demande extends demande_gen {
656      }      }
657    
658      /**      /**
659         * Gestion des liens entre les lots du DA et le nouveau dossier
660         **/
661        function lienLotDossierInstruction($id, $db, $val, $DEBUG) {
662            require_once ("../obj/lot.class.php");
663            $lot = new lot("]", $db, $DEBUG);
664            require_once ("../obj/lien_dossier_lot.class.php");
665            $ldl = new lien_dossier_lot("]", $db, $DEBUG);
666            require_once ("../obj/lien_lot_demandeur.class.php");
667            $lld = new lien_lot_demandeur("]", $db, $DEBUG);
668    
669    
670            $sqlLots = "SELECT * FROM ".DB_PREFIXE."lot
671            WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'";
672            $resLot = $db -> query($sqlLots);
673            $this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE);
674            $this->f->isDatabaseError($resLot);
675            while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){
676                // Insertion du nouveau lot
677                $valLot['lot'] = "";
678                $valLot['libelle'] = $rowLot['libelle'];
679                $valLot['dossier_autorisation'] = NULL;
680                $lot -> ajouter($valLot, $db, $DEBUG);
681    
682                //Insertion du lien entre le lot et le dossier d'instruction
683                $valLdl['lien_dossier_lot'] = "";
684                $valLdl['dossier'] = $this->valF['dossier_instruction'];
685                $valLdl['lot'] = $lot->valF['lot'];
686                $ldl->ajouter($valLdl, $db, $DEBUG);
687    
688                //Insertion des liens entre dossier et les lots
689                $sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur
690                WHERE lot = ".$rowLot['lot'];
691                $res = $db -> query($sqlDemandeurs);
692                $this->f->addToLog("db->query(\"".$sqlDemandeurs."\");", VERBOSE_MODE);
693                $this->f->isDatabaseError($res);
694                
695                while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
696                    $valLld["lien_lot_demandeur"] = "";
697                    $valLld["lot"]=$lot->valF['lot'];
698                    $valLld["demandeur"] = $row['demandeur'];
699                    $valLld["petitionnaire_principal"] = $row['petitionnaire_principal'];
700                    $lld->ajouter($valLld, $db, $DEBUG);
701                }
702            }
703        }
704    
705        /**
706       * Gestion des liens entre la demande et les demandeurs recemment ajoutés       * Gestion des liens entre la demande et les demandeurs recemment ajoutés
707       **/       **/
708      function insertLinkDemandeDemandeur($db, $DEBUG) {      function insertLinkDemandeDemandeur($db, $DEBUG) {
# Line 627  class demande extends demande_gen { Line 831  class demande extends demande_gen {
831       **/       **/
832      function listeDemandeur($from, $id) {      function listeDemandeur($from, $id) {
833          // Récupération des demandeurs de la base          // Récupération des demandeurs de la base
834          $sql = "SELECT demandeur.demandeur,          if(isset($this->valF['demande_type']) AND $this->getCodeDemandeType($this->valF['demande_type']) != "DT") {
835                          demandeur.type_demandeur,              $sql = "SELECT demandeur.demandeur,
836                          lien_".$from."_demandeur.petitionnaire_principal                              demandeur.type_demandeur,
837              FROM ".DB_PREFIXE."lien_".$from."_demandeur                              lien_".$from."_demandeur.petitionnaire_principal
838              INNER JOIN ".DB_PREFIXE."demandeur                  FROM ".DB_PREFIXE."lien_".$from."_demandeur
839              ON demandeur.demandeur=lien_".$from."_demandeur.demandeur                  INNER JOIN ".DB_PREFIXE."demandeur
840              WHERE ".$from." = '".$id."'";                  ON demandeur.demandeur=lien_".$from."_demandeur.demandeur
841          $res = $this->f->db->query($sql);                  WHERE ".$from." = '".$id."'";
842          $this->f->addToLog("listeDemandeur() : ".$sql);              $res = $this->f->db->query($sql);
843          $this->f->isDatabaseError($res);              $this->f->addToLog("listeDemandeur() : ".$sql);
844          // Stoquage du résultat dans un tableau              $this->f->isDatabaseError($res);
845          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              // Stoquage du résultat dans un tableau
846              if ($row['petitionnaire_principal'] == 't' AND              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
847                  $row['type_demandeur']=="petitionnaire") {                  if ($row['petitionnaire_principal'] == 't' AND
848                  $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];                      $row['type_demandeur']=="petitionnaire") {
849              } elseif ($row['petitionnaire_principal'] == 'f' AND                      $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];
850                  $row['type_demandeur']=="petitionnaire"){                  } elseif ($row['petitionnaire_principal'] == 'f' AND
851                  $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];                      $row['type_demandeur']=="petitionnaire"){
852              } elseif ($row['type_demandeur']=="delegataire"){                      $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];
853                  $this->valIdDemandeur['delegataire']=$row['demandeur'];                  } elseif ($row['type_demandeur']=="delegataire"){
854                        $this->valIdDemandeur['delegataire']=$row['demandeur'];
855                    }
856              }              }
857          }          }
858      }      }

Legend:
Removed from v.1127  
changed lines
  Added in v.1595

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26