public static function update($data) { try { //Update an index. $index = Zend_Search_Lucene::open('../application/searchindex'); Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive()); } catch (Zend_Search_Exception $e) { throw $e; } // remove an existing entry $hits = $index->find('pk:' . $data['pk']); foreach ($hits as $hit) { $index->delete($hit->id); } $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $data['pk'])); $doc->addField(Zend_Search_Lucene_Field::Keyword('code', $data['code'], 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::Keyword('u_code', strtolower($data['code']), 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::unIndexed('type', $data['type'], 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::unIndexed('id', $data['id'], 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::Text('title', $data['title'], 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::Text('en_title', Default_Model_Functions::convert_vi_to_en($data['title']), 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::Text('description', $data['description'], 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::Text('en_description', Default_Model_Functions::convert_vi_to_en($data['description']), 'UTF-8')); $index->addDocument($doc); $index->commit(); }
public function themHaAction() { // TODO Auto-generated {0}::indexAction() default action $form = new Admin_Form_HinhAnh(); $form->submitCon->setLabel('Lưu và tiếp tục'); $form->submitExit->setLabel('Lưu và thoát'); $form->cancel->setLabel('Không lưu'); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { //determine filename and extension $info = pathinfo($form->ten_file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->ten_file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true)))->addFilter(new Khcn_Filter_File_Resize(array('width' => 720, 'height' => 720, 'keepRatio' => true))); $form->getValue('ten_file'); $hinh_anh = new Default_Model_HinhAnh(); $hinh_anh->setTrangThai($form->getValue('trang_thai')); $hinh_anh->setTenFile($file); $kq = $hinh_anh->them(); if (!$kq) { $_SESSION['msg'] = 'Lỗi !. Đã có lỗi trong quá trình xử lý, vui lòng thử lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/cau-hinh/index'); } $this->flash(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được lưu trữ .'; $_SESSION['type_msg'] = 'success'; if ($form->submitCon->isChecked()) { $this->_redirect('/admin/cau-hinh/them-ha'); } else { $this->_redirect('/admin/cau-hinh/hinh-anh'); } } else { $form->populate($formData); } } }
public function getSelect($text, $params = array()) { // Build base query $table = Khcn_Api::_()->getDbtable('search', 'default'); $db = $table->getAdapter(); $select = $table->select(); $text = Default_Model_Functions::convert_vi_to_en($text, false); if (strlen($text) < 4 || isset($params['search_full']) && $params['search_full'] == 1) { $select->where("`title` like ? or `description` like ? or `keywords` like ? or `hidden` like ?", '%' . $text . '%'); } else { $select->where(new Zend_Db_Expr($db->quoteInto('MATCH(`title`, `description`, `keywords`, `hidden`) AGAINST (? IN BOOLEAN MODE)', $text)))->order(new Zend_Db_Expr($db->quoteInto('MATCH(`title`, `description`, `keywords`, `hidden`) AGAINST (?) DESC', $text))); } // Filter by item types $availableTypes = $this->getAvailableTypes(); if (isset($params['types']) && !empty($params['types'])) { if (!is_array($params['types'])) { $params['types'] = (array) $params['types']; } $availableTypes = $params['types']; } $select->where('type IN(?)', $availableTypes); return $select; }
public function suaAction() { $this->view->form = $form = new Admin_Form_Download(); $id = $this->_getParam('id'); $download = Khcn_Api::_()->getItem('default_download', $id); $form->populate($download->toArray()); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } $table = Khcn_Api::_()->getDbTable('download', 'default'); $db = $table->getAdapter(); $db->beginTransaction(); try { if ($form->file->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true)))->addFilter(new Khcn_Filter_File_Resize(array('width' => 720, 'height' => 720, 'keepRatio' => true))); $form->getValue('file'); $download->ten_file = $file; } $values = $form->getValues(); $download->setFromArray($values); $download->save(); $db->commit(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/download/index'); } catch (Exception $e) { $db->rollBack(); throw $e; } }
public function suaNhanSuAction() { $id = $this->_getParam('id', null); $nhan_su = Khcn_Api::_()->getItem('default_nhan_su', $id); if (!$nhan_su) { $_SESSION['msg'] = 'Lỗi !. Thông tin nhân sự không tồn tại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/gioi-thieu/nhan-su'); } $this->view->form = $form = new Admin_Form_NhanSu_Edit(); $form->populate($nhan_su->toArray()); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } if ($form->file->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true)))->addFilter(new Khcn_Filter_File_Resize(array('width' => 200, 'height' => 400, 'keepRatio' => true))); $form->getValue('file'); $nhan_su->ten_file = $file; } $values = $form->getValues(); $nhan_su->setFromArray($values); $nhan_su->save(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/gioi-thieu/nhan-su'); }
public function suaAction() { $form = new Admin_Form_LichBieu(); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $form->ten_file->setRequired(false); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $lich_bieu = new Default_Model_LichBieu(); $lich_bieu->setId($form->getValue('id')); $lich_bieu->setTen($form->getValue('ten')); //kiem tra co chon lai file if ($form->ten_file->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->ten_file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->ten_file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true))); $form->getValue('ten_file'); $lich_bieu->setTenFile($file); $oldFile = $this->lich_bieu->getFile($form->getValue('id')); if ($oldFile != '' && file_exists(APPLICATION_PATH . '/../public/upload/files/lich_bieu/' . $oldFile)) { unlink(APPLICATION_PATH . '/../public/upload/files/lich_bieu/' . $oldFile); } } $kq = $lich_bieu->sua(); if (!kq) { $_SESSION['msg'] = 'Lỗi !. Đã có lỗi trong quá trình xử lý, vui lòng thử lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/lich-bieu/index'); } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/lich-bieu/index'); } else { $form->populate($formData); } } else { $id = $this->_getParam('id'); if (!empty($id)) { $data = $this->lich_bieu->getLichBieu($id); if ($data != null) { $data = $this->lich_bieu->LichBieuToArray($data); $form->populate($data); } else { $_SESSION['msg'] = 'Lỗi !. Mã lịch biểu không tồn tại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/lich-bieu/index'); } } else { $this->_redirect('/admin/lich-bieu/index'); } } }
public function importAction() { $form = new Admin_Form_BaiBao_Import(); $this->view->form = $form; if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } //copy file to folder temp //determine filename and extension $info = pathinfo($form->file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true))); $form->getValue('file'); try { $data = array(); $data = Khcn_Api::_()->admin()->getDataImport(BASE_PATH . '/upload/files/temp/' . $file, $info['extension']); $baiBaoTable = Khcn_Api::_()->getDbTable('bai_bao', 'default'); $giangVientable = Khcn_Api::_()->getDbTable('giang_vien', 'default'); $tacGiaTable = Khcn_Api::_()->getDbTable('bai_bao_tac_gia', 'default'); $line_start = 2; for ($i = $line_start; $i <= count($data); $i++) { $giang_vien = null; if (!empty($data[$i]['B'])) { $baiBao = $baiBaoTable->createRow(); $baiBao->ten = $data[$i]['B']; $baiBao->thong_tin = $data[$i]['F']; $baiBao->noi_dang = $data[$i]['G']; $baiBao->ngay_dang = $data[$i]['H']; $baiBao->so = $data[$i]['I']; $baiBao->chi_so = $data[$i]['J']; $baiBao->diem_cong_trinh = $data[$i]['K']; if (!empty($data[$i]['C'])) { $don_vi = Khcn_Api::_()->getItem('default_don_vi', $data[$i]['C']); $baiBao->don_vi_id = $data[$i]['C']; } $baiBao->save(); } if (!empty($data[$i]['D'])) { $giang_vien = Khcn_Api::_()->getItem('default_giang_vien', $data[$i]['D']); if ($giang_vien) { $tac_gia = $tacGiaTable->createRow(); $tac_gia->bai_bao_id = $baiBao->bai_bao_id; $tac_gia->giang_vien_id = $giang_vien->getIdentity(); $tac_gia->save(); } } } //remove file in temp unlink(BASE_PATH . '/upload/files/temp/' . $file); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được lưu trữ.'; $_SESSION['type_msg'] = 'success'; } catch (Zend_Exception $ex) { echo $ex; die; //xóa file trong temp unlink(BASE_PATH . '/upload/files/temp/' . $file); $_SESSION['msg'] = 'Lỗi !. File không đúng định dạng, vui lòng kiểm tra lại.'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/bai-bao/import'); } }
public function suaAction() { $form = new Admin_Form_BaiViet(); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $this->view->form = $form; $id = $this->_getParam('id'); $bai_viet = Khcn_Api::_()->getItem('default_bai_viet', $id); if (!$bai_viet) { $_SESSION['msg'] = 'Lỗi !. Dữ liệu không tồn tại .'; $_SESSION['type_msg'] = 'error'; return $this->_redirect('/admin/bai-viet/index'); } $form->populate($bai_viet->toArray()); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } if ($form->photo->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->photo->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->photo->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true)))->addFilter(new Khcn_Filter_File_Resize(array('width' => 720, 'height' => 720, 'keepRatio' => true))); $form->getValue('photo'); // Remove old file $oldFile = $bai_viet->file; if ($oldFile != '' && file_exists(APPLICATION_PATH . '/../public/upload/files/bai_viet/' . $oldFile)) { unlink(APPLICATION_PATH . '/../public/upload/files/bai_viet/' . $oldFile); } $bai_viet->file = $file; } $values = $form->getValues(); $bai_viet->setFromArray($values); $bai_viet->save(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/bai-viet/index'); }
public function import_dt($inputFileName) { try { //$inputFileType = 'Excel2007'; $inputFileType = 'Excel5'; $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); $data = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $result = ''; $session = new Zend_Session_Namespace('import_dt'); $deTais = array(); $thanhViens = array(); $count = -1; for ($row = 10; $row <= count($data); $row++) { //if cell[$row,B] là đề tài mới if (!empty($data[$row]['B'])) { //luu de tai $cap_quan_ly = Default_Model_Functions::convert_vi_to_en(strtolower(trim($data[$row]['M']))); $deTais[] = array('ten' => $data[$row]['B'], 'linh_vuc' => trim($data[$row]['C']), 'thoi_gian_bat_dau' => trim($data[$row]['K']), 'thoi_gian_hoan_thanh' => trim($data[$row]['L']), 'cap_quan_ly' => $cap_quan_ly, 'kinh_phi' => trim($data[$row]['N'])); //luu chu nhiem $count++; $thanhViens[$count][] = array('ma_giang_vien' => trim($data[$row]['E']), 'ho_ten' => preg_replace('/\\s+/u', ' ', trim($data[$row]['F'])), 'hoc_vi' => trim($data[$row]['G']), 'ghi_chu' => trim($data[$row]['H']), 'nhiem_vu' => '1', 'email' => trim($data[$row]['I']), 'so_dien_thoai' => trim($data[$row]['J'])); } else { //luu thanh vien neu co if (!empty($data[$row]['F'])) { $thanhViens[$count][] = array('ma_giang_vien' => trim($data[$row]['E']), 'ho_ten' => preg_replace('/\\s+/u', ' ', trim($data[$row]['F'])), 'hoc_vi' => trim($data[$row]['G']), 'ghi_chu' => trim($data[$row]['H']), 'nhiem_vu' => '0', 'email' => trim($data[$row]['I']), 'so_dien_thoai' => trim($data[$row]['J'])); } } } $session->deTais = $deTais; $session->thanhViens = $thanhViens; } catch (Zend_Exception $ex) { throw $ex; } }
public function suaAction() { $form = new Admin_Form_HoSo(); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $form->file->setRequired(false); $this->view->form = $form; $id = $this->_getParam('id'); $ho_so = Khcn_Api::_()->getItem('default_ho_so', $id); if (!$ho_so) { $_SESSION['msg'] = 'Lỗi !. Hồ sơ không tồn tại .'; $_SESSION['type_msg'] = 'error'; return $this->_redirect('/admin/ho-so/index'); } $form->populate($ho_so->toArray()); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } //kiem tra co chon lai file if ($form->file->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true))); $form->getValue('file'); $oldFile = $ho_so->ten_file; if ($oldFile != '' && file_exists(APPLICATION_PATH . '/../public/upload/files/ho_so/' . $oldFile)) { unlink(APPLICATION_PATH . '/../public/upload/files/ho_so/' . $oldFile); } $ho_so['ten_file'] = $file; } $values = $form->getValues(); $ho_so->setFromArray($values); $ho_so->save(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/ho-so/index'); }
public function suaAction() { $form = new Admin_Form_HoiThao(); $form->removeElement('submitCon'); $this->view->form = $form; $id = $this->_getParam('id'); $hoi_thao = Khcn_Api::_()->getItem('default_hoi_thao', $id); $form->populate($hoi_thao->toArray()); if ($hoi_thao['anh_trang_bia'] != '') { $form->image->setImage(Khcn_View_Helper_GetBaseUrl::getBaseUrl() . '/upload/images/hoi_thao/' . $hoi_thao['anh_trang_bia']); } else { $form->removeElement('image'); } if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } $table = Khcn_Api::_()->getDbTable('hoi_thao', 'default'); $db = $table->getAdapter(); $db->beginTransaction(); try { if ($form->file_anh_trang_bia->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->file_anh_trang_bia->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $anh_trang_bia = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file_anh_trang_bia->addFilter(new Zend_Filter_File_Rename(array("target" => $anh_trang_bia, "overwrite" => true)))->addFilter(new Khcn_Filter_File_Resize(array('width' => 720, 'height' => 720, 'keepRatio' => true))); $form->getValue('file_anh_trang_bia'); $hoi_thao->anh_trang_bia = $anh_trang_bia; } if ($form->file_thong_cao_bao_chi->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->file_thong_cao_bao_chi->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $thong_cao_bao_chi = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file_thong_cao_bao_chi->addFilter(new Zend_Filter_File_Rename(array("target" => $thong_cao_bao_chi, "overwrite" => true))); $form->getValue('file_thong_cao_bao_chi'); $hoi_thao->thong_cao_bao_chi = $thong_cao_bao_chi; } $values = $form->getValues(); if (!empty($values['ngay_to_chuc'])) { $values['ngay_to_chuc'] = date('Y-m-d', strtotime($values['ngay_to_chuc'])); } $hoi_thao->setFromArray($values); $hoi_thao->save(); $db->commit(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/hoi-thao/index'); } catch (Exception $e) { $db->rollBack(); throw $e; } }
public function themHaAction() { // TODO Auto-generated {0}::indexAction() default action $id = $this->_getParam('id'); $this->view->sinh_hoat_chuyen_de = $sinh_hoat_chuyen_de = Khcn_Api::_()->getItem('default_sinh_hoat_chuyen_de', $id); $form = new Admin_Form_HinhAnhChuyenDe(); $form->submitCon->setLabel('Lưu và tiếp tục'); $form->submitExit->setLabel('Lưu và thoát'); $form->cancel->setLabel('Không lưu'); $this->view->form = $form; if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } //determine filename and extension $info = pathinfo($form->ten_file->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->ten_file->addFilter(new Zend_Filter_File_Rename(array("target" => $file, "overwrite" => true)))->addFilter(new Khcn_Filter_File_Resize(array('width' => 720, 'height' => 720, 'keepRatio' => true))); $values = $form->getValues(); $table = Khcn_Api::_()->getDbTable('hinh_anh_chuyen_de', 'default'); $row = $table->createRow(); $row->ten_file = $file; $row->chuyen_de_id = $id; $row->save(); $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được lưu trữ .'; $_SESSION['type_msg'] = 'success'; if ($form->submitCon->isChecked()) { $this->_redirect('/admin/sinh-hoat-chuyen-de/them-ha/id/' . $id); } else { $this->_redirect('/admin/sinh-hoat-chuyen-de/hinh-anh/id/' . $id); } }
public function suaAction() { $de_tai_id = $this->_getParam('id'); $de_tai = Khcn_Api::_()->getItem('default_de_tai', $de_tai_id); $tableDK = Khcn_Api::_()->getDbTable('dang_ky', 'default'); $form = new Admin_Form_DeTai(); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $this->view->form = $form; if (!$this->getRequest()->isPost()) { //populate chủ nhiệm $giang_vien = new Default_Model_GiangVien(); $gvOptions = $giang_vien->getDSGVByDV($de_tai->ma_don_vi); $chu_nhiem = $this->dang_ky->getMaChuNhiemByDT($de_tai_id); $form->chu_nhiem->setMultiOptions($gvOptions)->setValue($chu_nhiem); //populate thành viên $thanhViens = $this->dang_ky->getDSTVByDT($de_tai_id); $code = count($thanhViens); $form->code->setValue($code); $don_vi = new Default_Model_DonVi(); $donVis = $don_vi->getDSDV(); unset($donVis['1']); $dvOptions = array("multiOptions" => $donVis); $i = 0; foreach ($thanhViens as $thanh_vien) { $don_vi = new Zend_Form_Element_Select('don_vi_' . $i, $dvOptions); $don_vi->setValue($thanh_vien['ma_don_vi'])->setDecorators(Khcn_Form_Decorator_Select::getDecorator())->setAttribs(array('class' => 'text-input', 'id' => 'don_vi_' . $i, 'onchange' => 'change(this,' . $i . ')')); $giang_vien = new Default_Model_GiangVien(); $gvOptions = array("multiOptions" => $giang_vien->getDSGVByDV($thanh_vien['ma_don_vi'])); $ma_giang_vien = $thanh_vien['ma_giang_vien']; $thanh_vien = new Zend_Form_Element_Select('thanh_vien_' . $i, $gvOptions); $thanh_vien->setRequired(true)->setValue($ma_giang_vien)->setDecorators(Khcn_Form_Decorator_Select::getDecorator())->setAttribs(array('class' => 'text-input', 'id' => 'thanh_vien_' . $i))->setRegisterInArrayValidator(false); $form->addElements(array($don_vi, $thanh_vien)); $form->addDisplayGroup(array('don_vi_' . $i, 'thanh_vien_' . $i), 'dk_tv_' . $i, array('order' => $i + 6, 'legend' => 'Thành viên', 'decorators' => array('FormElements', 'Fieldset', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'td')), array('HtmlTag', array('tag' => 'tr', 'id' => 'dk_tv_' . $i))))); $i++; } $url = new Zend_View_Helper_Url(); if ($de_tai->ma_hd_duyet != null) { $hd_duyet = new Default_Model_Hdd(); $hdd = $hd_duyet->getHDD($de_tai->ma_hd_duyet); $link = $url->url(array('module' => 'admin', 'controller' => 'hoi-dong', 'action' => 'sua-hdd', 'id' => $de_tai->ma_hd_duyet), null, true); $element = new Zend_Form_Element_Text('hdd'); $element->setLabel('Hội đồng duyệt')->setValue($hdd['ma'])->setDescription('<a href="' . $link . '">Xem hội đồng duyệt</a>')->setDecorators(array('ViewHelper', array('Description', array('tag' => 'span', 'escape' => false)), array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))->setAttribs(array('class' => 'text-input', 'disabled' => 'disabled'))->setOrder(100); $form->addElement($element); } // Popuate Bo Mon if (!empty($de_tai->bo_mon_id)) { $boMons = Khcn_Api::_()->getDbTable('bo_mon', 'default')->getBoMonByDonViAssoc($de_tai->ma_don_vi); $form->bo_mon_id->setMultiOptions($boMons)->setValue($de_tai->bo_mon_id); } $form->populate($de_tai->toArray()); return; } $form->preValidation($_POST); if (!$form->isValid($this->getRequest()->getPost())) { return; } $ma = trim($form->getValue('ma')); if (!empty($ma)) { if (!Default_Model_Functions::kiem_tra_ma($ma, null, true, 2)) { $_SESSION['msg'] = 'Lỗi !. Mã đề tài không đúng định dạng, vui lòng kiểm tra lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/de-tai'); } if ($this->de_tai->kiem_tra_id_ma($de_tai_id, $ma)) { $_SESSION['msg'] = 'Lỗi !. Mã đề tài đã tồn tại, vui lòng kiểm tra lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/de-tai'); } } $db = Zend_Registry::get('connectDB'); $db->beginTransaction(); try { if ($form->file_tom_tat->getFileName(null, false) != null) { //determine filename and extension $info = pathinfo($form->file_tom_tat->getFileName(null, false)); $filename = $info['filename']; $ext = $info['extension'] ? "." . $info['extension'] : ""; //filter for renaming.. prepend with current time $file_tom_tat = time() . '_' . Default_Model_Functions::convert_vi_to_en($filename) . $ext; $form->file_tom_tat->addFilter(new Zend_Filter_File_Rename(array("target" => $file_tom_tat, "overwrite" => true))); $form->getValue('file_tom_tat'); $de_tai->file_tom_tat = $file_tom_tat; } $values = $form->getValues(); if (empty($values['file_tom_tat'])) { unset($values['file_tom_tat']); } if (empty($values['ngay_gia_han'])) { $values['ngay_gia_han'] = new Zend_Db_Expr('NULL'); } $values['ma'] = $ma; $values['kinh_phi'] = $values['kinh_phi'] != '' ? str_ireplace(',', '', $values['kinh_phi']) : 0; $de_tai->setFromArray($values); $de_tai->save(); $thanhViens = array(); $thanhViens[] = array('giang_vien_id' => $values['chu_nhiem'], 'nhiem_vu' => 1); for ($i = 0; $i < $values['code']; $i++) { $thanhViens[] = array('giang_vien_id' => $values['thanh_vien_' . $i], 'nhiem_vu' => 0); } $tableDK->setChucVu($de_tai_id, $thanhViens); $db->commit(); } catch (Zend_Db_Exception $e) { $db->rollBack(); $_SESSION['msg'] = 'Lỗi !. Đã có lỗi trong quá trình xử lý, vui lòng thử lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/de-tai'); } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/de-tai'); }