diff --git a/.gitignore b/.gitignore index 1b58a932618a4de5ed7cea69c5b4ac23fd04787a..585abce2b3edb78d0d5e1b4aa2f0db528c23fccb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor/* !vendor/.htaccess +.vscode/* \ No newline at end of file diff --git a/layouts/v7/modules/Settings/Workflows/resources/AdvanceFilter.js b/layouts/v7/modules/Settings/Workflows/resources/AdvanceFilter.js index d1559a86a1dbf47ccce49d3606ac791d6c4cd16f..efa5a1ac09a0642424764a72c859da68d5be732c 100644 --- a/layouts/v7/modules/Settings/Workflows/resources/AdvanceFilter.js +++ b/layouts/v7/modules/Settings/Workflows/resources/AdvanceFilter.js @@ -384,12 +384,20 @@ Vtiger_Currency_Field_Js('Workflows_Currency_Field_Js',{},{ Vtiger_Time_Field_Js('Workflows_Time_Field_Js',{},{ + /** + * Function to get the user time format + */ + getTimeFormat : function(){ + console.log(this.get('time-format')) + return this.get('time-format'); + }, + /** * Function to get the ui * @return - input text field */ getUi : function() { - var html = '<input type="text" class="getPopupUi time inputElement" name="'+ this.getName() +'" value="'+ this.getValue() + '" />'+ + var html = '<input type="text" class="getPopupUi time inputElement" name="'+ this.getName() +'" data-time-format="'+ this.getTimeFormat() + '" value="'+ this.getValue() + '" />'+ '<input type="hidden" name="valuetype" value="'+this.get('workflow_valuetype')+'" />'; var element = jQuery(html); return this.addValidationToElement(element); diff --git a/layouts/v7/modules/Settings/Workflows/resources/Edit.js b/layouts/v7/modules/Settings/Workflows/resources/Edit.js index fa768106f00f1c639d86c75f9ceab54b72d4c662..3f433fdd2739a879ca6bc3c1ae3eb634c98ba7e7 100644 --- a/layouts/v7/modules/Settings/Workflows/resources/Edit.js +++ b/layouts/v7/modules/Settings/Workflows/resources/Edit.js @@ -147,12 +147,13 @@ Settings_Vtiger_Edit_Js("Settings_Workflows_Edit_Js", { clonedPopupUi.find('.fieldValueContainer div').prepend(clonedDateElement); } else if (fieldValueElement.hasClass('time')) { clonedPopupUi.find('.textType').find('option[value="rawtext"]').attr('data-ui', 'input'); + var timeFormat = fieldValueElement.data('time-format'); if (valueType == 'rawtext') { var value = fieldValueElement.val(); } else { value = ''; } - var clonedTimeElement = '<input type="text" style="width: 30%;" class="timepicker-default fieldValue inputElement" value="' + value + '" data-input="true" >' + var clonedTimeElement = '<input type="text" style="width: 30%;" class="timepicker-default fieldValue inputElement" value="' + value + '" data-format="' + timeFormat + '" data-input="true" >' clonedPopupUi.find('.fieldValueContainer div').prepend(clonedTimeElement); } else if (fieldValueElement.hasClass('boolean')) { clonedPopupUi.find('.textType').find('option[value="rawtext"]').attr('data-ui', 'input'); diff --git a/modules/Settings/Workflows/models/Record.php b/modules/Settings/Workflows/models/Record.php index fa99605f44e46cfd014f9d943a38e6373e0b2b19..5f3fb4530b58b4fe7642e652c5ef5d505a95cbe0 100644 --- a/modules/Settings/Workflows/models/Record.php +++ b/modules/Settings/Workflows/models/Record.php @@ -245,8 +245,18 @@ class Settings_Workflows_Record_Model extends Settings_Vtiger_Record_Model { $isDateValue = true; $valueArray[$i] = DateTimeField::convertToUserFormat($valueArray[$i]); } + if(Vtiger_Functions::isTimeValue($valueArray[$i])){ + $isTimeValue = true; + $userModel = Users_Record_Model::getCurrentUserModel(); + $hourFormat = $userModel->get('hour_format'); + if($hourFormat == '24') { + $valueArray[$i] = date('H:i', strtotime($valueArray[$i])); + } else { + $valueArray[$i] = date('g:i A', strtotime($valueArray[$i])); + } + } } - if($isDateValue) { + if($isDateValue || $isTimeValue ) { $value = implode(',', $valueArray); } // End diff --git a/vtlib/Vtiger/Functions.php b/vtlib/Vtiger/Functions.php index be26f3d920f24a221b57ec38e12a5b7cfb007c9b..5464064a8ee7c4ddeb60d3a1e2233845e44439f8 100644 --- a/vtlib/Vtiger/Functions.php +++ b/vtlib/Vtiger/Functions.php @@ -1287,6 +1287,28 @@ class Vtiger_Functions { } } + /** + * Function to check if a string is a valid time value or not + * @param string $value string to check if that is a time value or not + * @return boolean Returns true if $value is time else returns false + */ + static function isTimeValue($value) { + $value = trim($value); + $patterns = array( + '/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/', + '/^(1[0-2]|0?[1-9]):[0-5][0-9] (AM|PM)$/i', + '/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/' + ); + + foreach ($patterns as $pattern) { + if (preg_match($pattern, $value)) { + return true; + } + } + + return false; + } + /** * Function to get name and email value from a string of format <b>Your Name<youremail@company.com></b> * @param String $string Name and email value in required format.