/[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 1777 by vpihour, Tue Apr 23 10:37:14 2013 UTC revision 2061 by softime, Thu Jul 4 14:51:49 2013 UTC
# Line 93  class demande extends demande_gen { Line 93  class demande extends demande_gen {
93          elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))          elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))
94              include ("../sql/".$db->phptype."/".$this->table.".form.inc");              include ("../sql/".$db->phptype."/".$this->table.".form.inc");
95    
96          //Récupération de paramètre pour le rechargement ajax du select          // Si en ajout
97          $idx_dossier = $this->getParameter("idx_dossier");          if ($maj == 0) {
98          $datd = $this->getParameter("datd");              //Récupération de paramètre pour le rechargement ajax du select
99                $idx_dossier = $this->getParameter("idx_dossier");
100          $contenu = array();              $datd = $this->getParameter("datd");
101    
102          // Ajout de filtre sur la requête (initial)              $contenu = array();
103          if(isset($idx_dossier) AND $idx_dossier != "") {  
104              $sql_demande_type .= " WHERE demande_type.demande_nature = 2 ";              $sql_demande_type = "SELECT demande_type.demande_type, demande_type.libelle FROM ".DB_PREFIXE."demande_type
105                            LEFT OUTER JOIN ".DB_PREFIXE."lien_demande_type_etat_dossier_autorisation
106                                ON lien_demande_type_etat_dossier_autorisation.demande_type=demande_type.demande_type
107                            LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation
108                                ON lien_demande_type_etat_dossier_autorisation.etat_dossier_autorisation=
109                                    dossier_autorisation.etat_dossier_autorisation
110                            LEFT OUTER JOIN ".DB_PREFIXE."dossier
111                                ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation";
112    
113    
114                // Ajout de filtre sur la requête (initial)
115                if(isset($idx_dossier) AND $idx_dossier != "") {
116                    $sql_demande_type .= " WHERE demande_type.demande_nature = 2 ";
117    
118              // ajout du numéro de dossier existant pour tester l'état du DA                  // ajout du numéro de dossier existant pour tester l'état du DA
119              $sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' ";                  $sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' ";
120          } else {              } else {
121              $sql_demande_type .= " WHERE demande_type.demande_nature = 1 ";                  $sql_demande_type .= " WHERE demande_type.demande_nature = 1 ";
122          }              }
123          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"] != "") {
124              $datd = $_POST["dossier_autorisation_type_detaille"];                  $datd = $_POST["dossier_autorisation_type_detaille"];
125          }              }
126          // Ajout de filtre sur la requête (dossier_autorisation_type_detaille)              // Ajout de filtre sur la requête (dossier_autorisation_type_detaille)
127          if(isset($datd) AND $datd != "") {              if(isset($datd) AND $datd != "") {
             $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;  
         } else {  
             $datd = $this->getVal("dossier_autorisation_type_detaille");  
             if ($datd != "") {  
128                  $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;                  $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;
129                } else {
130                    $datd = $this->getVal("dossier_autorisation_type_detaille");
131                    if ($datd != "") {
132                        $sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd;
133                    }
134              }              }
135          }              $sql_demande_type .= " ORDER BY demande_type.libelle";
136                $res = $db->query($sql_demande_type);
137    
138          $res = $db->query($sql_demande_type);              // logger
139                $this->f->addToLog("setSelect(): db->query(\"".$sql_demande_type."\");",
140                                VERBOSE_MODE);
141                if ( database::isError($res)){
142                    die();
143                }
144    
145          // logger              $contenu[0][0] = '';
146          $this->f->addToLog("setSelect(): db->query(\"".$sql_demande_type."\");",              $contenu[1][0] = _('choisir')." "._("demande_type");
                         VERBOSE_MODE);  
         if ( database::isError($res)){  
             die();  
         }  
147    
148          $contenu[0][0] = '';              $k=1;
149          $contenu[1][0] = _('choisir')." "._("demande_type");              while($row =& $res->fetchRow()){
150    
151          $k=1;                  $contenu[0][$k] = $row[0];
152          while($row =& $res->fetchRow()){                  $contenu[1][$k] = $row[1];
153                    $k++;
154                }
155    
156              $contenu[0][$k] = $row[0];              $form->setSelect("demande_type", $contenu);
             $contenu[1][$k] = $row[1];  
             $k++;  
157          }          }
158            
         $form->setSelect("demande_type", $contenu);  
   
