Skip to content

Commit

Permalink
Merge pull request #144 from compucorp/integration
Browse files Browse the repository at this point in the history
Sync master with integration
  • Loading branch information
Alessandro authored Jul 5, 2016
2 parents 978cf7f + cebff73 commit 69c9adf
Show file tree
Hide file tree
Showing 16 changed files with 438 additions and 152 deletions.
274 changes: 236 additions & 38 deletions civihr_employee_portal/civihr_employee_portal.module

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' => '<none>',
Expand Down Expand Up @@ -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' => '<none>',
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ array(
'description' => '',
'width' => 20,
'private' => 0,
'maxlength' => '',
'maxlength' => '12',
'field_prefix' => '',
'field_suffix' => '',
'disabled' => 0,
Expand Down Expand Up @@ -685,7 +685,7 @@ array(
'description' => '',
'width' => 20,
'private' => 0,
'maxlength' => '',
'maxlength' => '12',
'field_prefix' => '',
'field_suffix' => '',
'disabled' => 0,
Expand Down Expand Up @@ -931,4 +931,4 @@ array(
'menu' => NULL,
'node_export_drupal_version' => '7',
),
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ array(
'extra' => array(
'width' => 7,
'private' => 0,
'maxlength' => '',
'maxlength' => '12',
'field_prefix' => '',
'field_suffix' => '',
'disabled' => 0,
Expand Down Expand Up @@ -547,4 +547,4 @@ array(
'menu' => NULL,
'node_export_drupal_version' => '7',
),
)
)
16 changes: 8 additions & 8 deletions civihr_employee_portal/src/Forms/AbsenceRequestForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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']);

Expand All @@ -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) {

Expand Down Expand Up @@ -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));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down
Loading

0 comments on commit 69c9adf

Please sign in to comment.