[ 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 * Reports ListView Model Class 13 */ 14 class Reports_ListView_Model extends Vtiger_ListView_Model { 15 16 /** 17 * Function to get the list of listview links for the module 18 * @return <Array> - Associate array of Link Type to List of Vtiger_Link_Model instances 19 */ 20 public function getListViewLinks() { 21 $currentUserModel = Users_Record_Model::getCurrentUserModel(); 22 $privileges = Users_Privileges_Model::getCurrentUserPrivilegesModel(); 23 $basicLinks = array(); 24 if($currentUserModel->isAdminUser() || $privileges->hasModulePermission($this->getModule()->getId())) { 25 $basicLinks = array( 26 array( 27 'linktype' => 'LISTVIEWBASIC', 28 'linklabel' => 'LBL_ADD_RECORD', 29 'linkurl' => $this->getCreateRecordUrl(), 30 'linkicon' => '', 31 'childlinks' => array( 32 array ( 33 'linktype' => 'LISTVIEWBASIC', 34 'linklabel' => 'LBL_DETAIL_REPORT', 35 'linkurl' => $this->getCreateRecordUrl(), 36 'linkicon' => '', 37 ), 38 array ( 39 'linktype' => 'LISTVIEWBASIC', 40 'linklabel' => 'LBL_CHARTS', 41 'linkurl' => 'javascript:Reports_List_Js.addReport("index.php?module='.$this->getModule()->get('name').'&view=ChartEdit")', 42 'linkicon' => '', 43 ) 44 ) 45 ), 46 array( 47 'linktype' => 'LISTVIEWBASIC', 48 'linklabel' => 'LBL_ADD_FOLDER', 49 'linkurl' => 'javascript:Reports_List_Js.triggerAddFolder("'.$this->getModule()->getAddFolderUrl().'")', 50 'linkicon' => '' 51 ) 52 ); 53 } 54 55 foreach($basicLinks as $basicLink) { 56 $headerLinkInstance = Vtiger_Link_Model::getInstanceFromValues($basicLink); 57 if(!empty($basicLink['childlinks'])){ 58 foreach($basicLink['childlinks'] as $childLink) { 59 $headerLinkInstance->addChildLink(Vtiger_Link_Model::getInstanceFromValues($childLink)); 60 } 61 } 62 $links['LISTVIEWBASIC'][] = $headerLinkInstance; 63 } 64 65 return $links; 66 } 67 68 /** 69 * Function to get the list of Mass actions for the module 70 * @param <Array> $linkParams 71 * @return <Array> - Associative array of Link type to List of Vtiger_Link_Model instances for Mass Actions 72 */ 73 public function getListViewMassActions() { 74 $currentUserModel = Users_Privileges_Model::getCurrentUserPrivilegesModel(); 75 76 $massActionLinks = array(); 77 if($currentUserModel->hasModulePermission($this->getModule()->getId())) { 78 $massActionLinks[] = array( 79 'linktype' => 'LISTVIEWMASSACTION', 80 'linklabel' => 'LBL_DELETE', 81 'linkurl' => 'javascript:Reports_List_Js.massDelete("index.php?module='.$this->getModule()->get('name').'&action=MassDelete");', 82 'linkicon' => '' 83 ); 84 85 $massActionLinks[] = array( 86 'linktype' => 'LISTVIEWMASSACTION', 87 'linklabel' => 'LBL_MOVE_REPORT', 88 'linkurl' => 'javascript:Reports_List_Js.massMove("index.php?module='.$this->getModule()->get('name').'&view=MoveReports");', 89 'linkicon' => '' 90 ); 91 } 92 93 foreach($massActionLinks as $massActionLink) { 94 $links[] = Vtiger_Link_Model::getInstanceFromValues($massActionLink); 95 } 96 97 return $links; 98 } 99 100 /** 101 * Function to get the list view header 102 * @return <Array> - List of Vtiger_Field_Model instances 103 */ 104 public function getListViewHeaders() { 105 return array( 106 'reportname'=>'Report Name', 107 'description'=>'Description' 108 ); 109 } 110 111 /** 112 * Function to get the list view entries 113 * @param Vtiger_Paging_Model $pagingModel 114 * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance. 115 */ 116 public function getListViewEntries($pagingModel) { 117 $reportFolderModel = Reports_Folder_Model::getInstance(); 118 $reportFolderModel->set('folderid', $this->get('folderid')); 119 120 $orderBy = $this->get('orderby'); 121 if (!empty($orderBy) && $orderBy === 'smownerid') { 122 $fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel); 123 if ($fieldModel->getFieldDataType() == 'owner') { 124 $orderBy = 'COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)'; 125 } 126 } 127 if(!empty($orderBy)) { 128 $reportFolderModel->set('orderby', $orderBy); 129 $reportFolderModel->set('sortby', $this->get('sortorder')); 130 } 131 132 $reportRecordModels = $reportFolderModel->getReports($pagingModel); 133 $pagingModel->calculatePageRange($reportRecordModels); 134 return $reportRecordModels; 135 } 136 137 /** 138 * Function to get the list view entries count 139 * @return <Integer> 140 */ 141 public function getListViewCount() { 142 $reportFolderModel = Reports_Folder_Model::getInstance(); 143 $reportFolderModel->set('folderid', $this->get('folderid')); 144 return $reportFolderModel->getReportsCount(); 145 } 146 147 public function getCreateRecordUrl(){ 148 return 'javascript:Reports_List_Js.addReport("'.$this->getModule()->getCreateRecordUrl().'")'; 149 } 150 151 }
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 |