948 |
// Retourne la valeur du champ |
// Retourne la valeur du champ |
949 |
return $return; |
return $return; |
950 |
} |
} |
951 |
|
|
952 |
function regle($regle){ |
/** |
953 |
|
* Calcul des règle d'action. |
954 |
|
* @param string $rule Règle d'action |
955 |
|
* @param string $rule_name Nom de la règle |
956 |
|
* @param string $type Type de la règle |
957 |
|
* |
958 |
|
* @return mixed Résultat de la règle |
959 |
|
*/ |
960 |
|
function regle($rule, $rule_name, $type = null) { |
961 |
|
|
962 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
963 |
$regle = str_replace(' ', '', $regle); |
$rule = str_replace(' ', '', $rule); |
964 |
// Coupe la chaîne au niveau des "+" |
// Coupe la chaîne au niveau de l'opérateur |
965 |
$temp = explode ("+",$regle); |
$operands = explode ("+", $rule); |
966 |
//echo '|'.$regle; |
// Nombre d'opérande |
967 |
// cas rejet |
$nb_operands = count($operands); |
968 |
if($regle=="null") // 1 dimension -> null |
|
969 |
|
// Règle à null |
970 |
|
if ($rule == "null") { |
971 |
return null; |
return null; |
|
if(sizeof($temp)==1) // 1 dimension |
|
|
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
|
|
return $this->$regle; |
|
|
else // cas general |
|
|
return $this->valF[$regle]; |
|
|
if(sizeof($temp)==2){ // 2 dimensions |
|
|
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
|
|
if(is_numeric($temp[1])) |
|
|
return $this->f->mois_date($this->$temp[0], $temp[1]); |
|
|
else |
|
|
return $this->f->mois_date($this->$temp[0], $this->valF[$temp[1]]); |
|
|
if($temp[0]=="archive_delai") // majoration de delai |
|
|
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
|
|
// cas general 2 dimensions |
|
|
if(is_numeric($temp[1])) |
|
|
return $this->f->mois_date($this->valF[$temp[0]], $temp[1]); |
|
|
else |
|
|
return $this->f->mois_date($this->valF[$temp[0]], $this->valF[$temp[1]]); |
|
|
} |
|
|
if(sizeof($temp)==3){ // 3 dimensions |
|
|
// cas date de validite de sursis |
|
|
if(is_numeric($temp[1])) |
|
|
$temp1 = $this->f->mois_date($this->valF[$temp[0]], $temp[1]); |
|
|
else |
|
|
$temp1 = $this->f->mois_date($this->valF[$temp[0]], $this->valF[$temp[1]]); |
|
|
if(is_numeric($temp[2])) |
|
|
return $this->f->mois_date($temp1, $temp[2]); |
|
|
else |
|
|
return $this->f->mois_date($temp1, $this->valF[$temp[2]]); |
|
972 |
} |
} |
973 |
|
|
974 |
|
// Si c'est une règle spécifique |
975 |
|
if ($rule_name == "regle_autorite_competente" |
976 |
|
|| $rule_name == "regle_etat" |
977 |
|
|| $rule_name == "regle_accord_tacite" |
978 |
|
|| $rule_name == "regle_avis") { |
979 |
|
// |
980 |
|
return $this->valF[$rule]; |
981 |
|
} |
982 |
|
|
983 |
|
// Tableau des champs de type date |
984 |
|
$rule_type_date = array( |
985 |
|
"regle_date_limite", |
986 |
|
"regle_date_notification_delai", |
987 |
|
"regle_date_complet", |
988 |
|
"regle_date_validite", |
989 |
|
"regle_date_decision", |
990 |
|
"regle_date_chantier", |
991 |
|
"regle_date_achevement", |
992 |
|
"regle_date_conformite", |
993 |
|
"regle_date_rejet", |
994 |
|
"regle_date_dernier_depot", |
995 |
|
"regle_date_limite_incompletude", |
996 |
|
); |
997 |
|
// Tableau des champs de type numérique |
998 |
|
$rule_type_numeric = array( |
999 |
|
"regle_delai", |
1000 |
|
"regle_delai_incompletude", |
1001 |
|
); |
1002 |
|
|
1003 |
|
// Définit le type du champ |
1004 |
|
if (in_array($rule_name, $rule_type_date) == true) { |
1005 |
|
$type = "date"; |
1006 |
|
} |
1007 |
|
if (in_array($rule_name, $rule_type_numeric) == true) { |
1008 |
|
$type = "numeric"; |
1009 |
|
} |
1010 |
|
|
1011 |
|
// Initialisation des variables |
1012 |
|
$key_date = 0; |
1013 |
|
$total_numeric = 0; |
1014 |
|
|
1015 |
|
// Pour chaque opérande |
1016 |
|
foreach ($operands as $key => $operand) { |
1017 |
|
|
1018 |
|
// Si c'est une règle de type date |
1019 |
|
if ($type == 'date') { |
1020 |
|
// Vérifie si au moins une des opérandes est une date |
1021 |
|
if (!is_numeric($operand) |
1022 |
|
&& isset($this->valF[$operand]) |
1023 |
|
&& $this->f->check_date($this->valF[$operand]) == true) { |
1024 |
|
// Récupère la position de la date |
1025 |
|
$key_date = $key; |
1026 |
|
} |
1027 |
|
// Les autres opérandes doivent être que des numériques |
1028 |
|
if (is_numeric($operand) == true) { |
1029 |
|
// Ajoute l'opérande au total |
1030 |
|
$total_numeric += $operand; |
1031 |
|
} |
1032 |
|
if (!is_numeric($operand) |
1033 |
|
&& isset($this->valF[$operand]) |
1034 |
|
&& is_numeric($this->valF[$operand]) == true) { |
1035 |
|
// Ajoute l'opérande au total |
1036 |
|
$total_numeric += $this->valF[$operand]; |
1037 |
|
} |
1038 |
|
} |
1039 |
|
|
1040 |
|
// Si c'est une règle de type numérique |
1041 |
|
if ($type == 'numeric') { |
1042 |
|
// Les opérandes doivent être que des numériques |
1043 |
|
if (is_numeric($operand) == true) { |
1044 |
|
// Ajoute l'opérande au total |
1045 |
|
$total_numeric += $operand; |
1046 |
|
} |
1047 |
|
if (!is_numeric($operand) |
1048 |
|
&& isset($this->valF[$operand]) |
1049 |
|
&& is_numeric($this->valF[$operand]) == true) { |
1050 |
|
// Ajoute l'opérande au total |
1051 |
|
$total_numeric += $this->valF[$operand]; |
1052 |
|
} |
1053 |
|
} |
1054 |
|
} |
1055 |
|
|
1056 |
|
// Résultat pour une règle de type date |
1057 |
|
if ($type == 'date') { |
1058 |
|
// Retourne le calcul de la date |
1059 |
|
return $this->f->mois_date($this->valF[$operands[$key_date]], |
1060 |
|
$total_numeric, "+"); |
1061 |
|
} |
1062 |
|
|
1063 |
|
// Résultat pour une règle de type numérique |
1064 |
|
if ($type == 'numeric') { |
1065 |
|
// Retourne le calcul |
1066 |
|
return $total_numeric; |
1067 |
|
} |
1068 |
|
|
1069 |
} |
} |
|
|
|
|
|
|
1070 |
|
|
1071 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
1072 |
/** |
/** |
1119 |
|
|
1120 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
1121 |
if($row['regle_delai']!=''){ |
if($row['regle_delai']!=''){ |
1122 |
$valF['delai'] = $this->regle($row['regle_delai']); |
$valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai'); |
1123 |
} |
} |
1124 |
if($row['regle_accord_tacite']!=''){ |
if($row['regle_accord_tacite']!=''){ |
1125 |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite']); |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite'); |
1126 |
} |
} |
1127 |
if($row['regle_avis']!=''){ |
if($row['regle_avis']!=''){ |
1128 |
$valF['avis_decision'] = $this->regle($row['regle_avis']); |
$valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis'); |
1129 |
} |
} |
1130 |
if($row['regle_date_limite']!=''){ |
if($row['regle_date_limite']!=''){ |
1131 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
1132 |
} |
} |
1133 |
if($row['regle_date_complet']!=''){ |
if($row['regle_date_complet']!=''){ |
1134 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
1135 |
} |
} |
1136 |
if($row['regle_date_dernier_depot']!=''){ |
if($row['regle_date_dernier_depot']!=''){ |
1137 |
$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'); |
1138 |
} |
} |
1139 |
if($row['regle_date_notification_delai']!=''){ |
if($row['regle_date_notification_delai']!=''){ |
1140 |
$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'); |
1141 |
} |
} |
1142 |
if($row['regle_date_decision']!=''){ |
if($row['regle_date_decision']!=''){ |
1143 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
1144 |
} |
} |
1145 |
if($row['regle_date_rejet']!=''){ |
if($row['regle_date_rejet']!=''){ |
1146 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
1147 |
} |
} |
1148 |
if($row['regle_date_validite']!=''){ |
if($row['regle_date_validite']!=''){ |
1149 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
1150 |
} |
} |
1151 |
if($row['regle_date_chantier']!=''){ |
if($row['regle_date_chantier']!=''){ |
1152 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
1153 |
} |
} |
1154 |
if($row['regle_date_achevement']!=''){ |
if($row['regle_date_achevement']!=''){ |
1155 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
1156 |
} |
} |
1157 |
if($row['regle_date_conformite']!=''){ |
if($row['regle_date_conformite']!=''){ |
1158 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
1159 |
} |
} |
1160 |
if($row['regle_date_limite_incompletude']!=''){ |
if($row['regle_date_limite_incompletude']!=''){ |
1161 |
$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'); |
1162 |
} |
} |
1163 |
if($row['regle_delai_incompletude']!=''){ |
if($row['regle_delai_incompletude']!=''){ |
1164 |
$valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude']); |
$valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude'); |
1165 |
} |
} |
1166 |
if($row['regle_autorite_competente']!=''){ |
if($row['regle_autorite_competente']!=''){ |
1167 |
$valF['autorite_competente']= $this->regle($row['regle_autorite_competente']); |
$valF['autorite_competente']= $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
1168 |
} |
} |
1169 |
if($row['regle_etat']!=''){ |
if($row['regle_etat']!=''){ |
1170 |
// 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 |
1171 |
// 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 |
1172 |
// l'état dans la variable courante |
// l'état dans la variable courante |
1173 |
if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") { |
if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") { |
1174 |
$valF['etat'] = $this->regle($row['regle_etat']); |
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
1175 |
} else { |
} else { |
1176 |
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat']); |
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat'); |
1177 |
} |
} |
1178 |
} |
} |
1179 |
if($this->valEvenement['evenement_suivant_tacite'] != '') { |
if($this->valEvenement['evenement_suivant_tacite'] != '') { |
1282 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
1283 |
// application des regles sur le courrier + delai |
// application des regles sur le courrier + delai |
1284 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
1285 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
1286 |
} |
} |
1287 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
1288 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
1289 |
} |
} |
1290 |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
1291 |
$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'); |
1292 |
} |
} |
1293 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
1294 |
$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'); |
1295 |
} |
} |
1296 |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
1297 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
1298 |
} |
} |
1299 |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
1300 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
1301 |
} |
} |
1302 |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
1303 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
1304 |
} |
} |
1305 |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
1306 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
1307 |
} |
} |
1308 |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
1309 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
1310 |
} |
} |
1311 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
1312 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
1313 |
} |
} |
1314 |
} |
} |
1315 |
// 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 |
1765 |
} |
} |
1766 |
|
|
1767 |
//Mise à jour des données |
//Mise à jour des données |
1768 |
if ( $uid != '' || $uid == 'OP_FAILURE' ){ |
if ( $uid != '' && $uid != 'OP_FAILURE' ){ |
1769 |
// Logger |
// Logger |
1770 |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
1771 |
// Recuperation de la valeur de la cle primaire de l'objet |
// Recuperation de la valeur de la cle primaire de l'objet |