2022-01-19 22:26:58 +01:00
|
|
|
<?php
|
2020-09-19 16:08:07 +02:00
|
|
|
ob_start(); // Start reading html
|
2022-06-16 20:18:06 +02:00
|
|
|
|
|
|
|
include "script/db.php";
|
|
|
|
|
|
|
|
if(isset($_GET['planning']) AND !empty(['planning']))
|
|
|
|
{
|
|
|
|
$planning = (int) htmlspecialchars($_GET['planning']);
|
2022-06-16 23:05:10 +02:00
|
|
|
} else {
|
2022-07-31 20:08:32 +02:00
|
|
|
header('Location: planning.php?planning=1');
|
2022-06-16 20:18:06 +02:00
|
|
|
}
|
2022-06-19 17:19:07 +02:00
|
|
|
|
2020-09-19 16:08:07 +02:00
|
|
|
?>
|
2022-06-16 20:18:06 +02:00
|
|
|
<main>
|
|
|
|
|
|
|
|
<div class="box-jaune">
|
|
|
|
<span class="corners corners-top"></span>
|
|
|
|
<span class="corners corners-bottom"></span>
|
|
|
|
|
|
|
|
<div class="title">Planning</div>
|
|
|
|
|
|
|
|
<span class="circles circles-top"></span>
|
|
|
|
<span class="circles circles-bottom"></span>
|
|
|
|
</div>
|
2022-07-10 10:34:35 +02:00
|
|
|
<!--
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/////// Le lien de cette page est modifiable ^^ ////////////
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
-->
|
2020-09-19 16:08:07 +02:00
|
|
|
|
2022-06-19 17:19:07 +02:00
|
|
|
<?php if(isset($planning)) { ?>
|
|
|
|
|
|
|
|
<div id="planning-container" class="planning-container" selected="0">
|
|
|
|
|
|
|
|
<div id="days" class="column days">
|
|
|
|
<div class="day_title">Jour</div>
|
|
|
|
|
|
|
|
<div class="day day0">L</div>
|
|
|
|
<div class="day day1">Ma</div>
|
|
|
|
<div class="day day2">Me</div>
|
|
|
|
<div class="day day3">J</div>
|
|
|
|
<div class="day day4">V</div>
|
|
|
|
<div class="day day5">S</div>
|
|
|
|
<div class="day day6">D</div>
|
|
|
|
|
|
|
|
<script defer>
|
|
|
|
|
|
|
|
const daysPLA = document.getElementsByClassName("day");
|
|
|
|
const containerPLA = document.getElementById("planning-container");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < daysPLA.length; i++) {
|
|
|
|
const day = daysPLA[i];
|
|
|
|
day.addEventListener("click", (e) => {
|
|
|
|
let number = day.classList.item(1).charAt(3)
|
|
|
|
containerPLA.setAttribute("selected", number)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="column time">
|
|
|
|
|
|
|
|
<div class="day_title">Heure</div>
|
|
|
|
<div class="hour">07</div>
|
|
|
|
<div class="hour">08</div>
|
|
|
|
<div class="hour">09</div>
|
|
|
|
<div class="hour">10</div>
|
|
|
|
|
|
|
|
<div class="hour">11</div>
|
|
|
|
<div class="hour">12</div>
|
|
|
|
<div class="hour">13</div>
|
|
|
|
<div class="hour">14</div>
|
|
|
|
<div class="hour">15</div>
|
|
|
|
|
|
|
|
<div class="hour">16</div>
|
|
|
|
<div class="hour">17</div>
|
|
|
|
<div class="hour">18</div>
|
|
|
|
<div class="hour">19</div>
|
|
|
|
<div class="hour">20</div>
|
|
|
|
|
|
|
|
<div class="hour">21</div>
|
|
|
|
<div class="hour">22</div>
|
|
|
|
<div class="hour">23</div>
|
|
|
|
<div class="hour">00</div>
|
|
|
|
<div class="hour">01</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="lundi" class="column lundi">
|
|
|
|
<div class="day_title">L</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 1 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 12:23:48 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="mardi" class="column mardi">
|
|
|
|
<div class="day_title">Ma</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 2 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 20:07:44 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="mercredi" class="column mercredi">
|
|
|
|
<div class="day_title">Me</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 3 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 20:07:44 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="jeudi" class="column jeudi">
|
|
|
|
<div class="day_title">J</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 4 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 20:07:44 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="vendredi" class="column vendredi">
|
|
|
|
<div class="day_title">V</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 5 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 20:07:44 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="samedi" class="column samedi">
|
|
|
|
<div class="day_title">S</div>
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 6 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 20:07:44 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="dimanche" class="column dimanche">
|
|
|
|
<div class="day_title">D</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// For every planned activity on day 0
|
2022-06-19 18:09:31 +02:00
|
|
|
$req1 = $db->prepare('SELECT title, description, color, length FROM planning_insa WHERE day = 7 AND num_planning = ? ORDER BY order_start ASC');
|
2022-06-19 17:28:22 +02:00
|
|
|
$req1->execute(array($planning));
|
2022-06-19 17:19:07 +02:00
|
|
|
while($r1 = $req1->fetch()) {
|
|
|
|
?>
|
2022-07-31 20:07:44 +02:00
|
|
|
<div class="class" data-description="<?=$r1['description']?>" style="background-color: <?= $r1['color'] ?>; height: <?= $r1['length'] ?>vh;">
|
2022-06-19 17:19:07 +02:00
|
|
|
<?= $r1['title'] ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2022-08-15 21:12:36 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
//début download planning avec php2ics (doc ici => https://github.com/baptistereb/php2ics)
|
|
|
|
include("assets/script/php2ics.php");
|
|
|
|
|
2022-08-15 21:14:48 +02:00
|
|
|
|
|
|
|
if(isset($_POST['download_planning'])) {
|
|
|
|
$cal = new php2ics("accueil_insa", "voila les loustiks");
|
|
|
|
|
|
|
|
for($day = 1; $day <= 7; $day++) { //on tourne sur les 7 jours
|
|
|
|
$hours_beginning = (int) 7; //commence à 7h tout les matin
|
|
|
|
$day_beginning = (int) 5; //commence le 5 septembre (premier jour = 5 septembre)
|
|
|
|
|
|
|
|
$hours = $hours_beginning;
|
|
|
|
$minute = 0;
|
|
|
|
|
|
|
|
$reqcal = $db->prepare('SELECT id,title, description, length FROM planning_insa WHERE day = ? AND num_planning = ? ORDER BY order_start ASC');
|
|
|
|
$reqcal->execute(array($day, $planning));
|
|
|
|
while($c = $reqcal->fetch()) {
|
|
|
|
//le planning commence à $hours_beginning le $day_beginning et sous forme : date('Y-m-d H:i:s')
|
|
|
|
if($c['title'] == " ") { //si le titre est vide c'est qu'il n'y a rien
|
|
|
|
$time = (float) $c['length']/4.1;
|
|
|
|
$hours += floor($time);
|
|
|
|
$minute += 60*($time-floor($time));
|
|
|
|
} else {
|
|
|
|
$begin_hours = $hours;
|
|
|
|
$begin_min = $minute;
|
|
|
|
$time = (float) $c['length']/4.1;
|
|
|
|
$hours += floor($time);
|
|
|
|
$minute += round(60*($time-floor($time)),3);
|
|
|
|
while($minute >= 60) {
|
|
|
|
$minute -= 60;
|
|
|
|
$hours++;
|
|
|
|
}
|
|
|
|
while($hours >= 24) {
|
|
|
|
$hours --; //bon la on tronque entre les jours sinon c'est hyper relou à coder pour rien
|
|
|
|
}
|
|
|
|
|
|
|
|
//pour tester décommenter la ligne juste en dessous
|
|
|
|
//echo $c['title'].": ".$begin_hours.'h'.$begin_min.'m to :'.$hours.'h'.$minute.'m<br>';
|
|
|
|
|
|
|
|
//mktime => hours, minute, second, month, day, year
|
|
|
|
$btime = mktime($begin_hours, $begin_min, 0, 9, $day_beginning+$day-1, 2022);
|
|
|
|
$etime = mktime($hours, $minute, 0, 9, $day_beginning+$day-1, 2022);
|
|
|
|
$cal->AddEvent($c['title'], $c['description'], $btime, $etime, "INSA Toulouse", "https://etud.insa-toulouse.fr/~accueil_insa/planning.php");
|
2022-08-15 21:12:36 +02:00
|
|
|
|
2022-08-15 21:14:48 +02:00
|
|
|
}
|
2022-08-15 21:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-15 21:14:48 +02:00
|
|
|
$cal->End();
|
2022-08-15 21:12:36 +02:00
|
|
|
$cal->DownloadICS("planning_semaine_accueil_insa_toulouse");
|
|
|
|
}
|
|
|
|
//fin download planning
|
|
|
|
?>
|
|
|
|
|
2022-08-15 21:22:36 +02:00
|
|
|
<!--<form method="POST">
|
2022-08-15 21:12:36 +02:00
|
|
|
<input type="submit" name="download_planning" value="télécharger le planning" class="submit">
|
2022-08-15 21:22:36 +02:00
|
|
|
</form>-->
|
2022-08-15 21:12:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-31 12:23:48 +02:00
|
|
|
<!-- needed for showing custom alert -->
|
|
|
|
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
const pln_cases = document.getElementsByClassName("class");
|
|
|
|
for (let i = 0; i < pln_cases.length; i++) {
|
|
|
|
let current = pln_cases[i];
|
|
|
|
|
|
|
|
current.addEventListener("click", (e) => {
|
|
|
|
Swal.fire({
|
|
|
|
title: '<strong id="modal-title">' + current.innerHTML.trim() + '</strong>',
|
|
|
|
html: current.dataset.description
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2022-06-19 17:19:07 +02:00
|
|
|
<?php } else { ?>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
Clique sur le planning que tu souhaites visionner : <br>
|
|
|
|
<font color="red">On les a pas encore en fait</font>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
|
2022-06-16 20:18:06 +02:00
|
|
|
</main>
|
2022-06-19 17:19:07 +02:00
|
|
|
|
2020-09-19 16:08:07 +02:00
|
|
|
<?php
|
2022-01-19 22:26:58 +01:00
|
|
|
$infopage = ["", "Planning", ob_get_clean(), "", "planning"]; //relativepath, pagetitle, pagecontent, pagescript, pagename | cf structure/template.php ligne 2 à 6
|
|
|
|
include("structure/template.php");
|
|
|
|
?>
|