From d6ce870bbacfb1324a6a844b1ac63a713b3e5fc5 Mon Sep 17 00:00:00 2001
From: Prasad <prasad@vtiger.com>
Date: Fri, 23 Sep 2022 14:01:17 +0530
Subject: [PATCH] Fixed: Time_UIType static function call and conflict with
 base type

---
 layouts/v7/modules/Calendar/QuickCreateFollowup.tpl    |  2 +-
 .../vlayout/modules/Calendar/QuickCreateFollowup.tpl   |  2 +-
 modules/Leads/models/DetailView.php                    |  6 +++++-
 modules/Reports/models/ScheduleReports.php             |  2 +-
 modules/Vtiger/models/DetailView.php                   |  2 +-
 modules/Vtiger/models/Record.php                       |  2 +-
 modules/Vtiger/uitypes/Time.php                        | 10 +++++++++-
 modules/com_vtiger_workflow/VTSimpleTemplate.inc       |  2 +-
 8 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/layouts/v7/modules/Calendar/QuickCreateFollowup.tpl b/layouts/v7/modules/Calendar/QuickCreateFollowup.tpl
index 721a1bb61..970fb9fa4 100644
--- a/layouts/v7/modules/Calendar/QuickCreateFollowup.tpl
+++ b/layouts/v7/modules/Calendar/QuickCreateFollowup.tpl
@@ -18,7 +18,7 @@
 			{assign var="timeformat" value=$USER_MODEL->get('hour_format')}
 			{assign var="currentDate" value=Vtiger_Date_UIType::getDisplayDateValue('')}
 			{assign var="time" value=Vtiger_Time_UIType::getDisplayTimeValue(null)}
-			{assign var="currentTimeInVtigerFormat" value=Vtiger_Time_UIType::getDisplayValue($time)}
+			{assign var="currentTimeInVtigerFormat" value=Vtiger_Time_UIType::getDisplayValueUserFormat($time)}
 			{assign var=FOLLOW_UP_LABEL value={vtranslate('LBL_HOLD_FOLLOWUP_ON',"Events")}}
 			<input type="hidden" name="module" value="{$MODULE}">
 			<input type="hidden" name="action" value="SaveFollowupAjax" />
diff --git a/layouts/vlayout/modules/Calendar/QuickCreateFollowup.tpl b/layouts/vlayout/modules/Calendar/QuickCreateFollowup.tpl
index 782f75f8b..14f60b320 100755
--- a/layouts/vlayout/modules/Calendar/QuickCreateFollowup.tpl
+++ b/layouts/vlayout/modules/Calendar/QuickCreateFollowup.tpl
@@ -20,7 +20,7 @@
     {assign var="timeformat" value=$USER_MODEL->get('hour_format')}
     {assign var="currentDate" value=Vtiger_Date_UIType::getDisplayDateValue('')}
     {assign var="time" value=Vtiger_Time_UIType::getDisplayTimeValue(null)}
-    {assign var="currentTimeInVtigerFormat" value=Vtiger_Time_UIType::getDisplayValue($time)}
+    {assign var="currentTimeInVtigerFormat" value=Vtiger_Time_UIType::getDisplayValueUserFormat($time)}
     {assign var=FOLLOW_UP_LABEL value={vtranslate('LBL_HOLD_FOLLOWUP_ON',"Events")}}
     
     <form class="form-horizontal followupCreateView" id="followupQuickCreate" name="followupQuickCreate" method="post" action="index.php">
