Skip to content

Commit

Permalink
Merge pull request #112 from compucorp/integration
Browse files Browse the repository at this point in the history
Sync master with integration
  • Loading branch information
Alessandro committed Apr 4, 2016
2 parents e6fdd2d + 6eefa80 commit 140d2cc
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 11 deletions.
5 changes: 4 additions & 1 deletion civihr_employee_portal/civihr_employee_portal.module
Original file line number Diff line number Diff line change
Expand Up @@ -5356,5 +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());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @file
* civihr_employee_portal_features.features.menu_custom.inc
*/

/**
* Implements hook_menu_default_menu_custom().
*/
function civihr_employee_portal_features_menu_default_menu_custom() {
$menus = array();

// Exported menu: main-menu.
$menus['main-menu'] = array(
'menu_name' => 'main-menu',
'title' => 'Main menu',
'description' => 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.',
);
// Translatables
// Included for use with string extractors like potx.
t('Main menu');
t('The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.');


return $menus;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* @file
* civihr_employee_portal_features.features.menu_links.inc
*/

/**
* Implements hook_menu_default_menu_links().
*/
function civihr_employee_portal_features_menu_default_menu_links() {
$menu_links = array();

// Exported menu link: main-menu_home:dashboard
$menu_links['main-menu_home:dashboard'] = array(
'menu_name' => 'main-menu',
'link_path' => 'dashboard',
'router_path' => 'dashboard',
'link_title' => 'Home',
'options' => array(
'attributes' => array(
'title' => '',
),
'identifier' => 'main-menu_home:dashboard',
),
'module' => 'menu',
'hidden' => 0,
'external' => 0,
'has_children' => 0,
'expanded' => 0,
'weight' => 0,
'customized' => 1,
);
// Translatables
// Included for use with string extractors like potx.
t('Home');


return $menu_links;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies[] = download
dependencies[] = entity
dependencies[] = features
dependencies[] = file
dependencies[] = menu
dependencies[] = mimemail
dependencies[] = mimemail_action
dependencies[] = mimemail_compress
Expand Down Expand Up @@ -37,6 +38,7 @@ features[field_instance][] = node-hr_documents-field_attachment
features[field_instance][] = node-hr_documents-field_download
features[field_instance][] = node-hr_documents-field_resource_type
features[field_instance][] = node-hr_documents-field_short_description
features[menu_links][] = main-menu_home:dashboard
features[node][] = hr_documents
features[page_manager_pages][] = dashboard
features[page_manager_pages][] = welcome_page
Expand Down Expand Up @@ -148,3 +150,4 @@ features[variable][] = node_submitted_hr_documents
features[variable][] = node_submitted_webform
features[variable][] = site_frontpage
features_exclude[node][webform] = webform
features_exclude[menu_custom][main-menu] = main-menu
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');

$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
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ $handler->display->display_options['row_options']['inline'] = array(
);
$handler->display->display_options['row_options']['colors']['legend'] = 'absence_type';
$handler->display->display_options['row_options']['colors']['calendar_colors_absence_type'] = array(
52 => '#E48282', // sick
53 => '#4D6C81', // vacation
54 => '#EBA782', // maternity
55 => '#91C68E', // paternity
57 => '#1606c3', // TOIL (CREDIT)
56 => '#977CA9', // TOIL
58 => '#C198AC', // Other
52 => '#E48282',
53 => '#4D6C81',
54 => '#EBA782',
55 => '#91C68E',
57 => '#1606c3',
56 => '#977CA9',
58 => '#C198AC',
);
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['footer'] = FALSE;
Expand Down Expand Up @@ -177,6 +177,14 @@ $handler->display->display_options['arguments']['drupal_uid']['default_argument_
$handler->display->display_options['arguments']['drupal_uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['drupal_uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['drupal_uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
/* Filter criterion: Absence entity: Absence status */
$handler->display->display_options['filters']['absence_status']['id'] = 'absence_status';
$handler->display->display_options['filters']['absence_status']['table'] = 'absence_list';
$handler->display->display_options['filters']['absence_status']['field'] = 'absence_status';
$handler->display->display_options['filters']['absence_status']['operator'] = '!=';
$handler->display->display_options['filters']['absence_status']['value'] = '3';
$handler->display->display_options['path'] = 'calendar-absence-list';
$handler->display->display_options['menu']['type'] = 'default tab';
$handler->display->display_options['menu']['title'] = 'Month';
Expand Down

0 comments on commit 140d2cc

Please sign in to comment.