/[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 1406 by nhaye, Thu Mar 14 17:05:37 2013 UTC revision 1606 by nhaye, Tue Apr 2 17:25:20 2013 UTC
# Line 81  class demande extends demande_gen { Line 81  class demande extends demande_gen {
81      }      }
82    
83      /**      /**
      * Méthode permettant de vérifier si un autre dossier d'instruction est en cour  
      * pour le même dossier d'autorisation.  
      */  
     function autreDossierEnCour() {  
   
         $idx_dossier = $this->getParameter("idx_dossier");  
   
         // Lorsqu'on se trouve sur un dossier existant  
         if(isset($idx_dossier) AND $idx_dossier != "") {  
   
             // Si on a pas encore défini si un autre dossier est en cours  
             if(!isset($this->autreDossierEnCour)) {  
   
                 if(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php"))  
                     include ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php");  
                 elseif(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc"))  
                     include ("../sql/".$this->db->phptype."/".$this->table.".form.inc");  
                 $request = str_replace('<idx>', $idx_dossier,  
                                          $sql_autreDossierEnCour);  
   
                 $nbDossier = $this->db->getOne($request);  
                 $this->f->addToLog("db->getone(\"".$request."\");", VERBOSE_MODE);  
                 $this->f->isDatabaseError($nbDossier);  
                 // Si un dossier est en cour return true  
                 if($nbDossier>0) {  
                       
                     $this->autreDossierEnCour = true;  
                 } else {  
   
                     $this->autreDossierEnCour = false;  
                 }  
   
             }  
         } else {  
             $this->autreDossierEnCour = false;  
         }  
   
         return $this->autreDossierEnCour;  
     }  
   
     /**  
84       * Configuration des select       * Configuration des select
85       */       */
86      function setSelect(&$form, $maj,&$db,$debug) {      function setSelect(&$form, $maj,&$db,$debug) {
# Line 140  class demande extends demande_gen { Line 99  class demande extends demande_gen {
99    
100          // Ajout de filtre sur la requête (initial)          // Ajout de filtre sur la requête (initial)
101          if(isset($idx_dossier) AND $idx_dossier != "") {          if(isset($idx_dossier) AND $idx_dossier != "") {
102              $sql_demande_type .= " WHERE demande_nature = 2 ";              $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 {          } else {
107              $sql_demande_type .= " WHERE demande_nature = 1 ";              $sql_demande_type .= " WHERE demande_type.demande_nature = 1 ";
108          }          }
109          if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") {          if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") {
110              $datd = $_POST["dossier_autorisation_type_detaille"];              $datd = $_POST["dossier_autorisation_type_detaille"];
111          }          }
112          // Ajout de filtre sur la requête (dossier_autorisation_type_detaille)          // Ajout de filtre sur la requête (dossier_autorisation_type_detaille)
113          if(isset($datd) AND $datd != "") {          if(isset($datd) AND $datd != "") {
114              $sql_demande_type .= " AND dossier_autorisation_type_detaille = ".$datd;              $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;
115          } else {          } else {
116              $sql_demande_type .= " AND dossier_autorisation_type_detaille = ".$this->getVal("dossier_autorisation_type_detaille");              $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);          $res = $db->query($sql_demande_type);
# Line 166  class demande extends demande_gen { Line 131  class demande extends demande_gen {
131    
132          $k=1;          $k=1;
133          while($row =& $res->fetchRow()){          while($row =& $res->fetchRow()){
             $display = true;  
134    
135              // Vérification des contraintes              $contenu[0][$k] = $row[0];
136              if($row[2] != "") {              $contenu[1][$k] = $row[1];
137                  foreach(explode(";", $row[2]) as $meth) {              $k++;
                     if(method_exists($this, $row[2])) {  
                         // Si une des contrainte est validée on affiche pas l'option  
                         if($this->$row[2]() === true) {  
                             $display = false;  
                         }  
                    }  
                 }  
             }  
             // Affichage ou non de l'option  
             if($display) {  
                 $contenu[0][$k] = $row[0];  
                 $contenu[1][$k] = $row[1];  
                 $k++;  
             }  
138          }          }
139    
140          $form->setSelect("demande_type", $contenu);          $form->setSelect("demande_type", $contenu);
# Line 234  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 278  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['exercice']=NULL;                      WHERE etat_dossier_autorisation = ".$id_etat_initial_da;
243          $valAuto['insee']=NULL;              $count = $this->db->getOne($sql);
244          $valAuto['arrondissement']=NULL;              $this->addToLog("ajoutDossierAutorisation() getOne() : ".$sql);
245          $valAuto['etat_dossier_autorisation']=1;              $this->f->isDatabaseError($count);
246          $valAuto['erp_numero_batiment']=NULL;              if($count != 1) {
247          $valAuto['erp_ouvert']=NULL;                  $error = true;
248          $valAuto['erp_arrete_decision']=NULL;              } else {
249          $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];                  // Création du dossier
250          $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);                  foreach($dossier_autorisation->champs as $value) {
251          $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];                      $valAuto[$value] = NULL;
252          $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];                  }
253          $valAuto['complement']=$this->valF['complement'];                  $valAuto['dossier_autorisation']="";
254          $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];                  $valAuto['exercice']=NULL;
255          $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];                  $valAuto['insee']=NULL;
256          $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];                  $valAuto['arrondissement']=NULL;
257          $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];                  $valAuto['etat_dossier_autorisation']=$this->getParameter('etat_initial_dossier_autorisation');
258          $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];                  $valAuto['erp_numero_batiment']=NULL;
259          $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];                  $valAuto['erp_ouvert']=NULL;
260          $valAuto['numero_version']=-1;                  $valAuto['erp_arrete_decision']=NULL;
261          // Ajout du dossier dans la base                  $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
262          $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);                  $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
263          // Liaison du dossier ajouter à la demande                  $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
264          $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];                  $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
265                    $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){      function getCodeDemandeType($demande_type){
# Line 343  class demande extends demande_gen { Line 324  class demande extends demande_gen {
324          // Définition des valeurs à entrée dans la table          // Définition des valeurs à entrée dans la table
325          $valInstr['dossier_instruction_type']=$dossier_instruction_type;          $valInstr['dossier_instruction_type']=$dossier_instruction_type;
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 592  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;

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26