diff --git a/modules/Leads/models/DetailView.php b/modules/Leads/models/DetailView.php
index 01fe5f0b4..0f0f611e8 100644
--- a/modules/Leads/models/DetailView.php
+++ b/modules/Leads/models/DetailView.php
@@ -22,7 +22,11 @@ class Leads_DetailView_Model extends Accounts_DetailView_Model {
 		$recordModel = $this->getRecord();
 		$emailModuleModel = Vtiger_Module_Model::getInstance('Emails');
 
-		$linkModelList = Vtiger_DetailView_Model::getDetailViewLinks($linkParams);
+		$baseDetailViewModel = new Vtiger_DetailView_Model();
+		$baseDetailViewModel->setModule($moduleModel);
+		$baseDetailViewModel->setRecord($recordModel);
+
+		$linkModelList = $baseDetailViewModel::getDetailViewLinks($linkParams);
 
 		if($currentUserModel->hasModulePermission($emailModuleModel->getId())) {
 			$basicActionLink = array(
diff --git a/modules/Reports/models/ScheduleReports.php b/modules/Reports/models/ScheduleReports.php
index ece397634..e03a8b256 100644
--- a/modules/Reports/models/ScheduleReports.php
+++ b/modules/Reports/models/ScheduleReports.php
@@ -414,7 +414,7 @@ class Reports_ScheduleReports_Model extends Vtiger_Base_Model {
 		$dateTime = new DateTimeField($this->get('next_trigger_time'));
 		$nextTriggerTime = $dateTime->getDisplayDateTimeValue();
 		$valueParts = explode(' ', $nextTriggerTime);
-		$value = $valueParts[0].' '.Vtiger_Time_UIType::getDisplayValue($valueParts[1]);
+		$value = $valueParts[0].' '.Vtiger_Time_UIType::getDisplayValueUserFormat($valueParts[1]);
 		return $value;
 	}
 
diff --git a/modules/Vtiger/models/DetailView.php b/modules/Vtiger/models/DetailView.php
index b61fa79b2..dda317ccc 100644
--- a/modules/Vtiger/models/DetailView.php
+++ b/modules/Vtiger/models/DetailView.php
@@ -55,7 +55,7 @@ class Vtiger_DetailView_Model extends Vtiger_Base_Model {
 	 * @return <array> - array of link models in the format as below
 	 *                   array('linktype'=>list of link models);
 	 */
-	public static function getDetailViewLinks($linkParams) {
+	public function getDetailViewLinks($linkParams) {
 		$linkTypes = array('DETAILVIEWBASIC','DETAILVIEW');
 		$moduleModel = $this->getModule();
 		$recordModel = $this->getRecord();
diff --git a/modules/Vtiger/models/Record.php b/modules/Vtiger/models/Record.php
index ed34c5b94..f4988dcd0 100644
--- a/modules/Vtiger/models/Record.php
+++ b/modules/Vtiger/models/Record.php
@@ -212,7 +212,7 @@ class Vtiger_Record_Model extends Vtiger_Base_Model {
 		if($fieldName == "time_start" && $this->getModule()->getName() == "Emails"){
 			$date = new DateTime();
 			$dateTime = new DateTimeField($date->format('Y-m-d').' '.$this->get($fieldName));
-			$value = Vtiger_Time_UIType::getDisplayValue($dateTime->getDisplayTime());
+			$value = Vtiger_Time_UIType::getDisplayValueUserFormat($dateTime->getDisplayTime());
 			$this->set($fieldName, $value);
 			return $value;
 		}else if($fieldName == "date_start" && $this->getModule()->getName() == "Emails"){
diff --git a/modules/Vtiger/uitypes/Time.php b/modules/Vtiger/uitypes/Time.php
index b7e00d23f..c212e0cd0 100644
--- a/modules/Vtiger/uitypes/Time.php
+++ b/modules/Vtiger/uitypes/Time.php
@@ -90,7 +90,7 @@ class Vtiger_Time_UIType extends Vtiger_Base_UIType {
 	 * @param <Object> $value
 	 * @return $value
 	 */
-	public static function getDisplayValue($value, $record = false, $recordInstance=false) {
+	public function getDisplayValue($value, $record = false, $recordInstance=false) {
 		$userModel = Users_Privileges_Model::getCurrentUserModel();
 		if($userModel->get('hour_format') == '12'){
 			return self::getTimeValueInAMorPM($value);
@@ -98,6 +98,14 @@ class Vtiger_Time_UIType extends Vtiger_Base_UIType {
 		return $value;
 	}
 
+	/**
+	 * Helper static function.
+	 */
+	public static function getDisplayValueUserFormat($value, $record = false, $recordInstance = false) {
+		$instance = new static();
+		return $instance->getDisplayValue($value, $record, $recordInstance);
+	}
+
 	/**
 	 * Function to get the display value in edit view
 	 * @param $value
diff --git a/modules/com_vtiger_workflow/VTSimpleTemplate.inc b/modules/com_vtiger_workflow/VTSimpleTemplate.inc
index 3db7f28d1..4db30837a 100644
--- a/modules/com_vtiger_workflow/VTSimpleTemplate.inc
+++ b/modules/com_vtiger_workflow/VTSimpleTemplate.inc
@@ -383,7 +383,7 @@ class VTSimpleTemplate{
 				$dateTime = new DateTimeField($adb->query_result($result, $i, 'createdtime'));
 				$dateTimeValue = $dateTime->getDisplayDateTimeValue();
 				$dateTimeParts = explode(' ', $dateTimeValue);
-				$createdTime = $dateTimeParts[0].' '.Vtiger_Time_UIType::getDisplayValue($dateTimeParts[1]);
+				$createdTime = $dateTimeParts[0].' '.Vtiger_Time_UIType::getDisplayValueUserFormat($dateTimeParts[1]);
 				$timeZone = vtranslate($current_user->time_zone, 'Users');
 				$userId = $adb->query_result($result, $i, 'userid');
 				$commenter = getOwnerName($userId);
-- 
GitLab