33 |
var $retourformulaire; // specific |
var $retourformulaire; // specific |
34 |
var $idxformulaire; // specific |
var $idxformulaire; // specific |
35 |
var $valEvenement; |
var $valEvenement; |
36 |
|
var $restriction_valid = null; |
37 |
// Tableau contenant une partie des métadonnées arrêtés |
// Tableau contenant une partie des métadonnées arrêtés |
38 |
var $metadonneesArrete; |
var $metadonneesArrete; |
39 |
|
|
816 |
// Test si une restriction est valide |
// Test si une restriction est valide |
817 |
// return boolean |
// return boolean |
818 |
function restrictionIsValid($restriction){ |
function restrictionIsValid($restriction){ |
819 |
|
if($this->restriction_valid != null) { |
820 |
|
return $this->restriction_valid; |
821 |
|
} |
822 |
// Liste des opérateurs possible |
// Liste des opérateurs possible |
823 |
$operateurs = array(">=", "<=", "+", "-"); |
$operateurs = array(">=", "<=", "+", "-"); |
824 |
// Liste des opérateurs avec espace |
// Liste des opérateurs avec espace |
932 |
} |
} |
933 |
|
|
934 |
/** |
/** |
935 |
|
* Permet de définir si l'événement passé en paramètre est un événement retour. |
936 |
|
* @param integer $evenement événement à tester |
937 |
|
* |
938 |
|
* @return boolean retourne true si événement retour sinon false |
939 |
|
*/ |
940 |
|
function is_evenement_retour($evenement) { |
941 |
|
if(empty($evenement) || !is_numeric($evenement)) { |
942 |
|
return ""; |
943 |
|
} |
944 |
|
$sql = "SELECT retour |
945 |
|
FROM ".DB_PREFIXE."evenement |
946 |
|
WHERE evenement = ".$evenement; |
947 |
|
$retour = $this->db->getOne($sql); |
948 |
|
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
949 |
|
if (database::isError($retour)) { |
950 |
|
die($retour->getMessage()); |
951 |
|
} |
952 |
|
if ($retour == 't') { |
953 |
|
return true; |
954 |
|
} else { |
955 |
|
return false; |
956 |
|
} |
957 |
|
} |
958 |
|
|
959 |
|
/** |
960 |
|
* Retourne le champ restriction de l'événement passé en paramètre. |
961 |
|
* |
962 |
|
* @param integer $evenement id de l'événement sur lequel récupérer la restriction |
963 |
|
* |
964 |
|
* @return string contenu du champ restriction |
965 |
|
*/ |
966 |
|
function get_restriction($evenement) { |
967 |
|
if(empty($evenement) || !is_numeric($evenement)) { |
968 |
|
return ""; |
969 |
|
} |
970 |
|
//Récupère la restriction |
971 |
|
$sql= "SELECT |
972 |
|
restriction |
973 |
|
FROM |
974 |
|
".DB_PREFIXE."evenement |
975 |
|
WHERE |
976 |
|
evenement =".$evenement; |
977 |
|
|
978 |
|
$restriction = $this->db->getOne($sql); |
979 |
|
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
980 |
|
if (database::isError($restriction)) { |
981 |
|
die($restriction->getMessage()); |
982 |
|
} |
983 |
|
return $restriction; |
984 |
|
} |
985 |
|
|
986 |
|
/** |
987 |
* Récupère la valeur du champ dans la restriction |
* Récupère la valeur du champ dans la restriction |
988 |
* @param string $restrictionValue Nom du champ |
* @param string $restrictionValue Nom du champ |
989 |
* @return mixed Valeur du champ |
* @return mixed Valeur du champ |
1421 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1422 |
} |
} |
1423 |
|
|
1424 |
// Récupération de tous les paramètres de l'événement sélectionné |
$restriction = $this->get_restriction($val['evenement']); |
1425 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
|
1426 |
WHERE evenement=".$this->valF['evenement']; |
if($this->restrictionIsValid($restriction)){ |
1427 |
$res = $db->query($sql); |
// Récupération de tous les paramètres de l'événement sélectionné |
1428 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
1429 |
if (database::isError($res)) { |
WHERE evenement=".$this->valF['evenement']; |
1430 |
die($res->getMessage()); |
$res = $db->query($sql); |
1431 |
} |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1432 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
if (database::isError($res)) { |
1433 |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
die($res->getMessage()); |
|
if ($this->getVal('date_retour_signature') == "" AND |
|
|
$this->valF['date_retour_signature'] != "" AND |
|
|
$row['evenement_retour_signature'] != "") { |
|
|
$new_instruction = new instruction("]", $db, $DEBUG); |
|
|
// Création d'un tableau avec la liste des champs de l'instruction |
|
|
foreach($new_instruction->champs as $champ) { |
|
|
$valNewInstr[$champ] = ""; |
|
|
} |
|
|
// Définition des valeurs de la nouvelle instruction |
|
|
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
|
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
|
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
|
|
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_signature']); |
|
|
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
|
|
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
|
|
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
|
|
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
|
|
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
|
|
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
|
|
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
|
|
|
|
|
//Si une erreur s'est produite |
|
|
if ($retour == false){ |
|
|
$this->correct = false ; |
|
|
$this->msg .= $new_instruction->msg; |
|
|
return false; |
|
|
} |
|
1434 |
} |
} |
1435 |
// Si la date de retour AR est éditée on vérifie si il existe un événement automatique |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1436 |
if ($this->getVal('date_retour_rar') == "" AND |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
1437 |
$this->valF['date_retour_rar'] != "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
1438 |
$row['evenement_retour_ar'] != "" ) { |
$this->valF['date_retour_signature'] != "" AND |
1439 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$row['evenement_retour_signature'] != "") { |
1440 |
// Création d'un tableau avec la liste des champs de l'instruction |
$new_instruction = new instruction("]", $db, $DEBUG); |
1441 |
foreach($new_instruction->champs as $champ) { |
// Création d'un tableau avec la liste des champs de l'instruction |
1442 |
$valNewInstr[$champ] = ""; |
foreach($new_instruction->champs as $champ) { |
1443 |
} |
$valNewInstr[$champ] = ""; |
1444 |
// Définition des valeurs de la nouvelle instruction |
} |
1445 |
$valNewInstr["evenement"] = $row['evenement_retour_ar']; |
// Définition des valeurs de la nouvelle instruction |
1446 |
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
1447 |
$valNewInstr["dossier"] = $this->valF['dossier']; |
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
1448 |
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["dossier"] = $this->valF['dossier']; |
1449 |
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_signature']); |
1450 |
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
1451 |
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
1452 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
1453 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1454 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1455 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
1456 |
|
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1457 |
//Si une erreur s'est produite |
|
1458 |
if ($retour == false){ |
//Si une erreur s'est produite |
1459 |
$this->correct = false ; |
if ($retour == false){ |
1460 |
$this->msg .= $new_instruction->msg; |
$this->correct = false ; |
1461 |
return false; |
$this->msg .= $new_instruction->msg; |
1462 |
|
return false; |
1463 |
|
} |
1464 |
|
} |
1465 |
|
// Si la date de retour AR est éditée on vérifie si il existe un événement automatique |
1466 |
|
if ($this->getVal('date_retour_rar') == "" AND |
1467 |
|
$this->valF['date_retour_rar'] != "" AND |
1468 |
|
$row['evenement_retour_ar'] != "" ) { |
1469 |
|
$new_instruction = new instruction("]", $db, $DEBUG); |
1470 |
|
// Création d'un tableau avec la liste des champs de l'instruction |
1471 |
|
foreach($new_instruction->champs as $champ) { |
1472 |
|
$valNewInstr[$champ] = ""; |
1473 |
|
} |
1474 |
|
// Définition des valeurs de la nouvelle instruction |
1475 |
|
$valNewInstr["evenement"] = $row['evenement_retour_ar']; |
1476 |
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
1477 |
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
1478 |
|
$valNewInstr["date_evenement"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1479 |
|
$valNewInstr["date_envoi_signature"] = $this->f->formatDate($this->valF['date_envoi_signature']); |
1480 |
|
$valNewInstr["date_retour_signature"] = $this->f->formatDate($this->valF['date_retour_signature']); |
1481 |
|
$valNewInstr["date_envoi_rar"] = $this->f->formatDate($this->valF['date_envoi_rar']); |
1482 |
|
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1483 |
|
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1484 |
|
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
1485 |
|
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1486 |
|
|
1487 |
|
//Si une erreur s'est produite |
1488 |
|
if ($retour == false){ |
1489 |
|
$this->correct = false ; |
1490 |
|
$this->msg .= $new_instruction->msg; |
1491 |
|
return false; |
1492 |
|
} |
1493 |
} |
} |
1494 |
} |
} |
1495 |
} |
} |
1731 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val, $db, $DEBUG); |
1732 |
|
|
1733 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
1734 |
//Récupère la restriction |
$restriction = $this->get_restriction($val['evenement']); |
|
$sql= "SELECT |
|
|
restriction |
|
|
FROM |
|
|
".DB_PREFIXE."evenement |
|
|
WHERE |
|
|
evenement =".$val['evenement']; |
|
|
|
|
|
$res = $db->query($sql); |
|
|
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
|
1735 |
|
|
1736 |
//Test qu'une restriction est présente |
//Test qu'une restriction est présente |
1737 |
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
if ($restriction != "" ){ |
|
|
|
|
$restriction = $row['restriction']; |
|
1738 |
|
|
1739 |
//Test si la restriction est valide |
//Test si la restriction est valide |
1740 |
if ( !$this->restrictionIsValid($restriction) ){ |
if ( !$this->restrictionIsValid($restriction) ){ |
1741 |
|
|
|
$this->correct=false; |
|
1742 |
$this->addToMessage(_("Restriction non valide")); |
$this->addToMessage(_("Restriction non valide")); |
1743 |
} |
|
1744 |
else { |
// Si l'événement courant est un événement retour |
1745 |
|
// alors la restriction est appliquée |
1746 |
$this->correct = true; |
if(!$this->is_evenement_retour($val['evenement'])) { |
1747 |
|
$this->correct = false; |
1748 |
|
return false; |
1749 |
|
} |
1750 |
} |
} |
1751 |
|
|
1752 |
// Liste des opérateurs possible |
// Liste des opérateurs possible |