public function actionId($id)
 {
     $data = $this->model->get($id);
     $this->setTitle("Třída " . $data->shortname);
     $this->template->data = $data;
     $studentsGrid = $this["studentsGrid"];
     $studentsGrid->setModel($this->studentsModel->getSelection()->where(array("class_id" => $id))->orderBy("catalog_number"));
     $groupsGrid = $this["groupsGrid"];
     $groupsGrid->setModel($this->groupsModel->getSelection()->where(array("sch_class_id" => $id)));
 }
Exemple #2
0
 public function actionId($user_id)
 {
     $data = $this->model->get($user_id);
     $this->setTitle("Student " . $data->firstname . " " . $data->lastname);
     $this->template->data = $data;
     $groupsGrid = $this["groupsGrid"];
     $groupsGrid->setModel($this->groupsModel->getSelection()->where(array("sch_group_membership.user_id" => $user_id)));
     $studentGroups = $this->membershipModel->getStudentsGroupsId($user_id);
     $studentGroupList = array();
     foreach ($studentGroups as $gr) {
         $studentGroupList[] = $gr->sch_group_id;
     }
     $studentGroupString = implode(",", $studentGroupList);
     $loadsGrid = $this["loadsGrid"];
     if ($studentGroupList) {
         $loadsGrid->setModel($this->loadsModel->getSelection()->where("sch_group_id IN(" . $studentGroupString . ")"));
     } else {
         $loadsGrid->setModel($this->loadsModel->getSelection()->where("sch_group_id = 0"));
     }
 }
Exemple #3
0
 public function actionImportGroups()
 {
     $result = $this->model->importGroups();
     $data = $result->data;
     $reports = array();
     $this->groupsModel->purge();
     $this->membersModel->purge();
     $classConversionTable = array();
     $classData = $this->classesModel->query("SELECT id, bakalari_code FROM sch_class")->fetchAll();
     foreach ($classData as $classRecord) {
         $classConversionTable[$classRecord["bakalari_code"]] = $classRecord["id"];
     }
     foreach ($data as $record) {
         $newid = $this->groupsModel->insert(array("name" => $record->name, "shortname" => $record->shortname, "bakalari_code" => $record->bakalari_code, "sch_class_id" => $classConversionTable[$record->class_code]));
         $reports[] = "ADD: Skupina " . $record->name . " byla přidána. ({$newid})";
     }
     $result2 = $this->model->importMembership();
     $data = $result2->data;
     $groupConversionTable = array();
     $groupData = $this->groupsModel->query("SELECT id, bakalari_code FROM sch_group")->fetchAll();
     foreach ($groupData as $groupRecord) {
         $groupConversionTable[$groupRecord["bakalari_code"]] = $groupRecord["id"];
     }
     $studentConversionTable = array();
     $studentData = $this->studentsModel->query("SELECT user_id, bakalari_code FROM sch_student")->fetchAll();
     foreach ($studentData as $studentRecord) {
         $studentConversionTable[$studentRecord["bakalari_code"]] = $studentRecord["user_id"];
     }
     foreach ($data as $record) {
         if (isset($studentConversionTable[$record->student_code]) && isset($groupConversionTable[$record->group_code])) {
             try {
                 if (!$this->membersModel->query("SELECT user_id, sch_group_id FROM sch_group_membership WHERE user_id = " . $studentConversionTable[$record->student_code] . " AND sch_group_id = " . $groupConversionTable[$record->group_code])->fetch()) {
                     $this->membersModel->dumbInsert(array("user_id" => $studentConversionTable[$record->student_code], "sch_group_id" => $groupConversionTable[$record->group_code]));
                 }
             } catch (Exception $ex) {
                 $reports[] = "ERROR: Duplicitní data [" . $record->student_code . ", " . $record->group_code . "]";
             }
         } else {
             $reports[] = "ERROR: Nekonzistentní data [" . $record->student_code . ", " . $record->group_code . "]";
         }
     }
     $messages = array_merge($result->messages, $result2->messages);
     $this->template->reports = $reports;
     $this->template->messages = $messages;
     $this->setView("result");
 }
 public function actionId($user_id)
 {
     $data = $this->model->get($user_id);
     $this->setTitle("Student " . $data->firstname . " " . $data->lastname);
     $this->template->data = $data;
 }