/** * Implementation of hook_civicrm_tabs */ function hrabsence_civicrm_tabs(&$tabs, $contactID) { $contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type', 'id'); if (!($contactType == 'Individual' && CRM_HRAbsence_Page_EmployeeAbsencePage::checkPermissions($contactID, 'viewWidget'))) { return; } $absence = civicrm_api3('Activity', 'getabsences', array('target_contact_id' => $contactID)); $absenceDuration = 0; foreach ($absence['values'] as $k => $v) { $absenceDuration += CRM_HRAbsence_BAO_HRAbsenceType::getAbsenceDuration($v['id']); } CRM_HRAbsence_Page_EmployeeAbsencePage::registerResources($contactID); $tabs[] = array('id' => 'absenceTab', 'url' => CRM_Utils_System::url('civicrm/absences', array('cid' => $contactID, 'snippet' => 1)), 'count' => $absenceDuration / (8 * 60), 'title' => ts('Absences'), 'weight' => 300); }
<?php // CRM_Core_Resources::singleton()->addScriptFile(...); // CRM_Core_Resources::singleton()->addStyleFile(...); // CRM_Core_Resources::singleton()->addSetting(...); CRM_HRAbsence_Page_EmployeeAbsencePage::registerResources(202, array(100 => array('id' => 100, 'name' => 'Vacation', 'title' => 'Vacation', 'is_active' => 1, 'allow_debits' => 1, 'debit_activity_type_id' => 10, 'allow_credits' => 0, 'credit_activity_type_id' => NULL), 101 => array('id' => 101, 'name' => 'TOIL', 'title' => 'TOIL', 'is_active' => 1, 'allow_debits' => 1, 'debit_activity_type_id' => 11, 'allow_credits' => 1, 'credit_activity_type_id' => 12)), array(10 => 'Vacation', 11 => 'TOIL', 12 => 'TOIL (Credit)'), array(2 => array('id' => 2, 'name' => 'FY2012', 'title' => 'FY 2012', 'start_date' => '2012-04-01 00:00:00', 'end_date' => '2013-03-31 23:59:59'), 3 => array('id' => 3, 'name' => 'FY2013', 'title' => 'FY 2013', 'start_date' => '2013-04-01 00:00:00', 'end_date' => '2014-03-31 23:59:59'))); CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrabsence', 'tests/qunit/assert.js', 10); CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrabsence', 'tests/qunit/hrabsenceapp/fixtures.js', 10); CRM_HRAbsence_Page_EmployeeAbsencePage::addScriptFiles('org.civicrm.hrabsence', 'tests/qunit/hrabsenceapp/test-*.js', 20);