public function initDayly() { $matRepo = new ItemRepository(); $matieres = $matRepo->getAllMatieres(); $days = array("Mon" => 'monday', "Tue" => 'thuesday', "Wed" => 'wednesday', "Thu" => 'thursday', "Fri" => 'friday', "Sat" => 'saturday', "Sun" => 'sunday'); //chaque jour de la semaine foreach ($days as $code => $day) { //mat_id = 0 ==> ligne globale $command_insert_0 = $this->db->createCommand()->insert('aggreg_daily', ['id' => '', 'day' => $day, 'mat_id' => 0, 'cpt' => 0, 'mkb_cpt' => 0, 'code' => $code]); $command_insert_0->execute(); //pour chaque matiere foreach ($matieres as $mat) { $command_insert_daily = $this->db->createCommand()->insert('aggreg_daily', ['id' => '', 'day' => $day, 'mat_id' => $mat->id, 'cpt' => 0, 'mkb_cpt' => 0, 'code' => $code]); $command_insert_daily->execute(); } } }
public function createNewTour($num_tour) { $itemRepo = new ItemRepository(); $items = $itemRepo->getAll(); //On crée un KanBan pour chaque matière pour le nouveau tour $matieres = $itemRepo->getAllMatieres(); foreach ($matieres as $mat) { $command_insert_kanban = $this->db->createCommand()->insert('kanban', ['id' => '', 'mat_id' => $mat->id, 'numero_tour' => $num_tour, 'done' => 0]); $command_insert_kanban->execute(); $idkanban = $this->db->getLastInsertId(); $items = $itemRepo->getAllByMatiere($mat->id); //pour chaque item on crée une ligne dans la table tour foreach ($items as $item) { $command_insert_tour = $this->db->createCommand()->insert('tour', ['numero_tour' => $num_tour, 'item_id' => $item->id, 'mat_id' => $item->mat_id, 'done' => 0]); $command_insert_tour->execute(); //ET une ligne dans la table KanbanItems $command_insert_kanbanitems = $this->db->createCommand()->insert('kanban_items', ['id_kanban' => $idkanban, 'id_item' => $item->id, 'step' => 0]); $command_insert_kanbanitems->execute(); } } }
public function initMonthly() { $matRepo = new ItemRepository(); $matieres = $matRepo->getAllMatieres(); $today = date("W m Y"); $month = explode(" ", $today)[1]; $year = explode(" ", $today)[2]; $i = 1; //pour chaque mois de l'année while ($i < 13) { $current = $i == $month ? 1 : 0; //mat_id = 0 ==> ligne globale $command_insert_0 = $this->db->createCommand()->insert('aggreg_monthly', ['id' => '', 'num' => $i, 'mat_id' => 0, 'cpt' => 0, 'mkb_cpt' => 0, 'current' => $current, 'year' => $year]); $command_insert_0->execute(); //pour chaque matiere foreach ($matieres as $mat) { //mat_id = 0 ==> ligne globale $command_insert_month = $this->db->createCommand()->insert('aggreg_monthly', ['id' => '', 'num' => $i, 'mat_id' => $mat->id, 'cpt' => 0, 'mkb_cpt' => 0, 'current' => $current, 'year' => $year]); $command_insert_month->execute(); } $i++; } }
public function actionStatsgenerales() { if (!Yii::$app->getUser()->isGuest) { $statsRepository = new StatsRepository(); $itemRepo = new ItemRepository(); $current_stats = $statsRepository->getGlobalData(); $matieres = $itemRepo->getAllMatieres(); return $this->render('statsglobales', ['weeks' => $current_stats['weeks'], 'months' => $current_stats['months'], 'matieres' => $matieres]); } else { Yii::$app->session->setFlash('error', 'Please log in to acces the website features.'); $this->redirect(BASE_URL . 'web/index.php/site/login'); } }