/[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 1823 by vpihour, Thu May 2 17:17:40 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
942              if ($this->getVal('date_retour_signature') == "" AND $this->valF['date_retour_signature'] != "") {                  $this->valF['date_retour_signature'] != "" AND
943                    $row['evenement_retour_signature'] != "") {
944                  $new_instruction = new instruction("]", $db, $DEBUG);                  $new_instruction = new instruction("]", $db, $DEBUG);
945                    // Création d'un tableau avec la liste des champs de l'instruction
946                  foreach($new_instruction->champs as $champ) {                  foreach($new_instruction->champs as $champ) {
947                      $valNewInstr[$champ] = "";                      $valNewInstr[$champ] = "";
948                  }                  }
949                    // Définition des valeurs de la nouvelle instruction
950                  $valNewInstr["evenement"] = $row['evenement_retour_signature'];                  $valNewInstr["evenement"] = $row['evenement_retour_signature'];
951                  $valNewInstr["destinataire"] = $this->valF['destinataire'];                  $valNewInstr["destinataire"] = $this->valF['destinataire'];
952                  $valNewInstr["dossier"] = $this->valF['dossier'];                  $valNewInstr["dossier"] = $this->valF['dossier'];
953                  $valNewInstr["date_evenement"] = date("d/m/Y");                  $valNewInstr["date_evenement"] = date("d/m/Y");
954                  $new_instruction->ajouter($valNewInstr,$db, $DEBUG);                  $new_instruction->ajouter($valNewInstr,$db, $DEBUG);
955              }              }
956                // Si la date de retour AR est éditée on vérifie si il existe un événement automatique
957                if ($this->getVal('date_retour_rar') == "" AND
958                    $this->valF['date_retour_rar'] != "" AND
959                    $row['evenement_retour_ar'] != "" ) {
960                    $new_instruction = new instruction("]", $db, $DEBUG);
961                    // Création d'un tableau avec la liste des champs de l'instruction
962                    foreach($new_instruction->champs as $champ) {
963                        $valNewInstr[$champ] = "";
964                    }
965                    // Définition des valeurs de la nouvelle instruction
966                    $valNewInstr["evenement"] = $row['evenement_retour_ar'];
967                    $valNewInstr["destinataire"] = $this->valF['destinataire'];
968                    $valNewInstr["dossier"] = $this->valF['dossier'];
969                    $valNewInstr["date_evenement"] = date("d/m/Y");
970                    $new_instruction->ajouter($valNewInstr,$db, $DEBUG);
971                }
972          }          }
973    
974          // 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 1075  class instruction extends instruction_ge
1075                              WHERE instruction.instruction = ".$this->valF['instruction'];                              WHERE instruction.instruction = ".$this->valF['instruction'];
1076                  $resArrete = $this->db->query($sqlArrete);                  $resArrete = $this->db->query($sqlArrete);
1077                  $this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE);                  $this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE);
1078                  $this->f->isDatabaseError();                  if ( database::isError($resArrete)){
1079                        die();
1080                    }
1081            
1082                  $rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC);                  $rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC);
1083                  $msgenque->setArreteInfo($rowArrete);                  $msgenque->setArreteInfo($rowArrete);
1084                  $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI);                                  $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI);                
1085              }              }
1086          }          }
1087    
1088            // Mise à jour des données du dossier d'autorisation
1089            require_once "../obj/dossier_autorisation.class.php";
1090            $da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG);
1091            $da->majDossierAutorisation();
1092      }      }
1093    
1094      function triggersupprimer($id,&$db,$val,$DEBUG) {      function triggersupprimer($id,&$db,$val,$DEBUG) {
# Line 965  class instruction extends instruction_ge Line 1097  class instruction extends instruction_ge
1097           * archive dans le dossier d'instruction avant de supprimer l'événement           * archive dans le dossier d'instruction avant de supprimer l'événement
1098           * d'instruction           * d'instruction
1099           */           */
1100          // archive en instruction (si suppression) [archive if delete instruction]          // Mise à jour des 4 valeurs modifiées par l'action
1101          $valF['delai']=$val['archive_delai'];          $valF['delai'] = $val['archive_delai'];
1102          $valF['accord_tacite']=$val['archive_accord_tacite'];          $valF['accord_tacite'] = $val['archive_accord_tacite'];
1103          $valF['etat']=$val['archive_etat'];          $valF['etat'] = $val['archive_etat'];
1104          if($val['archive_avis']=='')          if ($val['archive_avis'] != '') {
1105              $valF['avis_decision']= null;              $valF['avis_decision'] = $val['archive_avis'];
1106          else          } else {
1107              $valF['avis_decision']=$val['archive_avis'];              $valF['avis_decision'] = NULL;
1108          if($val['archive_date_complet']!='')          }
1109              $valF['date_complet']=$val['archive_date_complet'];          // Mise à jour des 10 dates avec la valeur présente dans le formulaire
1110          if($val['archive_date_dernier_depot']!='')          // de suppression. Si la valeur de la date est vide alors on fixe
1111              $valF['date_dernier_depot']=$val['archive_date_dernier_depot'];          // à la valeur NULL
1112          if($val['archive_date_rejet']!='')          //
1113              $valF['date_rejet']= $val['archive_date_rejet'];          if ($val['archive_date_complet'] != '') {
1114          if($val['archive_date_limite']!='')              $valF['date_complet'] = $val['archive_date_complet'];
1115              $valF['date_limite']= $val['archive_date_limite'];          } else {
1116          if($val['archive_date_notification_delai']!='')              $valF['date_complet'] = NULL;
1117              $valF['date_notification_delai']= $val['archive_date_notification_delai'];          }
1118          if($val['archive_date_decision']!='')          if ($val['archive_date_dernier_depot'] != '') {
1119              $valF['date_decision']= $val['archive_date_decision'];              $valF['date_dernier_depot'] = $val['archive_date_dernier_depot'];
1120          if($val['archive_date_validite']!='')          } else {
1121              $valF['date_validite']= $val['archive_date_validite'];              $valF['date_dernier_depot'] = NULL;
1122          if($val['archive_date_achevement']!='')          }
1123              $valF['date_achevement']= $val['archive_date_achevement'];          if ($val['archive_date_rejet'] != '') {
1124          if($val['archive_date_chantier']!='')              $valF['date_rejet'] = $val['archive_date_rejet'];
1125              $valF['date_chantier']= $val['archive_date_chantier'];          } else {
1126          if($val['archive_date_conformite']!='')              $valF['date_rejet'] = NULL;
1127              $valF['date_conformite']= $val['archive_date_conformite'];          }
1128            if ($val['archive_date_limite'] != '') {
1129                $valF['date_limite'] = $val['archive_date_limite'];
1130            } else {
1131                $valF['date_limite'] = NULL;
1132            }
1133            if ($val['archive_date_notification_delai'] != '') {
1134                $valF['date_notification_delai'] = $val['archive_date_notification_delai'];
1135            } else {
1136                $valF['date_notification_delai'] = NULL;
1137            }
1138            if ($val['archive_date_decision'] != '') {
1139                $valF['date_decision'] = $val['archive_date_decision'];
1140            } else {
1141                $valF['date_decision'] = NULL;
1142            }
1143            if ($val['archive_date_validite'] != '') {
1144                $valF['date_validite'] = $val['archive_date_validite'];
1145            } else {
1146                $valF['date_validite'] = NULL;
1147            }
1148            if ($val['archive_date_achevement'] != '') {
1149                $valF['date_achevement'] = $val['archive_date_achevement'];
1150            } else {
1151                $valF['date_achevement'] = NULL;
1152            }
1153            if ($val['archive_date_chantier'] != '') {
1154                $valF['date_chantier'] = $val['archive_date_chantier'];
1155            } else {
1156                $valF['date_chantier'] = NULL;
1157            }
1158            if ($val['archive_date_conformite'] != '') {
1159                $valF['date_conformite'] = $val['archive_date_conformite'];
1160            } else {
1161                $valF['date_conformite'] = NULL;
1162            }
1163            if ($val['archive_incompletude'] != '') {
1164                $valF['incompletude'] = $val['archive_incompletude'];
1165            } else {
1166                $valF['incompletude'] = NULL;
1167            }
1168            if ($val['archive_evenement_suivant_tacite'] != '') {
1169                $valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite'];
1170            } else {
1171                $valF['evenement_suivant_tacite'] = NULL;
1172            }
1173            if ($val['archive_evenement_suivant_tacite_incompletude'] != '') {
1174                $valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude'];
1175            } else {
1176                $valF['evenement_suivant_tacite_incompletude'] = NULL;
1177            }
1178            if ($val['archive_etat_pendant_incompletude'] != '') {
1179                $valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude'];
1180            } else {
1181                $valF['etat_pendant_incompletude'] = NULL;
1182            }
1183            if ($val['archive_date_limite_incompletude'] != '') {
1184                $valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude'];
1185            } else {
1186                $valF['date_limite_incompletude'] = NULL;
1187            }
1188            if ($val['archive_delai_incompletude'] != '') {
1189                $valF['delai_incompletude'] = $val['archive_delai_incompletude'];
1190            } else {
1191                $valF['delai_incompletude'] = NULL;
1192            }
1193          // On met à jour le dossier          // On met à jour le dossier
1194          $cle = " dossier='".$val['dossier']."'";          $cle = " dossier='".$val['dossier']."'";
1195          $res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle);          $res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle);
1196          $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);
1197          if (database::isError($res1)) {          if (database::isError($res)) {
1198              die($res->getMessage());              die($res->getMessage());
1199          }          }
1200          // Affichage d'informations à l'utilisateur          // Affichage d'informations à l'utilisateur
1201          $this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]");          $this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]");
1202    
1203        }
1204    
1205        function triggersupprimerapres($id,&$db,$val,$DEBUG) {
1206    
1207            // Mise à jour des données du dossier d'autorisation
1208            require_once "../obj/dossier_autorisation.class.php";
1209            $da = new dossier_autorisation($this->getDossierAutorisationFromDossier($val["dossier"]), $this->db, DEBUG);
1210            $da->majDossierAutorisation();
1211      }      }
1212    
1213      // =============================================      // =============================================
# Line 1058  class instruction extends instruction_ge Line 1264  class instruction extends instruction_ge
1264      // Vérifie la restriction sur l'événement      // Vérifie la restriction sur l'événement
1265      function verifier($val = array(), &$db, $DEBUG){      function verifier($val = array(), &$db, $DEBUG){
1266          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'];  
1267    
1268          $res = $db->query($sql);          if ( isset($val['evenement']) && is_numeric($val['evenement'])){
1269          $this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);          //Récupère la restriction
1270          $this->f->isDatabaseError();              $sql= "SELECT
1271                                  restriction
1272          $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);                    FROM
1273                          ".DB_PREFIXE."evenement
1274          //Test qu'une restriction est présente                    WHERE
1275          if ( isset($row['restriction']) && $row['restriction'] != "" ){                        evenement =".$val['evenement'];
1276                    
1277              //Test si la restriction est valide              $res = $db->query($sql);
1278              if ( !$this->restrictionIsValid($row['restriction']) ){              $this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);
1279                                if (database::isError($res)) {
1280                  $this->correct=false;                  die($res->getMessage());
1281                  $this->addToMessage(_("Restriction non valide"));              }        
1282              }              $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1283              else {      
1284                //Test qu'une restriction est présente
1285                if ( isset($row['restriction']) && $row['restriction'] != "" ){
1286                                    
1287                  $this->correct = true;                  //Test si la restriction est valide
1288                    if ( !$this->restrictionIsValid($row['restriction']) ){
1289                        
1290                        $this->correct=false;
1291                        $this->addToMessage(_("Restriction non valide"));
1292                    }
1293                    else {
1294                        
1295                        $this->correct = true;
1296                    }
1297              }              }
1298          }          }
1299            
1300          $this->updateDate("date_envoi_signature");          $this->updateDate("date_envoi_signature");
1301          $this->updateDate("date_retour_signature");          $this->updateDate("date_retour_signature");
1302          $this->updateDate("date_envoi_rar");          $this->updateDate("date_envoi_rar");
# Line 1094  class instruction extends instruction_ge Line 1304  class instruction extends instruction_ge
1304          $this->updateDate("date_envoi_controle_legalite");          $this->updateDate("date_envoi_controle_legalite");
1305          $this->updateDate("date_retour_controle_legalite");          $this->updateDate("date_retour_controle_legalite");
1306      }      }
1307        
1308      /**      /**
1309       * 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
1310         * sélectionné après validation du formulaire d'instruction
1311         *
1312         * @return array() veleurs de l'événement lié
1313       */       */
     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];  
         }  
