예제 #1
0
 public function delete()
 {
     $sql = "DELETE FROM edt_calendrier_manager WHERE id = '" . $this->id . "' ";
     $req = mysqli_query($GLOBALS["mysqli"], $sql);
     if ($req) {
         // ======== Suppression des périodes calendaires
         $PeriodesCalendaires = new PeriodeCalendaire();
         $PeriodesCalendaires->id_calendar = $this->id;
         if ($PeriodesCalendaires->deleteCalendar()) {
             // ========= Suppression des liaisons classes <-> calendar
             $jointure = new jointure_calendar_classes();
             $jointure->id_calendar = $this->id;
             if ($jointure->delete_classes()) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
예제 #2
0
파일: calendar.php 프로젝트: rhertzog/lcs
 public static function getFrontiersPeriodID(&$debut, &$fin, $id)
 {
     $period = PeriodeCalendaire::getPeriods(null);
     if (1 <= date("n") and date("n") <= 8) {
         $annee = date("Y");
     } else {
         $annee = date("Y") + 1;
     }
     $ts = mktime(0, 0, 0, 1, 4, $annee);
     // définition ISO de la semaine 01 : semaine du 4 janvier.
     while (date("D", $ts) != "Mon") {
         $ts -= 86400;
     }
     $ts_max = $ts + 86400 * 7 * 36;
     $semaine = calendar::getNumLastWeek();
     $ts_ref = $ts;
     while ($semaine >= 33) {
         $ts -= 86400 * 7;
         $semaine--;
     }
     // =====================================================
     $i = 1;
     $j = 0;
     $stop = false;
     while ($period['id'][$j] != $id) {
         $j++;
     }
     while ($ts <= $ts_max && !$stop) {
         $ts_sup = $ts + 86400 - 1;
         if ($ts == $period['debut'][$j]) {
             $debut[] = $i;
             while ($period['fin'][$j] > $ts) {
                 $ts += 86400;
                 $i++;
                 if (($i - 1) % 6 == 0) {
                     $ts += 86400;
                 }
             }
             $fin[] = $i;
             $stop = true;
         } else {
             $ts += 86400;
             $i++;
             if (($i - 1) % 6 == 0) {
                 $ts += 86400;
             }
         }
     }
 }
예제 #3
0
 public function launch(Request $request, Response $response)
 {
     $message = null;
     $new_name = null;
     $delete_confirmation = null;
     if ($_SESSION['statut'] == "administrateur") {
         if ($request->getParam('operation')) {
             check_token(false);
             if ($request->getParam('operation') == "delete") {
                 if ($request->getParam('confirm_delete')) {
                     if ($request->getParam('id_calendrier')) {
                         $calendrier = new Calendrier();
                         $calendrier->id = $request->getParam('id_calendrier');
                         if (!$calendrier->delete()) {
                             $message = "Impossible de supprimer le calendrier";
                         }
                     }
                 } else {
                     if ($request->getParam('id_calendrier')) {
                         $delete_confirmation = "<form action=\"index.php?action=calendriermanager\" method=\"post\">" . add_token_field(false) . "\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"operation\" type=\"hidden\" value=\"delete\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"id_calendrier\" type=\"hidden\" value=\"" . $request->getParam('id_calendrier') . "\">\r\n\t\t\t\t\t\t\t\t\t\t\t<p>La suppression d'un calendrier entraîne la suppression de toutes les périodes calendaires qui en dépendent !</p>\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"confirm_delete\" type=\"submit\" style=\"width:200px;\" value=\"Confirmer la suppression\">\r\n\t\t\t\t\t\t\t\t\t\t</form>";
                     }
                 }
             } else {
                 if ($request->getParam('operation') == "new") {
                     if ($request->getParam('nom_calendrier')) {
                         $calendrier = new Calendrier();
                         $calendrier->nom = $request->getParam('nom_calendrier');
                         if (!$calendrier->save()) {
                             $message = "Impossible de créer le calendrier";
                         }
                     }
                 } else {
                     if ($request->getParam('operation') == "modify_name") {
                         if ($request->getParam('new_name')) {
                             $calendrier = new Calendrier();
                             $calendrier->nom = $request->getParam('new_name');
                             $calendrier->id = $request->getParam('id_calendrier');
                             if (!$calendrier->update()) {
                                 $message = "Impossible de modifier le nom du calendrier";
                             }
                         } else {
                             if ($request->getParam('id_calendrier')) {
                                 $new_name = "<form action=\"index.php?action=calendriermanager\" method=\"post\">" . add_token_field(false) . "\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"operation\" type=\"hidden\" value=\"modify_name\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"id_calendrier\" type=\"hidden\" value=\"" . $request->getParam('id_calendrier') . "\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"new_name\" type=\"text\" style=\"width:200px;\" value=\"" . Calendrier::getNom($request->getParam('id_calendrier')) . "\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"bouton_valider_new_name\" type=\"submit\" style=\"width:200px;\" value=\"Modifier le nom du calendrier\">\r\n\t\t\t\t\t\t\t\t\t\t</form>";
                             }
                         }
                     } else {
                         if ($request->getParam('operation') == "edit_classes") {
                             if ($request->getParam('id_calendrier')) {
                                 $id_calendrier = $request->getParam('id_calendrier');
                                 $jointure = new jointure_calendar_classes();
                                 $periodes = new PeriodeCalendaire();
                                 $classe = new Classe();
                                 $jointure->id_calendar = $id_calendrier;
                                 $jointure->delete_classes();
                                 if ($request->getParam('classes_' . $id_calendrier)) {
                                     $liste_classes = null;
                                     foreach ($request->getParam('classes_' . $id_calendrier) as $id_classe) {
                                         $classe->id = $id_classe;
                                         $liste_classes .= $classe->getShortName() . ";";
                                         $jointure->id_classe = $id_classe;
                                         if (!$jointure->save_classe()) {
                                             $message .= "Une classe est déjà affectée dans un autre calendrier<br/>";
                                         }
                                     }
                                     // ================ Compatibilité pour les autres modules GEPi
                                     $periodes->id_calendar = $id_calendrier;
                                     $periodes->classes_concernees = $liste_classes;
                                     $periodes->update_classes();
                                 }
                             }
                         }
                     }
                 }
             }
         }
         calendar::updateTables();
     }
     $response->addVar('delete_confirmation', $delete_confirmation);
     $response->addVar('new_name', $new_name);
     $response->addVar('message', $message);
     $response->addVar('NomPeriode', calendar::getPeriodName(time()));
     $response->addVar('TypeSemaineCourante', calendar::getTypeCurrentWeek());
     $response->addVar('SemaineCourante', calendar::getCurrentWeek());
     $response->addVar('calendrier', calendar::GenerateCalendarList());
     $this->render("./lib/template/calendriermanagerSuccess.php");
     $this->printOut();
 }
예제 #4
0
 public function insertPeriod(&$content, Request $request)
 {
     if ($request->getParam('periodname')) {
         $content .= "nom de la periode :" . $request->getParam('periodname');
         if ($request->getParam('firstday')) {
             if ($request->getParam('lastday')) {
                 if ($request->getParam('lastday') > $request->getParam('firstday')) {
                     $lastday = $request->getParam('lastday');
                     $firstday = $request->getParam('firstday');
                 } else {
                     $lastday = $request->getParam('firstday');
                     $firstday = $request->getParam('lastday');
                 }
                 $PeriodeCalendaire = new PeriodeCalendaire();
                 $PeriodeCalendaire->nom = $request->getParam('periodname');
                 $result = calendar::getDayNumber($firstday);
                 $PeriodeCalendaire->debut_ts = $result['timestamp'];
                 $PeriodeCalendaire->jourdebut = $result['day'];
                 $PeriodeCalendaire->heuredebut = "00:00:00";
                 $result = calendar::getDayNumber($lastday);
                 $PeriodeCalendaire->fin_ts = $result['timestamp'];
                 $PeriodeCalendaire->jourfin = $result['day'];
                 $PeriodeCalendaire->heurefin = "23:59:00";
                 $PeriodeCalendaire->periode_note = $request->getParam('periode_notes');
                 $PeriodeCalendaire->etabvacances = $request->getParam('type');
                 $PeriodeCalendaire->etabferme = $request->getParam('ouvert');
                 $PeriodeCalendaire->id_calendar = $request->getParam('id_calendar');
                 if ($PeriodeCalendaire->insertable()) {
                     if (!$PeriodeCalendaire->save()) {
                         $content = "error Impossible d'enregistrer la période";
                     } else {
                         $content = "success";
                     }
                 } else {
                     $content = "error Les p&eacute;riodes ne peuvent pas se chevaucher";
                 }
             }
         }
     } else {
         $content = "error Veuillez entrer un nom de période";
     }
 }