[Vtigercrm-developers] How to have an empty DateTime field in Detail View?

Alan Lord alanslists at gmail.com
Mon Mar 26 15:54:47 GMT 2018


Thanks Nilay,

I'll check this out in the next few days. Appreciate your feedback.

Al

On 26/03/18 10:37, nilay khatri wrote:
> Hi Alan,
> 
> yes you have to take care of the time part as well.
> 
> We needed a similar datetime field in Helpdesk module so we did override 
> date, time and datetime in Helpdesk. See if that couldbe of any help:
> 
> HelpDesk/uitype/DateTime.php
> class HelpDesk_Datetime_UIType extends Vtiger_Datetime_UIType {
> 	
> 	public function getDisplayValue($value) {
> 	if(empty($value))
> 	return null;
> 	if($this->hasTimeComponent($value)) {
> 	return self::getDisplayDateTimeValue($value);
> 	}else{
> 	return $this->getDisplayDateValue($value);
> 	}
> 	}
> 	
> 	public function hasTimeComponent($value) {
> 	$component = explode(' ', $value);
> 	if(!empty($component[1])) {
> 	return true;
> 	}
> 	return false;
> 	}
> 	
> 	}
> 
> 
> 
> Date.php:
> 
> class HelpDesk_Date_UIType extends Vtiger_Date_UIType {
> 	
> 	/**
> 	* Function to get the display value in edit view
> 	* @param $value
> 	* @return converted value
> 	*/
> 	public function getEditViewDisplayValue($value) {
> 	if (!empty($value)) {
> 	return parent::getEditViewDisplayValue($value);
> 	}
> 	return $value;
> 	}
> 	
> 	
> 	}
> 
> Time.php:
> 
> class HelpDesk_Time_UIType extends Vtiger_Time_UIType {
> 	
> 	
> 	
> 	/**
> 	* Function to get the display value in edit view
> 	* @param $value
> 	* @return converted value
> 	*/
> 	public function getEditViewDisplayValue($value) {
> 	if(!empty($value)){
> 	return parent::getEditViewDisplayValue($value);
> 	}
> 	return '';
> 	}
> 	
> 	/**
> 	* Function to get the calendar event call duration value in hour format
> 	* @param type $fieldName
> 	* @param type $value
> 	* @return <Vtiger_Time_UIType> - getTimeValue
> 	*/
> 	public function getDisplayTimeDifferenceValue($fieldName, $value) {
> 	$userModel = Users_Privileges_Model::getCurrentUserModel();
> 	$date = new DateTime($value);
> 	
> 	$dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s'));
> 	$value = $dateTimeField->getDisplayTime();
> 	return $value;
> 	}
> 	
> 	}
> 
> 
> 
> 
> On Mon, Mar 26, 2018 at 2:47 PM, Alan Lord <alanslists at gmail.com 
> <mailto:alanslists at gmail.com>> wrote:
> 
>     Bump
> 
> 
>     On 12/03/18 11:47, Alan Lord wrote:
> 
>         This is on vtiger 6.3
> 
>         I have added a new DateTime column to a custom module and want
>         to display the value in DetailView only, e.g. displaytype 2.
> 
>         If the row's value is NULL I want the field to show nothing. But
>         irrespective of what UIType I try (5, 6, 70) if the database row
>         is empty, the field in DetailView shows NOW(). I do not want this.
> 
>         I think it is down to the constructor of the DateTimeField class
>         but If I tweak this to make $value = NULL or '' I still get the
>         Time part(?), and I'm not sure if this will break anything else
>         either?
> 
> 
>         TIA
> 
> 
>         Al
> 
> 
> 
> 
>     _______________________________________________
>     http://www.vtiger.com/
> 
> 
> 
> 
> _______________________________________________
> http://www.vtiger.com/
> 




More information about the vtigercrm-developers mailing list