1314    
1315          $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);      private function getValEvenement() {
1316      }          if(!empty($this->valEvenement)) {
1317                    return $this->valEvenement;
1318     /**          } else {
1319      * Méthode permettant de mettre à jour les données d'un DA              $sql = "SELECT * FROM ".DB_PREFIXE."evenement
1320      */                  WHERE evenement=".$this->valF['evenement'];
1321      function majDataDA() {              $res = $this->db->query($sql);
1322                        $this->addToLog("getValEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);
1323          //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction              if (database::isError($res)) {
1324          $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];  
1325              }              }
1326                $this->valEvenement = $res->fetchRow(DB_FETCHMODE_ASSOC);
1327                return $this->valEvenement;
1328          }          }
1329        }
1330    
1331          $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);      /**
1332                 * Méthode permettant de savoir si le dossier lié à l'instruction à le flag
1333          // Suppression du liens entre les lots et le DA       * incompletude à true après validation du formulaire d'instruction
1334          $valLot['dossier_autorisation'] = NULL;       *
1335          $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "dossier_autorisation='".$IDdossier_autorisation."'");       * @return boolean
1336                 */
1337          // Liaison des lots du DI avec le DA      private function dossierIncomplet() {
1338          $sqlLot = "SELECT lot FROM ".DB_PREFIXE."lien_dossier_lot WHERE dossier='".$this->valF['dossier']."'";          $sql = "SELECT incompletude FROM ".DB_PREFIXE."dossier
1339          $res = $this->db->query($sqlLot);                  WHERE dossier='".$this->valF['dossier']."'";
1340          $this->addToLog($sqlLot);          $incompletude = $this->db->getOne($sql);
1341          $this->f->isDatabaseError();          $this->addToLog("dossierIncomplet(): db->query(\"".$sql."\");", VERBOSE_MODE);
1342          while($rowLot = $res->fetchRow(DB_FETCHMODE_ASSOC)) {          if (database::isError($incompletude)) {
1343              $valLot['dossier_autorisation'] = $IDdossier_autorisation;              die($incompletude->getMessage());
1344              $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "lot=".$rowLot['lot']);          }
1345            if ($incompletude == 't') {
1346                return true;
1347            } else {
1348                return false;
1349          }          }
1350      }      }
1351        
     // 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;  
     }  
1352  }// fin classe  }// fin classe
1353  ?>  ?>

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26