Browse Source

Maj Stats

stany.ferer 2 năm trước cách đây
mục cha
commit
b7b29b7cdd

+ 7 - 0
core/class/core.class.php

@@ -149,6 +149,13 @@ class core
         return $return;
     }
 
+    public static function caculPourcentage(?int $_nombre, ?int $_total, int $_pourcentage = 100)
+    { 
+        if ($_nombre == NULL) return 0;
+        $resultat = ($_nombre/$_total) * $_pourcentage;
+        return round($resultat); 
+    }
+
     public static function encodeUTF8(string $_data)
     {
         return (mb_detect_encoding($_data) != "UTF-8") ? mb_convert_encoding($_data, 'UTF-8', mb_list_encodings()) : $_data;

+ 13 - 8
core/class/stats.class.php

@@ -2,7 +2,7 @@
 
 class stats {
     
-    public static function countStatistiquesGenrale(int $_actifOnly = 1){
+    public static function countStatistiquesGenerale(int $_actifOnly = 1){
         $actif = ($_actifOnly == 1) ? " AND actif = 1" : "";
         db::query("SELECT "
                 . "SUM(IF(sexe = 'F'" . $actif . ", 1, 0)) AS Femme, "
@@ -11,12 +11,12 @@ class stats {
                 . "SUM(IF(contrat = 0" . $actif . ", 1, 0)) AS ContratOff, "
                 . "SUM(IF(actif = 1, 1, 0)) AS ActifOn, "
                 . "SUM(IF(actif = 0, 1, 0)) AS ActifOff, "
-                . "SUM(IF(lieu = 'ISSY - 147', 1, 0)) AS lieuParis147, "
-                . "SUM(IF(lieu = 'LYON (IVOIRE)', 1, 0)) AS lieuLyonIvoire, "
-                . "SUM(IF(lieu = 'PEROLS', 1, 0)) AS lieuPerols, "
-                . "SUM(IF(lieu = 'PARIS CAMBACERE', 1, 0)) AS lieuParisCambaceres, "
-                . "SUM(IF(lieu = 'BLAGNAC CENT. 3', 1, 0)) AS lieuToulouseBalgnac, "
-                . "SUM(IF(lieu = 'PARIS-BOUCHARDO', 1, 0)) AS lieuParisBouchardo "
+                . "SUM(IF(lieu = 'ISSY - 147', 1, 0)" . $actif . ") AS lieuParis147, "
+                . "SUM(IF(lieu = 'LYON (IVOIRE)', 1, 0)" . $actif . ") AS lieuLyonIvoire, "
+                . "SUM(IF(lieu = 'PEROLS', 1, 0)" . $actif . ") AS lieuPerols, "
+                . "SUM(IF(lieu = 'PARIS CAMBACERE', 1, 0)" . $actif . ") AS lieuParisCambaceres, "
+                . "SUM(IF(lieu = 'BLAGNAC CENT. 3', 1, 0)" . $actif . ") AS lieuToulouseBalgnac, "
+                . "SUM(IF(lieu = 'PARIS-BOUCHARDO', 1, 0)" . $actif . ") AS lieuParisBouchardo "
                 . "FROM " . DB_T_SALARIES);
         return db::single();
     }
@@ -55,7 +55,12 @@ class stats {
         foreach (db::resultset() as $value) {
             $return[$value["anEntree"]] = (empty($return[$value["anEntree"]])) ? 1 : $return[$value["anEntree"]]+1;
         }
-        ksort($return);
+        if(!empty($return)){
+            ksort($return);
+        } else {
+            $return = array(date("Y") => 0);
+        }
+        
         return $return;
     }
     

+ 33 - 0
core/json/cms.stats-general.php

@@ -0,0 +1,33 @@
+<?php 
+
+function create(string $_lieu){
+    $return = array();
+    $return = stats::countStatistiquesByLieu($_lieu);
+    $return["Lieu"] = $_lieu;
+    $return["PourcentageFemme"] = core::caculPourcentage($return["Femme"], $return["ActifOn"]);
+    $return["PourcentageHomme"] = core::caculPourcentage($return["Homme"], $return["ActifOn"]);
+    return $return;
+}
+
+$statGeneral = stats::countStatistiquesGenerale();
+
+$return[] = array(
+    "Lieu" => "TOUT INVENT",
+    "Femme" => $statGeneral["Femme"],
+    "Homme" => $statGeneral["Homme"],
+    "ContratOn" => $statGeneral["ContratOn"],
+    "ContratOff" => $statGeneral["ContratOff"],
+    "ActifOn" => $statGeneral["ActifOn"],
+    "ActifOff" => $statGeneral["ActifOff"],
+    "PourcentageFemme" => core::caculPourcentage($statGeneral["Femme"], $statGeneral["ActifOn"]),
+    "PourcentageHomme" => core::caculPourcentage($statGeneral["Homme"], $statGeneral["ActifOn"]),
+);
+
+$return[] = create("147");
+$return[] = create("LYON");
+$return[] = create("PEROLS");
+$return[] = create("CAMBACERE");
+$return[] = create("BLAGNAC");
+$return[] = create("BOUCHARDO");
+
+echo json_encode($return);

+ 1 - 1
core/views/pages/cms.stats-an-entree.php

@@ -91,7 +91,7 @@
         ?>
     </div>
     <div class="col-md-5" style="margin-top: 30px;">
-         <h6 class="bg-light p-2">Paris - Bouchardo</h6>
+        <h6 class="bg-light p-2">Paris - Bouchardo</h6>
         <?php
         $config = array(
             "id" => "statBouchardoEntree",

+ 1 - 1
core/views/pages/cms.stats-contrats.php

@@ -1,5 +1,5 @@
 <?php
-    $statGeneral = stats::countStatistiquesGenrale();
+    $statGeneral = stats::countStatistiquesGenerale();
     $stat147 = stats::countStatistiquesByLieu("147");
     $statLyon = stats::countStatistiquesByLieu("LYON");
     $statPerol = stats::countStatistiquesByLieu("PEROLS");

+ 1 - 1
core/views/pages/cms.stats-femmes-hommes.php

@@ -1,5 +1,5 @@
 <?php
-    $statGeneral = stats::countStatistiquesGenrale();
+    $statGeneral = stats::countStatistiquesGenerale();
     $stat147 = stats::countStatistiquesByLieu("147");
     $statLyon = stats::countStatistiquesByLieu("LYON");
     $statPerol = stats::countStatistiquesByLieu("PEROLS");

+ 31 - 67
core/views/pages/cms.stats-general.php

@@ -1,71 +1,35 @@
-<?php
-    $statGeneral = stats::countStatistiquesGenrale();  
-    $statGeneralEntree = stats::countStatistiquesGenraleEntrees(); 
-?>
-<div class="row" style="margin-top: 20px;">
-    
-    <div class="col-md-10" style="margin-top: 10px;">
-        <h6 class="bg-light p-2">Nb. salariés par site</h6>
-        <?php
-        $config = array(
-            "id" => "statGeneralLieu",
-            "charts" => "bar",
-            "label" => "Sites (général)",
-            "data" => array(
-                array("label" => "Paris - 147", "nb" => $statGeneral["lieuParis147"]),
-                array("label" => "Paris - Cambacérès", "nb" => $statGeneral["lieuParisCambaceres"]),
-                array("label" => "Paris - Bouchardo", "nb" => $statGeneral["lieuParisBouchardo"]),
-                array("label" => "Lyon - Tour d'ivoire", "nb" => $statGeneral["lieuLyonIvoire"]),
-                array("label" => "Montpellier - Pérols", "nb" => $statGeneral["lieuPerols"]),
-                array("label" => "Toulouse - BLanchar", "nb" => $statGeneral["lieuToulouseBalgnac"]))
-        );
-
-        chart::printCanvas($config);
-        ?>
-    </div>
-    
+<div class="row" style="margin-top: 20x;">
     <div class="col-md-10" style="margin-top: 30px;">
-        <h6 class="bg-light p-2">Années d'entrée</h6>
-        <?php
-        $config = array(
-            "id" => "statGeneralEntree",
-            "charts" => "line",
-            "label" => "Année d'entrée (général)",
-            "data" => array($statGeneralEntree)
-        );
-
-        chart::printCanvas($config);
-        ?>
+        <h6 class="bg-light p-2">Général</h6>
+        <table  id="table" 
+                class="table-striped table-hover table-sm" 
+                data-toggle="table"
+                data-flat="true"
+                data-sort-name="ActifOn"
+                data-sort-order="desc"
+                data-url="/json.php?jsonData=stats-general">
+            <thead>
+                <tr>
+                    <th data-sortable="true" data-field="Lieu" data-filter-control="select">Etablissement</th>
+                    <th data-sortable="true" data-field="ActifOn" data-filter-control="select">Effectif</th>
+                    <th data-sortable="true" data-field="Femme" data-filter-control="select">Femme</th>
+                    <th data-sortable="true" data-field="Homme" data-filter-control="select">Homme</th>
+                    <th data-sortable="true" data-field="PourcentageFemme" data-formatter="formatPourcentageFemme" data-filter-control="select">% Femme</th>
+                    <th data-sortable="true" data-field="PourcentageHomme" data-formatter="formatPourcentageHomme" data-filter-control="select">% Homme</th>
+                    <th data-sortable="true" data-field="ContratOn" data-filter-control="select">Contrats actifs</th>
+                    <th data-sortable="true" data-field="ContratOff" data-filter-control="select">Contrats suspendus</th>
+                </tr>
+            </thead>
+        </table>
     </div>
-    
-    <div class="col-md-5" style="margin-top: 30px;">
-        <h6 class="bg-light p-2">Femme / Homme</h6>
-        <?php
-        $config = array(
-            "id" => "statGeneralHommeFemme",
-            "charts" => "doughnut",
-            "label" => "Femmes/Hommes (général)",
-            "data" => array(
-                array("label" => "Femme", "nb" => $statGeneral["Femme"]),
-                array("label" => "Homme", "nb" => $statGeneral["Homme"]))
-        );
+</div>
 
-        chart::printCanvas($config);
-        ?>  
-    </div>
-    <div class="col-md-5" style="margin-top: 30px;">
-        <h6 class="bg-light p-2">Contrats actifs et non actifs</h6>
-        <?php
-        $config = array(
-            "id" => "statGeneralContratActif",
-            "charts" => "doughnut",
-            "label" => "Contrats actifs (général)",
-            "data" => array(
-                array("label" => "Contrats actifs", "nb" => $statGeneral["ContratOn"]),
-                array("label" => "Contrats en arrêt", "nb" => $statGeneral["ContratOff"]))
-        );
+<script>
+    function formatPourcentageFemme(value, row) {
+        return row.PourcentageFemme + "%";
+    }
 
-        chart::printCanvas($config);
-        ?>  
-    </div>
-</div>
+    function formatPourcentageHomme(value, row) {
+        return row.PourcentageHomme + "%";
+    }
+</script>

+ 74 - 0
core/views/pages/cms.stats-tous-sites.php

@@ -0,0 +1,74 @@
+<?php
+$statGeneral = stats::countStatistiquesGenerale();
+$statGeneralEntree = stats::countStatistiquesGenraleEntrees();
+?>
+<div class="row" style="margin-top: 20px;">
+
+    <div class="col-md-10" style="margin-top: 10px;">
+        <h6 class="bg-light p-2">Nb. salariés par site</h6>
+        <?php
+        $config = array(
+            "id" => "statGeneralLieu",
+            "charts" => "bar",
+            "label" => "Sites (général)",
+            "data" => array(
+                array("label" => "Paris - 147", "nb" => $statGeneral["lieuParis147"]),
+                array("label" => "Paris - Cambacérès", "nb" => $statGeneral["lieuParisCambaceres"]),
+                array("label" => "Paris - Bouchardo", "nb" => $statGeneral["lieuParisBouchardo"]),
+                array("label" => "Lyon - Tour d'ivoire", "nb" => $statGeneral["lieuLyonIvoire"]),
+                array("label" => "Montpellier - Pérols", "nb" => $statGeneral["lieuPerols"]),
+                array("label" => "Toulouse - BLanchar", "nb" => $statGeneral["lieuToulouseBalgnac"])
+            )
+        );
+
+        chart::printCanvas($config);
+        ?>
+    </div>
+
+    <div class="col-md-10" style="margin-top: 30px;">
+        <h6 class="bg-light p-2">Années d'entrée</h6>
+        <?php
+        $config = array(
+            "id" => "statGeneralEntree",
+            "charts" => "line",
+            "label" => "Année d'entrée (général)",
+            "data" => array($statGeneralEntree)
+        );
+
+        chart::printCanvas($config);
+        ?>
+    </div>
+
+    <div class="col-md-5" style="margin-top: 30px;">
+        <h6 class="bg-light p-2">Femme / Homme</h6>
+        <?php
+        $config = array(
+            "id" => "statGeneralHommeFemme",
+            "charts" => "doughnut",
+            "label" => "Femmes/Hommes (général)",
+            "data" => array(
+                array("label" => "Femme", "nb" => $statGeneral["Femme"]),
+                array("label" => "Homme", "nb" => $statGeneral["Homme"])
+            )
+        );
+
+        chart::printCanvas($config);
+        ?>
+    </div>
+    <div class="col-md-5" style="margin-top: 30px;">
+        <h6 class="bg-light p-2">Contrats actifs et non actifs</h6>
+        <?php
+        $config = array(
+            "id" => "statGeneralContratActif",
+            "charts" => "doughnut",
+            "label" => "Contrats actifs (général)",
+            "data" => array(
+                array("label" => "Contrats actifs", "nb" => $statGeneral["ContratOn"]),
+                array("label" => "Contrats en arrêt", "nb" => $statGeneral["ContratOff"])
+            )
+        );
+
+        chart::printCanvas($config);
+        ?>
+    </div>
+</div>

+ 19 - 2
core/views/pages/cms.stats.php

@@ -15,6 +15,9 @@
     <li class="nav-item">
         <a class="nav-link active" data-toggle="tab" id="stats-general-tab" role="tab" aria-selected="true">Général</a>
     </li>
+    <li class="nav-item">
+        <a class="nav-link" data-toggle="tab" id="stats-tous-sites-tab" role="tab">Tous sites confondus</a>
+    </li>
     <li class="nav-item">
         <a class="nav-link" data-toggle="tab" id="stats-an-entree-tab" role="tab">Par année d'entrée</a>
     </li>
@@ -26,14 +29,17 @@
     </li>
 </ul>
 
-<div class="tab-content">
+<div class="tab-content" style="margin-bottom:40px;">
     <div id="tab-stats-general"> 
         <?php get::page("stats-general") ?>
     </div>
+    <div id="tab-stats-tous-sites" style="display: none;"> 
+        <?php get::page("stats-tous-sites") ?>
+    </div>
     <div id="tab-stats-an-entree" style="display: none;"> 
         <?php get::page("stats-an-entree") ?>
     </div>
-    <div id="tab-stats-femmes-hommes" style="display: none;"> 
+    <div id="tab-stats-femmes-hommes" style="display: none;">
         <?php get::page("stats-femmes-hommes") ?>
     </div>
     <div id="tab-stats-contrats" style="display: none;"> 
@@ -45,24 +51,35 @@
     $(document).ready(function(){
         $("#stats-general-tab").click(function() {
             $("#tab-stats-general").show();
+            $("#tab-stats-tous-sites").hide();
+            $("#tab-stats-an-entree").hide();
+            $("#tab-stats-femmes-hommes").hide();
+            $("#tab-stats-contrats").hide();
+        });
+        $("#stats-tous-sites-tab").click(function() {
+            $("#tab-stats-general").hide();
+            $("#tab-stats-tous-sites").show();
             $("#tab-stats-an-entree").hide();
             $("#tab-stats-femmes-hommes").hide();
             $("#tab-stats-contrats").hide();
         });
         $("#stats-an-entree-tab").click(function() {
             $("#tab-stats-general").hide();
+            $("#tab-stats-tous-sites").hide();
             $("#tab-stats-an-entree").show();
             $("#tab-stats-femmes-hommes").hide();
             $("#tab-stats-contrats").hide();
         });
         $("#stats-femmes-hommes-tab").click(function() {
             $("#tab-stats-general").hide();
+            $("#tab-stats-tous-sites").hide();
             $("#tab-stats-an-entree").hide();
             $("#tab-stats-femmes-hommes").show();
             $("#tab-stats-contrats").hide();
         });
         $("#stats-contrats-tab").click(function() {
             $("#tab-stats-general").hide();
+            $("#tab-stats-tous-sites").hide();
             $("#tab-stats-an-entree").hide();
             $("#tab-stats-femmes-hommes").hide();
             $("#tab-stats-contrats").show();