function testPhotoPng() { $a = new Activite(); $a->slug = 'imagick-png'; $a->debut = new Zend_Db_Expr('CURRENT_TIMESTAMP'); $a->fin = new Zend_Db_Expr('CURRENT_TIMESTAMP'); $a->save(); $c = new Commentaire(); $c->message = ''; $c->save(); $o = new Photo(); $o->activite = $a->id; $o->commentaires = $c->id; $o->slug = 'photo-png'; $o->storeFile(dirname(__FILE__) . '/images/transparente.png'); }
public function insert($param) { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': if (isset($_SESSION['user'])) { $this->load->model("Activite"); $jour = substr($param, 0, 2); $mois = substr($param, 2, 2); $annee = substr($param, 4, 4); $heureDebut = substr($param, 8, 2)[0] == '0' ? substr($param, 9, 1) . 'h' : substr($param, 8, 2) . 'h'; $heureFin = substr($param, 10, 2)[0] == '0' ? substr($param, 11, 1) . 'h' : substr($param, 10, 2) . 'h'; $activites = Activite::getAll(); $date = new \DateTime($annee . '-' . $mois . '-' . $jour); setlocale(LC_TIME, 'fr_FR.utf8', 'fra'); $titre = ucfirst(strftime("%A", $date->getTimestamp())) . ' ' . $date->format('d') . ' ' . ucfirst(strftime("%B", $date->getTimestamp())) . ' - ' . $heureDebut . '-' . $heureFin; $data['titre'] = $titre; $data["hidden"] = $date->format('Y-m-d') . '|' . $heureDebut . ':' . $heureFin; $data['activites'] = $activites; $this->load->view("ajoutActiviteAgenda", $data); } else { $_SESSION['messagee'] = "Erreur, accès refusé"; header('Location: ' . BASEURL); exit; } break; case 'POST': if (isset($_SESSION['user']) && isset($_POST['redondance']) && $_POST['redondance'] != null) { $this->load->model("Agenda"); $dateHeure = preg_split('/[|]/', $_POST['dateDebut']); $dateDebut = new \DateTime($dateHeure[0] . '00:00:01'); $redondance = $_POST['redondance']; $dateFin = date_modify(new \DateTime($dateHeure[0] . '23:59:59'), "+ " . $redondance . ' week'); $hDebut = preg_split('/[:]/', $dateHeure[1])[0]; $heureMinuteSecondeDebut = preg_split('/h/', $hDebut); $hFin = preg_split('/[:]/', $dateHeure[1])[1]; $heureMinuteSecondeFin = preg_split('/h/', $hFin); $heureDebut = $heureMinuteSecondeDebut[1] != "" ? $heureMinuteSecondeDebut[0] . ':' . $heureMinuteSecondeDebut[1] . ':00' : $heureMinuteSecondeDebut[0] . ':00:00'; $heureFin = $heureMinuteSecondeFin[1] != "" ? $heureMinuteSecondeFin[0] . ':' . $heureMinuteSecondeFin[1] . ':00' : $heureMinuteSecondeFin[0] . ':00:00'; $idActivite = $_POST['activite']; $jour = $dateDebut->format('N'); $ajoutActivite = new Agenda(null, $idActivite, $dateDebut->format("Y-m-d H:i:s"), $dateFin->format("Y-m-d H:i:s"), $jour, $heureDebut, $heureFin); $ajoutActivite->create(); header('Location: ' . base_url() . '/index.php/agendaActivite/gestion'); exit; } break; } }
public static function add_pause($idActivite, $idUser) { switch ($_SERVER['REQUEST_METHOD']) { case 'POST': if (isset($_SESSION['user'])) { $date_debut = date_create_from_format('Y-n-j?H:i', $_POST['datedebpause']); $date_debut_ts = $date_debut->format('U'); $heure_debut = $date_debut->format('H'); $jour_debut = $date_debut->format('j'); $mois_debut = $date_debut->format('n'); $annee_debut = $date_debut->format('Y'); $date_debut = $date_debut->format('Y-n-j H'); $date_fin = date_create_from_format('Y-n-j?H:i', $_POST['datefinpause']); $date_fin_ts = $date_fin->format('U'); $heure_fin = $date_fin->format('H'); $jour_fin = $date_fin->format('j'); $mois_fin = $date_fin->format('n'); $annee_fin = $date_fin->format('Y'); $date_fin = $date_fin->format('Y-n-j H'); if (empty($_POST['periodicite'])) { $periodicite = 'P'; } else { $periodicite = $_POST['periodicite']; } if (empty($_POST['occurences'])) { $occ = 0; } else { $occ = $_POST['occurences']; } $pause = new Pause(1, $idActivite, $date_debut, $date_fin, $periodicite, $occurences); $act = Activite::get_by_id($idActivite); $activites = Activite::get_by_idUtilisateurAgendaDateSimilaire($idUser, $act->idAgenda(), $act->idSimilaire(), $date_debut, $date_fin); for ($i = 0; $i < count($activites); $i++) { $activites[$i]->delete(); } if ($occ > 1) { if ($periodicite == 'J') { while ($occ > 1) { $nb_jours = date("t", $date_debut_ts); if ($jour_debut + 1 > $nb_jours) { if ($mois_debut >= 12) { $mois_debut = 1; $annee_debut = $annee_debut + 1; } else { $mois_debut = $mois_debut + 1; } $jour_debut = $jour_debut + 1 - $nb_jours; } else { $jour_debut = $jour_debut + 1; } $nb_jours = date("t", $date_fin_ts); if ($jour_fin + 1 > $nb_jours) { if ($mois_fin >= 12) { $mois_fin = 1; $annee_fin = $annee_fin + 1; } else { $mois_fin = $mois_fin + 1; } $jour_fin = $jour_fin + 1 - $nb_jours; } else { $jour_fin = $jour_fin + 1; } $date_debut_ts = date('U', mktime(0, 0, 0, $mois_debut, $jour_debut, $annee_debut)); $date_fin_ts = date('U', mktime(0, 0, 0, $mois_fin, $jour_fin, $annee_fin)); $date_debut = date('Y-n-j H', mktime($heure_debut, 0, 0, $mois_debut, $jour_debut, $annee_debut)); $date_fin = date('Y-n-j H', mktime($heure_fin, 0, 0, $mois_fin, $jour_fin, $annee_fin)); $occ = $occ - 1; $activites = Activite::get_by_idUtilisateurAgendaDateSimilaire($idUser, $act->idAgenda(), $act->idSimilaire(), $date_debut, $date_fin); for ($i = 0; $i < count($activites); $i++) { $activites[$i]->delete(); } } } else { if ($periodicite == 'S') { while ($occ > 1) { $nb_jours = date("t", $date_debut_ts); if ($jour_debut + 7 > $nb_jours) { if ($mois_debut >= 12) { $mois_debut = 1; $annee_debut = $annee_debut + 1; } else { $mois_debut = $mois_debut + 1; } $jour_debut = $jour_debut + 7 - $nb_jours; } else { $jour_debut = $jour_debut + 7; } $nb_jours = date("t", $date_fin_ts); if ($jour_fin + 7 > $nb_jours) { if ($mois_fin >= 12) { $mois_fin = 1; $annee_fin = $annee_fin + 1; } else { $mois_fin = $mois_fin + 1; } $jour_fin = $jour_fin + 7 - $nb_jours; } else { $jour_fin = $jour_fin + 7; } $date_debut_ts = date('U', mktime(0, 0, 0, $mois_debut, $jour_debut, $annee_debut)); $date_fin_ts = date('U', mktime(0, 0, 0, $mois_fin, $jour_fin, $annee_fin)); $date_debut = date('Y-n-j H', mktime($heure_debut, 0, 0, $mois_debut, $jour_debut, $annee_debut)); $date_fin = date('Y-n-j H', mktime($heure_fin, 0, 0, $mois_fin, $jour_fin, $annee_fin)); $occ = $occ - 1; $activites = Activite::get_by_idUtilisateurAgendaDateSimilaire($idUser, $act->idAgenda(), $act->idSimilaire(), $date_debut, $date_fin); for ($i = 0; $i < count($activites); $i++) { $activites[$i]->delete(); } } } else { if ($periodicite == 'M') { while ($occ > 1) { if ($mois_debut >= 12) { $mois_debut = 1; $annee_debut = $annee_debut + 1; } else { $mois_debut = $mois_debut + 1; } if ($mois_fin >= 12) { $mois_fin = 1; $annee_fin = $annee_fin + 1; } else { $mois_fin = $mois_fin + 1; } $date_debut = date('Y-n-j H', mktime($heure_debut, 0, 0, $mois_debut, $jour_debut, $annee_debut)); $date_fin = date('Y-n-j H', mktime($heure_fin, 0, 0, $mois_fin, $jour_fin, $annee_fin)); $occ = $occ - 1; $activites = Activite::get_by_idUtilisateurAgendaDateSimilaire($idUser, $act->idAgenda(), $act->idSimilaire(), $date_debut, $date_fin); for ($i = 0; $i < count($activites); $i++) { $activites[$i]->delete(); } } } else { if ($periodicite == 'A') { while ($occ > 1) { $annee_debut = $annee_debut + 1; $annee_fin = $annee_fin + 1; $date_debut = date('Y-n-j H', mktime($heure_debut, 0, 0, $mois_debut, $jour_debut, $annee_debut)); $date_fin = date('Y-n-j H', mktime($heure_fin, 0, 0, $mois_fin, $jour_fin, $annee_fin)); $occ = $occ - 1; $activites = Activite::get_by_idUtilisateurAgendaDateSimilaire($idUser, $act->idAgenda(), $act->idSimilaire(), $date_debut, $date_fin); for ($i = 0; $i < count($activites); $i++) { $activites[$i]->delete(); } } } } } } } include 'views/pause.php'; } else { $_SESSION['message']['type'] = 'error'; $_SESSION['message']['text'] = "You aren't connected"; include 'views/connexion.php'; } break; case 'GET': if (isset($_SESSION['user'])) { include 'views/pause.php'; } else { $_SESSION['message']['type'] = 'error'; $_SESSION['message']['text'] = "You aren't connected"; include 'views/connexion.php'; } break; } }
public function suppParent() { $this->load->model("Activite"); Activite::delete($_POST['idSuppActivite']); }
public function actualise_date_maintenant() { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': //si l'utilisateur est connecté on affiche la page de création d'une note if (isset($_SESSION['user'])) { $jour = date("w"); $_SESSION['mois'] = date("n"); $_SESSION['jour'] = date("j"); $_SESSION['annee'] = date("y"); $dateDebSemaineFr = date("Y-n-j H:i:s", mktime(0, 0, 0, $_SESSION['mois'], $_SESSION['jour'] - $jour + 1, $_SESSION['annee'])); $datePrecise = date("Y-n-j H:i:s", mktime(0, 0, 0, $_SESSION['mois'], $_SESSION['jour'], $_SESSION['annee'])); $dateFinSemaineFr = date("Y-n-j H:i:s", mktime(23, 59, 0, $_SESSION['mois'], $_SESSION['jour'] - $jour + 7, $_SESSION['annee'])); $abonnement = Abonnement::get_by_user($_SESSION['idUser']); $mes_agendas = Agenda::get_by_user_login($_SESSION['user']); $all_agendas = array(); $abonnements = array(); for ($i = 0; $i < count($mes_agendas); $i++) { $all_agendas[] = Agenda::get_by_id($mes_agendas[$i]->idAgenda()); } for ($i = 0; $i < count($abonnement); $i++) { $abonnements[] = Agenda::get_by_id($abonnement[$i]->idAgenda()); $all_agendas[] = Agenda::get_by_id($abonnement[$i]->idAgenda()); } if (!empty($all_agendas)) { $activites = Activite::get_by_idUtilisateurAgendaDate($all_agendas[$_SESSION['num']]->idUtilisateur(), $all_agendas[$_SESSION['num']]->idAgenda(), $dateDebSemaineFr, $dateFinSemaineFr); for ($m = 0; $m < count($activites); $m++) { for ($l = 0; $l < 24; $l++) { for ($k = 0; $k < 7; $k++) { $date_deb_inter = date_create_from_format('Y-n-j H:i:s', $activites[$m]->dateDeb()); $date_fin_inter = date_create_from_format('Y-n-j H:i:s', $activites[$m]->dateFin()); $date_debsem_inter = date_create_from_format('Y-n-j H:i:s', $dateDebSemaineFr); if ($date_deb_inter->format('G') <= $l && $date_fin_inter->format('G') > $l && $date_deb_inter->format('j') == $date_debsem_inter->format('j') + $k) { $heure_jour[$l][$k] = $activites[$m]; } } } } } include 'views/calendar.php'; } else { $_SESSION['message']['type'] = 'error'; $_SESSION['message']['text'] = "Vous n'êtes pas connecté"; include 'views/connexion.php'; } break; case 'POST': if (isset($_SESSION['user'])) { } else { $_SESSION['message']['type'] = 'error'; $_SESSION['message']['text'] = "Vous n'êtes pas connecté"; include 'views/connexion.php'; } break; } }