/[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 5024 by softime, Wed Nov 2 14:39:23 2016 UTC revision 6565 by softime, Fri Apr 21 16:14:15 2017 UTC
# Line 14  Line 14 
14   * - voir script_lang.js : bible ...   * - voir script_lang.js : bible ...
15   *   *
16   * @package openfoncier   * @package openfoncier
17   * @version SVN : $Id: instruction.class.php 6178 2016-03-15 10:56:43Z nmeucci $   * @version SVN : $Id$
18   */   */
19    
20  //  //
# Line 42  class instruction extends instruction_ge Line 42  class instruction extends instruction_ge
42       */       */
43      var $inst_dossier = null;      var $inst_dossier = null;
44    
45        /**
46         * Instance de la classe instructeur
47         *
48         * @var mixed
49         */
50        var $inst_instructeur = null;
51    
52        /**
53         * Instance de la classe om_utilisateur
54         *
55         * @var mixed
56         */
57        var $inst_om_utilisateur = null;
58    
59      var $metadata = array(      var $metadata = array(
60          "om_fichier_instruction" => array(          "om_fichier_instruction" => array(
61              "dossier" => "getDossier",              "dossier" => "getDossier",
# Line 54  class instruction extends instruction_ge Line 68  class instruction extends instruction_ge
68              "dateEvenementDocument" => "getDateEvenementDocument",              "dateEvenementDocument" => "getDateEvenementDocument",
69              "groupeInstruction" => 'getGroupeInstruction',              "groupeInstruction" => 'getGroupeInstruction',
70              "title" => 'getTitle',              "title" => 'getTitle',
71                'concerneERP' => 'get_concerne_erp',
72          ),          ),
73          "arrete" => array(          "arrete" => array(
74              "numArrete" => "getNumArrete",              "numArrete" => "getNumArrete",
# Line 72  class instruction extends instruction_ge Line 87  class instruction extends instruction_ge
87              "dateControleLegalite" => "getDateControleLegalite",              "dateControleLegalite" => "getDateControleLegalite",
88          ),          ),
89      );      );
     /** @var boolean Les nouvelles actions sont activées sur cet objet */  
     var $activate_class_action;  
90    
91      function __construct($id, &$db, $debug) {      function __construct($id, &$db, $debug) {
         //On active les nouvelles actions  
         $this->activate_class_action = true;  
92          $this->constructeur($id, $db, $debug);          $this->constructeur($id, $db, $debug);
93      }      }
94    
# Line 94  class instruction extends instruction_ge Line 105  class instruction extends instruction_ge
105    
106          // ACTION - 000 - ajouter          // ACTION - 000 - ajouter
107          // Modifie la condition d'affichage du bouton ajouter          // Modifie la condition d'affichage du bouton ajouter
108          $this->class_actions[0]["condition"] = array("is_addable");          $this->class_actions[0]["condition"] = array("is_addable", "can_user_access_dossier_contexte_ajout");
109    
110          // ACTION - 001 - modifier          // ACTION - 001 - modifier
111          // Modifie la condition et le libellé du bouton modifier          // Modifie la condition et le libellé du bouton modifier
112          $this->class_actions[1]["condition"] = array("is_editable", "is_finalizable_without_bypass");          $this->class_actions[1]["condition"] = array(
113                "is_editable",
114                "is_finalizable_without_bypass",
115                "can_user_access_dossier_contexte_modification",
116            );
117          $this->class_actions[1]["portlet"]["libelle"] = _("Modifier");          $this->class_actions[1]["portlet"]["libelle"] = _("Modifier");
118                    
119          // ACTION - 002 - supprimer          // ACTION - 002 - supprimer
120          // Modifie la condition et le libellé du bouton supprimer          // Modifie la condition et le libellé du bouton supprimer
121          $this->class_actions[2]["condition"] = array("is_deletable", "is_finalizable_without_bypass");          $this->class_actions[2]["condition"] = array(
122                "is_deletable",
123                "is_finalizable_without_bypass",
124                "can_user_access_dossier_contexte_modification"
125            );
126          $this->class_actions[2]["portlet"]["libelle"] = _("Supprimer");          $this->class_actions[2]["portlet"]["libelle"] = _("Supprimer");
127    
128            // ACTION - 003 - consulter
129            //
130            $this->class_actions[3]["condition"] = "can_user_access_dossier_contexte_modification";
131    
132          // ACTION - 100 - finaliser          // ACTION - 100 - finaliser
133          // Finalise l'enregistrement          // Finalise l'enregistrement
134          $this->class_actions[100] = array(          $this->class_actions[100] = array(
# Line 120  class instruction extends instruction_ge Line 143  class instruction extends instruction_ge
143              "method" => "finalize",              "method" => "finalize",
144              "button" => "finaliser",              "button" => "finaliser",
145              "permission_suffix" => "finaliser",              "permission_suffix" => "finaliser",
146              "condition" => array("is_finalizable", "is_finalizable_without_bypass", "has_an_edition"),              "condition" => array(
147                    "is_finalizable",
148                    "is_finalizable_without_bypass",
149                    "has_an_edition",
150                    "can_user_access_dossier_contexte_modification",
151                ),
152          );          );
153    
154          // ACTION - 110 - definaliser          // ACTION - 110 - definaliser
# Line 137  class instruction extends instruction_ge Line 165  class instruction extends instruction_ge
165              "method" => "unfinalize",              "method" => "unfinalize",
166              "button" => "definaliser",              "button" => "definaliser",
167              "permission_suffix" => "definaliser",              "permission_suffix" => "definaliser",
168              "condition" => array("is_unfinalizable", "is_unfinalizable_without_bypass"),              "condition" => array(
169                    "is_unfinalizable",
170                    "is_unfinalizable_without_bypass",
171                    "can_user_access_dossier_contexte_modification",
172                ),
173          );          );
174    
175          // ACTION - 120 - edition          // ACTION - 120 - edition
# Line 151  class instruction extends instruction_ge Line 183  class instruction extends instruction_ge
183                  "class" => "pdf-16",                  "class" => "pdf-16",
184              ),              ),
185              "view" => "view_edition",              "view" => "view_edition",
186              "condition" => "has_an_edition",              "condition" => array("has_an_edition", "can_user_access_dossier_contexte_modification"),
187              "permission_suffix" => "om_fichier_instruction_telecharger",              "permission_suffix" => "om_fichier_instruction_telecharger",
188          );          );
189    
# Line 166  class instruction extends instruction_ge Line 198  class instruction extends instruction_ge
198                  "class" => "suivi-dates-16",                  "class" => "suivi-dates-16",
199              ),              ),
200              "crud" => "update",              "crud" => "update",
201              "condition" => array("is_unfinalizable", "is_unfinalizable_without_bypass"),              "condition" => array("can_monitoring_dates", "can_user_access_dossier_contexte_modification"),
202              "permission_suffix" => "modification_dates",              "permission_suffix" => "modification_dates",
203          );          );
204    
# Line 248  class instruction extends instruction_ge Line 280  class instruction extends instruction_ge
280              "view" => "formulaire",              "view" => "formulaire",
281              "method" => "notifier_commune",              "method" => "notifier_commune",
282              "permission_suffix" => "notifier_commune",              "permission_suffix" => "notifier_commune",
283              "condition" => "is_notifiable",              "condition" => array("is_notifiable", "can_user_access_dossier_contexte_modification"),
284          );          );
285    
286          // ACTION - 220 - generate_suivi_bordereaux          // ACTION - 220 - generate_suivi_bordereaux
# Line 256  class instruction extends instruction_ge Line 288  class instruction extends instruction_ge
288          $this->class_actions[220] = array(          $this->class_actions[220] = array(
289              "identifier" => "generate_suivi_bordereaux",              "identifier" => "generate_suivi_bordereaux",
290              "view" => "view_generate_suivi_bordereaux",              "view" => "view_generate_suivi_bordereaux",
291              "permission_suffix" => "consulter",              "permission_suffix" => "consulter",
292          );          );
293      }      }
294    
     /**  
      * Cette variable permet de stocker le résultat de la méthode  
      * getDivisionFromDossier() afin de ne pas effectuer le recalcul à chacun de  
      * ces appels.  
      * @var string Code de la division du dossier en cours  
      */  
     var $_division_from_dossier = NULL;  
   
     /**  
      * Cette méthode permet de récupérer le code de division correspondant  
      * au dossier sur lequel on se trouve.  
      *  
      * @return string Code de la division du dossier en cours  
      */  
     function getDivisionFromDossier() {  
   
         // Cette méthode peut être appelée plusieurs fois lors d'une requête.  
         // Pour éviter de refaire le traitement de recherche de la division  
         // alors on vérifie si nous ne l'avons pas déjà calculé.  
         if ($this->_division_from_dossier != NULL) {  
             // Logger  
             $this->addToLog("getDivisionFromDossier(): retour de la valeur déjà calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE);  
             // On retourne la valeur déjà calculée  
             return $this->_division_from_dossier;  
         }  
   
         // Par défaut, on définit la valeur du dossier à NULL  
         $dossier = NULL;  
         // Test sur le mode et le contexte du formulaire  
         if ($this->getParameter("maj") == 0  
             && ($this->getParameter("retourformulaire") == "dossier"  
                 || $this->getParameter("retourformulaire") == "dossier_instruction"  
                 || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"  
                 || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"  
                 || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"  
                 || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures")) {  
             // Si on se trouve en mode AJOUT (seul mode où l'enregistrement  
             // n'existe pas en base de données) ET que nous nous trouvons  
             // dans le contexte d'un dossier d'instruction alors on récupère  
             // le numéro de dossier depuis le paramètre 'idxformulaire'  
             $dossier = $this->getParameter("idxformulaire");  
         } else {  
             // Sinon on récupère le numéro de dossier dans le champs dossier de  
             // l'enregistrement (en base de données)  
             $dossier = $this->getVal("dossier");  
         }  
   
         // On appelle la méthode de la classe utils qui renvoi le code de la  
         // division d'un dossier, on la stocke pour ne pas refaire le calcul au  
         // prochain appel de cette méthode  
         $this->_division_from_dossier = $this->f->getDivisionFromDossier($dossier);  
         // Logger  
         $this->addToLog("getDivisionFromDossier(): retour de la valeur nouvellement calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE);  
         // On retourne la valeur retournée  
         return $this->_division_from_dossier;  
   
     }  
295    
296      /**      /**
297       * Cette méthode permet de récupérer le dossier d'autorisation d'un dossier       * Cette méthode permet de récupérer le dossier d'autorisation d'un dossier
# Line 406  class instruction extends instruction_ge Line 381  class instruction extends instruction_ge
381          $form->setType('archive_delai_incompletude','hidden');          $form->setType('archive_delai_incompletude','hidden');
382    
383          //          //
384            $form->setType('archive_date_cloture_instruction','hidden');
385            $form->setType('archive_date_premiere_visite','hidden');
386            $form->setType('archive_date_derniere_visite','hidden');
387            $form->setType('archive_date_contradictoire','hidden');
388            $form->setType('archive_date_retour_contradictoire','hidden');
389            $form->setType('archive_date_ait','hiddendate');
390            $form->setType('archive_date_transmission_parquet','hidden');
391    
392            //
393          $form->setType('duree_validite','hidden');          $form->setType('duree_validite','hidden');
394          $form->setType('duree_validite_parametrage','hidden');          $form->setType('duree_validite_parametrage','hidden');
395    
# Line 457  class instruction extends instruction_ge Line 441  class instruction extends instruction_ge
441                  // les administrateurs technique et fonctionnel peuvent                  // les administrateurs technique et fonctionnel peuvent
442                  // modifier tous les champs de date                  // modifier tous les champs de date
443                  // si l'instruction a déjà été finalisée au moins une fois                  // si l'instruction a déjà été finalisée au moins une fois
444                  if ($this->f->isAccredited(array("instruction", "instruction_modification_dates"), "OR")                  if (($this->f->isAccredited(array(get_class($this), get_class($this)."modification_dates"), "OR")
445                            || $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR"))
446                      && $this->getVal("date_finalisation_courrier") != '') {                      && $this->getVal("date_finalisation_courrier") != '') {
447                      $form->setType('date_envoi_signature', 'date');                      $form->setType('date_envoi_signature', 'date');
448                      $form->setType('date_retour_signature', 'date');                      $form->setType('date_retour_signature', 'date');
# Line 566  class instruction extends instruction_ge Line 551  class instruction extends instruction_ge
551                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"
552                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"
553                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"
554                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") {                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures"
555                    || $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions"
556                    || $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions"
557                    || $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours"
558                    || $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") {
559              // on recupère les signataires de la multicollectivité et de celle du DI              // on recupère les signataires de la multicollectivité et de celle du DI
560              require_once "../obj/dossier_instruction.class.php";              require_once "../obj/dossier_instruction.class.php";
561              $di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug);              $di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug);
# Line 604  class instruction extends instruction_ge Line 593  class instruction extends instruction_ge
593    
594              // Si changement de décision par instructeur commune              // Si changement de décision par instructeur commune
595              if($this->f->isUserInstructeur() === true              if($this->f->isUserInstructeur() === true
596                  && $this->f->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"]                  && $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"]
597                  && $this->f->isInstrCanChangeDecision($this->idxformulaire) === true) {                  && $this->isInstrCanChangeDecision($this->idxformulaire) === true) {
598                  $sql .= "AND evenement.type IN ('arrete', 'changement_decision') ";                  $sql .= "AND evenement.type IN ('arrete', 'changement_decision') ";
599              }              }
600              $sql .= "ORDER BY evenement.libelle, evenement.action";              $sql .= "ORDER BY evenement.libelle, evenement.action";
# Line 757  class instruction extends instruction_ge Line 746  class instruction extends instruction_ge
746                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"
747                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"
748                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"
749                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") {                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures"
750                    || $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions"
751                    || $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions"
752                    || $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours"
753                    || $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") {
754    
755              // Vérification de la possibilité de modifier les dates si déjà éditées              // Vérification de la possibilité de modifier les dates si déjà éditées
756              if($this->valF[$champ] != "" AND !$this->f->user_is_admin) {              if($this->valF[$champ] != "" AND !$this->f->user_is_admin) {
# Line 809  class instruction extends instruction_ge Line 802  class instruction extends instruction_ge
802                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours"
803                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours"
804                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"                  || $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures"
805                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") {                  || $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures"
806                    || $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions"
807                    || $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions"
808                    || $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours"
809                    || $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") {
810                  // on recupère les signataires de la multicollectivité et de celle du DI                  // on recupère les signataires de la multicollectivité et de celle du DI
811                  require_once "../obj/dossier_instruction.class.php";                  require_once "../obj/dossier_instruction.class.php";
812                  $di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG);                  $di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG);
# Line 914  class instruction extends instruction_ge Line 911  class instruction extends instruction_ge
911           * - delai_notification           * - delai_notification
912           * - lettretype           * - lettretype
913           * - autorite_competente           * - autorite_competente
914             * - complement_om_html
915             * - complement2_om_html
916             * - complement3_om_html
917             * - complement4_om_html
918             * - complement5_om_html
919           * DEPUIS LE DOSSIER D'INSTRUCTION           * DEPUIS LE DOSSIER D'INSTRUCTION
920           * - archive_delai           * - archive_delai
921           * - archive_accord_tacite           * - archive_accord_tacite
# Line 1256  class instruction extends instruction_ge Line 1258  class instruction extends instruction_ge
1258          return $return;          return $return;
1259      }      }
1260    
1261    
1262      /**      /**
1263       * Calcul des règle d'action.       * Calcul des règle d'action selon leur type.
1264       * @param string $rule      Règle d'action       *
1265       * @param string $rule_name Nom de la règle       * Types de règle :
1266       * @param string $type      Type de la règle       * - date
1267         * - numeric
1268         * - text
1269         * - bool
1270         * - specific
1271         * - technical_data
1272         *
1273         * @param string $rule      Règle d'action.
1274         * @param string $rule_name Nom de la règle.
1275         * @param string $type      Type de la règle.
1276       *       *
1277       * @return mixed            Résultat de la règle       * @return mixed            Résultat de la règle
1278       */       */
1279      function regle($rule, $rule_name, $type = null) {      public function regle($rule, $rule_name, $type = null) {
1280    
1281          // Supprime tous les espaces de la chaîne de caractère          // Supprime tous les espaces de la chaîne de caractère
1282          $rule = str_replace(' ', '', $rule);          $rule = str_replace(' ', '', $rule);
# Line 1278  class instruction extends instruction_ge Line 1290  class instruction extends instruction_ge
1290              return null;              return null;
1291          }          }
1292    
         // Si c'est une règle spécifique  
         if ($rule_name == "regle_autorite_competente"  
             || $rule_name == "regle_etat"  
             || $rule_name == "regle_accord_tacite"  
             || $rule_name == "regle_avis") {  
             //  
             return $this->valF[$rule];  
         }  
   
1293          // Tableau des champs de type date          // Tableau des champs de type date
1294          $rule_type_date = array(          $rule_type_date = array(
1295              "regle_date_limite",              "regle_date_limite",
# Line 1300  class instruction extends instruction_ge Line 1303  class instruction extends instruction_ge
1303              "regle_date_rejet",              "regle_date_rejet",
1304              "regle_date_dernier_depot",              "regle_date_dernier_depot",
1305              "regle_date_limite_incompletude",              "regle_date_limite_incompletude",
1306                "regle_date_cloture_instruction",
1307                "regle_date_premiere_visite",
1308                "regle_date_derniere_visite",
1309                "regle_date_contradictoire",
1310                "regle_date_retour_contradictoire",
1311                "regle_date_ait",
1312                "regle_date_transmission_parquet",
1313          );          );
1314          // Tableau des champs de type numérique          // Tableau des champs de type numérique
1315          $rule_type_numeric = array(          $rule_type_numeric = array(
1316              "regle_delai",              "regle_delai",
1317              "regle_delai_incompletude",              "regle_delai_incompletude",
1318          );          );
1319            // Tableau des champs de type text
1320            $rule_type_text = array(
1321            );
1322            // Tableau des champs de type booléen
1323            $rule_type_bool = array(
1324            );
1325            // Tableau des champs spécifiques
1326            $rule_type_specific = array(
1327                "regle_autorite_competente",
1328                "regle_etat",
1329                "regle_accord_tacite",
1330                "regle_avis",
1331            );
1332            // Tableau des champs de données techniques
1333            $rule_type_technical_data = array(
1334                'regle_donnees_techniques1',
1335                'regle_donnees_techniques2',
1336                'regle_donnees_techniques3',
1337                'regle_donnees_techniques4',
1338                'regle_donnees_techniques5',
1339            );
1340    
1341          // Définit le type du champ          // Définit le type du champ
1342          if (in_array($rule_name, $rule_type_date) == true) {          if (in_array($rule_name, $rule_type_date) == true) {
# Line 1314  class instruction extends instruction_ge Line 1345  class instruction extends instruction_ge
1345          if (in_array($rule_name, $rule_type_numeric) == true) {          if (in_array($rule_name, $rule_type_numeric) == true) {
1346              $type = "numeric";              $type = "numeric";
1347          }          }
1348            if (in_array($rule_name, $rule_type_text) === true) {
1349                $type = "text";
1350            }
1351            if (in_array($rule_name, $rule_type_bool) === true) {
1352                $type = "bool";
1353            }
1354            if (in_array($rule_name, $rule_type_specific) === true) {
1355                $type = "specific";
1356            }
1357            if (in_array($rule_name, $rule_type_technical_data) === true) {
1358                $type = 'text';
1359            }
1360    
1361            // Si c'est un type spécifique ou booléen alors il n'a qu'un opérande
1362            // Récupère directement la valeur de l'opérande
1363            if ($type === 'specific' || $type === 'bool') {
1364                //
1365                return $this->get_value_for_rule($rule);
1366            }
1367    
1368          // Initialisation des variables          // Initialisation des variables
1369          $key_date = 0;          $key_date = 0;
1370          $total_numeric = 0;          $total_numeric = 0;
1371            $res_text = '';
1372    
1373          // Pour chaque opérande          // Pour chaque opérande
1374          foreach ($operands as $key => $operand) {          foreach ($operands as $key => $operand) {
# Line 1325  class instruction extends instruction_ge Line 1376  class instruction extends instruction_ge
1376              // Si c'est une règle de type date              // Si c'est une règle de type date
1377              if ($type == 'date') {              if ($type == 'date') {
1378                  // Vérifie si au moins une des opérandes est une date                  // Vérifie si au moins une des opérandes est une date
1379                  if (!is_numeric($operand)                  if (is_numeric($operand) === false
1380                      && isset($this->valF[$operand])                      && $this->get_value_for_rule($operand) !== null
1381                      && $this->f->check_date($this->valF[$operand]) == true) {                      && $this->f->check_date($this->get_value_for_rule($operand)) == true) {
1382                      // Récupère la position de la date                      // Récupère la position de la date
1383                      $key_date = $key;                      $key_date = $key;
1384                  }                  }
# Line 1336  class instruction extends instruction_ge Line 1387  class instruction extends instruction_ge
1387                      // Ajoute l'opérande au total                      // Ajoute l'opérande au total
1388                      $total_numeric += $operand;                      $total_numeric += $operand;
1389                  }                  }
1390                  if (!is_numeric($operand)                  if (is_numeric($operand) === false
1391                      && isset($this->valF[$operand])                      && $this->get_value_for_rule($operand) !== null
1392                      && is_numeric($this->valF[$operand]) == true) {                      && is_numeric($this->get_value_for_rule($operand)) == true) {
1393                      // Ajoute l'opérande au total                      // Ajoute l'opérande au total
1394                      $total_numeric += $this->valF[$operand];                      $total_numeric += $this->get_value_for_rule($operand);
1395                  }                  }
1396              }              }
1397    
# Line 1351  class instruction extends instruction_ge Line 1402  class instruction extends instruction_ge
1402                      // Ajoute l'opérande au total                      // Ajoute l'opérande au total
1403                      $total_numeric += $operand;                      $total_numeric += $operand;
1404                  }                  }
1405                  if (!is_numeric($operand)                  if (is_numeric($operand) === false
1406                      && isset($this->valF[$operand])                      && $this->get_value_for_rule($operand) !== null
1407                      && is_numeric($this->valF[$operand]) == true) {                      && is_numeric($this->get_value_for_rule($operand)) == true) {
1408                      // Ajoute l'opérande au total                      // Ajoute l'opérande au total
1409                      $total_numeric += $this->valF[$operand];                      $total_numeric += $this->get_value_for_rule($operand);
1410                  }                  }
1411              }              }
1412    
1413                // Si c'est une règle de type text
1414                if ($type === 'text') {
1415                    // Concatène toutes les chaînes de caractère
1416                    $res_text .= $this->get_value_for_rule($operand);
1417                }
1418          }          }
1419    
1420          // Résultat pour une règle de type date          // Résultat pour une règle de type date
# Line 1372  class instruction extends instruction_ge Line 1429  class instruction extends instruction_ge
1429              // Retourne le calcul              // Retourne le calcul
1430              return $total_numeric;              return $total_numeric;
1431          }          }
1432    
1433            // Résultat pour une règle de type text
1434            if ($type === 'text') {
1435                // Retourne la chaîne de caractère
1436                return $res_text;
1437            }
1438        }
1439    
1440    
1441        /**
1442         * Récupère la valeur du champs dans l'instruction ou dans les données
1443         * techniques.
1444         * Spécifique au calcul des règles.
1445         *
1446         * @param string $field Champ
1447         *
1448         * @return mixed Valeur du champ
1449         */
1450        private function get_value_for_rule($field) {
1451            // Si le champ n'existe pas dans la table instruction
1452            if (array_key_exists($field, $this->valF) === false) {
1453                // Récupère l'instance de la classe donnees_techniques
1454                $inst_donnees_techniques = $this->get_inst_donnees_techniques();
1455                // Retourne la valeur de la donnée technique
1456                return $inst_donnees_techniques->getVal($field);
1457            }
1458    
1459            //
1460            return $this->valF[$field];
1461        }
1462    
1463    
1464        /**
1465         * [get_inst_donnees_techniques description]
1466         *
1467         * @param [type] $donnees_techniques [description]
1468         *
1469         * @return [type] [description]
1470         */
1471        function get_inst_donnees_techniques($donnees_techniques = null) {
1472            //
1473            if (isset($this->inst_donnees_techniques) === false or
1474                $this->inst_donnees_techniques === null) {
1475                //
1476                if (is_null($donnees_techniques)) {
1477                    $donnees_techniques = $this->getDonneesTechniques();
1478                }
1479                //
1480                require_once "../obj/donnees_techniques.class.php";
1481                $this->inst_donnees_techniques = new donnees_techniques($donnees_techniques);
1482            }
1483            //
1484            return $this->inst_donnees_techniques;
1485        }
1486    
1487    
1488        /**
1489         * Retourne l'identifiant des données techniques liées du dossier
1490         * @return string L'identifiant des données techniques liées du dossier
1491         */
1492        function getDonneesTechniques() {
1493                    
1494            $donnees_techniques = '';
1495    
1496            $sql = "SELECT donnees_techniques
1497                FROM ".DB_PREFIXE."donnees_techniques
1498                WHERE dossier_instruction ='".$this->valF["dossier"]."'";
1499            $donnees_techniques = $this->db->getOne($sql);
1500            $this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE);
1501            if ( database::isError($donnees_techniques)){
1502                die();
1503            }
1504    
1505            return $donnees_techniques;
1506      }      }
1507    
1508    
1509      /**      /**
1510       * TRIGGER - triggerajouterapres.       * TRIGGER - triggerajouterapres.
1511       *       *
# Line 1401  class instruction extends instruction_ge Line 1532  class instruction extends instruction_ge
1532          $incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false);          $incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false);
1533          // Initialisation          // Initialisation
1534          $valF = "";          $valF = "";
1535            $valF_dt = "";
1536          //          //
1537          if($incompletude === FALSE) {          if($incompletude === FALSE) {
1538              // Si l'événement d'instruction est de type incompletude              // Si l'événement d'instruction est de type incompletude
# Line 1443  class instruction extends instruction_ge Line 1575  class instruction extends instruction_ge
1575          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) {          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
1576    
1577              // pour chacune des regles, on applique la regle              // pour chacune des regles, on applique la regle
1578              if($row['regle_delai']!=''){              if ($row['regle_delai'] != '') {
1579                  $valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai');                  $valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai');
1580              }              }
1581              if($row['regle_accord_tacite']!=''){              if ($row['regle_accord_tacite'] != '') {
1582                  $valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite');                  $valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite');
1583              }              }
1584              if($row['regle_avis']!=''){              if ($row['regle_avis'] != '') {
1585                  $valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis');                  $valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis');
1586              }              }
1587              if($row['regle_date_limite']!=''){              if ($row['regle_date_limite'] != '') {
1588                  $valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite');                  $valF['date_limite'] = $this->regle($row['regle_date_limite'], 'regle_date_limite');
1589              }              }
1590              if($row['regle_date_complet']!=''){              if ($row['regle_date_complet'] != '') {
1591                  $valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet');                  $valF['date_complet'] = $this->regle($row['regle_date_complet'], 'regle_date_complet');
1592              }              }
1593              if($row['regle_date_dernier_depot']!=''){              if ($row['regle_date_dernier_depot'] != '') {
1594                  $valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot');                  $valF['date_dernier_depot'] = $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot');
1595              }              }
1596              if($row['regle_date_notification_delai']!=''){              if ($row['regle_date_notification_delai'] != '') {
1597                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai');                  $valF['date_notification_delai'] = $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai');
1598              }              }
1599              if($row['regle_date_decision']!=''){              if ($row['regle_date_decision'] != '') {
1600                  $valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision');                  $valF['date_decision'] = $this->regle($row['regle_date_decision'], 'regle_date_decision');
1601              }              }
1602              if($row['regle_date_rejet']!=''){              if ($row['regle_date_rejet'] != '') {
1603                  $valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet');                  $valF['date_rejet'] = $this->regle($row['regle_date_rejet'], 'regle_date_rejet');
1604              }              }
1605              if($row['regle_date_validite']!=''){              if ($row['regle_date_validite'] != '') {
1606                  $valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite');                  $valF['date_validite'] = $this->regle($row['regle_date_validite'], 'regle_date_validite');
1607              }              }
1608              if($row['regle_date_chantier']!=''){              if ($row['regle_date_chantier'] != '') {
1609                  $valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier');                  $valF['date_chantier'] = $this->regle($row['regle_date_chantier'], 'regle_date_chantier');
1610              }              }
1611              if($row['regle_date_achevement']!=''){              if ($row['regle_date_achevement'] != '') {
1612                  $valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement');                  $valF['date_achevement'] = $this->regle($row['regle_date_achevement'], 'regle_date_achevement');
1613              }              }
1614              if($row['regle_date_conformite']!=''){              if ($row['regle_date_conformite'] != '') {
1615                  $valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite');                  $valF['date_conformite'] = $this->regle($row['regle_date_conformite'], 'regle_date_conformite');
1616              }              }
1617              if($row['regle_date_limite_incompletude']!=''){              if ($row['regle_date_limite_incompletude'] != '') {
1618                  $valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude'], 'regle_date_limite_incompletude');                  $valF['date_limite_incompletude'] = $this->regle($row['regle_date_limite_incompletude'], 'regle_date_limite_incompletude');
1619              }              }
1620              if($row['regle_delai_incompletude']!=''){              if ($row['regle_delai_incompletude'] != '') {
1621                  $valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude');                  $valF['delai_incompletude'] = $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude');
1622              }              }
1623              if($row['regle_autorite_competente']!=''){              if ($row['regle_autorite_competente'] != '') {
1624                  $valF['autorite_competente']= $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente');                  $valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente');
1625              }              }
1626              if($row['regle_etat']!=''){              if ($row['regle_etat'] != '') {
1627                  // Si on est dans le cas général ou qu'on est en incomplétude et                  // Si on est dans le cas général ou qu'on est en incomplétude et
1628                  // qu'on a un événement de type incomplétude alors : on stocke                  // qu'on a un événement de type incomplétude alors : on stocke
1629                  // l'état dans la variable courante                  // l'état dans la variable courante
# Line 1501  class instruction extends instruction_ge Line 1633  class instruction extends instruction_ge
1633                      $valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat');                      $valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat');
1634                  }                  }
1635              }              }
1636                if ($row['regle_date_cloture_instruction'] !== '') {
1637                    $valF['date_cloture_instruction'] = $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction');
1638                }
1639                if ($row['regle_date_premiere_visite'] !== '') {
1640                    $valF['date_premiere_visite'] = $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite');
1641                }
1642                if ($row['regle_date_derniere_visite'] !== '') {
1643                    $valF['date_derniere_visite'] = $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite');
1644                }
1645                if ($row['regle_date_contradictoire'] !== '') {
1646                    $valF['date_contradictoire'] = $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire');
1647                }
1648                if ($row['regle_date_retour_contradictoire'] !== '') {
1649                    $valF['date_retour_contradictoire'] = $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire');
1650                }
1651                if ($row['regle_date_ait'] !== '') {
1652                    $valF['date_ait'] = $this->regle($row['regle_date_ait'], 'regle_date_ait');
1653                }
1654                if ($row['regle_donnees_techniques1'] !== '') {
1655                    $valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1');
1656                }
1657                if ($row['regle_donnees_techniques2'] !== '') {
1658                    $valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2');
1659                }
1660                if ($row['regle_donnees_techniques3'] !== '') {
1661                    $valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3');
1662                }
1663                if ($row['regle_donnees_techniques4'] !== '') {
1664                    $valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4');
1665                }
1666                if ($row['regle_donnees_techniques5'] !== '') {
1667                    $valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5');
1668                }
1669                if ($row['regle_date_transmission_parquet'] !== '') {
1670                    $valF['date_transmission_parquet'] = $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet');
1671                }
1672          }          }
1673    
1674            // Si l'événement a un événement suivant tacite
1675          if($inst_evenement->getVal('evenement_suivant_tacite') != '') {          if($inst_evenement->getVal('evenement_suivant_tacite') != '') {
1676              // Si on est pas en incomplétude on stocke l'événement tacite              // Si le DI n'est pas en incomplétude, l'événement tacite est stocké
1677                  //de l'événement dans la variable courante              // dans le champ evenement_suivant_tacite du dossier
1678                                if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") {
1679                  if ($incompletude == FALSE OR $inst_evenement->getVal('type') != "incompletude") {                  //
1680                      $valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite');                  $valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite');
1681                  } else {              } else {
1682                      $valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite');                  // Sinon l'événement tacite est stocké dans le champ
1683                  }                  // evenement_suivant_tacite_incompletude du dossier
1684                    $valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite');
1685                }
1686            }
1687            // Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement
1688            if ($valF_dt != "") {
1689                $dt_id = $this->getDonneesTechniques();
1690                // On met à jour le dossier
1691                $cle = " donnees_techniques='".$dt_id."'";
1692                $res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle);
1693                $this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE);
1694                if (database::isError($res1)) {
1695                    die($res->getMessage());
1696                }
1697                // Affichage d'informations à l'utilisateur
1698                $this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]");
1699          }          }
1700          // Si des valeurs ont été calculées alors on met à jour l'enregistrement          // Si des valeurs ont été calculées alors on met à jour l'enregistrement
1701          if ($valF != "") {          if ($valF != "") {
# Line 1584  class instruction extends instruction_ge Line 1769  class instruction extends instruction_ge
1769           */           */
1770          // Initialisation          // Initialisation
1771          $valF = "";          $valF = "";
1772            $valF_dt = "";
1773          // Initialisation du type d'événement          // Initialisation du type d'événement
1774          $type_evmt = "";          $type_evmt = "";
1775          // Récupération de l'action correspondante à l'événement          // Récupération de l'action correspondante à l'événement
# Line 1636  class instruction extends instruction_ge Line 1822  class instruction extends instruction_ge
1822              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){
1823                  $valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite');                  $valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite');
1824              }              }
1825                if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){
1826                    $valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction');
1827                }
1828                if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){
1829                    $valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite');
1830                }
1831                if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){
1832                    $valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite');
1833                }
1834                if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){
1835                    $valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire');
1836                }
1837                if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){
1838                    $valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire');
1839                }
1840                if(preg_match("/date_evenement/",$row['regle_date_ait'])){
1841                    $valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait');
1842                }
1843                if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){
1844                    $valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet');
1845                }
1846                if ($row['regle_donnees_techniques1'] !== '') {
1847                    $valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1');
1848                }
1849                if ($row['regle_donnees_techniques2'] !== '') {
1850                    $valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2');
1851                }
1852                if ($row['regle_donnees_techniques3'] !== '') {
1853                    $valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3');
1854                }
1855                if ($row['regle_donnees_techniques4'] !== '') {
1856                    $valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4');
1857                }
1858                if ($row['regle_donnees_techniques5'] !== '') {
1859                    $valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5');
1860                }
1861            }
1862            // Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement
1863            if ($valF_dt != "") {
1864                $dt_id = $this->getDonneesTechniques();
1865                // On met à jour le dossier
1866                $cle = " donnees_techniques='".$dt_id."'";
1867                $res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle);
1868                $this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE);
1869                if (database::isError($res1)) {
1870                    die($res->getMessage());
1871                }
1872                // Affichage d'informations à l'utilisateur
1873                $this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]");
1874          }          }
1875          // Si des valeurs ont été calculées alors on met à jour l'enregistrement          // Si des valeurs ont été calculées alors on met à jour l'enregistrement
1876          if ($valF != "") {          if ($valF != "") {
# Line 1801  class instruction extends instruction_ge Line 2036  class instruction extends instruction_ge
2036          if ($val['archive_avis'] != '') {          if ($val['archive_avis'] != '') {
2037              $valF['avis_decision'] = $val['archive_avis'];              $valF['avis_decision'] = $val['archive_avis'];
2038          } else {          } else {
2039              $valF['avis_decision'] = NULL;              $valF['avis_decision'] = null;
2040          }          }
2041          // Mise à jour des 10 dates avec la valeur présente dans le formulaire          // Mise à jour des dates avec la valeur présente dans le formulaire
2042          // de suppression. Si la valeur de la date est vide alors on fixe          // de suppression. Si la valeur de la date est vide alors on fixe
2043          // à la valeur NULL          // à la valeur null
         //  
2044          if ($val['archive_date_complet'] != '') {          if ($val['archive_date_complet'] != '') {
2045              $valF['date_complet'] = $val['archive_date_complet'];              $valF['date_complet'] = $val['archive_date_complet'];
2046          } else {          } else {
2047              $valF['date_complet'] = NULL;              $valF['date_complet'] = null;
2048          }          }
2049          if ($val['archive_date_dernier_depot'] != '') {          if ($val['archive_date_dernier_depot'] != '') {
2050              $valF['date_dernier_depot'] = $val['archive_date_dernier_depot'];              $valF['date_dernier_depot'] = $val['archive_date_dernier_depot'];
2051          } else {          } else {
2052              $valF['date_dernier_depot'] = NULL;              $valF['date_dernier_depot'] = null;
2053          }          }
2054          if ($val['archive_date_rejet'] != '') {          if ($val['archive_date_rejet'] != '') {
2055              $valF['date_rejet'] = $val['archive_date_rejet'];              $valF['date_rejet'] = $val['archive_date_rejet'];
2056          } else {          } else {
2057              $valF['date_rejet'] = NULL;              $valF['date_rejet'] = null;
2058          }          }
2059          if ($val['archive_date_limite'] != '') {          if ($val['archive_date_limite'] != '') {
2060              $valF['date_limite'] = $val['archive_date_limite'];              $valF['date_limite'] = $val['archive_date_limite'];
2061          } else {          } else {
2062              $valF['date_limite'] = NULL;              $valF['date_limite'] = null;
2063          }          }
2064          if ($val['archive_date_notification_delai'] != '') {          if ($val['archive_date_notification_delai'] != '') {
2065              $valF['date_notification_delai'] = $val['archive_date_notification_delai'];              $valF['date_notification_delai'] = $val['archive_date_notification_delai'];
2066          } else {          } else {
2067              $valF['date_notification_delai'] = NULL;              $valF['date_notification_delai'] = null;
2068          }          }
2069          if ($val['archive_date_decision'] != '') {          if ($val['archive_date_decision'] != '') {
2070              $valF['date_decision'] = $val['archive_date_decision'];              $valF['date_decision'] = $val['archive_date_decision'];
2071          } else {          } else {
2072              $valF['date_decision'] = NULL;              $valF['date_decision'] = null;
2073          }          }
2074          if ($val['archive_date_validite'] != '') {          if ($val['archive_date_validite'] != '') {
2075              $valF['date_validite'] = $val['archive_date_validite'];              $valF['date_validite'] = $val['archive_date_validite'];
2076          } else {          } else {
2077              $valF['date_validite'] = NULL;              $valF['date_validite'] = null;
2078          }          }
2079          if ($val['archive_date_achevement'] != '') {          if ($val['archive_date_achevement'] != '') {
2080              $valF['date_achevement'] = $val['archive_date_achevement'];              $valF['date_achevement'] = $val['archive_date_achevement'];
2081          } else {          } else {
2082              $valF['date_achevement'] = NULL;              $valF['date_achevement'] = null;
2083          }          }
2084          if ($val['archive_date_chantier'] != '') {          if ($val['archive_date_chantier'] != '') {
2085              $valF['date_chantier'] = $val['archive_date_chantier'];              $valF['date_chantier'] = $val['archive_date_chantier'];
2086          } else {          } else {
2087              $valF['date_chantier'] = NULL;              $valF['date_chantier'] = null;
2088          }          }
2089          if ($val['archive_date_conformite'] != '') {          if ($val['archive_date_conformite'] != '') {
2090              $valF['date_conformite'] = $val['archive_date_conformite'];              $valF['date_conformite'] = $val['archive_date_conformite'];
2091          } else {          } else {
2092              $valF['date_conformite'] = NULL;              $valF['date_conformite'] = null;
2093          }          }
2094          if ($val['archive_incompletude'] != '') {          if ($val['archive_incompletude'] != '') {
2095              $valF['incompletude'] = $val['archive_incompletude'];              $valF['incompletude'] = $val['archive_incompletude'];
2096          } else {          } else {
2097              $valF['incompletude'] = NULL;              $valF['incompletude'] = null;
2098          }          }
2099          if ($val['archive_incomplet_notifie'] != '') {          if ($val['archive_incomplet_notifie'] != '') {
2100              $valF['incomplet_notifie'] = $val['archive_incomplet_notifie'];              $valF['incomplet_notifie'] = $val['archive_incomplet_notifie'];
2101          } else {          } else {
2102              $valF['incomplet_notifie'] = NULL;              $valF['incomplet_notifie'] = null;
2103          }          }
2104          if ($val['archive_evenement_suivant_tacite'] != '') {          if ($val['archive_evenement_suivant_tacite'] != '') {
2105              $valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite'];              $valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite'];
2106          } else {          } else {
2107              $valF['evenement_suivant_tacite'] = NULL;              $valF['evenement_suivant_tacite'] = null;
2108          }          }
2109          if ($val['archive_evenement_suivant_tacite_incompletude'] != '') {          if ($val['archive_evenement_suivant_tacite_incompletude'] != '') {
2110              $valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude'];              $valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude'];
2111          } else {          } else {
2112              $valF['evenement_suivant_tacite_incompletude'] = NULL;              $valF['evenement_suivant_tacite_incompletude'] = null;
2113          }          }
2114          if ($val['archive_etat_pendant_incompletude'] != '') {          if ($val['archive_etat_pendant_incompletude'] != '') {
2115              $valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude'];              $valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude'];
2116          } else {          } else {
2117              $valF['etat_pendant_incompletude'] = NULL;              $valF['etat_pendant_incompletude'] = null;
2118          }          }
2119          if ($val['archive_date_limite_incompletude'] != '') {          if ($val['archive_date_limite_incompletude'] != '') {
2120              $valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude'];              $valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude'];
2121          } else {          } else {
2122              $valF['date_limite_incompletude'] = NULL;              $valF['date_limite_incompletude'] = null;
2123          }          }
2124          if ($val['archive_delai_incompletude'] != '') {          if ($val['archive_delai_incompletude'] != '') {
2125              $valF['delai_incompletude'] = $val['archive_delai_incompletude'];              $valF['delai_incompletude'] = $val['archive_delai_incompletude'];
2126          } else {          } else {
2127              $valF['delai_incompletude'] = NULL;              $valF['delai_incompletude'] = null;
2128          }          }
2129          if ($val['archive_autorite_competente'] != '') {          if ($val['archive_autorite_competente'] != '') {
2130              $valF['autorite_competente'] = $val['archive_autorite_competente'];              $valF['autorite_competente'] = $val['archive_autorite_competente'];
2131          } else {          } else {
2132              $valF['autorite_competente'] = NULL;              $valF['autorite_competente'] = null;
2133          }          }
2134            $valF['date_cloture_instruction'] = null;
2135            if ($val['archive_date_cloture_instruction'] !== '') {
2136                $valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction'];
2137            }
2138            // Dates concernant les dossiers contentieux
2139            // Date de première visite
2140            $valF['date_premiere_visite'] = null;
2141            if ($val['archive_date_premiere_visite'] !== '') {
2142                $valF['date_premiere_visite'] = $val['archive_date_premiere_visite'];
2143            }
2144            // Date de dernière visite
2145            $valF['date_derniere_visite'] = null;
2146            if ($val['archive_date_derniere_visite'] !== '') {
2147                $valF['date_derniere_visite'] = $val['archive_date_derniere_visite'];
2148            }
2149            // Date contradictoire
2150            $valF['date_contradictoire'] = null;
2151            if ($val['archive_date_contradictoire'] !== '') {
2152                $valF['date_contradictoire'] = $val['archive_date_contradictoire'];
2153            }
2154            // Date de retour contradictoire
2155            $valF['date_retour_contradictoire'] = null;
2156            if ($val['archive_date_retour_contradictoire'] !== '') {
2157                $valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire'];
2158            }
2159            // Date de l'AIT
2160            $valF['date_ait'] = null;
2161            if ($val['archive_date_ait'] !== '') {
2162                $valF['date_ait'] = $val['archive_date_ait'];
2163            }
2164            // Date de transmission au parquet
2165            $valF['date_transmission_parquet'] = null;
2166            if ($val['archive_date_transmission_parquet'] !== '') {
2167                $valF['date_transmission_parquet'] = $val['archive_date_transmission_parquet'];
2168            }
2169    
2170          // On met à jour le dossier          // On met à jour le dossier
2171          $cle = " dossier='".$val['dossier']."'";          $cle = " dossier='".$val['dossier']."'";
2172          $res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle);          $res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle);
# Line 2070  class instruction extends instruction_ge Line 2340  class instruction extends instruction_ge
2340              ." ".$admin_msg_error;              ." ".$admin_msg_error;
2341          $bdd_msg_error = _("Erreur de base de données.")          $bdd_msg_error = _("Erreur de base de données.")
2342              ." ".$admin_msg_error;              ." ".$admin_msg_error;
2343          $log_msg_error = "Finalisation non enregistrée          $log_msg_error = "Finalisation non enregistrée - id instruction = %s - uid fichier = %s";
             - id instruction = %s  
             - uid fichier = %s";  
