<?php require_once "../model/session.php"; require_once '../model/models.php'; $controllerCalled = 1; $report = new Model(); $listReport = ""; if (isset($_POST['id'])) { $_SESSION["report-list"] = array("id" => '', "key" => ''); $_SESSION["report-list"]['id'] = json_decode($_POST['id'], true); $_SESSION["report-list"]['key'] = json_decode($_POST['key'], true); } if (!empty($_SESSION["report-list"]['id']) && !empty($_SESSION["report-list"]['key'])) { $listReport = $report->dynamicSelectAll("tours", "id IN(" . implode(',', $_SESSION["report-list"]['id']) . ")", implode(',', $_SESSION["report-list"]['key'])); } $company = $report->_list("company", "*")[0]; for ($i = 0; $i < sizeof($listReport); $i++) { foreach ($listReport[$i] as $key => $value) { if ($key == "guardtours_id") { $guardtours_id = $listReport[$i][$key]; $guard_id = $report->getBy("guardtours", "guard_id", "id", $guardtours_id); $nom = $report->getBy("guard", "nom", "id", $guard_id); $prenom = $report->getBy("guard", "prenom", "id", $guard_id); $listReport[$i][$key] = $nom . " " . $prenom; } if ($key == "mention") { if ($listReport[$i][$key] == "#dd5826") { $listReport[$i][$key] = "Bad"; } if ($listReport[$i][$key] == "#f0b518") { $listReport[$i][$key] = "Warning";
public static function listDataFK() { $model = new Model(); $stmt = $model->query("SELECT poste_id FROM `guardtours` GROUP BY poste_id HAVING COUNT(poste_id)>1"); $guardpost = $stmt->fetchAll(PDO::FETCH_ASSOC); $guard_ = $model->_list("guardtours", "guard_id"); $array = array("poste_id" => array(), "guard_id" => array()); for ($i = 0; $i < sizeof($guardpost); $i++) { foreach ($guardpost[$i] as $key => $value) { $array[$key][] = $value; } } for ($i = 0; $i < sizeof($guard_); $i++) { foreach ($guard_[$i] as $key => $value) { $array[$key][] = $value; } } $postAdress = $model->dynamicSelectAll("poste", "id NOT IN(" . implode(',', $array['poste_id']) . ")", "adress, nom"); $guardId = $model->dynamicSelectAll("guard", "id NOT IN(" . implode(',', $array['guard_id']) . ")", "uid, nom, prenom"); $array['poste_id'] = $postAdress; $array['guard_id'] = $guardId; return $array; }
<?php require_once "../model/session.php"; $model = new Model(); $controllerCalled = 1; $date = date("Y-m-d"); $guardSuccess = $model->count("tours", "mention = '#555' AND date_tour='" . $date . "'"); $guardBad = $model->count("tours", "mention='#dd5826' AND date_tour='" . $date . "'"); $guardWarning = $model->count("tours", "mention='#f0b518' AND date_tour='" . $date . "'"); $nbGuard = $model->count("tours", "date_tour='" . $date . "'"); $list = $model->dynamicSelectAll("tours", "date_tour='" . $date . "'", "*"); // echo "-------------------------------------------------------------"; // print_r($list); // echo "-------------------------------------------------------------"; // echo $date; if ($nbGuard != 0) { $pSuccess = round(doubleval($guardSuccess * 100) / $nbGuard, 2); $pWarning = round(doubleval($guardWarning * 100) / $nbGuard, 2); $pDanger = round(doubleval($guardBad * 100) / $nbGuard, 2); } else { $pSuccess = 0; $pWarning = 0; $pDanger = 0; } include "../vue/dashboard.php";