Browse Source

Change authent birthday

stany.ferer 2 years ago
parent
commit
cac8a66e05

+ 2 - 6
core/class/core.class.php

@@ -109,13 +109,9 @@ class core
         }
     }
 
-    public static function dateFromTimestamp(int $_timestamp = NULL)
+    public static function dateWhithoutHours(string $_datetime)
     {
-        if ($_timestamp == NULL) {
-            return NULL;
-        } else {
-            return date("Y-m-d H:i:s", $_timestamp);
-        }
+        return explode(" ", $_datetime)[0];
     }
 
     public static function formatFileSize(float $_size, int $_decimalplaces = 0)

+ 15 - 9
core/class/event.class.php

@@ -154,12 +154,14 @@ class event
             . "" . DB_T_SALARIES . ".prenom, "
             . "" . DB_T_SALARIES . ".sexe, "
             . "" . DB_T_SALARIES . ".contrat, "
+            . "" . DB_T_SALARIES_PROWEB . ".dateNaissance, "
             . "" . DB_T_SALARIES . ".lieu, "
             . "" . DB_T_SALARIES . ".actif, "
             . "IF(" . DB_T_EVENTS_INSCRITS . ".id_salarie IS NOT NULL, 1, 0) AS inscrit, "
             . "" . DB_T_EVENTS_INSCRITS . ".present "
             . "FROM " . DB_T_SALARIES . " "
             . "LEFT JOIN " . DB_T_EVENTS_INSCRITS . " ON " . DB_T_SALARIES . ".id = " . DB_T_EVENTS_INSCRITS . ".id_salarie "
+            . "LEFT JOIN " . DB_T_SALARIES_PROWEB . " ON " . DB_T_SALARIES . ".loginId = " . DB_T_SALARIES_PROWEB . ".loginId "
             . "AND " . DB_T_EVENTS_INSCRITS . ".id_evenement = " . core::getGet("id"));
             return db::resultset();
     }
@@ -182,22 +184,24 @@ class event
         $date = $date->format('Y-m-d H:i:s');
 
         db::query("SELECT "
-            . "id, "
-            . "sel, "
-            . "nom, "
-            . "prenom, "
-            . "actif, "
-            . "contrat, "
-            . "jourEntree "
+            . "" . DB_T_SALARIES . ".id, "
+            . "" . DB_T_SALARIES . ".sel, "
+            . "" . DB_T_SALARIES . ".nom, "
+            . "" . DB_T_SALARIES_PROWEB . ".dateNaissance, "
+            . "" . DB_T_SALARIES . ".prenom, "
+            . "" . DB_T_SALARIES . ".actif, "
+            . "" . DB_T_SALARIES . ".contrat, "
+            . "" . DB_T_SALARIES . ".jourEntree "
             . "FROM " . DB_T_SALARIES . " "
-            . "WHERE loginId = :login OR idLocal = :login");
+            . "INNER JOIN " . DB_T_SALARIES_PROWEB . " ON " . DB_T_SALARIES . ".loginId = " . DB_T_SALARIES_PROWEB . ".loginId "
+            . "WHERE " . DB_T_SALARIES . ".loginId = :login OR " . DB_T_SALARIES . ".idLocal = :login");
         db::bind(':login', $login);
         $salarie = db::single();
 
         if (isset($salarie["id"])) {
             if ($salarie["actif"] == 0) {
                 return FALSE;
-            } elseif ($salarie["jourEntree"] != $date) {
+            } elseif (core::dateWhithoutHours($salarie["dateNaissance"]) != core::dateWhithoutHours($date)) {
                 return FALSE;
             } else {
                 $_SESSION["salarie"] = array(
@@ -306,6 +310,7 @@ class event
                 . "" . DB_T_SALARIES . ".id, "
                 . "" . DB_T_SALARIES . ".loginId, "
                 . "" . DB_T_SALARIES . ".idLocal, "
+                . "" . DB_T_SALARIES_PROWEB . ".dateNaissance, "
                 . "" . DB_T_SALARIES . ".jourEntree, "
                 . "" . DB_T_SALARIES . ".nom, "
                 . "" . DB_T_SALARIES . ".prenom, "
@@ -317,6 +322,7 @@ class event
                 . "" . DB_T_EVENTS_INSCRITS . ".present "
                 . "FROM " . DB_T_SALARIES . " "
                 . "INNER JOIN " . DB_T_EVENTS_INSCRITS . " ON " . DB_T_EVENTS_INSCRITS . ".id_salarie = " . DB_T_SALARIES . ".id "
+                . "LEFT JOIN " . DB_T_SALARIES_PROWEB . " ON " . DB_T_SALARIES . ".loginId = " . DB_T_SALARIES_PROWEB . ".loginId "
                 . "WHERE " . DB_T_EVENTS_INSCRITS . ".id_evenement = " . $_id_event);
         return db::resultset();
     }

+ 31 - 5
core/class/proweb.class.php

@@ -66,11 +66,12 @@ class proweb
         $_return["nom"] = self::archiveExcelValuesNom($_array[1]);
         $_return["prenom"] = self::archiveExcelValuesPrenom($_array[2]);
         $_return["sexe"] = self::archiveExcelValuesSexe($_array[3]);
-        $_return["jourEntree"] = self::archiveExcelValuesDate($_array[4]);
-        $_return["jourSortie"] = self::archiveExcelValuesDate($_array[5]);
-        $_return["actif"] = self::archiveExcelValuesActif($_array[6]);
-        $_return["lieu"] = self::archiveExcelValuesLieu($_array[7]);
-        $_return["loginId"] = self::archiveExcelValuesloginId($_array[8]);
+        $_return["dateNaissance"] = self::archiveExcelValuesDate($_array[4]);
+        $_return["jourEntree"] = self::archiveExcelValuesDate($_array[5]);
+        $_return["jourSortie"] = self::archiveExcelValuesDate($_array[6]);
+        $_return["actif"] = self::archiveExcelValuesActif($_array[7]);
+        $_return["lieu"] = self::archiveExcelValuesLieu($_array[8]);
+        $_return["loginId"] = self::archiveExcelValuesloginId($_array[9]);
 
         $verifRH = self::checksalarieByLoginId($_return["loginId"], $_return["nom"], $_return["prenom"]);
 
@@ -109,6 +110,11 @@ class proweb
                 array_push($_return["errorJson"], "loginId");
             }
 
