- Template Name */ public function getTemplateName() { return 'uitypes/Date.tpl'; } /** * Function to get the Display Value, for the current field type with given DB Insert Value * @param $value * @return */ public function getDisplayValue($value) { if(empty($value)){ return $value; } else { $dateValue = self::getDisplayDateValue($value); } if($dateValue == '--') { return ""; } else { return $dateValue; } } /** * Function to get the Value of the field in the format, the user provides it on Save * @param $value * @return */ public function getUserRequestValue($value) { return $this->getDisplayValue($value); } /** * Function to get the DB Insert Value, for the current field type with given User Value * @param $value * @return */ public function getDBInsertValue($value) { return self::getDBInsertedValue($value); } /** * Function converts the date to database format * @param $value * @return */ public static function getDBInsertedValue($value) { return DateTimeField::convertToDBFormat($value); } /** * Function to get the display value in edit view * @param $value * @return converted value */ public function getEditViewDisplayValue($value) { if (empty($value) || $value === ' ') { $value = trim($value); $fieldInstance = $this->get('field')->getWebserviceFieldObject(); $moduleName = $this->get('field')->getModule()->getName(); $fieldName = $fieldInstance->getFieldName(); //Restricted Fields for to show Default Value if (($fieldName === 'birthday' && $moduleName === 'Contacts') || ($fieldName === 'validtill' && $moduleName === 'Quotes') || $moduleName === 'Products' ) { return $value; } //Special Condition for field 'support_end_date' in Contacts Module if ($fieldName === 'support_end_date' && $moduleName === 'Contacts') { $value = DateTimeField::convertToUserFormat(date('Y-m-d', strtotime("+1 year"))); } elseif ($fieldName === 'support_start_date' && $moduleName === 'Contacts') { $value = DateTimeField::convertToUserFormat(date('Y-m-d')); } } else { $value = DateTimeField::convertToUserFormat($value); } return $value; } /** * Function to get Date value for Display * @param $date * @return */ public static function getDisplayDateValue($date) { $date = new DateTimeField($date); return $date->getDisplayDate(); } /** * Function to get DateTime value for Display * @param $dateTime * @return */ public static function getDisplayDateTimeValue($dateTime) { $date = new DateTimeField($dateTime); return $date->getDisplayDateTimeValue(); } public function getListSearchTemplateName() { return 'uitypes/DateFieldSearchView.tpl'; } }