/[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 2786 by softime, Tue Feb 25 14:56:56 2014 UTC revision 2787 by softime, Thu Mar 6 13:47:18 2014 UTC
# Line 924  class instruction extends instruction_ge Line 924  class instruction extends instruction_ge
924      }      }
925    
926      /**      /**
927       * Récupère la valeur du champ dans la restriction       * Calcul des règle d'action.
928       * @param  string   $restrictionValue   Nom du champ       * @param string $rule      Règle d'action
929       * @return mixed                        Valeur du champ       * @param string $rule_name Nom de la règle
930         * @param string $type      Type de la règle
931         *
932         * @return mixed            Résultat de la règle
933       */       */
934      function getRestrictionValue($restrictionValue){      function regle($rule, $rule_name, $type = null) {
935    
936          // Initialisation de la valeur de retour          // Supprime tous les espaces de la chaîne de caractère
937          $return = false;          $rule = str_replace(' ', '', $rule);
938            // Coupe la chaîne au niveau de l'opérateur
939            $operands = explode ("+", $rule);
940            // Nombre d'opérande
941            $nb_operands = count($operands);
942    
943          // Récupére les valeurs du dossier          // Règle à null
944          $value_dossier = $this->get_dossier_actual();          if ($rule == "null") {
945                return null;
946            }
947    
948          //          // Si c'est une règle spécifique
949          if (is_numeric($restrictionValue)) {          if ($rule_name == "regle_autorite_competente"
950              $return = $restrictionValue;              || $rule_name == "regle_etat"
951          }elseif (isset($value_dossier[$restrictionValue])) {              || $rule_name == "regle_accord_tacite"
952              $return = $value_dossier[$restrictionValue];              || $rule_name == "regle_avis") {
953          }elseif (isset($this->valF[$restrictionValue])) {              //
954              $return = $this->valF[$restrictionValue];              return $this->valF[$rule];
955          }          }
956    
957          // Retourne la valeur du champ          // Tableau des champs de type date
958          return $return;          $rule_type_date = array(
959      }              "regle_date_limite",
960                    "regle_date_notification_delai",
961      function regle($regle){              "regle_date_complet",
962          // Supprime tous les espaces de la chaîne de caractère              "regle_date_validite",
963          $regle = str_replace(' ', '', $regle);              "regle_date_decision",
964          // Coupe la chaîne au niveau des "+"              "regle_date_chantier",
965          $temp = explode ("+",$regle);              "regle_date_achevement",
966          //echo '|'.$regle;              "regle_date_conformite",
967          // cas rejet              "regle_date_rejet",
968          if($regle=="null") // 1 dimension -> null              "regle_date_dernier_depot",
969              return null;              "regle_date_limite_incompletude",
970          if(sizeof($temp)==1) // 1 dimension          );
971              if($temp[0]=="archive_date_depot") // initialisation avec le depot          // Tableau des champs de type numérique
972                  return $this->$regle;          $rule_type_numeric = array(
973              else // cas general              "regle_delai",
974                  return $this->valF[$regle];              "regle_delai_incompletude",
975          if(sizeof($temp)==2){ // 2 dimensions          );
976              if($temp[0]=="archive_date_depot") //initialisation avec le depot  
977                  if(is_numeric($temp[1]))          // Définit le type du champ
978                      return  $this->f->mois_date($this->$temp[0], $temp[1]);            if (in_array($rule_name, $rule_type_date) == true) {
979                  else              $type = "date";
980                      return  $this->f->mois_date($this->$temp[0], $this->valF[$temp[1]]);          }
981              if($temp[0]=="archive_delai") // majoration de delai          if (in_array($rule_name, $rule_type_numeric) == true) {
982                  return  $this->valF[$temp[0]]+$this->valF[$temp[1]];              $type = "numeric";
983              // cas general 2 dimensions          }
984              if(is_numeric($temp[1]))  
985                  return $this->f->mois_date($this->valF[$temp[0]], $temp[1]);          // Initialisation des variables
986              else                        $key_date = 0;
987                 return  $this->f->mois_date($this->valF[$temp[0]], $this->valF[$temp[1]]);          $total_numeric = 0;
988          }  
989          if(sizeof($temp)==3){ // 3 dimensions          // Pour chaque opérande
990              // cas date de validite de sursis          foreach ($operands as $key => $operand) {
991              if(is_numeric($temp[1]))  
992                  $temp1 = $this->f->mois_date($this->valF[$temp[0]], $temp[1]);              // Si c'est une règle de type date
993              else                            if ($type == 'date') {
994                  $temp1 = $this->f->mois_date($this->valF[$temp[0]], $this->valF[$temp[1]]);                  // Vérifie si au moins une des opérandes est une date
995              if(is_numeric($temp[2]))                  if (!is_numeric($operand)
996                  return $this->f->mois_date($temp1, $temp[2]);                      && isset($this->valF[$operand])
997              else                      && $this->f->check_date($this->valF[$operand]) == true) {
998                  return $this->f->mois_date($temp1, $this->valF[$temp[2]]);                      // Récupère la position de la date
999                        $key_date = $key;
1000                    }
1001                    // Les autres opérandes doivent être que des numériques
1002                    if (is_numeric($operand) == true) {
1003                        // Ajoute l'opérande au total
1004                        $total_numeric += $operand;
1005                    }
1006                    if (!is_numeric($operand)
1007                        && isset($this->valF[$operand])
1008                        && is_numeric($this->valF[$operand]) == true) {
1009                        // Ajoute l'opérande au total
1010                        $total_numeric += $this->valF[$operand];
1011                    }
1012                }
1013    
1014                // Si c'est une règle de type numérique
1015                if ($type == 'numeric') {
1016                    // Les opérandes doivent être que des numériques
1017                    if (is_numeric($operand) == true) {
1018                        // Ajoute l'opérande au total
1019                        $total_numeric += $operand;
1020                    }
1021                    if (!is_numeric($operand)
1022                        && isset($this->valF[$operand])
1023                        && is_numeric($this->valF[$operand]) == true) {
1024                        // Ajoute l'opérande au total
1025                        $total_numeric += $this->valF[$operand];
1026                    }
1027                }
1028            }
1029    
1030            // Résultat pour une règle de type date
1031            if ($type == 'date') {
1032                // Retourne le calcul de la date
1033                return $this->f->mois_date($this->valF[$operands[$key_date]],
1034                    $total_numeric, "+");
1035            }
1036    
1037            // Résultat pour une règle de type numérique
1038            if ($type == 'numeric') {
1039                // Retourne le calcul
1040                return $total_numeric;
1041          }          }
1042            
1043      }      }
       
       
1044    
1045      function triggerajouterapres($id,&$db,$val,$DEBUG) {      function triggerajouterapres($id,&$db,$val,$DEBUG) {
1046          /**          /**
# Line 1043  class instruction extends instruction_ge Line 1093  class instruction extends instruction_ge
1093    
1094              // pour chacune des regles, on applique la regle              // pour chacune des regles, on applique la regle
1095              if($row['regle_delai']!=''){              if($row['regle_delai']!=''){
1096                  $valF['delai'] = $this->regle($row['regle_delai']);                  $valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai');
1097              }              }
1098              if($row['regle_accord_tacite']!=''){              if($row['regle_accord_tacite']!=''){
1099                  $valF['accord_tacite'] = $this->regle($row['regle_accord_tacite']);                  $valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite');
1100              }              }
1101              if($row['regle_avis']!=''){              if($row['regle_avis']!=''){
1102                  $valF['avis_decision'] = $this->regle($row['regle_avis']);                  $valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis');
1103              }              }
1104              if($row['regle_date_limite']!=''){              if($row['regle_date_limite']!=''){
1105                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                  $valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite');
1106              }              }
1107              if($row['regle_date_complet']!=''){              if($row['regle_date_complet']!=''){
1108                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                  $valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet');
1109              }              }
1110              if($row['regle_date_dernier_depot']!=''){              if($row['regle_date_dernier_depot']!=''){
1111                  $valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot']);                  $valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot');
1112              }              }
1113              if($row['regle_date_notification_delai']!=''){              if($row['regle_date_notification_delai']!=''){
1114                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai');
1115              }              }
1116              if($row['regle_date_decision']!=''){              if($row['regle_date_decision']!=''){
1117                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                  $valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision');
1118              }              }
1119              if($row['regle_date_rejet']!=''){              if($row['regle_date_rejet']!=''){
1120                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                  $valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet');
1121              }              }
1122              if($row['regle_date_validite']!=''){              if($row['regle_date_validite']!=''){
1123                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                  $valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite');
1124              }              }
1125              if($row['regle_date_chantier']!=''){              if($row['regle_date_chantier']!=''){
1126                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                  $valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier');
1127              }              }
1128              if($row['regle_date_achevement']!=''){              if($row['regle_date_achevement']!=''){
1129                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                  $valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement');
1130              }              }
1131              if($row['regle_date_conformite']!=''){              if($row['regle_date_conformite']!=''){
1132                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                  $valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite');
1133              }              }
1134              if($row['regle_date_limite_incompletude']!=''){              if($row['regle_date_limite_incompletude']!=''){
1135                  $valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude']);                  $valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude'], 'regle_date_limite_incompletude');
1136              }              }
1137              if($row['regle_delai_incompletude']!=''){              if($row['regle_delai_incompletude']!=''){
1138                  $valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude']);                  $valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude');
1139              }              }
1140              if($row['regle_autorite_competente']!=''){              if($row['regle_autorite_competente']!=''){
1141                  $valF['autorite_competente']= $this->regle($row['regle_autorite_competente']);                  $valF['autorite_competente']= $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente');
1142              }              }
1143              if($row['regle_etat']!=''){              if($row['regle_etat']!=''){
1144                  // 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
1145                  // 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
1146                  // l'état dans la variable courante                  // l'état dans la variable courante
1147                  if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") {                  if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") {
1148                      $valF['etat'] = $this->regle($row['regle_etat']);                      $valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat');
1149                  } else {                  } else {
1150                      $valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat']);                      $valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat');
1151                  }                  }
1152              }              }
1153              if($this->valEvenement['evenement_suivant_tacite'] != '') {              if($this->valEvenement['evenement_suivant_tacite'] != '') {
# Line 1206  class instruction extends instruction_ge Line 1256  class instruction extends instruction_ge
1256          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1257              // application des regles sur le courrier + delai              // application des regles sur le courrier + delai
1258              if(preg_match("/date_evenement/",$row['regle_date_limite'])){              if(preg_match("/date_evenement/",$row['regle_date_limite'])){
1259                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                  $valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite');
1260              }              }
1261              if(preg_match("/date_evenement/",$row['regle_date_complet'])){              if(preg_match("/date_evenement/",$row['regle_date_complet'])){
1262                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                  $valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet');
1263              }              }
1264              if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){              if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){
1265                  $valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot']);                  $valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot');
1266              }              }
1267              if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){              if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){
1268                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai');
1269              }              }
1270              if(preg_match("/date_evenement/",$row['regle_date_decision'])){              if(preg_match("/date_evenement/",$row['regle_date_decision'])){
1271                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                  $valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision');
1272              }              }
1273              if(preg_match("/date_evenement/",$row['regle_date_rejet'])){              if(preg_match("/date_evenement/",$row['regle_date_rejet'])){
1274                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                  $valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet');
1275              }              }
1276              if(preg_match("/date_evenement/",$row['regle_date_validite'])){              if(preg_match("/date_evenement/",$row['regle_date_validite'])){
1277                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                  $valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite');
1278              }              }
1279              if(preg_match("/date_evenement/",$row['regle_date_chantier'])){              if(preg_match("/date_evenement/",$row['regle_date_chantier'])){
1280                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                  $valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier');
1281              }              }
1282              if(preg_match("/date_evenement/",$row['regle_date_achevement'])){              if(preg_match("/date_evenement/",$row['regle_date_achevement'])){
1283                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                  $valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement');
1284              }              }
1285              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){
1286                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                  $valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite');
1287              }              }
1288          }          }
1289          // 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

Legend:
Removed from v.2786  
changed lines
  Added in v.2787

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26