git.ntnlv.ca
Repositories
Help
Report an Issue
lbd.git
Code
Commits
Branches
Tags
Search
Tree:
ab9f122
Branches
Tags
prod
lbd.git
horaire-et-pointage.php
horaire v0.1.0
davvalent
commited
ab9f122
at 2022-05-29 15:41:19
horaire-et-pointage.php
Blame
History
Raw
<?php try { require 'parse-ini.php'; $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $bdd = new PDO( $infos['db_name'], $infos['db_user'], $infos['db_pwd'] ); $bdd->exec("SET CHARACTER SET utf8"); $req = $bdd->prepare('SELECT wplg_posts.ID, post_date AS date, wplg_postmeta.meta_id AS team_meta_id, wplg_postmeta.meta_value AS team_id, abbrev.meta_value AS team_abbreviation FROM wplg_posts INNER JOIN wplg_postmeta ON ID = wplg_postmeta.post_id INNER JOIN (SELECT post_id, meta_value FROM wplg_postmeta WHERE meta_key = "sp_abbreviation") AS abbrev ON abbrev.post_id = wplg_postmeta.meta_value WHERE post_type = "sp_event" AND DATE_FORMAT(post_date,"%Y-%m-%d") = DATE_FORMAT(CURRENT_DATE(),"%Y-%m-%d") # CURRENT_DATE() AND meta_key IN ("sp_team") ORDER BY post_date, meta_id' ); $req->execute(); // tableaux des résultats $raw_data_matchs = $req->fetchAll(PDO::FETCH_ASSOC); $date = date("Y/m/d"); $h1_title = ($raw_data_matchs) ? "Matchs à l’horaire - " . $date : "Pas de matchs à l’horaire aujourd’hui - " . $date; if (!$raw_data_matchs) $match_informations = []; // Fermeture de la requête et de la base de données $req->closeCursor(); $bdd = null; foreach ($raw_data_matchs as $i => $a) { // i est un index; a est un array // match_informations sont des valeurs à afficher $match_informations[$i]["ID"] = $a["ID"]; $match_informations[$i]["date"] = date_format(date_create($a["date"]), "md"); $match_informations[$i]["time"] = date_format(date_create($a["date"]), "Hi"); $is_first_index = ($i == 0) ? 1 : false; $p_ID = ($is_first_index) ?: $match_informations[$i - 1]["ID"]; if ($a["ID"] == $p_ID) $match_informations[$i]["away"] = $raw_data_matchs[$i - 1]["team_abbreviation"]; $match_informations[$i]["home"] = $a["team_abbreviation"]; } foreach ($match_informations as $key => $value) { if ($key - 1 < 0) continue; if ($value["ID"] == $match_informations[$key - 1]["ID"]) unset($match_informations[$key - 1]); } } catch(Exception $e) { die('Erreur : ' . $e->getMessage()); } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="fr-CA"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>Horaire et pointage - LBD</title> <style> * { box-sizing: border-box; } html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; } body { line-height: 1.5; background-color: #f9f9f9; color: #4a4a4a; font-size: 1.5rem; margin: 0; } h1 { font-size: 1.5rem; padding: 10px; } table { width: 100%; border-collapse: collapse; } tr:nth-child(4n+1), tr:nth-child(4n+2) { background: #e6e6e6; } td { border: 2px solid grey; position: relative; font-weight: 700; } td div { width: 100%; text-align: center; } td.date-heure div:first-of-type, td.away-home div:first-of-type { color: grey; top : 0; text-align: left; padding-left: 4px; font-size: 1.15rem; font-weight: normal; } td.date-heure div:first-of-type { position: absolute; } td.away-home div:first-of-type { position: relative; } </style> </head> <body> <h1><?=$h1_title;?></h1> <table> <?php foreach($match_informations as $mi): ?> <tr> <td class="away-home"> <div>Visiteur</div> <div><?=$mi["away"];?></div> </td> <td class="date-heure" rowspan="2"> <div>Date</div> <div><?=$mi["date"];?></div> </td> <td class="date-heure" rowspan="2"> <div>Heure</div> <div><?=$mi["time"];?></div> </td> </tr> <tr> <td class="away-home"> <div>Domicile</div> <div><?=$mi["home"];?></div> </td> </tr> <?php endforeach; ?> <table> </body> </html> <?php/* var_dump($raw_data_matchs); var_dump($match_informations); */?>