|
|
@@ -1,7 +1,17 @@
|
|
|
<?php
|
|
|
|
|
|
+/**
|
|
|
+ * Classe proweb
|
|
|
+ *
|
|
|
+ * Cette classe gère les opérations liées aux données Proweb, telles que la récupération, la suppression et la vérification des données.
|
|
|
+ */
|
|
|
class proweb
|
|
|
{
|
|
|
+ /**
|
|
|
+ * Récupère les données de base des salariés Proweb.
|
|
|
+ *
|
|
|
+ * @return array Résultats des salariés Proweb.
|
|
|
+ */
|
|
|
public static function getBase()
|
|
|
{
|
|
|
db::query("SELECT *,
|
|
|
@@ -13,6 +23,12 @@ class proweb
|
|
|
return db::resultset();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère les informations d'un fichier Excel Proweb par son identifiant.
|
|
|
+ *
|
|
|
+ * @param int $_id Identifiant du fichier Excel.
|
|
|
+ * @return array Informations du fichier Excel.
|
|
|
+ */
|
|
|
public static function getExcelById(int $_id)
|
|
|
{
|
|
|
db::query("SELECT * FROM " . DB_T_EXCEL_PROWEB . " WHERE id = :id");
|
|
|
@@ -20,6 +36,12 @@ class proweb
|
|
|
return db::single();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Supprime un fichier Excel Proweb par son identifiant.
|
|
|
+ *
|
|
|
+ * @param int $_id Identifiant du fichier Excel.
|
|
|
+ * @return bool Succès ou échec de la suppression.
|
|
|
+ */
|
|
|
public static function deleteExcel(int $_id)
|
|
|
{
|
|
|
|
|
|
@@ -36,12 +58,23 @@ class proweb
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère les informations du dernier fichier Excel.
|
|
|
+ *
|
|
|
+ * @return array Informations du dernier fichier Excel.
|
|
|
+ */
|
|
|
public static function getExcel()
|
|
|
{
|
|
|
db::query("SELECT * FROM " . DB_T_EXCEL . " ORDER BY id DESC LIMIT 0, 1");
|
|
|
return db::single();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit une date en format "MoisAnnée".
|
|
|
+ *
|
|
|
+ * @param string $datetime La date à convertir.
|
|
|
+ * @return string La date convertie.
|
|
|
+ */
|
|
|
public static function convertDateMoisAn(string $datetime)
|
|
|
{
|
|
|
$pieces = explode(" ", $datetime);
|
|
|
@@ -49,12 +82,24 @@ class proweb
|
|
|
return $pieces2[0] . $pieces2[1];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit une date en format "JourMoisAnnée".
|
|
|
+ *
|
|
|
+ * @param string $datetime La date à convertir.
|
|
|
+ * @return string La date convertie.
|
|
|
+ */
|
|
|
public static function convertDateMoisAnJour(string $datetime)
|
|
|
{
|
|
|
$pieces = explode(" ", $datetime);
|
|
|
return $pieces[0];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Archive les valeurs d'un fichier Excel Proweb.
|
|
|
+ *
|
|
|
+ * @param array $_array Données à archiver.
|
|
|
+ * @return array Données archivées avec les erreurs éventuelles.
|
|
|
+ */
|
|
|
public static function archiveExcelValues(array $_array)
|
|
|
{
|
|
|
$_return["error"] = 0;
|
|
|
@@ -147,8 +192,50 @@ class proweb
|
|
|
return $_return;
|
|
|
}
|
|
|
|
|
|
- // Les initialisations
|
|
|
+ /**
|
|
|
+ * Vérifie les données d'un salarié par son identifiant de connexion.
|
|
|
+ *
|
|
|
+ * @param string $_loginId Identifiant de connexion du salarié.
|
|
|
+ * @param string|null $_nom Nom du salarié (optionnel).
|
|
|
+ * @param string|null $_prenom Prénom du salarié (optionnel).
|
|
|
+ * @return array Données du salarié vérifié.
|
|
|
+ */
|
|
|
+ public static function checkSalarieByLoginId(string $_loginId, ?string $_nom = NULL, ?string $_prenom = NULL)
|
|
|
+ {
|
|
|
+ // Récupération des données de l'excel au format Json
|
|
|
+ if ($_nom == NULL) {
|
|
|
+ db::query("SELECT id, loginId, jourEntree, jourSortie, contrat FROM " . DB_T_SALARIES . " WHERE loginId = :loginId");
|
|
|
+ } else {
|
|
|
+ db::query("SELECT id, loginId, jourEntree, jourSortie, contrat FROM " . DB_T_SALARIES . " WHERE loginId = :loginId OR (nom = :nom AND prenom = :prenom)");
|
|
|
+ db::bind(':nom', $_nom);
|
|
|
+ db::bind(':prenom', $_prenom);
|
|
|
+ }
|
|
|
+ db::bind(':loginId', $_loginId);
|
|
|
+ return db::single();
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * Télécharge un fichier Excel Proweb par son identifiant.
|
|
|
+ *
|
|
|
+ * @param int $_id Identifiant du fichier Excel.
|
|
|
+ * @param string $_file Nom du fichier temporaire.
|
|
|
+ * @return string Chemin du fichier téléchargé.
|
|
|
+ */
|
|
|
+ public static function downloadExcel(int $_id, string $_file)
|
|
|
+ {
|
|
|
+ $data = base64_decode(self::getExcelById($_id)["file"]);
|
|
|
+ $fileTemp = fopen(DIR_TEMP . $_file, "w");
|
|
|
+ file_put_contents(DIR_TEMP . $_file, $data);
|
|
|
+ fclose($fileTemp);
|
|
|
+ return DIR_TEMP . $_file;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Convertit une date en format approprié pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string La date à convertir.
|
|
|
+ * @return string La date convertie ou "N/A" si invalide.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesDate(string $_string)
|
|
|
{
|
|
|
if(!isset($_string) or $_string == "00-00-0000"){
|
|
|
@@ -158,26 +245,56 @@ class proweb
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit le sexe en format approprié pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string Le sexe à convertir.
|
|
|
+ * @return string Le sexe converti ou "N/A" si invalide.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesSexe(string $_string)
|
|
|
{
|
|
|
return (empty($_string)) ? "N/A" : $_string;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Nettoie et convertit un identifiant de connexion pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string L'identifiant à convertir.
|
|
|
+ * @return string L'identifiant nettoyé.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesloginId(string $_string)
|
|
|
{
|
|
|
return core::cleanAccent($_string);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Nettoie et convertit un nom pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string Le nom à convertir.
|
|
|
+ * @return string Le nom nettoyé.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesNom(string $_string)
|
|
|
{
|
|
|
return core::cleanAccent($_string);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Nettoie et convertit un prénom pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string Le prénom à convertir.
|
|
|
+ * @return string Le prénom nettoyé.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesPrenom(string $_string)
|
|
|
{
|
|
|
return core::cleanAccent($_string);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit une valeur d'activité pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string La valeur à convertir.
|
|
|
+ * @return int|string La valeur convertie ou "N/A" si invalide.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesActif(string $_string)
|
|
|
{
|
|
|
if ($_string == "O") {
|
|
|
@@ -189,33 +306,36 @@ class proweb
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Nettoie et convertit un lieu pour l'archivage.
|
|
|
+ *
|
|
|
+ * @param string $_string Le lieu à convertir.
|
|
|
+ * @return string Le lieu nettoyé ou "N/A" si invalide.
|
|
|
+ */
|
|
|
private static function archiveExcelValuesLieu(string $_string)
|
|
|
{
|
|
|
return (empty($_string)) ? "N/A" : $_string;
|
|
|
}
|
|
|
|
|
|
- // Les checks
|
|
|
-
|
|
|
- public static function checkSalarieByLoginId(string $_loginId, string $_nom = NULL, string $_prenom = NULL)
|
|
|
- {
|
|
|
- // Récupération des données de l'excel au format Json
|
|
|
- if ($_nom == NULL) {
|
|
|
- db::query("SELECT id, loginId, jourEntree, jourSortie, contrat FROM " . DB_T_SALARIES . " WHERE loginId = :loginId");
|
|
|
- } else {
|
|
|
- db::query("SELECT id, loginId, jourEntree, jourSortie, contrat FROM " . DB_T_SALARIES . " WHERE loginId = :loginId OR (nom = :nom AND prenom = :prenom)");
|
|
|
- db::bind(':nom', $_nom);
|
|
|
- db::bind(':prenom', $_prenom);
|
|
|
- }
|
|
|
- db::bind(':loginId', $_loginId);
|
|
|
- return db::single();
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Vérifie si une valeur d'activité est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string La valeur à vérifier.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesActif(string $_string)
|
|
|
{
|
|
|
return ($_string == "N/A") ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
- private static function checkValuesloginId(string $_idLogin, string $_idLoginRH = NULL)
|
|
|
+ /**
|
|
|
+ * Vérifie si un identifiant de connexion est valide.
|
|
|
+ *
|
|
|
+ * @param string $_idLogin Identifiant de connexion.
|
|
|
+ * @param string|null $_idLoginRH Identifiant RH (optionnel).
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
+ private static function checkValuesloginId(string $_idLogin, ?string $_idLoginRH = NULL)
|
|
|
{
|
|
|
if ($_idLoginRH != NULL) {
|
|
|
if (empty(self::checkSalarieByLoginId($_idLogin)["id"])) {
|
|
|
@@ -234,41 +354,91 @@ class proweb
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une valeur RHBase est valide.
|
|
|
+ *
|
|
|
+ * @param int $_RH Valeur RHBase.
|
|
|
+ * @param int $_actif Valeur actif.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesRHBase(int $_RH, int $_actif)
|
|
|
{
|
|
|
return ($_RH == 0 and $_actif == 1) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une date d'entrée est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string La date d'entrée.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesJourEntree(string $_string)
|
|
|
{
|
|
|
return ($_string == "N/A") ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une date de sortie est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string La date de sortie.
|
|
|
+ * @param int $_actif Valeur actif.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesJourSortie(string $_string, int $_actif)
|
|
|
{
|
|
|
return ($_string != "N/A" and $_actif == 1) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si un nom est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string Le nom à vérifier.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesNom(string $_string)
|
|
|
{
|
|
|
return (empty($_string)) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si un prénom est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string Le prénom à vérifier.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesPrenom(string $_string)
|
|
|
{
|
|
|
return (empty($_string)) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si un sexe est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string Le sexe à vérifier.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesSexe(string $_string)
|
|
|
{
|
|
|
return ($_string == NULL or ($_string != "M." and $_string != "Mme")) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si un lieu est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string Le lieu à vérifier.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesLieu(string $_string)
|
|
|
{
|
|
|
return (empty($_string)) ? FALSE : TRUE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une date de naissance est valide.
|
|
|
+ *
|
|
|
+ * @param string $_string La date de naissance.
|
|
|
+ * @return bool TRUE si valide, FALSE sinon.
|
|
|
+ */
|
|
|
private static function checkValuesNaissance(string $_string)
|
|
|
{
|
|
|
if(empty($_string) OR $_string == "N/A") {
|
|
|
@@ -280,6 +450,12 @@ class proweb
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Calcule l'âge à partir d'une date de naissance.
|
|
|
+ *
|
|
|
+ * @param string $_date La date de naissance.
|
|
|
+ * @return int L'âge calculé.
|
|
|
+ */
|
|
|
private static function calculAge(string $_date)
|
|
|
{
|
|
|
$pieces = explode(" ", $_date);
|
|
|
@@ -288,13 +464,4 @@ class proweb
|
|
|
? ((date("Y") - $birthDate[0]) - 1)
|
|
|
: (date("Y") - $birthDate[0]));
|
|
|
}
|
|
|
-
|
|
|
- public static function downloadExcel(int $_id, string $_file)
|
|
|
- {
|
|
|
- $data = base64_decode(self::getExcelById($_id)["file"]);
|
|
|
- $fileTemp = fopen(DIR_TEMP . $_file, "w");
|
|
|
- file_put_contents(DIR_TEMP . $_file, $data);
|
|
|
- fclose($fileTemp);
|
|
|
- return DIR_TEMP . $_file;
|
|
|
- }
|
|
|
}
|