[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+*********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 *************************************************************************************/ 10 11 /** 12 * Portal ListView Model Class 13 */ 14 class Portal_ListView_Model extends Vtiger_ListView_Model { 15 16 public function getListViewEntries($pagingModel) { 17 $db = PearDatabase::getInstance(); 18 $moduleModel = Vtiger_Module_Model::getInstance('Portal'); 19 20 $listQuery = $this->getQuery(); 21 22 $startIndex = $pagingModel->getStartIndex(); 23 $pageLimit = $pagingModel->getPageLimit(); 24 25 $orderBy = $this->get('orderby'); 26 $sortOrder = $this->get('sortorder'); 27 28 if(!empty($orderBy)) 29 $listQuery .= ' ORDER BY '.$orderBy.' '.$sortOrder; 30 31 32 $listQuery .= " LIMIT $startIndex,".($pageLimit); 33 34 $listResult = $db->pquery($listQuery, array()); 35 36 $listViewEntries = array(); 37 38 for($i = 0; $i < $db->num_rows($listResult); $i++) { 39 $row = $db->fetch_row($listResult, $i); 40 $listViewEntries[$row['portalid']] = array(); 41 $listViewEntries[$row['portalid']]['portalname'] = $row['portalname']; 42 $listViewEntries[$row['portalid']]['portalurl'] = $row['portalurl']; 43 $listViewEntries[$row['portalid']]['createdtime'] = Vtiger_Date_UIType::getDisplayDateValue($row['createdtime']); 44 } 45 $index = 0; 46 foreach($listViewEntries as $recordId => $record) { 47 $rawData = $db->query_result_rowdata($listResult, $index++); 48 $record['id'] = $recordId; 49 $listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record, $rawData); 50 } 51 52 return $listViewRecordModels; 53 } 54 55 public function getQuery() { 56 $query = 'SELECT portalid, portalname, portalurl, createdtime FROM vtiger_portal'; 57 $searchValue = $this->get('search_value'); 58 if(!empty($searchValue)) 59 $query .= " WHERE portalname LIKE '".$searchValue."%'"; 60 61 return $query; 62 } 63 64 public function calculatePageRange($record, $pagingModel) { 65 $pageLimit = $pagingModel->getPageLimit(); 66 $page = $pagingModel->get('page'); 67 68 $startSequence = ($page - 1) * $pageLimit + 1; 69 $endSequence = $startSequence + count($record) - 1; 70 $recordCount = Portal_ListView_Model::getRecordCount(); 71 72 $pageCount = intval($recordCount / $pageLimit); 73 if(($recordCount % $pageLimit) != 0) 74 $pageCount++; 75 if($pageCount == 0) 76 $pageCount = 1; 77 if($page < $pageCount) 78 $nextPageExists = true; 79 else 80 $nextPageExists = false; 81 82 $result = array( 83 'startSequence' => $startSequence, 84 'endSequence' => $endSequence, 85 'recordCount' => $recordCount, 86 'pageCount' => $pageCount, 87 'nextPageExists' => $nextPageExists, 88 'pageLimit' => $pageLimit 89 ); 90 91 return $result; 92 } 93 94 public function getRecordCount() { 95 $db = PearDatabase::getInstance(); 96 $listQuery = $this->getQuery(); 97 $queryParts = explode('FROM', $listQuery); 98 $query = 'SELECT COUNT(*) AS count FROM '.$queryParts[1]; 99 $result = $db->pquery($query, array()); 100 101 return $db->query_result($result, 0, 'count'); 102 } 103 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |