public function indexAction() { // TODO Auto-generated {0}::indexAction() default action\ $this->view->form = $form = new Admin_Form_FilterGV(); $params = Default_Model_Functions::filterParams($this->_getAllParams()); $_SESSION['filterGV'] = $_SERVER['QUERY_STRING']; if (empty($params['order'])) { $params['order'] = 'ho_ten'; } if (empty($params['direction'])) { $params['direction'] = 'ASC'; } $form->populate($params); $giangViens = $this->giang_vien->loc($params); if ($giangViens == null) { $_SESSION['msg'] = 'Không tìm thấy dữ liệu, vui lòng thử lại .'; $_SESSION['type_msg'] = 'attention'; } //Set the properties for the pagination $paginator = Zend_Paginator::factory($giangViens); $paginator->setItemCountPerPage(20); $paginator->setPageRange(10); $paginator->setCurrentPageNumber($this->_getParam('page', 1)); Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml'); $paginator->setView($this->view); $this->view->paginator = $paginator; $this->view->filterValues = $params; $this->view->order = $params['order']; $this->view->direction = $params['direction']; }
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 sua($tin_tuc) { $mo_ta_chi_tiet = Default_Model_Functions::strip_magic_slashes($tin_tuc->getMoTaChiTiet()); if ($tin_tuc->getHinh() != null) { $data = array('tieu_de' => $tin_tuc->getTieuDe(), 'file' => $tin_tuc->getHinh(), 'trang_thai' => $tin_tuc->getTrangThai(), 'mo_ta_tom_tat' => $tin_tuc->getMoTaTomTat(), 'mo_ta_chi_tiet' => $mo_ta_chi_tiet); } else { $data = array('tieu_de' => $tin_tuc->getTieuDe(), 'trang_thai' => $tin_tuc->getTrangThai(), 'mo_ta_tom_tat' => $tin_tuc->getMoTaTomTat(), 'mo_ta_chi_tiet' => $mo_ta_chi_tiet); } return $this->update($data, 'id = ' . (int) $tin_tuc->getId()); }
public function gopYAction() { // TODO Auto-generated {0}::indexAction() default action $this->view->form = $form = new Admin_Form_GopY_Filter(); $params = Default_Model_Functions::filterParams($this->_getAllParams()); $form->populate($params); $this->view->tinhTrangOptions = $tinhTrangOptions = array('initial' => 'Mới', 'pending' => 'Đang kiểm tra', 'failure' => 'Hủy bỏ', 'completed' => 'Hoàn thành'); //Set the properties for the pagination $this->view->paginator = $paginator = Khcn_Api::_()->getDbTable('gop_y', 'default')->getGopYsPaginator($params); $paginator->setItemCountPerPage(20); $paginator->setPageRange(10); $paginator->setCurrentPageNumber($this->_getParam('page', 1)); Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml'); $this->view->filterValues = $params; }
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 indexAction() { $this->view->form = $form = new Admin_Form_BoMon_Filter(); $params = Default_Model_Functions::filterParams($this->_getAllParams()); $form->populate($params); // TODO Auto-generated {0}::indexAction() default action $this->view->paginator = $paginator = Khcn_Api::_()->getDbTable('bo_mon', 'default')->getBoMonsPaginator($params); $currentPage = 1; //Check if the user is not on page 1 $page = $this->_getParam('page'); if (!empty($page)) { //Where page is the current page $currentPage = $this->_getParam('page'); } //Set the properties for the pagination $paginator->setItemCountPerPage(15); $paginator->setPageRange(10); $paginator->setCurrentPageNumber($currentPage); Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml'); $paginator->setView($this->view); }
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 save_dt($id_don_vi, $nam, $deTais, $thanhViens) { $tableDT = Khcn_Api::_()->getDbTable('de_tai', 'default'); $tableGV = Khcn_Api::_()->getDbTable('giang_vien', 'default'); $don_vi = $this->don_vi->getDonVi($id_don_vi); $ma_don_vi = $don_vi['ma']; $str = ''; $dts = array(); $tong_so_gv = 0; $gv_sai_ma_don_vi = array(); $gv_sai_ma_hoc_vi = array(); $session = new Zend_Session_Namespace('imported_dt'); $session->ma_don_vi = $id_don_vi; $session->nam = $nam; $db = $tableDT->getAdapter(); $db->beginTransaction(); try { for ($i = 0; $i < count($deTais); $i++) { //tao ma cho de tai //linh vuc $ma_loai_lv = 'CS'; $linh_vuc = $this->linh_vuc->getLVByMa($deTais[$i]['linh_vuc']); $loai_lv = $this->loai_lv->getLoaiLV($linh_vuc['ma_loai']); if ($loai_lv) { $ma_loai_lv = $loai_lv['ma']; } $id_linh_vuc = $linh_vuc['id']; $cap_quan_ly = $deTais[$i]['cap_quan_ly']; $ma = ''; if ($cap_quan_ly != 'cap-khoa') { $count_m_t = 1; while ($ma == '') { if ($count_m_t < 10) { $temp_m = $ma_loai_lv . $nam . '-0' . $count_m_t++; } else { $temp_m = $ma_loai_lv . $nam . '-' . $count_m_t++; } if (!$this->de_tai->kiem_tra_ma($temp_m)) { $ma = $temp_m; } } } //dinh dang ngay thang $sperator = array('/', ' '); $tgbd = '01-' . str_replace($sperator, '-', $deTais[$i]['thoi_gian_bat_dau']); $tght = '01-' . str_replace($sperator, '-', $deTais[$i]['thoi_gian_hoan_thanh']); $thoi_gian_bat_dau = date('Y-m-d', strtotime($tgbd)); $thoi_gian_hoan_thanh = date('Y-m-d', strtotime($tght)); //cap quan ly if ($cap_quan_ly == 'cap-khoa') { $cap_quan_ly = 1; } else { $cap_quan_ly = 2; } $kinh_phi = 0; if (!empty($deTais[$i]['kinh_phi']) && is_numeric($deTais[$i]['kinh_phi'])) { $kinh_phi = $deTais[$i]['kinh_phi']; } try { //them de tai $de_tai = $tableDT->createRow(); $de_tai->ma = $ma; $de_tai->ten = $deTais[$i]['ten']; $de_tai->thoi_gian_bat_dau = $thoi_gian_bat_dau; $de_tai->thoi_gian_hoan_thanh = $thoi_gian_hoan_thanh; $de_tai->tinh_trang = 1; $de_tai->kinh_phi = $kinh_phi; $de_tai->cap_quan_ly = $cap_quan_ly; $de_tai->ma_linh_vuc = $id_linh_vuc; $de_tai->ma_don_vi = $id_don_vi; $de_tai->nam = $nam; $kq = $de_tai->save(); } catch (Zend_Db_Exception $e) { $str .= $deTais[$i]['ten'] . ', '; continue; } $dt_id = $de_tai->id; $dts[$dt_id] = $dt_id; //them thanh vien $tvs = $thanhViens[$i]; foreach ($tvs as $thanh_vien) { $tong_so_gv++; $tv_id = null; $sai_ma_hv = false; $sai_ma_dv = false; //kiem tra neu co nhap ma giang vien $ho_ten = Default_Model_Functions::tach_ho_ten($thanh_vien['ho_ten']); // Get ID Hoc Vi $id_hv = $this->hoc_vi->getIdByMa($thanh_vien['hoc_vi']); if ($id_hv == null) { $sai_ma_hv = true; //set hoc vi la chua xac dinh $id_hv = 9; } // Get ID Don Vi if (!empty($thanh_vien['ghi_chu'])) { //kiem tra neu nhap sai ma don vi,thi dua vao danh sach gv chua xac dinh don vi $id_dv = $this->don_vi->getIdByMa($thanh_vien['ghi_chu']); if ($id_dv == null) { $sai_ma_dv = true; $id_dv = $id_don_vi; } } else { $id_dv = $id_don_vi; } if (!empty($thanh_vien['ma_giang_vien'])) { //kiem tra ton tai ma giang vien $giang_vien = $tableGV->getGVByMa($thanh_vien['ma_giang_vien']); if ($giang_vien) { $tv_id = $giang_vien->id; } } // Get GV By ho_ten, dv, hv if ($tv_id == null) { $giang_vien = $tableGV->checkExistImport($thanh_vien['ho_ten'], $id_dv, $id_hv); if ($giang_vien == null) { $giang_vien = $tableGV->createRow(); $giang_vien->ho = $ho_ten['ho']; $giang_vien->ten = $ho_ten['ten']; $giang_vien->ma_hoc_vi = $id_hv; $giang_vien->ma_don_vi = $id_dv; $giang_vien->trang_thai = 1; $giang_vien->save(); } $tv_id = $giang_vien->id; } //neu co nhap email - so dien thoai thi cap nhat lai if (!empty($thanh_vien['email'])) { $giang_vien->email = $thanh_vien['email']; } if (!empty($thanh_vien['so_dien_thoai'])) { $giang_vien->so_dien_thoai = $thanh_vien['so_dien_thoai']; } $giang_vien->save(); // Them dang ky $dang_ky = new Default_Model_DangKy(); $dang_ky->setMaDeTai($dt_id)->setMaGiangVien($tv_id)->setNhiemVu($thanh_vien['nhiem_vu']); $dang_ky->them(); if ($sai_ma_dv) { $gv_sai_ma_don_vi[$tv_id] = $thanh_vien['ho_ten']; } if ($sai_ma_hv) { $gv_sai_ma_hoc_vi[$tv_id] = $thanh_vien['ho_ten']; } } } $db->commit(); if ($str != '') { $_SESSION['msg'] = "Lỗi. Các đề tài sau đây không import được : " . $str; $_SESSION['type_msg'] = "error"; } else { $_SESSION['msg'] = "Thành công! Dữ liệu đã được lưu trữ."; $_SESSION['type_msg'] = "success"; } $session->deTais = $dts; $session->tong_so_gv = $tong_so_gv; $session->gv_sai_ma_hoc_vi = $gv_sai_ma_hoc_vi; $session->gv_sai_ma_don_vi = $gv_sai_ma_don_vi; } catch (Exception $e) { $db->rollBack(); throw $e; } }
public function them($mail_tb) { $data = array('tieu_de' => $mail_tb->getTieuDe(), 'noi_dung' => Default_Model_Functions::strip_magic_slashes($mail_tb->getNoiDung()), 'loai' => $mail_tb->getLoai(), 'ngay_goi' => $mail_tb->getNgayGoi(), 'noi_nhan' => $mail_tb->getNoiNhan()); return $this->insert($data); }
public function suaHdntAction() { $form = new Admin_Form_HDNT(); $form->removeElement('submitCon'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $this->view->form = $form; if ($this->getRequest()->isPost()) { $form->preValidation($_POST); $formData = $this->getRequest()->getPost(); foreach ($formData as $k => $v) { if (strpos($k, 'thanh_vien_') !== false && $v == '0') { $formData[$k] = null; } } if ($form->isValid($formData)) { if (!Default_Model_Functions::kiem_tra_ma($form->getValue('ma'), 'HDNT', true)) { $_SESSION['msg'] = 'Lỗi !. Mã hội đồng nghiệm thu không đúng định dạng, vui lòng kiểm tra lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/hoi-dong/danh-sach-hdnt?' . $_SESSION['filterHDNT']); } if ($this->hd_nghiem_thu->kiem_tra_id_ma($form->getValue('id'), $form->getValue('ma'))) { $_SESSION['msg'] = 'Lỗi !. Mã hội đồng nghiệm thu đã tồn tại, vui lòng kiểm tra lại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/hoi-dong/danh-sach-hdnt?' . $_SESSION['filterHDNT']); } $db = Zend_Registry::get('connectDB'); $db->beginTransaction(); try { $hdnt = new Default_Model_Hdnt(); $id = $form->getValue('id'); $hdnt->setId($id)->setMa($form->getValue('ma'))->setNgayThanhLap(date('Y-m-d', strtotime($form->getValue('ngay_thanh_lap'))))->setGhiChu($form->getValue('ghi_chu'))->setMaDeTai($_POST['hdnt'][0]); $hdnt->sua(); //cat nhat thanh vien hoi dong $pc_nghiem_thu = new Default_Model_Pcnt(); $thanhViens = array(); for ($i = 0; $i <= 4; $i++) { //kiem tra co chon giang vien if ($form->getValue('thanh_vien_' . $i) != 0) { $thanhViens[] = array('ma_giang_vien' => $form->getValue('thanh_vien_' . $i), 'chuc_danh' => $i); } } $pc_nghiem_thu->capNhatTV($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/hoi-dong/danh-sach-hdnt?' . $_SESSION['filterHDNT']); } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/hoi-dong/danh-sach-hdnt?' . $_SESSION['filterHDNT']); } else { $form->populate($formData); } } else { $id = $this->_getParam('id'); if (!empty($id)) { $data = $this->hd_nghiem_thu->getHDNT($id); if ($data != null) { $data = $this->hd_nghiem_thu->HDNTToArray($data); $data['ma_linh_vuc'] = $this->hd_nghiem_thu->getLinhVucByDT($data['id']); $data['nam'] = substr($data['ma'], 4, 4); //lay danh sach giang vien trong hoi dong $thanhViens = $this->pc_nghiem_thu->getDSGVByHDNT($id); $i = 0; foreach ($thanhViens as $thanh_vien) { $dv = 'don_vi_' . $i; $tv = 'thanh_vien_' . $i; $data[$dv] = $thanh_vien['ma_don_vi']; $giang_vien = new Default_Model_GiangVien(); $gvOptions = $giang_vien->getDSGVByDV($thanh_vien['ma_don_vi']); $form->{$tv}->addMultiOptions($gvOptions)->setValue($thanh_vien['ma_giang_vien']); $i++; } $form->populate($data); } else { $_SESSION['msg'] = 'Lỗi !. Mã hội đồng nghiệm thu không tồn tại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/hoi-dong/danh-sach-hdnt?' . $_SESSION['filterHDNT']); } } else { $this->_redirect('/admin/hoi-dong/danh-sach-hdnt?' . $_SESSION['filterHDNT']); } } }
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() { $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() { $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'); }
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 sua($thong_bao) { $data = array('tieu_de' => $thong_bao->getTieuDe(), 'noi_dung' => Default_Model_Functions::strip_magic_slashes($thong_bao->getNoiDung()), 'trang_thai' => $thong_bao->getTrangThai(), 'loai' => $thong_bao->getLoai()); return $this->update($data, 'id = ' . (int) $thong_bao->getId()); }
public function getGiangVienByHoTen($ho_ten) { $ho_ten = Default_Model_Functions::tach_ho_ten($ho_ten); $ho = $ho_ten['ho']; $ten = $ho_ten['ten']; var_dump($ho_ten); $select = $this->select()->where('ho = ?', $ho)->where('ten = ?', $ten); echo $select; die; return $this->fetchRow($select); }
public function suaGvNgoaiSguAction() { $form = new Admin_Form_GiangVien(); $don_vi = new Default_Model_DonVi(); $form->removeElement('submitCon'); $form->removeElement('ma'); $form->submitExit->setLabel('Lưu'); $form->cancel->setLabel('Không lưu'); $form->ma_don_vi->setMultiOptions($don_vi->getDSDVNgoaiSGU()); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $giang_vien = new Default_Model_GiangVien(); $ho_ten = Default_Model_Functions::tach_ho_ten($form->getValue('ho_ten')); $giang_vien->setId($form->getValue('id'))->setMa(null)->setHo($ho_ten['ho'])->setTen($ho_ten['ten'])->setChucVu($form->getValue('chuc_vu'))->setMaDonVi($form->getValue('ma_don_vi'))->setMaHocVi($form->getValue('ma_hoc_vi'))->setEmail($form->getValue('email'))->setSoDienThoai($form->getValue('so_dien_thoai')); $kq = $giang_vien->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/ds-ngoai-sgu?' . $_SESSION['filterGV']); } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật .'; $_SESSION['type_msg'] = 'success'; $this->_redirect('/admin/ds-ngoai-sgu?' . $_SESSION['filterGV']); } else { $form->populate($formData); } } else { $id = $this->_getParam('id'); if (!empty($id)) { $data = $this->giang_vien->getGiangVien($id); if ($data != null) { $data = $this->giang_vien->GiangVienToArray($data); $data['ho_ten'] = $data['ho'] . ' ' . $data['ten']; $form->populate($data); } else { $_SESSION['msg'] = 'Lỗi !. Mã giảng viên không tồn tại .'; $_SESSION['type_msg'] = 'error'; $this->_redirect('/admin/ds-ngoai-sgu?' . $_SESSION['filterGV']); } } else { $this->_redirect('/admin/ds-ngoai-sgu?' . $_SESSION['filterGV']); } } }
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 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 baiGiangAction() { $params = Default_Model_Functions::filterParams($this->_getAllParams()); $this->view->form = $form = new Default_Form_SearchDT(); $form->populate($params); if (empty($params['from'])) { $params['from'] = date('Y'); } if (empty($params['direction'])) { $params['direction'] = 'DESC'; } $params['loai_linh_vuc'] = 'bai-giang'; $deTais = Khcn_Api::_()->getDbTable('de_tai', 'default')->getDeTais($params); //Set the properties for the pagination $paginator = Zend_Paginator::factory($deTais); $paginator->setItemCountPerPage(20); $paginator->setPageRange(10); $paginator->setCurrentPageNumber($this->_getParam('page', 1)); Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('includes/pagination.phtml'); $paginator->setView($this->view); $this->view->paginator = $paginator; $this->view->capQLs = $capQLs = Default_Model_Constraints::detai_capquanly(); }
public function listQueuesAction() { // TODO Auto-generated {0}::indexAction() default action\ $table = Khcn_Api::_()->getDbTable('queue', 'default'); $this->view->form = $form = new Admin_Form_FilterGV(); $form->removeElement('reset'); $params = Default_Model_Functions::filterParams($this->_getAllParams()); $form->populate($params); $params['page'] = $this->_getParam('page', 1); // Delete or Approve queue if (!empty($params['submit'])) { if ($params['submit'] == 'Xóa') { foreach ($params['items'] as $id) { $queue = Khcn_Api::_()->getItem('default_queue', $id); if ($queue != null) { $queue->delete(); } } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được xóa.'; $_SESSION['type_msg'] = 'success'; } else { if ($params['submit'] == 'Xác nhận') { foreach ($params['items'] as $id) { $queue = Khcn_Api::_()->getItem('default_queue', $id); if ($queue != null) { $this->addGiangVien($queue); $queue->delete(); } } $_SESSION['msg'] = 'Thành công !. Dữ liệu đã được cập nhật.'; $_SESSION['type_msg'] = 'success'; } } } //Set the properties for the pagination $paginator = $table->getQueuesPaginator($params); $paginator->setItemCountPerPage(20); $this->view->paginator = $paginator; $this->view->filterValues = $params; }
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'); }