/[openfoncier]/trunk/obj/instruction.class.php
ViewVC logotype

Diff of /trunk/obj/instruction.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1571 by nhaye, Thu Mar 28 12:22:00 2013 UTC revision 1784 by vpihour, Wed Apr 24 10:10:51 2013 UTC
# Line 32  class instruction extends instruction_ge Line 32  class instruction extends instruction_ge
32      var $archive_date_depot; // specific      var $archive_date_depot; // specific
33      var $retourformulaire;   // specific      var $retourformulaire;   // specific
34      var $idxformulaire;      // specific      var $idxformulaire;      // specific
35        var $valEvenement;
36    
37      function instruction($id, &$db, $debug) {      function instruction($id, &$db, $debug) {
38          $this->constructeur($id, $db, $debug);          $this->constructeur($id, $db, $debug);
# Line 99  class instruction extends instruction_ge Line 100  class instruction extends instruction_ge
100          return $division;          return $division;
101      }      }
102    
103        /**
104         * Cette méthode permet de récupérer le dossier d'autorisation d'un dossier
105         */
106        function getDossierAutorisationFromDossier($id) {
107            //
108            if (!isset($id)) {
109                return NULL;
110            }
111            //
112            $sql = "select dossier_autorisation from ".DB_PREFIXE."dossier ";
113            $sql .= " where dossier='".$id."'";
114            //
115            $dossier_autorisation = $this->db->getOne($sql);
116            $this->addToLog("getDossierAutorisationFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE);
117            database::isError($dossier_autorisation);
118            //
119            return $dossier_autorisation;
120        }
121    
122      // }}}      // }}}
123    
124      function setType(&$form, $maj) {      function setType(&$form, $maj) {
# Line 156  class instruction extends instruction_ge Line 176  class instruction extends instruction_ge
176          $form->setType('archive_date_chantier', 'hidden');            $form->setType('archive_date_chantier', 'hidden');  
177          //          //
178          $form->setType('numero_arrete', 'hidden');          $form->setType('numero_arrete', 'hidden');
179            //
180            $form->setType('code_barres', 'hidden');
181                    
182          //          //
183            $form->setType('archive_incompletude','hidden');
184            $form->setType('archive_evenement_suivant_tacite','hidden');
185            $form->setType('archive_evenement_suivant_tacite_incompletude','hidden');
186            $form->setType('archive_etat_pendant_incompletude','hidden');
187            $form->setType('archive_date_limite_incompletude','hidden');
188            $form->setType('archive_delai_incompletude','hidden');
189          if ($maj < 2) { //ajouter et modifier          if ($maj < 2) { //ajouter et modifier
190              $form->setType('destinataire', 'hidden');              $form->setType('destinataire', 'hidden');
191              $form->setType('lettretype', 'hiddenstatic');              $form->setType('lettretype', 'hiddenstatic');
# Line 363  class instruction extends instruction_ge Line 391  class instruction extends instruction_ge
391                      WHERE defaut IS TRUE";                      WHERE defaut IS TRUE";
392                            
393              // Exécution de la requête              // Exécution de la requête
             $this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);  
394              $res = $this->f->db->query($sql);              $res = $this->f->db->query($sql);
395              $this->f->isDatabaseError();              $this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);
396                if ( database::isError($res)){
397                    die();
398                }
399                    
400              $row = $res->fetchrow(DB_FETCHMODE_ASSOC);              $row = $res->fetchrow(DB_FETCHMODE_ASSOC);
401                            
# Line 556  class instruction extends instruction_ge Line 586  class instruction extends instruction_ge
586              if ($row['date_conformite']!='') {              if ($row['date_conformite']!='') {
587                  $this->valF['archive_date_conformite']= $row['date_conformite'];                    $this->valF['archive_date_conformite']= $row['date_conformite'];  
588              }              }
589                if ($row['incompletude']!='') {
590                    $this->valF['archive_incompletude']= $row['incompletude'];  
591                }
592                if ($row['evenement_suivant_tacite']!='') {
593                    $this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite'];  
594                }
595                if ($row['evenement_suivant_tacite_incompletude']!='') {
596                    $this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude'];  
597                }
598                if ($row['etat_pendant_incompletude']!='') {
599                    $this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude'];  
600                }
601                if ($row['date_limite_incompletude']!='') {
602                    $this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude'];  
603                }
604                if ($row['delai_incompletude']!='') {
605                    $this->valF['archive_delai_incompletude']= $row['delai_incompletude'];  
606                }
607          }          }
608    
609            // Identifiant du type de courrier
610            $idTypeCourrier = '11';
611            $idCourrier = str_pad($this->valF["instruction"], 10, "0", STR_PAD_LEFT);
612            // Code barres
613            $this->valF["code_barres"] = $idTypeCourrier . $idCourrier;
614      }      }
615            
616      // Test si une restriction est valide      // Test si une restriction est valide
# Line 680  class instruction extends instruction_ge Line 734  class instruction extends instruction_ge
734           * Mise à jour des valeurs du dossier en fonction des valeurs calculées           * Mise à jour des valeurs du dossier en fonction des valeurs calculées
735           * par l'action           * par l'action
736           */           */
737            $this->getValEvenement();
738          // Initialisation          // Initialisation
739          $valF = "";          $valF = "";
740            // état de complétude actuel du dossier
741            $incompletude =  $this->dossierIncomplet();
742    
743            if($incompletude === FALSE) {
744                // Si l'événement d'instruction est de type incompletude
745                if($this->valEvenement['type'] == "incompletude") {
746                    // On marque le dossier en incomplétude pour application des actions
747                    $incompletude = TRUE;
748                    // Set du flag incomplétude de la table dossier
749                    $valF['incompletude'] = TRUE;
750                    // Enregistrement de l'état dans la variable provisoire
751                    $valF['etat_pendant_incompletude'] = $this->valF['archive_etat'];
752                }
753            } else {
754                // Si l'evenement d'instruction est de type retour ou contient une
755                // decision, on sort d'incomplétude
756                if($this->valEvenement['type'] == "retour" OR
757                   $this->valEvenement['avis_decision'] != NULL) {
758                    // On enlève la marque d'incomplétude pour application des actions
759                    $incompletude = FALSE;
760                    // On enlève le flag d'incomplétude sur l'enregistrement de la table dossier
761                    $valF['incompletude'] = FALSE;
762                     // Restauration de l'état depuis l'état provisoire
763                    $valF['etat'] = $this->valF['archive_etat_pendant_incompletude'];
764                    // On vide la variable provisoire ainsi que le délai de complétude
765                    // et la date limite de complétude
766                    $valF['etat_pendant_incompletude'] = NULL;
767                    $valF['delai_incompletude'] = NULL;
768                    $valF['date_limite_incompletude'] = NULL;
769                }
770            }
771          // Récupération des paramètres de l'action          // Récupération des paramètres de l'action
772          $sql = "SELECT * FROM ".DB_PREFIXE."action          $sql = "SELECT * FROM ".DB_PREFIXE."action
773          WHERE action='".$this->valF['action']."'";          WHERE action='".$this->valF['action']."'";
# Line 691  class instruction extends instruction_ge Line 777  class instruction extends instruction_ge
777              die($res->getMessage());              die($res->getMessage());
778          }          }
779          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) {          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
780    
781              // pour chacune des regles, on applique la regle              // pour chacune des regles, on applique la regle
             if($row['regle_etat']!=''){  
                 $valF['etat'] = $this->regle($row['regle_etat']);  
             }  
782              if($row['regle_delai']!=''){              if($row['regle_delai']!=''){
783                  $valF['delai'] = $this->regle($row['regle_delai']);                  $valF['delai'] = $this->regle($row['regle_delai']);
784              }              }
# Line 734  class instruction extends instruction_ge Line 818  class instruction extends instruction_ge
818              if($row['regle_date_conformite']!=''){              if($row['regle_date_conformite']!=''){
819                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);
820              }              }
821              // Appel des méthode stockées dans le champ methode_trigger              if($row['regle_date_limite_incompletude']!=''){
822              if ($row['methode_trigger'] != "") {                  $valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude']);
823                  foreach (explode(";", $row['methode_trigger']) as $methode) {              }
824                      if (method_exists($this, $methode)) {              if($row['regle_delai_incompletude']!=''){
825                          $this->$methode();                  $valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude']);
826                      }              }
827                if($row['regle_etat']!=''){
828                    // Si on est dans le cas général ou qu'on est en incomplétude et
829                    // qu'on a un événement de type incomplétude alors : on stocke
830                    // l'état dans la variable courante
831                    if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") {
832                        $valF['etat'] = $this->regle($row['regle_etat']);
833                    } else {
834                        $valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat']);
835                    }
836                }
837    
838                if($this->valEvenement['evenement_suivant_tacite'] != '') {
839                    // Si on est pas en incomplétude on stocke l'événement tacite
840                    //de l'événement dans la variable courante
841                    if ($incompletude == FALSE) {
842                        $valF['evenement_suivant_tacite'] = $this->valEvenement['evenement_suivant_tacite'];
843                    } else {
844                        $valF['evenement_suivant_tacite_incompletude'] = $this->valEvenement['evenement_suivant_tacite'];
845                  }                  }
846              }              }
847          }          }
# Line 802  class instruction extends instruction_ge Line 904  class instruction extends instruction_ge
904                  }                  }
905              }              }
906          } // fin de if ($this->f->getParameter('option_erp') != "")          } // fin de if ($this->f->getParameter('option_erp') != "")
907    
908            // Mise à jour des données du dossier d'autorisation
909            require_once "../obj/dossier_autorisation.class.php";
910            $da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG);
911            $da->majDossierAutorisation();
912      }          }    
913    
914      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 830  class instruction extends instruction_ge Line 937  class instruction extends instruction_ge
937              die($res->getMessage());              die($res->getMessage());
938          }          }
939          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) {          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
940              // Ajout d'un événement d'instruction              // Si la date de retour signature est éditée on vérifie si il existe un événement automatique
   
941              if ($this->getVal('date_retour_signature') == "" AND $this->valF['date_retour_signature'] != "") {              if ($this->getVal('date_retour_signature') == "" AND $this->valF['date_retour_signature'] != "") {
942                  $new_instruction = new instruction("]", $db, $DEBUG);                  $new_instruction = new instruction("]", $db, $DEBUG);
943                    // Création d'un tableau avec la liste des champs de l'instruction
944                  foreach($new_instruction->champs as $champ) {                  foreach($new_instruction->champs as $champ) {
945                      $valNewInstr[$champ] = "";                      $valNewInstr[$champ] = "";
946                  }                  }
947                    // Définition des valeurs de la nouvelle instruction
948                  $valNewInstr["evenement"] = $row['evenement_retour_signature'];                  $valNewInstr["evenement"] = $row['evenement_retour_signature'];
949                  $valNewInstr["destinataire"] = $this->valF['destinataire'];                  $valNewInstr["destinataire"] = $this->valF['destinataire'];
950                  $valNewInstr["dossier"] = $this->valF['dossier'];                  $valNewInstr["dossier"] = $this->valF['dossier'];
951                  $valNewInstr["date_evenement"] = date("d/m/Y");                  $valNewInstr["date_evenement"] = date("d/m/Y");
952                  $new_instruction->ajouter($valNewInstr,$db, $DEBUG);                  $new_instruction->ajouter($valNewInstr,$db, $DEBUG);
953              }              }
954                // Si la date de retour AR est éditée on vérifie si il existe un événement automatique
955                if ($this->getVal('date_retour_rar') == "" AND $this->valF['date_retour_rar'] != "") {
956                    $new_instruction = new instruction("]", $db, $DEBUG);
957                    // Création d'un tableau avec la liste des champs de l'instruction
958                    foreach($new_instruction->champs as $champ) {
959                        $valNewInstr[$champ] = "";
960                    }
961                    // Définition des valeurs de la nouvelle instruction
962                    $valNewInstr["evenement"] = $row['evenement_retour_ar'];
963                    $valNewInstr["destinataire"] = $this->valF['destinataire'];
964                    $valNewInstr["dossier"] = $this->valF['dossier'];
965                    $valNewInstr["date_evenement"] = date("d/m/Y");
966                    $new_instruction->ajouter($valNewInstr,$db, $DEBUG);
967                }
968          }          }
969    
970          // Récupération des paramètres de l'action          // Récupération des paramètres de l'action
# Line 950  class instruction extends instruction_ge Line 1071  class instruction extends instruction_ge
1071                              WHERE instruction.instruction = ".$this->valF['instruction'];                              WHERE instruction.instruction = ".$this->valF['instruction'];
1072                  $resArrete = $this->db->query($sqlArrete);                  $resArrete = $this->db->query($sqlArrete);
1073                  $this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE);                  $this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE);
1074                  $this->f->isDatabaseError();                  if ( database::isError($resArrete)){
1075                        die();
1076                    }
1077            
1078                  $rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC);                  $rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC);
1079                  $msgenque->setArreteInfo($rowArrete);                  $msgenque->setArreteInfo($rowArrete);
1080                  $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI);                                  $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI);                
1081              }              }
1082          }          }
1083    
1084            // Mise à jour des données du dossier d'autorisation
1085            require_once "../obj/dossier_autorisation.class.php";
1086            $da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG);
1087            $da->majDossierAutorisation();
1088      }      }
1089    
1090      function triggersupprimer($id,&$db,$val,$DEBUG) {      function triggersupprimer($id,&$db,$val,$DEBUG) {
# Line 965  class instruction extends instruction_ge Line 1093  class instruction extends instruction_ge
1093           * archive dans le dossier d'instruction avant de supprimer l'événement           * archive dans le dossier d'instruction avant de supprimer l'événement
1094           * d'instruction           * d'instruction
1095           */           */
1096          // archive en instruction (si suppression) [archive if delete instruction]          // Mise à jour des 4 valeurs modifiées par l'action
1097          $valF['delai']=$val['archive_delai'];          $valF['delai'] = $val['archive_delai'];
1098          $valF['accord_tacite']=$val['archive_accord_tacite'];          $valF['accord_tacite'] = $val['archive_accord_tacite'];
1099          $valF['etat']=$val['archive_etat'];          $valF['etat'] = $val['archive_etat'];
1100          if($val['archive_avis']=='')          if ($val['archive_avis'] != '') {
1101              $valF['avis_decision']= null;              $valF['avis_decision'] = $val['archive_avis'];
1102          else          } else {
1103              $valF['avis_decision']=$val['archive_avis'];              $valF['avis_decision'] = NULL;
1104          if($val['archive_date_complet']!='')          }
1105              $valF['date_complet']=$val['archive_date_complet'];          // Mise à jour des 10 dates avec la valeur présente dans le formulaire
1106          if($val['archive_date_dernier_depot']!='')          // de suppression. Si la valeur de la date est vide alors on fixe
1107              $valF['date_dernier_depot']=$val['archive_date_dernier_depot'];          // à la valeur NULL
1108          if($val['archive_date_rejet']!='')          //
1109              $valF['date_rejet']= $val['archive_date_rejet'];          if ($val['archive_date_complet'] != '') {
1110          if($val['archive_date_limite']!='')              $valF['date_complet'] = $val['archive_date_complet'];
1111              $valF['date_limite']= $val['archive_date_limite'];          } else {
1112          if($val['archive_date_notification_delai']!='')              $valF['date_complet'] = NULL;
1113              $valF['date_notification_delai']= $val['archive_date_notification_delai'];          }
1114          if($val['archive_date_decision']!='')          if ($val['archive_date_dernier_depot'] != '') {
1115              $valF['date_decision']= $val['archive_date_decision'];              $valF['date_dernier_depot'] = $val['archive_date_dernier_depot'];
1116          if($val['archive_date_validite']!='')          } else {
1117              $valF['date_validite']= $val['archive_date_validite'];              $valF['date_dernier_depot'] = NULL;
1118          if($val['archive_date_achevement']!='')          }
1119              $valF['date_achevement']= $val['archive_date_achevement'];          if ($val['archive_date_rejet'] != '') {
1120          if($val['archive_date_chantier']!='')              $valF['date_rejet'] = $val['archive_date_rejet'];
1121              $valF['date_chantier']= $val['archive_date_chantier'];          } else {
1122          if($val['archive_date_conformite']!='')              $valF['date_rejet'] = NULL;
1123              $valF['date_conformite']= $val['archive_date_conformite'];          }
1124            if ($val['archive_date_limite'] != '') {
1125                $valF['date_limite'] = $val['archive_date_limite'];
1126            } else {
1127                $valF['date_limite'] = NULL;
1128            }
1129            if ($val['archive_date_notification_delai'] != '') {
1130                $valF['date_notification_delai'] = $val['archive_date_notification_delai'];
1131            } else {
1132                $valF['date_notification_delai'] = NULL;
1133            }
1134            if ($val['archive_date_decision'] != '') {
1135                $valF['date_decision'] = $val['archive_date_decision'];
1136            } else {
1137                $valF['date_decision'] = NULL;
1138            }
1139            if ($val['archive_date_validite'] != '') {
1140                $valF['date_validite'] = $val['archive_date_validite'];
1141            } else {
1142                $valF['date_validite'] = NULL;
1143            }
1144            if ($val['archive_date_achevement'] != '') {
1145                $valF['date_achevement'] = $val['archive_date_achevement'];
1146            } else {
1147                $valF['date_achevement'] = NULL;
1148            }
1149            if ($val['archive_date_chantier'] != '') {
1150                $valF['date_chantier'] = $val['archive_date_chantier'];
1151            } else {
1152                $valF['date_chantier'] = NULL;
1153            }
1154            if ($val['archive_date_conformite'] != '') {
1155                $valF['date_conformite'] = $val['archive_date_conformite'];
1156            } else {
1157                $valF['date_conformite'] = NULL;
1158            }
1159            if ($val['archive_incompletude'] != '') {
1160                $valF['incompletude'] = $val['archive_incompletude'];
1161            } else {
1162                $valF['incompletude'] = NULL;
1163            }
1164            if ($val['archive_evenement_suivant_tacite'] != '') {
1165                $valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite'];
1166            } else {
1167                $valF['evenement_suivant_tacite'] = NULL;
1168            }
1169            if ($val['archive_evenement_suivant_tacite_incompletude'] != '') {
1170                $valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude'];
1171            } else {
1172                $valF['evenement_suivant_tacite_incompletude'] = NULL;
1173            }
1174            if ($val['archive_etat_pendant_incompletude'] != '') {
1175                $valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude'];
1176            } else {
1177                $valF['etat_pendant_incompletude'] = NULL;
1178            }
1179            if ($val['archive_date_limite_incompletude'] != '') {
1180                $valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude'];
1181            } else {
1182                $valF['date_limite_incompletude'] = NULL;
1183            }
1184            if ($val['archive_delai_incompletude'] != '') {
1185                $valF['delai_incompletude'] = $val['archive_delai_incompletude'];
1186            } else {
1187                $valF['delai_incompletude'] = NULL;
1188            }
1189          // On met à jour le dossier          // On met à jour le dossier
1190          $cle = " dossier='".$val['dossier']."'";          $cle = " dossier='".$val['dossier']."'";
1191          $res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle);          $res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle);
1192          $this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE);          $this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE);
1193          if (database::isError($res1)) {          if (database::isError($res)) {
1194              die($res->getMessage());              die($res->getMessage());
1195          }          }
1196          // Affichage d'informations à l'utilisateur          // Affichage d'informations à l'utilisateur
1197          $this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]");          $this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]");
1198    
1199        }
1200    
1201        function triggersupprimerapres($id,&$db,$val,$DEBUG) {
1202    
1203            // Mise à jour des données du dossier d'autorisation
1204            require_once "../obj/dossier_autorisation.class.php";
1205            $da = new dossier_autorisation($this->getDossierAutorisationFromDossier($val["dossier"]), $this->db, DEBUG);
1206            $da->majDossierAutorisation();
1207      }      }
1208    
1209      // =============================================      // =============================================
# Line 1058  class instruction extends instruction_ge Line 1260  class instruction extends instruction_ge
1260      // Vérifie la restriction sur l'événement      // Vérifie la restriction sur l'événement
1261      function verifier($val = array(), &$db, $DEBUG){      function verifier($val = array(), &$db, $DEBUG){
1262          parent::verifier($val, $db, $DEBUG);          parent::verifier($val, $db, $DEBUG);
         //Récupère la restriction  
         $sql= "SELECT  
                   restriction  
               FROM  
                   ".DB_PREFIXE."evenement  
               WHERE  
                   evenement =".$this->valF['evenement'];  
1263    
1264          $res = $db->query($sql);          if ( isset($val['evenement']) && is_numeric($val['evenement'])){
1265          $this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);          //Récupère la restriction
1266          $this->f->isDatabaseError();              $sql= "SELECT
1267                                  restriction
1268          $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);                    FROM
1269                          ".DB_PREFIXE."evenement
1270          //Test qu'une restriction est présente                    WHERE
1271          if ( isset($row['restriction']) && $row['restriction'] != "" ){                        evenement =".$val['evenement'];
1272                    
1273              //Test si la restriction est valide              $res = $db->query($sql);
1274              if ( !$this->restrictionIsValid($row['restriction']) ){              $this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);
1275                                if (database::isError($res)) {
1276                  $this->correct=false;                  die($res->getMessage());
1277                  $this->addToMessage(_("Restriction non valide"));              }        
1278              }              $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1279              else {      
1280                //Test qu'une restriction est présente
1281                if ( isset($row['restriction']) && $row['restriction'] != "" ){
1282                                    
1283                  $this->correct = true;                  //Test si la restriction est valide
1284                    if ( !$this->restrictionIsValid($row['restriction']) ){
1285                        
1286                        $this->correct=false;
1287                        $this->addToMessage(_("Restriction non valide"));
1288                    }
1289                    else {
1290                        
1291                        $this->correct = true;
1292                    }
1293              }              }
1294          }          }
1295            
1296          $this->updateDate("date_envoi_signature");          $this->updateDate("date_envoi_signature");
1297          $this->updateDate("date_retour_signature");          $this->updateDate("date_retour_signature");
1298          $this->updateDate("date_envoi_rar");          $this->updateDate("date_envoi_rar");
# Line 1094  class instruction extends instruction_ge Line 1300  class instruction extends instruction_ge
1300          $this->updateDate("date_envoi_controle_legalite");          $this->updateDate("date_envoi_controle_legalite");
1301          $this->updateDate("date_retour_controle_legalite");          $this->updateDate("date_retour_controle_legalite");
1302      }      }
1303        
1304      /**      /**
1305       * Méthode permettant de mettre à jour l'état d'un DA       * Méthode permettant de récupérer toutes les valeurs de l'événement
1306         * sélectionné après validation du formulaire d'instruction
1307         *
1308         * @return array() veleurs de l'événement lié
1309       */       */
     function majEtatDA() {  
         if($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 8) {  
             $val['etat_dossier_autorisation']=5;  
         } elseif($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 15) {  
             $val['etat_dossier_autorisation']=3;  
         } elseif($this->valF['action'] == 'accepter') {  
             $val['etat_dossier_autorisation']=2;  
         } elseif($this->valF['action'] == 'rejeter') {  
             $val['etat_dossier_autorisation']=4;  
         } elseif($this->valF['action'] == 'terminer') {  
             $val['etat_dossier_autorisation']=8;  
         } elseif($this->valF['action'] == 'majorer') {  
             $val['etat_dossier_autorisation']=6;  
         } else {  
             $val['etat_dossier_autorisation']=7;  
         }  
           
         //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction  
         $IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']);  
         
         // Mis à jour de l'état du dossier d'autorisation  
         require_once '../obj/dossier_autorisation.class.php';  
         $dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG);  
           
         $dossier_autorisation->val[array_search("etat_dossier_autorisation", $dossier_autorisation->champs)] = $val['etat_dossier_autorisation'];  
           
         //Récupération des données  
         $valDossierAutorisation = array();  
         for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){  
               
             $valDossierAutorisation[$dossier_autorisation->champs[$i]]=  
                 $dossier_autorisation->val[$i];  
         }  
