This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
||
3 | /********************************************************************************* |
||
4 | * SugarCRM Community Edition is a customer relationship management program developed by |
||
5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
||
6 | |||
7 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
8 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or modify it under |
||
11 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
12 | * Free Software Foundation with the addition of the following permission added |
||
13 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
14 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
15 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
16 | * |
||
17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
19 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
20 | * details. |
||
21 | * |
||
22 | * You should have received a copy of the GNU Affero General Public License along with |
||
23 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
24 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
25 | * 02110-1301 USA. |
||
26 | * |
||
27 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
28 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
29 | * |
||
30 | * The interactive user interfaces in modified source and object code versions |
||
31 | * of this program must display Appropriate Legal Notices, as required under |
||
32 | * Section 5 of the GNU Affero General Public License version 3. |
||
33 | * |
||
34 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
35 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
36 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
37 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
39 | ********************************************************************************/ |
||
40 | |||
41 | /********************************************************************************* |
||
42 | |||
43 | * Description: Class defining queries of predefined charts. |
||
44 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
||
45 | * All Rights Reserved. |
||
46 | * Contributor(s): ______________________________________. |
||
47 | ********************************************************************************/ |
||
48 | |||
49 | |||
50 | |||
51 | class PredefinedChart{ |
||
52 | var $params = array(); |
||
53 | |||
54 | function __construct(){ |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
||
59 | */ |
||
60 | function PredefinedChart(){ |
||
61 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
||
62 | if(isset($GLOBALS['log'])) { |
||
63 | $GLOBALS['log']->deprecated($deprecatedMessage); |
||
64 | } |
||
65 | else { |
||
66 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
||
67 | } |
||
68 | self::__construct(); |
||
69 | } |
||
70 | |||
71 | |||
72 | function predefinedChartQuery($chart, $params=array()){ |
||
73 | switch($chart){ |
||
74 | case 'pipeline_by_sales_stage': |
||
75 | case 'pipeline_by_sales_stage_funnel': |
||
76 | return $this->pipelineBySalesStageQuery(); |
||
77 | case 'lead_source_by_outcome': |
||
78 | return $this->leadSourceByOutcomeQuery($params); |
||
79 | case 'outcome_by_month': |
||
80 | return $this->outcomeByMonthQuery(); |
||
81 | case 'pipeline_by_lead_source': |
||
82 | return $this->pipelineByLeadSourceQuery($params); |
||
83 | case 'my_modules_used_last_30_days': |
||
84 | return $this->myModuleUsageLast30Days(); |
||
85 | default: |
||
86 | return $this->customChartQuery($chart); |
||
87 | } |
||
88 | return; |
||
0 ignored issues
–
show
|
|||
89 | } |
||
90 | |||
91 | function pipelineBySalesStageQuery(){ |
||
92 | |||
93 | |||
94 | global $current_user; |
||
95 | global $timedate; |
||
96 | global $app_list_strings; |
||
97 | |||
98 | //get the dates to display |
||
99 | $user_date_start = $current_user->getPreference('pbss_date_start'); |
||
100 | |||
101 | if (!empty($user_date_start) && !isset($_REQUEST['pbss_date_start'])) { |
||
102 | $date_start = $timedate->to_display_date($user_date_start, false); |
||
103 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_date_start'] is:"); |
||
104 | $GLOBALS['log']->debug($user_date_start); |
||
105 | } |
||
106 | elseif (isset($_REQUEST['pbss_date_start']) && $_REQUEST['pbss_date_start'] != '') { |
||
107 | $date_start = $_REQUEST['pbss_date_start']; |
||
108 | $ds = $timedate->to_db_date($date_start, false); |
||
109 | $current_user->setPreference('pbss_date_start', $ds); |
||
110 | $GLOBALS['log']->debug("_REQUEST['pbss_date_start'] is:"); |
||
111 | $GLOBALS['log']->debug($_REQUEST['pbss_date_start']); |
||
112 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_date_start'] is:"); |
||
113 | $GLOBALS['log']->debug($current_user->getPreference('pbss_date_start')); |
||
114 | } |
||
115 | else { |
||
116 | $date_start = $timedate->nowDate(); |
||
117 | } |
||
118 | |||
119 | $user_date_end = $current_user->getPreference('pbss_date_end'); |
||
120 | if (!empty($user_date_end) && !isset($_REQUEST['pbss_date_end'])) { |
||
121 | $date_end = $timedate->to_display_date($user_date_end, false); |
||
122 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_date_end'] is:"); |
||
123 | $GLOBALS['log']->debug($user_date_end); |
||
124 | } |
||
125 | elseif (isset($_REQUEST['pbss_date_end']) && $_REQUEST['pbss_date_end'] != '') { |
||
126 | $date_end = $_REQUEST['pbss_date_end']; |
||
127 | $de = $timedate->to_db_date($date_end, false); |
||
128 | $current_user->setPreference('pbss_date_end', $de); |
||
129 | $GLOBALS['log']->debug("_REQUEST['pbss_date_end'] is:"); |
||
130 | $GLOBALS['log']->debug($_REQUEST['pbss_date_end']); |
||
131 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_date_end'] is:"); |
||
132 | $GLOBALS['log']->debug( $current_user->getPreference('pbss_date_end')); |
||
133 | } |
||
134 | else { |
||
135 | $date_end = $timedate->asUserDate($timedate->fromString("2010-01-01")); |
||
136 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_date_end'] not found. Using: ".$date_end); |
||
137 | } |
||
138 | |||
139 | $tempx = array(); |
||
140 | $datax = array(); |
||
141 | $datax_selected= array(); |
||
142 | $user_tempx = $current_user->getPreference('pbss_sales_stages'); |
||
143 | //get list of sales stage keys to display |
||
144 | if (!empty($user_tempx) && count($user_tempx) > 0 && !isset($_REQUEST['pbss_sales_stages'])) { |
||
145 | $tempx = $user_tempx ; |
||
146 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_sales_stages'] is:"); |
||
147 | $GLOBALS['log']->debug($user_tempx ); |
||
148 | } |
||
149 | elseif (isset($_REQUEST['pbss_sales_stages']) && count($_REQUEST['pbss_sales_stages']) > 0) { |
||
150 | $tempx = $_REQUEST['pbss_sales_stages']; |
||
151 | $current_user->setPreference('pbss_sales_stages', $_REQUEST['pbss_sales_stages']); |
||
152 | $GLOBALS['log']->debug("_REQUEST['pbss_sales_stages'] is:"); |
||
153 | $GLOBALS['log']->debug($_REQUEST['pbss_sales_stages']); |
||
154 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_sales_stages'] is:"); |
||
155 | $GLOBALS['log']->debug($current_user->getPreference('pbss_sales_stages')); |
||
156 | } |
||
157 | |||
158 | //set $datax using selected sales stage keys |
||
159 | if (count($tempx) > 0) { |
||
160 | foreach ($tempx as $key) { |
||
161 | $datax[$key] = $app_list_strings['sales_stage_dom'][$key]; |
||
162 | array_push($datax_selected,$key); |
||
163 | } |
||
164 | } |
||
165 | else { |
||
166 | $datax = $app_list_strings['sales_stage_dom']; |
||
167 | $datax_selected = array_keys($app_list_strings['sales_stage_dom']); |
||
168 | } |
||
169 | $GLOBALS['log']->debug("datax is:"); |
||
170 | $GLOBALS['log']->debug($datax); |
||
171 | |||
172 | $ids = array(); |
||
173 | $new_ids = array(); |
||
174 | $user_ids = $current_user->getPreference('pbss_ids'); |
||
175 | //get list of user ids for which to display data |
||
176 | if (!empty($user_ids) && count($user_ids) != 0 && !isset($_REQUEST['pbss_ids'])) { |
||
177 | $ids = $user_ids; |
||
178 | |||
179 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_ids'] is:"); |
||
180 | $GLOBALS['log']->debug($user_ids); |
||
181 | } |
||
182 | elseif (isset($_REQUEST['pbss_ids']) && count($_REQUEST['pbss_ids']) > 0) { |
||
183 | $ids = $_REQUEST['pbss_ids']; |
||
184 | $current_user->setPreference('pbss_ids', $_REQUEST['pbss_ids']); |
||
185 | $GLOBALS['log']->debug("_REQUEST['pbss_ids'] is:"); |
||
186 | $GLOBALS['log']->debug($_REQUEST['pbss_ids']); |
||
187 | $GLOBALS['log']->debug("USER PREFERENCES['pbss_ids'] is:"); |
||
188 | $GLOBALS['log']->debug($current_user->getPreference('pbss_ids')); |
||
189 | } |
||
190 | else { |
||
191 | $ids = get_user_array(false); |
||
192 | $ids = array_keys($ids); |
||
193 | |||
194 | } |
||
195 | |||
196 | $user_id = $ids; |
||
197 | $opp = new Opportunity; |
||
198 | $where=""; |
||
199 | //build the where clause for the query that matches $user |
||
200 | $count = count($user_id); |
||
201 | $id = array(); |
||
202 | $user_list = get_user_array(false); |
||
203 | foreach ($user_id as $key) { |
||
204 | $new_ids[$key] = $user_list[$key]; |
||
205 | } |
||
206 | if ($count>0) { |
||
207 | foreach ($new_ids as $the_id=>$the_name) { |
||
208 | $id[] = "'".$the_id."'"; |
||
209 | } |
||
210 | $ids = join(",",$id); |
||
211 | $where .= "opportunities.assigned_user_id IN ($ids) "; |
||
212 | |||
213 | } |
||
214 | //build the where clause for the query that matches $datax |
||
215 | $count = count($datax); |
||
216 | $dataxArr = array(); |
||
217 | if ($count>0) { |
||
218 | |||
219 | foreach ($datax as $key=>$value) { |
||
220 | $dataxArr[] = "'".$key."'"; |
||
221 | } |
||
222 | $dataxArr = join(",",$dataxArr); |
||
223 | $where .= "AND opportunities.sales_stage IN ($dataxArr) "; |
||
224 | } |
||
225 | |||
226 | $date_start = $timedate->swap_formats($date_start, $timedate->get_date_format(), $timedate->dbDayFormat); |
||
227 | $date_end = $timedate->swap_formats($date_end, $timedate->get_date_format(), $timedate->dbDayFormat); |
||
228 | //build the where clause for the query that matches $date_start and $date_end |
||
229 | $where .= " AND opportunities.date_closed >= ". db_convert("'".$date_start."'",'date'). " |
||
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
230 | AND opportunities.date_closed <= ".db_convert("'".$date_end."'",'date') ; |
||
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
231 | $where .= " AND opportunities.assigned_user_id = users.id AND opportunities.deleted=0 "; |
||
232 | |||
233 | //Now do the db queries |
||
234 | //query for opportunity data that matches $datax and $user |
||
235 | $query = " SELECT opportunities.sales_stage, |
||
236 | users.user_name, |
||
237 | opportunities.assigned_user_id, |
||
238 | count( * ) AS opp_count, |
||
239 | sum(amount_usdollar/1000) AS total |
||
240 | FROM users,opportunities "; |
||
241 | $query .= "WHERE " .$where; |
||
242 | $query .= " GROUP BY opportunities.sales_stage"; |
||
243 | |||
244 | $additional_params = array( 'date_start' => $date_start, 'date_closed' => $date_end, ); |
||
245 | |||
246 | $this->params = $additional_params; |
||
247 | |||
248 | return $query; |
||
249 | } |
||
250 | |||
251 | function leadSourceByOutcomeQuery($filters){ |
||
252 | |||
253 | |||
254 | global $current_user; |
||
255 | global $app_list_strings; |
||
256 | |||
257 | $tempx = array(); |
||
258 | $datax = array(); |
||
259 | $selected_datax = array(); |
||
260 | //get list of sales stage keys to display |
||
261 | |||
262 | $tempx = $filters['lsbo_lead_sources']; |
||
263 | if (!empty($lsbo_lead_sources) && count($lsbo_lead_sources) > 0 && !isset($_REQUEST['lsbo_lead_sources'])) { |
||
0 ignored issues
–
show
The variable
$lsbo_lead_sources seems to never exist, and therefore empty should always return true . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
264 | $GLOBALS['log']->fatal("user->getPreference('lsbo_lead_sources') is:"); |
||
265 | $GLOBALS['log']->fatal($tempx); |
||
266 | } |
||
267 | elseif (isset($_REQUEST['lsbo_lead_sources']) && count($_REQUEST['lsbo_lead_sources']) > 0) { |
||
268 | $tempx = $_REQUEST['lsbo_lead_sources']; |
||
269 | $current_user->setPreference('lsbo_lead_sources', $_REQUEST['lsbo_lead_sources']); |
||
270 | $GLOBALS['log']->fatal("_REQUEST['lsbo_lead_sources'] is:"); |
||
271 | $GLOBALS['log']->fatal($_REQUEST['lsbo_lead_sources']); |
||
272 | $GLOBALS['log']->fatal("user->getPreference('lsbo_lead_sources') is:"); |
||
273 | $GLOBALS['log']->fatal($current_user->getPreference('lsbo_lead_sources')); |
||
274 | } |
||
275 | //set $datax using selected sales stage keys |
||
276 | if (!empty($tempx) && sizeof($tempx) > 0) { |
||
277 | foreach ($tempx as $key) { |
||
278 | $datax[$key] = $app_list_strings['lead_source_dom'][$key]; |
||
279 | array_push($selected_datax,$key); |
||
280 | } |
||
281 | } |
||
282 | else { |
||
283 | $datax = $app_list_strings['lead_source_dom']; |
||
284 | $selected_datax = array_keys($app_list_strings['lead_source_dom']); |
||
285 | } |
||
286 | |||
287 | $datay = $datax; |
||
288 | |||
289 | $ids = $filters['lsbo_ids']; |
||
290 | //get list of user ids for which to display data |
||
291 | if (!empty($ids) && count($ids) != 0 && !isset($_REQUEST['lsbo_ids'])) { |
||
292 | $GLOBALS['log']->debug("_SESSION['lsbo_ids'] is:"); |
||
293 | $GLOBALS['log']->debug($ids); |
||
294 | } |
||
295 | elseif (isset($_REQUEST['lsbo_ids']) && count($_REQUEST['lsbo_ids']) > 0) { |
||
296 | $ids = $_REQUEST['lsbo_ids']; |
||
297 | $current_user->setPreference('lsbo_ids', $_REQUEST['lsbo_ids']); |
||
298 | $GLOBALS['log']->debug("_REQUEST['lsbo_ids'] is:"); |
||
299 | $GLOBALS['log']->debug($_REQUEST['lsbo_ids']); |
||
300 | $GLOBALS['log']->debug("user->getPreference('lsbo_ids') is:"); |
||
301 | $GLOBALS['log']->debug($current_user->getPreference('lsbo_ids')); |
||
302 | } |
||
303 | else { |
||
304 | $ids = get_user_array(false); |
||
305 | $ids = array_keys($ids); |
||
306 | } |
||
307 | |||
308 | $user_id = $ids; |
||
309 | |||
310 | $opp = new Opportunity(); |
||
311 | $where=""; |
||
312 | //build the where clause for the query that matches $user |
||
313 | $count = count($user_id); |
||
314 | $id = array(); |
||
315 | if ($count>0) { |
||
316 | foreach ($user_id as $the_id) { |
||
317 | $id[] = "'".$the_id."'"; |
||
318 | } |
||
319 | $ids = join(",",$id); |
||
320 | $where .= "opportunities.assigned_user_id IN ($ids) "; |
||
321 | |||
322 | } |
||
323 | |||
324 | //build the where clause for the query that matches $datay |
||
325 | $count = count($datay); |
||
326 | $datayArr = array(); |
||
327 | if ($count>0) { |
||
328 | |||
329 | foreach ($datay as $key=>$value) { |
||
330 | $datayArr[] = "'".$key."'"; |
||
331 | } |
||
332 | $datayArr = join(",",$datayArr); |
||
333 | $where .= "AND opportunities.lead_source IN ($datayArr) "; |
||
334 | } |
||
335 | $query = "SELECT lead_source,sales_stage,sum(amount_usdollar/1000) as total,count(*) as opp_count FROM opportunities "; |
||
336 | $query .= "WHERE " .$where." AND opportunities.deleted=0 "; |
||
337 | $query .= " GROUP BY sales_stage,lead_source ORDER BY lead_source,sales_stage"; |
||
338 | |||
339 | return $query; |
||
340 | } |
||
341 | |||
342 | function outcomeByMonthQuery(){ |
||
343 | |||
344 | |||
345 | global $current_user; |
||
346 | global $timedate; |
||
347 | |||
348 | $user_date_start = $current_user->getPreference('obm_date_start'); |
||
349 | if (!empty($user_date_start) && !isset($_REQUEST['obm_date_start'])) { |
||
350 | $date_start =$user_date_start; |
||
351 | $GLOBALS['log']->debug("USER PREFERENCES['obm_date_start'] is:"); |
||
352 | $GLOBALS['log']->debug($user_date_start); |
||
353 | } |
||
354 | elseif (isset($_REQUEST['obm_year']) && $_REQUEST['obm_year'] != '') { |
||
355 | $date_start = $_REQUEST['obm_year'].'-01-01'; |
||
356 | $current_user->setPreference('obm_date_start', $date_start); |
||
357 | $GLOBALS['log']->debug("_REQUEST['obm_date_start'] is:"); |
||
358 | $GLOBALS['log']->debug($_REQUEST['obm_date_start']); |
||
359 | $GLOBALS['log']->debug("_SESSION['obm_date_start'] is:"); |
||
360 | $GLOBALS['log']->debug($current_user->getPreference('obm_date_start')); |
||
361 | } |
||
362 | else { |
||
363 | $date_start = date('Y').'-01-01'; |
||
364 | } |
||
365 | $user_date_end = $current_user->getPreference('obm_date_end'); |
||
366 | if (!empty($user_date_end) && !isset($_REQUEST['obm_date_end'])) { |
||
367 | $date_end =$user_date_end; |
||
368 | $GLOBALS['log']->debug("USER PREFERENCES['obm_date_end'] is:"); |
||
369 | $GLOBALS['log']->debug($date_end); |
||
370 | } |
||
371 | elseif (isset($_REQUEST['obm_year']) && $_REQUEST['obm_year'] != '') { |
||
372 | $date_end = $_REQUEST['obm_year'].'-12-31'; |
||
373 | $current_user->setPreference('obm_date_end', $date_end ); |
||
374 | $GLOBALS['log']->debug("_REQUEST['obm_date_end'] is:"); |
||
375 | $GLOBALS['log']->debug($_REQUEST['obm_date_end']); |
||
376 | $GLOBALS['log']->debug("USER PREFERENCES['obm_date_end'] is:"); |
||
377 | $GLOBALS['log']->debug($current_user->getPreference('obm_date_end')); |
||
378 | } |
||
379 | else { |
||
380 | $date_end = date('Y').'-12-31'; |
||
381 | } |
||
382 | |||
383 | $ids = array(); |
||
384 | //get list of user ids for which to display data |
||
385 | $user_ids = $current_user->getPreference('obm_ids'); |
||
386 | if (!empty($user_ids) && count($user_ids) != 0 && !isset($_REQUEST['obm_ids'])) { |
||
387 | $ids = $user_ids; |
||
388 | $GLOBALS['log']->debug("USER PREFERENCES['obm_ids'] is:"); |
||
389 | $GLOBALS['log']->debug($user_ids); |
||
390 | } |
||
391 | elseif (isset($_REQUEST['obm_ids']) && count($_REQUEST['obm_ids']) > 0) { |
||
392 | $ids = $_REQUEST['obm_ids']; |
||
393 | $current_user->setPreference('obm_ids', $_REQUEST['obm_ids']); |
||
394 | $GLOBALS['log']->debug("_REQUEST['obm_ids'] is:"); |
||
395 | $GLOBALS['log']->debug($_REQUEST['obm_ids']); |
||
396 | $GLOBALS['log']->debug("USER PREFRENCES['obm_ids'] is:"); |
||
397 | $GLOBALS['log']->debug($current_user->getPreference('obm_ids')); |
||
398 | } |
||
399 | else { |
||
400 | $ids = get_user_array(false); |
||
401 | $ids = array_keys($ids); |
||
402 | } |
||
403 | |||
404 | $user_id = $ids; |
||
405 | |||
406 | $where = ""; |
||
407 | //build the where clause for the query that matches $user |
||
408 | $count = count($user_id); |
||
409 | $id = array(); |
||
410 | if ($count>0) { |
||
411 | foreach ($user_id as $the_id) { |
||
412 | $id[] = "'".$the_id."'"; |
||
413 | } |
||
414 | $ids = join(",",$id); |
||
415 | $where .= "opportunities.assigned_user_id IN ($ids) "; |
||
416 | |||
417 | } |
||
418 | |||
419 | // cn: adding user-pref date handling |
||
420 | $dateStartDisplay = $timedate->asUserDate($timedate->fromString($date_start)); |
||
421 | $dateEndDisplay = $timedate->asUserDate($timedate->fromString($date_end)); |
||
422 | |||
423 | $opp = new Opportunity(); |
||
424 | //build the where clause for the query that matches $date_start and $date_end |
||
425 | $where .= "AND opportunities.date_closed >= ".db_convert("'".$date_start."'",'date')." AND opportunities.date_closed <= ".db_convert("'".$date_end."'",'date')." AND opportunities.deleted=0"; |
||
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
426 | $query = "SELECT sales_stage,".db_convert('opportunities.date_closed','date_format',array("'%Y-%m'"),array("'YYYY-MM'"))." as m, sum(amount_usdollar/1000) as total, count(*) as opp_count FROM opportunities "; |
||
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
427 | $query .= "WHERE ".$where; |
||
428 | $query .= " GROUP BY sales_stage,".db_convert('opportunities.date_closed','date_format',array("'%Y-%m'"),array("'YYYY-MM'"))."ORDER BY m"; |
||
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
429 | return $query; |
||
430 | } |
||
431 | |||
432 | function pipelineByLeadSourceQuery($filters){ |
||
433 | |||
434 | |||
435 | global $current_user; |
||
436 | global $app_list_strings; |
||
437 | |||
438 | $tempx = array(); |
||
439 | $datax = array(); |
||
440 | $selected_datax = array(); |
||
441 | |||
442 | //get list of sales stage keys to display |
||
443 | $user_tempx = $filters['pbls_lead_sources']; |
||
444 | if (!empty($user_tempx) && count($user_tempx) > 0 && !isset($_REQUEST['pbls_lead_sources'])) { |
||
445 | $tempx = $user_tempx; |
||
446 | $GLOBALS['log']->debug("USER PREFERENCES['pbls_lead_sources'] is:"); |
||
447 | $GLOBALS['log']->debug($user_tempx); |
||
448 | } |
||
449 | elseif (isset($_REQUEST['pbls_lead_sources']) && count($_REQUEST['pbls_lead_sources']) > 0) { |
||
450 | $tempx = $_REQUEST['pbls_lead_sources']; |
||
451 | $current_user->setPreference('pbls_lead_sources', $_REQUEST['pbls_lead_sources']); |
||
452 | $GLOBALS['log']->debug("_REQUEST['pbls_lead_sources'] is:"); |
||
453 | $GLOBALS['log']->debug($_REQUEST['pbls_lead_sources']); |
||
454 | $GLOBALS['log']->debug("USER PREFERENCES['pbls_lead_sources'] is:"); |
||
455 | $GLOBALS['log']->debug($current_user->getPreference('pbls_lead_sources')); |
||
456 | } |
||
457 | |||
458 | //set $datax using selected sales stage keys |
||
459 | if (count($tempx) > 0) { |
||
460 | foreach ($tempx as $key) { |
||
461 | $datax[$key] = $app_list_strings['lead_source_dom'][$key]; |
||
462 | array_push($selected_datax,$key); |
||
463 | } |
||
464 | } |
||
465 | else { |
||
466 | $datax = $app_list_strings['lead_source_dom']; |
||
467 | $selected_datax = array_keys($app_list_strings['lead_source_dom']); |
||
468 | } |
||
469 | |||
470 | $legends = $datax; |
||
471 | |||
472 | $ids = array(); |
||
473 | $user_ids = $filters['pbls_ids']; |
||
474 | //get list of user ids for which to display data |
||
475 | if (!empty($user_ids) && count($user_ids) > 0){ |
||
476 | $ids = $user_ids; |
||
477 | } |
||
478 | else { |
||
479 | $ids = get_user_array(false); |
||
480 | $ids = array_keys($ids); |
||
481 | } |
||
482 | |||
483 | $user_id = $ids; |
||
484 | $opp = new Opportunity; |
||
485 | //Now do the db queries |
||
486 | //query for opportunity data that matches $legends and $user |
||
487 | $where=""; |
||
488 | //build the where clause for the query that matches $user |
||
489 | |||
490 | $count = count($user_id); |
||
491 | $id = array(); |
||
492 | if ($count > 0 && !empty($user_id)) { |
||
493 | foreach ($user_id as $the_id) { |
||
494 | $id[] = "'".$the_id."'"; |
||
495 | } |
||
496 | $ids = join(",",$id); |
||
497 | $where .= "opportunities.assigned_user_id IN ($ids) "; |
||
498 | |||
499 | } |
||
500 | if(!empty($where)) $where .= 'AND'; |
||
501 | //build the where clause for the query that matches $datax |
||
502 | $count = count($legends); |
||
503 | $legendItem = array(); |
||
504 | if ($count > 0 && !empty($legends)) { |
||
505 | |||
506 | foreach ($legends as $key=>$value) { |
||
507 | $legendItem[] = "'".$key."'"; |
||
508 | } |
||
509 | $legendItems = join(",",$legendItem); |
||
510 | $where .= " opportunities.lead_source IN ($legendItems) "; |
||
511 | } |
||
512 | $query = "SELECT lead_source,sum(amount_usdollar/1000) as total,count(*) as opp_count FROM opportunities "; |
||
513 | $query .= "WHERE ".$where." AND opportunities.deleted=0 "; |
||
514 | $query .= "GROUP BY lead_source ORDER BY total DESC"; |
||
515 | |||
516 | return $query; |
||
517 | } |
||
518 | |||
519 | function myModuleUsageLast30Days() { |
||
520 | global $current_user; |
||
521 | $dateValue = db_convert("'".$timedate->getNow()->modify("-30 days")->asDb()."'" ,"datetime"); |
||
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
522 | |||
523 | $query = "SELECT tracker.module_name as module_name "; |
||
524 | $query .= ",COUNT(*) count FROM tracker "; |
||
525 | $query .= "WHERE tracker.user_id = '$current_user->id' AND tracker.module_name != 'UserPreferences' AND tracker.date_modified > $dateValue "; |
||
526 | $query .= "GROUP BY tracker.module_name ORDER BY count DESC"; |
||
527 | |||
528 | return $query; |
||
529 | } |
||
530 | |||
531 | |||
532 | // This function will grab a query from the custom directory to be used for charting |
||
533 | function customChartQuery($chart){ |
||
534 | if (file_exists('custom/Charts/' . $chart . '.php')){ |
||
535 | require_once('custom/Charts/' . $chart . '.php'); |
||
536 | return customChartQuery(); |
||
537 | } |
||
538 | else return false; |
||
539 | } |
||
540 | } |
||
541 | |||
542 | |||
543 | ?> |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.