From 5a479bba47be7b3c49ae412d40dbc55f0872a9aa Mon Sep 17 00:00:00 2001 From: prasad <prasad@vtiger.com> Date: Tue, 14 May 2024 17:19:23 +0530 Subject: [PATCH] Fixed - php errors for dashboard widgets --- modules/CustomView/CustomView.php | 2 ++ modules/Install/views/Index.php | 9 ++++++--- modules/Leads/models/Module.php | 2 ++ modules/Migration/views/Index.php | 5 ++++- modules/Potentials/models/Module.php | 6 ++++++ modules/Vtiger/dashboards/History.php | 1 + modules/Vtiger/helpers/Util.php | 1 + modules/Vtiger/models/DashBoard.php | 2 +- 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/CustomView/CustomView.php b/modules/CustomView/CustomView.php index 0fc173362..27e5df9a6 100644 --- a/modules/CustomView/CustomView.php +++ b/modules/CustomView/CustomView.php @@ -916,6 +916,8 @@ class CustomView extends CRMEntity { $advft_criteria = Vtiger_Cache::get('advftCriteria',$cvid); if(!$advft_criteria){ + $advft_criteria = array(); + // Not a good approach to get all the fields if not required(May leads to Performance issue) $sql = 'SELECT groupid,group_condition FROM vtiger_cvadvfilter_grouping WHERE cvid = ? ORDER BY groupid'; $groupsresult = $adb->pquery($sql, array($cvid)); diff --git a/modules/Install/views/Index.php b/modules/Install/views/Index.php index 8fb55655f..cc8cc56d0 100644 --- a/modules/Install/views/Index.php +++ b/modules/Install/views/Index.php @@ -28,9 +28,12 @@ class Install_Index_view extends Vtiger_View_Controller { } protected function applyInstallFriendlyEnv() { - // config.inc.php - will not be ready to control this yet. - // version_compare(PHP_VERSION, '5.5.0') <= 0 ? error_reporting(E_ERROR & ~E_NOTICE & ~E_DEPRECATED) : error_reporting(E_ERROR & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT); // Production - // version_compare(PHP_VERSION, '7.0.0') >= 0 ? error_reporting(E_WARNING & ~E_NOTICE) : error_reporting(E_WARNING & ~E_NOTICE & ~E_DEPRECATED & E_ERROR & ~E_STRICT); // Debug + // config.inc.php - will not be ready to control this yet + // if overriden in dev mode skip changes. + if (error_reporting() != E_ALL) { + version_compare(PHP_VERSION, '5.5.0') <= 0 ? error_reporting(E_ERROR & ~E_NOTICE & ~E_DEPRECATED) : error_reporting(E_ERROR & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT); // Production + // version_compare(PHP_VERSION, '7.0.0') >= 0 ? error_reporting(E_WARNING & ~E_NOTICE) : error_reporting(E_WARNING & ~E_NOTICE & ~E_DEPRECATED & E_ERROR & ~E_STRICT); // Debug + } set_time_limit(0); // override limits on execution time to allow install to finish } diff --git a/modules/Leads/models/Module.php b/modules/Leads/models/Module.php index 91754b926..31a2e4d35 100644 --- a/modules/Leads/models/Module.php +++ b/modules/Leads/models/Module.php @@ -233,6 +233,8 @@ class Leads_Module_Model extends Vtiger_Module_Model { } $params = array(); + + $dateFilterSql = ''; if(!empty($dateFilter)) { $dateFilterSql = ' AND createdtime BETWEEN ? AND ? '; //appended time frame and converted to db time zone in showwidget.php diff --git a/modules/Migration/views/Index.php b/modules/Migration/views/Index.php index 23d0e0903..6d83cf687 100644 --- a/modules/Migration/views/Index.php +++ b/modules/Migration/views/Index.php @@ -28,7 +28,10 @@ class Migration_Index_View extends Vtiger_View_Controller { public function process(Vtiger_Request $request) { // Override error reporting to production mode - // version_compare(PHP_VERSION, '5.5.0') <= 0 ? error_reporting(E_WARNING & ~E_NOTICE & ~E_DEPRECATED) : error_reporting(E_WARNING & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT); + // if not set to strict development. + if (error_reporting() != E_ALL) { + version_compare(PHP_VERSION, '5.5.0') <= 0 ? error_reporting(E_WARNING & ~E_NOTICE & ~E_DEPRECATED) : error_reporting(E_WARNING & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT); + } // Migration could be heavy at-times. set_time_limit(0); diff --git a/modules/Potentials/models/Module.php b/modules/Potentials/models/Module.php index cc90a4899..869252767 100644 --- a/modules/Potentials/models/Module.php +++ b/modules/Potentials/models/Module.php @@ -56,6 +56,8 @@ class Potentials_Module_Model extends Vtiger_Module_Model { $ownerSql = ' AND smownerid = ? '; $params[] = $owner; } + + $dateFilterSql = ''; if(!empty($dateFilter)) { $dateFilterSql = ' AND closingdate BETWEEN ? AND ? '; $params[] = $dateFilter['start']; @@ -141,6 +143,8 @@ class Potentials_Module_Model extends Vtiger_Module_Model { 'INNER JOIN vtiger_sales_stage ON vtiger_potential.sales_stage = vtiger_sales_stage.sales_stage WHERE vtiger_potential.sales_stage IN ('.generateQuestionMarks($picklistvaluesmap).') GROUP BY smownerid, sales_stage ORDER BY vtiger_sales_stage.sortorderid', $params); + + $data = array(); for($i=0; $i<$db->num_rows($result); $i++) { $row = $db->query_result_rowdata($result, $i); $row['link'] = decode_html($row['sales_stage']); @@ -161,6 +165,8 @@ class Potentials_Module_Model extends Vtiger_Module_Model { //TODO need to handle security $params = array(); $params[] = 'Closed Won'; + + $dateFilterSql = ''; if(!empty($dateFilter)) { $dateFilterSql = ' AND createdtime BETWEEN ? AND ? '; //appended time frame and converted to db time zone in showwidget.php diff --git a/modules/Vtiger/dashboards/History.php b/modules/Vtiger/dashboards/History.php index b336e5185..94cc32ed0 100644 --- a/modules/Vtiger/dashboards/History.php +++ b/modules/Vtiger/dashboards/History.php @@ -27,6 +27,7 @@ class Vtiger_History_Dashboard extends Vtiger_IndexAjax_View { $modifiedTime = $request->get('modifiedtime'); //Date conversion from user to database format + $dates = array(); if(!empty($modifiedTime)) { $startDate = Vtiger_Date_UIType::getDBInsertedValue($modifiedTime['start']); $dates['start'] = getValidDBInsertDateTimeValue($startDate . ' 00:00:00'); diff --git a/modules/Vtiger/helpers/Util.php b/modules/Vtiger/helpers/Util.php index 98207671b..f793b582a 100644 --- a/modules/Vtiger/helpers/Util.php +++ b/modules/Vtiger/helpers/Util.php @@ -269,6 +269,7 @@ class Vtiger_Util_Helper { $dateTimeInUserFormat = Vtiger_Datetime_UIType::getDisplayDateTimeValue($dateTime); } + if (substr_count($dateTimeInUserFormat,' ') == 1) $dateTimeInUserFormat .= ' '; // init for meridiem if not present list($dateInUserFormat, $timeInUserFormat, $meridiem) = explode(' ', $dateTimeInUserFormat); if($meridiem && $currentUser->get('hour_format') === '12' ){ $displayTime = $timeInUserFormat.' '.$meridiem; diff --git a/modules/Vtiger/models/DashBoard.php b/modules/Vtiger/models/DashBoard.php index 9073eede0..40acffb22 100644 --- a/modules/Vtiger/models/DashBoard.php +++ b/modules/Vtiger/models/DashBoard.php @@ -118,7 +118,7 @@ class Vtiger_DashBoard_Model extends Vtiger_Base_Model { for($i=0, $len=$db->num_rows($result); $i<$len; $i++) { $row = $db->query_result_rowdata($result, $i); $data = json_decode(decode_html($row['data']), true); - $sourceModule = $data['module']; + $sourceModule = $data && isset($data['module']) ? $data['module'] : ""; if(!empty($sourceModule) && !vtlib_isModuleActive($sourceModule)) { continue; } -- GitLab