public function saveAction()
 {
     $user = Zend_Auth::getInstance()->getStorage()->read();
     $request = $this->getRequest();
     $student_data = $request->getPost();
     $studentName = trim($student_data['studentName']);
     $gender = trim($student_data['gender']);
     $birthDate = trim($student_data['birthDate']);
     if (!strlen($studentName)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('REQUIRED_STUDENTNAME') . '</div>');
         $this->_redirect('/managestudents/add');
     }
     if (!strlen($gender)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('REQUIRED_GENDER') . '</div>');
         $this->_redirect('/managestudents/add');
     }
     if (!strlen($birthDate)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('REQUIRED_BIRTHDATE') . '</div>');
         $this->_redirect('/managestudents/add');
     }
     $student_DB = new Application_Model_DbTable_Student();
     $new_student = array('ganID' => $user->ganID, 'name' => $student_data['studentName'], 'lastName' => $student_data['studentLastName'], 'gender' => $student_data['gender'], 'birthDate' => $student_data['birthDate'], 'fatherName' => $student_data['fatherName'], 'fatherPhone' => $student_data['fatherPhone'], 'motherName' => $student_data['motherName'], 'motherPhone' => $student_data['motherPhone'], 'idNumber' => $student_data['idNumber']);
     try {
         $student_id = $student_DB->insert($new_student);
     } catch (Exception $ex) {
         die(json_encode(array('status' => 'danger', 'msg' => $ex->getMessage())));
     }
     $fields_DB = new Application_Model_DbTable_Field();
     $fields = $fields_DB->getAll();
     $studentinfield_DB = new Application_Model_DbTable_StudentsInField();
     foreach ($fields as $f) {
         $new_studentinfield = array('studentID' => $student_id, 'fieldID' => $f['fieldID']);
         try {
             $id = $studentinfield_DB->insert($new_studentinfield);
         } catch (Exception $ex) {
             die(json_encode(array('status' => 'danger', 'msg' => $ex->getMessage())));
         }
     }
     $this->_redirect("/managestudents");
 }
Ejemplo n.º 2
0
 function init()
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('/');
     }
     #FIELDS
     $fields_DB = new Application_Model_DbTable_Field();
     $fields = $fields_DB->getAll();
     #VIEWS
     $this->view->fields = $fields;
     $this->view->userRole = $_SESSION['Default']['role'];
     #Layout
     $this->_helper->layout->setLayout('layout');
     $this->config = Zend_Registry::get('config');
     #SEO:
     $this->view->title = $this->view->lang->_('SITE_TITLE');
     $this->view->sitedesc = $this->view->lang->_('SITE_DESC');
     $this->view->sitekeywords = $this->view->lang->_('SITE_KEYWORDS');
     #MSG
     $this->msger = $this->_helper->getHelper('FlashMessenger');
     $this->view->flashmsgs = $this->msger->getMessages();
     $this->lang = Zend_Registry::get('lang');
 }
Ejemplo n.º 3
0
 public function fieldsAction()
 {
     $fields_DB = new Application_Model_DbTable_Field();
     $fields = $fields_DB->getAll();
     $this->view->fields = $fields;
 }
Ejemplo n.º 4
0
 public function importgroupsAction()
 {
     $fieldID = $this->_request->getParam('f');
     if ($fieldID) {
         $user = Zend_Auth::getInstance()->getStorage()->read();
         $groups_DB = new Application_Model_DbTable_Group();
         $students_DB = new Application_Model_DbTable_StudentsInField();
         $groups = $groups_DB->getAll($user->ganID, $fieldID);
         foreach ($groups as $g) {
             $new_group = array('name' => $g['name'], 'color' => $g['color'], 'ganID' => $user->ganID, 'fieldID' => $_SESSION['Default']['field']);
             try {
                 $group_id = $groups_DB->insert($new_group);
             } catch (Exception $ex) {
                 die(json_encode(array('status' => 'danger', 'msg' => $ex->getMessage())));
             }
             $students = $students_DB->getAll($g['groupID']);
             foreach ($students as $s) {
                 $new_student = array('studentID' => $s['studentID'], 'fieldID' => $_SESSION['Default']['field'], 'groupID' => $group_id);
                 try {
                     $student_id = $students_DB->insert($new_student);
                 } catch (Exception $ex) {
                     die(json_encode(array('status' => 'danger', 'msg' => $ex->getMessage())));
                 }
             }
         }
         $this->_redirect("/managegroups");
     } else {
         $fields_DB = new Application_Model_DbTable_Field();
         $fields = $fields_DB->getAll();
         $this->view->fields = $fields;
         $this->view->fieldID = $_SESSION['Default']['field'];
     }
 }