/** * Ajax listing of applications */ public function listAction() { //criteria $criteria = array('application_id' => $this->_applicationId); if (null != $this->_getParam('langFilter')) { $criteria['lang'] = $this->_getParam('langFilter'); } if (null != $this->_getParam('typeFilter')) { $criteria['type_id'] = $this->_getParam('typeFilter'); } if (null != $this->_getParam('statusFilter')) { $criteria['status'] = $this->_getParam('statusFilter'); } if (null != $this->_getParam('searchFilter')) { $criteria['search_filter'] = $this->_getParam('searchFilter'); } //order $order = $this->_request->getParam('order'); if (isset($order)) { $order = array($order); } else { $order = array("p.name ASC"); } $records = Application_Model_ApplicationMapper::getInstance()->fetchAll($criteria); /* @var $record Cms_Model_Page */ foreach ($records as $record) { $data['rows'][] = array('id' => $record->get_id(), 'name' => $record->get_name(), 'status' => $this->translate($record->get_status()), 'status_dt' => HCMS_Utils_Time::timeMysql2Local($record->get_status_dt())); } $this->_helper->json->sendJson($data); }
public function formatUnlimitedDate($date, $str_unlimited = '') { if (strpos($date, '3000-01-01') !== false) { return $str_unlimited; } else { return HCMS_Utils_Time::timeMysql2Local($date); } }
/** * List action */ public function contactListAction() { $page = $this->_request->getParam('page'); $perPage = $this->_request->getParam('perPage'); $langFilter = $this->_request->getParam('langFilter'); $searchFilter = $this->_request->getParam('searchFilter'); $fromFilter = $this->_request->getParam('fromFilter'); $toFilter = $this->_request->getParam('toFilter'); $orderFilter = $this->_request->getParam('order'); if (isset($fromFilter) && !empty($fromFilter)) { $fromFilter = HCMS_Utils_Date::dateLocalToCustom($fromFilter); } if (isset($toFilter) && !empty($toFilter)) { $toFilter = HCMS_Utils_Date::dateLocalToCustom($toFilter); } if (isset($orderFilter) && !empty($orderFilter)) { $orderBy = array($orderFilter); } else { $orderBy = array('c.posted DESC'); } if (!isset($page) || $page < 1) { $page = 1; } if (!isset($perPage) || $perPage < 1 || $perPage > 100) { $perPage = 100; } $paging = array('page' => $page, 'perPage' => $perPage); $criteria = array('application_id' => $this->_applicationId); if (isset($searchFilter) && $searchFilter != "") { $criteria['search_filter'] = $searchFilter; } if (isset($langFilter) && $langFilter != "") { $criteria['lang_filter'] = $langFilter; } if (isset($fromFilter) && $fromFilter != "") { $criteria['from_filter'] = $fromFilter; } if (isset($toFilter) && $toFilter != "") { $criteria['to_filter'] = $toFilter; } $records = Contact_Model_ContactMapper::getInstance()->fetchAll($criteria, $orderBy, $paging); $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array()); $languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); /* @var $record Application_Model_Candidate */ foreach ($records as $record) { $data['rows'][] = array('id' => $record->get_id(), 'posted' => HCMS_Utils_Time::timeMysql2Local($record->get_posted()), 'first_name' => $record->get_first_name(), 'last_name' => $record->get_last_name(), 'email' => $record->get_email(), 'street' => $record->get_street(), 'country' => $record->get_country(), 'phone' => $record->get_phone(), 'mobile' => $record->get_mobile(), 'fax' => $record->get_fax(), 'zip' => $record->get_zip(), 'city' => $record->get_city(), 'gender' => $this->translate($record->get_gender()), 'description' => $record->get_description(), 'description_short' => $this->view->abbreviate($record->get_description(), 150), 'message' => $record->get_message(), 'message_short' => $this->view->abbreviate($record->get_message(), 150), 'language' => $languages[$record->get_language()]['name']); } $this->_helper->json->sendJson($data); }
/** * List ajax action */ public function listAction() { $page = $this->_request->getParam('page'); $perPage = $this->_request->getParam('perPage'); $orderFilter = $this->_request->getParam('order'); $criteria = array('application_id' => $this->_applicationId); if (null != $this->_getParam('langFilter')) { $criteria['lang'] = $this->_getParam('langFilter'); } if (null != $this->_getParam('statusFilter')) { $criteria['status'] = $this->_getParam('statusFilter'); } if (null != $this->_getParam('genderFilter')) { $criteria['gender'] = $this->_getParam('genderFilter'); } if (null != $this->_getParam('subscribed_from_dt')) { $criteria['subscribed_from'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('subscribed_from_dt')); } if (null != $this->_getParam('subscribed_to_dt')) { $criteria['subscribed_to'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('subscribed_to_dt')); } if (null != $this->_getParam('unsubscribed_from_dt')) { $criteria['unsubscribed_from'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('unsubscribed_from_dt')); } if (null != $this->_getParam('unsubscribed_to_dt')) { $criteria['unsubscribed_to'] = HCMS_Utils_Date::dateLocalToIso($this->_getParam('unsubscribed_to_dt')); } if (isset($orderFilter) && !empty($orderFilter)) { $orderBy = array($orderFilter); } else { $orderBy = array('s.subscribed_dt DESC', 's.unsubscribed_dt DESC', 's.id DESC'); } if (!isset($page) || $page < 1) { $page = 1; } if (!isset($perPage) || $perPage < 1 || $perPage > 100) { $perPage = 100; } $paging = array('page' => $page, 'perPage' => $perPage); $records = Contact_Model_SubscriptionMapper::getInstance()->fetchAll($criteria, $orderBy, $paging); $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array()); $languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); /* @var $record Contact_Model_Subscription */ foreach ($records as $record) { $data['rows'][] = array('id' => $record->get_id(), 'subscribed' => HCMS_Utils_Time::timeMysql2Local($record->get_subscribed_dt()), 'unsubscribed' => HCMS_Utils_Time::timeMysql2Local($record->get_unsubscribed_dt()), 'status' => $record->get_status(), 'first_name' => $record->get_first_name(), 'last_name' => $record->get_last_name(), 'email' => $record->get_email(), 'gender' => $this->translate($record->get_gender()), 'language' => $languages[$record->get_lang()]['name']); } $this->_helper->json->sendJson($data); }
protected function getRowData($record, $columns) { $result = array(); foreach ($columns as $columnId => $column) { if ($columnId == 'posted') { $result[$columnId] = HCMS_Utils_Time::timeMysql2Local($record->get_posted()); continue; } if ($columnId == 'language') { $result[$columnId] = $this->_languages[$record->get_language()]['name']; continue; } if ($columnId == 'gender') { $result[$columnId] = $this->translate($record->get_gender()); continue; } $methodName = 'get_' . $columnId; if (!method_exists($record, $methodName)) { continue; } $result[$columnId] = $record->{$methodName}(); if (isset($column['type']) && in_array($column['type'], array('textarea', 'message'))) { $result[$columnId . '_short'] = $this->view->abbreviate($record->{$methodName}(), 150); } } return $result; }
/** * Format mysql date * * @param string $date * @return string */ public function formatDate($date) { return HCMS_Utils_Time::timeMysql2Local($date); }
/** * Ajax listing of pages */ public function pageListAction() { //criteria $criteria = array('application_id' => $this->_applicationId); if (null != $this->_getParam('langFilter')) { $criteria['lang'] = $this->_getParam('langFilter'); } if (null != $this->_getParam('typeFilter')) { $criteria['type_id'] = $this->_getParam('typeFilter'); } if (null != $this->_getParam('categoryFilter')) { $criteria['category_id'] = $this->_getParam('categoryFilter'); } if (null != $this->_getParam('statusFilter')) { $criteria['status'] = $this->_getParam('statusFilter'); } if (null != $this->_getParam('menuFilter')) { $criteria['menu_item_id'] = $this->_getParam('menuFilter'); } if (null != $this->_getParam('searchFilter')) { $criteria['search_filter'] = $this->_getParam('searchFilter'); } //order $order = $this->_request->getParam('order'); if (isset($order)) { $order = array($order); } else { $order = array("p.title ASC"); } //paging $page = $this->_request->getParam('page'); $perPage = $this->_request->getParam('perPage'); if (!isset($page) || $page < 1) { $page = 1; } if (!isset($perPage) || $perPage < 1 || $perPage > 300) { $perPage = 20; } $paging = array('page' => $page, 'perPage' => $perPage); $records = Cms_Model_PageMapper::getInstance()->fetchAll($criteria, $order, $paging); $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array()); /* @var $record Cms_Model_Page */ foreach ($records as $record) { //find route to page $cmsRoute = new Cms_Model_Route(); $lang = null != $this->_getParam('langFilter') ? $this->_getParam('langFilter') : CURR_LANG; if (!Cms_Model_RouteMapper::getInstance()->findByPageId($record->get_id(), $cmsRoute, $lang)) { //default path $module = 'cms'; $controller = 'page'; $action = 'index'; } else { list($module, $controller, $action) = explode("/", $cmsRoute->get_path()); } $urlParams = array('module' => $module, 'controller' => $controller, 'action' => $action, 'page_id' => $record->get_id(), 'lang' => $lang); $data['rows'][] = array('id' => $record->get_id(), 'title' => $record->get_title(), 'code' => $record->get_code(), 'url_id' => $record->get_url_id(), 'type_id' => $record->get_type_id(), 'type_name' => $this->translate($record->get_type_name()), 'type_code' => $record->get_type_name(), 'user_name' => $record->get_user_name(), 'status' => $this->translate($record->get_status()), 'posted' => HCMS_Utils_Time::timeMysql2Local($record->get_posted()), 'url' => $this->view->url($urlParams, 'cms', true)); } $this->_helper->json->sendJson($data); }
public function exportToExcel($applicationId, $headerData, $records, $controller) { $logger = Zend_Registry::get('Zend_Log'); try { /** PHPExcel */ //require_once APPLICATION_PATH . '/../library/PHPExcel/PHPExcel.php'; // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set properties $objPHPExcel->getProperties()->setCreator("Horisen")->setLastModifiedBy("Horisen")->setTitle("Office XLS Test Document")->setSubject("Office XLS Test Document")->setDescription("Test document for Office XLS, generated using PHP classes.")->setKeywords("office 5 openxml php")->setCategory("Test result file"); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); //------------- HEADER settings ------------// //define style $styleHeader = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FFA0A0A0'))); $languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); //set size of every column $columns = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); foreach ($columns as $value) { $objPHPExcel->getActiveSheet()->getColumnDimension($value)->setAutoSize(true); } $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(20); //fill with data $activeSheet = $objPHPExcel->getActiveSheet(); $i = 0; foreach ($headerData as $key => $val) { $activeSheet->setCellValue($columns[$i] . "1", $controller->translate($val)); //apply style to header $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($i, "1")->applyFromArray($styleHeader); $i++; } //------------- BODY settings ------------// //define style $styleBody = array('font' => array('bold' => false), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID)); if (count($records) > 0) { //fill with data $row = 2; foreach ($records as $record) { $col = 0; foreach ($headerData as $key => $value) { if ($key == 'id' || $key == 'application_id') { continue; } if (in_array($key, array('posted', 'subscribed_dt', 'unsubscribed_dt'))) { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, HCMS_Utils_Time::timeMysql2Local($record[$key])); } else { if ($key == 'lang') { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $languages[$record[$key]]['name']); } else { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $record[$key]); } } //set size of every column $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true); //apply style to body $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->applyFromArray($styleBody); $col++; } $row++; } } return $objPHPExcel; } catch (Exception $e) { $logger->log($e->getMessage(), Zend_Log::CRIT); $logger->log("Exception in export to excel!", Zend_Log::CRIT); return false; } }