',
@@ -3427,7 +3489,7 @@ function civihr_employee_portal_appraisal_manager_form($form, &$form_state) {
'#cols' => 100,
'#default_value' => isset($appraisal['notes']) ? strip_tags($appraisal['notes']) : '',
);
-
+
$form['grade'] = array(
'#type' => 'textfield',
'#title' => t('Grade'),
@@ -3479,7 +3541,7 @@ function civihr_employee_portal_appraisal_manager_form_submit($form, &$form_stat
$meetingApproved = (int)strip_tags($form_state['values']['checkboxes'][2]) ? 1 : 0;
$notes = strip_tags($form_state['values']['notes']);
$grade = (int)strip_tags($form_state['values']['grade']);
-
+
$params = array(
'sequential' => 1,
'id' => $id,
@@ -3491,7 +3553,7 @@ function civihr_employee_portal_appraisal_manager_form_submit($form, &$form_stat
//TODO: if (has_appraisal_permissions to grade) {
$params['grade'] = $grade;
//}
-
+
// setting appraisal status to Awaiting Grade:
$params['status_id'] = 3;
@@ -3518,7 +3580,7 @@ function civihr_employee_portal_appraisal_manager_form_submit($form, &$form_stat
}
function civihr_employee_portal_appraisal_manager_view($ajax, $id) {
-
+
$appraisal = civicrm_api3('Appraisal', 'getsingle', array(
'sequential' => 1,
'id' => (int)$id,
@@ -3532,7 +3594,7 @@ function civihr_employee_portal_appraisal_manager_view($ajax, $id) {
$manager = get_civihr_contact_data($appraisal['manager_id']);
$title = $contact['display_name'] . ' Appraisal';
$documents = civihr_employee_portal_get_appraisal_documents($appraisal['id']);
-
+
$output = theme_render_template(
drupal_get_path('module', 'civihr_employee_portal') .
'/templates/civihr-employee-portal-appraisal-manager-view-modal.tpl.php',
@@ -3546,7 +3608,7 @@ function civihr_employee_portal_appraisal_manager_view($ajax, $id) {
'documents' => $documents,
)
);
-
+
if ($ajax) {
ctools_include('ajax');
ctools_include('modal');
@@ -3716,12 +3778,12 @@ function civihr_employee_portal_appraisal_employee_form_submit($form, &$form_sta
}
$id = (int)strip_tags($form_state['values']['id']);
-
+
$params = array(
'sequential' => 1,
'id' => $id,
);
-
+
// setting appraisal status to Awaiting Manager Appraisal:
$params['status_id'] = 2;
@@ -3748,7 +3810,7 @@ function civihr_employee_portal_appraisal_employee_form_submit($form, &$form_sta
}
function civihr_employee_portal_get_appraisal_documents($appraisalId) {
-
+
$documents = array();
$selfAppraisalFiles = CRM_Appraisals_Page_Files::fileList(array(
'entityTable' => 'civicrm_appraisal-self',
@@ -3766,7 +3828,7 @@ function civihr_employee_portal_get_appraisal_documents($appraisalId) {
$file['appraisalFileTypeLabel'] = 'Manager Appraisal';
$documents['managerAppraisal'] = $file;
}
-
+
return $documents;
}
@@ -4724,6 +4786,28 @@ function civihr_employee_portal_directory_block_form_submit($form, &$form_state)
)));
}
+/**
+ * Implement hook_node_view().
+ *
+ * @param object $node
+ * @param string $view_mode
+ * @param string $langcode
+ */
+function civihr_employee_portal_node_view($node, $view_mode, $langcode) {
+ // Set up default State/Province values for Emergency Contact webform.
+ if ($node->nid === variable_get('emergency_contact_webform_nid')) {
+ $fieldset = _get_emergency_contact_fieldset_list();
+ for ($contact = 1; $contact < 3; $contact++) {
+ $country_id = null;
+ if (isset($node->content['webform']['#form']['submitted'][$fieldset[$contact]]['civicrm_1_contact_' . $contact . '_cg99999_custom_100008']['#default_value'])) {
+ $country_id = $node->content['webform']['#form']['submitted'][$fieldset[$contact]]['civicrm_1_contact_' . $contact . '_cg99999_custom_100008']['#default_value'];
+ }
+ $state_province_options = _get_state_province_list_by_country_id($country_id);
+ $node->content['webform']['#form']['submitted'][$fieldset[$contact]]['civicrm_1_contact_' . $contact . '_cg99999_custom_100009']['#options'] = $state_province_options;
+ }
+ }
+}
+
// Note: Under "Redirection location" NO redirect option should be select to get the confirmation message with ajax.
// We can use this trick to make it generic for all webforms those have No redirect settings enabled under "Redirection location" setting.
function civihr_employee_portal_form_alter(&$form, &$form_state, $form_id) {
@@ -4801,7 +4885,7 @@ function civihr_employee_portal_form_alter(&$form, &$form_state, $form_id) {
// Check whether the form id have nid at the end like _nid
preg_match('/[\d]+$/', $form_id, $matches);
- $nid_match = $matches[0];
+ $nid_match = !empty($matches[0]) ? $matches[0] : null;
if(strpos($form_id, 'webform_client_form_') !== false && !empty($nid_match)) {
@@ -4815,9 +4899,99 @@ function civihr_employee_portal_form_alter(&$form, &$form_state, $form_id) {
'#value' => t('Submit'),
);
}
+ }
+
+ // Set up Emergency Contact webform ajax fields and callbacks.
+ if (!empty($form['#node']) && $form['#node']->nid === variable_get('emergency_contact_webform_nid')) {
+ $fieldset = _get_emergency_contact_fieldset_list();
+ for ($contact = 1; $contact < 3; $contact++) {
+ $form['submitted'][$fieldset[$contact]]['civicrm_1_contact_' . $contact . '_cg99999_custom_100008']['#ajax'] = array(
+ 'event' => 'change',
+ 'wrapper' => 'emergency-contact' . $contact . '-state-province',
+ 'callback' => 'civihr_employee_portal_state_province_contact' . $contact . '_callback',
+ 'method' => 'replace',
+ );
+ $form['submitted'][$fieldset[$contact]]['civicrm_1_contact_' . $contact . '_cg99999_custom_100009']['#prefix'] = '
';
+ $form['submitted'][$fieldset[$contact]]['civicrm_1_contact_' . $contact . '_cg99999_custom_100009']['#suffix'] = '
';
+ }
+ }
+}
+
+/**
+ * Get a recalculated State/Province form field for Emergency Contact 1.
+ *
+ * @param array $form
+ * @param array $form_state
+ * @return array
+ */
+function civihr_employee_portal_state_province_contact1_callback($form, $form_state) {
+ return _get_emergency_contact_state_province_webform_field($form, 1);
+}
+
+/**
+ * Get a recalculated State/Province form field for Emergency Contact 2.
+ *
+ * @param array $form
+ * @param array $form_state
+ * @return array
+ */
+function civihr_employee_portal_state_province_contact2_callback($form, $form_state) {
+ return _get_emergency_contact_state_province_webform_field($form, 2);
+}
+
+/**
+ * Get a form select field for given emergency contact containing
+ * State/Province list of selected Country.
+ *
+ * @param array $form
+ * @param int $emergency_contact
+ * @return array
+ */
+function _get_emergency_contact_state_province_webform_field($form, $emergency_contact) {
+ $fieldset = _get_emergency_contact_fieldset_list();
+ $country_id = $form['submitted'][$fieldset[$emergency_contact]]['civicrm_1_contact_' . $emergency_contact . '_cg99999_custom_100008']['#value'];
+ $form['submitted'][$fieldset[$emergency_contact]]['civicrm_1_contact_' . $emergency_contact . '_cg99999_custom_100009']['#options'] = _get_state_province_list_by_country_id($country_id);
+
+ $bootstrap_form = civihr_default_theme_form_apply_bootstrap($form['submitted']);
+ return $bootstrap_form[$fieldset[$emergency_contact]]['civicrm_1_contact_' . $emergency_contact . '_cg99999_custom_100009'];
+}
+
+/**
+ * Return an array containing fieldset list of Emergency Contact webform.
+ *
+ * @return array
+ */
+function _get_emergency_contact_fieldset_list() {
+ return array(
+ 1 => 'civicrm_1_contact_1_fieldset_fieldset',
+ 2 => 'secondary_emergency_contact',
+ );
+}
+/**
+ * Get an assotiative array containing IDs of State/Province as keys
+ * and labels of State/Province as values.
+ *
+ * @param int $country_id
+ * @return array
+ */
+function _get_state_province_list_by_country_id($country_id) {
+ if (!$country_id) {
+ return array();
}
- }
+ civicrm_initialize();
+ $civi_settings = parse_url(CIVICRM_DSN);
+ $civi_db_name = trim($civi_settings['path'], '/');
+ $state_province_list = array();
+ $result = db_select($civi_db_name . '.civicrm_state_province', 'sp')
+ ->fields('sp', array('id', 'name'))
+ ->condition('country_id', $country_id, '=')
+ ->execute();
+ while ($row = $result->fetchAssoc()) {
+ $state_province_list[$row['id']] = $row['name'];
+ }
+ return $state_province_list;
+}
function civihr_employee_portal_preprocess_user_login(&$vars) {
@@ -4978,6 +5152,16 @@ function civihr_employee_portal_form_views_exposed_form_alter(&$form, &$form_sta
'progress' => array('type' => 'none')
);
+ // Autosubmit the form on page load as views autosubmit doesn't pass values of contextual filters to inserted view in Global : View Area
+ drupal_add_js(
+ 'jQuery(document).ready(function () { jQuery("#edit-submit-absence-list").click() });',
+ array(
+ 'type' => 'inline',
+ 'scope' => 'footer',
+ 'group' => JS_THEME,
+ 'weight' => 5,
+ )
+ );
// Autosubmit the form after date_period select change
$form['absence_start_date_period_filter']['#attributes'] = array('onchange' => "jQuery('#edit-submit-absence-list').click()");
}
@@ -5035,33 +5219,33 @@ function _absence_start_date_period_change_submit(&$form, &$form_state) {
* @param $vars
*/
function civihr_employee_portal_preprocess_page(&$vars) {
-
global $user;
global $base_url;
- $contact_data['display_name'] = t('Anonymus');
-
- // Set empty image URL
- $vars['image_url'] = $base_url . '/' . drupal_get_path('module', 'civihr_employee_portal') . '/images/profile-default.png';
+ $display_name = t('Anonymus');
+ $edit_account_link = '';
+ $logout_link = '';
+ $image_url = $base_url . '/' . drupal_get_path('module', 'civihr_employee_portal') . '/images/profile-default.png';
- if (isset($_SESSION['CiviCRM'])) {
+ if (isset($_SESSION['CiviCRM']) && $user->uid) {
+ $edit_account_link = l('
' . t('Edit Account'), 'user/' . $user->uid . '/edit', array('html' => true));
+ $logout_link = l('
' . t('Log Out'), 'user/logout', array('html' => true));
// Get the contact data
$contact_data = get_civihr_contact_data($_SESSION['CiviCRM']['userID']);
-
+ if (!empty($contact_data['display_name'])) {
+ $display_name = $contact_data['display_name'];
+ }
if (isset($contact_data['image_URL']) && !empty($contact_data['image_URL'])) {
-
- // Set the profile image URL
- $vars['image_url'] = $contact_data['image_URL'];
-
+ $image_url = $contact_data['image_URL'];
}
-
}
// This values will be used in the template by Drupal
- $vars['user_name'] = $contact_data['display_name'];
- $vars['edit_account'] = l('
' . t('Edit Account'), 'user/' . $user->uid . '/edit', array('html' => true));
- $vars['logout_link'] = l('
' . t('Log Out'), 'user/logout', array('html' => true));
+ $vars['user_name'] = $display_name;
+ $vars['image_url'] = $image_url;
+ $vars['edit_account'] = $edit_account_link;
+ $vars['logout_link'] = $logout_link;
}
@@ -5302,6 +5486,20 @@ function civihr_employee_portal_civicrm_post($op, $objectName, $objectId, &$obje
}
}
+/**
+ * Checks if the given absence is of the "Sick" type
+ *
+ * There is no other way currently to check if an absence type is of the
+ * "Sick" type other than checking its title, so we have to resort to a
+ * simple regex match on the title string, looking for the "sick" word
+ *
+ * @param string $absenceName
+ * @return boolean
+ */
+function civihr_employee_portal_is_sick_absence($absenceName) {
+ return preg_match('/^sick/i', $absenceName);
+}
+
/**
* Pass the contact ID and this function will return array of assigned ACTIVE manager contact IDs
* @param $contact_id
diff --git a/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.features.user_permission.inc b/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.features.user_permission.inc
index efd6c8f3..f4e0f40b 100644
--- a/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.features.user_permission.inc
+++ b/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.features.user_permission.inc
@@ -654,5 +654,101 @@ function civihr_employee_portal_features_user_default_permissions() {
'module' => 'civicrm',
);
+ // Exported permission: 'view my details'.
+ $permissions['view my details'] = array(
+ 'name' => 'view my details',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view my tasks block'.
+ $permissions['view my tasks block'] = array(
+ 'name' => 'view my tasks block',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view appraisals'.
+ $permissions['view appraisals'] = array(
+ 'name' => 'view appraisals',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view my leave block'.
+ $permissions['view my leave block'] = array(
+ 'name' => 'view my leave block',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view my sickness report block'.
+ $permissions['view my sickness report block'] = array(
+ 'name' => 'view my sickness report block',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view staff directory'.
+ $permissions['view staff directory'] = array(
+ 'name' => 'view staff directory',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view hr resources'.
+ $permissions['view hr resources'] = array(
+ 'name' => 'view hr resources',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
+ // Exported permission: 'view vacancies'.
+ $permissions['view vacancies'] = array(
+ 'name' => 'view vacancies',
+ 'roles' => array(
+ 'administrator' => 'administrator',
+ 'civihr_admin' => 'civihr_admin',
+ 'civihr_manager' => 'civihr_manager',
+ 'civihr_staff' => 'civihr_staff',
+ ),
+ 'module' => 'civihr_employee_portal',
+ );
+
return $permissions;
}
diff --git a/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.pages_default.inc b/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.pages_default.inc
index 11861215..c51dbad3 100644
--- a/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.pages_default.inc
+++ b/civihr_employee_portal/features/civihr_employee_portal_features/civihr_employee_portal_features.pages_default.inc
@@ -203,13 +203,9 @@ function civihr_employee_portal_features_default_page_manager_pages() {
$pane->access = array(
'plugins' => array(
0 => array(
- 'name' => 'role',
+ 'name' => 'perm',
'settings' => array(
- 'rids' => array(
- 0 => 55120974,
- 1 => 17087012,
- 2 => 57573969,
- ),
+ 'perm' => 'view my details',
),
'context' => 'logged-in-user',
'not' => FALSE,
@@ -339,7 +335,18 @@ function civihr_employee_portal_features_default_page_manager_pages() {
$pane->type = 'block';
$pane->subtype = 'civihr_employee_portal-leave';
$pane->shown = TRUE;
- $pane->access = array();
+ $pane->access = array(
+ 'plugins' => array(
+ 0 => array(
+ 'name' => 'perm',
+ 'settings' => array(
+ 'perm' => 'view my leave block',
+ ),
+ 'context' => 'logged-in-user',
+ 'not' => FALSE,
+ ),
+ ),
+ );
$pane->configuration = array(
'override_title' => 1,
'override_title_text' => '
',
@@ -386,7 +393,18 @@ function civihr_employee_portal_features_default_page_manager_pages() {
$pane->type = 'block';
$pane->subtype = 'civihr_employee_portal-sick';
$pane->shown = TRUE;
- $pane->access = array();
+ $pane->access = array(
+ 'plugins' => array(
+ 0 => array(
+ 'name' => 'perm',
+ 'settings' => array(
+ 'perm' => 'view my sickness report block',
+ ),
+ 'context' => 'logged-in-user',
+ 'not' => FALSE,
+ ),
+ ),
+ );
$pane->configuration = array(
'override_title' => 1,
'override_title_text' => '',
@@ -411,13 +429,9 @@ function civihr_employee_portal_features_default_page_manager_pages() {
$pane->access = array(
'plugins' => array(
0 => array(
- 'name' => 'role',
+ 'name' => 'perm',
'settings' => array(
- 'rids' => array(
- 0 => 55120974,
- 1 => 17087012,
- 2 => 57573969,
- ),
+ 'perm' => 'view staff directory',
),
'context' => 'logged-in-user',
'not' => FALSE,
diff --git a/civihr_employee_portal/features/node_export_files/emergency_contact.export b/civihr_employee_portal/features/node_export_files/emergency_contact.export
index 092dcf6f..e2e2f4da 100644
--- a/civihr_employee_portal/features/node_export_files/emergency_contact.export
+++ b/civihr_employee_portal/features/node_export_files/emergency_contact.export
@@ -325,7 +325,7 @@ array(
'description' => '',
'width' => 20,
'private' => 0,
- 'maxlength' => '',
+ 'maxlength' => '12',
'field_prefix' => '',
'field_suffix' => '',
'disabled' => 0,
@@ -685,7 +685,7 @@ array(
'description' => '',
'width' => 20,
'private' => 0,
- 'maxlength' => '',
+ 'maxlength' => '12',
'field_prefix' => '',
'field_suffix' => '',
'disabled' => 0,
@@ -931,4 +931,4 @@ array(
'menu' => NULL,
'node_export_drupal_version' => '7',
),
-)
\ No newline at end of file
+)
diff --git a/civihr_employee_portal/features/node_export_files/my_details.export b/civihr_employee_portal/features/node_export_files/my_details.export
index 5bea4d9f..a81ae5b9 100644
--- a/civihr_employee_portal/features/node_export_files/my_details.export
+++ b/civihr_employee_portal/features/node_export_files/my_details.export
@@ -348,7 +348,7 @@ array(
'extra' => array(
'width' => 7,
'private' => 0,
- 'maxlength' => '',
+ 'maxlength' => '12',
'field_prefix' => '',
'field_suffix' => '',
'disabled' => 0,
@@ -547,4 +547,4 @@ array(
'menu' => NULL,
'node_export_drupal_version' => '7',
),
-)
\ No newline at end of file
+)
diff --git a/civihr_employee_portal/src/Forms/AbsenceRequestForm.php b/civihr_employee_portal/src/Forms/AbsenceRequestForm.php
index 29b598fb..6e537b50 100644
--- a/civihr_employee_portal/src/Forms/AbsenceRequestForm.php
+++ b/civihr_employee_portal/src/Forms/AbsenceRequestForm.php
@@ -146,12 +146,12 @@ public function validate() {
if ($mk_time_start_timestamp > strtotime('today') && $this->form_state['values']['absence_type'] == "sick") {
form_set_error('absence_request_date_from', t('You are not allowed to report Sickness in advance!'));
}
-
+
// If we requested leave with dates that have already been requested before (duplicate dates)
if($this->duplicate_dates_exist($mk_time_start_timestamp, $mk_time_end_timestamp)){
form_set_error('form', t('You have already requested leave for this date.'));
}
-
+
// Check if we have enough leave left to request this leave (only if leave type is DEBIT or CREDIT_USE) -> deducting days
if (isset($this->form_state['values']['absence_type']) && ($this->form_state['values']['absence_type'] == 'debit' || $this->form_state['values']['absence_type'] == 'credit_use')) {
$leave = $this->leave_data();
@@ -221,19 +221,19 @@ protected function absence_types() {
}
// If debit type is allowed show debit types (only if the employee clicked -> Request Leave)
- if ($absence_type['allow_debits'] == '1' && $this->absence_type() == 'debit' && $absence_type['allow_credits'] !== '1' && $absence_type['title'] != 'Sick') {
+ if ($absence_type['allow_debits'] == '1' && $this->absence_type() == 'debit' && $absence_type['allow_credits'] !== '1' && !civihr_employee_portal_is_sick_absence($absence_type['title'])) {
// Default debit types
$options[$absence_type['debit_activity_type_id']] = $absence_type['title'];
}
// If Use TOIL is clicked show only debit types, which has credit type allowed too
- if ($absence_type['allow_debits'] == '1' && $absence_type['allow_credits'] == '1' && $this->absence_type() == 'credit_use' && $absence_type['title'] != 'Sick') {
+ if ($absence_type['allow_debits'] == '1' && $absence_type['allow_credits'] == '1' && $this->absence_type() == 'credit_use' && !civihr_employee_portal_is_sick_absence($absence_type['title'])) {
// Default debit types which has credit type too
$options[$absence_type['debit_activity_type_id']] = $absence_type['title'];
}
// If Report New Sickness is clicked, show the debit types which are selected as the Sickness Absence Type @TODO -> currently hardcoded based on absence title
- if ($absence_type['allow_debits'] == '1' && $this->absence_type() == 'sick' && $absence_type['title'] == 'Sick') {
+ if ($absence_type['allow_debits'] == '1' && $this->absence_type() == 'sick' && civihr_employee_portal_is_sick_absence($absence_type['title'])) {
// Default debit types which has credit type too
$options[$absence_type['debit_activity_type_id']] = $absence_type['title'];
}
@@ -402,7 +402,7 @@ protected function approved_duration($year) {
return $q->execute()->fetchField();
}
-
+
/**
* Check if the dates requested for leaves are already requested for other leaves before
*
@@ -438,12 +438,12 @@ protected function duplicate_dates_exist($requestedStartTimestamp, $requestedEnd
else if($startTimestamp >= $requestedStartTimestamp && $endTimestamp <= $requestedEndTimestamp) {
$dateExists = true;
}
-
+
if($dateExists == true) {
break;
}
}
-
+
return $dateExists;
}
diff --git a/civihr_employee_portal/views/includes/civihr_employee_portal_handler_area_totals.inc b/civihr_employee_portal/views/includes/civihr_employee_portal_handler_area_totals.inc
index 171acf9f..69808a0e 100644
--- a/civihr_employee_portal/views/includes/civihr_employee_portal_handler_area_totals.inc
+++ b/civihr_employee_portal/views/includes/civihr_employee_portal_handler_area_totals.inc
@@ -4,15 +4,15 @@
*/
class civihr_employee_portal_handler_area_totals extends views_handler_area {
function render($empty = FALSE) {
-
+
// Get the absence types
$absenceTypes = get_civihr_absence_types();
-
+
$results = array();
-
+
$header = array();
$rows = array();
-
+
/**
* Date filters
*/
@@ -23,36 +23,36 @@ class civihr_employee_portal_handler_area_totals extends views_handler_area {
// Set default period
$request_date = variable_get('default_date_period_id', '1');
}
-
+
// Build the query
$query = db_select('civicrm_hrabsence_entitlement', 'che')
->fields('che', array('contact_id', 'period_id'))
->orderBy('che.contact_id');
-
+
// Add the where query
$query->where('(che.contact_id = :c_id)', array(':c_id' => $_SESSION['CiviCRM']['userID']));
$query->where('(che.period_id = :period_id)', array(':period_id' => $request_date));
-
+
// Add the concat
$query->addExpression("CONCAT_WS('||', GROUP_CONCAT(amount SEPARATOR '@@'), GROUP_CONCAT(type_id SEPARATOR '@@'))", "entitlement_type");
-
+
// Add the group by
$query->groupBy('che.contact_id, che.period_id');
-
+
$result = $query->execute();
-
+
$result_output = array();
-
+
// Loop and prepare the array
while($record = $result->fetchAssoc()) {
$result_output['data'][] = $record;
}
-
+
$header[] = t('Balance: ');
$header[] = t('');
if (isset($result_output['data'])) {
-
+
// Get the entitlement for the employee, add it to the basic / totals count
$value_explode = explode("||", $result_output['data'][0]['entitlement_type']);
@@ -63,7 +63,7 @@ class civihr_employee_portal_handler_area_totals extends views_handler_area {
$results[$absenceType['id']] = 0;
- if (isset($absenceType['is_active']) && $absenceType['is_active'] == '1' && $absenceType['title'] != 'Sick') {
+ if (isset($absenceType['is_active']) && $absenceType['is_active'] == '1' && !civihr_employee_portal_is_sick_absence($absenceType['title'])) {
foreach ($absence_ids as $absence_array_key => $absence_id) {
@@ -99,12 +99,12 @@ class civihr_employee_portal_handler_area_totals extends views_handler_area {
* Populate the table
*/
$header[] = $results[$absenceType['id']];
-
+
}
}
}
-
+
return theme('table', array('header' => $header));
-
+
}
}
diff --git a/civihr_employee_portal/views/includes/civihr_employee_portal_handler_task_contacts.inc b/civihr_employee_portal/views/includes/civihr_employee_portal_handler_task_contacts.inc
index 01349d97..d6bcb8c9 100644
--- a/civihr_employee_portal/views/includes/civihr_employee_portal_handler_task_contacts.inc
+++ b/civihr_employee_portal/views/includes/civihr_employee_portal_handler_task_contacts.inc
@@ -20,9 +20,10 @@ class civihr_employee_portal_handler_task_contacts extends views_json_query_hand
// Get the contact data based on the contact ID
$contact_data = get_civihr_contact_data($id);
+ $fieldValue = !empty($contact_data['id']) ? $contact_data['id'] : '';
// Pass the display name to the render_field
- return $this->render_field($contact_data['id']);
+ return $this->render_field($fieldValue);
}
diff --git a/civihr_employee_portal/views/views_export/views_abence_entitlement.inc b/civihr_employee_portal/views/views_export/views_abence_entitlement.inc
index 46e5fe04..0d9c1cd8 100644
--- a/civihr_employee_portal/views/views_export/views_abence_entitlement.inc
+++ b/civihr_employee_portal/views/views_export/views_abence_entitlement.inc
@@ -20,12 +20,8 @@ $view->disabled = FALSE; /* Edit this to true to make a default view disabled in
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Absence Entitlement';
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view my leave block';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['json_file'] = $base_url . '/absence_entitlement_json/';
@@ -100,7 +96,7 @@ foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['id']) && $absenceType['is_active'] == 1) {
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
/* Field: entitlement_type: Absence entitlement value */
$handler->display->display_options['fields']['absence_entitlement_' . $absenceType['id']]['id'] = 'absence_entitlement_' . $absenceType['id'];
$handler->display->display_options['fields']['absence_entitlement_' . $absenceType['id']]['table'] = 'json';
diff --git a/civihr_employee_portal/views/views_export/views_absence_list.inc b/civihr_employee_portal/views/views_export/views_absence_list.inc
index 78f6c689..135d0b05 100644
--- a/civihr_employee_portal/views/views_export/views_absence_list.inc
+++ b/civihr_employee_portal/views/views_export/views_absence_list.inc
@@ -20,12 +20,7 @@ $handler->display->display_options['title'] = 'Absence List';
$handler->display->display_options['css_class'] = 'view--w-table';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
@@ -185,6 +180,9 @@ $handler->display->display_options['filters']['absence_start_date_timestamp']['g
/* Display: Leave report */
$handler = $view->new_display('page', 'Leave report', 'page');
+$handler->display->display_options['defaults']['access'] = FALSE;
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view my leave block';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
@@ -205,13 +203,13 @@ $handler->display->display_options['style_options']['columns'] = array(
foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['id']) && $absenceType['is_active'] == 1) {
-
+
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
$handler->display->display_options['style_options']['columns']['duration_' . $absenceType['id']] = 'duration_' . $absenceType['id'];
}
}
-
+
}
/**
@@ -273,7 +271,7 @@ $handler->display->display_options['style_options']['info'] = array(
'align' => '',
'separator' => '',
'empty_column' => 0,
- )
+ )
);
@@ -284,9 +282,9 @@ $handler->display->display_options['style_options']['info'] = array(
foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['id']) && $absenceType['is_active'] == 1) {
-
+
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
$handler->display->display_options['style_options']['info']['duration_' . $absenceType['id']] = array(
'sortable' => 0,
'default_sort_order' => 'asc',
@@ -296,7 +294,7 @@ foreach ($absenceTypes as $absenceType) {
);
}
}
-
+
}
/**
@@ -394,8 +392,8 @@ $handler->display->display_options['fields']['absence_status']['element_label_co
foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['id']) && $absenceType['is_active'] == 1) {
-
-
+
+
// Store the debit / credit activity type IDs as well
$suffix = '';
@@ -406,10 +404,10 @@ foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['allow_credits']) && $absenceType['allow_credits'] == '1') {
$suffix .= '_' . $absenceType['credit_activity_type_id'];
}
-
+
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
/* Field: Absence entity: Absence type row value (Duration) */
$handler->display->display_options['fields']['duration_' . $absenceType['id']]['id'] = 'duration_' . $absenceType['id'];
$handler->display->display_options['fields']['duration_' . $absenceType['id']]['table'] = 'absence_list';
@@ -460,8 +458,8 @@ $handler->display->display_options['filters']['absence_start_date_period_filter'
'min' => $current_year . '-01-01 00:00:00',
'max' => $current_year . '-12-31 23:59:59',
),
- )
-
+ )
+
);
/**
@@ -473,13 +471,16 @@ $handler->display->display_options['filters']['absence_start_date_period_filter'
$handler->display->display_options['filters']['absence_title']['id'] = 'absence_title';
$handler->display->display_options['filters']['absence_title']['table'] = 'absence_list';
$handler->display->display_options['filters']['absence_title']['field'] = 'absence_title';
-$handler->display->display_options['filters']['absence_title']['operator'] = '!=';
+$handler->display->display_options['filters']['absence_title']['operator'] = 'not';
$handler->display->display_options['filters']['absence_title']['value'] = 'Sick';
$handler->display->display_options['filters']['absence_title']['group'] = 1;
$handler->display->display_options['path'] = 'absence-list';
/* Display: Sickness report */
$handler = $view->new_display('page', 'Sickness report', 'page_1');
+$handler->display->display_options['defaults']['access'] = FALSE;
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view my sickness report block';
$handler->display->display_options['exposed_block'] = TRUE;
$handler->display->display_options['defaults']['footer'] = FALSE;
$handler->display->display_options['defaults']['fields'] = FALSE;
@@ -578,8 +579,8 @@ $handler->display->display_options['filters']['absence_start_date_period_filter'
'min' => $current_year . '-01-01 00:00:00',
'max' => $current_year . '-12-31 23:59:59',
),
- )
-
+ )
+
);
/**
@@ -590,6 +591,7 @@ $handler->display->display_options['filters']['absence_start_date_period_filter'
$handler->display->display_options['filters']['absence_title']['id'] = 'absence_title';
$handler->display->display_options['filters']['absence_title']['table'] = 'absence_list';
$handler->display->display_options['filters']['absence_title']['field'] = 'absence_title';
+$handler->display->display_options['filters']['absence_title']['operator'] = 'contains';
$handler->display->display_options['filters']['absence_title']['value'] = 'Sick';
$handler->display->display_options['filters']['absence_title']['group'] = 1;
$handler->display->display_options['path'] = 'sickness-report';
@@ -600,6 +602,9 @@ $handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Print Leave Report';
$handler->display->display_options['defaults']['css_class'] = FALSE;
$handler->display->display_options['css_class'] = 'print-leave-report-view';
+$handler->display->display_options['defaults']['access'] = FALSE;
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view my leave block';
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
@@ -625,7 +630,7 @@ foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['id']) && $absenceType['is_active'] == 1) {
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
$handler->display->display_options['style_options']['columns']['duration_' . $absenceType['id']] = 'duration_' . $absenceType['id'];
}
}
@@ -703,7 +708,7 @@ foreach ($absenceTypes as $absenceType) {
if (isset($absenceType['id']) && $absenceType['is_active'] == 1) {
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
$handler->display->display_options['style_options']['info']['duration_' . $absenceType['id']] = array(
'sortable' => 0,
'default_sort_order' => 'asc',
@@ -823,7 +828,7 @@ foreach ($absenceTypes as $absenceType) {
// Should have a settings somewhere that the Sick type is our special case, which we need to display in different block
- if ($absenceType['name'] != 'Sick') {
+ if (!civihr_employee_portal_is_sick_absence($absenceType['name'])) {
/* Field: Absence entity: Absence type row value (Duration) */
$handler->display->display_options['fields']['duration_' . $absenceType['id']]['id'] = 'duration_' . $absenceType['id'];
$handler->display->display_options['fields']['duration_' . $absenceType['id']]['table'] = 'absence_list';
@@ -887,7 +892,7 @@ $handler->display->display_options['filters']['absence_start_date_period_filter'
$handler->display->display_options['filters']['absence_title']['id'] = 'absence_title';
$handler->display->display_options['filters']['absence_title']['table'] = 'absence_list';
$handler->display->display_options['filters']['absence_title']['field'] = 'absence_title';
-$handler->display->display_options['filters']['absence_title']['operator'] = '!=';
+$handler->display->display_options['filters']['absence_title']['operator'] = 'not';
$handler->display->display_options['filters']['absence_title']['value'] = 'Sick';
$handler->display->display_options['filters']['absence_title']['group'] = 1;
$handler->display->display_options['path'] = 'print-leave-report';
diff --git a/civihr_employee_portal/views/views_export/views_appraisals.inc b/civihr_employee_portal/views/views_export/views_appraisals.inc
index 8b2058b2..683ef99c 100644
--- a/civihr_employee_portal/views/views_export/views_appraisals.inc
+++ b/civihr_employee_portal/views/views_export/views_appraisals.inc
@@ -117,11 +117,8 @@ $handler = $view->new_display('page', 'Page', 'appraisals_manager');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Appraisals';
$handler->display->display_options['defaults']['access'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 3 => '3',
- 57573969 => '57573969',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view appraisals';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Json: Appraisal Employee */
$handler->display->display_options['fields']['appraisal_employee']['id'] = 'appraisal_employee';
diff --git a/civihr_employee_portal/views/views_export/views_hr_documents.inc b/civihr_employee_portal/views/views_export/views_hr_documents.inc
index 27e0626b..2ada5dba 100644
--- a/civihr_employee_portal/views/views_export/views_hr_documents.inc
+++ b/civihr_employee_portal/views/views_export/views_hr_documents.inc
@@ -18,12 +18,8 @@ $view->disabled = FALSE; /* Edit this to true to make a default view disabled in
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'HR Resources';
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view hr resources';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
diff --git a/civihr_employee_portal/views/views_export/views_hr_staff_directory.inc b/civihr_employee_portal/views/views_export/views_hr_staff_directory.inc
index 772a5a00..5b66d8a7 100644
--- a/civihr_employee_portal/views/views_export/views_hr_staff_directory.inc
+++ b/civihr_employee_portal/views/views_export/views_hr_staff_directory.inc
@@ -20,12 +20,8 @@ $handler->display->display_options['title'] = 'Staff Directory';
$handler->display->display_options['css_class'] = 'view-hr-staff-directory';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view staff directory';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
diff --git a/civihr_employee_portal/views/views_export/views_hr_vacancies.inc b/civihr_employee_portal/views/views_export/views_hr_vacancies.inc
index 4b988634..e71029fd 100644
--- a/civihr_employee_portal/views/views_export/views_hr_vacancies.inc
+++ b/civihr_employee_portal/views/views_export/views_hr_vacancies.inc
@@ -20,12 +20,8 @@ $view->disabled = FALSE; /* Edit this to true to make a default view disabled in
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'HR Vacancies';
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view vacancies';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['json_file'] = $base_url . '/civihr_vacancies/';
diff --git a/civihr_employee_portal/views/views_export/views_my_details_block.inc b/civihr_employee_portal/views/views_export/views_my_details_block.inc
index 975cc358..e8f3816f 100644
--- a/civihr_employee_portal/views/views_export/views_my_details_block.inc
+++ b/civihr_employee_portal/views/views_export/views_my_details_block.inc
@@ -18,12 +18,8 @@ $view->disabled = FALSE; /* Edit this to true to make a default view disabled in
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'My Details Block';
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view my details';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
diff --git a/civihr_employee_portal/views/views_export/views_tasks.inc b/civihr_employee_portal/views/views_export/views_tasks.inc
index 0ea502bf..d990f597 100644
--- a/civihr_employee_portal/views/views_export/views_tasks.inc
+++ b/civihr_employee_portal/views/views_export/views_tasks.inc
@@ -17,13 +17,8 @@ $handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Tasks';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
-$handler->display->display_options['access']['type'] = 'role';
-$handler->display->display_options['access']['role'] = array(
- 3 => '3',
- 55120974 => '55120974',
- 57573969 => '57573969',
- 17087012 => '17087012',
-);
+$handler->display->display_options['access']['type'] = 'perm';
+$handler->display->display_options['access']['perm'] = 'view my tasks block';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['json_file'] = $base_url . '/civi_tasks/';