[ 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 * Settings List View Model Class 13 */ 14 class Settings_Workflows_ListView_Model extends Settings_Vtiger_ListView_Model { 15 16 /** 17 * Function to get the list view entries 18 * @param Vtiger_Paging_Model $pagingModel 19 * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance. 20 */ 21 public function getListViewEntries($pagingModel) { 22 $db = PearDatabase::getInstance(); 23 24 $module = $this->getModule(); 25 $moduleName = $module->getName(); 26 $parentModuleName = $module->getParentName(); 27 $qualifiedModuleName = $moduleName; 28 if(!empty($parentModuleName)) { 29 $qualifiedModuleName = $parentModuleName.':'.$qualifiedModuleName; 30 } 31 $recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName); 32 33 $listFields = $module->listFields; 34 $listQuery = "SELECT "; 35 foreach ($listFields as $fieldName => $fieldLabel) { 36 $listQuery .= "$fieldName, "; 37 } 38 $listQuery .= $module->baseIndex . " FROM ". $module->baseTable; 39 40 $params = array(); 41 $sourceModule = $this->get('sourceModule'); 42 if(!empty($sourceModule)) { 43 $listQuery .= ' WHERE module_name = ?'; 44 $params[] = $sourceModule; 45 } 46 47 $startIndex = $pagingModel->getStartIndex(); 48 $pageLimit = $pagingModel->getPageLimit(); 49 50 $orderBy = $this->getForSql('orderby'); 51 if (!empty($orderBy) && $orderBy === 'smownerid') { 52 $fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel); 53 if ($fieldModel->getFieldDataType() == 'owner') { 54 $orderBy = 'COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)'; 55 } 56 } 57 if(!empty($orderBy)) { 58 $listQuery .= ' ORDER BY '. $orderBy . ' ' .$this->getForSql('sortorder'); 59 } 60 $nextListQuery = $listQuery.' LIMIT '.($startIndex+$pageLimit).',1'; 61 $listQuery .= " LIMIT $startIndex,".($pageLimit+1); 62 63 $listResult = $db->pquery($listQuery, $params); 64 $noOfRecords = $db->num_rows($listResult); 65 66 $listViewRecordModels = array(); 67 for($i=0; $i<$noOfRecords; ++$i) { 68 $row = $db->query_result_rowdata($listResult, $i); 69 $record = new $recordModelClass(); 70 $module_name = $row['module_name']; 71 72 //To handle translation of calendar to To Do 73 if($module_name == 'Calendar'){ 74 $module_name = vtranslate('LBL_TASK', $module_name); 75 }else{ 76 $module_name = vtranslate($module_name, $module_name); 77 } 78 79 $row['module_name'] = $module_name; 80 $row['execution_condition'] = vtranslate($record->executionConditionAsLabel($row['execution_condition']), 'Settings:Workflows'); 81 $record->setData($row); 82 $listViewRecordModels[$record->getId()] = $record; 83 } 84 $pagingModel->calculatePageRange($listViewRecordModels); 85 86 if($db->num_rows($listResult) > $pageLimit){ 87 array_pop($listViewRecordModels); 88 $pagingModel->set('nextPageExists', true); 89 }else{ 90 $pagingModel->set('nextPageExists', false); 91 } 92 93 $nextPageResult = $db->pquery($nextListQuery, $params); 94 $nextPageNumRows = $db->num_rows($nextPageResult); 95 if($nextPageNumRows <= 0) { 96 $pagingModel->set('nextPageExists', false); 97 } 98 return $listViewRecordModels; 99 } 100 101 /* * * 102 * Function which will get the list view count 103 * @return - number of records 104 */ 105 106 public function getListViewCount() { 107 $db = PearDatabase::getInstance(); 108 109 $module = $this->getModule(); 110 $listQuery = 'SELECT count(*) AS count FROM ' . $module->baseTable; 111 112 $sourceModule = $this->get('sourceModule'); 113 if($sourceModule) { 114 $listQuery .= " WHERE module_name = '$sourceModule'"; 115 } 116 117 $listResult = $db->pquery($listQuery, array()); 118 return $db->query_result($listResult, 0, 'count'); 119 } 120 }
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 |