2344    
2345          // Si on finalise le document          // Si on finalise le document
2346          if ($mode == "finalize"){          if ($mode == "finalize"){
# Line 2156  class instruction extends instruction_ge Line 2424  class instruction extends instruction_ge
2424          }          }
2425    
2426          //          //
2427          $val['date_evenement']=$this->dateDBToForm($val['date_evenement']);          $val['date_evenement'] = $this->dateDBToForm($val['date_evenement']);
2428          $val['archive_date_complet']=$this->dateDBToForm($val['archive_date_complet']);          $val['archive_date_complet'] = $this->dateDBToForm($val['archive_date_complet']);
2429          $val['archive_date_rejet']=$this->dateDBToForm($val['archive_date_rejet']);          $val['archive_date_rejet'] = $this->dateDBToForm($val['archive_date_rejet']);
2430          $val['archive_date_limite']=$this->dateDBToForm($val['archive_date_limite']);          $val['archive_date_limite'] = $this->dateDBToForm($val['archive_date_limite']);
2431          $val['archive_date_notification_delai']=$this->dateDBToForm($val['archive_date_notification_delai']);          $val['archive_date_notification_delai'] = $this->dateDBToForm($val['archive_date_notification_delai']);
2432          $val['archive_date_decision']=$this->dateDBToForm($val['archive_date_decision']);          $val['archive_date_decision'] = $this->dateDBToForm($val['archive_date_decision']);
2433          $val['archive_date_validite']=$this->dateDBToForm($val['archive_date_validite']);          $val['archive_date_validite'] = $this->dateDBToForm($val['archive_date_validite']);
2434          $val['archive_date_achevement']=$this->dateDBToForm($val['archive_date_achevement']);          $val['archive_date_achevement'] = $this->dateDBToForm($val['archive_date_achevement']);
2435          $val['archive_date_chantier']=$this->dateDBToForm($val['archive_date_chantier']);          $val['archive_date_chantier'] = $this->dateDBToForm($val['archive_date_chantier']);
2436          $val['archive_date_conformite']=$this->dateDBToForm($val['archive_date_conformite']);          $val['archive_date_conformite'] = $this->dateDBToForm($val['archive_date_conformite']);
2437          $val['archive_date_dernier_depot']=$this->dateDBToForm($val['archive_date_dernier_depot']);          $val['archive_date_dernier_depot'] = $this->dateDBToForm($val['archive_date_dernier_depot']);
2438          $val['archive_date_limite_incompletude']=$this->dateDBToForm($val['archive_date_limite_incompletude']);          $val['archive_date_limite_incompletude'] = $this->dateDBToForm($val['archive_date_limite_incompletude']);
2439          $val['date_finalisation_courrier']=$this->dateDBToForm($val['date_finalisation_courrier']);          $val['date_finalisation_courrier'] = $this->dateDBToForm($val['date_finalisation_courrier']);
2440          $val['date_envoi_signature']=$this->dateDBToForm($val['date_envoi_signature']);          $val['date_envoi_signature'] = $this->dateDBToForm($val['date_envoi_signature']);
2441          $val['date_retour_signature']=$this->dateDBToForm($val['date_retour_signature']);          $val['date_retour_signature'] = $this->dateDBToForm($val['date_retour_signature']);
2442          $val['date_envoi_rar']=$this->dateDBToForm($val['date_envoi_rar']);          $val['date_envoi_rar'] = $this->dateDBToForm($val['date_envoi_rar']);
2443          $val['date_retour_rar']=$this->dateDBToForm($val['date_retour_rar']);          $val['date_retour_rar'] = $this->dateDBToForm($val['date_retour_rar']);
2444          $val['date_envoi_controle_legalite']=$this->dateDBToForm($val['date_envoi_controle_legalite']);          $val['date_envoi_controle_legalite'] = $this->dateDBToForm($val['date_envoi_controle_legalite']);
2445          $val['date_retour_controle_legalite']=$this->dateDBToForm($val['date_retour_controle_legalite']);          $val['date_retour_controle_legalite'] = $this->dateDBToForm($val['date_retour_controle_legalite']);
2446            $val['archive_date_cloture_instruction'] = $this->dateDBToForm($val['archive_date_cloture_instruction']);
2447            $val['archive_date_premiere_visite'] = $this->dateDBToForm($val['archive_date_premiere_visite']);
2448            $val['archive_date_derniere_visite'] = $this->dateDBToForm($val['archive_date_derniere_visite']);
2449            $val['archive_date_contradictoire'] = $this->dateDBToForm($val['archive_date_contradictoire']);
2450            $val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']);
2451            $val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']);
2452            $val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']);
2453          $this->setvalF($val);          $this->setvalF($val);
2454    
2455          // Verification de la validite des donnees          // Verification de la validite des donnees
# Line 2350  class instruction extends instruction_ge Line 2625  class instruction extends instruction_ge
2625          return $evenement_libelle;          return $evenement_libelle;
2626      }      }
2627    
2628    
2629        /**
2630         * Récupération du champ ERP du dossier d'instruction.
2631         *
2632         * @return boolean
2633         */
2634        public function get_concerne_erp() {
2635            //
2636            if(empty($this->specificMetadata)) {
2637                $this->getSpecificMetadata();
2638            }
2639            //
2640            return $this->specificMetadata->erp;
2641        }
2642    
2643    
2644      /**      /**
2645       * Cette méthode permet de stocker en attribut toutes les métadonnées       * Cette méthode permet de stocker en attribut toutes les métadonnées
2646       * nécessaire à l'ajout d'un document.       * nécessaire à l'ajout d'un document.
# Line 2367  class instruction extends instruction_ge Line 2658  class instruction extends instruction_ge
2658                          dossier_instruction_type.code as dossier_instruction_type,                          dossier_instruction_type.code as dossier_instruction_type,
2659                          etat_dossier_autorisation.libelle as statut,                          etat_dossier_autorisation.libelle as statut,
2660                          dossier_autorisation_type.code as dossier_autorisation_type,                          dossier_autorisation_type.code as dossier_autorisation_type,
2661                          groupe.code as groupe_instruction                          groupe.code as groupe_instruction,
2662                            CASE WHEN dossier.erp IS TRUE
2663                                THEN 'true'
2664                                ELSE 'false'
2665                            END as erp
2666                  FROM ".DB_PREFIXE."dossier                  FROM ".DB_PREFIXE."dossier
2667                      LEFT JOIN ".DB_PREFIXE."dossier_instruction_type                        LEFT JOIN ".DB_PREFIXE."dossier_instruction_type  
2668                          ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type                          ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type
# Line 2457  class instruction extends instruction_ge Line 2752  class instruction extends instruction_ge
2752    
2753              // Récupération de la valeur actuelle du délai, de l'accord tacite,              // Récupération de la valeur actuelle du délai, de l'accord tacite,
2754              // de l'état et de l'avis du dossier d'instruction              // de l'état et de l'avis du dossier d'instruction
2755              $return['archive_delai']=$row['delai'];              $return['archive_delai'] = $row['delai'];
2756              $return['archive_accord_tacite']=$row['accord_tacite'];              $return['archive_accord_tacite'] = $row['accord_tacite'];
2757              $return['archive_etat']=$row['etat'];              $return['archive_etat'] = $row['etat'];
2758              $return['archive_avis']=$row['avis_decision'];              $return['archive_avis'] = $row['avis_decision'];
2759              // Récupération de la valeur actuelle des 9 dates du dossier              // Récupération de la valeur actuelle des dates du dossier
2760              // d'instruction              // d'instruction
2761              $return['archive_date_complet']=$row['date_complet'];              $return['archive_date_complet'] = $row['date_complet'];
2762              $return['archive_date_dernier_depot']=$row['date_dernier_depot'];              $return['archive_date_dernier_depot'] = $row['date_dernier_depot'];
2763              $return['archive_date_rejet']= $row['date_rejet'];              $return['archive_date_rejet'] = $row['date_rejet'];
2764              $return['archive_date_limite']= $row['date_limite'];              $return['archive_date_limite'] = $row['date_limite'];
2765              $return['archive_date_notification_delai']= $row['date_notification_delai'];              $return['archive_date_notification_delai'] = $row['date_notification_delai'];
2766              $return['archive_date_decision']= $row['date_decision'];              $return['archive_date_decision'] = $row['date_decision'];
2767              $return['archive_date_validite']= $row['date_validite'];              $return['archive_date_validite'] = $row['date_validite'];
2768              $return['archive_date_achevement']= $row['date_achevement'];              $return['archive_date_achevement'] = $row['date_achevement'];
2769              $return['archive_date_chantier']= $row['date_chantier'];              $return['archive_date_chantier'] = $row['date_chantier'];
2770              $return['archive_date_conformite']= $row['date_conformite'];              $return['archive_date_conformite'] = $row['date_conformite'];
2771              $return['archive_incompletude']= $row['incompletude'];              $return['archive_incompletude'] = $row['incompletude'];
2772              $return['archive_incomplet_notifie']= $row['incomplet_notifie'];              $return['archive_incomplet_notifie'] = $row['incomplet_notifie'];
2773              $return['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite'];              $return['archive_evenement_suivant_tacite'] = $row['evenement_suivant_tacite'];
2774              $return['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude'];              $return['archive_evenement_suivant_tacite_incompletude'] = $row['evenement_suivant_tacite_incompletude'];
2775              $return['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude'];              $return['archive_etat_pendant_incompletude'] = $row['etat_pendant_incompletude'];
2776              $return['archive_date_limite_incompletude']= $row['date_limite_incompletude'];              $return['archive_date_limite_incompletude'] = $row['date_limite_incompletude'];
2777              $return['archive_delai_incompletude']= $row['delai_incompletude'];              $return['archive_delai_incompletude'] = $row['delai_incompletude'];
2778              $return['archive_autorite_competente']= $row['autorite_competente'];              $return['archive_autorite_competente'] = $row['autorite_competente'];
2779              $return['duree_validite']= $row['duree_validite'];              $return['duree_validite'] = $row['duree_validite'];
2780              $return['date_depot']= $row['date_depot'];              $return['date_depot'] = $row['date_depot'];
2781                $return['archive_date_cloture_instruction'] = $row['date_cloture_instruction'];
2782                $return['archive_date_premiere_visite'] = $row['date_premiere_visite'];
2783                $return['archive_date_derniere_visite'] = $row['date_derniere_visite'];
2784                $return['archive_date_contradictoire'] = $row['date_contradictoire'];
2785                $return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire'];
2786                $return['archive_date_ait'] = $row['date_ait'];
2787                $return['archive_date_transmission_parquet'] = $row['date_transmission_parquet'];
2788          }          }
2789    
2790          // Retour de la fonction          // Retour de la fonction
# Line 2544  class instruction extends instruction_ge Line 2846  class instruction extends instruction_ge
2846          if ($row['date_dernier_depot'] != '') {          if ($row['date_dernier_depot'] != '') {
2847              $this->valF['archive_date_dernier_depot']=$row['date_dernier_depot'];              $this->valF['archive_date_dernier_depot']=$row['date_dernier_depot'];
2848          }          }
2849          if ($row['date_rejet']!='') {          if ($row['date_rejet'] != '') {
2850              $this->valF['archive_date_rejet']= $row['date_rejet'];              $this->valF['archive_date_rejet']= $row['date_rejet'];
2851          }          }
2852          if ($row['date_limite']!='') {          if ($row['date_limite'] != '') {
2853              $this->valF['archive_date_limite']= $row['date_limite'];              $this->valF['archive_date_limite']= $row['date_limite'];
2854          }          }
2855          if ($row['date_notification_delai']!='') {          if ($row['date_notification_delai'] != '') {
2856              $this->valF['archive_date_notification_delai']= $row['date_notification_delai'];              $this->valF['archive_date_notification_delai']= $row['date_notification_delai'];
2857          }          }
2858          if ($row['date_decision']!='') {          if ($row['date_decision'] != '') {
2859              $this->valF['archive_date_decision']= $row['date_decision'];              $this->valF['archive_date_decision']= $row['date_decision'];
2860          }          }
2861          if ($row['date_validite']!='') {          if ($row['date_validite'] != '') {
2862              $this->valF['archive_date_validite']= $row['date_validite'];              $this->valF['archive_date_validite']= $row['date_validite'];
2863          }          }
2864          if ($row['date_achevement']!='') {          if ($row['date_achevement'] != '') {
2865              $this->valF['archive_date_achevement']= $row['date_achevement'];              $this->valF['archive_date_achevement']= $row['date_achevement'];
2866          }          }
2867          if ($row['date_chantier']!='') {          if ($row['date_chantier'] != '') {
2868              $this->valF['archive_date_chantier']= $row['date_chantier'];              $this->valF['archive_date_chantier']= $row['date_chantier'];
2869          }          }
2870          if ($row['date_conformite']!='') {          if ($row['date_conformite'] != '') {
2871              $this->valF['archive_date_conformite']= $row['date_conformite'];                $this->valF['archive_date_conformite']= $row['date_conformite'];  
2872          }          }
2873          if ($row['incompletude']!='') {          if ($row['incompletude'] != '') {
2874              $this->valF['archive_incompletude']= $row['incompletude'];                $this->valF['archive_incompletude']= $row['incompletude'];  
2875          }          }
2876          if ($row['incomplet_notifie']!='') {          if ($row['incomplet_notifie'] != '') {
2877              $this->valF['archive_incomplet_notifie']= $row['incomplet_notifie'];                $this->valF['archive_incomplet_notifie']= $row['incomplet_notifie'];  
2878          }          }
2879          if ($row['evenement_suivant_tacite']!='') {          if ($row['evenement_suivant_tacite'] != '') {
2880              $this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite'];                $this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite'];  
2881          }          }
2882          if ($row['evenement_suivant_tacite_incompletude']!='') {          if ($row['evenement_suivant_tacite_incompletude'] != '') {
2883              $this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude'];                $this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude'];  
2884          }          }
2885          if ($row['etat_pendant_incompletude']!='') {          if ($row['etat_pendant_incompletude'] != '') {
2886              $this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude'];                $this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude'];  
2887          }          }
2888          if ($row['date_limite_incompletude']!='') {          if ($row['date_limite_incompletude'] != '') {
2889              $this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude'];                $this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude'];  
2890          }          }
2891          if ($row['delai_incompletude']!='') {          if ($row['delai_incompletude'] != '') {
2892              $this->valF['archive_delai_incompletude']= $row['delai_incompletude'];                $this->valF['archive_delai_incompletude']= $row['delai_incompletude'];  
2893          }          }
2894          if ($row['autorite_competente']!='') {          if ($row['autorite_competente'] != '') {
2895              $this->valF['archive_autorite_competente']= $row['autorite_competente'];                $this->valF['archive_autorite_competente']= $row['autorite_competente'];  
2896          }          }
2897          if ($row['duree_validite']!='') {          if ($row['duree_validite'] != '') {
2898              $this->valF['duree_validite']= $row['duree_validite'];                $this->valF['duree_validite']= $row['duree_validite'];  
2899          }          }
2900          if ($row['date_depot']!='') {          if ($row['date_depot'] != '') {
2901              $this->valF['date_depot']= $row['date_depot'];                $this->valF['date_depot']= $row['date_depot'];  
2902          }          }
2903            // Dates concernant les dossiers contentieux
2904            if ($row['date_cloture_instruction'] != '') {
2905                $this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction'];  
2906            }
2907            if ($row['date_premiere_visite'] != '') {
2908                $this->valF['archive_date_premiere_visite']= $row['date_premiere_visite'];  
2909            }
2910            if ($row['date_derniere_visite'] != '') {
2911                $this->valF['archive_date_derniere_visite']= $row['date_derniere_visite'];  
2912            }
2913            if ($row['date_contradictoire'] != '') {
2914                $this->valF['archive_date_contradictoire']= $row['date_contradictoire'];  
2915            }
2916            if ($row['date_retour_contradictoire'] != '') {
2917                $this->valF['archive_date_retour_contradictoire']= $row['date_retour_contradictoire'];  
2918            }
2919            if ($row['date_ait'] != '') {
2920                $this->valF['archive_date_ait']= $row['date_ait'];  
2921            }
2922            if ($row['date_transmission_parquet'] != '') {
2923                $this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet'];  
2924            }
2925      }      }
2926    
2927      // {{{      // {{{
# Line 2785  class instruction extends instruction_ge Line 3109  class instruction extends instruction_ge
3109       */       */
3110      function is_editable() {      function is_editable() {
3111          // Contrôle si l'utilisateur possède un bypass          // Contrôle si l'utilisateur possède un bypass
3112          $bypass = $this->f->isAccredited(get_class()."_modifier_bypass");          $bypass = $this->f->isAccredited(get_class($this)."_modifier_bypass");
3113          //          //
3114          if ($bypass == true) {          if ($bypass == true) {
   
3115              //              //
3116              return true;              return true;
3117          }          }
3118            
         // Si l'utilisateur est un intructeur qui ne correspond pas à la  
         // division du dossier  
         if ($this->f->isUserInstructeur()  
             && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()  
             && $this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === false) {  
   
             //  
             return false;  
         }  
   
         // si instructeur commune  
         if($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === true  
             && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()  
             && ($this->f->isInstrCanChangeDecision($this->getVal('dossier')) !== true  
             || $this->getVal('created_by_commune') !== 't')) {  
             return false;  
         }  
3119          // Si l'utilisateur est un instructeur, que le dossier est cloturé et          // Si l'utilisateur est un instructeur, que le dossier est cloturé et
3120          // que l'événement n'est pas identifié comme non verrouillable          // que l'événement n'est pas identifié comme non verrouillable
3121          if ($this->f->isUserInstructeur()          if ($this->f->isUserInstructeur()
3122              && $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture"              && $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture"
3123              && $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) {              && $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) {
   
3124              //              //
3125              return false;              return false;
3126          }          }
3127    
3128            // Si l'utilisateur est un intructeur qui correspond à la division du
3129            // dossier
3130            if ($this->is_instructeur_from_division_dossier() === true) {
3131                //
3132                return true;
3133            }
3134    
3135            // Si l'utilisateur est instructeur de la commune du dossier et que la
3136            // décision peut être changée par la commune.
3137            if ($this->is_instructeur_from_collectivite_dossier() === true and
3138                $this->isInstrCanChangeDecision($this->getVal('dossier')) === true) {
3139                return true;
3140            }
3141    
3142            // Si l'utilisateur est instructeur de la commune du dossier et que
3143            // l'instruction est créée par un instructeur de la commune
3144            if ($this->is_instructeur_from_collectivite_dossier() === true and
3145                $this->getVal('created_by_commune') === 't') {
3146                return true;
3147            }
3148    
3149          //          //
3150          return true;          return false;
3151      }      }
3152    
3153      /**      /**
# Line 2833  class instruction extends instruction_ge Line 3159  class instruction extends instruction_ge
3159       */       */
3160      function is_deletable() {      function is_deletable() {
3161          // Contrôle si l'utilisateur possède un bypass          // Contrôle si l'utilisateur possède un bypass
3162          $bypass = $this->f->isAccredited(get_class()."_supprimer_bypass");          $bypass = $this->f->isAccredited(get_class($this)."_supprimer_bypass");
3163          //          //
3164          if ($bypass == true) {          if ($bypass == true) {
3165    
# Line 2843  class instruction extends instruction_ge Line 3169  class instruction extends instruction_ge
3169    
3170          // Si l'utilisateur est un intructeur qui ne correspond pas à la          // Si l'utilisateur est un intructeur qui ne correspond pas à la
3171          // division du dossier          // division du dossier
3172          if ($this->f->isUserInstructeur()          if ($this->is_instructeur_from_division_dossier() !== true) {
             && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) {  
3173    
3174              //              //
3175              return false;              return false;
# Line 2880  class instruction extends instruction_ge Line 3205  class instruction extends instruction_ge
3205          //          //
3206          return true;          return true;
3207      }      }
3208        
3209        
3210        /**
3211         * Vérifie que l'utilisateur est instructeur et qu'il est de la division du
3212         * dossier.
3213         *
3214         * @return,  boolean true/false
3215         */
3216        function is_instructeur_from_collectivite_dossier() {
3217            if ($this->f->isUserInstructeur() === true and
3218                $this->f->om_utilisateur["om_collectivite"] == $this->get_dossier_instruction_om_collectivite()) {
3219                return true;
3220            }
3221            return false;
3222        }
3223        
3224      /**      /**
3225       * CONDITION - is_addable.       * CONDITION - is_addable.
3226       *       *
# Line 2890  class instruction extends instruction_ge Line 3230  class instruction extends instruction_ge
3230       */       */
3231      function is_addable() {      function is_addable() {
3232          // Contrôle si l'utilisateur possède un bypass          // Contrôle si l'utilisateur possède un bypass
3233          $bypass = $this->f->isAccredited(get_class()."_ajouter_bypass");          $bypass = $this->f->isAccredited(get_class($this)."_ajouter_bypass");
3234          //          //
3235          if ($bypass == true) {          if ($bypass == true) {
3236    
3237              //              //
3238              return true;              return true;
3239          }          }
3240            // Si l'utilisateur est un intructeur qui correspond à la
3241          // Si l'utilisateur est un intructeur qui ne correspond pas à la          // division du dossier ou qu'il peut changer la décision
3242          // division du dossier          if ($this->is_instructeur_from_division_dossier() === true or
3243          if ($this->f->isUserInstructeur()              $this->isInstrCanChangeDecision($this->getParameter('idxformulaire')) === true) {
             && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()  
             && $this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === false) {  
   
3244              //              //
3245              return false;              return true;
         }  
   
         // si instructeur commune  
         if($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === false  
             && $this->f->isInstrCanChangeDecision($this->getVal('dossier')) === true) {  
             return false;  
3246          }          }
3247    
   
3248          //          //
3249          return true;          return false;
3250      }      }
3251    
3252      /**      /**
# Line 2928  class instruction extends instruction_ge Line 3258  class instruction extends instruction_ge
3258       */       */
3259      function is_finalizable() {      function is_finalizable() {
3260          // Contrôle si l'utilisateur possède un bypass          // Contrôle si l'utilisateur possède un bypass
3261          $bypass = $this->f->isAccredited(get_class()."_finaliser_bypass");          $bypass = $this->f->isAccredited(get_class($this)."_finaliser_bypass");
3262          //          //
3263          if ($bypass == true) {          if ($bypass == true) {
   
3264              //              //
3265              return true;              return true;
3266          }          }
3267            
         // Si l'utilisateur est un intructeur qui ne correspond pas à la  
         // division du dossier  
         if ($this->f->isUserInstructeur()  
             && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()  
             && $this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === false) {  
   
             //  
             return false;  
         }  
   
         // si instructeur commune  
         if($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === true  
             && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()  
             && ($this->f->isInstrCanChangeDecision($this->getVal('dossier')) !== true  
             || $this->getVal('created_by_commune') !== 't')) {  
             return false;  
         }  
   
3268          // Si l'utilisateur est un instructeur, que le dossier est cloturé et          // Si l'utilisateur est un instructeur, que le dossier est cloturé et
3269          // que l'événement n'est pas identifié comme non verrouillable          // que l'événement n'est pas identifié comme non verrouillable
3270          if ($this->f->isUserInstructeur()          if ($this->f->isUserInstructeur()
3271              && $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture"              && $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture"
3272              && $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) {              && $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) {
   
3273              //              //
3274              return false;              return false;
3275          }          }
3276            
3277            // Si l'utilisateur est un intructeur qui correspond à la division du
3278            // dossier
3279            if ($this->is_instructeur_from_division_dossier() === true) {
3280                //
3281                return true;
3282            }
3283    
3284            // Si l'utilisateur est instructeur de la commune du dossier et que la
3285            // décision peut être changée par la commune.
3286            if ($this->is_instructeur_from_collectivite_dossier() === true and
3287                $this->isInstrCanChangeDecision($this->getVal('dossier')) === true) {
3288                return true;
3289            }
3290    
3291            // Si l'utilisateur est instructeur de la commune du dossier et que
3292            // l'instruction est créée par un instructeur de la commune
3293            if ($this->is_instructeur_from_collectivite_dossier() === true and
3294                $this->getVal('created_by_commune') === 't') {
3295                return true;
3296            }
3297    
3298          //          //
3299          return true;          return false;
3300      }      }
3301    
3302      /**      /**
# Line 2999  class instruction extends instruction_ge Line 3330  class instruction extends instruction_ge
3330       */       */
3331      function is_unfinalizable(){      function is_unfinalizable(){
3332          // Contrôle si l'utilisateur possède un bypass          // Contrôle si l'utilisateur possède un bypass
3333          $bypass = $this->f->isAccredited(get_class()."_definaliser_bypass");          $bypass = $this->f->isAccredited(get_class($this)."_definaliser_bypass");
3334          //          //
3335          if ($bypass == true) {          if ($bypass == true) {
   
3336              //              //
3337              return true;              return true;
3338          }          }
3339            
3340          // Si l'utilisateur est un intructeur qui ne correspond pas à la          // Si l'utilisateur est un instructeur, que le dossier est cloturé et
3341          // division du dossier          // que l'événement n'est pas identifié comme non verrouillable
3342          if ($this->f->isUserInstructeur()          if ($this->f->isUserInstructeur()
3343              && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()              && $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture"
3344              && $this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === false) {              && $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) {
   
3345              //              //
3346              return false;              return false;
3347          }          }
3348    
3349          // si instructeur commune          // Si l'utilisateur est un intructeur qui correspond à la division du
3350          if($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") === true          // dossier
3351              && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()          if ($this->is_instructeur_from_division_dossier() === true) {
3352              && ($this->f->isInstrCanChangeDecision($this->getVal('dossier')) !== true              //
3353              || $this->getVal('created_by_commune') !== 't')) {              return true;
             return false;  
3354          }          }
3355    
3356          // Si l'utilisateur est un instructeur, que le dossier est cloturé et          // Si l'utilisateur est instructeur de la commune du dossier et que la
3357          // que l'événement n'est pas identifié comme non verrouillable          // décision peut être changée par la commune.
3358          if ($this->f->isUserInstructeur()          if ($this->is_instructeur_from_collectivite_dossier() === true and
3359              && $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture"              $this->isInstrCanChangeDecision($this->getVal('dossier')) === true) {
3360              && $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) {              return true;
3361            }
3362    
3363              //          // Si l'utilisateur est instructeur de la commune du dossier et que
3364              return false;          // l'instruction est créée par un instructeur de la commune
3365            if ($this->is_instructeur_from_collectivite_dossier() === true and
3366                $this->getVal('created_by_commune') === 't') {
3367                return true;
3368          }          }
3369    
3370          //          //
3371          return true;          return false;
3372      }      }
3373    
3374      /**      /**
# Line 3060  class instruction extends instruction_ge Line 3392  class instruction extends instruction_ge
3392          return false;          return false;
3393      }      }
3394    
3395    
3396        /**
3397         * Permet de définir si un instructeur commune peut editer une instruction
3398         *
3399         * @return boolean true si il peut
3400         */
3401        function isInstrCanChangeDecision($idx) {
3402            
3403            if ($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") !== true or
3404                $this->f->isUserInstructeur() !== true) {
3405                return false;
3406            }
3407            
3408            
3409    
3410            // Sinon on vérifie l'éligibilité du dossier au changement de décision
3411            $sql =
3412                "SELECT
3413                    dossier.dossier
3414                FROM
3415                    ".DB_PREFIXE."dossier
3416                JOIN ".DB_PREFIXE."instruction ON instruction.instruction = (
3417                    SELECT instruction
3418                    FROM ".DB_PREFIXE."instruction
3419                    JOIN ".DB_PREFIXE."evenement on instruction.evenement=evenement.evenement
3420                    WHERE instruction.dossier = dossier.dossier
3421                    AND evenement.retour IS FALSE
3422                    ORDER BY date_evenement DESC, instruction DESC
3423                    LIMIT 1
3424                )
3425                JOIN ".DB_PREFIXE."evenement ON instruction.evenement=evenement.evenement
3426                JOIN ".DB_PREFIXE."instructeur ON dossier.instructeur=instructeur.instructeur
3427                JOIN ".DB_PREFIXE."om_utilisateur ON instructeur.om_utilisateur=om_utilisateur.om_utilisateur
3428                JOIN ".DB_PREFIXE."om_collectivite ON om_collectivite.om_collectivite=om_utilisateur.om_collectivite
3429                JOIN ".DB_PREFIXE."etat ON dossier.etat = etat.etat
3430                WHERE
3431                    
3432                        (
3433                            evenement.type = 'arrete' AND
3434                            (
3435                                instruction.om_final_instruction IS TRUE
3436                                OR instruction.created_by_commune IS TRUE
3437                            ) OR
3438                            evenement.type = 'changement_decision'
3439                        )
3440                    AND evenement.retour IS FALSE
3441                    AND instruction.date_retour_signature IS NULL
3442                    AND instruction.date_envoi_rar IS NULL
3443                    AND instruction.date_retour_rar IS NULL
3444                    AND instruction.date_envoi_controle_legalite IS NULL
3445                    AND instruction.date_retour_controle_legalite IS NULL
3446                    AND etat.statut = 'encours'
3447                    AND dossier.dossier = '".$idx."'
3448                    AND om_collectivite.niveau = '2'
3449                ";
3450    
3451    
3452            // Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci
3453            if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) {
3454                $sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite'];
3455            }
3456            $res = $this->db->getone($sql);
3457            if (database::isError($res)) {
3458                die();
3459            }
3460            // Si le dossier n'est pas sujet au changement de decision
3461            if($res == null) {
3462                return false;
3463            }
3464            return true;
3465        }
3466    
3467    
3468        /**
3469         * CONDITION - can_monitoring_dates.
3470         *
3471         * Condition pour afficher le bouton de suivi des dates.
3472         *
3473         * @return boolean
3474         */
3475        public function can_monitoring_dates() {
3476            // Récupère la valeur du champ finalisé
3477            $om_final_instruction = $this->getVal('om_final_instruction');
3478    
3479            // Si l'instruction n'est pas finalisée
3480            if ($om_final_instruction !== 't') {
3481                //
3482                return false;
3483            }
3484    
3485            // Contrôle si l'utilisateur possède un bypass
3486            $bypass = $this->f->isAccredited(get_class($this)."_modification_dates_bypass");
3487            if ($bypass === true) {
3488                return true;
3489            }
3490    
3491            // On vérifie en premier lieu que le DI n'est pas clôturé
3492            $inst_dossier = $this->get_inst_dossier();
3493            if ($inst_dossier->getStatut() === 'cloture') {
3494                //
3495                return false;
3496            }
3497            // On récupère ses infos
3498            $coll_di = $inst_dossier->getVal('om_collectivite');
3499            $div_di = $this->getDivisionFromDossier();
3500            // et celles de son éventuel instructeur
3501            $instr_di = $inst_dossier->getVal('instructeur');
3502    
3503            // Il faut disposer d'une entrée instructeur
3504            if ($this->f->isUserInstructeur() === false) {
3505                return false;
3506            }
3507    
3508            // Par défaut on prétend que l'instructeur n'est pas multi
3509            $instr_di_coll_multi = false;
3510            // Si un instructeur est affecté au dossier
3511            if ($instr_di !== '' && $instr_di !== null) {
3512                // Vérifie si l'instructeur est de la collectivité de niveau 2
3513                $instr_di_coll = $this->get_instructeur_om_collectivite($instr_di);
3514                if ($this->f->isCollectiviteMono($instr_di_coll) === false) {
3515                    //
3516                    $instr_di_coll_multi = true;
3517                }
3518            }
3519    
3520            // Il faut qu'il instruise le dossier ou soit de la même division
3521            if ($this->f->om_utilisateur['instructeur'] === $instr_di
3522                    || $this->f->om_utilisateur['division'] === $div_di) {
3523                //
3524                return true;
3525            }
3526    
3527            // On donne également le droit s'il est de la même collectivité que
3528            // le dossier ET si l'instruction est déléguée à la communauté
3529            if ($this->f->isCollectiviteMono($this->f->om_utilisateur['om_collectivite']) === true
3530                && $this->f->om_utilisateur['om_collectivite'] === $coll_di
3531                && $instr_di_coll_multi === true) {
3532                //
3533                return true;
3534            }
3535    
3536            // Si l'instructeur ne rentre pas dans les deux cas précédents
3537            return false;
3538        }
3539    
3540    
3541      /**      /**
3542       * TREATMENT - finalize.       * TREATMENT - finalize.
3543       *       *
# Line 3218  class instruction extends instruction_ge Line 3696  class instruction extends instruction_ge
3696          $evenement = intval($evenement);          $evenement = intval($evenement);
3697          //          //
3698          ($f->get_submitted_get_value("idx") ? $idx = $f->get_submitted_get_value("idx") : $idx = "");          ($f->get_submitted_get_value("idx") ? $idx = $f->get_submitted_get_value("idx") : $idx = "");
3699          $nature = substr($idx, 0, 2);          // Récupération du code du type de DA
3700            $code_da_type = '';
3701            if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) {
3702                $code_da_type = $matches[0];
3703            }
3704          //          //
3705          ($f->get_submitted_get_value("complement") ? $complement = $f->get_submitted_get_value("complement") : $complement = "1");          ($f->get_submitted_get_value("complement") ? $complement = $f->get_submitted_get_value("complement") : $complement = "1");
3706    
# Line 3239  class instruction extends instruction_ge Line 3721  class instruction extends instruction_ge
3721          WHERE evenement=".$evenement."          WHERE evenement=".$evenement."
3722              AND complement=".$complement."              AND complement=".$complement."
3723              AND (bible.dossier_autorisation_type IS NULL              AND (bible.dossier_autorisation_type IS NULL
3724                  OR dossier_autorisation_type.code ='".$nature."')                  OR dossier_autorisation_type.code ='".$code_da_type."')
3725              AND (om_collectivite.niveau = '2'              AND (om_collectivite.niveau = '2'
3726                  OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")                  OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")
3727          ORDER BY bible_lib ASC";          ORDER BY bible_lib ASC";
# Line 3305  class instruction extends instruction_ge Line 3787  class instruction extends instruction_ge
3787      }      }
3788    
3789      /**      /**
3790       * VIEW - view_bible       * VIEW - view_bible_auto
3791       *       *
3792       * Affiche la bible manuelle.       * Renvoie les valeurs de la bible à placer dans les compléments de l'instruction.
3793       *       *
3794       * @return void       * @return void
3795       */       */
# Line 3405  class instruction extends instruction_ge Line 3887  class instruction extends instruction_ge
3887          // Récupération de la collectivité du dossier          // Récupération de la collectivité du dossier
3888          require_once "../obj/dossier.class.php";          require_once "../obj/dossier.class.php";
3889          $dossier = new dossier($idx, $f->db, DEBUG);          $dossier = new dossier($idx, $f->db, DEBUG);
3890            // Récupération du code du type de DA
3891            $code_da_type = '';
3892            if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) {
3893                $code_da_type = $matches[0];
3894            }
3895          //          //
3896          $sql = "SELECT * FROM ".DB_PREFIXE."bible          $sql = "SELECT * FROM ".DB_PREFIXE."bible
3897              LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type              LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type
# Line 3416  class instruction extends instruction_ge Line 3903  class instruction extends instruction_ge
3903              WHERE evenement =".$event." and              WHERE evenement =".$event." and
3904                  complement=".$compnb." and                  complement=".$compnb." and
3905                  automatique='Oui' and                  automatique='Oui' and
3906                  (dossier_autorisation_type.code ='".substr($idx, 0, 2)."' or                  (dossier_autorisation_type.code ='".$code_da_type."' or
3907                      bible.dossier_autorisation_type IS NULL) and                      bible.dossier_autorisation_type IS NULL) and
3908                  (om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")";                  (om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")";
3909    
# Line 3678  class instruction extends instruction_ge Line 4165  class instruction extends instruction_ge
4165          //          //
4166          $error = "";          $error = "";
4167    
4168            // Initialisation du tableau qui va contenir les DI pour lister les liens
4169            $dossierTab = array();
4170            // On vérifie que l'utilisateur ait les droits pour afficher des consultations
4171            $isAccredited = $this->f->isAccredited(array("dossier_instruction","dossier_instruction_consulter"), "OR");
4172            $hasHidden = true;
4173            // S'il ne peut pas les consulter il aura des dossiers caché
4174            if ($isAccredited === true) {
4175                $hasHidden = false;
4176            }
4177    
4178          /**          /**
4179           * Validation du formulaire           * Validation du formulaire
4180           */           */
# Line 3700  class instruction extends instruction_ge Line 4197  class instruction extends instruction_ge
4197                          // Si la valeur transmise est numérique                          // Si la valeur transmise est numérique
4198                          if (is_numeric($code_barres)) {                          if (is_numeric($code_barres)) {
4199                              //                              //
4200                              $sql = "SELECT count(*) FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'";                              $sql = "SELECT count(*)
4201                                        FROM ".DB_PREFIXE."instruction
4202                                            INNER JOIN ".DB_PREFIXE."dossier
4203                                                ON dossier.dossier=instruction.dossier
4204                                            INNER JOIN ".DB_PREFIXE."dossier_instruction_type
4205                                                ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type
4206                                            INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille
4207                                                ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
4208                                            INNER JOIN ".DB_PREFIXE."dossier_autorisation_type
4209                                                ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type
4210                                            INNER JOIN ".DB_PREFIXE."groupe
4211                                                ON dossier_autorisation_type.groupe = groupe.groupe
4212                                                    AND groupe.code != 'CTX'
4213                                            WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'";
4214                              $nbInstr = $f->db->getone($sql);                              $nbInstr = $f->db->getone($sql);
4215                              $f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE);                              $f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE);
4216                              $f->isDatabaseError($nbInstr);                              $f->isDatabaseError($nbInstr);
# Line 3717  class instruction extends instruction_ge Line 4227  class instruction extends instruction_ge
4227                                  if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) {                                  if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) {
4228                                                                            
4229                                      require_once '../obj/instruction.class.php';                                      require_once '../obj/instruction.class.php';
4230                                        require_once '../obj/dossier.class.php';
4231                                                    
4232                                      $instr = new instruction($row['instruction'], $f->db, DEBUG);                                      $instr = new instruction($row['instruction'], $f->db, DEBUG);
4233                                      $valF = array();                                      $valF = array();
4234                                      foreach($instr->champs as $id => $champ) {                                      foreach($instr->champs as $id => $champ) {
4235                                          $valF[$champ] = $instr->val[$id];                                          $valF[$champ] = $instr->val[$id];
4236                                      }                                      }
4237    
4238                                        # Si on peut consulter les dossiers et que le dossier n'existe pas déjà dans la liste
4239                                        if ($isAccredited === true
4240                                            && array_key_exists($instr->getVal("dossier"), $dossierTab) === false) {
4241                                            $dossier = new dossier($instr->getVal("dossier"));
4242                                            if ($dossier->is_user_from_allowed_collectivite()){
4243                                                $dossierTab[$instr->getVal("dossier")] = $dossier;
4244                                            } else {
4245                                                $hasHidden = true;
4246                                            }
4247                                        }
4248    
4249                                      $valF['date_evenement']=                                      $valF['date_evenement']=
4250                                          $instr->dateDBToForm($valF['date_evenement']);                                          $instr->dateDBToForm($valF['date_evenement']);
4251                                      $valF['archive_date_complet']=                                      $valF['archive_date_complet']=
# Line 3761  class instruction extends instruction_ge Line 4284  class instruction extends instruction_ge
4284                                          $instr->dateDBToForm($valF['date_envoi_controle_legalite']);                                          $instr->dateDBToForm($valF['date_envoi_controle_legalite']);
4285                                      $valF['date_retour_controle_legalite']=                                      $valF['date_retour_controle_legalite']=
4286                                          $instr->dateDBToForm($valF['date_retour_controle_legalite']);                                          $instr->dateDBToForm($valF['date_retour_controle_legalite']);
   
4287                                      $valF['date_envoi_rar'] = $date;                                      $valF['date_envoi_rar'] = $date;
4288    
4289                                      // Vérification de la finalisation du document                                      // Vérification de la finalisation du document
# Line 3834  class instruction extends instruction_ge Line 4356  class instruction extends instruction_ge
4356          // Affichage du message de validation de la saisie          // Affichage du message de validation de la saisie
4357          if ($nbLettres > 0) {          if ($nbLettres > 0) {
4358              //              //
4359              $message_class = "valid";              echo "\n<div class=\"message ui-widget ui-corner-all ui-state-highlight ui-state-valid\" >";
4360              $message = _("Cliquez sur le lien ci-dessous pour telecharger votre document");              echo "\n<p>";
4361              $message .= " : <br/><br/>";              echo "\n<span class=\"ui-icon ui-icon-info\"></span>";
4362              $message .= "<a class='om-prev-icon pdf-16'";              echo "\n<span class=\"text\">";
4363              $message .= " title=\""._("imprimer les RAR")."\"";              echo _("Cliquez sur le lien ci-dessous pour telecharger votre document");
4364              $message .= " href=\"../scr/form.php?obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\"";              echo " : \n<br/><br/>";
4365              $message .= " target='_blank'>";              echo "\n<a class='om-prev-icon pdf-16'";
4366              $message .= _("Telecharger le document pour")." ".$nbLettres." "._("RAR");              echo "\n title=\""._("imprimer les RAR")."\"";
4367              $message .= "</a>";              echo "\n href=\"../scr/form.php?obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\"";
4368              $f->displayMessage($message_class, $message);              echo "\n target='_blank'>";
4369                echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR");
4370                echo "\n</a>";
4371                echo "\n</span>";
4372                echo "\n</p>";
4373                echo "\n<br/>\n";
4374                if ($isAccredited === true) {
4375                    echo '<fieldset id="fieldset-form-rar-lien_di" class="cadre ui-corner-all startClosed" style="background-color: inherite;">';
4376                    echo "\n<legend class=\"ui-corner-all ui-widget-content ui-state-active\" style=\"background-color: transparent; color: inherit;\">\n";
4377                    echo _('Dossiers concernés par ce traitement');
4378                    echo "\n</legend>";
4379                    echo "\n<div class=\"fieldsetContent\" style=\"display: none;background-color: inherite\">";
4380                    
4381                    if ($hasHidden === true) {
4382                        echo "\n<br/>";
4383                        echo "\n<p>";
4384                        echo "\n<span class='text'>";
4385                        echo _("Certains dossiers ont été omis de la liste ci-dessous car vous ne possédez pas les permissions nécessaires pour y accéder.");
4386                        echo "</span>";
4387                        echo "\n</p>";
4388                        echo "\n<br/>";
4389                    }
4390                    foreach ($dossierTab as $dossier) {
4391                        echo "\n<div class=\"bloc group\">";
4392                        echo "\n<div class=\"field field-type-text\">";
4393    
4394                        echo "\n<p>";
4395                        echo "\n<span class='text'>";
4396                        echo "\n<a class=\"om-icon om-icon-16 consult-16\" title=\"" . _('Consulter') . "\"";
4397                        echo "\n href=\"../scr/form.php?obj=dossier_instruction&action=3&idx=";
4398                        echo $dossier->getVal("dossier");
4399                        echo "\">";
4400                        echo "\n</a>";
4401    
4402                        echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\"";
4403                        echo " href=\"../scr/form.php?obj=dossier_instruction&action=3&idx=";
4404                        echo $dossier->getVal("dossier");
4405                        echo "\">";
4406                        echo $dossier->getVal("dossier_libelle");
4407                        echo "\n</a>";
4408                        echo "\n</span>";
4409                        echo "\n</p>";
4410    
4411                        echo "\n</div>";
4412                        echo "\n</div>";
4413                    }
4414                    echo "\n</div>";
4415                    echo "\n</fieldset>";
4416                }
4417                echo "\n</div>";
4418                echo "\n</div>";
4419          }          }
4420          // Inclusion de la classe de gestion des formulaires          // Inclusion de la classe de gestion des formulaires
4421          require_once "../obj/om_formulaire.class.php";          require_once "../obj/om_formulaire.class.php";
# Line 3930  class instruction extends instruction_ge Line 4502  class instruction extends instruction_ge
4502          if ($f->get_submitted_post_value('validation') !== null) {          if ($f->get_submitted_post_value('validation') !== null) {
4503              if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) {              if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) {
4504    
4505                  //Vérification de l'existance de l'instruction                  // Vérification de l'existence de l'instruction
4506                  $sql = "SELECT instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'";                  $sql = "SELECT instruction
4507                            FROM ".DB_PREFIXE."instruction
4508                                INNER JOIN ".DB_PREFIXE."dossier
4509                                    ON dossier.dossier=instruction.dossier
4510                                INNER JOIN ".DB_PREFIXE."dossier_instruction_type
4511                                    ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type
4512                                INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille
4513                                    ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
4514                                INNER JOIN ".DB_PREFIXE."dossier_autorisation_type
4515                                    ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type
4516                                INNER JOIN ".DB_PREFIXE."groupe
4517                                    ON dossier_autorisation_type.groupe = groupe.groupe
4518                                        AND groupe.code != 'CTX'
4519                                WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'";
4520                  $res = $f->db->query($sql);                  $res = $f->db->query($sql);
4521                  $f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE);                  $f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE);
4522                  $f->isDatabaseError($res);                  $f->isDatabaseError($res);
# Line 3947  class instruction extends instruction_ge Line 4532  class instruction extends instruction_ge
4532                          foreach($instr->champs as $id => $champ) {                          foreach($instr->champs as $id => $champ) {
4533                              $valF[$champ] = $instr->val[$id];                              $valF[$champ] = $instr->val[$id];
4534                          }                          }
4535                          $valF['date_evenement']=$instr->dateDBToForm($valF['date_evenement']);                          $valF['date_evenement'] = $instr->dateDBToForm($valF['date_evenement']);
4536                          $valF['archive_date_complet']=$instr->dateDBToForm($valF['archive_date_complet']);                          $valF['archive_date_complet'] = $instr->dateDBToForm($valF['archive_date_complet']);
4537                          $valF['archive_date_rejet']=$instr->dateDBToForm($valF['archive_date_rejet']);                          $valF['archive_date_rejet'] = $instr->dateDBToForm($valF['archive_date_rejet']);
4538                          $valF['archive_date_limite']=$instr->dateDBToForm($valF['archive_date_limite']);                          $valF['archive_date_limite'] = $instr->dateDBToForm($valF['archive_date_limite']);
4539                          $valF['archive_date_notification_delai']=$instr->dateDBToForm($valF['archive_date_notification_delai']);                          $valF['archive_date_notification_delai'] = $instr->dateDBToForm($valF['archive_date_notification_delai']);
4540                          $valF['archive_date_decision']=$instr->dateDBToForm($valF['archive_date_decision']);                          $valF['archive_date_decision'] = $instr->dateDBToForm($valF['archive_date_decision']);
4541                          $valF['archive_date_validite']=$instr->dateDBToForm($valF['archive_date_validite']);                          $valF['archive_date_validite'] = $instr->dateDBToForm($valF['archive_date_validite']);
4542                          $valF['archive_date_achevement']=$instr->dateDBToForm($valF['archive_date_achevement']);                          $valF['archive_date_achevement'] = $instr->dateDBToForm($valF['archive_date_achevement']);
4543                          $valF['archive_date_chantier']=$instr->dateDBToForm($valF['archive_date_chantier']);                          $valF['archive_date_chantier'] = $instr->dateDBToForm($valF['archive_date_chantier']);
4544                          $valF['archive_date_conformite']=$instr->dateDBToForm($valF['archive_date_conformite']);                          $valF['archive_date_conformite'] = $instr->dateDBToForm($valF['archive_date_conformite']);
4545                          $valF['archive_date_dernier_depot']=$instr->dateDBToForm($valF['archive_date_dernier_depot']);                          $valF['archive_date_dernier_depot'] = $instr->dateDBToForm($valF['archive_date_dernier_depot']);
4546                          $valF['archive_date_limite_incompletude']=$instr->dateDBToForm($valF['archive_date_limite_incompletude']);                          $valF['archive_date_limite_incompletude'] = $instr->dateDBToForm($valF['archive_date_limite_incompletude']);
4547                          $valF['date_finalisation_courrier']=$instr->dateDBToForm($valF['date_finalisation_courrier']);                          $valF['date_finalisation_courrier'] = $instr->dateDBToForm($valF['date_finalisation_courrier']);
4548                          $valF['date_envoi_signature']=$instr->dateDBToForm($valF['date_envoi_signature']);                          $valF['date_envoi_signature'] = $instr->dateDBToForm($valF['date_envoi_signature']);
4549                          $valF['date_retour_signature']=$instr->dateDBToForm($valF['date_retour_signature']);                          $valF['date_retour_signature'] = $instr->dateDBToForm($valF['date_retour_signature']);
4550                          $valF['date_envoi_rar']=$instr->dateDBToForm($valF['date_envoi_rar']);                          $valF['date_envoi_rar'] = $instr->dateDBToForm($valF['date_envoi_rar']);
4551                          $valF['date_retour_rar']=$instr->dateDBToForm($valF['date_retour_rar']);                          $valF['date_retour_rar'] = $instr->dateDBToForm($valF['date_retour_rar']);
4552                          $valF['date_envoi_controle_legalite']=$instr->dateDBToForm($valF['date_envoi_controle_legalite']);                          $valF['date_envoi_controle_legalite'] = $instr->dateDBToForm($valF['date_envoi_controle_legalite']);
4553                          $valF['date_retour_controle_legalite']=$instr->dateDBToForm($valF['date_retour_controle_legalite']);                          $valF['date_retour_controle_legalite'] = $instr->dateDBToForm($valF['date_retour_controle_legalite']);
4554                            $valF['archive_date_cloture_instruction'] = $instr->dateDBToForm($valF['archive_date_cloture_instruction']);
4555                            $valF['archive_date_premiere_visite'] = $instr->dateDBToForm($valF['archive_date_premiere_visite']);
4556                            $valF['archive_date_derniere_visite'] = $instr->dateDBToForm($valF['archive_date_derniere_visite']);
4557                            $valF['archive_date_contradictoire'] = $instr->dateDBToForm($valF['archive_date_contradictoire']);
4558                            $valF['archive_date_retour_contradictoire'] = $instr->dateDBToForm($valF['archive_date_retour_contradictoire']);
4559                            $valF['archive_date_ait'] = $instr->dateDBToForm($valF['archive_date_ait']);
4560                            $valF['archive_date_transmission_parquet'] = $instr->dateDBToForm($valF['archive_date_transmission_parquet']);
4561    
4562                          foreach(explode(";", $type_mise_a_jour) as $maj_date) {                          foreach(explode(";", $type_mise_a_jour) as $maj_date) {
4563                              $valF[$maj_date]=$date;                              $valF[$maj_date]=$date;
# Line 4559  class instruction extends instruction_ge Line 5151  class instruction extends instruction_ge
5151      }      }
5152    
5153      /**      /**
5154       * Retourne l'événement d'instruction dont on donne le code-barres       * Retourne l'événement d'instruction dont on donne le code-barres, avec un filtre
5155         * pour exclure les dossiers du groupe contentieux.
5156       *       *
5157       * @param   [string]  $barcode  numéro du code-barres       * @param   [string]  $barcode  numéro du code-barres
5158       * @return  [mixed]             ID de son instruction ou null si aucun code       * @return  [mixed]             ID de son instruction ou null si aucun code
# Line 4568  class instruction extends instruction_ge Line 5161  class instruction extends instruction_ge
5161          // Begin          // Begin
5162          $this->begin_treatment(__METHOD__);          $this->begin_treatment(__METHOD__);
5163          // Vérification de l'existence de l'événement d'instruction          // Vérification de l'existence de l'événement d'instruction
5164          // pour le code-barres donné          // pour le code-barres donné, en excluant les dossiers liés au groupe CTX
5165          $sql = "SELECT instruction          $sql = "SELECT instruction
5166              FROM ".DB_PREFIXE."instruction                  FROM ".DB_PREFIXE."instruction
5167              WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'";                      INNER JOIN ".DB_PREFIXE."dossier
5168                            ON dossier.dossier=instruction.dossier
5169                        INNER JOIN ".DB_PREFIXE."dossier_instruction_type
5170                            ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type
5171                        INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille
5172                            ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
5173                        INNER JOIN ".DB_PREFIXE."dossier_autorisation_type
5174                            ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type
5175                        INNER JOIN ".DB_PREFIXE."groupe
5176                            ON dossier_autorisation_type.groupe = groupe.groupe
5177                                AND groupe.code != 'CTX'
5178                    WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'";
5179          $res = $this->f->db->getOne($sql);          $res = $this->f->db->getOne($sql);
5180          $this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE);          $this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE);
5181          $this->f->isDatabaseError($res);          $this->f->isDatabaseError($res);
# Line 4616  class instruction extends instruction_ge Line 5220  class instruction extends instruction_ge
5220      function setValFAjout($val) {      function setValFAjout($val) {
5221          // Mise à jour du flag created_by_commune lors d'un changement de décision          // Mise à jour du flag created_by_commune lors d'un changement de décision
5222          // par un utilisateur de commune sur un dossier instruit par la comcom          // par un utilisateur de commune sur un dossier instruit par la comcom
5223          if($this->f->isInstrCanChangeDecision($this->valF["dossier"])) {          if ($this->isInstrCanChangeDecision($this->valF["dossier"])) {
5224              $this->valF['created_by_commune'] = true;              $this->valF['created_by_commune'] = true;
5225          }          }
5226      }      }
5227    
     /**  
      * Récupère l'instance du dossier d'instruction  
      *  
      * @param mixed Identifiant du dossier d'instruction  
      *  
      * @return object  
      */  
     function get_inst_dossier($dossier = null) {  
         //  
         return $this->get_inst_common("dossier", $dossier);  
     }  
5228    
5229      /**      /**
5230       * Récupère l'instance d'un événement de workflow.       * Récupère l'instance d'un événement de workflow.
# Line 4906  class instruction extends instruction_ge Line 5499  class instruction extends instruction_ge
5499          //          //
5500          return $modele;          return $modele;
5501      }      }
5502    
5503    
5504        /**
5505         * Récupère l'instance de l'instructeur
5506         *
5507         * @param integer $instructeur Identifiant de l'instructeur.
5508         *
5509         * @return object
5510         */
5511        protected function get_inst_instructeur($instructeur) {
5512            //
5513            return $this->get_inst_common("instructeur", $instructeur);
5514        }
5515    
5516    
5517        /**
5518         * Récupère l'instance de l'utilisateur
5519         *
5520         * @param integer $om_utilisateur Identifiant de l'utilisateur.
5521         *
5522         * @return object
5523         */
5524        protected function get_inst_om_utilisateur($om_utilisateur) {
5525            //
5526            return $this->get_inst_common("om_utilisateur", $om_utilisateur);
5527        }
5528    
5529    
5530        /**
5531         * Récupère l'instance de la division.
5532         *
5533         * @param integer $division Identifiant de la division.
5534         *
5535         * @return object
5536         */
5537        protected function get_inst_division($division) {
5538            //
5539            return $this->get_inst_common("division", $division);
5540        }
5541    
5542    
5543         /**
5544         * Récupère l'instance de la direction.
5545         *
5546         * @param integer $direction Identifiant de la direction.
5547         *
5548         * @return object
5549         */
5550        protected function get_inst_direction($direction) {
5551            //
5552            return $this->get_inst_common("direction", $direction);
5553        }
5554    
5555    
5556        /**
5557         * Récupère la collectivité d'un instructeur en passant par sa division puis
5558         * par sa direction.
5559         *
5560         * @param integer $instructeur Identifiant de l'instructeur.
5561         *
5562         * @return integer
5563         */
5564        protected function get_instructeur_om_collectivite($instructeur) {
5565            // Chemin vers la collectivité d'un instructeur
5566            $inst_instr = $this->get_inst_instructeur($instructeur);
5567            $inst_division = $this->get_inst_division($inst_instr->getVal('division'));
5568            $inst_direction = $this->get_inst_direction($inst_division->getVal('direction'));
5569    
5570            // Collectivité
5571            $om_collectivite = $inst_direction->getVal('om_collectivite');
5572    
5573            //
5574            return $om_collectivite;
5575        }
5576    
5577        /*
5578         * CONDITION - can_user_access_dossier_contexte_ajout
5579         *
5580         * Vérifie que l'utilisateur a bien accès au dossier d'instruction passé dans le
5581         * formulaire d'ajout.
5582         * Cette méthode vérifie que l'utilisateur est lié au groupe du dossier, et si le
5583         * dossier est confidentiel qu'il a accès aux confidentiels de ce groupe.
5584         *
5585         */
5586        function can_user_access_dossier_contexte_ajout() {
5587    
5588            ($this->f->get_submitted_get_value('idxformulaire') !== null ? $id_dossier =
5589                $this->f->get_submitted_get_value('idxformulaire') : $id_dossier = "");
5590            //
5591            if ($id_dossier !== "") {
5592                require_once "../obj/dossier_instruction.class.php";
5593                $dossier = new dossier_instruction($id_dossier, $f->db, DEBUG);
5594                //
5595                return $dossier->can_user_access_dossier();
5596            }
5597            return false;
5598        }
5599    
5600       /*
5601         * CONDITION - can_user_access_dossier
5602         *
5603         * Vérifie que l'utilisateur a bien accès au dossier lié à l'instruction instanciée.
5604         * Cette méthode vérifie que l'utilisateur est lié au groupe du dossier, et si le
5605         * dossier est confidentiel qu'il a accès aux confidentiels de ce groupe.
5606         *
5607         */
5608        function can_user_access_dossier_contexte_modification() {
5609    
5610            $id_dossier = $this->getVal('dossier');
5611            //
5612            if ($id_dossier !== "" && $id_dossier !== null) {
5613                require_once "../obj/dossier_instruction.class.php";
5614                $dossier = new dossier_instruction($id_dossier, $f->db, DEBUG);
5615                //
5616                return $dossier->can_user_access_dossier();
5617            }
5618            return false;
5619        }
5620    
5621  }// fin classe  }// fin classe
5622    
5623  ?>  ?>

Legend:
Removed from v.5024  
changed lines
  Added in v.6565

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26