public function _createContent(&$toReturn) { _classInclude('agenda|dateservices'); $ppo = new CopixPPO(); // Récupération des paramètres $ppo->cahierId = $this->getParam('cahierId'); $ppo->jour = $this->getParam('date_jour'); $ppo->mois = $this->getParam('date_mois'); $ppo->annee = $this->getParam('date_annee'); $ppo->current = $this->getParam('current'); // Timestamp de la date sélectionnée $ppo->dateSelectionnee = mktime(0, 0, 0, $ppo->mois, $ppo->jour, $ppo->annee); $numeroSemaine = date('W', $ppo->dateSelectionnee); $service = new DateService(); // Récupération des timestamp des jours de la semaine $ppo->lun = CopixDateTime::timestampToyyyymmdd($service->numweekToDate($numeroSemaine, $ppo->annee, 1)); $ppo->mar = CopixDateTime::timestampToyyyymmdd($service->numweekToDate($numeroSemaine, $ppo->annee, 2)); $ppo->mer = CopixDateTime::timestampToyyyymmdd($service->numweekToDate($numeroSemaine, $ppo->annee, 3)); $ppo->jeu = CopixDateTime::timestampToyyyymmdd($service->numweekToDate($numeroSemaine, $ppo->annee, 4)); $ppo->ven = CopixDateTime::timestampToyyyymmdd($service->numweekToDate($numeroSemaine, $ppo->annee, 5)); $ppo->sam = CopixDateTime::timestampToyyyymmdd($service->numweekToDate($numeroSemaine, $ppo->annee, 6)); $ppo->semainePrecedente = strtotime("-1 week", $service->numweekToDate($numeroSemaine, $ppo->annee, 1)); $ppo->semaineSuivante = strtotime("+1 week", $service->numweekToDate($numeroSemaine, $ppo->annee, 1)); $toReturn = $this->_usePPO($ppo, '_menu_eleve.tpl'); }
/** * Fonction qui prépare l'affichage de la vue semaine */ public function getVueSemaine() { CopixHTMLHeader::addCSSLink(_resource("styles/module_agenda.css")); CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_agenda.js'); $obj = new AgendaService(); $listAgendas = $obj->getAvailableAgenda(); $agendaService = new AgendaService(); $dateService = new DateService(); if (($params = $this->_getSessionSemaineParams()) == null) { $params = new SemaineParams(); $params->numSemaine = $this->getRequest('numSemaine', $dateService->dateToWeeknum(mktime()), true); $params->annee = $this->getRequest('annee', date('Y'), true); } else { $params->numSemaine = $this->getRequest('numSemaine', $params->numSemaine, true); $params->annee = $this->getRequest('annee', $params->annee, true); } //pour savoir si on a cliqué sur un agenda à afficher if (_request('updateAgendaAffiches')) { $arIdAgendas = array(); foreach ($listAgendas as $agenda) { if (_request('agendas_' . $agenda->id_agenda)) { $arIdAgendas[$agenda->id_agenda] = $agenda->id_agenda; } } $agendaService->setAgendaAffiches($arIdAgendas); } //on récupère en session les agendas à afficher $params->agendas = $agendaService->getAgendaAffiches(); //on met à jour la session $this->_setSessionSemaineParams($params); //on determine la date de début et de fin de la semaine en cours d'affichage $dateDebutSemaine = date('Ymd', $dateService->numweekToDate($params->numSemaine, $params->annee, 1)); //date au format bdd $dateFinSemaine = date('Ymd', $dateService->numweekToDate($params->numSemaine, $params->annee, 0)); //date au format bdd $arEventsSemaine = array(); //on récupère tous les évènements de la semaine en cours de vue foreach ((array) $params->agendas as $idAgenda) { $arEventsSemaine[$idAgenda] = $agendaService->checkEventOfAgendaInBdd($idAgenda, $dateDebutSemaine, $dateFinSemaine); } //on classe ces évènements par jour $arEventByDay = $agendaService->getEventsByDay($arEventsSemaine, $dateDebutSemaine, $dateFinSemaine); //on ordonne les évènements par ordre croissant d'heure de début d'évènement dans la journée $arEventByDay = $agendaService->getEventsInOrderByDay($arEventByDay); //on détermine l'heure de début et l'heure de fin pour l'affichage du calendrier //on travail sur des heures sans séparateur pour pouvoir les comparer $heureDeb = CopixConfig::get('agenda|heuredebcal'); $heureFin = CopixConfig::get('agenda|heurefincal'); foreach ((array) $arEventByDay as $jours) { if (!isset($jours->events)) { continue; } //print_r($jours); foreach ((array) $jours->events as $event) { if ($event->alldaylong_event == 0) { if ($dateService->heureWithSeparateurToheureWithoutSeparateur($event->heuredeb_event) < $dateService->heureWithSeparateurToheureWithoutSeparateur($heureDeb)) { $heureDeb = $dateService->heureWithSeparateurToheureWithoutSeparateur($event->heuredeb_event); } if ($dateService->heureWithSeparateurToheureWithoutSeparateur($heureFin) < $dateService->heureWithSeparateurToheureWithoutSeparateur($event->heurefin_event)) { $heureFin = $dateService->heureWithSeparateurToheureWithoutSeparateur($event->heurefin_event); } } } } //on arrondit à l'heure inférieure pour l'heure de début et à l'heure supérieure pour l'heure de fin $heureDeb = substr($heureDeb, 0, 2); if (substr($heureFin, 2, 2) == 0) { //si les minutes sont à 0, on arrondit à l'heure $heureFin = substr($heureFin, 0, 2); } else { //si les minutes ne sont pas à 0, on arrondit à l'heure supérieure $heureFin = substr($heureFin, 0, 2) + 1; } //on récupère les leçons de la semaine à afficher $arLecons = $agendaService->getLeconsByDay((array) $params->agendas, $dateDebutSemaine, $dateFinSemaine); // On récupère les travaux de la semaine par agenda $travailDAO = _ioDAO('cahierdetextes|cahierdetextestravail'); $agenda2cahier = array(); $arTravauxEnClasse = array(); $arTravauxAFaire = array(); foreach ($params->agendas as $agendaId) { $agendaInfos = Kernel::getModParentInfo('MOD_AGENDA', $agendaId); $agendaType = AgendaType::getAgendaTypeForNode($agendaInfos['type'], $agendaInfos['id']); $mods = Kernel::getModEnabled($agendaInfos['type'], $agendaInfos['id']); $cahierDeTextes = Kernel::filterModuleList($mods, 'MOD_CAHIERDETEXTES'); $agendaLevel = Kernel::getLevel($agendaInfos['type'], $agendaInfos['id']); if (isset($cahierDeTextes[0])) { $agenda2cahier[$agendaId] = $cahierDeTextes[0]->module_id; $travauxEnClasse = $travailDAO->findTravauxEnClasseByAgendaParJour($agendaId, $dateDebutSemaine, $dateFinSemaine, $agendaInfos['type'], $agendaInfos['id'], $agendaLevel); if (!is_null($travauxEnClasse)) { foreach ($travauxEnClasse as $date => $travail) { $arTravauxEnClasse[$date][$agendaId] = $travail; } } $travauxAFaire = $travailDAO->findTravauxAFaireByAgendaParJour($agendaId, $dateDebutSemaine, $dateFinSemaine, $agendaInfos['type'], $agendaInfos['id'], $agendaLevel); if (!is_null($travauxAFaire)) { foreach ($travauxAFaire as $date => $travail) { $arTravauxAFaire[$date][$agendaId] = $travail; } } } } //récupération de la liste des agendas affichés $listAgendasAffiches = $obj->getAgendaAffiches(); //template pour agenda $tplAgenda = new CopixTpl(); $tplAgenda->assign('MAIN_AGENDA', CopixZone::process('agenda|agendavuesemaine', array('elementsSemaineAffichee' => $params, 'arEventByDay' => $arEventByDay, 'heureDeb' => $heureDeb, 'heureFin' => $heureFin, 'arLecons' => $arLecons, 'arTravauxEnClasse' => $arTravauxEnClasse, 'arTravauxAFaire' => $arTravauxAFaire, 'agenda2cahier' => $agenda2cahier))); $title = $obj->getCurrentTitle(); //template principal $tpl = new CopixTpl(); $tpl->assign('TITLE_PAGE', $title['title']); $menu = $agendaService->getAgendaMenu('week'); $tpl->assign('MENU', $menu); $tpl->assign('MAIN', $tplAgenda->fetch('agenda|main.agenda.tpl')); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
public function _createContent(&$toReturn) { $service = new DateService(); $serviceAgenda = new AgendaService(); $serviceType = new AgendaType(); $serviceAuth = new AgendaAuth(); //on determine la date du jour en timestamp $dimanche = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 0); $lundi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 1); $mardi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 2); $mercredi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 3); $jeudi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 4); $vendredi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 5); $samedi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 6); $tpl = new CopixTpl(); //date du jour $tpl->assign('dimanche', date('d', $dimanche)); $tpl->assign('lundi', date('d', $lundi)); $tpl->assign('mardi', date('d', $mardi)); $tpl->assign('mercredi', date('d', $mercredi)); $tpl->assign('jeudi', date('d', $jeudi)); $tpl->assign('vendredi', date('d', $vendredi)); $tpl->assign('samedi', date('d', $samedi)); $tpl->assign('date_deb', date('Ymd', $lundi)); $tpl->assign('date_fin', date('Ymd', $dimanche)); $tpl->assign('moisDebutSemaine', $service->moisNumericToMoisLitteral(date('m', $lundi))); $tpl->assign('moisFinSemaine', $service->moisNumericToMoisLitteral(date('m', $dimanche))); $tpl->assign('semaine', $this->getParam('elementsSemaineAffichee')->numSemaine); $tpl->assign('annee', $this->getParam('elementsSemaineAffichee')->annee); //on vérifie si un agenda de classe est affiché //$lecon = false; $readLecon = false; $writeLecon = false; $idAgendaScolaire = null; $agendasAffiches = $this->getParam('agendasAffiches', null); foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) { if ($serviceAgenda->getTypeAgendaByIdAgenda($id_agenda) == $serviceType->getClassRoom()) { //on vérifie si l'utilisateur peut écrire des leçons if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteLecon()) { $writeLecon = true; //$lecon = true; $idAgendaScolaire = $id_agenda; break; } //on vérifie si l'utilisateur peut lire les leçons if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getRead()) { $readLecon = true; //$lecon = true; //$idAgendaScolaire = $id_agenda; //break; } } } //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affichés $writeAgenda = false; $agendasAffiches = $this->getParam('agendasAffiches', null); foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) { if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteAgenda()) { $writeAgenda = true; break; } } //on construit un tableau de droits pour chaque agenda affiché $arDroits = array(); foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) { if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getRead()) { $arDroits[$id_agenda]->canRead = true; } else { $arDroits[$id_agenda]->canRead = false; } if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteAgenda()) { $arDroits[$id_agenda]->canWrite = true; } else { $arDroits[$id_agenda]->canWrite = false; } if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getModerate()) { $arDroits[$id_agenda]->canModerate = true; } else { $arDroits[$id_agenda]->canModerate = false; } } //on construit le tableau de couleurs associées au type d'agenda $arColorByIdAgenda = array(); foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) { $arColor = $serviceType->getColors($serviceAgenda->getTypeAgendaByIdAgenda($id_agenda)); $i = 0; foreach ($arColorByIdAgenda as $idAgenda => $couleurAgenda) { if ($arColorByIdAgenda[$idAgenda] == $arColor[$i]) { $i = $i + 1; } } if ($i < count($arColor)) { $arColorByIdAgenda[$id_agenda] = $arColor[$i]; } else { $arColorByIdAgenda[$id_agenda] = $arColor[0]; } } $tpl->assign('arColorByIdAgenda', $arColorByIdAgenda); //on détermine l'heure de début et de fin pour l'affichage du calendrier $tpl->assign('heure_deb', $this->getParam('heureDeb')); $tpl->assign('heure_fin', $this->getParam('heureFin')); $tpl->assign('arEventByDay', $this->getParam('arEventByDay')); $tpl->assign('readLecon', $readLecon); $tpl->assign('writeLecon', $writeLecon); $tpl->assign('agendaScolaire', $idAgendaScolaire); $tpl->assign('arLecons', $this->getParam('arLecons')); $tpl->assign('arTravauxEnClasse', $this->getParam('arTravauxEnClasse')); $tpl->assign('arTravauxAFaire', $this->getParam('arTravauxAFaire')); $tpl->assign('agenda2cahier', $this->getParam('agenda2cahier')); $tpl->assign('writeAgenda', $writeAgenda); $tpl->assign('arDroits', $arDroits); $tpl->assign('todayJour', date('d')); $tpl->assign('todaySemaine', date('W')); $tpl->assign('todayAnnee', date('Y')); //paramètres pour passer d'une semaine à l'autre $tpl->assign('semaine_precedente', $service->dateToWeeknum(mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) - 7, date('Y', $lundi)))); $tpl->assign('semaine_suivante', $service->dateToWeeknum(mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) + 7, date('Y', $lundi)))); $tpl->assign('annee_precedente', date('Y', mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) - 4, date('Y', $lundi)))); $tpl->assign('annee_suivante', date('Y', mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) + 10, date('Y', $lundi)))); $listAgendas = $this->getParam('listAgendas', null); $tpl->assign('listAgendas', $listAgendas); $toReturn = $tpl->fetch('vuesemaine.agenda.ptpl'); return true; }