From 43cd579f8ce8173bdbbad588e09b281617027387 Mon Sep 17 00:00:00 2001 From: Camilo Rodriguez Date: Mon, 23 Jan 2017 13:05:54 +0000 Subject: [PATCH 01/11] PCHR-1782: Use Human Readable Time Intervals for Length of Service in Reports Length of service in reports was being shown in number of days since start date of contract. Changed to human readable format: "%y years %m months %d days". --- .../views/civihr_employee_portal.views.inc | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) mode change 100644 => 100755 civihr_employee_portal/views/civihr_employee_portal.views.inc diff --git a/civihr_employee_portal/views/civihr_employee_portal.views.inc b/civihr_employee_portal/views/civihr_employee_portal.views.inc old mode 100644 new mode 100755 index 0ebbe02a..05927365 --- a/civihr_employee_portal/views/civihr_employee_portal.views.inc +++ b/civihr_employee_portal/views/civihr_employee_portal.views.inc @@ -1025,6 +1025,50 @@ function civihr_employee_portal_views_pre_render(&$view) { if ($view->name == "approvals") { $view->result = removeAbsencesForOtherManagers($view->result); } + + if ($view->name == "civihr_report_people") { + formatLengthsOfService($view->result); + } +} + +/** + * Processes results in people report view to format length of service for each + * contact in a human readable form. + * + * @param array $results + * Array of objects (stdClass) that hold data for each contact in people report. + */ +function formatLengthsOfService(&$results) { + + foreach ($results as $key => $currentRecord) { + + if (!empty($currentRecord->civicrm_value_length_of_service_11_length_of_service)) { + $length = []; + + $startDate = new \DateTime($currentRecord->hrjc_details_hrjc_revision_period_start_date); + + $endDate = new \DateTime($currentRecord->hrjc_details_hrjc_revision_period_start_date); + $endDate->add(new DateInterval("P{$currentRecord->civicrm_value_length_of_service_11_length_of_service}D")); + + $interval = $startDate->diff($endDate); + + $years = intval($interval->format('%y')); + $months = intval($interval->format('%m')); + $days = intval($interval->format('%d')); + + if ($years > 0) { + $length[] = $years > 1 ? "$years years" : "$years year"; + } + if ($months > 0) { + $length[] = $months > 1 ? "$months months" : "$months month"; + } + if ($days > 0) { + $length[] = $days > 1 ? "$days days" : "$days day"; + } + + $currentRecord->civicrm_value_length_of_service_11_length_of_service = implode(' ', $length); + } + } } /** From 1aeff17301f0894fe2121e637c43a33aa30293ce Mon Sep 17 00:00:00 2001 From: Hitesh Jain Date: Tue, 31 Jan 2017 13:44:04 +0530 Subject: [PATCH 02/11] PCHR-1782: Changing data for employee length of service under pivot table. --- civihr_employee_portal/js/reports.js | 56 +++++++++++++++++++ .../views/civihr_employee_portal.views.inc | 4 +- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/civihr_employee_portal/js/reports.js b/civihr_employee_portal/js/reports.js index 95e821a0..2e092f09 100644 --- a/civihr_employee_portal/js/reports.js +++ b/civihr_employee_portal/js/reports.js @@ -187,6 +187,8 @@ * */ HRReport.prototype.updateFilterbox = function() { + + var that = this; $('.pvtFilterBox').each(function () { $(this).find('.pvtSearch').removeClass('pvtSearch').addClass('form-text'); $(this).find('button').addClass('btn btn-primary btn-default btn-block'); @@ -203,9 +205,63 @@ $(this).find('.pvtCheckContainer p').addClass('chr_custom-checkbox'); } + + // Altering Employee length of service data to show number of days into + // String format of Year Months and days of length of service. + // Finding the field called Employee length of service. + if($(this).find('h4').text().indexOf("Employee length of service (") >= 0 ) { + // Iterating through all the filter values. + $(this).find('p.chr_custom-checkbox').each(function(i){ + // Skip the Select All checkbox from filters. + if (!$(this).hasClass("pvtFilterSelectAllWrap")){ + // Fetching the Employee length of service from filter values. + var employee_length_service = $(this).find('span:first').text(); + // Replacing with format string calling function as parameter. + $(this).find('span:first').text(that.formatLengthsOfService(employee_length_service)); + } + }); + } + }); }; + /** + * Processes results in people report view to format length of service for each + * contact in a human readable form. + * + * @param employee_length_service + * + * @returns string + * + */ + HRReport.prototype.formatLengthsOfService = function (employee_length_service) { + + var date_current = new Date(); + var utime_target = date_current.getTime() + employee_length_service*86400*1000; + var date_target = new Date(utime_target); + + var diff_year = parseInt(date_target.getUTCFullYear() - date_current.getUTCFullYear()); + var diff_month = parseInt(date_target.getUTCMonth() - date_current.getUTCMonth()); + var diff_day = parseInt(date_target.getUTCDate() - date_current.getUTCDate()); + + var days_in_month = [31, (date_target.getUTCFullYear()%4?29:28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + var date_string = ""; + while(true) + { + date_string = ""; + date_string += (diff_year>0?diff_year + " years ":""); + + if(diff_month<0){diff_year -= 1; diff_month += 12; continue;} + date_string += (diff_month>0?diff_month + " months ":""); + + if(diff_day<0){diff_month -= 1; diff_day += days_in_month[((11+date_target.getUTCMonth())%12)]; continue;} + date_string += (diff_day>0?diff_day + " days ":""); + break; + } + + return date_string; + }; + /** * Shows the Report */ diff --git a/civihr_employee_portal/views/civihr_employee_portal.views.inc b/civihr_employee_portal/views/civihr_employee_portal.views.inc index 05927365..e273374e 100755 --- a/civihr_employee_portal/views/civihr_employee_portal.views.inc +++ b/civihr_employee_portal/views/civihr_employee_portal.views.inc @@ -1026,7 +1026,7 @@ function civihr_employee_portal_views_pre_render(&$view) { $view->result = removeAbsencesForOtherManagers($view->result); } - if ($view->name == "civihr_report_people") { + if ($view->name == "civihr_report_people" && $view->current_display == 'civihr_report_table_people' ) { formatLengthsOfService($view->result); } } @@ -1038,7 +1038,7 @@ function civihr_employee_portal_views_pre_render(&$view) { * @param array $results * Array of objects (stdClass) that hold data for each contact in people report. */ -function formatLengthsOfService(&$results) { +function formatLengthsOfService($results) { foreach ($results as $key => $currentRecord) { From c2364764114461529443eca90a4fdac687b8da18 Mon Sep 17 00:00:00 2001 From: Hitesh Jain Date: Tue, 31 Jan 2017 14:14:57 +0530 Subject: [PATCH 03/11] PCHR-1782: Coding standards issue fixed. --- civihr_employee_portal/js/reports.js | 85 ++++++++++++++----- .../views/civihr_employee_portal.views.inc | 2 - 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/civihr_employee_portal/js/reports.js b/civihr_employee_portal/js/reports.js index 2e092f09..9085db5f 100644 --- a/civihr_employee_portal/js/reports.js +++ b/civihr_employee_portal/js/reports.js @@ -207,55 +207,96 @@ } // Altering Employee length of service data to show number of days into - // String format of Year Months and days of length of service. - // Finding the field called Employee length of service. - if($(this).find('h4').text().indexOf("Employee length of service (") >= 0 ) { + // String format of Year, Months and Days of length of service. + if(that.lengthOfServiceFilter(this)) { // Iterating through all the filter values. - $(this).find('p.chr_custom-checkbox').each(function(i){ + $(this).find('p.chr_custom-checkbox').each(function(i) { // Skip the Select All checkbox from filters. - if (!$(this).hasClass("pvtFilterSelectAllWrap")){ - // Fetching the Employee length of service from filter values. - var employee_length_service = $(this).find('span:first').text(); - // Replacing with format string calling function as parameter. - $(this).find('span:first').text(that.formatLengthsOfService(employee_length_service)); + if (!$(this).hasClass("pvtFilterSelectAllWrap")) { + that.lengthOfServiceValue(this); } }); } - }); }; + /* + * Finding the filter box for field Employee length of service. + * + * @param {string} filter_data + * + * @return {bool} + */ + HRReport.prototype.lengthOfServiceFilter = function(filter_data) { + if($(filter_data).find('h4').text().indexOf("Employee length of service (") >= 0) { + return true; + } + return false; + } + + /* + * Finding and replacing the value of Employee length of service. + * + * @param {string} filter_selector - DOM element that has value. + */ + HRReport.prototype.lengthOfServiceValue = function(filter_selector) { + var that = this; + // Fetching the Employee length of service from filter values. + var employee_length_service = $(filter_selector).find('span:first').text(); + if($.isNumeric(employee_length_service)) { + $(filter_selector).find('span:first').text(that.formatLengthsOfService(employee_length_service)); + } + } + /** * Processes results in people report view to format length of service for each * contact in a human readable form. * - * @param employee_length_service - * - * @returns string + * @param {string} employee_length_service - Employee length of service field value. * + * @returns {string} date_string - Date format string for provide length of service. */ HRReport.prototype.formatLengthsOfService = function (employee_length_service) { var date_current = new Date(); - var utime_target = date_current.getTime() + employee_length_service*86400*1000; + // Calculating unix timestamp from current time adding length of service. + var utime_target = date_current.getTime() + employee_length_service * (24*60*60) * 1000; var date_target = new Date(utime_target); + // Getting difference of Dates in integer between current and target date. var diff_year = parseInt(date_target.getUTCFullYear() - date_current.getUTCFullYear()); var diff_month = parseInt(date_target.getUTCMonth() - date_current.getUTCMonth()); var diff_day = parseInt(date_target.getUTCDate() - date_current.getUTCDate()); - var days_in_month = [31, (date_target.getUTCFullYear()%4?29:28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + // Checking and assigning values for days in month considering leap year. + var days_in_month = [31, (date_target.getUTCFullYear() % 4 ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; var date_string = ""; - while(true) - { + + while(true) { + var date_noun; date_string = ""; - date_string += (diff_year>0?diff_year + " years ":""); - if(diff_month<0){diff_year -= 1; diff_month += 12; continue;} - date_string += (diff_month>0?diff_month + " months ":""); + // Checking for singular or plural for year string. + diff_year > 1 ? date_noun = "s" : date_noun = ""; + date_string += (diff_year > 0 ? diff_year + " year" + date_noun + " " : ""); - if(diff_day<0){diff_month -= 1; diff_day += days_in_month[((11+date_target.getUTCMonth())%12)]; continue;} - date_string += (diff_day>0?diff_day + " days ":""); + if(diff_month < 0) { + diff_year -= 1; + diff_month += 12; + continue; + } + // Checking for singular or plural for month string. + diff_month > 1 ? date_noun = "s" : date_noun = ""; + date_string += (diff_month > 0 ? diff_month + " month" + date_noun + " " : ""); + + if(diff_day < 0) { + diff_month -= 1; + diff_day += days_in_month[diff_month]; + continue; + } + // Checking for singular or plural for day string. + diff_day > 1 ? date_noun = "s" : date_noun = ""; + date_string += (diff_day > 0 ? diff_day + " day" + date_noun + " " : ""); break; } diff --git a/civihr_employee_portal/views/civihr_employee_portal.views.inc b/civihr_employee_portal/views/civihr_employee_portal.views.inc index e273374e..dd68f96e 100755 --- a/civihr_employee_portal/views/civihr_employee_portal.views.inc +++ b/civihr_employee_portal/views/civihr_employee_portal.views.inc @@ -1039,9 +1039,7 @@ function civihr_employee_portal_views_pre_render(&$view) { * Array of objects (stdClass) that hold data for each contact in people report. */ function formatLengthsOfService($results) { - foreach ($results as $key => $currentRecord) { - if (!empty($currentRecord->civicrm_value_length_of_service_11_length_of_service)) { $length = []; From eccf2a2f064883fb6f5edcfb82bb917422f0cce3 Mon Sep 17 00:00:00 2001 From: Hitesh Jain Date: Thu, 2 Feb 2017 14:43:52 +0530 Subject: [PATCH 04/11] PCHR-1870: Adding destination parameters while user login and redirection. --- .../civihr_employee_portal.module | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/civihr_employee_portal/civihr_employee_portal.module b/civihr_employee_portal/civihr_employee_portal.module index 6fe14ce9..fe994ace 100755 --- a/civihr_employee_portal/civihr_employee_portal.module +++ b/civihr_employee_portal/civihr_employee_portal.module @@ -5929,12 +5929,17 @@ function civihr_employee_portal_user_login_submit(&$form, &$form_state) { } /** - * Implements hook_user_login + * Implements hook_user_login(). */ function civihr_employee_portal_user_login(&$edit, $account) { - global $base_url; + if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset') { - $_GET['destination'] = user_access('access CiviCRM') ? 'civicrm/tasksassignments/dashboard#/tasks' : 'dashboard'; + $sspEntryPath = 'dashboard'; + $civicrmEntryPath = 'civicrm/tasksassignments/dashboard#/tasks'; + if (current_path() != drupal_get_destination()['destination']) { + $civicrmEntryPath = $_GET['destination']; + } + $_GET['destination'] = user_access('access CiviCRM') ? $civicrmEntryPath : $sspEntryPath; } } @@ -7240,6 +7245,9 @@ function _user_redirection() { if ((!in_array($current_path, $allowed_paths) && substr($current_path, 0, 4) !== 'user') || $current_path == 'user/register') { $redirect_path = 'welcome-page'; + if ($current_path) { + $redirect_path .= "?destination={$current_path}"; + } } } else if (in_array($current_path, ['', 'civicrm', 'civicrm/dashboard'])) { From 8e990635e181757a339c174fcbc2aa5eeaf5bc4f Mon Sep 17 00:00:00 2001 From: Hitesh Jain Date: Thu, 2 Feb 2017 20:47:37 +0530 Subject: [PATCH 05/11] PCHR-1782: Refractoring function to calculate length of service field. --- civihr_employee_portal/js/reports.js | 59 ++++++------------- .../views/civihr_employee_portal.views.inc | 16 ++--- 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/civihr_employee_portal/js/reports.js b/civihr_employee_portal/js/reports.js index 9085db5f..90e9a984 100644 --- a/civihr_employee_portal/js/reports.js +++ b/civihr_employee_portal/js/reports.js @@ -250,57 +250,34 @@ /** * Processes results in people report view to format length of service for each - * contact in a human readable form. + * contact in a human readable form using moment lib. * * @param {string} employee_length_service - Employee length of service field value. * - * @returns {string} date_string - Date format string for provide length of service. + * @returns {string} Date format string for provide length of service. */ HRReport.prototype.formatLengthsOfService = function (employee_length_service) { + var dateEnd = moment(); + var dateStart = moment().subtract(employee_length_service, 'days'); + if (!dateStart || !dateEnd) { + return null; + } - var date_current = new Date(); - // Calculating unix timestamp from current time adding length of service. - var utime_target = date_current.getTime() + employee_length_service * (24*60*60) * 1000; - var date_target = new Date(utime_target); - - // Getting difference of Dates in integer between current and target date. - var diff_year = parseInt(date_target.getUTCFullYear() - date_current.getUTCFullYear()); - var diff_month = parseInt(date_target.getUTCMonth() - date_current.getUTCMonth()); - var diff_day = parseInt(date_target.getUTCDate() - date_current.getUTCDate()); - - // Checking and assigning values for days in month considering leap year. - var days_in_month = [31, (date_target.getUTCFullYear() % 4 ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - var date_string = ""; + var days, months, m, years; - while(true) { - var date_noun; - date_string = ""; + m = moment(dateEnd); + years = m.diff(dateStart, 'years'); - // Checking for singular or plural for year string. - diff_year > 1 ? date_noun = "s" : date_noun = ""; - date_string += (diff_year > 0 ? diff_year + " year" + date_noun + " " : ""); + m.add(-years, 'years'); + months = m.diff(dateStart, 'months'); - if(diff_month < 0) { - diff_year -= 1; - diff_month += 12; - continue; - } - // Checking for singular or plural for month string. - diff_month > 1 ? date_noun = "s" : date_noun = ""; - date_string += (diff_month > 0 ? diff_month + " month" + date_noun + " " : ""); - - if(diff_day < 0) { - diff_month -= 1; - diff_day += days_in_month[diff_month]; - continue; - } - // Checking for singular or plural for day string. - diff_day > 1 ? date_noun = "s" : date_noun = ""; - date_string += (diff_day > 0 ? diff_day + " day" + date_noun + " " : ""); - break; - } + m.add(-months, 'months'); + days = m.diff(dateStart, 'days'); - return date_string; + years = years > 0 ? (years > 1 ? years + ' years ' : years + ' year ') : ''; + months = months > 0 ? (months > 1 ? months + ' months ' : months + ' month ') : ''; + days = days > 0 ? (days > 1 ? days + ' days' : days + ' day') : ''; + return (years + months + days) || '0 days'; }; /** diff --git a/civihr_employee_portal/views/civihr_employee_portal.views.inc b/civihr_employee_portal/views/civihr_employee_portal.views.inc index dd68f96e..7d666d17 100755 --- a/civihr_employee_portal/views/civihr_employee_portal.views.inc +++ b/civihr_employee_portal/views/civihr_employee_portal.views.inc @@ -1042,18 +1042,14 @@ function formatLengthsOfService($results) { foreach ($results as $key => $currentRecord) { if (!empty($currentRecord->civicrm_value_length_of_service_11_length_of_service)) { $length = []; - - $startDate = new \DateTime($currentRecord->hrjc_details_hrjc_revision_period_start_date); - - $endDate = new \DateTime($currentRecord->hrjc_details_hrjc_revision_period_start_date); - $endDate->add(new DateInterval("P{$currentRecord->civicrm_value_length_of_service_11_length_of_service}D")); - - $interval = $startDate->diff($endDate); - + $today = new DateTime(); + $past = (new DateTime())->sub(new DateInterval('P' . $currentRecord->civicrm_value_length_of_service_11_length_of_service . 'D')); + $interval = $today->diff($past); + $years = intval($interval->format('%y')); $months = intval($interval->format('%m')); $days = intval($interval->format('%d')); - + if ($years > 0) { $length[] = $years > 1 ? "$years years" : "$years year"; } @@ -1063,7 +1059,7 @@ function formatLengthsOfService($results) { if ($days > 0) { $length[] = $days > 1 ? "$days days" : "$days day"; } - + $currentRecord->civicrm_value_length_of_service_11_length_of_service = implode(' ', $length); } } From 661cca3b74be95aa561b9346db63d59ac08574b2 Mon Sep 17 00:00:00 2001 From: Camilo Rodriguez Date: Tue, 7 Feb 2017 16:17:56 +0000 Subject: [PATCH 06/11] PCHR-1870: Fix Redirection of Valid URL's with Parameters on Login Changed path for relative URI and encoded it to be passed as destination parameter, to avoid losing information on GET query. Also fixed so users with no access to CiviCRM are still redirected to destination enconded in URI, even if they don't have access, so 403 error pages are shown. --- .../civihr_employee_portal.module | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/civihr_employee_portal/civihr_employee_portal.module b/civihr_employee_portal/civihr_employee_portal.module index fe994ace..0108c756 100755 --- a/civihr_employee_portal/civihr_employee_portal.module +++ b/civihr_employee_portal/civihr_employee_portal.module @@ -5918,14 +5918,14 @@ function civihr_employee_portal_user_login_validate(&$form, &$form_state) { } function civihr_employee_portal_user_login_submit(&$form, &$form_state) { + $destination = !empty($_REQUEST['destination']) ? rawurldecode($_REQUEST['destination']) : ''; - $destination = !empty($_REQUEST['destination']) ? $_REQUEST['destination'] : ''; - if ($form_state['input']['forgot-password']) { - user_pass_submit($form, $form_state); - _drupal_session_write('custom_login_success_message', t('Details sent!')); - drupal_goto($destination); - return true; - } + if ($form_state['input']['forgot-password']) { + user_pass_submit($form, $form_state); + _drupal_session_write('custom_login_success_message', t('Details sent!')); + drupal_goto($destination); + return true; + } } /** @@ -5936,10 +5936,10 @@ function civihr_employee_portal_user_login(&$edit, $account) { if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset') { $sspEntryPath = 'dashboard'; $civicrmEntryPath = 'civicrm/tasksassignments/dashboard#/tasks'; - if (current_path() != drupal_get_destination()['destination']) { - $civicrmEntryPath = $_GET['destination']; + + if (current_path() == drupal_get_destination()['destination']) { + $_GET['destination'] = user_access('access CiviCRM') ? $civicrmEntryPath : $sspEntryPath; } - $_GET['destination'] = user_access('access CiviCRM') ? $civicrmEntryPath : $sspEntryPath; } } @@ -7229,6 +7229,7 @@ function _user_redirection() { } $current_path = request_path(); + $requestURI = rawurlencode(request_uri()); $user_is_anonymous = $user->uid == 0; $allowed_paths = [ @@ -7246,7 +7247,7 @@ function _user_redirection() { $current_path == 'user/register') { $redirect_path = 'welcome-page'; if ($current_path) { - $redirect_path .= "?destination={$current_path}"; + $redirect_path .= "?destination={$requestURI}"; } } } From 414b478192807eed9945fd15ae44f241020f1da9 Mon Sep 17 00:00:00 2001 From: Hitesh Jain Date: Wed, 15 Feb 2017 10:52:03 +0530 Subject: [PATCH 07/11] PCHR-1782: Removed condition for pivot table length of service data. --- civihr_employee_portal/views/civihr_employee_portal.views.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/civihr_employee_portal/views/civihr_employee_portal.views.inc b/civihr_employee_portal/views/civihr_employee_portal.views.inc index 7d666d17..1444d194 100755 --- a/civihr_employee_portal/views/civihr_employee_portal.views.inc +++ b/civihr_employee_portal/views/civihr_employee_portal.views.inc @@ -1026,7 +1026,7 @@ function civihr_employee_portal_views_pre_render(&$view) { $view->result = removeAbsencesForOtherManagers($view->result); } - if ($view->name == "civihr_report_people" && $view->current_display == 'civihr_report_table_people' ) { + if ($view->name == "civihr_report_people" ) { formatLengthsOfService($view->result); } } From 69c43f1c8b09794fd8e11282f5bbd0af4e5d999f Mon Sep 17 00:00:00 2001 From: Hitesh Jain Date: Thu, 16 Feb 2017 11:19:29 +0530 Subject: [PATCH 08/11] PCHR-1782: Fixed length of service for leave_and_absence page. --- civihr_employee_portal/views/civihr_employee_portal.views.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/civihr_employee_portal/views/civihr_employee_portal.views.inc b/civihr_employee_portal/views/civihr_employee_portal.views.inc index 1444d194..e2ad4093 100755 --- a/civihr_employee_portal/views/civihr_employee_portal.views.inc +++ b/civihr_employee_portal/views/civihr_employee_portal.views.inc @@ -1026,7 +1026,7 @@ function civihr_employee_portal_views_pre_render(&$view) { $view->result = removeAbsencesForOtherManagers($view->result); } - if ($view->name == "civihr_report_people" ) { + if ($view->name == "civihr_report_people" || $view->name == "civihr_report_leave_and_absence") { formatLengthsOfService($view->result); } } From 706f90cb4acf145a36d9db41335ff065df385922 Mon Sep 17 00:00:00 2001 From: Camilo Rodriguez Date: Tue, 21 Feb 2017 12:15:31 +0000 Subject: [PATCH 09/11] PCHR-1974: Remove Sender Name from Absence E-mails When users use e-mail as username, and the e-mail used did not belong to a domain allowed on Amazon SES as a valid sender, e-mails for absence requests, approval, and rejection failed. Fixed by removing sender name from e-mails, so now From sender name defaults to site name. --- .../civihr_employee_portal_features.rules_defaults.inc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.rules_defaults.inc b/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.rules_defaults.inc index 1b085524..fac06d71 100755 --- a/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.rules_defaults.inc +++ b/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.rules_defaults.inc @@ -26,7 +26,6 @@ function civihr_employee_portal_features_default_rules_configuration() { { "mimemail" : { "key" : "email-absence-request", "to" : "[current-user:assigned_manager_email]", - "from_name" : "[current-user:name]", "from_mail" : "[site:mail]", "subject" : "CiviHR - Absence Request!", "body" : "\\u003Cbody bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n\\u003Ctable class=\\u0022head-wrap\\u0022 bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022header container\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003Cimg style=\\u0022height:30px\\u0022 src=\\u0022[site:url]sites\\/all\\/modules\\/civihr-custom\\/civihr_employee_portal\\/images\\/email-logo.png\\u0022\\/\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd align=\\u0022right\\u0022\\u003E\\u003Ch6 class=\\u0022collapse\\u0022\\u003ECiviHR\\u003C\\/h6\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003Ctable class=\\u0022body-wrap\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022container\\u0022 bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch3\\u003EDear, [current-user:assigned_manager_name]\\u003C\\/h3\\u003E\\r\\n \\u003Cp class=\\u0022lead\\u0022\\u003EEmployee [current-user:contact_display_name] has \\u003Cb\\u003Erequested\\u003C\\/b\\u003E leave!\\u003C\\/p\\u003E\\r\\n \\u003Cp\\u003E\\r\\n Leave Type: [leave-type:value] \\u003Cbr \\/\\u003E\\r\\n Leave Date: [leave-date:value] \\u003Cbr \\/\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Cp class=\\u0022callout\\u0022\\u003E\\r\\n \\u003Cb\\u003EStaff notes:\\u003C\\/b\\u003E \\u003Cbr \\/\\u003E\\r\\n [absence-details:value]\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Ctable class=\\u0022social\\u0022 width=\\u0022100%\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003EManage the request here:\\u003C\\/h5\\u003E\\r\\n \\u003Cp class=\\u0022\\u0022\\u003E\\r\\n \\u003Ca href=\\u0022/manager-absence-approval\\u0022 class=\\u0022soc-btn gp\\u0022\\u003ESelf Service Portal\\u003C\\/a\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003EStaff details:\\u003C\\/h5\\u003E\\r\\n \\u003Cp\\u003EName: \\u003Cstrong\\u003E[current-user:contact_display_name]\\u003C\\/strong\\u003E \\u003Cbr \\/\\u003E\\r\\n Phone: \\u003Cstrong\\u003E[current-user:contact_phone]\\u003C\\/strong\\u003E \\u003Cbr \\/\\u003E\\r\\n Email: \\u003Cstrong\\u003E\\u003Ca href=\\u0022mailto:[current-user:mail]\\u0022\\u003E\\u003Cspan class=\\u0022__cf_email__\\u0022\\u003E[current-user:mail]\\u003C\\/span\\u003E\\u003C\\/a\\u003E\\u003C\\/strong\\u003E\\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003Cspan class=\\u0022clear\\u0022\\u003E\\u003C\\/span\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003C\\/body\\u003E", @@ -52,7 +51,6 @@ function civihr_employee_portal_features_default_rules_configuration() { { "mimemail" : { "key" : "approve-all-absence", "to" : "[target-user:mail]", - "from_name" : "[current-user:name]", "from_mail" : "[site:mail]", "subject" : "CiviHR - Approved Absence", "body" : "\\u003Cbody bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n\\u003Ctable class=\\u0022head-wrap\\u0022 bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022header container\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003Cimg style=\\u0022height:30px\\u0022 src=\\u0022[site:url]sites\\/all\\/modules\\/civihr-custom\\/civihr_employee_portal\\/images\\/email-logo.png\\u0022\\/\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd align=\\u0022right\\u0022\\u003E\\u003Ch6 class=\\u0022collapse\\u0022\\u003ECiviHR\\u003C\\/h6\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003Ctable class=\\u0022body-wrap\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022container\\u0022 bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch3\\u003EDear, [target-user:contact_display_name]\\u003C\\/h3\\u003E\\r\\n \\u003Cp class=\\u0022lead\\u0022\\u003EYour leave has been \\u003Cb\\u003Eapproved!\\u003C\\/b\\u003E\\u003C\\/p\\u003E\\r\\n \\u003Cp\\u003E\\r\\n Leave Type: [leave-type:value] \\u003Cbr \\/\\u003E\\r\\n Leave Date: [leave-date:value] \\u003Cbr \\/\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Cp class=\\u0022callout\\u0022\\u003E\\r\\n \\u003Cb\\u003EManager notes:\\u003C\\/b\\u003E \\u003Cbr \\/\\u003E\\r\\n [manager-notes:value]\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Ctable class=\\u0022social\\u0022 width=\\u0022100%\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003ECheck your request here:\\u003C\\/h5\\u003E\\r\\n \\u003Cp class=\\u0022\\u0022\\u003E\\r\\n \\u003Ca href=\\u0022[site:url]\\u0022 class=\\u0022soc-btn gp\\u0022\\u003ESelf Service Portal\\u003C\\/a\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003EYour Manager details:\\u003C\\/h5\\u003E\\r\\n \\u003Cp\\u003EName: \\u003Cstrong\\u003E[target-user:assigned_manager_name]\\u003C\\/strong\\u003E\\r\\n Phone: \\u003Cstrong\\u003E[target-user:assigned_manager_phone]\\u003C\\/strong\\u003E \\u003Cbr \\/\\u003E\\r\\n Email: \\u003Cstrong\\u003E\\u003Ca href=\\u0022mailto:[target-user:assigned_manager_email]\\u0022\\u003E\\u003Cspan class=\\u0022__cf_email__\\u0022\\u003E[target-user:assigned_manager_email]\\u003C\\/span\\u003E\\u003C\\/a\\u003E\\u003C\\/strong\\u003E\\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003Cspan class=\\u0022clear\\u0022\\u003E\\u003C\\/span\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003C\\/body\\u003E", @@ -79,7 +77,6 @@ function civihr_employee_portal_features_default_rules_configuration() { "key" : "employee-access-request", "roles" : { "value" : { "55120974" : "55120974" } }, "active" : "1", - "from_name" : "[site:name]", "from_mail" : "[site:mail]", "subject" : "Employee Access Request", "body" : "User [current-user:contact_display_name] with username: [current-user:name] ([current-user:mail]) has requested access to your CiviHR Self Service Portal.\\r\\nPlease login to activate this account and assign appropriate access level.", @@ -101,7 +98,6 @@ function civihr_employee_portal_features_default_rules_configuration() { { "mimemail" : { "key" : "partially-approve-absence", "to" : "[target-user:mail]", - "from_name" : "[current-user:name]", "from_mail" : "[site:mail]", "subject" : "CiviHR - Partially Approved Absence", "body" : "\\u003Cbody bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n\\u003Ctable class=\\u0022head-wrap\\u0022 bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022header container\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003Cimg style=\\u0022height:30px\\u0022 src=\\u0022[site:url]sites\\/all\\/modules\\/civihr-custom\\/civihr_employee_portal\\/images\\/email-logo.png\\u0022\\/\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd align=\\u0022right\\u0022\\u003E\\u003Ch6 class=\\u0022collapse\\u0022\\u003ECiviHR\\u003C\\/h6\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003Ctable class=\\u0022body-wrap\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022container\\u0022 bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch3\\u003EDear, [target-user:contact_display_name]\\u003C\\/h3\\u003E\\r\\n \\u003Cp class=\\u0022lead\\u0022\\u003EYour leave has been \\u003Cb\\u003Epartially approved!\\u003C\\/b\\u003E\\u003C\\/p\\u003E\\r\\n \\u003Cp\\u003E\\r\\n Leave Type: [leave-type:value] \\u003Cbr \\/\\u003E\\r\\n Leave Date: [leave-date:value] \\u003Cbr \\/\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Cp class=\\u0022callout\\u0022\\u003E\\r\\n \\u003Cb\\u003EManager notes:\\u003C\\/b\\u003E \\u003Cbr \\/\\u003E\\r\\n [manager-notes:value]\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Ctable class=\\u0022social\\u0022 width=\\u0022100%\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003ECheck your request here:\\u003C\\/h5\\u003E\\r\\n \\u003Cp class=\\u0022\\u0022\\u003E\\r\\n \\u003Ca href=\\u0022[site:url]\\u0022 class=\\u0022soc-btn gp\\u0022\\u003ESelf Service Portal\\u003C\\/a\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003EYour Manager details:\\u003C\\/h5\\u003E\\r\\n \\u003Cp\\u003EName: \\u003Cstrong\\u003E[target-user:assigned_manager_name]\\u003C\\/strong\\u003E\\r\\n Phone: \\u003Cstrong\\u003E[target-user:assigned_manager_phone]\\u003C\\/strong\\u003E \\u003Cbr \\/\\u003E\\r\\n Email: \\u003Cstrong\\u003E\\u003Ca href=\\u0022mailto:[target-user:assigned_manager_email]\\u0022\\u003E\\u003Cspan class=\\u0022__cf_email__\\u0022\\u003E[target-user:assigned_manager_email]\\u003C\\/span\\u003E\\u003C\\/a\\u003E\\u003C\\/strong\\u003E\\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003Cspan class=\\u0022clear\\u0022\\u003E\\u003C\\/span\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003C\\/body\\u003E", @@ -127,7 +123,6 @@ function civihr_employee_portal_features_default_rules_configuration() { { "mimemail" : { "key" : "reject-all-absence", "to" : "[target-user:mail]", - "from_name" : "[current-user:name]", "from_mail" : "[site:mail]", "subject" : "CiviHR - Rejected Absence", "body" : "\\u003Cbody bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n\\u003Ctable class=\\u0022head-wrap\\u0022 bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022header container\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable bgcolor=\\u0022#999999\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003Cimg style=\\u0022height:30px\\u0022 src=\\u0022[site:url]sites\\/all\\/modules\\/civihr-custom\\/civihr_employee_portal\\/images\\/email-logo.png\\u0022\\/\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd align=\\u0022right\\u0022\\u003E\\u003Ch6 class=\\u0022collapse\\u0022\\u003ECiviHR\\u003C\\/h6\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003Ctable class=\\u0022body-wrap\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003Ctd class=\\u0022container\\u0022 bgcolor=\\u0022#FFFFFF\\u0022\\u003E\\r\\n \\u003Cdiv class=\\u0022content\\u0022\\u003E\\r\\n \\u003Ctable\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch3\\u003EDear, [target-user:contact_display_name]\\u003C\\/h3\\u003E\\r\\n \\u003Cp class=\\u0022lead\\u0022\\u003EYour leave has been \\u003Cb\\u003Erejected!\\u003C\\/b\\u003E\\u003C\\/p\\u003E\\r\\n \\u003Cp\\u003E\\r\\n Leave Type: [leave-type:value] \\u003Cbr \\/\\u003E\\r\\n Leave Date: [leave-date:value] \\u003Cbr \\/\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Cp class=\\u0022callout\\u0022\\u003E\\r\\n \\u003Cb\\u003EManager notes:\\u003C\\/b\\u003E \\u003Cbr \\/\\u003E\\r\\n [manager-notes:value]\\r\\n \\u003C\\/p\\u003E\\r\\n\\r\\n \\u003Ctable class=\\u0022social\\u0022 width=\\u0022100%\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003ECheck your request here:\\u003C\\/h5\\u003E\\r\\n \\u003Cp class=\\u0022\\u0022\\u003E\\r\\n \\u003Ca href=\\u0022[site:url]\\u0022 class=\\u0022soc-btn gp\\u0022\\u003ESelf Service Portal\\u003C\\/a\\u003E\\r\\n \\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n\\r\\n \\u003Ctable align=\\u0022left\\u0022 class=\\u0022column\\u0022\\u003E\\r\\n \\u003Ctr\\u003E\\r\\n \\u003Ctd\\u003E\\r\\n \\u003Ch5 class=\\u0022\\u0022\\u003EYour Manager details:\\u003C\\/h5\\u003E\\r\\n \\u003Cp\\u003EName: \\u003Cstrong\\u003E[target-user:assigned_manager_name]\\u003C\\/strong\\u003E\\r\\n Phone: \\u003Cstrong\\u003E[target-user:assigned_manager_phone]\\u003C\\/strong\\u003E \\u003Cbr \\/\\u003E\\r\\n Email: \\u003Cstrong\\u003E\\u003Ca href=\\u0022mailto:[target-user:assigned_manager_email]\\u0022\\u003E\\u003Cspan class=\\u0022__cf_email__\\u0022\\u003E[target-user:assigned_manager_email]\\u003C\\/span\\u003E\\u003C\\/a\\u003E\\u003C\\/strong\\u003E\\u003C\\/p\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003Cspan class=\\u0022clear\\u0022\\u003E\\u003C\\/span\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n \\u003C\\/table\\u003E\\r\\n \\u003C\\/div\\u003E\\r\\n \\u003C\\/td\\u003E\\r\\n \\u003Ctd\\u003E\\u003C\\/td\\u003E\\r\\n \\u003C\\/tr\\u003E\\r\\n\\u003C\\/table\\u003E\\r\\n\\r\\n\\u003C\\/body\\u003E", From 548ea1631329748865d6c6d01e5503c3c53c5b9c Mon Sep 17 00:00:00 2001 From: Camilo Rodriguez Date: Tue, 21 Feb 2017 20:23:59 +0000 Subject: [PATCH 10/11] PCHR-1976: Log Periods Cache on Start Date Leave Request Validation Implemented watchdog logs to record where period data is coming from when used to validate start date of a leave request, and the contents of the periods array being used. --- .../civihr_employee_portal.module | 61 +++++++++++-------- .../src/Forms/AbsenceRequestForm.php | 9 +++ 2 files changed, 45 insertions(+), 25 deletions(-) mode change 100644 => 100755 civihr_employee_portal/src/Forms/AbsenceRequestForm.php diff --git a/civihr_employee_portal/civihr_employee_portal.module b/civihr_employee_portal/civihr_employee_portal.module index 0108c756..784c31a1 100755 --- a/civihr_employee_portal/civihr_employee_portal.module +++ b/civihr_employee_portal/civihr_employee_portal.module @@ -839,39 +839,50 @@ function civihr_employee_portal_views_default_views() { } /** - * Function for caching date periods returned from CiviCRM (avoiding expensive DB calls for each dashboard page hit) + * Function for caching date periods returned from CiviCRM (avoiding expensive + * DB calls for each dashboard page hit) */ function get_civihr_date_periods() { - $periods_data = &drupal_static(__FUNCTION__); + $periods_data = &drupal_static(__FUNCTION__); - if (!isset($periods_data)) { - if ($cache = cache_get('civihr_date_periods')) { - $periods_data = $cache->data; - } - else { - - try { - - // Civi init - civicrm_initialize(); - - $res = civicrm_api3('HRAbsencePeriod', 'get', array('options' => array('sort' => "start_date DESC"))); - $periods_data = $res['values']; - watchdog('DB hit', 'DB'); - - } + if (!isset($periods_data)) { + if ($cache = cache_get('civihr_date_periods')) { + $periods_data = $cache->data; + watchdog( + 'CiviHR Period Cache', + 'Periods found in cache:
' . print_r($periods_data, true) . '
' + ); + } + else { + try { + // Civi init + civicrm_initialize(); - catch (CiviCRM_API3_Exception $e) { - $error = $e->getMessage(); - } + $res = civicrm_api3('HRAbsencePeriod', 'get', ['options' => ['sort' => "start_date DESC"]]); + $periods_data = $res['values']; + watchdog('DB hit', 'DB'); + } + catch (CiviCRM_API3_Exception $e) { + $error = $e->getMessage(); + watchdog( + 'CiviHR Period Cache', + "Error obtaining periods from DB: $error ", + array(), + WATCHDOG_ALERT + ); + } - // Cache the date periods for 5 minutes - cache_set('civihr_date_periods', $periods_data, 'cache', time() + 360); - } + // Cache the date periods for 5 minutes + cache_set('civihr_date_periods', $periods_data, 'cache', time() + 360); + watchdog( + 'CiviHR Period Cache', + 'Periods obtained from DB and stored in cache:
' . print_r($periods_data, true) . '
' + ); } + } - return $periods_data; + return $periods_data; } /** diff --git a/civihr_employee_portal/src/Forms/AbsenceRequestForm.php b/civihr_employee_portal/src/Forms/AbsenceRequestForm.php old mode 100644 new mode 100755 index 6e537b50..bdd9403c --- a/civihr_employee_portal/src/Forms/AbsenceRequestForm.php +++ b/civihr_employee_portal/src/Forms/AbsenceRequestForm.php @@ -544,6 +544,15 @@ protected function period_id($start_date) { } } + if ($period_id == null) { + watchdog( + 'CiviHR Period Cache', + 'Period for ' . implode('-', $start_date) . ' not found in period cache. Cache data:
' . print_r(get_civihr_date_periods(), true) . '
', + array(), + WATCHDOG_ALERT + ); + } + return $period_id; } From 59e61ec5819b3dffb1b0d1a47b5011b7adaec7bf Mon Sep 17 00:00:00 2001 From: Camilo Rodriguez Date: Wed, 22 Feb 2017 12:20:15 +0000 Subject: [PATCH 11/11] PCHR-1976: Set Period Cache Lifetime to Six Minutes Documentation for lifetime of period cache stated it was set to five minutes, while actual instruction added 360 seconds (ie. 6 minutes). Removed unnecessary documentation to avoid ambiguity vs code and used strtotime to set the cache, to improve readibility. --- civihr_employee_portal/civihr_employee_portal.module | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/civihr_employee_portal/civihr_employee_portal.module b/civihr_employee_portal/civihr_employee_portal.module index 784c31a1..df1becea 100755 --- a/civihr_employee_portal/civihr_employee_portal.module +++ b/civihr_employee_portal/civihr_employee_portal.module @@ -873,8 +873,7 @@ function get_civihr_date_periods() { ); } - // Cache the date periods for 5 minutes - cache_set('civihr_date_periods', $periods_data, 'cache', time() + 360); + cache_set('civihr_date_periods', $periods_data, 'cache', strtotime('+6 minutes')); watchdog( 'CiviHR Period Cache', 'Periods obtained from DB and stored in cache:
' . print_r($periods_data, true) . '
'