75 lines
2.8 KiB
PHP
75 lines
2.8 KiB
PHP
<?php
|
|
namespace Module\ACM\Classe\GestionBD;
|
|
class gestionVariableDate {
|
|
/**
|
|
* @return array renvoie toutes les dates férié sous forme de liste de dictionnaire
|
|
*/
|
|
public static function getACMFeries() : array{
|
|
global $db;
|
|
$db->query("SET NAMES 'utf8mb4'");
|
|
$list = [];
|
|
$sql = "SELECT nom, regle, jour, mois, actif FROM llx_acm_feries ORDER BY regle ASC, mois ASC, jour ASC";
|
|
$resql=$db->query($sql);
|
|
if ($resql)
|
|
while ($row = $db->fetch_array($resql))
|
|
$list[] = ["nom"=>$row['nom'],"regle"=>$row['regle'],"jour"=>$row['jour'],"mois"=>$row['mois'],"actif"=>$row['actif']];
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* @param $nom string label de la date
|
|
* @return bool renvoie si la modification a été effectuer
|
|
*/
|
|
public static function putACMDateActif(string $nom) : bool {
|
|
global $db; $db->query("SET NAMES 'utf8mb4'");
|
|
$nom = $db->escape($nom);
|
|
$sql = "UPDATE llx_acm_feries SET actif='actif' WHERE nom = '$nom';";
|
|
$resql=$db->query($sql);
|
|
if ($resql) return true;
|
|
else return false;
|
|
}
|
|
/**
|
|
* @param $nom string label de la date
|
|
* @return bool renvoie si la modification a été effectuer
|
|
*/
|
|
public static function putACMDateInactif($nom) : bool{
|
|
global $db; $db->query("SET NAMES 'utf8mb4'");
|
|
$nom = $db->escape($nom);
|
|
$sql = "UPDATE llx_acm_feries SET actif='inactif' WHERE nom = '$nom';";
|
|
$resql=$db->query($sql);
|
|
if ($resql) return true;
|
|
else return false;
|
|
}
|
|
|
|
/**
|
|
* @param $nom string label de la date
|
|
* @param $regle string type de regle
|
|
* @param $jour string|int jour
|
|
* @param $mois string|int mois
|
|
* @param $actif string si est actif ou inactif
|
|
* @return bool renvoie la valeur d'insertion
|
|
*/
|
|
public static function addACMFeries(string $nom, string $regle, $jour, $mois, string $actif) : bool {
|
|
global $db; $db->query("SET NAMES 'utf8mb4'");
|
|
$nom = $db->escape($nom); $regle = $db->escape($regle);
|
|
$jour = $db->escape($jour); $mois = $db->escape($mois);
|
|
$actif = $db->escape($actif);
|
|
$sql = "INSERT INTO llx_acm_feries(nom, regle, jour, mois, actif) VALUES ('$nom','$regle','$jour','$mois','$actif')";
|
|
$resql=$db->query($sql);
|
|
if ($resql) return true;
|
|
else return false;
|
|
}
|
|
|
|
/**
|
|
* @param $nom string label de la date
|
|
* @return bool renvoie la valeur de suppression
|
|
*/
|
|
public static function deleteACMFeries($nom) : bool {
|
|
global $db; $db->query("SET NAMES 'utf8mb4'");
|
|
$nom = $db->escape($nom);
|
|
$sql = "DELETE FROM llx_acm_feries WHERE nom = '$nom'";
|
|
$resql=$db->query($sql);
|
|
if ($resql) return true;
|
|
else return false;
|
|
}
|
|
} |