forked from vergnet/site-accueil-insa
patch
This commit is contained in:
parent
6362bf9fc3
commit
9b272f48f7
1 changed files with 39 additions and 39 deletions
78
planning.php
78
planning.php
|
@ -215,52 +215,52 @@ if(isset($_GET['planning']) AND !empty(['planning']))
|
||||||
//début download planning avec php2ics (doc ici => https://github.com/baptistereb/php2ics)
|
//début download planning avec php2ics (doc ici => https://github.com/baptistereb/php2ics)
|
||||||
include("assets/script/php2ics.php");
|
include("assets/script/php2ics.php");
|
||||||
|
|
||||||
$cal = new php2ics("accueil_insa", "voila les loustiks");
|
|
||||||
|
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
|
for($day = 1; $day <= 7; $day++) { //on tourne sur les 7 jours
|
||||||
$hours_beginning = (int) 7; //commence à 7h tout les matin
|
$hours_beginning = (int) 7; //commence à 7h tout les matin
|
||||||
$day_beginning = (int) 5; //commence le 5 septembre (premier jour = 5 septembre)
|
$day_beginning = (int) 5; //commence le 5 septembre (premier jour = 5 septembre)
|
||||||
|
|
||||||
$hours = $hours_beginning;
|
$hours = $hours_beginning;
|
||||||
$minute = 0;
|
$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");
|
||||||
|
|
||||||
$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");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$cal->End();
|
$cal->End();
|
||||||
//echo $cal->GetICS();
|
|
||||||
if(isset($_POST['download_planning'])) {
|
|
||||||
$cal->DownloadICS("planning_semaine_accueil_insa_toulouse");
|
$cal->DownloadICS("planning_semaine_accueil_insa_toulouse");
|
||||||
}
|
}
|
||||||
//fin download planning
|
//fin download planning
|
||||||
|
|
Loading…
Reference in a new issue