Skip to content

Commit

Permalink
Merge pull request #108 from compucorp/PCHR-831-show-leave-requests-t…
Browse files Browse the repository at this point in the history
…ill-end-date

PCHR-831: Show leave request until the end day of relationships
  • Loading branch information
nishant-bhorodia committed Feb 9, 2016
2 parents 08b36eb + e684493 commit 5aa5fb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion civihr_employee_portal/civihr_employee_portal.module
Original file line number Diff line number Diff line change
Expand Up @@ -5356,6 +5356,8 @@ function _getManagerContacts($contact_id) {
* @return boolean
*/
function relationActiveAndCurrent($relation){
return $relation['is_active'] == 1 && (strtotime($relation['end_date']) >= time() || empty($relation['end_date']))
$endDate = empty($relation['end_date']) ? NULL : $relation['end_date'] . " 23:59:59";

return $relation['is_active'] == 1 && (strtotime($endDate) >= time() || empty($endDate))
&& (empty($relation['start_date']) || strtotime($relation['start_date']) <= time());
}
13 changes: 10 additions & 3 deletions civihr_employee_portal/src/Blocks/ManagerCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ public function generateBlock() {
$months_data = array();

$uid = $user->uid;
$result = db_query('SELECT aal.employee_id, aal.id, aal.activity_type_id, aal.absence_title, aal.duration, aal.absence_start_date_timestamp, aal.absence_end_date_timestamp, absence_status
FROM {absence_approval_list} aal WHERE absence_status != :cancelled AND YEAR(absence_end_date) = YEAR(CURDATE())', array('cancelled' => 3));

$managerData = get_civihr_uf_match_data($uid);
$managerId = $managerData['contact_id'];

$result = db_query('SELECT aal.employee_id, aal.id, aal.activity_type_id, aal.absence_title, aal.duration, aal.absence_start_date_timestamp, aal.absence_end_date_timestamp, absence_status,
manager_id FROM {absence_approval_list} aal WHERE absence_status != :cancelled AND YEAR(absence_end_date) = YEAR(CURDATE())', array('cancelled' => 3));

// Result is returned as a iterable object that returns a stdClass object on each iteration
foreach ($result as $record) {

$managers = _getManagerContacts($record->employee_id);
if(!in_array($managerId, $managers)){
continue;
}
$check_start_month = intval(date('n', $record->absence_start_date_timestamp + 3600)); // 1-12
$check_end_month = intval(date('n', $record->absence_end_date_timestamp + 3600)); // 1-12
$check_start_day = intval(date('d', $record->absence_start_date_timestamp + 3600));
Expand Down

0 comments on commit 5aa5fb3

Please sign in to comment.