300 |
// mise a jour instruction avec evenement |
// mise a jour instruction avec evenement |
301 |
// [modify instruction with evenement] |
// [modify instruction with evenement] |
302 |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
303 |
|
|
304 |
$res = $db->query($sql); |
$res = $db->query($sql); |
305 |
if (database::isError($res)) die($res->getMessage()); |
if (database::isError($res)) die($res->getMessage()); |
306 |
|
|
307 |
if ($DEBUG == 1) |
if ($DEBUG == 1) |
308 |
echo " la requete ".$sql." est exécutée<br>"; |
echo " la requete ".$sql." est exécutée<br>"; |
309 |
|
|
310 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
311 |
|
|
312 |
if(isset($row['action']) and !empty($row['action'])) { |
if(isset($row['action']) and !empty($row['action'])) { |
313 |
$this->valF['action']=$row['action']; |
$this->valF['action']=$row['action']; |
314 |
} else { |
} else { |
331 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
332 |
else |
else |
333 |
$this->valF['lettretype']="standard"; |
$this->valF['lettretype']="standard"; |
334 |
|
|
335 |
} |
} |
336 |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
337 |
$res = $db->query($sql); |
$res = $db->query($sql); |
369 |
} |
} |
370 |
} |
} |
371 |
|
|
372 |
|
// Test si une restriction est valide |
373 |
|
// return boolean |
374 |
|
function restrictionIsValid($restriction){ |
375 |
|
|
376 |
|
/* Met des espace avant et après les opérateurs puis transforme la chaine en |
377 |
|
* un tableau */ |
378 |
|
$tabRestriction = str_replace(">="," >= ", |
379 |
|
str_replace("<="," <= ", |
380 |
|
str_replace("-"," - ", |
381 |
|
str_replace("+"," + ",$restriction)))); |
382 |
|
$tabRestriction = explode( " ", $tabRestriction); |
383 |
|
|
384 |
|
//Variables de résultat |
385 |
|
$res = array(); |
386 |
|
$i = 0; |
387 |
|
$comp = ""; |
388 |
|
|
389 |
|
|
390 |
|
//Test que le tableau n'est pas vide |
391 |
|
if ( count($tabRestriction) > 0 ){ |
392 |
|
|
393 |
|
$res[0] = $this->getRestrictionValue($tabRestriction[0]); |
394 |
|
|
395 |
|
//Calcul des variables |
396 |
|
for ( $j = 1 ; $j < count($tabRestriction) ; $j += 2 ) { |
397 |
|
|
398 |
|
//Variable de comparaison |
399 |
|
if ( strcmp( ">=", $tabRestriction[$j] ) == 0 || |
400 |
|
strcmp( "<=", $tabRestriction[$j]) ==0 ){ |
401 |
|
|
402 |
|
$comp = $tabRestriction[$j]; |
403 |
|
$res[++$i] = $this->getRestrictionValue($tabRestriction[$j+1]); |
404 |
|
} |
405 |
|
// Fait l'addition |
406 |
|
elseif ( strcmp( "+", $tabRestriction[$j]) == 0 ){ |
407 |
|
|
408 |
|
$res[$i] = $this->moisdate( $res[$i], $this->getRestrictionValue($tabRestriction[$j+1]) ); |
409 |
|
} |
410 |
|
} |
411 |
|
} |
412 |
|
|
413 |
|
// Effectue le test |
414 |
|
if ( strcmp($comp, ">=") == 0 ){ |
415 |
|
|
416 |
|
if ( $res[0] >= $res[1] || $res[0] == "" ){ |
417 |
|
|
418 |
|
return true; |
419 |
|
} |
420 |
|
else { |
421 |
|
|
422 |
|
return false; |
423 |
|
} |
424 |
|
} |
425 |
|
elseif ( strcmp($comp, "<=") == 0 ){ |
426 |
|
|
427 |
|
if ( $res[0] <= $res[1] || $res[1] == "" ){ |
428 |
|
|
429 |
|
return true; |
430 |
|
} |
431 |
|
else { |
432 |
|
|
433 |
|
return false; |
434 |
|
} |
435 |
|
} |
436 |
|
|
437 |
|
return true; |
438 |
|
} |
439 |
|
|
440 |
|
//Retourne la valeur de valF si $restrictionValue n'est pas un chiffre, le chiffre sinon |
441 |
|
function getRestrictionValue($restrictionValue){ |
442 |
|
|
443 |
|
return ( is_numeric($restrictionValue) ) ? |
444 |
|
$restrictionValue : |
445 |
|
$this->valF[$restrictionValue]; |
446 |
|
} |
447 |
|
|
448 |
function regle($regle){ |
function regle($regle){ |
449 |
$temp = explode ("+",$regle); |
$temp = explode ("+",$regle); |
450 |
//echo '|'.$regle; |
//echo '|'.$regle; |
860 |
return $annee."-".$mois."-".$jour ; |
return $annee."-".$mois."-".$jour ; |
861 |
} |
} |
862 |
|
|
863 |
|
// Vérifie la restriction sur l'événement |
864 |
|
function verifier($val = array(), &$db, $DEBUG){ |
865 |
|
|
866 |
|
//Récupère la restriction |
867 |
|
$sql= "SELECT |
868 |
|
restriction |
869 |
|
FROM |
870 |
|
".DB_PREFIXE."evenement |
871 |
|
WHERE |
872 |
|
evenement =".$this->valF['evenement']; |
873 |
|
|
874 |
|
$res = $db->query($sql); |
875 |
|
$this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
876 |
|
$this->f->isDatabaseError(); |
877 |
|
|
878 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
879 |
|
|
880 |
|
//Test qu'une restriction est présente |
881 |
|
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
882 |
|
|
883 |
|
//Test si la restriction est valide |
884 |
|
if ( !$this->restrictionIsValid($row['restriction']) ){ |
885 |
|
|
886 |
|
$this->correct=false; |
887 |
|
$this->addToMessage(_("Restriction non valide")); |
888 |
|
} |
889 |
|
else { |
890 |
|
|
891 |
|
$this->correct = true; |
892 |
|
} |
893 |
|
} |
894 |
|
} |
895 |
|
|
896 |
}// fin classe |
}// fin classe |
897 |
?> |
?> |