[ 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 SugarCRM Public License Version 1.1.2 4 * ("License"); You may not use this file except in compliance with the 5 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL 6 * Software distributed under the License is distributed on an "AS IS" basis, 7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 8 * the specific language governing rights and limitations under the License. 9 * The Original Code is: SugarCRM Open Source 10 * The Initial Developer of the Original Code is SugarCRM, Inc. 11 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; 12 * All Rights Reserved. 13 * Contributor(s): ______________________________________. 14 ********************************************************************************/ 15 /********************************************************************************* 16 * $Header$ 17 * Description: TODO: To be written. 18 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 19 * All Rights Reserved. 20 * Contributor(s): ______________________________________.. 21 ********************************************************************************/ 22 23 /** to get the details of a KeyMetrics on Home page 24 * @returns $customviewlist Array in the following format 25 * $values = Array('Title'=>Array(0=>'image name', 26 * 1=>'Key Metrics', 27 * 2=>'home_metrics' 28 * ), 29 * 'Header'=>Array(0=>'Metrics', 30 * 1=>'Count' 31 * ), 32 * 'Entries'=>Array($cvid=>Array( 33 * 0=>$customview name, 34 * 1=>$no of records for the view 35 * ), 36 * $cvid=>Array( 37 * 0=>$customview name, 38 * 1=>$no of records for the view 39 * ), 40 * | 41 * | 42 * $cvid=>Array( 43 * 0=>$customview name, 44 * 1=>$no of records for the view 45 * ) 46 * ) 47 * 48 */ 49 function getKeyMetrics($maxval,$calCnt) 50 { 51 require_once ("data/Tracker.php"); 52 require_once ('modules/CustomView/CustomView.php'); 53 require_once ('include/logging.php'); 54 require_once('include/ListView/ListView.php'); 55 56 global $app_strings; 57 global $adb; 58 global $log; 59 global $current_language; 60 $metricviewnames = "'Hot Leads'"; 61 62 $current_module_strings = return_module_language($current_language, "CustomView"); 63 $log = LoggerManager::getLogger('metrics'); 64 65 $metriclists = getMetricList(); 66 67 // Determine if the KeyMetrics widget should appear or not? 68 if($calCnt == 'calculateCnt') { 69 return count($metriclists); 70 } 71 72 $log->info("Metrics :: Successfully got MetricList to be displayed"); 73 if(isset($metriclists)) 74 { 75 global $current_user; 76 foreach ($metriclists as $key => $metriclist) { 77 if($metriclist['module'] == "Calendar") { 78 $listquery = getListQuery($metriclist['module']); 79 $oCustomView = new CustomView($metriclist['module']); 80 $metricsql = $oCustomView->getModifiedCvListQuery($metriclist['id'],$listquery,$metriclist['module']); 81 $metricsql = Vtiger_Functions::mkCountQuery($metricsql); 82 $metricresult = $adb->query($metricsql); 83 if($metricresult) 84 { 85 $rowcount = $adb->fetch_array($metricresult); 86 $metriclists[$key]['count'] = $rowcount['count']; 87 } 88 89 } else { 90 $queryGenerator = new QueryGenerator($metriclist['module'], $current_user); 91 $queryGenerator->initForCustomViewById($metriclist['id']); 92 $metricsql = $queryGenerator->getQuery(); 93 $metricsql = Vtiger_Functions::mkCountQuery($metricsql); 94 $metricresult = $adb->query($metricsql); 95 if($metricresult) 96 { 97 $rowcount = $adb->fetch_array($metricresult); 98 $metriclists[$key]['count'] = $rowcount['count']; 99 } 100 } 101 } 102 $log->info("Metrics :: Successfully build the Metrics"); 103 } 104 $title=array(); 105 $title[]='keyMetrics.gif'; 106 $title[]=$app_strings['LBL_HOME_KEY_METRICS']; 107 $title[]='home_metrics'; 108 $header=Array(); 109 $header[]=$app_strings['LBL_HOME_METRICS']; 110 $header[]=$app_strings['LBL_MODULE']; 111 $header[]=$app_strings['LBL_HOME_COUNT']; 112 $entries=Array(); 113 if(isset($metriclists)) 114 { 115 $oddRow = true; 116 foreach($metriclists as $metriclist) 117 { 118 $value=array(); 119 $CVname = (strlen($metriclist['name']) > 20) ? (substr($metriclist['name'],0,20).'...') : $metriclist['name']; 120 $value[]='<a href="index.php?action=ListView&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.$CVname . '</a> <font style="color:#6E6E6E;">('. $metriclist['user'] .')</font>'; 121 $value[]='<a href="index.php?action=ListView&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.getTranslatedString($metriclist['module']). '</a>'; 122 $value[]='<a href="index.php?action=ListView&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.$metriclist['count'].'</a>'; 123 $entries[$metriclist['id']]=$value; 124 } 125 126 } 127 $values=Array('Title'=>$title,'Header'=>$header,'Entries'=>$entries); 128 if ( ($display_empty_home_blocks ) || (count($value)!= 0) ) 129 return $values; 130 131 } 132 133 /** to get the details of a customview Entries 134 * @returns $metriclists Array in the following format 135 * $customviewlist []= Array('id'=>custom view id, 136 * 'name'=>custom view name, 137 * 'module'=>modulename, 138 'count'=>'' 139 ) 140 */ 141 function getMetricList() 142 { 143 global $adb, $current_user; 144 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 145 146 $ssql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype"; 147 $ssql .= " where vtiger_customview.setmetrics = 1 "; 148 $sparams = array(); 149 150 if($is_admin == false){ 151 $ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status =3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%'))"; 152 array_push($sparams, $current_user->id); 153 } 154 $ssql .= " order by vtiger_customview.entitytype"; 155 $result = $adb->pquery($ssql, $sparams); 156 157 $metriclists = array(); 158 159 while($cvrow=$adb->fetch_array($result)) 160 { 161 $metricslist = Array(); 162 163 if(vtlib_isModuleActive($cvrow['entitytype'])){ 164 $metricslist['id'] = $cvrow['cvid']; 165 $metricslist['name'] = $cvrow['viewname']; 166 $metricslist['module'] = $cvrow['entitytype']; 167 $metricslist['user'] = getUserFullName($cvrow['userid']); 168 $metricslist['count'] = ''; 169 if(isPermitted($cvrow['entitytype'],"index") == "yes"){ 170 $metriclists[] = $metricslist; 171 } 172 } 173 } 174 175 return $metriclists; 176 } 177 178 ?>
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 |