159      }      }
160      /*      /*
161      * Ajout du fielset      * Ajout du fielset
# Line 185  class demande extends demande_gen { Line 198  class demande extends demande_gen {
198      */      */
199      function setOnchange(&$form,$maj){      function setOnchange(&$form,$maj){
200          parent::setOnchange($form,$maj);          parent::setOnchange($form,$maj);
201    
202          $form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();");          $form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();");
203          $form->setOnchange("demande_type","showFormsDemande();");          $form->setOnchange("demande_type","showFormsDemande();");
204      }      }
# Line 193  class demande extends demande_gen { Line 207  class demande extends demande_gen {
207          parent::setLib($form,$maj);          parent::setLib($form,$maj);
208          //libelle des champs          //libelle des champs
209                    
210          $form->setLib('complement',_('terrain_adresse'));          $form->setLib('terrain_adresse_voie',_('terrain_adresse'));
211      }      }
212      /*      /*
213      * Cache le champ terrain_references_cadastrales      * Cache le champ terrain_references_cadastrales
# Line 214  class demande extends demande_gen { Line 228  class demande extends demande_gen {
228              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');              $form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic');
229              $form->setType('terrain_references_cadastrales', 'hiddenstatic');              $form->setType('terrain_references_cadastrales', 'hiddenstatic');
230              $form->setType('terrain_adresse_voie_numero', 'hiddenstatic');              $form->setType('terrain_adresse_voie_numero', 'hiddenstatic');
231              $form->setType('complement', 'hiddenstatic');              $form->setType('terrain_adresse_voie', 'hiddenstatic');
232              $form->setType('terrain_adresse_lieu_dit', 'hiddenstatic');              $form->setType('terrain_adresse_lieu_dit', 'hiddenstatic');
233              $form->setType('terrain_adresse_localite', 'hiddenstatic');              $form->setType('terrain_adresse_localite', 'hiddenstatic');
234              $form->setType('terrain_adresse_code_postal', 'hiddenstatic');              $form->setType('terrain_adresse_code_postal', 'hiddenstatic');
# Line 273  class demande extends demande_gen { Line 287  class demande extends demande_gen {
287                  $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);                  $valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
288                  $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];                  $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
289                  $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];                  $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
290                  $valAuto['complement']=$this->valF['complement'];                  $valAuto['terrain_adresse_voie']=$this->valF['terrain_adresse_voie'];
291                  $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];                  $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
292                  $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];                  $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
293                  $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];                  $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
# Line 340  class demande extends demande_gen { Line 354  class demande extends demande_gen {
354          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);          $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
355          $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];          $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
356          $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];          $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
357          $valInstr['complement']=$this->valF['complement'];          $valInstr['terrain_adresse_voie']=$this->valF['terrain_adresse_voie'];
358          $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];          $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
359          $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];          $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
360          $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];          $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
# Line 412  class demande extends demande_gen { Line 426  class demande extends demande_gen {
426      }      }
427    
428      /**      /**
429       * Ajout des liens demandeurs / dossier d'autorisation       * Ajout des liens demandeurs / dossier d'autorisation s'ils n'y sont pas déjà
430       **/       **/
431      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {      function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
432          // Création des liens entre le dossier autorisation et les demandeurs          // Création des liens entre le dossier autorisation et les demandeurs
# Line 420  class demande extends demande_gen { Line 434  class demande extends demande_gen {
434          require_once '../obj/lien_dossier_autorisation_demandeur.class.php';          require_once '../obj/lien_dossier_autorisation_demandeur.class.php';
435          $ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG);          $ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG);
436          // Recupération des demandeurs liés à la demande          // Recupération des demandeurs liés à la demande
437          $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);          $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur.
438            " AND lien_demande_demandeur.demandeur NOT IN (
439                SELECT lien_dossier_autorisation_demandeur.demandeur
440                FROM ".DB_PREFIXE."lien_dossier_autorisation_demandeur
441                WHERE lien_dossier_autorisation_demandeur.dossier_autorisation =
442                    '".$this->valF['dossier_autorisation']."'
443            )");
444          $res = $db->query($sql);          $res = $db->query($sql);
445          $this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE);          $this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE);
446          if ( database::isError($res)){          if ( database::isError($res)){
# Line 556  class demande extends demande_gen { Line 576  class demande extends demande_gen {
576              if ( database::isError($res)){              if ( database::isError($res)){
577                  die();                  die();
578              }              }
579                // Attribut permettant de définir si un dossier a été créé
580                $this->ajoutDI = FALSE;
581              $dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC);              $dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC);
582              // Création du dossier_autorisation              // Création du dossier_autorisation
583              if($this->valF['dossier_autorisation'] == "") {              if($this->valF['dossier_autorisation'] == "") {
584                  $this->ajoutDossierAutorisation($id, $db, $val, $DEBUG);                  $this->ajoutDossierAutorisation($id, $db, $val, $DEBUG);
585                  $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);                  $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);
586              }              }
587                // Enregistrement du numéro dossier existant (il sera écrasé si un DI est créé)
588                if ($this->getParameter("idx_dossier") != "") {
589                    $this->valF['dossier_instruction'] = $this->getParameter("idx_dossier");
590                }
591              // Création du dossier d'instruction              // Création du dossier d'instruction
592              if($dossier_type['dossier_instruction_type'] != NULL) {              if($dossier_type['dossier_instruction_type'] != NULL) {
593                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);                  $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
594                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);                  $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
595                    // Attribut permettant de définir si un dossier a été créé.
596                    $this->ajoutDI = TRUE;
597                                    
598                  //Ajout des données techniques au dossier d'instruction                  //Ajout des données techniques au dossier d'instruction
599                  $this->ajoutDonneesTechniques($id, $db, $val, $DEBUG);                  $this->ajoutDonneesTechniques($id, $db, $val, $DEBUG);
# Line 642  class demande extends demande_gen { Line 670  class demande extends demande_gen {
670                  $valInstr['date_retour_controle_legalite']=NULL;                  $valInstr['date_retour_controle_legalite']=NULL;
671                  $valInstr['signataire_arrete']=NULL;                  $valInstr['signataire_arrete']=NULL;
672                  $valInstr['numero_arrete']=NULL;                  $valInstr['numero_arrete']=NULL;
673                    $valInstr['code_barres']=NULL;
674                    $valInstr['om_fichier_instruction']=NULL;
675                    $valInstr['om_final_instruction']=NULL;
676                    $valInstr['document_numerise']=NULL;
677                                                                    
678                  /*Fichier requis*/                  /*Fichier requis*/
679                  require_once '../obj/instruction.class.php';                  require_once '../obj/instruction.class.php';
# Line 651  class demande extends demande_gen { Line 683  class demande extends demande_gen {
683                  $instruction->valF = "";                  $instruction->valF = "";
684                  $instruction->ajouter($valInstr, $db, $DEBUG);                  $instruction->ajouter($valInstr, $db, $DEBUG);
685                                    
686                    //Finalisation du document
687                    $_GET['obj']='instruction';
688                    $_GET['idx']=$instruction->valF[$instruction->clePrimaire];
689                    $instruction = new instruction($_GET['idx'],$db,$DEBUG);
690                    $res = $instruction->finaliser('', 1, '', '');
691                    
692                  /*Si la création a réussie*/                  /*Si la création a réussie*/
693                  if ( $instruction->valF['instruction'] != "" ){                  if ( $instruction->valF['instruction'] != "" ){
694                                            
# Line 658  class demande extends demande_gen { Line 696  class demande extends demande_gen {
696                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];                      $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
697                      $this -> addToMessage("<br/><a                      $this -> addToMessage("<br/><a
698                          class='lien'                          class='lien'
699                          href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$instruction->valF['instruction']."'                          href='"
700                                .((isset($res['pdf'])&&$instruction->valF['om_final_instruction'])?$res['pdf']:
701                                "../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$instruction->valF['instruction'])."'
702                          target='_blank'>                          target='_blank'>
703                              <span                              <span
704                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"                              class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
# Line 691  class demande extends demande_gen { Line 731  class demande extends demande_gen {
731          $this->insertLinkDemandeDemandeur($db, $DEBUG);          $this->insertLinkDemandeDemandeur($db, $DEBUG);
732                    
733          // Ajout des lliens entre dossier_autorisation et demandeur          // Ajout des lliens entre dossier_autorisation et demandeur
734          if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) {          if(!empty($this->valF['dossier_autorisation'])) {
735              $this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG);              $this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG);
736          }          }
737          // Ajout des lliens entre dossier et demandeur          // Ajout des lliens entre dossier et demandeur
738          if(!empty($this->valF['dossier_instruction'])) {          if($this->ajoutDI === TRUE) {
739              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);              $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
740          }          }
741    

Legend:
Removed from v.1777  
changed lines
  Added in v.2061

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26