public function __construct($serviceLocator) { parent::__construct("add_cong_tac_giang_day_form"); $this->setAttribute('method', 'post'); // khai báo biến cần sử dụng $service_config = $serviceLocator->get('config'); $function_class = new FunctionClass(); // truy cập vào config lấy ra danh sách config bậc học $bac_hoc = array(); $bac_hoc_source_model = array(); $bac_hoc_source_model['source_model']['application'] = 'bac_hoc'; $bac_hoc = $function_class->selectElementArray(array('array_element' => $bac_hoc_source_model, 'array' => $service_config)); // truy cập vào config lấy ra danh sách config số tiết $so_tiet = array(); $so_tiet_source_model = array(); $so_tiet_source_model['source_model']['application'] = 'so_tiet'; $so_tiet = $function_class->selectElementArray(array('array_element' => $so_tiet_source_model, 'array' => $service_config)); // truy cập vào config lấy ra danh sách config hệ đào tạo $he_dao_tao = array(); $he_dao_tao_source_model = array(); $he_dao_tao_source_model['source_model']['application'] = 'he_dao_tao'; $he_dao_tao = $function_class->selectElementArray(array('array_element' => $he_dao_tao_source_model, 'array' => $service_config)); // id công tác giảng dạy $this->add(array('name' => 'id_cong_tac', 'type' => 'Zend\\Form\\Element\\Hidden')); // Tên môn $mon_hoc_table = $serviceLocator->get('MonHoc\\Model\\JosSubjectTable'); $mon_hocs = $mon_hoc_table->getSubjectByYearActive(array('value_id', 'name')); $mon_hoc_option = array(); $mon_hoc_option['empty_option'] = 'Chọn'; foreach ($mon_hocs as $key => $mon_hoc) { $mon_hoc_option['value_options'][$mon_hoc['value_id']] = $mon_hoc['name']; } $this->add(array('name' => 'ten_mon', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('title' => 'Tên môn', 'class' => 'form-control'), 'options' => $mon_hoc_option)); // Số tiết $so_tiet_option = array(); $so_tiet_option['empty_option'] = 'Chọn'; $so_tiet_option['value_options'] = $so_tiet; $this->add(array('name' => 'so_tiet', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('title' => 'Số tiết', 'class' => 'form-control'), 'options' => $so_tiet_option)); // bậc học foreach ($bac_hoc as $key => $bh) { $this->add(array('name' => 'bac_hoc_' . $key, 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => array('title' => '$bh', 'class' => 'form-control'))); } // hệ đào tạo foreach ($he_dao_tao as $key => $hdt) { $this->add(array('name' => 'he_dao_tao_' . $key, 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => array('title' => '$hdt', 'class' => 'form-control'))); } // ghi chú $this->add(array('name' => 'ghi_chu', 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => array('title' => 'Ghi chú', 'class' => 'form-control'))); $this->setInputFilter(new AddCongTacGiangDayFormFilter(array('he_dao_tao' => $he_dao_tao, 'bac_hoc' => $bac_hoc))); }
public function __construct($serviceLocator, $certificates) { parent::__construct("edit_certificate_form"); $this->setAttribute('method', 'post'); // khai báo biến cần sử dụng $service_config = $serviceLocator->get('config'); $function_class = new FunctionClass(); foreach ($certificates as $key => $certificate) { $certificate_id = 'certificate_id_' . $certificate['value_id']; $this->add(array('name' => $certificate_id, 'type' => 'Zend\\Form\\Element\\Hidden', 'attributes' => array('title' => 'Id chứng chỉ', 'class' => 'form-control ajax-certificate'))); $certificate_name = 'certificate_name_' . $certificate['value_id']; $this->add(array('name' => $certificate_name, 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => array('title' => 'Tên chứng chỉ', 'class' => 'form-control ajax-certificate', 'value' => $certificate['name'], 'disabled' => true))); if ($certificate['name'] == 'Ngoại ngữ') { $options = array(); $source_model = array(); $source_model['source_model']['cetificate'] = 'ngoai_ngu'; // truy cập vào config lấy ra danh sách config $options['value_options'] = $function_class->selectElementArray(array('array_element' => $source_model, 'array' => $service_config)); $options['empty_option'] = 'Chọn'; // nếu là ngoại ngữ thì cột chú thích (certificate_note) sẽ lưu lại loại ngoại ngữ: có thể là tieng_anh, tieng_nhat, tieng_phap... $certificate_note = 'certificate_loai_ngoai_ngu_' . $certificate['value_id']; $this->add(array('name' => $certificate_note, 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('title' => 'Loại ngoại ngữ', 'class' => 'form-control ajax-certificate'), 'options' => $options)); // cột level sẽ lưu lại trình độ ngoại ngữ đó $certificate_level = 'certificate_level_' . $certificate['value_id']; $this->add(array('name' => $certificate_level, 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => array('title' => 'Trình độ', 'class' => 'form-control ajax-certificate'))); } else { // ngược lại thì sẽ lưu ghi chú $certificate_note = 'certificate_note_' . $certificate['value_id']; $this->add(array('name' => $certificate_note, 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => array('title' => 'Ghi chú', 'class' => 'form-control ajax-certificate'))); $certificate_check = 'certificate_check_' . $certificate['value_id']; $this->add(array('name' => $certificate_check, 'type' => 'Zend\\Form\\Element\\Checkbox', 'attributes' => array('title' => 'Ghi chú', 'class' => 'checkbox ajax-certificate'), 'options' => array('use_hidden_element' => true, 'checked_value' => 1, 'unchecked_value' => 0))); } } $this->setInputFilter(new EditCertificateFormFilter($certificates)); }
public function __construct($serviceLocator) { parent::__construct("add_attribute_form"); $this->setAttribute('method', 'post'); // khai báo biến cần sử dụng $service_config = $serviceLocator->get('config'); $function_class = new FunctionClass(); $this->add(array('name' => 'attribute_code', 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => array('title' => 'Mã thuộc tính', 'class' => 'form-control', 'id' => 'attribute-code', 'placeholder' => 'Nhập mã thuộc tính'))); $options = array(); $source_model_frontend_input = array(); $source_model_frontend_input['source_model']['attribute'] = 'frontend_input'; // truy cập vào config lấy ra danh sách config $options['value_options'] = $function_class->selectElementArray(array('array_element' => $source_model_frontend_input, 'array' => $service_config)); $options['empty_option'] = 'Chọn'; $this->add(array('name' => 'frontend_input', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('title' => 'Loại thuộc tính', 'class' => 'form-control', 'id' => 'frontend-input', 'placeholder' => 'Chọn loại thuộc tính'), 'options' => $options)); $this->add(array('name' => 'frontend_label', 'type' => 'Zend\\Form\\Element\\Text', 'attributes' => array('title' => 'Tên thuộc tính', 'class' => 'form-control', 'id' => 'frontend-label', 'placeholder' => 'Nhập tên thuộc tính'))); $this->setInputFilter(new AddAttributeFormFilter()); }
public function editFutureTeachingAction() { $id = $this->params('id'); $request = $this->getRequest(); if ($request->isPost()) { // điểm truy cập csdl $jos_users_table = $this->getServiceLocator()->get('Permission\\Model\\JosUsersTable'); $jos_year_table = $this->getServiceLocator()->get('NamHoc\\Model\\JosYearTable'); $jos_future_teaching_table = $this->getServiceLocator()->get('Application\\Model\\JosFutureTeachingTable'); $service_config = $this->getServiceLocator()->get('config'); $function_class = new FunctionClass(); // post $post = $request->getPost(); // nếu đã đăng nhập $read = $this->getServiceLocator()->get('AuthService')->getStorage()->read(); if (isset($read['username']) and $read['username']) { // kiểm tra user đang đăng nhập $user = $jos_users_table->getGiangVienByArrayConditionAndArrayColumns(array('username' => $read['username'])); // kiểm tra user có quyền editAllProfile không $white_lists = $read['white_list']; $edit_all_profile = 0; foreach ($white_lists as $key => $white_list) { if ($white_list['action'] == 'editAllProfile') { $edit_all_profile = 1; } } // nếu id cần sửa bằng với user_id đang đăng nhập hoặc có quyền editAllProfile if ($user and $user[0]['id'] == $id or $edit_all_profile == 1) { $future_teaching_edit_form = new EditCongTacGiangDayForm($this->getServiceLocator()); $future_teaching_edit_form->setData($post); if ($future_teaching_edit_form->isValid()) { // lấy year_id default $jos_year_table = $this->getServiceLocator()->get('NamHoc\\Model\\JosYearTable'); $year = $jos_year_table->getYearByArrayConditionAndArrayColumn(array('is_active' => 1)); if (!$year or !isset($year[0]['year_id'])) { die('Lỗi, Không xác định được năm cần sửa'); } $year_id = $year[0]['year_id']; // kiểm tra dữ liệu post đã tồn tại chưa nếu tồn tại rồi thì sửa $future_teaching_exist = $jos_future_teaching_table->getFutureTeachingAndSubjectByArrayConditionAndArrayColumns(array('t1.user_id' => $id, 't1.subject_id' => $post['ten_mon'], 't2.year_id' => $year_id), array(), array()); if ((!$future_teaching_exist or $future_teaching_exist and $future_teaching_exist[0]['value_id'] == $post['id_cong_tac']) and ($edit_all_profile == 1 or $future_teaching_exist[0]['user_id'] == $id)) { //if(!$future_teaching_exist or ($future_teaching_exist and $future_teaching_exist[0]['value_id']==$post['id_cong_tac']) and ($edit_all_profile==1 or $future_teaching_exist[0]['user_id']==$id)){ // truy cập vào config lấy ra danh sách config bậc học $bac_hocs = array(); $bac_hoc_source_model = array(); $bac_hoc_source_model['source_model']['application'] = 'bac_hoc'; $bac_hocs = $function_class->selectElementArray(array('array_element' => $bac_hoc_source_model, 'array' => $service_config)); $bac_hoc = ''; $co_bac_hoc = 0; foreach ($bac_hocs as $key => $bh) { if (isset($post['bac_hoc_' . $key]) and $post['bac_hoc_' . $key] == 1) { $co_bac_hoc++; if ($co_bac_hoc > 1) { $bac_hoc .= ', '; } $bac_hoc .= $bh; } } // truy cập vào config lấy ra danh sách config hệ đào tạo $he_dao_taos = array(); $he_dao_tao_source_model = array(); $he_dao_tao_source_model['source_model']['application'] = 'he_dao_tao'; $he_dao_taos = $function_class->selectElementArray(array('array_element' => $he_dao_tao_source_model, 'array' => $service_config)); $he_dao_tao = ''; $co_he_dao_tao = 0; foreach ($he_dao_taos as $key => $hdt) { if (isset($post['he_dao_tao_' . $key]) and $post['he_dao_tao_' . $key] == 1) { $co_he_dao_tao++; if ($co_he_dao_tao > 1) { $he_dao_tao .= ', '; } $he_dao_tao .= $hdt; } } $future_teaching_new = new JosFutureTeaching(); $future_teaching_new->setValueId($post['id_cong_tac']); $future_teaching_new->setSubjectId($post['ten_mon']); $future_teaching_new->setUserId($id); $future_teaching_new->setLessonNumber($post['so_tiet']); $future_teaching_new->setQualifications($bac_hoc); $future_teaching_new->setEduSystem($he_dao_tao); $future_teaching_new->setNote($post['ghi_chu']); $jos_future_teaching_table->saveJosFutureTeaching($future_teaching_new); $this->flashMessenger()->addSuccessMessage('Chúc mừng, cập nhật thành công!'); return $this->redirect()->toRoute('application/crud', array('action' => 'index', 'id' => $id)); } } } } } if (isset($id)) { $this->flashMessenger()->addErrorMessage('Bạn không có quyền truy cập. Vui lòng kiểm tra lại!'); return $this->redirect()->toRoute('application/crud', array('action' => 'index', 'id' => $id)); } // không có quyền sửa $this->flashMessenger()->addErrorMessage('Bạn không có quyền truy cập. Vui lòng kiểm tra lại!'); return $this->redirect()->toRoute('application/crud', array('action' => 'index')); }
public function addAction() { // add form $add_form = new AddAttributeForm($this->getServiceLocator()); $request = $this->getRequest(); if ($request->isPost()) { $post = $request->getPost(); $add_form->setData($post); if ($add_form->isValid()) { $attribute_code = $post['attribute_code']; $frontend_label = $post['frontend_label']; $frontend_input = $post['frontend_input']; $value_table = 'jos_infomation'; // khai báo model bảng jos_year $jos_year_table = $this->getServiceLocator()->get('NamHoc\\Model\\JosYearTable'); // lấy year_id default $years = $jos_year_table->getYearByArrayConditionAndArrayColumn(array('is_active')); // không tồn tại year default if (!$years) { $this->flashMessenger()->addErrorMessage('Lỗi. Bạn muốn thêm "Môn Học" vào năm học nào? Vui lòng kiểm tra lại!'); return $this->redirect()->toRoute('thuoc_tinh/crud', array('action' => 'index')); } // tạo điểm truy cập csdl jos_subject $jos_attribute_table = $this->getServiceLocator()->get('Attribute\\Model\\JosAttributeTable'); // kiểm tra với năm hiện tại có tồn tại có tồn tại môn học này chưa $jos_attribute_exist = $jos_attribute_table->getAttributeByArrayConditionAndArrayColumn(array('attribute_code' => $attribute_code, 'year_id' => $years[0]['year_id'])); if ($jos_attribute_exist) { $this->flashMessenger()->addErrorMessage('Lỗi, Thuộc tính vừa thêm đã tồn tại. Vui lòng kiểm tra lại!'); return $this->redirect()->toRoute('thuoc_tinh/crud', array('action' => 'index')); } // kiểm tra dữ liệu frontend_input có thuộc loại trong config hong $service_config = $this->getServiceLocator()->get('config'); $function_class = new FunctionClass(); $options = array(); $source_model_frontend_input = array(); $source_model_frontend_input['source_model']['attribute'] = 'frontend_input'; // truy cập vào config lấy ra danh sách config $options = $function_class->selectElementArray(array('array_element' => $source_model_frontend_input, 'array' => $service_config)); if (!isset($options[$frontend_input])) { $this->flashMessenger()->addErrorMessage('Lỗi, Loại thuộc tính không tồn tại. Vui lòng kiểm tra lại!'); return $this->redirect()->toRoute('thuoc_tinh/crud', array('action' => 'index')); } // thêm vào csdl $new_attribute = new JosAttribute(); $new_attribute->exchangeArray($post); $new_attribute->setAttributeCode($attribute_code); $new_attribute->setFrontendLabel($frontend_label); $new_attribute->setValueTable($value_table); $new_attribute->setYearId($years[0]['year_id']); // lưu thuộc tính $jos_attribute_table->saveAttribute($new_attribute); // nếu frontend_input==Select thì lưu option vào bảng jos_attribute_option if ($frontend_input == 'Select') { // lấy id jos_attribute $attribute = $jos_attribute_table->getAttributeByArrayConditionAndArrayColumn(array('attribute_code' => $attribute_code, 'year_id' => $years[0]['year_id']), array('attribute_id')); if (isset($attribute[0]['attribute_id'])) { $jos_attribute_option_table = $this->getServiceLocator()->get('Attribute\\Model\\JosAttributeOptionTable'); foreach ($post['frontend_input_value'] as $key => $value) { if ($value and $post['frontend_input_label'][$key]) { $jos_attribute_option_exist = $jos_attribute_option_table->getAttributeOptionByArrayConditionAndArrayColumn(array('attribute_id' => $attribute[0]['attribute_id'], 'key' => $post['frontend_input_label'][$key]), array('value_id')); if ($jos_attribute_option_exist) { continue; } $new_attribute_option = new JosAttributeOption(); $new_attribute_option->setAttributeId($attribute[0]['attribute_id']); $new_attribute_option->setKey($value); $new_attribute_option->setLabel($post['frontend_input_label'][$key]); $jos_attribute_option_table->saveAttributeOption($new_attribute_option); } } } } // lưu thành công $this->flashMessenger()->addSuccessMessage('Chúc mừng, thêm thuộc tính thành công!'); return $this->redirect()->toRoute('thuoc_tinh/crud', array('action' => 'index')); } } $this->flashMessenger()->addErrorMessage('Lỗi, thực thi không thành công. Vui lòng kiểm tra lại!'); return $this->redirect()->toRoute('thuoc_tinh/crud', array('action' => 'index')); }