1310    
1311          $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);      private function getValEvenement() {
1312      }          if(!empty($this->valEvenement)) {
1313                    return $this->valEvenement;
1314     /**          } else {
1315      * Méthode permettant de mettre à jour les données d'un DA              $sql = "SELECT * FROM ".DB_PREFIXE."evenement
1316      */                  WHERE evenement=".$this->valF['evenement'];
1317      function majDataDA() {              $res = $this->db->query($sql);
1318                        $this->addToLog("getValEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);
1319          //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction              if (database::isError($res)) {
1320          $IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']);                  die($res->getMessage());
         require_once '../obj/dossier_autorisation.class.php';  
         $dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG);  
           
         require_once '../obj/dossier.class.php';  
         $dossier = new dossier($this->valF['dossier'],$this->db,DEBUG);  
           
         //Récupération des données  
         $valDossierAutorisation = array();  
         for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){  
               
             if ( array_search($dossier_autorisation->champs[$i], $dossier->champs) ){  
                   
                 $valDossierAutorisation[$dossier_autorisation->champs[$i]]=$dossier->getVal($dossier_autorisation->champs[$i]);  
             }  
             else {  
                 $valDossierAutorisation[$dossier_autorisation->champs[$i]]=  
                 $dossier_autorisation->val[$i];  
1321              }              }
1322                $this->valEvenement = $res->fetchRow(DB_FETCHMODE_ASSOC);
1323                return $this->valEvenement;
1324          }          }
1325        }
1326    
1327          $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);      /**
1328                 * Méthode permettant de savoir si le dossier lié à l'instruction à le flag
1329          // Suppression du liens entre les lots et le DA       * incompletude à true après validation du formulaire d'instruction
1330          $valLot['dossier_autorisation'] = NULL;       *
1331          $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "dossier_autorisation='".$IDdossier_autorisation."'");       * @return boolean
1332                 */
1333          // Liaison des lots du DI avec le DA      private function dossierIncomplet() {
1334          $sqlLot = "SELECT lot FROM ".DB_PREFIXE."lien_dossier_lot WHERE dossier='".$this->valF['dossier']."'";          $sql = "SELECT incompletude FROM ".DB_PREFIXE."dossier
1335          $res = $this->db->query($sqlLot);                  WHERE dossier='".$this->valF['dossier']."'";
1336          $this->addToLog($sqlLot);          $incompletude = $this->db->getOne($sql);
1337          $this->f->isDatabaseError();          $this->addToLog("dossierIncomplet(): db->query(\"".$sql."\");", VERBOSE_MODE);
1338          while($rowLot = $res->fetchRow(DB_FETCHMODE_ASSOC)) {          if (database::isError($incompletude)) {
1339              $valLot['dossier_autorisation'] = $IDdossier_autorisation;              die($incompletude->getMessage());
1340              $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "lot=".$rowLot['lot']);          }
1341            if ($incompletude == 't') {
1342                return true;
1343            } else {
1344                return false;
1345          }          }
1346      }      }
1347        
     // Récupération de l'identifiant du dossier d'autorisation lié au dossier d'instruction  
     function getDossierAutorisation($dossier_instruction){  
           
         $sql = "SELECT  
                     dossier_autorisation.dossier_autorisation  
                 FROM  
                     ".DB_PREFIXE."dossier_autorisation  
                 LEFT JOIN  
                     ".DB_PREFIXE."dossier  
                     ON  
                         dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation  
                 WHERE  
                     dossier.dossier = '".$dossier_instruction."'";  
         
         $IDdossier_autorisation = $this->db->getOne($sql);  
         $this->addToLog("getDossierAutorisation(): db->getone(\"".$sql."\")", VERBOSE_MODE);  
         database::isError($IDdossier_autorisation);  
           
         return $IDdossier_autorisation;  
     }  
1348  }// fin classe  }// fin classe
1349  ?>  ?>

Legend:
Removed from v.1571  
changed lines
  Added in v.1784

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26