+            if (!self::checkValuesNaissance($_return["dateNaissance"])) {
+                $_return["error"] = 1;
+                array_push($_return["errorJson"], "dateNaissance");
+            }
+
             if (!self::checkValuesJourEntree($_return["jourEntree"])) {
                 $_return["error"] = 1;
                 array_push($_return["errorJson"], "jourEntree");
@@ -262,6 +268,26 @@ class proweb
         return (empty($_string)) ? FALSE : TRUE;
     }
 
+    private static function checkValuesNaissance(string $_string)
+    {
+        if(empty($_string) OR $_string == "N/A") {
+            return FALSE;
+        } elseif(self::calculAge($_string) > core::getConfig("AGE_MAX_ERROR")) {
+            return FALSE;
+        } else {
+            return TRUE;
+        }
+    }
+
+    private static function calculAge(string $_date)
+    {
+        $pieces = explode(" ", $_date);
+        $birthDate = explode("-", $pieces[0]);
+        return (date("md", date("U", mktime(0, 0, 0, $birthDate[2], $birthDate[1], $birthDate[0]))) > date("md")
+        ? ((date("Y") - $birthDate[0]) - 1)
+        : (date("Y") - $birthDate[0]));
+    }
+
     public static function downloadExcel(int $_id, string $_file)
     {
         $data = base64_decode(self::getExcelById($_id)["file"]);

+ 1 - 0
core/submit/cms.event-export-inscription.php

@@ -13,6 +13,7 @@ if (core::ifGet("from") AND core::getGet("from") == "event-export-inscription")
         "id", 
         "loginId",
         "idLocal", 
+        "dateNaissance",
         "jourEntree", 
         "nom", 
         "prenom", 

+ 15 - 12
core/submit/cms.proweb-import-salaries.php

@@ -47,11 +47,12 @@ if (core::ifPost("from") AND core::getPost("from") == $name["files"]) {
                             OR $excelValues[1] != "od_nom" 
                             OR $excelValues[2] != "od_prenom" 
                             OR $excelValues[3] != "od_civilite" 
-                            OR $excelValues[4] != "date_deb_anciennete()" 
-                            OR $excelValues[5] != "date_fin_anciennete()" 
-                            OR $excelValues[6] != "od_31" 
-                            OR $excelValues[7] != "site_nom"
-                            OR $excelValues[8] != "od_login" ){
+                            OR $excelValues[4] != "od_date_naiss" 
+                            OR $excelValues[5] != "date_deb_anciennete()" 
+                            OR $excelValues[6] != "date_fin_anciennete()" 
+                            OR $excelValues[7] != "od_31" 
+                            OR $excelValues[8] != "site_nom"
+                            OR $excelValues[9] != "od_login" ){
 
                         alert::recError("Le fichier " . $_FILES[$name["files"]]['name'] . " n'est pas un export ProWeb global.");
 
@@ -59,11 +60,12 @@ if (core::ifPost("from") AND core::getPost("from") == $name["files"]) {
                         ($excelValues[1] != "od_nom") ? alert::recError("La 2em colonne doit se nommer od_nom") : "";
                         ($excelValues[2] != "od_prenom") ? alert::recError("La 3em colonne doit se nommer od_prenom") : "";
                         ($excelValues[3] != "od_civilite") ? alert::recError("La 4em colonne doit se nommer od_civilite") : "";
-                        ($excelValues[4] != "date_deb_anciennete()") ? alert::recError("La 5em colonne doit se nommer date_deb_anciennete()") : "";
-                        ($excelValues[5] != "date_fin_anciennete()") ? alert::recError("La 6em colonne doit se nommer date_fin_anciennete()") : "";
-                        ($excelValues[6] != "od_31") ? alert::recError("La 7em colonne doit se nommer od_31") : "";
-                        ($excelValues[7] != "site_nom") ? alert::recError("La 8em colonne doit se nommer site_nom") : "";
-                        ($excelValues[8] != "od_login") ? alert::recError("La 9em colonne doit se nommer od_login") : "";
+                        ($excelValues[4] != "od_date_naiss") ? alert::recError("La 5em colonne doit se nommer od_date_naiss") : "";
+                        ($excelValues[5] != "date_deb_anciennete()") ? alert::recError("La 6em colonne doit se nommer date_deb_anciennete()") : "";
+                        ($excelValues[6] != "date_fin_anciennete()") ? alert::recError("La 7em colonne doit se nommer date_fin_anciennete()") : "";
+                        ($excelValues[7] != "od_31") ? alert::recError("La 8em colonne doit se nommer od_31") : "";
+                        ($excelValues[8] != "site_nom") ? alert::recError("La 9em colonne doit se nommer site_nom") : "";
+                        ($excelValues[9] != "od_login") ? alert::recError("La 10em colonne doit se nommer od_login") : "";
 
                         header("Location: /".$name["returnKo"] . ".html");
                         exit();
@@ -74,8 +76,8 @@ if (core::ifPost("from") AND core::getPost("from") == $name["files"]) {
                     $final = proweb::archiveExcelValues($excelValues);
                     
                     db::query("INSERT INTO ". DB_T_SALARIES_PROWEB ." "
-                            . "(idProweb, loginId, loginIdRH, nom, prenom, sexe, contrat, jourEntree, jourEntreeRH, jourSortie, lieu, actif, RHBase, error, errorJson) "
-                            . "VALUES (:idProweb, :loginId, :loginIdRH, :nom, :prenom, :sexe, :contrat, :jourEntree, :jourEntreeRH, :jourSortie, :lieu, :actif, :RHBase, :error, :errorJson)");
+                            . "(idProweb, loginId, loginIdRH, nom, prenom, sexe, contrat, dateNaissance, jourEntree, jourEntreeRH, jourSortie, lieu, actif, RHBase, error, errorJson) "
+                            . "VALUES (:idProweb, :loginId, :loginIdRH, :nom, :prenom, :sexe, :contrat, :dateNaissance, :jourEntree, :jourEntreeRH, :jourSortie, :lieu, :actif, :RHBase, :error, :errorJson)");
                     db::bind(':idProweb', $final["idProweb"]);
                     db::bind(':loginId', $final["loginId"]);
                     db::bind(':loginIdRH', $final["loginIdRH"]);
@@ -83,6 +85,7 @@ if (core::ifPost("from") AND core::getPost("from") == $name["files"]) {
                     db::bind(':prenom', $final["prenom"]);
                     db::bind(':sexe', $final["sexe"]);
                     db::bind(':contrat', $final["contrat"]);
+                    db::bind(':dateNaissance', $final["dateNaissance"]);
                     db::bind(':jourEntree', $final["jourEntree"]);
                     db::bind(':jourEntreeRH', $final["jourEntreeRH"]);
                     db::bind(':jourSortie', $final["jourSortie"]);

+ 3 - 1
core/views/pages/cms.evenement-inscrits.php

@@ -22,7 +22,9 @@
     data-url="/json.php?jsonData=event-inscrits&id=<?php echo core::getGet("id") ?>">
     <thead>
         <tr>
-            <th data-sortable="true" data-field="loginId" data-filter-control="input">Login</th>
+            <th data-sortable="true" data-field="idLocal" data-filter-control="input">Identifiant</th>
+            <th data-sortable="true" data-field="loginId" data-filter-control="input">Matricule</th>
+            <th data-sortable="true" data-field="dateNaissance" data-filter-control="input">Naissances</th>
             <th data-sortable="true" data-field="nom" data-filter-control="input">Nom</th>
             <th data-sortable="true" data-field="prenom" data-filter-control="input">Prénom</th>
             <th data-sortable="true" data-field="sexe" data-filter-control="select">Sexe</th>

+ 3 - 1
core/views/pages/cms.evenement-salaries.php

@@ -18,7 +18,9 @@ if(core::ifGet("id")){
     data-url="/json.php?jsonData=event-salaries&id=<?php echo core::getGet("id") ?>">
     <thead>
         <tr>
-            <th data-sortable="true" data-field="loginId" data-filter-control="input">Login</th>
+            <th data-sortable="true" data-field="idLocal" data-filter-control="input">Identifiant</th>
+            <th data-sortable="true" data-field="loginId" data-filter-control="input">Matricule</th>
+            <th data-sortable="true" data-field="dateNaissance" data-filter-control="input">Naissances</th>
             <th data-sortable="true" data-field="nom" data-filter-control="input">Nom</th>
             <th data-sortable="true" data-field="prenom" data-filter-control="input">Prénom</th>
             <th data-sortable="true" data-field="sexe" data-filter-control="select">Sexe</th>

+ 2 - 1
core/views/pages/cms.proweb-salaries.php

@@ -34,11 +34,12 @@
         <thead>
             <tr>
                 <th data-sortable="true" data-field="idProweb" data-filter-control="input" data-formatter="selectFicheProweb" data-width="35">#</th>
-                <th data-sortable="true" data-field="loginId" data-filter-control="input">Identifiant Proweb</th>
+                <th data-sortable="true" data-field="loginId" data-filter-control="input">Id Proweb</th>
                 <th data-sortable="true" data-field="loginIdRH" data-filter-control="input">Dif. RH</th>
                 <th data-sortable="true" data-field="nom" data-filter-control="input">Nom</th>
                 <th data-sortable="true" data-field="prenom" data-filter-control="input">Prénom</th>
                 <th data-sortable="true" data-field="sexe" data-filter-control="select">Sexe</th>
+                <th data-sortable="true" data-field="dateNaissance" data-filter-control="input">Naissance</th>
                 <th data-sortable="true" data-field="jourEntree" data-filter-control="input">Entrée Proweb</th>
                 <th data-sortable="true" data-field="jourEntreeRH" data-filter-control="input">Entrée RH</th>
                 <th data-sortable="true" data-field="jourSortie" data-filter-control="input">Sortie</th>

+ 1 - 1
core/views/pages/events.login-salarie.php

@@ -26,7 +26,7 @@
                 <input type="text" aria-label="Matricule ou identifiant" id="ident" value="" oninput="this.value = this.value.toUpperCase()" maxlength="8" name="ident" required>
             </div>
             <div>
-                <label for="date">Date d'ancienne</label>
+                <label for="date">Date de naissance</label>
                 <input type="date" pseudo="webkit-date-and-time-value" aria-label="Date d'ancienneté" id="date" value="" name="date" required>
                 <input type="password" id="date_password" onchange="copyDate()" value="" name="password" style="display:none;">
             </div>