From 02031447489fdcd53d1581d4b6897fa4b281833d Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Mon, 26 Feb 2018 14:22:23 +0100
Subject: [PATCH 001/203] PCHR-3353: Set custom field group that should not be
editable to is_reserved yes
---
hrdemog/CRM/HRDemog/Upgrader.php | 14 ++++++++++++
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 15 +++++++++++++
hrrecruitment/CRM/HRRecruitment/Upgrader.php | 15 +++++++++++++
hrui/CRM/HRUI/Upgrader.php | 1 +
hrui/CRM/HRUI/Upgrader/Steps/4708.php | 20 +++++++++++++++++
.../CRM/Hremergency/Upgrader.php | 1 +
.../CRM/Hremergency/Upgrader/Steps/1004.php | 22 +++++++++++++++++++
7 files changed, 88 insertions(+)
create mode 100644 hrui/CRM/HRUI/Upgrader/Steps/4708.php
create mode 100644 org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
diff --git a/hrdemog/CRM/HRDemog/Upgrader.php b/hrdemog/CRM/HRDemog/Upgrader.php
index 4a61caf1926..e4946e316af 100644
--- a/hrdemog/CRM/HRDemog/Upgrader.php
+++ b/hrdemog/CRM/HRDemog/Upgrader.php
@@ -161,4 +161,18 @@ public function upgrade_1400() {
CRM_Core_DAO::executeQuery("UPDATE civicrm_custom_group SET is_reserved = 0, collapse_display = 1 where name = 'Extended_Demographics'");
return TRUE;
}
+
+ /**
+ * Upgrade CustomGroup, setting Extended_Demographics is_reserved value to YES
+ */
+ public function upgrade_1401() {
+ $result = civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ["id"],
+ 'name' => "Extended_Demographics",
+ 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 0],
+ ]);
+
+ return true;
+ }
}
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 50b323a33dc..d60ae228d42 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1157,6 +1157,21 @@ public function upgrade_1033() {
return TRUE;
}
+ /**
+ * Update CustomGroup, setting Contact_Length_Of_Service is_reserved to Yes
+ * @return bool
+ */
+ public function upgrade_1034() {
+ $result = civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ["id"],
+ 'name' => "Contact_Length_Of_Service",
+ 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 0],
+ ]);
+
+ return true;
+ }
+
/**
* Removes the "Pension Type" item from the
* "Administer -> Customize Data and Screens -> Dropdowns" menu
diff --git a/hrrecruitment/CRM/HRRecruitment/Upgrader.php b/hrrecruitment/CRM/HRRecruitment/Upgrader.php
index 41bca437eb0..417ebbeeccc 100644
--- a/hrrecruitment/CRM/HRRecruitment/Upgrader.php
+++ b/hrrecruitment/CRM/HRRecruitment/Upgrader.php
@@ -49,4 +49,19 @@ public function upgrade_1402() {
return TRUE;
}
+
+ /**
+ * Upgrade CustomGroup, setting Application, application_case and Evaluation_fields names to is_reserved Yes
+ * @return bool
+ */
+ public function upgrade_1403() {
+ $result = civicrm_api3('CustomGroup', 'get', array(
+ 'sequential' => 1,
+ 'return' => array("id"),
+ 'name' => array('IN' => array("Application", "application_case", "Evaluation_fields")),
+ 'api.CustomGroup.create' => array('id' => "\$value.id", 'is_reserved' => 0),
+ ));
+
+ return true;
+ }
}
diff --git a/hrui/CRM/HRUI/Upgrader.php b/hrui/CRM/HRUI/Upgrader.php
index d63ccad0f47..3645442b0e4 100755
--- a/hrui/CRM/HRUI/Upgrader.php
+++ b/hrui/CRM/HRUI/Upgrader.php
@@ -38,6 +38,7 @@ class CRM_HRUI_Upgrader extends CRM_HRUI_Upgrader_Base {
use CRM_HRUI_Upgrader_Steps_4705;
use CRM_HRUI_Upgrader_Steps_4706;
use CRM_HRUI_Upgrader_Steps_4707;
+ use CRM_HRUI_Upgrader_Steps_4708;
public function install() {
$this->runAllUpgraders();
diff --git a/hrui/CRM/HRUI/Upgrader/Steps/4708.php b/hrui/CRM/HRUI/Upgrader/Steps/4708.php
new file mode 100644
index 00000000000..3dc509486f3
--- /dev/null
+++ b/hrui/CRM/HRUI/Upgrader/Steps/4708.php
@@ -0,0 +1,20 @@
+ 1,
+ 'return' => ["id"],
+ 'name' => "Inline_Custom_Data",
+ 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 1],
+ ]);
+
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/org.civicrm.hremergency/CRM/Hremergency/Upgrader.php b/org.civicrm.hremergency/CRM/Hremergency/Upgrader.php
index c6efb3a4b5f..af912c99c81 100644
--- a/org.civicrm.hremergency/CRM/Hremergency/Upgrader.php
+++ b/org.civicrm.hremergency/CRM/Hremergency/Upgrader.php
@@ -9,6 +9,7 @@ class CRM_Hremergency_Upgrader extends CRM_Hremergency_Upgrader_Base {
use CRM_Hremergency_Upgrader_Steps_1001;
use CRM_Hremergency_Upgrader_Steps_1002;
use CRM_Hremergency_Upgrader_Steps_1003;
+ use CRM_Hremergency_Upgrader_Steps_1004;
/**
* Change the custom_group ID to 99999 as we have this exported through Drupal webforms so the ID needs to be always the same
diff --git a/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php b/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
new file mode 100644
index 00000000000..ab57de21603
--- /dev/null
+++ b/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
@@ -0,0 +1,22 @@
+ 1,
+ 'return' => ["id"],
+ 'name' => "Emergency_Contacts",
+ 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 1, 'title' => "Emergency Contacts"],
+ ]);
+
+ return true;
+ }
+
+}
\ No newline at end of file
From 6a89702af3a845ca78861c7c98809f5f95f8e959 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Mon, 26 Feb 2018 14:46:00 +0100
Subject: [PATCH 002/203] PCHR-3353: Code refactoring from review
---
hrdemog/CRM/HRDemog/Upgrader.php | 25 ++++++------
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 23 +++++------
hrrecruitment/CRM/HRRecruitment/Upgrader.php | 24 ++++++------
hrui/CRM/HRUI/Upgrader/Steps/4708.php | 29 +++++++-------
.../CRM/Hremergency/Upgrader/Steps/1004.php | 39 +++++++++++--------
5 files changed, 77 insertions(+), 63 deletions(-)
diff --git a/hrdemog/CRM/HRDemog/Upgrader.php b/hrdemog/CRM/HRDemog/Upgrader.php
index e4946e316af..eea9e09c32f 100644
--- a/hrdemog/CRM/HRDemog/Upgrader.php
+++ b/hrdemog/CRM/HRDemog/Upgrader.php
@@ -162,17 +162,20 @@ public function upgrade_1400() {
return TRUE;
}
- /**
- * Upgrade CustomGroup, setting Extended_Demographics is_reserved value to YES
- */
+ /**
+ * Upgrade CustomGroup, setting Extended_Demographics is_reserved value to YES
+ *
+ * @return bool
+ */
public function upgrade_1401() {
- $result = civicrm_api3('CustomGroup', 'get', [
- 'sequential' => 1,
- 'return' => ["id"],
- 'name' => "Extended_Demographics",
- 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 0],
- ]);
-
- return true;
+ civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => 'Extended_Demographics',
+ 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
+ ]);
+
+ return TRUE;
}
+
}
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index d60ae228d42..c9ddc18c230 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1157,19 +1157,20 @@ public function upgrade_1033() {
return TRUE;
}
- /**
- * Update CustomGroup, setting Contact_Length_Of_Service is_reserved to Yes
- * @return bool
- */
+ /**
+ * Update CustomGroup, setting Contact_Length_Of_Service is_reserved to Yes
+ *
+ * @return bool
+ */
public function upgrade_1034() {
- $result = civicrm_api3('CustomGroup', 'get', [
- 'sequential' => 1,
- 'return' => ["id"],
- 'name' => "Contact_Length_Of_Service",
- 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 0],
- ]);
+ civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => 'Contact_Length_Of_Service',
+ 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
+ ]);
- return true;
+ return TRUE;
}
/**
diff --git a/hrrecruitment/CRM/HRRecruitment/Upgrader.php b/hrrecruitment/CRM/HRRecruitment/Upgrader.php
index 417ebbeeccc..52eed6daa18 100644
--- a/hrrecruitment/CRM/HRRecruitment/Upgrader.php
+++ b/hrrecruitment/CRM/HRRecruitment/Upgrader.php
@@ -50,18 +50,20 @@ public function upgrade_1402() {
return TRUE;
}
- /**
- * Upgrade CustomGroup, setting Application, application_case and Evaluation_fields names to is_reserved Yes
- * @return bool
- */
+ /**
+ * Upgrade CustomGroup, setting Application, application_case and Evaluation_fields names to is_reserved Yes
+ *
+ * @return bool
+ */
public function upgrade_1403() {
- $result = civicrm_api3('CustomGroup', 'get', array(
- 'sequential' => 1,
- 'return' => array("id"),
- 'name' => array('IN' => array("Application", "application_case", "Evaluation_fields")),
- 'api.CustomGroup.create' => array('id' => "\$value.id", 'is_reserved' => 0),
- ));
+ civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => ['IN' => ['Application', 'application_case', 'Evaluation_fields']],
+ 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
+ ]);
- return true;
+ return TRUE;
}
+
}
diff --git a/hrui/CRM/HRUI/Upgrader/Steps/4708.php b/hrui/CRM/HRUI/Upgrader/Steps/4708.php
index 3dc509486f3..f28b33e274b 100644
--- a/hrui/CRM/HRUI/Upgrader/Steps/4708.php
+++ b/hrui/CRM/HRUI/Upgrader/Steps/4708.php
@@ -2,19 +2,20 @@
trait CRM_HRUI_Upgrader_Steps_4708 {
- /**
- * Upgrade CustomGroup, set Inline_Custom_Data is_reserved Yes
- * @return bool
- */
- public function upgrade_4708() {
- $result = civicrm_api3('CustomGroup', 'get', [
- 'sequential' => 1,
- 'return' => ["id"],
- 'name' => "Inline_Custom_Data",
- 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 1],
- ]);
+ /**
+ * Upgrade CustomGroup, set Inline_Custom_Data is_reserved Yes
+ *
+ * @return bool
+ */
+ public function upgrade_4708() {
+ civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => 'Inline_Custom_Data',
+ 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
+ ]);
- return true;
- }
+ return TRUE;
+ }
-}
\ No newline at end of file
+}
diff --git a/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php b/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
index ab57de21603..18f27d38b80 100644
--- a/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
+++ b/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
@@ -2,21 +2,28 @@
trait CRM_Hremergency_Upgrader_Steps_1004 {
- /**
- * Upgrade CustomGroup, setting Emergency_Contacts is_reserved to Yes
- * title was included here because of an issue with webform_civicrm
- * @see https://www.drupal.org/project/webform_civicrm/issues/2947922
- * @return bool
- */
- public function upgrade_1004() {
- $result = civicrm_api3('CustomGroup', 'get', [
- 'sequential' => 1,
- 'return' => ["id"],
- 'name' => "Emergency_Contacts",
- 'api.CustomGroup.create' => ['id' => "\$value.id", 'is_reserved' => 1, 'title' => "Emergency Contacts"],
- ]);
+ /**
+ * Upgrade CustomGroup, setting Emergency_Contacts is_reserved to Yes.
+ * Title was included here because of an issue with webform_civicrm
+ * @see https://www.drupal.org/project/webform_civicrm/issues/2947922
+ *
+ * @return bool
+ */
+ public function upgrade_1004() {
+ $creationParams = [
+ 'id' => '\$value.id',
+ 'is_reserved' => 1,
+ 'title' => 'Emergency Contacts'
+ ];
+
+ civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => 'Emergency_Contacts',
+ 'api.CustomGroup.create' => $creationParams,
+ ]);
- return true;
- }
+ return TRUE;
+ }
-}
\ No newline at end of file
+}
From 6ccde6e1826a3f536e5912d98b5e0ab3ad95b16c Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Wed, 28 Feb 2018 11:18:14 +0000
Subject: [PATCH 003/203] PCHR-3353: Code refactor for Jenkins build failure
---
hrdemog/CRM/HRDemog/Upgrader.php | 8 ++++++--
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 18 +++++++++++-------
hrrecruitment/CRM/HRRecruitment/Upgrader.php | 10 ++++++++--
hrui/CRM/HRUI/Upgrader/Steps/4708.php | 10 +++++++---
.../CRM/Hremergency/Upgrader/Steps/1004.php | 17 ++++++++---------
5 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/hrdemog/CRM/HRDemog/Upgrader.php b/hrdemog/CRM/HRDemog/Upgrader.php
index eea9e09c32f..e32e54c4e78 100644
--- a/hrdemog/CRM/HRDemog/Upgrader.php
+++ b/hrdemog/CRM/HRDemog/Upgrader.php
@@ -168,11 +168,15 @@ public function upgrade_1400() {
* @return bool
*/
public function upgrade_1401() {
- civicrm_api3('CustomGroup', 'get', [
+ $result = civicrm_api3('CustomGroup', 'get', [
'sequential' => 1,
'return' => ['id'],
'name' => 'Extended_Demographics',
- 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
+ ]);
+
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
]);
return TRUE;
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index c9ddc18c230..19140c0a7dc 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -165,7 +165,7 @@ public function upgradeBundle() {
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
");
CRM_Core_DAO::executeQuery("
- INSERT INTO `civicrm_hrhours_location` (`id`, `location`, `standard_hours`, `periodicity`, `is_active`)
+ INSERT INTO `civicrm_hrhours_location` (`id`, `location`, `standard_hours`, `periodicity`, `is_active`)
VALUES (1, 'Head office', 40, 'Week', 1)
");
@@ -925,7 +925,7 @@ function upgrade_1020() {
if (empty($data)) {
CRM_Core_DAO::executeQuery("
- INSERT INTO `civicrm_hrpay_scale` (`pay_scale`, `pay_grade`, `currency`, `amount`, `periodicity`, `is_active`)
+ INSERT INTO `civicrm_hrpay_scale` (`pay_scale`, `pay_grade`, `currency`, `amount`, `periodicity`, `is_active`)
VALUES ('Not Applicable', NULL, NULL, NULL, NULL, 1)
");
}
@@ -1007,8 +1007,8 @@ public function upgrade_1025() {
*/
public function upgrade_1026() {
$query = "
- ALTER TABLE `civicrm_hrjobcontract_hour`
- CHANGE `fte_num` `fte_num` INT(10) UNSIGNED NULL DEFAULT '0' COMMENT '.',
+ ALTER TABLE `civicrm_hrjobcontract_hour`
+ CHANGE `fte_num` `fte_num` INT(10) UNSIGNED NULL DEFAULT '0' COMMENT '.',
CHANGE `fte_denom` `fte_denom` INT(10) UNSIGNED NULL DEFAULT '0' COMMENT '.'
";
CRM_Core_DAO::executeQuery($query);
@@ -1163,12 +1163,16 @@ public function upgrade_1033() {
* @return bool
*/
public function upgrade_1034() {
- civicrm_api3('CustomGroup', 'get', [
+ $result = civicrm_api3('CustomGroup', 'get', array(
'sequential' => 1,
'return' => ['id'],
'name' => 'Contact_Length_Of_Service',
- 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
- ]);
+ ));
+
+ civicrm_api3('CustomGroup', 'create', array(
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ ));
return TRUE;
}
diff --git a/hrrecruitment/CRM/HRRecruitment/Upgrader.php b/hrrecruitment/CRM/HRRecruitment/Upgrader.php
index 52eed6daa18..2b0c053ded6 100644
--- a/hrrecruitment/CRM/HRRecruitment/Upgrader.php
+++ b/hrrecruitment/CRM/HRRecruitment/Upgrader.php
@@ -56,12 +56,18 @@ public function upgrade_1402() {
* @return bool
*/
public function upgrade_1403() {
- civicrm_api3('CustomGroup', 'get', [
+ $result = civicrm_api3('CustomGroup', 'get', [
'sequential' => 1,
'return' => ['id'],
'name' => ['IN' => ['Application', 'application_case', 'Evaluation_fields']],
- 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
]);
+
+ foreach ($result['values'] as $value) {
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $value['id'],
+ 'is_reserved' => 1,
+ ]);
+ }
return TRUE;
}
diff --git a/hrui/CRM/HRUI/Upgrader/Steps/4708.php b/hrui/CRM/HRUI/Upgrader/Steps/4708.php
index f28b33e274b..bbd3c0de73a 100644
--- a/hrui/CRM/HRUI/Upgrader/Steps/4708.php
+++ b/hrui/CRM/HRUI/Upgrader/Steps/4708.php
@@ -8,13 +8,17 @@ trait CRM_HRUI_Upgrader_Steps_4708 {
* @return bool
*/
public function upgrade_4708() {
- civicrm_api3('CustomGroup', 'get', [
+ $result = civicrm_api3('CustomGroup', 'get', [
'sequential' => 1,
'return' => ['id'],
'name' => 'Inline_Custom_Data',
- 'api.CustomGroup.create' => ['id' => '\$value.id', 'is_reserved' => 1],
]);
-
+
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ ]);
+
return TRUE;
}
diff --git a/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php b/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
index 18f27d38b80..cf222bce359 100644
--- a/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
+++ b/org.civicrm.hremergency/CRM/Hremergency/Upgrader/Steps/1004.php
@@ -6,21 +6,20 @@ trait CRM_Hremergency_Upgrader_Steps_1004 {
* Upgrade CustomGroup, setting Emergency_Contacts is_reserved to Yes.
* Title was included here because of an issue with webform_civicrm
* @see https://www.drupal.org/project/webform_civicrm/issues/2947922
- *
+ *
* @return bool
*/
public function upgrade_1004() {
- $creationParams = [
- 'id' => '\$value.id',
- 'is_reserved' => 1,
- 'title' => 'Emergency Contacts'
- ];
-
- civicrm_api3('CustomGroup', 'get', [
+ $result = civicrm_api3('CustomGroup', 'get', [
'sequential' => 1,
'return' => ['id'],
'name' => 'Emergency_Contacts',
- 'api.CustomGroup.create' => $creationParams,
+ ]);
+
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ 'title' => 'Emergency Contacts'
]);
return TRUE;
From 928f1414626b167ab16b5f3c3cfc08645c64514d Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Thu, 1 Mar 2018 10:38:49 +0100
Subject: [PATCH 004/203] PCHR-3162-configurability-changes: Merge conflict
resolution
---
hrui/CRM/HRUI/Upgrader.php | 1 +
hrui/CRM/HRUI/Upgrader/Steps/4709.php | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 hrui/CRM/HRUI/Upgrader/Steps/4709.php
diff --git a/hrui/CRM/HRUI/Upgrader.php b/hrui/CRM/HRUI/Upgrader.php
index 3645442b0e4..d80d0eb7771 100755
--- a/hrui/CRM/HRUI/Upgrader.php
+++ b/hrui/CRM/HRUI/Upgrader.php
@@ -39,6 +39,7 @@ class CRM_HRUI_Upgrader extends CRM_HRUI_Upgrader_Base {
use CRM_HRUI_Upgrader_Steps_4706;
use CRM_HRUI_Upgrader_Steps_4707;
use CRM_HRUI_Upgrader_Steps_4708;
+ use CRM_HRUI_Upgrader_Steps_4709;
public function install() {
$this->runAllUpgraders();
diff --git a/hrui/CRM/HRUI/Upgrader/Steps/4709.php b/hrui/CRM/HRUI/Upgrader/Steps/4709.php
new file mode 100644
index 00000000000..1d5b4645365
--- /dev/null
+++ b/hrui/CRM/HRUI/Upgrader/Steps/4709.php
@@ -0,0 +1,25 @@
+ 1,
+ 'return' => ['id'],
+ 'name' => 'Inline_Custom_Data',
+ ]);
+
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ ]);
+
+ return TRUE;
+ }
+
+}
From 80cd279d208c09a0b8854c807a5a8c92d5c1fa4d Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Thu, 1 Mar 2018 15:16:11 +0100
Subject: [PATCH 005/203] PCHR-3392: Set custom field group to is_reserved yes
---
hrident/CRM/HRIdent/Upgrader.php | 24 ++++++++++++
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 41 +++++++++++++++++---
2 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/hrident/CRM/HRIdent/Upgrader.php b/hrident/CRM/HRIdent/Upgrader.php
index dd45de20b7e..96044b97b34 100755
--- a/hrident/CRM/HRIdent/Upgrader.php
+++ b/hrident/CRM/HRIdent/Upgrader.php
@@ -135,4 +135,28 @@ public function upgrade_1501() {
return true;
}
+
+ /**
+ * Upgrade CustomGroup, setting Identify is_reserved value to Yes
+ * if it existing.
+ *
+ * @return bool
+ */
+ public function upgrade_1502() {
+ $result = civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => 'Identify',
+ ]);
+
+ if ($result['id']) {
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ ]);
+ }
+
+ return TRUE;
+ }
+
}
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 19140c0a7dc..bd806c1b77b 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1163,16 +1163,47 @@ public function upgrade_1033() {
* @return bool
*/
public function upgrade_1034() {
- $result = civicrm_api3('CustomGroup', 'get', array(
+ $result = civicrm_api3('CustomGroup', 'get', [
'sequential' => 1,
'return' => ['id'],
'name' => 'Contact_Length_Of_Service',
- ));
-
- civicrm_api3('CustomGroup', 'create', array(
+ ]);
+
+ civicrm_api3('CustomGroup', 'create', [
'id' => $result['id'],
'is_reserved' => 1,
- ));
+ ]);
+
+ return TRUE;
+ }
+
+ /**
+ * Upgrade CustomGroup, setting HRJobContract_Dates, HRJob_Summary and
+ * HRJobContract_Summary is_reserved value to Yes if it is existing.
+ *
+ * @return bool
+ */
+ public function upgrade_1035() {
+ $customGroups = [
+ 'HRJobContract_Dates',
+ 'HRJob_Summary',
+ 'HRJobContract_Summary'
+ ];
+
+ $result = civicrm_api3('CustomGroup', 'get', [
+ 'sequential' => 1,
+ 'return' => ['id'],
+ 'name' => ['IN' => $customGroups],
+ ]);
+
+ if (count($result['values'])) {
+ foreach ($result['values'] as $value) {
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $value['id'],
+ 'is_reserved' => 1,
+ ]);
+ }
+ }
return TRUE;
}
From b79bddc78c663a88c46014cd84390cbf6d430c68 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Thu, 1 Mar 2018 17:20:27 +0100
Subject: [PATCH 006/203] PCHR-3392: Code refactoring
---
hrident/CRM/HRIdent/Upgrader.php | 1 -
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/hrident/CRM/HRIdent/Upgrader.php b/hrident/CRM/HRIdent/Upgrader.php
index 96044b97b34..18b0cb6df93 100755
--- a/hrident/CRM/HRIdent/Upgrader.php
+++ b/hrident/CRM/HRIdent/Upgrader.php
@@ -144,7 +144,6 @@ public function upgrade_1501() {
*/
public function upgrade_1502() {
$result = civicrm_api3('CustomGroup', 'get', [
- 'sequential' => 1,
'return' => ['id'],
'name' => 'Identify',
]);
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index bd806c1b77b..3645ec3a097 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1191,12 +1191,11 @@ public function upgrade_1035() {
];
$result = civicrm_api3('CustomGroup', 'get', [
- 'sequential' => 1,
'return' => ['id'],
'name' => ['IN' => $customGroups],
]);
- if (count($result['values'])) {
+ if ($result['count'] > 0) {
foreach ($result['values'] as $value) {
civicrm_api3('CustomGroup', 'create', [
'id' => $value['id'],
From b1f4ad138b85bd87a1da526f7842a8ad7dc08fe1 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Tue, 6 Mar 2018 11:49:49 +0100
Subject: [PATCH 007/203] PCHR-3392: Moved HRIdent upgrade to HRCore due to
HRIdent extension being disabled
---
hrident/CRM/HRIdent/Upgrader.php | 22 --------------
.../CRM/HRCore/Upgrader.php | 1 +
.../CRM/HRCore/Upgrader/Steps/1011.php | 30 +++++++++++++++++++
3 files changed, 31 insertions(+), 22 deletions(-)
create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php
diff --git a/hrident/CRM/HRIdent/Upgrader.php b/hrident/CRM/HRIdent/Upgrader.php
index 18b0cb6df93..f52db740561 100755
--- a/hrident/CRM/HRIdent/Upgrader.php
+++ b/hrident/CRM/HRIdent/Upgrader.php
@@ -136,26 +136,4 @@ public function upgrade_1501() {
return true;
}
- /**
- * Upgrade CustomGroup, setting Identify is_reserved value to Yes
- * if it existing.
- *
- * @return bool
- */
- public function upgrade_1502() {
- $result = civicrm_api3('CustomGroup', 'get', [
- 'return' => ['id'],
- 'name' => 'Identify',
- ]);
-
- if ($result['id']) {
- civicrm_api3('CustomGroup', 'create', [
- 'id' => $result['id'],
- 'is_reserved' => 1,
- ]);
- }
-
- return TRUE;
- }
-
}
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
index c5dabab231d..e15a417dc7b 100755
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
@@ -18,6 +18,7 @@ class CRM_HRCore_Upgrader extends CRM_HRCore_Upgrader_Base {
use CRM_HRCore_Upgrader_Steps_1008;
use CRM_HRCore_Upgrader_Steps_1009;
use CRM_HRCore_Upgrader_Steps_1010;
+ use CRM_HRCore_Upgrader_Steps_1011;
/**
* @var array
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php
new file mode 100644
index 00000000000..d5140595f63
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php
@@ -0,0 +1,30 @@
+ ['id'],
+ 'name' => 'Identify',
+ ]);
+
+ if ($result['id']) {
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ ]);
+ }
+
+ return TRUE;
+ }
+}
From f2dea6219a1f33993625d8fa4f8650b8b8358264 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Tue, 6 Mar 2018 12:32:51 +0100
Subject: [PATCH 008/203] PCHR-3392: Comments refactor
---
.../CRM/HRCore/Upgrader/Steps/1011.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php
index d5140595f63..736482c7272 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1011.php
@@ -1,14 +1,11 @@
Date: Wed, 7 Mar 2018 09:40:12 +0100
Subject: [PATCH 009/203] PCHR-3433: Rename inline custom field data
---
hrui/CRM/HRUI/Upgrader.php | 1 +
hrui/CRM/HRUI/Upgrader/Steps/4710.php | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 hrui/CRM/HRUI/Upgrader/Steps/4710.php
diff --git a/hrui/CRM/HRUI/Upgrader.php b/hrui/CRM/HRUI/Upgrader.php
index d80d0eb7771..883b60a142c 100755
--- a/hrui/CRM/HRUI/Upgrader.php
+++ b/hrui/CRM/HRUI/Upgrader.php
@@ -40,6 +40,7 @@ class CRM_HRUI_Upgrader extends CRM_HRUI_Upgrader_Base {
use CRM_HRUI_Upgrader_Steps_4707;
use CRM_HRUI_Upgrader_Steps_4708;
use CRM_HRUI_Upgrader_Steps_4709;
+ use CRM_HRUI_Upgrader_Steps_4710;
public function install() {
$this->runAllUpgraders();
diff --git a/hrui/CRM/HRUI/Upgrader/Steps/4710.php b/hrui/CRM/HRUI/Upgrader/Steps/4710.php
new file mode 100644
index 00000000000..f93b9b94ecf
--- /dev/null
+++ b/hrui/CRM/HRUI/Upgrader/Steps/4710.php
@@ -0,0 +1,23 @@
+ ['id'],
+ 'name' => 'Inline_Custom_Data',
+ ]);
+
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'title' => 'NI/SSN Number',
+ ]);
+
+ return TRUE;
+ }
+
+}
From 8805efb76002758e3568fb88447eb52fa582c94b Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 26 Feb 2018 11:12:53 +0000
Subject: [PATCH 010/203] PCHR-3354: Add permission 'access root menu items and
configurations'
---
uk.co.compucorp.civicrm.hrcore/hrcore.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/hrcore.php b/uk.co.compucorp.civicrm.hrcore/hrcore.php
index 3ef44d449fe..883ae508a6d 100644
--- a/uk.co.compucorp.civicrm.hrcore/hrcore.php
+++ b/uk.co.compucorp.civicrm.hrcore/hrcore.php
@@ -309,11 +309,13 @@ function hrcore_civicrm_alterMenu(&$items) {
* Implements hook_civicrm_permission().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/
+ *
+ * @param array $permissions
*/
function hrcore_civicrm_permission(&$permissions) {
- $permissions += [
- 'access CiviCRM developer menu and tools' => ts('Access CiviCRM developer menu and tools')
- ];
+ $prefix = ts('CiviHR') . ': ';
+ $permissions['access CiviCRM developer menu and tools'] = ts('Access CiviCRM developer menu and tools');
+ $permissions['access root menu items and configurations'] = $prefix . ts('Access root menu items and configurations');
}
/**
From 5696b1e0cac35d16f008a9f08f52d76466fd0250 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 26 Feb 2018 13:11:33 +0000
Subject: [PATCH 011/203] PCHR-3365: Change permission on "CiviHR website" menu
link
---
uk.co.compucorp.civicrm.hrcore/hrcore.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/hrcore.php b/uk.co.compucorp.civicrm.hrcore/hrcore.php
index 883ae508a6d..ce4c410a7c0 100644
--- a/uk.co.compucorp.civicrm.hrcore/hrcore.php
+++ b/uk.co.compucorp.civicrm.hrcore/hrcore.php
@@ -427,7 +427,7 @@ function _hrcore_createHelpMenu(&$menu) {
'name' => ts('CiviHR website'),
'url' => 'https://www.civihr.org/',
'target' => '_blank',
- 'permission' => 'access CiviCRM'
+ 'permission' => 'access root menu items and configurations'
]);
_hrcore_civix_insert_navigation_menu($menu, 'Help', [
From 113c0e78a84d51a9f999f7310603747817c3f9bf Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 28 Feb 2018 13:33:45 +0000
Subject: [PATCH 012/203] PCHR-3374: Add helper class for nav menu manipulation
---
.../HRCore/Helper/NavigationMenuHelper.php | 214 +
.../HRCore/Files/sample_navigation_menu.json | 4348 +++++++++++++++++
.../Helper/NavigationMenuHelperTest.php | 208 +
3 files changed, 4770 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
create mode 100644 uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
create mode 100644 uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
new file mode 100644
index 00000000000..2b9c8f7f860
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -0,0 +1,214 @@
+ $label, 'active' => 1];
+ $newItem = ['attributes' => array_merge($defaults, $itemAttributes)];
+
+ $parent['child'][] = $newItem;
+ }
+
+ /**
+ * @param $menu
+ * @param $nameOfItemToMove
+ * @param $nameOfItemBefore
+ * @throws Exception
+ */
+ public static function relocateAfter(&$menu, $nameOfItemToMove, $nameOfItemBefore) {
+ $parentName = self::findParentItemName($menu, $nameOfItemBefore);
+
+ if ($parentName === 'root') {
+ $children = &$menu;
+ }
+ else {
+ $parent = &self::findMenuItemReferenceByName($menu, $parentName);
+ $children = &$parent['child'];
+ }
+
+ $itemToMove = self::findMenuItemByName($menu, $nameOfItemToMove);
+ self::remove($menu, $nameOfItemToMove);
+
+ $targetIndex = NULL;
+ $offset = 1; // because we want to insert it after
+ $found = FALSE;
+ foreach ($children as $index => $child) {
+ if ($child['attributes']['name'] === $nameOfItemBefore) {
+ $found = TRUE;
+ break;
+ }
+ $offset++;
+ }
+
+ if (!$found) {
+ $err = sprintf('Could not find menu item "%s"', $nameOfItemBefore);
+ throw new \Exception($err);
+ }
+
+ array_splice($children, $offset, 0, [$itemToMove]);
+ }
+
+ public static function remove(&$menu, $name) {
+ $parentName = self::findParentItemName($menu, $name);
+
+ if ($parentName === NULL) {
+ $err = sprintf('Cannot find parent of menu item "%s"', $name);
+ throw new \Exception($err);
+ }
+
+ if ($parentName === 'root') {
+ $children = &$menu;
+ }
+ else {
+ $parent = &self::findMenuItemReferenceByName($menu, $parentName);
+ $children = &$parent['child'];
+ }
+
+ foreach ($children as $index => $child) {
+ if ($child['attributes']['name'] === $name) {
+ unset($children[$index]);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Sets the permission on a named menu item
+ *
+ * @param array $menu
+ * The full menu
+ * @param string $name
+ * The name of the target menu item
+ * @param string $newPermission
+ * The new permission for accessing this item
+ */
+ public static function updatePermissionByName(&$menu, $name, $newPermission) {
+ $item = &self::findMenuItemReferenceByName($menu, $name);
+
+ if (!$item) {
+ $err = sprintf('Cannot find menu item with name "%s"', $name);
+ throw new \Exception($err);
+ }
+
+ $item['attributes']['permission'] = $newPermission;
+ }
+
+ /**
+ * Recursively search for a menu item by its name
+ *
+ * @param array $menu
+ * @param string $name
+ *
+ * @return array|null
+ * The menu item, if found, or null otherwise
+ */
+ public static function findMenuItemByName($menu, $name) {
+ return self::findMenuItemReferenceByName($menu, $name);
+ }
+
+ /**
+ * Recursively search for a menu item by its name. Returns a reference to
+ * the item.
+ *
+ * @param array $menu
+ * @param string $name
+ *
+ * @return array|null
+ * The referenced menu item, if found, or null otherwise
+ */
+ private static function &findMenuItemReferenceByName(&$menu, $name) {
+ foreach ($menu as &$item) {
+ if ($item['attributes']['name'] === $name) {
+ return $item;
+ }
+ if (!empty($item['child'])) {
+ $found = &self::findMenuItemReferenceByName($item['child'], $name);
+
+ if ($found) {
+ return $found;
+ }
+ }
+ }
+
+ // must return reference to variable
+ $item = NULL;
+
+ return $item;
+ }
+
+ /**
+ * Recursively search for a menu item's parent name by the child name
+ *
+ * This is a wrapper for a private function that requires a third argument.
+ *
+ * @param array $menu
+ * @param string $childName
+ *
+ * @return string|null
+ * The parent item name, if found, or null otherwise.
+ * If item is at top level parent name will be 'root'
+ */
+ public static function findParentItemName($menu, $childName
+ ) {
+ return self::findParentItemNameFromRoot($menu, $childName, 'root');
+ }
+
+ /**
+ * Recursively search for a menu item's parent name by the child name
+ *
+ * @param array $menu
+ * @param string $childName
+ * @param string $parentName
+ *
+ * @return string|null
+ * The parent item name, if found, or null otherwise.
+ * If item is at top level parent name will be 'root'
+ */
+ private static function findParentItemNameFromRoot(
+ $menu,
+ $childName,
+ $parentName
+ ) {
+ foreach ($menu as $item) {
+ if ($item['attributes']['name'] === $childName) {
+ return $parentName;
+ }
+ if (!empty($item['child'])) {
+ $children = $item['child'];
+ $found = self::findParentItemNameFromRoot(
+ $children,
+ $childName,
+ $item['attributes']['name']
+ );
+
+ if ($found) {
+ return $found;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
new file mode 100644
index 00000000000..e5d18f90d3f
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
@@ -0,0 +1,4348 @@
+{
+ "1": {
+ "attributes": {
+ "label": "Home",
+ "name": "Home",
+ "url": "civicrm/tasksassignments/dashboard#/tasks",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "1",
+ "active": "1"
+ }
+ },
+ "2": {
+ "attributes": {
+ "label": "Search",
+ "name": "Search...",
+ "url": null,
+ "icon": "crm-i fa-search",
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "2",
+ "active": "1"
+ },
+ "child": {
+ "3": {
+ "attributes": {
+ "label": "Find Contacts",
+ "name": "Find Contacts",
+ "url": "civicrm/contact/search?reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "3",
+ "active": "1"
+ }
+ },
+ "4": {
+ "attributes": {
+ "label": "Advanced Search",
+ "name": "Advanced Search",
+ "url": "civicrm/contact/search/advanced?reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "4",
+ "active": "1"
+ }
+ },
+ "5": {
+ "attributes": {
+ "label": "Full-text Search",
+ "name": "Full-text Search",
+ "url": "civicrm/contact/search/custom?csid=15&reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "5",
+ "active": "1"
+ }
+ },
+ "6": {
+ "attributes": {
+ "label": "Search Builder",
+ "name": "Search Builder",
+ "url": "civicrm/contact/search/builder?reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": "1",
+ "parentID": "2",
+ "navID": "6",
+ "active": "1"
+ }
+ },
+ "7": {
+ "attributes": {
+ "label": "Find Cases",
+ "name": "Find Cases",
+ "url": "civicrm/case/search?reset=1",
+ "icon": null,
+ "permission": "access my cases and activities,access all cases and activities",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "2",
+ "navID": "7",
+ "active": "1"
+ }
+ },
+ "8": {
+ "attributes": {
+ "label": "Find Contributions",
+ "name": "Find Contributions",
+ "url": "civicrm/contribute/search?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "8",
+ "active": "1"
+ }
+ },
+ "9": {
+ "attributes": {
+ "label": "Find Mailings",
+ "name": "Find Mailings",
+ "url": "civicrm/mailing?reset=1",
+ "icon": null,
+ "permission": "access CiviMail",
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "9",
+ "active": "1"
+ }
+ },
+ "10": {
+ "attributes": {
+ "label": "Find Memberships",
+ "name": "Find Memberships",
+ "url": "civicrm/member/search?reset=1",
+ "icon": null,
+ "permission": "access CiviMember",
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "10",
+ "active": "1"
+ }
+ },
+ "11": {
+ "attributes": {
+ "label": "Find Participants",
+ "name": "Find Participants",
+ "url": "civicrm/event/search?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent",
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "11",
+ "active": "1"
+ }
+ },
+ "12": {
+ "attributes": {
+ "label": "Find Pledges",
+ "name": "Find Pledges",
+ "url": "civicrm/pledge/search?reset=1",
+ "icon": null,
+ "permission": "access CiviPledge",
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "12",
+ "active": "1"
+ }
+ },
+ "13": {
+ "attributes": {
+ "label": "Find Activities",
+ "name": "Find Activities",
+ "url": "civicrm/activity/search?reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": "1",
+ "parentID": "2",
+ "navID": "13",
+ "active": "1"
+ }
+ },
+ "14": {
+ "attributes": {
+ "label": "Custom Searches",
+ "name": "Custom Searches",
+ "url": "civicrm/contact/search/custom/list?reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": "2",
+ "navID": "14",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "15": {
+ "attributes": {
+ "label": "Contacts",
+ "name": "Contacts",
+ "url": null,
+ "icon": "crm-i fa-users",
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "15",
+ "active": "1"
+ },
+ "child": {
+ "16": {
+ "attributes": {
+ "label": "New Individual",
+ "name": "New Individual",
+ "url": "civicrm/contact/add?reset=1&ct=Individual",
+ "icon": null,
+ "permission": "add contacts",
+ "operator": "",
+ "separator": null,
+ "parentID": "15",
+ "navID": "16",
+ "active": "1"
+ }
+ },
+ "17": {
+ "attributes": {
+ "label": "New Household",
+ "name": "New Household",
+ "url": "civicrm/contact/add?reset=1&ct=Household",
+ "icon": null,
+ "permission": "add contacts",
+ "operator": "",
+ "separator": null,
+ "parentID": "15",
+ "navID": "17",
+ "active": "0"
+ }
+ },
+ "18": {
+ "attributes": {
+ "label": "New Organization",
+ "name": "New Organization",
+ "url": "civicrm/contact/add?reset=1&ct=Organization",
+ "icon": null,
+ "permission": "add contacts",
+ "operator": "",
+ "separator": "1",
+ "parentID": "15",
+ "navID": "18",
+ "active": "1"
+ },
+ "child": {
+ "265": {
+ "attributes": {
+ "label": "New Health Insurance Provider",
+ "name": "New Health_Insurance_Provider",
+ "url": "civicrm/contact/add?ct=Organization&cst=Health_Insurance_Provider&reset=1",
+ "icon": null,
+ "permission": "add contacts",
+ "operator": null,
+ "separator": "0",
+ "parentID": "18",
+ "navID": "265",
+ "active": "1"
+ }
+ },
+ "266": {
+ "attributes": {
+ "label": "New Life Insurance Provider",
+ "name": "New Life_Insurance_Provider",
+ "url": "civicrm/contact/add?ct=Organization&cst=Life_Insurance_Provider&reset=1",
+ "icon": null,
+ "permission": "add contacts",
+ "operator": null,
+ "separator": "0",
+ "parentID": "18",
+ "navID": "266",
+ "active": "1"
+ }
+ },
+ "282": {
+ "attributes": {
+ "label": "New Pension Provider",
+ "name": "New Pension_Provider",
+ "url": "civicrm/contact/add?ct=Organization&cst=Pension_Provider&reset=1",
+ "icon": null,
+ "permission": "add contacts",
+ "operator": null,
+ "separator": "0",
+ "parentID": "18",
+ "navID": "282",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "19": {
+ "attributes": {
+ "label": "Contact Reports",
+ "name": "Contact Reports",
+ "url": "civicrm/report/list?compid=99&reset=1",
+ "icon": null,
+ "permission": "access CiviReport",
+ "operator": "",
+ "separator": "1",
+ "parentID": "15",
+ "navID": "19",
+ "active": "1"
+ }
+ },
+ "20": {
+ "attributes": {
+ "label": "New Activity",
+ "name": "New Activity",
+ "url": "civicrm/activity?reset=1&action=add&context=standalone",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": "15",
+ "navID": "20",
+ "active": "1"
+ }
+ },
+ "21": {
+ "attributes": {
+ "label": "New Email",
+ "name": "New Email",
+ "url": "civicrm/activity/email/add?atype=3&action=add&reset=1&context=standalone",
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": "1",
+ "parentID": "15",
+ "navID": "21",
+ "active": "1"
+ }
+ },
+ "22": {
+ "attributes": {
+ "label": "Import Contacts",
+ "name": "Import Contacts",
+ "url": "civicrm/import/contact?reset=1",
+ "icon": null,
+ "permission": "import contacts",
+ "operator": "",
+ "separator": null,
+ "parentID": "15",
+ "navID": "22",
+ "active": "1"
+ }
+ },
+ "23": {
+ "attributes": {
+ "label": "Import Activities",
+ "name": "Import Activities",
+ "url": "civicrm/import/activity?reset=1",
+ "icon": null,
+ "permission": "import contacts",
+ "operator": "",
+ "separator": "1",
+ "parentID": "15",
+ "navID": "23",
+ "active": "1"
+ }
+ },
+ "24": {
+ "attributes": {
+ "label": "New Group",
+ "name": "New Group",
+ "url": "civicrm/group/add?reset=1",
+ "icon": null,
+ "permission": "edit groups",
+ "operator": "",
+ "separator": null,
+ "parentID": "15",
+ "navID": "24",
+ "active": "1"
+ }
+ },
+ "25": {
+ "attributes": {
+ "label": "Manage Groups",
+ "name": "Manage Groups",
+ "url": "civicrm/group?reset=1",
+ "icon": null,
+ "permission": "access CiviCRM",
+ "operator": "",
+ "separator": "1",
+ "parentID": "15",
+ "navID": "25",
+ "active": "1"
+ }
+ },
+ "26": {
+ "attributes": {
+ "label": "New Tag",
+ "name": "New Tag",
+ "url": "civicrm/tag?reset=1&action=add",
+ "icon": null,
+ "permission": "manage tags",
+ "operator": "",
+ "separator": null,
+ "parentID": "15",
+ "navID": "26",
+ "active": "1"
+ }
+ },
+ "27": {
+ "attributes": {
+ "label": "Manage Tags (Categories)",
+ "name": "Manage Tags (Categories)",
+ "url": "civicrm/tag?reset=1",
+ "icon": null,
+ "permission": "manage tags",
+ "operator": "",
+ "separator": "1",
+ "parentID": "15",
+ "navID": "27",
+ "active": "1"
+ }
+ },
+ "28": {
+ "attributes": {
+ "label": "Find and Merge Duplicate Contacts",
+ "name": "Find and Merge Duplicate Contacts",
+ "url": "civicrm/contact/deduperules?reset=1",
+ "icon": null,
+ "permission": "administer dedupe rules,merge duplicate contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "15",
+ "navID": "28",
+ "active": "1"
+ }
+ },
+ "280": {
+ "attributes": {
+ "label": "Import / Export",
+ "name": "import_export_job_contracts",
+ "url": null,
+ "icon": null,
+ "permission": "access HRJobs",
+ "operator": null,
+ "separator": null,
+ "parentID": "15",
+ "navID": "280",
+ "active": "1"
+ },
+ "child": {
+ "281": {
+ "attributes": {
+ "label": "Import Job Contracts",
+ "name": "import_job_contracts",
+ "url": "civicrm/job/import",
+ "icon": null,
+ "permission": "access HRJobs",
+ "operator": null,
+ "separator": "0",
+ "parentID": "280",
+ "navID": "281",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "302": {
+ "attributes": {
+ "label": "Import Custom Fields",
+ "name": "import_custom_fields",
+ "url": "civicrm/import/custom?reset=1",
+ "icon": null,
+ "permission": "access CiviCRM",
+ "operator": null,
+ "separator": null,
+ "parentID": "15",
+ "navID": "302",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "29": {
+ "attributes": {
+ "label": "Contributions",
+ "name": "Contributions",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "29",
+ "active": "1"
+ },
+ "child": {
+ "30": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "Dashboard",
+ "url": "civicrm/contribute?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": null,
+ "parentID": "29",
+ "navID": "30",
+ "active": "1"
+ }
+ },
+ "31": {
+ "attributes": {
+ "label": "New Contribution",
+ "name": "New Contribution",
+ "url": "civicrm/contribute/add?reset=1&action=add&context=standalone",
+ "icon": null,
+ "permission": "access CiviContribute,edit contributions",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "29",
+ "navID": "31",
+ "active": "1"
+ }
+ },
+ "32": {
+ "attributes": {
+ "label": "Find Contributions",
+ "name": "Find Contributions",
+ "url": "civicrm/contribute/search?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": null,
+ "parentID": "29",
+ "navID": "32",
+ "active": "1"
+ }
+ },
+ "33": {
+ "attributes": {
+ "label": "Contribution Reports",
+ "name": "Contribution Reports",
+ "url": "civicrm/report/list?compid=2&reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "33",
+ "active": "1"
+ }
+ },
+ "34": {
+ "attributes": {
+ "label": "Import Contributions",
+ "name": "Import Contributions",
+ "url": "civicrm/contribute/import?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,edit contributions",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "34",
+ "active": "1"
+ }
+ },
+ "35": {
+ "attributes": {
+ "label": "Batch Data Entry",
+ "name": "Batch Data Entry",
+ "url": "civicrm/batch?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": null,
+ "parentID": "29",
+ "navID": "35",
+ "active": "1"
+ }
+ },
+ "36": {
+ "attributes": {
+ "label": "Pledges",
+ "name": "Pledges",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviPledge",
+ "operator": "",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "36",
+ "active": "1"
+ },
+ "child": {
+ "38": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "Dashboard",
+ "url": "civicrm/pledge?reset=1",
+ "icon": null,
+ "permission": "access CiviPledge",
+ "operator": "",
+ "separator": null,
+ "parentID": "36",
+ "navID": "38",
+ "active": "1"
+ }
+ },
+ "39": {
+ "attributes": {
+ "label": "New Pledge",
+ "name": "New Pledge",
+ "url": "civicrm/pledge/add?reset=1&action=add&context=standalone",
+ "icon": null,
+ "permission": "access CiviPledge,edit pledges",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "36",
+ "navID": "39",
+ "active": "1"
+ }
+ },
+ "40": {
+ "attributes": {
+ "label": "Find Pledges",
+ "name": "Find Pledges",
+ "url": "civicrm/pledge/search?reset=1",
+ "icon": null,
+ "permission": "access CiviPledge",
+ "operator": "",
+ "separator": null,
+ "parentID": "36",
+ "navID": "40",
+ "active": "1"
+ }
+ },
+ "41": {
+ "attributes": {
+ "label": "Pledge Reports",
+ "name": "Pledge Reports",
+ "url": "civicrm/report/list?compid=6&reset=1",
+ "icon": null,
+ "permission": "access CiviPledge",
+ "operator": "",
+ "separator": "0",
+ "parentID": "36",
+ "navID": "41",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "37": {
+ "attributes": {
+ "label": "Accounting Batches",
+ "name": "Accounting Batches",
+ "url": null,
+ "icon": null,
+ "permission": "view own manual batches,view all manual batches",
+ "operator": "OR",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "37",
+ "active": "1"
+ },
+ "child": {
+ "48": {
+ "attributes": {
+ "label": "New Batch",
+ "name": "New Batch",
+ "url": "civicrm/financial/batch?reset=1&action=add",
+ "icon": null,
+ "permission": "create manual batch",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "37",
+ "navID": "48",
+ "active": "1"
+ }
+ },
+ "49": {
+ "attributes": {
+ "label": "Open Batches",
+ "name": "Open Batches",
+ "url": "civicrm/financial/financialbatches?reset=1&batchStatus=1",
+ "icon": null,
+ "permission": "view own manual batches,view all manual batches",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "37",
+ "navID": "49",
+ "active": "1"
+ }
+ },
+ "50": {
+ "attributes": {
+ "label": "Closed Batches",
+ "name": "Closed Batches",
+ "url": "civicrm/financial/financialbatches?reset=1&batchStatus=2",
+ "icon": null,
+ "permission": "view own manual batches,view all manual batches",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "37",
+ "navID": "50",
+ "active": "1"
+ }
+ },
+ "51": {
+ "attributes": {
+ "label": "Exported Batches",
+ "name": "Exported Batches",
+ "url": "civicrm/financial/financialbatches?reset=1&batchStatus=5",
+ "icon": null,
+ "permission": "view own manual batches,view all manual batches",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "37",
+ "navID": "51",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "42": {
+ "attributes": {
+ "label": "New Contribution Page",
+ "name": "New Contribution Page",
+ "url": "civicrm/admin/contribute/add?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "29",
+ "navID": "42",
+ "active": "1"
+ }
+ },
+ "43": {
+ "attributes": {
+ "label": "Manage Contribution Pages",
+ "name": "Manage Contribution Pages",
+ "url": "civicrm/admin/contribute?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "43",
+ "active": "1"
+ }
+ },
+ "44": {
+ "attributes": {
+ "label": "Personal Campaign Pages",
+ "name": "Personal Campaign Pages",
+ "url": "civicrm/admin/pcp?reset=1&page_type=contribute",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "29",
+ "navID": "44",
+ "active": "1"
+ }
+ },
+ "45": {
+ "attributes": {
+ "label": "Premiums (Thank-you Gifts)",
+ "name": "Premiums",
+ "url": "civicrm/admin/contribute/managePremiums?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "45",
+ "active": "1"
+ }
+ },
+ "46": {
+ "attributes": {
+ "label": "New Price Set",
+ "name": "New Price Set",
+ "url": "civicrm/admin/price?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "29",
+ "navID": "46",
+ "active": "1"
+ }
+ },
+ "47": {
+ "attributes": {
+ "label": "Manage Price Sets",
+ "name": "Manage Price Sets",
+ "url": "civicrm/admin/price?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "29",
+ "navID": "47",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "52": {
+ "attributes": {
+ "label": "Events",
+ "name": "Events",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviEvent",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "52",
+ "active": "1"
+ },
+ "child": {
+ "53": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "CiviEvent Dashboard",
+ "url": "civicrm/event?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent",
+ "operator": "",
+ "separator": null,
+ "parentID": "52",
+ "navID": "53",
+ "active": "1"
+ }
+ },
+ "54": {
+ "attributes": {
+ "label": "Register Event Participant",
+ "name": "Register Event Participant",
+ "url": "civicrm/participant/add?reset=1&action=add&context=standalone",
+ "icon": null,
+ "permission": "access CiviEvent,edit event participants",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "52",
+ "navID": "54",
+ "active": "1"
+ }
+ },
+ "55": {
+ "attributes": {
+ "label": "Find Participants",
+ "name": "Find Participants",
+ "url": "civicrm/event/search?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent",
+ "operator": "",
+ "separator": null,
+ "parentID": "52",
+ "navID": "55",
+ "active": "1"
+ }
+ },
+ "56": {
+ "attributes": {
+ "label": "Event Reports",
+ "name": "Event Reports",
+ "url": "civicrm/report/list?compid=1&reset=1",
+ "icon": null,
+ "permission": "access CiviEvent",
+ "operator": "",
+ "separator": "1",
+ "parentID": "52",
+ "navID": "56",
+ "active": "1"
+ }
+ },
+ "57": {
+ "attributes": {
+ "label": "Import Participants",
+ "name": "Import Participants",
+ "url": "civicrm/event/import?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,edit event participants",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "52",
+ "navID": "57",
+ "active": "1"
+ }
+ },
+ "58": {
+ "attributes": {
+ "label": "New Event",
+ "name": "New Event",
+ "url": "civicrm/event/add?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviEvent,edit all events",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "52",
+ "navID": "58",
+ "active": "1"
+ }
+ },
+ "59": {
+ "attributes": {
+ "label": "Manage Events",
+ "name": "Manage Events",
+ "url": "civicrm/event/manage?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,edit all events",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "52",
+ "navID": "59",
+ "active": "1"
+ }
+ },
+ "60": {
+ "attributes": {
+ "label": "Personal Campaign Pages",
+ "name": "Personal Campaign Pages",
+ "url": "civicrm/admin/pcp?reset=1&page_type=event",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "52",
+ "navID": "60",
+ "active": "1"
+ }
+ },
+ "61": {
+ "attributes": {
+ "label": "Event Templates",
+ "name": "Event Templates",
+ "url": "civicrm/admin/eventTemplate?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,edit all events",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "52",
+ "navID": "61",
+ "active": "1"
+ }
+ },
+ "62": {
+ "attributes": {
+ "label": "New Price Set",
+ "name": "New Price Set",
+ "url": "civicrm/admin/price?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviEvent,edit all events",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "52",
+ "navID": "62",
+ "active": "1"
+ }
+ },
+ "63": {
+ "attributes": {
+ "label": "Manage Price Sets",
+ "name": "Manage Price Sets",
+ "url": "civicrm/admin/price?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,edit all events",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "52",
+ "navID": "63",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "64": {
+ "attributes": {
+ "label": "Mailings",
+ "name": "Mailings",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviMail,create mailings,approve mailings,schedule mailings",
+ "operator": "OR",
+ "separator": null,
+ "parentID": null,
+ "navID": "64",
+ "active": "1"
+ },
+ "child": {
+ "65": {
+ "attributes": {
+ "label": "New Mailing",
+ "name": "New Mailing",
+ "url": "civicrm/mailing/send?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,create mailings",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "64",
+ "navID": "65",
+ "active": "1"
+ }
+ },
+ "66": {
+ "attributes": {
+ "label": "Draft and Unscheduled Mailings",
+ "name": "Draft and Unscheduled Mailings",
+ "url": "civicrm/mailing/browse/unscheduled?reset=1&scheduled=false",
+ "icon": null,
+ "permission": "access CiviMail,create mailings,schedule mailings",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "64",
+ "navID": "66",
+ "active": "1"
+ }
+ },
+ "67": {
+ "attributes": {
+ "label": "Scheduled and Sent Mailings",
+ "name": "Scheduled and Sent Mailings",
+ "url": "civicrm/mailing/browse/scheduled?reset=1&scheduled=true",
+ "icon": null,
+ "permission": "access CiviMail,approve mailings,create mailings,schedule mailings",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "64",
+ "navID": "67",
+ "active": "1"
+ }
+ },
+ "68": {
+ "attributes": {
+ "label": "Archived Mailings",
+ "name": "Archived Mailings",
+ "url": "civicrm/mailing/browse/archived?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,create mailings",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "64",
+ "navID": "68",
+ "active": "1"
+ }
+ },
+ "69": {
+ "attributes": {
+ "label": "Mailing Reports",
+ "name": "Mailing Reports",
+ "url": "civicrm/report/list?compid=4&reset=1",
+ "icon": null,
+ "permission": "access CiviMail",
+ "operator": "",
+ "separator": "1",
+ "parentID": "64",
+ "navID": "69",
+ "active": "1"
+ }
+ },
+ "70": {
+ "attributes": {
+ "label": "Headers, Footers, and Automated Messages",
+ "name": "Headers, Footers, and Automated Messages",
+ "url": "civicrm/admin/component?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "64",
+ "navID": "70",
+ "active": "1"
+ }
+ },
+ "71": {
+ "attributes": {
+ "label": "Message Templates",
+ "name": "Message Templates",
+ "url": "civicrm/admin/messageTemplates?reset=1",
+ "icon": null,
+ "permission": "edit message templates",
+ "operator": "",
+ "separator": null,
+ "parentID": "64",
+ "navID": "71",
+ "active": "1"
+ }
+ },
+ "72": {
+ "attributes": {
+ "label": "From Email Addresses",
+ "name": "From Email Addresses",
+ "url": "civicrm/admin/options/from_email_address?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": "1",
+ "parentID": "64",
+ "navID": "72",
+ "active": "1"
+ }
+ },
+ "73": {
+ "attributes": {
+ "label": "New SMS",
+ "name": "New SMS",
+ "url": "civicrm/sms/send?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": null,
+ "parentID": "64",
+ "navID": "73",
+ "active": "1"
+ }
+ },
+ "74": {
+ "attributes": {
+ "label": "Find Mass SMS",
+ "name": "Find Mass SMS",
+ "url": "civicrm/mailing/browse?reset=1&sms=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "1",
+ "parentID": "64",
+ "navID": "74",
+ "active": "1"
+ }
+ },
+ "75": {
+ "attributes": {
+ "label": "New A/B Test",
+ "name": "New A/B Test",
+ "url": "civicrm/a/#/abtest/new",
+ "icon": null,
+ "permission": "access CiviMail",
+ "operator": "",
+ "separator": null,
+ "parentID": "64",
+ "navID": "75",
+ "active": "1"
+ }
+ },
+ "76": {
+ "attributes": {
+ "label": "Manage A/B Tests",
+ "name": "Manage A/B Tests",
+ "url": "civicrm/a/#/abtest",
+ "icon": null,
+ "permission": "access CiviMail",
+ "operator": "",
+ "separator": "1",
+ "parentID": "64",
+ "navID": "76",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "77": {
+ "attributes": {
+ "label": "Memberships",
+ "name": "Memberships",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviMember",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "77",
+ "active": "1"
+ },
+ "child": {
+ "78": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "Dashboard",
+ "url": "civicrm/member?reset=1",
+ "icon": null,
+ "permission": "access CiviMember",
+ "operator": "",
+ "separator": null,
+ "parentID": "77",
+ "navID": "78",
+ "active": "1"
+ }
+ },
+ "79": {
+ "attributes": {
+ "label": "New Membership",
+ "name": "New Membership",
+ "url": "civicrm/member/add?reset=1&action=add&context=standalone",
+ "icon": null,
+ "permission": "access CiviMember,edit memberships",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "77",
+ "navID": "79",
+ "active": "1"
+ }
+ },
+ "80": {
+ "attributes": {
+ "label": "Find Memberships",
+ "name": "Find Memberships",
+ "url": "civicrm/member/search?reset=1",
+ "icon": null,
+ "permission": "access CiviMember",
+ "operator": "",
+ "separator": null,
+ "parentID": "77",
+ "navID": "80",
+ "active": "1"
+ }
+ },
+ "81": {
+ "attributes": {
+ "label": "Membership Reports",
+ "name": "Membership Reports",
+ "url": "civicrm/report/list?compid=3&reset=1",
+ "icon": null,
+ "permission": "access CiviMember",
+ "operator": "",
+ "separator": "1",
+ "parentID": "77",
+ "navID": "81",
+ "active": "1"
+ }
+ },
+ "82": {
+ "attributes": {
+ "label": "Batch Data Entry",
+ "name": "Batch Data Entry",
+ "url": "civicrm/batch?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": null,
+ "parentID": "77",
+ "navID": "82",
+ "active": "1"
+ }
+ },
+ "83": {
+ "attributes": {
+ "label": "Import Memberships",
+ "name": "Import Members",
+ "url": "civicrm/member/import?reset=1",
+ "icon": null,
+ "permission": "access CiviMember,edit memberships",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "77",
+ "navID": "83",
+ "active": "1"
+ }
+ },
+ "84": {
+ "attributes": {
+ "label": "New Price Set",
+ "name": "New Price Set",
+ "url": "civicrm/admin/price?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "77",
+ "navID": "84",
+ "active": "1"
+ }
+ },
+ "85": {
+ "attributes": {
+ "label": "Manage Price Sets",
+ "name": "Manage Price Sets",
+ "url": "civicrm/admin/price?reset=1",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "77",
+ "navID": "85",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "86": {
+ "attributes": {
+ "label": "Campaigns",
+ "name": "Campaigns",
+ "url": null,
+ "icon": null,
+ "permission": "interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": null,
+ "navID": "86",
+ "active": "1"
+ },
+ "child": {
+ "87": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "Dashboard",
+ "url": "civicrm/campaign?reset=1",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "87",
+ "active": "1"
+ },
+ "child": {
+ "88": {
+ "attributes": {
+ "label": "Surveys",
+ "name": "Survey Dashboard",
+ "url": "civicrm/campaign?reset=1&subPage=survey",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "87",
+ "navID": "88",
+ "active": "1"
+ }
+ },
+ "89": {
+ "attributes": {
+ "label": "Petitions",
+ "name": "Petition Dashboard",
+ "url": "civicrm/campaign?reset=1&subPage=petition",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "87",
+ "navID": "89",
+ "active": "1"
+ }
+ },
+ "90": {
+ "attributes": {
+ "label": "Campaigns",
+ "name": "Campaign Dashboard",
+ "url": "civicrm/campaign?reset=1&subPage=campaign",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "87",
+ "navID": "90",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "91": {
+ "attributes": {
+ "label": "New Campaign",
+ "name": "New Campaign",
+ "url": "civicrm/campaign/add?reset=1",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "91",
+ "active": "1"
+ }
+ },
+ "92": {
+ "attributes": {
+ "label": "New Survey",
+ "name": "New Survey",
+ "url": "civicrm/survey/add?reset=1",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "92",
+ "active": "1"
+ }
+ },
+ "93": {
+ "attributes": {
+ "label": "New Petition",
+ "name": "New Petition",
+ "url": "civicrm/petition/add?reset=1",
+ "icon": null,
+ "permission": "manage campaign,administer CiviCampaign",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "93",
+ "active": "1"
+ }
+ },
+ "94": {
+ "attributes": {
+ "label": "Reserve Respondents",
+ "name": "Reserve Respondents",
+ "url": "civicrm/survey/search?reset=1&op=reserve",
+ "icon": null,
+ "permission": "administer CiviCampaign,manage campaign,reserve campaign contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "94",
+ "active": "1"
+ }
+ },
+ "95": {
+ "attributes": {
+ "label": "Interview Respondents",
+ "name": "Interview Respondents",
+ "url": "civicrm/survey/search?reset=1&op=interview",
+ "icon": null,
+ "permission": "administer CiviCampaign,manage campaign,interview campaign contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "95",
+ "active": "1"
+ }
+ },
+ "96": {
+ "attributes": {
+ "label": "Release Respondents",
+ "name": "Release Respondents",
+ "url": "civicrm/survey/search?reset=1&op=release",
+ "icon": null,
+ "permission": "administer CiviCampaign,manage campaign,release campaign contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "96",
+ "active": "1"
+ }
+ },
+ "97": {
+ "attributes": {
+ "label": "Campaign Reports",
+ "name": "Campaign Reports",
+ "url": "civicrm/report/list?compid=9&reset=1",
+ "icon": null,
+ "permission": "interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts",
+ "operator": "OR",
+ "separator": "1",
+ "parentID": "86",
+ "navID": "97",
+ "active": "1"
+ }
+ },
+ "98": {
+ "attributes": {
+ "label": "Conduct Survey",
+ "name": "Conduct Survey",
+ "url": "civicrm/campaign/vote?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign,manage campaign,reserve campaign contacts,interview campaign contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "98",
+ "active": "1"
+ }
+ },
+ "99": {
+ "attributes": {
+ "label": "GOTV (Voter Tracking)",
+ "name": "Voter Listing",
+ "url": "civicrm/campaign/gotv?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign,manage campaign,release campaign contacts,gotv campaign contacts",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "86",
+ "navID": "99",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "100": {
+ "attributes": {
+ "label": "Cases",
+ "name": "Cases",
+ "url": null,
+ "icon": null,
+ "permission": "access my cases and activities,access all cases and activities",
+ "operator": "OR",
+ "separator": null,
+ "parentID": null,
+ "navID": "100",
+ "active": "0"
+ },
+ "child": {
+ "101": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "Dashboard",
+ "url": "civicrm/case?reset=1",
+ "icon": null,
+ "permission": "access my cases and activities,access all cases and activities",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "100",
+ "navID": "101",
+ "active": "1"
+ }
+ },
+ "102": {
+ "attributes": {
+ "label": "New Case",
+ "name": "New Case",
+ "url": "civicrm/case/add?reset=1&action=add&atype=13&context=standalone",
+ "icon": null,
+ "permission": "add cases,access all cases and activities",
+ "operator": "OR",
+ "separator": null,
+ "parentID": "100",
+ "navID": "102",
+ "active": "1"
+ }
+ },
+ "103": {
+ "attributes": {
+ "label": "Find Cases",
+ "name": "Find Cases",
+ "url": "civicrm/case/search?reset=1",
+ "icon": null,
+ "permission": "access my cases and activities,access all cases and activities",
+ "operator": "OR",
+ "separator": "1",
+ "parentID": "100",
+ "navID": "103",
+ "active": "1"
+ }
+ },
+ "104": {
+ "attributes": {
+ "label": "Case Reports",
+ "name": "Case Reports",
+ "url": "civicrm/report/list?compid=7&reset=1",
+ "icon": null,
+ "permission": "access my cases and activities,access all cases and activities,administer CiviCase",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "100",
+ "navID": "104",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "105": {
+ "attributes": {
+ "label": "Grants",
+ "name": "Grants",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviGrant",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "105",
+ "active": "1"
+ },
+ "child": {
+ "106": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "Dashboard",
+ "url": "civicrm/grant?reset=1",
+ "icon": null,
+ "permission": "access CiviGrant",
+ "operator": "",
+ "separator": null,
+ "parentID": "105",
+ "navID": "106",
+ "active": "1"
+ }
+ },
+ "107": {
+ "attributes": {
+ "label": "New Grant",
+ "name": "New Grant",
+ "url": "civicrm/grant/add?reset=1&action=add&context=standalone",
+ "icon": null,
+ "permission": "access CiviGrant,edit grants",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "105",
+ "navID": "107",
+ "active": "1"
+ }
+ },
+ "108": {
+ "attributes": {
+ "label": "Find Grants",
+ "name": "Find Grants",
+ "url": "civicrm/grant/search?reset=1",
+ "icon": null,
+ "permission": "access CiviGrant",
+ "operator": "",
+ "separator": "1",
+ "parentID": "105",
+ "navID": "108",
+ "active": "1"
+ }
+ },
+ "109": {
+ "attributes": {
+ "label": "Grant Reports",
+ "name": "Grant Reports",
+ "url": "civicrm/report/list?compid=5&reset=1",
+ "icon": null,
+ "permission": "access CiviGrant",
+ "operator": "",
+ "separator": "0",
+ "parentID": "105",
+ "navID": "109",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "110": {
+ "attributes": {
+ "label": "Administer",
+ "name": "Administer",
+ "url": null,
+ "icon": "crm-i fa-cog",
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "110",
+ "active": "1"
+ },
+ "child": {
+ "111": {
+ "attributes": {
+ "label": "Administration Console",
+ "name": "Administration Console",
+ "url": "civicrm/admin?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "110",
+ "navID": "111",
+ "active": "1"
+ },
+ "child": {
+ "112": {
+ "attributes": {
+ "label": "System Status",
+ "name": "System Status",
+ "url": "civicrm/a/#/status",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "111",
+ "navID": "112",
+ "active": "1"
+ }
+ },
+ "113": {
+ "attributes": {
+ "label": "Configuration Checklist",
+ "name": "Configuration Checklist",
+ "url": "civicrm/admin/configtask?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "111",
+ "navID": "113",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "114": {
+ "attributes": {
+ "label": "Customize Data and Screens",
+ "name": "Customize Data and Screens",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "110",
+ "navID": "114",
+ "active": "1"
+ },
+ "child": {
+ "115": {
+ "attributes": {
+ "label": "Custom Fields",
+ "name": "Custom Fields",
+ "url": "civicrm/admin/custom/group?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "115",
+ "active": "1"
+ }
+ },
+ "116": {
+ "attributes": {
+ "label": "Profiles",
+ "name": "Profiles",
+ "url": "civicrm/admin/uf/group?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "116",
+ "active": "1"
+ }
+ },
+ "117": {
+ "attributes": {
+ "label": "Tags (Categories)",
+ "name": "Tags (Categories)",
+ "url": "civicrm/tag?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "117",
+ "active": "1"
+ }
+ },
+ "118": {
+ "attributes": {
+ "label": "Activity Types",
+ "name": "Activity Types",
+ "url": "civicrm/admin/options/activity_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "118",
+ "active": "1"
+ }
+ },
+ "119": {
+ "attributes": {
+ "label": "Relationship Types",
+ "name": "Relationship Types",
+ "url": "civicrm/admin/reltype?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "119",
+ "active": "1"
+ }
+ },
+ "120": {
+ "attributes": {
+ "label": "Contact Types",
+ "name": "Contact Types",
+ "url": "civicrm/admin/options/subtype?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "120",
+ "active": "1"
+ }
+ },
+ "121": {
+ "attributes": {
+ "label": "Display Preferences",
+ "name": "Display Preferences",
+ "url": "civicrm/admin/setting/preferences/display?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "121",
+ "active": "1"
+ }
+ },
+ "122": {
+ "attributes": {
+ "label": "Search Preferences",
+ "name": "Search Preferences",
+ "url": "civicrm/admin/setting/search?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "122",
+ "active": "1"
+ }
+ },
+ "123": {
+ "attributes": {
+ "label": "Date Preferences",
+ "name": "Date Preferences",
+ "url": "civicrm/admin/setting/preferences/date?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "123",
+ "active": "1"
+ }
+ },
+ "124": {
+ "attributes": {
+ "label": "Navigation Menu",
+ "name": "Navigation Menu",
+ "url": "civicrm/admin/menu?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "124",
+ "active": "1"
+ }
+ },
+ "125": {
+ "attributes": {
+ "label": "Word Replacements",
+ "name": "Word Replacements",
+ "url": "civicrm/admin/options/wordreplacements?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "125",
+ "active": "1"
+ }
+ },
+ "126": {
+ "attributes": {
+ "label": "Manage Custom Searches",
+ "name": "Manage Custom Searches",
+ "url": "civicrm/admin/options/custom_search?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "126",
+ "active": "1"
+ }
+ },
+ "127": {
+ "attributes": {
+ "label": "Dropdown Options",
+ "name": "Dropdown Options",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "114",
+ "navID": "127",
+ "active": "1"
+ },
+ "child": {
+ "128": {
+ "attributes": {
+ "label": "Gender Options",
+ "name": "Gender Options",
+ "url": "civicrm/admin/options/gender?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "128",
+ "active": "1"
+ }
+ },
+ "129": {
+ "attributes": {
+ "label": "Individual Prefixes (Ms, Mr...)",
+ "name": "Individual Prefixes (Ms, Mr...)",
+ "url": "civicrm/admin/options/individual_prefix?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "129",
+ "active": "1"
+ }
+ },
+ "130": {
+ "attributes": {
+ "label": "Individual Suffixes (Jr, Sr...)",
+ "name": "Individual Suffixes (Jr, Sr...)",
+ "url": "civicrm/admin/options/individual_suffix?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "130",
+ "active": "1"
+ }
+ },
+ "131": {
+ "attributes": {
+ "label": "Instant Messenger Services",
+ "name": "Instant Messenger Services",
+ "url": "civicrm/admin/options/instant_messenger_service?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "131",
+ "active": "1"
+ }
+ },
+ "132": {
+ "attributes": {
+ "label": "Location Types (Home, Work...)",
+ "name": "Location Types (Home, Work...)",
+ "url": "civicrm/admin/locationType?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "132",
+ "active": "1"
+ }
+ },
+ "133": {
+ "attributes": {
+ "label": "Mobile Phone Providers",
+ "name": "Mobile Phone Providers",
+ "url": "civicrm/admin/options/mobile_provider?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "133",
+ "active": "1"
+ }
+ },
+ "134": {
+ "attributes": {
+ "label": "Phone Types",
+ "name": "Phone Types",
+ "url": "civicrm/admin/options/phone_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "134",
+ "active": "1"
+ }
+ },
+ "135": {
+ "attributes": {
+ "label": "Website Types",
+ "name": "Website Types",
+ "url": "civicrm/admin/options/website_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "135",
+ "active": "1"
+ }
+ },
+ "267": {
+ "attributes": {
+ "label": "Hours Types",
+ "name": "hoursType",
+ "url": "civicrm/hour/editoption",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "267",
+ "active": "1"
+ }
+ },
+ "268": {
+ "attributes": {
+ "label": "Job Contract Pay Scale",
+ "name": "pay_scale",
+ "url": "civicrm/pay_scale",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "268",
+ "active": "1"
+ }
+ },
+ "269": {
+ "attributes": {
+ "label": "Job Contract Hours/Location",
+ "name": "hours_location",
+ "url": "civicrm/hours_location",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "269",
+ "active": "1"
+ }
+ },
+ "270": {
+ "attributes": {
+ "label": "Contract Type",
+ "name": "hrjc_contract_type",
+ "url": "civicrm/admin/options/hrjc_contract_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "270",
+ "active": "1"
+ }
+ },
+ "271": {
+ "attributes": {
+ "label": "Normal place of work",
+ "name": "hrjc_location",
+ "url": "civicrm/admin/options/hrjc_location?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "271",
+ "active": "1"
+ }
+ },
+ "272": {
+ "attributes": {
+ "label": "Pay cycle",
+ "name": "hrjc_pay_cycle",
+ "url": "civicrm/admin/options/hrjc_pay_cycle?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "272",
+ "active": "1"
+ }
+ },
+ "273": {
+ "attributes": {
+ "label": "Benefits",
+ "name": "hrjc_benefit_name",
+ "url": "civicrm/admin/options/hrjc_benefit_name?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "273",
+ "active": "1"
+ }
+ },
+ "274": {
+ "attributes": {
+ "label": "Benefit type",
+ "name": "hrjc_benefit_type",
+ "url": "civicrm/admin/options/hrjc_benefit_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "274",
+ "active": "1"
+ }
+ },
+ "275": {
+ "attributes": {
+ "label": "Deductions",
+ "name": "hrjc_deduction_name",
+ "url": "civicrm/admin/options/hrjc_deduction_name?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "275",
+ "active": "1"
+ }
+ },
+ "276": {
+ "attributes": {
+ "label": "Deduction type",
+ "name": "hrjc_deduction_type",
+ "url": "civicrm/admin/options/hrjc_deduction_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "276",
+ "active": "1"
+ }
+ },
+ "278": {
+ "attributes": {
+ "label": "Reason for change",
+ "name": "hrjc_revision_change_reason",
+ "url": "civicrm/admin/options/hrjc_revision_change_reason?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "278",
+ "active": "1"
+ }
+ },
+ "279": {
+ "attributes": {
+ "label": "Reason for Job Contract end",
+ "name": "hrjc_contract_end_reason",
+ "url": "civicrm/admin/options/hrjc_contract_end_reason?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": null,
+ "separator": "0",
+ "parentID": "127",
+ "navID": "279",
+ "active": "1"
+ }
+ }
+ }
+ }
+ }
+ },
+ "136": {
+ "attributes": {
+ "label": "Communications",
+ "name": "Communications",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "110",
+ "navID": "136",
+ "active": "1"
+ },
+ "child": {
+ "137": {
+ "attributes": {
+ "label": "Organization Address and Contact Info",
+ "name": "Organization Address and Contact Info",
+ "url": "civicrm/admin/domain?action=update&reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "137",
+ "active": "1"
+ }
+ },
+ "138": {
+ "attributes": {
+ "label": "FROM Email Addresses",
+ "name": "FROM Email Addresses",
+ "url": "civicrm/admin/options/from_email_address?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "138",
+ "active": "1"
+ }
+ },
+ "139": {
+ "attributes": {
+ "label": "Message Templates",
+ "name": "Message Templates",
+ "url": "civicrm/admin/messageTemplates?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "139",
+ "active": "1"
+ }
+ },
+ "140": {
+ "attributes": {
+ "label": "Schedule Reminders",
+ "name": "Schedule Reminders",
+ "url": "civicrm/admin/scheduleReminders?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "140",
+ "active": "1"
+ }
+ },
+ "141": {
+ "attributes": {
+ "label": "Preferred Communication Methods",
+ "name": "Preferred Communication Methods",
+ "url": "civicrm/admin/options/preferred_communication_method?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "141",
+ "active": "1"
+ }
+ },
+ "142": {
+ "attributes": {
+ "label": "Label Formats",
+ "name": "Label Formats",
+ "url": "civicrm/admin/labelFormats?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "142",
+ "active": "1"
+ }
+ },
+ "143": {
+ "attributes": {
+ "label": "Print Page (PDF) Formats",
+ "name": "Print Page (PDF) Formats",
+ "url": "civicrm/admin/pdfFormats?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "143",
+ "active": "1"
+ }
+ },
+ "144": {
+ "attributes": {
+ "label": "Communication Style Options",
+ "name": "Communication Style Options",
+ "url": "civicrm/admin/options/communication_style?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "144",
+ "active": "1"
+ }
+ },
+ "145": {
+ "attributes": {
+ "label": "Email Greeting Formats",
+ "name": "Email Greeting Formats",
+ "url": "civicrm/admin/options/email_greeting?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "145",
+ "active": "1"
+ }
+ },
+ "146": {
+ "attributes": {
+ "label": "Postal Greeting Formats",
+ "name": "Postal Greeting Formats",
+ "url": "civicrm/admin/options/postal_greeting?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "146",
+ "active": "1"
+ }
+ },
+ "147": {
+ "attributes": {
+ "label": "Addressee Formats",
+ "name": "Addressee Formats",
+ "url": "civicrm/admin/options/addressee?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "136",
+ "navID": "147",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "148": {
+ "attributes": {
+ "label": "Localization",
+ "name": "Localization",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "110",
+ "navID": "148",
+ "active": "1"
+ },
+ "child": {
+ "149": {
+ "attributes": {
+ "label": "Languages, Currency, Locations",
+ "name": "Languages, Currency, Locations",
+ "url": "civicrm/admin/setting/localization?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "148",
+ "navID": "149",
+ "active": "1"
+ }
+ },
+ "150": {
+ "attributes": {
+ "label": "Address Settings",
+ "name": "Address Settings",
+ "url": "civicrm/admin/setting/preferences/address?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "148",
+ "navID": "150",
+ "active": "1"
+ }
+ },
+ "151": {
+ "attributes": {
+ "label": "Date Formats",
+ "name": "Date Formats",
+ "url": "civicrm/admin/setting/date?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "148",
+ "navID": "151",
+ "active": "1"
+ }
+ },
+ "152": {
+ "attributes": {
+ "label": "Preferred Language Options",
+ "name": "Preferred Language Options",
+ "url": "civicrm/admin/options/languages?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "148",
+ "navID": "152",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "153": {
+ "attributes": {
+ "label": "Users and Permissions",
+ "name": "Users and Permissions",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "110",
+ "navID": "153",
+ "active": "1"
+ },
+ "child": {
+ "154": {
+ "attributes": {
+ "label": "Permissions (Access Control)",
+ "name": "Permissions (Access Control)",
+ "url": "civicrm/admin/access?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "153",
+ "navID": "154",
+ "active": "1"
+ }
+ },
+ "155": {
+ "attributes": {
+ "label": "Synchronize Users to Contacts",
+ "name": "Synchronize Users to Contacts",
+ "url": "civicrm/admin/synchUser?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "153",
+ "navID": "155",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "156": {
+ "attributes": {
+ "label": "System Settings",
+ "name": "System Settings",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "110",
+ "navID": "156",
+ "active": "1"
+ },
+ "child": {
+ "157": {
+ "attributes": {
+ "label": "Components",
+ "name": "Enable Components",
+ "url": "civicrm/admin/setting/component?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "157",
+ "active": "1"
+ }
+ },
+ "158": {
+ "attributes": {
+ "label": "Connections",
+ "name": "Connections",
+ "url": "civicrm/a/#/cxn",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "158",
+ "active": "1"
+ }
+ },
+ "159": {
+ "attributes": {
+ "label": "Extensions",
+ "name": "Manage Extensions",
+ "url": "civicrm/admin/extensions?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": "1",
+ "parentID": "156",
+ "navID": "159",
+ "active": "1"
+ }
+ },
+ "160": {
+ "attributes": {
+ "label": "Cleanup Caches and Update Paths",
+ "name": "Cleanup Caches and Update Paths",
+ "url": "civicrm/admin/setting/updateConfigBackend?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "160",
+ "active": "1"
+ }
+ },
+ "161": {
+ "attributes": {
+ "label": "CMS Database Integration",
+ "name": "CMS Integration",
+ "url": "civicrm/admin/setting/uf?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "161",
+ "active": "1"
+ }
+ },
+ "162": {
+ "attributes": {
+ "label": "Debugging and Error Handling",
+ "name": "Debugging and Error Handling",
+ "url": "civicrm/admin/setting/debug?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "162",
+ "active": "1"
+ }
+ },
+ "163": {
+ "attributes": {
+ "label": "Directories",
+ "name": "Directories",
+ "url": "civicrm/admin/setting/path?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "163",
+ "active": "1"
+ }
+ },
+ "164": {
+ "attributes": {
+ "label": "Import/Export Mappings",
+ "name": "Import/Export Mappings",
+ "url": "civicrm/admin/mapping?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "164",
+ "active": "1"
+ }
+ },
+ "165": {
+ "attributes": {
+ "label": "Mapping and Geocoding",
+ "name": "Mapping and Geocoding",
+ "url": "civicrm/admin/setting/mapping?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "165",
+ "active": "1"
+ }
+ },
+ "166": {
+ "attributes": {
+ "label": "Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)",
+ "name": "Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)",
+ "url": "civicrm/admin/setting/misc?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "166",
+ "active": "1"
+ }
+ },
+ "167": {
+ "attributes": {
+ "label": "Multi Site Settings",
+ "name": "Multi Site Settings",
+ "url": "civicrm/admin/setting/preferences/multisite?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "167",
+ "active": "1"
+ }
+ },
+ "168": {
+ "attributes": {
+ "label": "Option Groups",
+ "name": "Option Groups",
+ "url": "civicrm/admin/options?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "168",
+ "active": "1"
+ }
+ },
+ "169": {
+ "attributes": {
+ "label": "Outbound Email (SMTP/Sendmail)",
+ "name": "Outbound Email",
+ "url": "civicrm/admin/setting/smtp?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "169",
+ "active": "1"
+ }
+ },
+ "170": {
+ "attributes": {
+ "label": "Payment Processors",
+ "name": "Payment Processors",
+ "url": "civicrm/admin/paymentProcessor?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "170",
+ "active": "1"
+ }
+ },
+ "171": {
+ "attributes": {
+ "label": "Resource URLs",
+ "name": "Resource URLs",
+ "url": "civicrm/admin/setting/url?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "171",
+ "active": "1"
+ }
+ },
+ "172": {
+ "attributes": {
+ "label": "Safe File Extensions",
+ "name": "Safe File Extensions",
+ "url": "civicrm/admin/options/safe_file_extension?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "172",
+ "active": "1"
+ }
+ },
+ "173": {
+ "attributes": {
+ "label": "Scheduled Jobs",
+ "name": "Scheduled Jobs",
+ "url": "civicrm/admin/job?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "173",
+ "active": "1"
+ }
+ },
+ "174": {
+ "attributes": {
+ "label": "SMS Providers",
+ "name": "SMS Providers",
+ "url": "civicrm/admin/sms/provider?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "156",
+ "navID": "174",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "175": {
+ "attributes": {
+ "label": "CiviCampaign",
+ "name": "CiviCampaign",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCampaign,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "175",
+ "active": "1"
+ },
+ "child": {
+ "176": {
+ "attributes": {
+ "label": "Survey Types",
+ "name": "Survey Types",
+ "url": "civicrm/admin/campaign/surveyType?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign",
+ "operator": "",
+ "separator": null,
+ "parentID": "175",
+ "navID": "176",
+ "active": "1"
+ }
+ },
+ "177": {
+ "attributes": {
+ "label": "Campaign Types",
+ "name": "Campaign Types",
+ "url": "civicrm/admin/options/campaign_type?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign",
+ "operator": "",
+ "separator": null,
+ "parentID": "175",
+ "navID": "177",
+ "active": "1"
+ }
+ },
+ "178": {
+ "attributes": {
+ "label": "Campaign Status",
+ "name": "Campaign Status",
+ "url": "civicrm/admin/options/campaign_status?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign",
+ "operator": "",
+ "separator": null,
+ "parentID": "175",
+ "navID": "178",
+ "active": "1"
+ }
+ },
+ "179": {
+ "attributes": {
+ "label": "Engagement Index",
+ "name": "Engagement Index",
+ "url": "civicrm/admin/options/engagement_index?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign",
+ "operator": "",
+ "separator": null,
+ "parentID": "175",
+ "navID": "179",
+ "active": "1"
+ }
+ },
+ "180": {
+ "attributes": {
+ "label": "CiviCampaign Component Settings",
+ "name": "CiviCampaign Component Settings",
+ "url": "civicrm/admin/setting/preferences/campaign?reset=1",
+ "icon": null,
+ "permission": "administer CiviCampaign",
+ "operator": "",
+ "separator": null,
+ "parentID": "175",
+ "navID": "180",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "181": {
+ "attributes": {
+ "label": "CiviCase",
+ "name": "CiviCase",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCase",
+ "operator": null,
+ "separator": null,
+ "parentID": "110",
+ "navID": "181",
+ "active": "1"
+ },
+ "child": {
+ "182": {
+ "attributes": {
+ "label": "CiviCase Settings",
+ "name": "CiviCase Settings",
+ "url": "civicrm/admin/setting/case?reset=1",
+ "icon": null,
+ "permission": "administer CiviCase",
+ "operator": null,
+ "separator": null,
+ "parentID": "181",
+ "navID": "182",
+ "active": "1"
+ }
+ },
+ "183": {
+ "attributes": {
+ "label": "Case Types",
+ "name": "Case Types",
+ "url": "civicrm/a/#/caseType",
+ "icon": null,
+ "permission": "administer CiviCase",
+ "operator": null,
+ "separator": null,
+ "parentID": "181",
+ "navID": "183",
+ "active": "1"
+ }
+ },
+ "184": {
+ "attributes": {
+ "label": "Redaction Rules",
+ "name": "Redaction Rules",
+ "url": "civicrm/admin/options/redaction_rule?reset=1",
+ "icon": null,
+ "permission": "administer CiviCase",
+ "operator": null,
+ "separator": null,
+ "parentID": "181",
+ "navID": "184",
+ "active": "1"
+ }
+ },
+ "185": {
+ "attributes": {
+ "label": "Case Statuses",
+ "name": "Case Statuses",
+ "url": "civicrm/admin/options/case_status?reset=1",
+ "icon": null,
+ "permission": "administer CiviCase",
+ "operator": null,
+ "separator": null,
+ "parentID": "181",
+ "navID": "185",
+ "active": "1"
+ }
+ },
+ "186": {
+ "attributes": {
+ "label": "Encounter Medium",
+ "name": "Encounter Medium",
+ "url": "civicrm/admin/options/encounter_medium?reset=1",
+ "icon": null,
+ "permission": "administer CiviCase",
+ "operator": null,
+ "separator": null,
+ "parentID": "181",
+ "navID": "186",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "187": {
+ "attributes": {
+ "label": "CiviContribute",
+ "name": "CiviContribute",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "187",
+ "active": "1"
+ },
+ "child": {
+ "188": {
+ "attributes": {
+ "label": "New Contribution Page",
+ "name": "New Contribution Page",
+ "url": "civicrm/admin/contribute?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "188",
+ "active": "1"
+ }
+ },
+ "189": {
+ "attributes": {
+ "label": "Manage Contribution Pages",
+ "name": "Manage Contribution Pages",
+ "url": "civicrm/admin/contribute?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "187",
+ "navID": "189",
+ "active": "1"
+ }
+ },
+ "190": {
+ "attributes": {
+ "label": "Personal Campaign Pages",
+ "name": "Personal Campaign Pages",
+ "url": "civicrm/admin/pcp?reset=1&page_type=contribute",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "190",
+ "active": "1"
+ }
+ },
+ "191": {
+ "attributes": {
+ "label": "Premiums (Thank-you Gifts)",
+ "name": "Premiums",
+ "url": "civicrm/admin/contribute/managePremiums?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "187",
+ "navID": "191",
+ "active": "1"
+ }
+ },
+ "192": {
+ "attributes": {
+ "label": "Financial Types",
+ "name": "Financial Types",
+ "url": "civicrm/admin/financial/financialType?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "192",
+ "active": "1"
+ }
+ },
+ "193": {
+ "attributes": {
+ "label": "Financial Accounts",
+ "name": "Financial Accounts",
+ "url": "civicrm/admin/financial/financialAccount?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "193",
+ "active": "1"
+ }
+ },
+ "194": {
+ "attributes": {
+ "label": "Payment Methods",
+ "name": "Payment Instruments",
+ "url": "civicrm/admin/options/payment_instrument?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "194",
+ "active": "1"
+ }
+ },
+ "195": {
+ "attributes": {
+ "label": "Accepted Credit Cards",
+ "name": "Accepted Credit Cards",
+ "url": "civicrm/admin/options/accept_creditcard?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "195",
+ "active": "1"
+ }
+ },
+ "196": {
+ "attributes": {
+ "label": "Soft Credit Types",
+ "name": "Soft Credit Types",
+ "url": "civicrm/admin/options/soft_credit_type?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "187",
+ "navID": "196",
+ "active": "1"
+ }
+ },
+ "197": {
+ "attributes": {
+ "label": "New Price Set",
+ "name": "New Price Set",
+ "url": "civicrm/admin/price?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "197",
+ "active": "1"
+ }
+ },
+ "198": {
+ "attributes": {
+ "label": "Manage Price Sets",
+ "name": "Manage Price Sets",
+ "url": "civicrm/admin/price?reset=1",
+ "icon": null,
+ "permission": "access CiviContribute,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "187",
+ "navID": "198",
+ "active": "1"
+ }
+ },
+ "199": {
+ "attributes": {
+ "label": "Payment Processors",
+ "name": "Payment Processors",
+ "url": "civicrm/admin/paymentProcessor?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "187",
+ "navID": "199",
+ "active": "1"
+ }
+ },
+ "200": {
+ "attributes": {
+ "label": "CiviContribute Component Settings",
+ "name": "CiviContribute Component Settings",
+ "url": "civicrm/admin/setting/preferences/contribute?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "187",
+ "navID": "200",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "201": {
+ "attributes": {
+ "label": "CiviEvent",
+ "name": "CiviEvent",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "201",
+ "active": "1"
+ },
+ "child": {
+ "202": {
+ "attributes": {
+ "label": "New Event",
+ "name": "New Event",
+ "url": "civicrm/event/add?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "202",
+ "active": "1"
+ }
+ },
+ "203": {
+ "attributes": {
+ "label": "Manage Events",
+ "name": "Manage Events",
+ "url": "civicrm/event/manage?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "201",
+ "navID": "203",
+ "active": "1"
+ }
+ },
+ "204": {
+ "attributes": {
+ "label": "Personal Campaign Pages",
+ "name": "Personal Campaign Pages",
+ "url": "civicrm/admin/pcp?reset=1&page_type=event",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "201",
+ "navID": "204",
+ "active": "1"
+ }
+ },
+ "205": {
+ "attributes": {
+ "label": "Event Templates",
+ "name": "Event Templates",
+ "url": "civicrm/admin/eventTemplate?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "201",
+ "navID": "205",
+ "active": "1"
+ }
+ },
+ "206": {
+ "attributes": {
+ "label": "New Price Set",
+ "name": "New Price Set",
+ "url": "civicrm/admin/price?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "206",
+ "active": "1"
+ }
+ },
+ "207": {
+ "attributes": {
+ "label": "Manage Price Sets",
+ "name": "Manage Price Sets",
+ "url": "civicrm/admin/price?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "201",
+ "navID": "207",
+ "active": "1"
+ }
+ },
+ "208": {
+ "attributes": {
+ "label": "Event Types",
+ "name": "Event Types",
+ "url": "civicrm/admin/options/event_type?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "208",
+ "active": "1"
+ }
+ },
+ "209": {
+ "attributes": {
+ "label": "Participant Statuses",
+ "name": "Participant Statuses",
+ "url": "civicrm/admin/participant_status?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "209",
+ "active": "1"
+ }
+ },
+ "210": {
+ "attributes": {
+ "label": "Participant Roles",
+ "name": "Participant Roles",
+ "url": "civicrm/admin/options/participant_role?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "210",
+ "active": "1"
+ }
+ },
+ "211": {
+ "attributes": {
+ "label": "Participant Listing Options",
+ "name": "Participant Listing Options",
+ "url": "civicrm/admin/options/participant_listing?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "211",
+ "active": "1"
+ }
+ },
+ "212": {
+ "attributes": {
+ "label": "Event Name Badge Layouts",
+ "name": "Event Name Badge Layouts",
+ "url": "civicrm/admin/badgelayout?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "212",
+ "active": "1"
+ }
+ },
+ "213": {
+ "attributes": {
+ "label": "Payment Processors",
+ "name": "Payment Processors",
+ "url": "civicrm/admin/paymentProcessor?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "201",
+ "navID": "213",
+ "active": "1"
+ }
+ },
+ "214": {
+ "attributes": {
+ "label": "CiviEvent Component Settings",
+ "name": "CiviEvent Component Settings",
+ "url": "civicrm/admin/setting/preferences/event?reset=1",
+ "icon": null,
+ "permission": "access CiviEvent,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "201",
+ "navID": "214",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "215": {
+ "attributes": {
+ "label": "CiviGrant",
+ "name": "CiviGrant",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviGrant,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "215",
+ "active": "1"
+ },
+ "child": {
+ "216": {
+ "attributes": {
+ "label": "Grant Types",
+ "name": "Grant Types",
+ "url": "civicrm/admin/options/grant_type?reset=1",
+ "icon": null,
+ "permission": "access CiviGrant,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "215",
+ "navID": "216",
+ "active": "1"
+ }
+ },
+ "217": {
+ "attributes": {
+ "label": "Grant Status",
+ "name": "Grant Status",
+ "url": "civicrm/admin/options/grant_status?reset=1",
+ "icon": null,
+ "permission": "access CiviGrant,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "215",
+ "navID": "217",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "218": {
+ "attributes": {
+ "label": "CiviMail",
+ "name": "CiviMail",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviMail,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "218",
+ "active": "1"
+ },
+ "child": {
+ "219": {
+ "attributes": {
+ "label": "Headers, Footers, and Automated Messages",
+ "name": "Headers, Footers, and Automated Messages",
+ "url": "civicrm/admin/component?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "218",
+ "navID": "219",
+ "active": "1"
+ }
+ },
+ "220": {
+ "attributes": {
+ "label": "Message Templates",
+ "name": "Message Templates",
+ "url": "civicrm/admin/messageTemplates?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "218",
+ "navID": "220",
+ "active": "1"
+ }
+ },
+ "221": {
+ "attributes": {
+ "label": "From Email Addresses",
+ "name": "From Email Addresses",
+ "url": "civicrm/admin/options/from_email_address?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "218",
+ "navID": "221",
+ "active": "1"
+ }
+ },
+ "222": {
+ "attributes": {
+ "label": "Mail Accounts",
+ "name": "Mail Accounts",
+ "url": "civicrm/admin/mailSettings?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "218",
+ "navID": "222",
+ "active": "1"
+ }
+ },
+ "223": {
+ "attributes": {
+ "label": "Mailer Settings",
+ "name": "Mailer Settings",
+ "url": "civicrm/admin/mail?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "218",
+ "navID": "223",
+ "active": "1"
+ }
+ },
+ "224": {
+ "attributes": {
+ "label": "CiviMail Component Settings",
+ "name": "CiviMail Component Settings",
+ "url": "civicrm/admin/setting/preferences/mailing?reset=1",
+ "icon": null,
+ "permission": "access CiviMail,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "218",
+ "navID": "224",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "225": {
+ "attributes": {
+ "label": "CiviMember",
+ "name": "CiviMember",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "225",
+ "active": "1"
+ },
+ "child": {
+ "226": {
+ "attributes": {
+ "label": "Membership Types",
+ "name": "Membership Types",
+ "url": "civicrm/admin/member/membershipType?reset=1",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "225",
+ "navID": "226",
+ "active": "1"
+ }
+ },
+ "227": {
+ "attributes": {
+ "label": "Membership Status Rules",
+ "name": "Membership Status Rules",
+ "url": "civicrm/admin/member/membershipStatus?reset=1",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "225",
+ "navID": "227",
+ "active": "1"
+ }
+ },
+ "228": {
+ "attributes": {
+ "label": "New Price Set",
+ "name": "New Price Set",
+ "url": "civicrm/admin/price?reset=1&action=add",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "225",
+ "navID": "228",
+ "active": "1"
+ }
+ },
+ "229": {
+ "attributes": {
+ "label": "Manage Price Sets",
+ "name": "Manage Price Sets",
+ "url": "civicrm/admin/price?reset=1",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "225",
+ "navID": "229",
+ "active": "1"
+ }
+ },
+ "230": {
+ "attributes": {
+ "label": "CiviMember Component Settings",
+ "name": "CiviMember Component Settings",
+ "url": "civicrm/admin/setting/preferences/member?reset=1",
+ "icon": null,
+ "permission": "access CiviMember,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "225",
+ "navID": "230",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "231": {
+ "attributes": {
+ "label": "CiviReport",
+ "name": "CiviReport",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviReport,administer CiviCRM",
+ "operator": "AND",
+ "separator": null,
+ "parentID": "110",
+ "navID": "231",
+ "active": "1"
+ },
+ "child": {
+ "232": {
+ "attributes": {
+ "label": "All Reports",
+ "name": "All Reports",
+ "url": "civicrm/report/list?reset=1",
+ "icon": null,
+ "permission": "access CiviReport",
+ "operator": "",
+ "separator": null,
+ "parentID": "231",
+ "navID": "232",
+ "active": "1"
+ }
+ },
+ "233": {
+ "attributes": {
+ "label": "Create New Report from Template",
+ "name": "Create New Report from Template",
+ "url": "civicrm/admin/report/template/list?reset=1",
+ "icon": null,
+ "permission": "administer Reports",
+ "operator": "",
+ "separator": null,
+ "parentID": "231",
+ "navID": "233",
+ "active": "1"
+ }
+ },
+ "234": {
+ "attributes": {
+ "label": "Manage Templates",
+ "name": "Manage Templates",
+ "url": "civicrm/admin/report/options/report_template?reset=1",
+ "icon": null,
+ "permission": "administer Reports",
+ "operator": "",
+ "separator": null,
+ "parentID": "231",
+ "navID": "234",
+ "active": "1"
+ }
+ },
+ "235": {
+ "attributes": {
+ "label": "Register Report",
+ "name": "Register Report",
+ "url": "civicrm/admin/report/register?reset=1",
+ "icon": null,
+ "permission": "administer Reports",
+ "operator": "",
+ "separator": null,
+ "parentID": "231",
+ "navID": "235",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "286": {
+ "attributes": {
+ "label": "Tasks",
+ "name": "tasksassignments_administer",
+ "url": null,
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": null,
+ "parentID": "110",
+ "navID": "286",
+ "active": "1"
+ },
+ "child": {
+ "285": {
+ "attributes": {
+ "label": "Tasks Settings",
+ "name": "ta_settings",
+ "url": "civicrm/tasksassignments/settings",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "286",
+ "navID": "285",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "292": {
+ "attributes": {
+ "label": "Leave",
+ "name": "leave_and_absences",
+ "url": null,
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": null,
+ "parentID": "110",
+ "navID": "292",
+ "active": "1"
+ },
+ "child": {
+ "293": {
+ "attributes": {
+ "label": "Leave/Absence Types",
+ "name": "leave_and_absence_types",
+ "url": "civicrm/admin/leaveandabsences/types?action=browse&reset=1",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "293",
+ "active": "1"
+ }
+ },
+ "294": {
+ "attributes": {
+ "label": "Leave/Absence Periods",
+ "name": "leave_and_absence_periods",
+ "url": "civicrm/admin/leaveandabsences/periods?action=browse&reset=1",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "294",
+ "active": "1"
+ }
+ },
+ "295": {
+ "attributes": {
+ "label": "Public Holidays",
+ "name": "leave_and_absence_public_holidays",
+ "url": "civicrm/admin/leaveandabsences/public_holidays?action=browse&reset=1",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "295",
+ "active": "1"
+ }
+ },
+ "296": {
+ "attributes": {
+ "label": "Manage Work Patterns",
+ "name": "leave_and_absence_manage_work_patterns",
+ "url": "civicrm/admin/leaveandabsences/work_patterns?action=browse&reset=1",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "296",
+ "active": "1"
+ }
+ },
+ "297": {
+ "attributes": {
+ "label": "General Settings",
+ "name": "leave_and_absence_general_settings",
+ "url": "civicrm/admin/leaveandabsences/general_settings",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "297",
+ "active": "1"
+ }
+ },
+ "298": {
+ "attributes": {
+ "label": "Import Leave/Absence Requests",
+ "name": "leave_and_absences_import",
+ "url": "civicrm/admin/leaveandabsences/import",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "298",
+ "active": "1"
+ }
+ }
+ }
+ }
+ }
+ },
+ "236": {
+ "attributes": {
+ "label": "Support",
+ "name": "Support",
+ "url": null,
+ "icon": null,
+ "permission": null,
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "236",
+ "active": "1"
+ },
+ "child": {
+ "237": {
+ "attributes": {
+ "label": "Get started",
+ "name": "Get started",
+ "url": "https://civicrm.org/get-started?src=iam",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": null,
+ "parentID": "236",
+ "navID": "237",
+ "active": "1"
+ }
+ },
+ "238": {
+ "attributes": {
+ "label": "Documentation",
+ "name": "Documentation",
+ "url": "https://civicrm.org/documentation?src=iam",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": null,
+ "parentID": "236",
+ "navID": "238",
+ "active": "1"
+ }
+ },
+ "239": {
+ "attributes": {
+ "label": "Ask a question",
+ "name": "Ask a question",
+ "url": "https://civicrm.org/ask-a-question?src=iam",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": null,
+ "parentID": "236",
+ "navID": "239",
+ "active": "1"
+ }
+ },
+ "240": {
+ "attributes": {
+ "label": "Get expert help",
+ "name": "Get expert help",
+ "url": "https://civicrm.org/experts?src=iam",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": null,
+ "parentID": "236",
+ "navID": "240",
+ "active": "1"
+ }
+ },
+ "241": {
+ "attributes": {
+ "label": "About CiviCRM",
+ "name": "About CiviCRM",
+ "url": "https://civicrm.org/about?src=iam",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": "1",
+ "parentID": "236",
+ "navID": "241",
+ "active": "1"
+ }
+ },
+ "242": {
+ "attributes": {
+ "label": "Register your site",
+ "name": "Register your site",
+ "url": "https://civicrm.org/register-your-site?src=iam&sid={sid}",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": null,
+ "parentID": "236",
+ "navID": "242",
+ "active": "1"
+ }
+ },
+ "243": {
+ "attributes": {
+ "label": "Join CiviCRM",
+ "name": "Join CiviCRM",
+ "url": "https://civicrm.org/become-a-member?src=iam&sid={sid}",
+ "icon": null,
+ "permission": null,
+ "operator": "AND",
+ "separator": null,
+ "parentID": "236",
+ "navID": "243",
+ "active": "1"
+ }
+ },
+ "244": {
+ "attributes": {
+ "label": "Developer",
+ "name": "Developer",
+ "url": null,
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": "1",
+ "parentID": "236",
+ "navID": "244",
+ "active": "1"
+ },
+ "child": {
+ "245": {
+ "attributes": {
+ "label": "API Explorer",
+ "name": "API Explorer",
+ "url": "civicrm/api",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "244",
+ "navID": "245",
+ "active": "1"
+ }
+ },
+ "246": {
+ "attributes": {
+ "label": "Developer Docs",
+ "name": "Developer Docs",
+ "url": "https://civicrm.org/developer-documentation?src=iam",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "244",
+ "navID": "246",
+ "active": "1"
+ }
+ }
+ }
+ }
+ }
+ },
+ "247": {
+ "attributes": {
+ "label": "Reports",
+ "name": "Reports",
+ "url": null,
+ "icon": null,
+ "permission": "access CiviReport",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "247",
+ "active": "1"
+ },
+ "child": {
+ "248": {
+ "attributes": {
+ "label": "Contact Reports",
+ "name": "Contact Reports",
+ "url": "civicrm/report/list?compid=99&reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "248",
+ "active": "1"
+ }
+ },
+ "249": {
+ "attributes": {
+ "label": "Contribution Reports",
+ "name": "Contribution Reports",
+ "url": "civicrm/report/list?compid=2&reset=1",
+ "icon": null,
+ "permission": "access CiviContribute",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "249",
+ "active": "1"
+ }
+ },
+ "250": {
+ "attributes": {
+ "label": "Pledge Reports",
+ "name": "Pledge Reports",
+ "url": "civicrm/report/list?compid=6&reset=1",
+ "icon": null,
+ "permission": "access CiviPledge",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "250",
+ "active": "1"
+ }
+ },
+ "251": {
+ "attributes": {
+ "label": "Event Reports",
+ "name": "Event Reports",
+ "url": "civicrm/report/list?compid=1&reset=1",
+ "icon": null,
+ "permission": "access CiviEvent",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "251",
+ "active": "1"
+ }
+ },
+ "252": {
+ "attributes": {
+ "label": "Mailing Reports",
+ "name": "Mailing Reports",
+ "url": "civicrm/report/list?compid=4&reset=1",
+ "icon": null,
+ "permission": "access CiviMail",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "252",
+ "active": "1"
+ }
+ },
+ "253": {
+ "attributes": {
+ "label": "Membership Reports",
+ "name": "Membership Reports",
+ "url": "civicrm/report/list?compid=3&reset=1",
+ "icon": null,
+ "permission": "access CiviMember",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "253",
+ "active": "1"
+ }
+ },
+ "254": {
+ "attributes": {
+ "label": "Campaign Reports",
+ "name": "Campaign Reports",
+ "url": "civicrm/report/list?compid=9&reset=1",
+ "icon": null,
+ "permission": "interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "254",
+ "active": "1"
+ }
+ },
+ "255": {
+ "attributes": {
+ "label": "Case Reports",
+ "name": "Case Reports",
+ "url": "civicrm/report/list?compid=7&reset=1",
+ "icon": null,
+ "permission": "access my cases and activities,access all cases and activities,administer CiviCase",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "255",
+ "active": "1"
+ }
+ },
+ "256": {
+ "attributes": {
+ "label": "Grant Reports",
+ "name": "Grant Reports",
+ "url": "civicrm/report/list?compid=5&reset=1",
+ "icon": null,
+ "permission": "access CiviGrant",
+ "operator": "",
+ "separator": "0",
+ "parentID": "247",
+ "navID": "256",
+ "active": "1"
+ }
+ },
+ "257": {
+ "attributes": {
+ "label": "All Reports",
+ "name": "All Reports",
+ "url": "civicrm/report/list?reset=1",
+ "icon": null,
+ "permission": "access CiviReport",
+ "operator": "",
+ "separator": "1",
+ "parentID": "247",
+ "navID": "257",
+ "active": "1"
+ }
+ },
+ "258": {
+ "attributes": {
+ "label": "My Reports",
+ "name": "My Reports",
+ "url": "civicrm/report/list?myreports=1&reset=1",
+ "icon": null,
+ "permission": "access CiviReport",
+ "operator": "",
+ "separator": "1",
+ "parentID": "247",
+ "navID": "258",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "264": {
+ "attributes": {
+ "label": "Reports",
+ "name": "hr-reports",
+ "url": "civicrm/reports",
+ "icon": "fa fa-table",
+ "permission": "access hrreports",
+ "operator": null,
+ "separator": null,
+ "parentID": null,
+ "navID": "264",
+ "active": "1"
+ }
+ },
+ "283": {
+ "attributes": {
+ "label": "Tasks",
+ "name": "tasksassignments",
+ "url": "",
+ "icon": "crm-i fa-list-ul",
+ "permission": "access Tasks and Assignments",
+ "operator": null,
+ "separator": null,
+ "parentID": null,
+ "navID": "283",
+ "active": "1"
+ },
+ "child": {
+ "287": {
+ "attributes": {
+ "label": "Tasks",
+ "name": "ta_dashboard_tasks",
+ "url": "civicrm/tasksassignments/dashboard#/tasks",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "283",
+ "navID": "287",
+ "active": "1"
+ }
+ },
+ "288": {
+ "attributes": {
+ "label": "Documents",
+ "name": "ta_dashboard_documents",
+ "url": "civicrm/tasksassignments/dashboard#/documents",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "283",
+ "navID": "288",
+ "active": "1"
+ }
+ },
+ "289": {
+ "attributes": {
+ "label": "Calendar",
+ "name": "ta_dashboard_calendar",
+ "url": "civicrm/tasksassignments/dashboard#/calendar",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "283",
+ "navID": "289",
+ "active": "1"
+ }
+ },
+ "290": {
+ "attributes": {
+ "label": "Key Dates",
+ "name": "ta_dashboard_keydates",
+ "url": "civicrm/tasksassignments/dashboard#/key-dates",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "283",
+ "navID": "290",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "291": {
+ "attributes": {
+ "label": "Leave",
+ "name": "leave_and_absences_dashboard",
+ "url": null,
+ "icon": "crm-i fa-briefcase",
+ "permission": "access leave and absences",
+ "operator": null,
+ "separator": null,
+ "parentID": null,
+ "navID": "291",
+ "active": "1"
+ },
+ "child": {
+ "299": {
+ "attributes": {
+ "label": "Leave Requests",
+ "name": "leave_and_absences_leave_requests",
+ "url": "civicrm/leaveandabsences/dashboard#/requests",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "291",
+ "navID": "299",
+ "active": "1"
+ }
+ },
+ "300": {
+ "attributes": {
+ "label": "Leave Calendar",
+ "name": "leave_and_absences_leave_calendar",
+ "url": "civicrm/leaveandabsences/dashboard#/calendar",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "291",
+ "navID": "300",
+ "active": "1"
+ }
+ },
+ "301": {
+ "attributes": {
+ "label": "Leave Balances",
+ "name": "leave_and_absences_leave_balances",
+ "url": "civicrm/leaveandabsences/dashboard#/leave-balances",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "0",
+ "parentID": "291",
+ "navID": "301",
+ "active": "1"
+ }
+ }
+ }
+ },
+ "303": {
+ "attributes": {
+ "label": "Recruitment",
+ "name": "Vacancies",
+ "url": null,
+ "icon": "crm-i fa-user-plus",
+ "permission": null,
+ "operator": null,
+ "separator": null,
+ "parentID": null,
+ "navID": "303",
+ "active": "1"
+ },
+ "child": {
+ "304": {
+ "attributes": {
+ "label": "Dashboard",
+ "name": "dashboard",
+ "url": "civicrm/vacancy/dashboard?reset=1",
+ "icon": null,
+ "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "304",
+ "active": "1"
+ }
+ },
+ "305": {
+ "attributes": {
+ "label": "Public Vacancy List",
+ "name": "public_list",
+ "url": "civicrm/vacancy/publiclisting?reset=1",
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "1",
+ "parentID": "303",
+ "navID": "305",
+ "active": "1"
+ }
+ },
+ "306": {
+ "attributes": {
+ "label": "New Vacancy",
+ "name": "new_vacancy",
+ "url": "civicrm/vacancy/add?reset=1",
+ "icon": null,
+ "permission": "administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "306",
+ "active": "1"
+ }
+ },
+ "307": {
+ "attributes": {
+ "label": "New Template",
+ "name": "new_template",
+ "url": "civicrm/vacancy/add?reset=1&template=1",
+ "icon": null,
+ "permission": "administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "307",
+ "active": "1"
+ }
+ },
+ "308": {
+ "attributes": {
+ "label": "New Applicant",
+ "name": "new_applicant",
+ "url": null,
+ "icon": null,
+ "permission": null,
+ "operator": null,
+ "separator": "1",
+ "parentID": "303",
+ "navID": "308",
+ "active": "1"
+ }
+ },
+ "309": {
+ "attributes": {
+ "label": "Find Vacancies",
+ "name": "find_vacancies",
+ "url": "civicrm/vacancy/find?reset=1",
+ "icon": null,
+ "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "309",
+ "active": "1"
+ }
+ },
+ "310": {
+ "attributes": {
+ "label": "Find Templates",
+ "name": "find_templates",
+ "url": "civicrm/vacancy/find?reset=1&template=1",
+ "icon": null,
+ "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "310",
+ "active": "1"
+ }
+ },
+ "311": {
+ "attributes": {
+ "label": "Search by Application Form Fields",
+ "name": "find_application",
+ "url": "civicrm/case/search?force=1&type=5&reset=1",
+ "icon": null,
+ "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "311",
+ "active": "1"
+ }
+ },
+ "312": {
+ "attributes": {
+ "label": "Search by Evaluation Criteria",
+ "name": "find_evaluation",
+ "url": "civicrm/activity/search?force=1&type=114&reset=1",
+ "icon": null,
+ "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
+ "operator": "OR",
+ "separator": "0",
+ "parentID": "303",
+ "navID": "312",
+ "active": "1"
+ }
+ }
+ }
+ }
+}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
new file mode 100644
index 00000000000..f85222fd447
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
@@ -0,0 +1,208 @@
+getSampleMenu();
+ $result = NavigationMenuHelper::findMenuItemByName($menu, $name);
+
+ if ($exists) {
+ $foundName = $result['attributes']['name'];
+ $this->assertEquals($name, $foundName);
+ }
+ else {
+ $this->assertNull($result);
+ }
+ }
+
+ public function testInsertionWillAddChildMenuItem() {
+ $menu = $this->getSampleMenu();
+ $name = 'Test Item';
+ $newItem = ['name' => $name];
+ $parent = 'Dropdown Options';
+ NavigationMenuHelper::insertChild($menu, $parent, $newItem);
+
+ $added = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $this->assertNotNull($added);
+
+ $parent = NavigationMenuHelper::findMenuItemByName($menu, 'Dropdown Options');
+ $children = $parent['child'];
+ $matchingChildItems = array_filter($children, function ($item) use ($name) {
+ return $item['attributes']['name'] === $name;
+ });
+
+ $this->assertCount(1, $matchingChildItems);
+ $matchingItem = reset($matchingChildItems);
+ $this->assertEquals($name, $matchingItem['attributes']['name']);
+ }
+
+ public function testInsertionWillThrowExceptionWithInvalidPath() {
+ $expectedError = 'Cannot find parent item "Bar"';
+ $this->setExpectedException(\Exception::class, $expectedError);
+ $menu = [];
+ $parent = 'Bar';
+ NavigationMenuHelper::insertChild($menu, $parent, []);
+ }
+
+ public function testSettingPermissionWillUpdateItInMenu() {
+ $menu = $this->getSampleMenu();
+ $name = 'System Status';
+ NavigationMenuHelper::updatePermissionByName($menu, $name, 'foo');
+ $item = NavigationMenuHelper::findMenuItemByName($menu, $name);
+
+ $this->assertEquals('foo', $item['attributes']['permission']);
+ }
+
+ public function testFetchingWillNotReturnAReference() {
+ $menu = $this->getSampleMenu();
+ $name = 'System Status';
+ $item = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $item['foo'] = 'bar';
+ $sameItem = NavigationMenuHelper::findMenuItemByName($menu, $name);
+
+ $this->assertArrayNotHasKey('foo', $sameItem);
+ }
+
+ public function testMovingTopLevelMenuItemsWillChangeTheirPositions() {
+ $menu = $this->getSampleMenu();
+ $first = 'Home';
+ $second = 'Search...';
+ NavigationMenuHelper::relocateAfter($menu, $first, $second);
+
+ $newFirst = reset($menu);
+ $newSecond = next($menu);
+
+ $this->assertEquals($second, $newFirst['attributes']['name']);
+ $this->assertEquals($first, $newSecond['attributes']['name']);
+ }
+
+ public function testMovingNestedItemsWillChangeTheirPositions() {
+ $nestedName = 'Activity Types';
+ $nestedParent = 'Customize Data and Screens';
+ $moveAfter = 'Membership Status Rules';
+ $targetParent = 'CiviMember';
+
+ $menu = $this->getSampleMenu();
+ NavigationMenuHelper::relocateAfter($menu, $nestedName, $moveAfter);
+
+ $origParent = NavigationMenuHelper::findMenuItemByName($menu, $nestedParent);
+ $newParent = NavigationMenuHelper::findMenuItemByName($menu, $targetParent);
+
+ $origChildren = $origParent['child'];
+ $newChildren = $newParent['child'];
+ $finderFunc = function ($child) use ($nestedName) {
+ return $child['attributes']['name'] === $nestedName;
+ };
+ $matchingOriginalChildren = array_filter($origChildren, $finderFunc);
+ $matchingNewChildren = array_filter($newChildren, $finderFunc);
+
+ $this->assertCount(0, $matchingOriginalChildren);
+ $this->assertCount(1, $matchingNewChildren);
+
+ $newChildrenNames = array_map(function ($item) {
+ return $item['attributes']['name'];
+ }, $newChildren);
+
+ $moveAfterPosition = array_search($moveAfter, $newChildrenNames);
+ $movedItemPosition = array_search($nestedName, $newChildrenNames);
+ $this->assertEquals($moveAfterPosition + 1, $movedItemPosition);
+ }
+
+ public function testRemovalWillUnsetElementAndChildren() {
+ $menu = $this->getSampleMenu();
+ $rootElement = 'Administer';
+ $childElement = 'Custom Fields';
+ NavigationMenuHelper::remove($menu, $rootElement);
+
+ $foundRoot = NavigationMenuHelper::findParentItemName($menu, $rootElement);
+ $foundChild = NavigationMenuHelper::findParentItemName($menu, $childElement);
+ $this->assertNull($foundRoot);
+ $this->assertNull($foundChild);
+ }
+
+ /**
+ * @dataProvider menuItemParentNameProvider
+ *
+ * @param string $child
+ * @param string $expected
+ */
+ public function testFetchingParentItemNameWillReturnParentName($child, $expected) {
+ $menu = $this->getSampleMenu();
+ $parentName = NavigationMenuHelper::findParentItemName($menu, $child);
+
+ $this->assertEquals($expected, $parentName);
+ }
+
+ public function menuItemParentNameProvider() {
+ return [
+ [
+ 'Home',
+ 'root'
+ ],
+ [
+ 'ta_dashboard_tasks',
+ 'tasksassignments'
+ ],
+ [
+ 'hrjc_revision_change_reason',
+ 'Dropdown Options'
+ ],
+ [
+ 'I_DO_NOT_EXIST',
+ NULL
+ ],
+ [
+ 'Administer',
+ 'root'
+ ]
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ public function menuItemNameProvider() {
+ return [
+ [
+ 'Home',
+ TRUE
+ ],
+ [
+ 'I_DO_NOT_EXIST',
+ FALSE
+ ],
+ [
+ 'About CiviCRM',
+ TRUE
+ ],
+ [
+ 'New Life_Insurance_Provider',
+ TRUE
+ ]
+ ];
+ }
+
+ /**
+ * Get a sample navigation menu array
+ *
+ * @return array
+ */
+ private function getSampleMenu() {
+ $jsonFile = __DIR__ . '/../Files/sample_navigation_menu.json';
+ $contents = file_get_contents($jsonFile);
+
+ return json_decode($contents, TRUE);
+ }
+
+}
From 029d27d0c33d73d0d7f079f18374da07ba5d643e Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 28 Feb 2018 18:25:16 +0000
Subject: [PATCH 013/203] PCHR-3374: Cleanup
---
.../HRCore/Helper/NavigationMenuHelper.php | 222 ++++++++++--------
.../Helper/NavigationMenuHelperTest.php | 18 +-
2 files changed, 139 insertions(+), 101 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 2b9c8f7f860..b77d27112e4 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -6,14 +6,27 @@
class CRM_HRCore_Helper_NavigationMenuHelper {
/**
- * Inserts a navigation menu item at a given place in the hierarchy.
+ * Recursively search for a menu item by its name
+ *
+ * @param array $menu
+ * @param string $name
+ *
+ * @return array|null
+ * The menu item, if found, or null otherwise
+ */
+ public static function findMenuItemByName($menu, $name) {
+ return self::findMenuItemReferenceByName($menu, $name);
+ }
+
+ /**
+ * Inserts a navigation menu item as a child of the given parent
*
* @param array $menu
* menu hierarchy
* @param string $parentName
* Name of the parent menu item
* @param array $itemAttributes
- * Menu you need to insert
+ * Attributes of item to insert, e.g. ['name' => 'New Item']
*/
public static function insertChild(&$menu, $parentName, $itemAttributes) {
$parent = &self::findMenuItemReferenceByName($menu, $parentName);
@@ -31,63 +44,51 @@ public static function insertChild(&$menu, $parentName, $itemAttributes) {
}
/**
- * @param $menu
- * @param $nameOfItemToMove
- * @param $nameOfItemBefore
- * @throws Exception
+ * Moves a menu item to after another specified menu item
+ *
+ * @param array $menu
+ * The full menu structure
+ * @param string $itemToMoveName
+ * The name of the menu item we want to move
+ * @param string $precedingItemName
+ * The name of the item that the target should be inserted after
*/
- public static function relocateAfter(&$menu, $nameOfItemToMove, $nameOfItemBefore) {
- $parentName = self::findParentItemName($menu, $nameOfItemBefore);
-
- if ($parentName === 'root') {
- $children = &$menu;
- }
- else {
- $parent = &self::findMenuItemReferenceByName($menu, $parentName);
- $children = &$parent['child'];
- }
+ public static function relocateAfter(
+ &$menu,
+ $itemToMoveName,
+ $precedingItemName
+ ) {
+ $siblings = &self::getSiblingsReference($menu, $precedingItemName);
+ $itemToMove = self::findMenuItemByName($menu, $itemToMoveName);
- $itemToMove = self::findMenuItemByName($menu, $nameOfItemToMove);
- self::remove($menu, $nameOfItemToMove);
+ // remove original from the menu
+ self::remove($menu, $itemToMoveName);
- $targetIndex = NULL;
- $offset = 1; // because we want to insert it after
- $found = FALSE;
- foreach ($children as $index => $child) {
- if ($child['attributes']['name'] === $nameOfItemBefore) {
- $found = TRUE;
- break;
- }
- $offset++;
- }
+ // re-index and find point to insert the new item
+ $siblings = array_values($siblings);
+ $insertionIndex = self::getMenuItemIndex($siblings, $precedingItemName);
- if (!$found) {
- $err = sprintf('Could not find menu item "%s"', $nameOfItemBefore);
+ if (NULL === $insertionIndex) {
+ $err = sprintf('Could not find menu item "%s"', $precedingItemName);
throw new \Exception($err);
}
- array_splice($children, $offset, 0, [$itemToMove]);
+ $insertionIndex++; // we want to insert it after
+ array_splice($siblings, $insertionIndex, 0, [$itemToMove]);
}
+ /**
+ * Removes an item from the menu by name
+ *
+ * @param array $menu
+ * @param string $name
+ */
public static function remove(&$menu, $name) {
- $parentName = self::findParentItemName($menu, $name);
+ $siblings = &self::getSiblingsReference($menu, $name);
- if ($parentName === NULL) {
- $err = sprintf('Cannot find parent of menu item "%s"', $name);
- throw new \Exception($err);
- }
-
- if ($parentName === 'root') {
- $children = &$menu;
- }
- else {
- $parent = &self::findMenuItemReferenceByName($menu, $parentName);
- $children = &$parent['child'];
- }
-
- foreach ($children as $index => $child) {
- if ($child['attributes']['name'] === $name) {
- unset($children[$index]);
+ foreach ($siblings as $index => $sibling) {
+ if ($sibling['attributes']['name'] === $name) {
+ unset($siblings[$index]);
return;
}
}
@@ -115,16 +116,59 @@ public static function updatePermissionByName(&$menu, $name, $newPermission) {
}
/**
- * Recursively search for a menu item by its name
+ * Recursively search for a menu item's parent name by the child name
+ *
+ * This is a wrapper for a private function that requires a third argument.
*
* @param array $menu
- * @param string $name
+ * @param string $childName
*
- * @return array|null
- * The menu item, if found, or null otherwise
+ * @return string|null
+ * The parent item name, if found, or null otherwise.
+ * If item is at top level parent name will be 'root'
*/
- public static function findMenuItemByName($menu, $name) {
- return self::findMenuItemReferenceByName($menu, $name);
+ public static function findParentItemName($menu, $childName) {
+ return self::findNestedItemParentName($menu, $childName, 'root');
+ }
+
+ /**
+ * Recursively search for a menu item's parent name by the child name
+ *
+ * @param array $menu
+ * The full menu structure
+ * @param string $childName
+ * The name of the child we are searching for
+ * @param string $parentAtThisLevel
+ * The name of the parent at the current level of nesting
+ *
+ * @return string|null
+ * The parent item name, if found, or null otherwise.
+ * If item is at top level parent name will be 'root'
+ */
+ private static function findNestedItemParentName(
+ $menu,
+ $childName,
+ $parentAtThisLevel
+ ) {
+ foreach ($menu as $item) {
+ if ($item['attributes']['name'] === $childName) {
+ return $parentAtThisLevel;
+ }
+ if (!empty($item['child'])) {
+ $children = $item['child'];
+ $found = self::findNestedItemParentName(
+ $children,
+ $childName,
+ $item['attributes']['name']
+ );
+
+ if ($found) {
+ return $found;
+ }
+ }
+ }
+
+ return NULL;
}
/**
@@ -158,57 +202,51 @@ private static function &findMenuItemReferenceByName(&$menu, $name) {
}
/**
- * Recursively search for a menu item's parent name by the child name
- *
- * This is a wrapper for a private function that requires a third argument.
+ * Returns an array containing all sibling items on the same menu level.
+ * This includes the target item.
*
* @param array $menu
- * @param string $childName
+ * The full menu structure
+ * @param string $name
+ * The name of the menu item whose siblings we want
*
- * @return string|null
- * The parent item name, if found, or null otherwise.
- * If item is at top level parent name will be 'root'
+ * @return array
*/
- public static function findParentItemName($menu, $childName
- ) {
- return self::findParentItemNameFromRoot($menu, $childName, 'root');
+ private static function &getSiblingsReference(&$menu, $name) {
+ $parentName = self::findParentItemName($menu, $name);
+
+ if ($parentName === NULL) {
+ $err = sprintf('Cannot find parent of menu item "%s"', $name);
+ throw new \Exception($err);
+ }
+
+ if ($parentName === 'root') {
+ $siblings = &$menu;
+ }
+ else {
+ $parent = &self::findMenuItemReferenceByName($menu, $parentName);
+ $siblings = &$parent['child'];
+ }
+
+ return $siblings;
}
/**
- * Recursively search for a menu item's parent name by the child name
+ * Like array_search, but for menu items
*
- * @param array $menu
- * @param string $childName
- * @param string $parentName
+ * @param array $items
+ * @param string $name
*
- * @return string|null
- * The parent item name, if found, or null otherwise.
- * If item is at top level parent name will be 'root'
+ * @return bool|int
*/
- private static function findParentItemNameFromRoot(
- $menu,
- $childName,
- $parentName
- ) {
- foreach ($menu as $item) {
- if ($item['attributes']['name'] === $childName) {
- return $parentName;
- }
- if (!empty($item['child'])) {
- $children = $item['child'];
- $found = self::findParentItemNameFromRoot(
- $children,
- $childName,
- $item['attributes']['name']
- );
-
- if ($found) {
- return $found;
- }
+ private static function getMenuItemIndex($items, $name) {
+ foreach ($items as $index => $sibling) {
+ if ($sibling['attributes']['name'] === $name) {
+ return $index;
}
}
- return NULL;
+ return FALSE;
}
}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
index f85222fd447..752e4235008 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
@@ -88,21 +88,21 @@ public function testMovingTopLevelMenuItemsWillChangeTheirPositions() {
}
public function testMovingNestedItemsWillChangeTheirPositions() {
- $nestedName = 'Activity Types';
- $nestedParent = 'Customize Data and Screens';
+ $itemName = 'Activity Types';
+ $originalParent = 'Customize Data and Screens';
$moveAfter = 'Membership Status Rules';
$targetParent = 'CiviMember';
$menu = $this->getSampleMenu();
- NavigationMenuHelper::relocateAfter($menu, $nestedName, $moveAfter);
+ NavigationMenuHelper::relocateAfter($menu, $itemName, $moveAfter);
- $origParent = NavigationMenuHelper::findMenuItemByName($menu, $nestedParent);
+ $origParent = NavigationMenuHelper::findMenuItemByName($menu, $originalParent);
$newParent = NavigationMenuHelper::findMenuItemByName($menu, $targetParent);
$origChildren = $origParent['child'];
$newChildren = $newParent['child'];
- $finderFunc = function ($child) use ($nestedName) {
- return $child['attributes']['name'] === $nestedName;
+ $finderFunc = function ($child) use ($itemName) {
+ return $child['attributes']['name'] === $itemName;
};
$matchingOriginalChildren = array_filter($origChildren, $finderFunc);
$matchingNewChildren = array_filter($newChildren, $finderFunc);
@@ -115,7 +115,7 @@ public function testMovingNestedItemsWillChangeTheirPositions() {
}, $newChildren);
$moveAfterPosition = array_search($moveAfter, $newChildrenNames);
- $movedItemPosition = array_search($nestedName, $newChildrenNames);
+ $movedItemPosition = array_search($itemName, $newChildrenNames);
$this->assertEquals($moveAfterPosition + 1, $movedItemPosition);
}
@@ -125,8 +125,8 @@ public function testRemovalWillUnsetElementAndChildren() {
$childElement = 'Custom Fields';
NavigationMenuHelper::remove($menu, $rootElement);
- $foundRoot = NavigationMenuHelper::findParentItemName($menu, $rootElement);
- $foundChild = NavigationMenuHelper::findParentItemName($menu, $childElement);
+ $foundRoot = NavigationMenuHelper::findMenuItemByName($menu, $rootElement);
+ $foundChild = NavigationMenuHelper::findMenuItemByName($menu, $childElement);
$this->assertNull($foundRoot);
$this->assertNull($foundChild);
}
From d9495d7657f022cd64bab1a108dd1d26c2d01abb Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 6 Mar 2018 14:09:23 +0000
Subject: [PATCH 014/203] PCHR-3374: Changes to use path instead of item name
I realized (too late) that civicrm_navigation does not use any unique
constraint on menu item name, so a lot of the functions I had prepared
would be unpredictable when the item name was duplicated. I changed all
functions to use path instead of item name. Path is still not unique,
but it's much less likely to be duplicated (having the same item name in
the same submenu doesn't really make sense)
---
.../HRCore/Helper/NavigationMenuHelper.php | 176 ++++++++----------
.../Helper/NavigationMenuHelperTest.php | 93 +++++----
2 files changed, 125 insertions(+), 144 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index b77d27112e4..69f094e0e7f 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -9,13 +9,15 @@ class CRM_HRCore_Helper_NavigationMenuHelper {
* Recursively search for a menu item by its name
*
* @param array $menu
- * @param string $name
+ * The menu array to search in
+ * @param string $path
+ * The path to the item, e.g. "Events/Dashboard"
*
* @return array|null
* The menu item, if found, or null otherwise
*/
- public static function findMenuItemByName($menu, $name) {
- return self::findMenuItemReferenceByName($menu, $name);
+ public static function findMenuItemByPath($menu, $path) {
+ return self::findMenuItemReferenceByPath($menu, $path);
}
/**
@@ -23,16 +25,16 @@ public static function findMenuItemByName($menu, $name) {
*
* @param array $menu
* menu hierarchy
- * @param string $parentName
- * Name of the parent menu item
+ * @param string $parentPath
+ * Path to the parent menu item, e.g. "Events/Dashboard"
* @param array $itemAttributes
* Attributes of item to insert, e.g. ['name' => 'New Item']
*/
- public static function insertChild(&$menu, $parentName, $itemAttributes) {
- $parent = &self::findMenuItemReferenceByName($menu, $parentName);
+ public static function insertChild(&$menu, $parentPath, $itemAttributes) {
+ $parent = &self::findMenuItemReferenceByPath($menu, $parentPath);
if (!$parent) {
- $err = sprintf('Cannot find parent item "%s"', $parentName);
+ $err = sprintf('Cannot find parent item "%s"', $parentPath);
throw new \Exception($err);
}
@@ -48,28 +50,29 @@ public static function insertChild(&$menu, $parentName, $itemAttributes) {
*
* @param array $menu
* The full menu structure
- * @param string $itemToMoveName
- * The name of the menu item we want to move
- * @param string $precedingItemName
- * The name of the item that the target should be inserted after
+ * @param string $itemToMovePath
+ * The path to the menu item we want to move
+ * @param string $precedingItemPath
+ * The path to the item that the target should be inserted after
*/
public static function relocateAfter(
&$menu,
- $itemToMoveName,
- $precedingItemName
+ $itemToMovePath,
+ $precedingItemPath
) {
- $siblings = &self::getSiblingsReference($menu, $precedingItemName);
- $itemToMove = self::findMenuItemByName($menu, $itemToMoveName);
+ $siblings = &self::getSiblingsReference($menu, $precedingItemPath);
+ $itemToMove = self::findMenuItemByPath($menu, $itemToMovePath);
// remove original from the menu
- self::remove($menu, $itemToMoveName);
+ self::remove($menu, $itemToMovePath);
// re-index and find point to insert the new item
$siblings = array_values($siblings);
+ $precedingItemName = self::getItemNameFromPath($precedingItemPath);
$insertionIndex = self::getMenuItemIndex($siblings, $precedingItemName);
if (NULL === $insertionIndex) {
- $err = sprintf('Could not find menu item "%s"', $precedingItemName);
+ $err = sprintf('Could not find menu item "%s"', $precedingItemPath);
throw new \Exception($err);
}
@@ -78,16 +81,17 @@ public static function relocateAfter(
}
/**
- * Removes an item from the menu by name
+ * Removes an item from the menu by path
*
* @param array $menu
- * @param string $name
+ * @param string $path
*/
- public static function remove(&$menu, $name) {
- $siblings = &self::getSiblingsReference($menu, $name);
+ public static function remove(&$menu, $path) {
+ $siblings = &self::getSiblingsReference($menu, $path);
+ $itemName = self::getItemNameFromPath($path);
foreach ($siblings as $index => $sibling) {
- if ($sibling['attributes']['name'] === $name) {
+ if ($sibling['attributes']['name'] === $itemName) {
unset($siblings[$index]);
return;
}
@@ -99,84 +103,60 @@ public static function remove(&$menu, $name) {
*
* @param array $menu
* The full menu
- * @param string $name
- * The name of the target menu item
+ * @param string $path
+ * The path to the item, e.g. "Events/Dashboard"
* @param string $newPermission
* The new permission for accessing this item
*/
- public static function updatePermissionByName(&$menu, $name, $newPermission) {
- $item = &self::findMenuItemReferenceByName($menu, $name);
+ public static function updatePermissionByPath(&$menu, $path, $newPermission) {
+ $item = &self::findMenuItemReferenceByPath($menu, $path);
if (!$item) {
- $err = sprintf('Cannot find menu item with name "%s"', $name);
+ $err = sprintf('Cannot find menu item with path "%s"', $path);
throw new \Exception($err);
}
$item['attributes']['permission'] = $newPermission;
}
- /**
- * Recursively search for a menu item's parent name by the child name
- *
- * This is a wrapper for a private function that requires a third argument.
- *
- * @param array $menu
- * @param string $childName
- *
- * @return string|null
- * The parent item name, if found, or null otherwise.
- * If item is at top level parent name will be 'root'
- */
- public static function findParentItemName($menu, $childName) {
- return self::findNestedItemParentName($menu, $childName, 'root');
- }
/**
- * Recursively search for a menu item's parent name by the child name
- *
* @param array $menu
- * The full menu structure
- * @param string $childName
- * The name of the child we are searching for
- * @param string $parentAtThisLevel
- * The name of the parent at the current level of nesting
+ * The menu array to search in
+ * @param string $path
+ * The path to the item, e.g. "Events/Dashboard"
*
- * @return string|null
- * The parent item name, if found, or null otherwise.
- * If item is at top level parent name will be 'root'
+ * @return array|null
+ * The menu item if found, or NULL if not
*/
- private static function findNestedItemParentName(
- $menu,
- $childName,
- $parentAtThisLevel
- ) {
- foreach ($menu as $item) {
- if ($item['attributes']['name'] === $childName) {
- return $parentAtThisLevel;
- }
- if (!empty($item['child'])) {
- $children = $item['child'];
- $found = self::findNestedItemParentName(
- $children,
- $childName,
- $item['attributes']['name']
- );
-
- if ($found) {
- return $found;
- }
+ private static function &findMenuItemReferenceByPath(&$menu, $path) {
+ $path = explode('/', $path);
+ $submenu = &$menu;
+
+ while (count($path) > 1) {
+ $parentName = array_shift($path);
+ $submenu = &self::findMenuItemReferenceByName($submenu, $parentName);
+ if (!isset($submenu['child'])) {
+ $null = NULL; // must return reference to variable
+
+ return $null;
}
+ $submenu = &$submenu['child'];
}
- return NULL;
+ $itemName = array_shift($path);
+ $item = &self::findMenuItemReferenceByName($submenu, $itemName);
+
+ return $item;
}
/**
- * Recursively search for a menu item by its name. Returns a reference to
- * the item.
+ * Search for a menu item by its name. Returns a reference to the item.
*
* @param array $menu
+ * The menu to search, can be a submenu of the full structure
* @param string $name
+ * The name of the item to search for
*
* @return array|null
* The referenced menu item, if found, or null otherwise
@@ -186,13 +166,6 @@ private static function &findMenuItemReferenceByName(&$menu, $name) {
if ($item['attributes']['name'] === $name) {
return $item;
}
- if (!empty($item['child'])) {
- $found = &self::findMenuItemReferenceByName($item['child'], $name);
-
- if ($found) {
- return $found;
- }
- }
}
// must return reference to variable
@@ -207,25 +180,21 @@ private static function &findMenuItemReferenceByName(&$menu, $name) {
*
* @param array $menu
* The full menu structure
- * @param string $name
- * The name of the menu item whose siblings we want
+ * @param string $path
+ * The path of the menu item whose siblings we want
*
* @return array
*/
- private static function &getSiblingsReference(&$menu, $name) {
- $parentName = self::findParentItemName($menu, $name);
+ private static function &getSiblingsReference(&$menu, $path) {
+ $finalForwardSlashPos = strrpos($path, '/');
- if ($parentName === NULL) {
- $err = sprintf('Cannot find parent of menu item "%s"', $name);
- throw new \Exception($err);
- }
-
- if ($parentName === 'root') {
- $siblings = &$menu;
+ if (FALSE !== $finalForwardSlashPos) {
+ $parentPath = substr($path, 0, $finalForwardSlashPos);
+ $parent = &self::findMenuItemReferenceByPath($menu, $parentPath);
+ $siblings = &$parent['child'];
}
else {
- $parent = &self::findMenuItemReferenceByName($menu, $parentName);
- $siblings = &$parent['child'];
+ $siblings = &$menu;
}
return $siblings;
@@ -249,4 +218,19 @@ private static function getMenuItemIndex($items, $name) {
return FALSE;
}
+ /**
+ * Gets the last item name in a menu item path
+ *
+ * @param string $path
+ * The path of the menu item, e.g. "Events/Dashboard"
+ *
+ * @return string
+ * The final item in the path, e.g. "Dashboard"
+ */
+ private static function getItemNameFromPath($path) {
+ $path = explode('/', $path);
+
+ return end($path);
+ }
+
}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
index 752e4235008..2663bb38836 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
@@ -10,16 +10,18 @@ class NavigationMenuHelperTest extends CRM_HRCore_Test_BaseHeadlessTest {
/**
* @dataProvider menuItemNameProvider
*
- * @param string $name
+ * @param string $path
* @param bool $exists
*/
- public function testFindingMenuItemWillReturnExpectedResult($name, $exists) {
+ public function testFindingMenuItemWillReturnExpectedResult($path, $exists) {
$menu = $this->getSampleMenu();
- $result = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $result = NavigationMenuHelper::findMenuItemByPath($menu, $path);
+ $parts = explode('/', $path);
+ $expectedName = end($parts);
if ($exists) {
$foundName = $result['attributes']['name'];
- $this->assertEquals($name, $foundName);
+ $this->assertEquals($expectedName, $foundName);
}
else {
$this->assertNull($result);
@@ -28,23 +30,25 @@ public function testFindingMenuItemWillReturnExpectedResult($name, $exists) {
public function testInsertionWillAddChildMenuItem() {
$menu = $this->getSampleMenu();
- $name = 'Test Item';
- $newItem = ['name' => $name];
- $parent = 'Dropdown Options';
- NavigationMenuHelper::insertChild($menu, $parent, $newItem);
-
- $added = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $childName = 'Test Item';
+ $newItem = ['name' => $childName];
+ $parentName = 'Dropdown Options';
+ $parentPath = 'Administer/Customize Data and Screens/' . $parentName;
+ $childPath = $parentPath . '/' . $childName;
+ NavigationMenuHelper::insertChild($menu, $parentPath, $newItem);
+
+ $added = NavigationMenuHelper::findMenuItemByPath($menu, $childPath);
$this->assertNotNull($added);
- $parent = NavigationMenuHelper::findMenuItemByName($menu, 'Dropdown Options');
- $children = $parent['child'];
- $matchingChildItems = array_filter($children, function ($item) use ($name) {
- return $item['attributes']['name'] === $name;
+ $parentPath = NavigationMenuHelper::findMenuItemByPath($menu, $parentPath);
+ $children = $parentPath['child'];
+ $childMatches = array_filter($children, function ($item) use ($childName) {
+ return $item['attributes']['name'] === $childName;
});
- $this->assertCount(1, $matchingChildItems);
- $matchingItem = reset($matchingChildItems);
- $this->assertEquals($name, $matchingItem['attributes']['name']);
+ $this->assertCount(1, $childMatches);
+ $matchingItem = reset($childMatches);
+ $this->assertEquals($childName, $matchingItem['attributes']['name']);
}
public function testInsertionWillThrowExceptionWithInvalidPath() {
@@ -57,19 +61,19 @@ public function testInsertionWillThrowExceptionWithInvalidPath() {
public function testSettingPermissionWillUpdateItInMenu() {
$menu = $this->getSampleMenu();
- $name = 'System Status';
- NavigationMenuHelper::updatePermissionByName($menu, $name, 'foo');
- $item = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $path = 'Administer/Administration Console/System Status';
+ NavigationMenuHelper::updatePermissionByPath($menu, $path, 'foo');
+ $item = NavigationMenuHelper::findMenuItemByPath($menu, $path);
$this->assertEquals('foo', $item['attributes']['permission']);
}
public function testFetchingWillNotReturnAReference() {
$menu = $this->getSampleMenu();
- $name = 'System Status';
- $item = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $name = 'Administer/Administration Console/System Status';
+ $item = NavigationMenuHelper::findMenuItemByPath($menu, $name);
$item['foo'] = 'bar';
- $sameItem = NavigationMenuHelper::findMenuItemByName($menu, $name);
+ $sameItem = NavigationMenuHelper::findMenuItemByPath($menu, $name);
$this->assertArrayNotHasKey('foo', $sameItem);
}
@@ -89,15 +93,17 @@ public function testMovingTopLevelMenuItemsWillChangeTheirPositions() {
public function testMovingNestedItemsWillChangeTheirPositions() {
$itemName = 'Activity Types';
- $originalParent = 'Customize Data and Screens';
- $moveAfter = 'Membership Status Rules';
- $targetParent = 'CiviMember';
+ $originalParentPath = 'Administer/Customize Data and Screens';
+ $itemPath = $originalParentPath . '/' . $itemName;
+ $targetParentPath = 'Administer/CiviMember';
+ $precedingItemName = 'Membership Status Rules';
+ $moveAfterPath = $targetParentPath . '/' . $precedingItemName;
$menu = $this->getSampleMenu();
- NavigationMenuHelper::relocateAfter($menu, $itemName, $moveAfter);
+ NavigationMenuHelper::relocateAfter($menu, $itemPath, $moveAfterPath);
- $origParent = NavigationMenuHelper::findMenuItemByName($menu, $originalParent);
- $newParent = NavigationMenuHelper::findMenuItemByName($menu, $targetParent);
+ $origParent = NavigationMenuHelper::findMenuItemByPath($menu, $originalParentPath);
+ $newParent = NavigationMenuHelper::findMenuItemByPath($menu, $targetParentPath);
$origChildren = $origParent['child'];
$newChildren = $newParent['child'];
@@ -114,7 +120,7 @@ public function testMovingNestedItemsWillChangeTheirPositions() {
return $item['attributes']['name'];
}, $newChildren);
- $moveAfterPosition = array_search($moveAfter, $newChildrenNames);
+ $moveAfterPosition = array_search($precedingItemName, $newChildrenNames);
$movedItemPosition = array_search($itemName, $newChildrenNames);
$this->assertEquals($moveAfterPosition + 1, $movedItemPosition);
}
@@ -122,28 +128,15 @@ public function testMovingNestedItemsWillChangeTheirPositions() {
public function testRemovalWillUnsetElementAndChildren() {
$menu = $this->getSampleMenu();
$rootElement = 'Administer';
- $childElement = 'Custom Fields';
+ $childElement = 'Administer/Custom Fields';
NavigationMenuHelper::remove($menu, $rootElement);
- $foundRoot = NavigationMenuHelper::findMenuItemByName($menu, $rootElement);
- $foundChild = NavigationMenuHelper::findMenuItemByName($menu, $childElement);
+ $foundRoot = NavigationMenuHelper::findMenuItemByPath($menu, $rootElement);
+ $foundChild = NavigationMenuHelper::findMenuItemByPath($menu, $childElement);
$this->assertNull($foundRoot);
$this->assertNull($foundChild);
}
- /**
- * @dataProvider menuItemParentNameProvider
- *
- * @param string $child
- * @param string $expected
- */
- public function testFetchingParentItemNameWillReturnParentName($child, $expected) {
- $menu = $this->getSampleMenu();
- $parentName = NavigationMenuHelper::findParentItemName($menu, $child);
-
- $this->assertEquals($expected, $parentName);
- }
-
public function menuItemParentNameProvider() {
return [
[
@@ -183,11 +176,15 @@ public function menuItemNameProvider() {
FALSE
],
[
- 'About CiviCRM',
+ 'Support/About CiviCRM',
+ TRUE
+ ],
+ [
+ 'Contacts/New Organization/New Life_Insurance_Provider',
TRUE
],
[
- 'New Life_Insurance_Provider',
+ 'Events/Register Event Participant',
TRUE
]
];
From cfd7ec8a9161610ad808c150e19dd595d14f40ed Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 7 Mar 2018 10:33:42 +0000
Subject: [PATCH 015/203] PCHR-3374: Add "relocateBefore" helper function
---
.../HRCore/Helper/NavigationMenuHelper.php | 38 +++++
.../Helper/NavigationMenuHelperTest.php | 142 +++++++++++++++---
2 files changed, 158 insertions(+), 22 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 69f094e0e7f..6afcb65480e 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -45,6 +45,40 @@ public static function insertChild(&$menu, $parentPath, $itemAttributes) {
$parent['child'][] = $newItem;
}
+ /**
+ * Moves a menu item to before another specified menu item
+ *
+ * @param $menu
+ * The full menu structure
+ * @param $itemToMovePath
+ * The path to the menu item we want to move
+ * @param $followingItemPath
+ * The path to the item that the target should be inserted before
+ */
+ public static function relocateBefore(
+ &$menu,
+ $itemToMovePath,
+ $followingItemPath
+ ) {
+ $siblings = &self::getSiblingsReference($menu, $followingItemPath);
+ $itemToMove = self::findMenuItemByPath($menu, $itemToMovePath);
+
+ // remove original from the menu
+ self::remove($menu, $itemToMovePath);
+
+ // re-index and find point to insert the new item
+ $siblings = array_values($siblings);
+ $followingItemName = self::getItemNameFromPath($followingItemPath);
+ $insertionIndex = self::getMenuItemIndex($siblings, $followingItemName);
+
+ if (NULL === $insertionIndex) {
+ $err = sprintf('Could not find menu item "%s"', $followingItemPath);
+ throw new \Exception($err);
+ }
+
+ array_splice($siblings, $insertionIndex, 0, [$itemToMove]);
+ }
+
/**
* Moves a menu item to after another specified menu item
*
@@ -130,6 +164,10 @@ public static function updatePermissionByPath(&$menu, $path, $newPermission) {
* The menu item if found, or NULL if not
*/
private static function &findMenuItemReferenceByPath(&$menu, $path) {
+ if ($path === '') {
+ return $menu;
+ }
+
$path = explode('/', $path);
$submenu = &$menu;
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
index 2663bb38836..6bc8f44bb36 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
@@ -91,38 +91,116 @@ public function testMovingTopLevelMenuItemsWillChangeTheirPositions() {
$this->assertEquals($first, $newSecond['attributes']['name']);
}
- public function testMovingNestedItemsWillChangeTheirPositions() {
- $itemName = 'Activity Types';
- $originalParentPath = 'Administer/Customize Data and Screens';
- $itemPath = $originalParentPath . '/' . $itemName;
- $targetParentPath = 'Administer/CiviMember';
- $precedingItemName = 'Membership Status Rules';
- $moveAfterPath = $targetParentPath . '/' . $precedingItemName;
+ /**
+ * @dataProvider itemsToMoveProvider
+ *
+ * @param string $pathToMove
+ * @param string $pathBefore
+ */
+ public function testInsertingAfterWillPlaceAfterNamedItem(
+ $pathToMove,
+ $pathBefore
+ ) {
+ $menu = $this->getSampleMenu();
+ $parts = explode('/', $pathToMove);
+ $itemName = array_pop($parts);
+ $originalParentPath = implode('/', $parts);
+ $newParentParts = explode('/', $pathBefore);
+ $insertBeforeName = array_pop($newParentParts);
+ $newParentPath = implode('/', $newParentParts);
+
+ NavigationMenuHelper::relocateAfter($menu, $pathToMove, $pathBefore);
+ $matcherFunc = function ($child) use ($itemName) {
+ return $child['attributes']['name'] === $itemName;
+ };
+
+ if ($originalParentPath !== '') {
+ $originalParent = NavigationMenuHelper::findMenuItemByPath($menu, $originalParentPath);
+ $originalChildren = $originalParent['child'];
+ } else {
+ $originalChildren = $menu;
+ }
+
+ if ($newParentPath !== '') {
+ $newParent = NavigationMenuHelper::findMenuItemByPath($menu, $newParentPath);
+ $newParentChildren = $newParent['child'];
+ } else {
+ $newParentChildren = $menu;
+ }
+
+ // If it was moved to a different menu, check that it doesn't exist in old
+ if ($originalParentPath !== $newParentPath) {
+ $matchingOriginalChildren = array_filter($originalChildren, $matcherFunc);
+ $matchingNewChildren = array_filter($newParentChildren, $matcherFunc);
+
+ $this->assertCount(0, $matchingOriginalChildren);
+ $this->assertCount(1, $matchingNewChildren);
+ }
+
+ $moveTargetMenuNames = array_map(function ($item) {
+ return $item['attributes']['name'];
+ }, $newParentChildren);
+
+ $moveBeforePosition = array_search($insertBeforeName, $moveTargetMenuNames);
+ $movedItemPosition = array_search($itemName, $moveTargetMenuNames);
+ $this->assertEquals($moveBeforePosition + 1, $movedItemPosition);
+ }
+
+ /**
+ * @dataProvider itemsToMoveProvider
+ *
+ * @param string $pathToMove
+ * @param string $pathAfter
+ */
+ public function testInsertingBeforeWillPlaceBeforeNamedItem(
+ $pathToMove,
+ $pathAfter
+ ) {
$menu = $this->getSampleMenu();
- NavigationMenuHelper::relocateAfter($menu, $itemPath, $moveAfterPath);
+ $parts = explode('/', $pathToMove);
+ $itemName = array_pop($parts);
+ $originalParentPath = implode('/', $parts);
+ $newParentParts = explode('/', $pathAfter);
+ $insertBeforeName = array_pop($newParentParts);
+ $newParentPath = implode('/', $newParentParts);
- $origParent = NavigationMenuHelper::findMenuItemByPath($menu, $originalParentPath);
- $newParent = NavigationMenuHelper::findMenuItemByPath($menu, $targetParentPath);
+ NavigationMenuHelper::relocateBefore($menu, $pathToMove, $pathAfter);
- $origChildren = $origParent['child'];
- $newChildren = $newParent['child'];
- $finderFunc = function ($child) use ($itemName) {
+ $matcherFunc = function ($child) use ($itemName) {
return $child['attributes']['name'] === $itemName;
};
- $matchingOriginalChildren = array_filter($origChildren, $finderFunc);
- $matchingNewChildren = array_filter($newChildren, $finderFunc);
- $this->assertCount(0, $matchingOriginalChildren);
- $this->assertCount(1, $matchingNewChildren);
+ if ($originalParentPath !== '') {
+ $originalParent = NavigationMenuHelper::findMenuItemByPath($menu, $originalParentPath);
+ $originalChildren = $originalParent['child'];
+ } else {
+ $originalChildren = $menu;
+ }
+
+ if ($newParentPath !== '') {
+ $newParent = NavigationMenuHelper::findMenuItemByPath($menu, $newParentPath);
+ $newParentChildren = $newParent['child'];
+ } else {
+ $newParentChildren = $menu;
+ }
+
+ // If it was moved to a different menu, check that it doesn't exist in old
+ if ($originalParentPath !== $newParentPath) {
+ $matchingOriginalChildren = array_filter($originalChildren, $matcherFunc);
+ $matchingNewChildren = array_filter($newParentChildren, $matcherFunc);
- $newChildrenNames = array_map(function ($item) {
+ $this->assertCount(0, $matchingOriginalChildren);
+ $this->assertCount(1, $matchingNewChildren);
+ }
+
+ $moveTargetMenuNames = array_map(function ($item) {
return $item['attributes']['name'];
- }, $newChildren);
+ }, $newParentChildren);
- $moveAfterPosition = array_search($precedingItemName, $newChildrenNames);
- $movedItemPosition = array_search($itemName, $newChildrenNames);
- $this->assertEquals($moveAfterPosition + 1, $movedItemPosition);
+ $moveBeforePosition = array_search($insertBeforeName, $moveTargetMenuNames);
+ $movedItemPosition = array_search($itemName, $moveTargetMenuNames);
+ $this->assertEquals($moveBeforePosition - 1, $movedItemPosition);
}
public function testRemovalWillUnsetElementAndChildren() {
@@ -190,6 +268,26 @@ public function menuItemNameProvider() {
];
}
+ /**
+ * @return array
+ */
+ public function itemsToMoveProvider() {
+ return [
+ [
+ 'Vacancies/new_vacancy',
+ 'Home'
+ ],
+ [
+ 'Home',
+ 'Administer'
+ ],
+ [
+ 'Administer/Customize Data and Screens/Custom Fields',
+ 'Contacts/New Organization'
+ ]
+ ];
+ }
+
/**
* Get a sample navigation menu array
*
From 3df4aee1c63a73c9df16c3e7e70136d9dfe27ebd Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 7 Mar 2018 10:49:19 +0000
Subject: [PATCH 016/203] PCHR-3374: Refactoring
---
.../HRCore/Helper/NavigationMenuHelper.php | 50 +++++++++++--------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 6afcb65480e..8d2dcde5d12 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -60,23 +60,7 @@ public static function relocateBefore(
$itemToMovePath,
$followingItemPath
) {
- $siblings = &self::getSiblingsReference($menu, $followingItemPath);
- $itemToMove = self::findMenuItemByPath($menu, $itemToMovePath);
-
- // remove original from the menu
- self::remove($menu, $itemToMovePath);
-
- // re-index and find point to insert the new item
- $siblings = array_values($siblings);
- $followingItemName = self::getItemNameFromPath($followingItemPath);
- $insertionIndex = self::getMenuItemIndex($siblings, $followingItemName);
-
- if (NULL === $insertionIndex) {
- $err = sprintf('Could not find menu item "%s"', $followingItemPath);
- throw new \Exception($err);
- }
-
- array_splice($siblings, $insertionIndex, 0, [$itemToMove]);
+ self::relocateWithOffset($menu, $itemToMovePath, $followingItemPath, -1);
}
/**
@@ -94,7 +78,27 @@ public static function relocateAfter(
$itemToMovePath,
$precedingItemPath
) {
- $siblings = &self::getSiblingsReference($menu, $precedingItemPath);
+ self::relocateWithOffset($menu, $itemToMovePath, $precedingItemPath);
+ }
+
+ /**
+ * @param $menu
+ * The full menu structure
+ * @param $itemToMovePath
+ * The path to the menu item we want to move
+ * @param $targetSiblingPath
+ * The path to the sibling the item will be moved next to
+ * @param int $offset
+ * How many places the item should be before / after the sibling item. Use
+ * 0 to place it right after it.
+ */
+ private static function relocateWithOffset(
+ &$menu,
+ $itemToMovePath,
+ $targetSiblingPath,
+ $offset = 0
+ ) {
+ $siblings = &self::getSiblingsReference($menu, $targetSiblingPath);
$itemToMove = self::findMenuItemByPath($menu, $itemToMovePath);
// remove original from the menu
@@ -102,15 +106,19 @@ public static function relocateAfter(
// re-index and find point to insert the new item
$siblings = array_values($siblings);
- $precedingItemName = self::getItemNameFromPath($precedingItemPath);
+ $precedingItemName = self::getItemNameFromPath($targetSiblingPath);
$insertionIndex = self::getMenuItemIndex($siblings, $precedingItemName);
if (NULL === $insertionIndex) {
- $err = sprintf('Could not find menu item "%s"', $precedingItemPath);
+ $err = sprintf('Could not find menu item "%s"', $targetSiblingPath);
throw new \Exception($err);
}
- $insertionIndex++; // we want to insert it after
+ // array_splice offset should be 1 greater than the target index +/- the
+ // offset, i.e. if we want to inset 2 after 1 in [1,3] the
+ // target index is 0, offset is 0 (right after) so insertion index is 1
+ $insertionIndex += ($offset + 1);
+
array_splice($siblings, $insertionIndex, 0, [$itemToMove]);
}
From 64b141d28b2afc7f1e1a7525cc6c2f31f2404501 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 7 Mar 2018 11:41:44 +0000
Subject: [PATCH 017/203] PCHR-3374: Reduce size of sample menu JSON file.
Update tests
---
.../HRCore/Files/sample_navigation_menu.json | 4332 +----------------
.../Helper/NavigationMenuHelperTest.php | 16 +-
2 files changed, 93 insertions(+), 4255 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
index e5d18f90d3f..70046e26207 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
@@ -13,190 +13,6 @@
"active": "1"
}
},
- "2": {
- "attributes": {
- "label": "Search",
- "name": "Search...",
- "url": null,
- "icon": "crm-i fa-search",
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "2",
- "active": "1"
- },
- "child": {
- "3": {
- "attributes": {
- "label": "Find Contacts",
- "name": "Find Contacts",
- "url": "civicrm/contact/search?reset=1",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "3",
- "active": "1"
- }
- },
- "4": {
- "attributes": {
- "label": "Advanced Search",
- "name": "Advanced Search",
- "url": "civicrm/contact/search/advanced?reset=1",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "4",
- "active": "1"
- }
- },
- "5": {
- "attributes": {
- "label": "Full-text Search",
- "name": "Full-text Search",
- "url": "civicrm/contact/search/custom?csid=15&reset=1",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "5",
- "active": "1"
- }
- },
- "6": {
- "attributes": {
- "label": "Search Builder",
- "name": "Search Builder",
- "url": "civicrm/contact/search/builder?reset=1",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": "1",
- "parentID": "2",
- "navID": "6",
- "active": "1"
- }
- },
- "7": {
- "attributes": {
- "label": "Find Cases",
- "name": "Find Cases",
- "url": "civicrm/case/search?reset=1",
- "icon": null,
- "permission": "access my cases and activities,access all cases and activities",
- "operator": "OR",
- "separator": null,
- "parentID": "2",
- "navID": "7",
- "active": "1"
- }
- },
- "8": {
- "attributes": {
- "label": "Find Contributions",
- "name": "Find Contributions",
- "url": "civicrm/contribute/search?reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "8",
- "active": "1"
- }
- },
- "9": {
- "attributes": {
- "label": "Find Mailings",
- "name": "Find Mailings",
- "url": "civicrm/mailing?reset=1",
- "icon": null,
- "permission": "access CiviMail",
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "9",
- "active": "1"
- }
- },
- "10": {
- "attributes": {
- "label": "Find Memberships",
- "name": "Find Memberships",
- "url": "civicrm/member/search?reset=1",
- "icon": null,
- "permission": "access CiviMember",
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "10",
- "active": "1"
- }
- },
- "11": {
- "attributes": {
- "label": "Find Participants",
- "name": "Find Participants",
- "url": "civicrm/event/search?reset=1",
- "icon": null,
- "permission": "access CiviEvent",
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "11",
- "active": "1"
- }
- },
- "12": {
- "attributes": {
- "label": "Find Pledges",
- "name": "Find Pledges",
- "url": "civicrm/pledge/search?reset=1",
- "icon": null,
- "permission": "access CiviPledge",
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "12",
- "active": "1"
- }
- },
- "13": {
- "attributes": {
- "label": "Find Activities",
- "name": "Find Activities",
- "url": "civicrm/activity/search?reset=1",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": "1",
- "parentID": "2",
- "navID": "13",
- "active": "1"
- }
- },
- "14": {
- "attributes": {
- "label": "Custom Searches",
- "name": "Custom Searches",
- "url": "civicrm/contact/search/custom/list?reset=1",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": "2",
- "navID": "14",
- "active": "1"
- }
- }
- }
- },
"15": {
"attributes": {
"label": "Contacts",
@@ -211,34 +27,6 @@
"active": "1"
},
"child": {
- "16": {
- "attributes": {
- "label": "New Individual",
- "name": "New Individual",
- "url": "civicrm/contact/add?reset=1&ct=Individual",
- "icon": null,
- "permission": "add contacts",
- "operator": "",
- "separator": null,
- "parentID": "15",
- "navID": "16",
- "active": "1"
- }
- },
- "17": {
- "attributes": {
- "label": "New Household",
- "name": "New Household",
- "url": "civicrm/contact/add?reset=1&ct=Household",
- "icon": null,
- "permission": "add contacts",
- "operator": "",
- "separator": null,
- "parentID": "15",
- "navID": "17",
- "active": "0"
- }
- },
"18": {
"attributes": {
"label": "New Organization",
@@ -266,4083 +54,129 @@
"navID": "265",
"active": "1"
}
- },
- "266": {
- "attributes": {
- "label": "New Life Insurance Provider",
- "name": "New Life_Insurance_Provider",
- "url": "civicrm/contact/add?ct=Organization&cst=Life_Insurance_Provider&reset=1",
- "icon": null,
- "permission": "add contacts",
- "operator": null,
- "separator": "0",
- "parentID": "18",
- "navID": "266",
- "active": "1"
- }
- },
- "282": {
- "attributes": {
- "label": "New Pension Provider",
- "name": "New Pension_Provider",
- "url": "civicrm/contact/add?ct=Organization&cst=Pension_Provider&reset=1",
- "icon": null,
- "permission": "add contacts",
- "operator": null,
- "separator": "0",
- "parentID": "18",
- "navID": "282",
- "active": "1"
- }
}
}
- },
- "19": {
- "attributes": {
- "label": "Contact Reports",
- "name": "Contact Reports",
- "url": "civicrm/report/list?compid=99&reset=1",
- "icon": null,
- "permission": "access CiviReport",
- "operator": "",
- "separator": "1",
- "parentID": "15",
- "navID": "19",
- "active": "1"
- }
- },
- "20": {
- "attributes": {
- "label": "New Activity",
- "name": "New Activity",
- "url": "civicrm/activity?reset=1&action=add&context=standalone",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": "15",
- "navID": "20",
- "active": "1"
- }
- },
- "21": {
- "attributes": {
- "label": "New Email",
- "name": "New Email",
- "url": "civicrm/activity/email/add?atype=3&action=add&reset=1&context=standalone",
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": "1",
- "parentID": "15",
- "navID": "21",
- "active": "1"
- }
- },
- "22": {
- "attributes": {
- "label": "Import Contacts",
- "name": "Import Contacts",
- "url": "civicrm/import/contact?reset=1",
- "icon": null,
- "permission": "import contacts",
- "operator": "",
- "separator": null,
- "parentID": "15",
- "navID": "22",
- "active": "1"
- }
- },
- "23": {
- "attributes": {
- "label": "Import Activities",
- "name": "Import Activities",
- "url": "civicrm/import/activity?reset=1",
- "icon": null,
- "permission": "import contacts",
- "operator": "",
- "separator": "1",
- "parentID": "15",
- "navID": "23",
- "active": "1"
- }
- },
- "24": {
- "attributes": {
- "label": "New Group",
- "name": "New Group",
- "url": "civicrm/group/add?reset=1",
- "icon": null,
- "permission": "edit groups",
- "operator": "",
- "separator": null,
- "parentID": "15",
- "navID": "24",
- "active": "1"
- }
- },
- "25": {
- "attributes": {
- "label": "Manage Groups",
- "name": "Manage Groups",
- "url": "civicrm/group?reset=1",
- "icon": null,
- "permission": "access CiviCRM",
- "operator": "",
- "separator": "1",
- "parentID": "15",
- "navID": "25",
- "active": "1"
- }
- },
- "26": {
- "attributes": {
- "label": "New Tag",
- "name": "New Tag",
- "url": "civicrm/tag?reset=1&action=add",
- "icon": null,
- "permission": "manage tags",
- "operator": "",
- "separator": null,
- "parentID": "15",
- "navID": "26",
- "active": "1"
- }
- },
- "27": {
+ }
+ }
+ },
+ "110": {
+ "attributes": {
+ "label": "Administer",
+ "name": "Administer",
+ "url": null,
+ "icon": "crm-i fa-cog",
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": null,
+ "navID": "110",
+ "active": "1"
+ },
+ "child": {
+ "111": {
"attributes": {
- "label": "Manage Tags (Categories)",
- "name": "Manage Tags (Categories)",
- "url": "civicrm/tag?reset=1",
+ "label": "Administration Console",
+ "name": "Administration Console",
+ "url": "civicrm/admin?reset=1",
"icon": null,
- "permission": "manage tags",
+ "permission": "administer CiviCRM",
"operator": "",
- "separator": "1",
- "parentID": "15",
- "navID": "27",
- "active": "1"
- }
- },
- "28": {
- "attributes": {
- "label": "Find and Merge Duplicate Contacts",
- "name": "Find and Merge Duplicate Contacts",
- "url": "civicrm/contact/deduperules?reset=1",
- "icon": null,
- "permission": "administer dedupe rules,merge duplicate contacts",
- "operator": "OR",
- "separator": null,
- "parentID": "15",
- "navID": "28",
- "active": "1"
- }
- },
- "280": {
- "attributes": {
- "label": "Import / Export",
- "name": "import_export_job_contracts",
- "url": null,
- "icon": null,
- "permission": "access HRJobs",
- "operator": null,
"separator": null,
- "parentID": "15",
- "navID": "280",
+ "parentID": "110",
+ "navID": "111",
"active": "1"
},
"child": {
- "281": {
+ "112": {
"attributes": {
- "label": "Import Job Contracts",
- "name": "import_job_contracts",
- "url": "civicrm/job/import",
+ "label": "System Status",
+ "name": "System Status",
+ "url": "civicrm/a/#/status",
"icon": null,
- "permission": "access HRJobs",
- "operator": null,
- "separator": "0",
- "parentID": "280",
- "navID": "281",
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "111",
+ "navID": "112",
"active": "1"
}
}
}
},
- "302": {
+ "114": {
"attributes": {
- "label": "Import Custom Fields",
- "name": "import_custom_fields",
- "url": "civicrm/import/custom?reset=1",
+ "label": "Customize Data and Screens",
+ "name": "Customize Data and Screens",
+ "url": null,
"icon": null,
- "permission": "access CiviCRM",
- "operator": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
"separator": null,
- "parentID": "15",
- "navID": "302",
- "active": "1"
- }
- }
- }
- },
- "29": {
- "attributes": {
- "label": "Contributions",
- "name": "Contributions",
- "url": null,
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "29",
- "active": "1"
- },
- "child": {
- "30": {
- "attributes": {
- "label": "Dashboard",
- "name": "Dashboard",
- "url": "civicrm/contribute?reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": null,
- "parentID": "29",
- "navID": "30",
- "active": "1"
- }
- },
- "31": {
- "attributes": {
- "label": "New Contribution",
- "name": "New Contribution",
- "url": "civicrm/contribute/add?reset=1&action=add&context=standalone",
- "icon": null,
- "permission": "access CiviContribute,edit contributions",
- "operator": "AND",
- "separator": null,
- "parentID": "29",
- "navID": "31",
- "active": "1"
- }
- },
- "32": {
- "attributes": {
- "label": "Find Contributions",
- "name": "Find Contributions",
- "url": "civicrm/contribute/search?reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": null,
- "parentID": "29",
- "navID": "32",
- "active": "1"
- }
- },
- "33": {
- "attributes": {
- "label": "Contribution Reports",
- "name": "Contribution Reports",
- "url": "civicrm/report/list?compid=2&reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": "1",
- "parentID": "29",
- "navID": "33",
- "active": "1"
- }
- },
- "34": {
- "attributes": {
- "label": "Import Contributions",
- "name": "Import Contributions",
- "url": "civicrm/contribute/import?reset=1",
- "icon": null,
- "permission": "access CiviContribute,edit contributions",
- "operator": "AND",
- "separator": "1",
- "parentID": "29",
- "navID": "34",
- "active": "1"
- }
- },
- "35": {
- "attributes": {
- "label": "Batch Data Entry",
- "name": "Batch Data Entry",
- "url": "civicrm/batch?reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": null,
- "parentID": "29",
- "navID": "35",
- "active": "1"
- }
- },
- "36": {
- "attributes": {
- "label": "Pledges",
- "name": "Pledges",
- "url": null,
- "icon": null,
- "permission": "access CiviPledge",
- "operator": "",
- "separator": "1",
- "parentID": "29",
- "navID": "36",
- "active": "1"
- },
- "child": {
- "38": {
- "attributes": {
- "label": "Dashboard",
- "name": "Dashboard",
- "url": "civicrm/pledge?reset=1",
- "icon": null,
- "permission": "access CiviPledge",
- "operator": "",
- "separator": null,
- "parentID": "36",
- "navID": "38",
- "active": "1"
- }
- },
- "39": {
- "attributes": {
- "label": "New Pledge",
- "name": "New Pledge",
- "url": "civicrm/pledge/add?reset=1&action=add&context=standalone",
- "icon": null,
- "permission": "access CiviPledge,edit pledges",
- "operator": "AND",
- "separator": null,
- "parentID": "36",
- "navID": "39",
- "active": "1"
- }
- },
- "40": {
- "attributes": {
- "label": "Find Pledges",
- "name": "Find Pledges",
- "url": "civicrm/pledge/search?reset=1",
- "icon": null,
- "permission": "access CiviPledge",
- "operator": "",
- "separator": null,
- "parentID": "36",
- "navID": "40",
- "active": "1"
- }
- },
- "41": {
- "attributes": {
- "label": "Pledge Reports",
- "name": "Pledge Reports",
- "url": "civicrm/report/list?compid=6&reset=1",
- "icon": null,
- "permission": "access CiviPledge",
- "operator": "",
- "separator": "0",
- "parentID": "36",
- "navID": "41",
- "active": "1"
- }
- }
- }
- },
- "37": {
- "attributes": {
- "label": "Accounting Batches",
- "name": "Accounting Batches",
- "url": null,
- "icon": null,
- "permission": "view own manual batches,view all manual batches",
- "operator": "OR",
- "separator": "1",
- "parentID": "29",
- "navID": "37",
- "active": "1"
- },
- "child": {
- "48": {
- "attributes": {
- "label": "New Batch",
- "name": "New Batch",
- "url": "civicrm/financial/batch?reset=1&action=add",
- "icon": null,
- "permission": "create manual batch",
- "operator": "AND",
- "separator": null,
- "parentID": "37",
- "navID": "48",
- "active": "1"
- }
- },
- "49": {
- "attributes": {
- "label": "Open Batches",
- "name": "Open Batches",
- "url": "civicrm/financial/financialbatches?reset=1&batchStatus=1",
- "icon": null,
- "permission": "view own manual batches,view all manual batches",
- "operator": "OR",
- "separator": null,
- "parentID": "37",
- "navID": "49",
- "active": "1"
- }
- },
- "50": {
- "attributes": {
- "label": "Closed Batches",
- "name": "Closed Batches",
- "url": "civicrm/financial/financialbatches?reset=1&batchStatus=2",
- "icon": null,
- "permission": "view own manual batches,view all manual batches",
- "operator": "OR",
- "separator": null,
- "parentID": "37",
- "navID": "50",
- "active": "1"
- }
- },
- "51": {
- "attributes": {
- "label": "Exported Batches",
- "name": "Exported Batches",
- "url": "civicrm/financial/financialbatches?reset=1&batchStatus=5",
- "icon": null,
- "permission": "view own manual batches,view all manual batches",
- "operator": "OR",
- "separator": null,
- "parentID": "37",
- "navID": "51",
- "active": "1"
- }
- }
- }
- },
- "42": {
- "attributes": {
- "label": "New Contribution Page",
- "name": "New Contribution Page",
- "url": "civicrm/admin/contribute/add?reset=1&action=add",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "29",
- "navID": "42",
- "active": "1"
- }
- },
- "43": {
- "attributes": {
- "label": "Manage Contribution Pages",
- "name": "Manage Contribution Pages",
- "url": "civicrm/admin/contribute?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "29",
- "navID": "43",
- "active": "1"
- }
- },
- "44": {
- "attributes": {
- "label": "Personal Campaign Pages",
- "name": "Personal Campaign Pages",
- "url": "civicrm/admin/pcp?reset=1&page_type=contribute",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "29",
- "navID": "44",
- "active": "1"
- }
- },
- "45": {
- "attributes": {
- "label": "Premiums (Thank-you Gifts)",
- "name": "Premiums",
- "url": "civicrm/admin/contribute/managePremiums?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "29",
- "navID": "45",
- "active": "1"
- }
- },
- "46": {
- "attributes": {
- "label": "New Price Set",
- "name": "New Price Set",
- "url": "civicrm/admin/price?reset=1&action=add",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "29",
- "navID": "46",
- "active": "1"
- }
- },
- "47": {
- "attributes": {
- "label": "Manage Price Sets",
- "name": "Manage Price Sets",
- "url": "civicrm/admin/price?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "29",
- "navID": "47",
- "active": "1"
- }
- }
- }
- },
- "52": {
- "attributes": {
- "label": "Events",
- "name": "Events",
- "url": null,
- "icon": null,
- "permission": "access CiviEvent",
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "52",
- "active": "1"
- },
- "child": {
- "53": {
- "attributes": {
- "label": "Dashboard",
- "name": "CiviEvent Dashboard",
- "url": "civicrm/event?reset=1",
- "icon": null,
- "permission": "access CiviEvent",
- "operator": "",
- "separator": null,
- "parentID": "52",
- "navID": "53",
- "active": "1"
- }
- },
- "54": {
- "attributes": {
- "label": "Register Event Participant",
- "name": "Register Event Participant",
- "url": "civicrm/participant/add?reset=1&action=add&context=standalone",
- "icon": null,
- "permission": "access CiviEvent,edit event participants",
- "operator": "AND",
- "separator": null,
- "parentID": "52",
- "navID": "54",
- "active": "1"
- }
- },
- "55": {
- "attributes": {
- "label": "Find Participants",
- "name": "Find Participants",
- "url": "civicrm/event/search?reset=1",
- "icon": null,
- "permission": "access CiviEvent",
- "operator": "",
- "separator": null,
- "parentID": "52",
- "navID": "55",
- "active": "1"
- }
- },
- "56": {
- "attributes": {
- "label": "Event Reports",
- "name": "Event Reports",
- "url": "civicrm/report/list?compid=1&reset=1",
- "icon": null,
- "permission": "access CiviEvent",
- "operator": "",
- "separator": "1",
- "parentID": "52",
- "navID": "56",
- "active": "1"
- }
- },
- "57": {
- "attributes": {
- "label": "Import Participants",
- "name": "Import Participants",
- "url": "civicrm/event/import?reset=1",
- "icon": null,
- "permission": "access CiviEvent,edit event participants",
- "operator": "AND",
- "separator": "1",
- "parentID": "52",
- "navID": "57",
- "active": "1"
- }
- },
- "58": {
- "attributes": {
- "label": "New Event",
- "name": "New Event",
- "url": "civicrm/event/add?reset=1&action=add",
- "icon": null,
- "permission": "access CiviEvent,edit all events",
- "operator": "AND",
- "separator": null,
- "parentID": "52",
- "navID": "58",
- "active": "1"
- }
- },
- "59": {
- "attributes": {
- "label": "Manage Events",
- "name": "Manage Events",
- "url": "civicrm/event/manage?reset=1",
- "icon": null,
- "permission": "access CiviEvent,edit all events",
- "operator": "AND",
- "separator": "1",
- "parentID": "52",
- "navID": "59",
- "active": "1"
- }
- },
- "60": {
- "attributes": {
- "label": "Personal Campaign Pages",
- "name": "Personal Campaign Pages",
- "url": "civicrm/admin/pcp?reset=1&page_type=event",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "52",
- "navID": "60",
- "active": "1"
- }
- },
- "61": {
- "attributes": {
- "label": "Event Templates",
- "name": "Event Templates",
- "url": "civicrm/admin/eventTemplate?reset=1",
- "icon": null,
- "permission": "access CiviEvent,edit all events",
- "operator": "AND",
- "separator": "1",
- "parentID": "52",
- "navID": "61",
- "active": "1"
- }
- },
- "62": {
- "attributes": {
- "label": "New Price Set",
- "name": "New Price Set",
- "url": "civicrm/admin/price?reset=1&action=add",
- "icon": null,
- "permission": "access CiviEvent,edit all events",
- "operator": "AND",
- "separator": null,
- "parentID": "52",
- "navID": "62",
- "active": "1"
- }
- },
- "63": {
- "attributes": {
- "label": "Manage Price Sets",
- "name": "Manage Price Sets",
- "url": "civicrm/admin/price?reset=1",
- "icon": null,
- "permission": "access CiviEvent,edit all events",
- "operator": "AND",
- "separator": null,
- "parentID": "52",
- "navID": "63",
- "active": "1"
- }
- }
- }
- },
- "64": {
- "attributes": {
- "label": "Mailings",
- "name": "Mailings",
- "url": null,
- "icon": null,
- "permission": "access CiviMail,create mailings,approve mailings,schedule mailings",
- "operator": "OR",
- "separator": null,
- "parentID": null,
- "navID": "64",
- "active": "1"
- },
- "child": {
- "65": {
- "attributes": {
- "label": "New Mailing",
- "name": "New Mailing",
- "url": "civicrm/mailing/send?reset=1",
- "icon": null,
- "permission": "access CiviMail,create mailings",
- "operator": "OR",
- "separator": null,
- "parentID": "64",
- "navID": "65",
- "active": "1"
- }
- },
- "66": {
- "attributes": {
- "label": "Draft and Unscheduled Mailings",
- "name": "Draft and Unscheduled Mailings",
- "url": "civicrm/mailing/browse/unscheduled?reset=1&scheduled=false",
- "icon": null,
- "permission": "access CiviMail,create mailings,schedule mailings",
- "operator": "OR",
- "separator": null,
- "parentID": "64",
- "navID": "66",
- "active": "1"
- }
- },
- "67": {
- "attributes": {
- "label": "Scheduled and Sent Mailings",
- "name": "Scheduled and Sent Mailings",
- "url": "civicrm/mailing/browse/scheduled?reset=1&scheduled=true",
- "icon": null,
- "permission": "access CiviMail,approve mailings,create mailings,schedule mailings",
- "operator": "OR",
- "separator": null,
- "parentID": "64",
- "navID": "67",
- "active": "1"
- }
- },
- "68": {
- "attributes": {
- "label": "Archived Mailings",
- "name": "Archived Mailings",
- "url": "civicrm/mailing/browse/archived?reset=1",
- "icon": null,
- "permission": "access CiviMail,create mailings",
- "operator": "OR",
- "separator": null,
- "parentID": "64",
- "navID": "68",
- "active": "1"
- }
- },
- "69": {
- "attributes": {
- "label": "Mailing Reports",
- "name": "Mailing Reports",
- "url": "civicrm/report/list?compid=4&reset=1",
- "icon": null,
- "permission": "access CiviMail",
- "operator": "",
- "separator": "1",
- "parentID": "64",
- "navID": "69",
- "active": "1"
- }
- },
- "70": {
- "attributes": {
- "label": "Headers, Footers, and Automated Messages",
- "name": "Headers, Footers, and Automated Messages",
- "url": "civicrm/admin/component?reset=1",
- "icon": null,
- "permission": "access CiviMail,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "64",
- "navID": "70",
- "active": "1"
- }
- },
- "71": {
- "attributes": {
- "label": "Message Templates",
- "name": "Message Templates",
- "url": "civicrm/admin/messageTemplates?reset=1",
- "icon": null,
- "permission": "edit message templates",
- "operator": "",
- "separator": null,
- "parentID": "64",
- "navID": "71",
- "active": "1"
- }
- },
- "72": {
- "attributes": {
- "label": "From Email Addresses",
- "name": "From Email Addresses",
- "url": "civicrm/admin/options/from_email_address?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": "1",
- "parentID": "64",
- "navID": "72",
- "active": "1"
- }
- },
- "73": {
- "attributes": {
- "label": "New SMS",
- "name": "New SMS",
- "url": "civicrm/sms/send?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": null,
- "parentID": "64",
- "navID": "73",
- "active": "1"
- }
- },
- "74": {
- "attributes": {
- "label": "Find Mass SMS",
- "name": "Find Mass SMS",
- "url": "civicrm/mailing/browse?reset=1&sms=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "1",
- "parentID": "64",
- "navID": "74",
- "active": "1"
- }
- },
- "75": {
- "attributes": {
- "label": "New A/B Test",
- "name": "New A/B Test",
- "url": "civicrm/a/#/abtest/new",
- "icon": null,
- "permission": "access CiviMail",
- "operator": "",
- "separator": null,
- "parentID": "64",
- "navID": "75",
- "active": "1"
- }
- },
- "76": {
- "attributes": {
- "label": "Manage A/B Tests",
- "name": "Manage A/B Tests",
- "url": "civicrm/a/#/abtest",
- "icon": null,
- "permission": "access CiviMail",
- "operator": "",
- "separator": "1",
- "parentID": "64",
- "navID": "76",
- "active": "1"
- }
- }
- }
- },
- "77": {
- "attributes": {
- "label": "Memberships",
- "name": "Memberships",
- "url": null,
- "icon": null,
- "permission": "access CiviMember",
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "77",
- "active": "1"
- },
- "child": {
- "78": {
- "attributes": {
- "label": "Dashboard",
- "name": "Dashboard",
- "url": "civicrm/member?reset=1",
- "icon": null,
- "permission": "access CiviMember",
- "operator": "",
- "separator": null,
- "parentID": "77",
- "navID": "78",
- "active": "1"
- }
- },
- "79": {
- "attributes": {
- "label": "New Membership",
- "name": "New Membership",
- "url": "civicrm/member/add?reset=1&action=add&context=standalone",
- "icon": null,
- "permission": "access CiviMember,edit memberships",
- "operator": "AND",
- "separator": null,
- "parentID": "77",
- "navID": "79",
- "active": "1"
- }
- },
- "80": {
- "attributes": {
- "label": "Find Memberships",
- "name": "Find Memberships",
- "url": "civicrm/member/search?reset=1",
- "icon": null,
- "permission": "access CiviMember",
- "operator": "",
- "separator": null,
- "parentID": "77",
- "navID": "80",
- "active": "1"
- }
- },
- "81": {
- "attributes": {
- "label": "Membership Reports",
- "name": "Membership Reports",
- "url": "civicrm/report/list?compid=3&reset=1",
- "icon": null,
- "permission": "access CiviMember",
- "operator": "",
- "separator": "1",
- "parentID": "77",
- "navID": "81",
- "active": "1"
- }
- },
- "82": {
- "attributes": {
- "label": "Batch Data Entry",
- "name": "Batch Data Entry",
- "url": "civicrm/batch?reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": null,
- "parentID": "77",
- "navID": "82",
- "active": "1"
- }
- },
- "83": {
- "attributes": {
- "label": "Import Memberships",
- "name": "Import Members",
- "url": "civicrm/member/import?reset=1",
- "icon": null,
- "permission": "access CiviMember,edit memberships",
- "operator": "AND",
- "separator": "1",
- "parentID": "77",
- "navID": "83",
- "active": "1"
- }
- },
- "84": {
- "attributes": {
- "label": "New Price Set",
- "name": "New Price Set",
- "url": "civicrm/admin/price?reset=1&action=add",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "77",
- "navID": "84",
- "active": "1"
- }
- },
- "85": {
- "attributes": {
- "label": "Manage Price Sets",
- "name": "Manage Price Sets",
- "url": "civicrm/admin/price?reset=1",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "77",
- "navID": "85",
- "active": "1"
- }
- }
- }
- },
- "86": {
- "attributes": {
- "label": "Campaigns",
- "name": "Campaigns",
- "url": null,
- "icon": null,
- "permission": "interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts",
- "operator": "OR",
- "separator": null,
- "parentID": null,
- "navID": "86",
- "active": "1"
- },
- "child": {
- "87": {
- "attributes": {
- "label": "Dashboard",
- "name": "Dashboard",
- "url": "civicrm/campaign?reset=1",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "87",
- "active": "1"
- },
- "child": {
- "88": {
- "attributes": {
- "label": "Surveys",
- "name": "Survey Dashboard",
- "url": "civicrm/campaign?reset=1&subPage=survey",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "87",
- "navID": "88",
- "active": "1"
- }
- },
- "89": {
- "attributes": {
- "label": "Petitions",
- "name": "Petition Dashboard",
- "url": "civicrm/campaign?reset=1&subPage=petition",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "87",
- "navID": "89",
- "active": "1"
- }
- },
- "90": {
- "attributes": {
- "label": "Campaigns",
- "name": "Campaign Dashboard",
- "url": "civicrm/campaign?reset=1&subPage=campaign",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "87",
- "navID": "90",
- "active": "1"
- }
- }
- }
- },
- "91": {
- "attributes": {
- "label": "New Campaign",
- "name": "New Campaign",
- "url": "civicrm/campaign/add?reset=1",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "91",
- "active": "1"
- }
- },
- "92": {
- "attributes": {
- "label": "New Survey",
- "name": "New Survey",
- "url": "civicrm/survey/add?reset=1",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "92",
- "active": "1"
- }
- },
- "93": {
- "attributes": {
- "label": "New Petition",
- "name": "New Petition",
- "url": "civicrm/petition/add?reset=1",
- "icon": null,
- "permission": "manage campaign,administer CiviCampaign",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "93",
- "active": "1"
- }
- },
- "94": {
- "attributes": {
- "label": "Reserve Respondents",
- "name": "Reserve Respondents",
- "url": "civicrm/survey/search?reset=1&op=reserve",
- "icon": null,
- "permission": "administer CiviCampaign,manage campaign,reserve campaign contacts",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "94",
- "active": "1"
- }
- },
- "95": {
- "attributes": {
- "label": "Interview Respondents",
- "name": "Interview Respondents",
- "url": "civicrm/survey/search?reset=1&op=interview",
- "icon": null,
- "permission": "administer CiviCampaign,manage campaign,interview campaign contacts",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "95",
- "active": "1"
- }
- },
- "96": {
- "attributes": {
- "label": "Release Respondents",
- "name": "Release Respondents",
- "url": "civicrm/survey/search?reset=1&op=release",
- "icon": null,
- "permission": "administer CiviCampaign,manage campaign,release campaign contacts",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "96",
- "active": "1"
- }
- },
- "97": {
- "attributes": {
- "label": "Campaign Reports",
- "name": "Campaign Reports",
- "url": "civicrm/report/list?compid=9&reset=1",
- "icon": null,
- "permission": "interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts",
- "operator": "OR",
- "separator": "1",
- "parentID": "86",
- "navID": "97",
- "active": "1"
- }
- },
- "98": {
- "attributes": {
- "label": "Conduct Survey",
- "name": "Conduct Survey",
- "url": "civicrm/campaign/vote?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign,manage campaign,reserve campaign contacts,interview campaign contacts",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "98",
- "active": "1"
- }
- },
- "99": {
- "attributes": {
- "label": "GOTV (Voter Tracking)",
- "name": "Voter Listing",
- "url": "civicrm/campaign/gotv?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign,manage campaign,release campaign contacts,gotv campaign contacts",
- "operator": "OR",
- "separator": null,
- "parentID": "86",
- "navID": "99",
- "active": "1"
- }
- }
- }
- },
- "100": {
- "attributes": {
- "label": "Cases",
- "name": "Cases",
- "url": null,
- "icon": null,
- "permission": "access my cases and activities,access all cases and activities",
- "operator": "OR",
- "separator": null,
- "parentID": null,
- "navID": "100",
- "active": "0"
- },
- "child": {
- "101": {
- "attributes": {
- "label": "Dashboard",
- "name": "Dashboard",
- "url": "civicrm/case?reset=1",
- "icon": null,
- "permission": "access my cases and activities,access all cases and activities",
- "operator": "OR",
- "separator": null,
- "parentID": "100",
- "navID": "101",
- "active": "1"
- }
- },
- "102": {
- "attributes": {
- "label": "New Case",
- "name": "New Case",
- "url": "civicrm/case/add?reset=1&action=add&atype=13&context=standalone",
- "icon": null,
- "permission": "add cases,access all cases and activities",
- "operator": "OR",
- "separator": null,
- "parentID": "100",
- "navID": "102",
- "active": "1"
- }
- },
- "103": {
- "attributes": {
- "label": "Find Cases",
- "name": "Find Cases",
- "url": "civicrm/case/search?reset=1",
- "icon": null,
- "permission": "access my cases and activities,access all cases and activities",
- "operator": "OR",
- "separator": "1",
- "parentID": "100",
- "navID": "103",
- "active": "1"
- }
- },
- "104": {
- "attributes": {
- "label": "Case Reports",
- "name": "Case Reports",
- "url": "civicrm/report/list?compid=7&reset=1",
- "icon": null,
- "permission": "access my cases and activities,access all cases and activities,administer CiviCase",
- "operator": "OR",
- "separator": "0",
- "parentID": "100",
- "navID": "104",
- "active": "1"
- }
- }
- }
- },
- "105": {
- "attributes": {
- "label": "Grants",
- "name": "Grants",
- "url": null,
- "icon": null,
- "permission": "access CiviGrant",
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "105",
- "active": "1"
- },
- "child": {
- "106": {
- "attributes": {
- "label": "Dashboard",
- "name": "Dashboard",
- "url": "civicrm/grant?reset=1",
- "icon": null,
- "permission": "access CiviGrant",
- "operator": "",
- "separator": null,
- "parentID": "105",
- "navID": "106",
- "active": "1"
- }
- },
- "107": {
- "attributes": {
- "label": "New Grant",
- "name": "New Grant",
- "url": "civicrm/grant/add?reset=1&action=add&context=standalone",
- "icon": null,
- "permission": "access CiviGrant,edit grants",
- "operator": "AND",
- "separator": null,
- "parentID": "105",
- "navID": "107",
- "active": "1"
- }
- },
- "108": {
- "attributes": {
- "label": "Find Grants",
- "name": "Find Grants",
- "url": "civicrm/grant/search?reset=1",
- "icon": null,
- "permission": "access CiviGrant",
- "operator": "",
- "separator": "1",
- "parentID": "105",
- "navID": "108",
- "active": "1"
- }
- },
- "109": {
- "attributes": {
- "label": "Grant Reports",
- "name": "Grant Reports",
- "url": "civicrm/report/list?compid=5&reset=1",
- "icon": null,
- "permission": "access CiviGrant",
- "operator": "",
- "separator": "0",
- "parentID": "105",
- "navID": "109",
- "active": "1"
- }
- }
- }
- },
- "110": {
- "attributes": {
- "label": "Administer",
- "name": "Administer",
- "url": null,
- "icon": "crm-i fa-cog",
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "110",
- "active": "1"
- },
- "child": {
- "111": {
- "attributes": {
- "label": "Administration Console",
- "name": "Administration Console",
- "url": "civicrm/admin?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "110",
- "navID": "111",
- "active": "1"
- },
- "child": {
- "112": {
- "attributes": {
- "label": "System Status",
- "name": "System Status",
- "url": "civicrm/a/#/status",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "111",
- "navID": "112",
- "active": "1"
- }
- },
- "113": {
- "attributes": {
- "label": "Configuration Checklist",
- "name": "Configuration Checklist",
- "url": "civicrm/admin/configtask?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "111",
- "navID": "113",
- "active": "1"
- }
- }
- }
- },
- "114": {
- "attributes": {
- "label": "Customize Data and Screens",
- "name": "Customize Data and Screens",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "110",
- "navID": "114",
- "active": "1"
- },
- "child": {
- "115": {
- "attributes": {
- "label": "Custom Fields",
- "name": "Custom Fields",
- "url": "civicrm/admin/custom/group?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "115",
- "active": "1"
- }
- },
- "116": {
- "attributes": {
- "label": "Profiles",
- "name": "Profiles",
- "url": "civicrm/admin/uf/group?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "116",
- "active": "1"
- }
- },
- "117": {
- "attributes": {
- "label": "Tags (Categories)",
- "name": "Tags (Categories)",
- "url": "civicrm/tag?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "117",
- "active": "1"
- }
- },
- "118": {
- "attributes": {
- "label": "Activity Types",
- "name": "Activity Types",
- "url": "civicrm/admin/options/activity_type?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "118",
- "active": "1"
- }
- },
- "119": {
- "attributes": {
- "label": "Relationship Types",
- "name": "Relationship Types",
- "url": "civicrm/admin/reltype?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "119",
- "active": "1"
- }
- },
- "120": {
- "attributes": {
- "label": "Contact Types",
- "name": "Contact Types",
- "url": "civicrm/admin/options/subtype?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "120",
- "active": "1"
- }
- },
- "121": {
- "attributes": {
- "label": "Display Preferences",
- "name": "Display Preferences",
- "url": "civicrm/admin/setting/preferences/display?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "121",
- "active": "1"
- }
- },
- "122": {
- "attributes": {
- "label": "Search Preferences",
- "name": "Search Preferences",
- "url": "civicrm/admin/setting/search?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "122",
- "active": "1"
- }
- },
- "123": {
- "attributes": {
- "label": "Date Preferences",
- "name": "Date Preferences",
- "url": "civicrm/admin/setting/preferences/date?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "123",
- "active": "1"
- }
- },
- "124": {
- "attributes": {
- "label": "Navigation Menu",
- "name": "Navigation Menu",
- "url": "civicrm/admin/menu?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "124",
- "active": "1"
- }
- },
- "125": {
- "attributes": {
- "label": "Word Replacements",
- "name": "Word Replacements",
- "url": "civicrm/admin/options/wordreplacements?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "125",
- "active": "1"
- }
- },
- "126": {
- "attributes": {
- "label": "Manage Custom Searches",
- "name": "Manage Custom Searches",
- "url": "civicrm/admin/options/custom_search?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "126",
- "active": "1"
- }
- },
- "127": {
- "attributes": {
- "label": "Dropdown Options",
- "name": "Dropdown Options",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "114",
- "navID": "127",
- "active": "1"
- },
- "child": {
- "128": {
- "attributes": {
- "label": "Gender Options",
- "name": "Gender Options",
- "url": "civicrm/admin/options/gender?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "128",
- "active": "1"
- }
- },
- "129": {
- "attributes": {
- "label": "Individual Prefixes (Ms, Mr...)",
- "name": "Individual Prefixes (Ms, Mr...)",
- "url": "civicrm/admin/options/individual_prefix?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "129",
- "active": "1"
- }
- },
- "130": {
- "attributes": {
- "label": "Individual Suffixes (Jr, Sr...)",
- "name": "Individual Suffixes (Jr, Sr...)",
- "url": "civicrm/admin/options/individual_suffix?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "130",
- "active": "1"
- }
- },
- "131": {
- "attributes": {
- "label": "Instant Messenger Services",
- "name": "Instant Messenger Services",
- "url": "civicrm/admin/options/instant_messenger_service?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "131",
- "active": "1"
- }
- },
- "132": {
- "attributes": {
- "label": "Location Types (Home, Work...)",
- "name": "Location Types (Home, Work...)",
- "url": "civicrm/admin/locationType?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "132",
- "active": "1"
- }
- },
- "133": {
- "attributes": {
- "label": "Mobile Phone Providers",
- "name": "Mobile Phone Providers",
- "url": "civicrm/admin/options/mobile_provider?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "133",
- "active": "1"
- }
- },
- "134": {
- "attributes": {
- "label": "Phone Types",
- "name": "Phone Types",
- "url": "civicrm/admin/options/phone_type?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "134",
- "active": "1"
- }
- },
- "135": {
- "attributes": {
- "label": "Website Types",
- "name": "Website Types",
- "url": "civicrm/admin/options/website_type?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "127",
- "navID": "135",
- "active": "1"
- }
- },
- "267": {
- "attributes": {
- "label": "Hours Types",
- "name": "hoursType",
- "url": "civicrm/hour/editoption",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "267",
- "active": "1"
- }
- },
- "268": {
- "attributes": {
- "label": "Job Contract Pay Scale",
- "name": "pay_scale",
- "url": "civicrm/pay_scale",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "268",
- "active": "1"
- }
- },
- "269": {
- "attributes": {
- "label": "Job Contract Hours/Location",
- "name": "hours_location",
- "url": "civicrm/hours_location",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "269",
- "active": "1"
- }
- },
- "270": {
- "attributes": {
- "label": "Contract Type",
- "name": "hrjc_contract_type",
- "url": "civicrm/admin/options/hrjc_contract_type?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "270",
- "active": "1"
- }
- },
- "271": {
- "attributes": {
- "label": "Normal place of work",
- "name": "hrjc_location",
- "url": "civicrm/admin/options/hrjc_location?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "271",
- "active": "1"
- }
- },
- "272": {
- "attributes": {
- "label": "Pay cycle",
- "name": "hrjc_pay_cycle",
- "url": "civicrm/admin/options/hrjc_pay_cycle?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "272",
- "active": "1"
- }
- },
- "273": {
- "attributes": {
- "label": "Benefits",
- "name": "hrjc_benefit_name",
- "url": "civicrm/admin/options/hrjc_benefit_name?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "273",
- "active": "1"
- }
- },
- "274": {
- "attributes": {
- "label": "Benefit type",
- "name": "hrjc_benefit_type",
- "url": "civicrm/admin/options/hrjc_benefit_type?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "274",
- "active": "1"
- }
- },
- "275": {
- "attributes": {
- "label": "Deductions",
- "name": "hrjc_deduction_name",
- "url": "civicrm/admin/options/hrjc_deduction_name?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "275",
- "active": "1"
- }
- },
- "276": {
- "attributes": {
- "label": "Deduction type",
- "name": "hrjc_deduction_type",
- "url": "civicrm/admin/options/hrjc_deduction_type?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "276",
- "active": "1"
- }
- },
- "278": {
- "attributes": {
- "label": "Reason for change",
- "name": "hrjc_revision_change_reason",
- "url": "civicrm/admin/options/hrjc_revision_change_reason?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "278",
- "active": "1"
- }
- },
- "279": {
- "attributes": {
- "label": "Reason for Job Contract end",
- "name": "hrjc_contract_end_reason",
- "url": "civicrm/admin/options/hrjc_contract_end_reason?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": null,
- "separator": "0",
- "parentID": "127",
- "navID": "279",
- "active": "1"
- }
- }
- }
- }
- }
- },
- "136": {
- "attributes": {
- "label": "Communications",
- "name": "Communications",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "110",
- "navID": "136",
- "active": "1"
- },
- "child": {
- "137": {
- "attributes": {
- "label": "Organization Address and Contact Info",
- "name": "Organization Address and Contact Info",
- "url": "civicrm/admin/domain?action=update&reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "137",
- "active": "1"
- }
- },
- "138": {
- "attributes": {
- "label": "FROM Email Addresses",
- "name": "FROM Email Addresses",
- "url": "civicrm/admin/options/from_email_address?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "138",
- "active": "1"
- }
- },
- "139": {
- "attributes": {
- "label": "Message Templates",
- "name": "Message Templates",
- "url": "civicrm/admin/messageTemplates?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "139",
- "active": "1"
- }
- },
- "140": {
- "attributes": {
- "label": "Schedule Reminders",
- "name": "Schedule Reminders",
- "url": "civicrm/admin/scheduleReminders?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "140",
- "active": "1"
- }
- },
- "141": {
- "attributes": {
- "label": "Preferred Communication Methods",
- "name": "Preferred Communication Methods",
- "url": "civicrm/admin/options/preferred_communication_method?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "141",
- "active": "1"
- }
- },
- "142": {
- "attributes": {
- "label": "Label Formats",
- "name": "Label Formats",
- "url": "civicrm/admin/labelFormats?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "142",
- "active": "1"
- }
- },
- "143": {
- "attributes": {
- "label": "Print Page (PDF) Formats",
- "name": "Print Page (PDF) Formats",
- "url": "civicrm/admin/pdfFormats?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "143",
- "active": "1"
- }
- },
- "144": {
- "attributes": {
- "label": "Communication Style Options",
- "name": "Communication Style Options",
- "url": "civicrm/admin/options/communication_style?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "144",
- "active": "1"
- }
- },
- "145": {
- "attributes": {
- "label": "Email Greeting Formats",
- "name": "Email Greeting Formats",
- "url": "civicrm/admin/options/email_greeting?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "145",
- "active": "1"
- }
- },
- "146": {
- "attributes": {
- "label": "Postal Greeting Formats",
- "name": "Postal Greeting Formats",
- "url": "civicrm/admin/options/postal_greeting?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "146",
- "active": "1"
- }
- },
- "147": {
- "attributes": {
- "label": "Addressee Formats",
- "name": "Addressee Formats",
- "url": "civicrm/admin/options/addressee?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "136",
- "navID": "147",
- "active": "1"
- }
- }
- }
- },
- "148": {
- "attributes": {
- "label": "Localization",
- "name": "Localization",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "110",
- "navID": "148",
- "active": "1"
- },
- "child": {
- "149": {
- "attributes": {
- "label": "Languages, Currency, Locations",
- "name": "Languages, Currency, Locations",
- "url": "civicrm/admin/setting/localization?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "148",
- "navID": "149",
- "active": "1"
- }
- },
- "150": {
- "attributes": {
- "label": "Address Settings",
- "name": "Address Settings",
- "url": "civicrm/admin/setting/preferences/address?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "148",
- "navID": "150",
- "active": "1"
- }
- },
- "151": {
- "attributes": {
- "label": "Date Formats",
- "name": "Date Formats",
- "url": "civicrm/admin/setting/date?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "148",
- "navID": "151",
- "active": "1"
- }
- },
- "152": {
- "attributes": {
- "label": "Preferred Language Options",
- "name": "Preferred Language Options",
- "url": "civicrm/admin/options/languages?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "148",
- "navID": "152",
- "active": "1"
- }
- }
- }
- },
- "153": {
- "attributes": {
- "label": "Users and Permissions",
- "name": "Users and Permissions",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "110",
- "navID": "153",
- "active": "1"
- },
- "child": {
- "154": {
- "attributes": {
- "label": "Permissions (Access Control)",
- "name": "Permissions (Access Control)",
- "url": "civicrm/admin/access?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "153",
- "navID": "154",
- "active": "1"
- }
- },
- "155": {
- "attributes": {
- "label": "Synchronize Users to Contacts",
- "name": "Synchronize Users to Contacts",
- "url": "civicrm/admin/synchUser?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "153",
- "navID": "155",
- "active": "1"
- }
- }
- }
- },
- "156": {
- "attributes": {
- "label": "System Settings",
- "name": "System Settings",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "110",
- "navID": "156",
- "active": "1"
- },
- "child": {
- "157": {
- "attributes": {
- "label": "Components",
- "name": "Enable Components",
- "url": "civicrm/admin/setting/component?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "157",
- "active": "1"
- }
- },
- "158": {
- "attributes": {
- "label": "Connections",
- "name": "Connections",
- "url": "civicrm/a/#/cxn",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "158",
- "active": "1"
- }
- },
- "159": {
- "attributes": {
- "label": "Extensions",
- "name": "Manage Extensions",
- "url": "civicrm/admin/extensions?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": "1",
- "parentID": "156",
- "navID": "159",
- "active": "1"
- }
- },
- "160": {
- "attributes": {
- "label": "Cleanup Caches and Update Paths",
- "name": "Cleanup Caches and Update Paths",
- "url": "civicrm/admin/setting/updateConfigBackend?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "160",
- "active": "1"
- }
- },
- "161": {
- "attributes": {
- "label": "CMS Database Integration",
- "name": "CMS Integration",
- "url": "civicrm/admin/setting/uf?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "161",
- "active": "1"
- }
- },
- "162": {
- "attributes": {
- "label": "Debugging and Error Handling",
- "name": "Debugging and Error Handling",
- "url": "civicrm/admin/setting/debug?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "162",
- "active": "1"
- }
- },
- "163": {
- "attributes": {
- "label": "Directories",
- "name": "Directories",
- "url": "civicrm/admin/setting/path?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "163",
- "active": "1"
- }
- },
- "164": {
- "attributes": {
- "label": "Import/Export Mappings",
- "name": "Import/Export Mappings",
- "url": "civicrm/admin/mapping?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "164",
- "active": "1"
- }
- },
- "165": {
- "attributes": {
- "label": "Mapping and Geocoding",
- "name": "Mapping and Geocoding",
- "url": "civicrm/admin/setting/mapping?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "165",
- "active": "1"
- }
- },
- "166": {
- "attributes": {
- "label": "Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)",
- "name": "Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)",
- "url": "civicrm/admin/setting/misc?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "166",
- "active": "1"
- }
- },
- "167": {
- "attributes": {
- "label": "Multi Site Settings",
- "name": "Multi Site Settings",
- "url": "civicrm/admin/setting/preferences/multisite?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "167",
- "active": "1"
- }
- },
- "168": {
- "attributes": {
- "label": "Option Groups",
- "name": "Option Groups",
- "url": "civicrm/admin/options?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "168",
- "active": "1"
- }
- },
- "169": {
- "attributes": {
- "label": "Outbound Email (SMTP/Sendmail)",
- "name": "Outbound Email",
- "url": "civicrm/admin/setting/smtp?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "169",
- "active": "1"
- }
- },
- "170": {
- "attributes": {
- "label": "Payment Processors",
- "name": "Payment Processors",
- "url": "civicrm/admin/paymentProcessor?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "170",
- "active": "1"
- }
- },
- "171": {
- "attributes": {
- "label": "Resource URLs",
- "name": "Resource URLs",
- "url": "civicrm/admin/setting/url?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "171",
- "active": "1"
- }
- },
- "172": {
- "attributes": {
- "label": "Safe File Extensions",
- "name": "Safe File Extensions",
- "url": "civicrm/admin/options/safe_file_extension?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "172",
- "active": "1"
- }
- },
- "173": {
- "attributes": {
- "label": "Scheduled Jobs",
- "name": "Scheduled Jobs",
- "url": "civicrm/admin/job?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "173",
- "active": "1"
- }
- },
- "174": {
- "attributes": {
- "label": "SMS Providers",
- "name": "SMS Providers",
- "url": "civicrm/admin/sms/provider?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "156",
- "navID": "174",
- "active": "1"
- }
- }
- }
- },
- "175": {
- "attributes": {
- "label": "CiviCampaign",
- "name": "CiviCampaign",
- "url": null,
- "icon": null,
- "permission": "administer CiviCampaign,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "175",
- "active": "1"
- },
- "child": {
- "176": {
- "attributes": {
- "label": "Survey Types",
- "name": "Survey Types",
- "url": "civicrm/admin/campaign/surveyType?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign",
- "operator": "",
- "separator": null,
- "parentID": "175",
- "navID": "176",
- "active": "1"
- }
- },
- "177": {
- "attributes": {
- "label": "Campaign Types",
- "name": "Campaign Types",
- "url": "civicrm/admin/options/campaign_type?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign",
- "operator": "",
- "separator": null,
- "parentID": "175",
- "navID": "177",
- "active": "1"
- }
- },
- "178": {
- "attributes": {
- "label": "Campaign Status",
- "name": "Campaign Status",
- "url": "civicrm/admin/options/campaign_status?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign",
- "operator": "",
- "separator": null,
- "parentID": "175",
- "navID": "178",
- "active": "1"
- }
- },
- "179": {
- "attributes": {
- "label": "Engagement Index",
- "name": "Engagement Index",
- "url": "civicrm/admin/options/engagement_index?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign",
- "operator": "",
- "separator": null,
- "parentID": "175",
- "navID": "179",
- "active": "1"
- }
- },
- "180": {
- "attributes": {
- "label": "CiviCampaign Component Settings",
- "name": "CiviCampaign Component Settings",
- "url": "civicrm/admin/setting/preferences/campaign?reset=1",
- "icon": null,
- "permission": "administer CiviCampaign",
- "operator": "",
- "separator": null,
- "parentID": "175",
- "navID": "180",
- "active": "1"
- }
- }
- }
- },
- "181": {
- "attributes": {
- "label": "CiviCase",
- "name": "CiviCase",
- "url": null,
- "icon": null,
- "permission": "administer CiviCase",
- "operator": null,
- "separator": null,
- "parentID": "110",
- "navID": "181",
- "active": "1"
- },
- "child": {
- "182": {
- "attributes": {
- "label": "CiviCase Settings",
- "name": "CiviCase Settings",
- "url": "civicrm/admin/setting/case?reset=1",
- "icon": null,
- "permission": "administer CiviCase",
- "operator": null,
- "separator": null,
- "parentID": "181",
- "navID": "182",
- "active": "1"
- }
- },
- "183": {
- "attributes": {
- "label": "Case Types",
- "name": "Case Types",
- "url": "civicrm/a/#/caseType",
- "icon": null,
- "permission": "administer CiviCase",
- "operator": null,
- "separator": null,
- "parentID": "181",
- "navID": "183",
- "active": "1"
- }
- },
- "184": {
- "attributes": {
- "label": "Redaction Rules",
- "name": "Redaction Rules",
- "url": "civicrm/admin/options/redaction_rule?reset=1",
- "icon": null,
- "permission": "administer CiviCase",
- "operator": null,
- "separator": null,
- "parentID": "181",
- "navID": "184",
- "active": "1"
- }
- },
- "185": {
- "attributes": {
- "label": "Case Statuses",
- "name": "Case Statuses",
- "url": "civicrm/admin/options/case_status?reset=1",
- "icon": null,
- "permission": "administer CiviCase",
- "operator": null,
- "separator": null,
- "parentID": "181",
- "navID": "185",
- "active": "1"
- }
- },
- "186": {
- "attributes": {
- "label": "Encounter Medium",
- "name": "Encounter Medium",
- "url": "civicrm/admin/options/encounter_medium?reset=1",
- "icon": null,
- "permission": "administer CiviCase",
- "operator": null,
- "separator": null,
- "parentID": "181",
- "navID": "186",
- "active": "1"
- }
- }
- }
- },
- "187": {
- "attributes": {
- "label": "CiviContribute",
- "name": "CiviContribute",
- "url": null,
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "187",
- "active": "1"
- },
- "child": {
- "188": {
- "attributes": {
- "label": "New Contribution Page",
- "name": "New Contribution Page",
- "url": "civicrm/admin/contribute?reset=1&action=add",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "188",
- "active": "1"
- }
- },
- "189": {
- "attributes": {
- "label": "Manage Contribution Pages",
- "name": "Manage Contribution Pages",
- "url": "civicrm/admin/contribute?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "187",
- "navID": "189",
- "active": "1"
- }
- },
- "190": {
- "attributes": {
- "label": "Personal Campaign Pages",
- "name": "Personal Campaign Pages",
- "url": "civicrm/admin/pcp?reset=1&page_type=contribute",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "190",
- "active": "1"
- }
- },
- "191": {
- "attributes": {
- "label": "Premiums (Thank-you Gifts)",
- "name": "Premiums",
- "url": "civicrm/admin/contribute/managePremiums?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "187",
- "navID": "191",
- "active": "1"
- }
- },
- "192": {
- "attributes": {
- "label": "Financial Types",
- "name": "Financial Types",
- "url": "civicrm/admin/financial/financialType?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "192",
- "active": "1"
- }
- },
- "193": {
- "attributes": {
- "label": "Financial Accounts",
- "name": "Financial Accounts",
- "url": "civicrm/admin/financial/financialAccount?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "193",
- "active": "1"
- }
- },
- "194": {
- "attributes": {
- "label": "Payment Methods",
- "name": "Payment Instruments",
- "url": "civicrm/admin/options/payment_instrument?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "194",
- "active": "1"
- }
- },
- "195": {
- "attributes": {
- "label": "Accepted Credit Cards",
- "name": "Accepted Credit Cards",
- "url": "civicrm/admin/options/accept_creditcard?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "195",
- "active": "1"
- }
- },
- "196": {
- "attributes": {
- "label": "Soft Credit Types",
- "name": "Soft Credit Types",
- "url": "civicrm/admin/options/soft_credit_type?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "187",
- "navID": "196",
- "active": "1"
- }
- },
- "197": {
- "attributes": {
- "label": "New Price Set",
- "name": "New Price Set",
- "url": "civicrm/admin/price?reset=1&action=add",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "197",
- "active": "1"
- }
- },
- "198": {
- "attributes": {
- "label": "Manage Price Sets",
- "name": "Manage Price Sets",
- "url": "civicrm/admin/price?reset=1",
- "icon": null,
- "permission": "access CiviContribute,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "187",
- "navID": "198",
- "active": "1"
- }
- },
- "199": {
- "attributes": {
- "label": "Payment Processors",
- "name": "Payment Processors",
- "url": "civicrm/admin/paymentProcessor?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "187",
- "navID": "199",
- "active": "1"
- }
- },
- "200": {
- "attributes": {
- "label": "CiviContribute Component Settings",
- "name": "CiviContribute Component Settings",
- "url": "civicrm/admin/setting/preferences/contribute?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "187",
- "navID": "200",
- "active": "1"
- }
- }
- }
- },
- "201": {
- "attributes": {
- "label": "CiviEvent",
- "name": "CiviEvent",
- "url": null,
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "201",
- "active": "1"
- },
- "child": {
- "202": {
- "attributes": {
- "label": "New Event",
- "name": "New Event",
- "url": "civicrm/event/add?reset=1&action=add",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "202",
- "active": "1"
- }
- },
- "203": {
- "attributes": {
- "label": "Manage Events",
- "name": "Manage Events",
- "url": "civicrm/event/manage?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "201",
- "navID": "203",
- "active": "1"
- }
- },
- "204": {
- "attributes": {
- "label": "Personal Campaign Pages",
- "name": "Personal Campaign Pages",
- "url": "civicrm/admin/pcp?reset=1&page_type=event",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "201",
- "navID": "204",
- "active": "1"
- }
- },
- "205": {
- "attributes": {
- "label": "Event Templates",
- "name": "Event Templates",
- "url": "civicrm/admin/eventTemplate?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "201",
- "navID": "205",
- "active": "1"
- }
- },
- "206": {
- "attributes": {
- "label": "New Price Set",
- "name": "New Price Set",
- "url": "civicrm/admin/price?reset=1&action=add",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "206",
- "active": "1"
- }
- },
- "207": {
- "attributes": {
- "label": "Manage Price Sets",
- "name": "Manage Price Sets",
- "url": "civicrm/admin/price?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "201",
- "navID": "207",
- "active": "1"
- }
- },
- "208": {
- "attributes": {
- "label": "Event Types",
- "name": "Event Types",
- "url": "civicrm/admin/options/event_type?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "208",
- "active": "1"
- }
- },
- "209": {
- "attributes": {
- "label": "Participant Statuses",
- "name": "Participant Statuses",
- "url": "civicrm/admin/participant_status?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "209",
- "active": "1"
- }
- },
- "210": {
- "attributes": {
- "label": "Participant Roles",
- "name": "Participant Roles",
- "url": "civicrm/admin/options/participant_role?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "210",
- "active": "1"
- }
- },
- "211": {
- "attributes": {
- "label": "Participant Listing Options",
- "name": "Participant Listing Options",
- "url": "civicrm/admin/options/participant_listing?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "211",
- "active": "1"
- }
- },
- "212": {
- "attributes": {
- "label": "Event Name Badge Layouts",
- "name": "Event Name Badge Layouts",
- "url": "civicrm/admin/badgelayout?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "212",
- "active": "1"
- }
- },
- "213": {
- "attributes": {
- "label": "Payment Processors",
- "name": "Payment Processors",
- "url": "civicrm/admin/paymentProcessor?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "201",
- "navID": "213",
- "active": "1"
- }
- },
- "214": {
- "attributes": {
- "label": "CiviEvent Component Settings",
- "name": "CiviEvent Component Settings",
- "url": "civicrm/admin/setting/preferences/event?reset=1",
- "icon": null,
- "permission": "access CiviEvent,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "201",
- "navID": "214",
- "active": "1"
- }
- }
- }
- },
- "215": {
- "attributes": {
- "label": "CiviGrant",
- "name": "CiviGrant",
- "url": null,
- "icon": null,
- "permission": "access CiviGrant,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "215",
- "active": "1"
- },
- "child": {
- "216": {
- "attributes": {
- "label": "Grant Types",
- "name": "Grant Types",
- "url": "civicrm/admin/options/grant_type?reset=1",
- "icon": null,
- "permission": "access CiviGrant,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "215",
- "navID": "216",
- "active": "1"
- }
- },
- "217": {
- "attributes": {
- "label": "Grant Status",
- "name": "Grant Status",
- "url": "civicrm/admin/options/grant_status?reset=1",
- "icon": null,
- "permission": "access CiviGrant,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "215",
- "navID": "217",
- "active": "1"
- }
- }
- }
- },
- "218": {
- "attributes": {
- "label": "CiviMail",
- "name": "CiviMail",
- "url": null,
- "icon": null,
- "permission": "access CiviMail,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "218",
- "active": "1"
- },
- "child": {
- "219": {
- "attributes": {
- "label": "Headers, Footers, and Automated Messages",
- "name": "Headers, Footers, and Automated Messages",
- "url": "civicrm/admin/component?reset=1",
- "icon": null,
- "permission": "access CiviMail,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "218",
- "navID": "219",
- "active": "1"
- }
- },
- "220": {
- "attributes": {
- "label": "Message Templates",
- "name": "Message Templates",
- "url": "civicrm/admin/messageTemplates?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "218",
- "navID": "220",
- "active": "1"
- }
- },
- "221": {
- "attributes": {
- "label": "From Email Addresses",
- "name": "From Email Addresses",
- "url": "civicrm/admin/options/from_email_address?reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": null,
- "parentID": "218",
- "navID": "221",
- "active": "1"
- }
- },
- "222": {
- "attributes": {
- "label": "Mail Accounts",
- "name": "Mail Accounts",
- "url": "civicrm/admin/mailSettings?reset=1",
- "icon": null,
- "permission": "access CiviMail,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "218",
- "navID": "222",
- "active": "1"
- }
- },
- "223": {
- "attributes": {
- "label": "Mailer Settings",
- "name": "Mailer Settings",
- "url": "civicrm/admin/mail?reset=1",
- "icon": null,
- "permission": "access CiviMail,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "218",
- "navID": "223",
- "active": "1"
- }
- },
- "224": {
- "attributes": {
- "label": "CiviMail Component Settings",
- "name": "CiviMail Component Settings",
- "url": "civicrm/admin/setting/preferences/mailing?reset=1",
- "icon": null,
- "permission": "access CiviMail,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "218",
- "navID": "224",
- "active": "1"
- }
- }
- }
- },
- "225": {
- "attributes": {
- "label": "CiviMember",
- "name": "CiviMember",
- "url": null,
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "225",
- "active": "1"
- },
- "child": {
- "226": {
- "attributes": {
- "label": "Membership Types",
- "name": "Membership Types",
- "url": "civicrm/admin/member/membershipType?reset=1",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "225",
- "navID": "226",
- "active": "1"
- }
- },
- "227": {
- "attributes": {
- "label": "Membership Status Rules",
- "name": "Membership Status Rules",
- "url": "civicrm/admin/member/membershipStatus?reset=1",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": "1",
- "parentID": "225",
- "navID": "227",
- "active": "1"
- }
- },
- "228": {
- "attributes": {
- "label": "New Price Set",
- "name": "New Price Set",
- "url": "civicrm/admin/price?reset=1&action=add",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "225",
- "navID": "228",
- "active": "1"
- }
- },
- "229": {
- "attributes": {
- "label": "Manage Price Sets",
- "name": "Manage Price Sets",
- "url": "civicrm/admin/price?reset=1",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "225",
- "navID": "229",
- "active": "1"
- }
- },
- "230": {
- "attributes": {
- "label": "CiviMember Component Settings",
- "name": "CiviMember Component Settings",
- "url": "civicrm/admin/setting/preferences/member?reset=1",
- "icon": null,
- "permission": "access CiviMember,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "225",
- "navID": "230",
- "active": "1"
- }
- }
- }
- },
- "231": {
- "attributes": {
- "label": "CiviReport",
- "name": "CiviReport",
- "url": null,
- "icon": null,
- "permission": "access CiviReport,administer CiviCRM",
- "operator": "AND",
- "separator": null,
- "parentID": "110",
- "navID": "231",
- "active": "1"
- },
- "child": {
- "232": {
- "attributes": {
- "label": "All Reports",
- "name": "All Reports",
- "url": "civicrm/report/list?reset=1",
- "icon": null,
- "permission": "access CiviReport",
- "operator": "",
- "separator": null,
- "parentID": "231",
- "navID": "232",
- "active": "1"
- }
- },
- "233": {
- "attributes": {
- "label": "Create New Report from Template",
- "name": "Create New Report from Template",
- "url": "civicrm/admin/report/template/list?reset=1",
- "icon": null,
- "permission": "administer Reports",
- "operator": "",
- "separator": null,
- "parentID": "231",
- "navID": "233",
- "active": "1"
- }
- },
- "234": {
- "attributes": {
- "label": "Manage Templates",
- "name": "Manage Templates",
- "url": "civicrm/admin/report/options/report_template?reset=1",
- "icon": null,
- "permission": "administer Reports",
- "operator": "",
- "separator": null,
- "parentID": "231",
- "navID": "234",
- "active": "1"
- }
- },
- "235": {
- "attributes": {
- "label": "Register Report",
- "name": "Register Report",
- "url": "civicrm/admin/report/register?reset=1",
- "icon": null,
- "permission": "administer Reports",
- "operator": "",
- "separator": null,
- "parentID": "231",
- "navID": "235",
- "active": "1"
- }
- }
- }
- },
- "286": {
- "attributes": {
- "label": "Tasks",
- "name": "tasksassignments_administer",
- "url": null,
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": null,
- "parentID": "110",
- "navID": "286",
- "active": "1"
- },
- "child": {
- "285": {
- "attributes": {
- "label": "Tasks Settings",
- "name": "ta_settings",
- "url": "civicrm/tasksassignments/settings",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "286",
- "navID": "285",
- "active": "1"
- }
- }
- }
- },
- "292": {
- "attributes": {
- "label": "Leave",
- "name": "leave_and_absences",
- "url": null,
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": null,
- "parentID": "110",
- "navID": "292",
- "active": "1"
- },
- "child": {
- "293": {
- "attributes": {
- "label": "Leave/Absence Types",
- "name": "leave_and_absence_types",
- "url": "civicrm/admin/leaveandabsences/types?action=browse&reset=1",
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": "0",
- "parentID": "292",
- "navID": "293",
- "active": "1"
- }
- },
- "294": {
- "attributes": {
- "label": "Leave/Absence Periods",
- "name": "leave_and_absence_periods",
- "url": "civicrm/admin/leaveandabsences/periods?action=browse&reset=1",
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": "0",
- "parentID": "292",
- "navID": "294",
- "active": "1"
- }
- },
- "295": {
- "attributes": {
- "label": "Public Holidays",
- "name": "leave_and_absence_public_holidays",
- "url": "civicrm/admin/leaveandabsences/public_holidays?action=browse&reset=1",
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": "0",
- "parentID": "292",
- "navID": "295",
- "active": "1"
- }
- },
- "296": {
- "attributes": {
- "label": "Manage Work Patterns",
- "name": "leave_and_absence_manage_work_patterns",
- "url": "civicrm/admin/leaveandabsences/work_patterns?action=browse&reset=1",
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": "0",
- "parentID": "292",
- "navID": "296",
- "active": "1"
- }
- },
- "297": {
- "attributes": {
- "label": "General Settings",
- "name": "leave_and_absence_general_settings",
- "url": "civicrm/admin/leaveandabsences/general_settings",
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": "0",
- "parentID": "292",
- "navID": "297",
- "active": "1"
- }
- },
- "298": {
- "attributes": {
- "label": "Import Leave/Absence Requests",
- "name": "leave_and_absences_import",
- "url": "civicrm/admin/leaveandabsences/import",
- "icon": null,
- "permission": "administer leave and absences",
- "operator": null,
- "separator": "0",
- "parentID": "292",
- "navID": "298",
- "active": "1"
- }
- }
- }
- }
- }
- },
- "236": {
- "attributes": {
- "label": "Support",
- "name": "Support",
- "url": null,
- "icon": null,
- "permission": null,
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "236",
- "active": "1"
- },
- "child": {
- "237": {
- "attributes": {
- "label": "Get started",
- "name": "Get started",
- "url": "https://civicrm.org/get-started?src=iam",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": null,
- "parentID": "236",
- "navID": "237",
- "active": "1"
- }
- },
- "238": {
- "attributes": {
- "label": "Documentation",
- "name": "Documentation",
- "url": "https://civicrm.org/documentation?src=iam",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": null,
- "parentID": "236",
- "navID": "238",
- "active": "1"
- }
- },
- "239": {
- "attributes": {
- "label": "Ask a question",
- "name": "Ask a question",
- "url": "https://civicrm.org/ask-a-question?src=iam",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": null,
- "parentID": "236",
- "navID": "239",
- "active": "1"
- }
- },
- "240": {
- "attributes": {
- "label": "Get expert help",
- "name": "Get expert help",
- "url": "https://civicrm.org/experts?src=iam",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": null,
- "parentID": "236",
- "navID": "240",
- "active": "1"
- }
- },
- "241": {
- "attributes": {
- "label": "About CiviCRM",
- "name": "About CiviCRM",
- "url": "https://civicrm.org/about?src=iam",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": "1",
- "parentID": "236",
- "navID": "241",
- "active": "1"
- }
- },
- "242": {
- "attributes": {
- "label": "Register your site",
- "name": "Register your site",
- "url": "https://civicrm.org/register-your-site?src=iam&sid={sid}",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": null,
- "parentID": "236",
- "navID": "242",
- "active": "1"
- }
- },
- "243": {
- "attributes": {
- "label": "Join CiviCRM",
- "name": "Join CiviCRM",
- "url": "https://civicrm.org/become-a-member?src=iam&sid={sid}",
- "icon": null,
- "permission": null,
- "operator": "AND",
- "separator": null,
- "parentID": "236",
- "navID": "243",
- "active": "1"
- }
- },
- "244": {
- "attributes": {
- "label": "Developer",
- "name": "Developer",
- "url": null,
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": "1",
- "parentID": "236",
- "navID": "244",
+ "parentID": "110",
+ "navID": "114",
"active": "1"
},
"child": {
- "245": {
+ "115": {
"attributes": {
- "label": "API Explorer",
- "name": "API Explorer",
- "url": "civicrm/api",
+ "label": "Custom Fields",
+ "name": "Custom Fields",
+ "url": "civicrm/admin/custom/group?reset=1",
"icon": null,
"permission": "administer CiviCRM",
"operator": "",
"separator": null,
- "parentID": "244",
- "navID": "245",
+ "parentID": "114",
+ "navID": "115",
"active": "1"
}
},
- "246": {
+ "127": {
"attributes": {
- "label": "Developer Docs",
- "name": "Developer Docs",
- "url": "https://civicrm.org/developer-documentation?src=iam",
+ "label": "Dropdown Options",
+ "name": "Dropdown Options",
+ "url": null,
"icon": null,
"permission": "administer CiviCRM",
"operator": "",
"separator": null,
- "parentID": "244",
- "navID": "246",
+ "parentID": "114",
+ "navID": "127",
"active": "1"
+ },
+ "child": {
+ "128": {
+ "attributes": {
+ "label": "Gender Options",
+ "name": "Gender Options",
+ "url": "civicrm/admin/options/gender?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "128",
+ "active": "1"
+ }
+ },
+ "129": {
+ "attributes": {
+ "label": "Individual Prefixes (Ms, Mr...)",
+ "name": "Individual Prefixes (Ms, Mr...)",
+ "url": "civicrm/admin/options/individual_prefix?reset=1",
+ "icon": null,
+ "permission": "administer CiviCRM",
+ "operator": "",
+ "separator": null,
+ "parentID": "127",
+ "navID": "129",
+ "active": "1"
+ }
+ }
}
}
}
}
}
- },
- "247": {
- "attributes": {
- "label": "Reports",
- "name": "Reports",
- "url": null,
- "icon": null,
- "permission": "access CiviReport",
- "operator": "",
- "separator": null,
- "parentID": null,
- "navID": "247",
- "active": "1"
- },
- "child": {
- "248": {
- "attributes": {
- "label": "Contact Reports",
- "name": "Contact Reports",
- "url": "civicrm/report/list?compid=99&reset=1",
- "icon": null,
- "permission": "administer CiviCRM",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "248",
- "active": "1"
- }
- },
- "249": {
- "attributes": {
- "label": "Contribution Reports",
- "name": "Contribution Reports",
- "url": "civicrm/report/list?compid=2&reset=1",
- "icon": null,
- "permission": "access CiviContribute",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "249",
- "active": "1"
- }
- },
- "250": {
- "attributes": {
- "label": "Pledge Reports",
- "name": "Pledge Reports",
- "url": "civicrm/report/list?compid=6&reset=1",
- "icon": null,
- "permission": "access CiviPledge",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "250",
- "active": "1"
- }
- },
- "251": {
- "attributes": {
- "label": "Event Reports",
- "name": "Event Reports",
- "url": "civicrm/report/list?compid=1&reset=1",
- "icon": null,
- "permission": "access CiviEvent",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "251",
- "active": "1"
- }
- },
- "252": {
- "attributes": {
- "label": "Mailing Reports",
- "name": "Mailing Reports",
- "url": "civicrm/report/list?compid=4&reset=1",
- "icon": null,
- "permission": "access CiviMail",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "252",
- "active": "1"
- }
- },
- "253": {
- "attributes": {
- "label": "Membership Reports",
- "name": "Membership Reports",
- "url": "civicrm/report/list?compid=3&reset=1",
- "icon": null,
- "permission": "access CiviMember",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "253",
- "active": "1"
- }
- },
- "254": {
- "attributes": {
- "label": "Campaign Reports",
- "name": "Campaign Reports",
- "url": "civicrm/report/list?compid=9&reset=1",
- "icon": null,
- "permission": "interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts",
- "operator": "OR",
- "separator": "0",
- "parentID": "247",
- "navID": "254",
- "active": "1"
- }
- },
- "255": {
- "attributes": {
- "label": "Case Reports",
- "name": "Case Reports",
- "url": "civicrm/report/list?compid=7&reset=1",
- "icon": null,
- "permission": "access my cases and activities,access all cases and activities,administer CiviCase",
- "operator": "OR",
- "separator": "0",
- "parentID": "247",
- "navID": "255",
- "active": "1"
- }
- },
- "256": {
- "attributes": {
- "label": "Grant Reports",
- "name": "Grant Reports",
- "url": "civicrm/report/list?compid=5&reset=1",
- "icon": null,
- "permission": "access CiviGrant",
- "operator": "",
- "separator": "0",
- "parentID": "247",
- "navID": "256",
- "active": "1"
- }
- },
- "257": {
- "attributes": {
- "label": "All Reports",
- "name": "All Reports",
- "url": "civicrm/report/list?reset=1",
- "icon": null,
- "permission": "access CiviReport",
- "operator": "",
- "separator": "1",
- "parentID": "247",
- "navID": "257",
- "active": "1"
- }
- },
- "258": {
- "attributes": {
- "label": "My Reports",
- "name": "My Reports",
- "url": "civicrm/report/list?myreports=1&reset=1",
- "icon": null,
- "permission": "access CiviReport",
- "operator": "",
- "separator": "1",
- "parentID": "247",
- "navID": "258",
- "active": "1"
- }
- }
- }
- },
- "264": {
- "attributes": {
- "label": "Reports",
- "name": "hr-reports",
- "url": "civicrm/reports",
- "icon": "fa fa-table",
- "permission": "access hrreports",
- "operator": null,
- "separator": null,
- "parentID": null,
- "navID": "264",
- "active": "1"
- }
- },
- "283": {
- "attributes": {
- "label": "Tasks",
- "name": "tasksassignments",
- "url": "",
- "icon": "crm-i fa-list-ul",
- "permission": "access Tasks and Assignments",
- "operator": null,
- "separator": null,
- "parentID": null,
- "navID": "283",
- "active": "1"
- },
- "child": {
- "287": {
- "attributes": {
- "label": "Tasks",
- "name": "ta_dashboard_tasks",
- "url": "civicrm/tasksassignments/dashboard#/tasks",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "283",
- "navID": "287",
- "active": "1"
- }
- },
- "288": {
- "attributes": {
- "label": "Documents",
- "name": "ta_dashboard_documents",
- "url": "civicrm/tasksassignments/dashboard#/documents",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "283",
- "navID": "288",
- "active": "1"
- }
- },
- "289": {
- "attributes": {
- "label": "Calendar",
- "name": "ta_dashboard_calendar",
- "url": "civicrm/tasksassignments/dashboard#/calendar",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "283",
- "navID": "289",
- "active": "1"
- }
- },
- "290": {
- "attributes": {
- "label": "Key Dates",
- "name": "ta_dashboard_keydates",
- "url": "civicrm/tasksassignments/dashboard#/key-dates",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "283",
- "navID": "290",
- "active": "1"
- }
- }
- }
- },
- "291": {
- "attributes": {
- "label": "Leave",
- "name": "leave_and_absences_dashboard",
- "url": null,
- "icon": "crm-i fa-briefcase",
- "permission": "access leave and absences",
- "operator": null,
- "separator": null,
- "parentID": null,
- "navID": "291",
- "active": "1"
- },
- "child": {
- "299": {
- "attributes": {
- "label": "Leave Requests",
- "name": "leave_and_absences_leave_requests",
- "url": "civicrm/leaveandabsences/dashboard#/requests",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "291",
- "navID": "299",
- "active": "1"
- }
- },
- "300": {
- "attributes": {
- "label": "Leave Calendar",
- "name": "leave_and_absences_leave_calendar",
- "url": "civicrm/leaveandabsences/dashboard#/calendar",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "291",
- "navID": "300",
- "active": "1"
- }
- },
- "301": {
- "attributes": {
- "label": "Leave Balances",
- "name": "leave_and_absences_leave_balances",
- "url": "civicrm/leaveandabsences/dashboard#/leave-balances",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "0",
- "parentID": "291",
- "navID": "301",
- "active": "1"
- }
- }
- }
- },
- "303": {
- "attributes": {
- "label": "Recruitment",
- "name": "Vacancies",
- "url": null,
- "icon": "crm-i fa-user-plus",
- "permission": null,
- "operator": null,
- "separator": null,
- "parentID": null,
- "navID": "303",
- "active": "1"
- },
- "child": {
- "304": {
- "attributes": {
- "label": "Dashboard",
- "name": "dashboard",
- "url": "civicrm/vacancy/dashboard?reset=1",
- "icon": null,
- "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "304",
- "active": "1"
- }
- },
- "305": {
- "attributes": {
- "label": "Public Vacancy List",
- "name": "public_list",
- "url": "civicrm/vacancy/publiclisting?reset=1",
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "1",
- "parentID": "303",
- "navID": "305",
- "active": "1"
- }
- },
- "306": {
- "attributes": {
- "label": "New Vacancy",
- "name": "new_vacancy",
- "url": "civicrm/vacancy/add?reset=1",
- "icon": null,
- "permission": "administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "306",
- "active": "1"
- }
- },
- "307": {
- "attributes": {
- "label": "New Template",
- "name": "new_template",
- "url": "civicrm/vacancy/add?reset=1&template=1",
- "icon": null,
- "permission": "administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "307",
- "active": "1"
- }
- },
- "308": {
- "attributes": {
- "label": "New Applicant",
- "name": "new_applicant",
- "url": null,
- "icon": null,
- "permission": null,
- "operator": null,
- "separator": "1",
- "parentID": "303",
- "navID": "308",
- "active": "1"
- }
- },
- "309": {
- "attributes": {
- "label": "Find Vacancies",
- "name": "find_vacancies",
- "url": "civicrm/vacancy/find?reset=1",
- "icon": null,
- "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "309",
- "active": "1"
- }
- },
- "310": {
- "attributes": {
- "label": "Find Templates",
- "name": "find_templates",
- "url": "civicrm/vacancy/find?reset=1&template=1",
- "icon": null,
- "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "310",
- "active": "1"
- }
- },
- "311": {
- "attributes": {
- "label": "Search by Application Form Fields",
- "name": "find_application",
- "url": "civicrm/case/search?force=1&type=5&reset=1",
- "icon": null,
- "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "311",
- "active": "1"
- }
- },
- "312": {
- "attributes": {
- "label": "Search by Evaluation Criteria",
- "name": "find_evaluation",
- "url": "civicrm/activity/search?force=1&type=114&reset=1",
- "icon": null,
- "permission": "view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM",
- "operator": "OR",
- "separator": "0",
- "parentID": "303",
- "navID": "312",
- "active": "1"
- }
- }
- }
}
}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
index 6bc8f44bb36..26683ab9f59 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
@@ -68,7 +68,7 @@ public function testSettingPermissionWillUpdateItInMenu() {
$this->assertEquals('foo', $item['attributes']['permission']);
}
- public function testFetchingWillNotReturnAReference() {
+ public function testFindMenuItemByNameWillNotReturnAReference() {
$menu = $this->getSampleMenu();
$name = 'Administer/Administration Console/System Status';
$item = NavigationMenuHelper::findMenuItemByPath($menu, $name);
@@ -81,7 +81,7 @@ public function testFetchingWillNotReturnAReference() {
public function testMovingTopLevelMenuItemsWillChangeTheirPositions() {
$menu = $this->getSampleMenu();
$first = 'Home';
- $second = 'Search...';
+ $second = 'Contacts';
NavigationMenuHelper::relocateAfter($menu, $first, $second);
$newFirst = reset($menu);
@@ -254,15 +254,15 @@ public function menuItemNameProvider() {
FALSE
],
[
- 'Support/About CiviCRM',
+ 'Contacts/New Organization/New Health_Insurance_Provider',
TRUE
],
[
- 'Contacts/New Organization/New Life_Insurance_Provider',
+ 'Administer/Administration Console',
TRUE
],
[
- 'Events/Register Event Participant',
+ 'Administer/Customize Data and Screens/Dropdown Options/Gender Options',
TRUE
]
];
@@ -274,7 +274,7 @@ public function menuItemNameProvider() {
public function itemsToMoveProvider() {
return [
[
- 'Vacancies/new_vacancy',
+ 'Administer/Administration Console',
'Home'
],
[
@@ -284,6 +284,10 @@ public function itemsToMoveProvider() {
[
'Administer/Customize Data and Screens/Custom Fields',
'Contacts/New Organization'
+ ],
+ [
+ 'Administer/Customize Data and Screens/Dropdown Options/Gender Options',
+ 'Administer/Administration Console',
]
];
}
From c23b3195db7a0eb22de997d18372b25e776ce33d Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 7 Mar 2018 13:41:01 +0000
Subject: [PATCH 018/203] PCHR-3374: Disallow zero offset in function to
improve readability
---
.../HRCore/Helper/NavigationMenuHelper.php | 21 +++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 8d2dcde5d12..1387c937bb2 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -78,10 +78,13 @@ public static function relocateAfter(
$itemToMovePath,
$precedingItemPath
) {
- self::relocateWithOffset($menu, $itemToMovePath, $precedingItemPath);
+ self::relocateWithOffset($menu, $itemToMovePath, $precedingItemPath, 1);
}
/**
+ * Moves a given item to the same submenu as another target item. Can be
+ * placed before or after the target item using an offset.
+ *
* @param $menu
* The full menu structure
* @param $itemToMovePath
@@ -90,14 +93,18 @@ public static function relocateAfter(
* The path to the sibling the item will be moved next to
* @param int $offset
* How many places the item should be before / after the sibling item. Use
- * 0 to place it right after it.
+ * 1 to place it right after it, -1 to put before it
*/
private static function relocateWithOffset(
&$menu,
$itemToMovePath,
$targetSiblingPath,
- $offset = 0
+ $offset
) {
+ if ($offset === 0) {
+ throw new \Exception('Offset cannot be zero');
+ }
+
$siblings = &self::getSiblingsReference($menu, $targetSiblingPath);
$itemToMove = self::findMenuItemByPath($menu, $itemToMovePath);
@@ -114,8 +121,14 @@ private static function relocateWithOffset(
throw new \Exception($err);
}
+ // we disallow zero offset insertion to make the function clearer,
+ // however this means positive offsets are 1 higher than they should be
+ if ($offset > 0) {
+ $offset--;
+ }
+
// array_splice offset should be 1 greater than the target index +/- the
- // offset, i.e. if we want to inset 2 after 1 in [1,3] the
+ // offset, i.e. if we want to insert 2 after 1 in [1,3] the
// target index is 0, offset is 0 (right after) so insertion index is 1
$insertionIndex += ($offset + 1);
From 035cbd7e985072d01dd49facca46adbf8565e432 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 7 Mar 2018 15:30:20 +0000
Subject: [PATCH 019/203] PCHR-3374: Cleanup offset logic, comments
---
.../CRM/HRCore/Helper/NavigationMenuHelper.php | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 1387c937bb2..1ee57bdda8d 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -121,16 +121,14 @@ private static function relocateWithOffset(
throw new \Exception($err);
}
- // we disallow zero offset insertion to make the function clearer,
- // however this means positive offsets are 1 higher than they should be
- if ($offset > 0) {
- $offset--;
- }
+ $insertionIndex += $offset;
- // array_splice offset should be 1 greater than the target index +/- the
- // offset, i.e. if we want to insert 2 after 1 in [1,3] the
- // target index is 0, offset is 0 (right after) so insertion index is 1
- $insertionIndex += ($offset + 1);
+ // the offset is fine as it is for positive offsets, but we skip 0 when
+ // changing from 'insert after' (offset 1) to 'insert before' (offset -1)
+ // so we need to adjust negative offsets
+ if ($offset < 0) {
+ $insertionIndex++;
+ }
array_splice($siblings, $insertionIndex, 0, [$itemToMove]);
}
From 0d147c543eeb089808a1f4c4c869b5090f129e1d Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 7 Mar 2018 15:38:53 +0000
Subject: [PATCH 020/203] PCHR-3374: Handle negative insertion index
---
.../CRM/HRCore/Helper/NavigationMenuHelper.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 1ee57bdda8d..508e66e13f5 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -130,6 +130,9 @@ private static function relocateWithOffset(
$insertionIndex++;
}
+ // insertion index cannot be lower than 0 (the first element)
+ $insertionIndex = max(0, $insertionIndex);
+
array_splice($siblings, $insertionIndex, 0, [$itemToMove]);
}
From 0391d23ee7f8b4e02b8536d441e8ae929a87d3a4 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 6 Mar 2018 16:49:02 +0000
Subject: [PATCH 021/203] PCHR-3375: Replace insertChild with simpler 'insert'
function
---
.../HRCore/Helper/NavigationMenuHelper.php | 67 +++++++++++++------
.../HRCore/Files/sample_navigation_menu.json | 30 +++++++++
.../Helper/NavigationMenuHelperTest.php | 32 +++++++--
3 files changed, 104 insertions(+), 25 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
index 508e66e13f5..5298aa3ddd7 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Helper/NavigationMenuHelper.php
@@ -21,28 +21,33 @@ public static function findMenuItemByPath($menu, $path) {
}
/**
- * Inserts a navigation menu item as a child of the given parent
+ * Inserts a navigation menu item
*
* @param array $menu
* menu hierarchy
- * @param string $parentPath
+ * @param string $path
* Path to the parent menu item, e.g. "Events/Dashboard"
- * @param array $itemAttributes
- * Attributes of item to insert, e.g. ['name' => 'New Item']
+ * @param array $attributes
+ * Attributes of item to insert, e.g. ['label' => 'New Item']
*/
- public static function insertChild(&$menu, $parentPath, $itemAttributes) {
- $parent = &self::findMenuItemReferenceByPath($menu, $parentPath);
-
- if (!$parent) {
- $err = sprintf('Cannot find parent item "%s"', $parentPath);
- throw new \Exception($err);
- }
+ public static function insert(&$menu, $path, $attributes = []) {
+ $name = self::getItemNameFromPath($path);
+ $defaults = ['name' => $name, 'label' => $name, 'active' => 1];
+ $newItem = ['attributes' => array_merge($defaults, $attributes)];
+
+ if (self::isRootItem($path)) {
+ $menu[] = $newItem;
+ } else {
+ $parentPath = self::getParentPathFromPath($path);
+ $parent = &self::findMenuItemReferenceByPath($menu, $parentPath);
- $label = CRM_Utils_Array::value('name', $itemAttributes);
- $defaults = ['label' => $label, 'active' => 1];
- $newItem = ['attributes' => array_merge($defaults, $itemAttributes)];
+ if (!$parent) {
+ $err = sprintf('Cannot find parent item "%s"', $parentPath);
+ throw new \Exception($err);
+ }
- $parent['child'][] = $newItem;
+ $parent['child'][] = $newItem;
+ }
}
/**
@@ -246,10 +251,8 @@ private static function &findMenuItemReferenceByName(&$menu, $name) {
* @return array
*/
private static function &getSiblingsReference(&$menu, $path) {
- $finalForwardSlashPos = strrpos($path, '/');
-
- if (FALSE !== $finalForwardSlashPos) {
- $parentPath = substr($path, 0, $finalForwardSlashPos);
+ if (!self::isRootItem($path)) {
+ $parentPath = self::getParentPathFromPath($path);
$parent = &self::findMenuItemReferenceByPath($menu, $parentPath);
$siblings = &$parent['child'];
}
@@ -260,6 +263,21 @@ private static function &getSiblingsReference(&$menu, $path) {
return $siblings;
}
+ /**
+ * Gets the parent path from a given path, e.g. "Events" from
+ * "Events/Dashboard"
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ private static function getParentPathFromPath($path) {
+ $path = explode('/', $path);
+ array_pop($path);
+
+ return implode('/', $path);
+ }
+
/**
* Like array_search, but for menu items
*
@@ -293,4 +311,15 @@ private static function getItemNameFromPath($path) {
return end($path);
}
+ /**
+ * Checks whether the given path is a root menu item, i.e. "Home"
+ *
+ * @param string $path
+ *
+ * @return bool
+ */
+ private static function isRootItem($path) {
+ return FALSE === strpos($path, '/');
+ }
+
}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
index 70046e26207..fb427b924a7 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Files/sample_navigation_menu.json
@@ -176,6 +176,36 @@
}
}
}
+ },
+ "292": {
+ "attributes": {
+ "label": "Leave",
+ "name": "leave_and_absences",
+ "url": null,
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": null,
+ "parentID": "110",
+ "navID": "292",
+ "active": "1"
+ },
+ "child": {
+ "293": {
+ "attributes": {
+ "label": "Leave/Absence Types",
+ "name": "leave_and_absence_types",
+ "url": "civicrm/admin/leaveandabsences/types?action=browse&reset=1",
+ "icon": null,
+ "permission": "administer leave and absences",
+ "operator": null,
+ "separator": "0",
+ "parentID": "292",
+ "navID": "293",
+ "active": "1"
+ }
+ }
+ }
}
}
}
diff --git a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
index 26683ab9f59..e81f3c01ddc 100644
--- a/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
+++ b/uk.co.compucorp.civicrm.hrcore/tests/phpunit/CRM/HRCore/Helper/NavigationMenuHelperTest.php
@@ -1,11 +1,12 @@
getSampleMenu();
$childName = 'Test Item';
- $newItem = ['name' => $childName];
+ $attributes = ['foo' => 'bar'];
$parentName = 'Dropdown Options';
$parentPath = 'Administer/Customize Data and Screens/' . $parentName;
$childPath = $parentPath . '/' . $childName;
- NavigationMenuHelper::insertChild($menu, $parentPath, $newItem);
+ NavigationMenuHelper::insert($menu, $childPath, $attributes);
$added = NavigationMenuHelper::findMenuItemByPath($menu, $childPath);
$this->assertNotNull($added);
@@ -51,12 +52,31 @@ public function testInsertionWillAddChildMenuItem() {
$this->assertEquals($childName, $matchingItem['attributes']['name']);
}
+ public function testInsertionWillAddRootMenuItem() {
+ $menu = $this->getSampleMenu();
+ $name = 'Foo';
+ NavigationMenuHelper::insert($menu, $name);
+ $newestEntry = array_pop($menu);
+
+ $this->assertEquals($name, $newestEntry['attributes']['name']);
+ }
+
+ public function testAttributesWillOverrideDefaultsInInsertion() {
+ $menu = $this->getSampleMenu();
+ $name = 'Foo';
+ $label = 'Bar';
+ NavigationMenuHelper::insert($menu, $name, ['label' => $label]);
+ $newestEntry = array_pop($menu);
+
+ $this->assertEquals($label, $newestEntry['attributes']['label']);
+ }
+
public function testInsertionWillThrowExceptionWithInvalidPath() {
- $expectedError = 'Cannot find parent item "Bar"';
+ $expectedError = 'Cannot find parent item "Foo"';
$this->setExpectedException(\Exception::class, $expectedError);
$menu = [];
- $parent = 'Bar';
- NavigationMenuHelper::insertChild($menu, $parent, []);
+ $path = 'Foo/Bar';
+ NavigationMenuHelper::insert($menu, $path, []);
}
public function testSettingPermissionWillUpdateItInMenu() {
From 5b60906c82378c3cdd5e2a10ad4afca24f42cab0 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 09:51:40 +0000
Subject: [PATCH 022/203] PCHR-3375: Add upgrader to add link for editing job
contract options
---
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 61 ++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 3645ec3a097..97dc95e32f9 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -512,6 +512,7 @@ public function upgradeBundle() {
$this->upgrade_1030();
$this->upgrade_1032();
$this->upgrade_1033();
+ $this->upgrade_1036();
}
function upgrade_1001() {
@@ -1207,6 +1208,66 @@ public function upgrade_1035() {
return TRUE;
}
+ /**
+ * Adds a submenu containing links to edit job contract option groups
+ *
+ * @return bool
+ */
+ public function upgrade_1036() {
+ $params = ['return' => 'id', 'name' => 'Administer'];
+ $administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+
+ $permission = 'Access CiviCRM';
+ $parent = $this->createNavItem('Job Contract', $permission, $administerId);
+ $parentId = $parent['id'];
+
+ // Weight cannot be set when creating for the first time
+ civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -100]);
+
+ // If we don't flush it will not recognize newly created parent_id
+ CRM_Core_PseudoConstant::flush();
+
+ $optionGroupLinks = [
+ 'Contract Types' => 'hrjc_contract_type',
+ 'Normal Place of Work' => 'hrjc_location',
+ 'Contract End Reasons' => 'hrjc_contract_end_reason',
+ 'Standard Full Time Hours' => 'hrjc_hours_type',
+ 'Pay Scales' => 'hrjc_pay_grade',
+ 'Benefits' => 'hrjc_benefit_type',
+ 'Deductions' => 'hrjc_deduction_type',
+ 'Insurance Plan Types' => 'hrjc_insurance_plantype',
+ ];
+
+ foreach ($optionGroupLinks as $itemName => $optionGroup) {
+ $link = 'civicrm/admin/options/' . $optionGroup . '?reset=1';
+ $this->createNavItem($itemName, $permission, $parentId, ['url' => $link]);
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Creates a navigation menu item using the API
+ *
+ * @param string $name
+ * @param string $permission
+ * @param int $parentID
+ * @param array $params
+ *
+ * @return array
+ */
+ private function createNavItem($name, $permission, $parentID, $params = []) {
+ $params = array_merge([
+ 'name' => $name,
+ 'label' => ts($name),
+ 'permission' => $permission,
+ 'parent_id' => $parentID,
+ 'is_active' => 1,
+ ], $params);
+
+ return civicrm_api3('navigation', 'create', $params);
+ }
+
/**
* Removes the "Pension Type" item from the
* "Administer -> Customize Data and Screens -> Dropdowns" menu
From e08d740decca9bf9004c861ae3b9919049fedd0e Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 10:47:16 +0000
Subject: [PATCH 023/203] PCHR-3375: Add upgrader to add link for editing job
role options
---
.../CRM/Hrjobroles/Upgrader.php | 57 +++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
index 372818cfdad..d276ad98db0 100644
--- a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
+++ b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
@@ -45,6 +45,63 @@ public function upgrade_1004() {
return TRUE;
}
+ /**
+ * Adds a submenu containing links to edit job role option groups
+ *
+ * @return bool
+ */
+ public function upgrade_1005() {
+ $params = ['return' => 'id', 'name' => 'Administer'];
+ $administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+
+ $permission = 'Access CiviCRM';
+ $parent = $this->createNavItem('Job Roles', $permission, $administerId);
+ $parentId = $parent['id'];
+
+ // Weight cannot be set when creating for the first time
+ civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -99]);
+
+ // If we don't flush it will not recognize newly created parent_id
+ CRM_Core_PseudoConstant::flush();
+
+ $optionGroupLinks = [
+ 'Locations' => 'hrjc_location',
+ 'Regions' => 'hrjc_region',
+ 'Departments' => 'hrjc_department',
+ 'Levels' => 'hrjc_level_type',
+ 'Cost Centres' => 'cost_centres',
+ ];
+
+ foreach ($optionGroupLinks as $itemName => $optionGroup) {
+ $link = 'civicrm/admin/options/' . $optionGroup . '?reset=1';
+ $this->createNavItem($itemName, $permission, $parentId, ['url' => $link]);
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Creates a navigation menu item using the API
+ *
+ * @param string $name
+ * @param string $permission
+ * @param int $parentID
+ * @param array $params
+ *
+ * @return array
+ */
+ private function createNavItem($name, $permission, $parentID, $params = []) {
+ $params = array_merge([
+ 'name' => $name,
+ 'label' => ts($name),
+ 'permission' => $permission,
+ 'parent_id' => $parentID,
+ 'is_active' => 1,
+ ], $params);
+
+ return civicrm_api3('navigation', 'create', $params);
+ }
+
/**
* Creates new Option Group for Cost Centres
*/
From 180583654f15b1acdb92e1b33acf485c681c184d Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 10:48:42 +0000
Subject: [PATCH 024/203] PCHR-3375: Add upgrader to add link for editing staff
detail options
---
.../CRM/HRCore/Upgrader.php | 1 +
.../CRM/HRCore/Upgrader/Steps/1012.php | 70 +++++++++++++++++++
2 files changed, 71 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
index e15a417dc7b..e194b80139f 100755
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
@@ -19,6 +19,7 @@ class CRM_HRCore_Upgrader extends CRM_HRCore_Upgrader_Base {
use CRM_HRCore_Upgrader_Steps_1009;
use CRM_HRCore_Upgrader_Steps_1010;
use CRM_HRCore_Upgrader_Steps_1011;
+ use CRM_HRCore_Upgrader_Steps_1012;
/**
* @var array
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
new file mode 100644
index 00000000000..8e3df627d66
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -0,0 +1,70 @@
+ 'id', 'name' => 'Administer'];
+ $administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+
+ $permission = 'Access CiviCRM';
+ $parentName = 'Other Staff Details';
+ $parent = $this->up1012_createNavItem($parentName, $permission, $administerId);
+ $parentId = $parent['id'];
+
+ // Weight cannot be set when creating for the first time
+ civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -98]);
+
+ // If we don't flush it will not recognize newly created parent_id
+ CRM_Core_PseudoConstant::flush();
+
+ $optionGroupLinks = [
+ 'Prefixes' => 'individual_prefix',
+ 'Emergency Contact Relationships' => 'relationship_with_employee_20150304120408',
+ 'Career History' => 'occupation_type_20130617111138',
+ 'Disability Types' => 'type_20130502151940',
+ 'Qualifications – Skill Categories' => 'category_of_skill_20130510015438',
+ 'Qualifications – Skill Levels' => 'level_of_skill_20130510015934',
+ ];
+
+ foreach ($optionGroupLinks as $itemName => $optionGroup) {
+ $link = 'civicrm/admin/options/' . $optionGroup . '?reset=1';
+ $params = ['url' => $link];
+ $this->up1012_createNavItem($itemName, $permission, $parentId, $params);
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Creates a navigation menu item using the API
+ *
+ * @param string $name
+ * @param string $permission
+ * @param int $parentID
+ * @param array $params
+ *
+ * @return array
+ */
+ private function up1012_createNavItem(
+ $name,
+ $permission,
+ $parentID,
+ $params = []
+ ) {
+ $params = array_merge([
+ 'name' => $name,
+ 'label' => ts($name),
+ 'permission' => $permission,
+ 'parent_id' => $parentID,
+ 'is_active' => 1,
+ ], $params);
+
+ return civicrm_api3('navigation', 'create', $params);
+ }
+}
From 9f11b365856462926a142f3c21438654bde7b364 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 10:53:28 +0000
Subject: [PATCH 025/203] PCHR-3375: Add upgrader to add link for editing L&A
options
---
.../CRM/HRLeaveAndAbsences/Upgrader.php | 1 +
.../HRLeaveAndAbsences/Upgrader/Step/1020.php | 58 +++++++++++++++++++
2 files changed, 59 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
index ae3b66d8b47..fd996daf1bf 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
@@ -25,6 +25,7 @@ class CRM_HRLeaveAndAbsences_Upgrader extends CRM_HRLeaveAndAbsences_Upgrader_Ba
use CRM_HRLeaveAndAbsences_Upgrader_Step_1017;
use CRM_HRLeaveAndAbsences_Upgrader_Step_1018;
use CRM_HRLeaveAndAbsences_Upgrader_Step_1019;
+ use CRM_HRLeaveAndAbsences_Upgrader_Step_1020;
/**
* A list of directories to be scanned for XML installation files
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
new file mode 100644
index 00000000000..0a999f298f0
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
@@ -0,0 +1,58 @@
+ 'id', 'name' => 'leave_and_absences'];
+ $parentId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -96]);
+
+ $optionGroupLinks = [
+ 'Sickness Reasons' => 'hrleaveandabsences_sickness_reason',
+ 'TOIL to be Accrued' => 'hrleaveandabsences_toil_amounts',
+ 'Work Pattern Change Reasons' => 'hrleaveandabsences_work_pattern_change_reason',
+ 'Work Pattern Day Equivalents' => 'hrleaveandabsences_leave_days_amounts'
+ ];
+
+ foreach ($optionGroupLinks as $itemName => $optionGroup) {
+ $link = 'civicrm/admin/options/' . $optionGroup . '?reset=1';
+ $params = ['url' => $link];
+ $this->up1020_createNavItem($itemName, $permission, $parentId, $params);
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Creates a navigation menu item using the API
+ *
+ * @param string $name
+ * @param string $permission
+ * @param int $parentID
+ * @param array $params
+ *
+ * @return array
+ */
+ private function up1020_createNavItem(
+ $name,
+ $permission,
+ $parentID,
+ $params = []
+ ) {
+ $params = array_merge([
+ 'name' => $name,
+ 'label' => ts($name),
+ 'permission' => $permission,
+ 'parent_id' => $parentID,
+ 'is_active' => 1,
+ ], $params);
+
+ return civicrm_api3('navigation', 'create', $params);
+ }
+}
From d9363fdb7b7cef535866b690a40af429035c2159 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 11:32:49 +0000
Subject: [PATCH 026/203] PCHR-3375: (unrelated) Fix error about undefined
index
---
uk.co.compucorp.civicrm.hrcore/hrcore.civix.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/hrcore.civix.php b/uk.co.compucorp.civicrm.hrcore/hrcore.civix.php
index 2b5dcccfba6..49a45eef221 100644
--- a/uk.co.compucorp.civicrm.hrcore/hrcore.civix.php
+++ b/uk.co.compucorp.civicrm.hrcore/hrcore.civix.php
@@ -292,7 +292,9 @@ function _hrcore_civix_insert_navigation_menu(&$menu, $path, $item) {
$first = array_shift($path);
foreach ($menu as $key => &$entry) {
if ($entry['attributes']['name'] == $first) {
- if (!$entry['child']) $entry['child'] = array();
+ if (!isset($entry['child'])) {
+ $entry['child'] = array();
+ }
$found = _hrcore_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key);
}
}
From b58bbf44d8082e7c0e172f8a2d3e31ccba37bfb7 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 11:57:07 +0000
Subject: [PATCH 027/203] PCHR-3375: Update links to match specs
---
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 1 +
.../CRM/HRCore/Upgrader/Steps/1012.php | 38 ++++++++++++++-----
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 97dc95e32f9..4836997b50d 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1231,6 +1231,7 @@ public function upgrade_1036() {
'Contract Types' => 'hrjc_contract_type',
'Normal Place of Work' => 'hrjc_location',
'Contract End Reasons' => 'hrjc_contract_end_reason',
+ 'Contract Revision Reasons' => 'hrjc_revision_change_reason',
'Standard Full Time Hours' => 'hrjc_hours_type',
'Pay Scales' => 'hrjc_pay_grade',
'Benefits' => 'hrjc_benefit_type',
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index 8e3df627d66..3d1bdeb073d 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -23,17 +23,26 @@ public function upgrade_1012() {
// If we don't flush it will not recognize newly created parent_id
CRM_Core_PseudoConstant::flush();
- $optionGroupLinks = [
- 'Prefixes' => 'individual_prefix',
- 'Emergency Contact Relationships' => 'relationship_with_employee_20150304120408',
- 'Career History' => 'occupation_type_20130617111138',
- 'Disability Types' => 'type_20130502151940',
- 'Qualifications – Skill Categories' => 'category_of_skill_20130510015438',
- 'Qualifications – Skill Levels' => 'level_of_skill_20130510015934',
+ $childLinks = [
+ 'Prefixes' =>
+ $this->getOptionGroupLink('individual_prefix'),
+ 'Genders' =>
+ $this->getOptionGroupLink('gender'),
+ 'Emergency Contact Relationships' =>
+ $this->getOptionGroupLink('relationship_with_employee_20150304120408'),
+ 'Manager Types' =>
+ 'civicrm/admin/reltype?reset=1',
+ 'Career History' =>
+ $this->getOptionGroupLink('occupation_type_20130617111138'),
+ 'Disability Types' =>
+ $this->getOptionGroupLink('type_20130502151940'),
+ 'Qualifications – Skill Categories' =>
+ $this->getOptionGroupLink('category_of_skill_20130510015438'),
+ 'Qualifications – Skill Levels' =>
+ $this->getOptionGroupLink('level_of_skill_20130510015934'),
];
- foreach ($optionGroupLinks as $itemName => $optionGroup) {
- $link = 'civicrm/admin/options/' . $optionGroup . '?reset=1';
+ foreach ($childLinks as $itemName => $link) {
$params = ['url' => $link];
$this->up1012_createNavItem($itemName, $permission, $parentId, $params);
}
@@ -41,6 +50,17 @@ public function upgrade_1012() {
return TRUE;
}
+ /**
+ * Gets the link to edit an option group
+ *
+ * @param string $groupName
+ *
+ * @return string
+ */
+ private function getOptionGroupLink($groupName) {
+ return 'civicrm/admin/options/' . $groupName . '?reset=1';
+ }
+
/**
* Creates a navigation menu item using the API
*
From ac584cb24738a654489ef0a468f760991df938d5 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 12:32:34 +0000
Subject: [PATCH 028/203] PCHR-3375: Relabel, reorder and add separators for
leave submenu
---
.../HRLeaveAndAbsences/Upgrader/Step/1020.php | 80 ++++++++++++++++++-
1 file changed, 76 insertions(+), 4 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
index 0a999f298f0..5cde75d55d7 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
@@ -7,12 +7,26 @@ trait CRM_HRLeaveAndAbsences_Upgrader_Step_1020 {
*
* @return bool
*/
- public function upgrade_1020() {
- $permission = 'administer leave and absences';
+ public function upgrade_1021() {
$params = ['return' => 'id', 'name' => 'leave_and_absences'];
$parentId = (int) civicrm_api3('Navigation', 'getvalue', $params);
civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -96]);
+ $this->createNewLinks($parentId);
+ $this->relabelExistingLinks($parentId);
+ $this->addSeparators($parentId);
+ $this->updateWeight($parentId);
+
+ return TRUE;
+ }
+
+ /**
+ * Creates new entries in the leave submenu
+ *
+ * @param int $parentId
+ */
+ private function createNewLinks($parentId) {
+ $permission = 'administer leave and absences';
$optionGroupLinks = [
'Sickness Reasons' => 'hrleaveandabsences_sickness_reason',
'TOIL to be Accrued' => 'hrleaveandabsences_toil_amounts',
@@ -25,8 +39,60 @@ public function upgrade_1020() {
$params = ['url' => $link];
$this->up1020_createNavItem($itemName, $permission, $parentId, $params);
}
+ }
- return TRUE;
+ /**
+ * Relabels some of the existing leave items
+ *
+ * @param int $parentId
+ */
+ private function relabelExistingLinks($parentId) {
+ $nameToLabelMapping = [
+ 'leave_and_absence_types' => ts('Leave Types'),
+ 'leave_and_absence_periods' => ts('Leave Periods'),
+ 'leave_and_absence_manage_work_patterns' => ts('Work Patterns'),
+ 'leave_and_absence_general_settings' => ts('Leave Settings'),
+ 'leave_and_absences_import' => ts('Import Leave Requests'),
+ ];
+
+ foreach ($nameToLabelMapping as $name => $label) {
+ $params = ['parent_id' => $parentId, 'name' => $name, 'return' => 'id'];
+ $id = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ civicrm_api3('Navigation', 'create', ['id' => $id, 'label' => $label]);
+ }
+ }
+
+ /**
+ * Adds separators after certain items in the leave submenu
+ *
+ * @param int $parentId
+ */
+ private function addSeparators($parentId) {
+ $itemsWithSeparators = [
+ 'leave_and_absence_general_settings',
+ 'Work Pattern Day Equivalents',
+ ];
+
+ CRM_Core_PseudoConstant::flush();
+
+ foreach ($itemsWithSeparators as $name) {
+ $params = ['parent_id' => $parentId, 'name' => $name, 'return' => 'id'];
+ $id = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ civicrm_api3('Navigation', 'create', ['id' => $id, 'has_separator' => 1]);
+ }
+ }
+
+ /**
+ * Sets the weight for the "Import" item so it will appear last
+ *
+ * @param int $parentId
+ */
+ private function updateWeight($parentId) {
+ $name = 'leave_and_absences_import';
+ $params = ['parent_id' => $parentId, 'name' => $name, 'return' => 'id'];
+ $id = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ $maxWeight = CRM_Core_BAO_Navigation::calculateWeight($parentId);
+ civicrm_api3('Navigation', 'create', ['id' => $id, 'weight' => $maxWeight]);
}
/**
@@ -53,6 +119,12 @@ private function up1020_createNavItem(
'is_active' => 1,
], $params);
- return civicrm_api3('navigation', 'create', $params);
+ $existing = civicrm_api3('Navigation', 'get', $params);
+
+ if ($existing['count'] > 0) {
+ return array_shift($existing['values']);
+ }
+
+ return civicrm_api3('Navigation', 'create', $params);
}
}
From 8503b33148b99456b2cae5878be4bdc475bc8a82 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 12:33:23 +0000
Subject: [PATCH 029/203] PCHR-3375: Don't recreate menu items if upgrader is
run twice
---
com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php | 8 +++++++-
.../CRM/HRCore/Upgrader/Steps/1012.php | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
index d276ad98db0..70663796e59 100644
--- a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
+++ b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
@@ -99,7 +99,13 @@ private function createNavItem($name, $permission, $parentID, $params = []) {
'is_active' => 1,
], $params);
- return civicrm_api3('navigation', 'create', $params);
+ $existing = civicrm_api3('Navigation', 'get', $params);
+
+ if ($existing['count'] > 0) {
+ return array_shift($existing['values']);
+ }
+
+ return civicrm_api3('Navigation', 'create', $params);
}
/**
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index 3d1bdeb073d..e0ff94b19b9 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -85,6 +85,12 @@ private function up1012_createNavItem(
'is_active' => 1,
], $params);
- return civicrm_api3('navigation', 'create', $params);
+ $existing = civicrm_api3('Navigation', 'get', $params);
+
+ if ($existing['count'] > 0) {
+ return array_shift($existing['values']);
+ }
+
+ return civicrm_api3('Navigation', 'create', $params);
}
}
From db4b089543205da606f6ec8da15fe32faf3452d8 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 12:41:26 +0000
Subject: [PATCH 030/203] PCHR-3375: Rename trait methods to avoid conflicts
---
.../CRM/HRCore/Upgrader/Steps/1012.php | 16 ++++++++--------
.../HRLeaveAndAbsences/Upgrader/Step/1020.php | 18 +++++++++---------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index e0ff94b19b9..b19babc208e 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -25,21 +25,21 @@ public function upgrade_1012() {
$childLinks = [
'Prefixes' =>
- $this->getOptionGroupLink('individual_prefix'),
+ $this->up1020_getOptionGroupLink('individual_prefix'),
'Genders' =>
- $this->getOptionGroupLink('gender'),
+ $this->up1020_getOptionGroupLink('gender'),
'Emergency Contact Relationships' =>
- $this->getOptionGroupLink('relationship_with_employee_20150304120408'),
+ $this->up1020_getOptionGroupLink('relationship_with_employee_20150304120408'),
'Manager Types' =>
'civicrm/admin/reltype?reset=1',
'Career History' =>
- $this->getOptionGroupLink('occupation_type_20130617111138'),
+ $this->up1020_getOptionGroupLink('occupation_type_20130617111138'),
'Disability Types' =>
- $this->getOptionGroupLink('type_20130502151940'),
+ $this->up1020_getOptionGroupLink('type_20130502151940'),
'Qualifications – Skill Categories' =>
- $this->getOptionGroupLink('category_of_skill_20130510015438'),
+ $this->up1020_getOptionGroupLink('category_of_skill_20130510015438'),
'Qualifications – Skill Levels' =>
- $this->getOptionGroupLink('level_of_skill_20130510015934'),
+ $this->up1020_getOptionGroupLink('level_of_skill_20130510015934'),
];
foreach ($childLinks as $itemName => $link) {
@@ -57,7 +57,7 @@ public function upgrade_1012() {
*
* @return string
*/
- private function getOptionGroupLink($groupName) {
+ private function up1020_getOptionGroupLink($groupName) {
return 'civicrm/admin/options/' . $groupName . '?reset=1';
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
index 5cde75d55d7..ca90607c164 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
@@ -7,15 +7,15 @@ trait CRM_HRLeaveAndAbsences_Upgrader_Step_1020 {
*
* @return bool
*/
- public function upgrade_1021() {
+ public function upgrade_1020() {
$params = ['return' => 'id', 'name' => 'leave_and_absences'];
$parentId = (int) civicrm_api3('Navigation', 'getvalue', $params);
civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -96]);
- $this->createNewLinks($parentId);
- $this->relabelExistingLinks($parentId);
- $this->addSeparators($parentId);
- $this->updateWeight($parentId);
+ $this->up1020_createNewLinks($parentId);
+ $this->up1020_relabelExistingLinks($parentId);
+ $this->up1020_addSeparators($parentId);
+ $this->up1020_updateWeight($parentId);
return TRUE;
}
@@ -25,7 +25,7 @@ public function upgrade_1021() {
*
* @param int $parentId
*/
- private function createNewLinks($parentId) {
+ private function up1020_createNewLinks($parentId) {
$permission = 'administer leave and absences';
$optionGroupLinks = [
'Sickness Reasons' => 'hrleaveandabsences_sickness_reason',
@@ -46,7 +46,7 @@ private function createNewLinks($parentId) {
*
* @param int $parentId
*/
- private function relabelExistingLinks($parentId) {
+ private function up1020_relabelExistingLinks($parentId) {
$nameToLabelMapping = [
'leave_and_absence_types' => ts('Leave Types'),
'leave_and_absence_periods' => ts('Leave Periods'),
@@ -67,7 +67,7 @@ private function relabelExistingLinks($parentId) {
*
* @param int $parentId
*/
- private function addSeparators($parentId) {
+ private function up1020_addSeparators($parentId) {
$itemsWithSeparators = [
'leave_and_absence_general_settings',
'Work Pattern Day Equivalents',
@@ -87,7 +87,7 @@ private function addSeparators($parentId) {
*
* @param int $parentId
*/
- private function updateWeight($parentId) {
+ private function up1020_updateWeight($parentId) {
$name = 'leave_and_absences_import';
$params = ['parent_id' => $parentId, 'name' => $name, 'return' => 'id'];
$id = (int) civicrm_api3('Navigation', 'getvalue', $params);
From f34c3e359db171f433fa768cfa1eb7ce464ee7f3 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 12:46:21 +0000
Subject: [PATCH 031/203] PCHR-3375: Don't recreate menu items if they exist
---
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 4836997b50d..41eda3dafbb 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1266,7 +1266,13 @@ private function createNavItem($name, $permission, $parentID, $params = []) {
'is_active' => 1,
], $params);
- return civicrm_api3('navigation', 'create', $params);
+ $existing = civicrm_api3('Navigation', 'get', $params);
+
+ if ($existing['count'] > 0) {
+ return array_shift($existing['values']);
+ }
+
+ return civicrm_api3('Navigation', 'create', $params);
}
/**
From f2f3747481f263495f95876b83257129c00610a4 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 12:52:43 +0000
Subject: [PATCH 032/203] PCHR-3375: Move flushing to make it clearer why it's
needed
---
.../CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
index ca90607c164..c19e6fe1141 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1020.php
@@ -13,6 +13,8 @@ public function upgrade_1020() {
civicrm_api3('Navigation', 'create', ['id' => $parentId, 'weight' => -96]);
$this->up1020_createNewLinks($parentId);
+ // we need to flush for new items to be recognized
+ CRM_Core_PseudoConstant::flush();
$this->up1020_relabelExistingLinks($parentId);
$this->up1020_addSeparators($parentId);
$this->up1020_updateWeight($parentId);
@@ -73,8 +75,6 @@ private function up1020_addSeparators($parentId) {
'Work Pattern Day Equivalents',
];
- CRM_Core_PseudoConstant::flush();
-
foreach ($itemsWithSeparators as $name) {
$params = ['parent_id' => $parentId, 'name' => $name, 'return' => 'id'];
$id = (int) civicrm_api3('Navigation', 'getvalue', $params);
From 6e5ee8c37d72b126e8873d4019c3e72dfd940ade Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 13:10:17 +0000
Subject: [PATCH 033/203] PCHR-3375: Handle case where multiple domains exist
Even if we don't have clients with multiple domains, it does exist in
the test database and tests fail if this is not handled.
---
com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php | 3 ++-
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 3 ++-
.../CRM/HRCore/Upgrader/Steps/1012.php | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
index 70663796e59..e9cd2b5ae5c 100644
--- a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
+++ b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
@@ -51,7 +51,8 @@ public function upgrade_1004() {
* @return bool
*/
public function upgrade_1005() {
- $params = ['return' => 'id', 'name' => 'Administer'];
+ $domain = CRM_Core_Config::domainID();
+ $params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
$permission = 'Access CiviCRM';
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 41eda3dafbb..0c5a8d48c03 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1214,7 +1214,8 @@ public function upgrade_1035() {
* @return bool
*/
public function upgrade_1036() {
- $params = ['return' => 'id', 'name' => 'Administer'];
+ $domain = CRM_Core_Config::domainID();
+ $params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
$permission = 'Access CiviCRM';
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index b19babc208e..b9eb3ea92e4 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -9,7 +9,8 @@ trait CRM_HRCore_Upgrader_Steps_1012 {
* @return bool
*/
public function upgrade_1012() {
- $params = ['return' => 'id', 'name' => 'Administer'];
+ $domain = CRM_Core_Config::domainID();
+ $params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
$permission = 'Access CiviCRM';
From 3537654ad2f3951b79a80a4b6c342e5921ac5701 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Thu, 8 Mar 2018 10:05:49 +0100
Subject: [PATCH 034/203] PCHR-3420: Hide options on localisation page
---
.../Hook/BuildForm/LocalisationPageFilter.php | 81 +++++++++++++++++++
uk.co.compucorp.civicrm.hrcore/hrcore.php | 3 +-
2 files changed, 83 insertions(+), 1 deletion(-)
create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php
new file mode 100644
index 00000000000..e18673cee0b
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php
@@ -0,0 +1,81 @@
+shouldHandle($formName)) {
+ return;
+ }
+
+ $this->filterLocalisationOptions($form);
+ }
+
+ /**
+ * Checks if the hook should be handled.
+ *
+ * @param string $formName
+ *
+ * @return bool
+ */
+ private function shouldHandle($formName) {
+ if ($formName == CRM_Admin_Form_Setting_Localization::class) {
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Hide options on localisation page if user does not have required permission
+ *
+ * @param CRM_Core_Form $form
+ */
+ private function filterLocalisationOptions($form) {
+ $canViewAllFields = CRM_Core_Permission::check('access root menu items and configurations ');
+ $settings = [
+ 'customTranslateFunction',
+ 'contact_default_language',
+ 'fieldSeparator',
+ 'inheritLocale',
+ 'lcMessages',
+ 'legacyEncoding',
+ 'monetaryThousandSeparator',
+ 'monetaryDecimalPoint',
+ 'moneyformat',
+ 'moneyvalueformat'
+ ];
+
+ if (! $canViewAllFields) {
+ $this->hideOptionLabels();
+ foreach ($settings as $setting) {
+ if ($form->elementExists($setting)) {
+ $form->freeze($setting);
+ }
+ }
+ }
+ }
+
+ /**
+ * Hide labels for frozen elements
+ */
+ private function hideOptionLabels() {
+ CRM_Core_Resources::singleton()->addStyle(
+ 'tr.crm-localization-form-block-lcMessages,
+ tr.crm-localization-form-block-inheritLocale,
+ tr.crm-localization-form-contact_default_language,
+ tr.crm-localization-form-block-monetaryThousandSeparator,
+ tr.crm-localization-form-block-monetaryDecimalPoint,
+ tr.crm-localization-form-block-moneyformat,
+ tr.crm-localization-form-block-moneyvalueformat,
+ tr.crm-localization-form-block-customTranslateFunction,
+ tr.crm-localization-form-block-legacyEncoding,
+ tr.crm-localization-form-block-fieldSeparator { display: none; }'
+ );
+ }
+
+}
diff --git a/uk.co.compucorp.civicrm.hrcore/hrcore.php b/uk.co.compucorp.civicrm.hrcore/hrcore.php
index 3ef44d449fe..45b4136ad54 100644
--- a/uk.co.compucorp.civicrm.hrcore/hrcore.php
+++ b/uk.co.compucorp.civicrm.hrcore/hrcore.php
@@ -110,12 +110,13 @@ function hrcore_civicrm_container($container) {
* Implements hook_civicrm_buildForm
*
* @param string $formName
- * @param object $form
+ * @param CRM_Core_Form $form
*/
function hrcore_civicrm_buildForm($formName, &$form) {
$listeners = [
new CRM_HRCore_Hook_BuildForm_ActivityFilterSelectFieldsModifier(),
new CRM_HRCore_Hook_BuildForm_ActivityLinksFilter(),
+ new CRM_HRCore_Hook_BuildForm_LocalisationPageFilter(),
];
foreach ($listeners as $currentListener) {
From c6ad4c259a00317873e752390014781fd4fa4098 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Mon, 12 Mar 2018 14:12:10 +0100
Subject: [PATCH 035/203] PCHR-3420: Code refactoring
---
.../Hook/BuildForm/LocalisationPageFilter.php | 54 ++++++++-----------
1 file changed, 21 insertions(+), 33 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php
index e18673cee0b..c14e136b384 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Hook/BuildForm/LocalisationPageFilter.php
@@ -1,6 +1,19 @@
hideOptionLabels();
- foreach ($settings as $setting) {
+ $hiddenOptionsStyle = "tr.crm-localization-form-contact_default_language";
+
+ foreach ($this->restrictedSettings as $setting) {
if ($form->elementExists($setting)) {
+ $hiddenOptionsStyle .= ", tr.crm-localization-form-block-$setting";
$form->freeze($setting);
}
}
- }
- }
- /**
- * Hide labels for frozen elements
- */
- private function hideOptionLabels() {
- CRM_Core_Resources::singleton()->addStyle(
- 'tr.crm-localization-form-block-lcMessages,
- tr.crm-localization-form-block-inheritLocale,
- tr.crm-localization-form-contact_default_language,
- tr.crm-localization-form-block-monetaryThousandSeparator,
- tr.crm-localization-form-block-monetaryDecimalPoint,
- tr.crm-localization-form-block-moneyformat,
- tr.crm-localization-form-block-moneyvalueformat,
- tr.crm-localization-form-block-customTranslateFunction,
- tr.crm-localization-form-block-legacyEncoding,
- tr.crm-localization-form-block-fieldSeparator { display: none; }'
- );
+ $hiddenOptionsStyle .= ' { display: none; }';
+ CRM_Core_Resources::singleton()->addStyle($hiddenOptionsStyle);
+ }
}
}
From d167894ba55ea440e39305ace02490ad8d77a989 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 15:01:54 +0000
Subject: [PATCH 036/203] PCHR-3375: Update method name to match trait
---
.../CRM/HRCore/Upgrader/Steps/1012.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index b9eb3ea92e4..2a5505118cc 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -26,21 +26,21 @@ public function upgrade_1012() {
$childLinks = [
'Prefixes' =>
- $this->up1020_getOptionGroupLink('individual_prefix'),
+ $this->up1012_getOptionGroupLink('individual_prefix'),
'Genders' =>
- $this->up1020_getOptionGroupLink('gender'),
+ $this->up1012_getOptionGroupLink('gender'),
'Emergency Contact Relationships' =>
- $this->up1020_getOptionGroupLink('relationship_with_employee_20150304120408'),
+ $this->up1012_getOptionGroupLink('relationship_with_employee_20150304120408'),
'Manager Types' =>
'civicrm/admin/reltype?reset=1',
'Career History' =>
- $this->up1020_getOptionGroupLink('occupation_type_20130617111138'),
+ $this->up1012_getOptionGroupLink('occupation_type_20130617111138'),
'Disability Types' =>
- $this->up1020_getOptionGroupLink('type_20130502151940'),
+ $this->up1012_getOptionGroupLink('type_20130502151940'),
'Qualifications – Skill Categories' =>
- $this->up1020_getOptionGroupLink('category_of_skill_20130510015438'),
+ $this->up1012_getOptionGroupLink('category_of_skill_20130510015438'),
'Qualifications – Skill Levels' =>
- $this->up1020_getOptionGroupLink('level_of_skill_20130510015934'),
+ $this->up1012_getOptionGroupLink('level_of_skill_20130510015934'),
];
foreach ($childLinks as $itemName => $link) {
@@ -58,7 +58,7 @@ public function upgrade_1012() {
*
* @return string
*/
- private function up1020_getOptionGroupLink($groupName) {
+ private function up1012_getOptionGroupLink($groupName) {
return 'civicrm/admin/options/' . $groupName . '?reset=1';
}
From 2471dc153751c65e7e313064b028e07468755135 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 16:51:51 +0000
Subject: [PATCH 037/203] PCHR-3375: Add custom fields shortcut
---
.../CRM/HRCore/Upgrader/Steps/1012.php | 30 ++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index 2a5505118cc..12732d559dd 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -13,6 +13,17 @@ public function upgrade_1012() {
$params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ $this->up1012_addOtherStaffDetailsSubmenu($administerId);
+ $this->up1012_addCustomFieldsShortcut($administerId);
+
+ return TRUE;
+ }
+
+ /**
+ * @param $administerId
+ * @throws CiviCRM_API3_Exception
+ */
+ private function up1012_addOtherStaffDetailsSubmenu($administerId) {
$permission = 'Access CiviCRM';
$parentName = 'Other Staff Details';
$parent = $this->up1012_createNavItem($parentName, $permission, $administerId);
@@ -47,8 +58,24 @@ public function upgrade_1012() {
$params = ['url' => $link];
$this->up1012_createNavItem($itemName, $permission, $parentId, $params);
}
+ }
- return TRUE;
+ /**
+ * Adds a shortcut to the edit custom groups + fields page
+ *
+ * @param int $administerId
+ */
+ private function up1012_addCustomFieldsShortcut($administerId) {
+ $result = $this->up1012_createNavItem(
+ 'Custom Fields',
+ 'administer CiviCRM',
+ $administerId,
+ ['url' => 'civicrm/admin/custom/group?reset=1']
+ );
+
+ // weight cannot be set when you're creating first time
+ $id = $result['id'];
+ civicrm_api3('Navigation', 'create', ['id' => $id, 'weight' => -95]);
}
/**
@@ -94,4 +121,5 @@ private function up1012_createNavItem(
return civicrm_api3('Navigation', 'create', $params);
}
+
}
From 9009d609968e3f633538a4c1effd752892d8cac6 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 18:07:54 +0000
Subject: [PATCH 038/203] PCHR-3376: Fix the permission name on existing items
Permissions are case sensitive and the permission used to create items
in PCHR_3375 uses the wrong case for "Access"
---
com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php | 2 +-
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 2 +-
.../CRM/HRCore/Upgrader/Steps/1012.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
index e9cd2b5ae5c..3e58b5465f2 100644
--- a/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
+++ b/com.civicrm.hrjobroles/CRM/Hrjobroles/Upgrader.php
@@ -55,7 +55,7 @@ public function upgrade_1005() {
$params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
- $permission = 'Access CiviCRM';
+ $permission = 'access CiviCRM';
$parent = $this->createNavItem('Job Roles', $permission, $administerId);
$parentId = $parent['id'];
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 0c5a8d48c03..2ecae3b9fff 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1218,7 +1218,7 @@ public function upgrade_1036() {
$params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
- $permission = 'Access CiviCRM';
+ $permission = 'access CiviCRM';
$parent = $this->createNavItem('Job Contract', $permission, $administerId);
$parentId = $parent['id'];
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index 12732d559dd..6175a9d3a1b 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -24,7 +24,7 @@ public function upgrade_1012() {
* @throws CiviCRM_API3_Exception
*/
private function up1012_addOtherStaffDetailsSubmenu($administerId) {
- $permission = 'Access CiviCRM';
+ $permission = 'access CiviCRM';
$parentName = 'Other Staff Details';
$parent = $this->up1012_createNavItem($parentName, $permission, $administerId);
$parentId = $parent['id'];
From 87201da7ec30e7b77130c2a96d9ea7c6193dab6e Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Mon, 12 Mar 2018 18:11:08 +0000
Subject: [PATCH 039/203] PCHR-3376: Update the existing permission on
"Administer" child items
To limit access to existing items on the "Administer" menu we set change
the permission from "administer CiviCRM" to "access root menu items and
configurations".
---
.../CRM/HRCore/Upgrader.php | 1 +
.../CRM/HRCore/Upgrader/Steps/1013.php | 60 +++++++++++++++++++
2 files changed, 61 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
index e194b80139f..2da53861be1 100755
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
@@ -20,6 +20,7 @@ class CRM_HRCore_Upgrader extends CRM_HRCore_Upgrader_Base {
use CRM_HRCore_Upgrader_Steps_1010;
use CRM_HRCore_Upgrader_Steps_1011;
use CRM_HRCore_Upgrader_Steps_1012;
+ use CRM_HRCore_Upgrader_Steps_1013;
/**
* @var array
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
new file mode 100644
index 00000000000..d203a23245a
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
@@ -0,0 +1,60 @@
+ 'id', 'name' => 'Administer', 'domain_id' => $domain];
+ $administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+
+ $this->up1013_replaceExistingAdministerItemsPermission($administerId);
+
+ return TRUE;
+ }
+
+ /**
+ * @param $administerId
+ * @throws CiviCRM_API3_Exception
+ */
+ private function up1013_replaceExistingAdministerItemsPermission($administerId) {
+ $allChildren = [];
+ $this->up1013_findAllChildElements($administerId, $allChildren);
+ $replacement = 'access root menu items and configurations';
+ $original = 'administer CiviCRM';
+
+ $exceptions = ['Custom Fields'];
+
+ foreach ($allChildren as $child) {
+ if (in_array($child['name'], $exceptions)) {
+ continue;
+ }
+
+ $permissions = CRM_Utils_Array::value('permission', $child);
+ $permissions = str_replace($original, $replacement, $permissions);
+ $params = ['id' => $child['id'], 'permission' => $permissions];
+ civicrm_api3('Navigation', 'create', $params);
+ }
+ }
+
+ /**
+ * Recursively search for all children of a given parent ID
+ *
+ * @param int $parentId
+ * @param array $allChildren
+ */
+ private function up1013_findAllChildElements($parentId, &$allChildren) {
+ $params = ['parent_id' => $parentId];
+ $children = civicrm_api3('Navigation', 'get', $params)['values'];
+ $allChildren = array_merge($allChildren, $children);
+
+ foreach ($children as $child) {
+ $this->up1013_findAllChildElements($child['id'], $allChildren);
+ }
+ }
+
+}
From 5170941a9373512489ba94d40c5c88c5479ba69c Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 13 Mar 2018 13:29:47 +0000
Subject: [PATCH 040/203] PCHR-3376: Add missing "Localise" link
---
.../CRM/HRCore/Upgrader/Steps/1012.php | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
index 6175a9d3a1b..4313fbaed5d 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1012.php
@@ -13,12 +13,31 @@ public function upgrade_1012() {
$params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ $this->up1012_addLocalisationShortcut($administerId);
$this->up1012_addOtherStaffDetailsSubmenu($administerId);
$this->up1012_addCustomFieldsShortcut($administerId);
return TRUE;
}
+ /**
+ * Adds a shortcut to the localization page
+ *
+ * @param int $administerId
+ */
+ private function up1012_addLocalisationShortcut($administerId) {
+ $result = $this->up1012_createNavItem(
+ 'Localise CiviCRM',
+ 'access CiviCRM',
+ $administerId,
+ ['url' => 'civicrm/admin/setting/localization?reset=1']
+ );
+
+ // weight cannot be set when you're creating first time
+ $id = $result['id'];
+ civicrm_api3('Navigation', 'create', ['id' => $id, 'weight' => -101]);
+ }
+
/**
* @param $administerId
* @throws CiviCRM_API3_Exception
From a0dba384e5cf8d57eb26a81b9b81410891ff7c68 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 13 Mar 2018 14:09:53 +0000
Subject: [PATCH 041/203] PCHR-3376: Fix wrong links
---
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 28 +++++++++++---------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 2ecae3b9fff..2e1581736d9 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1228,20 +1228,24 @@ public function upgrade_1036() {
// If we don't flush it will not recognize newly created parent_id
CRM_Core_PseudoConstant::flush();
- $optionGroupLinks = [
- 'Contract Types' => 'hrjc_contract_type',
- 'Normal Place of Work' => 'hrjc_location',
- 'Contract End Reasons' => 'hrjc_contract_end_reason',
- 'Contract Revision Reasons' => 'hrjc_revision_change_reason',
- 'Standard Full Time Hours' => 'hrjc_hours_type',
- 'Pay Scales' => 'hrjc_pay_grade',
- 'Benefits' => 'hrjc_benefit_type',
- 'Deductions' => 'hrjc_deduction_type',
- 'Insurance Plan Types' => 'hrjc_insurance_plantype',
+ // returns the link to an option group edit page
+ $optGroupLinker = function ($groupName) {
+ return 'civicrm/admin/options/' . $groupName . '?reset=1';
+ };
+
+ $childLinks = [
+ 'Contract Types' => $optGroupLinker('hrjc_contract_type'),
+ 'Normal Place of Work' => $optGroupLinker('hrjc_location'),
+ 'Contract End Reasons' => $optGroupLinker('hrjc_contract_end_reason'),
+ 'Contract Revision Reasons' => $optGroupLinker('hrjc_revision_change_reason'),
+ 'Standard Full Time Hours' => 'civicrm/hours_location',
+ 'Pay Scales' => 'civicrm/pay_scale',
+ 'Benefits' => $optGroupLinker('hrjc_benefit_name'),
+ 'Deductions' => $optGroupLinker('hrjc_deduction_name'),
+ 'Insurance Plan Types' => $optGroupLinker('hrjc_insurance_plantype'),
];
- foreach ($optionGroupLinks as $itemName => $optionGroup) {
- $link = 'civicrm/admin/options/' . $optionGroup . '?reset=1';
+ foreach ($childLinks as $itemName => $link) {
$this->createNavItem($itemName, $permission, $parentId, ['url' => $link]);
}
From db727d99efa7f22e14750f01ee58de17c686baf2 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 13 Mar 2018 14:17:02 +0000
Subject: [PATCH 042/203] PCHR-3376: Update docblock
---
.../CRM/HRCore/Upgrader/Steps/1013.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
index d203a23245a..f0604f9636c 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
@@ -18,8 +18,10 @@ public function upgrade_1013() {
}
/**
- * @param $administerId
- * @throws CiviCRM_API3_Exception
+ * Replaces all existing 'administer CiviCRM' permissions in the
+ * 'Administer' submenu with 'access root menu items and configurations'
+ *
+ * @param int $administerId
*/
private function up1013_replaceExistingAdministerItemsPermission($administerId) {
$allChildren = [];
From d43c3d216e0c2e344b55218792af42d7068ab537 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 13 Mar 2018 14:50:24 +0000
Subject: [PATCH 043/203] PCHR-3376: Fix error when running tests
---
.../CRM/HRCore/Upgrader/Steps/1013.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
index f0604f9636c..7127dd7c34d 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1013.php
@@ -12,6 +12,9 @@ public function upgrade_1013() {
$params = ['return' => 'id', 'name' => 'Administer', 'domain_id' => $domain];
$administerId = (int) civicrm_api3('Navigation', 'getvalue', $params);
+ // If running two consecutive upgraders, items from first are not found
+ CRM_Core_PseudoConstant::flush();
+
$this->up1013_replaceExistingAdministerItemsPermission($administerId);
return TRUE;
From e8d2cae487075a6cb8672fbbdec0f57d357b175c Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Tue, 13 Mar 2018 17:42:20 +0000
Subject: [PATCH 044/203] PCHR-3162: Re-add upgrader after merging staging
The filename had a conflict so I kept Tunbola's changes. This upgrader
was originally added by Samson.
---
.../CRM/HRCore/Upgrader.php | 1 +
.../CRM/HRCore/Upgrader/Steps/1014.php | 28 +++++++++++++++++++
2 files changed, 29 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
index 2da53861be1..abfce6b0897 100755
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader.php
@@ -21,6 +21,7 @@ class CRM_HRCore_Upgrader extends CRM_HRCore_Upgrader_Base {
use CRM_HRCore_Upgrader_Steps_1011;
use CRM_HRCore_Upgrader_Steps_1012;
use CRM_HRCore_Upgrader_Steps_1013;
+ use CRM_HRCore_Upgrader_Steps_1014;
/**
* @var array
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php
new file mode 100644
index 00000000000..f0f441c3fd6
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php
@@ -0,0 +1,28 @@
+
+ ['id'],
+ 'name' => 'Identify',
+ ]);
+
+ if ($result['id']) {
+ civicrm_api3('CustomGroup', 'create', [
+ 'id' => $result['id'],
+ 'is_reserved' => 1,
+ ]);
+ }
+
+ return TRUE;
+ }
+}
From 1b6f9a88e5afe20002846a633d33538210890540 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Wed, 14 Mar 2018 09:34:01 +0000
Subject: [PATCH 045/203] PCHR-3162: Fix upgrader number
After I copied over the upgrader I forgot to update the number in the
method, leading to a conflict
---
.../CRM/HRCore/Upgrader/Steps/1014.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php
index f0f441c3fd6..3093a8db73a 100644
--- a/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php
+++ b/uk.co.compucorp.civicrm.hrcore/CRM/HRCore/Upgrader/Steps/1014.php
@@ -10,7 +10,7 @@ trait CRM_HRCore_Upgrader_Steps_1014 {
*
* @return bool
*/
- public function upgrade_1011() {
+ public function upgrade_1014() {
$result = civicrm_api3('CustomGroup', 'get', [
'return' => ['id'],
'name' => 'Identify',
From 4eac009dad72706ba3705ad1e3b8725435da9e3f Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Wed, 14 Mar 2018 16:33:57 +0100
Subject: [PATCH 046/203] PCHR-3451: New option group work pattern change
---
.../CRM/HRLeaveAndAbsences/Upgrader.php | 1 +
.../HRLeaveAndAbsences/Upgrader/Step/1021.php | 42 +++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
index fd996daf1bf..9b9fd3058a4 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
@@ -26,6 +26,7 @@ class CRM_HRLeaveAndAbsences_Upgrader extends CRM_HRLeaveAndAbsences_Upgrader_Ba
use CRM_HRLeaveAndAbsences_Upgrader_Step_1018;
use CRM_HRLeaveAndAbsences_Upgrader_Step_1019;
use CRM_HRLeaveAndAbsences_Upgrader_Step_1020;
+ use CRM_HRLeaveAndAbsences_Upgrader_Step_1021;
/**
* A list of directories to be scanned for XML installation files
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
new file mode 100644
index 00000000000..9211f2fbf59
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
@@ -0,0 +1,42 @@
+ $groupName
+ ]);
+ if ($result['count'] > 0) {
+ return TRUE;
+ }
+
+ $groupValues = [
+ 'As per contract',
+ 'Change in contractual hours',
+ 'Change in contract type'
+ ];
+ $optionParams = [
+ 'name' => $groupName,
+ 'title' => 'Leave and Absence Work Pattern Change Reason',
+ 'is_active' => 1
+ ];
+ civicrm_api3('OptionGroup', 'create', $optionParams);
+ foreach ($groupValues as $value) {
+ $opValueParams = [
+ 'option_group_id' => $groupName,
+ 'name' => $value,
+ 'label' => $value,
+ ];
+ civicrm_api3('OptionValue', 'create', $opValueParams);
+ }
+ return TRUE;
+ }
+}
From c1ea6128721d7f4b375218ef7058e25f0a2101d3 Mon Sep 17 00:00:00 2001
From: Michael Devery
Date: Thu, 15 Mar 2018 10:31:30 +0000
Subject: [PATCH 047/203] PCHR-3162: Update label
---
hrjobcontract/CRM/Hrjobcontract/Upgrader.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
index 2e1581736d9..bbf8d939910 100755
--- a/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
+++ b/hrjobcontract/CRM/Hrjobcontract/Upgrader.php
@@ -1235,7 +1235,7 @@ public function upgrade_1036() {
$childLinks = [
'Contract Types' => $optGroupLinker('hrjc_contract_type'),
- 'Normal Place of Work' => $optGroupLinker('hrjc_location'),
+ 'Normal Places of Work' => $optGroupLinker('hrjc_location'),
'Contract End Reasons' => $optGroupLinker('hrjc_contract_end_reason'),
'Contract Revision Reasons' => $optGroupLinker('hrjc_revision_change_reason'),
'Standard Full Time Hours' => 'civicrm/hours_location',
From 9c50684782ece3ee08df557ccb404c3ba7f190e7 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Fri, 16 Mar 2018 06:05:56 +0100
Subject: [PATCH 048/203] PCHR-3451: Added work pattern change reason XML for
setup and updated references
---
.../DAO/ContactWorkPattern.php | 6 +--
.../HRLeaveAndAbsences/Upgrader/Step/1021.php | 33 +++---------
...ces_work_pattern_change_reason_install.xml | 52 +++++++++++++++++++
.../HRLeaveAndAbsences/ContactWorkPattern.xml | 2 +-
4 files changed, 62 insertions(+), 31 deletions(-)
create mode 100644 uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
index fd25c5fe6e2..bbf08516e2b 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
@@ -173,7 +173,7 @@ static function &fields() {
'name' => 'change_reason',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Change Reason') ,
- 'description' => 'One of the values of the Job Contract Revision Change Reason option group',
+ 'description' => 'One of the values of the Work Pattern Change Reasons option group',
'maxlength' => 512,
'size' => CRM_Utils_Type::HUGE,
'table_name' => 'civicrm_hrleaveandabsences_contact_work_pattern',
@@ -181,8 +181,8 @@ static function &fields() {
'bao' => 'CRM_HRLeaveAndAbsences_DAO_ContactWorkPattern',
'localizable' => 0,
'pseudoconstant' => array(
- 'optionGroupName' => 'hrjc_revision_change_reason',
- 'optionEditPath' => 'civicrm/admin/options/hrjc_revision_change_reason',
+ 'optionGroupName' => 'hrleaveandabsences_work_pattern_change_reason',
+ 'optionEditPath' => 'civicrm/admin/options/hrleaveandabsences_work_pattern_change_reason',
)
) ,
);
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
index 9211f2fbf59..49dc2326372 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
@@ -10,33 +10,12 @@ trait CRM_HRLeaveAndAbsences_Upgrader_Step_1021 {
* @return bool
*/
public function upgrade_1021() {
- $groupName = 'hrleaveandabsences_work_pattern_change_reason';
- $result = civicrm_api3('OptionGroup', 'get', [
- 'name' => $groupName
- ]);
- if ($result['count'] > 0) {
- return TRUE;
- }
-
- $groupValues = [
- 'As per contract',
- 'Change in contractual hours',
- 'Change in contract type'
- ];
- $optionParams = [
- 'name' => $groupName,
- 'title' => 'Leave and Absence Work Pattern Change Reason',
- 'is_active' => 1
- ];
- civicrm_api3('OptionGroup', 'create', $optionParams);
- foreach ($groupValues as $value) {
- $opValueParams = [
- 'option_group_id' => $groupName,
- 'name' => $value,
- 'label' => $value,
- ];
- civicrm_api3('OptionValue', 'create', $opValueParams);
- }
+ require_once 'CRM/Utils/Migrate/Import.php';
+ $import = new CRM_Utils_Migrate_Import();
+ $extension = 'uk.co.compucorp.civicrm.hrleaveandabsences';
+ $file = 'xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml';
+
+ $import->run(CRM_Core_Resources::singleton()->getPath($extension, $file));
return TRUE;
}
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml
new file mode 100644
index 00000000000..cca90fa0782
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+ hrleaveandabsences_work_pattern_change_reason
+ Leave and Absence Work Pattern Change Reason
+ 1
+ 1
+
+
+
+
+
+ As per contract
+ 1
+ as_per_contract
+ 1
+ 0
+ 0
+ 1
+ 1
+ hrleaveandabsences_work_pattern_change_reason
+
+
+
+ Change in contractual hours
+ 2
+ change_in_contractual_hours
+ 0
+ 2
+ 0
+ 1
+ 1
+ hrleaveandabsences_work_pattern_change_reason
+
+
+
+ Change in contractual type
+ 3
+ change_in_contractual_type
+ 0
+ 3
+ 0
+ 1
+ 1
+ hrleaveandabsences_work_pattern_change_reason
+
+
+
+
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/schema/CRM/HRLeaveAndAbsences/ContactWorkPattern.xml b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/schema/CRM/HRLeaveAndAbsences/ContactWorkPattern.xml
index 1e0f18cd1be..cf51391c881 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/schema/CRM/HRLeaveAndAbsences/ContactWorkPattern.xml
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/schema/CRM/HRLeaveAndAbsences/ContactWorkPattern.xml
@@ -73,7 +73,7 @@
One of the values of the Job Contract Revision Change Reason option group
4.4
- hrjc_revision_change_reason
+ hrleaveandabsences_work_pattern_change_reason
From 50a6b80347493147d9bcacd9dbe09bbe1f7e7163 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Fri, 16 Mar 2018 12:23:01 +0100
Subject: [PATCH 049/203] PCHR-3451: Code refactoring
---
.../CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php | 4 ++--
.../CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php | 3 +--
...son_install.xml => work_pattern_change_reason_install.xml} | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
rename uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/{leave_and_absences_work_pattern_change_reason_install.xml => work_pattern_change_reason_install.xml} (95%)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
index bbf08516e2b..54698a2c44a 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
@@ -181,8 +181,8 @@ static function &fields() {
'bao' => 'CRM_HRLeaveAndAbsences_DAO_ContactWorkPattern',
'localizable' => 0,
'pseudoconstant' => array(
- 'optionGroupName' => 'hrleaveandabsences_work_pattern_change_reason',
- 'optionEditPath' => 'civicrm/admin/options/hrleaveandabsences_work_pattern_change_reason',
+ 'optionGroupName' => 'hrjc_revision_change_reason',
+ 'optionEditPath' => 'civicrm/admin/options/hrjc_revision_change_reason',
)
) ,
);
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
index 49dc2326372..ab6deb84992 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1021.php
@@ -10,10 +10,9 @@ trait CRM_HRLeaveAndAbsences_Upgrader_Step_1021 {
* @return bool
*/
public function upgrade_1021() {
- require_once 'CRM/Utils/Migrate/Import.php';
$import = new CRM_Utils_Migrate_Import();
$extension = 'uk.co.compucorp.civicrm.hrleaveandabsences';
- $file = 'xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml';
+ $file = 'xml/option_groups/work_pattern_change_reason_install.xml';
$import->run(CRM_Core_Resources::singleton()->getPath($extension, $file));
return TRUE;
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
similarity index 95%
rename from uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml
rename to uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
index cca90fa0782..74e6d20bd1b 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/leave_and_absences_work_pattern_change_reason_install.xml
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
@@ -5,7 +5,7 @@
hrleaveandabsences_work_pattern_change_reason
- Leave and Absence Work Pattern Change Reason
+ Work Pattern Change Reason
1
1
From 0169930f02d73efd91a3566ddcaddf24926e71dc Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Mon, 19 Mar 2018 18:44:01 +0100
Subject: [PATCH 050/203] PCHR-3451: Frontend update and test integration
---
.../DAO/ContactWorkPattern.php | 8 ++--
...tab-custom-work-pattern-modal.component.js | 10 ++---
...ustom-work-pattern-modal.component.spec.js | 8 +++-
.../test/mocks/data/option-group.data.js | 37 +++++++++++++++++++
.../work_pattern_change_reason_install.xml | 8 ++--
5 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
index 54698a2c44a..5c0a0e1be47 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/DAO/ContactWorkPattern.php
@@ -30,7 +30,7 @@
*
* Generated from xml/schema/CRM/HRLeaveAndAbsences/ContactWorkPattern.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:dd2637660ac3be9bdaeb2955643974ae)
+ * (GenCodeChecksum:ded89fd6039ec891ba28b56d418a3179)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
@@ -173,7 +173,7 @@ static function &fields() {
'name' => 'change_reason',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Change Reason') ,
- 'description' => 'One of the values of the Work Pattern Change Reasons option group',
+ 'description' => 'One of the values of the Job Contract Revision Change Reason option group',
'maxlength' => 512,
'size' => CRM_Utils_Type::HUGE,
'table_name' => 'civicrm_hrleaveandabsences_contact_work_pattern',
@@ -181,8 +181,8 @@ static function &fields() {
'bao' => 'CRM_HRLeaveAndAbsences_DAO_ContactWorkPattern',
'localizable' => 0,
'pseudoconstant' => array(
- 'optionGroupName' => 'hrjc_revision_change_reason',
- 'optionEditPath' => 'civicrm/admin/options/hrjc_revision_change_reason',
+ 'optionGroupName' => 'hrleaveandabsences_work_pattern_change_reason',
+ 'optionEditPath' => 'civicrm/admin/options/hrleaveandabsences_work_pattern_change_reason',
)
) ,
);
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
index bb35ad96785..4a4bde2c0c7 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
@@ -46,9 +46,9 @@ define([
loadWorkPatterns(),
loadJobContractRevisionChangeReasons()
])
- .finally(function () {
- vm.loading.content = false;
- });
+ .finally(function () {
+ vm.loading.content = false;
+ });
})();
/**
@@ -107,12 +107,12 @@ define([
}
/**
- * Loads the Job Contract Revision Change Reasons and indexes by `value`
+ * Loads the Leave and Absences Work Pattern Change Reason and indexes by `value`
*
* @return {Promise}
*/
function loadJobContractRevisionChangeReasons () {
- return OptionGroup.valuesOf('hrjc_revision_change_reason')
+ return OptionGroup.valuesOf('hrleaveandabsences_work_pattern_change_reason')
.then(function (reasons) {
vm.changeReasons = reasons;
});
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js
index e06748e339d..4a2bad6c9ee 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js
@@ -34,7 +34,7 @@
spyOn($log, 'debug');
spyOn(WorkPatternAPI, 'get').and.callThrough();
spyOn(OptionGroup, 'valuesOf').and.callFake(function () {
- return $q.resolve(optionGroupMock.getCollection('hrjc_revision_change_reason'));
+ return $q.resolve(optionGroupMock.getCollection('hrleaveandabsences_work_pattern_change_reason'));
});
compileComponent();
@@ -49,8 +49,12 @@
});
describe('init()', function () {
+ it('calls the valueOf with hrleaveandabsences_work_pattern_change_reason', function () {
+ expect(OptionGroup.valuesOf).toHaveBeenCalledWith('hrleaveandabsences_work_pattern_change_reason');
+ });
+
it('loads change reasons', function () {
- expect(controller.changeReasons).toEqual(optionGroupMock.getCollection('hrjc_revision_change_reason'));
+ expect(controller.changeReasons).toEqual(optionGroupMock.getCollection('hrleaveandabsences_work_pattern_change_reason'));
});
it('loads work patterns', function () {
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
index fce76f3e0f2..8ffbcb8efb9 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
@@ -863,6 +863,43 @@ define([
'is_reserved': '0',
'is_active': '1'
}],
+ hrleaveandabsences_work_pattern_change_reason: [{
+ 'id': '1314',
+ 'option_group_id': '196',
+ 'label': 'As per contract',
+ 'value': '1',
+ 'name': 'as_per_contract',
+ 'filter': '0',
+ 'is_default': '1',
+ 'weight': '1',
+ 'is_optgroup': '0',
+ 'is_reserved': '0',
+ 'is_active': '1'
+ }, {
+ 'id': '1315',
+ 'option_group_id': '196',
+ 'label': 'Change in contractual hours',
+ 'value': '2',
+ 'name': 'change_in_contractual_hours',
+ 'filter': '0',
+ 'is_default': '0',
+ 'weight': '2',
+ 'is_optgroup': '0',
+ 'is_reserved': '0',
+ 'is_active': '1'
+ }, {
+ 'id': '1316',
+ 'option_group_id': '196',
+ 'label': 'Change in contractual type',
+ 'value': '3',
+ 'name': 'change_in_contractual_type',
+ 'filter': '0',
+ 'is_default': '0',
+ 'weight': '3',
+ 'is_optgroup': '0',
+ 'is_reserved': '0',
+ 'is_active': '1'
+ }],
safe_file_extension: [{
'id': '296',
'option_group_id': '30',
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
index 74e6d20bd1b..e30adffdf3a 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
@@ -17,9 +17,9 @@
1
as_per_contract
1
- 0
+ 1
0
- 1
+ 0
1
hrleaveandabsences_work_pattern_change_reason
@@ -31,7 +31,7 @@
0
2
0
- 1
+ 0
1
hrleaveandabsences_work_pattern_change_reason
@@ -43,7 +43,7 @@
0
3
0
- 1
+ 0
1
hrleaveandabsences_work_pattern_change_reason
From 8a7dfe7297d0f0a9995690678ba008fda524d08d Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Tue, 20 Mar 2018 11:29:48 +0000
Subject: [PATCH 051/203] PCHR-3451: Code refactoring
---
.../js/angular/dist/absence-tab.min.js | 4 ++--
.../absence-tab-custom-work-pattern-modal.component.js | 4 ++--
.../absence-tab-custom-work-pattern-modal.component.spec.js | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
index 319ab39ee97..e7dcdbb2cad 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
@@ -1,5 +1,5 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/modules/shared-settings",["common/angular"],function(t){return t.module("leave-absences.settings",[]).constant("shared-settings",{attachmentToken:e.vars.leaveAndAbsences.attachmentToken,debug:e.debug,managerPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/",sharedPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/shared/",serverDateFormat:"YYYY-MM-DD",serverDateTimeFormat:"YYYY-MM-DD HH:mm:ss",permissions:{admin:{access:"access leave and absences",administer:"administer leave and absences"},ssp:{access:"access leave and absences in ssp",manage:"manage leave and absences in ssp"}},fileUploader:{queueLimit:10},statusNames:{approved:"approved",adminApproved:"admin_approved",awaitingApproval:"awaiting_approval",moreInformationRequired:"more_information_required",rejected:"rejected",cancelled:"cancelled"}})})}(CRM),define("leave-absences/shared/modules/apis",["common/angular","common/modules/apis","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.apis",["common.apis","leave-absences.settings"])}),define("leave-absences/shared/modules/models-instances",["common/angular","common/models/instances/instance","common/modules/services","common/modules/models","common/services/check-permissions","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models.instances",["common.models","common.models.instances","common.services","leave-absences.settings"])}),define("leave-absences/shared/modules/models",["common/angular","common/modules/models","common/modules/services","leave-absences/shared/modules/apis","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models",["common.models","common.services","leave-absences.apis","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,o){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,s,r){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),r=e.assign({},r,{absence_type_id:a,date:t(s).format(o.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",r).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,o,s,r){return t.debug("AbsenceType"),a.extend({all:function(e){return s.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return s.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return s.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return o.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,o,s,r){return this.sendPOST("ContactWorkPattern","create",e.assign({},r,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:o,change_reason:s})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,o,s){return t.debug("WorkPatternAPI.getCalendar",n,a,o,s),this.sendGET("WorkPattern","getcalendar",e.assign({},s,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:o}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,o){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),o).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,o,s,r){function i(t,n){return u().then(function(a){var o=this.days[c(t).valueOf()];return!!o&&e.find(a,function(e){return e.name===n}).value===o.type}.bind(this))}function c(e){return t(e,s.serverDateFormat).clone()}function u(){return l=l||r.valuesOf("hrleaveandabsences_work_day_type")}var l;return o.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[c(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,o){return t.debug("Calendar"),n.extend({get:function(n,s,r,i){return t.debug("Calendar.get"),a.getCalendar(n,s,r,i).then(function(t){var a=t.values.map(function(e){return o.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function o(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(o),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,o,s){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,o,"getLeaveBalances",s)}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,o,s){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return o.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return o.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),s.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,o,s,r){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,o,s,"getFull",r)),i.promise},balanceChangeByAbsenceType:function(t,n,o,s){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var r=a.defer();t&&n||r.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:o?{IN:o}:null,public_holiday:s||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){r.resolve(e.values)}),r.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var o=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?o.reject(t(e.values).map().flatten().value()):o.resolve(e.values)}),o.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,o,s,r,i,c){function u(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return c.all({id:this.type_id}).then(c.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function m(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function f(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return o.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),o=a.breakdown.length>1,s=e.first(e.values(a.breakdown)),r=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(s.date),o&&this.getWorkDayForDate(r.date)]).then(function(t){return s.amount=t[0].time_from?Math.min(this.from_date_amount,f(t[0])):0,o&&(r.amount=t[1].time_from?Math.min(this.to_date_amount,f(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return r.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return u.call(this,s.statusNames.cancelled)},approve:function(){return u.call(this,s.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return u.call(this,s.statusNames.rejected)},sendBack:function(){return u.call(this,s.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),m.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,s.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,s.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,s.statusNames.cancelled)},isRejected:function(){return d.call(this,s.statusNames.rejected)},isSentBack:function(){return d.call(this,s.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(s.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,o,s,r){return n.all(this.processFilters(e),t,o,s,r).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,o){return n.balanceChangeByAbsenceType(e,t,a,o)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/instances/work-pattern.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("WorkPatternInstance",["$log","ModelInstance",function(e,t){return e.debug("WorkPatternInstance"),t.extend({})}])}),define("leave-absences/shared/models/work-pattern.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/work-pattern.instance"],function(e,t){"use strict";t.factory("WorkPattern",["$log","Model","WorkPatternAPI","WorkPatternInstance",function(t,n,a,o){return t.debug("WorkPattern"),n.extend({assignWorkPattern:function(e,t,n,o,s,r){return a.assignWorkPattern(e,t,n,o,s,r)},default:function(){return a.get({is_default:!0}).then(function(t){return o.init(e.first(t),!0)})},unassignWorkPattern:function(e){return a.unassignWorkPattern(e)},workPatternsOf:function(e,t,n){return a.workPatternsOf(e,t,n).then(function(e){return e.map(function(e){return o.init(e,!0)})})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,o,s,r,i){function c(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(v.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(v.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function u(){return{loadContacts:function(){var e=v.filters.userSettings.assignedTo.type;return m(e).then(function(e){v.lookupContacts=e}).then(function(){return"me"!==e?c():a.resolve(null)}).then(function(e){return v.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return o.all(f(),null,"display_name").then(function(e){return e.list})}function d(){return h?a.resolve(h):r.all()}function m(e){return"me"===e?o.leaveManagees(v.contactId):"unassigned"===e?o.leaveManagees(void 0,{unassigned:!0}):o.all().then(function(e){return e.list})}function f(){return{department:v.filters.userSettings.department?v.filters.userSettings.department.value:null,level_type:v.filters.userSettings.level_type?v.filters.userSettings.level_type.value:null,location:v.filters.userSettings.location?v.filters.userSettings.location.value:null,region:v.filters.userSettings.region?v.filters.userSettings.region.value:null,id:{IN:v.filters.userSettings.contact?[v.filters.userSettings.contact.id]:v.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",["When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,u()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:r.contactId}).leaveManagees().then(function(e){r.lookupContacts=e}).then(o)}}}function o(){return t.all(s(),null,"display_name").then(function(e){return e.list})}function s(){return{department:r.filters.userSettings.department?r.filters.userSettings.department.value:null,level_type:r.filters.userSettings.level_type?r.filters.userSettings.level_type.value:null,location:r.filters.userSettings.location?r.filters.userSettings.location.value:null,region:r.filters.userSettings.region?r.filters.userSettings.region.value:null,id:{IN:r.filters.userSettings.contact?[r.filters.userSettings.contact.id]:r.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var r;return{init:function(e){return r=e,r.showContactName=!0,r.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function o(a,o,s,r,i,c,u,l,d,m){function f(){for(var e=[],t=n(O.selectedPeriod.start_date).clone().startOf("month"),a=n(O.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(A(t)),t.add(1,"month");O.months=e}function p(){r.$new().$watch(function(){return O.selectedMonths},function(t,n){null===n||e.equals(t,n)||w()})}function h(e){O.injectMonths=!0,L("injected").then(function(){w(e)}).then(function(){O.loading.calendar=!1})}function v(){S=a("LeaveCalendar"+t.capitalize(M)+"Controller").init(O)}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function g(){return c.all().then(function(e){O.absencePeriods=t.sortBy(e,"start_date"),O.selectedPeriod=t.find(O.absencePeriods,function(e){return!!e.current})}).then(f).then(I)}function _(){return u.all().then(u.loadCalculationUnits)}function y(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return S.loadContacts().then(function(e){O.contacts=e})}function C(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){O.filters.optionValues.regions=e.hrjc_region,O.filters.optionValues.locations=e.hrjc_location,O.filters.optionValues.levelTypes=e.hrjc_level_type,O.filters.optionValues.departments=e.hrjc_department})}function P(){return l.all()}function D(){return o.all([_(),P(),y()]).then(function(e){O.supportData.absenceTypes=e[0],O.supportData.publicHolidays=e[1],O.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,O.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,O.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,O.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function R(){var e=o.resolve();return O.injectMonths&&(e=L("destroyed"),O.injectMonths=!1),e}function A(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function T(e){e=t.includes(["contacts","period"],e)?e:"period",o.resolve().then(function(){O.loading.calendar=!0}).then(R).then("period"===e?f:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function w(e){var n=O.selectedMonths.length?O.months.filter(function(e){return t.includes(O.selectedMonths,e.index)}):O.months;r.$emit("LeaveCalendar::showMonths",n,!!e)}function I(){O.selectedMonths=[n().month()]}function k(){return O.roleOverride?o.resolve().then(function(){M=O.roleOverride}):o.all([m(i.permissions.admin.administer),m(i.permissions.ssp.manage)]).then(function(e){M=e[0]?"admin":e[1]?"manager":"staff"})}function L(e){return o(function(n){var a=0,o=r.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===O.months.length&&(o(),n())})})}s.debug("Component: leave-calendar");var S,M,O=this;O.absencePeriods=[],O.contacts=[],O.contactIdsToReduceTo=null,O.injectMonths=!1,O.months=[],O.selectedMonths=null,O.selectedPeriod=null,O.showContactName=!1,O.showFilters=!1,O.supportData={},O.loading={calendar:!0,page:!0},O.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},O.labelPeriod=b,O.refresh=T,function(){k().then(p).then(v).then(R).then(g).then(function(){return o.all([q(),D()])}).then(function(){return O.showFilters?C():t.noop}).then(function(){h()}).then(function(){O.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",o]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,o){"use strict";function s(){y.calculationUnit=r(y.supportData.calculationUnits,"value",b.calculation_unit)}function r(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(y.contactData.leaveRequest.from_date).isSame(y.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+y.calculationUnit.name+"-on-"+e+"-tooltip"}function c(){b=r(y.supportData.absenceTypes,"id",y.contactData.leaveRequest.type_id),y.contactData.leaveRequest["type_id.title"]=b.title}function u(){"days"===y.calculationUnit.name&&(g=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.from_date_type),_=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.to_date_type),y.contactData.leaveRequest["from_date_type.label"]=g.label,y.contactData.leaveRequest["to_date_type.label"]=_.label)}function l(e,t,n,a,s){e.stopPropagation(),o.openModal(t,n,a,s)}function d(){y.dates.from=new Date(y.contactData.leaveRequest.from_date),y.dates.to=new Date(y.contactData.leaveRequest.to_date)}function m(){y.contactData.isAccruedTOIL?y.label="AT":"days"===y.calculationUnit.name?f():p()}function f(){y.label=y.contactData.isAM?"AM":y.contactData.isPM?"PM":""}function p(){var e=t(y.contactData.leaveRequest.from_date).isSame(y.date,"day"),n=t(y.contactData.leaveRequest.to_date).isSame(y.date,"day");y.label=e?t(y.contactData.leaveRequest.from_date).format("HH:mm"):n?t(y.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){y.tooltipTemplate=y.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){y.contactData&&y.contactData.leaveRequest&&(c(),s(),u(),m(),d(),h())
-})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){F.push(o.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",u)),F.push(i.subscribe("LeaveRequest::edit",B)),F.push(i.subscribe("LeaveRequest::updatedByManager",B)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){j=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!j)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var j=!1,F=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function j(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(j("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!j("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=j,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||j("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:F(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[F(m.statusNames.rejected),F(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{
-in:[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)]}})}function L(){return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function j(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function F(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=j,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==F())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return j($e.getStatusFromValue($e.request.status_id).name)}function j(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function F(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():j("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=F(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrjc_revision_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrjc_revision_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,t=C.changeLogRows.length-1;e>=0;){
+})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){j.push(o.$on("LeaveCalendar::showMonths",x)),j.push(i.subscribe("LeaveRequest::new",u)),j.push(i.subscribe("LeaveRequest::edit",B)),j.push(i.subscribe("LeaveRequest::updatedByManager",B)),j.push(i.subscribe("LeaveRequest::delete",h)),j.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){F=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),j.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!F)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var F=!1,j=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function F(e){return pe.request.request_type===e}function j(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(F("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!F("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=F,pe.isNotWorkingDay=j,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||F("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:j(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[j(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[j(m.statusNames.awaitingApproval),j(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[j(m.statusNames.rejected),j(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{
+in:[j(m.statusNames.awaitingApproval),j(m.statusNames.moreInformationRequired)]}})}function L(){return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function F(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function j(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=F,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==j())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=j();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return F($e.getStatusFromValue($e.request.status_id).name)}function F(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function j(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():F("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=j(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrleaveandabsences_work_pattern_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrjc_revision_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,t=C.changeLogRows.length-1;e>=0;){
var n=C.changeLogRows[e],a=C.changeLogRows[t];n.entitlements.forEach(function(e,t){var n=a.entitlements[t];e.comment===n.comment&&delete e.comment}),e--,t--}}function _(e){var t,n,a=C.changeLogRows[e];u(a,function(o,s,r){o.comment&&(t=s.concat(o).concat(r),n={date:a.date.clone(),entitlements:t},n.highlightedEntitlement=o,p(n,e++))}),y(e)}function y(e){C.changeLogRows.splice(e,1)}var q=[],C=this;C.absencePeriod=null,C.absenceTypes=[],C.changeLogRows=[],C.loading={component:!0},function(){h().then(v).then(b).then(i).then(c).then(g).then(f).finally(function(){C.loading.component=!1})}()}n.component("annualEntitlementChangeLog",{bindings:{contactId:"<",periodId:"<",dismissModal:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlement-change-log.html"}],controllerAs:"changeLog",controller:a}),a.$inject=["AbsencePeriod","AbsenceType","Entitlement","OptionGroup","shared-settings"]}),function(e){define("leave-absences/absence-tab/components/annual-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contact"],function(t,n,a){function o(a,o,s,r,i,c,u,l,d){function m(){P.absencePeriods=t.chain(P.absencePeriods).filter(function(e){return t.find(q,function(t){return t.period_id===e.id})}).sortBy(function(e){return-n(e.start_date).valueOf()}).value()}function f(){P.absenceTypes=t.filter(P.absenceTypes,function(e){return t.find(q,function(t){return t.type_id===e.id})})}function p(t){var n=e.url("civicrm/contact/view",{cid:P.contactId,selectedChild:"absence"});return e.url("civicrm/admin/leaveandabsences/periods/manage_entitlements",{id:t,cid:P.contactId,returnUrl:n})}function h(){return c.all().then(function(e){P.absencePeriods=e})}function v(){var e=t.uniq(t.map(q,function(e){return e.editor_id}));return l.all({id:{IN:e}}).then(function(e){C=t.indexBy(e.list,"contact_id")})}function b(){return u.all({contact_id:P.contactId}).then(function(e){q=e})}function g(e){r.open({appendTo:s.children().eq(0),templateUrl:"annual-entitlement-change-log-modal",controller:["$uibModalInstance",function(t){this.contactId=P.contactId,this.dismiss=t.dismiss,this.periodId=e}],controllerAs:"modal"})}function _(){P.absencePeriods=t.map(P.absencePeriods,function(e){var n=t.map(P.absenceTypes,function(n){var a=t.find(q,function(t){return t.type_id===n.id&&t.period_id===e.id});return a?{amount:a.value,calculation_unit:n.calculation_unit_name,comment:a.comment?{message:a.comment,author_name:C[a.editor_id].display_name,date:a.created_date}:null}:null});return{id:e.id,title:e.title,entitlements:n}})}function y(e){var t=e.message+"Last updated: By: "+e.author_name+" Date: "+n.utc(e.date).local().format("DD/M/YYYY HH:mm")+" ";d.info("Calculation comment:",t)}a.debug("Component: annual-entitlements");var q=[],C=[],P=this;P.absencePeriods=[],P.loading={absencePeriods:!0},P.getEditEntitlementsPageURL=p,P.openAnnualEntitlementChangeLog=g,P.showComment=y,function(){b().then(v).then(h).then(m).then(f).then(_).finally(function(){P.loading.absencePeriods=!1})}()}a.component("annualEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlements.html"}],controllerAs:"entitlements",controller:o}),o.$inject=["$log","$q","$rootElement","$uibModal","AbsenceType","AbsencePeriod","Entitlement","Contact","notificationService"]})}(CRM),define("leave-absences/absence-tab/components/contract-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r,i){function c(){m.absenceTypes=e.filter(m.absenceTypes,function(t){return e.find(m.contracts,function(n){return e.find(n.info.leave,function(e){return e.leave_type===t.id})})})}function u(e){var n=o.DATE_FORMAT.toUpperCase();return e?t(e).format(n):""}function l(){return r.all({contact_id:m.contactId}).then(function(e){m.contracts=e})}function d(){m.contracts=e.sortBy(m.contracts,function(e){return t(e.info.details.period_start_date)}).map(function(t){var n=t.info,a=n.details,o=e.map(m.absenceTypes,function(t){var a=e.filter(n.leave,function(e){return e.leave_type===t.id})[0];return{amount:a?a.leave_amount:"",calculation_unit:t.calculation_unit_name}});return{position:a.position,start_date:u(a.period_start_date),end_date:u(a.period_end_date),absences:o}})}n.debug("Component: contract-entitlements");var m=this;m.contracts=[],m.loading={contracts:!0},function(){i.getDateFormat().then(l).then(c).then(d).finally(function(){m.loading.contracts=!1})}()}n.component("contractEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/contract-entitlements.html"}],controllerAs:"entitlements",controller:a}),a.$inject=["$log","$q","HR_settings","AbsenceType","Contract","DateFormat"]}),function(e){define("leave-absences/absence-tab/modules/settings",["common/angular"],function(t){return t.module("absence-tab.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.contactId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/absence-tab/"})})}(CRM),define("leave-absences/absence-tab/modules/config",["common/angular","leave-absences/absence-tab/modules/settings"],function(e){return e.module("absence-tab.config",["absence-tab.settings"]).config(["$resourceProvider","$httpProvider","$logProvider","settings",function(e,t,n,a){n.debugEnabled(a.debug),e.defaults.stripTrailingSlashes=!1,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}])}),define("leave-absences/absence-tab/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/modules/directives","common/services/check-permissions","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/absence-tab/components/absence-tab-container.component","leave-absences/absence-tab/components/absence-tab-entitlements.component","leave-absences/absence-tab/components/absence-tab-work-patterns.component","leave-absences/absence-tab/components/annual-entitlement-change-log.component","leave-absences/absence-tab/components/annual-entitlements.component","leave-absences/absence-tab/components/contract-entitlements.component","leave-absences/absence-tab/modules/config"],function(e){return e.module("absence-tab",["ngResource","ui.bootstrap","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.services","common.mocks","leave-absences.settings","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","absence-tab.config","absence-tab.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/absence-tab":n+"/absence-tab"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/absence-tab/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("absenceTabReady"):function(){var e=document.createEvent("Event");return e.initEvent("absenceTabReady",!0,!0),e}())})})}(CRM,require),define("absence-tab",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
index 4a4bde2c0c7..a3ca4a9bf35 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
@@ -107,9 +107,9 @@ define([
}
/**
- * Loads the Leave and Absences Work Pattern Change Reason and indexes by `value`
+ * Loads the Leave and Absences Work Pattern Change Reasons and indexes by `value`
*
- * @return {Promise}
+ * @return {Promise} resolves with {Array}
*/
function loadJobContractRevisionChangeReasons () {
return OptionGroup.valuesOf('hrleaveandabsences_work_pattern_change_reason')
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js
index 4a2bad6c9ee..ab1035522cb 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-custom-work-pattern-modal.component.spec.js
@@ -49,7 +49,7 @@
});
describe('init()', function () {
- it('calls the valueOf with hrleaveandabsences_work_pattern_change_reason', function () {
+ it('fetches values of the Work Pattern Change Reason option group', function () {
expect(OptionGroup.valuesOf).toHaveBeenCalledWith('hrleaveandabsences_work_pattern_change_reason');
});
From 8ff23948eb7ecec56fcd06d8e1bf22db98526623 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Tue, 20 Mar 2018 16:39:54 +0100
Subject: [PATCH 052/203] PCHR-3451: PR Feedback
---
.../js/angular/dist/absence-tab.min.js | 4 +-
...tab-custom-work-pattern-modal.component.js | 2 +-
.../absence-tab-work-patterns.component.js | 6 +--
...bsence-tab-work-patterns.component.spec.js | 8 +++-
.../test/mocks/data/option-group.data.js | 37 -------------------
5 files changed, 12 insertions(+), 45 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
index e7dcdbb2cad..cbdfd8d1e16 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
@@ -1,5 +1,5 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/modules/shared-settings",["common/angular"],function(t){return t.module("leave-absences.settings",[]).constant("shared-settings",{attachmentToken:e.vars.leaveAndAbsences.attachmentToken,debug:e.debug,managerPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/",sharedPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/shared/",serverDateFormat:"YYYY-MM-DD",serverDateTimeFormat:"YYYY-MM-DD HH:mm:ss",permissions:{admin:{access:"access leave and absences",administer:"administer leave and absences"},ssp:{access:"access leave and absences in ssp",manage:"manage leave and absences in ssp"}},fileUploader:{queueLimit:10},statusNames:{approved:"approved",adminApproved:"admin_approved",awaitingApproval:"awaiting_approval",moreInformationRequired:"more_information_required",rejected:"rejected",cancelled:"cancelled"}})})}(CRM),define("leave-absences/shared/modules/apis",["common/angular","common/modules/apis","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.apis",["common.apis","leave-absences.settings"])}),define("leave-absences/shared/modules/models-instances",["common/angular","common/models/instances/instance","common/modules/services","common/modules/models","common/services/check-permissions","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models.instances",["common.models","common.models.instances","common.services","leave-absences.settings"])}),define("leave-absences/shared/modules/models",["common/angular","common/modules/models","common/modules/services","leave-absences/shared/modules/apis","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models",["common.models","common.services","leave-absences.apis","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,o){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,s,r){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),r=e.assign({},r,{absence_type_id:a,date:t(s).format(o.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",r).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,o,s,r){return t.debug("AbsenceType"),a.extend({all:function(e){return s.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return s.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return s.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return o.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,o,s,r){return this.sendPOST("ContactWorkPattern","create",e.assign({},r,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:o,change_reason:s})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,o,s){return t.debug("WorkPatternAPI.getCalendar",n,a,o,s),this.sendGET("WorkPattern","getcalendar",e.assign({},s,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:o}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,o){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),o).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,o,s,r){function i(t,n){return u().then(function(a){var o=this.days[c(t).valueOf()];return!!o&&e.find(a,function(e){return e.name===n}).value===o.type}.bind(this))}function c(e){return t(e,s.serverDateFormat).clone()}function u(){return l=l||r.valuesOf("hrleaveandabsences_work_day_type")}var l;return o.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[c(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,o){return t.debug("Calendar"),n.extend({get:function(n,s,r,i){return t.debug("Calendar.get"),a.getCalendar(n,s,r,i).then(function(t){var a=t.values.map(function(e){return o.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function o(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(o),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,o,s){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,o,"getLeaveBalances",s)}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,o,s){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return o.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return o.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),s.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,o,s,r){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,o,s,"getFull",r)),i.promise},balanceChangeByAbsenceType:function(t,n,o,s){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var r=a.defer();t&&n||r.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:o?{IN:o}:null,public_holiday:s||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){r.resolve(e.values)}),r.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var o=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?o.reject(t(e.values).map().flatten().value()):o.resolve(e.values)}),o.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,o,s,r,i,c){function u(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return c.all({id:this.type_id}).then(c.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function m(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function f(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return o.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),o=a.breakdown.length>1,s=e.first(e.values(a.breakdown)),r=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(s.date),o&&this.getWorkDayForDate(r.date)]).then(function(t){return s.amount=t[0].time_from?Math.min(this.from_date_amount,f(t[0])):0,o&&(r.amount=t[1].time_from?Math.min(this.to_date_amount,f(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return r.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return u.call(this,s.statusNames.cancelled)},approve:function(){return u.call(this,s.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return u.call(this,s.statusNames.rejected)},sendBack:function(){return u.call(this,s.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),m.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,s.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,s.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,s.statusNames.cancelled)},isRejected:function(){return d.call(this,s.statusNames.rejected)},isSentBack:function(){return d.call(this,s.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(s.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,o,s,r){return n.all(this.processFilters(e),t,o,s,r).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,o){return n.balanceChangeByAbsenceType(e,t,a,o)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/instances/work-pattern.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("WorkPatternInstance",["$log","ModelInstance",function(e,t){return e.debug("WorkPatternInstance"),t.extend({})}])}),define("leave-absences/shared/models/work-pattern.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/work-pattern.instance"],function(e,t){"use strict";t.factory("WorkPattern",["$log","Model","WorkPatternAPI","WorkPatternInstance",function(t,n,a,o){return t.debug("WorkPattern"),n.extend({assignWorkPattern:function(e,t,n,o,s,r){return a.assignWorkPattern(e,t,n,o,s,r)},default:function(){return a.get({is_default:!0}).then(function(t){return o.init(e.first(t),!0)})},unassignWorkPattern:function(e){return a.unassignWorkPattern(e)},workPatternsOf:function(e,t,n){return a.workPatternsOf(e,t,n).then(function(e){return e.map(function(e){return o.init(e,!0)})})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,o,s,r,i){function c(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(v.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(v.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function u(){return{loadContacts:function(){var e=v.filters.userSettings.assignedTo.type;return m(e).then(function(e){v.lookupContacts=e}).then(function(){return"me"!==e?c():a.resolve(null)}).then(function(e){return v.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return o.all(f(),null,"display_name").then(function(e){return e.list})}function d(){return h?a.resolve(h):r.all()}function m(e){return"me"===e?o.leaveManagees(v.contactId):"unassigned"===e?o.leaveManagees(void 0,{unassigned:!0}):o.all().then(function(e){return e.list})}function f(){return{department:v.filters.userSettings.department?v.filters.userSettings.department.value:null,level_type:v.filters.userSettings.level_type?v.filters.userSettings.level_type.value:null,location:v.filters.userSettings.location?v.filters.userSettings.location.value:null,region:v.filters.userSettings.region?v.filters.userSettings.region.value:null,id:{IN:v.filters.userSettings.contact?[v.filters.userSettings.contact.id]:v.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",["When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,u()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:r.contactId}).leaveManagees().then(function(e){r.lookupContacts=e}).then(o)}}}function o(){return t.all(s(),null,"display_name").then(function(e){return e.list})}function s(){return{department:r.filters.userSettings.department?r.filters.userSettings.department.value:null,level_type:r.filters.userSettings.level_type?r.filters.userSettings.level_type.value:null,location:r.filters.userSettings.location?r.filters.userSettings.location.value:null,region:r.filters.userSettings.region?r.filters.userSettings.region.value:null,id:{IN:r.filters.userSettings.contact?[r.filters.userSettings.contact.id]:r.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var r;return{init:function(e){return r=e,r.showContactName=!0,r.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function o(a,o,s,r,i,c,u,l,d,m){function f(){for(var e=[],t=n(O.selectedPeriod.start_date).clone().startOf("month"),a=n(O.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(A(t)),t.add(1,"month");O.months=e}function p(){r.$new().$watch(function(){return O.selectedMonths},function(t,n){null===n||e.equals(t,n)||w()})}function h(e){O.injectMonths=!0,L("injected").then(function(){w(e)}).then(function(){O.loading.calendar=!1})}function v(){S=a("LeaveCalendar"+t.capitalize(M)+"Controller").init(O)}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function g(){return c.all().then(function(e){O.absencePeriods=t.sortBy(e,"start_date"),O.selectedPeriod=t.find(O.absencePeriods,function(e){return!!e.current})}).then(f).then(I)}function _(){return u.all().then(u.loadCalculationUnits)}function y(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return S.loadContacts().then(function(e){O.contacts=e})}function C(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){O.filters.optionValues.regions=e.hrjc_region,O.filters.optionValues.locations=e.hrjc_location,O.filters.optionValues.levelTypes=e.hrjc_level_type,O.filters.optionValues.departments=e.hrjc_department})}function P(){return l.all()}function D(){return o.all([_(),P(),y()]).then(function(e){O.supportData.absenceTypes=e[0],O.supportData.publicHolidays=e[1],O.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,O.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,O.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,O.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function R(){var e=o.resolve();return O.injectMonths&&(e=L("destroyed"),O.injectMonths=!1),e}function A(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function T(e){e=t.includes(["contacts","period"],e)?e:"period",o.resolve().then(function(){O.loading.calendar=!0}).then(R).then("period"===e?f:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function w(e){var n=O.selectedMonths.length?O.months.filter(function(e){return t.includes(O.selectedMonths,e.index)}):O.months;r.$emit("LeaveCalendar::showMonths",n,!!e)}function I(){O.selectedMonths=[n().month()]}function k(){return O.roleOverride?o.resolve().then(function(){M=O.roleOverride}):o.all([m(i.permissions.admin.administer),m(i.permissions.ssp.manage)]).then(function(e){M=e[0]?"admin":e[1]?"manager":"staff"})}function L(e){return o(function(n){var a=0,o=r.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===O.months.length&&(o(),n())})})}s.debug("Component: leave-calendar");var S,M,O=this;O.absencePeriods=[],O.contacts=[],O.contactIdsToReduceTo=null,O.injectMonths=!1,O.months=[],O.selectedMonths=null,O.selectedPeriod=null,O.showContactName=!1,O.showFilters=!1,O.supportData={},O.loading={calendar:!0,page:!0},O.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},O.labelPeriod=b,O.refresh=T,function(){k().then(p).then(v).then(R).then(g).then(function(){return o.all([q(),D()])}).then(function(){return O.showFilters?C():t.noop}).then(function(){h()}).then(function(){O.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",o]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,o){"use strict";function s(){y.calculationUnit=r(y.supportData.calculationUnits,"value",b.calculation_unit)}function r(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(y.contactData.leaveRequest.from_date).isSame(y.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+y.calculationUnit.name+"-on-"+e+"-tooltip"}function c(){b=r(y.supportData.absenceTypes,"id",y.contactData.leaveRequest.type_id),y.contactData.leaveRequest["type_id.title"]=b.title}function u(){"days"===y.calculationUnit.name&&(g=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.from_date_type),_=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.to_date_type),y.contactData.leaveRequest["from_date_type.label"]=g.label,y.contactData.leaveRequest["to_date_type.label"]=_.label)}function l(e,t,n,a,s){e.stopPropagation(),o.openModal(t,n,a,s)}function d(){y.dates.from=new Date(y.contactData.leaveRequest.from_date),y.dates.to=new Date(y.contactData.leaveRequest.to_date)}function m(){y.contactData.isAccruedTOIL?y.label="AT":"days"===y.calculationUnit.name?f():p()}function f(){y.label=y.contactData.isAM?"AM":y.contactData.isPM?"PM":""}function p(){var e=t(y.contactData.leaveRequest.from_date).isSame(y.date,"day"),n=t(y.contactData.leaveRequest.to_date).isSame(y.date,"day");y.label=e?t(y.contactData.leaveRequest.from_date).format("HH:mm"):n?t(y.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){y.tooltipTemplate=y.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){y.contactData&&y.contactData.leaveRequest&&(c(),s(),u(),m(),d(),h())
})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){j.push(o.$on("LeaveCalendar::showMonths",x)),j.push(i.subscribe("LeaveRequest::new",u)),j.push(i.subscribe("LeaveRequest::edit",B)),j.push(i.subscribe("LeaveRequest::updatedByManager",B)),j.push(i.subscribe("LeaveRequest::delete",h)),j.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){F=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),j.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!F)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var F=!1,j=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function F(e){return pe.request.request_type===e}function j(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(F("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!F("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=F,pe.isNotWorkingDay=j,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||F("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:j(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[j(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[j(m.statusNames.awaitingApproval),j(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[j(m.statusNames.rejected),j(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{
-in:[j(m.statusNames.awaitingApproval),j(m.statusNames.moreInformationRequired)]}})}function L(){return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function F(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function j(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=F,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==j())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=j();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return F($e.getStatusFromValue($e.request.status_id).name)}function F(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function j(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():F("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=j(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrleaveandabsences_work_pattern_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrjc_revision_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,t=C.changeLogRows.length-1;e>=0;){
-var n=C.changeLogRows[e],a=C.changeLogRows[t];n.entitlements.forEach(function(e,t){var n=a.entitlements[t];e.comment===n.comment&&delete e.comment}),e--,t--}}function _(e){var t,n,a=C.changeLogRows[e];u(a,function(o,s,r){o.comment&&(t=s.concat(o).concat(r),n={date:a.date.clone(),entitlements:t},n.highlightedEntitlement=o,p(n,e++))}),y(e)}function y(e){C.changeLogRows.splice(e,1)}var q=[],C=this;C.absencePeriod=null,C.absenceTypes=[],C.changeLogRows=[],C.loading={component:!0},function(){h().then(v).then(b).then(i).then(c).then(g).then(f).finally(function(){C.loading.component=!1})}()}n.component("annualEntitlementChangeLog",{bindings:{contactId:"<",periodId:"<",dismissModal:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlement-change-log.html"}],controllerAs:"changeLog",controller:a}),a.$inject=["AbsencePeriod","AbsenceType","Entitlement","OptionGroup","shared-settings"]}),function(e){define("leave-absences/absence-tab/components/annual-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contact"],function(t,n,a){function o(a,o,s,r,i,c,u,l,d){function m(){P.absencePeriods=t.chain(P.absencePeriods).filter(function(e){return t.find(q,function(t){return t.period_id===e.id})}).sortBy(function(e){return-n(e.start_date).valueOf()}).value()}function f(){P.absenceTypes=t.filter(P.absenceTypes,function(e){return t.find(q,function(t){return t.type_id===e.id})})}function p(t){var n=e.url("civicrm/contact/view",{cid:P.contactId,selectedChild:"absence"});return e.url("civicrm/admin/leaveandabsences/periods/manage_entitlements",{id:t,cid:P.contactId,returnUrl:n})}function h(){return c.all().then(function(e){P.absencePeriods=e})}function v(){var e=t.uniq(t.map(q,function(e){return e.editor_id}));return l.all({id:{IN:e}}).then(function(e){C=t.indexBy(e.list,"contact_id")})}function b(){return u.all({contact_id:P.contactId}).then(function(e){q=e})}function g(e){r.open({appendTo:s.children().eq(0),templateUrl:"annual-entitlement-change-log-modal",controller:["$uibModalInstance",function(t){this.contactId=P.contactId,this.dismiss=t.dismiss,this.periodId=e}],controllerAs:"modal"})}function _(){P.absencePeriods=t.map(P.absencePeriods,function(e){var n=t.map(P.absenceTypes,function(n){var a=t.find(q,function(t){return t.type_id===n.id&&t.period_id===e.id});return a?{amount:a.value,calculation_unit:n.calculation_unit_name,comment:a.comment?{message:a.comment,author_name:C[a.editor_id].display_name,date:a.created_date}:null}:null});return{id:e.id,title:e.title,entitlements:n}})}function y(e){var t=e.message+"Last updated: By: "+e.author_name+" Date: "+n.utc(e.date).local().format("DD/M/YYYY HH:mm")+" ";d.info("Calculation comment:",t)}a.debug("Component: annual-entitlements");var q=[],C=[],P=this;P.absencePeriods=[],P.loading={absencePeriods:!0},P.getEditEntitlementsPageURL=p,P.openAnnualEntitlementChangeLog=g,P.showComment=y,function(){b().then(v).then(h).then(m).then(f).then(_).finally(function(){P.loading.absencePeriods=!1})}()}a.component("annualEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlements.html"}],controllerAs:"entitlements",controller:o}),o.$inject=["$log","$q","$rootElement","$uibModal","AbsenceType","AbsencePeriod","Entitlement","Contact","notificationService"]})}(CRM),define("leave-absences/absence-tab/components/contract-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r,i){function c(){m.absenceTypes=e.filter(m.absenceTypes,function(t){return e.find(m.contracts,function(n){return e.find(n.info.leave,function(e){return e.leave_type===t.id})})})}function u(e){var n=o.DATE_FORMAT.toUpperCase();return e?t(e).format(n):""}function l(){return r.all({contact_id:m.contactId}).then(function(e){m.contracts=e})}function d(){m.contracts=e.sortBy(m.contracts,function(e){return t(e.info.details.period_start_date)}).map(function(t){var n=t.info,a=n.details,o=e.map(m.absenceTypes,function(t){var a=e.filter(n.leave,function(e){return e.leave_type===t.id})[0];return{amount:a?a.leave_amount:"",calculation_unit:t.calculation_unit_name}});return{position:a.position,start_date:u(a.period_start_date),end_date:u(a.period_end_date),absences:o}})}n.debug("Component: contract-entitlements");var m=this;m.contracts=[],m.loading={contracts:!0},function(){i.getDateFormat().then(l).then(c).then(d).finally(function(){m.loading.contracts=!1})}()}n.component("contractEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/contract-entitlements.html"}],controllerAs:"entitlements",controller:a}),a.$inject=["$log","$q","HR_settings","AbsenceType","Contract","DateFormat"]}),function(e){define("leave-absences/absence-tab/modules/settings",["common/angular"],function(t){return t.module("absence-tab.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.contactId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/absence-tab/"})})}(CRM),define("leave-absences/absence-tab/modules/config",["common/angular","leave-absences/absence-tab/modules/settings"],function(e){return e.module("absence-tab.config",["absence-tab.settings"]).config(["$resourceProvider","$httpProvider","$logProvider","settings",function(e,t,n,a){n.debugEnabled(a.debug),e.defaults.stripTrailingSlashes=!1,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}])}),define("leave-absences/absence-tab/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/modules/directives","common/services/check-permissions","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/absence-tab/components/absence-tab-container.component","leave-absences/absence-tab/components/absence-tab-entitlements.component","leave-absences/absence-tab/components/absence-tab-work-patterns.component","leave-absences/absence-tab/components/annual-entitlement-change-log.component","leave-absences/absence-tab/components/annual-entitlements.component","leave-absences/absence-tab/components/contract-entitlements.component","leave-absences/absence-tab/modules/config"],function(e){return e.module("absence-tab",["ngResource","ui.bootstrap","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.services","common.mocks","leave-absences.settings","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","absence-tab.config","absence-tab.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/absence-tab":n+"/absence-tab"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/absence-tab/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("absenceTabReady"):function(){var e=document.createEvent("Event");return e.initEvent("absenceTabReady",!0,!0),e}())})})}(CRM,require),define("absence-tab",function(){});
+in:[j(m.statusNames.awaitingApproval),j(m.statusNames.moreInformationRequired)]}})}function L(){return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function F(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function j(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=F,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==j())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=j();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return F($e.getStatusFromValue($e.request.status_id).name)}function F(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function j(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():F("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=j(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrleaveandabsences_work_pattern_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrleaveandabsences_work_pattern_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,
+t=C.changeLogRows.length-1;e>=0;){var n=C.changeLogRows[e],a=C.changeLogRows[t];n.entitlements.forEach(function(e,t){var n=a.entitlements[t];e.comment===n.comment&&delete e.comment}),e--,t--}}function _(e){var t,n,a=C.changeLogRows[e];u(a,function(o,s,r){o.comment&&(t=s.concat(o).concat(r),n={date:a.date.clone(),entitlements:t},n.highlightedEntitlement=o,p(n,e++))}),y(e)}function y(e){C.changeLogRows.splice(e,1)}var q=[],C=this;C.absencePeriod=null,C.absenceTypes=[],C.changeLogRows=[],C.loading={component:!0},function(){h().then(v).then(b).then(i).then(c).then(g).then(f).finally(function(){C.loading.component=!1})}()}n.component("annualEntitlementChangeLog",{bindings:{contactId:"<",periodId:"<",dismissModal:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlement-change-log.html"}],controllerAs:"changeLog",controller:a}),a.$inject=["AbsencePeriod","AbsenceType","Entitlement","OptionGroup","shared-settings"]}),function(e){define("leave-absences/absence-tab/components/annual-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contact"],function(t,n,a){function o(a,o,s,r,i,c,u,l,d){function m(){P.absencePeriods=t.chain(P.absencePeriods).filter(function(e){return t.find(q,function(t){return t.period_id===e.id})}).sortBy(function(e){return-n(e.start_date).valueOf()}).value()}function f(){P.absenceTypes=t.filter(P.absenceTypes,function(e){return t.find(q,function(t){return t.type_id===e.id})})}function p(t){var n=e.url("civicrm/contact/view",{cid:P.contactId,selectedChild:"absence"});return e.url("civicrm/admin/leaveandabsences/periods/manage_entitlements",{id:t,cid:P.contactId,returnUrl:n})}function h(){return c.all().then(function(e){P.absencePeriods=e})}function v(){var e=t.uniq(t.map(q,function(e){return e.editor_id}));return l.all({id:{IN:e}}).then(function(e){C=t.indexBy(e.list,"contact_id")})}function b(){return u.all({contact_id:P.contactId}).then(function(e){q=e})}function g(e){r.open({appendTo:s.children().eq(0),templateUrl:"annual-entitlement-change-log-modal",controller:["$uibModalInstance",function(t){this.contactId=P.contactId,this.dismiss=t.dismiss,this.periodId=e}],controllerAs:"modal"})}function _(){P.absencePeriods=t.map(P.absencePeriods,function(e){var n=t.map(P.absenceTypes,function(n){var a=t.find(q,function(t){return t.type_id===n.id&&t.period_id===e.id});return a?{amount:a.value,calculation_unit:n.calculation_unit_name,comment:a.comment?{message:a.comment,author_name:C[a.editor_id].display_name,date:a.created_date}:null}:null});return{id:e.id,title:e.title,entitlements:n}})}function y(e){var t=e.message+"Last updated: By: "+e.author_name+" Date: "+n.utc(e.date).local().format("DD/M/YYYY HH:mm")+" ";d.info("Calculation comment:",t)}a.debug("Component: annual-entitlements");var q=[],C=[],P=this;P.absencePeriods=[],P.loading={absencePeriods:!0},P.getEditEntitlementsPageURL=p,P.openAnnualEntitlementChangeLog=g,P.showComment=y,function(){b().then(v).then(h).then(m).then(f).then(_).finally(function(){P.loading.absencePeriods=!1})}()}a.component("annualEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlements.html"}],controllerAs:"entitlements",controller:o}),o.$inject=["$log","$q","$rootElement","$uibModal","AbsenceType","AbsencePeriod","Entitlement","Contact","notificationService"]})}(CRM),define("leave-absences/absence-tab/components/contract-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r,i){function c(){m.absenceTypes=e.filter(m.absenceTypes,function(t){return e.find(m.contracts,function(n){return e.find(n.info.leave,function(e){return e.leave_type===t.id})})})}function u(e){var n=o.DATE_FORMAT.toUpperCase();return e?t(e).format(n):""}function l(){return r.all({contact_id:m.contactId}).then(function(e){m.contracts=e})}function d(){m.contracts=e.sortBy(m.contracts,function(e){return t(e.info.details.period_start_date)}).map(function(t){var n=t.info,a=n.details,o=e.map(m.absenceTypes,function(t){var a=e.filter(n.leave,function(e){return e.leave_type===t.id})[0];return{amount:a?a.leave_amount:"",calculation_unit:t.calculation_unit_name}});return{position:a.position,start_date:u(a.period_start_date),end_date:u(a.period_end_date),absences:o}})}n.debug("Component: contract-entitlements");var m=this;m.contracts=[],m.loading={contracts:!0},function(){i.getDateFormat().then(l).then(c).then(d).finally(function(){m.loading.contracts=!1})}()}n.component("contractEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/contract-entitlements.html"}],controllerAs:"entitlements",controller:a}),a.$inject=["$log","$q","HR_settings","AbsenceType","Contract","DateFormat"]}),function(e){define("leave-absences/absence-tab/modules/settings",["common/angular"],function(t){return t.module("absence-tab.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.contactId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/absence-tab/"})})}(CRM),define("leave-absences/absence-tab/modules/config",["common/angular","leave-absences/absence-tab/modules/settings"],function(e){return e.module("absence-tab.config",["absence-tab.settings"]).config(["$resourceProvider","$httpProvider","$logProvider","settings",function(e,t,n,a){n.debugEnabled(a.debug),e.defaults.stripTrailingSlashes=!1,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}])}),define("leave-absences/absence-tab/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/modules/directives","common/services/check-permissions","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/absence-tab/components/absence-tab-container.component","leave-absences/absence-tab/components/absence-tab-entitlements.component","leave-absences/absence-tab/components/absence-tab-work-patterns.component","leave-absences/absence-tab/components/annual-entitlement-change-log.component","leave-absences/absence-tab/components/annual-entitlements.component","leave-absences/absence-tab/components/contract-entitlements.component","leave-absences/absence-tab/modules/config"],function(e){return e.module("absence-tab",["ngResource","ui.bootstrap","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.services","common.mocks","leave-absences.settings","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","absence-tab.config","absence-tab.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/absence-tab":n+"/absence-tab"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/absence-tab/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("absenceTabReady"):function(){var e=document.createEvent("Event");return e.initEvent("absenceTabReady",!0,!0),e}())})})}(CRM,require),define("absence-tab",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
index a3ca4a9bf35..d24c0f46db8 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component.js
@@ -107,7 +107,7 @@ define([
}
/**
- * Loads the Leave and Absences Work Pattern Change Reasons and indexes by `value`
+ * Loads the Leave and Absences Work Pattern Change Reasons
*
* @return {Promise} resolves with {Array}
*/
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-work-patterns.component.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-work-patterns.component.js
index dfdb479e816..8d20a053a16 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-work-patterns.component.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/absence-tab/components/absence-tab-work-patterns.component.js
@@ -104,12 +104,12 @@ define([
}
/**
- * Loads the Job Contract Revision Change Reasons and indexes by `value`
+ * Loads the Leave and Absences Work Pattern Change Reasons
*
- * @return {Promise}
+ * @return {Promise} resolves with {Array}
*/
function loadJobContractRevisionChangeReasons () {
- return OptionGroup.valuesOf('hrjc_revision_change_reason')
+ return OptionGroup.valuesOf('hrleaveandabsences_work_pattern_change_reason')
.then(function (reasons) {
changeReasons = _.indexBy(reasons, 'value');
});
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-work-patterns.component.spec.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-work-patterns.component.spec.js
index 4a3c1d3b660..bf1befc94ff 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-work-patterns.component.spec.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/absence-tab/components/absence-tab-work-patterns.component.spec.js
@@ -34,7 +34,7 @@
WorkPattern = _WorkPattern_;
spyOn(OptionGroup, 'valuesOf').and.callFake(function () {
- return $q.resolve(optionGroupMock.getCollection('hrjc_revision_change_reason'));
+ return $q.resolve(optionGroupMock.getCollection('hrleaveandabsences_work_pattern_change_reason'));
});
spyOn($log, 'debug');
@@ -47,13 +47,17 @@
describe('init()', function () {
describe('when custom Work patterns are present', function () {
+ it('fetches values of the Work Pattern Change Reason option group', function () {
+ expect(OptionGroup.valuesOf).toHaveBeenCalledWith('hrleaveandabsences_work_pattern_change_reason');
+ });
+
it('Loads custom Work patterns', function () {
expect(controller.customWorkPatterns.length).toEqual(workPatternData.workPatternsOf.values.length);
});
it('Assign correct change reason label', function () {
_.each(controller.customWorkPatterns, function (customWorkpattern) {
- var changeReasonLabel = optionGroupMock.getCollection('hrjc_revision_change_reason').find(function (reason) {
+ var changeReasonLabel = optionGroupMock.getCollection('hrleaveandabsences_work_pattern_change_reason').find(function (reason) {
return customWorkpattern.change_reason === reason.value;
}).label;
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
index 8ffbcb8efb9..484b091fcb0 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
@@ -826,43 +826,6 @@ define([
'is_active': '1'
}
],
- hrjc_revision_change_reason: [{
- 'id': '938',
- 'option_group_id': '110',
- 'label': 'Promotion',
- 'value': '1',
- 'name': 'Promotion',
- 'filter': '0',
- 'is_default': '0',
- 'weight': '1',
- 'is_optgroup': '0',
- 'is_reserved': '0',
- 'is_active': '1'
- }, {
- 'id': '939',
- 'option_group_id': '110',
- 'label': 'Increment',
- 'value': '2',
- 'name': 'Increment',
- 'filter': '0',
- 'is_default': '0',
- 'weight': '2',
- 'is_optgroup': '0',
- 'is_reserved': '0',
- 'is_active': '1'
- }, {
- 'id': '940',
- 'option_group_id': '110',
- 'label': 'Disciplinary',
- 'value': '3',
- 'name': 'Disciplinary',
- 'filter': '0',
- 'is_default': '0',
- 'weight': '3',
- 'is_optgroup': '0',
- 'is_reserved': '0',
- 'is_active': '1'
- }],
hrleaveandabsences_work_pattern_change_reason: [{
'id': '1314',
'option_group_id': '196',
From 81a0a551a8a20ed43cf00bfc9d14df7037994006 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Thu, 22 Mar 2018 09:40:03 +0100
Subject: [PATCH 053/203] PCHR-3451: Typo correction
---
.../js/angular/test/mocks/data/option-group.data.js | 4 ++--
.../xml/option_groups/work_pattern_change_reason_install.xml | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
index 484b091fcb0..8f29872897e 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/mocks/data/option-group.data.js
@@ -853,9 +853,9 @@ define([
}, {
'id': '1316',
'option_group_id': '196',
- 'label': 'Change in contractual type',
+ 'label': 'Change in contract type',
'value': '3',
- 'name': 'change_in_contractual_type',
+ 'name': 'change_in_contract_type',
'filter': '0',
'is_default': '0',
'weight': '3',
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
index e30adffdf3a..611be1a0d4b 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/xml/option_groups/work_pattern_change_reason_install.xml
@@ -37,9 +37,9 @@
- Change in contractual type
+ Change in contract type
3
- change_in_contractual_type
+ change_in_contract_type
0
3
0
From 3061414f26be20a62916c5a5cf5e851bbd37388e Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Fri, 23 Mar 2018 10:24:45 +0100
Subject: [PATCH 054/203] PCHR-3460: Add tool icon to edit job role options
---
.../views/include/add_new_role.html | 125 +++++++++++------
.../views/include/job_role_panel.html | 128 ++++++++++++------
2 files changed, 167 insertions(+), 86 deletions(-)
diff --git a/com.civicrm.hrjobroles/views/include/add_new_role.html b/com.civicrm.hrjobroles/views/include/add_new_role.html
index 049a9cef5f1..411c09dfa6e 100755
--- a/com.civicrm.hrjobroles/views/include/add_new_role.html
+++ b/com.civicrm.hrjobroles/views/include/add_new_role.html
@@ -85,63 +85,104 @@
diff --git a/com.civicrm.hrjobroles/views/include/job_role_panel.html b/com.civicrm.hrjobroles/views/include/job_role_panel.html
index 07be3feac3d..f2b61df5eb3 100755
--- a/com.civicrm.hrjobroles/views/include/job_role_panel.html
+++ b/com.civicrm.hrjobroles/views/include/job_role_panel.html
@@ -158,17 +158,27 @@
{{jobroles.LocationsData[jobroles.editData[job_roles_data.id]['location']]['title'] || '-'}}
-
- {{$select.selected.value.title}}
-
-
-
-
+
@@ -181,17 +191,27 @@
{{jobroles.RegionsData[jobroles.editData[job_roles_data.id]['region']]['title'] || '-'}}
-
- {{$select.selected.value.title}}
-
-
-
-
+
@@ -204,17 +224,27 @@
{{jobroles.DepartmentsData[jobroles.editData[job_roles_data.id]['department']]['title'] || '-'}}
-
- {{$select.selected.value.title}}
-
-
-
-
+
@@ -227,17 +257,27 @@
{{jobroles.LevelsData[jobroles.editData[job_roles_data.id]['level']]['title'] || '-'}}
-
- {{$select.selected.value.title}}
-
-
-
-
+
From 25d1ada0b616b6b1aa9869202c6c3d185793011f Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Mon, 19 Mar 2018 14:39:37 +0000
Subject: [PATCH 055/203] PCHR-3426: Fix partial name
---
...nt-change-log.scss => _annual-entitlement-change-log.scss} | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
rename uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/{annual-entitlement-change-log.scss => _annual-entitlement-change-log.scss} (52%)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/annual-entitlement-change-log.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_annual-entitlement-change-log.scss
similarity index 52%
rename from uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/annual-entitlement-change-log.scss
rename to uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_annual-entitlement-change-log.scss
index 45ba34906cc..988e40700a8 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/annual-entitlement-change-log.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_annual-entitlement-change-log.scss
@@ -1,9 +1,9 @@
.annual-entitlement-change-log-component {
- table thead td {
+ thead td {
min-width: 100px;
}
- table thead td.annual-entitlement-change-log-component__comments {
+ thead .annual-entitlement-change-log-component__comments {
min-width: 300px;
}
}
From 6780e807428acb942d22fb8b16fd7db920d30194 Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Mon, 19 Mar 2018 14:41:40 +0000
Subject: [PATCH 056/203] PCHR-3426: Move buttons above tab selector
---
.../components/manager-leave-container.html | 8 ++++----
.../my-leave/components/my-leave-container.html | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html
index f3cafdd9c82..7ee85885f06 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html
@@ -1,5 +1,9 @@
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/my-leave/components/my-leave-container.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/my-leave/components/my-leave-container.html
index 09db95b6a12..98df8be2728 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/my-leave/components/my-leave-container.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/my-leave/components/my-leave-container.html
@@ -1,5 +1,11 @@
From 2830522540ed962978f7d189d8e225e42c0e66fb Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Tue, 20 Mar 2018 11:52:44 +0000
Subject: [PATCH 057/203] PCHR-3426: Remove force exactly one space after
column in SASS
---
package-lock.json | 6 +++---
package.json | 5 +++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index ee4ea49d814..d848417e174 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3826,9 +3826,9 @@
}
},
"stylelint-scss": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/stylelint-scss/-/stylelint-scss-2.3.0.tgz",
- "integrity": "sha512-gYLw1jma/BUZ9eQ3hsrL/7bddQN2BJ13oSp0A0kOqje4hBrSCrUjf7rmpnK8taRWoU3KASwMo4apWg+YopDK5Q==",
+ "version": "2.5.0",
+ "resolved": "https://registry.npmjs.org/stylelint-scss/-/stylelint-scss-2.5.0.tgz",
+ "integrity": "sha512-+joZpza5nQxAyGwzRMancFEl0EH9+1Vy88YzBghRMS0wHulzDPE9fEkBi6ZOlz+I3tYIBI4x9NbqO5/LkbeE3Q==",
"dev": true,
"requires": {
"lodash": "4.17.5",
diff --git a/package.json b/package.json
index 4cd7dcc87f4..7fccf89e6ee 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,8 @@
"selector-class-pattern": null,
"max-nesting-depth": 3,
"no-extra-semicolons": true,
- "no-duplicate-selectors": true
+ "no-duplicate-selectors": true,
+ "scss/dollar-variable-colon-space-after": "at-least-one-space"
}
},
"devDependencies": {
@@ -55,6 +56,6 @@
"stylelint": "^8.4.0",
"stylelint-config-sass-guidelines": "^4.1.0",
"stylelint-order": "^0.8.0",
- "stylelint-scss": "^2.3.0"
+ "stylelint-scss": "^2.5.0"
}
}
From 720d2cca2605c10c1006f481c827305c071dcc53 Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Tue, 20 Mar 2018 16:24:19 +0000
Subject: [PATCH 058/203] PCHR-3426: Fix Backstop tests
---
...sp-leave-absences-manager-leave-requests.js | 11 ++++-------
.../ssp-leave-absences-my-leave-report.js | 18 +++++++++---------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-manager-leave-requests.js b/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-manager-leave-requests.js
index f8de09a4b15..8d0d4613081 100644
--- a/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-manager-leave-requests.js
+++ b/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-manager-leave-requests.js
@@ -101,7 +101,8 @@ module.exports = (function () {
},
/**
* Apply leave on behalf of staff
- * @param {String} row number corresponding to leave request in the list like leave, sickness or toil
+ *
+ * @param {String} leaveType leave, sickness or toil
* @return {Promise}
*/
applyLeaveForStaff: function (leaveType) {
@@ -109,15 +110,11 @@ module.exports = (function () {
return new Promise(function (resolve) {
casper.then(function () {
- var selector = '.button-container leave-request-record-actions .dropdown-toggle';
-
- casper.click(selector);
+ casper.click('leave-request-record-actions .dropdown-toggle');
});
casper.then(function () {
- var leaveSerialNo = leaveType === 'leave' ? 1 : leaveType === 'sickness' ? 2 : 3;
-
- casper.click('.button-container li:nth-child(' + leaveSerialNo + ') a');
+ casper.click('.leave-request-record-actions__new-' + leaveType);
});
casper.then(function () {
diff --git a/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-my-leave-report.js b/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-my-leave-report.js
index 3653bab3874..d524e021320 100644
--- a/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-my-leave-report.js
+++ b/uk.co.compucorp.civicrm.hrcore/backstop_data/page-objects/ssp-leave-absences-my-leave-report.js
@@ -71,17 +71,17 @@ module.exports = (function () {
*/
newRequest: function (requestType) {
var casper = this.casper;
- var requestTypes = ['leave', 'sickness', 'toil']; // must be in the same quantity and order as in UI
- var requestTypeButtonIndex = requestTypes.indexOf(requestType) + 1;
- var actionDropdownSelector = 'leave-request-record-actions';
- var actionButtonSelector = actionDropdownSelector + ' .dropdown-menu a:nth-child(' + requestTypeButtonIndex + ')';
casper.then(function () {
- casper.click(actionDropdownSelector + ' [uib-dropdown] > button');
- casper.waitForSelector(actionButtonSelector, function () {
- casper.click(actionButtonSelector);
- casper.waitUntilVisible('.chr_leave-request-modal__tab .form-group');
- });
+ casper.click('leave-request-record-actions .dropdown-toggle');
+ });
+
+ casper.then(function () {
+ casper.click('.leave-request-record-actions__new-' + requestType);
+ });
+
+ casper.then(function () {
+ casper.waitUntilVisible('.chr_leave-request-modal__tab .form-group');
});
return this;
From d63f48ce3f18b10ae9fd5b5dd4f1ac776ccfae95 Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Tue, 20 Mar 2018 16:42:51 +0000
Subject: [PATCH 059/203] PCHR-3426: Split request record button into two
---
.../css/leaveandabsence.css | 2 +-
.../js/angular/dist/absence-tab.min.js | 6 ++--
.../js/angular/dist/admin-dashboard.min.js | 2 +-
.../js/angular/dist/manager-leave.min.js | 4 +--
.../js/angular/dist/my-leave.min.js | 2 +-
.../leave-request-record-actions.component.js | 4 +--
...e-request-record-actions.component.spec.js | 2 +-
.../_leave-request-record-actions.scss | 34 ++++++++++++++++++
.../scss/components/_leave.scss | 17 +--------
.../scss/pages/_absence-tab-page.scss | 12 +++----
.../scss/pages/_admin-dashboard-page.scss | 25 +++++++------
.../leave-request-record-actions.html | 36 ++++++++++++-------
12 files changed, 85 insertions(+), 61 deletions(-)
create mode 100644 uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css b/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
index 09e1ca024da..3f0b2ede710 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
@@ -1 +1 @@
-#bootstrap-theme .chr_disabled{opacity:0.5;pointer-events:none}#bootstrap-theme .table-condensed>thead>tr>th{background:#fff !important;padding:8px 5px}#bootstrap-theme .table-condensed-mixed>thead>tr>th,#bootstrap-theme .table-condensed-mixed>thead>tr>td,#bootstrap-theme .table-condensed-mixed>tbody>tr>th,#bootstrap-theme .table-condensed-mixed>tbody>tr>td{padding-left:5px;padding-right:5px}#bootstrap-theme .table-condensed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed>thead>tr>td:first-child,#bootstrap-theme .table-condensed>thead>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:first-child{padding-left:20px}#bootstrap-theme .table-condensed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed>thead>tr>td:last-child,#bootstrap-theme .table-condensed>thead>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:last-child{padding-right:20px}#bootstrap-theme .table-nested{overflow-y:hidden;position:relative}#bootstrap-theme .table-nested:before{box-shadow:inset 0px 6px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;top:0;width:100%;z-index:10}#bootstrap-theme .table-nested:after{box-shadow:inset 0px -4px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;bottom:0;width:100%;z-index:10}#bootstrap-theme .table-nested>table,#bootstrap-theme .table-nested>.table{background-color:#fff}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>table>thead>tr>td:first-child,#bootstrap-theme .table-nested>table>thead>tr>th:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child{padding-left:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child:before{background:#C2CFD8;content:'';display:block;height:110%;left:0;position:absolute;top:0;width:10px;z-index:2}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>table>thead>tr>td:last-child,#bootstrap-theme .table-nested>table>thead>tr>th:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child{padding-right:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child:after{background:#C2CFD8;content:'';display:block;height:110%;right:0;position:absolute;top:0;width:10px;z-index:2}@media screen and (max-width: 767px){#bootstrap-theme .table-nested.table-responsive{border:0;margin-bottom:0}}#bootstrap-theme .table-nested-cell{padding:0 !important}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(1){width:40%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(2){width:15%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(3){width:35%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(4){width:10%}#bootstrap-theme .chr_absence-work-pattern__work-pattern-listing{display:inline-block}#bootstrap-theme .chr_absence-work-pattern__alert{margin-bottom:0 !important}#bootstrap-theme .chr_annual-entitlements__period{width:130px}#bootstrap-theme .chr_annual-entitlements__edit-entitlements{width:150px}#bootstrap-theme .chr_contract-entitlements__position{width:140px}@media (max-width: 992px){#bootstrap-theme .chr_leave-balance-tab .chr_leave-balance-tab__filter:not(:last-child){padding-bottom:15px}}#bootstrap-theme .chr_leave-balance-tab__body{padding:0}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__dates-container .chr_leave-calendar{table-layout:fixed}}#bootstrap-theme .chr_leave-calendar__names-container .chr_leave-calendar{table-layout:fixed}#bootstrap-theme .chr_leave-calendar__day{font-size:10px !important;line-height:1.4em !important;padding:10px !important;text-align:center !important}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__day{padding:10px 0 !important}}#bootstrap-theme .chr_leave-calendar__day--disabled{opacity:0.5}#bootstrap-theme .chr_leave-calendar__day--current{color:#0071BD !important}#bootstrap-theme .chr_leave-calendar__item{color:#FFF;display:block;font-size:10px;height:100%;position:relative;text-align:center;text-transform:uppercase;width:100%}#bootstrap-theme .chr_leave-calendar__item>span{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;height:1.2em}#bootstrap-theme .chr_leave-calendar__item>.chr_leave-calendar__time-unit{font-size:7px;height:1em;margin-left:-1px}#bootstrap-theme .chr_leave-calendar__item>a{cursor:pointer;bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}#bootstrap-theme .chr_leave-calendar__item--disabled{cursor:not-allowed;opacity:0.5}#bootstrap-theme .chr_leave-calendar__item--type--late{background-color:#eca67e;border-color:#eca67e}#bootstrap-theme .chr_leave-calendar__item--type--non-working{background-color:#41afcb !important;border-color:#41afcb}#bootstrap-theme .chr_leave-calendar__item--type--public-holiday{background-color:#8ec68a !important;border-color:#8ec68a}#bootstrap-theme .chr_leave-calendar__item--type--weekend{background-color:#c7cbd0 !important;border-color:#c7cbd0}#bootstrap-theme .chr_leave-calendar__item--alt{background:#FFF !important;border:1px solid transparent;color:#464354}#bootstrap-theme .chr_leave-calendar__item--requested:before{background:#c7cbd0;content:'';display:block;height:.5em;position:absolute;width:100%;top:0}#bootstrap-theme .chr_leave-calendar__item--toil-requested:before{background:red;content:'';display:block;height:.5em;left:-1px;position:absolute;width:calc(100% + 2px);top:-1px}#bootstrap-theme .chr_leave-calendar__items>td{overflow:hidden;height:35px;padding:0 !important}#bootstrap-theme .chr_leave-calendar__items leave-calendar-day{display:block;height:100%}#bootstrap-theme .chr_leave-calendar__legend__title{font-size:12px}#bootstrap-theme .chr_leave-calendar__legend>.row:not(:first-child){margin-top:20px}#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:10px}@media (min-width: 768px){#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:0}}#bootstrap-theme .chr_leave-calendar__legend__entry{overflow:auto}#bootstrap-theme .chr_leave-calendar__legend__entry+#bootstrap-theme .chr_leave-calendar__legend__entry{margin-top:10px}#bootstrap-theme .chr_leave-calendar__legend__entry>.chr_leave-calendar__item{font-size:8px;height:20px;margin-right:10px;position:absolute;width:20px}#bootstrap-theme .chr_leave-calendar__legend__label{display:inline-block;font-size:12px;margin-left:26px}#bootstrap-theme .chr_leave-calendar__month-header{background:#F3F6F7}#bootstrap-theme .chr_leave-calendar__month-header .panel-title{font-size:16px}#bootstrap-theme td.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__name{font-size:12px !important;line-height:100%;padding:0 20px !important;text-align:left;text-overflow:ellipsis;width:100%}#bootstrap-theme th.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__day{height:49px}#bootstrap-theme th.chr_leave-calendar__name{padding-bottom:10px !important}#bootstrap-theme td.chr_leave-calendar__name{vertical-align:middle !important}#bootstrap-theme .chr_leave-calendar__pagination{font-size:10px;text-align:center}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]{outline:none;padding:0;line-height:1em}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"] .fa{color:#555}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"][disabled] .fa{opacity:0.5}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]:hover:not([disabled]) .fa{color:#464354}#bootstrap-theme .chr_leave-calendar__pagination-next{border-top:none}#bootstrap-theme .chr_leave-calendar__pagination-next th{height:24px;padding:4px 0 6px !important}#bootstrap-theme .chr_leave-calendar__pagination-next .chr_leave-calendar__pagination{padding-right:3px !important}#bootstrap-theme .chr_leave-calendar__month-container{margin:0}#bootstrap-theme .chr_leave-calendar__month-container>div{padding:0}#bootstrap-theme .chr_leave-calendar__dates-container{overflow-x:auto}#bootstrap-theme .chr_leave-calendar__admin-filters-hint{display:inline-block;font-size:20px;vertical-align:middle}#bootstrap-theme .chr_leave-calendar__admin-filters-select{width:calc(100% - 50px);display:inline-block;margin-right:20px}#bootstrap-theme .chr_leave-report .dropdown-toggle{color:#464354;padding:0 10px}#bootstrap-theme .chr_leave-report .dropdown-toggle:hover{background:#e6e6e6}#bootstrap-theme .chr_leave-report table{table-layout:fixed}#bootstrap-theme .chr_leave-report table thead th,#bootstrap-theme .chr_leave-report table tbody td{padding:8px 5px}#bootstrap-theme .chr_leave-report__label{color:#464354;font-weight:700}#bootstrap-theme .chr_leave-report__label>.fa{margin-right:5px}#bootstrap-theme .chr_leave-report__label--toggle{cursor:pointer;user-select:none}#bootstrap-theme .chr_leave-report__heading{background-color:#F3F6F7;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_leave-report__heading .chr_leave-report__export-button{line-height:2.4}#bootstrap-theme .chr_leave-report__table table,#bootstrap-theme .chr_leave-report__table .table{border-collapse:separate}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-top-width:0}#bootstrap-theme .chr_leave-report__table table>thead+tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>thead+tbody>tr:first-child>td{border-top-width:1px}#bootstrap-theme .chr_leave-report__table table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td{border-color:#F3F6F7}#bootstrap-theme .chr_leave-report__table table>thead>tr>th,#bootstrap-theme .chr_leave-report__table .table>thead>tr>th{background:#F3F6F7;border-bottom:0;color:#464354;text-transform:capitalize}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-color:#E8EEF0 !important}#bootstrap-theme .chr_leave-report__table table>tfoot>tr,#bootstrap-theme .chr_leave-report__table .table>tfoot>tr{background:#F3F6F7}#bootstrap-theme .chr_leave-report__table>table>thead>tr>th,#bootstrap-theme .chr_leave-report__table>.table>thead>tr>th{padding-bottom:13px;padding-top:13px}#bootstrap-theme .chr_leave-report__table-container{overflow:auto}#bootstrap-theme .chr_leave-report__table-container .panel{display:inline-block;min-width:100%}#bootstrap-theme .chr_leave-report__table__heading--action{width:45px}#bootstrap-theme .chr_leave-report__table__heading--label{width:280px}#bootstrap-theme .chr_leave-report__table__heading--dates{width:170px}#bootstrap-theme .chr_leave-report__table__heading--status{width:180px}#bootstrap-theme .chr_leave-report__table__heading--type{width:65px;word-break:break-word}#bootstrap-theme .chr_leave-request-comment{margin-top:10px}#bootstrap-theme .chr_leave-request-comment__text{border-bottom:1px solid #E8EEF0;color:#C2CFD8;margin-right:10px;padding-bottom:20px}#bootstrap-theme .chr_leave-request-files_list{height:150px;overflow-y:auto;margin-top:20px;margin-bottom:20px}#bootstrap-theme .chr_leave-request-files_meta{margin-bottom:10px}#bootstrap-theme .chr_leave-request-files_upload{border:dashed 1px #464354;padding:20px}#bootstrap-theme .chr_leave-request-files_upload_action{padding:5px}#bootstrap-theme .chr_leave-request-files_file-name{display:inline-block;max-width:240px;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}#bootstrap-theme .chr_leave-request-files_delete{margin-top:-7px}#bootstrap-theme .chr_leave-request-modal .modal-title{font-size:18px !important}#bootstrap-theme .chr_leave-request-modal .table-responsive{border:0}#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container .input-group{width:100%}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal__chevron{font-size:0.6em;margin-right:5px;vertical-align:middle}#bootstrap-theme .chr_leave-request-modal__comments{height:230px;margin-bottom:20px;overflow:auto}#bootstrap-theme .chr_leave-request-modal__comments_empty{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__footer{margin:0}#bootstrap-theme .chr_leave-request-modal__delete{margin-left:15px;margin-top:8px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container ul{opacity:1 !important}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container:not(.ui-select-multiple) input{width:100% !important}#bootstrap-theme .chr_leave-request-modal__form-group,#bootstrap-theme .chr_leave-request-modal__required-documents>div{margin-bottom:15px}#bootstrap-theme .chr_leave-request-modal__response{padding:20px 20px 0}#bootstrap-theme .chr_leave-request-modal__response label{font-size:17px;margin-top:-3px}#bootstrap-theme .chr_leave-request-modal__response .chr_wysiwyg{margin-top:15px}#bootstrap-theme .chr_leave-request-modal__required-documents input{margin-right:5px}#bootstrap-theme .chr_leave-request-modal__small_spinner>div.chr_spinner{margin-top:18px;min-height:initial}#bootstrap-theme .chr_leave-request-modal__tab input[uib-datepicker-popup]{font-size:13px}#bootstrap-theme .chr_leave-request-modal__table{border:1px solid #F3F6F7;margin-bottom:15px !important}#bootstrap-theme .chr_leave-request-modal__user-info{font-size:17px;padding:20px}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(1){color:#464354}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){color:#555}@media screen and (min-width: 480px){#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){border-left:1px solid #E8EEF0}}#bootstrap-theme .chr_leave-request-modal__span-expiry{display:inline-block;margin-top:7px}#bootstrap-theme .chr_leave-request-modal__expiry-clear{position:absolute;right:3.5em;top:0.6em;z-index:2}#bootstrap-theme .chr_leave-request-modal__small-text{font-size:80%}#bootstrap-theme .chr_leave-request-modal__custom-deduction-toggling-row{margin-top:-5px}@media screen and (min-width: 768px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{text-align:right}}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal .form-group{overflow:inherit !important}#bootstrap-theme .chr_leave-request-modal .alert{margin-bottom:0 !important}#bootstrap-theme .chr_leave-request-modal input[uib-datepicker-popup]{box-shadow:none !important;background-color:inherit !important;color:inherit !important;cursor:pointer !important;border-right:none}#bootstrap-theme .leave-widget h4{color:#4D4D69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4D4D69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071BD;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .chr_leave__page-selector-dropdown{margin-right:5px;position:relative;top:1px;width:calc(100% - 80px)}#bootstrap-theme .chr_leave__page-selector-dropdown select{height:40px}#bootstrap-theme .chr_leave__page-selector-dropdown .crm_custom-select__arrow{line-height:40px;width:40px}#bootstrap-theme leave-request-record-actions .dropdown-menu{left:auto;right:0}#bootstrap-theme leave-request-record-actions .dropdown-toggle{height:40px}#bootstrap-theme leave-request-record-actions i.fa{margin-right:8px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{margin-top:7px;display:inline-block}@media screen and (max-width: 992px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>div:not(:last-child),#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{padding-bottom:20px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{display:inline-block;margin-top:7px;white-space:nowrap}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter .fa{font-size:0.6em;margin-right:5px;margin-top:-2px;vertical-align:middle}@media screen and (max-width: 991px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{margin-top:15px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0;padding-top:15px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>div:not(:last-child){padding-bottom:20px}}@media screen and (min-width: 992px) and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>.no_gutter{padding-bottom:0 !important}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body{margin:0;padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class^="col-"],#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class*=" col-"]{padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body a{cursor:pointer}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container{padding-left:10px;padding-right:10px;background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>div{padding-left:15px;padding-right:15px}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .form-group{overflow:inherit !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel{background-image:none !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel-body,#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .chr_vertical_tabs{background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] input[type="search"]{width:100% !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header .checkbox{margin-top:5px}#bootstrap-theme .page-manager-leave .chr_manage_leave_requests .btn-sm{font-size:100% !important}#bootstrap-theme .chr_manager_calendar__header{padding-left:10px;padding-right:10px;padding-top:15px;margin:0;background-color:#f7f7f9;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_manager_calendar__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manager_calendar__header .checkbox{margin:0}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__header>div:not(:last-child){padding-bottom:20px}}#bootstrap-theme .chr_manager_calendar__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;margin:0}#bootstrap-theme .chr_manager_calendar__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__sub-header>div:not(:last-child){padding-bottom:20px}#bootstrap-theme .chr_manager_calendar__sub-header .ui-select-container{height:auto}}#bootstrap-theme .annual-entitlement-change-log-component table thead td{min-width:100px}#bootstrap-theme .annual-entitlement-change-log-component table thead td.annual-entitlement-change-log-component__comments{min-width:300px}#bootstrap-theme .time-amount-picker .crm_custom-select{display:inline-block;margin-right:2px}#bootstrap-theme .time-amount-picker .crm_custom-select:nth-child(2){margin-left:10px}#bootstrap-theme .absence-tab-page .btn-group{margin-bottom:20px}#bootstrap-theme .absence-tab-page .btn-group>.btn{border-color:transparent !important}#bootstrap-theme .absence-tab-page .tab-pane{padding:0 !important}#bootstrap-theme .absence-tab-page .tab-content{background-color:transparent !important}#bootstrap-theme .crm-absence_type-form-block .crm-section .label{width:35%}#bootstrap-theme .crm-absence_type-form-block .crm-section .content{margin-left:40%}#bootstrap-theme .crm-absence_type-form-block .toil-option,#bootstrap-theme .crm-absence_type-form-block .carry-forward-option,#bootstrap-theme .crm-absence_type-form-block .toil-expiration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-duration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-date{display:none}#bootstrap-theme .crm-absence_type-form-block .sp-replacer{padding:2px}#bootstrap-theme .crm-absence_type-form-block .sp-preview{height:15px;width:15px}#bootstrap-theme .crm-absence_type-form-block .sp-dd{height:0;line-height:15px;font-size:9px}.page-civicrm-leaveandabsences-dashboard h1.page-title,.page-civicrm-leaveandabsences-dashboard #branding{display:none !important}.page-civicrm-leaveandabsences-dashboard #page{margin:0;padding:0}.admin-dashboard-page{position:relative}.admin-dashboard-page .crm_page__topbar{height:65px}.admin-dashboard-page .crm_page__topbar .dropdown-toggle{margin:15px 30px 0 0 !important}.admin-dashboard-page .crm_page__topbar .dropdown-toggle+ul{margin-right:30px !important}.admin-dashboard-page .chr_admin-dashboard_side-nav{overflow:hidden;width:170px;position:absolute;height:calc(100% - 12px);background-color:#fff}.admin-dashboard-page .chr_admin-dashboard_side-nav li.active{background:#E8EEF0}.admin-dashboard-page .chr_admin-dashboard_content{float:right;width:calc(100% - 170px - 16px * 2);margin:16px;margin-bottom:0}#bootstrap-theme #calculation-details{background:#fff}#bootstrap-theme #calculation-details .base-contractual-entitlement{color:#0071BD}#bootstrap-theme #calculation-details .working-days-to-work{color:#44CB7E}#bootstrap-theme #calculation-details .working-days-in-period{color:#E6AB5E}#bootstrap-theme #calculation-details .contract-1-pro-rata{color:#E6807F}#bootstrap-theme #calculation-details .contract-2-pro-rata{color:#797300}#bootstrap-theme #calculation-details .contract-3-pro-rata{color:#904E1E}#bootstrap-theme #calculation-details .contract-4-pro-rata{color:#0511B1}#bootstrap-theme #calculation-details .contract-5-pro-rata{color:#4B9609}#bootstrap-theme #calculation-details .calculation-pro-rata{color:#95c0ff}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body{padding-top:20px;padding-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body .row:first-child h3{margin-top:0}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body h3{margin-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-footer .crm-button:last-child{margin-right:0}#bootstrap-theme.crm-leave-and-balance-import .panel{background-color:#fff}#bootstrap-theme.crm-leave-and-balance-import .panel-header{position:relative}#bootstrap-theme.crm-leave-and-balance-import .panel-header h2{padding:10px 20px}#bootstrap-theme.crm-leave-and-balance-import .panel-body .row:not(:last-child){padding-bottom:2em}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats .label{display:none}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats label{font-weight:normal !important}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats td{border:0;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block{box-shadow:none;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table{margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th{padding:10px 20px;border-right:none}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th,#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table td{padding:5px}#bootstrap-theme.crm-leave-and-balance-import #preview-counts,#bootstrap-theme.crm-leave-and-balance-import #summary-counts{box-shadow:none;margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td{background-color:#f2dede !important;color:#CF3458}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a{color:#bd2d4e;font-weight:bold}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a:hover,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a:hover{color:#0062a4}#bootstrap-theme.manage-entitlements-form .wider-hr{margin-left:-20px;margin-right:-20px;border-width:2px}#bootstrap-theme.manage-entitlements-form .wider-row{margin-left:-20px;margin-right:-20px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters{padding:15px 0;text-align:center}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label{display:inline-block}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label:before{display:none}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .absence-type-filter{margin-right:10px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .col-sm-4:last-child{text-align:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list{margin-bottom:0}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .title{float:left;width:65%}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .actions{float:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list tr.hidden{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .absence-type{color:#fff;display:inline-block;padding:5px}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .overridden-proposed-entitlement,#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .calculation-unit{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .borderless-button{background-color:transparent;border:0;cursor:pointer}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .add-comment{font-size:1.1em}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .comment-text{display:none}#bootstrap-theme.manage-entitlements-form .manage-entitlements-form__filters{padding-bottom:1em}#bootstrap-theme.manage-entitlements-form .table{background:#f9f9f9;border-top:1px solid #E8EEF0;border-bottom:1px solid #E8EEF0;margin-bottom:2em}#bootstrap-theme.manage-entitlements-form .table th{background:#F3F6F7 !important}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header{border-left:1px solid #E8EEF0;border-right:1px solid #E8EEF0;background:#e4ebed !important;min-width:200px}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .row>div{display:table-cell;float:none;vertical-align:bottom}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .fa{color:#4D4D69}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .action-button-container{padding:0}#bootstrap-theme.manage-entitlements-form .table td.proposed-entitlement{border-left:1px solid #E8EEF0;border-right:1px solid #E8EEF0;background:white}#bootstrap-theme.manage-entitlements-form .table span.absence-type{border-radius:3px;padding:0 5px}#bootstrap-theme.manage-entitlements-form .table tbody .fa{color:#0071BD}#bootstrap-theme.manage-entitlements-form .crm-container .CRM_HRLeaveAndAbsences_Form_ManageEntitlements .crm-button-type-next{float:right !important}#bootstrap-theme.manage-entitlements-form .panel-footer{border-top:none}#add-comment-dialog{display:none}#add-comment-dialog .calculation_comment{box-sizing:border-box;padding:10px;width:100%}#bootstrap-theme .crm-work-pattern-form-block .ui-tabs.ui-widget-content{background:none}#bootstrap-theme .work-pattern-calendar .number-of-weeks{padding:15px 0 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week{border-top:1px solid rgba(0,0,0,0.2);padding:15px 0 15px 0;margin-bottom:15px}#bootstrap-theme .work-pattern-calendar .work-pattern-week.hidden-week{display:none}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-number{float:left;font-weight:bold;padding:5px 0 15px 5px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days{table-layout:fixed}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours{float:right;padding:5px 5px 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours .number-of-hours{font-weight:bold}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days td{padding:5px 10px 5px 10px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days input{min-width:0;text-align:center}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days select{min-width:0;width:100% !important}#bootstrap-theme .work-pattern-calendar .work-pattern-week .hours-row td{padding-top:15px;padding-bottom:15px;border-top:1px solid rgba(0,0,0,0.2);border-bottom:1px solid rgba(0,0,0,0.2)}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:13px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.5384615385;color:#4D4D69;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#42425a;background-color:#F3F6F7}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#0071BD}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#E8EEF0}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.5384615385;color:#464354;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width: 768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{left:0;right:auto}}.dropdown-header{padding:11px 20px}.dropdown-menu{-webkit-box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);border:0;margin:0;padding:0}.dropdown-menu>li{border:0;margin:0;padding:0}.dropdown-menu>li>a{padding:11px 20px}
+#bootstrap-theme .chr_disabled{opacity:0.5;pointer-events:none}#bootstrap-theme .table-condensed>thead>tr>th{background:#fff !important;padding:8px 5px}#bootstrap-theme .table-condensed-mixed>thead>tr>th,#bootstrap-theme .table-condensed-mixed>thead>tr>td,#bootstrap-theme .table-condensed-mixed>tbody>tr>th,#bootstrap-theme .table-condensed-mixed>tbody>tr>td{padding-left:5px;padding-right:5px}#bootstrap-theme .table-condensed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed>thead>tr>td:first-child,#bootstrap-theme .table-condensed>thead>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:first-child{padding-left:20px}#bootstrap-theme .table-condensed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed>thead>tr>td:last-child,#bootstrap-theme .table-condensed>thead>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:last-child{padding-right:20px}#bootstrap-theme .table-nested{overflow-y:hidden;position:relative}#bootstrap-theme .table-nested:before{box-shadow:inset 0px 6px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;top:0;width:100%;z-index:10}#bootstrap-theme .table-nested:after{box-shadow:inset 0px -4px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;bottom:0;width:100%;z-index:10}#bootstrap-theme .table-nested>table,#bootstrap-theme .table-nested>.table{background-color:#fff}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>table>thead>tr>td:first-child,#bootstrap-theme .table-nested>table>thead>tr>th:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child{padding-left:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child:before{background:#c2cfd8;content:'';display:block;height:110%;left:0;position:absolute;top:0;width:10px;z-index:2}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>table>thead>tr>td:last-child,#bootstrap-theme .table-nested>table>thead>tr>th:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child{padding-right:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child:after{background:#c2cfd8;content:'';display:block;height:110%;right:0;position:absolute;top:0;width:10px;z-index:2}@media screen and (max-width: 767px){#bootstrap-theme .table-nested.table-responsive{border:0;margin-bottom:0}}#bootstrap-theme .table-nested-cell{padding:0 !important}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(1){width:40%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(2){width:15%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(3){width:35%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(4){width:10%}#bootstrap-theme .chr_absence-work-pattern__work-pattern-listing{display:inline-block}#bootstrap-theme .chr_absence-work-pattern__alert{margin-bottom:0 !important}#bootstrap-theme .annual-entitlement-change-log-component thead td{min-width:100px}#bootstrap-theme .annual-entitlement-change-log-component thead .annual-entitlement-change-log-component__comments{min-width:300px}#bootstrap-theme .chr_annual-entitlements__period{width:130px}#bootstrap-theme .chr_annual-entitlements__edit-entitlements{width:150px}#bootstrap-theme .chr_contract-entitlements__position{width:140px}@media (max-width: 992px){#bootstrap-theme .chr_leave-balance-tab .chr_leave-balance-tab__filter:not(:last-child){padding-bottom:15px}}#bootstrap-theme .chr_leave-balance-tab__body{padding:0}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__dates-container .chr_leave-calendar{table-layout:fixed}}#bootstrap-theme .chr_leave-calendar__names-container .chr_leave-calendar{table-layout:fixed}#bootstrap-theme .chr_leave-calendar__day{font-size:10px !important;line-height:1.4em !important;padding:10px !important;text-align:center !important}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__day{padding:10px 0 !important}}#bootstrap-theme .chr_leave-calendar__day--disabled{opacity:0.5}#bootstrap-theme .chr_leave-calendar__day--current{color:#0071bd !important}#bootstrap-theme .chr_leave-calendar__item{color:#FFF;display:block;font-size:10px;height:100%;position:relative;text-align:center;text-transform:uppercase;width:100%}#bootstrap-theme .chr_leave-calendar__item>span{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;height:1.2em}#bootstrap-theme .chr_leave-calendar__item>.chr_leave-calendar__time-unit{font-size:7px;height:1em;margin-left:-1px}#bootstrap-theme .chr_leave-calendar__item>a{cursor:pointer;bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}#bootstrap-theme .chr_leave-calendar__item--disabled{cursor:not-allowed;opacity:0.5}#bootstrap-theme .chr_leave-calendar__item--type--late{background-color:#eca67e;border-color:#eca67e}#bootstrap-theme .chr_leave-calendar__item--type--non-working{background-color:#41afcb !important;border-color:#41afcb}#bootstrap-theme .chr_leave-calendar__item--type--public-holiday{background-color:#8ec68a !important;border-color:#8ec68a}#bootstrap-theme .chr_leave-calendar__item--type--weekend{background-color:#c7cbd0 !important;border-color:#c7cbd0}#bootstrap-theme .chr_leave-calendar__item--alt{background:#FFF !important;border:1px solid transparent;color:#464354}#bootstrap-theme .chr_leave-calendar__item--requested:before{background:#c7cbd0;content:'';display:block;height:.5em;position:absolute;width:100%;top:0}#bootstrap-theme .chr_leave-calendar__item--toil-requested:before{background:red;content:'';display:block;height:.5em;left:-1px;position:absolute;width:calc(100% + 2px);top:-1px}#bootstrap-theme .chr_leave-calendar__items>td{overflow:hidden;height:35px;padding:0 !important}#bootstrap-theme .chr_leave-calendar__items leave-calendar-day{display:block;height:100%}#bootstrap-theme .chr_leave-calendar__legend__title{font-size:12px}#bootstrap-theme .chr_leave-calendar__legend>.row:not(:first-child){margin-top:20px}#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:10px}@media (min-width: 768px){#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:0}}#bootstrap-theme .chr_leave-calendar__legend__entry{overflow:auto}#bootstrap-theme .chr_leave-calendar__legend__entry+#bootstrap-theme .chr_leave-calendar__legend__entry{margin-top:10px}#bootstrap-theme .chr_leave-calendar__legend__entry>.chr_leave-calendar__item{font-size:8px;height:20px;margin-right:10px;position:absolute;width:20px}#bootstrap-theme .chr_leave-calendar__legend__label{display:inline-block;font-size:12px;margin-left:26px}#bootstrap-theme .chr_leave-calendar__month-header{background:#f3f6f7}#bootstrap-theme .chr_leave-calendar__month-header .panel-title{font-size:16px}#bootstrap-theme td.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__name{font-size:12px !important;line-height:100%;padding:0 20px !important;text-align:left;text-overflow:ellipsis;width:100%}#bootstrap-theme th.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__day{height:49px}#bootstrap-theme th.chr_leave-calendar__name{padding-bottom:10px !important}#bootstrap-theme td.chr_leave-calendar__name{vertical-align:middle !important}#bootstrap-theme .chr_leave-calendar__pagination{font-size:10px;text-align:center}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]{outline:none;padding:0;line-height:1em}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"] .fa{color:#555}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"][disabled] .fa{opacity:0.5}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]:hover:not([disabled]) .fa{color:#464354}#bootstrap-theme .chr_leave-calendar__pagination-next{border-top:none}#bootstrap-theme .chr_leave-calendar__pagination-next th{height:24px;padding:4px 0 6px !important}#bootstrap-theme .chr_leave-calendar__pagination-next .chr_leave-calendar__pagination{padding-right:3px !important}#bootstrap-theme .chr_leave-calendar__month-container{margin:0}#bootstrap-theme .chr_leave-calendar__month-container>div{padding:0}#bootstrap-theme .chr_leave-calendar__dates-container{overflow-x:auto}#bootstrap-theme .chr_leave-calendar__admin-filters-hint{display:inline-block;font-size:20px;vertical-align:middle}#bootstrap-theme .chr_leave-calendar__admin-filters-select{width:calc(100% - 50px);display:inline-block;margin-right:20px}#bootstrap-theme .chr_leave-report .dropdown-toggle{color:#464354;padding:0 10px}#bootstrap-theme .chr_leave-report .dropdown-toggle:hover{background:#e6e6e6}#bootstrap-theme .chr_leave-report table{table-layout:fixed}#bootstrap-theme .chr_leave-report table thead th,#bootstrap-theme .chr_leave-report table tbody td{padding:8px 5px}#bootstrap-theme .chr_leave-report__label{color:#464354;font-weight:700}#bootstrap-theme .chr_leave-report__label>.fa{margin-right:5px}#bootstrap-theme .chr_leave-report__label--toggle{cursor:pointer;user-select:none}#bootstrap-theme .chr_leave-report__heading{background-color:#f3f6f7;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_leave-report__heading .chr_leave-report__export-button{line-height:2.4}#bootstrap-theme .chr_leave-report__table table,#bootstrap-theme .chr_leave-report__table .table{border-collapse:separate}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-top-width:0}#bootstrap-theme .chr_leave-report__table table>thead+tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>thead+tbody>tr:first-child>td{border-top-width:1px}#bootstrap-theme .chr_leave-report__table table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td{border-color:#f3f6f7}#bootstrap-theme .chr_leave-report__table table>thead>tr>th,#bootstrap-theme .chr_leave-report__table .table>thead>tr>th{background:#f3f6f7;border-bottom:0;color:#464354;text-transform:capitalize}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-color:#e8eef0 !important}#bootstrap-theme .chr_leave-report__table table>tfoot>tr,#bootstrap-theme .chr_leave-report__table .table>tfoot>tr{background:#f3f6f7}#bootstrap-theme .chr_leave-report__table>table>thead>tr>th,#bootstrap-theme .chr_leave-report__table>.table>thead>tr>th{padding-bottom:13px;padding-top:13px}#bootstrap-theme .chr_leave-report__table-container{overflow:auto}#bootstrap-theme .chr_leave-report__table-container .panel{display:inline-block;min-width:100%}#bootstrap-theme .chr_leave-report__table__heading--action{width:45px}#bootstrap-theme .chr_leave-report__table__heading--label{width:280px}#bootstrap-theme .chr_leave-report__table__heading--dates{width:170px}#bootstrap-theme .chr_leave-report__table__heading--status{width:180px}#bootstrap-theme .chr_leave-report__table__heading--type{width:65px;word-break:break-word}#bootstrap-theme .chr_leave-request-comment{margin-top:10px}#bootstrap-theme .chr_leave-request-comment__text{border-bottom:1px solid #e8eef0;color:#c2cfd8;margin-right:10px;padding-bottom:20px}#bootstrap-theme .chr_leave-request-files_list{height:150px;overflow-y:auto;margin-top:20px;margin-bottom:20px}#bootstrap-theme .chr_leave-request-files_meta{margin-bottom:10px}#bootstrap-theme .chr_leave-request-files_upload{border:dashed 1px #464354;padding:20px}#bootstrap-theme .chr_leave-request-files_upload_action{padding:5px}#bootstrap-theme .chr_leave-request-files_file-name{display:inline-block;max-width:240px;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}#bootstrap-theme .chr_leave-request-files_delete{margin-top:-7px}#bootstrap-theme .chr_leave-request-modal .modal-title{font-size:18px !important}#bootstrap-theme .chr_leave-request-modal .table-responsive{border:0}#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container .input-group{width:100%}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal__chevron{font-size:0.6em;margin-right:5px;vertical-align:middle}#bootstrap-theme .chr_leave-request-modal__comments{height:230px;margin-bottom:20px;overflow:auto}#bootstrap-theme .chr_leave-request-modal__comments_empty{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__footer{margin:0}#bootstrap-theme .chr_leave-request-modal__delete{margin-left:15px;margin-top:8px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container ul{opacity:1 !important}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container:not(.ui-select-multiple) input{width:100% !important}#bootstrap-theme .chr_leave-request-modal__form-group,#bootstrap-theme .chr_leave-request-modal__required-documents>div{margin-bottom:15px}#bootstrap-theme .chr_leave-request-modal__response{padding:20px 20px 0}#bootstrap-theme .chr_leave-request-modal__response label{font-size:17px;margin-top:-3px}#bootstrap-theme .chr_leave-request-modal__response .chr_wysiwyg{margin-top:15px}#bootstrap-theme .chr_leave-request-modal__required-documents input{margin-right:5px}#bootstrap-theme .chr_leave-request-modal__small_spinner>div.chr_spinner{margin-top:18px;min-height:initial}#bootstrap-theme .chr_leave-request-modal__tab input[uib-datepicker-popup]{font-size:13px}#bootstrap-theme .chr_leave-request-modal__table{border:1px solid #f3f6f7;margin-bottom:15px !important}#bootstrap-theme .chr_leave-request-modal__user-info{font-size:17px;padding:20px}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(1){color:#464354}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){color:#555}@media screen and (min-width: 480px){#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){border-left:1px solid #e8eef0}}#bootstrap-theme .chr_leave-request-modal__span-expiry{display:inline-block;margin-top:7px}#bootstrap-theme .chr_leave-request-modal__expiry-clear{position:absolute;right:3.5em;top:0.6em;z-index:2}#bootstrap-theme .chr_leave-request-modal__small-text{font-size:80%}#bootstrap-theme .chr_leave-request-modal__custom-deduction-toggling-row{margin-top:-5px}@media screen and (min-width: 768px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{text-align:right}}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal .form-group{overflow:inherit !important}#bootstrap-theme .chr_leave-request-modal .alert{margin-bottom:0 !important}#bootstrap-theme .chr_leave-request-modal input[uib-datepicker-popup]{box-shadow:none !important;background-color:inherit !important;color:inherit !important;cursor:pointer !important;border-right:none}#bootstrap-theme leave-request-record-actions{display:block;margin-bottom:20px}#bootstrap-theme leave-request-record-actions .fa,#bootstrap-theme leave-request-record-actions .btn-group{margin-right:8px}#bootstrap-theme leave-request-record-actions .btn-toolbar{margin-left:0;overflow:inherit}#bootstrap-theme leave-request-record-actions .btn-toolbar .btn-group,#bootstrap-theme leave-request-record-actions .btn-toolbar .btn{margin-left:0}@media screen and (max-width: 767px){#bootstrap-theme leave-request-record-actions .btn-group,#bootstrap-theme leave-request-record-actions .btn{display:block;width:100%}#bootstrap-theme leave-request-record-actions .btn-group{margin-bottom:8px;margin-right:0}}#bootstrap-theme .leave-widget h4{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071bd;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .chr_leave__page-selector-dropdown{margin-right:5px;position:relative;top:1px;width:100%}#bootstrap-theme .chr_leave__page-selector-dropdown select{height:40px}#bootstrap-theme .chr_leave__page-selector-dropdown .crm_custom-select__arrow{line-height:40px;width:40px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{margin-top:7px;display:inline-block}@media screen and (max-width: 992px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>div:not(:last-child),#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{padding-bottom:20px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{display:inline-block;margin-top:7px;white-space:nowrap}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter .fa{font-size:0.6em;margin-right:5px;margin-top:-2px;vertical-align:middle}@media screen and (max-width: 991px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{margin-top:15px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0;padding-top:15px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>div:not(:last-child){padding-bottom:20px}}@media screen and (min-width: 992px) and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>.no_gutter{padding-bottom:0 !important}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body{margin:0;padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class^="col-"],#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class*=" col-"]{padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body a{cursor:pointer}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container{padding-left:10px;padding-right:10px;background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>div{padding-left:15px;padding-right:15px}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .form-group{overflow:inherit !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel{background-image:none !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel-body,#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .chr_vertical_tabs{background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] input[type="search"]{width:100% !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header .checkbox{margin-top:5px}#bootstrap-theme .page-manager-leave .chr_manage_leave_requests .btn-sm{font-size:100% !important}#bootstrap-theme .chr_manager_calendar__header{padding-left:10px;padding-right:10px;padding-top:15px;margin:0;background-color:#f7f7f9;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_manager_calendar__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manager_calendar__header .checkbox{margin:0}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__header>div:not(:last-child){padding-bottom:20px}}#bootstrap-theme .chr_manager_calendar__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;margin:0}#bootstrap-theme .chr_manager_calendar__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__sub-header>div:not(:last-child){padding-bottom:20px}#bootstrap-theme .chr_manager_calendar__sub-header .ui-select-container{height:auto}}#bootstrap-theme .time-amount-picker .crm_custom-select{display:inline-block;margin-right:2px}#bootstrap-theme .time-amount-picker .crm_custom-select:nth-child(2){margin-left:10px}#bootstrap-theme .absence-tab-page .tab-pane{padding:0 !important}#bootstrap-theme .absence-tab-page .tab-content{background-color:transparent !important}#bootstrap-theme .absence-tab-page leave-request-record-actions{margin-bottom:20px}#bootstrap-theme .crm-absence_type-form-block .crm-section .label{width:35%}#bootstrap-theme .crm-absence_type-form-block .crm-section .content{margin-left:40%}#bootstrap-theme .crm-absence_type-form-block .toil-option,#bootstrap-theme .crm-absence_type-form-block .carry-forward-option,#bootstrap-theme .crm-absence_type-form-block .toil-expiration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-duration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-date{display:none}#bootstrap-theme .crm-absence_type-form-block .sp-replacer{padding:2px}#bootstrap-theme .crm-absence_type-form-block .sp-preview{height:15px;width:15px}#bootstrap-theme .crm-absence_type-form-block .sp-dd{height:0;line-height:15px;font-size:9px}.page-civicrm-leaveandabsences-dashboard .page-title,.page-civicrm-leaveandabsences-dashboard #branding{display:none !important}.page-civicrm-leaveandabsences-dashboard #page{margin:0;padding:0}.admin-dashboard-page{position:relative}.admin-dashboard-page .crm_page__topbar{height:65px}.admin-dashboard-page leave-request-record-actions{margin:12px 30px 0 0}.admin-dashboard-page .chr_admin-dashboard_side-nav{background-color:#fff;height:calc(100% - 12px);overflow:hidden;position:absolute;width:170px}.admin-dashboard-page .chr_admin-dashboard_side-nav .active{background:#e8eef0}.admin-dashboard-page .chr_admin-dashboard_content{float:right;margin:16px;margin-bottom:0;width:calc(100% - 170px - 16px * 2)}#bootstrap-theme #calculation-details{background:#fff}#bootstrap-theme #calculation-details .base-contractual-entitlement{color:#0071bd}#bootstrap-theme #calculation-details .working-days-to-work{color:#44cb7e}#bootstrap-theme #calculation-details .working-days-in-period{color:#e6ab5e}#bootstrap-theme #calculation-details .contract-1-pro-rata{color:#E6807F}#bootstrap-theme #calculation-details .contract-2-pro-rata{color:#797300}#bootstrap-theme #calculation-details .contract-3-pro-rata{color:#904E1E}#bootstrap-theme #calculation-details .contract-4-pro-rata{color:#0511B1}#bootstrap-theme #calculation-details .contract-5-pro-rata{color:#4B9609}#bootstrap-theme #calculation-details .calculation-pro-rata{color:#95c0ff}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body{padding-top:20px;padding-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body .row:first-child h3{margin-top:0}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body h3{margin-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-footer .crm-button:last-child{margin-right:0}#bootstrap-theme.crm-leave-and-balance-import .panel{background-color:#fff}#bootstrap-theme.crm-leave-and-balance-import .panel-header{position:relative}#bootstrap-theme.crm-leave-and-balance-import .panel-header h2{padding:10px 20px}#bootstrap-theme.crm-leave-and-balance-import .panel-body .row:not(:last-child){padding-bottom:2em}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats .label{display:none}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats label{font-weight:normal !important}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats td{border:0;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block{box-shadow:none;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table{margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th{padding:10px 20px;border-right:none}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th,#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table td{padding:5px}#bootstrap-theme.crm-leave-and-balance-import #preview-counts,#bootstrap-theme.crm-leave-and-balance-import #summary-counts{box-shadow:none;margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td{background-color:#f2dede !important;color:#cf3458}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a{color:#bd2d4e;font-weight:bold}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a:hover,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a:hover{color:#0062a4}#bootstrap-theme.manage-entitlements-form .wider-hr{margin-left:-20px;margin-right:-20px;border-width:2px}#bootstrap-theme.manage-entitlements-form .wider-row{margin-left:-20px;margin-right:-20px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters{padding:15px 0;text-align:center}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label{display:inline-block}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label:before{display:none}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .absence-type-filter{margin-right:10px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .col-sm-4:last-child{text-align:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list{margin-bottom:0}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .title{float:left;width:65%}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .actions{float:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list tr.hidden{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .absence-type{color:#fff;display:inline-block;padding:5px}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .overridden-proposed-entitlement,#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .calculation-unit{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .borderless-button{background-color:transparent;border:0;cursor:pointer}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .add-comment{font-size:1.1em}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .comment-text{display:none}#bootstrap-theme.manage-entitlements-form .manage-entitlements-form__filters{padding-bottom:1em}#bootstrap-theme.manage-entitlements-form .table{background:#f9f9f9;border-top:1px solid #e8eef0;border-bottom:1px solid #e8eef0;margin-bottom:2em}#bootstrap-theme.manage-entitlements-form .table th{background:#f3f6f7 !important}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:#e4ebed !important;min-width:200px}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .row>div{display:table-cell;float:none;vertical-align:bottom}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .fa{color:#4d4d69}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .action-button-container{padding:0}#bootstrap-theme.manage-entitlements-form .table td.proposed-entitlement{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:white}#bootstrap-theme.manage-entitlements-form .table span.absence-type{border-radius:3px;padding:0 5px}#bootstrap-theme.manage-entitlements-form .table tbody .fa{color:#0071bd}#bootstrap-theme.manage-entitlements-form .crm-container .CRM_HRLeaveAndAbsences_Form_ManageEntitlements .crm-button-type-next{float:right !important}#bootstrap-theme.manage-entitlements-form .panel-footer{border-top:none}#add-comment-dialog{display:none}#add-comment-dialog .calculation_comment{box-sizing:border-box;padding:10px;width:100%}#bootstrap-theme .crm-work-pattern-form-block .ui-tabs.ui-widget-content{background:none}#bootstrap-theme .work-pattern-calendar .number-of-weeks{padding:15px 0 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week{border-top:1px solid rgba(0,0,0,0.2);padding:15px 0 15px 0;margin-bottom:15px}#bootstrap-theme .work-pattern-calendar .work-pattern-week.hidden-week{display:none}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-number{float:left;font-weight:bold;padding:5px 0 15px 5px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days{table-layout:fixed}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours{float:right;padding:5px 5px 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours .number-of-hours{font-weight:bold}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days td{padding:5px 10px 5px 10px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days input{min-width:0;text-align:center}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days select{min-width:0;width:100% !important}#bootstrap-theme .work-pattern-calendar .work-pattern-week .hours-row td{padding-top:15px;padding-bottom:15px;border-top:1px solid rgba(0,0,0,0.2);border-bottom:1px solid rgba(0,0,0,0.2)}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:13px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.5384615385;color:#4d4d69;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#42425a;background-color:#f3f6f7}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#0071bd}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#e8eef0}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.5384615385;color:#464354;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width: 768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{left:0;right:auto}}.dropdown-header{padding:11px 20px}.dropdown-menu{-webkit-box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);border:0;margin:0;padding:0}.dropdown-menu>li{border:0;margin:0;padding:0}.dropdown-menu>li>a{padding:11px 20px}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
index 319ab39ee97..d8af6d230a1 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
@@ -1,5 +1,5 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/modules/shared-settings",["common/angular"],function(t){return t.module("leave-absences.settings",[]).constant("shared-settings",{attachmentToken:e.vars.leaveAndAbsences.attachmentToken,debug:e.debug,managerPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/",sharedPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/shared/",serverDateFormat:"YYYY-MM-DD",serverDateTimeFormat:"YYYY-MM-DD HH:mm:ss",permissions:{admin:{access:"access leave and absences",administer:"administer leave and absences"},ssp:{access:"access leave and absences in ssp",manage:"manage leave and absences in ssp"}},fileUploader:{queueLimit:10},statusNames:{approved:"approved",adminApproved:"admin_approved",awaitingApproval:"awaiting_approval",moreInformationRequired:"more_information_required",rejected:"rejected",cancelled:"cancelled"}})})}(CRM),define("leave-absences/shared/modules/apis",["common/angular","common/modules/apis","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.apis",["common.apis","leave-absences.settings"])}),define("leave-absences/shared/modules/models-instances",["common/angular","common/models/instances/instance","common/modules/services","common/modules/models","common/services/check-permissions","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models.instances",["common.models","common.models.instances","common.services","leave-absences.settings"])}),define("leave-absences/shared/modules/models",["common/angular","common/modules/models","common/modules/services","leave-absences/shared/modules/apis","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models",["common.models","common.services","leave-absences.apis","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,o){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,s,r){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),r=e.assign({},r,{absence_type_id:a,date:t(s).format(o.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",r).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,o,s,r){return t.debug("AbsenceType"),a.extend({all:function(e){return s.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return s.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return s.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return o.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,o,s,r){return this.sendPOST("ContactWorkPattern","create",e.assign({},r,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:o,change_reason:s})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,o,s){return t.debug("WorkPatternAPI.getCalendar",n,a,o,s),this.sendGET("WorkPattern","getcalendar",e.assign({},s,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:o}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,o){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),o).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,o,s,r){function i(t,n){return u().then(function(a){var o=this.days[c(t).valueOf()];return!!o&&e.find(a,function(e){return e.name===n}).value===o.type}.bind(this))}function c(e){return t(e,s.serverDateFormat).clone()}function u(){return l=l||r.valuesOf("hrleaveandabsences_work_day_type")}var l;return o.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[c(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,o){return t.debug("Calendar"),n.extend({get:function(n,s,r,i){return t.debug("Calendar.get"),a.getCalendar(n,s,r,i).then(function(t){var a=t.values.map(function(e){return o.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function o(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(o),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,o,s){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,o,"getLeaveBalances",s)}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,o,s){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return o.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return o.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),s.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,o,s,r){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,o,s,"getFull",r)),i.promise},balanceChangeByAbsenceType:function(t,n,o,s){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var r=a.defer();t&&n||r.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:o?{IN:o}:null,public_holiday:s||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){r.resolve(e.values)}),r.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var o=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?o.reject(t(e.values).map().flatten().value()):o.resolve(e.values)}),o.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,o,s,r,i,c){function u(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return c.all({id:this.type_id}).then(c.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function m(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function f(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return o.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),o=a.breakdown.length>1,s=e.first(e.values(a.breakdown)),r=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(s.date),o&&this.getWorkDayForDate(r.date)]).then(function(t){return s.amount=t[0].time_from?Math.min(this.from_date_amount,f(t[0])):0,o&&(r.amount=t[1].time_from?Math.min(this.to_date_amount,f(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return r.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return u.call(this,s.statusNames.cancelled)},approve:function(){return u.call(this,s.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return u.call(this,s.statusNames.rejected)},sendBack:function(){return u.call(this,s.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),m.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,s.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,s.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,s.statusNames.cancelled)},isRejected:function(){return d.call(this,s.statusNames.rejected)},isSentBack:function(){return d.call(this,s.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(s.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,o,s,r){return n.all(this.processFilters(e),t,o,s,r).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,o){return n.balanceChangeByAbsenceType(e,t,a,o)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/instances/work-pattern.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("WorkPatternInstance",["$log","ModelInstance",function(e,t){return e.debug("WorkPatternInstance"),t.extend({})}])}),define("leave-absences/shared/models/work-pattern.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/work-pattern.instance"],function(e,t){"use strict";t.factory("WorkPattern",["$log","Model","WorkPatternAPI","WorkPatternInstance",function(t,n,a,o){return t.debug("WorkPattern"),n.extend({assignWorkPattern:function(e,t,n,o,s,r){return a.assignWorkPattern(e,t,n,o,s,r)},default:function(){return a.get({is_default:!0}).then(function(t){return o.init(e.first(t),!0)})},unassignWorkPattern:function(e){return a.unassignWorkPattern(e)},workPatternsOf:function(e,t,n){return a.workPatternsOf(e,t,n).then(function(e){return e.map(function(e){return o.init(e,!0)})})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,o,s,r,i){function c(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(v.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(v.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function u(){return{loadContacts:function(){var e=v.filters.userSettings.assignedTo.type;return m(e).then(function(e){v.lookupContacts=e}).then(function(){return"me"!==e?c():a.resolve(null)}).then(function(e){return v.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return o.all(f(),null,"display_name").then(function(e){return e.list})}function d(){return h?a.resolve(h):r.all()}function m(e){return"me"===e?o.leaveManagees(v.contactId):"unassigned"===e?o.leaveManagees(void 0,{unassigned:!0}):o.all().then(function(e){return e.list})}function f(){return{department:v.filters.userSettings.department?v.filters.userSettings.department.value:null,level_type:v.filters.userSettings.level_type?v.filters.userSettings.level_type.value:null,location:v.filters.userSettings.location?v.filters.userSettings.location.value:null,region:v.filters.userSettings.region?v.filters.userSettings.region.value:null,id:{IN:v.filters.userSettings.contact?[v.filters.userSettings.contact.id]:v.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",["When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,u()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:r.contactId}).leaveManagees().then(function(e){r.lookupContacts=e}).then(o)}}}function o(){return t.all(s(),null,"display_name").then(function(e){return e.list})}function s(){return{department:r.filters.userSettings.department?r.filters.userSettings.department.value:null,level_type:r.filters.userSettings.level_type?r.filters.userSettings.level_type.value:null,location:r.filters.userSettings.location?r.filters.userSettings.location.value:null,region:r.filters.userSettings.region?r.filters.userSettings.region.value:null,id:{IN:r.filters.userSettings.contact?[r.filters.userSettings.contact.id]:r.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var r;return{init:function(e){return r=e,r.showContactName=!0,r.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function o(a,o,s,r,i,c,u,l,d,m){function f(){for(var e=[],t=n(O.selectedPeriod.start_date).clone().startOf("month"),a=n(O.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(A(t)),t.add(1,"month");O.months=e}function p(){r.$new().$watch(function(){return O.selectedMonths},function(t,n){null===n||e.equals(t,n)||w()})}function h(e){O.injectMonths=!0,L("injected").then(function(){w(e)}).then(function(){O.loading.calendar=!1})}function v(){S=a("LeaveCalendar"+t.capitalize(M)+"Controller").init(O)}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function g(){return c.all().then(function(e){O.absencePeriods=t.sortBy(e,"start_date"),O.selectedPeriod=t.find(O.absencePeriods,function(e){return!!e.current})}).then(f).then(I)}function _(){return u.all().then(u.loadCalculationUnits)}function y(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return S.loadContacts().then(function(e){O.contacts=e})}function C(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){O.filters.optionValues.regions=e.hrjc_region,O.filters.optionValues.locations=e.hrjc_location,O.filters.optionValues.levelTypes=e.hrjc_level_type,O.filters.optionValues.departments=e.hrjc_department})}function P(){return l.all()}function D(){return o.all([_(),P(),y()]).then(function(e){O.supportData.absenceTypes=e[0],O.supportData.publicHolidays=e[1],O.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,O.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,O.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,O.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function R(){var e=o.resolve();return O.injectMonths&&(e=L("destroyed"),O.injectMonths=!1),e}function A(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function T(e){e=t.includes(["contacts","period"],e)?e:"period",o.resolve().then(function(){O.loading.calendar=!0}).then(R).then("period"===e?f:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function w(e){var n=O.selectedMonths.length?O.months.filter(function(e){return t.includes(O.selectedMonths,e.index)}):O.months;r.$emit("LeaveCalendar::showMonths",n,!!e)}function I(){O.selectedMonths=[n().month()]}function k(){return O.roleOverride?o.resolve().then(function(){M=O.roleOverride}):o.all([m(i.permissions.admin.administer),m(i.permissions.ssp.manage)]).then(function(e){M=e[0]?"admin":e[1]?"manager":"staff"})}function L(e){return o(function(n){var a=0,o=r.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===O.months.length&&(o(),n())})})}s.debug("Component: leave-calendar");var S,M,O=this;O.absencePeriods=[],O.contacts=[],O.contactIdsToReduceTo=null,O.injectMonths=!1,O.months=[],O.selectedMonths=null,O.selectedPeriod=null,O.showContactName=!1,O.showFilters=!1,O.supportData={},O.loading={calendar:!0,page:!0},O.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},O.labelPeriod=b,O.refresh=T,function(){k().then(p).then(v).then(R).then(g).then(function(){return o.all([q(),D()])}).then(function(){return O.showFilters?C():t.noop}).then(function(){h()}).then(function(){O.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",o]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,o){"use strict";function s(){y.calculationUnit=r(y.supportData.calculationUnits,"value",b.calculation_unit)}function r(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(y.contactData.leaveRequest.from_date).isSame(y.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+y.calculationUnit.name+"-on-"+e+"-tooltip"}function c(){b=r(y.supportData.absenceTypes,"id",y.contactData.leaveRequest.type_id),y.contactData.leaveRequest["type_id.title"]=b.title}function u(){"days"===y.calculationUnit.name&&(g=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.from_date_type),_=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.to_date_type),y.contactData.leaveRequest["from_date_type.label"]=g.label,y.contactData.leaveRequest["to_date_type.label"]=_.label)}function l(e,t,n,a,s){e.stopPropagation(),o.openModal(t,n,a,s)}function d(){y.dates.from=new Date(y.contactData.leaveRequest.from_date),y.dates.to=new Date(y.contactData.leaveRequest.to_date)}function m(){y.contactData.isAccruedTOIL?y.label="AT":"days"===y.calculationUnit.name?f():p()}function f(){y.label=y.contactData.isAM?"AM":y.contactData.isPM?"PM":""}function p(){var e=t(y.contactData.leaveRequest.from_date).isSame(y.date,"day"),n=t(y.contactData.leaveRequest.to_date).isSame(y.date,"day");y.label=e?t(y.contactData.leaveRequest.from_date).format("HH:mm"):n?t(y.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){y.tooltipTemplate=y.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){y.contactData&&y.contactData.leaveRequest&&(c(),s(),u(),m(),d(),h())
-})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){F.push(o.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",u)),F.push(i.subscribe("LeaveRequest::edit",B)),F.push(i.subscribe("LeaveRequest::updatedByManager",B)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){j=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!j)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var j=!1,F=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function j(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(j("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!j("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=j,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||j("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:F(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[F(m.statusNames.rejected),F(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{
-in:[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)]}})}function L(){return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function j(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function F(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=j,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==F())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return j($e.getStatusFromValue($e.request.status_id).name)}function j(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function F(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():j("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=F(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrjc_revision_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrjc_revision_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,t=C.changeLogRows.length-1;e>=0;){
-var n=C.changeLogRows[e],a=C.changeLogRows[t];n.entitlements.forEach(function(e,t){var n=a.entitlements[t];e.comment===n.comment&&delete e.comment}),e--,t--}}function _(e){var t,n,a=C.changeLogRows[e];u(a,function(o,s,r){o.comment&&(t=s.concat(o).concat(r),n={date:a.date.clone(),entitlements:t},n.highlightedEntitlement=o,p(n,e++))}),y(e)}function y(e){C.changeLogRows.splice(e,1)}var q=[],C=this;C.absencePeriod=null,C.absenceTypes=[],C.changeLogRows=[],C.loading={component:!0},function(){h().then(v).then(b).then(i).then(c).then(g).then(f).finally(function(){C.loading.component=!1})}()}n.component("annualEntitlementChangeLog",{bindings:{contactId:"<",periodId:"<",dismissModal:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlement-change-log.html"}],controllerAs:"changeLog",controller:a}),a.$inject=["AbsencePeriod","AbsenceType","Entitlement","OptionGroup","shared-settings"]}),function(e){define("leave-absences/absence-tab/components/annual-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contact"],function(t,n,a){function o(a,o,s,r,i,c,u,l,d){function m(){P.absencePeriods=t.chain(P.absencePeriods).filter(function(e){return t.find(q,function(t){return t.period_id===e.id})}).sortBy(function(e){return-n(e.start_date).valueOf()}).value()}function f(){P.absenceTypes=t.filter(P.absenceTypes,function(e){return t.find(q,function(t){return t.type_id===e.id})})}function p(t){var n=e.url("civicrm/contact/view",{cid:P.contactId,selectedChild:"absence"});return e.url("civicrm/admin/leaveandabsences/periods/manage_entitlements",{id:t,cid:P.contactId,returnUrl:n})}function h(){return c.all().then(function(e){P.absencePeriods=e})}function v(){var e=t.uniq(t.map(q,function(e){return e.editor_id}));return l.all({id:{IN:e}}).then(function(e){C=t.indexBy(e.list,"contact_id")})}function b(){return u.all({contact_id:P.contactId}).then(function(e){q=e})}function g(e){r.open({appendTo:s.children().eq(0),templateUrl:"annual-entitlement-change-log-modal",controller:["$uibModalInstance",function(t){this.contactId=P.contactId,this.dismiss=t.dismiss,this.periodId=e}],controllerAs:"modal"})}function _(){P.absencePeriods=t.map(P.absencePeriods,function(e){var n=t.map(P.absenceTypes,function(n){var a=t.find(q,function(t){return t.type_id===n.id&&t.period_id===e.id});return a?{amount:a.value,calculation_unit:n.calculation_unit_name,comment:a.comment?{message:a.comment,author_name:C[a.editor_id].display_name,date:a.created_date}:null}:null});return{id:e.id,title:e.title,entitlements:n}})}function y(e){var t=e.message+"Last updated: By: "+e.author_name+" Date: "+n.utc(e.date).local().format("DD/M/YYYY HH:mm")+" ";d.info("Calculation comment:",t)}a.debug("Component: annual-entitlements");var q=[],C=[],P=this;P.absencePeriods=[],P.loading={absencePeriods:!0},P.getEditEntitlementsPageURL=p,P.openAnnualEntitlementChangeLog=g,P.showComment=y,function(){b().then(v).then(h).then(m).then(f).then(_).finally(function(){P.loading.absencePeriods=!1})}()}a.component("annualEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlements.html"}],controllerAs:"entitlements",controller:o}),o.$inject=["$log","$q","$rootElement","$uibModal","AbsenceType","AbsencePeriod","Entitlement","Contact","notificationService"]})}(CRM),define("leave-absences/absence-tab/components/contract-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r,i){function c(){m.absenceTypes=e.filter(m.absenceTypes,function(t){return e.find(m.contracts,function(n){return e.find(n.info.leave,function(e){return e.leave_type===t.id})})})}function u(e){var n=o.DATE_FORMAT.toUpperCase();return e?t(e).format(n):""}function l(){return r.all({contact_id:m.contactId}).then(function(e){m.contracts=e})}function d(){m.contracts=e.sortBy(m.contracts,function(e){return t(e.info.details.period_start_date)}).map(function(t){var n=t.info,a=n.details,o=e.map(m.absenceTypes,function(t){var a=e.filter(n.leave,function(e){return e.leave_type===t.id})[0];return{amount:a?a.leave_amount:"",calculation_unit:t.calculation_unit_name}});return{position:a.position,start_date:u(a.period_start_date),end_date:u(a.period_end_date),absences:o}})}n.debug("Component: contract-entitlements");var m=this;m.contracts=[],m.loading={contracts:!0},function(){i.getDateFormat().then(l).then(c).then(d).finally(function(){m.loading.contracts=!1})}()}n.component("contractEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/contract-entitlements.html"}],controllerAs:"entitlements",controller:a}),a.$inject=["$log","$q","HR_settings","AbsenceType","Contract","DateFormat"]}),function(e){define("leave-absences/absence-tab/modules/settings",["common/angular"],function(t){return t.module("absence-tab.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.contactId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/absence-tab/"})})}(CRM),define("leave-absences/absence-tab/modules/config",["common/angular","leave-absences/absence-tab/modules/settings"],function(e){return e.module("absence-tab.config",["absence-tab.settings"]).config(["$resourceProvider","$httpProvider","$logProvider","settings",function(e,t,n,a){n.debugEnabled(a.debug),e.defaults.stripTrailingSlashes=!1,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}])}),define("leave-absences/absence-tab/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/modules/directives","common/services/check-permissions","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/absence-tab/components/absence-tab-container.component","leave-absences/absence-tab/components/absence-tab-entitlements.component","leave-absences/absence-tab/components/absence-tab-work-patterns.component","leave-absences/absence-tab/components/annual-entitlement-change-log.component","leave-absences/absence-tab/components/annual-entitlements.component","leave-absences/absence-tab/components/contract-entitlements.component","leave-absences/absence-tab/modules/config"],function(e){return e.module("absence-tab",["ngResource","ui.bootstrap","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.services","common.mocks","leave-absences.settings","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","absence-tab.config","absence-tab.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/absence-tab":n+"/absence-tab"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/absence-tab/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("absenceTabReady"):function(){var e=document.createEvent("Event");return e.initEvent("absenceTabReady",!0,!0),e}())})})}(CRM,require),define("absence-tab",function(){});
+})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){F.push(o.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",u)),F.push(i.subscribe("LeaveRequest::edit",B)),F.push(i.subscribe("LeaveRequest::updatedByManager",B)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){j=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!j)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var j=!1,F=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function j(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(j("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!j("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=j,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||j("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:F(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[F(m.statusNames.rejected),F(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{in:[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)]}})}function L(){
+return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function j(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function F(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=j,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==F())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return j($e.getStatusFromValue($e.request.status_id).name)}function j(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function F(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():j("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=F(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrjc_revision_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrjc_revision_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,t=C.changeLogRows.length-1;e>=0;){var n=C.changeLogRows[e],a=C.changeLogRows[t];n.entitlements.forEach(function(e,t){var n=a.entitlements[t]
+;e.comment===n.comment&&delete e.comment}),e--,t--}}function _(e){var t,n,a=C.changeLogRows[e];u(a,function(o,s,r){o.comment&&(t=s.concat(o).concat(r),n={date:a.date.clone(),entitlements:t},n.highlightedEntitlement=o,p(n,e++))}),y(e)}function y(e){C.changeLogRows.splice(e,1)}var q=[],C=this;C.absencePeriod=null,C.absenceTypes=[],C.changeLogRows=[],C.loading={component:!0},function(){h().then(v).then(b).then(i).then(c).then(g).then(f).finally(function(){C.loading.component=!1})}()}n.component("annualEntitlementChangeLog",{bindings:{contactId:"<",periodId:"<",dismissModal:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlement-change-log.html"}],controllerAs:"changeLog",controller:a}),a.$inject=["AbsencePeriod","AbsenceType","Entitlement","OptionGroup","shared-settings"]}),function(e){define("leave-absences/absence-tab/components/annual-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contact"],function(t,n,a){function o(a,o,s,r,i,c,u,l,d){function m(){P.absencePeriods=t.chain(P.absencePeriods).filter(function(e){return t.find(q,function(t){return t.period_id===e.id})}).sortBy(function(e){return-n(e.start_date).valueOf()}).value()}function f(){P.absenceTypes=t.filter(P.absenceTypes,function(e){return t.find(q,function(t){return t.type_id===e.id})})}function p(t){var n=e.url("civicrm/contact/view",{cid:P.contactId,selectedChild:"absence"});return e.url("civicrm/admin/leaveandabsences/periods/manage_entitlements",{id:t,cid:P.contactId,returnUrl:n})}function h(){return c.all().then(function(e){P.absencePeriods=e})}function v(){var e=t.uniq(t.map(q,function(e){return e.editor_id}));return l.all({id:{IN:e}}).then(function(e){C=t.indexBy(e.list,"contact_id")})}function b(){return u.all({contact_id:P.contactId}).then(function(e){q=e})}function g(e){r.open({appendTo:s.children().eq(0),templateUrl:"annual-entitlement-change-log-modal",controller:["$uibModalInstance",function(t){this.contactId=P.contactId,this.dismiss=t.dismiss,this.periodId=e}],controllerAs:"modal"})}function _(){P.absencePeriods=t.map(P.absencePeriods,function(e){var n=t.map(P.absenceTypes,function(n){var a=t.find(q,function(t){return t.type_id===n.id&&t.period_id===e.id});return a?{amount:a.value,calculation_unit:n.calculation_unit_name,comment:a.comment?{message:a.comment,author_name:C[a.editor_id].display_name,date:a.created_date}:null}:null});return{id:e.id,title:e.title,entitlements:n}})}function y(e){var t=e.message+"Last updated: By: "+e.author_name+" Date: "+n.utc(e.date).local().format("DD/M/YYYY HH:mm")+" ";d.info("Calculation comment:",t)}a.debug("Component: annual-entitlements");var q=[],C=[],P=this;P.absencePeriods=[],P.loading={absencePeriods:!0},P.getEditEntitlementsPageURL=p,P.openAnnualEntitlementChangeLog=g,P.showComment=y,function(){b().then(v).then(h).then(m).then(f).then(_).finally(function(){P.loading.absencePeriods=!1})}()}a.component("annualEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlements.html"}],controllerAs:"entitlements",controller:o}),o.$inject=["$log","$q","$rootElement","$uibModal","AbsenceType","AbsencePeriod","Entitlement","Contact","notificationService"]})}(CRM),define("leave-absences/absence-tab/components/contract-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r,i){function c(){m.absenceTypes=e.filter(m.absenceTypes,function(t){return e.find(m.contracts,function(n){return e.find(n.info.leave,function(e){return e.leave_type===t.id})})})}function u(e){var n=o.DATE_FORMAT.toUpperCase();return e?t(e).format(n):""}function l(){return r.all({contact_id:m.contactId}).then(function(e){m.contracts=e})}function d(){m.contracts=e.sortBy(m.contracts,function(e){return t(e.info.details.period_start_date)}).map(function(t){var n=t.info,a=n.details,o=e.map(m.absenceTypes,function(t){var a=e.filter(n.leave,function(e){return e.leave_type===t.id})[0];return{amount:a?a.leave_amount:"",calculation_unit:t.calculation_unit_name}});return{position:a.position,start_date:u(a.period_start_date),end_date:u(a.period_end_date),absences:o}})}n.debug("Component: contract-entitlements");var m=this;m.contracts=[],m.loading={contracts:!0},function(){i.getDateFormat().then(l).then(c).then(d).finally(function(){m.loading.contracts=!1})}()}n.component("contractEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/contract-entitlements.html"}],controllerAs:"entitlements",controller:a}),a.$inject=["$log","$q","HR_settings","AbsenceType","Contract","DateFormat"]}),function(e){define("leave-absences/absence-tab/modules/settings",["common/angular"],function(t){return t.module("absence-tab.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.contactId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/absence-tab/"})})}(CRM),define("leave-absences/absence-tab/modules/config",["common/angular","leave-absences/absence-tab/modules/settings"],function(e){return e.module("absence-tab.config",["absence-tab.settings"]).config(["$resourceProvider","$httpProvider","$logProvider","settings",function(e,t,n,a){n.debugEnabled(a.debug),e.defaults.stripTrailingSlashes=!1,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}])}),define("leave-absences/absence-tab/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/modules/directives","common/services/check-permissions","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/absence-tab/components/absence-tab-container.component","leave-absences/absence-tab/components/absence-tab-entitlements.component","leave-absences/absence-tab/components/absence-tab-work-patterns.component","leave-absences/absence-tab/components/annual-entitlement-change-log.component","leave-absences/absence-tab/components/annual-entitlements.component","leave-absences/absence-tab/components/contract-entitlements.component","leave-absences/absence-tab/modules/config"],function(e){return e.module("absence-tab",["ngResource","ui.bootstrap","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.services","common.mocks","leave-absences.settings","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","absence-tab.config","absence-tab.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/absence-tab":n+"/absence-tab"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/absence-tab/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("absenceTabReady"):function(){var e=document.createEvent("Event");return e.initEvent("absenceTabReady",!0,!0),e}())})})}(CRM,require),define("absence-tab",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js
index 819333dc536..a8a385f1b4e 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js
@@ -8,7 +8,7 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/ui-router",[],function(){return function(){"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(e,t,n){"use strict";function a(e,t){return W(new(W(function(){},{prototype:e})),t)}function r(e){return H(arguments,function(t){t!==e&&H(t,function(t,n){e.hasOwnProperty(n)||(e[n]=t)})}),e}function o(e,t){var n=[];for(var a in e.path){if(e.path[a]!==t.path[a])break;n.push(e.path[a])}return n}function s(e){if(Object.keys)return Object.keys(e);var t=[];return H(e,function(e,n){t.push(n)}),t}function i(e,t){if(Array.prototype.indexOf)return e.indexOf(t,Number(arguments[2])||0);var n=e.length>>>0,a=Number(arguments[2])||0;for((a=a<0?Math.ceil(a):Math.floor(a))<0&&(a+=n);a=0||(l.push(r[f]),c[r[f]]=e[r[f]]);return W({},c,t)}function c(e,t,n){if(!n){n=[];for(var a in e)n.push(a)}for(var r=0;r "));if(b[n]=a,N(e))v.push(n,[function(){return t.get(e)}],c);else{var r=t.annotate(e);H(r,function(e){e!==n&&u.hasOwnProperty(e)&&m(u[e],e)}),v.push(n,e,r)}g.pop(),b[n]=o}}function p(e){return F(e)&&e.then&&e.$$promises}if(!F(u))throw new Error("'invocables' must be an object");var h=s(u||{}),v=[],g=[],b={};return H(u,m),u=g=b=null,function(a,o,s){function i(){--y||(_||r(b,o.$$values),m.$$values=b,m.$$promises=m.$$promises||!0,delete m.$$inheritedValues,c.resolve(b))}function u(e){m.$$failure=e,c.reject(e)}if(p(a)&&s===n&&(s=o,o=a,a=null),a){if(!F(a))throw new Error("'locals' must be an object")}else a=l;if(o){if(!p(o))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else o=d;var c=e.defer(),m=c.promise,g=m.$$promises={},b=W({},a),y=1+v.length/3,_=!1;if(j(o.$$failure))return u(o.$$failure),m;o.$$inheritedValues&&r(b,f(o.$$inheritedValues,h)),W(g,o.$$promises),o.$$values?(_=r(b,f(o.$$values,h)),m.$$inheritedValues=f(o.$$values,h),i()):(o.$$inheritedValues&&(m.$$inheritedValues=f(o.$$inheritedValues,h)),o.then(i,u));for(var q=0,$=v.length;q<$;q+=3)a.hasOwnProperty(v[q])?i():function(n,r,o){function c(e){d.reject(e),u(e)}function l(){if(!j(m.$$failure))try{d.resolve(t.invoke(r,s,b)),d.promise.then(function(e){b[n]=e,i()},c)}catch(e){c(e)}}var d=e.defer(),f=0;H(o,function(e){g.hasOwnProperty(e)&&!a.hasOwnProperty(e)&&(f++,g[e].then(function(t){b[e]=t,--f||l()},c))}),f||l(),g[n]=d.promise}(v[q],v[q+1],v[q+2]);return m}},this.resolve=function(e,t,n,a){return this.study(e)(t,n,a)}}function g(e,t,n){this.fromConfig=function(e,t,n){return j(e.template)?this.fromString(e.template,t):j(e.templateUrl)?this.fromUrl(e.templateUrl,t):j(e.templateProvider)?this.fromProvider(e.templateProvider,t,n):null},this.fromString=function(e,t){return B(e)?e(t):e},this.fromUrl=function(n,a){return B(n)&&(n=n(a)),null==n?null:e.get(n,{cache:t,headers:{Accept:"text/html"}}).then(function(e){return e.data})},this.fromProvider=function(e,t,a){return n.invoke(e,null,a||{params:t})}}function b(e,t,r){function o(t,n,a,r){if(v.push(t),p[t])return p[t];if(!/^\w+([-.]+\w+)*(?:\[\])?$/.test(t))throw new Error("Invalid parameter name '"+t+"' in pattern '"+e+"'");if(h[t])throw new Error("Duplicate parameter name '"+t+"' in pattern '"+e+"'");return h[t]=new Y.Param(t,n,a,r),h[t]}function s(e,t,n,a){var r=["",""],o=e.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!t)return o;switch(n){case!1:r=["(",")"+(a?"?":"")];break;case!0:o=o.replace(/\/$/,""),r=["(?:/(",")|/)?"];break;default:r=["("+n+"|",")?"]}return o+r[0]+t+r[1]}function i(r,o){var s,i,u,c,l;return s=r[2]||r[3],l=t.params[s],u=e.substring(f,r.index),i=o?r[4]:r[4]||("*"==r[1]?".*":null),i&&(c=Y.type(i)||a(Y.type("string"),{pattern:new RegExp(i,t.caseInsensitive?"i":n)})),{id:s,regexp:i,segment:u,type:c,cfg:l}}t=W({params:{}},F(t)?t:{});var u,c=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l=/([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,d="^",f=0,m=this.segments=[],p=r?r.params:{},h=this.params=r?r.params.$$new():new Y.ParamSet,v=[];this.source=e;for(var g,b,y;(u=c.exec(e))&&(g=i(u,!1),!(g.segment.indexOf("?")>=0));)b=o(g.id,g.type,g.cfg,"path"),d+=s(g.segment,b.type.pattern.source,b.squash,b.isOptional),m.push(g.segment),f=c.lastIndex;y=e.substring(f);var _=y.indexOf("?");if(_>=0){var q=this.sourceSearch=y.substring(_);if(y=y.substring(0,_),this.sourcePath=e.substring(0,f+_),q.length>0)for(f=0;u=l.exec(q);)g=i(u,!0),b=o(g.id,g.type,g.cfg,"search"),f=c.lastIndex}else this.sourcePath=e,this.sourceSearch="";d+=s(y)+(!1===t.strict?"/?":"")+"$",m.push(y),this.regexp=new RegExp(d,t.caseInsensitive?"i":n),this.prefix=m[0],this.$$paramNames=v}function y(e){W(this,e)}function _(){function e(e){return null!=e?e.toString().replace(/(~|\/)/g,function(e){return{"~":"~~","/":"~2F"}[e]}):e}function r(e){return null!=e?e.toString().replace(/(~~|~2F)/g,function(e){return{"~~":"~","~2F":"/"}[e]}):e}function o(){return{strict:h,caseInsensitive:f}}function u(e){return B(e)||U(e)&&B(e[e.length-1])}function c(){for(;$.length;){var e=$.shift();if(e.pattern)throw new Error("You cannot override a type's .pattern at runtime.");t.extend(g[e.name],d.invoke(e.def))}}function l(e){W(this,e||{})}Y=this;var d,f=!1,h=!0,v=!1,g={},q=!0,$=[],C={string:{encode:e,decode:r,is:function(e){return null==e||!j(e)||"string"==typeof e},pattern:/[^\/]*/},int:{encode:e,decode:function(e){return parseInt(e,10)},is:function(e){return j(e)&&this.decode(e.toString())===e},pattern:/\d+/},bool:{encode:function(e){return e?1:0},decode:function(e){return 0!==parseInt(e,10)},is:function(e){return!0===e||!1===e},pattern:/0|1/},date:{encode:function(e){return this.is(e)?[e.getFullYear(),("0"+(e.getMonth()+1)).slice(-2),("0"+e.getDate()).slice(-2)].join("-"):n},decode:function(e){if(this.is(e))return e;var t=this.capture.exec(e);return t?new Date(t[1],t[2]-1,t[3]):n},is:function(e){return e instanceof Date&&!isNaN(e.valueOf())},equals:function(e,t){return this.is(e)&&this.is(t)&&e.toISOString()===t.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:t.toJson,decode:t.fromJson,is:t.isObject,equals:t.equals,pattern:/[^\/]*/},any:{encode:t.identity,decode:t.identity,equals:t.equals,pattern:/.*/}};_.$$getDefaultValue=function(e){if(!u(e.value))return e.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(e.value)},this.caseInsensitive=function(e){return j(e)&&(f=e),f},this.strictMode=function(e){return j(e)&&(h=e),h},this.defaultSquashPolicy=function(e){if(!j(e))return v;if(!0!==e&&!1!==e&&!N(e))throw new Error("Invalid squash policy: "+e+". Valid policies: false, true, arbitrary-string");return v=e,e},this.compile=function(e,t){return new b(e,W(o(),t))},this.isMatcher=function(e){if(!F(e))return!1;var t=!0;return H(b.prototype,function(n,a){B(n)&&(t=t&&j(e[a])&&B(e[a]))}),t},this.type=function(e,t,n){if(!j(t))return g[e];if(g.hasOwnProperty(e))throw new Error("A type named '"+e+"' has already been defined.");return g[e]=new y(W({name:e},t)),n&&($.push({name:e,def:n}),q||c()),this},H(C,function(e,t){g[t]=new y(W({name:t},e))}),g=a(g,{}),this.$get=["$injector",function(e){return d=e,q=!1,c(),H(C,function(e,t){g[t]||(g[t]=new y(e))}),this}],this.Param=function(e,a,r,o){function c(){if(!d)throw new Error("Injectable functions cannot be called at configuration time");var e=d.invoke(r.$$fn);if(null!==e&&e!==n&&!h.type.is(e))throw new Error("Default value ("+e+") for parameter '"+h.id+"' is not an instance of Type ("+h.type.name+")");return e}function l(e){function t(e){return function(t){return t.from===e}}return e=function(e){var n=p(m(h.replace,t(e)),function(e){return e.to});return n.length?n[0]:e}(e),j(e)?h.type.$normalize(e):c()}function f(){return"{Param:"+e+" "+a+" squash: '"+q+"' optional: "+_+"}"}var h=this;r=function(e){var t=F(e)?s(e):[];return-1===i(t,"value")&&-1===i(t,"type")&&-1===i(t,"squash")&&-1===i(t,"array")&&(e={value:e}),e.$$fn=u(e.value)?e.value:function(){return e.value},e}(r),a=function(n,a,r){if(n.type&&a)throw new Error("Param '"+e+"' has two type configurations.");return a||(n.type?t.isString(n.type)?g[n.type]:n.type instanceof y?n.type:new y(n.type):"config"===r?g.any:g.string)}(r,a,o);var b=function(){var t={array:"search"===o&&"auto"},n=e.match(/\[\]$/)?{array:!0}:{};return W(t,n,r).array}();a=b?a.$asArray(b,"search"===o):a,"string"!==a.name||b||"path"!==o||r.value!==n||(r.value="");var _=r.value!==n,q=function(e,t){var n=e.squash;if(!t||!1===n)return!1;if(!j(n)||null==n)return v;if(!0===n||N(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(r,_),$=function(e,t,a,r){var o,s,u=[{from:"",to:a||t?n:""},{from:null,to:a||t?n:""}];return o=U(e.replace)?e.replace:[],N(r)&&o.push({from:r,to:n}),s=p(o,function(e){return e.from}),m(u,function(e){return-1===i(s,e.from)}).concat(o)}(r,b,_,q);W(this,{id:e,type:a,location:o,array:b,squash:q,replace:$,isOptional:_,value:l,dynamic:n,config:r,toString:f})},l.prototype={$$new:function(){return a(this,W(new l,{$$parent:this}))},$$keys:function(){for(var e=[],t=[],n=this,a=s(l.prototype);n;)t.push(n),n=n.$$parent;return t.reverse(),H(t,function(t){H(s(t),function(t){-1===i(e,t)&&-1===i(a,t)&&e.push(t)})}),e},$$values:function(e){var t={},n=this;return H(n.$$keys(),function(a){t[a]=n[a].value(e&&e[a])}),t},$$equals:function(e,t){var n=!0,a=this;return H(a.$$keys(),function(r){var o=e&&e[r],s=t&&t[r];a[r].type.equals(o,s)||(n=!1)}),n},$$validates:function(e){var a,r,o,s,i,u=this.$$keys();for(a=0;a=0)throw new Error("State must have a valid name");if(P.hasOwnProperty(n))throw new Error("State '"+n+"' is already defined");var r=-1!==n.indexOf(".")?n.substring(0,n.lastIndexOf(".")):N(t.parent)?t.parent:F(t.parent)&&N(t.parent.name)?t.parent.name:"";if(r&&!P[r])return m(r,t.self);for(var o in S)B(S[o])&&(t[o]=S[o](t,S.$delegates[o]));return P[n]=t,!t[R]&&t.url&&e.when(t.url,["$match","$stateParams",function(e,n){A.$current.navigable==t&&c(e,n)||A.transitionTo(t,e,{inherit:!0,location:!1})}]),v(n),t}function b(e){return e.indexOf("*")>-1}function y(e){for(var t=e.split("."),n=A.$current.name.split("."),a=0,r=t.length;a=P;a--)s=p[a],s.self.onExit&&i.invoke(s.self.onExit,s.self,s.locals.globals),s.locals=null;for(a=P;a<_.length;a++)r=_[a],r.locals=M[a],r.self.onEnter&&i.invoke(r.self.onEnter,r.self,r.locals.globals);return A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.$current=t,A.current=t.self,A.params=n,V(A.params,m),A.transition=null,o.location&&t.navigable&&v.push(t.navigable.url,t.navigable.locals.globals.$stateParams,{$$avoidResync:!0,replace:"replace"===o.location}),o.notify&&e.$broadcast("$stateChangeSuccess",t.self,n,c.self,d),v.update(!0),A.current)}).then(null,function(a){return a===D?S:A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.transition=null,s=e.$broadcast("$stateChangeError",t.self,n,c.self,d,a),s.defaultPrevented||v.update(),r.reject(a))});return B},A.is=function(e,t,a){a=W({relative:A.$current},a||{});var r=f(e,a.relative);return j(r)?A.$current===r&&(!t||c(r.params.$$values(t),m)):n},A.includes=function(e,t,a){if(a=W({relative:A.$current},a||{}),N(e)&&b(e)){if(!y(e))return!1;e=A.$current.name}var r=f(e,a.relative);if(!j(r))return n;if(!j(A.$current.includes[r.name]))return!1;if(!t)return!0;for(var o=s(t),i=0;i2?c.enter(e,null,n).then(a):c.enter(e,null,n,a)},leave:function(e,n){t.version.minor>2?c.leave(e).then(n):c.leave(e,n)}};if(u){var a=u&&u(n,e);return{enter:function(e,t,n){a.enter(e,null,t),n()},leave:function(e,t){a.leave(e),t()}}}return function(){return{enter:function(e,t,n){t.after(e),n()},leave:function(e,t){e.remove(),t()}}}()}var i=function(){return n.has?function(e){return n.has(e)?n.get(e):null}:function(e){try{return n.get(e)}catch(e){return null}}}(),u=i("$animator"),c=i("$animate");return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(n,i,u){return function(n,i,c){function l(){if(f&&(f.remove(),f=null),p&&(p.$destroy(),p=null),m){var e=m.data("$uiViewAnim");b.leave(m,function(){e.$$animLeave.resolve(),f=null}),f=m,m=null}}function d(s){var d,f=D(n,c,i,r),y=f&&e.$current&&e.$current.locals[f];if(s||y!==h){d=n.$new(),h=e.$current.locals[f],d.$emit("$viewContentLoading",f);var _=u(d,function(e){var r=o.defer(),s=o.defer(),u={$animEnter:r.promise,$animLeave:s.promise,$$animLeave:s};e.data("$uiViewAnim",u),b.enter(e,i,function(){r.resolve(),p&&p.$emit("$viewContentAnimationEnded"),(t.isDefined(g)&&!g||n.$eval(g))&&a(e)}),l()});m=_,p=d,p.$emit("$viewContentLoaded",f),p.$eval(v)}}var f,m,p,h,v=c.onload||"",g=c.autoscroll,b=s(c,n);i.inheritedData("$uiView"),n.$on("$stateChangeSuccess",function(){d(!1)}),d(!0)}}}}function P(e,n,a,r){return{restrict:"ECA",priority:-400,compile:function(o){var s=o.html();return function(o,i,u){var c=a.$current,l=D(o,u,i,r),d=c&&c.locals[l];if(d){i.data("$uiView",{name:l,state:d.$$state}),i.html(d.$template?d.$template:s);var f=t.extend({},d);o[d.$$resolveAs]=f;var m=e(i.contents());if(d.$$controller){d.$scope=o,d.$element=i;var p=n(d.$$controller,d);d.$$controllerAs&&(o[d.$$controllerAs]=p,o[d.$$controllerAs][d.$$resolveAs]=f),B(p.$onInit)&&p.$onInit(),i.data("$ngControllerController",p),i.children().data("$ngControllerController",p)}m(o)}}}}}function D(e,t,n,a){var r=a(t.uiView||t.name||"")(e),o=n.inheritedData("$uiView");return r.indexOf("@")>=0?r:r+"@"+(o?o.state.name:"")}function R(e,t){var n,a=e.match(/^\s*({[^}]*})\s*$/);if(a&&(e=t+"("+a[1]+")"),!(n=e.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/))||4!==n.length)throw new Error("Invalid state ref '"+e+"'");return{state:n[1],paramExpr:n[3]||null}}function S(e){var t=e.parent().inheritedData("$uiView");if(t&&t.state&&t.state.name)return t.state}function T(e){var t="[object SVGAnimatedString]"===Object.prototype.toString.call(e.prop("href")),n="FORM"===e[0].nodeName;return{attr:n?"action":t?"xlink:href":"href",isAnchor:"A"===e.prop("tagName").toUpperCase(),clickable:!n}}function I(e,t,n,a,r){return function(o){var s=o.which||o.button,i=r();if(!(s>1||o.ctrlKey||o.metaKey||o.shiftKey||e.attr("target"))){var u=n(function(){t.go(i.state,i.params,i.options)});o.preventDefault();var c=a.isAnchor&&!i.href?1:0;o.preventDefault=function(){c--<=0&&n.cancel(u)}}}}function O(e,t){return{relative:S(e)||t.$current,inherit:!0}}function L(e,n){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(a,r,o,s){var i,u=R(o.uiSref,e.current.name),c={state:u.state,href:null,params:null},l=T(r),d=s[1]||s[0],f=null;c.options=W(O(r,e),o.uiSrefOpts?a.$eval(o.uiSrefOpts):{});var m=function(n){n&&(c.params=t.copy(n)),c.href=e.href(u.state,c.params,c.options),f&&f(),d&&(f=d.$$addStateInfo(u.state,c.params)),null!==c.href&&o.$set(l.attr,c.href)};u.paramExpr&&(a.$watch(u.paramExpr,function(e){e!==c.params&&m(e)},!0),c.params=t.copy(a.$eval(u.paramExpr))),m(),l.clickable&&(i=I(r,e,n,l,function(){return c}),r[r.on?"on":"bind"]("click",i),a.$on("$destroy",function(){r[r.off?"off":"unbind"]("click",i)}))}}}function M(e,t){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(n,a,r,o){function s(t){f.state=t[0],f.params=t[1],f.options=t[2],f.href=e.href(f.state,f.params,f.options),m&&m(),c&&(m=c.$$addStateInfo(f.state,f.params)),f.href&&r.$set(u.attr,f.href)}var i,u=T(a),c=o[1]||o[0],l=[r.uiState,r.uiStateParams||null,r.uiStateOpts||null],d="["+l.map(function(e){return e||"null"}).join(", ")+"]",f={state:null,params:null,options:null,href:null},m=null;n.$watch(d,s,!0),s(n.$eval(d)),u.clickable&&(i=I(a,e,t,u,function(){return f}),a[a.on?"on":"bind"]("click",i),n.$on("$destroy",function(){a[a.off?"off":"unbind"]("click",i)}))}}}function k(e,t,n){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout",function(t,a,r,o){function s(t,n,r){var o=e.get(t,S(a)),s=i(t,n),u={state:o||{name:t},params:n,hash:s};return h.push(u),v[s]=r,function(){var e=h.indexOf(u);-1!==e&&h.splice(e,1)}}function i(e,n){if(!N(e))throw new Error("state should be a string");return F(n)?e+G(n):(n=t.$eval(n),F(n)?e+G(n):e)}function u(){for(var e=0;e0)){var n=s(e,t,p);return u(),n}},t.$on("$stateChangeSuccess",u),u()}]}}function x(e){var t=function(t,n){return e.is(t,n)};return t.$stateful=!0,t}function E(e){var t=function(t,n,a){return e.includes(t,n,a)};return t.$stateful=!0,t}var j=t.isDefined,B=t.isFunction,N=t.isString,F=t.isObject,U=t.isArray,H=t.forEach,W=t.extend,V=t.copy,G=t.toJson;t.module("ui.router.util",["ng"]),t.module("ui.router.router",["ui.router.util"]),t.module("ui.router.state",["ui.router.router","ui.router.util"]),t.module("ui.router",["ui.router.state"]),t.module("ui.router.compat",["ui.router"]),v.$inject=["$q","$injector"],t.module("ui.router.util").service("$resolve",v),g.$inject=["$http","$templateCache","$injector"],t.module("ui.router.util").service("$templateFactory",g);var Y;b.prototype.concat=function(e,t){var n={caseInsensitive:Y.caseInsensitive(),strict:Y.strictMode(),squash:Y.defaultSquashPolicy()};return new b(this.sourcePath+e+this.sourceSearch,W(n,t),this)},b.prototype.toString=function(){return this.source},b.prototype.exec=function(e,t){var n=this.regexp.exec(e);if(!n)return null;t=t||{};var a,r,o,s=this.parameters(),i=s.length,u=this.segments.length-1,c={};if(u!==n.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");var l,d;for(a=0;aWhen All filter is selected, all staff members with contracts which are active in the selected absence period are displayed."," People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,c()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:s.contactId}).leaveManagees().then(function(e){s.lookupContacts=e}).then(r)}}}function r(){return t.all(o(),null,"display_name").then(function(e){return e.list})}function o(){return{department:s.filters.userSettings.department?s.filters.userSettings.department.value:null,level_type:s.filters.userSettings.level_type?s.filters.userSettings.level_type.value:null,location:s.filters.userSettings.location?s.filters.userSettings.location.value:null,region:s.filters.userSettings.region?s.filters.userSettings.region.value:null,id:{IN:s.filters.userSettings.contact?[s.filters.userSettings.contact.id]:s.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var s;return{init:function(e){return s=e,s.showContactName=!0,s.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function r(a,r,o,s,i,u,c,l,d,f){function m(){for(var e=[],t=n(M.selectedPeriod.start_date).clone().startOf("month"),a=n(M.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(P(t)),t.add(1,"month");M.months=e}function p(){s.$new().$watch(function(){return M.selectedMonths},function(t,n){null===n||e.equals(t,n)||R()})}function h(e){M.injectMonths=!0,I("injected").then(function(){R(e)}).then(function(){M.loading.calendar=!1})}function v(){O=a("LeaveCalendar"+t.capitalize(L)+"Controller").init(M)}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function b(){return u.all().then(function(e){M.absencePeriods=t.sortBy(e,"start_date"),M.selectedPeriod=t.find(M.absencePeriods,function(e){return!!e.current})}).then(m).then(S)}function y(){return c.all().then(c.loadCalculationUnits)}function _(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return O.loadContacts().then(function(e){M.contacts=e})}function $(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){M.filters.optionValues.regions=e.hrjc_region,M.filters.optionValues.locations=e.hrjc_location,M.filters.optionValues.levelTypes=e.hrjc_level_type,M.filters.optionValues.departments=e.hrjc_department})}function C(){return l.all()}function w(){return r.all([y(),C(),_()]).then(function(e){M.supportData.absenceTypes=e[0],M.supportData.publicHolidays=e[1],M.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,M.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,M.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,M.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function A(){var e=r.resolve();return M.injectMonths&&(e=I("destroyed"),M.injectMonths=!1),e}function P(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function D(e){e=t.includes(["contacts","period"],e)?e:"period",r.resolve().then(function(){M.loading.calendar=!0}).then(A).then("period"===e?m:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function R(e){var n=M.selectedMonths.length?M.months.filter(function(e){return t.includes(M.selectedMonths,e.index)}):M.months;s.$emit("LeaveCalendar::showMonths",n,!!e)}function S(){M.selectedMonths=[n().month()]}function T(){return M.roleOverride?r.resolve().then(function(){L=M.roleOverride}):r.all([f(i.permissions.admin.administer),f(i.permissions.ssp.manage)]).then(function(e){L=e[0]?"admin":e[1]?"manager":"staff"})}function I(e){return r(function(n){var a=0,r=s.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===M.months.length&&(r(),n())})})}o.debug("Component: leave-calendar");var O,L,M=this;M.absencePeriods=[],M.contacts=[],M.contactIdsToReduceTo=null,M.injectMonths=!1,M.months=[],M.selectedMonths=null,M.selectedPeriod=null,M.showContactName=!1,M.showFilters=!1,M.supportData={},M.loading={calendar:!0,page:!0},M.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},M.labelPeriod=g,M.refresh=D,function(){T().then(p).then(v).then(A).then(b).then(function(){return r.all([q(),w()])}).then(function(){return M.showFilters?$():t.noop}).then(function(){h()}).then(function(){M.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",r]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,r){"use strict";function o(){_.calculationUnit=s(_.supportData.calculationUnits,"value",g.calculation_unit)}function s(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(_.contactData.leaveRequest.from_date).isSame(_.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+_.calculationUnit.name+"-on-"+e+"-tooltip"}function u(){g=s(_.supportData.absenceTypes,"id",_.contactData.leaveRequest.type_id),_.contactData.leaveRequest["type_id.title"]=g.title}function c(){"days"===_.calculationUnit.name&&(b=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.from_date_type),y=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.to_date_type),_.contactData.leaveRequest["from_date_type.label"]=b.label,_.contactData.leaveRequest["to_date_type.label"]=y.label)}function l(e,t,n,a,o){e.stopPropagation(),r.openModal(t,n,a,o)}function d(){_.dates.from=new Date(_.contactData.leaveRequest.from_date),_.dates.to=new Date(_.contactData.leaveRequest.to_date)}function f(){_.contactData.isAccruedTOIL?_.label="AT":"days"===_.calculationUnit.name?m():p()}function m(){_.label=_.contactData.isAM?"AM":_.contactData.isPM?"PM":""}function p(){var e=t(_.contactData.leaveRequest.from_date).isSame(_.date,"day"),n=t(_.contactData.leaveRequest.to_date).isSame(_.date,"day");_.label=e?t(_.contactData.leaveRequest.from_date).format("HH:mm"):n?t(_.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){_.tooltipTemplate=_.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){_.contactData&&_.contactData.leaveRequest&&(u(),o(),c(),f(),d(),h())})}n.debug("Component: leave-calendar-day");var g,b,y,_=this;_.calculationUnit="",_.dates={from:null,to:null},_.label="",_.tooltipTemplate=null,_.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(e){y([e]),B(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),r=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:r.format("YYYY-MM-DD"),name:r.format("ddd"),index:r.format("D"),current:a.isSame(r,"day"),enabled:r.isSameOrAfter(W.period.start_date)&&r.isSameOrBefore(W.period.end_date),contactsData:{}};return r.add(1,"day"),e})}function f(e){return U[e]}function m(){return W.showOnlyWithLeaveRequests?W.contacts.filter(function(e){return Object.keys(H[e.id]||{}).length}):W.contacts}function p(e){return t(e,u.serverDateFormat)}function h(e){O(e),B(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function g(){return W.contactIdsToReduceTo&&(W.contacts=W.contacts.filter(function(t){return e.includes(W.contactIdsToReduceTo,t.contact_id)||e.find(H,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function b(){W.supportData.dayTypes=e.indexBy(W.supportData.dayTypes,"name"),W.supportData.leaveRequestStatuses=e.indexBy(W.supportData.leaveRequestStatuses,"value"),W.supportData.publicHolidays=e.transform(W.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function y(e){return e.forEach(function(e){var t=A(e);H[e.contact_id]=H[e.contact_id]||{},t.forEach(function(t){H[e.contact_id][t.date]=e})}),a.resolve()}function _(){F.push(r.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",c)),F.push(i.subscribe("LeaveRequest::edit",j)),F.push(i.subscribe("LeaveRequest::updatedByManager",j)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):j(e.leaveRequest)}))}function q(e,n,a){var r=W.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?r.value===n.from_date_type:t(a).isSame(n.to_date,"day")?r.value===n.to_date_type:void 0}function $(e,t){return e.request_type===t}function C(e){return!!W.supportData.publicHolidays[p(e).valueOf()]}function w(t){var n=W.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([u.statusNames.awaitingApproval,u.statusNames.moreInformationRequired],n)}function A(n){for(var a=[],r=t(n.from_date).clone(),o=t(n.to_date);r.isSameOrBefore(o);)r.month()===W.month.index&&r.year()===W.month.year&&a.push(e.find(W.month.days,function(e){return e.date===r.format("YYYY-MM-DD")})),r.add(1,"day");return a}function P(t){return e.find(H[t.contact_id],function(e){return t.id===e.id})}function D(t){var n=e.find(W.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function R(){return[D(u.statusNames.approved),D(u.statusNames.adminApproved),D(u.statusNames.awaitingApproval),D(u.statusNames.moreInformationRequired)]}function S(){return W.month.loading=!0,a.all([I(),T()]).then(g).then(k).then(function(){N=!0}).then(function(){W.month.loading=!1})}function T(){return s.all({from_date:{to:W.month.days[W.month.days.length-1].date},to_date:{from:W.month.days[0].date},status_id:{IN:R()},contact_id:{IN:W.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(W.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return y(e.list)})}function I(){var t=W.month.days[0].date,n=W.month.days[W.month.days.length-1].date;return o.get(W.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function O(t){H[t.contact_id]=e.omit(H[t.contact_id],function(e){return e.id===t.id})}function L(){r.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function M(t,n,r){var o,s;return t.contactsData[n]=t.contactsData[n]||{},s=f(n),o=!0===r?a.resolve():a.all([s.isWeekend(p(t.date)),s.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:C(t.date)})}),o.then(function(){return H[n]?H[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?$(a,"toil"):null,isRequested:a?w(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function k(){return a.all(W.month.days.map(function(e){return a.all(W.contacts.map(function(t){return M(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===W.month.index})?W.visible=!1:(W.currentPage=0,W.visible=!0,(a||!N)&&S())}function E(t){var n=e.find(W.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function j(e){var t=P(e);t&&(h(t),-1!==R().indexOf(e.status_id)&&c(e))}function B(e){return a.all(A(e).map(function(t){return M(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var N=!1,F=[],U={},H={},W=this;W.currentPage=0,W.pageSize=20,W.visible=!1,W.showContactName=!!W.showContactName,W.showOnlyWithLeaveRequests=!!W.showOnlyWithLeaveRequests,W.$onDestroy=L,W.contactsList=m,W.getContactUrl=v,function(){var e=t().month(W.month.index).year(W.month.year);b(),_(),W.month=l(e),r.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function r(){var t=n.defer();return a.open(e.defaults(o(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function o(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:o,promptBalanceChangeRecalculation:r}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(h(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=C[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function v(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(C,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:C[e].label,isDirectAction:C[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,C={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),
-define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,u.serverDateFormat).toDate()}function v(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):w(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function w(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function A(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function D(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function R(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():D()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(R(a.min,n)<=0||R(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return v(pe.request.from_date)===v(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=he[a].number_of_hours?R(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(A(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?D.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(D.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){D=e})}function w(e){return!e.attachment_id||T.canManage}function A(){e.forEach(R,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var D=[],R=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=A,T.canRemoveAttachment=w,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=h,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function h(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function v(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function w(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function A(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?D(e):n.all([D("table"),D("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function D(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function R(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,A(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=h,U.getAbsenceTypeByID=v,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),w(),I(),P(),S(),R(),O()]).then(function(){U.loading.page=!1,A()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=w.from_date!==s.request.from_date||w.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){w=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var w,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),r=t(e,n);return t(this.start_date).isSameOrBefore(r)&&t(this.end_date).isSameOrAfter(r)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),
+define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,u.serverDateFormat).toDate()}function v(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):w(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function w(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function A(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function D(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function R(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():D()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(R(a.min,n)<=0||R(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return v(pe.request.from_date)===v(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=he[a].number_of_hours?R(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(A(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?D.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(D.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){D=e})}function w(e){return!e.attachment_id||T.canManage}function A(){e.forEach(R,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var D=[],R=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=A,T.canRemoveAttachment=w,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=h,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function h(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function v(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function w(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function A(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?D(e):n.all([D("table"),D("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function D(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function R(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,A(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=h,U.getAbsenceTypeByID=v,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),w(),I(),P(),S(),R(),O()]).then(function(){U.loading.page=!1,A()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=w.from_date!==s.request.from_date||w.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){w=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var w,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),r=t(e,n);return t(this.start_date).isSameOrBefore(r)&&t(this.end_date).isSameOrAfter(r)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),
define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,r,o){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},current:function(){var e=t().format(o.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,r){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,o,s){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),s=e.assign({},s,{absence_type_id:a,date:t(o).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",s).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,r,o,s){return t.debug("AbsenceType"),a.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return s.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return o.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return o.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,h,v,g,b,y,_,q,$,C){function w(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function A(){["from","to"].forEach(w)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function D(){return Me.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function R(){return Me.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=D();return ke.isMode("edit")&&(e=e&&(V()||R())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function O(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return C.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function L(){ke.errors=[]}function M(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(De[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function W(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function V(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(he).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Oe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];De.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],De.awaiting_approval=e,De.more_information_required=e,De.rejected=e,De.approved=e,De.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(he).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){W(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){Re++})),s.$on("$destroy",Ce),s.$on("LeaveRequestPopup::addTab",function(e,t){Me.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Le="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Le="admin")}).then(function(){return"staff"===Le&&u(_.permissions.ssp.manage).then(function(e){e&&(Le="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Le===e}function se(){return h.all().then(function(e){ke.absencePeriods=e})}function ie(){return v.all(j()).then(v.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function he(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(Oe)}function ve(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),A(),ke.request.isValid().then(ee()&&O).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?Ae():M()}).catch(function(t){ke.request.status_id=e,t&&W(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Me.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===Re&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return Re>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Ce(){Te.forEach(function(e){e()})}function we(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Ae(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,De={},Re=0,Se={},Te=[],Ie="",Oe="No entitlement",Le="",Me=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=L,ke.deleteLeaveRequest=x,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=we,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(ve).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(W).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),function(e){define("leave-absences/admin-dashboard/modules/settings",["common/angular"],function(t){return t.module("admin-dashboard.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.loggedInUserId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/admin-dashboard/"})})}(CRM),define("leave-absences/admin-dashboard/modules/config",["common/angular","leave-absences/admin-dashboard/modules/settings"],function(e){return e.module("admin-dashboard.config",["admin-dashboard.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(e,t,n,a,r,o){var s={format:["DateFormat",function(e){return e.getDateFormat()}]};r.debugEnabled(o.debug),t.defaults.stripTrailingSlashes=!1,a.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",n.otherwise("/requests"),e.state("requests",{url:"/requests",template:' ',resolve:s}).state("calendar",{url:"/calendar",template:' ',resolve:s}).state("leave-balances",{url:"/leave-balances",template:" ",resolve:s})}])}),define("leave-absences/admin-dashboard/modules/components",["common/angular"],function(e){return e.module("admin-dashboard.components",[])}),define("leave-absences/admin-dashboard/components/admin-dashboard-container",["leave-absences/admin-dashboard/modules/components"],function(e){function t(e,t){e.debug("Component: admin-dashboard-container"),t.section="admin-dashboard"}e.component("adminDashboardContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/admin-dashboard-container.html"}],controllerAs:"vm",controller:["$log","$rootScope",t]})}),
define("leave-absences/admin-dashboard/app",["common/angular","common/angularBootstrap","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/services/check-permissions","common/services/angular-date/date-format","leave-absences/shared/ui-router","leave-absences/shared/components/leave-balance-tab.component","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/manage-leave-requests.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/admin-dashboard/modules/config","leave-absences/admin-dashboard/components/admin-dashboard-container"],function(e){return e.module("admin-dashboard",["ngAnimate","ngResource","ui.bootstrap","ui.router","ui.select","textAngular","common.angularDate","common.dialog","common.filters","common.mocks","leave-absences.components","leave-absences.controllers","leave-absences.settings","leave-absences.services","admin-dashboard.config","admin-dashboard.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/admin-dashboard":n+"/admin-dashboard"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/admin-dashboard/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("adminDashboardReady"):function(){var e=document.createEvent("Event");return e.initEvent("adminDashboardReady",!0,!0),e}())})})}(CRM,require),define("admin-dashboard",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js
index 6ec92696a82..cffb5875b44 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js
@@ -8,7 +8,7 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/ui-router",[],function(){return function(){"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(e,t,n){"use strict";function a(e,t){return W(new(W(function(){},{prototype:e})),t)}function r(e){return H(arguments,function(t){t!==e&&H(t,function(t,n){e.hasOwnProperty(n)||(e[n]=t)})}),e}function o(e,t){var n=[];for(var a in e.path){if(e.path[a]!==t.path[a])break;n.push(e.path[a])}return n}function s(e){if(Object.keys)return Object.keys(e);var t=[];return H(e,function(e,n){t.push(n)}),t}function i(e,t){if(Array.prototype.indexOf)return e.indexOf(t,Number(arguments[2])||0);var n=e.length>>>0,a=Number(arguments[2])||0;for((a=a<0?Math.ceil(a):Math.floor(a))<0&&(a+=n);a=0||(l.push(r[f]),c[r[f]]=e[r[f]]);return W({},c,t)}function c(e,t,n){if(!n){n=[];for(var a in e)n.push(a)}for(var r=0;r "));if(b[n]=a,N(e))h.push(n,[function(){return t.get(e)}],c);else{var r=t.annotate(e);H(r,function(e){e!==n&&u.hasOwnProperty(e)&&m(u[e],e)}),h.push(n,e,r)}g.pop(),b[n]=o}}function p(e){return F(e)&&e.then&&e.$$promises}if(!F(u))throw new Error("'invocables' must be an object");var v=s(u||{}),h=[],g=[],b={};return H(u,m),u=g=b=null,function(a,o,s){function i(){--y||(_||r(b,o.$$values),m.$$values=b,m.$$promises=m.$$promises||!0,delete m.$$inheritedValues,c.resolve(b))}function u(e){m.$$failure=e,c.reject(e)}if(p(a)&&s===n&&(s=o,o=a,a=null),a){if(!F(a))throw new Error("'locals' must be an object")}else a=l;if(o){if(!p(o))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else o=d;var c=e.defer(),m=c.promise,g=m.$$promises={},b=W({},a),y=1+h.length/3,_=!1;if(j(o.$$failure))return u(o.$$failure),m;o.$$inheritedValues&&r(b,f(o.$$inheritedValues,v)),W(g,o.$$promises),o.$$values?(_=r(b,f(o.$$values,v)),m.$$inheritedValues=f(o.$$values,v),i()):(o.$$inheritedValues&&(m.$$inheritedValues=f(o.$$inheritedValues,v)),o.then(i,u));for(var q=0,$=h.length;q<$;q+=3)a.hasOwnProperty(h[q])?i():function(n,r,o){function c(e){d.reject(e),u(e)}function l(){if(!j(m.$$failure))try{d.resolve(t.invoke(r,s,b)),d.promise.then(function(e){b[n]=e,i()},c)}catch(e){c(e)}}var d=e.defer(),f=0;H(o,function(e){g.hasOwnProperty(e)&&!a.hasOwnProperty(e)&&(f++,g[e].then(function(t){b[e]=t,--f||l()},c))}),f||l(),g[n]=d.promise}(h[q],h[q+1],h[q+2]);return m}},this.resolve=function(e,t,n,a){return this.study(e)(t,n,a)}}function g(e,t,n){this.fromConfig=function(e,t,n){return j(e.template)?this.fromString(e.template,t):j(e.templateUrl)?this.fromUrl(e.templateUrl,t):j(e.templateProvider)?this.fromProvider(e.templateProvider,t,n):null},this.fromString=function(e,t){return B(e)?e(t):e},this.fromUrl=function(n,a){return B(n)&&(n=n(a)),null==n?null:e.get(n,{cache:t,headers:{Accept:"text/html"}}).then(function(e){return e.data})},this.fromProvider=function(e,t,a){return n.invoke(e,null,a||{params:t})}}function b(e,t,r){function o(t,n,a,r){if(h.push(t),p[t])return p[t];if(!/^\w+([-.]+\w+)*(?:\[\])?$/.test(t))throw new Error("Invalid parameter name '"+t+"' in pattern '"+e+"'");if(v[t])throw new Error("Duplicate parameter name '"+t+"' in pattern '"+e+"'");return v[t]=new Y.Param(t,n,a,r),v[t]}function s(e,t,n,a){var r=["",""],o=e.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!t)return o;switch(n){case!1:r=["(",")"+(a?"?":"")];break;case!0:o=o.replace(/\/$/,""),r=["(?:/(",")|/)?"];break;default:r=["("+n+"|",")?"]}return o+r[0]+t+r[1]}function i(r,o){var s,i,u,c,l;return s=r[2]||r[3],l=t.params[s],u=e.substring(f,r.index),i=o?r[4]:r[4]||("*"==r[1]?".*":null),i&&(c=Y.type(i)||a(Y.type("string"),{pattern:new RegExp(i,t.caseInsensitive?"i":n)})),{id:s,regexp:i,segment:u,type:c,cfg:l}}t=W({params:{}},F(t)?t:{});var u,c=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l=/([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,d="^",f=0,m=this.segments=[],p=r?r.params:{},v=this.params=r?r.params.$$new():new Y.ParamSet,h=[];this.source=e;for(var g,b,y;(u=c.exec(e))&&(g=i(u,!1),!(g.segment.indexOf("?")>=0));)b=o(g.id,g.type,g.cfg,"path"),d+=s(g.segment,b.type.pattern.source,b.squash,b.isOptional),m.push(g.segment),f=c.lastIndex;y=e.substring(f);var _=y.indexOf("?");if(_>=0){var q=this.sourceSearch=y.substring(_);if(y=y.substring(0,_),this.sourcePath=e.substring(0,f+_),q.length>0)for(f=0;u=l.exec(q);)g=i(u,!0),b=o(g.id,g.type,g.cfg,"search"),f=c.lastIndex}else this.sourcePath=e,this.sourceSearch="";d+=s(y)+(!1===t.strict?"/?":"")+"$",m.push(y),this.regexp=new RegExp(d,t.caseInsensitive?"i":n),this.prefix=m[0],this.$$paramNames=h}function y(e){W(this,e)}function _(){function e(e){return null!=e?e.toString().replace(/(~|\/)/g,function(e){return{"~":"~~","/":"~2F"}[e]}):e}function r(e){return null!=e?e.toString().replace(/(~~|~2F)/g,function(e){return{"~~":"~","~2F":"/"}[e]}):e}function o(){return{strict:v,caseInsensitive:f}}function u(e){return B(e)||U(e)&&B(e[e.length-1])}function c(){for(;$.length;){var e=$.shift();if(e.pattern)throw new Error("You cannot override a type's .pattern at runtime.");t.extend(g[e.name],d.invoke(e.def))}}function l(e){W(this,e||{})}Y=this;var d,f=!1,v=!0,h=!1,g={},q=!0,$=[],C={string:{encode:e,decode:r,is:function(e){return null==e||!j(e)||"string"==typeof e},pattern:/[^\/]*/},int:{encode:e,decode:function(e){return parseInt(e,10)},is:function(e){return j(e)&&this.decode(e.toString())===e},pattern:/\d+/},bool:{encode:function(e){return e?1:0},decode:function(e){return 0!==parseInt(e,10)},is:function(e){return!0===e||!1===e},pattern:/0|1/},date:{encode:function(e){return this.is(e)?[e.getFullYear(),("0"+(e.getMonth()+1)).slice(-2),("0"+e.getDate()).slice(-2)].join("-"):n},decode:function(e){if(this.is(e))return e;var t=this.capture.exec(e);return t?new Date(t[1],t[2]-1,t[3]):n},is:function(e){return e instanceof Date&&!isNaN(e.valueOf())},equals:function(e,t){return this.is(e)&&this.is(t)&&e.toISOString()===t.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:t.toJson,decode:t.fromJson,is:t.isObject,equals:t.equals,pattern:/[^\/]*/},any:{encode:t.identity,decode:t.identity,equals:t.equals,pattern:/.*/}};_.$$getDefaultValue=function(e){if(!u(e.value))return e.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(e.value)},this.caseInsensitive=function(e){return j(e)&&(f=e),f},this.strictMode=function(e){return j(e)&&(v=e),v},this.defaultSquashPolicy=function(e){if(!j(e))return h;if(!0!==e&&!1!==e&&!N(e))throw new Error("Invalid squash policy: "+e+". Valid policies: false, true, arbitrary-string");return h=e,e},this.compile=function(e,t){return new b(e,W(o(),t))},this.isMatcher=function(e){if(!F(e))return!1;var t=!0;return H(b.prototype,function(n,a){B(n)&&(t=t&&j(e[a])&&B(e[a]))}),t},this.type=function(e,t,n){if(!j(t))return g[e];if(g.hasOwnProperty(e))throw new Error("A type named '"+e+"' has already been defined.");return g[e]=new y(W({name:e},t)),n&&($.push({name:e,def:n}),q||c()),this},H(C,function(e,t){g[t]=new y(W({name:t},e))}),g=a(g,{}),this.$get=["$injector",function(e){return d=e,q=!1,c(),H(C,function(e,t){g[t]||(g[t]=new y(e))}),this}],this.Param=function(e,a,r,o){function c(){if(!d)throw new Error("Injectable functions cannot be called at configuration time");var e=d.invoke(r.$$fn);if(null!==e&&e!==n&&!v.type.is(e))throw new Error("Default value ("+e+") for parameter '"+v.id+"' is not an instance of Type ("+v.type.name+")");return e}function l(e){function t(e){return function(t){return t.from===e}}return e=function(e){var n=p(m(v.replace,t(e)),function(e){return e.to});return n.length?n[0]:e}(e),j(e)?v.type.$normalize(e):c()}function f(){return"{Param:"+e+" "+a+" squash: '"+q+"' optional: "+_+"}"}var v=this;r=function(e){var t=F(e)?s(e):[];return-1===i(t,"value")&&-1===i(t,"type")&&-1===i(t,"squash")&&-1===i(t,"array")&&(e={value:e}),e.$$fn=u(e.value)?e.value:function(){return e.value},e}(r),a=function(n,a,r){if(n.type&&a)throw new Error("Param '"+e+"' has two type configurations.");return a||(n.type?t.isString(n.type)?g[n.type]:n.type instanceof y?n.type:new y(n.type):"config"===r?g.any:g.string)}(r,a,o);var b=function(){var t={array:"search"===o&&"auto"},n=e.match(/\[\]$/)?{array:!0}:{};return W(t,n,r).array}();a=b?a.$asArray(b,"search"===o):a,"string"!==a.name||b||"path"!==o||r.value!==n||(r.value="");var _=r.value!==n,q=function(e,t){var n=e.squash;if(!t||!1===n)return!1;if(!j(n)||null==n)return h;if(!0===n||N(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(r,_),$=function(e,t,a,r){var o,s,u=[{from:"",to:a||t?n:""},{from:null,to:a||t?n:""}];return o=U(e.replace)?e.replace:[],N(r)&&o.push({from:r,to:n}),s=p(o,function(e){return e.from}),m(u,function(e){return-1===i(s,e.from)}).concat(o)}(r,b,_,q);W(this,{id:e,type:a,location:o,array:b,squash:q,replace:$,isOptional:_,value:l,dynamic:n,config:r,toString:f})},l.prototype={$$new:function(){return a(this,W(new l,{$$parent:this}))},$$keys:function(){for(var e=[],t=[],n=this,a=s(l.prototype);n;)t.push(n),n=n.$$parent;return t.reverse(),H(t,function(t){H(s(t),function(t){-1===i(e,t)&&-1===i(a,t)&&e.push(t)})}),e},$$values:function(e){var t={},n=this;return H(n.$$keys(),function(a){t[a]=n[a].value(e&&e[a])}),t},$$equals:function(e,t){var n=!0,a=this;return H(a.$$keys(),function(r){var o=e&&e[r],s=t&&t[r];a[r].type.equals(o,s)||(n=!1)}),n},$$validates:function(e){var a,r,o,s,i,u=this.$$keys();for(a=0;a=0)throw new Error("State must have a valid name");if(P.hasOwnProperty(n))throw new Error("State '"+n+"' is already defined");var r=-1!==n.indexOf(".")?n.substring(0,n.lastIndexOf(".")):N(t.parent)?t.parent:F(t.parent)&&N(t.parent.name)?t.parent.name:"";if(r&&!P[r])return m(r,t.self);for(var o in S)B(S[o])&&(t[o]=S[o](t,S.$delegates[o]));return P[n]=t,!t[D]&&t.url&&e.when(t.url,["$match","$stateParams",function(e,n){w.$current.navigable==t&&c(e,n)||w.transitionTo(t,e,{inherit:!0,location:!1})}]),h(n),t}function b(e){return e.indexOf("*")>-1}function y(e){for(var t=e.split("."),n=w.$current.name.split("."),a=0,r=t.length;a=P;a--)s=p[a],s.self.onExit&&i.invoke(s.self.onExit,s.self,s.locals.globals),s.locals=null;for(a=P;a<_.length;a++)r=_[a],r.locals=M[a],r.self.onEnter&&i.invoke(r.self.onEnter,r.self,r.locals.globals);return w.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(w.$current=t,w.current=t.self,w.params=n,V(w.params,m),w.transition=null,o.location&&t.navigable&&h.push(t.navigable.url,t.navigable.locals.globals.$stateParams,{$$avoidResync:!0,replace:"replace"===o.location}),o.notify&&e.$broadcast("$stateChangeSuccess",t.self,n,c.self,d),h.update(!0),w.current)}).then(null,function(a){return a===R?S:w.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(w.transition=null,s=e.$broadcast("$stateChangeError",t.self,n,c.self,d,a),s.defaultPrevented||h.update(),r.reject(a))});return B},w.is=function(e,t,a){a=W({relative:w.$current},a||{});var r=f(e,a.relative);return j(r)?w.$current===r&&(!t||c(r.params.$$values(t),m)):n},w.includes=function(e,t,a){if(a=W({relative:w.$current},a||{}),N(e)&&b(e)){if(!y(e))return!1;e=w.$current.name}var r=f(e,a.relative);if(!j(r))return n;if(!j(w.$current.includes[r.name]))return!1;if(!t)return!0;for(var o=s(t),i=0;i2?c.enter(e,null,n).then(a):c.enter(e,null,n,a)},leave:function(e,n){t.version.minor>2?c.leave(e).then(n):c.leave(e,n)}};if(u){var a=u&&u(n,e);return{enter:function(e,t,n){a.enter(e,null,t),n()},leave:function(e,t){a.leave(e),t()}}}return function(){return{enter:function(e,t,n){t.after(e),n()},leave:function(e,t){e.remove(),t()}}}()}var i=function(){return n.has?function(e){return n.has(e)?n.get(e):null}:function(e){try{return n.get(e)}catch(e){return null}}}(),u=i("$animator"),c=i("$animate");return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(n,i,u){return function(n,i,c){function l(){if(f&&(f.remove(),f=null),p&&(p.$destroy(),p=null),m){var e=m.data("$uiViewAnim");b.leave(m,function(){e.$$animLeave.resolve(),f=null}),f=m,m=null}}function d(s){var d,f=R(n,c,i,r),y=f&&e.$current&&e.$current.locals[f];if(s||y!==v){d=n.$new(),v=e.$current.locals[f],d.$emit("$viewContentLoading",f);var _=u(d,function(e){var r=o.defer(),s=o.defer(),u={$animEnter:r.promise,$animLeave:s.promise,$$animLeave:s};e.data("$uiViewAnim",u),b.enter(e,i,function(){r.resolve(),p&&p.$emit("$viewContentAnimationEnded"),(t.isDefined(g)&&!g||n.$eval(g))&&a(e)}),l()});m=_,p=d,p.$emit("$viewContentLoaded",f),p.$eval(h)}}var f,m,p,v,h=c.onload||"",g=c.autoscroll,b=s(c,n);i.inheritedData("$uiView"),n.$on("$stateChangeSuccess",function(){d(!1)}),d(!0)}}}}function P(e,n,a,r){return{restrict:"ECA",priority:-400,compile:function(o){var s=o.html();return function(o,i,u){var c=a.$current,l=R(o,u,i,r),d=c&&c.locals[l];if(d){i.data("$uiView",{name:l,state:d.$$state}),i.html(d.$template?d.$template:s);var f=t.extend({},d);o[d.$$resolveAs]=f;var m=e(i.contents());if(d.$$controller){d.$scope=o,d.$element=i;var p=n(d.$$controller,d);d.$$controllerAs&&(o[d.$$controllerAs]=p,o[d.$$controllerAs][d.$$resolveAs]=f),B(p.$onInit)&&p.$onInit(),i.data("$ngControllerController",p),i.children().data("$ngControllerController",p)}m(o)}}}}}function R(e,t,n,a){var r=a(t.uiView||t.name||"")(e),o=n.inheritedData("$uiView");return r.indexOf("@")>=0?r:r+"@"+(o?o.state.name:"")}function D(e,t){var n,a=e.match(/^\s*({[^}]*})\s*$/);if(a&&(e=t+"("+a[1]+")"),!(n=e.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/))||4!==n.length)throw new Error("Invalid state ref '"+e+"'");return{state:n[1],paramExpr:n[3]||null}}function S(e){var t=e.parent().inheritedData("$uiView");if(t&&t.state&&t.state.name)return t.state}function T(e){var t="[object SVGAnimatedString]"===Object.prototype.toString.call(e.prop("href")),n="FORM"===e[0].nodeName;return{attr:n?"action":t?"xlink:href":"href",isAnchor:"A"===e.prop("tagName").toUpperCase(),clickable:!n}}function I(e,t,n,a,r){return function(o){var s=o.which||o.button,i=r();if(!(s>1||o.ctrlKey||o.metaKey||o.shiftKey||e.attr("target"))){var u=n(function(){t.go(i.state,i.params,i.options)});o.preventDefault();var c=a.isAnchor&&!i.href?1:0;o.preventDefault=function(){c--<=0&&n.cancel(u)}}}}function O(e,t){return{relative:S(e)||t.$current,inherit:!0}}function L(e,n){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(a,r,o,s){var i,u=D(o.uiSref,e.current.name),c={state:u.state,href:null,params:null},l=T(r),d=s[1]||s[0],f=null;c.options=W(O(r,e),o.uiSrefOpts?a.$eval(o.uiSrefOpts):{});var m=function(n){n&&(c.params=t.copy(n)),c.href=e.href(u.state,c.params,c.options),f&&f(),d&&(f=d.$$addStateInfo(u.state,c.params)),null!==c.href&&o.$set(l.attr,c.href)};u.paramExpr&&(a.$watch(u.paramExpr,function(e){e!==c.params&&m(e)},!0),c.params=t.copy(a.$eval(u.paramExpr))),m(),l.clickable&&(i=I(r,e,n,l,function(){return c}),r[r.on?"on":"bind"]("click",i),a.$on("$destroy",function(){r[r.off?"off":"unbind"]("click",i)}))}}}function M(e,t){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(n,a,r,o){function s(t){f.state=t[0],f.params=t[1],f.options=t[2],f.href=e.href(f.state,f.params,f.options),m&&m(),c&&(m=c.$$addStateInfo(f.state,f.params)),f.href&&r.$set(u.attr,f.href)}var i,u=T(a),c=o[1]||o[0],l=[r.uiState,r.uiStateParams||null,r.uiStateOpts||null],d="["+l.map(function(e){return e||"null"}).join(", ")+"]",f={state:null,params:null,options:null,href:null},m=null;n.$watch(d,s,!0),s(n.$eval(d)),u.clickable&&(i=I(a,e,t,u,function(){return f}),a[a.on?"on":"bind"]("click",i),n.$on("$destroy",function(){a[a.off?"off":"unbind"]("click",i)}))}}}function k(e,t,n){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout",function(t,a,r,o){function s(t,n,r){var o=e.get(t,S(a)),s=i(t,n),u={state:o||{name:t},params:n,hash:s};return v.push(u),h[s]=r,function(){var e=v.indexOf(u);-1!==e&&v.splice(e,1)}}function i(e,n){if(!N(e))throw new Error("state should be a string");return F(n)?e+G(n):(n=t.$eval(n),F(n)?e+G(n):e)}function u(){for(var e=0;e0)){var n=s(e,t,p);return u(),n}},t.$on("$stateChangeSuccess",u),u()}]}}function x(e){var t=function(t,n){return e.is(t,n)};return t.$stateful=!0,t}function E(e){var t=function(t,n,a){return e.includes(t,n,a)};return t.$stateful=!0,t}var j=t.isDefined,B=t.isFunction,N=t.isString,F=t.isObject,U=t.isArray,H=t.forEach,W=t.extend,V=t.copy,G=t.toJson;t.module("ui.router.util",["ng"]),t.module("ui.router.router",["ui.router.util"]),t.module("ui.router.state",["ui.router.router","ui.router.util"]),t.module("ui.router",["ui.router.state"]),t.module("ui.router.compat",["ui.router"]),h.$inject=["$q","$injector"],t.module("ui.router.util").service("$resolve",h),g.$inject=["$http","$templateCache","$injector"],t.module("ui.router.util").service("$templateFactory",g);var Y;b.prototype.concat=function(e,t){var n={caseInsensitive:Y.caseInsensitive(),strict:Y.strictMode(),squash:Y.defaultSquashPolicy()};return new b(this.sourcePath+e+this.sourceSearch,W(n,t),this)},b.prototype.toString=function(){return this.source},b.prototype.exec=function(e,t){var n=this.regexp.exec(e);if(!n)return null;t=t||{};var a,r,o,s=this.parameters(),i=s.length,u=this.segments.length-1,c={};if(u!==n.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");var l,d;for(a=0;a=":e}};return a.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,r){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,o,s){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),s=e.assign({},s,{absence_type_id:a,date:t(o).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",s).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,r,o,s){return t.debug("AbsenceType"),a.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return s.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return o.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return o.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/components/leave-balance-tab-filters.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n){function a(e){e.absencePeriods&&c.absencePeriods.length&&(c.filters.period_id=o().id),e.absenceTypes&&c.absenceTypes.length&&(c.filters.type_id=s().id),(e.loggedInContactId||e.userRole)&&(c.filters.managed_by="manager"===c.userRole?c.loggedInContactId:void 0),r()&&c.submitFilters()}function r(){return e.every(c.filters,function(e){return null!==e})}function o(){return e.find(c.absencePeriods,function(e){return e.current})||c.absencePeriods.reduce(function(e,n){return t(e.end_date).isAfter(n.end_date)?e:n})}function s(){return c.absenceTypes.reduce(function(e,t){return e.title.localeCompare(t.title)?e:t})}function i(e){return e.current?"Current Period ("+e.title+")":e.title}function u(){n.$emit("LeaveBalanceFilters::update",c.filters)}var c=this;c.filters={period_id:null,type_id:null,managed_by:null},c.$onChanges=a,c.labelPeriod=i,c.submitFilters=u}n.component("leaveBalanceTabFilters",{controller:a,controllerAs:"balanceFilters",bindings:{absencePeriods:"<",absenceTypes:"<",loggedInContactId:"<",lookupContacts:"<",userRole:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-balance-tab-filters.html"}]}),a.$inject=["$scope"]}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function r(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(r),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,r,o){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,r,"getLeaveBalances",o)}})}])}),define("leave-absences/shared/models/leave-balance-report.model",["leave-absences/shared/modules/models","leave-absences/shared/apis/entitlement.api","common/models/model"],function(e){"use strict";e.factory("LeaveBalanceReport",["Model","EntitlementAPI",function(e,t){return e.extend({all:function(e,n,a,r,o){return t.getLeaveBalances(this.processFilters(e),n,a,r,o)}})}])}),define("leave-absences/shared/components/leave-balance-tab.component",["common/angular","common/lodash","leave-absences/shared/modules/components","leave-absences/shared/components/leave-balance-tab-filters.component","leave-absences/shared/models/leave-balance-report.model","common/services/notification.service","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f){function m(){return r.all({options:{sort:"title ASC"}}).then(function(e){P.absencePeriods=e})}function p(){return o.all().then(o.loadCalculationUnits).then(function(e){P.absenceTypes=e})}function v(){return s.all(null,null,"sort_name ASC").then(function(e){P.lookupContacts=e.list})}function h(){return n.all([m(),p(),v(),g(),q()]).catch(function(e){u.error("Error",e)})}function g(){return l.get().then(function(e){P.loggedInContactId=e.contactId})}function b(){return P.loading.report=!0,i.all(w,P.pagination,void 0,void 0,!1).then(function(e){P.report=y(e.list),P.reportCount=e.total}).catch(function(e){u.error("Error",e.error_message)}).finally(function(){P.loading.report=!1})}function y(n){return n.map(function(n){return n=e.copy(n),n.absence_types=t.indexBy(n.absence_types,function(e){return e.id}),n})}function _(){a.$on("LeaveBalanceFilters::update",C),c.subscribe("LeaveRequest::new",$)}function q(){return f(d.permissions.admin.administer).then(function(e){P.userRole=e?"admin":"manager"})}function $(e){C(e,w)}function C(e,t){w=t,P.pagination.page=1,A(),P.loadReportCurrentPage()}function A(){P.selectedAbsenceTypes=P.absenceTypes.filter(function(e){return+e.id==+w.type_id})}var w={},P=this;P.absencePeriods=[],P.absenceTypes=[],P.loading={component:!0,report:!0},P.loggedInContactId=null,P.lookupContacts=[],P.pagination={page:1,size:50},P.report=[],P.reportCount=0,P.userRole=null,P.loadReportCurrentPage=b,function(){_(),h().then(function(){P.loading.component=!1})}()}n.component("leaveBalanceTab",{controller:a,controllerAs:"leaveBalanceTab",templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-balance-tab.html"}]}),a.$inject=["$q","$rootScope","AbsencePeriod","AbsenceType","Contact","LeaveBalanceReport","notificationService","pubSub","Session","shared-settings","checkPermissions"]}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,r,o,s,i){function u(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(h.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(h.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function c(){return{loadContacts:function(){var e=h.filters.userSettings.assignedTo.type;return f(e).then(function(e){h.lookupContacts=e}).then(function(){return"me"!==e?u():a.resolve(null)}).then(function(e){return h.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return r.all(m(),null,"display_name").then(function(e){return e.list})}function d(){return v?a.resolve(v):s.all()}function f(e){return"me"===e?r.leaveManagees(h.contactId):"unassigned"===e?r.leaveManagees(void 0,{unassigned:!0}):r.all().then(function(e){return e.list})}function m(){return{department:h.filters.userSettings.department?h.filters.userSettings.department.value:null,level_type:h.filters.userSettings.level_type?h.filters.userSettings.level_type.value:null,location:h.filters.userSettings.location?h.filters.userSettings.location.value:null,region:h.filters.userSettings.region?h.filters.userSettings.region.value:null,id:{IN:h.filters.userSettings.contact?[h.filters.userSettings.contact.id]:h.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",[" When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var v,h;return{init:function(e){return h=e,h.showContactDetailsLink=!0,h.showContactName=!0,h.showFilters=!0,h.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],h.filters.userSettings.assignedTo=h.filtersByAssignee[0],h.showAdminFilteringHint=p,c()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:s.contactId}).leaveManagees().then(function(e){s.lookupContacts=e}).then(r)}}}function r(){return t.all(o(),null,"display_name").then(function(e){return e.list})}function o(){return{department:s.filters.userSettings.department?s.filters.userSettings.department.value:null,level_type:s.filters.userSettings.level_type?s.filters.userSettings.level_type.value:null,location:s.filters.userSettings.location?s.filters.userSettings.location.value:null,region:s.filters.userSettings.region?s.filters.userSettings.region.value:null,id:{IN:s.filters.userSettings.contact?[s.filters.userSettings.contact.id]:s.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var s;return{init:function(e){return s=e,s.showContactName=!0,s.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function r(a,r,o,s,i,u,c,l,d,f){function m(){for(var e=[],t=n(M.selectedPeriod.start_date).clone().startOf("month"),a=n(M.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(P(t)),t.add(1,"month");M.months=e}function p(){s.$new().$watch(function(){return M.selectedMonths},function(t,n){null===n||e.equals(t,n)||D()})}function v(e){M.injectMonths=!0,I("injected").then(function(){D(e)}).then(function(){M.loading.calendar=!1})}function h(){O=a("LeaveCalendar"+t.capitalize(L)+"Controller").init(M)}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function b(){return u.all().then(function(e){M.absencePeriods=t.sortBy(e,"start_date"),M.selectedPeriod=t.find(M.absencePeriods,function(e){return!!e.current})}).then(m).then(S)}function y(){return c.all().then(c.loadCalculationUnits)}function _(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return O.loadContacts().then(function(e){M.contacts=e})}function $(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){M.filters.optionValues.regions=e.hrjc_region,M.filters.optionValues.locations=e.hrjc_location,M.filters.optionValues.levelTypes=e.hrjc_level_type,M.filters.optionValues.departments=e.hrjc_department})}function C(){return l.all()}function A(){return r.all([y(),C(),_()]).then(function(e){M.supportData.absenceTypes=e[0],M.supportData.publicHolidays=e[1],M.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,M.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,M.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,M.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function w(){var e=r.resolve();return M.injectMonths&&(e=I("destroyed"),M.injectMonths=!1),e}function P(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function R(e){e=t.includes(["contacts","period"],e)?e:"period",r.resolve().then(function(){M.loading.calendar=!0}).then(w).then("period"===e?m:t.noop).then("contacts"===e?q:t.noop).then(function(){v("contacts"===e)})}function D(e){var n=M.selectedMonths.length?M.months.filter(function(e){return t.includes(M.selectedMonths,e.index)}):M.months;s.$emit("LeaveCalendar::showMonths",n,!!e)}function S(){M.selectedMonths=[n().month()]}function T(){return M.roleOverride?r.resolve().then(function(){L=M.roleOverride}):r.all([f(i.permissions.admin.administer),f(i.permissions.ssp.manage)]).then(function(e){L=e[0]?"admin":e[1]?"manager":"staff"})}function I(e){return r(function(n){var a=0,r=s.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===M.months.length&&(r(),n())})})}o.debug("Component: leave-calendar");var O,L,M=this;M.absencePeriods=[],M.contacts=[],M.contactIdsToReduceTo=null,M.injectMonths=!1,M.months=[],M.selectedMonths=null,M.selectedPeriod=null,M.showContactName=!1,M.showFilters=!1,M.supportData={},M.loading={calendar:!0,page:!0},M.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},M.labelPeriod=g,M.refresh=R,function(){T().then(p).then(h).then(w).then(b).then(function(){return r.all([q(),A()])}).then(function(){return M.showFilters?$():t.noop}).then(function(){v()}).then(function(){M.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",r]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,r){"use strict";function o(){_.calculationUnit=s(_.supportData.calculationUnits,"value",g.calculation_unit)}function s(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(_.contactData.leaveRequest.from_date).isSame(_.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+_.calculationUnit.name+"-on-"+e+"-tooltip"}function u(){g=s(_.supportData.absenceTypes,"id",_.contactData.leaveRequest.type_id),_.contactData.leaveRequest["type_id.title"]=g.title}function c(){"days"===_.calculationUnit.name&&(b=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.from_date_type),y=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.to_date_type),_.contactData.leaveRequest["from_date_type.label"]=b.label,_.contactData.leaveRequest["to_date_type.label"]=y.label)}function l(e,t,n,a,o){e.stopPropagation(),r.openModal(t,n,a,o)}function d(){_.dates.from=new Date(_.contactData.leaveRequest.from_date),_.dates.to=new Date(_.contactData.leaveRequest.to_date)}function f(){_.contactData.isAccruedTOIL?_.label="AT":"days"===_.calculationUnit.name?m():p()}function m(){_.label=_.contactData.isAM?"AM":_.contactData.isPM?"PM":""}function p(){var e=t(_.contactData.leaveRequest.from_date).isSame(_.date,"day"),n=t(_.contactData.leaveRequest.to_date).isSame(_.date,"day");_.label=e?t(_.contactData.leaveRequest.from_date).format("HH:mm"):n?t(_.contactData.leaveRequest.to_date).format("HH:mm"):""}function v(){_.tooltipTemplate=_.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function h(){a.$watch("day.contactData.leaveRequest",function(){_.contactData&&_.contactData.leaveRequest&&(u(),o(),c(),f(),d(),v())})}n.debug("Component: leave-calendar-day");var g,b,y,_=this;_.calculationUnit="",_.dates={from:null,to:null},_.label="",_.tooltipTemplate=null,_.openLeavePopup=l,function(){h()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(e){y([e]),B(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),r=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:r.format("YYYY-MM-DD"),name:r.format("ddd"),index:r.format("D"),current:a.isSame(r,"day"),enabled:r.isSameOrAfter(W.period.start_date)&&r.isSameOrBefore(W.period.end_date),contactsData:{}};return r.add(1,"day"),e})}function f(e){return U[e]}function m(){return W.showOnlyWithLeaveRequests?W.contacts.filter(function(e){return Object.keys(H[e.id]||{}).length}):W.contacts}function p(e){return t(e,u.serverDateFormat)}function v(e){O(e),B(e)}function h(e){return CRM.url("civicrm/contact/view",{cid:e})}function g(){return W.contactIdsToReduceTo&&(W.contacts=W.contacts.filter(function(t){return e.includes(W.contactIdsToReduceTo,t.contact_id)||e.find(H,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function b(){W.supportData.dayTypes=e.indexBy(W.supportData.dayTypes,"name"),W.supportData.leaveRequestStatuses=e.indexBy(W.supportData.leaveRequestStatuses,"value"),W.supportData.publicHolidays=e.transform(W.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function y(e){return e.forEach(function(e){var t=w(e);H[e.contact_id]=H[e.contact_id]||{},t.forEach(function(t){H[e.contact_id][t.date]=e})}),a.resolve()}function _(){F.push(r.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",c)),F.push(i.subscribe("LeaveRequest::edit",j)),F.push(i.subscribe("LeaveRequest::updatedByManager",j)),F.push(i.subscribe("LeaveRequest::delete",v)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?v(e.leaveRequest):j(e.leaveRequest)}))}function q(e,n,a){var r=W.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?r.value===n.from_date_type:t(a).isSame(n.to_date,"day")?r.value===n.to_date_type:void 0}function $(e,t){return e.request_type===t}function C(e){return!!W.supportData.publicHolidays[p(e).valueOf()]}function A(t){var n=W.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([u.statusNames.awaitingApproval,u.statusNames.moreInformationRequired],n)}function w(n){for(var a=[],r=t(n.from_date).clone(),o=t(n.to_date);r.isSameOrBefore(o);)r.month()===W.month.index&&r.year()===W.month.year&&a.push(e.find(W.month.days,function(e){return e.date===r.format("YYYY-MM-DD")})),r.add(1,"day");return a}function P(t){return e.find(H[t.contact_id],function(e){return t.id===e.id})}function R(t){var n=e.find(W.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function D(){return[R(u.statusNames.approved),R(u.statusNames.adminApproved),R(u.statusNames.awaitingApproval),R(u.statusNames.moreInformationRequired)]}function S(){return W.month.loading=!0,a.all([I(),T()]).then(g).then(k).then(function(){N=!0}).then(function(){W.month.loading=!1})}function T(){return s.all({from_date:{to:W.month.days[W.month.days.length-1].date},to_date:{from:W.month.days[0].date},status_id:{IN:D()},contact_id:{IN:W.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(W.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return y(e.list)})}function I(){var t=W.month.days[0].date,n=W.month.days[W.month.days.length-1].date;return o.get(W.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function O(t){H[t.contact_id]=e.omit(H[t.contact_id],function(e){return e.id===t.id})}function L(){r.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function M(t,n,r){var o,s;return t.contactsData[n]=t.contactsData[n]||{},s=f(n),o=!0===r?a.resolve():a.all([s.isWeekend(p(t.date)),s.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:C(t.date)})}),o.then(function(){return H[n]?H[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?$(a,"toil"):null,isRequested:a?A(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function k(){return a.all(W.month.days.map(function(e){return a.all(W.contacts.map(function(t){return M(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===W.month.index})?W.visible=!1:(W.currentPage=0,W.visible=!0,(a||!N)&&S())}function E(t){var n=e.find(W.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function j(e){var t=P(e);t&&(v(t),-1!==D().indexOf(e.status_id)&&c(e))}function B(e){return a.all(w(e).map(function(t){return M(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var N=!1,F=[],U={},H={},W=this;W.currentPage=0,W.pageSize=20,W.visible=!1,W.showContactName=!!W.showContactName,W.showOnlyWithLeaveRequests=!!W.showOnlyWithLeaveRequests,W.$onDestroy=L,W.contactsList=m,W.getContactUrl=h,function(){var e=t().month(W.month.index).year(W.month.year);b(),_(),W.month=l(e),r.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function r(){var t=n.defer();return a.open(e.defaults(o(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function o(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:o,promptBalanceChangeRecalculation:r}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),
-define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(v(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):v(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function v(e){var t=C[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function h(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(C,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:C[e].label,isDirectAction:C[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,C={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=h,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function v(e){return q.mode===e}function h(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=v,q.onBeforeSubmit=h,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function v(e){return t(e,u.serverDateFormat).toDate()}function h(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=h(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):A(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function A(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function w(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function R(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function D(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():R()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=v(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=v(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(D(a.min,n)<=0||D(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(h(t)).then(function(t){ve[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return ve[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return h(pe.request.from_date)===h(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=v(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=v(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=ve[a].number_of_hours?D(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?h(e.fromDate):null,pe.request.to_date=e.toDate?h(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,ve={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=v,pe.convertDateToServerFormat=h,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(w(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?R.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(R.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){R=e})}function A(e){return!e.attachment_id||T.canManage}function w(){e.forEach(D,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var R=[],D=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=w,T.canRemoveAttachment=A,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=v,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function v(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function h(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function A(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function w(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?R(e):n.all([R("table"),R("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function R(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function D(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,w(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=v,U.getAbsenceTypeByID=h,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),A(),I(),P(),S(),D(),O()]).then(function(){U.loading.page=!1,w()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){
-return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=A.from_date!==s.request.from_date||A.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&w.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function v(){var e=s.isMode("create")&&w.hasExpirationFromAdminSettings,t=w.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function h(){return w.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){w.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",h().then(v).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){A=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var A,w={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function v(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function h(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?v.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([h.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([h.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,v,h,g,b,y,_,q,$,C){function A(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function w(){["from","to"].forEach(A)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function R(){return Me.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function D(){return Me.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=R();return ke.isMode("edit")&&(e=e&&(V()||D())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function O(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return C.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function L(){ke.errors=[]}function M(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(Re[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function W(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function V(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(ve).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Oe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];Re.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],Re.awaiting_approval=e,Re.more_information_required=e,Re.rejected=e,Re.approved=e,Re.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(ve).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){W(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){De++})),s.$on("$destroy",Ce),s.$on("LeaveRequestPopup::addTab",function(e,t){Me.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Le="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Le="admin")}).then(function(){return"staff"===Le&&u(_.permissions.ssp.manage).then(function(e){e&&(Le="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Le===e}function se(){return v.all().then(function(e){ke.absencePeriods=e})}function ie(){return h.all(j()).then(h.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function ve(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(Oe)}function he(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),w(),ke.request.isValid().then(ee()&&O).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?we():M()}).catch(function(t){ke.request.status_id=e,t&&W(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Me.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===De&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return De>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Ce(){Te.forEach(function(e){e()})}function Ae(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function we(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,Re={},De=0,Se={},Te=[],Ie="",Oe="No entitlement",Le="",Me=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=L,ke.deleteLeaveRequest=x,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ae,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(he).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(W).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/manager-leave/modules/components",["common/angular"],function(e){return e.module("manager-leave.components",[])}),define("leave-absences/manager-leave/components/manager-leave-container",["leave-absences/manager-leave/modules/components"],function(e){e.component("managerLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/manager-leave-container.html"}],controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: manager-leave-container"),t.section="manager-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}],controllerAs:"managerLeave"})}),function(e){define("leave-absences/manager-leave/modules/settings",["common/angular"],function(t){return t.module("manager-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/"})})}(CRM),function(e){define("leave-absences/manager-leave/modules/config",["common/angular","leave-absences/manager-leave/modules/settings"],function(t){return t.module("manager-leave.config",["manager-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/manager-leave/requests"),t.state("manager-leave",{abstract:!0,url:"/manager-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("manager-leave.requests",{url:"/requests?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("manager-leave.calendar",{url:"/calendar",template:' '}).state("manager-leave.leave-balances",{url:"/leave-balances",template:" "})}])})}(CRM),
+define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(v(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):v(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function v(e){var t=C[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function h(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(C,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:C[e].label,isDirectAction:C[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,C={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=h,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function v(e){return q.mode===e}function h(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=v,q.onBeforeSubmit=h,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function v(e){return t(e,u.serverDateFormat).toDate()}function h(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=h(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):A(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function A(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function w(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function R(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function D(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():R()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=v(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=v(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(D(a.min,n)<=0||D(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(h(t)).then(function(t){ve[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return ve[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return h(pe.request.from_date)===h(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=v(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=v(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=ve[a].number_of_hours?D(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?h(e.fromDate):null,pe.request.to_date=e.toDate?h(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,ve={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=v,pe.convertDateToServerFormat=h,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(w(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?R.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(R.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){R=e})}function A(e){return!e.attachment_id||T.canManage}function w(){e.forEach(D,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var R=[],D=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=w,T.canRemoveAttachment=A,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=v,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function v(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function h(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function A(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function w(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?R(e):n.all([R("table"),R("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function R(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function D(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,w(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=v,U.getAbsenceTypeByID=h,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),A(),I(),P(),S(),D(),O()]).then(function(){U.loading.page=!1,w()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){
+return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=A.from_date!==s.request.from_date||A.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&w.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function v(){var e=s.isMode("create")&&w.hasExpirationFromAdminSettings,t=w.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function h(){return w.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){w.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",h().then(v).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){A=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var A,w={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function v(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function h(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?v.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([h.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([h.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,v,h,g,b,y,_,q,$,C){function A(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function w(){["from","to"].forEach(A)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function R(){return Me.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function D(){return Me.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=R();return ke.isMode("edit")&&(e=e&&(V()||D())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function O(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return C.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function L(){ke.errors=[]}function M(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(Re[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function W(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function V(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(ve).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Oe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];Re.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],Re.awaiting_approval=e,Re.more_information_required=e,Re.rejected=e,Re.approved=e,Re.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(ve).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){W(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){De++})),s.$on("$destroy",Ce),s.$on("LeaveRequestPopup::addTab",function(e,t){Me.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Le="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Le="admin")}).then(function(){return"staff"===Le&&u(_.permissions.ssp.manage).then(function(e){e&&(Le="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Le===e}function se(){return v.all().then(function(e){ke.absencePeriods=e})}function ie(){return h.all(j()).then(h.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function ve(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(Oe)}function he(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),w(),ke.request.isValid().then(ee()&&O).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?we():M()}).catch(function(t){ke.request.status_id=e,t&&W(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Me.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===De&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return De>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Ce(){Te.forEach(function(e){e()})}function Ae(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function we(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,Re={},De=0,Se={},Te=[],Ie="",Oe="No entitlement",Le="",Me=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=L,ke.deleteLeaveRequest=x,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ae,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(he).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(W).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/manager-leave/modules/components",["common/angular"],function(e){return e.module("manager-leave.components",[])}),define("leave-absences/manager-leave/components/manager-leave-container",["leave-absences/manager-leave/modules/components"],function(e){e.component("managerLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/manager-leave-container.html"}],controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: manager-leave-container"),t.section="manager-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}],controllerAs:"managerLeave"})}),function(e){define("leave-absences/manager-leave/modules/settings",["common/angular"],function(t){return t.module("manager-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/"})})}(CRM),function(e){define("leave-absences/manager-leave/modules/config",["common/angular","leave-absences/manager-leave/modules/settings"],function(t){return t.module("manager-leave.config",["manager-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/manager-leave/requests"),t.state("manager-leave",{abstract:!0,url:"/manager-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("manager-leave.requests",{url:"/requests?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("manager-leave.calendar",{url:"/calendar",template:' '}).state("manager-leave.leave-balances",{url:"/leave-balances",template:" "})}])})}(CRM),
define("leave-absences/manager-leave/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/loading","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/services/angular-date/date-format","common/services/check-permissions","leave-absences/shared/ui-router","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/components/leave-balance-tab.component","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/manage-leave-requests.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/services/leave-popup.service","leave-absences/manager-leave/components/manager-leave-container","leave-absences/manager-leave/modules/config"],function(e){return e.module("manager-leave",["ngResource","ngAnimate","ui.bootstrap","ui.router","ui.select","textAngular","common.angularDate","common.dialog","common.filters","common.models","common.directives","common.mocks","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","manager-leave.config","manager-leave.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/manager-leave":n+"/manager-leave"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/manager-leave/app","leave-absences/shared/models/leave-request.model"],function(e){e.bootstrap(document.querySelector("[data-leave-absences-manager-leave]"),["manager-leave"])})})}(CRM,require),define("manager-leave",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js
index c7c7261a4b2..3758089832d 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js
@@ -9,5 +9,5 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/ui-router",[],function(){return function(){"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(e,t,n){"use strict";function a(e,t){return V(new(V(function(){},{prototype:e})),t)}function r(e){return H(arguments,function(t){t!==e&&H(t,function(t,n){e.hasOwnProperty(n)||(e[n]=t)})}),e}function o(e,t){var n=[];for(var a in e.path){if(e.path[a]!==t.path[a])break;n.push(e.path[a])}return n}function s(e){if(Object.keys)return Object.keys(e);var t=[];return H(e,function(e,n){t.push(n)}),t}function i(e,t){if(Array.prototype.indexOf)return e.indexOf(t,Number(arguments[2])||0);var n=e.length>>>0,a=Number(arguments[2])||0;for((a=a<0?Math.ceil(a):Math.floor(a))<0&&(a+=n);a=0||(l.push(r[f]),c[r[f]]=e[r[f]]);return V({},c,t)}function c(e,t,n){if(!n){n=[];for(var a in e)n.push(a)}for(var r=0;r "));if(b[n]=a,N(e))v.push(n,[function(){return t.get(e)}],c);else{var r=t.annotate(e);H(r,function(e){e!==n&&u.hasOwnProperty(e)&&m(u[e],e)}),v.push(n,e,r)}g.pop(),b[n]=o}}function p(e){return F(e)&&e.then&&e.$$promises}if(!F(u))throw new Error("'invocables' must be an object");var h=s(u||{}),v=[],g=[],b={};return H(u,m),u=g=b=null,function(a,o,s){function i(){--y||(_||r(b,o.$$values),m.$$values=b,m.$$promises=m.$$promises||!0,delete m.$$inheritedValues,c.resolve(b))}function u(e){m.$$failure=e,c.reject(e)}if(p(a)&&s===n&&(s=o,o=a,a=null),a){if(!F(a))throw new Error("'locals' must be an object")}else a=l;if(o){if(!p(o))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else o=d;var c=e.defer(),m=c.promise,g=m.$$promises={},b=V({},a),y=1+v.length/3,_=!1;if(j(o.$$failure))return u(o.$$failure),m;o.$$inheritedValues&&r(b,f(o.$$inheritedValues,h)),V(g,o.$$promises),o.$$values?(_=r(b,f(o.$$values,h)),m.$$inheritedValues=f(o.$$values,h),i()):(o.$$inheritedValues&&(m.$$inheritedValues=f(o.$$inheritedValues,h)),o.then(i,u));for(var q=0,$=v.length;q<$;q+=3)a.hasOwnProperty(v[q])?i():function(n,r,o){function c(e){d.reject(e),u(e)}function l(){if(!j(m.$$failure))try{d.resolve(t.invoke(r,s,b)),d.promise.then(function(e){b[n]=e,i()},c)}catch(e){c(e)}}var d=e.defer(),f=0;H(o,function(e){g.hasOwnProperty(e)&&!a.hasOwnProperty(e)&&(f++,g[e].then(function(t){b[e]=t,--f||l()},c))}),f||l(),g[n]=d.promise}(v[q],v[q+1],v[q+2]);return m}},this.resolve=function(e,t,n,a){return this.study(e)(t,n,a)}}function g(e,t,n){this.fromConfig=function(e,t,n){return j(e.template)?this.fromString(e.template,t):j(e.templateUrl)?this.fromUrl(e.templateUrl,t):j(e.templateProvider)?this.fromProvider(e.templateProvider,t,n):null},this.fromString=function(e,t){return B(e)?e(t):e},this.fromUrl=function(n,a){return B(n)&&(n=n(a)),null==n?null:e.get(n,{cache:t,headers:{Accept:"text/html"}}).then(function(e){return e.data})},this.fromProvider=function(e,t,a){return n.invoke(e,null,a||{params:t})}}function b(e,t,r){function o(t,n,a,r){if(v.push(t),p[t])return p[t];if(!/^\w+([-.]+\w+)*(?:\[\])?$/.test(t))throw new Error("Invalid parameter name '"+t+"' in pattern '"+e+"'");if(h[t])throw new Error("Duplicate parameter name '"+t+"' in pattern '"+e+"'");return h[t]=new Y.Param(t,n,a,r),h[t]}function s(e,t,n,a){var r=["",""],o=e.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!t)return o;switch(n){case!1:r=["(",")"+(a?"?":"")];break;case!0:o=o.replace(/\/$/,""),r=["(?:/(",")|/)?"];break;default:r=["("+n+"|",")?"]}return o+r[0]+t+r[1]}function i(r,o){var s,i,u,c,l;return s=r[2]||r[3],l=t.params[s],u=e.substring(f,r.index),i=o?r[4]:r[4]||("*"==r[1]?".*":null),i&&(c=Y.type(i)||a(Y.type("string"),{pattern:new RegExp(i,t.caseInsensitive?"i":n)})),{id:s,regexp:i,segment:u,type:c,cfg:l}}t=V({params:{}},F(t)?t:{});var u,c=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l=/([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,d="^",f=0,m=this.segments=[],p=r?r.params:{},h=this.params=r?r.params.$$new():new Y.ParamSet,v=[];this.source=e;for(var g,b,y;(u=c.exec(e))&&(g=i(u,!1),!(g.segment.indexOf("?")>=0));)b=o(g.id,g.type,g.cfg,"path"),d+=s(g.segment,b.type.pattern.source,b.squash,b.isOptional),m.push(g.segment),f=c.lastIndex;y=e.substring(f);var _=y.indexOf("?");if(_>=0){var q=this.sourceSearch=y.substring(_);if(y=y.substring(0,_),this.sourcePath=e.substring(0,f+_),q.length>0)for(f=0;u=l.exec(q);)g=i(u,!0),b=o(g.id,g.type,g.cfg,"search"),f=c.lastIndex}else this.sourcePath=e,this.sourceSearch="";d+=s(y)+(!1===t.strict?"/?":"")+"$",m.push(y),this.regexp=new RegExp(d,t.caseInsensitive?"i":n),this.prefix=m[0],this.$$paramNames=v}function y(e){V(this,e)}function _(){function e(e){return null!=e?e.toString().replace(/(~|\/)/g,function(e){return{"~":"~~","/":"~2F"}[e]}):e}function r(e){return null!=e?e.toString().replace(/(~~|~2F)/g,function(e){return{"~~":"~","~2F":"/"}[e]}):e}function o(){return{strict:h,caseInsensitive:f}}function u(e){return B(e)||U(e)&&B(e[e.length-1])}function c(){for(;$.length;){var e=$.shift();if(e.pattern)throw new Error("You cannot override a type's .pattern at runtime.");t.extend(g[e.name],d.invoke(e.def))}}function l(e){V(this,e||{})}Y=this;var d,f=!1,h=!0,v=!1,g={},q=!0,$=[],w={string:{encode:e,decode:r,is:function(e){return null==e||!j(e)||"string"==typeof e},pattern:/[^\/]*/},int:{encode:e,decode:function(e){return parseInt(e,10)},is:function(e){return j(e)&&this.decode(e.toString())===e},pattern:/\d+/},bool:{encode:function(e){return e?1:0},decode:function(e){return 0!==parseInt(e,10)},is:function(e){return!0===e||!1===e},pattern:/0|1/},date:{encode:function(e){return this.is(e)?[e.getFullYear(),("0"+(e.getMonth()+1)).slice(-2),("0"+e.getDate()).slice(-2)].join("-"):n},decode:function(e){if(this.is(e))return e;var t=this.capture.exec(e);return t?new Date(t[1],t[2]-1,t[3]):n},is:function(e){return e instanceof Date&&!isNaN(e.valueOf())},equals:function(e,t){return this.is(e)&&this.is(t)&&e.toISOString()===t.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:t.toJson,decode:t.fromJson,is:t.isObject,equals:t.equals,pattern:/[^\/]*/},any:{encode:t.identity,decode:t.identity,equals:t.equals,pattern:/.*/}};_.$$getDefaultValue=function(e){if(!u(e.value))return e.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(e.value)},this.caseInsensitive=function(e){return j(e)&&(f=e),f},this.strictMode=function(e){return j(e)&&(h=e),h},this.defaultSquashPolicy=function(e){if(!j(e))return v;if(!0!==e&&!1!==e&&!N(e))throw new Error("Invalid squash policy: "+e+". Valid policies: false, true, arbitrary-string");return v=e,e},this.compile=function(e,t){return new b(e,V(o(),t))},this.isMatcher=function(e){if(!F(e))return!1;var t=!0;return H(b.prototype,function(n,a){B(n)&&(t=t&&j(e[a])&&B(e[a]))}),t},this.type=function(e,t,n){if(!j(t))return g[e];if(g.hasOwnProperty(e))throw new Error("A type named '"+e+"' has already been defined.");return g[e]=new y(V({name:e},t)),n&&($.push({name:e,def:n}),q||c()),this},H(w,function(e,t){g[t]=new y(V({name:t},e))}),g=a(g,{}),this.$get=["$injector",function(e){return d=e,q=!1,c(),H(w,function(e,t){g[t]||(g[t]=new y(e))}),this}],this.Param=function(e,a,r,o){function c(){if(!d)throw new Error("Injectable functions cannot be called at configuration time");var e=d.invoke(r.$$fn);if(null!==e&&e!==n&&!h.type.is(e))throw new Error("Default value ("+e+") for parameter '"+h.id+"' is not an instance of Type ("+h.type.name+")");return e}function l(e){function t(e){return function(t){return t.from===e}}return e=function(e){var n=p(m(h.replace,t(e)),function(e){return e.to});return n.length?n[0]:e}(e),j(e)?h.type.$normalize(e):c()}function f(){return"{Param:"+e+" "+a+" squash: '"+q+"' optional: "+_+"}"}var h=this;r=function(e){var t=F(e)?s(e):[];return-1===i(t,"value")&&-1===i(t,"type")&&-1===i(t,"squash")&&-1===i(t,"array")&&(e={value:e}),e.$$fn=u(e.value)?e.value:function(){return e.value},e}(r),a=function(n,a,r){if(n.type&&a)throw new Error("Param '"+e+"' has two type configurations.");return a||(n.type?t.isString(n.type)?g[n.type]:n.type instanceof y?n.type:new y(n.type):"config"===r?g.any:g.string)}(r,a,o);var b=function(){var t={array:"search"===o&&"auto"},n=e.match(/\[\]$/)?{array:!0}:{};return V(t,n,r).array}();a=b?a.$asArray(b,"search"===o):a,"string"!==a.name||b||"path"!==o||r.value!==n||(r.value="");var _=r.value!==n,q=function(e,t){var n=e.squash;if(!t||!1===n)return!1;if(!j(n)||null==n)return v;if(!0===n||N(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(r,_),$=function(e,t,a,r){var o,s,u=[{from:"",to:a||t?n:""},{from:null,to:a||t?n:""}];return o=U(e.replace)?e.replace:[],N(r)&&o.push({from:r,to:n}),s=p(o,function(e){return e.from}),m(u,function(e){return-1===i(s,e.from)}).concat(o)}(r,b,_,q);V(this,{id:e,type:a,location:o,array:b,squash:q,replace:$,isOptional:_,value:l,dynamic:n,config:r,toString:f})},l.prototype={$$new:function(){return a(this,V(new l,{$$parent:this}))},$$keys:function(){for(var e=[],t=[],n=this,a=s(l.prototype);n;)t.push(n),n=n.$$parent;return t.reverse(),H(t,function(t){H(s(t),function(t){-1===i(e,t)&&-1===i(a,t)&&e.push(t)})}),e},$$values:function(e){var t={},n=this;return H(n.$$keys(),function(a){t[a]=n[a].value(e&&e[a])}),t},$$equals:function(e,t){var n=!0,a=this;return H(a.$$keys(),function(r){var o=e&&e[r],s=t&&t[r];a[r].type.equals(o,s)||(n=!1)}),n},$$validates:function(e){var a,r,o,s,i,u=this.$$keys();for(a=0;a=0)throw new Error("State must have a valid name");if(P.hasOwnProperty(n))throw new Error("State '"+n+"' is already defined");var r=-1!==n.indexOf(".")?n.substring(0,n.lastIndexOf(".")):N(t.parent)?t.parent:F(t.parent)&&N(t.parent.name)?t.parent.name:"";if(r&&!P[r])return m(r,t.self);for(var o in S)B(S[o])&&(t[o]=S[o](t,S.$delegates[o]));return P[n]=t,!t[R]&&t.url&&e.when(t.url,["$match","$stateParams",function(e,n){A.$current.navigable==t&&c(e,n)||A.transitionTo(t,e,{inherit:!0,location:!1})}]),v(n),t}function b(e){return e.indexOf("*")>-1}function y(e){for(var t=e.split("."),n=A.$current.name.split("."),a=0,r=t.length;a=P;a--)s=p[a],s.self.onExit&&i.invoke(s.self.onExit,s.self,s.locals.globals),s.locals=null;for(a=P;a<_.length;a++)r=_[a],r.locals=L[a],r.self.onEnter&&i.invoke(r.self.onEnter,r.self,r.locals.globals);return A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.$current=t,A.current=t.self,A.params=n,W(A.params,m),A.transition=null,o.location&&t.navigable&&v.push(t.navigable.url,t.navigable.locals.globals.$stateParams,{$$avoidResync:!0,replace:"replace"===o.location}),o.notify&&e.$broadcast("$stateChangeSuccess",t.self,n,c.self,d),v.update(!0),A.current)}).then(null,function(a){return a===D?S:A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.transition=null,s=e.$broadcast("$stateChangeError",t.self,n,c.self,d,a),s.defaultPrevented||v.update(),r.reject(a))});return B},A.is=function(e,t,a){a=V({relative:A.$current},a||{});var r=f(e,a.relative);return j(r)?A.$current===r&&(!t||c(r.params.$$values(t),m)):n},A.includes=function(e,t,a){if(a=V({relative:A.$current},a||{}),N(e)&&b(e)){if(!y(e))return!1;e=A.$current.name}var r=f(e,a.relative);if(!j(r))return n;if(!j(A.$current.includes[r.name]))return!1;if(!t)return!0;for(var o=s(t),i=0;i2?c.enter(e,null,n).then(a):c.enter(e,null,n,a)},leave:function(e,n){t.version.minor>2?c.leave(e).then(n):c.leave(e,n)}};if(u){var a=u&&u(n,e);return{enter:function(e,t,n){a.enter(e,null,t),n()},leave:function(e,t){a.leave(e),t()}}}return function(){return{enter:function(e,t,n){t.after(e),n()},leave:function(e,t){e.remove(),t()}}}()}var i=function(){return n.has?function(e){return n.has(e)?n.get(e):null}:function(e){try{return n.get(e)}catch(e){return null}}}(),u=i("$animator"),c=i("$animate");return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(n,i,u){return function(n,i,c){function l(){if(f&&(f.remove(),f=null),p&&(p.$destroy(),p=null),m){var e=m.data("$uiViewAnim");b.leave(m,function(){e.$$animLeave.resolve(),f=null}),f=m,m=null}}function d(s){var d,f=D(n,c,i,r),y=f&&e.$current&&e.$current.locals[f];if(s||y!==h){d=n.$new(),h=e.$current.locals[f],d.$emit("$viewContentLoading",f);var _=u(d,function(e){var r=o.defer(),s=o.defer(),u={$animEnter:r.promise,$animLeave:s.promise,$$animLeave:s};e.data("$uiViewAnim",u),b.enter(e,i,function(){r.resolve(),p&&p.$emit("$viewContentAnimationEnded"),(t.isDefined(g)&&!g||n.$eval(g))&&a(e)}),l()});m=_,p=d,p.$emit("$viewContentLoaded",f),p.$eval(v)}}var f,m,p,h,v=c.onload||"",g=c.autoscroll,b=s(c,n);i.inheritedData("$uiView"),n.$on("$stateChangeSuccess",function(){d(!1)}),d(!0)}}}}function P(e,n,a,r){return{restrict:"ECA",priority:-400,compile:function(o){var s=o.html();return function(o,i,u){var c=a.$current,l=D(o,u,i,r),d=c&&c.locals[l];if(d){i.data("$uiView",{name:l,state:d.$$state}),i.html(d.$template?d.$template:s);var f=t.extend({},d);o[d.$$resolveAs]=f;var m=e(i.contents());if(d.$$controller){d.$scope=o,d.$element=i;var p=n(d.$$controller,d);d.$$controllerAs&&(o[d.$$controllerAs]=p,o[d.$$controllerAs][d.$$resolveAs]=f),B(p.$onInit)&&p.$onInit(),i.data("$ngControllerController",p),i.children().data("$ngControllerController",p)}m(o)}}}}}function D(e,t,n,a){var r=a(t.uiView||t.name||"")(e),o=n.inheritedData("$uiView");return r.indexOf("@")>=0?r:r+"@"+(o?o.state.name:"")}function R(e,t){var n,a=e.match(/^\s*({[^}]*})\s*$/);if(a&&(e=t+"("+a[1]+")"),!(n=e.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/))||4!==n.length)throw new Error("Invalid state ref '"+e+"'");return{state:n[1],paramExpr:n[3]||null}}function S(e){var t=e.parent().inheritedData("$uiView");if(t&&t.state&&t.state.name)return t.state}function T(e){var t="[object SVGAnimatedString]"===Object.prototype.toString.call(e.prop("href")),n="FORM"===e[0].nodeName;return{attr:n?"action":t?"xlink:href":"href",isAnchor:"A"===e.prop("tagName").toUpperCase(),clickable:!n}}function I(e,t,n,a,r){return function(o){var s=o.which||o.button,i=r();if(!(s>1||o.ctrlKey||o.metaKey||o.shiftKey||e.attr("target"))){var u=n(function(){t.go(i.state,i.params,i.options)});o.preventDefault();var c=a.isAnchor&&!i.href?1:0;o.preventDefault=function(){c--<=0&&n.cancel(u)}}}}function x(e,t){return{relative:S(e)||t.$current,inherit:!0}}function O(e,n){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(a,r,o,s){var i,u=R(o.uiSref,e.current.name),c={state:u.state,href:null,params:null},l=T(r),d=s[1]||s[0],f=null;c.options=V(x(r,e),o.uiSrefOpts?a.$eval(o.uiSrefOpts):{});var m=function(n){n&&(c.params=t.copy(n)),c.href=e.href(u.state,c.params,c.options),f&&f(),d&&(f=d.$$addStateInfo(u.state,c.params)),null!==c.href&&o.$set(l.attr,c.href)};u.paramExpr&&(a.$watch(u.paramExpr,function(e){e!==c.params&&m(e)},!0),c.params=t.copy(a.$eval(u.paramExpr))),m(),l.clickable&&(i=I(r,e,n,l,function(){return c}),r[r.on?"on":"bind"]("click",i),a.$on("$destroy",function(){r[r.off?"off":"unbind"]("click",i)}))}}}function L(e,t){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(n,a,r,o){function s(t){f.state=t[0],f.params=t[1],f.options=t[2],f.href=e.href(f.state,f.params,f.options),m&&m(),c&&(m=c.$$addStateInfo(f.state,f.params)),f.href&&r.$set(u.attr,f.href)}var i,u=T(a),c=o[1]||o[0],l=[r.uiState,r.uiStateParams||null,r.uiStateOpts||null],d="["+l.map(function(e){return e||"null"}).join(", ")+"]",f={state:null,params:null,options:null,href:null},m=null;n.$watch(d,s,!0),s(n.$eval(d)),u.clickable&&(i=I(a,e,t,u,function(){return f}),a[a.on?"on":"bind"]("click",i),n.$on("$destroy",function(){a[a.off?"off":"unbind"]("click",i)}))}}}function k(e,t,n){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout",function(t,a,r,o){function s(t,n,r){var o=e.get(t,S(a)),s=i(t,n),u={state:o||{name:t},params:n,hash:s};return h.push(u),v[s]=r,function(){var e=h.indexOf(u);-1!==e&&h.splice(e,1)}}function i(e,n){if(!N(e))throw new Error("state should be a string");return F(n)?e+G(n):(n=t.$eval(n),F(n)?e+G(n):e)}function u(){for(var e=0;e0)){var n=s(e,t,p);return u(),n}},t.$on("$stateChangeSuccess",u),u()}]}}function M(e){var t=function(t,n){return e.is(t,n)};return t.$stateful=!0,t}function E(e){var t=function(t,n,a){return e.includes(t,n,a)};return t.$stateful=!0,t}var j=t.isDefined,B=t.isFunction,N=t.isString,F=t.isObject,U=t.isArray,H=t.forEach,V=t.extend,W=t.copy,G=t.toJson;t.module("ui.router.util",["ng"]),t.module("ui.router.router",["ui.router.util"]),t.module("ui.router.state",["ui.router.router","ui.router.util"]),t.module("ui.router",["ui.router.state"]),t.module("ui.router.compat",["ui.router"]),v.$inject=["$q","$injector"],t.module("ui.router.util").service("$resolve",v),g.$inject=["$http","$templateCache","$injector"],t.module("ui.router.util").service("$templateFactory",g);var Y;b.prototype.concat=function(e,t){var n={caseInsensitive:Y.caseInsensitive(),strict:Y.strictMode(),squash:Y.defaultSquashPolicy()};return new b(this.sourcePath+e+this.sourceSearch,V(n,t),this)},b.prototype.toString=function(){return this.source},b.prototype.exec=function(e,t){var n=this.regexp.exec(e);if(!n)return null;t=t||{};var a,r,o,s=this.parameters(),i=s.length,u=this.segments.length-1,c={};if(u!==n.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");var l,d;for(a=0;a=":e}};return a.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,r){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,o,s){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),s=e.assign({},s,{absence_type_id:a,date:t(o).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",s).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,r,o,s){return t.debug("AbsenceType"),a.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return s.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return o.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return o.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function r(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(r),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,r,o){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,r,"getLeaveBalances",o)}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,r,o,s,i){function u(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(v.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(v.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function c(){return{loadContacts:function(){var e=v.filters.userSettings.assignedTo.type;return f(e).then(function(e){v.lookupContacts=e}).then(function(){return"me"!==e?u():a.resolve(null)}).then(function(e){return v.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return r.all(m(),null,"display_name").then(function(e){return e.list})}function d(){return h?a.resolve(h):s.all()}function f(e){return"me"===e?r.leaveManagees(v.contactId):"unassigned"===e?r.leaveManagees(void 0,{unassigned:!0}):r.all().then(function(e){return e.list})}function m(){return{department:v.filters.userSettings.department?v.filters.userSettings.department.value:null,level_type:v.filters.userSettings.level_type?v.filters.userSettings.level_type.value:null,location:v.filters.userSettings.location?v.filters.userSettings.location.value:null,region:v.filters.userSettings.region?v.filters.userSettings.region.value:null,id:{IN:v.filters.userSettings.contact?[v.filters.userSettings.contact.id]:v.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",[" When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,c()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:s.contactId}).leaveManagees().then(function(e){s.lookupContacts=e}).then(r)}}}function r(){return t.all(o(),null,"display_name").then(function(e){return e.list})}function o(){return{department:s.filters.userSettings.department?s.filters.userSettings.department.value:null,level_type:s.filters.userSettings.level_type?s.filters.userSettings.level_type.value:null,location:s.filters.userSettings.location?s.filters.userSettings.location.value:null,region:s.filters.userSettings.region?s.filters.userSettings.region.value:null,id:{IN:s.filters.userSettings.contact?[s.filters.userSettings.contact.id]:s.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var s;return{init:function(e){return s=e,s.showContactName=!0,s.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function r(a,r,o,s,i,u,c,l,d,f){function m(){for(var e=[],t=n(L.selectedPeriod.start_date).clone().startOf("month"),a=n(L.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(P(t)),t.add(1,"month");L.months=e}function p(){s.$new().$watch(function(){return L.selectedMonths},function(t,n){null===n||e.equals(t,n)||R()})}function h(e){L.injectMonths=!0,I("injected").then(function(){R(e)}).then(function(){L.loading.calendar=!1})}function v(){x=a("LeaveCalendar"+t.capitalize(O)+"Controller").init(L)}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function b(){return u.all().then(function(e){L.absencePeriods=t.sortBy(e,"start_date"),L.selectedPeriod=t.find(L.absencePeriods,function(e){return!!e.current})}).then(m).then(S)}function y(){return c.all().then(c.loadCalculationUnits)}function _(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return x.loadContacts().then(function(e){L.contacts=e})}function $(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){L.filters.optionValues.regions=e.hrjc_region,L.filters.optionValues.locations=e.hrjc_location,L.filters.optionValues.levelTypes=e.hrjc_level_type,L.filters.optionValues.departments=e.hrjc_department})}function w(){return l.all()}function C(){return r.all([y(),w(),_()]).then(function(e){L.supportData.absenceTypes=e[0],L.supportData.publicHolidays=e[1],L.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,L.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,L.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,L.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function A(){var e=r.resolve();return L.injectMonths&&(e=I("destroyed"),L.injectMonths=!1),e}function P(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function D(e){
e=t.includes(["contacts","period"],e)?e:"period",r.resolve().then(function(){L.loading.calendar=!0}).then(A).then("period"===e?m:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function R(e){var n=L.selectedMonths.length?L.months.filter(function(e){return t.includes(L.selectedMonths,e.index)}):L.months;s.$emit("LeaveCalendar::showMonths",n,!!e)}function S(){L.selectedMonths=[n().month()]}function T(){return L.roleOverride?r.resolve().then(function(){O=L.roleOverride}):r.all([f(i.permissions.admin.administer),f(i.permissions.ssp.manage)]).then(function(e){O=e[0]?"admin":e[1]?"manager":"staff"})}function I(e){return r(function(n){var a=0,r=s.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===L.months.length&&(r(),n())})})}o.debug("Component: leave-calendar");var x,O,L=this;L.absencePeriods=[],L.contacts=[],L.contactIdsToReduceTo=null,L.injectMonths=!1,L.months=[],L.selectedMonths=null,L.selectedPeriod=null,L.showContactName=!1,L.showFilters=!1,L.supportData={},L.loading={calendar:!0,page:!0},L.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},L.labelPeriod=g,L.refresh=D,function(){T().then(p).then(v).then(A).then(b).then(function(){return r.all([q(),C()])}).then(function(){return L.showFilters?$():t.noop}).then(function(){h()}).then(function(){L.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",r]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,r){"use strict";function o(){_.calculationUnit=s(_.supportData.calculationUnits,"value",g.calculation_unit)}function s(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(_.contactData.leaveRequest.from_date).isSame(_.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+_.calculationUnit.name+"-on-"+e+"-tooltip"}function u(){g=s(_.supportData.absenceTypes,"id",_.contactData.leaveRequest.type_id),_.contactData.leaveRequest["type_id.title"]=g.title}function c(){"days"===_.calculationUnit.name&&(b=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.from_date_type),y=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.to_date_type),_.contactData.leaveRequest["from_date_type.label"]=b.label,_.contactData.leaveRequest["to_date_type.label"]=y.label)}function l(e,t,n,a,o){e.stopPropagation(),r.openModal(t,n,a,o)}function d(){_.dates.from=new Date(_.contactData.leaveRequest.from_date),_.dates.to=new Date(_.contactData.leaveRequest.to_date)}function f(){_.contactData.isAccruedTOIL?_.label="AT":"days"===_.calculationUnit.name?m():p()}function m(){_.label=_.contactData.isAM?"AM":_.contactData.isPM?"PM":""}function p(){var e=t(_.contactData.leaveRequest.from_date).isSame(_.date,"day"),n=t(_.contactData.leaveRequest.to_date).isSame(_.date,"day");_.label=e?t(_.contactData.leaveRequest.from_date).format("HH:mm"):n?t(_.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){_.tooltipTemplate=_.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){_.contactData&&_.contactData.leaveRequest&&(u(),o(),c(),f(),d(),h())})}n.debug("Component: leave-calendar-day");var g,b,y,_=this;_.calculationUnit="",_.dates={from:null,to:null},_.label="",_.tooltipTemplate=null,_.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(e){y([e]),B(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),r=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:r.format("YYYY-MM-DD"),name:r.format("ddd"),index:r.format("D"),current:a.isSame(r,"day"),enabled:r.isSameOrAfter(V.period.start_date)&&r.isSameOrBefore(V.period.end_date),contactsData:{}};return r.add(1,"day"),e})}function f(e){return U[e]}function m(){return V.showOnlyWithLeaveRequests?V.contacts.filter(function(e){return Object.keys(H[e.id]||{}).length}):V.contacts}function p(e){return t(e,u.serverDateFormat)}function h(e){x(e),B(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function g(){return V.contactIdsToReduceTo&&(V.contacts=V.contacts.filter(function(t){return e.includes(V.contactIdsToReduceTo,t.contact_id)||e.find(H,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function b(){V.supportData.dayTypes=e.indexBy(V.supportData.dayTypes,"name"),V.supportData.leaveRequestStatuses=e.indexBy(V.supportData.leaveRequestStatuses,"value"),V.supportData.publicHolidays=e.transform(V.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function y(e){return e.forEach(function(e){var t=A(e);H[e.contact_id]=H[e.contact_id]||{},t.forEach(function(t){H[e.contact_id][t.date]=e})}),a.resolve()}function _(){F.push(r.$on("LeaveCalendar::showMonths",M)),F.push(i.subscribe("LeaveRequest::new",c)),F.push(i.subscribe("LeaveRequest::edit",j)),F.push(i.subscribe("LeaveRequest::updatedByManager",j)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):j(e.leaveRequest)}))}function q(e,n,a){var r=V.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?r.value===n.from_date_type:t(a).isSame(n.to_date,"day")?r.value===n.to_date_type:void 0}function $(e,t){return e.request_type===t}function w(e){return!!V.supportData.publicHolidays[p(e).valueOf()]}function C(t){var n=V.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([u.statusNames.awaitingApproval,u.statusNames.moreInformationRequired],n)}function A(n){for(var a=[],r=t(n.from_date).clone(),o=t(n.to_date);r.isSameOrBefore(o);)r.month()===V.month.index&&r.year()===V.month.year&&a.push(e.find(V.month.days,function(e){return e.date===r.format("YYYY-MM-DD")})),r.add(1,"day");return a}function P(t){return e.find(H[t.contact_id],function(e){return t.id===e.id})}function D(t){var n=e.find(V.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function R(){return[D(u.statusNames.approved),D(u.statusNames.adminApproved),D(u.statusNames.awaitingApproval),D(u.statusNames.moreInformationRequired)]}function S(){return V.month.loading=!0,a.all([I(),T()]).then(g).then(k).then(function(){N=!0}).then(function(){V.month.loading=!1})}function T(){return s.all({from_date:{to:V.month.days[V.month.days.length-1].date},to_date:{from:V.month.days[0].date},status_id:{IN:R()},contact_id:{IN:V.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(V.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return y(e.list)})}function I(){var t=V.month.days[0].date,n=V.month.days[V.month.days.length-1].date;return o.get(V.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function x(t){H[t.contact_id]=e.omit(H[t.contact_id],function(e){return e.id===t.id})}function O(){r.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function L(t,n,r){var o,s;return t.contactsData[n]=t.contactsData[n]||{},s=f(n),o=!0===r?a.resolve():a.all([s.isWeekend(p(t.date)),s.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:w(t.date)})}),o.then(function(){return H[n]?H[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?$(a,"toil"):null,isRequested:a?C(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function k(){return a.all(V.month.days.map(function(e){return a.all(V.contacts.map(function(t){return L(e,t.id)}))}))}function M(t,n,a){!e.find(n,function(e){return e.index===V.month.index})?V.visible=!1:(V.currentPage=0,V.visible=!0,(a||!N)&&S())}function E(t){var n=e.find(V.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function j(e){var t=P(e);t&&(h(t),-1!==R().indexOf(e.status_id)&&c(e))}function B(e){return a.all(A(e).map(function(t){return L(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var N=!1,F=[],U={},H={},V=this;V.currentPage=0,V.pageSize=20,V.visible=!1,V.showContactName=!!V.showContactName,V.showOnlyWithLeaveRequests=!!V.showOnlyWithLeaveRequests,V.$onDestroy=O,V.contactsList=m,V.getContactUrl=v,function(){var e=t().month(V.month.index).year(V.month.year);b(),_(),V.month=l(e),r.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function r(){var t=n.defer();return a.open(e.defaults(o(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function o(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:o,promptBalanceChangeRecalculation:r}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(h(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=w[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function v(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(w,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:w[e].label,isDirectAction:w[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,w={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,u.serverDateFormat).toDate()}function v(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return w(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return W()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return V(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),V("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):C(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function w(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function C(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function A(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function D(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function R(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():D()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function x(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function O(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function L(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(R(a.min,n)<=0||R(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function M(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(V)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){x(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function V(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function W(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return v(pe.request.from_date)===v(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=he[a].number_of_hours?R(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return V("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(A(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),O(),pe.initChildController().then(function(){return s.all([W(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return M().then(oe)}).then(!pe.isMode("create")&&Z).then(L).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?D.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(D.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function w(){return u.valuesOf("safe_file_extension").then(function(e){D=e})}function C(e){return!e.attachment_id||T.canManage}function A(){e.forEach(R,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var D=[],R=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=A,T.canRemoveAttachment=C,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=h,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([w(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{
-type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"},{type:"toil",icon:"calendar-plus-o",label:"Overtime"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{btnClass:"@",contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,r,o,s,i,u,c,l,d,f){function m(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),H.sections.other.open&&m(e,H.sections.other)}function h(){Object.values(H.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):H.refresh()}function g(t){t.dataIndex=e.indexBy(t.data,"id")}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function y(){return o.all().then(function(t){H.absencePeriods=e.sortBy(t,"start_date"),H.selectedPeriod=e.find(H.absencePeriods,function(e){return!0===e.current})})}function _(){return s.all().then(s.loadCalculationUnits).then(function(t){H.absenceTypes=t,H.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return D("approved",{status_id:F(f.statusNames.approved)})}function $(){return n.all([u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,null,!0),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.approved)]),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)])]).then(function(e){H.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function w(){return i.all({contact_id:H.contactId,period_id:H.selectedPeriod.id},!0).then(function(e){H.entitlements=e}).then(function(){H.absenceTypesFiltered=H.absenceTypes.filter(function(t){var n=e.find(H.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function C(){return i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id},H.entitlements).then(function(){return L(H.entitlements)}).then(function(e){H.sections.entitlements.data=e})}function A(){return n.all([i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id,expired:!0}),P({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:L(e[0]),expiredTOILS:k(e[1].list)})}).then(function(t){H.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),H.sections.expired.data=e.sortBy(H.sections.expired.data,"expiry_date")})}function P(t){return u.all(e.assign({contact_id:H.contactId,from_date:{from:H.selectedPeriod.start_date},to_date:{to:H.selectedPeriod.end_date},type_id:{IN:H.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function D(e,t){return P(t).then(function(t){H.sections[e].data=t.list})}function R(){return n.all(Object.values(H.sections).filter(function(e){return e.open}).map(x))}function S(){return D("other",{status_id:{in:[F(f.statusNames.rejected),F(f.statusNames.cancelled)]}})}function T(){return D("pending",{status_id:{in:[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)]}})}function I(){return D("holidays",{public_holiday:!0})}function x(e){return e.loading=!0,e.loadLeaveRequests().then(g.bind(this,e)).then(function(){e.loading=!1})}function O(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){H.leaveRequestStatuses=e.indexBy(t,"value")})}function L(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(H.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function k(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function M(){l.subscribe("LeaveRequest::new",function(){H.refresh()}),l.subscribe("LeaveRequest::edit",function(){H.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(H.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],j(t,a))})}function j(e,t){var n=H.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function B(){H.loading.content=!0,n.all([w(),$()]).then(function(){H.loading.content=!1}).then(function(){return n.all([R(),h()])})}function N(e){var t=H.sections[e];t.open=!t.open,t.open&&!t.data.length&&x(t)}function F(t){return e.find(H.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},H=this;H.absencePeriods=[],H.absenceTypes=[],H.absenceTypesFiltered=[],H.absenceTypesIndexed={},H.dateFormat=d.DATE_FORMAT,H.leaveRequestStatuses={},H.selectedPeriod=null,H.role="absence-tab"===a.section?"admin":"staff",H.loading={content:!0,page:!0},H.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:C},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:A},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:T},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:S}},H.labelPeriod=b,H.refresh=B,H.toggleSection=N,function(){n.all([O(),_(),y()]).then(function(){H.loading.page=!1}).then(function(){return n.all([w(),$()])}).then(function(){H.loading.content=!1}),M()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=C.from_date!==s.request.from_date||C.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){C=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function w(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var C,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=w,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,h,v,g,b,y,_,q,$,w){function C(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function A(){["from","to"].forEach(C)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function D(){return Le.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function R(){return Le.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=D();return ke.isMode("edit")&&(e=e&&(W()||R())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function x(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return w.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function O(){ke.errors=[]}function L(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function M(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(De[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function V(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function W(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(he).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==xe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];De.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],De.awaiting_approval=e,De.more_information_required=e,De.rejected=e,De.approved=e,De.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(he).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){V(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){Re++})),s.$on("$destroy",we),s.$on("LeaveRequestPopup::addTab",function(e,t){Le.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Oe="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Oe="admin")}).then(function(){return"staff"===Oe&&u(_.permissions.ssp.manage).then(function(e){e&&(Oe="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Oe===e}function se(){return h.all().then(function(e){ke.absencePeriods=e})}function ie(){return v.all(j()).then(v.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function he(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(xe)}function ve(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),A(),ke.request.isValid().then(ee()&&x).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?Ae():L()}).catch(function(t){ke.request.status_id=e,t&&V(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Le.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===Re&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return Re>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function we(){Te.forEach(function(e){e()})}function Ce(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Ae(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,De={},Re=0,Se={},Te=[],Ie="",xe="No entitlement",Oe="",Le=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=O,ke.deleteLeaveRequest=M,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ce,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(ve).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(V).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/my-leave/modules/components",["common/angular"],function(e){return e.module("my-leave.components",[])}),define("leave-absences/my-leave/components/my-leave-container.component",["leave-absences/my-leave/modules/components"],function(e){e.component("myLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/my-leave-container.html"}],controllerAs:"myleave",controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: my-leave-container"),t.section="my-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}]})}),function(e){define("leave-absences/my-leave/modules/settings",["common/angular"],function(t){return t.module("my-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/my-leave/"})})}(CRM),function(e){define("leave-absences/my-leave/modules/config",["common/angular","leave-absences/my-leave/modules/settings"],function(t){return t.module("my-leave.config",["my-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/my-leave/report"),t.state("my-leave",{abstract:!0,url:"/my-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("my-leave.report",{url:"/report?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("my-leave.calendar",{url:"/calendar",template:' '})}])})}(CRM),define("leave-absences/my-leave/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/loading","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/models/option-group","common/modules/dialog","common/services/check-permissions","common/services/angular-date/date-format","leave-absences/shared/ui-router","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/my-leave/components/my-leave-container.component","leave-absences/my-leave/modules/config"],function(e){return e.module("my-leave",["ngResource","ngAnimate","ui.bootstrap","ui.router","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.mocks","common.models","common.services","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","my-leave.components","my-leave.config"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/my-leave":n+"/my-leave"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/my-leave/app"],function(e){e.bootstrap(document.querySelector("[data-leave-absences-my-leave]"),["my-leave"])})})}(CRM,require),define("my-leave",function(){});
+type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,r,o,s,i,u,c,l,d,f){function m(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),H.sections.other.open&&m(e,H.sections.other)}function h(){Object.values(H.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):H.refresh()}function g(t){t.dataIndex=e.indexBy(t.data,"id")}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function y(){return o.all().then(function(t){H.absencePeriods=e.sortBy(t,"start_date"),H.selectedPeriod=e.find(H.absencePeriods,function(e){return!0===e.current})})}function _(){return s.all().then(s.loadCalculationUnits).then(function(t){H.absenceTypes=t,H.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return D("approved",{status_id:F(f.statusNames.approved)})}function $(){return n.all([u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,null,!0),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.approved)]),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)])]).then(function(e){H.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function w(){return i.all({contact_id:H.contactId,period_id:H.selectedPeriod.id},!0).then(function(e){H.entitlements=e}).then(function(){H.absenceTypesFiltered=H.absenceTypes.filter(function(t){var n=e.find(H.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function C(){return i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id},H.entitlements).then(function(){return L(H.entitlements)}).then(function(e){H.sections.entitlements.data=e})}function A(){return n.all([i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id,expired:!0}),P({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:L(e[0]),expiredTOILS:k(e[1].list)})}).then(function(t){H.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),H.sections.expired.data=e.sortBy(H.sections.expired.data,"expiry_date")})}function P(t){return u.all(e.assign({contact_id:H.contactId,from_date:{from:H.selectedPeriod.start_date},to_date:{to:H.selectedPeriod.end_date},type_id:{IN:H.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function D(e,t){return P(t).then(function(t){H.sections[e].data=t.list})}function R(){return n.all(Object.values(H.sections).filter(function(e){return e.open}).map(x))}function S(){return D("other",{status_id:{in:[F(f.statusNames.rejected),F(f.statusNames.cancelled)]}})}function T(){return D("pending",{status_id:{in:[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)]}})}function I(){return D("holidays",{public_holiday:!0})}function x(e){return e.loading=!0,e.loadLeaveRequests().then(g.bind(this,e)).then(function(){e.loading=!1})}function O(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){H.leaveRequestStatuses=e.indexBy(t,"value")})}function L(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(H.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function k(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function M(){l.subscribe("LeaveRequest::new",function(){H.refresh()}),l.subscribe("LeaveRequest::edit",function(){H.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(H.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],j(t,a))})}function j(e,t){var n=H.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function B(){H.loading.content=!0,n.all([w(),$()]).then(function(){H.loading.content=!1}).then(function(){return n.all([R(),h()])})}function N(e){var t=H.sections[e];t.open=!t.open,t.open&&!t.data.length&&x(t)}function F(t){return e.find(H.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},H=this;H.absencePeriods=[],H.absenceTypes=[],H.absenceTypesFiltered=[],H.absenceTypesIndexed={},H.dateFormat=d.DATE_FORMAT,H.leaveRequestStatuses={},H.selectedPeriod=null,H.role="absence-tab"===a.section?"admin":"staff",H.loading={content:!0,page:!0},H.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:C},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:A},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:T},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:S}},H.labelPeriod=b,H.refresh=B,H.toggleSection=N,function(){n.all([O(),_(),y()]).then(function(){H.loading.page=!1}).then(function(){return n.all([w(),$()])}).then(function(){H.loading.content=!1}),M()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=C.from_date!==s.request.from_date||C.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){C=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function w(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var C,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=w,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,h,v,g,b,y,_,q,$,w){function C(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function A(){["from","to"].forEach(C)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function D(){return Le.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function R(){return Le.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=D();return ke.isMode("edit")&&(e=e&&(W()||R())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function x(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return w.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function O(){ke.errors=[]}function L(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function M(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(De[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function V(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function W(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(he).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==xe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];De.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],De.awaiting_approval=e,De.more_information_required=e,De.rejected=e,De.approved=e,De.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(he).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){V(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){Re++})),s.$on("$destroy",we),s.$on("LeaveRequestPopup::addTab",function(e,t){Le.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Oe="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Oe="admin")}).then(function(){return"staff"===Oe&&u(_.permissions.ssp.manage).then(function(e){e&&(Oe="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Oe===e}function se(){return h.all().then(function(e){ke.absencePeriods=e})}function ie(){return v.all(j()).then(v.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function he(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(xe)}function ve(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),A(),ke.request.isValid().then(ee()&&x).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?Ae():L()}).catch(function(t){ke.request.status_id=e,t&&V(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Le.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===Re&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return Re>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function we(){Te.forEach(function(e){e()})}function Ce(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Ae(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,De={},Re=0,Se={},Te=[],Ie="",xe="No entitlement",Oe="",Le=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=O,ke.deleteLeaveRequest=M,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ce,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(ve).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(V).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/my-leave/modules/components",["common/angular"],function(e){return e.module("my-leave.components",[])}),define("leave-absences/my-leave/components/my-leave-container.component",["leave-absences/my-leave/modules/components"],function(e){e.component("myLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/my-leave-container.html"}],controllerAs:"myleave",controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: my-leave-container"),t.section="my-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}]})}),function(e){define("leave-absences/my-leave/modules/settings",["common/angular"],function(t){return t.module("my-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/my-leave/"})})}(CRM),function(e){define("leave-absences/my-leave/modules/config",["common/angular","leave-absences/my-leave/modules/settings"],function(t){return t.module("my-leave.config",["my-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/my-leave/report"),t.state("my-leave",{abstract:!0,url:"/my-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("my-leave.report",{url:"/report?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("my-leave.calendar",{url:"/calendar",template:' '})}])})}(CRM),define("leave-absences/my-leave/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/loading","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/models/option-group","common/modules/dialog","common/services/check-permissions","common/services/angular-date/date-format","leave-absences/shared/ui-router","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/my-leave/components/my-leave-container.component","leave-absences/my-leave/modules/config"],function(e){return e.module("my-leave",["ngResource","ngAnimate","ui.bootstrap","ui.router","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.mocks","common.models","common.services","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","my-leave.components","my-leave.config"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/my-leave":n+"/my-leave"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/my-leave/app"],function(e){e.bootstrap(document.querySelector("[data-leave-absences-my-leave]"),["my-leave"])})})}(CRM,require),define("my-leave",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js
index a913af5cbcb..638441ccb48 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js
@@ -7,7 +7,6 @@ define([
], function (components) {
components.component('leaveRequestRecordActions', {
bindings: {
- btnClass: '@',
contactId: '<',
selectedContactId: '<',
isSelfRecord: '<'
@@ -27,8 +26,7 @@ define([
vm.leaveRequestOptions = [
{ type: 'leave', icon: 'briefcase', label: 'Leave' },
- { type: 'sickness', icon: 'stethoscope', label: 'Sickness' },
- { type: 'toil', icon: 'calendar-plus-o', label: 'Overtime' }
+ { type: 'sickness', icon: 'stethoscope', label: 'Sickness' }
];
vm.openLeavePopup = openLeavePopup;
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/components/leave-request-record-actions.component.spec.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/components/leave-request-record-actions.component.spec.js
index 74cb56f24ca..7888174f7bb 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/components/leave-request-record-actions.component.spec.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/components/leave-request-record-actions.component.spec.js
@@ -37,7 +37,7 @@ define([
return option.type;
});
- expect(options).toEqual(['leave', 'sickness', 'toil']);
+ expect(options).toEqual(['leave', 'sickness']);
});
});
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
new file mode 100644
index 00000000000..3004229de9e
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
@@ -0,0 +1,34 @@
+leave-request-record-actions {
+ display: block;
+ margin-bottom: $crm-panel-nested-indent;
+
+ .fa,
+ .btn-group {
+ margin-right: $crm-gap-medium;
+ }
+}
+
+leave-request-record-actions .btn-toolbar {
+ margin-left: 0;
+ overflow: inherit;
+
+ .btn-group,
+ .btn {
+ margin-left: 0;
+ }
+}
+
+@media screen and (max-width: $screen-xs-max) {
+ leave-request-record-actions {
+ .btn-group,
+ .btn {
+ display: block;
+ width: 100%;
+ }
+
+ .btn-group {
+ margin-bottom: $crm-gap-medium;
+ margin-right: 0;
+ }
+ }
+}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave.scss
index 2788714152a..6f4c41aa631 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave.scss
@@ -4,7 +4,7 @@ $leave-taller-input-height: 40px;
margin-right: 5px;
position: relative;
top: 1px;
- width: calc(100% - 80px);
+ width: 100%;
select {
height: $leave-taller-input-height;
@@ -15,18 +15,3 @@ $leave-taller-input-height: 40px;
width: $leave-taller-input-height;
}
}
-
-leave-request-record-actions {
- .dropdown-menu {
- left: auto;
- right: 0;
- }
-
- .dropdown-toggle {
- height: $leave-taller-input-height;
- }
-
- i.fa {
- margin-right: 8px;
- }
-}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
index 6787c3be2d1..656300104a6 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
@@ -1,12 +1,4 @@
.absence-tab-page {
- .btn-group {
- margin-bottom: 20px;
-
- > .btn {
- border-color: transparent !important;
- }
- }
-
.tab-pane {
padding: 0 !important;
}
@@ -14,4 +6,8 @@
.tab-content {
background-color: transparent !important;
}
+
+ leave-request-record-actions {
+ margin-bottom: 20px;
+ }
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss
index 7486864d8e1..310180921de 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss
@@ -3,7 +3,9 @@ $content-container-margin: 16px;
@at-root {
.page-civicrm-leaveandabsences-dashboard {
- h1.page-title,
+
+ /* stylelint-disable selector-max-id */
+ .page-title,
#branding {
display: none !important;
}
@@ -12,6 +14,7 @@ $content-container-margin: 16px;
margin: 0;
padding: 0;
}
+ /* stylelint-enable */
}
.admin-dashboard-page {
@@ -19,33 +22,29 @@ $content-container-margin: 16px;
.crm_page__topbar {
height: 65px;
+ }
- .dropdown-toggle {
- margin: 15px 30px 0 0 !important;
-
- +ul {
- margin-right: 30px !important;
- }
- }
+ leave-request-record-actions {
+ margin: 12px 30px 0 0;
}
.chr_admin-dashboard_side-nav {
+ background-color: $crm-white;
+ height: calc(100% - 12px);
overflow: hidden;
- width: $navigation-column-width;
position: absolute;
- height: calc(100% - 12px);
- background-color: $crm-white;
+ width: $navigation-column-width;
- li.active {
+ .active {
background: $gray-light;
}
}
.chr_admin-dashboard_content {
float: right;
- width: calc(100% - #{$navigation-column-width} - #{$content-container-margin} * 2);
margin: $content-container-margin;
margin-bottom: 0;
+ width: calc(100% - #{$navigation-column-width} - #{$content-container-margin} * 2);
}
}
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/shared/components/leave-request-record-actions.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/shared/components/leave-request-record-actions.html
index d17bf608bd7..13bea9c9691 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/shared/components/leave-request-record-actions.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/shared/components/leave-request-record-actions.html
@@ -1,14 +1,26 @@
-
-
- Record New Absence
- New
+
From 8189ea1cd1a784939845408a9e595dc3b8d4fc39 Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Tue, 20 Mar 2018 17:01:42 +0000
Subject: [PATCH 060/203] PCHR-3426: Fix work pattern tab layout
---
.../absence-tab/components/absence-tab-work-patterns.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html
index 1841e0ae6b5..77106b7ed35 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html
@@ -1,8 +1,8 @@
-
+
ADD CUSTOM WORK PATTERN
-
+
From a06a7d10d1b9ccf3d496dd873f95479da6bcdfda Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Tue, 20 Mar 2018 17:34:37 +0000
Subject: [PATCH 061/203] PCHR-3426: Improve components positions
---
.../css/leaveandabsence.css | 2 +-
.../scss/components/_leave-request-record-actions.scss | 1 -
.../scss/pages/_absence-tab-page.scss | 2 +-
.../scss/pages/_admin-dashboard-page.scss | 2 +-
4 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css b/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
index 3f0b2ede710..e7827dc794f 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
@@ -1 +1 @@
-#bootstrap-theme .chr_disabled{opacity:0.5;pointer-events:none}#bootstrap-theme .table-condensed>thead>tr>th{background:#fff !important;padding:8px 5px}#bootstrap-theme .table-condensed-mixed>thead>tr>th,#bootstrap-theme .table-condensed-mixed>thead>tr>td,#bootstrap-theme .table-condensed-mixed>tbody>tr>th,#bootstrap-theme .table-condensed-mixed>tbody>tr>td{padding-left:5px;padding-right:5px}#bootstrap-theme .table-condensed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed>thead>tr>td:first-child,#bootstrap-theme .table-condensed>thead>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:first-child{padding-left:20px}#bootstrap-theme .table-condensed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed>thead>tr>td:last-child,#bootstrap-theme .table-condensed>thead>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:last-child{padding-right:20px}#bootstrap-theme .table-nested{overflow-y:hidden;position:relative}#bootstrap-theme .table-nested:before{box-shadow:inset 0px 6px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;top:0;width:100%;z-index:10}#bootstrap-theme .table-nested:after{box-shadow:inset 0px -4px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;bottom:0;width:100%;z-index:10}#bootstrap-theme .table-nested>table,#bootstrap-theme .table-nested>.table{background-color:#fff}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>table>thead>tr>td:first-child,#bootstrap-theme .table-nested>table>thead>tr>th:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child{padding-left:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child:before{background:#c2cfd8;content:'';display:block;height:110%;left:0;position:absolute;top:0;width:10px;z-index:2}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>table>thead>tr>td:last-child,#bootstrap-theme .table-nested>table>thead>tr>th:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child{padding-right:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child:after{background:#c2cfd8;content:'';display:block;height:110%;right:0;position:absolute;top:0;width:10px;z-index:2}@media screen and (max-width: 767px){#bootstrap-theme .table-nested.table-responsive{border:0;margin-bottom:0}}#bootstrap-theme .table-nested-cell{padding:0 !important}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(1){width:40%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(2){width:15%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(3){width:35%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(4){width:10%}#bootstrap-theme .chr_absence-work-pattern__work-pattern-listing{display:inline-block}#bootstrap-theme .chr_absence-work-pattern__alert{margin-bottom:0 !important}#bootstrap-theme .annual-entitlement-change-log-component thead td{min-width:100px}#bootstrap-theme .annual-entitlement-change-log-component thead .annual-entitlement-change-log-component__comments{min-width:300px}#bootstrap-theme .chr_annual-entitlements__period{width:130px}#bootstrap-theme .chr_annual-entitlements__edit-entitlements{width:150px}#bootstrap-theme .chr_contract-entitlements__position{width:140px}@media (max-width: 992px){#bootstrap-theme .chr_leave-balance-tab .chr_leave-balance-tab__filter:not(:last-child){padding-bottom:15px}}#bootstrap-theme .chr_leave-balance-tab__body{padding:0}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__dates-container .chr_leave-calendar{table-layout:fixed}}#bootstrap-theme .chr_leave-calendar__names-container .chr_leave-calendar{table-layout:fixed}#bootstrap-theme .chr_leave-calendar__day{font-size:10px !important;line-height:1.4em !important;padding:10px !important;text-align:center !important}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__day{padding:10px 0 !important}}#bootstrap-theme .chr_leave-calendar__day--disabled{opacity:0.5}#bootstrap-theme .chr_leave-calendar__day--current{color:#0071bd !important}#bootstrap-theme .chr_leave-calendar__item{color:#FFF;display:block;font-size:10px;height:100%;position:relative;text-align:center;text-transform:uppercase;width:100%}#bootstrap-theme .chr_leave-calendar__item>span{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;height:1.2em}#bootstrap-theme .chr_leave-calendar__item>.chr_leave-calendar__time-unit{font-size:7px;height:1em;margin-left:-1px}#bootstrap-theme .chr_leave-calendar__item>a{cursor:pointer;bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}#bootstrap-theme .chr_leave-calendar__item--disabled{cursor:not-allowed;opacity:0.5}#bootstrap-theme .chr_leave-calendar__item--type--late{background-color:#eca67e;border-color:#eca67e}#bootstrap-theme .chr_leave-calendar__item--type--non-working{background-color:#41afcb !important;border-color:#41afcb}#bootstrap-theme .chr_leave-calendar__item--type--public-holiday{background-color:#8ec68a !important;border-color:#8ec68a}#bootstrap-theme .chr_leave-calendar__item--type--weekend{background-color:#c7cbd0 !important;border-color:#c7cbd0}#bootstrap-theme .chr_leave-calendar__item--alt{background:#FFF !important;border:1px solid transparent;color:#464354}#bootstrap-theme .chr_leave-calendar__item--requested:before{background:#c7cbd0;content:'';display:block;height:.5em;position:absolute;width:100%;top:0}#bootstrap-theme .chr_leave-calendar__item--toil-requested:before{background:red;content:'';display:block;height:.5em;left:-1px;position:absolute;width:calc(100% + 2px);top:-1px}#bootstrap-theme .chr_leave-calendar__items>td{overflow:hidden;height:35px;padding:0 !important}#bootstrap-theme .chr_leave-calendar__items leave-calendar-day{display:block;height:100%}#bootstrap-theme .chr_leave-calendar__legend__title{font-size:12px}#bootstrap-theme .chr_leave-calendar__legend>.row:not(:first-child){margin-top:20px}#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:10px}@media (min-width: 768px){#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:0}}#bootstrap-theme .chr_leave-calendar__legend__entry{overflow:auto}#bootstrap-theme .chr_leave-calendar__legend__entry+#bootstrap-theme .chr_leave-calendar__legend__entry{margin-top:10px}#bootstrap-theme .chr_leave-calendar__legend__entry>.chr_leave-calendar__item{font-size:8px;height:20px;margin-right:10px;position:absolute;width:20px}#bootstrap-theme .chr_leave-calendar__legend__label{display:inline-block;font-size:12px;margin-left:26px}#bootstrap-theme .chr_leave-calendar__month-header{background:#f3f6f7}#bootstrap-theme .chr_leave-calendar__month-header .panel-title{font-size:16px}#bootstrap-theme td.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__name{font-size:12px !important;line-height:100%;padding:0 20px !important;text-align:left;text-overflow:ellipsis;width:100%}#bootstrap-theme th.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__day{height:49px}#bootstrap-theme th.chr_leave-calendar__name{padding-bottom:10px !important}#bootstrap-theme td.chr_leave-calendar__name{vertical-align:middle !important}#bootstrap-theme .chr_leave-calendar__pagination{font-size:10px;text-align:center}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]{outline:none;padding:0;line-height:1em}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"] .fa{color:#555}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"][disabled] .fa{opacity:0.5}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]:hover:not([disabled]) .fa{color:#464354}#bootstrap-theme .chr_leave-calendar__pagination-next{border-top:none}#bootstrap-theme .chr_leave-calendar__pagination-next th{height:24px;padding:4px 0 6px !important}#bootstrap-theme .chr_leave-calendar__pagination-next .chr_leave-calendar__pagination{padding-right:3px !important}#bootstrap-theme .chr_leave-calendar__month-container{margin:0}#bootstrap-theme .chr_leave-calendar__month-container>div{padding:0}#bootstrap-theme .chr_leave-calendar__dates-container{overflow-x:auto}#bootstrap-theme .chr_leave-calendar__admin-filters-hint{display:inline-block;font-size:20px;vertical-align:middle}#bootstrap-theme .chr_leave-calendar__admin-filters-select{width:calc(100% - 50px);display:inline-block;margin-right:20px}#bootstrap-theme .chr_leave-report .dropdown-toggle{color:#464354;padding:0 10px}#bootstrap-theme .chr_leave-report .dropdown-toggle:hover{background:#e6e6e6}#bootstrap-theme .chr_leave-report table{table-layout:fixed}#bootstrap-theme .chr_leave-report table thead th,#bootstrap-theme .chr_leave-report table tbody td{padding:8px 5px}#bootstrap-theme .chr_leave-report__label{color:#464354;font-weight:700}#bootstrap-theme .chr_leave-report__label>.fa{margin-right:5px}#bootstrap-theme .chr_leave-report__label--toggle{cursor:pointer;user-select:none}#bootstrap-theme .chr_leave-report__heading{background-color:#f3f6f7;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_leave-report__heading .chr_leave-report__export-button{line-height:2.4}#bootstrap-theme .chr_leave-report__table table,#bootstrap-theme .chr_leave-report__table .table{border-collapse:separate}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-top-width:0}#bootstrap-theme .chr_leave-report__table table>thead+tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>thead+tbody>tr:first-child>td{border-top-width:1px}#bootstrap-theme .chr_leave-report__table table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td{border-color:#f3f6f7}#bootstrap-theme .chr_leave-report__table table>thead>tr>th,#bootstrap-theme .chr_leave-report__table .table>thead>tr>th{background:#f3f6f7;border-bottom:0;color:#464354;text-transform:capitalize}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-color:#e8eef0 !important}#bootstrap-theme .chr_leave-report__table table>tfoot>tr,#bootstrap-theme .chr_leave-report__table .table>tfoot>tr{background:#f3f6f7}#bootstrap-theme .chr_leave-report__table>table>thead>tr>th,#bootstrap-theme .chr_leave-report__table>.table>thead>tr>th{padding-bottom:13px;padding-top:13px}#bootstrap-theme .chr_leave-report__table-container{overflow:auto}#bootstrap-theme .chr_leave-report__table-container .panel{display:inline-block;min-width:100%}#bootstrap-theme .chr_leave-report__table__heading--action{width:45px}#bootstrap-theme .chr_leave-report__table__heading--label{width:280px}#bootstrap-theme .chr_leave-report__table__heading--dates{width:170px}#bootstrap-theme .chr_leave-report__table__heading--status{width:180px}#bootstrap-theme .chr_leave-report__table__heading--type{width:65px;word-break:break-word}#bootstrap-theme .chr_leave-request-comment{margin-top:10px}#bootstrap-theme .chr_leave-request-comment__text{border-bottom:1px solid #e8eef0;color:#c2cfd8;margin-right:10px;padding-bottom:20px}#bootstrap-theme .chr_leave-request-files_list{height:150px;overflow-y:auto;margin-top:20px;margin-bottom:20px}#bootstrap-theme .chr_leave-request-files_meta{margin-bottom:10px}#bootstrap-theme .chr_leave-request-files_upload{border:dashed 1px #464354;padding:20px}#bootstrap-theme .chr_leave-request-files_upload_action{padding:5px}#bootstrap-theme .chr_leave-request-files_file-name{display:inline-block;max-width:240px;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}#bootstrap-theme .chr_leave-request-files_delete{margin-top:-7px}#bootstrap-theme .chr_leave-request-modal .modal-title{font-size:18px !important}#bootstrap-theme .chr_leave-request-modal .table-responsive{border:0}#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container .input-group{width:100%}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal__chevron{font-size:0.6em;margin-right:5px;vertical-align:middle}#bootstrap-theme .chr_leave-request-modal__comments{height:230px;margin-bottom:20px;overflow:auto}#bootstrap-theme .chr_leave-request-modal__comments_empty{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__footer{margin:0}#bootstrap-theme .chr_leave-request-modal__delete{margin-left:15px;margin-top:8px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container ul{opacity:1 !important}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container:not(.ui-select-multiple) input{width:100% !important}#bootstrap-theme .chr_leave-request-modal__form-group,#bootstrap-theme .chr_leave-request-modal__required-documents>div{margin-bottom:15px}#bootstrap-theme .chr_leave-request-modal__response{padding:20px 20px 0}#bootstrap-theme .chr_leave-request-modal__response label{font-size:17px;margin-top:-3px}#bootstrap-theme .chr_leave-request-modal__response .chr_wysiwyg{margin-top:15px}#bootstrap-theme .chr_leave-request-modal__required-documents input{margin-right:5px}#bootstrap-theme .chr_leave-request-modal__small_spinner>div.chr_spinner{margin-top:18px;min-height:initial}#bootstrap-theme .chr_leave-request-modal__tab input[uib-datepicker-popup]{font-size:13px}#bootstrap-theme .chr_leave-request-modal__table{border:1px solid #f3f6f7;margin-bottom:15px !important}#bootstrap-theme .chr_leave-request-modal__user-info{font-size:17px;padding:20px}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(1){color:#464354}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){color:#555}@media screen and (min-width: 480px){#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){border-left:1px solid #e8eef0}}#bootstrap-theme .chr_leave-request-modal__span-expiry{display:inline-block;margin-top:7px}#bootstrap-theme .chr_leave-request-modal__expiry-clear{position:absolute;right:3.5em;top:0.6em;z-index:2}#bootstrap-theme .chr_leave-request-modal__small-text{font-size:80%}#bootstrap-theme .chr_leave-request-modal__custom-deduction-toggling-row{margin-top:-5px}@media screen and (min-width: 768px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{text-align:right}}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal .form-group{overflow:inherit !important}#bootstrap-theme .chr_leave-request-modal .alert{margin-bottom:0 !important}#bootstrap-theme .chr_leave-request-modal input[uib-datepicker-popup]{box-shadow:none !important;background-color:inherit !important;color:inherit !important;cursor:pointer !important;border-right:none}#bootstrap-theme leave-request-record-actions{display:block;margin-bottom:20px}#bootstrap-theme leave-request-record-actions .fa,#bootstrap-theme leave-request-record-actions .btn-group{margin-right:8px}#bootstrap-theme leave-request-record-actions .btn-toolbar{margin-left:0;overflow:inherit}#bootstrap-theme leave-request-record-actions .btn-toolbar .btn-group,#bootstrap-theme leave-request-record-actions .btn-toolbar .btn{margin-left:0}@media screen and (max-width: 767px){#bootstrap-theme leave-request-record-actions .btn-group,#bootstrap-theme leave-request-record-actions .btn{display:block;width:100%}#bootstrap-theme leave-request-record-actions .btn-group{margin-bottom:8px;margin-right:0}}#bootstrap-theme .leave-widget h4{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071bd;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .chr_leave__page-selector-dropdown{margin-right:5px;position:relative;top:1px;width:100%}#bootstrap-theme .chr_leave__page-selector-dropdown select{height:40px}#bootstrap-theme .chr_leave__page-selector-dropdown .crm_custom-select__arrow{line-height:40px;width:40px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{margin-top:7px;display:inline-block}@media screen and (max-width: 992px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>div:not(:last-child),#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{padding-bottom:20px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{display:inline-block;margin-top:7px;white-space:nowrap}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter .fa{font-size:0.6em;margin-right:5px;margin-top:-2px;vertical-align:middle}@media screen and (max-width: 991px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{margin-top:15px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0;padding-top:15px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>div:not(:last-child){padding-bottom:20px}}@media screen and (min-width: 992px) and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>.no_gutter{padding-bottom:0 !important}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body{margin:0;padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class^="col-"],#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class*=" col-"]{padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body a{cursor:pointer}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container{padding-left:10px;padding-right:10px;background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>div{padding-left:15px;padding-right:15px}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .form-group{overflow:inherit !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel{background-image:none !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel-body,#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .chr_vertical_tabs{background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] input[type="search"]{width:100% !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header .checkbox{margin-top:5px}#bootstrap-theme .page-manager-leave .chr_manage_leave_requests .btn-sm{font-size:100% !important}#bootstrap-theme .chr_manager_calendar__header{padding-left:10px;padding-right:10px;padding-top:15px;margin:0;background-color:#f7f7f9;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_manager_calendar__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manager_calendar__header .checkbox{margin:0}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__header>div:not(:last-child){padding-bottom:20px}}#bootstrap-theme .chr_manager_calendar__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;margin:0}#bootstrap-theme .chr_manager_calendar__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__sub-header>div:not(:last-child){padding-bottom:20px}#bootstrap-theme .chr_manager_calendar__sub-header .ui-select-container{height:auto}}#bootstrap-theme .time-amount-picker .crm_custom-select{display:inline-block;margin-right:2px}#bootstrap-theme .time-amount-picker .crm_custom-select:nth-child(2){margin-left:10px}#bootstrap-theme .absence-tab-page .tab-pane{padding:0 !important}#bootstrap-theme .absence-tab-page .tab-content{background-color:transparent !important}#bootstrap-theme .absence-tab-page leave-request-record-actions{margin-bottom:20px}#bootstrap-theme .crm-absence_type-form-block .crm-section .label{width:35%}#bootstrap-theme .crm-absence_type-form-block .crm-section .content{margin-left:40%}#bootstrap-theme .crm-absence_type-form-block .toil-option,#bootstrap-theme .crm-absence_type-form-block .carry-forward-option,#bootstrap-theme .crm-absence_type-form-block .toil-expiration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-duration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-date{display:none}#bootstrap-theme .crm-absence_type-form-block .sp-replacer{padding:2px}#bootstrap-theme .crm-absence_type-form-block .sp-preview{height:15px;width:15px}#bootstrap-theme .crm-absence_type-form-block .sp-dd{height:0;line-height:15px;font-size:9px}.page-civicrm-leaveandabsences-dashboard .page-title,.page-civicrm-leaveandabsences-dashboard #branding{display:none !important}.page-civicrm-leaveandabsences-dashboard #page{margin:0;padding:0}.admin-dashboard-page{position:relative}.admin-dashboard-page .crm_page__topbar{height:65px}.admin-dashboard-page leave-request-record-actions{margin:12px 30px 0 0}.admin-dashboard-page .chr_admin-dashboard_side-nav{background-color:#fff;height:calc(100% - 12px);overflow:hidden;position:absolute;width:170px}.admin-dashboard-page .chr_admin-dashboard_side-nav .active{background:#e8eef0}.admin-dashboard-page .chr_admin-dashboard_content{float:right;margin:16px;margin-bottom:0;width:calc(100% - 170px - 16px * 2)}#bootstrap-theme #calculation-details{background:#fff}#bootstrap-theme #calculation-details .base-contractual-entitlement{color:#0071bd}#bootstrap-theme #calculation-details .working-days-to-work{color:#44cb7e}#bootstrap-theme #calculation-details .working-days-in-period{color:#e6ab5e}#bootstrap-theme #calculation-details .contract-1-pro-rata{color:#E6807F}#bootstrap-theme #calculation-details .contract-2-pro-rata{color:#797300}#bootstrap-theme #calculation-details .contract-3-pro-rata{color:#904E1E}#bootstrap-theme #calculation-details .contract-4-pro-rata{color:#0511B1}#bootstrap-theme #calculation-details .contract-5-pro-rata{color:#4B9609}#bootstrap-theme #calculation-details .calculation-pro-rata{color:#95c0ff}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body{padding-top:20px;padding-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body .row:first-child h3{margin-top:0}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body h3{margin-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-footer .crm-button:last-child{margin-right:0}#bootstrap-theme.crm-leave-and-balance-import .panel{background-color:#fff}#bootstrap-theme.crm-leave-and-balance-import .panel-header{position:relative}#bootstrap-theme.crm-leave-and-balance-import .panel-header h2{padding:10px 20px}#bootstrap-theme.crm-leave-and-balance-import .panel-body .row:not(:last-child){padding-bottom:2em}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats .label{display:none}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats label{font-weight:normal !important}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats td{border:0;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block{box-shadow:none;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table{margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th{padding:10px 20px;border-right:none}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th,#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table td{padding:5px}#bootstrap-theme.crm-leave-and-balance-import #preview-counts,#bootstrap-theme.crm-leave-and-balance-import #summary-counts{box-shadow:none;margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td{background-color:#f2dede !important;color:#cf3458}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a{color:#bd2d4e;font-weight:bold}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a:hover,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a:hover{color:#0062a4}#bootstrap-theme.manage-entitlements-form .wider-hr{margin-left:-20px;margin-right:-20px;border-width:2px}#bootstrap-theme.manage-entitlements-form .wider-row{margin-left:-20px;margin-right:-20px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters{padding:15px 0;text-align:center}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label{display:inline-block}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label:before{display:none}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .absence-type-filter{margin-right:10px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .col-sm-4:last-child{text-align:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list{margin-bottom:0}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .title{float:left;width:65%}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .actions{float:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list tr.hidden{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .absence-type{color:#fff;display:inline-block;padding:5px}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .overridden-proposed-entitlement,#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .calculation-unit{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .borderless-button{background-color:transparent;border:0;cursor:pointer}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .add-comment{font-size:1.1em}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .comment-text{display:none}#bootstrap-theme.manage-entitlements-form .manage-entitlements-form__filters{padding-bottom:1em}#bootstrap-theme.manage-entitlements-form .table{background:#f9f9f9;border-top:1px solid #e8eef0;border-bottom:1px solid #e8eef0;margin-bottom:2em}#bootstrap-theme.manage-entitlements-form .table th{background:#f3f6f7 !important}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:#e4ebed !important;min-width:200px}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .row>div{display:table-cell;float:none;vertical-align:bottom}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .fa{color:#4d4d69}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .action-button-container{padding:0}#bootstrap-theme.manage-entitlements-form .table td.proposed-entitlement{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:white}#bootstrap-theme.manage-entitlements-form .table span.absence-type{border-radius:3px;padding:0 5px}#bootstrap-theme.manage-entitlements-form .table tbody .fa{color:#0071bd}#bootstrap-theme.manage-entitlements-form .crm-container .CRM_HRLeaveAndAbsences_Form_ManageEntitlements .crm-button-type-next{float:right !important}#bootstrap-theme.manage-entitlements-form .panel-footer{border-top:none}#add-comment-dialog{display:none}#add-comment-dialog .calculation_comment{box-sizing:border-box;padding:10px;width:100%}#bootstrap-theme .crm-work-pattern-form-block .ui-tabs.ui-widget-content{background:none}#bootstrap-theme .work-pattern-calendar .number-of-weeks{padding:15px 0 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week{border-top:1px solid rgba(0,0,0,0.2);padding:15px 0 15px 0;margin-bottom:15px}#bootstrap-theme .work-pattern-calendar .work-pattern-week.hidden-week{display:none}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-number{float:left;font-weight:bold;padding:5px 0 15px 5px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days{table-layout:fixed}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours{float:right;padding:5px 5px 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours .number-of-hours{font-weight:bold}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days td{padding:5px 10px 5px 10px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days input{min-width:0;text-align:center}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days select{min-width:0;width:100% !important}#bootstrap-theme .work-pattern-calendar .work-pattern-week .hours-row td{padding-top:15px;padding-bottom:15px;border-top:1px solid rgba(0,0,0,0.2);border-bottom:1px solid rgba(0,0,0,0.2)}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:13px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.5384615385;color:#4d4d69;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#42425a;background-color:#f3f6f7}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#0071bd}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#e8eef0}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.5384615385;color:#464354;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width: 768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{left:0;right:auto}}.dropdown-header{padding:11px 20px}.dropdown-menu{-webkit-box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);border:0;margin:0;padding:0}.dropdown-menu>li{border:0;margin:0;padding:0}.dropdown-menu>li>a{padding:11px 20px}
+#bootstrap-theme .chr_disabled{opacity:0.5;pointer-events:none}#bootstrap-theme .table-condensed>thead>tr>th{background:#fff !important;padding:8px 5px}#bootstrap-theme .table-condensed-mixed>thead>tr>th,#bootstrap-theme .table-condensed-mixed>thead>tr>td,#bootstrap-theme .table-condensed-mixed>tbody>tr>th,#bootstrap-theme .table-condensed-mixed>tbody>tr>td{padding-left:5px;padding-right:5px}#bootstrap-theme .table-condensed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed>thead>tr>td:first-child,#bootstrap-theme .table-condensed>thead>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:first-child{padding-left:20px}#bootstrap-theme .table-condensed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed>thead>tr>td:last-child,#bootstrap-theme .table-condensed>thead>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:last-child{padding-right:20px}#bootstrap-theme .table-nested{overflow-y:hidden;position:relative}#bootstrap-theme .table-nested:before{box-shadow:inset 0px 6px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;top:0;width:100%;z-index:10}#bootstrap-theme .table-nested:after{box-shadow:inset 0px -4px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;bottom:0;width:100%;z-index:10}#bootstrap-theme .table-nested>table,#bootstrap-theme .table-nested>.table{background-color:#fff}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>table>thead>tr>td:first-child,#bootstrap-theme .table-nested>table>thead>tr>th:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child{padding-left:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child:before{background:#c2cfd8;content:'';display:block;height:110%;left:0;position:absolute;top:0;width:10px;z-index:2}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>table>thead>tr>td:last-child,#bootstrap-theme .table-nested>table>thead>tr>th:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child{padding-right:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child:after{background:#c2cfd8;content:'';display:block;height:110%;right:0;position:absolute;top:0;width:10px;z-index:2}@media screen and (max-width: 767px){#bootstrap-theme .table-nested.table-responsive{border:0;margin-bottom:0}}#bootstrap-theme .table-nested-cell{padding:0 !important}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(1){width:40%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(2){width:15%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(3){width:35%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(4){width:10%}#bootstrap-theme .chr_absence-work-pattern__work-pattern-listing{display:inline-block}#bootstrap-theme .chr_absence-work-pattern__alert{margin-bottom:0 !important}#bootstrap-theme .annual-entitlement-change-log-component thead td{min-width:100px}#bootstrap-theme .annual-entitlement-change-log-component thead .annual-entitlement-change-log-component__comments{min-width:300px}#bootstrap-theme .chr_annual-entitlements__period{width:130px}#bootstrap-theme .chr_annual-entitlements__edit-entitlements{width:150px}#bootstrap-theme .chr_contract-entitlements__position{width:140px}@media (max-width: 992px){#bootstrap-theme .chr_leave-balance-tab .chr_leave-balance-tab__filter:not(:last-child){padding-bottom:15px}}#bootstrap-theme .chr_leave-balance-tab__body{padding:0}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__dates-container .chr_leave-calendar{table-layout:fixed}}#bootstrap-theme .chr_leave-calendar__names-container .chr_leave-calendar{table-layout:fixed}#bootstrap-theme .chr_leave-calendar__day{font-size:10px !important;line-height:1.4em !important;padding:10px !important;text-align:center !important}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__day{padding:10px 0 !important}}#bootstrap-theme .chr_leave-calendar__day--disabled{opacity:0.5}#bootstrap-theme .chr_leave-calendar__day--current{color:#0071bd !important}#bootstrap-theme .chr_leave-calendar__item{color:#FFF;display:block;font-size:10px;height:100%;position:relative;text-align:center;text-transform:uppercase;width:100%}#bootstrap-theme .chr_leave-calendar__item>span{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;height:1.2em}#bootstrap-theme .chr_leave-calendar__item>.chr_leave-calendar__time-unit{font-size:7px;height:1em;margin-left:-1px}#bootstrap-theme .chr_leave-calendar__item>a{cursor:pointer;bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}#bootstrap-theme .chr_leave-calendar__item--disabled{cursor:not-allowed;opacity:0.5}#bootstrap-theme .chr_leave-calendar__item--type--late{background-color:#eca67e;border-color:#eca67e}#bootstrap-theme .chr_leave-calendar__item--type--non-working{background-color:#41afcb !important;border-color:#41afcb}#bootstrap-theme .chr_leave-calendar__item--type--public-holiday{background-color:#8ec68a !important;border-color:#8ec68a}#bootstrap-theme .chr_leave-calendar__item--type--weekend{background-color:#c7cbd0 !important;border-color:#c7cbd0}#bootstrap-theme .chr_leave-calendar__item--alt{background:#FFF !important;border:1px solid transparent;color:#464354}#bootstrap-theme .chr_leave-calendar__item--requested:before{background:#c7cbd0;content:'';display:block;height:.5em;position:absolute;width:100%;top:0}#bootstrap-theme .chr_leave-calendar__item--toil-requested:before{background:red;content:'';display:block;height:.5em;left:-1px;position:absolute;width:calc(100% + 2px);top:-1px}#bootstrap-theme .chr_leave-calendar__items>td{overflow:hidden;height:35px;padding:0 !important}#bootstrap-theme .chr_leave-calendar__items leave-calendar-day{display:block;height:100%}#bootstrap-theme .chr_leave-calendar__legend__title{font-size:12px}#bootstrap-theme .chr_leave-calendar__legend>.row:not(:first-child){margin-top:20px}#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:10px}@media (min-width: 768px){#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:0}}#bootstrap-theme .chr_leave-calendar__legend__entry{overflow:auto}#bootstrap-theme .chr_leave-calendar__legend__entry+#bootstrap-theme .chr_leave-calendar__legend__entry{margin-top:10px}#bootstrap-theme .chr_leave-calendar__legend__entry>.chr_leave-calendar__item{font-size:8px;height:20px;margin-right:10px;position:absolute;width:20px}#bootstrap-theme .chr_leave-calendar__legend__label{display:inline-block;font-size:12px;margin-left:26px}#bootstrap-theme .chr_leave-calendar__month-header{background:#f3f6f7}#bootstrap-theme .chr_leave-calendar__month-header .panel-title{font-size:16px}#bootstrap-theme td.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__name{font-size:12px !important;line-height:100%;padding:0 20px !important;text-align:left;text-overflow:ellipsis;width:100%}#bootstrap-theme th.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__day{height:49px}#bootstrap-theme th.chr_leave-calendar__name{padding-bottom:10px !important}#bootstrap-theme td.chr_leave-calendar__name{vertical-align:middle !important}#bootstrap-theme .chr_leave-calendar__pagination{font-size:10px;text-align:center}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]{outline:none;padding:0;line-height:1em}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"] .fa{color:#555}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"][disabled] .fa{opacity:0.5}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]:hover:not([disabled]) .fa{color:#464354}#bootstrap-theme .chr_leave-calendar__pagination-next{border-top:none}#bootstrap-theme .chr_leave-calendar__pagination-next th{height:24px;padding:4px 0 6px !important}#bootstrap-theme .chr_leave-calendar__pagination-next .chr_leave-calendar__pagination{padding-right:3px !important}#bootstrap-theme .chr_leave-calendar__month-container{margin:0}#bootstrap-theme .chr_leave-calendar__month-container>div{padding:0}#bootstrap-theme .chr_leave-calendar__dates-container{overflow-x:auto}#bootstrap-theme .chr_leave-calendar__admin-filters-hint{display:inline-block;font-size:20px;vertical-align:middle}#bootstrap-theme .chr_leave-calendar__admin-filters-select{width:calc(100% - 50px);display:inline-block;margin-right:20px}#bootstrap-theme .chr_leave-report .dropdown-toggle{color:#464354;padding:0 10px}#bootstrap-theme .chr_leave-report .dropdown-toggle:hover{background:#e6e6e6}#bootstrap-theme .chr_leave-report table{table-layout:fixed}#bootstrap-theme .chr_leave-report table thead th,#bootstrap-theme .chr_leave-report table tbody td{padding:8px 5px}#bootstrap-theme .chr_leave-report__label{color:#464354;font-weight:700}#bootstrap-theme .chr_leave-report__label>.fa{margin-right:5px}#bootstrap-theme .chr_leave-report__label--toggle{cursor:pointer;user-select:none}#bootstrap-theme .chr_leave-report__heading{background-color:#f3f6f7;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_leave-report__heading .chr_leave-report__export-button{line-height:2.4}#bootstrap-theme .chr_leave-report__table table,#bootstrap-theme .chr_leave-report__table .table{border-collapse:separate}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-top-width:0}#bootstrap-theme .chr_leave-report__table table>thead+tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>thead+tbody>tr:first-child>td{border-top-width:1px}#bootstrap-theme .chr_leave-report__table table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td{border-color:#f3f6f7}#bootstrap-theme .chr_leave-report__table table>thead>tr>th,#bootstrap-theme .chr_leave-report__table .table>thead>tr>th{background:#f3f6f7;border-bottom:0;color:#464354;text-transform:capitalize}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-color:#e8eef0 !important}#bootstrap-theme .chr_leave-report__table table>tfoot>tr,#bootstrap-theme .chr_leave-report__table .table>tfoot>tr{background:#f3f6f7}#bootstrap-theme .chr_leave-report__table>table>thead>tr>th,#bootstrap-theme .chr_leave-report__table>.table>thead>tr>th{padding-bottom:13px;padding-top:13px}#bootstrap-theme .chr_leave-report__table-container{overflow:auto}#bootstrap-theme .chr_leave-report__table-container .panel{display:inline-block;min-width:100%}#bootstrap-theme .chr_leave-report__table__heading--action{width:45px}#bootstrap-theme .chr_leave-report__table__heading--label{width:280px}#bootstrap-theme .chr_leave-report__table__heading--dates{width:170px}#bootstrap-theme .chr_leave-report__table__heading--status{width:180px}#bootstrap-theme .chr_leave-report__table__heading--type{width:65px;word-break:break-word}#bootstrap-theme .chr_leave-request-comment{margin-top:10px}#bootstrap-theme .chr_leave-request-comment__text{border-bottom:1px solid #e8eef0;color:#c2cfd8;margin-right:10px;padding-bottom:20px}#bootstrap-theme .chr_leave-request-files_list{height:150px;overflow-y:auto;margin-top:20px;margin-bottom:20px}#bootstrap-theme .chr_leave-request-files_meta{margin-bottom:10px}#bootstrap-theme .chr_leave-request-files_upload{border:dashed 1px #464354;padding:20px}#bootstrap-theme .chr_leave-request-files_upload_action{padding:5px}#bootstrap-theme .chr_leave-request-files_file-name{display:inline-block;max-width:240px;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}#bootstrap-theme .chr_leave-request-files_delete{margin-top:-7px}#bootstrap-theme .chr_leave-request-modal .modal-title{font-size:18px !important}#bootstrap-theme .chr_leave-request-modal .table-responsive{border:0}#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container .input-group{width:100%}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal__chevron{font-size:0.6em;margin-right:5px;vertical-align:middle}#bootstrap-theme .chr_leave-request-modal__comments{height:230px;margin-bottom:20px;overflow:auto}#bootstrap-theme .chr_leave-request-modal__comments_empty{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__footer{margin:0}#bootstrap-theme .chr_leave-request-modal__delete{margin-left:15px;margin-top:8px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container ul{opacity:1 !important}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container:not(.ui-select-multiple) input{width:100% !important}#bootstrap-theme .chr_leave-request-modal__form-group,#bootstrap-theme .chr_leave-request-modal__required-documents>div{margin-bottom:15px}#bootstrap-theme .chr_leave-request-modal__response{padding:20px 20px 0}#bootstrap-theme .chr_leave-request-modal__response label{font-size:17px;margin-top:-3px}#bootstrap-theme .chr_leave-request-modal__response .chr_wysiwyg{margin-top:15px}#bootstrap-theme .chr_leave-request-modal__required-documents input{margin-right:5px}#bootstrap-theme .chr_leave-request-modal__small_spinner>div.chr_spinner{margin-top:18px;min-height:initial}#bootstrap-theme .chr_leave-request-modal__tab input[uib-datepicker-popup]{font-size:13px}#bootstrap-theme .chr_leave-request-modal__table{border:1px solid #f3f6f7;margin-bottom:15px !important}#bootstrap-theme .chr_leave-request-modal__user-info{font-size:17px;padding:20px}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(1){color:#464354}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){color:#555}@media screen and (min-width: 480px){#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){border-left:1px solid #e8eef0}}#bootstrap-theme .chr_leave-request-modal__span-expiry{display:inline-block;margin-top:7px}#bootstrap-theme .chr_leave-request-modal__expiry-clear{position:absolute;right:3.5em;top:0.6em;z-index:2}#bootstrap-theme .chr_leave-request-modal__small-text{font-size:80%}#bootstrap-theme .chr_leave-request-modal__custom-deduction-toggling-row{margin-top:-5px}@media screen and (min-width: 768px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{text-align:right}}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal .form-group{overflow:inherit !important}#bootstrap-theme .chr_leave-request-modal .alert{margin-bottom:0 !important}#bootstrap-theme .chr_leave-request-modal input[uib-datepicker-popup]{box-shadow:none !important;background-color:inherit !important;color:inherit !important;cursor:pointer !important;border-right:none}#bootstrap-theme leave-request-record-actions{display:block}#bootstrap-theme leave-request-record-actions .fa,#bootstrap-theme leave-request-record-actions .btn-group{margin-right:8px}#bootstrap-theme leave-request-record-actions .btn-toolbar{margin-left:0;overflow:inherit}#bootstrap-theme leave-request-record-actions .btn-toolbar .btn-group,#bootstrap-theme leave-request-record-actions .btn-toolbar .btn{margin-left:0}@media screen and (max-width: 767px){#bootstrap-theme leave-request-record-actions .btn-group,#bootstrap-theme leave-request-record-actions .btn{display:block;width:100%}#bootstrap-theme leave-request-record-actions .btn-group{margin-bottom:8px;margin-right:0}}#bootstrap-theme .leave-widget h4{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071bd;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .chr_leave__page-selector-dropdown{margin-right:5px;position:relative;top:1px;width:100%}#bootstrap-theme .chr_leave__page-selector-dropdown select{height:40px}#bootstrap-theme .chr_leave__page-selector-dropdown .crm_custom-select__arrow{line-height:40px;width:40px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{margin-top:7px;display:inline-block}@media screen and (max-width: 992px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>div:not(:last-child),#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{padding-bottom:20px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{display:inline-block;margin-top:7px;white-space:nowrap}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter .fa{font-size:0.6em;margin-right:5px;margin-top:-2px;vertical-align:middle}@media screen and (max-width: 991px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{margin-top:15px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0;padding-top:15px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>div:not(:last-child){padding-bottom:20px}}@media screen and (min-width: 992px) and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>.no_gutter{padding-bottom:0 !important}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body{margin:0;padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class^="col-"],#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class*=" col-"]{padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body a{cursor:pointer}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container{padding-left:10px;padding-right:10px;background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>div{padding-left:15px;padding-right:15px}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .form-group{overflow:inherit !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel{background-image:none !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel-body,#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .chr_vertical_tabs{background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] input[type="search"]{width:100% !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header .checkbox{margin-top:5px}#bootstrap-theme .page-manager-leave .chr_manage_leave_requests .btn-sm{font-size:100% !important}#bootstrap-theme .chr_manager_calendar__header{padding-left:10px;padding-right:10px;padding-top:15px;margin:0;background-color:#f7f7f9;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_manager_calendar__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manager_calendar__header .checkbox{margin:0}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__header>div:not(:last-child){padding-bottom:20px}}#bootstrap-theme .chr_manager_calendar__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;margin:0}#bootstrap-theme .chr_manager_calendar__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__sub-header>div:not(:last-child){padding-bottom:20px}#bootstrap-theme .chr_manager_calendar__sub-header .ui-select-container{height:auto}}#bootstrap-theme .time-amount-picker .crm_custom-select{display:inline-block;margin-right:2px}#bootstrap-theme .time-amount-picker .crm_custom-select:nth-child(2){margin-left:10px}#bootstrap-theme .absence-tab-page .tab-pane{padding:0 !important}#bootstrap-theme .absence-tab-page .tab-content{background-color:transparent !important}#bootstrap-theme .absence-tab-page leave-request-record-actions{margin-bottom:20px}#bootstrap-theme .crm-absence_type-form-block .crm-section .label{width:35%}#bootstrap-theme .crm-absence_type-form-block .crm-section .content{margin-left:40%}#bootstrap-theme .crm-absence_type-form-block .toil-option,#bootstrap-theme .crm-absence_type-form-block .carry-forward-option,#bootstrap-theme .crm-absence_type-form-block .toil-expiration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-duration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-date{display:none}#bootstrap-theme .crm-absence_type-form-block .sp-replacer{padding:2px}#bootstrap-theme .crm-absence_type-form-block .sp-preview{height:15px;width:15px}#bootstrap-theme .crm-absence_type-form-block .sp-dd{height:0;line-height:15px;font-size:9px}.page-civicrm-leaveandabsences-dashboard .page-title,.page-civicrm-leaveandabsences-dashboard #branding{display:none !important}.page-civicrm-leaveandabsences-dashboard #page{margin:0;padding:0}.admin-dashboard-page{position:relative}.admin-dashboard-page .crm_page__topbar{height:65px}.admin-dashboard-page leave-request-record-actions{margin:12px 16px 0 0}.admin-dashboard-page .chr_admin-dashboard_side-nav{background-color:#fff;height:calc(100% - 12px);overflow:hidden;position:absolute;width:170px}.admin-dashboard-page .chr_admin-dashboard_side-nav .active{background:#e8eef0}.admin-dashboard-page .chr_admin-dashboard_content{float:right;margin:16px;margin-bottom:0;width:calc(100% - 170px - 16px * 2)}#bootstrap-theme #calculation-details{background:#fff}#bootstrap-theme #calculation-details .base-contractual-entitlement{color:#0071bd}#bootstrap-theme #calculation-details .working-days-to-work{color:#44cb7e}#bootstrap-theme #calculation-details .working-days-in-period{color:#e6ab5e}#bootstrap-theme #calculation-details .contract-1-pro-rata{color:#E6807F}#bootstrap-theme #calculation-details .contract-2-pro-rata{color:#797300}#bootstrap-theme #calculation-details .contract-3-pro-rata{color:#904E1E}#bootstrap-theme #calculation-details .contract-4-pro-rata{color:#0511B1}#bootstrap-theme #calculation-details .contract-5-pro-rata{color:#4B9609}#bootstrap-theme #calculation-details .calculation-pro-rata{color:#95c0ff}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body{padding-top:20px;padding-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body .row:first-child h3{margin-top:0}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body h3{margin-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-footer .crm-button:last-child{margin-right:0}#bootstrap-theme.crm-leave-and-balance-import .panel{background-color:#fff}#bootstrap-theme.crm-leave-and-balance-import .panel-header{position:relative}#bootstrap-theme.crm-leave-and-balance-import .panel-header h2{padding:10px 20px}#bootstrap-theme.crm-leave-and-balance-import .panel-body .row:not(:last-child){padding-bottom:2em}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats .label{display:none}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats label{font-weight:normal !important}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats td{border:0;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block{box-shadow:none;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table{margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th{padding:10px 20px;border-right:none}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th,#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table td{padding:5px}#bootstrap-theme.crm-leave-and-balance-import #preview-counts,#bootstrap-theme.crm-leave-and-balance-import #summary-counts{box-shadow:none;margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td{background-color:#f2dede !important;color:#cf3458}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a{color:#bd2d4e;font-weight:bold}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a:hover,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a:hover{color:#0062a4}#bootstrap-theme.manage-entitlements-form .wider-hr{margin-left:-20px;margin-right:-20px;border-width:2px}#bootstrap-theme.manage-entitlements-form .wider-row{margin-left:-20px;margin-right:-20px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters{padding:15px 0;text-align:center}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label{display:inline-block}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label:before{display:none}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .absence-type-filter{margin-right:10px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .col-sm-4:last-child{text-align:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list{margin-bottom:0}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .title{float:left;width:65%}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .actions{float:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list tr.hidden{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .absence-type{color:#fff;display:inline-block;padding:5px}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .overridden-proposed-entitlement,#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .calculation-unit{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .borderless-button{background-color:transparent;border:0;cursor:pointer}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .add-comment{font-size:1.1em}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .comment-text{display:none}#bootstrap-theme.manage-entitlements-form .manage-entitlements-form__filters{padding-bottom:1em}#bootstrap-theme.manage-entitlements-form .table{background:#f9f9f9;border-top:1px solid #e8eef0;border-bottom:1px solid #e8eef0;margin-bottom:2em}#bootstrap-theme.manage-entitlements-form .table th{background:#f3f6f7 !important}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:#e4ebed !important;min-width:200px}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .row>div{display:table-cell;float:none;vertical-align:bottom}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .fa{color:#4d4d69}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .action-button-container{padding:0}#bootstrap-theme.manage-entitlements-form .table td.proposed-entitlement{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:white}#bootstrap-theme.manage-entitlements-form .table span.absence-type{border-radius:3px;padding:0 5px}#bootstrap-theme.manage-entitlements-form .table tbody .fa{color:#0071bd}#bootstrap-theme.manage-entitlements-form .crm-container .CRM_HRLeaveAndAbsences_Form_ManageEntitlements .crm-button-type-next{float:right !important}#bootstrap-theme.manage-entitlements-form .panel-footer{border-top:none}#add-comment-dialog{display:none}#add-comment-dialog .calculation_comment{box-sizing:border-box;padding:10px;width:100%}#bootstrap-theme .crm-work-pattern-form-block .ui-tabs.ui-widget-content{background:none}#bootstrap-theme .work-pattern-calendar .number-of-weeks{padding:15px 0 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week{border-top:1px solid rgba(0,0,0,0.2);padding:15px 0 15px 0;margin-bottom:15px}#bootstrap-theme .work-pattern-calendar .work-pattern-week.hidden-week{display:none}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-number{float:left;font-weight:bold;padding:5px 0 15px 5px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days{table-layout:fixed}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours{float:right;padding:5px 5px 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours .number-of-hours{font-weight:bold}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days td{padding:5px 10px 5px 10px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days input{min-width:0;text-align:center}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days select{min-width:0;width:100% !important}#bootstrap-theme .work-pattern-calendar .work-pattern-week .hours-row td{padding-top:15px;padding-bottom:15px;border-top:1px solid rgba(0,0,0,0.2);border-bottom:1px solid rgba(0,0,0,0.2)}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:13px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.5384615385;color:#4d4d69;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#42425a;background-color:#f3f6f7}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#0071bd}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#e8eef0}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.5384615385;color:#464354;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width: 768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{left:0;right:auto}}.dropdown-header{padding:11px 20px}.dropdown-menu{-webkit-box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);border:0;margin:0;padding:0}.dropdown-menu>li{border:0;margin:0;padding:0}.dropdown-menu>li>a{padding:11px 20px}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
index 3004229de9e..2690e40bddf 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
@@ -1,6 +1,5 @@
leave-request-record-actions {
display: block;
- margin-bottom: $crm-panel-nested-indent;
.fa,
.btn-group {
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
index 656300104a6..3c9e65ae305 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
@@ -8,6 +8,6 @@
}
leave-request-record-actions {
- margin-bottom: 20px;
+ margin-bottom: $crm-panel-nested-indent;
}
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss
index 310180921de..53017223e46 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_admin-dashboard-page.scss
@@ -25,7 +25,7 @@ $content-container-margin: 16px;
}
leave-request-record-actions {
- margin: 12px 30px 0 0;
+ margin: 12px #{$content-container-margin} 0 0;
}
.chr_admin-dashboard_side-nav {
From f001d3e4282e41a75f0827e567b28a359eca0bb5 Mon Sep 17 00:00:00 2001
From: Igor Pavlov
Date: Wed, 21 Mar 2018 13:47:59 +0000
Subject: [PATCH 062/203] PCHR-3426: PR Feedback
---
.../css/leaveandabsence.css | 2 +-
.../js/angular/dist/absence-tab.min.js | 2 +-
.../js/angular/dist/admin-dashboard.min.js | 2 +-
.../js/angular/dist/manager-leave.min.js | 2 +-
.../js/angular/dist/my-leave.min.js | 2 +-
.../leave-request-record-actions.component.js | 4 +--
.../components/_absence-work-patterns.scss | 4 +++
.../_leave-request-record-actions.scss | 35 +++++++++----------
.../scss/pages/_absence-tab-page.scss | 2 +-
.../components/absence-tab-container.html | 1 -
.../components/absence-tab-work-patterns.html | 8 ++---
.../components/admin-dashboard-container.html | 1 -
.../components/manager-leave-container.html | 1 -
.../leave-request-record-actions.html | 16 +++++----
14 files changed, 40 insertions(+), 42 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css b/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
index e7827dc794f..c9cee528612 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/css/leaveandabsence.css
@@ -1 +1 @@
-#bootstrap-theme .chr_disabled{opacity:0.5;pointer-events:none}#bootstrap-theme .table-condensed>thead>tr>th{background:#fff !important;padding:8px 5px}#bootstrap-theme .table-condensed-mixed>thead>tr>th,#bootstrap-theme .table-condensed-mixed>thead>tr>td,#bootstrap-theme .table-condensed-mixed>tbody>tr>th,#bootstrap-theme .table-condensed-mixed>tbody>tr>td{padding-left:5px;padding-right:5px}#bootstrap-theme .table-condensed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed>thead>tr>td:first-child,#bootstrap-theme .table-condensed>thead>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:first-child{padding-left:20px}#bootstrap-theme .table-condensed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed>thead>tr>td:last-child,#bootstrap-theme .table-condensed>thead>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:last-child{padding-right:20px}#bootstrap-theme .table-nested{overflow-y:hidden;position:relative}#bootstrap-theme .table-nested:before{box-shadow:inset 0px 6px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;top:0;width:100%;z-index:10}#bootstrap-theme .table-nested:after{box-shadow:inset 0px -4px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;bottom:0;width:100%;z-index:10}#bootstrap-theme .table-nested>table,#bootstrap-theme .table-nested>.table{background-color:#fff}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>table>thead>tr>td:first-child,#bootstrap-theme .table-nested>table>thead>tr>th:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child{padding-left:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child:before{background:#c2cfd8;content:'';display:block;height:110%;left:0;position:absolute;top:0;width:10px;z-index:2}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>table>thead>tr>td:last-child,#bootstrap-theme .table-nested>table>thead>tr>th:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child{padding-right:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child:after{background:#c2cfd8;content:'';display:block;height:110%;right:0;position:absolute;top:0;width:10px;z-index:2}@media screen and (max-width: 767px){#bootstrap-theme .table-nested.table-responsive{border:0;margin-bottom:0}}#bootstrap-theme .table-nested-cell{padding:0 !important}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(1){width:40%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(2){width:15%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(3){width:35%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(4){width:10%}#bootstrap-theme .chr_absence-work-pattern__work-pattern-listing{display:inline-block}#bootstrap-theme .chr_absence-work-pattern__alert{margin-bottom:0 !important}#bootstrap-theme .annual-entitlement-change-log-component thead td{min-width:100px}#bootstrap-theme .annual-entitlement-change-log-component thead .annual-entitlement-change-log-component__comments{min-width:300px}#bootstrap-theme .chr_annual-entitlements__period{width:130px}#bootstrap-theme .chr_annual-entitlements__edit-entitlements{width:150px}#bootstrap-theme .chr_contract-entitlements__position{width:140px}@media (max-width: 992px){#bootstrap-theme .chr_leave-balance-tab .chr_leave-balance-tab__filter:not(:last-child){padding-bottom:15px}}#bootstrap-theme .chr_leave-balance-tab__body{padding:0}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__dates-container .chr_leave-calendar{table-layout:fixed}}#bootstrap-theme .chr_leave-calendar__names-container .chr_leave-calendar{table-layout:fixed}#bootstrap-theme .chr_leave-calendar__day{font-size:10px !important;line-height:1.4em !important;padding:10px !important;text-align:center !important}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__day{padding:10px 0 !important}}#bootstrap-theme .chr_leave-calendar__day--disabled{opacity:0.5}#bootstrap-theme .chr_leave-calendar__day--current{color:#0071bd !important}#bootstrap-theme .chr_leave-calendar__item{color:#FFF;display:block;font-size:10px;height:100%;position:relative;text-align:center;text-transform:uppercase;width:100%}#bootstrap-theme .chr_leave-calendar__item>span{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;height:1.2em}#bootstrap-theme .chr_leave-calendar__item>.chr_leave-calendar__time-unit{font-size:7px;height:1em;margin-left:-1px}#bootstrap-theme .chr_leave-calendar__item>a{cursor:pointer;bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}#bootstrap-theme .chr_leave-calendar__item--disabled{cursor:not-allowed;opacity:0.5}#bootstrap-theme .chr_leave-calendar__item--type--late{background-color:#eca67e;border-color:#eca67e}#bootstrap-theme .chr_leave-calendar__item--type--non-working{background-color:#41afcb !important;border-color:#41afcb}#bootstrap-theme .chr_leave-calendar__item--type--public-holiday{background-color:#8ec68a !important;border-color:#8ec68a}#bootstrap-theme .chr_leave-calendar__item--type--weekend{background-color:#c7cbd0 !important;border-color:#c7cbd0}#bootstrap-theme .chr_leave-calendar__item--alt{background:#FFF !important;border:1px solid transparent;color:#464354}#bootstrap-theme .chr_leave-calendar__item--requested:before{background:#c7cbd0;content:'';display:block;height:.5em;position:absolute;width:100%;top:0}#bootstrap-theme .chr_leave-calendar__item--toil-requested:before{background:red;content:'';display:block;height:.5em;left:-1px;position:absolute;width:calc(100% + 2px);top:-1px}#bootstrap-theme .chr_leave-calendar__items>td{overflow:hidden;height:35px;padding:0 !important}#bootstrap-theme .chr_leave-calendar__items leave-calendar-day{display:block;height:100%}#bootstrap-theme .chr_leave-calendar__legend__title{font-size:12px}#bootstrap-theme .chr_leave-calendar__legend>.row:not(:first-child){margin-top:20px}#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:10px}@media (min-width: 768px){#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:0}}#bootstrap-theme .chr_leave-calendar__legend__entry{overflow:auto}#bootstrap-theme .chr_leave-calendar__legend__entry+#bootstrap-theme .chr_leave-calendar__legend__entry{margin-top:10px}#bootstrap-theme .chr_leave-calendar__legend__entry>.chr_leave-calendar__item{font-size:8px;height:20px;margin-right:10px;position:absolute;width:20px}#bootstrap-theme .chr_leave-calendar__legend__label{display:inline-block;font-size:12px;margin-left:26px}#bootstrap-theme .chr_leave-calendar__month-header{background:#f3f6f7}#bootstrap-theme .chr_leave-calendar__month-header .panel-title{font-size:16px}#bootstrap-theme td.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__name{font-size:12px !important;line-height:100%;padding:0 20px !important;text-align:left;text-overflow:ellipsis;width:100%}#bootstrap-theme th.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__day{height:49px}#bootstrap-theme th.chr_leave-calendar__name{padding-bottom:10px !important}#bootstrap-theme td.chr_leave-calendar__name{vertical-align:middle !important}#bootstrap-theme .chr_leave-calendar__pagination{font-size:10px;text-align:center}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]{outline:none;padding:0;line-height:1em}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"] .fa{color:#555}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"][disabled] .fa{opacity:0.5}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]:hover:not([disabled]) .fa{color:#464354}#bootstrap-theme .chr_leave-calendar__pagination-next{border-top:none}#bootstrap-theme .chr_leave-calendar__pagination-next th{height:24px;padding:4px 0 6px !important}#bootstrap-theme .chr_leave-calendar__pagination-next .chr_leave-calendar__pagination{padding-right:3px !important}#bootstrap-theme .chr_leave-calendar__month-container{margin:0}#bootstrap-theme .chr_leave-calendar__month-container>div{padding:0}#bootstrap-theme .chr_leave-calendar__dates-container{overflow-x:auto}#bootstrap-theme .chr_leave-calendar__admin-filters-hint{display:inline-block;font-size:20px;vertical-align:middle}#bootstrap-theme .chr_leave-calendar__admin-filters-select{width:calc(100% - 50px);display:inline-block;margin-right:20px}#bootstrap-theme .chr_leave-report .dropdown-toggle{color:#464354;padding:0 10px}#bootstrap-theme .chr_leave-report .dropdown-toggle:hover{background:#e6e6e6}#bootstrap-theme .chr_leave-report table{table-layout:fixed}#bootstrap-theme .chr_leave-report table thead th,#bootstrap-theme .chr_leave-report table tbody td{padding:8px 5px}#bootstrap-theme .chr_leave-report__label{color:#464354;font-weight:700}#bootstrap-theme .chr_leave-report__label>.fa{margin-right:5px}#bootstrap-theme .chr_leave-report__label--toggle{cursor:pointer;user-select:none}#bootstrap-theme .chr_leave-report__heading{background-color:#f3f6f7;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_leave-report__heading .chr_leave-report__export-button{line-height:2.4}#bootstrap-theme .chr_leave-report__table table,#bootstrap-theme .chr_leave-report__table .table{border-collapse:separate}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-top-width:0}#bootstrap-theme .chr_leave-report__table table>thead+tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>thead+tbody>tr:first-child>td{border-top-width:1px}#bootstrap-theme .chr_leave-report__table table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td{border-color:#f3f6f7}#bootstrap-theme .chr_leave-report__table table>thead>tr>th,#bootstrap-theme .chr_leave-report__table .table>thead>tr>th{background:#f3f6f7;border-bottom:0;color:#464354;text-transform:capitalize}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-color:#e8eef0 !important}#bootstrap-theme .chr_leave-report__table table>tfoot>tr,#bootstrap-theme .chr_leave-report__table .table>tfoot>tr{background:#f3f6f7}#bootstrap-theme .chr_leave-report__table>table>thead>tr>th,#bootstrap-theme .chr_leave-report__table>.table>thead>tr>th{padding-bottom:13px;padding-top:13px}#bootstrap-theme .chr_leave-report__table-container{overflow:auto}#bootstrap-theme .chr_leave-report__table-container .panel{display:inline-block;min-width:100%}#bootstrap-theme .chr_leave-report__table__heading--action{width:45px}#bootstrap-theme .chr_leave-report__table__heading--label{width:280px}#bootstrap-theme .chr_leave-report__table__heading--dates{width:170px}#bootstrap-theme .chr_leave-report__table__heading--status{width:180px}#bootstrap-theme .chr_leave-report__table__heading--type{width:65px;word-break:break-word}#bootstrap-theme .chr_leave-request-comment{margin-top:10px}#bootstrap-theme .chr_leave-request-comment__text{border-bottom:1px solid #e8eef0;color:#c2cfd8;margin-right:10px;padding-bottom:20px}#bootstrap-theme .chr_leave-request-files_list{height:150px;overflow-y:auto;margin-top:20px;margin-bottom:20px}#bootstrap-theme .chr_leave-request-files_meta{margin-bottom:10px}#bootstrap-theme .chr_leave-request-files_upload{border:dashed 1px #464354;padding:20px}#bootstrap-theme .chr_leave-request-files_upload_action{padding:5px}#bootstrap-theme .chr_leave-request-files_file-name{display:inline-block;max-width:240px;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}#bootstrap-theme .chr_leave-request-files_delete{margin-top:-7px}#bootstrap-theme .chr_leave-request-modal .modal-title{font-size:18px !important}#bootstrap-theme .chr_leave-request-modal .table-responsive{border:0}#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container .input-group{width:100%}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal__chevron{font-size:0.6em;margin-right:5px;vertical-align:middle}#bootstrap-theme .chr_leave-request-modal__comments{height:230px;margin-bottom:20px;overflow:auto}#bootstrap-theme .chr_leave-request-modal__comments_empty{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__footer{margin:0}#bootstrap-theme .chr_leave-request-modal__delete{margin-left:15px;margin-top:8px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container ul{opacity:1 !important}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container:not(.ui-select-multiple) input{width:100% !important}#bootstrap-theme .chr_leave-request-modal__form-group,#bootstrap-theme .chr_leave-request-modal__required-documents>div{margin-bottom:15px}#bootstrap-theme .chr_leave-request-modal__response{padding:20px 20px 0}#bootstrap-theme .chr_leave-request-modal__response label{font-size:17px;margin-top:-3px}#bootstrap-theme .chr_leave-request-modal__response .chr_wysiwyg{margin-top:15px}#bootstrap-theme .chr_leave-request-modal__required-documents input{margin-right:5px}#bootstrap-theme .chr_leave-request-modal__small_spinner>div.chr_spinner{margin-top:18px;min-height:initial}#bootstrap-theme .chr_leave-request-modal__tab input[uib-datepicker-popup]{font-size:13px}#bootstrap-theme .chr_leave-request-modal__table{border:1px solid #f3f6f7;margin-bottom:15px !important}#bootstrap-theme .chr_leave-request-modal__user-info{font-size:17px;padding:20px}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(1){color:#464354}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){color:#555}@media screen and (min-width: 480px){#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){border-left:1px solid #e8eef0}}#bootstrap-theme .chr_leave-request-modal__span-expiry{display:inline-block;margin-top:7px}#bootstrap-theme .chr_leave-request-modal__expiry-clear{position:absolute;right:3.5em;top:0.6em;z-index:2}#bootstrap-theme .chr_leave-request-modal__small-text{font-size:80%}#bootstrap-theme .chr_leave-request-modal__custom-deduction-toggling-row{margin-top:-5px}@media screen and (min-width: 768px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{text-align:right}}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal .form-group{overflow:inherit !important}#bootstrap-theme .chr_leave-request-modal .alert{margin-bottom:0 !important}#bootstrap-theme .chr_leave-request-modal input[uib-datepicker-popup]{box-shadow:none !important;background-color:inherit !important;color:inherit !important;cursor:pointer !important;border-right:none}#bootstrap-theme leave-request-record-actions{display:block}#bootstrap-theme leave-request-record-actions .fa,#bootstrap-theme leave-request-record-actions .btn-group{margin-right:8px}#bootstrap-theme leave-request-record-actions .btn-toolbar{margin-left:0;overflow:inherit}#bootstrap-theme leave-request-record-actions .btn-toolbar .btn-group,#bootstrap-theme leave-request-record-actions .btn-toolbar .btn{margin-left:0}@media screen and (max-width: 767px){#bootstrap-theme leave-request-record-actions .btn-group,#bootstrap-theme leave-request-record-actions .btn{display:block;width:100%}#bootstrap-theme leave-request-record-actions .btn-group{margin-bottom:8px;margin-right:0}}#bootstrap-theme .leave-widget h4{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071bd;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .chr_leave__page-selector-dropdown{margin-right:5px;position:relative;top:1px;width:100%}#bootstrap-theme .chr_leave__page-selector-dropdown select{height:40px}#bootstrap-theme .chr_leave__page-selector-dropdown .crm_custom-select__arrow{line-height:40px;width:40px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{margin-top:7px;display:inline-block}@media screen and (max-width: 992px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>div:not(:last-child),#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{padding-bottom:20px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{display:inline-block;margin-top:7px;white-space:nowrap}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter .fa{font-size:0.6em;margin-right:5px;margin-top:-2px;vertical-align:middle}@media screen and (max-width: 991px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{margin-top:15px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0;padding-top:15px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>div:not(:last-child){padding-bottom:20px}}@media screen and (min-width: 992px) and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>.no_gutter{padding-bottom:0 !important}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body{margin:0;padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class^="col-"],#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class*=" col-"]{padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body a{cursor:pointer}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container{padding-left:10px;padding-right:10px;background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>div{padding-left:15px;padding-right:15px}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .form-group{overflow:inherit !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel{background-image:none !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel-body,#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .chr_vertical_tabs{background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] input[type="search"]{width:100% !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header .checkbox{margin-top:5px}#bootstrap-theme .page-manager-leave .chr_manage_leave_requests .btn-sm{font-size:100% !important}#bootstrap-theme .chr_manager_calendar__header{padding-left:10px;padding-right:10px;padding-top:15px;margin:0;background-color:#f7f7f9;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_manager_calendar__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manager_calendar__header .checkbox{margin:0}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__header>div:not(:last-child){padding-bottom:20px}}#bootstrap-theme .chr_manager_calendar__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;margin:0}#bootstrap-theme .chr_manager_calendar__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__sub-header>div:not(:last-child){padding-bottom:20px}#bootstrap-theme .chr_manager_calendar__sub-header .ui-select-container{height:auto}}#bootstrap-theme .time-amount-picker .crm_custom-select{display:inline-block;margin-right:2px}#bootstrap-theme .time-amount-picker .crm_custom-select:nth-child(2){margin-left:10px}#bootstrap-theme .absence-tab-page .tab-pane{padding:0 !important}#bootstrap-theme .absence-tab-page .tab-content{background-color:transparent !important}#bootstrap-theme .absence-tab-page leave-request-record-actions{margin-bottom:20px}#bootstrap-theme .crm-absence_type-form-block .crm-section .label{width:35%}#bootstrap-theme .crm-absence_type-form-block .crm-section .content{margin-left:40%}#bootstrap-theme .crm-absence_type-form-block .toil-option,#bootstrap-theme .crm-absence_type-form-block .carry-forward-option,#bootstrap-theme .crm-absence_type-form-block .toil-expiration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-duration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-date{display:none}#bootstrap-theme .crm-absence_type-form-block .sp-replacer{padding:2px}#bootstrap-theme .crm-absence_type-form-block .sp-preview{height:15px;width:15px}#bootstrap-theme .crm-absence_type-form-block .sp-dd{height:0;line-height:15px;font-size:9px}.page-civicrm-leaveandabsences-dashboard .page-title,.page-civicrm-leaveandabsences-dashboard #branding{display:none !important}.page-civicrm-leaveandabsences-dashboard #page{margin:0;padding:0}.admin-dashboard-page{position:relative}.admin-dashboard-page .crm_page__topbar{height:65px}.admin-dashboard-page leave-request-record-actions{margin:12px 16px 0 0}.admin-dashboard-page .chr_admin-dashboard_side-nav{background-color:#fff;height:calc(100% - 12px);overflow:hidden;position:absolute;width:170px}.admin-dashboard-page .chr_admin-dashboard_side-nav .active{background:#e8eef0}.admin-dashboard-page .chr_admin-dashboard_content{float:right;margin:16px;margin-bottom:0;width:calc(100% - 170px - 16px * 2)}#bootstrap-theme #calculation-details{background:#fff}#bootstrap-theme #calculation-details .base-contractual-entitlement{color:#0071bd}#bootstrap-theme #calculation-details .working-days-to-work{color:#44cb7e}#bootstrap-theme #calculation-details .working-days-in-period{color:#e6ab5e}#bootstrap-theme #calculation-details .contract-1-pro-rata{color:#E6807F}#bootstrap-theme #calculation-details .contract-2-pro-rata{color:#797300}#bootstrap-theme #calculation-details .contract-3-pro-rata{color:#904E1E}#bootstrap-theme #calculation-details .contract-4-pro-rata{color:#0511B1}#bootstrap-theme #calculation-details .contract-5-pro-rata{color:#4B9609}#bootstrap-theme #calculation-details .calculation-pro-rata{color:#95c0ff}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body{padding-top:20px;padding-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body .row:first-child h3{margin-top:0}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body h3{margin-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-footer .crm-button:last-child{margin-right:0}#bootstrap-theme.crm-leave-and-balance-import .panel{background-color:#fff}#bootstrap-theme.crm-leave-and-balance-import .panel-header{position:relative}#bootstrap-theme.crm-leave-and-balance-import .panel-header h2{padding:10px 20px}#bootstrap-theme.crm-leave-and-balance-import .panel-body .row:not(:last-child){padding-bottom:2em}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats .label{display:none}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats label{font-weight:normal !important}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats td{border:0;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block{box-shadow:none;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table{margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th{padding:10px 20px;border-right:none}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th,#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table td{padding:5px}#bootstrap-theme.crm-leave-and-balance-import #preview-counts,#bootstrap-theme.crm-leave-and-balance-import #summary-counts{box-shadow:none;margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td{background-color:#f2dede !important;color:#cf3458}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a{color:#bd2d4e;font-weight:bold}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a:hover,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a:hover{color:#0062a4}#bootstrap-theme.manage-entitlements-form .wider-hr{margin-left:-20px;margin-right:-20px;border-width:2px}#bootstrap-theme.manage-entitlements-form .wider-row{margin-left:-20px;margin-right:-20px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters{padding:15px 0;text-align:center}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label{display:inline-block}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label:before{display:none}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .absence-type-filter{margin-right:10px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .col-sm-4:last-child{text-align:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list{margin-bottom:0}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .title{float:left;width:65%}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .actions{float:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list tr.hidden{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .absence-type{color:#fff;display:inline-block;padding:5px}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .overridden-proposed-entitlement,#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .calculation-unit{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .borderless-button{background-color:transparent;border:0;cursor:pointer}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .add-comment{font-size:1.1em}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .comment-text{display:none}#bootstrap-theme.manage-entitlements-form .manage-entitlements-form__filters{padding-bottom:1em}#bootstrap-theme.manage-entitlements-form .table{background:#f9f9f9;border-top:1px solid #e8eef0;border-bottom:1px solid #e8eef0;margin-bottom:2em}#bootstrap-theme.manage-entitlements-form .table th{background:#f3f6f7 !important}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:#e4ebed !important;min-width:200px}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .row>div{display:table-cell;float:none;vertical-align:bottom}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .fa{color:#4d4d69}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .action-button-container{padding:0}#bootstrap-theme.manage-entitlements-form .table td.proposed-entitlement{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:white}#bootstrap-theme.manage-entitlements-form .table span.absence-type{border-radius:3px;padding:0 5px}#bootstrap-theme.manage-entitlements-form .table tbody .fa{color:#0071bd}#bootstrap-theme.manage-entitlements-form .crm-container .CRM_HRLeaveAndAbsences_Form_ManageEntitlements .crm-button-type-next{float:right !important}#bootstrap-theme.manage-entitlements-form .panel-footer{border-top:none}#add-comment-dialog{display:none}#add-comment-dialog .calculation_comment{box-sizing:border-box;padding:10px;width:100%}#bootstrap-theme .crm-work-pattern-form-block .ui-tabs.ui-widget-content{background:none}#bootstrap-theme .work-pattern-calendar .number-of-weeks{padding:15px 0 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week{border-top:1px solid rgba(0,0,0,0.2);padding:15px 0 15px 0;margin-bottom:15px}#bootstrap-theme .work-pattern-calendar .work-pattern-week.hidden-week{display:none}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-number{float:left;font-weight:bold;padding:5px 0 15px 5px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days{table-layout:fixed}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours{float:right;padding:5px 5px 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours .number-of-hours{font-weight:bold}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days td{padding:5px 10px 5px 10px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days input{min-width:0;text-align:center}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days select{min-width:0;width:100% !important}#bootstrap-theme .work-pattern-calendar .work-pattern-week .hours-row td{padding-top:15px;padding-bottom:15px;border-top:1px solid rgba(0,0,0,0.2);border-bottom:1px solid rgba(0,0,0,0.2)}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:13px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.5384615385;color:#4d4d69;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#42425a;background-color:#f3f6f7}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#0071bd}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#e8eef0}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.5384615385;color:#464354;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width: 768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{left:0;right:auto}}.dropdown-header{padding:11px 20px}.dropdown-menu{-webkit-box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);border:0;margin:0;padding:0}.dropdown-menu>li{border:0;margin:0;padding:0}.dropdown-menu>li>a{padding:11px 20px}
+#bootstrap-theme .chr_disabled{opacity:0.5;pointer-events:none}#bootstrap-theme .table-condensed>thead>tr>th{background:#fff !important;padding:8px 5px}#bootstrap-theme .table-condensed-mixed>thead>tr>th,#bootstrap-theme .table-condensed-mixed>thead>tr>td,#bootstrap-theme .table-condensed-mixed>tbody>tr>th,#bootstrap-theme .table-condensed-mixed>tbody>tr>td{padding-left:5px;padding-right:5px}#bootstrap-theme .table-condensed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed>thead>tr>td:first-child,#bootstrap-theme .table-condensed>thead>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:first-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:first-child{padding-left:20px}#bootstrap-theme .table-condensed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed>thead>tr>td:last-child,#bootstrap-theme .table-condensed>thead>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>tbody>tr>th:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>td:last-child,#bootstrap-theme .table-condensed-mixed>thead>tr>th:last-child{padding-right:20px}#bootstrap-theme .table-nested{overflow-y:hidden;position:relative}#bootstrap-theme .table-nested:before{box-shadow:inset 0px 6px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;top:0;width:100%;z-index:10}#bootstrap-theme .table-nested:after{box-shadow:inset 0px -4px 9px -6px rgba(0,0,0,0.2);content:'';display:block;height:10px;left:0;position:absolute;bottom:0;width:100%;z-index:10}#bootstrap-theme .table-nested>table,#bootstrap-theme .table-nested>.table{background-color:#fff}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>table>thead>tr>td:first-child,#bootstrap-theme .table-nested>table>thead>tr>th:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child{padding-left:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>table>thead>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>tbody>tr>th:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>td:first-child:before,#bootstrap-theme .table-nested>.table>thead>tr>th:first-child:before{background:#c2cfd8;content:'';display:block;height:110%;left:0;position:absolute;top:0;width:10px;z-index:2}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>table>thead>tr>td:last-child,#bootstrap-theme .table-nested>table>thead>tr>th:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child{padding-right:30px;position:relative}#bootstrap-theme .table-nested>table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>table>thead>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>tbody>tr>th:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>td:last-child:after,#bootstrap-theme .table-nested>.table>thead>tr>th:last-child:after{background:#c2cfd8;content:'';display:block;height:110%;right:0;position:absolute;top:0;width:10px;z-index:2}@media screen and (max-width: 767px){#bootstrap-theme .table-nested.table-responsive{border:0;margin-bottom:0}}#bootstrap-theme .table-nested-cell{padding:0 !important}#bootstrap-theme .chr_absence-work-pattern__add-custom{margin-bottom:20px}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(1){width:40%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(2){width:15%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(3){width:35%}#bootstrap-theme .chr_absence-work-pattern__custom-work-pattern td:nth-child(4){width:10%}#bootstrap-theme .chr_absence-work-pattern__work-pattern-listing{display:inline-block}#bootstrap-theme .chr_absence-work-pattern__alert{margin-bottom:0 !important}#bootstrap-theme .annual-entitlement-change-log-component thead td{min-width:100px}#bootstrap-theme .annual-entitlement-change-log-component thead .annual-entitlement-change-log-component__comments{min-width:300px}#bootstrap-theme .chr_annual-entitlements__period{width:130px}#bootstrap-theme .chr_annual-entitlements__edit-entitlements{width:150px}#bootstrap-theme .chr_contract-entitlements__position{width:140px}@media (max-width: 992px){#bootstrap-theme .chr_leave-balance-tab .chr_leave-balance-tab__filter:not(:last-child){padding-bottom:15px}}#bootstrap-theme .chr_leave-balance-tab__body{padding:0}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__dates-container .chr_leave-calendar{table-layout:fixed}}#bootstrap-theme .chr_leave-calendar__names-container .chr_leave-calendar{table-layout:fixed}#bootstrap-theme .chr_leave-calendar__day{font-size:10px !important;line-height:1.4em !important;padding:10px !important;text-align:center !important}@media (min-width: 1200px){#bootstrap-theme .chr_leave-calendar__day{padding:10px 0 !important}}#bootstrap-theme .chr_leave-calendar__day--disabled{opacity:0.5}#bootstrap-theme .chr_leave-calendar__day--current{color:#0071bd !important}#bootstrap-theme .chr_leave-calendar__item{color:#FFF;display:block;font-size:10px;height:100%;position:relative;text-align:center;text-transform:uppercase;width:100%}#bootstrap-theme .chr_leave-calendar__item>span{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;height:1.2em}#bootstrap-theme .chr_leave-calendar__item>.chr_leave-calendar__time-unit{font-size:7px;height:1em;margin-left:-1px}#bootstrap-theme .chr_leave-calendar__item>a{cursor:pointer;bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}#bootstrap-theme .chr_leave-calendar__item--disabled{cursor:not-allowed;opacity:0.5}#bootstrap-theme .chr_leave-calendar__item--type--late{background-color:#eca67e;border-color:#eca67e}#bootstrap-theme .chr_leave-calendar__item--type--non-working{background-color:#41afcb !important;border-color:#41afcb}#bootstrap-theme .chr_leave-calendar__item--type--public-holiday{background-color:#8ec68a !important;border-color:#8ec68a}#bootstrap-theme .chr_leave-calendar__item--type--weekend{background-color:#c7cbd0 !important;border-color:#c7cbd0}#bootstrap-theme .chr_leave-calendar__item--alt{background:#FFF !important;border:1px solid transparent;color:#464354}#bootstrap-theme .chr_leave-calendar__item--requested:before{background:#c7cbd0;content:'';display:block;height:.5em;position:absolute;width:100%;top:0}#bootstrap-theme .chr_leave-calendar__item--toil-requested:before{background:red;content:'';display:block;height:.5em;left:-1px;position:absolute;width:calc(100% + 2px);top:-1px}#bootstrap-theme .chr_leave-calendar__items>td{overflow:hidden;height:35px;padding:0 !important}#bootstrap-theme .chr_leave-calendar__items leave-calendar-day{display:block;height:100%}#bootstrap-theme .chr_leave-calendar__legend__title{font-size:12px}#bootstrap-theme .chr_leave-calendar__legend>.row:not(:first-child){margin-top:20px}#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:10px}@media (min-width: 768px){#bootstrap-theme .chr_leave-calendar__legend .chr_leave-calendar__legend__entry{margin-top:0}}#bootstrap-theme .chr_leave-calendar__legend__entry{overflow:auto}#bootstrap-theme .chr_leave-calendar__legend__entry+#bootstrap-theme .chr_leave-calendar__legend__entry{margin-top:10px}#bootstrap-theme .chr_leave-calendar__legend__entry>.chr_leave-calendar__item{font-size:8px;height:20px;margin-right:10px;position:absolute;width:20px}#bootstrap-theme .chr_leave-calendar__legend__label{display:inline-block;font-size:12px;margin-left:26px}#bootstrap-theme .chr_leave-calendar__month-header{background:#f3f6f7}#bootstrap-theme .chr_leave-calendar__month-header .panel-title{font-size:16px}#bootstrap-theme td.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__name{font-size:12px !important;line-height:100%;padding:0 20px !important;text-align:left;text-overflow:ellipsis;width:100%}#bootstrap-theme th.chr_leave-calendar__name,#bootstrap-theme th.chr_leave-calendar__day{height:49px}#bootstrap-theme th.chr_leave-calendar__name{padding-bottom:10px !important}#bootstrap-theme td.chr_leave-calendar__name{vertical-align:middle !important}#bootstrap-theme .chr_leave-calendar__pagination{font-size:10px;text-align:center}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]{outline:none;padding:0;line-height:1em}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"] .fa{color:#555}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"][disabled] .fa{opacity:0.5}#bootstrap-theme .chr_leave-calendar__pagination [class*="btn"]:hover:not([disabled]) .fa{color:#464354}#bootstrap-theme .chr_leave-calendar__pagination-next{border-top:none}#bootstrap-theme .chr_leave-calendar__pagination-next th{height:24px;padding:4px 0 6px !important}#bootstrap-theme .chr_leave-calendar__pagination-next .chr_leave-calendar__pagination{padding-right:3px !important}#bootstrap-theme .chr_leave-calendar__month-container{margin:0}#bootstrap-theme .chr_leave-calendar__month-container>div{padding:0}#bootstrap-theme .chr_leave-calendar__dates-container{overflow-x:auto}#bootstrap-theme .chr_leave-calendar__admin-filters-hint{display:inline-block;font-size:20px;vertical-align:middle}#bootstrap-theme .chr_leave-calendar__admin-filters-select{width:calc(100% - 50px);display:inline-block;margin-right:20px}#bootstrap-theme .chr_leave-report .dropdown-toggle{color:#464354;padding:0 10px}#bootstrap-theme .chr_leave-report .dropdown-toggle:hover{background:#e6e6e6}#bootstrap-theme .chr_leave-report table{table-layout:fixed}#bootstrap-theme .chr_leave-report table thead th,#bootstrap-theme .chr_leave-report table tbody td{padding:8px 5px}#bootstrap-theme .chr_leave-report__label{color:#464354;font-weight:700}#bootstrap-theme .chr_leave-report__label>.fa{margin-right:5px}#bootstrap-theme .chr_leave-report__label--toggle{cursor:pointer;user-select:none}#bootstrap-theme .chr_leave-report__heading{background-color:#f3f6f7;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_leave-report__heading .chr_leave-report__export-button{line-height:2.4}#bootstrap-theme .chr_leave-report__table table,#bootstrap-theme .chr_leave-report__table .table{border-collapse:separate}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-top-width:0}#bootstrap-theme .chr_leave-report__table table>thead+tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>thead+tbody>tr:first-child>td{border-top-width:1px}#bootstrap-theme .chr_leave-report__table table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table:not(.table-bordered):not(.table-condensed)>tbody>tr:first-child>td{border-color:#f3f6f7}#bootstrap-theme .chr_leave-report__table table>thead>tr>th,#bootstrap-theme .chr_leave-report__table .table>thead>tr>th{background:#f3f6f7;border-bottom:0;color:#464354;text-transform:capitalize}#bootstrap-theme .chr_leave-report__table table>tbody>tr:first-child>td,#bootstrap-theme .chr_leave-report__table .table>tbody>tr:first-child>td{border-color:#e8eef0 !important}#bootstrap-theme .chr_leave-report__table table>tfoot>tr,#bootstrap-theme .chr_leave-report__table .table>tfoot>tr{background:#f3f6f7}#bootstrap-theme .chr_leave-report__table>table>thead>tr>th,#bootstrap-theme .chr_leave-report__table>.table>thead>tr>th{padding-bottom:13px;padding-top:13px}#bootstrap-theme .chr_leave-report__table-container{overflow:auto}#bootstrap-theme .chr_leave-report__table-container .panel{display:inline-block;min-width:100%}#bootstrap-theme .chr_leave-report__table__heading--action{width:45px}#bootstrap-theme .chr_leave-report__table__heading--label{width:280px}#bootstrap-theme .chr_leave-report__table__heading--dates{width:170px}#bootstrap-theme .chr_leave-report__table__heading--status{width:180px}#bootstrap-theme .chr_leave-report__table__heading--type{width:65px;word-break:break-word}#bootstrap-theme .chr_leave-request-comment{margin-top:10px}#bootstrap-theme .chr_leave-request-comment__text{border-bottom:1px solid #e8eef0;color:#c2cfd8;margin-right:10px;padding-bottom:20px}#bootstrap-theme .chr_leave-request-files_list{height:150px;overflow-y:auto;margin-top:20px;margin-bottom:20px}#bootstrap-theme .chr_leave-request-files_meta{margin-bottom:10px}#bootstrap-theme .chr_leave-request-files_upload{border:dashed 1px #464354;padding:20px}#bootstrap-theme .chr_leave-request-files_upload_action{padding:5px}#bootstrap-theme .chr_leave-request-files_file-name{display:inline-block;max-width:240px;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}#bootstrap-theme .chr_leave-request-files_delete{margin-top:-7px}#bootstrap-theme .chr_leave-request-modal .modal-title{font-size:18px !important}#bootstrap-theme .chr_leave-request-modal .table-responsive{border:0}#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container .input-group{width:100%}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal .chr_leave-request-date-picker-container{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal__chevron{font-size:0.6em;margin-right:5px;vertical-align:middle}#bootstrap-theme .chr_leave-request-modal__comments{height:230px;margin-bottom:20px;overflow:auto}#bootstrap-theme .chr_leave-request-modal__comments_empty{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__footer{margin:0}#bootstrap-theme .chr_leave-request-modal__delete{margin-left:15px;margin-top:8px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container{margin-bottom:20px}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container ul{opacity:1 !important}#bootstrap-theme .chr_leave-request-modal__form .ui-select-container:not(.ui-select-multiple) input{width:100% !important}#bootstrap-theme .chr_leave-request-modal__form-group,#bootstrap-theme .chr_leave-request-modal__required-documents>div{margin-bottom:15px}#bootstrap-theme .chr_leave-request-modal__response{padding:20px 20px 0}#bootstrap-theme .chr_leave-request-modal__response label{font-size:17px;margin-top:-3px}#bootstrap-theme .chr_leave-request-modal__response .chr_wysiwyg{margin-top:15px}#bootstrap-theme .chr_leave-request-modal__required-documents input{margin-right:5px}#bootstrap-theme .chr_leave-request-modal__small_spinner>div.chr_spinner{margin-top:18px;min-height:initial}#bootstrap-theme .chr_leave-request-modal__tab input[uib-datepicker-popup]{font-size:13px}#bootstrap-theme .chr_leave-request-modal__table{border:1px solid #f3f6f7;margin-bottom:15px !important}#bootstrap-theme .chr_leave-request-modal__user-info{font-size:17px;padding:20px}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(1){color:#464354}#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){color:#555}@media screen and (min-width: 480px){#bootstrap-theme .chr_leave-request-modal__user-info>span:nth-child(2){border-left:1px solid #e8eef0}}#bootstrap-theme .chr_leave-request-modal__span-expiry{display:inline-block;margin-top:7px}#bootstrap-theme .chr_leave-request-modal__expiry-clear{position:absolute;right:3.5em;top:0.6em;z-index:2}#bootstrap-theme .chr_leave-request-modal__small-text{font-size:80%}#bootstrap-theme .chr_leave-request-modal__custom-deduction-toggling-row{margin-top:-5px}@media screen and (min-width: 768px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{text-align:right}}@media screen and (max-width: 767px){#bootstrap-theme .chr_leave-request-modal__custom-deduction-label{margin-bottom:10px}}#bootstrap-theme .chr_leave-request-modal .form-group{overflow:inherit !important}#bootstrap-theme .chr_leave-request-modal .alert{margin-bottom:0 !important}#bootstrap-theme .chr_leave-request-modal input[uib-datepicker-popup]{box-shadow:none !important;background-color:inherit !important;color:inherit !important;cursor:pointer !important;border-right:none}#bootstrap-theme leave-request-record-actions{display:block}#bootstrap-theme leave-request-record-actions .leave-request-record-actions__button{display:block;float:left;margin-left:0}#bootstrap-theme leave-request-record-actions .leave-request-record-actions__button:first-child{margin-right:8px}@media screen and (max-width: 767px){#bootstrap-theme leave-request-record-actions .leave-request-record-actions__button{width:100%}#bootstrap-theme leave-request-record-actions .leave-request-record-actions__button>.btn{width:100%}#bootstrap-theme leave-request-record-actions .leave-request-record-actions__button:first-child{margin-bottom:8px;margin-right:0}}#bootstrap-theme .leave-widget h4{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4d4d69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071bd;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .chr_leave__page-selector-dropdown{margin-right:5px;position:relative;top:1px;width:100%}#bootstrap-theme .chr_leave__page-selector-dropdown select{height:40px}#bootstrap-theme .chr_leave__page-selector-dropdown .crm_custom-select__arrow{line-height:40px;width:40px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{margin-top:7px;display:inline-block}@media screen and (max-width: 992px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header>div:not(:last-child),#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__header .panel-title{padding-bottom:20px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{display:inline-block;margin-top:7px;white-space:nowrap}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter .fa{font-size:0.6em;margin-right:5px;margin-top:-2px;vertical-align:middle}@media screen and (max-width: 991px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__filter{margin-top:15px}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;border-bottom:1px solid #dadcde;margin:0;padding-top:15px}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>div:not(:last-child){padding-bottom:20px}}@media screen and (min-width: 992px) and (max-width: 1199px){#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header>.no_gutter{padding-bottom:0 !important}}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body{margin:0;padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class^="col-"],#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body [class*=" col-"]{padding:0}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__panel_body a{cursor:pointer}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container{padding-left:10px;padding-right:10px;background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__status_container>div{padding-left:15px;padding-right:15px}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .form-group{overflow:inherit !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel{background-image:none !important}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .panel-body,#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] .chr_vertical_tabs{background-color:#f7f7f9}#bootstrap-theme .chr_manage_leave_requests[data-role="admin"] input[type="search"]{width:100% !important}#bootstrap-theme .chr_manage_leave_requests .chr_manage_leave_requests__sub-header .checkbox{margin-top:5px}#bootstrap-theme .page-manager-leave .chr_manage_leave_requests .btn-sm{font-size:100% !important}#bootstrap-theme .chr_manager_calendar__header{padding-left:10px;padding-right:10px;padding-top:15px;margin:0;background-color:#f7f7f9;border-bottom:1px solid #dadcde}#bootstrap-theme .chr_manager_calendar__header>*{padding-left:10px !important;padding-right:10px !important}#bootstrap-theme .chr_manager_calendar__header .checkbox{margin:0}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__header>div:not(:last-child){padding-bottom:20px}}#bootstrap-theme .chr_manager_calendar__sub-header{padding-left:10px;padding-right:10px;background-color:#f7f7f9;margin:0}#bootstrap-theme .chr_manager_calendar__sub-header>*{padding-left:10px !important;padding-right:10px !important}@media screen and (max-width: 1199px){#bootstrap-theme .chr_manager_calendar__sub-header>div:not(:last-child){padding-bottom:20px}#bootstrap-theme .chr_manager_calendar__sub-header .ui-select-container{height:auto}}#bootstrap-theme .time-amount-picker .crm_custom-select{display:inline-block;margin-right:2px}#bootstrap-theme .time-amount-picker .crm_custom-select:nth-child(2){margin-left:10px}#bootstrap-theme .absence-tab-page .tab-pane{padding:0 !important}#bootstrap-theme .absence-tab-page .tab-content{background-color:transparent !important}#bootstrap-theme .absence-tab-page leave-request-record-actions{margin-bottom:20px}#bootstrap-theme .crm-absence_type-form-block .crm-section .label{width:35%}#bootstrap-theme .crm-absence_type-form-block .crm-section .content{margin-left:40%}#bootstrap-theme .crm-absence_type-form-block .toil-option,#bootstrap-theme .crm-absence_type-form-block .carry-forward-option,#bootstrap-theme .crm-absence_type-form-block .toil-expiration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-duration,#bootstrap-theme .crm-absence_type-form-block .carry-forward-expiration-date{display:none}#bootstrap-theme .crm-absence_type-form-block .sp-replacer{padding:2px}#bootstrap-theme .crm-absence_type-form-block .sp-preview{height:15px;width:15px}#bootstrap-theme .crm-absence_type-form-block .sp-dd{height:0;line-height:15px;font-size:9px}.page-civicrm-leaveandabsences-dashboard .page-title,.page-civicrm-leaveandabsences-dashboard #branding{display:none !important}.page-civicrm-leaveandabsences-dashboard #page{margin:0;padding:0}.admin-dashboard-page{position:relative}.admin-dashboard-page .crm_page__topbar{height:65px}.admin-dashboard-page leave-request-record-actions{margin:12px 16px 0 0}.admin-dashboard-page .chr_admin-dashboard_side-nav{background-color:#fff;height:calc(100% - 12px);overflow:hidden;position:absolute;width:170px}.admin-dashboard-page .chr_admin-dashboard_side-nav .active{background:#e8eef0}.admin-dashboard-page .chr_admin-dashboard_content{float:right;margin:16px;margin-bottom:0;width:calc(100% - 170px - 16px * 2)}#bootstrap-theme #calculation-details{background:#fff}#bootstrap-theme #calculation-details .base-contractual-entitlement{color:#0071bd}#bootstrap-theme #calculation-details .working-days-to-work{color:#44cb7e}#bootstrap-theme #calculation-details .working-days-in-period{color:#e6ab5e}#bootstrap-theme #calculation-details .contract-1-pro-rata{color:#E6807F}#bootstrap-theme #calculation-details .contract-2-pro-rata{color:#797300}#bootstrap-theme #calculation-details .contract-3-pro-rata{color:#904E1E}#bootstrap-theme #calculation-details .contract-4-pro-rata{color:#0511B1}#bootstrap-theme #calculation-details .contract-5-pro-rata{color:#4B9609}#bootstrap-theme #calculation-details .calculation-pro-rata{color:#95c0ff}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body{padding-top:20px;padding-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body .row:first-child h3{margin-top:0}#bootstrap-theme .crm-leave-and-absences-form-block .panel-body h3{margin-bottom:20px}#bootstrap-theme .crm-leave-and-absences-form-block .panel-footer .crm-button:last-child{margin-right:0}#bootstrap-theme.crm-leave-and-balance-import .panel{background-color:#fff}#bootstrap-theme.crm-leave-and-balance-import .panel-header{position:relative}#bootstrap-theme.crm-leave-and-balance-import .panel-header h2{padding:10px 20px}#bootstrap-theme.crm-leave-and-balance-import .panel-body .row:not(:last-child){padding-bottom:2em}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats .label{display:none}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats label{font-weight:normal !important}#bootstrap-theme.crm-leave-and-balance-import .table.date-formats td{border:0;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block{box-shadow:none;padding:0}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table{margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th{padding:10px 20px;border-right:none}#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table th,#bootstrap-theme.crm-leave-and-balance-import .crm-activity_map_table-form-block #map-field table td{padding:5px}#bootstrap-theme.crm-leave-and-balance-import #preview-counts,#bootstrap-theme.crm-leave-and-balance-import #summary-counts{box-shadow:none;margin-bottom:2em;width:100%}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td{background-color:#f2dede !important;color:#cf3458}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a{color:#bd2d4e;font-weight:bold}#bootstrap-theme.crm-leave-and-balance-import #preview-counts tr.danger td a:hover,#bootstrap-theme.crm-leave-and-balance-import #summary-counts tr.danger td a:hover{color:#0062a4}#bootstrap-theme.manage-entitlements-form .wider-hr{margin-left:-20px;margin-right:-20px;border-width:2px}#bootstrap-theme.manage-entitlements-form .wider-row{margin-left:-20px;margin-right:-20px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters{padding:15px 0;text-align:center}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label{display:inline-block}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .override-filters label:before{display:none}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .absence-type-filter{margin-right:10px}#bootstrap-theme.manage-entitlements-form .entitlement-calculation-filters .col-sm-4:last-child{text-align:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list{margin-bottom:0}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .title{float:left;width:65%}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement-header .actions{float:right}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list tr.hidden{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .absence-type{color:#fff;display:inline-block;padding:5px}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .overridden-proposed-entitlement,#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .proposed-entitlement .calculation-unit{display:none}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .borderless-button{background-color:transparent;border:0;cursor:pointer}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .add-comment{font-size:1.1em}#bootstrap-theme.manage-entitlements-form .table.entitlement-calculation-list .comment-text{display:none}#bootstrap-theme.manage-entitlements-form .manage-entitlements-form__filters{padding-bottom:1em}#bootstrap-theme.manage-entitlements-form .table{background:#f9f9f9;border-top:1px solid #e8eef0;border-bottom:1px solid #e8eef0;margin-bottom:2em}#bootstrap-theme.manage-entitlements-form .table th{background:#f3f6f7 !important}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:#e4ebed !important;min-width:200px}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .row>div{display:table-cell;float:none;vertical-align:bottom}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .fa{color:#4d4d69}#bootstrap-theme.manage-entitlements-form .table th.proposed-entitlement-header .action-button-container{padding:0}#bootstrap-theme.manage-entitlements-form .table td.proposed-entitlement{border-left:1px solid #e8eef0;border-right:1px solid #e8eef0;background:white}#bootstrap-theme.manage-entitlements-form .table span.absence-type{border-radius:3px;padding:0 5px}#bootstrap-theme.manage-entitlements-form .table tbody .fa{color:#0071bd}#bootstrap-theme.manage-entitlements-form .crm-container .CRM_HRLeaveAndAbsences_Form_ManageEntitlements .crm-button-type-next{float:right !important}#bootstrap-theme.manage-entitlements-form .panel-footer{border-top:none}#add-comment-dialog{display:none}#add-comment-dialog .calculation_comment{box-sizing:border-box;padding:10px;width:100%}#bootstrap-theme .crm-work-pattern-form-block .ui-tabs.ui-widget-content{background:none}#bootstrap-theme .work-pattern-calendar .number-of-weeks{padding:15px 0 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week{border-top:1px solid rgba(0,0,0,0.2);padding:15px 0 15px 0;margin-bottom:15px}#bootstrap-theme .work-pattern-calendar .work-pattern-week.hidden-week{display:none}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-number{float:left;font-weight:bold;padding:5px 0 15px 5px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days{table-layout:fixed}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours{float:right;padding:5px 5px 15px 0}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-hours .number-of-hours{font-weight:bold}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days td{padding:5px 10px 5px 10px}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days input{min-width:0;text-align:center}#bootstrap-theme .work-pattern-calendar .work-pattern-week .week-days select{min-width:0;width:100% !important}#bootstrap-theme .work-pattern-calendar .work-pattern-week .hours-row td{padding-top:15px;padding-bottom:15px;border-top:1px solid rgba(0,0,0,0.2);border-bottom:1px solid rgba(0,0,0,0.2)}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-top:4px solid \9;border-right:4px solid transparent;border-left:4px solid transparent}.dropup,.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;font-size:13px;text-align:left;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:2px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.5384615385;color:#4d4d69;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#42425a;background-color:#f3f6f7}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#0071bd}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#e8eef0}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);cursor:not-allowed}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:auto;right:0}.dropdown-menu-left{left:0;right:auto}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.5384615385;color:#464354;white-space:nowrap}.dropdown-backdrop{position:fixed;left:0;right:0;bottom:0;top:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px dashed;border-bottom:4px solid \9;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width: 768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{left:0;right:auto}}.dropdown-header{padding:11px 20px}.dropdown-menu{-webkit-box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);box-shadow:0 3px 18px 0 rgba(48,40,40,0.25);border:0;margin:0;padding:0}.dropdown-menu>li{border:0;margin:0;padding:0}.dropdown-menu>li>a{padding:11px 20px}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
index d8af6d230a1..d718ba04f66 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.min.js
@@ -1,5 +1,5 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/modules/shared-settings",["common/angular"],function(t){return t.module("leave-absences.settings",[]).constant("shared-settings",{attachmentToken:e.vars.leaveAndAbsences.attachmentToken,debug:e.debug,managerPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/",sharedPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/shared/",serverDateFormat:"YYYY-MM-DD",serverDateTimeFormat:"YYYY-MM-DD HH:mm:ss",permissions:{admin:{access:"access leave and absences",administer:"administer leave and absences"},ssp:{access:"access leave and absences in ssp",manage:"manage leave and absences in ssp"}},fileUploader:{queueLimit:10},statusNames:{approved:"approved",adminApproved:"admin_approved",awaitingApproval:"awaiting_approval",moreInformationRequired:"more_information_required",rejected:"rejected",cancelled:"cancelled"}})})}(CRM),define("leave-absences/shared/modules/apis",["common/angular","common/modules/apis","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.apis",["common.apis","leave-absences.settings"])}),define("leave-absences/shared/modules/models-instances",["common/angular","common/models/instances/instance","common/modules/services","common/modules/models","common/services/check-permissions","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models.instances",["common.models","common.models.instances","common.services","leave-absences.settings"])}),define("leave-absences/shared/modules/models",["common/angular","common/modules/models","common/modules/services","leave-absences/shared/modules/apis","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models",["common.models","common.services","leave-absences.apis","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,o){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,s,r){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),r=e.assign({},r,{absence_type_id:a,date:t(s).format(o.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",r).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,o,s,r){return t.debug("AbsenceType"),a.extend({all:function(e){return s.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return s.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return s.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return o.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,o,s,r){return this.sendPOST("ContactWorkPattern","create",e.assign({},r,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:o,change_reason:s})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,o,s){return t.debug("WorkPatternAPI.getCalendar",n,a,o,s),this.sendGET("WorkPattern","getcalendar",e.assign({},s,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:o}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,o){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),o).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,o,s,r){function i(t,n){return u().then(function(a){var o=this.days[c(t).valueOf()];return!!o&&e.find(a,function(e){return e.name===n}).value===o.type}.bind(this))}function c(e){return t(e,s.serverDateFormat).clone()}function u(){return l=l||r.valuesOf("hrleaveandabsences_work_day_type")}var l;return o.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[c(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,o){return t.debug("Calendar"),n.extend({get:function(n,s,r,i){return t.debug("Calendar.get"),a.getCalendar(n,s,r,i).then(function(t){var a=t.values.map(function(e){return o.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function o(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(o),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,o,s){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,o,"getLeaveBalances",s)}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,o,s){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return o.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return o.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),s.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,o,s,r){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,o,s,"getFull",r)),i.promise},balanceChangeByAbsenceType:function(t,n,o,s){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var r=a.defer();t&&n||r.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:o?{IN:o}:null,public_holiday:s||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){r.resolve(e.values)}),r.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var o=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?o.reject(t(e.values).map().flatten().value()):o.resolve(e.values)}),o.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,o,s,r,i,c){function u(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return c.all({id:this.type_id}).then(c.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function m(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function f(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return o.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),o=a.breakdown.length>1,s=e.first(e.values(a.breakdown)),r=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(s.date),o&&this.getWorkDayForDate(r.date)]).then(function(t){return s.amount=t[0].time_from?Math.min(this.from_date_amount,f(t[0])):0,o&&(r.amount=t[1].time_from?Math.min(this.to_date_amount,f(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return r.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return u.call(this,s.statusNames.cancelled)},approve:function(){return u.call(this,s.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return u.call(this,s.statusNames.rejected)},sendBack:function(){return u.call(this,s.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),m.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,s.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,s.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,s.statusNames.cancelled)},isRejected:function(){return d.call(this,s.statusNames.rejected)},isSentBack:function(){return d.call(this,s.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(s.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,o,s,r){return n.all(this.processFilters(e),t,o,s,r).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,o){return n.balanceChangeByAbsenceType(e,t,a,o)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/instances/work-pattern.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("WorkPatternInstance",["$log","ModelInstance",function(e,t){return e.debug("WorkPatternInstance"),t.extend({})}])}),define("leave-absences/shared/models/work-pattern.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/work-pattern.instance"],function(e,t){"use strict";t.factory("WorkPattern",["$log","Model","WorkPatternAPI","WorkPatternInstance",function(t,n,a,o){return t.debug("WorkPattern"),n.extend({assignWorkPattern:function(e,t,n,o,s,r){return a.assignWorkPattern(e,t,n,o,s,r)},default:function(){return a.get({is_default:!0}).then(function(t){return o.init(e.first(t),!0)})},unassignWorkPattern:function(e){return a.unassignWorkPattern(e)},workPatternsOf:function(e,t,n){return a.workPatternsOf(e,t,n).then(function(e){return e.map(function(e){return o.init(e,!0)})})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,o,s,r,i){function c(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(v.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(v.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function u(){return{loadContacts:function(){var e=v.filters.userSettings.assignedTo.type;return m(e).then(function(e){v.lookupContacts=e}).then(function(){return"me"!==e?c():a.resolve(null)}).then(function(e){return v.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return o.all(f(),null,"display_name").then(function(e){return e.list})}function d(){return h?a.resolve(h):r.all()}function m(e){return"me"===e?o.leaveManagees(v.contactId):"unassigned"===e?o.leaveManagees(void 0,{unassigned:!0}):o.all().then(function(e){return e.list})}function f(){return{department:v.filters.userSettings.department?v.filters.userSettings.department.value:null,level_type:v.filters.userSettings.level_type?v.filters.userSettings.level_type.value:null,location:v.filters.userSettings.location?v.filters.userSettings.location.value:null,region:v.filters.userSettings.region?v.filters.userSettings.region.value:null,id:{IN:v.filters.userSettings.contact?[v.filters.userSettings.contact.id]:v.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",["When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,u()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:r.contactId}).leaveManagees().then(function(e){r.lookupContacts=e}).then(o)}}}function o(){return t.all(s(),null,"display_name").then(function(e){return e.list})}function s(){return{department:r.filters.userSettings.department?r.filters.userSettings.department.value:null,level_type:r.filters.userSettings.level_type?r.filters.userSettings.level_type.value:null,location:r.filters.userSettings.location?r.filters.userSettings.location.value:null,region:r.filters.userSettings.region?r.filters.userSettings.region.value:null,id:{IN:r.filters.userSettings.contact?[r.filters.userSettings.contact.id]:r.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var r;return{init:function(e){return r=e,r.showContactName=!0,r.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function o(a,o,s,r,i,c,u,l,d,m){function f(){for(var e=[],t=n(O.selectedPeriod.start_date).clone().startOf("month"),a=n(O.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(A(t)),t.add(1,"month");O.months=e}function p(){r.$new().$watch(function(){return O.selectedMonths},function(t,n){null===n||e.equals(t,n)||w()})}function h(e){O.injectMonths=!0,L("injected").then(function(){w(e)}).then(function(){O.loading.calendar=!1})}function v(){S=a("LeaveCalendar"+t.capitalize(M)+"Controller").init(O)}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function g(){return c.all().then(function(e){O.absencePeriods=t.sortBy(e,"start_date"),O.selectedPeriod=t.find(O.absencePeriods,function(e){return!!e.current})}).then(f).then(I)}function _(){return u.all().then(u.loadCalculationUnits)}function y(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return S.loadContacts().then(function(e){O.contacts=e})}function C(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){O.filters.optionValues.regions=e.hrjc_region,O.filters.optionValues.locations=e.hrjc_location,O.filters.optionValues.levelTypes=e.hrjc_level_type,O.filters.optionValues.departments=e.hrjc_department})}function P(){return l.all()}function D(){return o.all([_(),P(),y()]).then(function(e){O.supportData.absenceTypes=e[0],O.supportData.publicHolidays=e[1],O.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,O.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,O.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,O.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function R(){var e=o.resolve();return O.injectMonths&&(e=L("destroyed"),O.injectMonths=!1),e}function A(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function T(e){e=t.includes(["contacts","period"],e)?e:"period",o.resolve().then(function(){O.loading.calendar=!0}).then(R).then("period"===e?f:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function w(e){var n=O.selectedMonths.length?O.months.filter(function(e){return t.includes(O.selectedMonths,e.index)}):O.months;r.$emit("LeaveCalendar::showMonths",n,!!e)}function I(){O.selectedMonths=[n().month()]}function k(){return O.roleOverride?o.resolve().then(function(){M=O.roleOverride}):o.all([m(i.permissions.admin.administer),m(i.permissions.ssp.manage)]).then(function(e){M=e[0]?"admin":e[1]?"manager":"staff"})}function L(e){return o(function(n){var a=0,o=r.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===O.months.length&&(o(),n())})})}s.debug("Component: leave-calendar");var S,M,O=this;O.absencePeriods=[],O.contacts=[],O.contactIdsToReduceTo=null,O.injectMonths=!1,O.months=[],O.selectedMonths=null,O.selectedPeriod=null,O.showContactName=!1,O.showFilters=!1,O.supportData={},O.loading={calendar:!0,page:!0},O.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},O.labelPeriod=b,O.refresh=T,function(){k().then(p).then(v).then(R).then(g).then(function(){return o.all([q(),D()])}).then(function(){return O.showFilters?C():t.noop}).then(function(){h()}).then(function(){O.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",o]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,o){"use strict";function s(){y.calculationUnit=r(y.supportData.calculationUnits,"value",b.calculation_unit)}function r(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(y.contactData.leaveRequest.from_date).isSame(y.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+y.calculationUnit.name+"-on-"+e+"-tooltip"}function c(){b=r(y.supportData.absenceTypes,"id",y.contactData.leaveRequest.type_id),y.contactData.leaveRequest["type_id.title"]=b.title}function u(){"days"===y.calculationUnit.name&&(g=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.from_date_type),_=r(y.supportData.dayTypes,"value",y.contactData.leaveRequest.to_date_type),y.contactData.leaveRequest["from_date_type.label"]=g.label,y.contactData.leaveRequest["to_date_type.label"]=_.label)}function l(e,t,n,a,s){e.stopPropagation(),o.openModal(t,n,a,s)}function d(){y.dates.from=new Date(y.contactData.leaveRequest.from_date),y.dates.to=new Date(y.contactData.leaveRequest.to_date)}function m(){y.contactData.isAccruedTOIL?y.label="AT":"days"===y.calculationUnit.name?f():p()}function f(){y.label=y.contactData.isAM?"AM":y.contactData.isPM?"PM":""}function p(){var e=t(y.contactData.leaveRequest.from_date).isSame(y.date,"day"),n=t(y.contactData.leaveRequest.to_date).isSame(y.date,"day");y.label=e?t(y.contactData.leaveRequest.from_date).format("HH:mm"):n?t(y.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){y.tooltipTemplate=y.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){y.contactData&&y.contactData.leaveRequest&&(c(),s(),u(),m(),d(),h())
-})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){F.push(o.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",u)),F.push(i.subscribe("LeaveRequest::edit",B)),F.push(i.subscribe("LeaveRequest::updatedByManager",B)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){j=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!j)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var j=!1,F=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function j(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(j("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!j("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=j,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||j("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:F(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[F(m.statusNames.rejected),F(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{in:[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)]}})}function L(){
+})}n.debug("Component: leave-calendar-day");var b,g,_,y=this;y.calculationUnit="",y.dates={from:null,to:null},y.label="",y.tooltipTemplate=null,y.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(e){_([e]),N(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),o=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:o.format("YYYY-MM-DD"),name:o.format("ddd"),index:o.format("D"),current:a.isSame(o,"day"),enabled:o.isSameOrAfter(H.period.start_date)&&o.isSameOrBefore(H.period.end_date),contactsData:{}};return o.add(1,"day"),e})}function m(e){return U[e]}function f(){return H.showOnlyWithLeaveRequests?H.contacts.filter(function(e){return Object.keys(W[e.id]||{}).length}):H.contacts}function p(e){return t(e,c.serverDateFormat)}function h(e){S(e),N(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function b(){return H.contactIdsToReduceTo&&(H.contacts=H.contacts.filter(function(t){return e.includes(H.contactIdsToReduceTo,t.contact_id)||e.find(W,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function g(){H.supportData.dayTypes=e.indexBy(H.supportData.dayTypes,"name"),H.supportData.leaveRequestStatuses=e.indexBy(H.supportData.leaveRequestStatuses,"value"),H.supportData.publicHolidays=e.transform(H.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function _(e){return e.forEach(function(e){var t=R(e);W[e.contact_id]=W[e.contact_id]||{},t.forEach(function(t){W[e.contact_id][t.date]=e})}),a.resolve()}function y(){F.push(o.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",u)),F.push(i.subscribe("LeaveRequest::edit",B)),F.push(i.subscribe("LeaveRequest::updatedByManager",B)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):B(e.leaveRequest)}))}function q(e,n,a){var o=H.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?o.value===n.from_date_type:t(a).isSame(n.to_date,"day")?o.value===n.to_date_type:void 0}function C(e,t){return e.request_type===t}function P(e){return!!H.supportData.publicHolidays[p(e).valueOf()]}function D(t){var n=H.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([c.statusNames.awaitingApproval,c.statusNames.moreInformationRequired],n)}function R(n){for(var a=[],o=t(n.from_date).clone(),s=t(n.to_date);o.isSameOrBefore(s);)o.month()===H.month.index&&o.year()===H.month.year&&a.push(e.find(H.month.days,function(e){return e.date===o.format("YYYY-MM-DD")})),o.add(1,"day");return a}function A(t){return e.find(W[t.contact_id],function(e){return t.id===e.id})}function T(t){var n=e.find(H.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function w(){return[T(c.statusNames.approved),T(c.statusNames.adminApproved),T(c.statusNames.awaitingApproval),T(c.statusNames.moreInformationRequired)]}function I(){return H.month.loading=!0,a.all([L(),k()]).then(b).then($).then(function(){j=!0}).then(function(){H.month.loading=!1})}function k(){return r.all({from_date:{to:H.month.days[H.month.days.length-1].date},to_date:{from:H.month.days[0].date},status_id:{IN:w()},contact_id:{IN:H.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(H.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return _(e.list)})}function L(){var t=H.month.days[0].date,n=H.month.days[H.month.days.length-1].date;return s.get(H.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function S(t){W[t.contact_id]=e.omit(W[t.contact_id],function(e){return e.id===t.id})}function M(){o.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function O(t,n,o){var s,r;return t.contactsData[n]=t.contactsData[n]||{},r=m(n),s=!0===o?a.resolve():a.all([r.isWeekend(p(t.date)),r.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:P(t.date)})}),s.then(function(){return W[n]?W[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?C(a,"toil"):null,isRequested:a?D(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function $(){return a.all(H.month.days.map(function(e){return a.all(H.contacts.map(function(t){return O(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===H.month.index})?H.visible=!1:(H.currentPage=0,H.visible=!0,(a||!j)&&I())}function E(t){var n=e.find(H.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function B(e){var t=A(e);t&&(h(t),-1!==w().indexOf(e.status_id)&&u(e))}function N(e){return a.all(R(e).map(function(t){return O(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var j=!1,F=[],U={},W={},H=this;H.currentPage=0,H.pageSize=20,H.visible=!1,H.showContactName=!!H.showContactName,H.showOnlyWithLeaveRequests=!!H.showOnlyWithLeaveRequests,H.$onDestroy=M,H.contactsList=f,H.getContactUrl=v,function(){var e=t().month(H.month.index).year(H.month.year);g(),y(),H.month=l(e),o.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function o(){var t=n.defer();return a.open(e.defaults(s(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function s(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:s,promptBalanceChangeRecalculation:o}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,o,s,r,i,c,u){function l(t){y=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?o.open(h(t)):f(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function m(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([C.awaitingApproval,C.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function f(t){o.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(r.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){s.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=P[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){b(e)}).catch(function(e){u.error("Error:",e)})}}}function v(e,t,n,a,o){e.stopPropagation(),s.openModal(t,n,a,o)}function b(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===c.statusNames.awaitingApproval}).value;y===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function g(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(P,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!m(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&_(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:P[e].label,isDirectAction:P[e].isDirectAction}})}function _(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var y,q=this,C=c.statusNames,P={edit:{label:"Edit",allowedStatuses:[C.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[C.moreInformationRequired]},view:{label:"View",allowedStatuses:[C.approved,C.rejected,C.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[C.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.approved,C.rejected,C.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[C.awaitingApproval,C.moreInformationRequired,C.approved,C.rejected,C.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),g()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,o,s,r,i,c){function u(){q.request.comments.push({contact_id:y,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function m(e){return t.utc(e,r.serverDateTimeFormat).local().format(s.DATE_FORMAT.toUpperCase()+" HH:mm")}function f(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===y?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function b(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function g(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&b()})}function _(){return q.loading.component=!0,c.get().then(function(e){y=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var y=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=u,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=m,q.getActiveComments=f,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){o.$emit("LeaveRequestPopup::addTab",q),g(),_()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d,m,f){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,c.serverDateFormat).toDate()}function v(e){return t(e).format(c.serverDateFormat)}function b(e){var t;return r.resolve().then(function(){J(e),"from"===e&&Q(),N("hours")&&(y(e),"from"!==e||pe.uiOptions.multipleDays||y("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return P(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return r.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return G()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(N("hours"))return H(e).then(function(){ne(e,!0)})}).then(function(){if(se(),!t)return V();o.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(I)}function g(){return se(),V()}function _(){return pe.uiOptions.toDate=null,J("to"),r.resolve().then(function(){if(N("hours")&&pe.uiOptions.fromDate)return y("from"),!pe.uiOptions.multipleDays&&y("to"),H("from").then(function(){ne("from",!0)}).then(se)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&V)}function y(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],o=e.clone(n.time_from),s=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&s&&o&&(s=A(s).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&o&&s&&(o=A(o).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=o||"00:00",a.max=s||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function C(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):D(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):r.reject([])}function P(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function D(e,n){return e=t(e),r.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function R(){return pe.request?pe.request.request_type:pe.leaveType||null}function A(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function T(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(K).catch(I)}function w(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function I(t){o.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function k(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?V():T()}function L(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function S(e){s.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){N("days")||+e==+t||(re(),pe.performBalanceChangeCalculation())})}function M(){fe.push(o.$on("LeaveRequestPopup::absenceTypeChanged",function(){ue()}),o.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),o.$on("LeaveRequestPopup::recalculateBalanceChange",V))}function O(){pe.isMode("edit")&&(pe.isLeaveStatus(c.statusNames.approved)||pe.isLeaveStatus(c.statusNames.adminApproved))&&(me={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function $(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(w(a.min,n)<=0||w(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return r.all(e.map(H)).then(function(){["from","to"].forEach(function(e){$(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(re)}function E(){["from","to"].forEach(function(e){S(e),B(e)})}function B(e){s.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){N("days")||t===n||(se(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function N(e){return pe.selectedAbsenceType.calculation_unit_name===e}function j(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return C(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function W(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function H(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},I(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):r.resolve()}function G(){return u.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function Y(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function V(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(K).catch(I).finally(function(){pe.loading.balanceChange=!1})):r.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function X(){return v(pe.request.from_date)===v(pe.request.to_date)}function Q(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,J("to"))}function J(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,se(),re(),ie()}function K(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&X()||pe.isMode("create")&&(j("sickness")||N("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,r.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",o=n.times[a],s=n.multipleDays&&"to"===a?o.min:n.times.from.time,r=n.multipleDays&&"from"===a?o.max:n.times.to.time,i=he[a].number_of_hours?w(s,r).toString():"0";o.maxAmount=i,t&&(o.amount=o.maxAmount)}function ae(){me&&me.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=me.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function oe(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function se(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),N("hours")&&!j("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function re(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ce(){e.forEach(fe,function(e){e()})}function ue(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return oe(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),r.resolve().then(e&&ee).then(function(){if(e&&N("hours"))return H("from").then(function(){ne("from",!0)})}).then(e&&se).then(V)}function le(e){return pe.absenceTypes=e,oe(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,J("to")),ae(),V()}function de(e){var t=A(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(A(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(A(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var me=null,fe=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=c.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:Y},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=b,pe.dateTypeChangeHandler=g,pe.daysSelectionModeChangeHandler=_,pe.isLeaveType=j,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=V,pe.$onDestroy=ce,function(){n("RequestModalDetails"+e.capitalize(R(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,s.$emit("LeaveRequestPopup::addTab",pe),M(),pe.initChildController().then(function(){return r.all([G(),W()])}).then(!pe.isMode("create")&&L).then(ee).then(function(){if(!pe.isMode("create")&&N("hours"))return x().then(se)}).then(!pe.isMode("create")&&Z).then(O).then(ae).then(k).then(function(){pe.isMode("view")||j("toil")||E()}).catch(I).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l){function d(){return k.fileUploader&&k.fileUploader.queue.length>0}function m(){return k.getFilesAmount()0?T.map(function(e){return e.label}).join(", "):""}function q(){return k.request.loadAttachments().then(function(){o.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function C(){return a.all(T.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){I[e.label]=t})})).catch(function(){I=null})}function P(){return c.valuesOf("safe_file_extension").then(function(e){T=e})}function D(e){return!e.attachment_id||k.canManage}function R(){e.forEach(w,function(e){e()})}function A(e,t){k.fileUploader.queue&&k.fileUploader.queue.length>0?k.fileUploader.uploadAll({entityID:k.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var T=[],w=[],I={},k=Object.create(this);return k.filesLoaded=!1,k.fileUploader=null,k.today=Date.now(),k.userDateFormatWithTime=r.DATE_FORMAT+" HH:mm",k.userDateFormat=r.DATE_FORMAT,k.$onDestroy=R,k.canRemoveAttachment=D,k.canSubmit=d,k.canUploadMore=m,k.formatDateTime=f,k.getAuthorName=p,k.getFilesAmount=h,k.listFileTypes=y,function(){o.$broadcast("LeaveRequestPopup::childComponent::register"),s.$emit("LeaveRequestPopup::addTab",k),g(),a.all([P(),q()]).then(_).finally(function(){k.filesLoaded=!0})}(),k}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,o){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var o,s=this;s.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],s.openLeavePopup=a,function(){o=n.parse(),o.openModal&&a(null,o.openModal,s.selectedContactId,s.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",isSelfRecord:"<",selectedContactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,o,s,r,i,c,u,l,d,m){function f(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),W.sections.other.open&&f(e,W.sections.other)}function h(){Object.values(W.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):W.refresh()}function b(t){t.dataIndex=e.indexBy(t.data,"id")}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function _(){return s.all().then(function(t){W.absencePeriods=e.sortBy(t,"start_date"),W.selectedPeriod=e.find(W.absencePeriods,function(e){return!0===e.current})})}function y(){return r.all().then(r.loadCalculationUnits).then(function(t){W.absenceTypes=t,W.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return T("approved",{status_id:F(m.statusNames.approved)})}function C(){return n.all([c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,null,!0),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.approved)]),c.balanceChangeByAbsenceType(W.contactId,W.selectedPeriod.id,[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)])]).then(function(e){W.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function P(){return i.all({contact_id:W.contactId,period_id:W.selectedPeriod.id},!0).then(function(e){W.entitlements=e}).then(function(){W.absenceTypesFiltered=W.absenceTypes.filter(function(t){var n=e.find(W.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function D(){return i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id},W.entitlements).then(function(){return O(W.entitlements)}).then(function(e){W.sections.entitlements.data=e})}function R(){return n.all([i.breakdown({contact_id:W.contactId,period_id:W.selectedPeriod.id,expired:!0}),A({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:O(e[0]),expiredTOILS:$(e[1].list)})}).then(function(t){W.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),W.sections.expired.data=e.sortBy(W.sections.expired.data,"expiry_date")})}function A(t){return c.all(e.assign({contact_id:W.contactId,from_date:{from:W.selectedPeriod.start_date},to_date:{to:W.selectedPeriod.end_date},type_id:{IN:W.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function T(e,t){return A(t).then(function(t){W.sections[e].data=t.list})}function w(){return n.all(Object.values(W.sections).filter(function(e){return e.open}).map(S))}function I(){return T("other",{status_id:{in:[F(m.statusNames.rejected),F(m.statusNames.cancelled)]}})}function k(){return T("pending",{status_id:{in:[F(m.statusNames.awaitingApproval),F(m.statusNames.moreInformationRequired)]}})}function L(){
return T("holidays",{public_holiday:!0})}function S(e){return e.loading=!0,e.loadLeaveRequests().then(b.bind(this,e)).then(function(){e.loading=!1})}function M(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){W.leaveRequestStatuses=e.indexBy(t,"value")})}function O(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(W.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function $(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function x(){l.subscribe("LeaveRequest::new",function(){W.refresh()}),l.subscribe("LeaveRequest::edit",function(){W.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(W.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],B(t,a))})}function B(e,t){var n=W.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function N(){W.loading.content=!0,n.all([P(),C()]).then(function(){W.loading.content=!1}).then(function(){return n.all([w(),h()])})}function j(e){var t=W.sections[e];t.open=!t.open,t.open&&!t.data.length&&S(t)}function F(t){return e.find(W.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},W=this;W.absencePeriods=[],W.absenceTypes=[],W.absenceTypesFiltered=[],W.absenceTypesIndexed={},W.dateFormat=d.DATE_FORMAT,W.leaveRequestStatuses={},W.selectedPeriod=null,W.role="absence-tab"===a.section?"admin":"staff",W.loading={content:!0,page:!0},W.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:D},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:R},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:L},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:k},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I}},W.labelPeriod=g,W.refresh=N,W.toggleSection=j,function(){n.all([M(),y(),_()]).then(function(){W.loading.page=!1}).then(function(){return n.all([P(),C()])}).then(function(){W.loading.content=!1}),x()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function o(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function s(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function r(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=o,a.canCalculateChange=s,a.canSubmit=r,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s){function r(){return!(!s.canCalculateChange()||!s.request.sickness_reason)}function i(){return a.all([l(),d()])}function c(t){var n=s.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function u(t){return!!e.find(s.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return o.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){s.sicknessDocumentTypes=e})}function d(){return o.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){s.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:s}),s.canSubmit=r,s.initChildController=i,s.isChecked=c,s.isDocumentInRequest=u}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,o,s,r){function i(){return r.balance.change.amount=+r.request.toil_to_accrue,n.resolve(r.balance.change)}function c(){return f().catch(function(e){return e.length&&(r.errors=e),n.reject(e)}).then(function(e){return s.calculateToilExpiryDate(r.request.type_id,e)}).then(function(e){return r.request.toil_expiry_date=e,r.uiOptions.expiryDate=new Date(e),e})}function u(){return!!r.request.toil_to_accrue}function l(){var e=r.uiOptions.multipleDays&&!!r.request.to_date,t=!r.uiOptions.multipleDays&&!!r.request.from_date,n=t||e,a=D.from_date!==r.request.from_date||D.to_date!==r.request.to_date;return r.canDisplayToilExpirationField&&n&&R.hasExpirationFromAdminSettings&&a}function d(){return!!(r.request.from_date&&r.request.to_date&&r.request.toil_duration&&r.request.toil_to_accrue)}function m(){r.request.toil_expiry_date=!1,r.uiOptions.expiryDate=null}function f(){var e=r.uiOptions.multipleDays,t=r.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=r.isMode("create")&&R.hasExpirationFromAdminSettings,t=R.hasPreviousExpirationDate,n=r.isLeaveType("toil"),a=r.canManage;r.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return R.hasPreviousExpirationDate=r.isMode("edit")&&!!r.request.toil_expiry_date,s.canExpire(r.request.type_id).then(function(e){R.hasExpirationFromAdminSettings=e})}function b(){return r.request.to_date_type=r.request.from_date_type="1",v().then(h).then(g).then(y)}function g(){r.canManage&&(r.uiOptions.expiryDate=r.convertDateFormatFromServer(r.request.toil_expiry_date))}function _(){r.isMode("view")||a.$watch(function(){return r.request.toil_to_accrue},function(e,t){+e!=+t&&r.performBalanceChangeCalculation()})}function y(){return o.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){r.toilAmounts=e.indexBy(t,"value")})}function q(){D=angular.copy(r.request.attributes())}function C(){return l()?c().catch(n.resolve):n.resolve()}function P(){r.uiOptions.expiryDate&&(r.request.toil_expiry_date=r.convertDateToServerFormat(r.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var D,R={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};r.canDisplayToilExpirationField=!1,r.calculateBalanceChange=i,r.canCalculateChange=u,r.canSubmit=d,r.clearExpiryDate=m,r.initChildController=b,r.onDateChangeExtended=C,r.setDaysSelectionModeExtended=C,r.updateExpiryDate=P,function(){_(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),o=t(e,n);return t(this.start_date).isSameOrBefore(o)&&t(this.end_date).isSameOrAfter(o)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,o,s){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},current:function(){var e=t().format(s.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?o.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,o,s){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return o.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var o=e(n).format(s.serverDateFormat),r={date:o};return a.all(r).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function o(t,o,s,r,i,c,u,l,d,m,f,p,h,v,b,g,_,y,q,C,P){function D(e){"days"===$e.selectedAbsenceType.calculation_unit_name?delete $e.request[e+"_date_amount"]:delete $e.request[e+"_date_type"]}function R(){["from","to"].forEach(D)}function A(){var e=$e.requestStatuses[y.statusNames.awaitingApproval].value;Ie.status_id===e&&e!==$e.request.status_id&&d.publish("ManagerBadge:: Update Count")}function T(){return Oe.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function w(){return Oe.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function I(){return!$e.loading.entitlements&&(!!se("admin")||!ae("view")&&!(se("manager")&&!ae("create")))}function k(){var e=T();return $e.isMode("edit")&&(e=e&&(G()||w())),$e.canManage&&$e.requestStatuses&&(e=e&&!!$e.getStatusFromValue($e.newStatusOnSave)),(e=e&&!!$e.period.id)&&!$e.isMode("view")}function L(){$e.isSelfRecord?$e.request.status_id=$e.requestStatuses[y.statusNames.awaitingApproval].value:$e.canManage&&($e.request.status_id=$e.newStatusOnSave||$e.request.status_id)}function S(){if($e.isMode("edit")&&!$e.isRole("staff")&&"toil"!==F())return $e.request.calculateBalanceChange($e.selectedAbsenceType.calculation_unit_name).then(function(e){if(+$e.balance.change.amount!=+e.amount)return P.promptBalanceChangeRecalculation().then(function(){s.$emit("LeaveRequestPopup::recalculateBalanceChange")}),o.reject()})}function M(){$e.errors=[]}function O(){return $e.request.create().then(Ce).then(function(){fe("LeaveRequest::new")})}function $(){ee()&&!$e.isRole("staff")&&($e.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return $e.request.delete().then(function(){$e.dismissModal(),d.publish("LeaveRequest::delete",$e.request)})}})}function E(){i.dismiss({$value:"cancel"})}function B(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function N(){return j($e.getStatusFromValue($e.request.status_id).name)}function j(e){return n.map(Te[e],function(e){return $e.requestStatuses[e]})}function F(){return $e.request?$e.request.request_type:$e.leaveType||null}function U(){return!$e.request||e.equals({},$e.requestStatuses)?[]:$e.request.status_id?N():j("none")}function W(e){return n.find($e.requestStatuses,function(t){return t.value===e})}function H(e){$e.errors=n.isArray(e)?e:[e],$e.loading.absenceTypes=!1,$e.submitting=!1}function G(){return!e.equals(Ie,$e.request.attributes())||$e.canManage&&$e.newStatusOnSave}function Y(){return $e.postContactSelection=!0,$e.staffMemberSelectionComplete=!1,$e.request.contact_id?o.resolve().then(ie).then(ce).then(he).then(be).then(Z).then(z).then($e.isMode("edit")?ge:n.noop).then(function(){$e.postContactSelection=!1,$e.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Se)return o.reject(e)}):o.reject("The contact id was not set")}function V(){var e=[y.statusNames.moreInformationRequired,y.statusNames.approved,y.statusNames.rejected,y.statusNames.cancelled];Te.none=[y.statusNames.moreInformationRequired,y.statusNames.approved],Te.awaiting_approval=e,Te.more_information_required=e,Te.rejected=e,Te.approved=e,Te.cancelled=[y.statusNames.awaitingApproval].concat(e)}function z(){return $e.canManage?f.find($e.request.contact_id).then(function(e){$e.contactName=e.display_name}):o.resolve()}function X(){ke.push(s.$on("LeaveRequestPopup::requestObjectUpdated",ge),s.$on("LeaveRequestPopup::absencePeriodChanged",function(){ce().then(he).then(function(){s.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",$e.absenceTypes)})}),s.$on("LeaveRequestPopup::handleError",function(e,t){H(t)}),s.$on("LeaveRequestPopup::childComponent::register",function(){we++})),r.$on("$destroy",Pe),r.$on("LeaveRequestPopup::addTab",function(e,t){Oe.push(t)})}function Q(){var e,t;$e.request=$e.leaveRequest||null,e=F(),t=$e.initRequestAttributes(),"leave"===e?$e.request=_.init(t):"sickness"===e?$e.request=q.init(t):"toil"===e&&($e.request=C.init(t))}function J(){var e={};return $e.request?e=$e.request.attributes():$e.canManage||(e={contact_id:Le}),e}function K(){if(Me="staff","my-leave"!==s.section)return c(y.permissions.admin.administer).then(function(e){e&&(Me="admin")}).then(function(){return"staff"===Me&&c(y.permissions.ssp.manage).then(function(e){e&&(Me="manager")})}).finally(function(){$e.canManage=$e.isRole("manager")||$e.isRole("admin")})}function Z(){($e.isRole("admin")||$e.isMode("create")&&$e.isRole("manager"))&&($e.newStatusOnSave=$e.requestStatuses[y.statusNames.approved].value)}function ee(){return!$e.request.status_id||!n.includes(["cancelled","rejected"],W($e.request.status_id).name)}function te(e){var t=$e.getStatusFromValue($e.request.status_id);return!!t&&t.name===e}function ne(e){return $e.request&&$e.request.request_type===e}function ae(e){return $e.mode===e}function oe(e,t){var n=a(e.from_date),o=a(e.to_date);return n.isSameOrAfter(t.start_date)&&o.isSameOrBefore(t.end_date)}function se(e){return Me===e}function re(){return h.all().then(function(e){$e.absencePeriods=e})}function ie(){return v.all(B()).then(v.loadCalculationUnits).then(function(e){Ae={types:e,ids:e.map(function(e){return e.id})}})}function ce(){return $e.loading.entitlements=!0,b.all({contact_id:$e.request.contact_id,period_id:$e.period.id,type_id:{IN:Ae.ids}},!0).finally(function(){$e.loading.entitlements=!1})}function ue(){return p.get().then(function(e){Le=e.contactId})}function le(){return $e.selectedContactId?f.find($e.selectedContactId).then(function(e){$e.managedContacts=[e]}):$e.isRole("admin")?f.all().then(function(e){$e.managedContacts=n.remove(e.list,function(e){return e.id!==Le})}):f.find(Le).then(function(e){return e.leaveManagees()}).then(function(e){$e.managedContacts=e})}function de(){return u.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){$e.requestStatuses=n.indexBy(e,"name")})}function me(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function fe(e){A(),d.publish(e,$e.request),$e.errors=[],$e.dismissModal()}function pe(){["from","to"].forEach(function(e){$e.request[e+"_date"]=Ie[e+"_date"]})}function he(e){if($e.absenceTypes=me(Ae.types,e),!$e.absenceTypes.length)return o.reject(Se)}function ve(){$e.period=n.find($e.absencePeriods,function(e){return $e.isMode("create")?e.current:oe($e.request,e)})}function be(){$e.isMode("create")?($e.selectedAbsenceType=$e.absenceTypes[0],$e.request.type_id=$e.selectedAbsenceType.id):$e.selectedAbsenceType=n.find($e.absenceTypes,function(e){return e.id===$e.request.type_id})}function ge(){Ie=e.copy($e.request.attributes())}function _e(){var e;$e.request.id?(e=[$e.requestStatuses[y.statusNames.approved].value,$e.requestStatuses[y.statusNames.adminApproved].value,$e.requestStatuses[y.statusNames.rejected].value,$e.requestStatuses[y.statusNames.cancelled].value],$e.mode="edit",$e.isRole("staff")&&e.indexOf($e.request.status_id)>-1&&($e.mode="view")):$e.mode="create"}function ye(){var e=$e.request.status_id;if(!$e.isMode("view")&&!$e.submitting)return $e.submitting=!0,L(),R(),$e.request.isValid().then(ee()&&S).then($).then(!$e.request.change_balance&&pe).then(qe).then(function(){return $e.isMode("edit")?Re():O()}).catch(function(t){$e.request.status_id=e,t&&H(t)}).finally(function(){$e.submitting=!1})}function qe(){return o.all(Oe.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function Ce(){function e(e){e&&n.push(e),++a===we&&(n.length>0?t.reject(n):t.resolve())}var t=o.defer(),n=[],a=0;return we>0?s.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Pe(){ke.forEach(function(e){e()})}function De(){s.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Re(){return $e.request.update().then(Ce).then(function(){$e.isRole("manager")?fe("LeaveRequest::updatedByManager"):($e.isRole("staff")||$e.isRole("admin"))&&fe("LeaveRequest::edit")})}t.debug("RequestCtrl");var Ae,Te={},we=0,Ie={},ke=[],Le="",Se="No entitlement",Me="",Oe=[],$e=n.assign(this,m);$e.absencePeriods=[],$e.absenceTypes=[],$e.canManage=!1,$e.contactName=null,$e.errors=[],$e.loading={absenceTypes:!0,entitlements:!0},$e.managedContacts=[],$e.mode="",$e.newStatusOnSave=null,$e.period={},$e.postContactSelection=!1,$e.requestStatuses={},$e.selectedAbsenceType={},$e.staffMemberSelectionComplete=!1,$e.submitting=!1,$e.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},$e.canChangeAbsenceType=I,$e.canSubmit=k,$e.closeAlert=M,$e.deleteLeaveRequest=x,$e.dismissModal=E,$e.getStatuses=U,$e.getStatusFromValue=W,$e.initAfterContactSelection=Y,$e.initRequestAttributes=J,$e.isLeaveStatus=te,$e.isLeaveType=ne,$e.isMode=ae,$e.isRole=se,$e.submit=ye,$e.updateAbsenceType=De,function(){$e.loading.absenceTypes=!0,V(),X(),o.all([ue(),K(),re(),de()]).then(Q).then(_e).then(ve).then(function(){return $e.canManage&&!$e.isMode("edit")&&le()}).then(function(){if($e.selectedContactId&&($e.request.contact_id=$e.selectedContactId),$e.request.contact_id)return $e.initAfterContactSelection()}).catch(H).finally(function(){$e.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",o),o.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,o,s,r,i,c){function u(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,o,r,i){a.open({appendTo:t.children().eq(0),templateUrl:s.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:o,isSelfRecord:r,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return c.find(e).then(function(e){return u(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):o.error("Error","You dont have permission to see this leave request")})}).catch(function(e){o.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/absence-tab/modules/components",["common/angular"],function(e){return e.module("absence-tab.components",[])}),function(e){define("leave-absences/absence-tab/components/absence-tab-container.component",["leave-absences/absence-tab/modules/components"],function(t){function n(t,n,a){t.debug("Component: absence-tab-container"),n.section="absence-tab",this.contactId=e.adminId,function(){a.getDateFormat()}()}t.component("absenceTabContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-container.html"}],controllerAs:"absence",controller:n}),n.$inject=["$log","$rootScope","DateFormat"]})}(CRM),define("leave-absences/absence-tab/components/absence-tab-entitlements.component",["common/lodash","leave-absences/absence-tab/modules/components"],function(e,t){function n(e,t,n){function a(){return n.all().then(n.loadCalculationUnits).then(function(e){o.absenceTypes=e})}t.debug("Component: absence-tab-entitlements");var o=this;o.absenceTypes=[],o.loading={component:!0},function(){a().finally(function(){o.loading.component=!1})}()}t.component("absenceTabEntitlements",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-entitlements.html"}],controllerAs:"entitlements",controller:n}),n.$inject=["$q","$log","AbsenceType"]}),define("leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component",["common/moment","leave-absences/absence-tab/modules/components"],function(e,t){function n(t,n,a,o,s,r){function i(e){l.errorMessage=e}function c(){return r.get({is_active:!0}).then(function(e){l.workPatterns=e})}function u(){return o.valuesOf("hrjc_revision_change_reason").then(function(e){l.changeReasons=e})}t.debug("Component: absence-tab-custom-work-pattern-modal");var l=Object.create(this);return l.changeReasons=[],l.errorMessage="",l.saveInProgress=!1,l.workPatterns=[],l.loading={content:!0},l.selected={workPattern:null,effectiveDate:null,changeReason:null},l.uiOptions={effectiveDate:{show:!1,options:{startingDay:1,showWeeks:!1}}},function(){n.all([c(),u()]).finally(function(){l.loading.content=!1})}(),l.closeModal=function(){l.dismiss({$value:"cancel"})},l.closeAlert=function(){l.errorMessage=""},l.save=function(){var t=e(l.selected.effectiveDate).format(s.serverDateFormat);return l.saveInProgress=!0,r.assignWorkPattern(l.contactId,l.selected.workPattern.id,t,null,l.selected.changeReason).then(function(){a.$broadcast("CustomWorkPattern::Added"),l.closeModal()}).catch(i).finally(function(){l.saveInProgress=!1})},l}t.component("absenceTabCustomWorkPatternModal",{bindings:{contactId:"<",dismiss:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-custom-work-pattern-modal.html"}],controllerAs:"workPatternModal",controller:["$log","$q","$rootScope","OptionGroup","shared-settings","WorkPatternAPI",n]})}),define("leave-absences/absence-tab/components/absence-tab-work-patterns.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","leave-absences/absence-tab/components/absence-tab-custom-work-pattern-modal.component"],function(e,t,n){function a(n,a,o,s,r,i,c,u,l,d){function m(){return d.workPatternsOf(g.contactId,{},!1).then(function(e){g.customWorkPatterns=e})}function f(){return d.default().then(function(e){g.defaultWorkPattern=e})}function p(){return l.valuesOf("hrjc_revision_change_reason").then(function(t){b=e.indexBy(t,"value")})}function h(e){var t=[m()];return e&&(t=t.concat(e)),g.loading.workPattern=!0,a.all(t).then(function(){v()}).finally(function(){g.loading.workPattern=!1})}function v(){var n,a=u.DATE_FORMAT.toUpperCase();g.customWorkPatterns=e(g.customWorkPatterns).map(function(e){return n=b[e.change_reason],e.change_reason_label=n?n.label:"",e.effective_date=e.effective_date?t(e.effective_date).format(a):"",e}).sortBy(function(e){return-t(e.effective_date,a).valueOf()}).value()}n.debug("Component: absence-tab-work-patterns");var b=[],g=Object.create(this);return g.customWorkPatterns=[],g.defaultWorkPattern=null,g.linkToWorkPatternListingPage=function(){var e=CRM.url("civicrm/contact/view",{cid:g.contactId,selectedChild:"absence"});return CRM.url("civicrm/admin/leaveandabsences/work_patterns",{cid:g.contactId,returnUrl:e})}(),g.loading={workPattern:!0},function(){h([p(),f(),c.getDateFormat()]),s.$on("CustomWorkPattern::Added",function(){h()})}(),g.deleteWorkPattern=function(e){i.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){d.unassignWorkPattern(e).then(function(){h()})}})},g.openModal=function(){r.open({appendTo:o.children().eq(0),template:' ',controller:["$uibModalInstance",function(e){this.dismiss=e.dismiss}],controllerAs:"$ctrl"})},g}n.component("absenceTabWorkPatterns",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/absence-tab-work-patterns.html"}],controllerAs:"workpatterns",controller:["$log","$q","$rootElement","$rootScope","$uibModal","dialog","DateFormat","HR_settings","OptionGroup","WorkPattern",a]})}),define("leave-absences/absence-tab/components/annual-entitlement-change-log.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r){function i(){return l().then(function(e){q=q.concat(e)})}function c(){var t=e.groupBy(q,"created_date");C.changeLogRows=e.map(t,d).sort(function(e,t){return t.date.diff(e.date)})}function u(e,t){var n,a,o=m(e);e.entitlements.forEach(function(s,r){n=o.entitlements.slice(0,r),a=e.entitlements.slice(r+1),t(s,n,a)})}function l(){return o.all({contact_id:C.contactId,period_id:C.periodId},!1).then(function(e){return e.map(function(e){return{comment:e.comment,contact_id:e.contact_id,created_date:e.created_date,editor_id:e.editor_id,entitlement_amount:e.value,entitlement_id:e.id,"entitlement_id.type_id":e.type_id}})})}function d(n,a){var o,s,r;return s=e.indexBy(n,"entitlement_id.type_id"),r=C.absenceTypes.map(function(t){return o=s[t.id],e.extend({calculation_unit:t.calculation_unit_name},o)}),{date:t(a),entitlements:r}}function m(e){var t;return t=C.changeLogRows.indexOf(e),C.changeLogRows[t+1]||{date:e.date.clone(),entitlements:e.entitlements.map(function(){return{}})}}function f(){for(var t,n,a,o=C.changeLogRows.length-1;o>=0;o--)if(t=C.changeLogRows[o],n=e.pluck(t.entitlements,"comment"),a=e.compact(n),1===a.length){var s=e.findIndex(n,"length");t.highlightedEntitlement=t.entitlements[s]}else a.length>1&&_(o)}function p(e,t){C.changeLogRows.splice(t,0,e)}function h(){return n.all({id:C.periodId}).then(function(e){C.absencePeriod=e[0]})}function v(e){return a.all().then(a.loadCalculationUnits).then(function(e){C.absenceTypes=e})}function b(){return o.logs({contact_id:C.contactId,period_id:C.periodId}).then(function(e){q=e})}function g(){var e,t;if(!(C.changeLogRows.length<=1))for(e=C.changeLogRows.length-2,t=C.changeLogRows.length-1;e>=0;){var n=C.changeLogRows[e],a=C.changeLogRows[t];n.entitlements.forEach(function(e,t){var n=a.entitlements[t]
;e.comment===n.comment&&delete e.comment}),e--,t--}}function _(e){var t,n,a=C.changeLogRows[e];u(a,function(o,s,r){o.comment&&(t=s.concat(o).concat(r),n={date:a.date.clone(),entitlements:t},n.highlightedEntitlement=o,p(n,e++))}),y(e)}function y(e){C.changeLogRows.splice(e,1)}var q=[],C=this;C.absencePeriod=null,C.absenceTypes=[],C.changeLogRows=[],C.loading={component:!0},function(){h().then(v).then(b).then(i).then(c).then(g).then(f).finally(function(){C.loading.component=!1})}()}n.component("annualEntitlementChangeLog",{bindings:{contactId:"<",periodId:"<",dismissModal:"&"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlement-change-log.html"}],controllerAs:"changeLog",controller:a}),a.$inject=["AbsencePeriod","AbsenceType","Entitlement","OptionGroup","shared-settings"]}),function(e){define("leave-absences/absence-tab/components/annual-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contact"],function(t,n,a){function o(a,o,s,r,i,c,u,l,d){function m(){P.absencePeriods=t.chain(P.absencePeriods).filter(function(e){return t.find(q,function(t){return t.period_id===e.id})}).sortBy(function(e){return-n(e.start_date).valueOf()}).value()}function f(){P.absenceTypes=t.filter(P.absenceTypes,function(e){return t.find(q,function(t){return t.type_id===e.id})})}function p(t){var n=e.url("civicrm/contact/view",{cid:P.contactId,selectedChild:"absence"});return e.url("civicrm/admin/leaveandabsences/periods/manage_entitlements",{id:t,cid:P.contactId,returnUrl:n})}function h(){return c.all().then(function(e){P.absencePeriods=e})}function v(){var e=t.uniq(t.map(q,function(e){return e.editor_id}));return l.all({id:{IN:e}}).then(function(e){C=t.indexBy(e.list,"contact_id")})}function b(){return u.all({contact_id:P.contactId}).then(function(e){q=e})}function g(e){r.open({appendTo:s.children().eq(0),templateUrl:"annual-entitlement-change-log-modal",controller:["$uibModalInstance",function(t){this.contactId=P.contactId,this.dismiss=t.dismiss,this.periodId=e}],controllerAs:"modal"})}function _(){P.absencePeriods=t.map(P.absencePeriods,function(e){var n=t.map(P.absenceTypes,function(n){var a=t.find(q,function(t){return t.type_id===n.id&&t.period_id===e.id});return a?{amount:a.value,calculation_unit:n.calculation_unit_name,comment:a.comment?{message:a.comment,author_name:C[a.editor_id].display_name,date:a.created_date}:null}:null});return{id:e.id,title:e.title,entitlements:n}})}function y(e){var t=e.message+"Last updated: By: "+e.author_name+" Date: "+n.utc(e.date).local().format("DD/M/YYYY HH:mm")+" ";d.info("Calculation comment:",t)}a.debug("Component: annual-entitlements");var q=[],C=[],P=this;P.absencePeriods=[],P.loading={absencePeriods:!0},P.getEditEntitlementsPageURL=p,P.openAnnualEntitlementChangeLog=g,P.showComment=y,function(){b().then(v).then(h).then(m).then(f).then(_).finally(function(){P.loading.absencePeriods=!1})}()}a.component("annualEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/annual-entitlements.html"}],controllerAs:"entitlements",controller:o}),o.$inject=["$log","$q","$rootElement","$uibModal","AbsenceType","AbsencePeriod","Entitlement","Contact","notificationService"]})}(CRM),define("leave-absences/absence-tab/components/contract-entitlements.component",["common/lodash","common/moment","leave-absences/absence-tab/modules/components","common/models/contract"],function(e,t,n){function a(n,a,o,s,r,i){function c(){m.absenceTypes=e.filter(m.absenceTypes,function(t){return e.find(m.contracts,function(n){return e.find(n.info.leave,function(e){return e.leave_type===t.id})})})}function u(e){var n=o.DATE_FORMAT.toUpperCase();return e?t(e).format(n):""}function l(){return r.all({contact_id:m.contactId}).then(function(e){m.contracts=e})}function d(){m.contracts=e.sortBy(m.contracts,function(e){return t(e.info.details.period_start_date)}).map(function(t){var n=t.info,a=n.details,o=e.map(m.absenceTypes,function(t){var a=e.filter(n.leave,function(e){return e.leave_type===t.id})[0];return{amount:a?a.leave_amount:"",calculation_unit:t.calculation_unit_name}});return{position:a.position,start_date:u(a.period_start_date),end_date:u(a.period_end_date),absences:o}})}n.debug("Component: contract-entitlements");var m=this;m.contracts=[],m.loading={contracts:!0},function(){i.getDateFormat().then(l).then(c).then(d).finally(function(){m.loading.contracts=!1})}()}n.component("contractEntitlements",{bindings:{absenceTypes:"<",contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/contract-entitlements.html"}],controllerAs:"entitlements",controller:a}),a.$inject=["$log","$q","HR_settings","AbsenceType","Contract","DateFormat"]}),function(e){define("leave-absences/absence-tab/modules/settings",["common/angular"],function(t){return t.module("absence-tab.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.contactId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/absence-tab/"})})}(CRM),define("leave-absences/absence-tab/modules/config",["common/angular","leave-absences/absence-tab/modules/settings"],function(e){return e.module("absence-tab.config",["absence-tab.settings"]).config(["$resourceProvider","$httpProvider","$logProvider","settings",function(e,t,n,a){n.debugEnabled(a.debug),e.defaults.stripTrailingSlashes=!1,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest"}])}),define("leave-absences/absence-tab/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/modules/directives","common/services/check-permissions","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/work-pattern.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/absence-tab/components/absence-tab-container.component","leave-absences/absence-tab/components/absence-tab-entitlements.component","leave-absences/absence-tab/components/absence-tab-work-patterns.component","leave-absences/absence-tab/components/annual-entitlement-change-log.component","leave-absences/absence-tab/components/annual-entitlements.component","leave-absences/absence-tab/components/contract-entitlements.component","leave-absences/absence-tab/modules/config"],function(e){return e.module("absence-tab",["ngResource","ui.bootstrap","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.services","common.mocks","leave-absences.settings","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","absence-tab.config","absence-tab.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/absence-tab":n+"/absence-tab"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/absence-tab/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("absenceTabReady"):function(){var e=document.createEvent("Event");return e.initEvent("absenceTabReady",!0,!0),e}())})})}(CRM,require),define("absence-tab",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/absence-tab.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js
index a8a385f1b4e..29a2bf30872 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.min.js
@@ -8,7 +8,7 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/ui-router",[],function(){return function(){"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(e,t,n){"use strict";function a(e,t){return W(new(W(function(){},{prototype:e})),t)}function r(e){return H(arguments,function(t){t!==e&&H(t,function(t,n){e.hasOwnProperty(n)||(e[n]=t)})}),e}function o(e,t){var n=[];for(var a in e.path){if(e.path[a]!==t.path[a])break;n.push(e.path[a])}return n}function s(e){if(Object.keys)return Object.keys(e);var t=[];return H(e,function(e,n){t.push(n)}),t}function i(e,t){if(Array.prototype.indexOf)return e.indexOf(t,Number(arguments[2])||0);var n=e.length>>>0,a=Number(arguments[2])||0;for((a=a<0?Math.ceil(a):Math.floor(a))<0&&(a+=n);a=0||(l.push(r[f]),c[r[f]]=e[r[f]]);return W({},c,t)}function c(e,t,n){if(!n){n=[];for(var a in e)n.push(a)}for(var r=0;r "));if(b[n]=a,N(e))v.push(n,[function(){return t.get(e)}],c);else{var r=t.annotate(e);H(r,function(e){e!==n&&u.hasOwnProperty(e)&&m(u[e],e)}),v.push(n,e,r)}g.pop(),b[n]=o}}function p(e){return F(e)&&e.then&&e.$$promises}if(!F(u))throw new Error("'invocables' must be an object");var h=s(u||{}),v=[],g=[],b={};return H(u,m),u=g=b=null,function(a,o,s){function i(){--y||(_||r(b,o.$$values),m.$$values=b,m.$$promises=m.$$promises||!0,delete m.$$inheritedValues,c.resolve(b))}function u(e){m.$$failure=e,c.reject(e)}if(p(a)&&s===n&&(s=o,o=a,a=null),a){if(!F(a))throw new Error("'locals' must be an object")}else a=l;if(o){if(!p(o))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else o=d;var c=e.defer(),m=c.promise,g=m.$$promises={},b=W({},a),y=1+v.length/3,_=!1;if(j(o.$$failure))return u(o.$$failure),m;o.$$inheritedValues&&r(b,f(o.$$inheritedValues,h)),W(g,o.$$promises),o.$$values?(_=r(b,f(o.$$values,h)),m.$$inheritedValues=f(o.$$values,h),i()):(o.$$inheritedValues&&(m.$$inheritedValues=f(o.$$inheritedValues,h)),o.then(i,u));for(var q=0,$=v.length;q<$;q+=3)a.hasOwnProperty(v[q])?i():function(n,r,o){function c(e){d.reject(e),u(e)}function l(){if(!j(m.$$failure))try{d.resolve(t.invoke(r,s,b)),d.promise.then(function(e){b[n]=e,i()},c)}catch(e){c(e)}}var d=e.defer(),f=0;H(o,function(e){g.hasOwnProperty(e)&&!a.hasOwnProperty(e)&&(f++,g[e].then(function(t){b[e]=t,--f||l()},c))}),f||l(),g[n]=d.promise}(v[q],v[q+1],v[q+2]);return m}},this.resolve=function(e,t,n,a){return this.study(e)(t,n,a)}}function g(e,t,n){this.fromConfig=function(e,t,n){return j(e.template)?this.fromString(e.template,t):j(e.templateUrl)?this.fromUrl(e.templateUrl,t):j(e.templateProvider)?this.fromProvider(e.templateProvider,t,n):null},this.fromString=function(e,t){return B(e)?e(t):e},this.fromUrl=function(n,a){return B(n)&&(n=n(a)),null==n?null:e.get(n,{cache:t,headers:{Accept:"text/html"}}).then(function(e){return e.data})},this.fromProvider=function(e,t,a){return n.invoke(e,null,a||{params:t})}}function b(e,t,r){function o(t,n,a,r){if(v.push(t),p[t])return p[t];if(!/^\w+([-.]+\w+)*(?:\[\])?$/.test(t))throw new Error("Invalid parameter name '"+t+"' in pattern '"+e+"'");if(h[t])throw new Error("Duplicate parameter name '"+t+"' in pattern '"+e+"'");return h[t]=new Y.Param(t,n,a,r),h[t]}function s(e,t,n,a){var r=["",""],o=e.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!t)return o;switch(n){case!1:r=["(",")"+(a?"?":"")];break;case!0:o=o.replace(/\/$/,""),r=["(?:/(",")|/)?"];break;default:r=["("+n+"|",")?"]}return o+r[0]+t+r[1]}function i(r,o){var s,i,u,c,l;return s=r[2]||r[3],l=t.params[s],u=e.substring(f,r.index),i=o?r[4]:r[4]||("*"==r[1]?".*":null),i&&(c=Y.type(i)||a(Y.type("string"),{pattern:new RegExp(i,t.caseInsensitive?"i":n)})),{id:s,regexp:i,segment:u,type:c,cfg:l}}t=W({params:{}},F(t)?t:{});var u,c=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l=/([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,d="^",f=0,m=this.segments=[],p=r?r.params:{},h=this.params=r?r.params.$$new():new Y.ParamSet,v=[];this.source=e;for(var g,b,y;(u=c.exec(e))&&(g=i(u,!1),!(g.segment.indexOf("?")>=0));)b=o(g.id,g.type,g.cfg,"path"),d+=s(g.segment,b.type.pattern.source,b.squash,b.isOptional),m.push(g.segment),f=c.lastIndex;y=e.substring(f);var _=y.indexOf("?");if(_>=0){var q=this.sourceSearch=y.substring(_);if(y=y.substring(0,_),this.sourcePath=e.substring(0,f+_),q.length>0)for(f=0;u=l.exec(q);)g=i(u,!0),b=o(g.id,g.type,g.cfg,"search"),f=c.lastIndex}else this.sourcePath=e,this.sourceSearch="";d+=s(y)+(!1===t.strict?"/?":"")+"$",m.push(y),this.regexp=new RegExp(d,t.caseInsensitive?"i":n),this.prefix=m[0],this.$$paramNames=v}function y(e){W(this,e)}function _(){function e(e){return null!=e?e.toString().replace(/(~|\/)/g,function(e){return{"~":"~~","/":"~2F"}[e]}):e}function r(e){return null!=e?e.toString().replace(/(~~|~2F)/g,function(e){return{"~~":"~","~2F":"/"}[e]}):e}function o(){return{strict:h,caseInsensitive:f}}function u(e){return B(e)||U(e)&&B(e[e.length-1])}function c(){for(;$.length;){var e=$.shift();if(e.pattern)throw new Error("You cannot override a type's .pattern at runtime.");t.extend(g[e.name],d.invoke(e.def))}}function l(e){W(this,e||{})}Y=this;var d,f=!1,h=!0,v=!1,g={},q=!0,$=[],C={string:{encode:e,decode:r,is:function(e){return null==e||!j(e)||"string"==typeof e},pattern:/[^\/]*/},int:{encode:e,decode:function(e){return parseInt(e,10)},is:function(e){return j(e)&&this.decode(e.toString())===e},pattern:/\d+/},bool:{encode:function(e){return e?1:0},decode:function(e){return 0!==parseInt(e,10)},is:function(e){return!0===e||!1===e},pattern:/0|1/},date:{encode:function(e){return this.is(e)?[e.getFullYear(),("0"+(e.getMonth()+1)).slice(-2),("0"+e.getDate()).slice(-2)].join("-"):n},decode:function(e){if(this.is(e))return e;var t=this.capture.exec(e);return t?new Date(t[1],t[2]-1,t[3]):n},is:function(e){return e instanceof Date&&!isNaN(e.valueOf())},equals:function(e,t){return this.is(e)&&this.is(t)&&e.toISOString()===t.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:t.toJson,decode:t.fromJson,is:t.isObject,equals:t.equals,pattern:/[^\/]*/},any:{encode:t.identity,decode:t.identity,equals:t.equals,pattern:/.*/}};_.$$getDefaultValue=function(e){if(!u(e.value))return e.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(e.value)},this.caseInsensitive=function(e){return j(e)&&(f=e),f},this.strictMode=function(e){return j(e)&&(h=e),h},this.defaultSquashPolicy=function(e){if(!j(e))return v;if(!0!==e&&!1!==e&&!N(e))throw new Error("Invalid squash policy: "+e+". Valid policies: false, true, arbitrary-string");return v=e,e},this.compile=function(e,t){return new b(e,W(o(),t))},this.isMatcher=function(e){if(!F(e))return!1;var t=!0;return H(b.prototype,function(n,a){B(n)&&(t=t&&j(e[a])&&B(e[a]))}),t},this.type=function(e,t,n){if(!j(t))return g[e];if(g.hasOwnProperty(e))throw new Error("A type named '"+e+"' has already been defined.");return g[e]=new y(W({name:e},t)),n&&($.push({name:e,def:n}),q||c()),this},H(C,function(e,t){g[t]=new y(W({name:t},e))}),g=a(g,{}),this.$get=["$injector",function(e){return d=e,q=!1,c(),H(C,function(e,t){g[t]||(g[t]=new y(e))}),this}],this.Param=function(e,a,r,o){function c(){if(!d)throw new Error("Injectable functions cannot be called at configuration time");var e=d.invoke(r.$$fn);if(null!==e&&e!==n&&!h.type.is(e))throw new Error("Default value ("+e+") for parameter '"+h.id+"' is not an instance of Type ("+h.type.name+")");return e}function l(e){function t(e){return function(t){return t.from===e}}return e=function(e){var n=p(m(h.replace,t(e)),function(e){return e.to});return n.length?n[0]:e}(e),j(e)?h.type.$normalize(e):c()}function f(){return"{Param:"+e+" "+a+" squash: '"+q+"' optional: "+_+"}"}var h=this;r=function(e){var t=F(e)?s(e):[];return-1===i(t,"value")&&-1===i(t,"type")&&-1===i(t,"squash")&&-1===i(t,"array")&&(e={value:e}),e.$$fn=u(e.value)?e.value:function(){return e.value},e}(r),a=function(n,a,r){if(n.type&&a)throw new Error("Param '"+e+"' has two type configurations.");return a||(n.type?t.isString(n.type)?g[n.type]:n.type instanceof y?n.type:new y(n.type):"config"===r?g.any:g.string)}(r,a,o);var b=function(){var t={array:"search"===o&&"auto"},n=e.match(/\[\]$/)?{array:!0}:{};return W(t,n,r).array}();a=b?a.$asArray(b,"search"===o):a,"string"!==a.name||b||"path"!==o||r.value!==n||(r.value="");var _=r.value!==n,q=function(e,t){var n=e.squash;if(!t||!1===n)return!1;if(!j(n)||null==n)return v;if(!0===n||N(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(r,_),$=function(e,t,a,r){var o,s,u=[{from:"",to:a||t?n:""},{from:null,to:a||t?n:""}];return o=U(e.replace)?e.replace:[],N(r)&&o.push({from:r,to:n}),s=p(o,function(e){return e.from}),m(u,function(e){return-1===i(s,e.from)}).concat(o)}(r,b,_,q);W(this,{id:e,type:a,location:o,array:b,squash:q,replace:$,isOptional:_,value:l,dynamic:n,config:r,toString:f})},l.prototype={$$new:function(){return a(this,W(new l,{$$parent:this}))},$$keys:function(){for(var e=[],t=[],n=this,a=s(l.prototype);n;)t.push(n),n=n.$$parent;return t.reverse(),H(t,function(t){H(s(t),function(t){-1===i(e,t)&&-1===i(a,t)&&e.push(t)})}),e},$$values:function(e){var t={},n=this;return H(n.$$keys(),function(a){t[a]=n[a].value(e&&e[a])}),t},$$equals:function(e,t){var n=!0,a=this;return H(a.$$keys(),function(r){var o=e&&e[r],s=t&&t[r];a[r].type.equals(o,s)||(n=!1)}),n},$$validates:function(e){var a,r,o,s,i,u=this.$$keys();for(a=0;a=0)throw new Error("State must have a valid name");if(P.hasOwnProperty(n))throw new Error("State '"+n+"' is already defined");var r=-1!==n.indexOf(".")?n.substring(0,n.lastIndexOf(".")):N(t.parent)?t.parent:F(t.parent)&&N(t.parent.name)?t.parent.name:"";if(r&&!P[r])return m(r,t.self);for(var o in S)B(S[o])&&(t[o]=S[o](t,S.$delegates[o]));return P[n]=t,!t[R]&&t.url&&e.when(t.url,["$match","$stateParams",function(e,n){A.$current.navigable==t&&c(e,n)||A.transitionTo(t,e,{inherit:!0,location:!1})}]),v(n),t}function b(e){return e.indexOf("*")>-1}function y(e){for(var t=e.split("."),n=A.$current.name.split("."),a=0,r=t.length;a=P;a--)s=p[a],s.self.onExit&&i.invoke(s.self.onExit,s.self,s.locals.globals),s.locals=null;for(a=P;a<_.length;a++)r=_[a],r.locals=M[a],r.self.onEnter&&i.invoke(r.self.onEnter,r.self,r.locals.globals);return A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.$current=t,A.current=t.self,A.params=n,V(A.params,m),A.transition=null,o.location&&t.navigable&&v.push(t.navigable.url,t.navigable.locals.globals.$stateParams,{$$avoidResync:!0,replace:"replace"===o.location}),o.notify&&e.$broadcast("$stateChangeSuccess",t.self,n,c.self,d),v.update(!0),A.current)}).then(null,function(a){return a===D?S:A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.transition=null,s=e.$broadcast("$stateChangeError",t.self,n,c.self,d,a),s.defaultPrevented||v.update(),r.reject(a))});return B},A.is=function(e,t,a){a=W({relative:A.$current},a||{});var r=f(e,a.relative);return j(r)?A.$current===r&&(!t||c(r.params.$$values(t),m)):n},A.includes=function(e,t,a){if(a=W({relative:A.$current},a||{}),N(e)&&b(e)){if(!y(e))return!1;e=A.$current.name}var r=f(e,a.relative);if(!j(r))return n;if(!j(A.$current.includes[r.name]))return!1;if(!t)return!0;for(var o=s(t),i=0;i2?c.enter(e,null,n).then(a):c.enter(e,null,n,a)},leave:function(e,n){t.version.minor>2?c.leave(e).then(n):c.leave(e,n)}};if(u){var a=u&&u(n,e);return{enter:function(e,t,n){a.enter(e,null,t),n()},leave:function(e,t){a.leave(e),t()}}}return function(){return{enter:function(e,t,n){t.after(e),n()},leave:function(e,t){e.remove(),t()}}}()}var i=function(){return n.has?function(e){return n.has(e)?n.get(e):null}:function(e){try{return n.get(e)}catch(e){return null}}}(),u=i("$animator"),c=i("$animate");return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(n,i,u){return function(n,i,c){function l(){if(f&&(f.remove(),f=null),p&&(p.$destroy(),p=null),m){var e=m.data("$uiViewAnim");b.leave(m,function(){e.$$animLeave.resolve(),f=null}),f=m,m=null}}function d(s){var d,f=D(n,c,i,r),y=f&&e.$current&&e.$current.locals[f];if(s||y!==h){d=n.$new(),h=e.$current.locals[f],d.$emit("$viewContentLoading",f);var _=u(d,function(e){var r=o.defer(),s=o.defer(),u={$animEnter:r.promise,$animLeave:s.promise,$$animLeave:s};e.data("$uiViewAnim",u),b.enter(e,i,function(){r.resolve(),p&&p.$emit("$viewContentAnimationEnded"),(t.isDefined(g)&&!g||n.$eval(g))&&a(e)}),l()});m=_,p=d,p.$emit("$viewContentLoaded",f),p.$eval(v)}}var f,m,p,h,v=c.onload||"",g=c.autoscroll,b=s(c,n);i.inheritedData("$uiView"),n.$on("$stateChangeSuccess",function(){d(!1)}),d(!0)}}}}function P(e,n,a,r){return{restrict:"ECA",priority:-400,compile:function(o){var s=o.html();return function(o,i,u){var c=a.$current,l=D(o,u,i,r),d=c&&c.locals[l];if(d){i.data("$uiView",{name:l,state:d.$$state}),i.html(d.$template?d.$template:s);var f=t.extend({},d);o[d.$$resolveAs]=f;var m=e(i.contents());if(d.$$controller){d.$scope=o,d.$element=i;var p=n(d.$$controller,d);d.$$controllerAs&&(o[d.$$controllerAs]=p,o[d.$$controllerAs][d.$$resolveAs]=f),B(p.$onInit)&&p.$onInit(),i.data("$ngControllerController",p),i.children().data("$ngControllerController",p)}m(o)}}}}}function D(e,t,n,a){var r=a(t.uiView||t.name||"")(e),o=n.inheritedData("$uiView");return r.indexOf("@")>=0?r:r+"@"+(o?o.state.name:"")}function R(e,t){var n,a=e.match(/^\s*({[^}]*})\s*$/);if(a&&(e=t+"("+a[1]+")"),!(n=e.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/))||4!==n.length)throw new Error("Invalid state ref '"+e+"'");return{state:n[1],paramExpr:n[3]||null}}function S(e){var t=e.parent().inheritedData("$uiView");if(t&&t.state&&t.state.name)return t.state}function T(e){var t="[object SVGAnimatedString]"===Object.prototype.toString.call(e.prop("href")),n="FORM"===e[0].nodeName;return{attr:n?"action":t?"xlink:href":"href",isAnchor:"A"===e.prop("tagName").toUpperCase(),clickable:!n}}function I(e,t,n,a,r){return function(o){var s=o.which||o.button,i=r();if(!(s>1||o.ctrlKey||o.metaKey||o.shiftKey||e.attr("target"))){var u=n(function(){t.go(i.state,i.params,i.options)});o.preventDefault();var c=a.isAnchor&&!i.href?1:0;o.preventDefault=function(){c--<=0&&n.cancel(u)}}}}function O(e,t){return{relative:S(e)||t.$current,inherit:!0}}function L(e,n){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(a,r,o,s){var i,u=R(o.uiSref,e.current.name),c={state:u.state,href:null,params:null},l=T(r),d=s[1]||s[0],f=null;c.options=W(O(r,e),o.uiSrefOpts?a.$eval(o.uiSrefOpts):{});var m=function(n){n&&(c.params=t.copy(n)),c.href=e.href(u.state,c.params,c.options),f&&f(),d&&(f=d.$$addStateInfo(u.state,c.params)),null!==c.href&&o.$set(l.attr,c.href)};u.paramExpr&&(a.$watch(u.paramExpr,function(e){e!==c.params&&m(e)},!0),c.params=t.copy(a.$eval(u.paramExpr))),m(),l.clickable&&(i=I(r,e,n,l,function(){return c}),r[r.on?"on":"bind"]("click",i),a.$on("$destroy",function(){r[r.off?"off":"unbind"]("click",i)}))}}}function M(e,t){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(n,a,r,o){function s(t){f.state=t[0],f.params=t[1],f.options=t[2],f.href=e.href(f.state,f.params,f.options),m&&m(),c&&(m=c.$$addStateInfo(f.state,f.params)),f.href&&r.$set(u.attr,f.href)}var i,u=T(a),c=o[1]||o[0],l=[r.uiState,r.uiStateParams||null,r.uiStateOpts||null],d="["+l.map(function(e){return e||"null"}).join(", ")+"]",f={state:null,params:null,options:null,href:null},m=null;n.$watch(d,s,!0),s(n.$eval(d)),u.clickable&&(i=I(a,e,t,u,function(){return f}),a[a.on?"on":"bind"]("click",i),n.$on("$destroy",function(){a[a.off?"off":"unbind"]("click",i)}))}}}function k(e,t,n){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout",function(t,a,r,o){function s(t,n,r){var o=e.get(t,S(a)),s=i(t,n),u={state:o||{name:t},params:n,hash:s};return h.push(u),v[s]=r,function(){var e=h.indexOf(u);-1!==e&&h.splice(e,1)}}function i(e,n){if(!N(e))throw new Error("state should be a string");return F(n)?e+G(n):(n=t.$eval(n),F(n)?e+G(n):e)}function u(){for(var e=0;e0)){var n=s(e,t,p);return u(),n}},t.$on("$stateChangeSuccess",u),u()}]}}function x(e){var t=function(t,n){return e.is(t,n)};return t.$stateful=!0,t}function E(e){var t=function(t,n,a){return e.includes(t,n,a)};return t.$stateful=!0,t}var j=t.isDefined,B=t.isFunction,N=t.isString,F=t.isObject,U=t.isArray,H=t.forEach,W=t.extend,V=t.copy,G=t.toJson;t.module("ui.router.util",["ng"]),t.module("ui.router.router",["ui.router.util"]),t.module("ui.router.state",["ui.router.router","ui.router.util"]),t.module("ui.router",["ui.router.state"]),t.module("ui.router.compat",["ui.router"]),v.$inject=["$q","$injector"],t.module("ui.router.util").service("$resolve",v),g.$inject=["$http","$templateCache","$injector"],t.module("ui.router.util").service("$templateFactory",g);var Y;b.prototype.concat=function(e,t){var n={caseInsensitive:Y.caseInsensitive(),strict:Y.strictMode(),squash:Y.defaultSquashPolicy()};return new b(this.sourcePath+e+this.sourceSearch,W(n,t),this)},b.prototype.toString=function(){return this.source},b.prototype.exec=function(e,t){var n=this.regexp.exec(e);if(!n)return null;t=t||{};var a,r,o,s=this.parameters(),i=s.length,u=this.segments.length-1,c={};if(u!==n.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");var l,d;for(a=0;aWhen All filter is selected, all staff members with contracts which are active in the selected absence period are displayed."," People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,c()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:s.contactId}).leaveManagees().then(function(e){s.lookupContacts=e}).then(r)}}}function r(){return t.all(o(),null,"display_name").then(function(e){return e.list})}function o(){return{department:s.filters.userSettings.department?s.filters.userSettings.department.value:null,level_type:s.filters.userSettings.level_type?s.filters.userSettings.level_type.value:null,location:s.filters.userSettings.location?s.filters.userSettings.location.value:null,region:s.filters.userSettings.region?s.filters.userSettings.region.value:null,id:{IN:s.filters.userSettings.contact?[s.filters.userSettings.contact.id]:s.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var s;return{init:function(e){return s=e,s.showContactName=!0,s.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function r(a,r,o,s,i,u,c,l,d,f){function m(){for(var e=[],t=n(M.selectedPeriod.start_date).clone().startOf("month"),a=n(M.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(P(t)),t.add(1,"month");M.months=e}function p(){s.$new().$watch(function(){return M.selectedMonths},function(t,n){null===n||e.equals(t,n)||R()})}function h(e){M.injectMonths=!0,I("injected").then(function(){R(e)}).then(function(){M.loading.calendar=!1})}function v(){O=a("LeaveCalendar"+t.capitalize(L)+"Controller").init(M)}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function b(){return u.all().then(function(e){M.absencePeriods=t.sortBy(e,"start_date"),M.selectedPeriod=t.find(M.absencePeriods,function(e){return!!e.current})}).then(m).then(S)}function y(){return c.all().then(c.loadCalculationUnits)}function _(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return O.loadContacts().then(function(e){M.contacts=e})}function $(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){M.filters.optionValues.regions=e.hrjc_region,M.filters.optionValues.locations=e.hrjc_location,M.filters.optionValues.levelTypes=e.hrjc_level_type,M.filters.optionValues.departments=e.hrjc_department})}function C(){return l.all()}function w(){return r.all([y(),C(),_()]).then(function(e){M.supportData.absenceTypes=e[0],M.supportData.publicHolidays=e[1],M.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,M.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,M.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,M.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function A(){var e=r.resolve();return M.injectMonths&&(e=I("destroyed"),M.injectMonths=!1),e}function P(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function D(e){e=t.includes(["contacts","period"],e)?e:"period",r.resolve().then(function(){M.loading.calendar=!0}).then(A).then("period"===e?m:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function R(e){var n=M.selectedMonths.length?M.months.filter(function(e){return t.includes(M.selectedMonths,e.index)}):M.months;s.$emit("LeaveCalendar::showMonths",n,!!e)}function S(){M.selectedMonths=[n().month()]}function T(){return M.roleOverride?r.resolve().then(function(){L=M.roleOverride}):r.all([f(i.permissions.admin.administer),f(i.permissions.ssp.manage)]).then(function(e){L=e[0]?"admin":e[1]?"manager":"staff"})}function I(e){return r(function(n){var a=0,r=s.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===M.months.length&&(r(),n())})})}o.debug("Component: leave-calendar");var O,L,M=this;M.absencePeriods=[],M.contacts=[],M.contactIdsToReduceTo=null,M.injectMonths=!1,M.months=[],M.selectedMonths=null,M.selectedPeriod=null,M.showContactName=!1,M.showFilters=!1,M.supportData={},M.loading={calendar:!0,page:!0},M.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},M.labelPeriod=g,M.refresh=D,function(){T().then(p).then(v).then(A).then(b).then(function(){return r.all([q(),w()])}).then(function(){return M.showFilters?$():t.noop}).then(function(){h()}).then(function(){M.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",r]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,r){"use strict";function o(){_.calculationUnit=s(_.supportData.calculationUnits,"value",g.calculation_unit)}function s(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(_.contactData.leaveRequest.from_date).isSame(_.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+_.calculationUnit.name+"-on-"+e+"-tooltip"}function u(){g=s(_.supportData.absenceTypes,"id",_.contactData.leaveRequest.type_id),_.contactData.leaveRequest["type_id.title"]=g.title}function c(){"days"===_.calculationUnit.name&&(b=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.from_date_type),y=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.to_date_type),_.contactData.leaveRequest["from_date_type.label"]=b.label,_.contactData.leaveRequest["to_date_type.label"]=y.label)}function l(e,t,n,a,o){e.stopPropagation(),r.openModal(t,n,a,o)}function d(){_.dates.from=new Date(_.contactData.leaveRequest.from_date),_.dates.to=new Date(_.contactData.leaveRequest.to_date)}function f(){_.contactData.isAccruedTOIL?_.label="AT":"days"===_.calculationUnit.name?m():p()}function m(){_.label=_.contactData.isAM?"AM":_.contactData.isPM?"PM":""}function p(){var e=t(_.contactData.leaveRequest.from_date).isSame(_.date,"day"),n=t(_.contactData.leaveRequest.to_date).isSame(_.date,"day");_.label=e?t(_.contactData.leaveRequest.from_date).format("HH:mm"):n?t(_.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){_.tooltipTemplate=_.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){_.contactData&&_.contactData.leaveRequest&&(u(),o(),c(),f(),d(),h())})}n.debug("Component: leave-calendar-day");var g,b,y,_=this;_.calculationUnit="",_.dates={from:null,to:null},_.label="",_.tooltipTemplate=null,_.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(e){y([e]),B(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),r=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:r.format("YYYY-MM-DD"),name:r.format("ddd"),index:r.format("D"),current:a.isSame(r,"day"),enabled:r.isSameOrAfter(W.period.start_date)&&r.isSameOrBefore(W.period.end_date),contactsData:{}};return r.add(1,"day"),e})}function f(e){return U[e]}function m(){return W.showOnlyWithLeaveRequests?W.contacts.filter(function(e){return Object.keys(H[e.id]||{}).length}):W.contacts}function p(e){return t(e,u.serverDateFormat)}function h(e){O(e),B(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function g(){return W.contactIdsToReduceTo&&(W.contacts=W.contacts.filter(function(t){return e.includes(W.contactIdsToReduceTo,t.contact_id)||e.find(H,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function b(){W.supportData.dayTypes=e.indexBy(W.supportData.dayTypes,"name"),W.supportData.leaveRequestStatuses=e.indexBy(W.supportData.leaveRequestStatuses,"value"),W.supportData.publicHolidays=e.transform(W.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function y(e){return e.forEach(function(e){var t=A(e);H[e.contact_id]=H[e.contact_id]||{},t.forEach(function(t){H[e.contact_id][t.date]=e})}),a.resolve()}function _(){F.push(r.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",c)),F.push(i.subscribe("LeaveRequest::edit",j)),F.push(i.subscribe("LeaveRequest::updatedByManager",j)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):j(e.leaveRequest)}))}function q(e,n,a){var r=W.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?r.value===n.from_date_type:t(a).isSame(n.to_date,"day")?r.value===n.to_date_type:void 0}function $(e,t){return e.request_type===t}function C(e){return!!W.supportData.publicHolidays[p(e).valueOf()]}function w(t){var n=W.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([u.statusNames.awaitingApproval,u.statusNames.moreInformationRequired],n)}function A(n){for(var a=[],r=t(n.from_date).clone(),o=t(n.to_date);r.isSameOrBefore(o);)r.month()===W.month.index&&r.year()===W.month.year&&a.push(e.find(W.month.days,function(e){return e.date===r.format("YYYY-MM-DD")})),r.add(1,"day");return a}function P(t){return e.find(H[t.contact_id],function(e){return t.id===e.id})}function D(t){var n=e.find(W.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function R(){return[D(u.statusNames.approved),D(u.statusNames.adminApproved),D(u.statusNames.awaitingApproval),D(u.statusNames.moreInformationRequired)]}function S(){return W.month.loading=!0,a.all([I(),T()]).then(g).then(k).then(function(){N=!0}).then(function(){W.month.loading=!1})}function T(){return s.all({from_date:{to:W.month.days[W.month.days.length-1].date},to_date:{from:W.month.days[0].date},status_id:{IN:R()},contact_id:{IN:W.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(W.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return y(e.list)})}function I(){var t=W.month.days[0].date,n=W.month.days[W.month.days.length-1].date;return o.get(W.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function O(t){H[t.contact_id]=e.omit(H[t.contact_id],function(e){return e.id===t.id})}function L(){r.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function M(t,n,r){var o,s;return t.contactsData[n]=t.contactsData[n]||{},s=f(n),o=!0===r?a.resolve():a.all([s.isWeekend(p(t.date)),s.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:C(t.date)})}),o.then(function(){return H[n]?H[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?$(a,"toil"):null,isRequested:a?w(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function k(){return a.all(W.month.days.map(function(e){return a.all(W.contacts.map(function(t){return M(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===W.month.index})?W.visible=!1:(W.currentPage=0,W.visible=!0,(a||!N)&&S())}function E(t){var n=e.find(W.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function j(e){var t=P(e);t&&(h(t),-1!==R().indexOf(e.status_id)&&c(e))}function B(e){return a.all(A(e).map(function(t){return M(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var N=!1,F=[],U={},H={},W=this;W.currentPage=0,W.pageSize=20,W.visible=!1,W.showContactName=!!W.showContactName,W.showOnlyWithLeaveRequests=!!W.showOnlyWithLeaveRequests,W.$onDestroy=L,W.contactsList=m,W.getContactUrl=v,function(){var e=t().month(W.month.index).year(W.month.year);b(),_(),W.month=l(e),r.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function r(){var t=n.defer();return a.open(e.defaults(o(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function o(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:o,promptBalanceChangeRecalculation:r}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(h(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=C[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function v(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(C,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:C[e].label,isDirectAction:C[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,C={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),
-define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,u.serverDateFormat).toDate()}function v(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):w(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function w(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function A(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function D(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function R(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():D()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(R(a.min,n)<=0||R(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return v(pe.request.from_date)===v(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=he[a].number_of_hours?R(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(A(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?D.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(D.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){D=e})}function w(e){return!e.attachment_id||T.canManage}function A(){e.forEach(R,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var D=[],R=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=A,T.canRemoveAttachment=w,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=h,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function h(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function v(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function w(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function A(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?D(e):n.all([D("table"),D("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function D(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function R(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,A(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=h,U.getAbsenceTypeByID=v,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),w(),I(),P(),S(),R(),O()]).then(function(){U.loading.page=!1,A()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=w.from_date!==s.request.from_date||w.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){w=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var w,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),r=t(e,n);return t(this.start_date).isSameOrBefore(r)&&t(this.end_date).isSameOrAfter(r)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),
+define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,u.serverDateFormat).toDate()}function v(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):w(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function w(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function A(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function D(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function R(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():D()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(R(a.min,n)<=0||R(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return v(pe.request.from_date)===v(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=he[a].number_of_hours?R(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(A(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?D.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(D.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){D=e})}function w(e){return!e.attachment_id||T.canManage}function A(){e.forEach(R,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var D=[],R=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=A,T.canRemoveAttachment=w,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=h,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",isSelfRecord:"<",selectedContactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function h(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function v(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function w(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function A(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?D(e):n.all([D("table"),D("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function D(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function R(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,A(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=h,U.getAbsenceTypeByID=v,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),w(),I(),P(),S(),R(),O()]).then(function(){U.loading.page=!1,A()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=w.from_date!==s.request.from_date||w.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){w=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var w,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,a){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=a.DATE_FORMAT.toUpperCase(),r=t(e,n);return t(this.start_date).isSameOrBefore(r)&&t(this.end_date).isSameOrAfter(r)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),
define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,a,r,o){return e.debug("AbsencePeriod"),n.extend({all:function(e){return a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},current:function(){var e=t().format(o.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return a.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,r){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,o,s){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),s=e.assign({},s,{absence_type_id:a,date:t(o).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",s).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,r,o,s){return t.debug("AbsenceType"),a.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return s.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return o.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return o.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,h,v,g,b,y,_,q,$,C){function w(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function A(){["from","to"].forEach(w)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function D(){return Me.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function R(){return Me.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=D();return ke.isMode("edit")&&(e=e&&(V()||R())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function O(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return C.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function L(){ke.errors=[]}function M(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(De[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function W(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function V(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(he).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Oe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];De.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],De.awaiting_approval=e,De.more_information_required=e,De.rejected=e,De.approved=e,De.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(he).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){W(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){Re++})),s.$on("$destroy",Ce),s.$on("LeaveRequestPopup::addTab",function(e,t){Me.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Le="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Le="admin")}).then(function(){return"staff"===Le&&u(_.permissions.ssp.manage).then(function(e){e&&(Le="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Le===e}function se(){return h.all().then(function(e){ke.absencePeriods=e})}function ie(){return v.all(j()).then(v.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function he(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(Oe)}function ve(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),A(),ke.request.isValid().then(ee()&&O).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?Ae():M()}).catch(function(t){ke.request.status_id=e,t&&W(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Me.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===Re&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return Re>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Ce(){Te.forEach(function(e){e()})}function we(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Ae(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,De={},Re=0,Se={},Te=[],Ie="",Oe="No entitlement",Le="",Me=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=L,ke.deleteLeaveRequest=x,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=we,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(ve).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(W).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),function(e){define("leave-absences/admin-dashboard/modules/settings",["common/angular"],function(t){return t.module("admin-dashboard.settings",[]).constant("settings",{contactId:e.vars.leaveAndAbsences.loggedInUserId,debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/admin-dashboard/"})})}(CRM),define("leave-absences/admin-dashboard/modules/config",["common/angular","leave-absences/admin-dashboard/modules/settings"],function(e){return e.module("admin-dashboard.config",["admin-dashboard.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(e,t,n,a,r,o){var s={format:["DateFormat",function(e){return e.getDateFormat()}]};r.debugEnabled(o.debug),t.defaults.stripTrailingSlashes=!1,a.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",n.otherwise("/requests"),e.state("requests",{url:"/requests",template:' ',resolve:s}).state("calendar",{url:"/calendar",template:' ',resolve:s}).state("leave-balances",{url:"/leave-balances",template:" ",resolve:s})}])}),define("leave-absences/admin-dashboard/modules/components",["common/angular"],function(e){return e.module("admin-dashboard.components",[])}),define("leave-absences/admin-dashboard/components/admin-dashboard-container",["leave-absences/admin-dashboard/modules/components"],function(e){function t(e,t){e.debug("Component: admin-dashboard-container"),t.section="admin-dashboard"}e.component("adminDashboardContainer",{templateUrl:["settings",function(e){return e.pathTpl+"components/admin-dashboard-container.html"}],controllerAs:"vm",controller:["$log","$rootScope",t]})}),
define("leave-absences/admin-dashboard/app",["common/angular","common/angularBootstrap","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/services/check-permissions","common/services/angular-date/date-format","leave-absences/shared/ui-router","leave-absences/shared/components/leave-balance-tab.component","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/manage-leave-requests.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/admin-dashboard/modules/config","leave-absences/admin-dashboard/components/admin-dashboard-container"],function(e){return e.module("admin-dashboard",["ngAnimate","ngResource","ui.bootstrap","ui.router","ui.select","textAngular","common.angularDate","common.dialog","common.filters","common.mocks","leave-absences.components","leave-absences.controllers","leave-absences.settings","leave-absences.services","admin-dashboard.config","admin-dashboard.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/admin-dashboard":n+"/admin-dashboard"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/admin-dashboard/app"],function(){document.dispatchEvent("function"==typeof window.CustomEvent?new CustomEvent("adminDashboardReady"):function(){var e=document.createEvent("Event");return e.initEvent("adminDashboardReady",!0,!0),e}())})})}(CRM,require),define("admin-dashboard",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/admin-dashboard.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js
index cffb5875b44..dfee0b5854d 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.min.js
@@ -8,7 +8,7 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/ui-router",[],function(){return function(){"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(e,t,n){"use strict";function a(e,t){return W(new(W(function(){},{prototype:e})),t)}function r(e){return H(arguments,function(t){t!==e&&H(t,function(t,n){e.hasOwnProperty(n)||(e[n]=t)})}),e}function o(e,t){var n=[];for(var a in e.path){if(e.path[a]!==t.path[a])break;n.push(e.path[a])}return n}function s(e){if(Object.keys)return Object.keys(e);var t=[];return H(e,function(e,n){t.push(n)}),t}function i(e,t){if(Array.prototype.indexOf)return e.indexOf(t,Number(arguments[2])||0);var n=e.length>>>0,a=Number(arguments[2])||0;for((a=a<0?Math.ceil(a):Math.floor(a))<0&&(a+=n);a=0||(l.push(r[f]),c[r[f]]=e[r[f]]);return W({},c,t)}function c(e,t,n){if(!n){n=[];for(var a in e)n.push(a)}for(var r=0;r "));if(b[n]=a,N(e))h.push(n,[function(){return t.get(e)}],c);else{var r=t.annotate(e);H(r,function(e){e!==n&&u.hasOwnProperty(e)&&m(u[e],e)}),h.push(n,e,r)}g.pop(),b[n]=o}}function p(e){return F(e)&&e.then&&e.$$promises}if(!F(u))throw new Error("'invocables' must be an object");var v=s(u||{}),h=[],g=[],b={};return H(u,m),u=g=b=null,function(a,o,s){function i(){--y||(_||r(b,o.$$values),m.$$values=b,m.$$promises=m.$$promises||!0,delete m.$$inheritedValues,c.resolve(b))}function u(e){m.$$failure=e,c.reject(e)}if(p(a)&&s===n&&(s=o,o=a,a=null),a){if(!F(a))throw new Error("'locals' must be an object")}else a=l;if(o){if(!p(o))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else o=d;var c=e.defer(),m=c.promise,g=m.$$promises={},b=W({},a),y=1+h.length/3,_=!1;if(j(o.$$failure))return u(o.$$failure),m;o.$$inheritedValues&&r(b,f(o.$$inheritedValues,v)),W(g,o.$$promises),o.$$values?(_=r(b,f(o.$$values,v)),m.$$inheritedValues=f(o.$$values,v),i()):(o.$$inheritedValues&&(m.$$inheritedValues=f(o.$$inheritedValues,v)),o.then(i,u));for(var q=0,$=h.length;q<$;q+=3)a.hasOwnProperty(h[q])?i():function(n,r,o){function c(e){d.reject(e),u(e)}function l(){if(!j(m.$$failure))try{d.resolve(t.invoke(r,s,b)),d.promise.then(function(e){b[n]=e,i()},c)}catch(e){c(e)}}var d=e.defer(),f=0;H(o,function(e){g.hasOwnProperty(e)&&!a.hasOwnProperty(e)&&(f++,g[e].then(function(t){b[e]=t,--f||l()},c))}),f||l(),g[n]=d.promise}(h[q],h[q+1],h[q+2]);return m}},this.resolve=function(e,t,n,a){return this.study(e)(t,n,a)}}function g(e,t,n){this.fromConfig=function(e,t,n){return j(e.template)?this.fromString(e.template,t):j(e.templateUrl)?this.fromUrl(e.templateUrl,t):j(e.templateProvider)?this.fromProvider(e.templateProvider,t,n):null},this.fromString=function(e,t){return B(e)?e(t):e},this.fromUrl=function(n,a){return B(n)&&(n=n(a)),null==n?null:e.get(n,{cache:t,headers:{Accept:"text/html"}}).then(function(e){return e.data})},this.fromProvider=function(e,t,a){return n.invoke(e,null,a||{params:t})}}function b(e,t,r){function o(t,n,a,r){if(h.push(t),p[t])return p[t];if(!/^\w+([-.]+\w+)*(?:\[\])?$/.test(t))throw new Error("Invalid parameter name '"+t+"' in pattern '"+e+"'");if(v[t])throw new Error("Duplicate parameter name '"+t+"' in pattern '"+e+"'");return v[t]=new Y.Param(t,n,a,r),v[t]}function s(e,t,n,a){var r=["",""],o=e.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!t)return o;switch(n){case!1:r=["(",")"+(a?"?":"")];break;case!0:o=o.replace(/\/$/,""),r=["(?:/(",")|/)?"];break;default:r=["("+n+"|",")?"]}return o+r[0]+t+r[1]}function i(r,o){var s,i,u,c,l;return s=r[2]||r[3],l=t.params[s],u=e.substring(f,r.index),i=o?r[4]:r[4]||("*"==r[1]?".*":null),i&&(c=Y.type(i)||a(Y.type("string"),{pattern:new RegExp(i,t.caseInsensitive?"i":n)})),{id:s,regexp:i,segment:u,type:c,cfg:l}}t=W({params:{}},F(t)?t:{});var u,c=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l=/([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,d="^",f=0,m=this.segments=[],p=r?r.params:{},v=this.params=r?r.params.$$new():new Y.ParamSet,h=[];this.source=e;for(var g,b,y;(u=c.exec(e))&&(g=i(u,!1),!(g.segment.indexOf("?")>=0));)b=o(g.id,g.type,g.cfg,"path"),d+=s(g.segment,b.type.pattern.source,b.squash,b.isOptional),m.push(g.segment),f=c.lastIndex;y=e.substring(f);var _=y.indexOf("?");if(_>=0){var q=this.sourceSearch=y.substring(_);if(y=y.substring(0,_),this.sourcePath=e.substring(0,f+_),q.length>0)for(f=0;u=l.exec(q);)g=i(u,!0),b=o(g.id,g.type,g.cfg,"search"),f=c.lastIndex}else this.sourcePath=e,this.sourceSearch="";d+=s(y)+(!1===t.strict?"/?":"")+"$",m.push(y),this.regexp=new RegExp(d,t.caseInsensitive?"i":n),this.prefix=m[0],this.$$paramNames=h}function y(e){W(this,e)}function _(){function e(e){return null!=e?e.toString().replace(/(~|\/)/g,function(e){return{"~":"~~","/":"~2F"}[e]}):e}function r(e){return null!=e?e.toString().replace(/(~~|~2F)/g,function(e){return{"~~":"~","~2F":"/"}[e]}):e}function o(){return{strict:v,caseInsensitive:f}}function u(e){return B(e)||U(e)&&B(e[e.length-1])}function c(){for(;$.length;){var e=$.shift();if(e.pattern)throw new Error("You cannot override a type's .pattern at runtime.");t.extend(g[e.name],d.invoke(e.def))}}function l(e){W(this,e||{})}Y=this;var d,f=!1,v=!0,h=!1,g={},q=!0,$=[],C={string:{encode:e,decode:r,is:function(e){return null==e||!j(e)||"string"==typeof e},pattern:/[^\/]*/},int:{encode:e,decode:function(e){return parseInt(e,10)},is:function(e){return j(e)&&this.decode(e.toString())===e},pattern:/\d+/},bool:{encode:function(e){return e?1:0},decode:function(e){return 0!==parseInt(e,10)},is:function(e){return!0===e||!1===e},pattern:/0|1/},date:{encode:function(e){return this.is(e)?[e.getFullYear(),("0"+(e.getMonth()+1)).slice(-2),("0"+e.getDate()).slice(-2)].join("-"):n},decode:function(e){if(this.is(e))return e;var t=this.capture.exec(e);return t?new Date(t[1],t[2]-1,t[3]):n},is:function(e){return e instanceof Date&&!isNaN(e.valueOf())},equals:function(e,t){return this.is(e)&&this.is(t)&&e.toISOString()===t.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:t.toJson,decode:t.fromJson,is:t.isObject,equals:t.equals,pattern:/[^\/]*/},any:{encode:t.identity,decode:t.identity,equals:t.equals,pattern:/.*/}};_.$$getDefaultValue=function(e){if(!u(e.value))return e.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(e.value)},this.caseInsensitive=function(e){return j(e)&&(f=e),f},this.strictMode=function(e){return j(e)&&(v=e),v},this.defaultSquashPolicy=function(e){if(!j(e))return h;if(!0!==e&&!1!==e&&!N(e))throw new Error("Invalid squash policy: "+e+". Valid policies: false, true, arbitrary-string");return h=e,e},this.compile=function(e,t){return new b(e,W(o(),t))},this.isMatcher=function(e){if(!F(e))return!1;var t=!0;return H(b.prototype,function(n,a){B(n)&&(t=t&&j(e[a])&&B(e[a]))}),t},this.type=function(e,t,n){if(!j(t))return g[e];if(g.hasOwnProperty(e))throw new Error("A type named '"+e+"' has already been defined.");return g[e]=new y(W({name:e},t)),n&&($.push({name:e,def:n}),q||c()),this},H(C,function(e,t){g[t]=new y(W({name:t},e))}),g=a(g,{}),this.$get=["$injector",function(e){return d=e,q=!1,c(),H(C,function(e,t){g[t]||(g[t]=new y(e))}),this}],this.Param=function(e,a,r,o){function c(){if(!d)throw new Error("Injectable functions cannot be called at configuration time");var e=d.invoke(r.$$fn);if(null!==e&&e!==n&&!v.type.is(e))throw new Error("Default value ("+e+") for parameter '"+v.id+"' is not an instance of Type ("+v.type.name+")");return e}function l(e){function t(e){return function(t){return t.from===e}}return e=function(e){var n=p(m(v.replace,t(e)),function(e){return e.to});return n.length?n[0]:e}(e),j(e)?v.type.$normalize(e):c()}function f(){return"{Param:"+e+" "+a+" squash: '"+q+"' optional: "+_+"}"}var v=this;r=function(e){var t=F(e)?s(e):[];return-1===i(t,"value")&&-1===i(t,"type")&&-1===i(t,"squash")&&-1===i(t,"array")&&(e={value:e}),e.$$fn=u(e.value)?e.value:function(){return e.value},e}(r),a=function(n,a,r){if(n.type&&a)throw new Error("Param '"+e+"' has two type configurations.");return a||(n.type?t.isString(n.type)?g[n.type]:n.type instanceof y?n.type:new y(n.type):"config"===r?g.any:g.string)}(r,a,o);var b=function(){var t={array:"search"===o&&"auto"},n=e.match(/\[\]$/)?{array:!0}:{};return W(t,n,r).array}();a=b?a.$asArray(b,"search"===o):a,"string"!==a.name||b||"path"!==o||r.value!==n||(r.value="");var _=r.value!==n,q=function(e,t){var n=e.squash;if(!t||!1===n)return!1;if(!j(n)||null==n)return h;if(!0===n||N(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(r,_),$=function(e,t,a,r){var o,s,u=[{from:"",to:a||t?n:""},{from:null,to:a||t?n:""}];return o=U(e.replace)?e.replace:[],N(r)&&o.push({from:r,to:n}),s=p(o,function(e){return e.from}),m(u,function(e){return-1===i(s,e.from)}).concat(o)}(r,b,_,q);W(this,{id:e,type:a,location:o,array:b,squash:q,replace:$,isOptional:_,value:l,dynamic:n,config:r,toString:f})},l.prototype={$$new:function(){return a(this,W(new l,{$$parent:this}))},$$keys:function(){for(var e=[],t=[],n=this,a=s(l.prototype);n;)t.push(n),n=n.$$parent;return t.reverse(),H(t,function(t){H(s(t),function(t){-1===i(e,t)&&-1===i(a,t)&&e.push(t)})}),e},$$values:function(e){var t={},n=this;return H(n.$$keys(),function(a){t[a]=n[a].value(e&&e[a])}),t},$$equals:function(e,t){var n=!0,a=this;return H(a.$$keys(),function(r){var o=e&&e[r],s=t&&t[r];a[r].type.equals(o,s)||(n=!1)}),n},$$validates:function(e){var a,r,o,s,i,u=this.$$keys();for(a=0;a=0)throw new Error("State must have a valid name");if(P.hasOwnProperty(n))throw new Error("State '"+n+"' is already defined");var r=-1!==n.indexOf(".")?n.substring(0,n.lastIndexOf(".")):N(t.parent)?t.parent:F(t.parent)&&N(t.parent.name)?t.parent.name:"";if(r&&!P[r])return m(r,t.self);for(var o in S)B(S[o])&&(t[o]=S[o](t,S.$delegates[o]));return P[n]=t,!t[D]&&t.url&&e.when(t.url,["$match","$stateParams",function(e,n){w.$current.navigable==t&&c(e,n)||w.transitionTo(t,e,{inherit:!0,location:!1})}]),h(n),t}function b(e){return e.indexOf("*")>-1}function y(e){for(var t=e.split("."),n=w.$current.name.split("."),a=0,r=t.length;a=P;a--)s=p[a],s.self.onExit&&i.invoke(s.self.onExit,s.self,s.locals.globals),s.locals=null;for(a=P;a<_.length;a++)r=_[a],r.locals=M[a],r.self.onEnter&&i.invoke(r.self.onEnter,r.self,r.locals.globals);return w.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(w.$current=t,w.current=t.self,w.params=n,V(w.params,m),w.transition=null,o.location&&t.navigable&&h.push(t.navigable.url,t.navigable.locals.globals.$stateParams,{$$avoidResync:!0,replace:"replace"===o.location}),o.notify&&e.$broadcast("$stateChangeSuccess",t.self,n,c.self,d),h.update(!0),w.current)}).then(null,function(a){return a===R?S:w.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(w.transition=null,s=e.$broadcast("$stateChangeError",t.self,n,c.self,d,a),s.defaultPrevented||h.update(),r.reject(a))});return B},w.is=function(e,t,a){a=W({relative:w.$current},a||{});var r=f(e,a.relative);return j(r)?w.$current===r&&(!t||c(r.params.$$values(t),m)):n},w.includes=function(e,t,a){if(a=W({relative:w.$current},a||{}),N(e)&&b(e)){if(!y(e))return!1;e=w.$current.name}var r=f(e,a.relative);if(!j(r))return n;if(!j(w.$current.includes[r.name]))return!1;if(!t)return!0;for(var o=s(t),i=0;i2?c.enter(e,null,n).then(a):c.enter(e,null,n,a)},leave:function(e,n){t.version.minor>2?c.leave(e).then(n):c.leave(e,n)}};if(u){var a=u&&u(n,e);return{enter:function(e,t,n){a.enter(e,null,t),n()},leave:function(e,t){a.leave(e),t()}}}return function(){return{enter:function(e,t,n){t.after(e),n()},leave:function(e,t){e.remove(),t()}}}()}var i=function(){return n.has?function(e){return n.has(e)?n.get(e):null}:function(e){try{return n.get(e)}catch(e){return null}}}(),u=i("$animator"),c=i("$animate");return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(n,i,u){return function(n,i,c){function l(){if(f&&(f.remove(),f=null),p&&(p.$destroy(),p=null),m){var e=m.data("$uiViewAnim");b.leave(m,function(){e.$$animLeave.resolve(),f=null}),f=m,m=null}}function d(s){var d,f=R(n,c,i,r),y=f&&e.$current&&e.$current.locals[f];if(s||y!==v){d=n.$new(),v=e.$current.locals[f],d.$emit("$viewContentLoading",f);var _=u(d,function(e){var r=o.defer(),s=o.defer(),u={$animEnter:r.promise,$animLeave:s.promise,$$animLeave:s};e.data("$uiViewAnim",u),b.enter(e,i,function(){r.resolve(),p&&p.$emit("$viewContentAnimationEnded"),(t.isDefined(g)&&!g||n.$eval(g))&&a(e)}),l()});m=_,p=d,p.$emit("$viewContentLoaded",f),p.$eval(h)}}var f,m,p,v,h=c.onload||"",g=c.autoscroll,b=s(c,n);i.inheritedData("$uiView"),n.$on("$stateChangeSuccess",function(){d(!1)}),d(!0)}}}}function P(e,n,a,r){return{restrict:"ECA",priority:-400,compile:function(o){var s=o.html();return function(o,i,u){var c=a.$current,l=R(o,u,i,r),d=c&&c.locals[l];if(d){i.data("$uiView",{name:l,state:d.$$state}),i.html(d.$template?d.$template:s);var f=t.extend({},d);o[d.$$resolveAs]=f;var m=e(i.contents());if(d.$$controller){d.$scope=o,d.$element=i;var p=n(d.$$controller,d);d.$$controllerAs&&(o[d.$$controllerAs]=p,o[d.$$controllerAs][d.$$resolveAs]=f),B(p.$onInit)&&p.$onInit(),i.data("$ngControllerController",p),i.children().data("$ngControllerController",p)}m(o)}}}}}function R(e,t,n,a){var r=a(t.uiView||t.name||"")(e),o=n.inheritedData("$uiView");return r.indexOf("@")>=0?r:r+"@"+(o?o.state.name:"")}function D(e,t){var n,a=e.match(/^\s*({[^}]*})\s*$/);if(a&&(e=t+"("+a[1]+")"),!(n=e.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/))||4!==n.length)throw new Error("Invalid state ref '"+e+"'");return{state:n[1],paramExpr:n[3]||null}}function S(e){var t=e.parent().inheritedData("$uiView");if(t&&t.state&&t.state.name)return t.state}function T(e){var t="[object SVGAnimatedString]"===Object.prototype.toString.call(e.prop("href")),n="FORM"===e[0].nodeName;return{attr:n?"action":t?"xlink:href":"href",isAnchor:"A"===e.prop("tagName").toUpperCase(),clickable:!n}}function I(e,t,n,a,r){return function(o){var s=o.which||o.button,i=r();if(!(s>1||o.ctrlKey||o.metaKey||o.shiftKey||e.attr("target"))){var u=n(function(){t.go(i.state,i.params,i.options)});o.preventDefault();var c=a.isAnchor&&!i.href?1:0;o.preventDefault=function(){c--<=0&&n.cancel(u)}}}}function O(e,t){return{relative:S(e)||t.$current,inherit:!0}}function L(e,n){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(a,r,o,s){var i,u=D(o.uiSref,e.current.name),c={state:u.state,href:null,params:null},l=T(r),d=s[1]||s[0],f=null;c.options=W(O(r,e),o.uiSrefOpts?a.$eval(o.uiSrefOpts):{});var m=function(n){n&&(c.params=t.copy(n)),c.href=e.href(u.state,c.params,c.options),f&&f(),d&&(f=d.$$addStateInfo(u.state,c.params)),null!==c.href&&o.$set(l.attr,c.href)};u.paramExpr&&(a.$watch(u.paramExpr,function(e){e!==c.params&&m(e)},!0),c.params=t.copy(a.$eval(u.paramExpr))),m(),l.clickable&&(i=I(r,e,n,l,function(){return c}),r[r.on?"on":"bind"]("click",i),a.$on("$destroy",function(){r[r.off?"off":"unbind"]("click",i)}))}}}function M(e,t){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(n,a,r,o){function s(t){f.state=t[0],f.params=t[1],f.options=t[2],f.href=e.href(f.state,f.params,f.options),m&&m(),c&&(m=c.$$addStateInfo(f.state,f.params)),f.href&&r.$set(u.attr,f.href)}var i,u=T(a),c=o[1]||o[0],l=[r.uiState,r.uiStateParams||null,r.uiStateOpts||null],d="["+l.map(function(e){return e||"null"}).join(", ")+"]",f={state:null,params:null,options:null,href:null},m=null;n.$watch(d,s,!0),s(n.$eval(d)),u.clickable&&(i=I(a,e,t,u,function(){return f}),a[a.on?"on":"bind"]("click",i),n.$on("$destroy",function(){a[a.off?"off":"unbind"]("click",i)}))}}}function k(e,t,n){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout",function(t,a,r,o){function s(t,n,r){var o=e.get(t,S(a)),s=i(t,n),u={state:o||{name:t},params:n,hash:s};return v.push(u),h[s]=r,function(){var e=v.indexOf(u);-1!==e&&v.splice(e,1)}}function i(e,n){if(!N(e))throw new Error("state should be a string");return F(n)?e+G(n):(n=t.$eval(n),F(n)?e+G(n):e)}function u(){for(var e=0;e0)){var n=s(e,t,p);return u(),n}},t.$on("$stateChangeSuccess",u),u()}]}}function x(e){var t=function(t,n){return e.is(t,n)};return t.$stateful=!0,t}function E(e){var t=function(t,n,a){return e.includes(t,n,a)};return t.$stateful=!0,t}var j=t.isDefined,B=t.isFunction,N=t.isString,F=t.isObject,U=t.isArray,H=t.forEach,W=t.extend,V=t.copy,G=t.toJson;t.module("ui.router.util",["ng"]),t.module("ui.router.router",["ui.router.util"]),t.module("ui.router.state",["ui.router.router","ui.router.util"]),t.module("ui.router",["ui.router.state"]),t.module("ui.router.compat",["ui.router"]),h.$inject=["$q","$injector"],t.module("ui.router.util").service("$resolve",h),g.$inject=["$http","$templateCache","$injector"],t.module("ui.router.util").service("$templateFactory",g);var Y;b.prototype.concat=function(e,t){var n={caseInsensitive:Y.caseInsensitive(),strict:Y.strictMode(),squash:Y.defaultSquashPolicy()};return new b(this.sourcePath+e+this.sourceSearch,W(n,t),this)},b.prototype.toString=function(){return this.source},b.prototype.exec=function(e,t){var n=this.regexp.exec(e);if(!n)return null;t=t||{};var a,r,o,s=this.parameters(),i=s.length,u=this.segments.length-1,c={};if(u!==n.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");var l,d;for(a=0;a=":e}};return a.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,r){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,o,s){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),s=e.assign({},s,{absence_type_id:a,date:t(o).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",s).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,r,o,s){return t.debug("AbsenceType"),a.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return s.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return o.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return o.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/components/leave-balance-tab-filters.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n){function a(e){e.absencePeriods&&c.absencePeriods.length&&(c.filters.period_id=o().id),e.absenceTypes&&c.absenceTypes.length&&(c.filters.type_id=s().id),(e.loggedInContactId||e.userRole)&&(c.filters.managed_by="manager"===c.userRole?c.loggedInContactId:void 0),r()&&c.submitFilters()}function r(){return e.every(c.filters,function(e){return null!==e})}function o(){return e.find(c.absencePeriods,function(e){return e.current})||c.absencePeriods.reduce(function(e,n){return t(e.end_date).isAfter(n.end_date)?e:n})}function s(){return c.absenceTypes.reduce(function(e,t){return e.title.localeCompare(t.title)?e:t})}function i(e){return e.current?"Current Period ("+e.title+")":e.title}function u(){n.$emit("LeaveBalanceFilters::update",c.filters)}var c=this;c.filters={period_id:null,type_id:null,managed_by:null},c.$onChanges=a,c.labelPeriod=i,c.submitFilters=u}n.component("leaveBalanceTabFilters",{controller:a,controllerAs:"balanceFilters",bindings:{absencePeriods:"<",absenceTypes:"<",loggedInContactId:"<",lookupContacts:"<",userRole:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-balance-tab-filters.html"}]}),a.$inject=["$scope"]}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function r(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(r),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,r,o){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,r,"getLeaveBalances",o)}})}])}),define("leave-absences/shared/models/leave-balance-report.model",["leave-absences/shared/modules/models","leave-absences/shared/apis/entitlement.api","common/models/model"],function(e){"use strict";e.factory("LeaveBalanceReport",["Model","EntitlementAPI",function(e,t){return e.extend({all:function(e,n,a,r,o){return t.getLeaveBalances(this.processFilters(e),n,a,r,o)}})}])}),define("leave-absences/shared/components/leave-balance-tab.component",["common/angular","common/lodash","leave-absences/shared/modules/components","leave-absences/shared/components/leave-balance-tab-filters.component","leave-absences/shared/models/leave-balance-report.model","common/services/notification.service","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f){function m(){return r.all({options:{sort:"title ASC"}}).then(function(e){P.absencePeriods=e})}function p(){return o.all().then(o.loadCalculationUnits).then(function(e){P.absenceTypes=e})}function v(){return s.all(null,null,"sort_name ASC").then(function(e){P.lookupContacts=e.list})}function h(){return n.all([m(),p(),v(),g(),q()]).catch(function(e){u.error("Error",e)})}function g(){return l.get().then(function(e){P.loggedInContactId=e.contactId})}function b(){return P.loading.report=!0,i.all(w,P.pagination,void 0,void 0,!1).then(function(e){P.report=y(e.list),P.reportCount=e.total}).catch(function(e){u.error("Error",e.error_message)}).finally(function(){P.loading.report=!1})}function y(n){return n.map(function(n){return n=e.copy(n),n.absence_types=t.indexBy(n.absence_types,function(e){return e.id}),n})}function _(){a.$on("LeaveBalanceFilters::update",C),c.subscribe("LeaveRequest::new",$)}function q(){return f(d.permissions.admin.administer).then(function(e){P.userRole=e?"admin":"manager"})}function $(e){C(e,w)}function C(e,t){w=t,P.pagination.page=1,A(),P.loadReportCurrentPage()}function A(){P.selectedAbsenceTypes=P.absenceTypes.filter(function(e){return+e.id==+w.type_id})}var w={},P=this;P.absencePeriods=[],P.absenceTypes=[],P.loading={component:!0,report:!0},P.loggedInContactId=null,P.lookupContacts=[],P.pagination={page:1,size:50},P.report=[],P.reportCount=0,P.userRole=null,P.loadReportCurrentPage=b,function(){_(),h().then(function(){P.loading.component=!1})}()}n.component("leaveBalanceTab",{controller:a,controllerAs:"leaveBalanceTab",templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-balance-tab.html"}]}),a.$inject=["$q","$rootScope","AbsencePeriod","AbsenceType","Contact","LeaveBalanceReport","notificationService","pubSub","Session","shared-settings","checkPermissions"]}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,r,o,s,i){function u(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(h.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(h.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function c(){return{loadContacts:function(){var e=h.filters.userSettings.assignedTo.type;return f(e).then(function(e){h.lookupContacts=e}).then(function(){return"me"!==e?u():a.resolve(null)}).then(function(e){return h.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return r.all(m(),null,"display_name").then(function(e){return e.list})}function d(){return v?a.resolve(v):s.all()}function f(e){return"me"===e?r.leaveManagees(h.contactId):"unassigned"===e?r.leaveManagees(void 0,{unassigned:!0}):r.all().then(function(e){return e.list})}function m(){return{department:h.filters.userSettings.department?h.filters.userSettings.department.value:null,level_type:h.filters.userSettings.level_type?h.filters.userSettings.level_type.value:null,location:h.filters.userSettings.location?h.filters.userSettings.location.value:null,region:h.filters.userSettings.region?h.filters.userSettings.region.value:null,id:{IN:h.filters.userSettings.contact?[h.filters.userSettings.contact.id]:h.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",[" When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var v,h;return{init:function(e){return h=e,h.showContactDetailsLink=!0,h.showContactName=!0,h.showFilters=!0,h.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],h.filters.userSettings.assignedTo=h.filtersByAssignee[0],h.showAdminFilteringHint=p,c()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:s.contactId}).leaveManagees().then(function(e){s.lookupContacts=e}).then(r)}}}function r(){return t.all(o(),null,"display_name").then(function(e){return e.list})}function o(){return{department:s.filters.userSettings.department?s.filters.userSettings.department.value:null,level_type:s.filters.userSettings.level_type?s.filters.userSettings.level_type.value:null,location:s.filters.userSettings.location?s.filters.userSettings.location.value:null,region:s.filters.userSettings.region?s.filters.userSettings.region.value:null,id:{IN:s.filters.userSettings.contact?[s.filters.userSettings.contact.id]:s.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var s;return{init:function(e){return s=e,s.showContactName=!0,s.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function r(a,r,o,s,i,u,c,l,d,f){function m(){for(var e=[],t=n(M.selectedPeriod.start_date).clone().startOf("month"),a=n(M.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(P(t)),t.add(1,"month");M.months=e}function p(){s.$new().$watch(function(){return M.selectedMonths},function(t,n){null===n||e.equals(t,n)||D()})}function v(e){M.injectMonths=!0,I("injected").then(function(){D(e)}).then(function(){M.loading.calendar=!1})}function h(){O=a("LeaveCalendar"+t.capitalize(L)+"Controller").init(M)}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function b(){return u.all().then(function(e){M.absencePeriods=t.sortBy(e,"start_date"),M.selectedPeriod=t.find(M.absencePeriods,function(e){return!!e.current})}).then(m).then(S)}function y(){return c.all().then(c.loadCalculationUnits)}function _(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return O.loadContacts().then(function(e){M.contacts=e})}function $(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){M.filters.optionValues.regions=e.hrjc_region,M.filters.optionValues.locations=e.hrjc_location,M.filters.optionValues.levelTypes=e.hrjc_level_type,M.filters.optionValues.departments=e.hrjc_department})}function C(){return l.all()}function A(){return r.all([y(),C(),_()]).then(function(e){M.supportData.absenceTypes=e[0],M.supportData.publicHolidays=e[1],M.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,M.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,M.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,M.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function w(){var e=r.resolve();return M.injectMonths&&(e=I("destroyed"),M.injectMonths=!1),e}function P(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function R(e){e=t.includes(["contacts","period"],e)?e:"period",r.resolve().then(function(){M.loading.calendar=!0}).then(w).then("period"===e?m:t.noop).then("contacts"===e?q:t.noop).then(function(){v("contacts"===e)})}function D(e){var n=M.selectedMonths.length?M.months.filter(function(e){return t.includes(M.selectedMonths,e.index)}):M.months;s.$emit("LeaveCalendar::showMonths",n,!!e)}function S(){M.selectedMonths=[n().month()]}function T(){return M.roleOverride?r.resolve().then(function(){L=M.roleOverride}):r.all([f(i.permissions.admin.administer),f(i.permissions.ssp.manage)]).then(function(e){L=e[0]?"admin":e[1]?"manager":"staff"})}function I(e){return r(function(n){var a=0,r=s.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===M.months.length&&(r(),n())})})}o.debug("Component: leave-calendar");var O,L,M=this;M.absencePeriods=[],M.contacts=[],M.contactIdsToReduceTo=null,M.injectMonths=!1,M.months=[],M.selectedMonths=null,M.selectedPeriod=null,M.showContactName=!1,M.showFilters=!1,M.supportData={},M.loading={calendar:!0,page:!0},M.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},M.labelPeriod=g,M.refresh=R,function(){T().then(p).then(h).then(w).then(b).then(function(){return r.all([q(),A()])}).then(function(){return M.showFilters?$():t.noop}).then(function(){v()}).then(function(){M.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",r]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,r){"use strict";function o(){_.calculationUnit=s(_.supportData.calculationUnits,"value",g.calculation_unit)}function s(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(_.contactData.leaveRequest.from_date).isSame(_.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+_.calculationUnit.name+"-on-"+e+"-tooltip"}function u(){g=s(_.supportData.absenceTypes,"id",_.contactData.leaveRequest.type_id),_.contactData.leaveRequest["type_id.title"]=g.title}function c(){"days"===_.calculationUnit.name&&(b=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.from_date_type),y=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.to_date_type),_.contactData.leaveRequest["from_date_type.label"]=b.label,_.contactData.leaveRequest["to_date_type.label"]=y.label)}function l(e,t,n,a,o){e.stopPropagation(),r.openModal(t,n,a,o)}function d(){_.dates.from=new Date(_.contactData.leaveRequest.from_date),_.dates.to=new Date(_.contactData.leaveRequest.to_date)}function f(){_.contactData.isAccruedTOIL?_.label="AT":"days"===_.calculationUnit.name?m():p()}function m(){_.label=_.contactData.isAM?"AM":_.contactData.isPM?"PM":""}function p(){var e=t(_.contactData.leaveRequest.from_date).isSame(_.date,"day"),n=t(_.contactData.leaveRequest.to_date).isSame(_.date,"day");_.label=e?t(_.contactData.leaveRequest.from_date).format("HH:mm"):n?t(_.contactData.leaveRequest.to_date).format("HH:mm"):""}function v(){_.tooltipTemplate=_.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function h(){a.$watch("day.contactData.leaveRequest",function(){_.contactData&&_.contactData.leaveRequest&&(u(),o(),c(),f(),d(),v())})}n.debug("Component: leave-calendar-day");var g,b,y,_=this;_.calculationUnit="",_.dates={from:null,to:null},_.label="",_.tooltipTemplate=null,_.openLeavePopup=l,function(){h()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(e){y([e]),B(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),r=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:r.format("YYYY-MM-DD"),name:r.format("ddd"),index:r.format("D"),current:a.isSame(r,"day"),enabled:r.isSameOrAfter(W.period.start_date)&&r.isSameOrBefore(W.period.end_date),contactsData:{}};return r.add(1,"day"),e})}function f(e){return U[e]}function m(){return W.showOnlyWithLeaveRequests?W.contacts.filter(function(e){return Object.keys(H[e.id]||{}).length}):W.contacts}function p(e){return t(e,u.serverDateFormat)}function v(e){O(e),B(e)}function h(e){return CRM.url("civicrm/contact/view",{cid:e})}function g(){return W.contactIdsToReduceTo&&(W.contacts=W.contacts.filter(function(t){return e.includes(W.contactIdsToReduceTo,t.contact_id)||e.find(H,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function b(){W.supportData.dayTypes=e.indexBy(W.supportData.dayTypes,"name"),W.supportData.leaveRequestStatuses=e.indexBy(W.supportData.leaveRequestStatuses,"value"),W.supportData.publicHolidays=e.transform(W.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function y(e){return e.forEach(function(e){var t=w(e);H[e.contact_id]=H[e.contact_id]||{},t.forEach(function(t){H[e.contact_id][t.date]=e})}),a.resolve()}function _(){F.push(r.$on("LeaveCalendar::showMonths",x)),F.push(i.subscribe("LeaveRequest::new",c)),F.push(i.subscribe("LeaveRequest::edit",j)),F.push(i.subscribe("LeaveRequest::updatedByManager",j)),F.push(i.subscribe("LeaveRequest::delete",v)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?v(e.leaveRequest):j(e.leaveRequest)}))}function q(e,n,a){var r=W.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?r.value===n.from_date_type:t(a).isSame(n.to_date,"day")?r.value===n.to_date_type:void 0}function $(e,t){return e.request_type===t}function C(e){return!!W.supportData.publicHolidays[p(e).valueOf()]}function A(t){var n=W.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([u.statusNames.awaitingApproval,u.statusNames.moreInformationRequired],n)}function w(n){for(var a=[],r=t(n.from_date).clone(),o=t(n.to_date);r.isSameOrBefore(o);)r.month()===W.month.index&&r.year()===W.month.year&&a.push(e.find(W.month.days,function(e){return e.date===r.format("YYYY-MM-DD")})),r.add(1,"day");return a}function P(t){return e.find(H[t.contact_id],function(e){return t.id===e.id})}function R(t){var n=e.find(W.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function D(){return[R(u.statusNames.approved),R(u.statusNames.adminApproved),R(u.statusNames.awaitingApproval),R(u.statusNames.moreInformationRequired)]}function S(){return W.month.loading=!0,a.all([I(),T()]).then(g).then(k).then(function(){N=!0}).then(function(){W.month.loading=!1})}function T(){return s.all({from_date:{to:W.month.days[W.month.days.length-1].date},to_date:{from:W.month.days[0].date},status_id:{IN:D()},contact_id:{IN:W.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(W.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return y(e.list)})}function I(){var t=W.month.days[0].date,n=W.month.days[W.month.days.length-1].date;return o.get(W.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function O(t){H[t.contact_id]=e.omit(H[t.contact_id],function(e){return e.id===t.id})}function L(){r.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function M(t,n,r){var o,s;return t.contactsData[n]=t.contactsData[n]||{},s=f(n),o=!0===r?a.resolve():a.all([s.isWeekend(p(t.date)),s.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:C(t.date)})}),o.then(function(){return H[n]?H[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?$(a,"toil"):null,isRequested:a?A(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function k(){return a.all(W.month.days.map(function(e){return a.all(W.contacts.map(function(t){return M(e,t.id)}))}))}function x(t,n,a){!e.find(n,function(e){return e.index===W.month.index})?W.visible=!1:(W.currentPage=0,W.visible=!0,(a||!N)&&S())}function E(t){var n=e.find(W.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function j(e){var t=P(e);t&&(v(t),-1!==D().indexOf(e.status_id)&&c(e))}function B(e){return a.all(w(e).map(function(t){return M(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var N=!1,F=[],U={},H={},W=this;W.currentPage=0,W.pageSize=20,W.visible=!1,W.showContactName=!!W.showContactName,W.showOnlyWithLeaveRequests=!!W.showOnlyWithLeaveRequests,W.$onDestroy=L,W.contactsList=m,W.getContactUrl=h,function(){var e=t().month(W.month.index).year(W.month.year);b(),_(),W.month=l(e),r.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function r(){var t=n.defer();return a.open(e.defaults(o(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function o(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:o,promptBalanceChangeRecalculation:r}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),
-define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(v(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):v(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function v(e){var t=C[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function h(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(C,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:C[e].label,isDirectAction:C[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,C={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=h,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function v(e){return q.mode===e}function h(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=v,q.onBeforeSubmit=h,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function v(e){return t(e,u.serverDateFormat).toDate()}function h(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=h(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):A(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function A(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function w(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function R(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function D(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():R()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=v(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=v(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(D(a.min,n)<=0||D(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(h(t)).then(function(t){ve[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return ve[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return h(pe.request.from_date)===h(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=v(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=v(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=ve[a].number_of_hours?D(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?h(e.fromDate):null,pe.request.to_date=e.toDate?h(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,ve={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=v,pe.convertDateToServerFormat=h,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(w(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?R.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(R.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){R=e})}function A(e){return!e.attachment_id||T.canManage}function w(){e.forEach(D,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var R=[],D=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=w,T.canRemoveAttachment=A,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=v,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function v(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function h(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function A(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function w(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?R(e):n.all([R("table"),R("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function R(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function D(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,w(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=v,U.getAbsenceTypeByID=h,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),A(),I(),P(),S(),D(),O()]).then(function(){U.loading.page=!1,w()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){
+define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(v(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):v(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function v(e){var t=C[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function h(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(C,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:C[e].label,isDirectAction:C[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,C={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=h,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function v(e){return q.mode===e}function h(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=v,q.onBeforeSubmit=h,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function v(e){return t(e,u.serverDateFormat).toDate()}function h(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return C(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return V()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return W(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),W("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=h(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):A(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function C(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function A(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function w(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function R(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function D(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():R()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=v(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=v(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function O(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function L(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function M(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(D(a.min,n)<=0||D(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function x(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(W)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){O(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function W(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(h(t)).then(function(t){ve[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return ve[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function V(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return h(pe.request.from_date)===h(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=v(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=v(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=ve[a].number_of_hours?D(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?h(e.fromDate):null,pe.request.to_date=e.toDate?h(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return W("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,ve={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=v,pe.convertDateToServerFormat=h,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(w(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),L(),pe.initChildController().then(function(){return s.all([V(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return x().then(oe)}).then(!pe.isMode("create")&&Z).then(M).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?R.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(R.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function C(){return u.valuesOf("safe_file_extension").then(function(e){R=e})}function A(e){return!e.attachment_id||T.canManage}function w(){e.forEach(D,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var R=[],D=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=w,T.canRemoveAttachment=A,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=v,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([C(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",isSelfRecord:"<",selectedContactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/manage-leave-requests.component",["common/lodash","leave-absences/shared/modules/components","common/models/contact","common/services/pub-sub"],function(e,t){function n(t,n,a,r,o,s,i,u,c,l,d,f){"use strict";function m(){U.filters.leaveRequest.contact_id=null,U.refresh()}function p(){var e=U.filters.contact;return{department:e.department,level_type:e.level_type,location:e.location,region:e.region}}function v(e){return"all"===e.name||""===e?U.leaveRequests.filter.list.length:U.leaveRequests.filter.list.filter(function(t){return t.status_id===e.value}).length}function h(t){return e.find(U.absenceTypes,{id:t})}function g(e){return new Array(e||0)}function b(t){var n=e.find(U.leaveRequestStatuses,function(e){return e.value===t});return n?n.label:null}function y(e){switch(e){case i.statusNames.approved:return"badge-success";case i.statusNames.rejected:return"badge-danger";case i.statusNames.cancelled:case"all":return"";default:return"badge-primary"}}function _(t){return e.find(U.leaveRequestStatuses,function(e){return e.name===t}).value}function q(t){var n=e.find(U.filteredUsers,function(e){return e.id===t});return n?n.display_name:null}function $(e){return e.current?"Current Period ("+e.title+")":e.title}function C(){return u.all().then(function(t){U.absencePeriods=e.sortBy(t,"start_date"),U.filters.leaveRequest.selectedPeriod=e.find(U.absencePeriods,function(e){return!!e.current})})}function A(){return c.all().then(c.loadCalculationUnits).then(function(e){U.absenceTypes=e})}function w(e){return(U.isAdmin?r.all(p()):r.leaveManagees(U.contactId,p())).then(function(t){return U.filteredUsers=U.isAdmin?t.list:t,e?R(e):n.all([R("table"),R("filter")])}).then(function(){U.filters.leaveRequest.leaveStatus!==H&&0===U.leaveRequests.table.list.length&&U.refresh(1,!0)})}function P(){return s.valuesOf("hrjc_department").then(function(e){U.departments=e})}function R(e){var t="filter"!==e,n="table"===e?e:"content",a="filter"===e?{size:0}:U.pagination,r="filter"===e?{return:["status_id"]}:{};return U.loading[n]=!0,l.all(T(t),a,"from_date DESC",r,!1).then(function(t){U.leaveRequests[e]=t}).catch(function(){U.leaveRequests[e].list=[]}).finally(function(){U.loading[n]=!1})}function D(){return s.valuesOf("hrjc_level_type").then(function(e){U.levelTypes=e})}function S(){return s.valuesOf("hrjc_location").then(function(e){U.locations=e})}function T(t){var n=U.filters.leaveRequest;return{contact_id:M(),managed_by:U.isAdmin&&"me"!==n.assignedTo.type?void 0:U.contactId,status_id:x(t),type_id:n.selectedAbsenceTypes?n.selectedAbsenceTypes.id:{IN:e.pluck(U.absenceTypes,"id")},from_date:{from:n.selectedPeriod.start_date},to_date:{to:n.selectedPeriod.end_date},unassigned:"unassigned"===n.assignedTo.type||void 0}}function I(){return s.valuesOf("hrjc_region").then(function(e){U.regions=e})}function O(){return s.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){U.leaveRequestStatuses=e.concat(U.leaveRequestStatuses)})}function L(e,t,n,a){d.openModal.apply(d,arguments)}function M(){return U.filteredUsers.length>0&&U.filters.leaveRequest.contact_id?U.filters.leaveRequest.contact_id:{IN:U.filteredUsers.map(function(e){return e.id})}}function k(e){var t=[_(i.statusNames.moreInformationRequired),_(i.statusNames.awaitingApproval)];return 0===e.length&&(e=e.concat(t)),e}function x(e){var t=U.filters.leaveRequest,n=[];if(e&&t.leaveStatus&&t.leaveStatus.value&&n.push(t.leaveStatus.value),t.pending_requests&&(n=k(n)),n.length)return{IN:n}}function E(e,t,n){e="number"==typeof e?e:1,t&&(U.filters.leaveRequest.leaveStatus=H),(e<=U.totalNoOfPages()||0===U.totalNoOfPages())&&(U.pagination.page=e,w(n))}function j(e){U.filters.leaveRequest.leaveStatus=e,U.refresh(1,!1,"table")}function B(e){U.filters.leaveRequest.assignedTo=e,U.refresh()}function N(){f.subscribe("LeaveRequest::updatedByManager",function(){U.refresh()}),f.subscribe("LeaveRequest::new",function(){U.refresh()}),f.subscribe("LeaveRequest::edit",function(){U.refresh()}),f.subscribe("LeaveRequest::delete",function(){U.refresh()}),f.subscribe("LeaveRequest::statusUpdate",function(){U.refresh()})}function F(){return Math.ceil(U.leaveRequests.table.total/U.pagination.size)}t.debug("Component: manage-leave-requests");var U=this,H={name:"all",label:"All"};U.absencePeriods=[],U.absenceTypes=[],U.filteredUsers=[],U.isFilterExpanded=!1,U.isAdmin=!1,U.leaveRequests={table:{list:[]},filter:{list:[]}},U.leaveRequestStatuses=[H],U.loading={content:!0,page:!0,table:!0},U.pagination={page:1,size:7},U.filtersByAssignee=[{type:"me",label:"Assigned To Me"},{type:"unassigned",label:"Unassigned"},{type:"all",label:"All"}],U.filters={contact:{department:null,level_type:null,location:null,region:null},leaveRequest:{leaveStatus:U.leaveRequestStatuses[0],pending_requests:!0,contact_id:null,selectedPeriod:null,selectedAbsenceTypes:null,assignedTo:U.filtersByAssignee[0]}},U.clearStaffSelection=m,U.countLeaveRequestByStatus=v,U.getAbsenceTypeByID=h,U.getArrayOfSize=g,U.getLeaveStatusByValue=b,U.getNavBadge=y,U.getUserNameByID=q,U.labelPeriod=$,U.openLeavePopup=L,U.refresh=E,U.refreshWithFilter=j,U.refreshWithFilterByAssignee=B,U.totalNoOfPages=F,function(){o(i.permissions.admin.administer).then(function(e){U.isAdmin=e,n.all([C(),A(),I(),P(),S(),D(),O()]).then(function(){U.loading.page=!1,w()}),N()})}()}t.component("manageLeaveRequests",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/manage-leave-requests.html"}],controllerAs:"vm",controller:n}),n.$inject=["$log","$q","$rootScope","Contact","checkPermissions","OptionGroup","shared-settings","AbsencePeriod","AbsenceType","LeaveRequest","LeavePopup","pubSub"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){
return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=A.from_date!==s.request.from_date||A.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&w.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function v(){var e=s.isMode("create")&&w.hasExpirationFromAdminSettings,t=w.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function h(){return w.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){w.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",h().then(v).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){A=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function C(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var A,w={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=C,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function v(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function h(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?v.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([h.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([h.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,v,h,g,b,y,_,q,$,C){function A(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function w(){["from","to"].forEach(A)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function R(){return Me.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function D(){return Me.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=R();return ke.isMode("edit")&&(e=e&&(V()||D())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function O(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return C.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function L(){ke.errors=[]}function M(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function x(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(Re[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function W(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function V(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(ve).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==Oe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];Re.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],Re.awaiting_approval=e,Re.more_information_required=e,Re.rejected=e,Re.approved=e,Re.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(ve).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){W(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){De++})),s.$on("$destroy",Ce),s.$on("LeaveRequestPopup::addTab",function(e,t){Me.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Le="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Le="admin")}).then(function(){return"staff"===Le&&u(_.permissions.ssp.manage).then(function(e){e&&(Le="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Le===e}function se(){return v.all().then(function(e){ke.absencePeriods=e})}function ie(){return h.all(j()).then(h.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function ve(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(Oe)}function he(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),w(),ke.request.isValid().then(ee()&&O).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?we():M()}).catch(function(t){ke.request.status_id=e,t&&W(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Me.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===De&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return De>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function Ce(){Te.forEach(function(e){e()})}function Ae(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function we(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,Re={},De=0,Se={},Te=[],Ie="",Oe="No entitlement",Le="",Me=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=L,ke.deleteLeaveRequest=x,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ae,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(he).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(W).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/manager-leave/modules/components",["common/angular"],function(e){return e.module("manager-leave.components",[])}),define("leave-absences/manager-leave/components/manager-leave-container",["leave-absences/manager-leave/modules/components"],function(e){e.component("managerLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/manager-leave-container.html"}],controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: manager-leave-container"),t.section="manager-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}],controllerAs:"managerLeave"})}),function(e){define("leave-absences/manager-leave/modules/settings",["common/angular"],function(t){return t.module("manager-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/"})})}(CRM),function(e){define("leave-absences/manager-leave/modules/config",["common/angular","leave-absences/manager-leave/modules/settings"],function(t){return t.module("manager-leave.config",["manager-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/manager-leave/requests"),t.state("manager-leave",{abstract:!0,url:"/manager-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("manager-leave.requests",{url:"/requests?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("manager-leave.calendar",{url:"/calendar",template:' '}).state("manager-leave.leave-balances",{url:"/leave-balances",template:" "})}])})}(CRM),
define("leave-absences/manager-leave/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/loading","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/dialog","common/services/angular-date/date-format","common/services/check-permissions","leave-absences/shared/ui-router","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/components/leave-balance-tab.component","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/manage-leave-requests.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/services/leave-popup.service","leave-absences/manager-leave/components/manager-leave-container","leave-absences/manager-leave/modules/config"],function(e){return e.module("manager-leave",["ngResource","ngAnimate","ui.bootstrap","ui.router","ui.select","textAngular","common.angularDate","common.dialog","common.filters","common.models","common.directives","common.mocks","leave-absences.models","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","manager-leave.config","manager-leave.components"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/manager-leave":n+"/manager-leave"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/manager-leave/app","leave-absences/shared/models/leave-request.model"],function(e){e.bootstrap(document.querySelector("[data-leave-absences-manager-leave]"),["manager-leave"])})})}(CRM,require),define("manager-leave",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/manager-leave.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js
index 3758089832d..73f9f672fb5 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.min.js
@@ -9,5 +9,5 @@
!function(e){define("leave-absences/shared/config",[],function(){var t=CRM.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences/shared";e.config({paths:{"leave-absences/shared/ui-router":"leave-absences/shared/vendor/angular-ui-router.min",mocks:"../test/mocks"},shim:{"leave-absences/shared/ui-router":{}}}),e.config({paths:{"leave-absences/shared/ui-router":t+"/vendor/angular-ui-router.min",mocks:CRM.vars.leaveAndAbsences.baseURL+"/js/angular/test/mocks"}})})}(require),function(e){define("leave-absences/shared/ui-router",[],function(){return function(){"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(e,t,n){"use strict";function a(e,t){return V(new(V(function(){},{prototype:e})),t)}function r(e){return H(arguments,function(t){t!==e&&H(t,function(t,n){e.hasOwnProperty(n)||(e[n]=t)})}),e}function o(e,t){var n=[];for(var a in e.path){if(e.path[a]!==t.path[a])break;n.push(e.path[a])}return n}function s(e){if(Object.keys)return Object.keys(e);var t=[];return H(e,function(e,n){t.push(n)}),t}function i(e,t){if(Array.prototype.indexOf)return e.indexOf(t,Number(arguments[2])||0);var n=e.length>>>0,a=Number(arguments[2])||0;for((a=a<0?Math.ceil(a):Math.floor(a))<0&&(a+=n);a=0||(l.push(r[f]),c[r[f]]=e[r[f]]);return V({},c,t)}function c(e,t,n){if(!n){n=[];for(var a in e)n.push(a)}for(var r=0;r "));if(b[n]=a,N(e))v.push(n,[function(){return t.get(e)}],c);else{var r=t.annotate(e);H(r,function(e){e!==n&&u.hasOwnProperty(e)&&m(u[e],e)}),v.push(n,e,r)}g.pop(),b[n]=o}}function p(e){return F(e)&&e.then&&e.$$promises}if(!F(u))throw new Error("'invocables' must be an object");var h=s(u||{}),v=[],g=[],b={};return H(u,m),u=g=b=null,function(a,o,s){function i(){--y||(_||r(b,o.$$values),m.$$values=b,m.$$promises=m.$$promises||!0,delete m.$$inheritedValues,c.resolve(b))}function u(e){m.$$failure=e,c.reject(e)}if(p(a)&&s===n&&(s=o,o=a,a=null),a){if(!F(a))throw new Error("'locals' must be an object")}else a=l;if(o){if(!p(o))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else o=d;var c=e.defer(),m=c.promise,g=m.$$promises={},b=V({},a),y=1+v.length/3,_=!1;if(j(o.$$failure))return u(o.$$failure),m;o.$$inheritedValues&&r(b,f(o.$$inheritedValues,h)),V(g,o.$$promises),o.$$values?(_=r(b,f(o.$$values,h)),m.$$inheritedValues=f(o.$$values,h),i()):(o.$$inheritedValues&&(m.$$inheritedValues=f(o.$$inheritedValues,h)),o.then(i,u));for(var q=0,$=v.length;q<$;q+=3)a.hasOwnProperty(v[q])?i():function(n,r,o){function c(e){d.reject(e),u(e)}function l(){if(!j(m.$$failure))try{d.resolve(t.invoke(r,s,b)),d.promise.then(function(e){b[n]=e,i()},c)}catch(e){c(e)}}var d=e.defer(),f=0;H(o,function(e){g.hasOwnProperty(e)&&!a.hasOwnProperty(e)&&(f++,g[e].then(function(t){b[e]=t,--f||l()},c))}),f||l(),g[n]=d.promise}(v[q],v[q+1],v[q+2]);return m}},this.resolve=function(e,t,n,a){return this.study(e)(t,n,a)}}function g(e,t,n){this.fromConfig=function(e,t,n){return j(e.template)?this.fromString(e.template,t):j(e.templateUrl)?this.fromUrl(e.templateUrl,t):j(e.templateProvider)?this.fromProvider(e.templateProvider,t,n):null},this.fromString=function(e,t){return B(e)?e(t):e},this.fromUrl=function(n,a){return B(n)&&(n=n(a)),null==n?null:e.get(n,{cache:t,headers:{Accept:"text/html"}}).then(function(e){return e.data})},this.fromProvider=function(e,t,a){return n.invoke(e,null,a||{params:t})}}function b(e,t,r){function o(t,n,a,r){if(v.push(t),p[t])return p[t];if(!/^\w+([-.]+\w+)*(?:\[\])?$/.test(t))throw new Error("Invalid parameter name '"+t+"' in pattern '"+e+"'");if(h[t])throw new Error("Duplicate parameter name '"+t+"' in pattern '"+e+"'");return h[t]=new Y.Param(t,n,a,r),h[t]}function s(e,t,n,a){var r=["",""],o=e.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!t)return o;switch(n){case!1:r=["(",")"+(a?"?":"")];break;case!0:o=o.replace(/\/$/,""),r=["(?:/(",")|/)?"];break;default:r=["("+n+"|",")?"]}return o+r[0]+t+r[1]}function i(r,o){var s,i,u,c,l;return s=r[2]||r[3],l=t.params[s],u=e.substring(f,r.index),i=o?r[4]:r[4]||("*"==r[1]?".*":null),i&&(c=Y.type(i)||a(Y.type("string"),{pattern:new RegExp(i,t.caseInsensitive?"i":n)})),{id:s,regexp:i,segment:u,type:c,cfg:l}}t=V({params:{}},F(t)?t:{});var u,c=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l=/([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,d="^",f=0,m=this.segments=[],p=r?r.params:{},h=this.params=r?r.params.$$new():new Y.ParamSet,v=[];this.source=e;for(var g,b,y;(u=c.exec(e))&&(g=i(u,!1),!(g.segment.indexOf("?")>=0));)b=o(g.id,g.type,g.cfg,"path"),d+=s(g.segment,b.type.pattern.source,b.squash,b.isOptional),m.push(g.segment),f=c.lastIndex;y=e.substring(f);var _=y.indexOf("?");if(_>=0){var q=this.sourceSearch=y.substring(_);if(y=y.substring(0,_),this.sourcePath=e.substring(0,f+_),q.length>0)for(f=0;u=l.exec(q);)g=i(u,!0),b=o(g.id,g.type,g.cfg,"search"),f=c.lastIndex}else this.sourcePath=e,this.sourceSearch="";d+=s(y)+(!1===t.strict?"/?":"")+"$",m.push(y),this.regexp=new RegExp(d,t.caseInsensitive?"i":n),this.prefix=m[0],this.$$paramNames=v}function y(e){V(this,e)}function _(){function e(e){return null!=e?e.toString().replace(/(~|\/)/g,function(e){return{"~":"~~","/":"~2F"}[e]}):e}function r(e){return null!=e?e.toString().replace(/(~~|~2F)/g,function(e){return{"~~":"~","~2F":"/"}[e]}):e}function o(){return{strict:h,caseInsensitive:f}}function u(e){return B(e)||U(e)&&B(e[e.length-1])}function c(){for(;$.length;){var e=$.shift();if(e.pattern)throw new Error("You cannot override a type's .pattern at runtime.");t.extend(g[e.name],d.invoke(e.def))}}function l(e){V(this,e||{})}Y=this;var d,f=!1,h=!0,v=!1,g={},q=!0,$=[],w={string:{encode:e,decode:r,is:function(e){return null==e||!j(e)||"string"==typeof e},pattern:/[^\/]*/},int:{encode:e,decode:function(e){return parseInt(e,10)},is:function(e){return j(e)&&this.decode(e.toString())===e},pattern:/\d+/},bool:{encode:function(e){return e?1:0},decode:function(e){return 0!==parseInt(e,10)},is:function(e){return!0===e||!1===e},pattern:/0|1/},date:{encode:function(e){return this.is(e)?[e.getFullYear(),("0"+(e.getMonth()+1)).slice(-2),("0"+e.getDate()).slice(-2)].join("-"):n},decode:function(e){if(this.is(e))return e;var t=this.capture.exec(e);return t?new Date(t[1],t[2]-1,t[3]):n},is:function(e){return e instanceof Date&&!isNaN(e.valueOf())},equals:function(e,t){return this.is(e)&&this.is(t)&&e.toISOString()===t.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:t.toJson,decode:t.fromJson,is:t.isObject,equals:t.equals,pattern:/[^\/]*/},any:{encode:t.identity,decode:t.identity,equals:t.equals,pattern:/.*/}};_.$$getDefaultValue=function(e){if(!u(e.value))return e.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(e.value)},this.caseInsensitive=function(e){return j(e)&&(f=e),f},this.strictMode=function(e){return j(e)&&(h=e),h},this.defaultSquashPolicy=function(e){if(!j(e))return v;if(!0!==e&&!1!==e&&!N(e))throw new Error("Invalid squash policy: "+e+". Valid policies: false, true, arbitrary-string");return v=e,e},this.compile=function(e,t){return new b(e,V(o(),t))},this.isMatcher=function(e){if(!F(e))return!1;var t=!0;return H(b.prototype,function(n,a){B(n)&&(t=t&&j(e[a])&&B(e[a]))}),t},this.type=function(e,t,n){if(!j(t))return g[e];if(g.hasOwnProperty(e))throw new Error("A type named '"+e+"' has already been defined.");return g[e]=new y(V({name:e},t)),n&&($.push({name:e,def:n}),q||c()),this},H(w,function(e,t){g[t]=new y(V({name:t},e))}),g=a(g,{}),this.$get=["$injector",function(e){return d=e,q=!1,c(),H(w,function(e,t){g[t]||(g[t]=new y(e))}),this}],this.Param=function(e,a,r,o){function c(){if(!d)throw new Error("Injectable functions cannot be called at configuration time");var e=d.invoke(r.$$fn);if(null!==e&&e!==n&&!h.type.is(e))throw new Error("Default value ("+e+") for parameter '"+h.id+"' is not an instance of Type ("+h.type.name+")");return e}function l(e){function t(e){return function(t){return t.from===e}}return e=function(e){var n=p(m(h.replace,t(e)),function(e){return e.to});return n.length?n[0]:e}(e),j(e)?h.type.$normalize(e):c()}function f(){return"{Param:"+e+" "+a+" squash: '"+q+"' optional: "+_+"}"}var h=this;r=function(e){var t=F(e)?s(e):[];return-1===i(t,"value")&&-1===i(t,"type")&&-1===i(t,"squash")&&-1===i(t,"array")&&(e={value:e}),e.$$fn=u(e.value)?e.value:function(){return e.value},e}(r),a=function(n,a,r){if(n.type&&a)throw new Error("Param '"+e+"' has two type configurations.");return a||(n.type?t.isString(n.type)?g[n.type]:n.type instanceof y?n.type:new y(n.type):"config"===r?g.any:g.string)}(r,a,o);var b=function(){var t={array:"search"===o&&"auto"},n=e.match(/\[\]$/)?{array:!0}:{};return V(t,n,r).array}();a=b?a.$asArray(b,"search"===o):a,"string"!==a.name||b||"path"!==o||r.value!==n||(r.value="");var _=r.value!==n,q=function(e,t){var n=e.squash;if(!t||!1===n)return!1;if(!j(n)||null==n)return v;if(!0===n||N(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(r,_),$=function(e,t,a,r){var o,s,u=[{from:"",to:a||t?n:""},{from:null,to:a||t?n:""}];return o=U(e.replace)?e.replace:[],N(r)&&o.push({from:r,to:n}),s=p(o,function(e){return e.from}),m(u,function(e){return-1===i(s,e.from)}).concat(o)}(r,b,_,q);V(this,{id:e,type:a,location:o,array:b,squash:q,replace:$,isOptional:_,value:l,dynamic:n,config:r,toString:f})},l.prototype={$$new:function(){return a(this,V(new l,{$$parent:this}))},$$keys:function(){for(var e=[],t=[],n=this,a=s(l.prototype);n;)t.push(n),n=n.$$parent;return t.reverse(),H(t,function(t){H(s(t),function(t){-1===i(e,t)&&-1===i(a,t)&&e.push(t)})}),e},$$values:function(e){var t={},n=this;return H(n.$$keys(),function(a){t[a]=n[a].value(e&&e[a])}),t},$$equals:function(e,t){var n=!0,a=this;return H(a.$$keys(),function(r){var o=e&&e[r],s=t&&t[r];a[r].type.equals(o,s)||(n=!1)}),n},$$validates:function(e){var a,r,o,s,i,u=this.$$keys();for(a=0;a=0)throw new Error("State must have a valid name");if(P.hasOwnProperty(n))throw new Error("State '"+n+"' is already defined");var r=-1!==n.indexOf(".")?n.substring(0,n.lastIndexOf(".")):N(t.parent)?t.parent:F(t.parent)&&N(t.parent.name)?t.parent.name:"";if(r&&!P[r])return m(r,t.self);for(var o in S)B(S[o])&&(t[o]=S[o](t,S.$delegates[o]));return P[n]=t,!t[R]&&t.url&&e.when(t.url,["$match","$stateParams",function(e,n){A.$current.navigable==t&&c(e,n)||A.transitionTo(t,e,{inherit:!0,location:!1})}]),v(n),t}function b(e){return e.indexOf("*")>-1}function y(e){for(var t=e.split("."),n=A.$current.name.split("."),a=0,r=t.length;a=P;a--)s=p[a],s.self.onExit&&i.invoke(s.self.onExit,s.self,s.locals.globals),s.locals=null;for(a=P;a<_.length;a++)r=_[a],r.locals=L[a],r.self.onEnter&&i.invoke(r.self.onEnter,r.self,r.locals.globals);return A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.$current=t,A.current=t.self,A.params=n,W(A.params,m),A.transition=null,o.location&&t.navigable&&v.push(t.navigable.url,t.navigable.locals.globals.$stateParams,{$$avoidResync:!0,replace:"replace"===o.location}),o.notify&&e.$broadcast("$stateChangeSuccess",t.self,n,c.self,d),v.update(!0),A.current)}).then(null,function(a){return a===D?S:A.transition!==B?(e.$broadcast("$stateChangeCancel",t.self,n,c.self,d),S):(A.transition=null,s=e.$broadcast("$stateChangeError",t.self,n,c.self,d,a),s.defaultPrevented||v.update(),r.reject(a))});return B},A.is=function(e,t,a){a=V({relative:A.$current},a||{});var r=f(e,a.relative);return j(r)?A.$current===r&&(!t||c(r.params.$$values(t),m)):n},A.includes=function(e,t,a){if(a=V({relative:A.$current},a||{}),N(e)&&b(e)){if(!y(e))return!1;e=A.$current.name}var r=f(e,a.relative);if(!j(r))return n;if(!j(A.$current.includes[r.name]))return!1;if(!t)return!0;for(var o=s(t),i=0;i2?c.enter(e,null,n).then(a):c.enter(e,null,n,a)},leave:function(e,n){t.version.minor>2?c.leave(e).then(n):c.leave(e,n)}};if(u){var a=u&&u(n,e);return{enter:function(e,t,n){a.enter(e,null,t),n()},leave:function(e,t){a.leave(e),t()}}}return function(){return{enter:function(e,t,n){t.after(e),n()},leave:function(e,t){e.remove(),t()}}}()}var i=function(){return n.has?function(e){return n.has(e)?n.get(e):null}:function(e){try{return n.get(e)}catch(e){return null}}}(),u=i("$animator"),c=i("$animate");return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(n,i,u){return function(n,i,c){function l(){if(f&&(f.remove(),f=null),p&&(p.$destroy(),p=null),m){var e=m.data("$uiViewAnim");b.leave(m,function(){e.$$animLeave.resolve(),f=null}),f=m,m=null}}function d(s){var d,f=D(n,c,i,r),y=f&&e.$current&&e.$current.locals[f];if(s||y!==h){d=n.$new(),h=e.$current.locals[f],d.$emit("$viewContentLoading",f);var _=u(d,function(e){var r=o.defer(),s=o.defer(),u={$animEnter:r.promise,$animLeave:s.promise,$$animLeave:s};e.data("$uiViewAnim",u),b.enter(e,i,function(){r.resolve(),p&&p.$emit("$viewContentAnimationEnded"),(t.isDefined(g)&&!g||n.$eval(g))&&a(e)}),l()});m=_,p=d,p.$emit("$viewContentLoaded",f),p.$eval(v)}}var f,m,p,h,v=c.onload||"",g=c.autoscroll,b=s(c,n);i.inheritedData("$uiView"),n.$on("$stateChangeSuccess",function(){d(!1)}),d(!0)}}}}function P(e,n,a,r){return{restrict:"ECA",priority:-400,compile:function(o){var s=o.html();return function(o,i,u){var c=a.$current,l=D(o,u,i,r),d=c&&c.locals[l];if(d){i.data("$uiView",{name:l,state:d.$$state}),i.html(d.$template?d.$template:s);var f=t.extend({},d);o[d.$$resolveAs]=f;var m=e(i.contents());if(d.$$controller){d.$scope=o,d.$element=i;var p=n(d.$$controller,d);d.$$controllerAs&&(o[d.$$controllerAs]=p,o[d.$$controllerAs][d.$$resolveAs]=f),B(p.$onInit)&&p.$onInit(),i.data("$ngControllerController",p),i.children().data("$ngControllerController",p)}m(o)}}}}}function D(e,t,n,a){var r=a(t.uiView||t.name||"")(e),o=n.inheritedData("$uiView");return r.indexOf("@")>=0?r:r+"@"+(o?o.state.name:"")}function R(e,t){var n,a=e.match(/^\s*({[^}]*})\s*$/);if(a&&(e=t+"("+a[1]+")"),!(n=e.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/))||4!==n.length)throw new Error("Invalid state ref '"+e+"'");return{state:n[1],paramExpr:n[3]||null}}function S(e){var t=e.parent().inheritedData("$uiView");if(t&&t.state&&t.state.name)return t.state}function T(e){var t="[object SVGAnimatedString]"===Object.prototype.toString.call(e.prop("href")),n="FORM"===e[0].nodeName;return{attr:n?"action":t?"xlink:href":"href",isAnchor:"A"===e.prop("tagName").toUpperCase(),clickable:!n}}function I(e,t,n,a,r){return function(o){var s=o.which||o.button,i=r();if(!(s>1||o.ctrlKey||o.metaKey||o.shiftKey||e.attr("target"))){var u=n(function(){t.go(i.state,i.params,i.options)});o.preventDefault();var c=a.isAnchor&&!i.href?1:0;o.preventDefault=function(){c--<=0&&n.cancel(u)}}}}function x(e,t){return{relative:S(e)||t.$current,inherit:!0}}function O(e,n){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(a,r,o,s){var i,u=R(o.uiSref,e.current.name),c={state:u.state,href:null,params:null},l=T(r),d=s[1]||s[0],f=null;c.options=V(x(r,e),o.uiSrefOpts?a.$eval(o.uiSrefOpts):{});var m=function(n){n&&(c.params=t.copy(n)),c.href=e.href(u.state,c.params,c.options),f&&f(),d&&(f=d.$$addStateInfo(u.state,c.params)),null!==c.href&&o.$set(l.attr,c.href)};u.paramExpr&&(a.$watch(u.paramExpr,function(e){e!==c.params&&m(e)},!0),c.params=t.copy(a.$eval(u.paramExpr))),m(),l.clickable&&(i=I(r,e,n,l,function(){return c}),r[r.on?"on":"bind"]("click",i),a.$on("$destroy",function(){r[r.off?"off":"unbind"]("click",i)}))}}}function L(e,t){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(n,a,r,o){function s(t){f.state=t[0],f.params=t[1],f.options=t[2],f.href=e.href(f.state,f.params,f.options),m&&m(),c&&(m=c.$$addStateInfo(f.state,f.params)),f.href&&r.$set(u.attr,f.href)}var i,u=T(a),c=o[1]||o[0],l=[r.uiState,r.uiStateParams||null,r.uiStateOpts||null],d="["+l.map(function(e){return e||"null"}).join(", ")+"]",f={state:null,params:null,options:null,href:null},m=null;n.$watch(d,s,!0),s(n.$eval(d)),u.clickable&&(i=I(a,e,t,u,function(){return f}),a[a.on?"on":"bind"]("click",i),n.$on("$destroy",function(){a[a.off?"off":"unbind"]("click",i)}))}}}function k(e,t,n){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout",function(t,a,r,o){function s(t,n,r){var o=e.get(t,S(a)),s=i(t,n),u={state:o||{name:t},params:n,hash:s};return h.push(u),v[s]=r,function(){var e=h.indexOf(u);-1!==e&&h.splice(e,1)}}function i(e,n){if(!N(e))throw new Error("state should be a string");return F(n)?e+G(n):(n=t.$eval(n),F(n)?e+G(n):e)}function u(){for(var e=0;e0)){var n=s(e,t,p);return u(),n}},t.$on("$stateChangeSuccess",u),u()}]}}function M(e){var t=function(t,n){return e.is(t,n)};return t.$stateful=!0,t}function E(e){var t=function(t,n,a){return e.includes(t,n,a)};return t.$stateful=!0,t}var j=t.isDefined,B=t.isFunction,N=t.isString,F=t.isObject,U=t.isArray,H=t.forEach,V=t.extend,W=t.copy,G=t.toJson;t.module("ui.router.util",["ng"]),t.module("ui.router.router",["ui.router.util"]),t.module("ui.router.state",["ui.router.router","ui.router.util"]),t.module("ui.router",["ui.router.state"]),t.module("ui.router.compat",["ui.router"]),v.$inject=["$q","$injector"],t.module("ui.router.util").service("$resolve",v),g.$inject=["$http","$templateCache","$injector"],t.module("ui.router.util").service("$templateFactory",g);var Y;b.prototype.concat=function(e,t){var n={caseInsensitive:Y.caseInsensitive(),strict:Y.strictMode(),squash:Y.defaultSquashPolicy()};return new b(this.sourcePath+e+this.sourceSearch,V(n,t),this)},b.prototype.toString=function(){return this.source},b.prototype.exec=function(e,t){var n=this.regexp.exec(e);if(!n)return null;t=t||{};var a,r,o,s=this.parameters(),i=s.length,u=this.segments.length-1,c={};if(u!==n.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");var l,d;for(a=0;a=":e}};return a.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,a,r){return n.debug("AbsenceTypeAPI"),a.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(a,o,s){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),s=e.assign({},s,{absence_type_id:a,date:t(o).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",s).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,a,r,o,s){return t.debug("AbsenceType"),a.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return s.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return o.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return o.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/apis/work-pattern.api",["common/lodash","leave-absences/shared/modules/apis","common/services/api"],function(e,t){"use strict";t.factory("WorkPatternAPI",["$log","api",function(t,n){function a(t){var n=e.clone(t);return n.workPattern=n["api.WorkPattern.get"].values[0],delete n["api.WorkPattern.get"],n}return t.debug("WorkPatternAPI"),n.extend({assignWorkPattern:function(t,n,a,r,o,s){return this.sendPOST("ContactWorkPattern","create",e.assign({},s,{contact_id:t,pattern_id:n,effective_date:a,effective_end_date:r,change_reason:o})).then(function(e){return e.values})},get:function(e){return this.sendGET("WorkPattern","get",e||{}).then(function(e){return e.values})},getCalendar:function(n,a,r,o){return t.debug("WorkPatternAPI.getCalendar",n,a,r,o),this.sendGET("WorkPattern","getcalendar",e.assign({},o,{contact_id:e.isArray(n)?{IN:n}:n,start_date:a,end_date:r}))},unassignWorkPattern:function(e){return this.sendPOST("ContactWorkPattern","delete",{id:e})},workPatternsOf:function(t,n,r){return this.sendGET("ContactWorkPattern","get",e.assign({},n,{contact_id:t,"api.WorkPattern.get":{id:"$value.pattern_id"}}),r).then(function(e){return e=e.values,e.map(a)})}})}])}),define("leave-absences/shared/instances/calendar.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance"],function(e,t,n){"use strict";n.factory("CalendarInstance",["$log","$q","ModelInstance","shared-settings","OptionGroup",function(n,a,r,o,s){function i(t,n){return c().then(function(a){var r=this.days[u(t).valueOf()];return!!r&&e.find(a,function(e){return e.name===n}).value===r.type}.bind(this))}function u(e){return t(e,o.serverDateFormat).clone()}function c(){return l=l||s.valuesOf("hrleaveandabsences_work_day_type")}var l;return r.extend({defaultCustomData:function(){return{days:[]}},isNonWorkingDay:function(e){return i.call(this,e,"non_working_day")},isWeekend:function(e){return i.call(this,e,"weekend")},isWorkingDay:function(e){return i.call(this,e,"working_day")},transformAttributes:function(t){var n={};return t.calendar.forEach(function(e){n[u(e.date).valueOf()]=e}),e(t).omit("calendar").assign({days:n}).value()}})}])}),define("leave-absences/shared/models/calendar.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/work-pattern.api","leave-absences/shared/instances/calendar.instance"],function(e,t){"use strict";t.factory("Calendar",["$log","Model","WorkPatternAPI","CalendarInstance",function(t,n,a,r){return t.debug("Calendar"),n.extend({get:function(n,o,s,i){return t.debug("Calendar.get"),a.getCalendar(n,o,s,i).then(function(t){var a=t.values.map(function(e){return r.init(e)});return e.isArray(n)?a:a[0]})}})}])}),define("leave-absences/shared/apis/entitlement.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("EntitlementAPI",["$log","api",function(e,n){function a(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getremainder"].values;return a.length&&(n.remainder=a[0].remainder),delete n["api.LeavePeriodEntitlement.getremainder"],n}function r(e){var n=t.clone(e),a=n["api.LeavePeriodEntitlement.getentitlement"].values[0].entitlement;return n.value=a,delete n["api.LeavePeriodEntitlement.getentitlement"],n}return e.debug("EntitlementAPI"),n.extend({all:function(t,n){return e.debug("EntitlementAPI.all"),t["api.LeavePeriodEntitlement.getentitlement"]={entitlement_id:"$value.id"},n&&(t["api.LeavePeriodEntitlement.getremainder"]={entitlement_id:"$value.id",include_future:!0}),this.sendGET("LeavePeriodEntitlement","get",t,!1).then(function(e){return e.values}).then(function(e){return e=e.map(r),n&&(e=e.map(a)),e})},breakdown:function(t){return e.debug("EntitlementAPI.breakdown"),this.sendGET("LeavePeriodEntitlement","getbreakdown",t).then(function(e){return e.values})},getLeaveBalances:function(t,n,a,r,o){return e.debug("EntitlementAPI.getLeaveBalances"),this.getAll("LeavePeriodEntitlement",t,n,a,r,"getLeaveBalances",o)}})}])}),define("leave-absences/shared/apis/entitlement-log.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("EntitlementLogAPI",["$log","api",function(e,t){return e.debug("EntitlementLogAPI"),t.extend({all:function(t){return e.debug("EntitlementLogAPI.all"),this.sendGET("LeavePeriodEntitlementLog","get",t,!1).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/entitlement.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("EntitlementInstance",["$log","ModelInstance","EntitlementAPI",function(e,t,n){return e.debug("EntitlementInstance"),t.extend({defaultCustomData:function(){return{remainder:{current:0,future:0},breakdown:[]}},getBreakdown:function(){return n.breakdown({entitlement_id:this.id}).then(function(e){this.breakdown=e}.bind(this))}})}])}),define("leave-absences/shared/models/entitlement.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/entitlement.api","leave-absences/shared/apis/entitlement-log.api","leave-absences/shared/instances/entitlement.instance"],function(e,t){"use strict";t.factory("Entitlement",["$log","Model","EntitlementAPI","EntitlementInstance","EntitlementLogAPI",function(t,n,a,r,o){return t.debug("Entitlement"),n.extend({all:function(e,t){return a.all(this.processFilters(e),t).then(function(e){return e.map(function(e){return r.init(e,!0)})})},breakdown:function(t,n){return a.breakdown(t).then(function(t){return n?(n.map(function(n){var a=e.find(t,function(e){return e.id===n.id});return a&&(n.breakdown=a.breakdown),n}),n):t.map(function(e){return r.init(e,!0)})})},logs:function(t){return t=e.cloneDeep(t||{}),t.contact_id&&(t["entitlement_id.contact_id"]=t.contact_id,delete t.contact_id),t.period_id&&(t["entitlement_id.period_id"]=t.period_id,delete t.period_id),t.return=t.return||[],t.return.push("entitlement_id","entitlement_id.type_id","editor_id","entitlement_amount","comment","created_date"),o.all(t)}})}])}),define("leave-absences/shared/apis/leave-request.api",["leave-absences/shared/modules/apis","common/lodash","common/services/api"],function(e,t){"use strict";e.factory("LeaveRequestAPI",["$log","api","$q","shared-settings",function(e,n,a){return e.debug("LeaveRequestAPI"),n.extend({all:function(t,n,r,o,s){e.debug("LeaveRequestAPI.all");var i=a.defer();return t&&t.contact_id&&t.contact_id.IN&&0===t.contact_id.IN.length?i.resolve({list:[],total:0,allIds:[]}):i.resolve(this.getAll("LeaveRequest",t,n,r,o,"getFull",s)),i.promise},balanceChangeByAbsenceType:function(t,n,r,o){e.debug("LeaveRequestAPI.balanceChangeByAbsenceType");var s=a.defer();t&&n||s.reject("contact_id and period_id are mandatory");var i={contact_id:t,period_id:n,statuses:r?{IN:r}:null,public_holiday:o||!1};return this.sendGET("LeaveRequest","getbalancechangebyabsencetype",i,!1).then(function(e){s.resolve(e.values)}),s.promise},calculateBalanceChange:function(n){return e.debug("LeaveRequestAPI.calculateBalanceChange",n),this.sendPOST("LeaveRequest","calculatebalancechange",n).then(function(e){return e.values.breakdown=t.values(e.values.breakdown),e.values})},getBalanceChangeBreakdown:function(e){return this.sendGET("LeaveRequest","getBreakdown",{leave_request_id:e},!1)},getWorkDayForDate:function(e,t){return this.sendGET("LeaveRequest","getWorkDayForDate",{leave_date:e,contact_id:t.toString()},!1)},create:function(t){return e.debug("LeaveRequestAPI.create",t),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})},delete:function(e){return this.sendPOST("LeaveRequest","delete",{id:e})},deleteAttachment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,attachment_id:n}),this.sendPOST("LeaveRequest","deleteattachment",a).then(function(e){return e.values})},deleteComment:function(e,n){return n=t.assign({},n,{comment_id:e}),this.sendPOST("LeaveRequest","deletecomment",n).then(function(e){return e.values})},find:function(t){return e.debug("LeaveRequestAPI.find"),this.sendGET("LeaveRequest","getFull",{id:t}).then(function(e){return 0===e.values.length?a.reject("LeaveRequest not found with this ID"):e.values[0]})},getAttachments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getattachments",n,!1).then(function(e){return e.values})},getComments:function(e,n){return n=t.assign({},n,{leave_request_id:e}),this.sendGET("LeaveRequest","getcomment",n,!1).then(function(e){return e.values})},isManagedBy:function(t,n){return e.debug("LeaveRequestAPI.isManagedBy"),this.sendPOST("LeaveRequest","isManagedBy",{leave_request_id:t,contact_id:n}).then(function(e){return e.values})},isValid:function(n){e.debug("LeaveRequestAPI.isValid",n);var r=a.defer();return this.sendPOST("LeaveRequest","isValid",n).then(function(e){e.count>0?r.reject(t(e.values).map().flatten().value()):r.resolve(e.values)}),r.promise},saveComment:function(e,n,a){return a=t.assign({},a,{leave_request_id:e,text:n.text,contact_id:n.contact_id}),this.sendPOST("LeaveRequest","addcomment",a).then(function(e){return e.values})},update:function(t){e.debug("LeaveRequestAPI.update",t);var n=a.defer();return t.id||n.reject("id is mandatory field"),this.sendPOST("LeaveRequest","create",t).then(function(e){return e.values[0]})}})}])}),define("leave-absences/shared/instances/leave-request.instance",["common/lodash","common/moment","leave-absences/shared/modules/models-instances","common/models/option-group","common/models/instances/instance","leave-absences/shared/models/absence-type.model"],function(e,t,n){"use strict";n.factory("LeaveRequestInstance",["$q","checkPermissions","OptionGroup","shared-settings","ModelInstance","LeaveRequestAPI","AbsenceType",function(n,a,r,o,s,i,u){function c(e){return p(e).then(function(e){var t=this.status_id;return this.status_id=e.value,this.update().catch(function(e){return this.status_id=t,n.reject(e)}.bind(this))}.bind(this))}function l(){return u.all({id:this.type_id}).then(u.loadCalculationUnits).then(function(e){return n.all({calculatedBalanceChange:this.calculateBalanceChange(e[0].calculation_unit_name),currentBalanceChange:this.getBalanceChangeBreakdown()})}.bind(this)).then(function(e){return+e.currentBalanceChange.amount!=+e.calculatedBalanceChange.amount})}function d(e){return p(e).then(function(e){return this.status_id===e.value}.bind(this))}function f(){var t=[];return e.forEach(this.files,function(e){e.toBeDeleted&&t.push(i.deleteAttachment(this.id,e.attachment_id))}.bind(this)),n.all(t)}function m(e){return t.duration(e.time_to).subtract(t.duration(e.time_from)).asHours()}function p(t){return r.valuesOf("hrleaveandabsences_leave_request_status").then(function(n){return e.find(n,function(e){return e.name===t})})}function h(t){var a=e.cloneDeep(t),r=a.breakdown.length>1,o=e.first(e.values(a.breakdown)),s=e.last(e.values(a.breakdown));return n.all([this.getWorkDayForDate(o.date),r&&this.getWorkDayForDate(s.date)]).then(function(t){return o.amount=t[0].time_from?Math.min(this.from_date_amount,m(t[0])):0,r&&(s.amount=t[1].time_from?Math.min(this.to_date_amount,m(t[1])):0),a.amount=-1*e.reduce(a.breakdown,function(e,t){return e+t.amount},0),a}.bind(this))}function v(){var e=this.id,t=[];return t.push(n.sequence(this.comments.filter(function(e){return!e.comment_id}).map(function(t){return function(){return i.saveComment(e,t)}}))),t=t.concat(this.comments.filter(function(e){return e.comment_id&&e.toBeDeleted}).map(function(e){return i.deleteComment(e.comment_id)})),n.all(t)}return s.extend({defaultCustomData:function(){return{comments:[],files:[],request_type:"leave"}},calculateBalanceChange:function(t){var n=["contact_id","from_date","to_date","type_id","from_date_type","to_date_type"];return"hours"===t&&e.pull(n,"from_date_type","to_date_type"),i.calculateBalanceChange(e.pick(this,n)).then(function(e){return"hours"===t?h.call(this,e):e}.bind(this))},cancel:function(){return c.call(this,o.statusNames.cancelled)},approve:function(){return c.call(this,o.statusNames.approved)},checkIfBalanceChangeNeedsRecalculation:function(){return l.call(this)},reject:function(){return c.call(this,o.statusNames.rejected)},sendBack:function(){return c.call(this,o.statusNames.moreInformationRequired)},update:function(){return i.update(this.toAPI()).then(function(){return n.all([v.call(this),f.call(this)])}.bind(this))},create:function(){return i.create(this.toAPI()).then(function(e){return this.id=e.id,n.all([v.call(this)])}.bind(this))},deleteAttachment:function(e){e.toBeDeleted||(e.toBeDeleted=!0)},deleteComment:function(t){if(t.comment_id)return void(t.toBeDeleted=!0);this.comments=e.reject(this.comments,function(e){return t.created_at===e.created_at&&t.text===e.text})},delete:function(){return i.delete(this.id)},getBalanceChangeBreakdown:function(){return i.getBalanceChangeBreakdown(this.id).then(function(t){return{amount:e.reduce(t.values,function(e,t){return e+parseFloat(t.amount)},0),breakdown:t.values.map(function(e){return{amount:Math.abs(parseFloat(e.amount)),date:e.date,type:{id:e.id,value:e.type,label:e.label}}})}})},getWorkDayForDate:function(e){return i.getWorkDayForDate(e,this.contact_id).then(function(e){return e.values}).catch(function(e){return n.reject(e)})},isValid:function(){return i.isValid(this.toAPI())},isApproved:function(){return d.call(this,o.statusNames.approved)},isAwaitingApproval:function(){return d.call(this,o.statusNames.awaitingApproval)},isCancelled:function(){return d.call(this,o.statusNames.cancelled)},isRejected:function(){return d.call(this,o.statusNames.rejected)},isSentBack:function(){return d.call(this,o.statusNames.moreInformationRequired)},loadComments:function(){return this.id?i.getComments(this.id).then(function(e){this.comments=e}.bind(this)):n.resolve()},roleOf:function(e){return this.contact_id===e?n.resolve("owner"):a(o.permissions.admin.administer).then(function(t){return t?"admin":i.isManagedBy(this.id,e).then(function(e){return e?"manager":"none"})}.bind(this))},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])},loadAttachments:function(){return this.id?i.getAttachments(this.id).then(function(e){this.files=e}.bind(this)):n.resolve()}})}])}),define("leave-absences/shared/models/leave-request.model",["leave-absences/shared/modules/models","common/models/model","leave-absences/shared/apis/leave-request.api","leave-absences/shared/instances/leave-request.instance"],function(e){"use strict";e.factory("LeaveRequest",["$log","Model","LeaveRequestAPI","LeaveRequestInstance",function(e,t,n,a){return e.debug("LeaveRequest"),t.extend({all:function(e,t,r,o,s){return n.all(this.processFilters(e),t,r,o,s).then(function(e){return e.list=e.list.map(function(e){return a.init(e,!0)}),e})},balanceChangeByAbsenceType:function(e,t,a,r){return n.balanceChangeByAbsenceType(e,t,a,r)},find:function(e){return n.find(e).then(function(e){return a.init(e,!0)})}})}])}),define("leave-absences/shared/apis/public-holiday.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("PublicHolidayAPI",["$log","api",function(e,t){return e.debug("PublicHolidayAPI"),t.extend({all:function(t){return e.debug("PublicHolidayAPI"),this.sendGET("PublicHoliday","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/instances/public-holiday.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("PublicHolidayInstance",["$log","ModelInstance",function(e,t){return e.debug("PublicHolidayInstance"),t.extend({})}])}),define("leave-absences/shared/models/public-holiday.model",["common/moment","leave-absences/shared/modules/models","common/models/model","common/services/hr-settings","leave-absences/shared/apis/public-holiday.api","leave-absences/shared/instances/public-holiday.instance"],function(e,t){"use strict";t.factory("PublicHoliday",["$log","Model","PublicHolidayAPI","PublicHolidayInstance","shared-settings",function(t,n,a,r,o){return t.debug("PublicHoliday"),n.extend({all:function(e){return t.debug("PublicHoliday.all",e),a.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},isPublicHoliday:function(n){t.debug("PublicHoliday.isPublicHoliday",n);var r=e(n).format(o.serverDateFormat),s={date:r};return a.all(s).then(function(e){return!!e.length})}})}])}),define("leave-absences/shared/modules/components",["common/angular","common/modules/directives","common/modules/models","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/models"],function(e){return e.module("leave-absences.components",["common.directives","common.models","leave-absences.settings","leave-absences.models"])}),define("leave-absences/shared/modules/controllers",["common/angular","common/angularBootstrap","leave-absences/shared/modules/models","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){return e.module("leave-absences.controllers",["ui.select","leave-absences.models","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers","common/models/contract","common/services/notification.service"],function(e,t,n){function a(n,a,r,o,s,i){function u(){return d().then(function(n){var a=n.filter(function(e){var n=e.info.details;return t(n.period_start_date).isSameOrBefore(v.selectedPeriod.end_date)&&(t(n.period_end_date).isSameOrAfter(v.selectedPeriod.start_date)||!n.period_end_date)});return e.uniq(a.map(function(e){return e.contact_id}))})}function c(){return{loadContacts:function(){var e=v.filters.userSettings.assignedTo.type;return f(e).then(function(e){v.lookupContacts=e}).then(function(){return"me"!==e?u():a.resolve(null)}).then(function(e){return v.contactIdsToReduceTo=e,l()}).then(function(e){return e})}}}function l(){return r.all(m(),null,"display_name").then(function(e){return e.list})}function d(){return h?a.resolve(h):s.all()}function f(e){return"me"===e?r.leaveManagees(v.contactId):"unassigned"===e?r.leaveManagees(void 0,{unassigned:!0}):r.all().then(function(e){return e.list})}function m(){return{department:v.filters.userSettings.department?v.filters.userSettings.department.value:null,level_type:v.filters.userSettings.level_type?v.filters.userSettings.level_type.value:null,location:v.filters.userSettings.location?v.filters.userSettings.location.value:null,region:v.filters.userSettings.region?v.filters.userSettings.region.value:null,id:{IN:v.filters.userSettings.contact?[v.filters.userSettings.contact.id]:v.lookupContacts.map(function(e){return e.id})}}}function p(e){i.info("",[" When All filter is selected, all staff members with contracts which are active in the selected absence period are displayed.
","People I approve filter displays only staff members who you approve leave for.
","People without approver filter displays all staff members with contracts which are active in the selected absence period and who do not have any leave approver assigned.
"].join(""))}n.debug("LeaveCalendarAdminController");var h,v;return{init:function(e){return v=e,v.showContactDetailsLink=!0,v.showContactName=!0,v.showFilters=!0,v.filtersByAssignee=[{type:"me",label:"People I approve"},{type:"unassigned",label:"People without approver"},{type:"all",label:"All"}],v.filters.userSettings.assignedTo=v.filtersByAssignee[0],v.showAdminFilteringHint=p,c()}}}n.controller("LeaveCalendarAdminController",["$log","$q","Contact","ContactInstance","Contract","notificationService",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t,n){function a(){return{loadContacts:function(){return n.init({id:s.contactId}).leaveManagees().then(function(e){s.lookupContacts=e}).then(r)}}}function r(){return t.all(o(),null,"display_name").then(function(e){return e.list})}function o(){return{department:s.filters.userSettings.department?s.filters.userSettings.department.value:null,level_type:s.filters.userSettings.level_type?s.filters.userSettings.level_type.value:null,location:s.filters.userSettings.location?s.filters.userSettings.location.value:null,region:s.filters.userSettings.region?s.filters.userSettings.region.value:null,id:{IN:s.filters.userSettings.contact?[s.filters.userSettings.contact.id]:s.lookupContacts.map(function(e){return e.id})}}}e.debug("LeaveCalendarManagerController");var s;return{init:function(e){return s=e,s.showContactName=!0,s.showFilters=!0,a()}}}n.controller("LeaveCalendarManagerController",["$log","Contact","ContactInstance",a])}),define("leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller",["common/lodash","common/moment","leave-absences/shared/modules/controllers"],function(e,t,n){function a(e,t){function n(){return{loadContacts:function(){return t.all({id:{in:[a.contactId]}}).then(function(e){return e.list})}}}e.debug("LeaveCalendarStaffController");var a;return{init:function(e){return a=e,a.filters.userSettings.contacts_with_leaves=!1,n()}}}n.controller("LeaveCalendarStaffController",["$log","Contact",a])}),define("leave-absences/shared/components/leave-calendar.component",["common/angular","common/lodash","common/moment","leave-absences/shared/modules/components","leave-absences/shared/controllers/sub-controllers/leave-calendar-admin.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-manager.controller","leave-absences/shared/controllers/sub-controllers/leave-calendar-staff.controller"],function(e,t,n,a){function r(a,r,o,s,i,u,c,l,d,f){function m(){for(var e=[],t=n(L.selectedPeriod.start_date).clone().startOf("month"),a=n(L.selectedPeriod.end_date).clone().endOf("month");t.isBefore(a);)e.push(P(t)),t.add(1,"month");L.months=e}function p(){s.$new().$watch(function(){return L.selectedMonths},function(t,n){null===n||e.equals(t,n)||R()})}function h(e){L.injectMonths=!0,I("injected").then(function(){R(e)}).then(function(){L.loading.calendar=!1})}function v(){x=a("LeaveCalendar"+t.capitalize(O)+"Controller").init(L)}function g(e){return e.current?"Current Period ("+e.title+")":e.title}function b(){return u.all().then(function(e){L.absencePeriods=t.sortBy(e,"start_date"),L.selectedPeriod=t.find(L.absencePeriods,function(e){return!!e.current})}).then(m).then(S)}function y(){return c.all().then(c.loadCalculationUnits)}function _(){return d.valuesOf(["hrleaveandabsences_absence_type_calculation_unit","hrleaveandabsences_leave_request_day_type","hrleaveandabsences_leave_request_status","hrleaveandabsences_toil_amounts"])}function q(){return x.loadContacts().then(function(e){L.contacts=e})}function $(){return d.valuesOf(["hrjc_region","hrjc_location","hrjc_level_type","hrjc_department"]).then(function(e){L.filters.optionValues.regions=e.hrjc_region,L.filters.optionValues.locations=e.hrjc_location,L.filters.optionValues.levelTypes=e.hrjc_level_type,L.filters.optionValues.departments=e.hrjc_department})}function w(){return l.all()}function C(){return r.all([y(),w(),_()]).then(function(e){L.supportData.absenceTypes=e[0],L.supportData.publicHolidays=e[1],L.supportData.calculationUnits=e[2].hrleaveandabsences_absence_type_calculation_unit,L.supportData.dayTypes=e[2].hrleaveandabsences_leave_request_day_type,L.supportData.leaveRequestStatuses=e[2].hrleaveandabsences_leave_request_status,L.supportData.toilAmounts=t.indexBy(e[2].hrleaveandabsences_toil_amounts,"value")})}function A(){var e=r.resolve();return L.injectMonths&&(e=I("destroyed"),L.injectMonths=!1),e}function P(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),shortName:e.format("MMM")}}function D(e){
e=t.includes(["contacts","period"],e)?e:"period",r.resolve().then(function(){L.loading.calendar=!0}).then(A).then("period"===e?m:t.noop).then("contacts"===e?q:t.noop).then(function(){h("contacts"===e)})}function R(e){var n=L.selectedMonths.length?L.months.filter(function(e){return t.includes(L.selectedMonths,e.index)}):L.months;s.$emit("LeaveCalendar::showMonths",n,!!e)}function S(){L.selectedMonths=[n().month()]}function T(){return L.roleOverride?r.resolve().then(function(){O=L.roleOverride}):r.all([f(i.permissions.admin.administer),f(i.permissions.ssp.manage)]).then(function(e){O=e[0]?"admin":e[1]?"manager":"staff"})}function I(e){return r(function(n){var a=0,r=s.$on("LeaveCalendar::month"+t.capitalize(e),function(){++a===L.months.length&&(r(),n())})})}o.debug("Component: leave-calendar");var x,O,L=this;L.absencePeriods=[],L.contacts=[],L.contactIdsToReduceTo=null,L.injectMonths=!1,L.months=[],L.selectedMonths=null,L.selectedPeriod=null,L.showContactName=!1,L.showFilters=!1,L.supportData={},L.loading={calendar:!0,page:!0},L.filters={optionValues:{},userSettings:{contact:null,contacts_with_leaves:!0,department:null,level_type:null,location:null,region:null}},L.labelPeriod=g,L.refresh=D,function(){T().then(p).then(v).then(A).then(b).then(function(){return r.all([q(),C()])}).then(function(){return L.showFilters?$():t.noop}).then(function(){h()}).then(function(){L.loading.page=!1})}()}a.component("leaveCalendar",{bindings:{contactId:"<",roleOverride:"@?"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar.html"}],controllerAs:"calendar",controller:["$controller","$q","$log","$rootScope","shared-settings","AbsencePeriod","AbsenceType","PublicHoliday","OptionGroup","checkPermissions",r]})}),define("leave-absences/shared/components/leave-calendar-day.component",["common/lodash","common/moment","leave-absences/shared/modules/components"],function(e,t,n){function a(n,a,r){"use strict";function o(){_.calculationUnit=s(_.supportData.calculationUnits,"value",g.calculation_unit)}function s(t,n,a){return e.find(t,function(e){return+e[n]==+a})}function i(){var e,n;return n=t(_.contactData.leaveRequest.from_date).isSame(_.contactData.leaveRequest.to_date,"day"),e=n?"single-date":"multiple-dates","type-"+_.calculationUnit.name+"-on-"+e+"-tooltip"}function u(){g=s(_.supportData.absenceTypes,"id",_.contactData.leaveRequest.type_id),_.contactData.leaveRequest["type_id.title"]=g.title}function c(){"days"===_.calculationUnit.name&&(b=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.from_date_type),y=s(_.supportData.dayTypes,"value",_.contactData.leaveRequest.to_date_type),_.contactData.leaveRequest["from_date_type.label"]=b.label,_.contactData.leaveRequest["to_date_type.label"]=y.label)}function l(e,t,n,a,o){e.stopPropagation(),r.openModal(t,n,a,o)}function d(){_.dates.from=new Date(_.contactData.leaveRequest.from_date),_.dates.to=new Date(_.contactData.leaveRequest.to_date)}function f(){_.contactData.isAccruedTOIL?_.label="AT":"days"===_.calculationUnit.name?m():p()}function m(){_.label=_.contactData.isAM?"AM":_.contactData.isPM?"PM":""}function p(){var e=t(_.contactData.leaveRequest.from_date).isSame(_.date,"day"),n=t(_.contactData.leaveRequest.to_date).isSame(_.date,"day");_.label=e?t(_.contactData.leaveRequest.from_date).format("HH:mm"):n?t(_.contactData.leaveRequest.to_date).format("HH:mm"):""}function h(){_.tooltipTemplate=_.contactData.isAccruedTOIL?"accrued-toil-tooltip":i()}function v(){a.$watch("day.contactData.leaveRequest",function(){_.contactData&&_.contactData.leaveRequest&&(u(),o(),c(),f(),d(),h())})}n.debug("Component: leave-calendar-day");var g,b,y,_=this;_.calculationUnit="",_.dates={from:null,to:null},_.label="",_.tooltipTemplate=null,_.openLeavePopup=l,function(){v()}()}n.component("leaveCalendarDay",{bindings:{contactData:"<",date:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-day.html"}],controllerAs:"day",controller:a}),a.$inject=["$log","$scope","LeavePopup"]}),define("leave-absences/shared/components/leave-calendar-legend.component",["leave-absences/shared/modules/components"],function(e){function t(e){function t(e){return{backgroundColor:e.color,borderColor:e.color}}e.debug("Component: leave-calendar-legend");var n=this;n.legendCollapsed=!0,n.getAbsenceTypeStyle=t}e.component("leaveCalendarLegend",{bindings:{absenceTypes:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-legend.html"}],controllerAs:"legend",controller:["$log",t]})}),define("leave-absences/shared/components/leave-calendar-month.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(e){y([e]),B(e)}function l(e){return{index:e.month(),year:e.year(),name:e.format("MMMM"),loading:!0,days:d(e)}}function d(n){var a=t(),r=n.clone().startOf("month");return e.map(e.times(n.daysInMonth()),function(){var e={date:r.format("YYYY-MM-DD"),name:r.format("ddd"),index:r.format("D"),current:a.isSame(r,"day"),enabled:r.isSameOrAfter(V.period.start_date)&&r.isSameOrBefore(V.period.end_date),contactsData:{}};return r.add(1,"day"),e})}function f(e){return U[e]}function m(){return V.showOnlyWithLeaveRequests?V.contacts.filter(function(e){return Object.keys(H[e.id]||{}).length}):V.contacts}function p(e){return t(e,u.serverDateFormat)}function h(e){x(e),B(e)}function v(e){return CRM.url("civicrm/contact/view",{cid:e})}function g(){return V.contactIdsToReduceTo&&(V.contacts=V.contacts.filter(function(t){return e.includes(V.contactIdsToReduceTo,t.contact_id)||e.find(H,function(e){return e.contact_id===t.contact_id})})),a.resolve()}function b(){V.supportData.dayTypes=e.indexBy(V.supportData.dayTypes,"name"),V.supportData.leaveRequestStatuses=e.indexBy(V.supportData.leaveRequestStatuses,"value"),V.supportData.publicHolidays=e.transform(V.supportData.publicHolidays,function(e,t){e[p(t.date).valueOf()]=t},{})}function y(e){return e.forEach(function(e){var t=A(e);H[e.contact_id]=H[e.contact_id]||{},t.forEach(function(t){H[e.contact_id][t.date]=e})}),a.resolve()}function _(){F.push(r.$on("LeaveCalendar::showMonths",M)),F.push(i.subscribe("LeaveRequest::new",c)),F.push(i.subscribe("LeaveRequest::edit",j)),F.push(i.subscribe("LeaveRequest::updatedByManager",j)),F.push(i.subscribe("LeaveRequest::delete",h)),F.push(i.subscribe("LeaveRequest::statusUpdate",function(e){"delete"===e.status?h(e.leaveRequest):j(e.leaveRequest)}))}function q(e,n,a){var r=V.supportData.dayTypes[e];return t(a).isSame(n.from_date,"day")?r.value===n.from_date_type:t(a).isSame(n.to_date,"day")?r.value===n.to_date_type:void 0}function $(e,t){return e.request_type===t}function w(e){return!!V.supportData.publicHolidays[p(e).valueOf()]}function C(t){var n=V.supportData.leaveRequestStatuses[t.status_id].name;return e.contains([u.statusNames.awaitingApproval,u.statusNames.moreInformationRequired],n)}function A(n){for(var a=[],r=t(n.from_date).clone(),o=t(n.to_date);r.isSameOrBefore(o);)r.month()===V.month.index&&r.year()===V.month.year&&a.push(e.find(V.month.days,function(e){return e.date===r.format("YYYY-MM-DD")})),r.add(1,"day");return a}function P(t){return e.find(H[t.contact_id],function(e){return t.id===e.id})}function D(t){var n=e.find(V.supportData.leaveRequestStatuses,function(e){return e.name===t});return n?n.value:null}function R(){return[D(u.statusNames.approved),D(u.statusNames.adminApproved),D(u.statusNames.awaitingApproval),D(u.statusNames.moreInformationRequired)]}function S(){return V.month.loading=!0,a.all([I(),T()]).then(g).then(k).then(function(){N=!0}).then(function(){V.month.loading=!1})}function T(){return s.all({from_date:{to:V.month.days[V.month.days.length-1].date},to_date:{from:V.month.days[0].date},status_id:{IN:R()},contact_id:{IN:V.contacts.map(function(e){return e.id})},type_id:{IN:e.pluck(V.supportData.absenceTypes,"id")}},null,null,null,!1).then(function(e){return y(e.list)})}function I(){var t=V.month.days[0].date,n=V.month.days[V.month.days.length-1].date;return o.get(V.contacts.map(function(e){return e.id}),t,n).then(function(t){U=e.indexBy(t,"contact_id")})}function x(t){H[t.contact_id]=e.omit(H[t.contact_id],function(e){return e.id===t.id})}function O(){r.$emit("LeaveCalendar::monthDestroyed"),F.map(function(e){e.remove?e.remove():e()})}function L(t,n,r){var o,s;return t.contactsData[n]=t.contactsData[n]||{},s=f(n),o=!0===r?a.resolve():a.all([s.isWeekend(p(t.date)),s.isNonWorkingDay(p(t.date))]).then(function(a){e.assign(t.contactsData[n],{isWeekend:a[0],isNonWorkingDay:a[1],isPublicHoliday:w(t.date)})}),o.then(function(){return H[n]?H[n][t.date]:null}).then(function(a){e.assign(t.contactsData[n],{leaveRequest:a||null,styles:a?E(a):null,isAccruedTOIL:a?$(a,"toil"):null,isRequested:a?C(a):null,isAM:a?q("half_day_am",a,t.date):null,isPM:a?q("half_day_pm",a,t.date):null})})}function k(){return a.all(V.month.days.map(function(e){return a.all(V.contacts.map(function(t){return L(e,t.id)}))}))}function M(t,n,a){!e.find(n,function(e){return e.index===V.month.index})?V.visible=!1:(V.currentPage=0,V.visible=!0,(a||!N)&&S())}function E(t){var n=e.find(V.supportData.absenceTypes,function(e){return e.id===t.type_id});return t.balance_change>0?{borderColor:n.color}:{borderColor:n.color,backgroundColor:n.color}}function j(e){var t=P(e);t&&(h(t),-1!==R().indexOf(e.status_id)&&c(e))}function B(e){return a.all(A(e).map(function(t){return L(t,e.contact_id,!0)}))}n.debug("Component: leave-calendar-month");var N=!1,F=[],U={},H={},V=this;V.currentPage=0,V.pageSize=20,V.visible=!1,V.showContactName=!!V.showContactName,V.showOnlyWithLeaveRequests=!!V.showOnlyWithLeaveRequests,V.$onDestroy=O,V.contactsList=m,V.getContactUrl=v,function(){var e=t().month(V.month.index).year(V.month.year);b(),_(),V.month=l(e),r.$emit("LeaveCalendar::monthInjected")}()}n.component("leaveCalendarMonth",{bindings:{contacts:"<",contactIdsToReduceTo:"<",month:"<",period:"<",showContactName:"<",showContactDetailsLink:"<",showOnlyWithLeaveRequests:"<",supportData:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-calendar-month.html"}],controllerAs:"month",controller:["$log","$q","$rootScope","Calendar","LeaveRequest","pubSub","shared-settings",a]})}),define("leave-absences/shared/modules/services",["common/angular","common/modules/services"],function(e){"use strict";return e.module("leave-absences.services",["common.services"])}),define("leave-absences/shared/services/leave-request.service",["common/lodash","leave-absences/shared/modules/services"],function(e,t){"use strict";function n(t,n,a){function r(){var t=n.defer();return a.open(e.defaults(o(),{onConfirm:function(){t.resolve(!0)}})),t.promise}function o(){return{title:"Recalculate Balance Change?",copyCancel:"Cancel",copyConfirm:"Yes",classConfirm:"btn-warning",msg:"The leave balance change has updated since this leave request was created. Do you want to recalculate the balance change?"}}return t.debug("LeaveRequest"),{getBalanceChangeRecalculationPromptOptions:o,promptBalanceChangeRecalculation:r}}t.factory("LeaveRequestService",n),n.$inject=["$log","$q","dialog"]}),define("leave-absences/shared/components/leave-request-actions.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/services/notification.service","common/services/pub-sub","leave-absences/shared/services/leave-request.service"],function(e,t,n){function a(n,a,r,o,s,i,u,c){function l(t){_=q.leaveRequest.status_id,e.includes(["cancel","reject","delete"],t)||"toil"===q.leaveRequest.request_type?r.open(h(t)):m(t)}function d(){return"admin"===q.role&&"public_holiday"===q.leaveRequest.request_type}function f(n){var a=q.absenceTypes[q.leaveRequest.type_id].allow_request_cancelation;return"admin"===q.role||!!e.includes([$.awaitingApproval,$.moreInformationRequired],n)&&("manager"===q.role||("3"===a?t().isBefore(q.leaveRequest.from_date):"2"===a))}function m(t){r.open({title:"Verifying balance...",loading:!0,optionsPromise:function(){return q.leaveRequest.checkIfBalanceChangeNeedsRecalculation().then(function(n){return n?e.assign(s.getBalanceChangeRecalculationPromptOptions(),{onCloseAfterConfirm:function(){o.openModal(q.leaveRequest,q.leaveRequest.request_type,q.leaveRequest.contact_id,"my-leave"===a.section,!0)}}):h(t)})}})}function p(){e.isArray(q.leaveRequestStatuses)&&(q.leaveRequestStatuses=e.indexBy(q.leaveRequestStatuses,"value")),e.isArray(q.absenceTypes)&&(q.absenceTypes=e.indexBy(q.absenceTypes,"id"))}function h(e){var t=w[e].dialog;return{title:"Confirm "+t.title+"?",copyCancel:"Cancel",copyConfirm:t.btnLabel,classConfirm:"btn-"+t.btnClass,msg:t.msg,onConfirm:function(){return q.leaveRequest[e]().then(function(){g(e)}).catch(function(e){c.error("Error:",e)})}}}function v(e,t,n,a,r){e.stopPropagation(),o.openModal(t,n,a,r)}function g(t){var n=e.find(q.leaveRequestStatuses,function(e){return e.name===u.statusNames.awaitingApproval}).value;_===n&&i.publish("ManagerBadge:: Update Count"),i.publish("LeaveRequest::statusUpdate",{status:t,leaveRequest:q.leaveRequest})}function b(){var t=q.leaveRequestStatuses[q.leaveRequest.status_id].name,n=e.compact(e.map(w,function(n,a){return e.includes(n.allowedStatuses,t)?a:null}));!f(t)&&e.pull(n,"cancel"),"admin"!==q.role&&e.pull(n,"delete"),"staff"===q.role&&e.pull(n,"approve","reject"),"staff"!==q.role&&y(n),d()&&n.push("delete"),q.allowedActions=e.map(n,function(e){return{key:e,label:w[e].label,isDirectAction:w[e].isDirectAction}})}function y(t){e.each(t,function(n,a){"edit"===n&&(t[a]="respond"),e.includes(["respond","view"],n)&&(t[a]="edit")})}n.debug("Component: leave-request-action-dropdown");var _,q=this,$=u.statusNames,w={edit:{label:"Edit",allowedStatuses:[$.awaitingApproval]},respond:{label:"Respond",allowedStatuses:[$.moreInformationRequired]},view:{label:"View",allowedStatuses:[$.approved,$.rejected,$.cancelled]},approve:{label:"Approve",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Approval",btnClass:"success",btnLabel:"Approve",msg:"Please confirm approval"}},reject:{label:"Reject",isDirectAction:!0,allowedStatuses:[$.awaitingApproval],dialog:{title:"Rejection",btnClass:"warning",btnLabel:"Reject",msg:"Please confirm rejection"}},cancel:{label:"Cancel",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.approved,$.rejected,$.moreInformationRequired],dialog:{title:"Cancellation",btnClass:"danger",btnLabel:"Confirm",msg:"Please confirm cancellation"}},delete:{label:"Delete",isDirectAction:!0,allowedStatuses:[$.awaitingApproval,$.moreInformationRequired,$.approved,$.rejected,$.cancelled],dialog:{title:"Deletion",btnClass:"danger",btnLabel:"Confirm",msg:"This cannot be undone"}}};q.allowedActions=[],q.action=l,q.openLeavePopup=v,function(){p(),b()}()}n.component("leaveRequestActions",{bindings:{leaveRequest:"<",leaveRequestStatuses:"<",absenceTypes:"<",role:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-actions.html"}],controllerAs:"actions",controller:a}),a.$inject=["$log","$rootScope","dialog","LeavePopup","LeaveRequestService","pubSub","shared-settings","notificationService"]}),define("leave-absences/shared/components/leave-request-popup-comments-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/hr-settings","common/models/session.model"],function(e,t,n){function a(n,a,r,o,s,i,u){function c(){q.request.comments.push({contact_id:_,leave_request_id:q.request.id,text:q.comment.text}),q.comment.text=""}function l(){return q.comment.text.length>0}function d(e){return!e.comment_id||q.canManage}function f(e){return t.utc(e,s.serverDateTimeFormat).local().format(o.DATE_FORMAT.toUpperCase()+" HH:mm")}function m(){return q.request.comments.filter(function(e){return!e.toBeDeleted})}function p(e){return e===_?"Me":q.comment.contacts[e]?q.comment.contacts[e].display_name:void 0}function h(e){return q.mode===e}function v(){q.comment.text.length&&q.addComment()}function g(){var t=e.indexBy(q.request.comments,"contact_id"),n=Object.keys(t);return i.all({id:{IN:n}},{page:1,size:0}).then(function(t){q.comment.contacts=e.indexBy(t.list,"contact_id")})}function b(){return q.request.loadComments().then(function(){a.$broadcast("LeaveRequestPopup::requestObjectUpdated"),q.request.comments.length&&g()})}function y(){return q.loading.component=!0,u.get().then(function(e){_=e.contactId}).then(function(){q.loading.component=!1})}n.debug("Component: leave-request-popup-comments-tab");var _=null,q=this;q.loading={component:!0},q.comment={text:"",contacts:{}},q.addComment=c,q.canRemoveComment=d,q.canSubmit=l,q.formatDateTime=f,q.getActiveComments=m,q.getCommentorName=p,q.isMode=h,q.onBeforeSubmit=v,function(){r.$emit("LeaveRequestPopup::addTab",q),b(),y()}()}n.component("leaveRequestPopupCommentsTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-comments-tab.html"}],controllerAs:"commentsCtrl",controller:["$log","$rootScope","$scope","HR_settings","shared-settings","Contact","Session",a]})}),define("leave-absences/shared/components/leave-request-popup-details-tab.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/models/session.model","leave-absences/shared/models/calendar.model"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l,d,f,m){function p(){pe.balance.closing=pe.balance.opening+pe.balance.change.amount}function h(e){return t(e,u.serverDateFormat).toDate()}function v(e){return t(e).format(u.serverDateFormat)}function g(e){var t;return s.resolve().then(function(){X(e),"from"===e&&K(),B("hours")&&(_(e),"from"!==e||pe.uiOptions.multipleDays||_("to")),pe.loading[e+"DayTypes"]=!0}).then(pe.onDateChangeExtended).then(function(){return w(e)}).then(function(e){if(t=e.id!==pe.period.id,t&&(pe.period=e),!pe.period.id)return s.reject("Please change date as it is not in any absence period")}).then(Z).then(function(){if(t)return W()}).then(function(){return U(pe.uiOptions[e+"Date"],e)}).then(function(){if(B("hours"))return V(e).then(function(){ne(e,!0)})}).then(function(){if(oe(),!t)return Y();r.$broadcast("LeaveRequestPopup::absencePeriodChanged")}).catch(S)}function b(){return oe(),Y()}function y(){return pe.uiOptions.toDate=null,X("to"),s.resolve().then(function(){if(B("hours")&&pe.uiOptions.fromDate)return _("from"),!pe.uiOptions.multipleDays&&_("to"),V("from").then(function(){ne("from",!0)}).then(oe)}).then(pe.setDaysSelectionModeExtended).then(!pe.uiOptions.multipleDays&&Y)}function _(e){var t=pe.uiOptions.times[e];t.loading=!0,t.disabled=!0}function q(t,n){var a=pe.uiOptions.times[t],r=e.clone(n.time_from),o=e.clone(n.time_to);pe.uiOptions.multipleDays||("from"===t&&o&&r&&(o=P(o).subtract(pe.uiOptions.time_interval,"minutes").format("HH:mm")),"to"===t&&r&&o&&(r=P(r).add(pe.uiOptions.time_interval,"minutes").format("HH:mm"))),a.min=r||"00:00",a.max=o||"00:00",a.time="to"===t?a.max:a.min,a.disabled=!1}function $(t,n){return t?(t=v(t),d.isPublicHoliday(t).then(function(n){return n?pe.requestDayTypes.filter(function(e){return"public_holiday"===e.name}):C(t,pe.requestDayTypes).then(function(t){return t.length?t:pe.requestDayTypes.filter(function(t){return e.includes(["all_day","half_day_am","half_day_pm"],t.name)})})}).then(function(e){return te(n,e),e})):s.reject([])}function w(n){var a=t(pe.uiOptions[n+"Date"]).format(pe.uiOptions.userDateFormat.toUpperCase());return e.find(pe.absencePeriods,function(e){return e.isInPeriod(a)})||{}}function C(e,n){return e=t(e),s.all([pe.calendar.isNonWorkingDay(e),pe.calendar.isWeekend(e)]).then(function(e){return e[0]?"non_working_day":e[1]?"weekend":null}).then(function(e){return e?n.filter(function(t){return t.name===e}):[]})}function A(){return pe.request?pe.request.request_type:pe.leaveType||null}function P(e){return t().set({hours:e.split(":")[0],minutes:e.split(":")[1]})}function D(){return ie(),pe.loading.balanceChange=!0,pe.request.getBalanceChangeBreakdown().then(Q).catch(S)}function R(e,n){return t.duration(n).subtract(t.duration(e)).asHours()}function S(t){r.$broadcast("LeaveRequestPopup::handleError",e.isArray(t)?t:[t]),pe.loading.fromDayTypes=!1,pe.loading.balanceChange=!1,pe.loading.tab=!1,pe.loading.toDayTypes=!1}function T(){return pe.isMode("create")||pe.forceRecalculateBalanceChange?Y():D()}function I(){var e=pe.request.attributes();return pe.uiOptions.fromDate=h(pe.request.from_date),U(pe.uiOptions.fromDate,"from").then(function(){return pe.request.to_date=e.to_date,pe.request.to_date_type=e.to_date_type,pe.uiOptions.toDate=h(pe.request.to_date),U(pe.uiOptions.toDate,"to")})}function x(e){o.$watch("detailsTab.uiOptions.times."+e+".amount",function(e,t){B("days")||+e==+t||(se(),pe.performBalanceChangeCalculation())})}function O(){me.push(r.$on("LeaveRequestPopup::absenceTypeChanged",function(){ce()}),r.$on("LeaveRequestPopup::absencePeriodBalancesUpdated",function(e,t){le(t)}),r.$on("LeaveRequestPopup::recalculateBalanceChange",Y))}function L(){pe.isMode("edit")&&(pe.isLeaveStatus(u.statusNames.approved)||pe.isLeaveStatus(u.statusNames.adminApproved))&&(fe={absenceTypeId:pe.request.type_id,value:pe.selectedAbsenceType.remainder-pe.request.balance_change})}function k(e){var n=t(pe.request[e+"_date"]).format("HH:mm"),a=pe.uiOptions.times[e];(R(a.min,n)<=0||R(a.max,n)>=0)&&(n="from"===e?a.min:a.max),pe.uiOptions.times[e].time=n}function M(){var e=pe.uiOptions.multipleDays?["from","to"]:["from"],t=pe.uiOptions.times;return s.all(e.map(V)).then(function(){["from","to"].forEach(function(e){k(e),ne(e),t[e].amount=Math.min(pe.request[e+"_date_amount"],t[e].maxAmount).toString()}),pe.uiOptions.multipleDays||de(pe.uiOptions.times.from.time)}).then(se)}function E(){["from","to"].forEach(function(e){x(e),j(e)})}function j(e){o.$watch("detailsTab.uiOptions.times."+e+".time",function(t,n){B("days")||t===n||(oe(),t&&(!pe.uiOptions.multipleDays&&"from"===e&&de(t),ne(e,!0)))})}function B(e){return pe.selectedAbsenceType.calculation_unit_name===e}function N(e){return pe.request.request_type===e}function F(t){return e.includes(["weekend","non_working_day","public_holiday"],t)}function U(e,t){return $(e,t).then(function(){pe.loading[t+"DayTypes"]=!1})}function H(){return l.valuesOf("hrleaveandabsences_leave_request_day_type").then(function(e){pe.requestDayTypes=e})}function V(e){var t=pe.uiOptions[e+"Date"],n=pe.uiOptions.times[e],a=!pe.uiOptions.multipleDays;return t?pe.request.getWorkDayForDate(v(t)).then(function(t){he[e]=t,q(e,t),a&&"from"===e&&q("to",t)}).catch(function(t){return he[e]={},S(t)}).finally(function(){n.loading=!1,a&&(pe.uiOptions.times.to.loading=!1)}):s.resolve()}function W(){return c.get(pe.request.contact_id,pe.period.start_date,pe.period.end_date).then(function(e){pe.calendar=e})}function G(){var e=(pe.pagination.currentPage-1)*pe.pagination.numPerPage,t=e+pe.pagination.numPerPage;pe.pagination.filteredbreakdown=pe.balance.change.breakdown.slice(e,t)}function Y(){return ie(),pe.canCalculateChange()?(pe.loading.balanceChange=!0,pe.request.change_balance=!0,pe.calculateBalanceChange().then(Q).catch(S).finally(function(){pe.loading.balanceChange=!1})):s.resolve()}function z(){pe.pagination.totalItems=pe.balance.change.breakdown.length,pe.pagination.filteredbreakdown=pe.balance.change.breakdown,pe.pagination.pageChanged()}function J(){return v(pe.request.from_date)===v(pe.request.to_date)}function K(){pe.uiOptions.toDate&&pe.uiOptions.fromDate&&pe.uiOptions.multipleDays&&t(pe.uiOptions.toDate).isSameOrBefore(pe.uiOptions.fromDate)&&(pe.uiOptions.toDate=null,X("to"))}function X(t){var n=pe.uiOptions.times[t];pe["request"+e.startCase(t)+"DayTypes"]=[],n.time="",n.min="00:00",n.max="00:00",n.amount="0",n.maxAmount="0",n.loading=!1,oe(),se(),ie()}function Q(e){pe.balance.change=e,pe.request.balance_change=e.amount,p(),z(),pe.loading.balanceChange=!1}function Z(){var e,n,a;pe.uiOptions.fromDate?(e=t(pe.uiOptions.fromDate).add(1,"day").toDate(),a=e,n=e):(a=h(pe.period.start_date),n=pe.uiOptions.date.to.options.minDate),pe.uiOptions.date.to.options.initDate=n,pe.uiOptions.date.to.options.minDate=a,pe.uiOptions.date.to.options.maxDate=h(pe.period.end_date)}function ee(){return!pe.isMode("create")&&J()||pe.isMode("create")&&(N("sickness")||B("hours"))?pe.uiOptions.multipleDays=!1:pe.uiOptions.multipleDays=!0,s.resolve().then(pe.setDaysSelectionModeExtended)}function te(t,n){var a="request"+e.startCase(t)+"DayTypes";pe[a]=n,pe.isMode("create")&&(pe.request[t+"_date_type"]=pe[a][0].value)}function ne(e,t){var n=pe.uiOptions,a=n.multipleDays?e:"from",r=n.times[a],o=n.multipleDays&&"to"===a?r.min:n.times.from.time,s=n.multipleDays&&"from"===a?r.max:n.times.to.time,i=he[a].number_of_hours?R(o,s).toString():"0";r.maxAmount=i,t&&(r.amount=r.maxAmount)}function ae(){fe&&fe.absenceTypeId===pe.selectedAbsenceType.id?pe.balance.opening=fe.value||0:pe.balance.opening=pe.selectedAbsenceType.remainder}function re(){pe.selectedAbsenceType=e.find(pe.absenceTypes,function(e){return e.id===pe.request.type_id})}function oe(){var e=pe.uiOptions,t=e.times;pe.request.from_date=e.fromDate?v(e.fromDate):null,pe.request.to_date=e.toDate?v(e.toDate):null,!e.multipleDays&&e.fromDate&&(pe.request.to_date=pe.request.from_date,pe.request.to_date_type=pe.request.from_date_type),B("hours")&&!N("toil")&&(pe.request.from_date=pe.request.from_date&&t.from.time?pe.request.from_date+" "+t.from.time:null,pe.request.to_date=pe.request.to_date&&t.to.time?pe.request.to_date+" "+t.to.time:null)}function se(){var e=pe.uiOptions.times;pe.request.from_date_amount=isNaN(+e.from.amount)?null:e.from.amount,pe.request.to_date_amount=isNaN(+e.to.amount)?null:e.to.amount}function ie(){pe.uiOptions.showBalance=pe.canCalculateChange()}function ue(){e.forEach(me,function(e){e()})}function ce(){var e,t=pe.selectedAbsenceType.calculation_unit_name;return re(),e=t!==pe.selectedAbsenceType.calculation_unit_name,ae(),s.resolve().then(e&&ee).then(function(){if(e&&B("hours"))return V("from").then(function(){ne("from",!0)})}).then(e&&oe).then(Y)}function le(e){return pe.absenceTypes=e,re(),t(pe.uiOptions.toDate).isAfter(pe.period.end_date)&&(pe.uiOptions.toDate=void 0,X("to")),ae(),Y()}function de(e){var t=P(e).add(pe.uiOptions.time_interval,"minutes");t.isAfter(P(pe.uiOptions.times.to.max))||(pe.uiOptions.times.to.min=t.format("HH:mm"),t.isAfter(P(pe.uiOptions.times.to.time))&&(pe.uiOptions.times.to.time=""))}a.debug("Component: leave-request-popup-details-tab");var fe=null,me=[],pe=this,he={};pe.canManage=!1,pe.calendar={},pe.errors=[],pe.isRequired=!0,pe.requestDayTypes=[],pe.statusNames=u.statusNames,pe.loading={tab:!1,balanceChange:!1,fromDayTypes:!1,toDayTypes:!1},pe.pagination={currentPage:1,filteredbreakdown:pe.balance.change.breakdown,numPerPage:7,totalItems:pe.balance.change.breakdown.length,pageChanged:G},pe.uiOptions={isChangeExpanded:!1,multipleDays:!0,userDateFormat:i.DATE_FORMAT,showBalance:!1,date:{from:{show:!1,options:{startingDay:1,showWeeks:!1}},to:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}},expiry:{show:!1,options:{minDate:null,maxDate:null,startingDay:1,showWeeks:!1}}},times:{from:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""},to:{amount:0,amountExpanded:!1,loading:!1,max:"00:00",maxAmount:0,min:"00:00",time:""}},time_interval:15},pe.convertDateFormatFromServer=h,pe.convertDateToServerFormat=v,pe.dateChangeHandler=g,pe.dateTypeChangeHandler=b,pe.daysSelectionModeChangeHandler=y,pe.isLeaveType=N,pe.isNotWorkingDay=F,pe.performBalanceChangeCalculation=Y,pe.$onDestroy=ue,function(){n("RequestModalDetails"+e.capitalize(A(pe.leaveType,pe.request))+"Controller",{detailsController:pe}),pe.canManage=pe.isRole("manager")||pe.isRole("admin"),pe.loading.tab=!0,o.$emit("LeaveRequestPopup::addTab",pe),O(),pe.initChildController().then(function(){return s.all([W(),H()])}).then(!pe.isMode("create")&&I).then(ee).then(function(){if(!pe.isMode("create")&&B("hours"))return M().then(oe)}).then(!pe.isMode("create")&&Z).then(L).then(ae).then(T).then(function(){pe.isMode("view")||N("toil")||E()}).catch(S).finally(function(){pe.loading.tab=!1})}()}n.component("leaveRequestPopupDetailsTab",{bindings:{absencePeriods:"<",absenceTypes:"<",balance:"=",request:"<",isLeaveStatus:"<",leaveType:"<",isMode:"<",isSelfRecord:"<",period:"=",isRole:"<",selectedAbsenceType:"=",forceRecalculateBalanceChange:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-details-tab.html"}],controllerAs:"detailsTab",controller:a}),a.$inject=["$controller","$log","$rootScope","$scope","$q","HR_settings","shared-settings","Calendar","OptionGroup","PublicHoliday","LeaveRequest","$timeout"]}),define("leave-absences/shared/components/leave-request-popup-files-tab",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/file-upload","common/services/file-mime-types","common/services/hr-settings"],function(e,t,n){function a(n,a,r,o,s,i,u,c,l){function d(){return T.fileUploader&&T.fileUploader.queue.length>0}function f(){return T.getFilesAmount()0?D.map(function(e){return e.label}).join(", "):""}function q(){return T.request.loadAttachments().then(function(){r.$broadcast("LeaveRequestPopup::requestObjectUpdated")})}function $(){return a.all(D.map(function(e){return l.getMimeTypeFor(e.label).then(function(t){S[e.label]=t})})).catch(function(){S=null})}function w(){return u.valuesOf("safe_file_extension").then(function(e){D=e})}function C(e){return!e.attachment_id||T.canManage}function A(){e.forEach(R,function(e){e()})}function P(e,t){T.fileUploader.queue&&T.fileUploader.queue.length>0?T.fileUploader.uploadAll({entityID:T.request.id}).then(function(){t()}).catch(t):t()}n.debug("Component: leave-request-popup-files-tab");var D=[],R=[],S={},T=Object.create(this);return T.filesLoaded=!1,T.fileUploader=null,T.today=Date.now(),T.userDateFormatWithTime=s.DATE_FORMAT+" HH:mm",T.userDateFormat=s.DATE_FORMAT,T.$onDestroy=A,T.canRemoveAttachment=C,T.canSubmit=d,T.canUploadMore=f,T.formatDateTime=m,T.getAuthorName=p,T.getFilesAmount=h,T.listFileTypes=_,function(){r.$broadcast("LeaveRequestPopup::childComponent::register"),o.$emit("LeaveRequestPopup::addTab",T),b(),a.all([w(),q()]).then(y).finally(function(){T.filesLoaded=!0})}(),T}n.component("leaveRequestPopupFilesTab",{bindings:{canManage:"<",mode:"<",request:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-popup/leave-request-popup-files-tab.html"}],controllerAs:"filesTab",controller:["$log","$q","$rootScope","$scope","HR_settings","shared-settings","OptionGroup","FileUpload","fileMimeTypes",a]})}),define("leave-absences/shared/components/leave-request-record-actions.component",["leave-absences/shared/modules/components","common/services/hr-settings","common/services/before-hash-query-params.service"],function(e){function t(e,t,n){function a(e,n,a,r){t.openModal.apply(t,arguments)}e.debug("Component: leave-request-record-actions");var r,o=this;o.leaveRequestOptions=[{
-type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",selectedContactId:"<",isSelfRecord:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,r,o,s,i,u,c,l,d,f){function m(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),H.sections.other.open&&m(e,H.sections.other)}function h(){Object.values(H.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):H.refresh()}function g(t){t.dataIndex=e.indexBy(t.data,"id")}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function y(){return o.all().then(function(t){H.absencePeriods=e.sortBy(t,"start_date"),H.selectedPeriod=e.find(H.absencePeriods,function(e){return!0===e.current})})}function _(){return s.all().then(s.loadCalculationUnits).then(function(t){H.absenceTypes=t,H.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return D("approved",{status_id:F(f.statusNames.approved)})}function $(){return n.all([u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,null,!0),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.approved)]),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)])]).then(function(e){H.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function w(){return i.all({contact_id:H.contactId,period_id:H.selectedPeriod.id},!0).then(function(e){H.entitlements=e}).then(function(){H.absenceTypesFiltered=H.absenceTypes.filter(function(t){var n=e.find(H.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function C(){return i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id},H.entitlements).then(function(){return L(H.entitlements)}).then(function(e){H.sections.entitlements.data=e})}function A(){return n.all([i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id,expired:!0}),P({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:L(e[0]),expiredTOILS:k(e[1].list)})}).then(function(t){H.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),H.sections.expired.data=e.sortBy(H.sections.expired.data,"expiry_date")})}function P(t){return u.all(e.assign({contact_id:H.contactId,from_date:{from:H.selectedPeriod.start_date},to_date:{to:H.selectedPeriod.end_date},type_id:{IN:H.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function D(e,t){return P(t).then(function(t){H.sections[e].data=t.list})}function R(){return n.all(Object.values(H.sections).filter(function(e){return e.open}).map(x))}function S(){return D("other",{status_id:{in:[F(f.statusNames.rejected),F(f.statusNames.cancelled)]}})}function T(){return D("pending",{status_id:{in:[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)]}})}function I(){return D("holidays",{public_holiday:!0})}function x(e){return e.loading=!0,e.loadLeaveRequests().then(g.bind(this,e)).then(function(){e.loading=!1})}function O(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){H.leaveRequestStatuses=e.indexBy(t,"value")})}function L(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(H.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function k(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function M(){l.subscribe("LeaveRequest::new",function(){H.refresh()}),l.subscribe("LeaveRequest::edit",function(){H.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(H.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],j(t,a))})}function j(e,t){var n=H.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function B(){H.loading.content=!0,n.all([w(),$()]).then(function(){H.loading.content=!1}).then(function(){return n.all([R(),h()])})}function N(e){var t=H.sections[e];t.open=!t.open,t.open&&!t.data.length&&x(t)}function F(t){return e.find(H.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},H=this;H.absencePeriods=[],H.absenceTypes=[],H.absenceTypesFiltered=[],H.absenceTypesIndexed={},H.dateFormat=d.DATE_FORMAT,H.leaveRequestStatuses={},H.selectedPeriod=null,H.role="absence-tab"===a.section?"admin":"staff",H.loading={content:!0,page:!0},H.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:C},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:A},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:T},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:S}},H.labelPeriod=b,H.refresh=B,H.toggleSection=N,function(){n.all([O(),_(),y()]).then(function(){H.loading.page=!1}).then(function(){return n.all([w(),$()])}).then(function(){H.loading.content=!1}),M()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=C.from_date!==s.request.from_date||C.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){C=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function w(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var C,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=w,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,h,v,g,b,y,_,q,$,w){function C(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function A(){["from","to"].forEach(C)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function D(){return Le.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function R(){return Le.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=D();return ke.isMode("edit")&&(e=e&&(W()||R())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function x(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return w.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function O(){ke.errors=[]}function L(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function M(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(De[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function V(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function W(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(he).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==xe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];De.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],De.awaiting_approval=e,De.more_information_required=e,De.rejected=e,De.approved=e,De.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(he).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){V(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){Re++})),s.$on("$destroy",we),s.$on("LeaveRequestPopup::addTab",function(e,t){Le.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Oe="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Oe="admin")}).then(function(){return"staff"===Oe&&u(_.permissions.ssp.manage).then(function(e){e&&(Oe="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Oe===e}function se(){return h.all().then(function(e){ke.absencePeriods=e})}function ie(){return v.all(j()).then(v.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function he(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(xe)}function ve(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),A(),ke.request.isValid().then(ee()&&x).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?Ae():L()}).catch(function(t){ke.request.status_id=e,t&&V(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Le.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===Re&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return Re>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function we(){Te.forEach(function(e){e()})}function Ce(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Ae(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,De={},Re=0,Se={},Te=[],Ie="",xe="No entitlement",Oe="",Le=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=O,ke.deleteLeaveRequest=M,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ce,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(ve).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(V).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/my-leave/modules/components",["common/angular"],function(e){return e.module("my-leave.components",[])}),define("leave-absences/my-leave/components/my-leave-container.component",["leave-absences/my-leave/modules/components"],function(e){e.component("myLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/my-leave-container.html"}],controllerAs:"myleave",controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: my-leave-container"),t.section="my-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}]})}),function(e){define("leave-absences/my-leave/modules/settings",["common/angular"],function(t){return t.module("my-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/my-leave/"})})}(CRM),function(e){define("leave-absences/my-leave/modules/config",["common/angular","leave-absences/my-leave/modules/settings"],function(t){return t.module("my-leave.config",["my-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/my-leave/report"),t.state("my-leave",{abstract:!0,url:"/my-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("my-leave.report",{url:"/report?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("my-leave.calendar",{url:"/calendar",template:' '})}])})}(CRM),define("leave-absences/my-leave/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/loading","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/models/option-group","common/modules/dialog","common/services/check-permissions","common/services/angular-date/date-format","leave-absences/shared/ui-router","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/my-leave/components/my-leave-container.component","leave-absences/my-leave/modules/config"],function(e){return e.module("my-leave",["ngResource","ngAnimate","ui.bootstrap","ui.router","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.mocks","common.models","common.services","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","my-leave.components","my-leave.config"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/my-leave":n+"/my-leave"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/my-leave/app"],function(e){e.bootstrap(document.querySelector("[data-leave-absences-my-leave]"),["my-leave"])})})}(CRM,require),define("my-leave",function(){});
+type:"leave",icon:"briefcase",label:"Leave"},{type:"sickness",icon:"stethoscope",label:"Sickness"}],o.openLeavePopup=a,function(){r=n.parse(),r.openModal&&a(null,r.openModal,o.selectedContactId,o.isSelfRecord)}()}e.component("leaveRequestRecordActions",{bindings:{contactId:"<",isSelfRecord:"<",selectedContactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/leave-request-record-actions.html"}],controllerAs:"vm",controller:["$log","LeavePopup","beforeHashQueryParams",t]})}),define("leave-absences/shared/components/staff-leave-report.component",["common/lodash","common/moment","leave-absences/shared/modules/components","common/services/pub-sub"],function(e,t,n){function a(t,n,a,r,o,s,i,u,c,l,d,f){function m(e,t){t.data.push(e),t.dataIndex[e.id]=e}function p(e){E(e),H.sections.other.open&&m(e,H.sections.other)}function h(){Object.values(H.sections).forEach(function(e){e.data=[]})}function v(e){var t=U[e.status];t?t(e.leaveRequest):H.refresh()}function g(t){t.dataIndex=e.indexBy(t.data,"id")}function b(e){return e.current?"Current Period ("+e.title+")":e.title}function y(){return o.all().then(function(t){H.absencePeriods=e.sortBy(t,"start_date"),H.selectedPeriod=e.find(H.absencePeriods,function(e){return!0===e.current})})}function _(){return s.all().then(s.loadCalculationUnits).then(function(t){H.absenceTypes=t,H.absenceTypesIndexed=e.indexBy(t,"id")})}function q(){return D("approved",{status_id:F(f.statusNames.approved)})}function $(){return n.all([u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,null,!0),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.approved)]),u.balanceChangeByAbsenceType(H.contactId,H.selectedPeriod.id,[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)])]).then(function(e){H.absenceTypes.forEach(function(t){t.balanceChanges={holidays:e[0][t.id],approved:e[1][t.id],pending:e[2][t.id]}})})}function w(){return i.all({contact_id:H.contactId,period_id:H.selectedPeriod.id},!0).then(function(e){H.entitlements=e}).then(function(){H.absenceTypesFiltered=H.absenceTypes.filter(function(t){var n=e.find(H.entitlements,function(e){return e.type_id===t.id});return t.entitlement=n?n.value:0,t.remainder=n?n.remainder:{current:0,future:0},!(0===t.entitlement&&"1"!==t.allow_overuse&&"1"!==t.allow_accruals_request)})})}function C(){return i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id},H.entitlements).then(function(){return L(H.entitlements)}).then(function(e){H.sections.entitlements.data=e})}function A(){return n.all([i.breakdown({contact_id:H.contactId,period_id:H.selectedPeriod.id,expired:!0}),P({request_type:"toil",expired:!0})]).then(function(e){return n.all({expiredBalanceChangesFlatten:L(e[0]),expiredTOILS:k(e[1].list)})}).then(function(t){H.sections.expired.data=t.expiredBalanceChangesFlatten.concat(t.expiredTOILS),H.sections.expired.data=e.sortBy(H.sections.expired.data,"expiry_date")})}function P(t){return u.all(e.assign({contact_id:H.contactId,from_date:{from:H.selectedPeriod.start_date},to_date:{to:H.selectedPeriod.end_date},type_id:{IN:H.absenceTypes.map(function(e){return e.id})}},t),null,"from_date ASC",null,!1)}function D(e,t){return P(t).then(function(t){H.sections[e].data=t.list})}function R(){return n.all(Object.values(H.sections).filter(function(e){return e.open}).map(x))}function S(){return D("other",{status_id:{in:[F(f.statusNames.rejected),F(f.statusNames.cancelled)]}})}function T(){return D("pending",{status_id:{in:[F(f.statusNames.awaitingApproval),F(f.statusNames.moreInformationRequired)]}})}function I(){return D("holidays",{public_holiday:!0})}function x(e){return e.loading=!0,e.loadLeaveRequests().then(g.bind(this,e)).then(function(){e.loading=!1})}function O(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(t){H.leaveRequestStatuses=e.indexBy(t,"value")})}function L(t){return n.resolve().then(function(){return t.map(function(t){var n=e.find(H.entitlements,function(e){return e.id===t.id});return t.breakdown.map(function(t){return e.assign(e.clone(t),{type_id:n.type_id})})})}).then(function(e){return Array.prototype.concat.apply([],e)})}function k(e){return n.resolve().then(function(){return e.map(function(e){return{expiry_date:e.toil_expiry_date,type:{label:"Accrued TOIL"}}})})}function M(){l.subscribe("LeaveRequest::new",function(){H.refresh()}),l.subscribe("LeaveRequest::edit",function(){H.refresh()}),l.subscribe("LeaveRequest::statusUpdate",v),l.subscribe("LeaveRequest::delete",function(e){E(e)})}function E(t){e.forEach(H.sections,function(n,a){n.dataIndex[t.id]&&(e.remove(n.data,function(e){return e.id===t.id}),delete n.dataIndex[t.id],j(t,a))})}function j(e,t){var n=H.absenceTypesIndexed[e.type_id],a="pending"===t?"future":"current";n.balanceChanges[t]-=e.balance_change,n.remainder[a]-=e.balance_change}function B(){H.loading.content=!0,n.all([w(),$()]).then(function(){H.loading.content=!1}).then(function(){return n.all([R(),h()])})}function N(e){var t=H.sections[e];t.open=!t.open,t.open&&!t.data.length&&x(t)}function F(t){return e.find(H.leaveRequestStatuses,function(e){return e.name===t}).value}t.debug("Component: staff-leave-report");var U={delete:E,cancel:p},H=this;H.absencePeriods=[],H.absenceTypes=[],H.absenceTypesFiltered=[],H.absenceTypesIndexed={},H.dateFormat=d.DATE_FORMAT,H.leaveRequestStatuses={},H.selectedPeriod=null,H.role="absence-tab"===a.section?"admin":"staff",H.loading={content:!0,page:!0},H.sections={approved:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:q},entitlements:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:C},expired:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:A},holidays:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:I},pending:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:T},other:{open:!1,data:[],dataIndex:{},loading:!1,loadLeaveRequests:S}},H.labelPeriod=b,H.refresh=B,H.toggleSection=N,function(){n.all([O(),_(),y()]).then(function(){H.loading.page=!1}).then(function(){return n.all([w(),$()])}).then(function(){H.loading.content=!1}),M()}()}n.component("staffLeaveReport",{bindings:{contactId:"<"},templateUrl:["shared-settings",function(e){return e.sharedPathTpl+"components/staff-leave-report.html"}],controllerAs:"report",controller:["$log","$q","$rootScope","checkPermissions","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","OptionGroup","pubSub","HR_settings","shared-settings",a]})}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller",["leave-absences/shared/modules/controllers"],function(e){function t(e,t,n,a){function r(){return a.request.calculateBalanceChange(a.selectedAbsenceType.calculation_unit_name)}function o(){var e=a.request,t=!!e.from_date&&!!e.to_date,n=a.selectedAbsenceType.calculation_unit_name;return"days"===n?t=t&&!!e.from_date_type&&!!e.to_date_type:"hours"===n&&(t=t&&!isNaN(+e.from_date_amount)&&!isNaN(+e.to_date_amount)),t}function s(){return a.canCalculateChange()}function i(){return n.resolve()}t.debug("RequestModalDetailsLeaveController"),a.calculateBalanceChange=r,a.canCalculateChange=o,a.canSubmit=s,a.initChildController=i}e.controller("RequestModalDetailsLeaveController",t),t.$inject=["$controller","$log","$q","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o){function s(){return!(!o.canCalculateChange()||!o.request.sickness_reason)}function i(){return a.all([l(),d()])}function u(t){var n=o.request.getDocumentArray();return!!e.find(n,function(e){return e===t})}function c(t){return!!e.find(o.sicknessDocumentTypes,function(e){return e.value===t})}function l(){return r.valuesOf("hrleaveandabsences_leave_request_required_document").then(function(e){o.sicknessDocumentTypes=e})}function d(){return r.valuesOf("hrleaveandabsences_sickness_reason").then(function(t){o.sicknessReasons=e.indexBy(t,"name")})}n.debug("RequestModalDetailsSicknessController"),t("RequestModalDetailsLeaveController",{detailsController:o}),o.canSubmit=s,o.initChildController=i,o.isChecked=u,o.isDocumentInRequest=c}t.controller("RequestModalDetailsSicknessController",n),n.$inject=["$controller","$log","$q","api.optionGroup","detailsController"]}),define("leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller",["common/lodash","leave-absences/shared/modules/controllers"],function(e,t){function n(t,n,a,r,o,s){function i(){return s.balance.change.amount=+s.request.toil_to_accrue,n.resolve(s.balance.change)}function u(){return m().catch(function(e){return e.length&&(s.errors=e),n.reject(e)}).then(function(e){return o.calculateToilExpiryDate(s.request.type_id,e)}).then(function(e){return s.request.toil_expiry_date=e,s.uiOptions.expiryDate=new Date(e),e})}function c(){return!!s.request.toil_to_accrue}function l(){var e=s.uiOptions.multipleDays&&!!s.request.to_date,t=!s.uiOptions.multipleDays&&!!s.request.from_date,n=t||e,a=C.from_date!==s.request.from_date||C.to_date!==s.request.to_date;return s.canDisplayToilExpirationField&&n&&A.hasExpirationFromAdminSettings&&a}function d(){return!!(s.request.from_date&&s.request.to_date&&s.request.toil_duration&&s.request.toil_to_accrue)}function f(){s.request.toil_expiry_date=!1,s.uiOptions.expiryDate=null}function m(){var e=s.uiOptions.multipleDays,t=s.request;return p({hasErrors:e?!t.to_date&&!t.from_date:!t.from_date,label:e?"To Date":"From Date",value:t.to_date})}function p(e){if(e.hasErrors){var t="Please select "+e.label+" to find expiry date";return n.reject([t])}return e.value?n.resolve(e.value):n.reject([])}function h(){var e=s.isMode("create")&&A.hasExpirationFromAdminSettings,t=A.hasPreviousExpirationDate,n=s.isLeaveType("toil"),a=s.canManage;s.canDisplayToilExpirationField=n&&(a||e||t)}function v(){return A.hasPreviousExpirationDate=s.isMode("edit")&&!!s.request.toil_expiry_date,o.canExpire(s.request.type_id).then(function(e){A.hasExpirationFromAdminSettings=e})}function g(){return s.request.to_date_type=s.request.from_date_type="1",v().then(h).then(b).then(_)}function b(){s.canManage&&(s.uiOptions.expiryDate=s.convertDateFormatFromServer(s.request.toil_expiry_date))}function y(){s.isMode("view")||a.$watch(function(){return s.request.toil_to_accrue},function(e,t){+e!=+t&&s.performBalanceChangeCalculation()})}function _(){return r.valuesOf("hrleaveandabsences_toil_amounts").then(function(t){s.toilAmounts=e.indexBy(t,"value")})}function q(){C=angular.copy(s.request.attributes())}function $(){return l()?u().catch(n.resolve):n.resolve()}function w(){s.uiOptions.expiryDate&&(s.request.toil_expiry_date=s.convertDateToServerFormat(s.uiOptions.expiryDate))}t.debug("RequestModalDetailsToilController");var C,A={hasPreviousExpirationDate:null,hasExpirationFromAdminSettings:null};s.canDisplayToilExpirationField=!1,s.calculateBalanceChange=i,s.canCalculateChange=c,s.canSubmit=d,s.clearExpiryDate=f,s.initChildController=g,s.onDateChangeExtended=$,s.setDaysSelectionModeExtended=$,s.updateExpiryDate=w,function(){y(),q()}()}t.controller("RequestModalDetailsToilController",n),n.$inject=["$log","$q","$rootScope","api.optionGroup","AbsenceType","detailsController"]}),define("leave-absences/shared/instances/sickness-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("SicknessRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={sickness_reason:null,sickness_required_documents:"",request_type:"sickness"};return e.assign({},n.defaultCustomData(),t)},getDocumentArray:function(){return this.sickness_required_documents?this.sickness_required_documents.split(","):[]},toggleDocument:function(t){var n=this.getDocumentArray(),a=n.indexOf(t);e.contains(n,t)?n.splice(a,1):n.push(t),this.sickness_required_documents=n.join(",")},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/instances/toil-request.instance",["common/lodash","leave-absences/shared/modules/models-instances","leave-absences/shared/instances/leave-request.instance"],function(e,t){"use strict";t.factory("TOILRequestInstance",["LeaveRequestAPI","LeaveRequestInstance",function(t,n){return n.extend({defaultCustomData:function(){var t={toilDurationHours:"0",toilDurationMinutes:"0",request_type:"toil"};return e.assign({},n.defaultCustomData(),t)},transformAttributes:function(e){var t=Number(e.toil_duration);return t&&(e.toilDurationHours=Math.floor(t/60).toString(),e.toilDurationMinutes=(t%60).toString()),e},updateDuration:function(){this.toil_duration=60*Number(this.toilDurationHours)+Number(this.toilDurationMinutes)},toAPIFilter:function(t,n,a){e.includes(["balance_change","dates","comments","files","toilDurationHours","toilDurationMinutes"],a)||(t[a]=this[a])}})}])}),define("leave-absences/shared/controllers/request.controller",["common/angular","leave-absences/shared/modules/controllers","common/lodash","common/moment","common/models/contact","common/models/session.model","common/services/api/option-group","common/services/hr-settings","common/services/pub-sub","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/instances/leave-request.instance","leave-absences/shared/instances/sickness-request.instance","leave-absences/shared/instances/toil-request.instance","leave-absences/shared/services/leave-request.service"],function(e,t,n,a){"use strict";function r(t,r,o,s,i,u,c,l,d,f,m,p,h,v,g,b,y,_,q,$,w){function C(e){"days"===ke.selectedAbsenceType.calculation_unit_name?delete ke.request[e+"_date_amount"]:delete ke.request[e+"_date_type"]}function A(){["from","to"].forEach(C)}function P(){var e=ke.requestStatuses[_.statusNames.awaitingApproval].value;Se.status_id===e&&e!==ke.request.status_id&&d.publish("ManagerBadge:: Update Count")}function D(){return Le.filter(function(e){return e.isRequired}).every(function(e){return e.canSubmit&&e.canSubmit()})}function R(){return Le.filter(function(e){return!e.isRequired}).some(function(e){return e.canSubmit&&e.canSubmit()})}function S(){return!ke.loading.entitlements&&(!!oe("admin")||!ae("view")&&!(oe("manager")&&!ae("create")))}function T(){var e=D();return ke.isMode("edit")&&(e=e&&(W()||R())),ke.canManage&&ke.requestStatuses&&(e=e&&!!ke.getStatusFromValue(ke.newStatusOnSave)),(e=e&&!!ke.period.id)&&!ke.isMode("view")}function I(){ke.isSelfRecord?ke.request.status_id=ke.requestStatuses[_.statusNames.awaitingApproval].value:ke.canManage&&(ke.request.status_id=ke.newStatusOnSave||ke.request.status_id)}function x(){if(ke.isMode("edit")&&!ke.isRole("staff")&&"toil"!==F())return ke.request.calculateBalanceChange(ke.selectedAbsenceType.calculation_unit_name).then(function(e){if(+ke.balance.change.amount!=+e.amount)return w.promptBalanceChangeRecalculation().then(function(){o.$emit("LeaveRequestPopup::recalculateBalanceChange")}),r.reject()})}function O(){ke.errors=[]}function L(){return ke.request.create().then($e).then(function(){me("LeaveRequest::new")})}function k(){ee()&&!ke.isRole("staff")&&(ke.request.change_balance=!0)}function M(){l.open({title:"Confirm Deletion?",copyCancel:"Cancel",copyConfirm:"Confirm",classConfirm:"btn-danger",msg:"This cannot be undone",onConfirm:function(){return ke.request.delete().then(function(){ke.dismissModal(),d.publish("LeaveRequest::delete",ke.request)})}})}function E(){i.dismiss({$value:"cancel"})}function j(){var e=F();return"leave"===e?{is_sick:!1}:"sickness"===e?{is_sick:!0}:"toil"===e?{allow_accruals_request:!0}:void 0}function B(){return N(ke.getStatusFromValue(ke.request.status_id).name)}function N(e){return n.map(De[e],function(e){return ke.requestStatuses[e]})}function F(){return ke.request?ke.request.request_type:ke.leaveType||null}function U(){return!ke.request||e.equals({},ke.requestStatuses)?[]:ke.request.status_id?B():N("none")}function H(e){return n.find(ke.requestStatuses,function(t){return t.value===e})}function V(e){ke.errors=n.isArray(e)?e:[e],ke.loading.absenceTypes=!1,ke.submitting=!1}function W(){return!e.equals(Se,ke.request.attributes())||ke.canManage&&ke.newStatusOnSave}function G(){return ke.postContactSelection=!0,ke.staffMemberSelectionComplete=!1,ke.request.contact_id?r.resolve().then(ie).then(ue).then(he).then(ge).then(Z).then(z).then(ke.isMode("edit")?be:n.noop).then(function(){ke.postContactSelection=!1,ke.staffMemberSelectionComplete=!0}).catch(function(e){if(e!==xe)return r.reject(e)}):r.reject("The contact id was not set")}function Y(){var e=[_.statusNames.moreInformationRequired,_.statusNames.approved,_.statusNames.rejected,_.statusNames.cancelled];De.none=[_.statusNames.moreInformationRequired,_.statusNames.approved],De.awaiting_approval=e,De.more_information_required=e,De.rejected=e,De.approved=e,De.cancelled=[_.statusNames.awaitingApproval].concat(e)}function z(){return ke.canManage?m.find(ke.request.contact_id).then(function(e){ke.contactName=e.display_name}):r.resolve()}function J(){Te.push(o.$on("LeaveRequestPopup::requestObjectUpdated",be),o.$on("LeaveRequestPopup::absencePeriodChanged",function(){ue().then(he).then(function(){o.$emit("LeaveRequestPopup::absencePeriodBalancesUpdated",ke.absenceTypes)})}),o.$on("LeaveRequestPopup::handleError",function(e,t){V(t)}),o.$on("LeaveRequestPopup::childComponent::register",function(){Re++})),s.$on("$destroy",we),s.$on("LeaveRequestPopup::addTab",function(e,t){Le.push(t)})}function K(){var e,t;ke.request=ke.leaveRequest||null,e=F(),t=ke.initRequestAttributes(),"leave"===e?ke.request=y.init(t):"sickness"===e?ke.request=q.init(t):"toil"===e&&(ke.request=$.init(t))}function X(){var e={};return ke.request?e=ke.request.attributes():ke.canManage||(e={contact_id:Ie}),e}function Q(){if(Oe="staff","my-leave"!==o.section)return u(_.permissions.admin.administer).then(function(e){e&&(Oe="admin")}).then(function(){return"staff"===Oe&&u(_.permissions.ssp.manage).then(function(e){e&&(Oe="manager")})}).finally(function(){ke.canManage=ke.isRole("manager")||ke.isRole("admin")})}function Z(){(ke.isRole("admin")||ke.isMode("create")&&ke.isRole("manager"))&&(ke.newStatusOnSave=ke.requestStatuses[_.statusNames.approved].value)}function ee(){return!ke.request.status_id||!n.includes(["cancelled","rejected"],H(ke.request.status_id).name)}function te(e){var t=ke.getStatusFromValue(ke.request.status_id);return!!t&&t.name===e}function ne(e){return ke.request&&ke.request.request_type===e}function ae(e){return ke.mode===e}function re(e,t){var n=a(e.from_date),r=a(e.to_date);return n.isSameOrAfter(t.start_date)&&r.isSameOrBefore(t.end_date)}function oe(e){return Oe===e}function se(){return h.all().then(function(e){ke.absencePeriods=e})}function ie(){return v.all(j()).then(v.loadCalculationUnits).then(function(e){Pe={types:e,ids:e.map(function(e){return e.id})}})}function ue(){return ke.loading.entitlements=!0,g.all({contact_id:ke.request.contact_id,period_id:ke.period.id,type_id:{IN:Pe.ids}},!0).finally(function(){ke.loading.entitlements=!1})}function ce(){return p.get().then(function(e){Ie=e.contactId})}function le(){return ke.selectedContactId?m.find(ke.selectedContactId).then(function(e){ke.managedContacts=[e]}):ke.isRole("admin")?m.all().then(function(e){ke.managedContacts=n.remove(e.list,function(e){return e.id!==Ie})}):m.find(Ie).then(function(e){return e.leaveManagees()}).then(function(e){ke.managedContacts=e})}function de(){return c.valuesOf("hrleaveandabsences_leave_request_status").then(function(e){ke.requestStatuses=n.indexBy(e,"name")})}function fe(e,t){var a;return n.compact(e.map(function(e){if(a=n.find(t,{type_id:e.id}))return{id:a.type_id,title:e.title+" ( "+a.remainder.current+" ) ",remainder:a.remainder.current,allow_overuse:e.allow_overuse,calculation_unit_name:e.calculation_unit_name}}))}function me(e){P(),d.publish(e,ke.request),ke.errors=[],ke.dismissModal()}function pe(){["from","to"].forEach(function(e){ke.request[e+"_date"]=Se[e+"_date"]})}function he(e){if(ke.absenceTypes=fe(Pe.types,e),!ke.absenceTypes.length)return r.reject(xe)}function ve(){ke.period=n.find(ke.absencePeriods,function(e){return ke.isMode("create")?e.current:re(ke.request,e)})}function ge(){ke.isMode("create")?(ke.selectedAbsenceType=ke.absenceTypes[0],ke.request.type_id=ke.selectedAbsenceType.id):ke.selectedAbsenceType=n.find(ke.absenceTypes,function(e){return e.id===ke.request.type_id})}function be(){Se=e.copy(ke.request.attributes())}function ye(){var e;ke.request.id?(e=[ke.requestStatuses[_.statusNames.approved].value,ke.requestStatuses[_.statusNames.adminApproved].value,ke.requestStatuses[_.statusNames.rejected].value,ke.requestStatuses[_.statusNames.cancelled].value],ke.mode="edit",ke.isRole("staff")&&e.indexOf(ke.request.status_id)>-1&&(ke.mode="view")):ke.mode="create"}function _e(){var e=ke.request.status_id;if(!ke.isMode("view")&&!ke.submitting)return ke.submitting=!0,I(),A(),ke.request.isValid().then(ee()&&x).then(k).then(!ke.request.change_balance&&pe).then(qe).then(function(){return ke.isMode("edit")?Ae():L()}).catch(function(t){ke.request.status_id=e,t&&V(t)}).finally(function(){ke.submitting=!1})}function qe(){return r.all(Le.map(function(e){return e.onBeforeSubmit&&e.onBeforeSubmit()}))}function $e(){function e(e){e&&n.push(e),++a===Re&&(n.length>0?t.reject(n):t.resolve())}var t=r.defer(),n=[],a=0;return Re>0?o.$broadcast("LeaveRequestPopup::submit",e):t.resolve(),t.promise}function we(){Te.forEach(function(e){e()})}function Ce(){o.$broadcast("LeaveRequestPopup::absenceTypeChanged")}function Ae(){return ke.request.update().then($e).then(function(){ke.isRole("manager")?me("LeaveRequest::updatedByManager"):(ke.isRole("staff")||ke.isRole("admin"))&&me("LeaveRequest::edit")})}t.debug("RequestCtrl");var Pe,De={},Re=0,Se={},Te=[],Ie="",xe="No entitlement",Oe="",Le=[],ke=n.assign(this,f);ke.absencePeriods=[],ke.absenceTypes=[],ke.canManage=!1,ke.contactName=null,ke.errors=[],ke.loading={absenceTypes:!0,entitlements:!0},ke.managedContacts=[],ke.mode="",ke.newStatusOnSave=null,ke.period={},ke.postContactSelection=!1,ke.requestStatuses={},ke.selectedAbsenceType={},ke.staffMemberSelectionComplete=!1,ke.submitting=!1,ke.balance={closing:0,opening:0,change:{amount:0,breakdown:[]}},ke.canChangeAbsenceType=S,ke.canSubmit=T,ke.closeAlert=O,ke.deleteLeaveRequest=M,ke.dismissModal=E,ke.getStatuses=U,ke.getStatusFromValue=H,ke.initAfterContactSelection=G,ke.initRequestAttributes=X,ke.isLeaveStatus=te,ke.isLeaveType=ne,ke.isMode=ae,ke.isRole=oe,ke.submit=_e,ke.updateAbsenceType=Ce,function(){ke.loading.absenceTypes=!0,Y(),J(),r.all([ce(),Q(),se(),de()]).then(K).then(ye).then(ve).then(function(){return ke.canManage&&!ke.isMode("edit")&&le()}).then(function(){if(ke.selectedContactId&&(ke.request.contact_id=ke.selectedContactId),ke.request.contact_id)return ke.initAfterContactSelection()}).catch(V).finally(function(){ke.loading.absenceTypes=!1})}()}t.controller("RequestCtrl",r),r.$inject=["$log","$q","$rootScope","$scope","$uibModalInstance","checkPermissions","api.optionGroup","dialog","pubSub","directiveOptions","Contact","Session","AbsencePeriod","AbsenceType","Entitlement","LeaveRequest","LeaveRequestInstance","shared-settings","SicknessRequestInstance","TOILRequestInstance","LeaveRequestService"]}),define("leave-absences/shared/services/leave-popup.service",["common/lodash","common/modules/angular-date","leave-absences/shared/modules/services","common/services/angular-date/date-format","common/services/notification.service","leave-absences/shared/controllers/request.controller"],function(e,t){"use strict";function n(e,t,n,a,r,o,s,i,u){function c(e){return i.get().then(function(t){return e.roleOf(t.contactId)}).then(function(e){return"none"!==e})}function l(e,n,r,s,i){a.open({appendTo:t.children().eq(0),templateUrl:o.sharedPathTpl+"components/leave-request-popup/leave-request-popup.html",controller:"RequestCtrl",controllerAs:"$ctrl",windowClass:"chr_leave-request-modal",resolve:{directiveOptions:function(){return{leaveType:n,leaveRequest:e,selectedContactId:r,isSelfRecord:s,forceRecalculateBalanceChange:i}},format:["DateFormat",function(e){return e.getDateFormat()}]}})}function d(e){return u.find(e).then(function(e){return c(e).then(function(t){t?l(e,e.request_type,e.contact_id,"my-leave"===n.section):r.error("Error","You dont have permission to see this leave request")})}).catch(function(e){r.error("Error",e)})}return e.debug("LeavePopup"),{openModal:l,openModalByID:d}}t.factory("LeavePopup",n),n.$inject=["$log","$rootElement","$rootScope","$uibModal","notificationService","shared-settings","DateFormat","Session","LeaveRequest"]}),define("leave-absences/my-leave/modules/components",["common/angular"],function(e){return e.module("my-leave.components",[])}),define("leave-absences/my-leave/components/my-leave-container.component",["leave-absences/my-leave/modules/components"],function(e){e.component("myLeaveContainer",{bindings:{contactId:"<"},templateUrl:["settings",function(e){return e.pathTpl+"components/my-leave-container.html"}],controllerAs:"myleave",controller:["$log","$rootScope","$state",function(e,t,n){function a(){n.go(r.tabName)}e.debug("Component: my-leave-container"),t.section="my-leave";var r=this;r.tabName=n.current.name,r.changeTab=a}]})}),function(e){define("leave-absences/my-leave/modules/settings",["common/angular"],function(t){return t.module("my-leave.settings",[]).constant("settings",{debug:e.debug,pathTpl:e.vars.leaveAndAbsences.baseURL+"/views/my-leave/"})})}(CRM),function(e){define("leave-absences/my-leave/modules/config",["common/angular","leave-absences/my-leave/modules/settings"],function(t){return t.module("my-leave.config",["my-leave.settings"]).config(["$stateProvider","$resourceProvider","$urlRouterProvider","$httpProvider","$logProvider","settings",function(t,n,a,r,o,s){o.debugEnabled(s.debug),n.defaults.stripTrailingSlashes=!1,r.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",a.otherwise("/my-leave/report"),t.state("my-leave",{abstract:!0,url:"/my-leave",template:' ',resolve:{contactId:function(){return e.vars.leaveAndAbsences.contactId},format:["DateFormat",function(e){return e.getDateFormat()}]}}).state("my-leave.report",{url:"/report?leave-request-id",template:' ',onEnter:["$stateParams","LeavePopup",function(e,t){e["leave-request-id"]&&t.openModalByID(e["leave-request-id"])}]}).state("my-leave.calendar",{url:"/calendar",template:' '})}])})}(CRM),define("leave-absences/my-leave/app",["common/angular","common/angularBootstrap","common/text-angular","common/directives/loading","common/directives/scroll-shadows.directive","common/directives/time-amount-picker.directive","common/directives/timepicker-select.directive","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/models/option-group","common/modules/dialog","common/services/check-permissions","common/services/angular-date/date-format","leave-absences/shared/ui-router","leave-absences/shared/modules/shared-settings","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/components/leave-calendar.component","leave-absences/shared/components/leave-calendar-day.component","leave-absences/shared/components/leave-calendar-legend.component","leave-absences/shared/components/leave-calendar-month.component","leave-absences/shared/components/leave-request-actions.component","leave-absences/shared/components/leave-request-popup-comments-tab.component","leave-absences/shared/components/leave-request-popup-details-tab.component","leave-absences/shared/components/leave-request-popup-files-tab","leave-absences/shared/components/leave-request-record-actions.component","leave-absences/shared/components/staff-leave-report.component","leave-absences/shared/controllers/sub-controllers/request-modal-details-leave.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-sickness.controller","leave-absences/shared/controllers/sub-controllers/request-modal-details-toil.controller","leave-absences/shared/models/absence-period.model","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/calendar.model","leave-absences/shared/models/entitlement.model","leave-absences/shared/models/leave-request.model","leave-absences/shared/models/public-holiday.model","leave-absences/shared/modules/shared-settings","leave-absences/shared/modules/shared-settings","leave-absences/shared/services/leave-popup.service","leave-absences/my-leave/components/my-leave-container.component","leave-absences/my-leave/modules/config"],function(e){return e.module("my-leave",["ngResource","ngAnimate","ui.bootstrap","ui.router","textAngular","common.angularDate","common.dialog","common.directives","common.filters","common.mocks","common.models","common.services","leave-absences.components","leave-absences.controllers","leave-absences.models","leave-absences.services","leave-absences.settings","my-leave.components","my-leave.config"]).run(["$log","$rootScope","shared-settings","settings",function(e,t,n,a){e.debug("app.run"),t.sharedPathTpl=n.sharedPathTpl,t.settings=a}]),e}),function(e,t){var n=e.vars.leaveAndAbsences.baseURL+"/js/angular/src/leave-absences";t.config({urlArgs:"bust="+(new Date).getTime(),paths:{"leave-absences/shared":n+"/shared","leave-absences/my-leave":n+"/my-leave"}}),t(["leave-absences/shared/config"],function(){t(["leave-absences/my-leave/app"],function(e){e.bootstrap(document.querySelector("[data-leave-absences-my-leave]"),["my-leave"])})})}(CRM,require),define("my-leave",function(){});
//# sourceMappingURL=/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/dist/my-leave.js.map
\ No newline at end of file
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js
index 638441ccb48..8f7cf0ec81e 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-request-record-actions.component.js
@@ -8,8 +8,8 @@ define([
components.component('leaveRequestRecordActions', {
bindings: {
contactId: '<',
- selectedContactId: '<',
- isSelfRecord: '<'
+ isSelfRecord: '<',
+ selectedContactId: '<'
},
templateUrl: ['shared-settings', function (sharedSettings) {
return sharedSettings.sharedPathTpl + 'components/leave-request-record-actions.html';
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_absence-work-patterns.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_absence-work-patterns.scss
index 962a3cb53b1..b9d628d75ce 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_absence-work-patterns.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_absence-work-patterns.scss
@@ -1,3 +1,7 @@
+.chr_absence-work-pattern__add-custom {
+ margin-bottom: 20px;
+}
+
.chr_absence-work-pattern__custom-work-pattern {
td:nth-child(1) {
width: 40%;
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
index 2690e40bddf..626b12d8c79 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/_leave-request-record-actions.scss
@@ -1,33 +1,30 @@
leave-request-record-actions {
display: block;
- .fa,
- .btn-group {
- margin-right: $crm-gap-medium;
- }
-}
-
-leave-request-record-actions .btn-toolbar {
- margin-left: 0;
- overflow: inherit;
-
- .btn-group,
- .btn {
+ .leave-request-record-actions__button {
+ display: block;
+ float: left;
margin-left: 0;
+
+ &:first-child {
+ margin-right: $crm-gap-medium;
+ }
}
}
@media screen and (max-width: $screen-xs-max) {
leave-request-record-actions {
- .btn-group,
- .btn {
- display: block;
+ .leave-request-record-actions__button {
width: 100%;
- }
- .btn-group {
- margin-bottom: $crm-gap-medium;
- margin-right: 0;
+ > .btn {
+ width: 100%;
+ }
+
+ &:first-child {
+ margin-bottom: $crm-gap-medium;
+ margin-right: 0;
+ }
}
}
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
index 3c9e65ae305..656300104a6 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/scss/pages/_absence-tab-page.scss
@@ -8,6 +8,6 @@
}
leave-request-record-actions {
- margin-bottom: $crm-panel-nested-indent;
+ margin-bottom: 20px;
}
}
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-container.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-container.html
index ebb325809dc..49f2d79ae32 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-container.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-container.html
@@ -1,7 +1,6 @@
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html
index 77106b7ed35..07c8fafdddf 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/absence-tab/components/absence-tab-work-patterns.html
@@ -1,8 +1,6 @@
-
-
- ADD CUSTOM WORK PATTERN
-
-
+
+ ADD CUSTOM WORK PATTERN
+
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/admin-dashboard/components/admin-dashboard-container.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/admin-dashboard/components/admin-dashboard-container.html
index 9170855c942..17366f6455e 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/admin-dashboard/components/admin-dashboard-container.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/admin-dashboard/components/admin-dashboard-container.html
@@ -2,7 +2,6 @@
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html b/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html
index 7ee85885f06..ae09d81edfa 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/views/manager-leave/components/manager-leave-container.html
@@ -1,7 +1,6 @@
-
diff --git a/com.civicrm.hrjobroles/views/include/job_role_panel.html b/com.civicrm.hrjobroles/views/include/job_role_panel.html
index f2b61df5eb3..ad992fdc223 100755
--- a/com.civicrm.hrjobroles/views/include/job_role_panel.html
+++ b/com.civicrm.hrjobroles/views/include/job_role_panel.html
@@ -205,10 +205,10 @@
-
@@ -238,10 +238,10 @@
-
@@ -271,10 +271,10 @@
-
From 49e363844aa45792d8e0f2fd28799d17ece822b4 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Mon, 26 Mar 2018 10:49:29 +0100
Subject: [PATCH 068/203] PCHR-3451: Upgrade existing work pattern to the new
default value
---
.../CRM/HRLeaveAndAbsences/Upgrader.php | 1 +
.../HRLeaveAndAbsences/Upgrader/Step/1022.php | 22 +++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
index 9b9fd3058a4..bc583e58322 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader.php
@@ -27,6 +27,7 @@ class CRM_HRLeaveAndAbsences_Upgrader extends CRM_HRLeaveAndAbsences_Upgrader_Ba
use CRM_HRLeaveAndAbsences_Upgrader_Step_1019;
use CRM_HRLeaveAndAbsences_Upgrader_Step_1020;
use CRM_HRLeaveAndAbsences_Upgrader_Step_1021;
+ use CRM_HRLeaveAndAbsences_Upgrader_Step_1022;
/**
* A list of directories to be scanned for XML installation files
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php
new file mode 100644
index 00000000000..5e19ae1ecf1
--- /dev/null
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php
@@ -0,0 +1,22 @@
+ ['id'],
+ 'api.ContactWorkPattern.update' => [
+ 'change_reason' => 1,
+ 'id' => "\$value.id"
+ ],
+ ]);
+
+ return TRUE;
+ }
+}
From 95e94778654f80f4dce29b378f300df0a9fe3f19 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Mon, 26 Mar 2018 14:44:23 +0100
Subject: [PATCH 069/203] PCHR-3451: PR Feedback
---
.../HRLeaveAndAbsences/Upgrader/Step/1022.php | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php
index 5e19ae1ecf1..d48ecf45232 100644
--- a/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php
+++ b/uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1022.php
@@ -9,13 +9,15 @@ trait CRM_HRLeaveAndAbsences_Upgrader_Step_1022 {
*/
public function upgrade_1022()
{
- civicrm_api3('ContactWorkPattern', 'get', [
- 'return' => ['id'],
- 'api.ContactWorkPattern.update' => [
- 'change_reason' => 1,
- 'id' => "\$value.id"
- ],
- ]);
+ $query = 'UPDATE civicrm_hrleaveandabsences_contact_work_pattern SET change_reason =
+ (
+ SELECT cov.value FROM civicrm_option_value cov LEFT JOIN civicrm_option_group cog
+ ON (cog.id = cov.option_group_id)
+ WHERE cog.name = "hrleaveandabsences_work_pattern_change_reason"
+ AND cov.is_default = 1
+ )';
+
+ CRM_Core_DAO::executeQuery($query);
return TRUE;
}
From 877fe044b6ac0bb4d5d998a876e5d99b19f388c2 Mon Sep 17 00:00:00 2001
From: Samson Alajede
Date: Tue, 27 Mar 2018 09:59:20 +0100
Subject: [PATCH 070/203] PCHR-3162: Merged in updates from staging
---
bin/git-release.sh | 3 +-
com.civicrm.hrjobroles/info.xml | 11 ++-
contactaccessrights/info.xml | 11 ++-
contactsummary/css/contactsummary.css | 2 +-
contactsummary/info.xml | 11 ++-
contactsummary/scss/contactsummary.scss | 11 +--
hrbank/info.xml | 7 +-
hrcareer/info.xml | 7 +-
hrcase/info.xml | 7 +-
hrdemog/info.xml | 7 +-
hrident/info.xml | 3 +-
hrim/info.xml | 7 +-
hrjobcontract/info.xml | 11 ++-
hrjobcontract/js/dist/job-contract.min.js | 4 +-
.../controllers/form/form-pay.controller.js | 4 +-
hrmed/info.xml | 7 +-
hrprofile/info.xml | 7 +-
hrqual/info.xml | 7 +-
hrrecruitment/info.xml | 7 +-
hrreport/info.xml | 7 +-
hrstaffdir/info.xml | 7 +-
hrui/info.xml | 7 +-
hrvisa/info.xml | 3 +-
org.civicrm.bootstrapcivihr/info.xml | 10 +--
org.civicrm.hremergency/info.xml | 14 +--
org.civicrm.reqangular/info.xml | 11 ++-
uk.co.compucorp.civicrm.hrcomments/info.xml | 6 +-
.../info.xml | 6 +-
uk.co.compucorp.civicrm.hrcore/info.xml | 6 +-
.../templates/CRM/HRCore/UserMenuMarkup.tpl | 2 +-
uk.co.compucorp.civicrm.hremails/info.xml | 6 +-
.../HRLeaveAndAbsences/BAO/LeaveRequest.php | 84 +++++++++++++----
.../CRM/HRLeaveAndAbsences/Upgrader.php | 3 +-
.../HRLeaveAndAbsences/Upgrader/Step/1023.php | 27 ++++++
.../info.xml | 6 +-
.../Form/ManageEntitlements.tpl | 14 +--
.../HRLeaveAndAbsences/Page/AbsencePeriod.tpl | 2 +-
.../HRLeaveAndAbsences/Page/AbsenceType.tpl | 2 +-
.../HRLeaveAndAbsences/Page/PublicHoliday.tpl | 2 +-
.../HRLeaveAndAbsences/Page/WorkPattern.tpl | 4 +-
.../BAO/LeaveRequestTest.php | 89 ++++++++++++++++++-
.../tests/phpunit/api/v3/LeaveRequestTest.php | 9 +-
.../option_groups/toil_amounts_install.xml | 12 ---
uk.co.compucorp.civicrm.hrsampledata/info.xml | 6 +-
44 files changed, 311 insertions(+), 168 deletions(-)
create mode 100644 uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/Upgrader/Step/1023.php
diff --git a/bin/git-release.sh b/bin/git-release.sh
index 9b008bf0ea5..8e774a84937 100755
--- a/bin/git-release.sh
+++ b/bin/git-release.sh
@@ -26,7 +26,8 @@ org.civicrm.reqangular \
uk.co.compucorp.civicrm.hrcore \
uk.co.compucorp.civicrm.hremails \
uk.co.compucorp.civicrm.hrleaveandabsences \
-uk.co.compucorp.civicrm.hrcomments
+uk.co.compucorp.civicrm.hrcomments \
+uk.co.compucorp.civicrm.hrcontactactionsmenu
)
set -e
diff --git a/com.civicrm.hrjobroles/info.xml b/com.civicrm.hrjobroles/info.xml
index fb09ae3447f..3f08b059f5a 100644
--- a/com.civicrm.hrjobroles/info.xml
+++ b/com.civicrm.hrjobroles/info.xml
@@ -5,16 +5,15 @@
Job Roles implementation for CiviHR
AGPL-3.0
- gregmeszaros
- meszaros275@gmail.com
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/Hrjobroles
diff --git a/contactaccessrights/info.xml b/contactaccessrights/info.xml
index 1b615f87fbd..bcf188ba4ee 100644
--- a/contactaccessrights/info.xml
+++ b/contactaccessrights/info.xml
@@ -5,16 +5,15 @@
This extension allows setting up access rights for contacts.
AGPL-3.0
- Robin Mitra
- robinmitra1@gmail.com
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/Contactaccessrights
diff --git a/contactsummary/css/contactsummary.css b/contactsummary/css/contactsummary.css
index 7955d5ba3db..8ff08c076f6 100644
--- a/contactsummary/css/contactsummary.css
+++ b/contactsummary/css/contactsummary.css
@@ -1 +1 @@
-#bootstrap-theme .leave-widget h4{color:#4D4D69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4D4D69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071BD;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .date-range-calendar{font-size:13px;font-weight:normal}#bootstrap-theme .date-range-calendar__from,#bootstrap-theme .date-range-calendar__to{float:left;margin-bottom:10px}#bootstrap-theme .date-range-calendar__to::before{content:'\f178';float:left;font-size:16px;font-family:'FontAwesome';line-height:21px;margin:10px;margin-left:16px}#bootstrap-theme .date-range-calendar__day{background:#E8EEF0;border:1px solid #DEE4ED;border-radius:2px;border-top:none;display:inline-block;float:left;font-size:18px;height:40px;line-height:32px;margin-right:10px;text-align:center;width:40px}#bootstrap-theme .date-range-calendar__day::before{border-top:8px solid #0071BD;border-top-left-radius:2px;border-top-right-radius:2px;content:'';display:block;margin:-1px;width:calc(100% + 2px)}#bootstrap-theme .date-range-calendar__time{display:block}#bootstrap-theme button.info-button{background:none;border:none}#bootstrap-theme button.info-button .fa{color:#0071BD}#bootstrap-theme ul.week-heatmap{font-size:0;list-style:none;padding:0}#bootstrap-theme ul.week-heatmap li{background-color:#44CB7E;border-radius:2px;display:inline-block;font-size:16px;font-weight:600;height:40px;line-height:40px;margin-bottom:10px;margin-right:10px;text-align:center;width:40px}#bootstrap-theme ul.week-heatmap li.week-heatmap__medium{background-color:#E6AB5E}#bootstrap-theme ul.week-heatmap li.week-heatmap__high{color:#fff;background-color:#CF3458}#bootstrap-theme ul.week-heatmap li.week-heatmap__disabled{background-color:#E8EEF0;color:#464354}#contactsummary{padding:20px}#contactsummary .panel--key-dates>.panel-body{padding-bottom:0;padding-top:0}#contactsummary .panel--key-details{margin-bottom:0 !important}
+#bootstrap-theme .leave-widget h4{color:#4D4D69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px}#bootstrap-theme .leave-widget__types>table,#bootstrap-theme .leave-widget__sickness>table,#bootstrap-theme .leave-widget__next-leave>table{border:none}#bootstrap-theme .leave-widget__types>table thead tr th,#bootstrap-theme .leave-widget__sickness>table thead tr th,#bootstrap-theme .leave-widget__next-leave>table thead tr th{color:#4D4D69;font-size:13px;font-weight:normal;margin-bottom:0;padding-bottom:13px;background:none;width:35%}#bootstrap-theme .leave-widget__types>table thead tr th:first-child,#bootstrap-theme .leave-widget__sickness>table thead tr th:first-child,#bootstrap-theme .leave-widget__next-leave>table thead tr th:first-child{width:65%}#bootstrap-theme .leave-widget__types>table tbody tr td,#bootstrap-theme .leave-widget__sickness>table tbody tr td,#bootstrap-theme .leave-widget__next-leave>table tbody tr td{color:#0071BD;font-size:16px;font-weight:600;padding-bottom:9px}#bootstrap-theme .leave-widget__types>table tbody tr td:first-child,#bootstrap-theme .leave-widget__sickness>table tbody tr td:first-child,#bootstrap-theme .leave-widget__next-leave>table tbody tr td:first-child{color:#464354}#bootstrap-theme .leave-widget hr{border-color:#DEE4ED;margin-bottom:25px;margin-top:25px}#bootstrap-theme .leave-widget__sickness h4{margin-top:18px}#bootstrap-theme .leave-widget__next-leave h3{font-size:16px;margin-bottom:16px;margin-top:0}#bootstrap-theme .leave-widget__next-leave__deduction{font-size:16px;font-weight:600;color:#464354}#bootstrap-theme .date-range-calendar{font-size:13px;font-weight:normal}#bootstrap-theme .date-range-calendar__from,#bootstrap-theme .date-range-calendar__to{float:left;margin-bottom:10px}#bootstrap-theme .date-range-calendar__to::before{content:'\f178';float:left;font-size:16px;font-family:'FontAwesome';line-height:21px;margin:10px;margin-left:16px}#bootstrap-theme .date-range-calendar__day{background:#E8EEF0;border:1px solid #DEE4ED;border-radius:2px;border-top:none;display:inline-block;float:left;font-size:18px;height:40px;line-height:32px;margin-right:10px;text-align:center;width:40px}#bootstrap-theme .date-range-calendar__day::before{border-top:8px solid #0071BD;border-top-left-radius:2px;border-top-right-radius:2px;content:'';display:block;margin:-1px;width:calc(100% + 2px)}#bootstrap-theme .date-range-calendar__time{display:block}#bootstrap-theme button.info-button{background:none;border:none}#bootstrap-theme button.info-button .fa{color:#0071BD}#bootstrap-theme ul.week-heatmap{font-size:0;list-style:none;padding:0}#bootstrap-theme ul.week-heatmap li{background-color:#44CB7E;border-radius:2px;display:inline-block;font-size:16px;font-weight:600;height:40px;line-height:40px;margin-bottom:10px;margin-right:10px;text-align:center;width:40px}#bootstrap-theme ul.week-heatmap li.week-heatmap__medium{background-color:#E6AB5E}#bootstrap-theme ul.week-heatmap li.week-heatmap__high{color:#fff;background-color:#CF3458}#bootstrap-theme ul.week-heatmap li.week-heatmap__disabled{background-color:#E8EEF0;color:#464354}#contactsummary .panel--key-dates>.panel-body{padding-bottom:0;padding-top:0}#contactsummary .panel--key-details{margin-bottom:0 !important}
diff --git a/contactsummary/info.xml b/contactsummary/info.xml
index 4e435d6526c..c520647e0ad 100644
--- a/contactsummary/info.xml
+++ b/contactsummary/info.xml
@@ -5,16 +5,15 @@
Custom contact summary page
AGPL-3.0
- Robin Mitra
- robinmitra1@gmail.com
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/Contactsummary
diff --git a/contactsummary/scss/contactsummary.scss b/contactsummary/scss/contactsummary.scss
index b575ed53ace..8d86b2d9a25 100644
--- a/contactsummary/scss/contactsummary.scss
+++ b/contactsummary/scss/contactsummary.scss
@@ -1,16 +1,13 @@
-@import "SCSSROOT/org.civicrm.shoreditch/scss/bootstrap/overrides/variables";
-@import "SCSSROOT/org.civicrm.shoreditch/base/scss/vendor/bootstrap/variables";
+@import 'SCSSROOT/org.civicrm.shoreditch/scss/bootstrap/overrides/variables';
+@import 'SCSSROOT/org.civicrm.shoreditch/base/scss/vendor/bootstrap/variables';
#bootstrap-theme {
- @import "SCSSROOT/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/leave-widget";
- @import "./components/*";
+ @import 'SCSSROOT/uk.co.compucorp.civicrm.hrleaveandabsences/scss/components/leave-widget';
+ @import './components/*';
}
#contactsummary {
- padding: 20px;
-
.panel--key-dates {
-
> .panel-body {
padding-bottom: 0;
padding-top: 0;
diff --git a/hrbank/info.xml b/hrbank/info.xml
index 0b49862ac05..728ab44bba7 100644
--- a/hrbank/info.xml
+++ b/hrbank/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRBank
diff --git a/hrcareer/info.xml b/hrcareer/info.xml
index 73778891328..6e41e7ba2ff 100644
--- a/hrcareer/info.xml
+++ b/hrcareer/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRCareer
diff --git a/hrcase/info.xml b/hrcase/info.xml
index 376ff4bed48..ab47c570dc6 100644
--- a/hrcase/info.xml
+++ b/hrcase/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRCase
diff --git a/hrdemog/info.xml b/hrdemog/info.xml
index 5970ce2c19d..2bb05c6e9b0 100644
--- a/hrdemog/info.xml
+++ b/hrdemog/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRDemog
diff --git a/hrident/info.xml b/hrident/info.xml
index 892f1a1276e..1c248c21026 100644
--- a/hrident/info.xml
+++ b/hrident/info.xml
@@ -10,11 +10,10 @@
2017-08-22
1.7.0-RC
- beta
+ stable
4.7
- This is a new, undeveloped module
CRM/HRIdent
diff --git a/hrim/info.xml b/hrim/info.xml
index 7f1d5e1023e..8909e6cccaf 100644
--- a/hrim/info.xml
+++ b/hrim/info.xml
@@ -8,11 +8,10 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
diff --git a/hrjobcontract/info.xml b/hrjobcontract/info.xml
index 60dd01245ec..6fa1283915b 100644
--- a/hrjobcontract/info.xml
+++ b/hrjobcontract/info.xml
@@ -5,16 +5,15 @@
Track job positions, job roles, etc (Human Resources)
AGPL-3.0
- Mateusz Cieplinski
- mateusz@coldrun.pl
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new version for Job (CiviHR) extension
CRM/Hrjobcontract
diff --git a/hrjobcontract/js/dist/job-contract.min.js b/hrjobcontract/js/dist/job-contract.min.js
index bb7dae57586..df6dd1ccad4 100644
--- a/hrjobcontract/js/dist/job-contract.min.js
+++ b/hrjobcontract/js/dist/job-contract.min.js
@@ -27,7 +27,7 @@ THE SOFTWARE.
// Copyright CiviCRM LLC 2013. See http://civicrm.org/licensing
-define("job-contract/modules/job-contract.config",["common/angular"],function(e){"use strict";function t(e,t,n,o,r,i,a){t.debugEnabled(a.debug),o.resolveForAll({format:["DateFormat",function(e){return e.getDateFormat()}]}).when("/",{controller:"ContractListController",templateUrl:a.pathApp+"views/contractList.html",resolve:{contractList:["contractService",function(e){return e.get()}]}}).otherwise({redirectTo:"/"}),n.defaults.stripTrailingSlashes=!1,e.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",i.theme="bootstrap",r.showWeeks=!1}e.module("job-contract.config",["job-contract.constants"]).config(t),t.$inject=["$httpProvider","$logProvider","$resourceProvider","$routeProvider","uibDatepickerConfig","uiSelectConfig","settings"]}),define("job-contract/modules/job-contract.constants",["common/angular"],function(e){"use strict";e.module("job-contract.constants",[]).constant("settings",{classNamePrefix:"hrjc-",contactId:CRM.jobContractTabApp.contactId,debug:+CRM.debug,pathApp:CRM.jobContractTabApp.path,pathFile:CRM.url("civicrm/hrjobcontract/file/"),pathReport:CRM.url("civicrm/report/hrjobcontract/summary"),pathRest:CRM.url("civicrm/ajax/rest"),pathTpl:CRM.jobContractTabApp.path+"views/",CRM:{options:CRM.FieldOptions||{},defaultCurrency:CRM.jobContractTabApp.defaultCurrency,apiTsFmt:"YYYY-MM-DD HH:mm:ss",fields:CRM.jobContractTabApp.fields,maxFileSize:CRM.jobContractTabApp.maxFileSize}})}),define("job-contract/controllers/contract.controller",["common/lodash","common/moment"],function(e,t){"use strict";function n(n,o,r,i,a,c,s,l,u,d,f,v,m,p,_,h,b,y,g,j,C,$){function w(t){var n,o;return r.all([v.getOne({jobcontract_revision_id:t.details_revision_id}),m.getOne({jobcontract_revision_id:t.hour_revision_id}),h.getOne({jobcontract_revision_id:t.health_revision_id}),p.getOne({jobcontract_revision_id:t.pay_revision_id}),b.getOne({jobcontract_revision_id:t.pension_revision_id}),_.getOne({jobcontract_revision_id:t.leave_revision_id})]).then(function(t){return o={details:t[0],hour:t[1],health:t[2],pay:t[3],pension:t[4],leave:t[5]},n={contract:c.contract},e.extend(n,e.cloneDeep(c.model)),e.extend(n.details,o.details),e.extend(n.hour,o.hour),e.extend(n.health,o.health),e.extend(n.pay,o.pay),e.extend(n.pension,o.pension),D(n.leave,o.leave),n})}function S(){c.$on("updateContractView",function(){c.$broadcast("hrjc-loader-show"),f.fullDetails(c.revisionCurrent.jobcontract_id).then(function(e){A(e),c.$broadcast("hrjc-loader-hide")}).then(E)})}function D(t,n,o){o=o||"",e.each(t,function(t){e.extend(t,n?e.find(n,{leave_type:t.leave_type})||o:o)})}function R(n,o){var a,s,d,v,m,p,_,h,b=["details","hour","pay"],g={controller:"ModalContractController",appendTo:i.find("div").eq(0),templateUrl:u.pathApp+"views/modalForm.html?v=4448",windowClass:"modal-contract",size:"lg",resolve:{action:function(){return n||"view"},content:function(){return{}},entity:function(){return o?I.fetchRevisionDetails(o):{contract:c.contract,details:c.details,hour:c.hour,pay:c.pay,leave:c.leave,health:c.health,pension:c.pension}},files:function(){return o?r.all({details:y.get(o.details_revision_id,"civicrm_hrjobcontract_details"),pension:y.get(o.pension_revision_id,"civicrm_hrjobcontract_pension")}):T},utils:function(){return c.utils}}};switch(c.$broadcast("hrjc-loader-show"),n){case"edit":g.resolve.content=function(){return{allowSave:!0,isDisabled:!1,copy:{close:"Cancel",save:"Save without making a new revision",title:"Edit contract"}}};break;case"change":g.resolve.content=function(){return{allowSave:!0,isDisabled:!1,copy:{close:"Cancel",save:"Save and make a new revision",title:"Change contract terms"}}}}a=l.open(g),a.result.then(function(n){n&&(f.updateHeaderInfo(),A(n),L(n.details.period_end_date),n.revisionCreated?(s=t(new Date(n.revisionCreated.effective_date)),d=t(new Date(c.revisionCurrent.effective_date)),v=t(),m={revisionEntityIdObj:n.revisionCreated,details:n.details,hour:n.hour,pay:n.pay},p=d.diff(v,"day")<=0||d.diff(s,"day")<=0,n.files&&(p?E().then(function(e){m.files=e}):r.all({details:y.get(n.revisionCreated.details_revision_id,"civicrm_hrjobcontract_details")}).then(function(e){m.files=e})),c.revisionList.unshift(n.revisionCreated),c.revisionDataList.unshift(m)):(c.contract.is_primary!==n.contract.is_primary&&c.$parent.$parent.toggleIsPrimary(c.contract.id),e.each(c.revisionDataList,function(t){for(_=0,h={};b[_];)t.revisionEntityIdObj[b[_]+"_revision_id"]===c.revisionCurrent[b[_]+"_revision_id"]&&(h[b[_]]=n[b[_]],"details"===b[_]&&n.files&&E().then(function(n){h.files=n,e.extend(t,h)}),e.extend(t,h)),_++})),CRM.refreshParent("#hrjobroles"),n.haveEntitlementFieldsChanged?$.updateEntitlements(c.contract.contact_id):C.success("Success","Contract successfully updated"))})}function P(e){var t,o=[],a="leave"!==e?"getOne":"get",s=0,f=c.revisionList.length;if(c.$broadcast("hrjc-loader-show"),!e)return null;for(s;sChange Contract Terms: When an employeees job or role changes, i.e. promotion, secondment or move,you can use this wizard to update the details of the contract and record a newrevision of the contract. A contract history is kept so you can always see theprevious version of the contract.
Correct an error on the contract record: If you notice an issue or error with the job terms you can correct these withoutcreating a new job history record. These changes are not stored as a new revisionof the contract.
')},c.utils={contractListLen:u.length},c.delete=j,c.modalContract=C,c.toggleIsPrimary=$,function(){for(w in R)S[w]=R[w].getFields();o.all(S).then(function(e){c.fields=e,n.debug("FIELDS:"),n.debug(e);for(w in R)D[w]=R[w].model(e[w]);return o.all(D)}).then(function(o){c.model=o,n.debug("MODEL:"),n.debug(o),u=t("orderBy")(u,"-is_primary"),e.forEach(u,function(e){+e.is_current?c.contractCurrent.push(e):c.contractPast.push(e)}),c.$watchCollection("contractCurrent",function(){c.utils.contractListLen=c.contractCurrent.length+c.contractPast.length}),c.$watchCollection("contractPast",function(){c.utils.contractListLen=c.contractCurrent.length+c.contractPast.length}),i.$broadcast("hrjc-loader-hide"),c.contractListLoaded=!0}),o.all(P).then(function(t){e.extend(c.utils,t)})}()}return n.__name="ContractListController",n.$inject=["$filter","$log","$q","$rootElement","$rootScope","$sce","$scope","$window","$uibModal","contractList","contractService","contractDetailsService","contractHourService","contractPayService","contractLeaveService","contractHealthService","contractPensionService","utilsService","settings","pubSub"],n}),define("job-contract/controllers/revision-list.controller",["common/angular","common/lodash"],function(e,t){"use strict";function n(t,n,o,r,i,a,c,s,l,u,d,f,v,m,p){function _(){var e=(a.currentPage-1)*a.itemsPerPage,t=e+a.itemsPerPage;a.revisionDataListPage=$.slice(e,t)}function h(e,t){if(1===a.revisionList.length)return void t.stopPropagation();if(e&&"number"==typeof+e){c.open({appendTo:r.find("div").eq(0),templateUrl:s.pathApp+"views/modalDialog.html",size:"sm",controller:"ModalDialogController",resolve:{content:function(){return{msg:"Are you sure you want to delete this job contract revision?"}}}}).result.then(function(t){t&&(a.$broadcast("hrjc-loader-show"),l.deleteRevision(e).then(function(t){var n=0,o=a.revisionList.length;if(!t.is_error){for(n;nt&&g(),a.sortBy(),a.createPage()})}function y(e){var t=e.effective_date,n=e.change_reason;c.open({appendTo:r.find("div").eq(0),templateUrl:s.pathApp+"views/modalChangeReason.html?v="+(new Date).getTime(),controller:"ModalChangeReasonController",resolve:{content:function(){return{copy:{title:"Edit revision data"}}},date:function(){return t},reasonId:function(){return n}}}).result.then(function(o){o.date===t&&o.reasonId===n||l.saveRevision({id:e.id,change_reason:o.reasonId,effective_date:o.date}).then(function(){e.effective_date=o.date,e.change_reason=o.reasonId,a.sortBy(),a.createPage(),a.revisionCurrent.id!==g()&&a.$emit("updateContractView")})})}function g(){var n,o=0;if(a.revisionList.length){var r=t("orderBy")(a.revisionList,["effective_date","id"]);if(e.forEach(r,function(e){new Date(e.effective_date).setHours(0,0,0,0)<=(new Date).setHours(0,0,0,0)&&(n=e)}),!n)do{n=r[o],o++}while(r[o]&&r[o-1].effective_date===r[o].effective_date);return e.extend(a.revisionCurrent,n),n.id}return null}function j(e,n){void 0!==e&&(a.sortCol===e?a.sortReverse=!a.sortReverse:a.sortCol=e),void 0!==n&&(a.sortReverse=n),$=t("orderBy")(a.revisionDataList,a.sortCol,a.sortReverse)}n.debug("Controller: RevisionListController");var C=a.contract.id,$=a.revisionDataList;a.changeReasons=i.options.contract.change_reason,a.currentPage=1,a.itemsPerPage=5,a.maxSize=5,a.sortCol="revisionEntityIdObj.effective_date",a.sortReverse=!0,a.urlCSV=function(){var t=s.pathReport+(s.pathReport.indexOf("?")>-1?"&":"?"),n=a.fields;return e.forEach(n,function(n,o){t+="fields["+o+"_revision_id]=1&",e.forEach(n,function(e){t+="fields["+o+"_"+e.name+"]=1&"})}),t+="fields[sort_name]=1&fields[first_name]=1&fields[last_name]=1&fields[external_identifier]=1&fields[email]=1&fields[street_address]=1&fields[city]=1&fields[name]=1&fields[contract_contact_id]=1&fields[contract_contract_id]=1&fields[jobcontract_revision_id]=1&fields[change_reason]=1&fields[created_date]=1&fields[effective_date]=1&fields[modified_date]=1&order_bys[1][column]=id&order_bys[1][order]=ASC&order_bys[2][column]=civicrm_hrjobcontract_revision_revision_id&order_bys[2][order]=ASC&order_bys[3][column]=-&order_bys[3][order]=ASC&order_bys[4][column]=-&order_bys[4][order]=ASC&order_bys[5][column]=-&order_bys[5][order]=ASC&contract_id_op=eq&permission=access+CiviReport&row_count=&_qf_Summary_submit_csv=Preview+CSV&groups=&contract_id_value="+C+"&group_bys[civicrm_hrjobcontract_revision_revision_id]=1"}(),a.display={effectiveDate:!0,position:!0,payScale:!0,totalSalary:!0,hours:!0,placeOfWork:!0,recordedBy:!0,changeReason:!0},a.createPage=_,a.deleteRevision=h,a.modalRevisionEdit=y,a.sortBy=j,function(){b(),a.revisionDataList||(a.$broadcast("hrjc-loader-show"),p.fetchRevisions(C).then(function(e){a.revisionList=e.revisionList,a.revisionDataList=e.revisionDataList,a.$broadcast("hrjc-loader-hide")}))}()}return n.__name="RevisionListController",n.$inject=["$filter","$log","$q","$rootElement","$rootScope","$scope","$uibModal","settings","contractService","contractDetailsService","contractHourService","contractPayService","contractFilesService","contractRevisionService","contractRevisionListService"],n}),define("job-contract/controllers/form/form-general.controller",["common/moment"],function(e){"use strict";function t(t,n,o){function r(e,t){e.preventDefault(),e.stopPropagation(),n[t]=!0}function i(t,n){if(!t||!n)return null;var o,r,i,a;return i=e(n),i.add(1,"days"),a=i.diff(t,"years"),i.add(-a,"years"),r=i.diff(t,"months"),i.add(-r,"months"),o=i.diff(t,"days"),a=a>0?a>1?a+" years ":a+" year ":"",r=r>0?r>1?r+" months ":r+" month ":"",o=o>0?o>1?o+" days":o+" day":"",a+r+o||"0 days"}function a(t,n){return n=n||"min",e(t)["max"===n?"subtract":"add"](1,"day").toDate()}function c(){n.$watch("entity.details.period_start_date",function(){n.datepickerOptions.end.minDate=a(s.period_start_date,"min"),n.duration=i(s.period_start_date,s.period_end_date)}),n.$watch("entity.details.period_end_date",function(){s.period_end_date?n.datepickerOptions.start.maxDate=a(s.period_end_date,"max"):(n.datepickerOptions.start.maxDate=null,s.end_reason=null),n.duration=i(s.period_start_date,s.period_end_date)}),n.$watch("entity.details.position",function(e,t){e!==t&&s.title===t&&(n.contractForm.detailsTitle.$setViewValue(e),n.contractForm.detailsTitle.$render())}),n.$watch("entity.details.notice_amount",function(e,t){+e&&!s.notice_unit&&(n.contractForm.detailsNoticeUnit.$setValidity("required",!1),n.contractForm.detailsNoticeUnit.$dirty=!0),e!==t&&s.notice_amount_employee===t&&(s.notice_amount_employee=e)}),n.$watch("entity.details.notice_amount_employee",function(e){+e&&!s.notice_unit_employee&&(n.contractForm.detailsNoticeUnitEmployee.$setValidity("required",!1),n.contractForm.detailsNoticeUnitEmployee.$dirty=!0)}),n.$watch("entity.details.notice_unit",function(e,t){e!==t&&s.notice_unit_employee===t&&(s.notice_unit_employee=e)})}t.debug("Controller: FormGeneralController");var s=n.entity.details;n.format=o.DATE_FORMAT,n.datepickerOptions=function(){return{start:{maxDate:s.period_end_date?a(s.period_end_date,"max"):null},end:{minDate:s.period_start_date?a(s.period_start_date,"min"):null}}}(),n.dpOpen=r,function(){c()}()}return t.__name="FormGeneralController",t.$inject=["$log","$scope","HR_settings"],t}),define("job-contract/controllers/form/form-health.controller",[],function(){"use strict";function e(e,t,n){function o(e,o){e&&n.search(e,{contact_type:"Organization",contact_sub_type:o}).then(function(e){t.contacts[o]=e})}e.debug("Controller: FormHealthController"),t.contacts={Health_Insurance_Provider:[],Life_Insurance_Provider:[]},t.refreshContacts=o,function(){t.entity.health.provider&&n.getOne(t.entity.health.provider).then(function(e){t.contacts.Health_Insurance_Provider.push(e)}),t.entity.health.provider_life_insurance&&n.getOne(t.entity.health.provider_life_insurance).then(function(e){t.contacts.Life_Insurance_Provider.push(e)})}()}return e.__name="FormHealthController",e.$inject=["$log","$scope","contactService"],e}),define("job-contract/vendor/fraction",[],function(){var e=function(t,n){if(void 0!==t&&n)"number"==typeof t&&"number"==typeof n?(this.numerator=t,this.denominator=n):"string"==typeof t&&"string"==typeof n&&(this.numerator=parseInt(t),this.denominator=parseInt(n));else if(void 0===n)if(num=t,"number"==typeof num)this.numerator=num,this.denominator=1;else if("string"==typeof num){var o,r,i=num.split(" ");if(i[0]&&(o=i[0]),i[1]&&(r=i[1]),o%1==0&&r&&r.match("/"))return new e(o).add(new e(r));if(!o||r)return;if("string"==typeof o&&o.match("/")){var a=o.split("/");this.numerator=a[0],this.denominator=a[1]}else{if("string"==typeof o&&o.match("."))return new e(parseFloat(o));this.numerator=parseInt(o),this.denominator=1}}this.normalize()};return e.prototype.clone=function(){return new e(this.numerator,this.denominator)},e.prototype.toString=function(){if("NaN"===this.denominator)return"NaN";var e=this.numerator/this.denominator>0?Math.floor(this.numerator/this.denominator):Math.ceil(this.numerator/this.denominator),t=this.numerator%this.denominator,n=this.denominator,o=[];return 0!=e&&o.push(e),0!=t&&o.push((0===e?t:Math.abs(t))+"/"+n),o.length>0?o.join(" "):0},e.prototype.rescale=function(e){return this.numerator*=e,this.denominator*=e,this},e.prototype.add=function(t){var n=this.clone();return t=t instanceof e?t.clone():new e(t),td=n.denominator,n.rescale(t.denominator),t.rescale(td),n.numerator+=t.numerator,n.normalize()},e.prototype.subtract=function(t){var n=this.clone();return t=t instanceof e?t.clone():new e(t),td=n.denominator,n.rescale(t.denominator),t.rescale(td),n.numerator-=t.numerator,n.normalize()},e.prototype.multiply=function(t){var n=this.clone();if(t instanceof e)n.numerator*=t.numerator,n.denominator*=t.denominator;else{if("number"!=typeof t)return n.multiply(new e(t));n.numerator*=t}return n.normalize()},e.prototype.divide=function(t){var n=this.clone();if(t instanceof e)n.numerator*=t.denominator,n.denominator*=t.numerator;else{if("number"!=typeof t)return n.divide(new e(t));n.denominator*=t}return n.normalize()},e.prototype.equals=function(t){t instanceof e||(t=new e(t));var n=this.clone().normalize(),t=t.clone().normalize();return n.numerator===t.numerator&&n.denominator===t.denominator},e.prototype.normalize=function(){var t=function(e){return"number"==typeof e&&(e>0&&e%1>0&&e%1<1||e<0&&e%-1<0&&e%-1>-1)},n=function(e,t){if(t){var n=Math.pow(10,t);return Math.round(e*n)/n}return Math.round(e)};return function(){if(t(this.denominator)){var o=n(this.denominator,9),r=Math.pow(10,o.toString().split(".")[1].length);this.denominator=Math.round(this.denominator*r),this.numerator*=r}if(t(this.numerator)){var o=n(this.numerator,9),r=Math.pow(10,o.toString().split(".")[1].length);this.numerator=Math.round(this.numerator*r),this.denominator*=r}var i=e.gcf(this.numerator,this.denominator);return this.numerator/=i,this.denominator/=i,(this.numerator<0&&this.denominator<0||this.numerator>0&&this.denominator<0)&&(this.numerator*=-1,this.denominator*=-1),this}}(),e.gcf=function(t,n){var o=[],r=e.primeFactors(t),i=e.primeFactors(n);return r.forEach(function(e){var t=i.indexOf(e);t>=0&&(o.push(e),i.splice(t,1))}),0===o.length?1:function(){var e,t=o[0];for(e=1;eTHE FILE IS TOO LARGE AND CANNOT BE UPLOADED. PLEASE REDUCE THE SIZE OF THE FILE AND TRY AGAIN."),fte:c.trustAsHtml("FTE stands forFull Time Equivalent. This is a useful measure foran organisation that has peopleworking part-time.For a full-time person, FTE is always equal to1.0, whereas for a part-time person, the FTE will representthe fraction of standard hours that the person works on aregular basis. E.g. if the standard working day at an organisationcomprises of 8 hours, then a person who regularly works for8 hours each day would be considered to be full- time andwould have an FTE value of 1.0. A person who regularly worksfor only 4 hours each day would be considered to be apart-time person and would have an FTE value of 0.5. If theorganisation had 10 people, each with an FTE of 1.0 theactual headcount of full-time people would be 10 and theFTE headcount (equal to actual headcount multiplied by theFTE value) would also be 10. However, if the organisationhad another 10 people who each worked part-time with an FTEvalue of 0.5 the actual headcount of part-time people wouldbe 10 while the FTE headcount would only be 5. Thus for anorganisation that had a total of 10 full-time people, and 10part-time people (each with an FTE of 0.5) the actualheadcount for the organisation would be 20 while the FTEheadcount would be 15.
")},s.uploader={details:{contract_file:y.uploader("civicrm_hrjobcontract_details")},pension:{evidence_file:y.uploader("civicrm_hrjobcontract_pension",1)}},s.cancel=S,s.filesValidate=D,s.save=M,function(){e.copy(g,s.entity),s.entity.contract={is_primary:0},e.forEach(s.uploader,function(t){e.forEach(t,function(e){e.onAfterAddingAll=function(){s.filesValidate()}})}),A(),a.$broadcast("hrjc-loader-show"),P().then(function(){a.$broadcast("hrjc-loader-hide")})}()}return o.__name="ModalContractNewController",o.$inject=["$log","$q","$rootElement","$rootScope","$sce","$scope","$uibModalInstance","$uibModal","Contract","contractService","contractDetailsService","contractHourService","contractPayService","contractLeaveService","contractHealthService","contractPensionService","contractFilesService","model","utilsService","utils","settings","pubSub"],o}),define("job-contract/controllers/modal/modal-contract.controller",["common/angular","common/lodash","common/moment"],function(e,t,n){"use strict";function o(o,r,i,a,c,s,l,u,d,f,v,m,p,_,h,b,y,g,j,C,$,w,S,D,R){function P(){if("view"===y||e.equals(g,o.entity)&&e.equals(C,o.files)&&!o.uploader.details.contract_file.queue.length&&!o.uploader.pension.evidence_file.queue.length)return o.$broadcast("hrjc-loader-hide"),void i.dismiss("cancel");S.debug&&e.forEach(g,function(t,n){e.equals(t,o.entity[n])||(D.debug("======================"),D.debug("Changed entity: "+n),D.debug("Before:"),D.debug(t),D.debug("After:"),D.debug(o.entity[n]))}),r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalDialog.html?v="+(new Date).getTime(),size:"sm",controller:"ModalDialogController",resolve:{content:function(){return{copyCancel:"No",title:"Alert",msg:"Are you sure you want to cancel? Changes will be lost!"}}}}).result.then(function(e){e&&(o.$broadcast("hrjc-loader-hide"),i.dismiss("cancel"))})}function M(){return r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalChangeReason.html?v="+(new Date).getTime(),controller:"ModalChangeReasonController",resolve:{content:function(){return{copy:{title:Y.title}}},date:null,reasonId:null}}).result}function A(){var t=x("period_end_date"),n=x("period_start_date"),r=!e.equals(o.entity.leave,g.leave);return n||t||r}function L(){return r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalConfirmEdit.html?v="+(new Date).getTime(),controller:"ModalDialogController",resolve:{content:function(){return{msg:"Save without making a new revision?"}}}}).result}function E(e,t){return o.$broadcast("hrjc-loader-show"),d.validateEffectiveDate({contact_id:S.contactId,effective_date:t}).then(function(n){if(n.success)return N(e,t);CRM.alert(n.message,"Error","error"),o.$broadcast("hrjc-loader-hide")},function(e){})}function T(){o.$broadcast("hrjc-loader-show"),o.entity.details.period_end_date=o.entity.details.period_end_date||"";var t,n,s,l,d,y=e.copy(o.entity),g=o.filesTrash,j=o.uploader,C={contract:u.save(y.contract),details:f.save(y.details),hour:v.save(y.hour),pay:m.save(y.pay),leave:p.save(y.leave),health:_.save(y.health),pension:h.save(y.pension)},$=[],w=[];for(t in g)for(s=0,l=g[t].length,s;so.fileMaxSize&&e.remove()})})}),j.details.contract_file.queue.length&&$.push(b.upload(j.details.contract_file,y.details.jobcontract_revision_id)),j.pension.evidence_file.queue.length&&$.push(b.upload(j.pension.evidence_file,y.pension.jobcontract_revision_id)),t.details.period_start_date=y.details.period_start_date,t.details.period_end_date=y.details.period_end_date,t.pay.annual_benefits=y.pay.annual_benefits,t.pay.annual_deductions=y.pay.annual_deductions,$.length?(d=r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalProgress.html?v="+(new Date).getTime(),size:"sm",controller:"ModalProgressController",resolve:{uploader:function(){return j},promiseFilesUpload:function(){return $}}}),t.files=d.result,a.all(t)):(t.haveEntitlementFieldsChanged=A(),t)}).then(function(e){o.$broadcast("hrjc-loader-hide"),i.close(e),R.publish("Contract::updated")},function(e){o.$broadcast("hrjc-loader-hide"),CRM.alert(e,"Error","error")})}function F(e){var t=l("formatDate")(e,Date);return"Unspecified"!==t?t:e}function I(){return a.all([{name:"hrjobcontract_health_health_plan_type",key:"plan_type"},{name:"hrjobcontract_health_life_insurance_plan_type",key:"plan_type_life_insurance"}].map(function(e){_.getOptions(e.name,!0).then(function(n){s.options.health[e.key]=t.transform(n,function(e,t){e[t.key]=t.value},{})})}))}function U(e,t){var n=o.files[t];o.filesTrash[t].push(n[e]),n.splice(e,1)}function q(){var e=t.every(o.uploader,function(e){return t.every(e,function(e){return!e.queue||t.every(e.queue,function(e){return e.file.sizeo.fileMaxSize&&e.remove()}),F.queue.length&&P.push(b.upload(F,l))}),P.length?(s=r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalProgress.html",size:"sm",controller:"ModalProgressController",resolve:{uploader:function(){return C},promiseFilesUpload:function(){return P}}}),e.files=s.result,a.all(e)):(e.haveEntitlementFieldsChanged=A(),e)}).then(function(e){o.$broadcast("hrjc-loader-hide"),i.close(e),R.publish("Contract::updated")})):(o.$broadcast("hrjc-loader-hide"),i.close())}D.debug("Controller: ModalContractController");var Y=j.copy||{};Y.close=Y.close||"Close",Y.save=Y.save||"Save changes",Y.title=Y.title||"Contract",o.action=y||"view",o.allowSave=void 0!==j.allowSave&&j.allowSave,o.copy=Y,o.entity={},o.fileMaxSize=S.CRM.maxFileSize||0,o.files={},o.filesTrash={},o.isDisabled=void 0===j.isDisabled||j.isDisabled,o.isPrimaryDisabled=+g.contract.is_primary,o.showIsPrimary=w.contractListLen>1&&"change"!==y,o.uploader={details:{contract_file:b.uploader("civicrm_hrjobcontract_details")},pension:{evidence_file:b.uploader("civicrm_hrjobcontract_pension",1)}},o.utils=w,o.cancel=P,o.fileMoveToTrash=U,o.filesValidate=q,o.save=z,function(){O(),H(),i.opened.then(function(){s.$broadcast("hrjc-loader-hide")}),s.$broadcast("hrjc-loader-show"),I().then(function(){s.$broadcast("hrjc-loader-hide")})}()}return o.__name="ModalContractController",o.$inject=["$scope","$uibModal","$uibModalInstance","$q","$rootElement","$rootScope","$filter","contractService","contractRevisionService","contractDetailsService","contractHourService","contractPayService","contractLeaveService","contractHealthService","contractPensionService","contractFilesService","action","entity","content","files","utilsService","utils","settings","$log","pubSub"],o}),define("job-contract/controllers/modal/modal-dialog.controller",[],function(){"use strict";function e(e,t,n,o,r){function i(){o.dismiss("Cancel")}function a(e){o.close(e||!0)}e.debug("Controller: ModalDialogController"),t.copyCancel=r.copyCancel||"Cancel",t.copyConfirm=r.copyConfirm||"Yes",t.msg=r.msg||"",t.title=r.title||"CiviHR Job Contract",t.cancel=i,t.confirm=a}return e.__name="ModalDialogController",e.$inject=["$log","$scope","$timeout","$uibModalInstance","content"],e}),define("job-contract/controllers/modal/modal-progress.controller",[],function(){"use strict";function e(e,t,n,o,r,i,a){function c(){r.dismiss("File upload canceled")}e.debug("Controller: ModalProgressController");var s,l;n.uploader=i,n.cancel=c,function(){for(s in i)for(l in i[s])i[s][l].queue.length&&(i[s][l].item=i[s][l].queue[0].file.name),i[s][l].onProgressItem=function(e){this.item=e.file.name};t.all(a).then(function(e){o(function(){r.close(e)},500)})}()}return e.__name="ModalProgressController",e.$inject=["$log","$q","$scope","$timeout","$uibModalInstance","uploader","promiseFilesUpload"],e}),define("job-contract/controllers/modal/modal-revision.controller",["common/angular"],function(e){"use strict";function t(t,n,o,r,i,a,c,s,l,u,d,f,v,m,p){function _(){a.dismiss("cancel")}function h(){var e=(i.currentPage-1)*i.itemsPerPage,t=e+i.itemsPerPage;i.revisionDataListPage=i.revisionDataList.slice(e,t)}function b(){var e,t=0,n=i.fields.length;for(t;t-1?"&":"?"),r=i.entity;return e.forEach(i.fields,function(e){t="editor_name"!==e.name?e.name:"editor_uid",n=e.extends?"":r+"_",e.selected&&(o+="fields["+n+t+"]=1&")}),o+="fields[sort_name]=1&fields[first_name]=1&fields[last_name]=1&fields[external_identifier]=1&fields[email]=1&fields[street_address]=1&fields[city]=1&fields[name]=1&fields[contract_contact_id]=1&fields[contract_contract_id]=1&fields[jobcontract_revision_id]=1&fields[change_reason]=1&fields[created_date]=1&fields[effective_date]=1&fields[modified_date]=1&order_bys[1][column]=id&order_bys[1][order]=ASC&order_bys[2][column]=civicrm_hrjobcontract_revision_revision_id&order_bys[2][order]=ASC&order_bys[3][column]=-&order_bys[3][order]=ASC&order_bys[4][column]=-&order_bys[4][order]=ASC&order_bys[5][column]=-&order_bys[5][order]=ASC&contract_id_op=eq&permission=access+CiviReport&row_count=&_qf_Summary_submit_csv=Preview+CSV&groups=&contract_id_value="+l[0].jobcontract_id+"&group_bys[civicrm_hrjobcontract_revision_revision_id]=1"}n.debug("Controller: ModalRevisionController"),i.$broadcast("hrjc-loader-show"),i.currentPage=1,i.entity=u,i.fields=e.copy(d),i.itemsPerPage=5,i.revisionDataList=[],i.revisionList=[],i.sortCol="effective_date",i.subFields={},i.maxSize=5,i.modalContract=v,i.sortReverse=!0,i.urlCSV=w(),i.cancel=_,i.createPage=h,i.sortBy=C,i.toggleFieldsSelected=$,function(){b(),y(),g(),j(),i.sortBy(),a.opened.then(function(){r.$broadcast("hrjc-loader-hide")})}()}return t.__name="ModalRevisionController",t.$inject=["$filter","$log","$q","$rootScope","$scope","$uibModalInstance","settings","revisionDataList","revisionList","entity","fields","model","modalContract","utils","contactService"],t}),define("job-contract/modules/job-contract.controllers",["common/angular","job-contract/controllers/contract.controller","job-contract/controllers/contract-list.controller","job-contract/controllers/revision-list.controller","job-contract/controllers/form/form-general.controller","job-contract/controllers/form/form-health.controller","job-contract/controllers/form/form-hour.controller","job-contract/controllers/form/form-leave.controller","job-contract/controllers/form/form-pay.controller","job-contract/controllers/form/form-pension.controller","job-contract/controllers/modal/modal-change-reason.controller","job-contract/controllers/modal/modal-contract-new.controller","job-contract/controllers/modal/modal-contract.controller","job-contract/controllers/modal/modal-dialog.controller","job-contract/controllers/modal/modal-progress.controller","job-contract/controllers/modal/modal-revision.controller"],function(e,t,n,o,r,i,a,c,s,l,u,d,f,v,m,p){"use strict";return e.module("job-contract.controllers",[]).controller(t.__name,t).controller(n.__name,n).controller(o.__name,o).controller(r.__name,r).controller(i.__name,i).controller(a.__name,a).controller(c.__name,c).controller(s.__name,s).controller(l.__name,l).controller(u.__name,u).controller(d.__name,d).controller(f.__name,f).controller(v.__name,v).controller(m.__name,m).controller(p.__name,p)}),function(e){define("leave-absences/shared/modules/shared-settings",["common/angular"],function(t){return t.module("leave-absences.settings",[]).constant("shared-settings",{attachmentToken:e.vars.leaveAndAbsences.attachmentToken,debug:e.debug,managerPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/",sharedPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/shared/",serverDateFormat:"YYYY-MM-DD",serverDateTimeFormat:"YYYY-MM-DD HH:mm:ss",permissions:{admin:{access:"access leave and absences",administer:"administer leave and absences"},ssp:{access:"access leave and absences in ssp",manage:"manage leave and absences in ssp"}},fileUploader:{queueLimit:10},statusNames:{approved:"approved",adminApproved:"admin_approved",awaitingApproval:"awaiting_approval",moreInformationRequired:"more_information_required",rejected:"rejected",cancelled:"cancelled"}})})}(CRM),define("leave-absences/shared/modules/apis",["common/angular","common/modules/apis","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.apis",["common.apis","leave-absences.settings"])}),define("leave-absences/shared/modules/models-instances",["common/angular","common/models/instances/instance","common/modules/services","common/modules/models","common/services/check-permissions","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models.instances",["common.models","common.models.instances","common.services","leave-absences.settings"])}),define("leave-absences/shared/modules/models",["common/angular","common/modules/models","common/modules/services","leave-absences/shared/modules/apis","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models",["common.models","common.services","leave-absences.apis","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,o,r){return n.debug("AbsenceTypeAPI"),o.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(o,i,a){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),a=e.assign({},a,{absence_type_id:o,date:t(i).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",a).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,o,r,i,a){return t.debug("AbsenceType"),o.extend({all:function(e){return i.all(e).then(function(e){return e.map(function(e){return a.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return i.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return i.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,o){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=o.DATE_FORMAT.toUpperCase(),r=t(e,n);return t(this.start_date).isSameOrBefore(r)&&t(this.end_date).isSameOrAfter(r)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,o,r,i){return e.debug("AbsencePeriod"),n.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},current:function(){var e=t().format(i.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return o.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),function(e,t){function n(){var e={nodiff:"",year:"year",years:"years",month:"month",months:"months",day:"day",days:"days",hour:"hour",hours:"hours",minute:"minute",minutes:"minutes",second:"second",seconds:"seconds",delimiter:" "};moment.fn.preciseDiff=function(e){return moment.preciseDiff(this,e)},moment.preciseDiff=function(t,n){function o(t,n){return t+" "+e[n+(1===t?"":"s")]}var r=moment(t),i=moment(n);if(r.isSame(i))return e.nodiff;if(r.isAfter(i)){var a=r;r=i,i=a}var c=i.year()-r.year(),s=i.month()-r.month(),l=i.date()-r.date();if(l<0){var u=moment(i.year()+"-"+(i.month()+1),"YYYY-MM").subtract("months",1).daysInMonth();l=uLength Of Employment
"),e(".lengthEmployment").html(a),o&&l<0&&e(".lengthEmployment").css({color:"#FF0000"})}var r=CRM.grID,i=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(2) .crm-custom-data").html(),a=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(3) .crm-custom-data").html();i&&o(i,a,r),e(document).on("click","#_qf_CustomData_upload",function(){e(document).ajaxSuccess(function(t,n,i){i.extraData&&"CRM_Contact_Form_Inline_CustomData"==i.extraData.class_name&&i.extraData.groupID==r&&setTimeout(function(){var t=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(2) .crm-custom-data").html(),n=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(3) .crm-custom-data").html();t&&o(t,n,r)},300)})})}(CRM.$,CRM._),define("job-contract/modules/job-contract.core",["common/angular","common/ui-select","common/directives/angular-date/date-input","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/routers/compu-ng-route","common/modules/directives","common/services/dom-event-trigger","common/services/pub-sub","common/services/angular-date/date-format","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/absence-period.model","job-contract/vendor/fraction","job-contract/vendor/job-summary"],function(e){"use strict";e.module("job-contract.core",["ngAnimate","compuNgRoute","ngResource","angularFileUpload","ui.bootstrap","ui.select","common.angularDate","common.services","common.directives","common.filters","leave-absences.models"])}),define("job-contract/directives/contact.directive",[],function(){"use strict";function e(e,t,n,o){return t.debug("Directive: hrjcContact"),{restrict:"A",scope:{renderAsLink:"=?hrjcContactLink",contactId:"=?hrjcContact"},template:"{{contact.label}}",link:function(t,n){t.contactId&&t.$watch("contactId",function(r){o.getOne(t.contactId).then(function(o){t.contact=o,t.renderAsLink&&(n.html('{{contact.label}} '),e(n.contents())(t))})})}}}return e.__name="hrjcContact",e.$inject=["$compile","$log","settings","contactService"],e}),define("job-contract/directives/loader.directive",[],function(){"use strict";function e(e,t){return e.debug("Directive: hrjcLoader"),{link:function(e,t,n){function o(){var e=window.getComputedStyle(t[0]).position;return"relative"===e||"absolute"===e||"fixed"===e}function r(){o()||(t.css("position","relative"),s=!0),t.append(a),c=!0}function i(){c&&a.parentNode.removeChild(a),c=!1,s&&t.css("position","")}var a=document.createElement("div"),c=!1,s=!1;a.className="hrjc-loader spinner",n.hrjcLoaderShow&&r(),e.$on("hrjc-loader-show",function(){r()}),e.$on("hrjc-loader-hide",function(){i()})}}}return e.__name="hrjcLoader",e.$inject=["$log","$rootScope"],e}),define("job-contract/directives/number.directive",[],function(){"use strict";function e(e){return e.debug("Directive: hrjcNumber"),{require:"ngModel",link:function(e,t,n,o){var r=2,i=n.hrjcNumberFloat||!1,a=n.hrjcToHours||!1,c=n.hrjcNotNegative||!1;n.hrjcNumber&&"number"==typeof+n.hrjcNumber&&(r=n.hrjcNumber),t.bind("blur",function(){var e=parseFloat(o.$viewValue)||0;c&&e<0&&(e=0),a&&(e=.25*Math.ceil(e/.25)),o.$setViewValue(i?Math.round(100*e)/100:e.toFixed(r)),o.$render()})}}}return e.__name="hrjcNumber",e.$inject=["$log"],e}),define("job-contract/directives/validate.directive",["common/angular"],function(e){"use strict";function t(t){return t.debug("Directive: hrjcValidate"),{restrict:"A",require:"^form",scope:{isWarning:"=?hrjcValidateWarning"},link:function(t,n,o,r){function i(e,t){n.toggleClass("has-success",!e&&!t),f.toggleClass("glyphicon-ok",!e&&!t)}function a(e,t){n.toggleClass("has-warning",!e&&t),f.toggleClass("glyphicon-warning-sign",!e&&t)}function c(e){n.toggleClass("has-error",e),f.toggleClass("glyphicon-remove",e)}var s=n[0].querySelector("[name]"),l=e.element(s),u=l.attr("name"),d=document.createElement("span"),f=e.element(d);u&&(n.addClass("has-feedback"),f.addClass("glyphicon form-control-feedback"),l.after(f),t.$watch(function(){return r[u]&&r[u].$invalid},function(e){r[u].$dirty&&(i(e,t.isWarning),c(e))}),void 0!==t.isWarning&&t.$watch("isWarning",function(e){var t=r[u].$invalid;r[u].$dirty&&(i(t,e),a(t,e))}),l.bind("blur",function(){c(r[u].$invalid)}))}}}return t.__name="hrjcValidate",t.$inject=["$log"],t}),define("job-contract/modules/job-contract.directives",["common/angular","job-contract/directives/contact.directive","job-contract/directives/loader.directive","job-contract/directives/number.directive","job-contract/directives/validate.directive"],function(e,t,n,o,r){"use strict";return e.module("job-contract.directives",[]).directive(t.__name,t).directive(n.__name,n).directive(o.__name,o).directive(r.__name,r)}),define("job-contract/filters/capitalize.filter",[],function(){"use strict";function e(e){return e.debug("Filter: capitalize"),function(e){return e?e.replace(/([^\W_]+[^\s-]*) */g,function(e){
+define("job-contract/modules/job-contract.config",["common/angular"],function(e){"use strict";function t(e,t,n,o,r,i,a){t.debugEnabled(a.debug),o.resolveForAll({format:["DateFormat",function(e){return e.getDateFormat()}]}).when("/",{controller:"ContractListController",templateUrl:a.pathApp+"views/contractList.html",resolve:{contractList:["contractService",function(e){return e.get()}]}}).otherwise({redirectTo:"/"}),n.defaults.stripTrailingSlashes=!1,e.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",i.theme="bootstrap",r.showWeeks=!1}e.module("job-contract.config",["job-contract.constants"]).config(t),t.$inject=["$httpProvider","$logProvider","$resourceProvider","$routeProvider","uibDatepickerConfig","uiSelectConfig","settings"]}),define("job-contract/modules/job-contract.constants",["common/angular"],function(e){"use strict";e.module("job-contract.constants",[]).constant("settings",{classNamePrefix:"hrjc-",contactId:CRM.jobContractTabApp.contactId,debug:+CRM.debug,pathApp:CRM.jobContractTabApp.path,pathFile:CRM.url("civicrm/hrjobcontract/file/"),pathReport:CRM.url("civicrm/report/hrjobcontract/summary"),pathRest:CRM.url("civicrm/ajax/rest"),pathTpl:CRM.jobContractTabApp.path+"views/",CRM:{options:CRM.FieldOptions||{},defaultCurrency:CRM.jobContractTabApp.defaultCurrency,apiTsFmt:"YYYY-MM-DD HH:mm:ss",fields:CRM.jobContractTabApp.fields,maxFileSize:CRM.jobContractTabApp.maxFileSize}})}),define("job-contract/controllers/contract.controller",["common/lodash","common/moment"],function(e,t){"use strict";function n(n,o,r,i,a,c,s,l,u,d,f,v,m,p,_,h,b,y,g,j,C,$){function w(t){var n,o;return r.all([v.getOne({jobcontract_revision_id:t.details_revision_id}),m.getOne({jobcontract_revision_id:t.hour_revision_id}),h.getOne({jobcontract_revision_id:t.health_revision_id}),p.getOne({jobcontract_revision_id:t.pay_revision_id}),b.getOne({jobcontract_revision_id:t.pension_revision_id}),_.getOne({jobcontract_revision_id:t.leave_revision_id})]).then(function(t){return o={details:t[0],hour:t[1],health:t[2],pay:t[3],pension:t[4],leave:t[5]},n={contract:c.contract},e.extend(n,e.cloneDeep(c.model)),e.extend(n.details,o.details),e.extend(n.hour,o.hour),e.extend(n.health,o.health),e.extend(n.pay,o.pay),e.extend(n.pension,o.pension),D(n.leave,o.leave),n})}function S(){c.$on("updateContractView",function(){c.$broadcast("hrjc-loader-show"),f.fullDetails(c.revisionCurrent.jobcontract_id).then(function(e){A(e),c.$broadcast("hrjc-loader-hide")}).then(E)})}function D(t,n,o){o=o||"",e.each(t,function(t){e.extend(t,n?e.find(n,{leave_type:t.leave_type})||o:o)})}function R(n,o){var a,s,d,v,m,p,_,h,b=["details","hour","pay"],g={controller:"ModalContractController",appendTo:i.find("div").eq(0),templateUrl:u.pathApp+"views/modalForm.html?v=4448",windowClass:"modal-contract",size:"lg",resolve:{action:function(){return n||"view"},content:function(){return{}},entity:function(){return o?I.fetchRevisionDetails(o):{contract:c.contract,details:c.details,hour:c.hour,pay:c.pay,leave:c.leave,health:c.health,pension:c.pension}},files:function(){return o?r.all({details:y.get(o.details_revision_id,"civicrm_hrjobcontract_details"),pension:y.get(o.pension_revision_id,"civicrm_hrjobcontract_pension")}):T},utils:function(){return c.utils}}};switch(c.$broadcast("hrjc-loader-show"),n){case"edit":g.resolve.content=function(){return{allowSave:!0,isDisabled:!1,copy:{close:"Cancel",save:"Save without making a new revision",title:"Edit contract"}}};break;case"change":g.resolve.content=function(){return{allowSave:!0,isDisabled:!1,copy:{close:"Cancel",save:"Save and make a new revision",title:"Change contract terms"}}}}a=l.open(g),a.result.then(function(n){n&&(f.updateHeaderInfo(),A(n),L(n.details.period_end_date),n.revisionCreated?(s=t(new Date(n.revisionCreated.effective_date)),d=t(new Date(c.revisionCurrent.effective_date)),v=t(),m={revisionEntityIdObj:n.revisionCreated,details:n.details,hour:n.hour,pay:n.pay},p=d.diff(v,"day")<=0||d.diff(s,"day")<=0,n.files&&(p?E().then(function(e){m.files=e}):r.all({details:y.get(n.revisionCreated.details_revision_id,"civicrm_hrjobcontract_details")}).then(function(e){m.files=e})),c.revisionList.unshift(n.revisionCreated),c.revisionDataList.unshift(m)):(c.contract.is_primary!==n.contract.is_primary&&c.$parent.$parent.toggleIsPrimary(c.contract.id),e.each(c.revisionDataList,function(t){for(_=0,h={};b[_];)t.revisionEntityIdObj[b[_]+"_revision_id"]===c.revisionCurrent[b[_]+"_revision_id"]&&(h[b[_]]=n[b[_]],"details"===b[_]&&n.files&&E().then(function(n){h.files=n,e.extend(t,h)}),e.extend(t,h)),_++})),CRM.refreshParent("#hrjobroles"),n.haveEntitlementFieldsChanged?$.updateEntitlements(c.contract.contact_id):C.success("Success","Contract successfully updated"))})}function P(e){var t,o=[],a="leave"!==e?"getOne":"get",s=0,f=c.revisionList.length;if(c.$broadcast("hrjc-loader-show"),!e)return null;for(s;sChange Contract Terms: When an employeees job or role changes, i.e. promotion, secondment or move,you can use this wizard to update the details of the contract and record a newrevision of the contract. A contract history is kept so you can always see theprevious version of the contract.
Correct an error on the contract record: If you notice an issue or error with the job terms you can correct these withoutcreating a new job history record. These changes are not stored as a new revisionof the contract.
')},c.utils={contractListLen:u.length},c.delete=j,c.modalContract=C,c.toggleIsPrimary=$,function(){for(w in R)S[w]=R[w].getFields();o.all(S).then(function(e){c.fields=e,n.debug("FIELDS:"),n.debug(e);for(w in R)D[w]=R[w].model(e[w]);return o.all(D)}).then(function(o){c.model=o,n.debug("MODEL:"),n.debug(o),u=t("orderBy")(u,"-is_primary"),e.forEach(u,function(e){+e.is_current?c.contractCurrent.push(e):c.contractPast.push(e)}),c.$watchCollection("contractCurrent",function(){c.utils.contractListLen=c.contractCurrent.length+c.contractPast.length}),c.$watchCollection("contractPast",function(){c.utils.contractListLen=c.contractCurrent.length+c.contractPast.length}),i.$broadcast("hrjc-loader-hide"),c.contractListLoaded=!0}),o.all(P).then(function(t){e.extend(c.utils,t)})}()}return n.__name="ContractListController",n.$inject=["$filter","$log","$q","$rootElement","$rootScope","$sce","$scope","$window","$uibModal","contractList","contractService","contractDetailsService","contractHourService","contractPayService","contractLeaveService","contractHealthService","contractPensionService","utilsService","settings","pubSub"],n}),define("job-contract/controllers/revision-list.controller",["common/angular","common/lodash"],function(e,t){"use strict";function n(t,n,o,r,i,a,c,s,l,u,d,f,v,m,p){function _(){var e=(a.currentPage-1)*a.itemsPerPage,t=e+a.itemsPerPage;a.revisionDataListPage=$.slice(e,t)}function h(e,t){if(1===a.revisionList.length)return void t.stopPropagation();if(e&&"number"==typeof+e){c.open({appendTo:r.find("div").eq(0),templateUrl:s.pathApp+"views/modalDialog.html",size:"sm",controller:"ModalDialogController",resolve:{content:function(){return{msg:"Are you sure you want to delete this job contract revision?"}}}}).result.then(function(t){t&&(a.$broadcast("hrjc-loader-show"),l.deleteRevision(e).then(function(t){var n=0,o=a.revisionList.length;if(!t.is_error){for(n;nt&&g(),a.sortBy(),a.createPage()})}function y(e){var t=e.effective_date,n=e.change_reason;c.open({appendTo:r.find("div").eq(0),templateUrl:s.pathApp+"views/modalChangeReason.html?v="+(new Date).getTime(),controller:"ModalChangeReasonController",resolve:{content:function(){return{copy:{title:"Edit revision data"}}},date:function(){return t},reasonId:function(){return n}}}).result.then(function(o){o.date===t&&o.reasonId===n||l.saveRevision({id:e.id,change_reason:o.reasonId,effective_date:o.date}).then(function(){e.effective_date=o.date,e.change_reason=o.reasonId,a.sortBy(),a.createPage(),a.revisionCurrent.id!==g()&&a.$emit("updateContractView")})})}function g(){var n,o=0;if(a.revisionList.length){var r=t("orderBy")(a.revisionList,["effective_date","id"]);if(e.forEach(r,function(e){new Date(e.effective_date).setHours(0,0,0,0)<=(new Date).setHours(0,0,0,0)&&(n=e)}),!n)do{n=r[o],o++}while(r[o]&&r[o-1].effective_date===r[o].effective_date);return e.extend(a.revisionCurrent,n),n.id}return null}function j(e,n){void 0!==e&&(a.sortCol===e?a.sortReverse=!a.sortReverse:a.sortCol=e),void 0!==n&&(a.sortReverse=n),$=t("orderBy")(a.revisionDataList,a.sortCol,a.sortReverse)}n.debug("Controller: RevisionListController");var C=a.contract.id,$=a.revisionDataList;a.changeReasons=i.options.contract.change_reason,a.currentPage=1,a.itemsPerPage=5,a.maxSize=5,a.sortCol="revisionEntityIdObj.effective_date",a.sortReverse=!0,a.urlCSV=function(){var t=s.pathReport+(s.pathReport.indexOf("?")>-1?"&":"?"),n=a.fields;return e.forEach(n,function(n,o){t+="fields["+o+"_revision_id]=1&",e.forEach(n,function(e){t+="fields["+o+"_"+e.name+"]=1&"})}),t+="fields[sort_name]=1&fields[first_name]=1&fields[last_name]=1&fields[external_identifier]=1&fields[email]=1&fields[street_address]=1&fields[city]=1&fields[name]=1&fields[contract_contact_id]=1&fields[contract_contract_id]=1&fields[jobcontract_revision_id]=1&fields[change_reason]=1&fields[created_date]=1&fields[effective_date]=1&fields[modified_date]=1&order_bys[1][column]=id&order_bys[1][order]=ASC&order_bys[2][column]=civicrm_hrjobcontract_revision_revision_id&order_bys[2][order]=ASC&order_bys[3][column]=-&order_bys[3][order]=ASC&order_bys[4][column]=-&order_bys[4][order]=ASC&order_bys[5][column]=-&order_bys[5][order]=ASC&contract_id_op=eq&permission=access+CiviReport&row_count=&_qf_Summary_submit_csv=Preview+CSV&groups=&contract_id_value="+C+"&group_bys[civicrm_hrjobcontract_revision_revision_id]=1"}(),a.display={effectiveDate:!0,position:!0,payScale:!0,totalSalary:!0,hours:!0,placeOfWork:!0,recordedBy:!0,changeReason:!0},a.createPage=_,a.deleteRevision=h,a.modalRevisionEdit=y,a.sortBy=j,function(){b(),a.revisionDataList||(a.$broadcast("hrjc-loader-show"),p.fetchRevisions(C).then(function(e){a.revisionList=e.revisionList,a.revisionDataList=e.revisionDataList,a.$broadcast("hrjc-loader-hide")}))}()}return n.__name="RevisionListController",n.$inject=["$filter","$log","$q","$rootElement","$rootScope","$scope","$uibModal","settings","contractService","contractDetailsService","contractHourService","contractPayService","contractFilesService","contractRevisionService","contractRevisionListService"],n}),define("job-contract/controllers/form/form-general.controller",["common/moment"],function(e){"use strict";function t(t,n,o){function r(e,t){e.preventDefault(),e.stopPropagation(),n[t]=!0}function i(t,n){if(!t||!n)return null;var o,r,i,a;return i=e(n),i.add(1,"days"),a=i.diff(t,"years"),i.add(-a,"years"),r=i.diff(t,"months"),i.add(-r,"months"),o=i.diff(t,"days"),a=a>0?a>1?a+" years ":a+" year ":"",r=r>0?r>1?r+" months ":r+" month ":"",o=o>0?o>1?o+" days":o+" day":"",a+r+o||"0 days"}function a(t,n){return n=n||"min",e(t)["max"===n?"subtract":"add"](1,"day").toDate()}function c(){n.$watch("entity.details.period_start_date",function(){n.datepickerOptions.end.minDate=a(s.period_start_date,"min"),n.duration=i(s.period_start_date,s.period_end_date)}),n.$watch("entity.details.period_end_date",function(){s.period_end_date?n.datepickerOptions.start.maxDate=a(s.period_end_date,"max"):(n.datepickerOptions.start.maxDate=null,s.end_reason=null),n.duration=i(s.period_start_date,s.period_end_date)}),n.$watch("entity.details.position",function(e,t){e!==t&&s.title===t&&(n.contractForm.detailsTitle.$setViewValue(e),n.contractForm.detailsTitle.$render())}),n.$watch("entity.details.notice_amount",function(e,t){+e&&!s.notice_unit&&(n.contractForm.detailsNoticeUnit.$setValidity("required",!1),n.contractForm.detailsNoticeUnit.$dirty=!0),e!==t&&s.notice_amount_employee===t&&(s.notice_amount_employee=e)}),n.$watch("entity.details.notice_amount_employee",function(e){+e&&!s.notice_unit_employee&&(n.contractForm.detailsNoticeUnitEmployee.$setValidity("required",!1),n.contractForm.detailsNoticeUnitEmployee.$dirty=!0)}),n.$watch("entity.details.notice_unit",function(e,t){e!==t&&s.notice_unit_employee===t&&(s.notice_unit_employee=e)})}t.debug("Controller: FormGeneralController");var s=n.entity.details;n.format=o.DATE_FORMAT,n.datepickerOptions=function(){return{start:{maxDate:s.period_end_date?a(s.period_end_date,"max"):null},end:{minDate:s.period_start_date?a(s.period_start_date,"min"):null}}}(),n.dpOpen=r,function(){c()}()}return t.__name="FormGeneralController",t.$inject=["$log","$scope","HR_settings"],t}),define("job-contract/controllers/form/form-health.controller",[],function(){"use strict";function e(e,t,n){function o(e,o){e&&n.search(e,{contact_type:"Organization",contact_sub_type:o}).then(function(e){t.contacts[o]=e})}e.debug("Controller: FormHealthController"),t.contacts={Health_Insurance_Provider:[],Life_Insurance_Provider:[]},t.refreshContacts=o,function(){t.entity.health.provider&&n.getOne(t.entity.health.provider).then(function(e){t.contacts.Health_Insurance_Provider.push(e)}),t.entity.health.provider_life_insurance&&n.getOne(t.entity.health.provider_life_insurance).then(function(e){t.contacts.Life_Insurance_Provider.push(e)})}()}return e.__name="FormHealthController",e.$inject=["$log","$scope","contactService"],e}),define("job-contract/vendor/fraction",[],function(){var e=function(t,n){if(void 0!==t&&n)"number"==typeof t&&"number"==typeof n?(this.numerator=t,this.denominator=n):"string"==typeof t&&"string"==typeof n&&(this.numerator=parseInt(t),this.denominator=parseInt(n));else if(void 0===n)if(num=t,"number"==typeof num)this.numerator=num,this.denominator=1;else if("string"==typeof num){var o,r,i=num.split(" ");if(i[0]&&(o=i[0]),i[1]&&(r=i[1]),o%1==0&&r&&r.match("/"))return new e(o).add(new e(r));if(!o||r)return;if("string"==typeof o&&o.match("/")){var a=o.split("/");this.numerator=a[0],this.denominator=a[1]}else{if("string"==typeof o&&o.match("."))return new e(parseFloat(o));this.numerator=parseInt(o),this.denominator=1}}this.normalize()};return e.prototype.clone=function(){return new e(this.numerator,this.denominator)},e.prototype.toString=function(){if("NaN"===this.denominator)return"NaN";var e=this.numerator/this.denominator>0?Math.floor(this.numerator/this.denominator):Math.ceil(this.numerator/this.denominator),t=this.numerator%this.denominator,n=this.denominator,o=[];return 0!=e&&o.push(e),0!=t&&o.push((0===e?t:Math.abs(t))+"/"+n),o.length>0?o.join(" "):0},e.prototype.rescale=function(e){return this.numerator*=e,this.denominator*=e,this},e.prototype.add=function(t){var n=this.clone();return t=t instanceof e?t.clone():new e(t),td=n.denominator,n.rescale(t.denominator),t.rescale(td),n.numerator+=t.numerator,n.normalize()},e.prototype.subtract=function(t){var n=this.clone();return t=t instanceof e?t.clone():new e(t),td=n.denominator,n.rescale(t.denominator),t.rescale(td),n.numerator-=t.numerator,n.normalize()},e.prototype.multiply=function(t){var n=this.clone();if(t instanceof e)n.numerator*=t.numerator,n.denominator*=t.denominator;else{if("number"!=typeof t)return n.multiply(new e(t));n.numerator*=t}return n.normalize()},e.prototype.divide=function(t){var n=this.clone();if(t instanceof e)n.numerator*=t.denominator,n.denominator*=t.numerator;else{if("number"!=typeof t)return n.divide(new e(t));n.denominator*=t}return n.normalize()},e.prototype.equals=function(t){t instanceof e||(t=new e(t));var n=this.clone().normalize(),t=t.clone().normalize();return n.numerator===t.numerator&&n.denominator===t.denominator},e.prototype.normalize=function(){var t=function(e){return"number"==typeof e&&(e>0&&e%1>0&&e%1<1||e<0&&e%-1<0&&e%-1>-1)},n=function(e,t){if(t){var n=Math.pow(10,t);return Math.round(e*n)/n}return Math.round(e)};return function(){if(t(this.denominator)){var o=n(this.denominator,9),r=Math.pow(10,o.toString().split(".")[1].length);this.denominator=Math.round(this.denominator*r),this.numerator*=r}if(t(this.numerator)){var o=n(this.numerator,9),r=Math.pow(10,o.toString().split(".")[1].length);this.numerator=Math.round(this.numerator*r),this.denominator*=r}var i=e.gcf(this.numerator,this.denominator);return this.numerator/=i,this.denominator/=i,(this.numerator<0&&this.denominator<0||this.numerator>0&&this.denominator<0)&&(this.numerator*=-1,this.denominator*=-1),this}}(),e.gcf=function(t,n){var o=[],r=e.primeFactors(t),i=e.primeFactors(n);return r.forEach(function(e){var t=i.indexOf(e);t>=0&&(o.push(e),i.splice(t,1))}),0===o.length?1:function(){var e,t=o[0];for(e=1;eTHE FILE IS TOO LARGE AND CANNOT BE UPLOADED. PLEASE REDUCE THE SIZE OF THE FILE AND TRY AGAIN."),fte:c.trustAsHtml("FTE stands forFull Time Equivalent. This is a useful measure foran organisation that has peopleworking part-time.For a full-time person, FTE is always equal to1.0, whereas for a part-time person, the FTE will representthe fraction of standard hours that the person works on aregular basis. E.g. if the standard working day at an organisationcomprises of 8 hours, then a person who regularly works for8 hours each day would be considered to be full- time andwould have an FTE value of 1.0. A person who regularly worksfor only 4 hours each day would be considered to be apart-time person and would have an FTE value of 0.5. If theorganisation had 10 people, each with an FTE of 1.0 theactual headcount of full-time people would be 10 and theFTE headcount (equal to actual headcount multiplied by theFTE value) would also be 10. However, if the organisationhad another 10 people who each worked part-time with an FTEvalue of 0.5 the actual headcount of part-time people wouldbe 10 while the FTE headcount would only be 5. Thus for anorganisation that had a total of 10 full-time people, and 10part-time people (each with an FTE of 0.5) the actualheadcount for the organisation would be 20 while the FTEheadcount would be 15.
")},s.uploader={details:{contract_file:y.uploader("civicrm_hrjobcontract_details")},pension:{evidence_file:y.uploader("civicrm_hrjobcontract_pension",1)}},s.cancel=S,s.filesValidate=D,s.save=M,function(){e.copy(g,s.entity),s.entity.contract={is_primary:0},e.forEach(s.uploader,function(t){e.forEach(t,function(e){e.onAfterAddingAll=function(){s.filesValidate()}})}),A(),a.$broadcast("hrjc-loader-show"),P().then(function(){a.$broadcast("hrjc-loader-hide")})}()}return o.__name="ModalContractNewController",o.$inject=["$log","$q","$rootElement","$rootScope","$sce","$scope","$uibModalInstance","$uibModal","Contract","contractService","contractDetailsService","contractHourService","contractPayService","contractLeaveService","contractHealthService","contractPensionService","contractFilesService","model","utilsService","utils","settings","pubSub"],o}),define("job-contract/controllers/modal/modal-contract.controller",["common/angular","common/lodash","common/moment"],function(e,t,n){"use strict";function o(o,r,i,a,c,s,l,u,d,f,v,m,p,_,h,b,y,g,j,C,$,w,S,D,R){function P(){if("view"===y||e.equals(g,o.entity)&&e.equals(C,o.files)&&!o.uploader.details.contract_file.queue.length&&!o.uploader.pension.evidence_file.queue.length)return o.$broadcast("hrjc-loader-hide"),void i.dismiss("cancel");S.debug&&e.forEach(g,function(t,n){e.equals(t,o.entity[n])||(D.debug("======================"),D.debug("Changed entity: "+n),D.debug("Before:"),D.debug(t),D.debug("After:"),D.debug(o.entity[n]))}),r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalDialog.html?v="+(new Date).getTime(),size:"sm",controller:"ModalDialogController",resolve:{content:function(){return{copyCancel:"No",title:"Alert",msg:"Are you sure you want to cancel? Changes will be lost!"}}}}).result.then(function(e){e&&(o.$broadcast("hrjc-loader-hide"),i.dismiss("cancel"))})}function M(){return r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalChangeReason.html?v="+(new Date).getTime(),controller:"ModalChangeReasonController",resolve:{content:function(){return{copy:{title:Y.title}}},date:null,reasonId:null}}).result}function A(){var t=x("period_end_date"),n=x("period_start_date"),r=!e.equals(o.entity.leave,g.leave);return n||t||r}function L(){return r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalConfirmEdit.html?v="+(new Date).getTime(),controller:"ModalDialogController",resolve:{content:function(){return{msg:"Save without making a new revision?"}}}}).result}function E(e,t){return o.$broadcast("hrjc-loader-show"),d.validateEffectiveDate({contact_id:S.contactId,effective_date:t}).then(function(n){if(n.success)return N(e,t);CRM.alert(n.message,"Error","error"),o.$broadcast("hrjc-loader-hide")},function(e){})}function T(){o.$broadcast("hrjc-loader-show"),o.entity.details.period_end_date=o.entity.details.period_end_date||"";var t,n,s,l,d,y=e.copy(o.entity),g=o.filesTrash,j=o.uploader,C={contract:u.save(y.contract),details:f.save(y.details),hour:v.save(y.hour),pay:m.save(y.pay),leave:p.save(y.leave),health:_.save(y.health),pension:h.save(y.pension)},$=[],w=[];for(t in g)for(s=0,l=g[t].length,s;so.fileMaxSize&&e.remove()})})}),j.details.contract_file.queue.length&&$.push(b.upload(j.details.contract_file,y.details.jobcontract_revision_id)),j.pension.evidence_file.queue.length&&$.push(b.upload(j.pension.evidence_file,y.pension.jobcontract_revision_id)),t.details.period_start_date=y.details.period_start_date,t.details.period_end_date=y.details.period_end_date,t.pay.annual_benefits=y.pay.annual_benefits,t.pay.annual_deductions=y.pay.annual_deductions,$.length?(d=r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalProgress.html?v="+(new Date).getTime(),size:"sm",controller:"ModalProgressController",resolve:{uploader:function(){return j},promiseFilesUpload:function(){return $}}}),t.files=d.result,a.all(t)):(t.haveEntitlementFieldsChanged=A(),t)}).then(function(e){o.$broadcast("hrjc-loader-hide"),i.close(e),R.publish("Contract::updated")},function(e){o.$broadcast("hrjc-loader-hide"),CRM.alert(e,"Error","error")})}function F(e){var t=l("formatDate")(e,Date);return"Unspecified"!==t?t:e}function I(){return a.all([{name:"hrjobcontract_health_health_plan_type",key:"plan_type"},{name:"hrjobcontract_health_life_insurance_plan_type",key:"plan_type_life_insurance"}].map(function(e){_.getOptions(e.name,!0).then(function(n){s.options.health[e.key]=t.transform(n,function(e,t){e[t.key]=t.value},{})})}))}function U(e,t){var n=o.files[t];o.filesTrash[t].push(n[e]),n.splice(e,1)}function q(){var e=t.every(o.uploader,function(e){return t.every(e,function(e){return!e.queue||t.every(e.queue,function(e){return e.file.sizeo.fileMaxSize&&e.remove()}),F.queue.length&&P.push(b.upload(F,l))}),P.length?(s=r.open({appendTo:c.find("div").eq(0),templateUrl:S.pathApp+"views/modalProgress.html",size:"sm",controller:"ModalProgressController",resolve:{uploader:function(){return C},promiseFilesUpload:function(){return P}}}),e.files=s.result,a.all(e)):(e.haveEntitlementFieldsChanged=A(),e)}).then(function(e){o.$broadcast("hrjc-loader-hide"),i.close(e),R.publish("Contract::updated")})):(o.$broadcast("hrjc-loader-hide"),i.close())}D.debug("Controller: ModalContractController");var Y=j.copy||{};Y.close=Y.close||"Close",Y.save=Y.save||"Save changes",Y.title=Y.title||"Contract",o.action=y||"view",o.allowSave=void 0!==j.allowSave&&j.allowSave,o.copy=Y,o.entity={},o.fileMaxSize=S.CRM.maxFileSize||0,o.files={},o.filesTrash={},o.isDisabled=void 0===j.isDisabled||j.isDisabled,o.isPrimaryDisabled=+g.contract.is_primary,o.showIsPrimary=w.contractListLen>1&&"change"!==y,o.uploader={details:{contract_file:b.uploader("civicrm_hrjobcontract_details")},pension:{evidence_file:b.uploader("civicrm_hrjobcontract_pension",1)}},o.utils=w,o.cancel=P,o.fileMoveToTrash=U,o.filesValidate=q,o.save=z,function(){O(),H(),i.opened.then(function(){s.$broadcast("hrjc-loader-hide")}),s.$broadcast("hrjc-loader-show"),I().then(function(){s.$broadcast("hrjc-loader-hide")})}()}return o.__name="ModalContractController",o.$inject=["$scope","$uibModal","$uibModalInstance","$q","$rootElement","$rootScope","$filter","contractService","contractRevisionService","contractDetailsService","contractHourService","contractPayService","contractLeaveService","contractHealthService","contractPensionService","contractFilesService","action","entity","content","files","utilsService","utils","settings","$log","pubSub"],o}),define("job-contract/controllers/modal/modal-dialog.controller",[],function(){"use strict";function e(e,t,n,o,r){function i(){o.dismiss("Cancel")}function a(e){o.close(e||!0)}e.debug("Controller: ModalDialogController"),t.copyCancel=r.copyCancel||"Cancel",t.copyConfirm=r.copyConfirm||"Yes",t.msg=r.msg||"",t.title=r.title||"CiviHR Job Contract",t.cancel=i,t.confirm=a}return e.__name="ModalDialogController",e.$inject=["$log","$scope","$timeout","$uibModalInstance","content"],e}),define("job-contract/controllers/modal/modal-progress.controller",[],function(){"use strict";function e(e,t,n,o,r,i,a){function c(){r.dismiss("File upload canceled")}e.debug("Controller: ModalProgressController");var s,l;n.uploader=i,n.cancel=c,function(){for(s in i)for(l in i[s])i[s][l].queue.length&&(i[s][l].item=i[s][l].queue[0].file.name),i[s][l].onProgressItem=function(e){this.item=e.file.name};t.all(a).then(function(e){o(function(){r.close(e)},500)})}()}return e.__name="ModalProgressController",e.$inject=["$log","$q","$scope","$timeout","$uibModalInstance","uploader","promiseFilesUpload"],e}),define("job-contract/controllers/modal/modal-revision.controller",["common/angular"],function(e){"use strict";function t(t,n,o,r,i,a,c,s,l,u,d,f,v,m,p){function _(){a.dismiss("cancel")}function h(){var e=(i.currentPage-1)*i.itemsPerPage,t=e+i.itemsPerPage;i.revisionDataListPage=i.revisionDataList.slice(e,t)}function b(){var e,t=0,n=i.fields.length;for(t;t-1?"&":"?"),r=i.entity;return e.forEach(i.fields,function(e){t="editor_name"!==e.name?e.name:"editor_uid",n=e.extends?"":r+"_",e.selected&&(o+="fields["+n+t+"]=1&")}),o+="fields[sort_name]=1&fields[first_name]=1&fields[last_name]=1&fields[external_identifier]=1&fields[email]=1&fields[street_address]=1&fields[city]=1&fields[name]=1&fields[contract_contact_id]=1&fields[contract_contract_id]=1&fields[jobcontract_revision_id]=1&fields[change_reason]=1&fields[created_date]=1&fields[effective_date]=1&fields[modified_date]=1&order_bys[1][column]=id&order_bys[1][order]=ASC&order_bys[2][column]=civicrm_hrjobcontract_revision_revision_id&order_bys[2][order]=ASC&order_bys[3][column]=-&order_bys[3][order]=ASC&order_bys[4][column]=-&order_bys[4][order]=ASC&order_bys[5][column]=-&order_bys[5][order]=ASC&contract_id_op=eq&permission=access+CiviReport&row_count=&_qf_Summary_submit_csv=Preview+CSV&groups=&contract_id_value="+l[0].jobcontract_id+"&group_bys[civicrm_hrjobcontract_revision_revision_id]=1"}n.debug("Controller: ModalRevisionController"),i.$broadcast("hrjc-loader-show"),i.currentPage=1,i.entity=u,i.fields=e.copy(d),i.itemsPerPage=5,i.revisionDataList=[],i.revisionList=[],i.sortCol="effective_date",i.subFields={},i.maxSize=5,i.modalContract=v,i.sortReverse=!0,i.urlCSV=w(),i.cancel=_,i.createPage=h,i.sortBy=C,i.toggleFieldsSelected=$,function(){b(),y(),g(),j(),i.sortBy(),a.opened.then(function(){r.$broadcast("hrjc-loader-hide")})}()}return t.__name="ModalRevisionController",t.$inject=["$filter","$log","$q","$rootScope","$scope","$uibModalInstance","settings","revisionDataList","revisionList","entity","fields","model","modalContract","utils","contactService"],t}),define("job-contract/modules/job-contract.controllers",["common/angular","job-contract/controllers/contract.controller","job-contract/controllers/contract-list.controller","job-contract/controllers/revision-list.controller","job-contract/controllers/form/form-general.controller","job-contract/controllers/form/form-health.controller","job-contract/controllers/form/form-hour.controller","job-contract/controllers/form/form-leave.controller","job-contract/controllers/form/form-pay.controller","job-contract/controllers/form/form-pension.controller","job-contract/controllers/modal/modal-change-reason.controller","job-contract/controllers/modal/modal-contract-new.controller","job-contract/controllers/modal/modal-contract.controller","job-contract/controllers/modal/modal-dialog.controller","job-contract/controllers/modal/modal-progress.controller","job-contract/controllers/modal/modal-revision.controller"],function(e,t,n,o,r,i,a,c,s,l,u,d,f,v,m,p){"use strict";return e.module("job-contract.controllers",[]).controller(t.__name,t).controller(n.__name,n).controller(o.__name,o).controller(r.__name,r).controller(i.__name,i).controller(a.__name,a).controller(c.__name,c).controller(s.__name,s).controller(l.__name,l).controller(u.__name,u).controller(d.__name,d).controller(f.__name,f).controller(v.__name,v).controller(m.__name,m).controller(p.__name,p)}),function(e){define("leave-absences/shared/modules/shared-settings",["common/angular"],function(t){return t.module("leave-absences.settings",[]).constant("shared-settings",{attachmentToken:e.vars.leaveAndAbsences.attachmentToken,debug:e.debug,managerPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/manager-leave/",sharedPathTpl:e.vars.leaveAndAbsences.baseURL+"/views/shared/",serverDateFormat:"YYYY-MM-DD",serverDateTimeFormat:"YYYY-MM-DD HH:mm:ss",permissions:{admin:{access:"access leave and absences",administer:"administer leave and absences"},ssp:{access:"access leave and absences in ssp",manage:"manage leave and absences in ssp"}},fileUploader:{queueLimit:10},statusNames:{approved:"approved",adminApproved:"admin_approved",awaitingApproval:"awaiting_approval",moreInformationRequired:"more_information_required",rejected:"rejected",cancelled:"cancelled"}})})}(CRM),define("leave-absences/shared/modules/apis",["common/angular","common/modules/apis","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.apis",["common.apis","leave-absences.settings"])}),define("leave-absences/shared/modules/models-instances",["common/angular","common/models/instances/instance","common/modules/services","common/modules/models","common/services/check-permissions","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models.instances",["common.models","common.models.instances","common.services","leave-absences.settings"])}),define("leave-absences/shared/modules/models",["common/angular","common/modules/models","common/modules/services","leave-absences/shared/modules/apis","leave-absences/shared/modules/models-instances","leave-absences/shared/modules/shared-settings"],function(e){"use strict";return e.module("leave-absences.models",["common.models","common.services","leave-absences.apis","leave-absences.models.instances","leave-absences.settings"])}),define("leave-absences/shared/apis/absence-type.api",["common/lodash","common/moment","leave-absences/shared/modules/apis","common/services/api"],function(e,t,n){"use strict";n.factory("AbsenceTypeAPI",["$log","api","shared-settings",function(n,o,r){return n.debug("AbsenceTypeAPI"),o.extend({all:function(t){return n.debug("AbsenceTypeAPI.all"),this.sendGET("AbsenceType","get",e.defaultsDeep(t||{},{is_active:!0,options:{sort:"weight ASC"}})).then(function(e){return e.values})},calculateToilExpiryDate:function(o,i,a){return n.debug("AbsenceTypeAPI.calculateToilExpiryDate"),a=e.assign({},a,{absence_type_id:o,date:t(i).format(r.serverDateFormat)}),this.sendPOST("AbsenceType","calculateToilExpiryDate",a).then(function(e){return e.values.expiry_date})}})}])}),define("leave-absences/shared/instances/absence-type.instance",["leave-absences/shared/modules/models-instances","common/models/instances/instance"],function(e){"use strict";e.factory("AbsenceTypeInstance",["$log","ModelInstance",function(e,t){return e.debug("AbsenceTypeInstance"),t.extend({})}])}),define("leave-absences/shared/models/absence-type.model",["common/lodash","leave-absences/shared/modules/models","common/models/model","common/models/option-group","leave-absences/shared/apis/absence-type.api","leave-absences/shared/instances/absence-type.instance"],function(e,t){"use strict";t.factory("AbsenceType",["$log","$q","Model","OptionGroup","AbsenceTypeAPI","AbsenceTypeInstance",function(t,n,o,r,i,a){return t.debug("AbsenceType"),o.extend({all:function(e){return i.all(e).then(function(e){return e.map(function(e){return a.init(e,!0)})})},calculateToilExpiryDate:function(e,t,n){return i.calculateToilExpiryDate(e,t,n)},canExpire:function(e){return i.all({accrual_expiration_unit:{"IS NOT NULL":1},accrual_expiration_duration:{"IS NOT NULL":1},allow_accruals_request:1,id:e,options:{limit:1},return:["id"]}).then(function(e){return e.length>0})},loadCalculationUnits:function(t){return r.valuesOf("hrleaveandabsences_absence_type_calculation_unit").then(function(n){return n=e.indexBy(n,"value"),e.map(t,function(t){return e.assign(t,{calculation_unit_label:n[t.calculation_unit].label,calculation_unit_name:n[t.calculation_unit].name})})})}})}])}),define("leave-absences/shared/instances/absence-period.instance",["leave-absences/shared/modules/models-instances","common/moment","common/models/instances/instance","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriodInstance",["$log","ModelInstance","HR_settings",function(e,n,o){return e.debug("AbsencePeriodInstance"),n.extend({defaultCustomData:function(){return{current:!1}},transformAttributes:function(e){var n=t();return e.current=!1,t(e.start_date).isSameOrBefore(n,"day")&&t(e.end_date).isSameOrAfter(n,"day")&&(e.current=!0),e},isInPeriod:function(e){var n=o.DATE_FORMAT.toUpperCase(),r=t(e,n);return t(this.start_date).isSameOrBefore(r)&&t(this.end_date).isSameOrAfter(r)}})}])}),define("leave-absences/shared/apis/absence-period.api",["leave-absences/shared/modules/apis","common/services/api"],function(e){"use strict";e.factory("AbsencePeriodAPI",["$log","api",function(e,t){return e.debug("AbsencePeriodAPI"),t.extend({all:function(t){return e.debug("AbsencePeriodAPI"),this.sendGET("AbsencePeriod","get",t).then(function(e){return e.values})}})}])}),define("leave-absences/shared/models/absence-period.model",["leave-absences/shared/modules/models","common/moment","leave-absences/shared/modules/shared-settings","leave-absences/shared/instances/absence-period.instance","leave-absences/shared/apis/absence-period.api","common/models/model","common/services/hr-settings"],function(e,t){"use strict";e.factory("AbsencePeriod",["$log","Model","AbsencePeriodAPI","AbsencePeriodInstance","shared-settings",function(e,n,o,r,i){return e.debug("AbsencePeriod"),n.extend({all:function(e){return o.all(e).then(function(e){return e.map(function(e){return r.init(e,!0)})})},current:function(){var e=t().format(i.serverDateFormat),n={start_date:{"<=":e},end_date:{">=":e}};return o.all(n).then(function(e){return e&&e.length?r.init(e[0],!0):null})}})}])}),function(e,t){function n(){var e={nodiff:"",year:"year",years:"years",month:"month",months:"months",day:"day",days:"days",hour:"hour",hours:"hours",minute:"minute",minutes:"minutes",second:"second",seconds:"seconds",delimiter:" "};moment.fn.preciseDiff=function(e){return moment.preciseDiff(this,e)},moment.preciseDiff=function(t,n){function o(t,n){return t+" "+e[n+(1===t?"":"s")]}var r=moment(t),i=moment(n);if(r.isSame(i))return e.nodiff;if(r.isAfter(i)){var a=r;r=i,i=a}var c=i.year()-r.year(),s=i.month()-r.month(),l=i.date()-r.date();if(l<0){var u=moment(i.year()+"-"+(i.month()+1),"YYYY-MM").subtract("months",1).daysInMonth();l=uLength Of Employment
"),e(".lengthEmployment").html(a),o&&l<0&&e(".lengthEmployment").css({color:"#FF0000"})}var r=CRM.grID,i=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(2) .crm-custom-data").html(),a=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(3) .crm-custom-data").html();i&&o(i,a,r),e(document).on("click","#_qf_CustomData_upload",function(){e(document).ajaxSuccess(function(t,n,i){i.extraData&&"CRM_Contact_Form_Inline_CustomData"==i.extraData.class_name&&i.extraData.groupID==r&&setTimeout(function(){var t=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(2) .crm-custom-data").html(),n=e("#custom-set-content-"+r+" .crm-inline-block-content div:nth-child(3) .crm-custom-data").html();t&&o(t,n,r)},300)})})}(CRM.$,CRM._),define("job-contract/modules/job-contract.core",["common/angular","common/ui-select","common/directives/angular-date/date-input","common/filters/angular-date/format-date","common/filters/time-unit-applier.filter","common/modules/routers/compu-ng-route","common/modules/directives","common/services/dom-event-trigger","common/services/pub-sub","common/services/angular-date/date-format","leave-absences/shared/models/absence-type.model","leave-absences/shared/models/absence-period.model","job-contract/vendor/fraction","job-contract/vendor/job-summary"],function(e){"use strict";e.module("job-contract.core",["ngAnimate","compuNgRoute","ngResource","angularFileUpload","ui.bootstrap","ui.select","common.angularDate","common.services","common.directives","common.filters","leave-absences.models"])}),define("job-contract/directives/contact.directive",[],function(){"use strict";function e(e,t,n,o){return t.debug("Directive: hrjcContact"),{restrict:"A",scope:{renderAsLink:"=?hrjcContactLink",contactId:"=?hrjcContact"},template:"{{contact.label}}",link:function(t,n){t.contactId&&t.$watch("contactId",function(r){o.getOne(t.contactId).then(function(o){t.contact=o,t.renderAsLink&&(n.html('{{contact.label}} '),e(n.contents())(t))})})}}}return e.__name="hrjcContact",e.$inject=["$compile","$log","settings","contactService"],e}),define("job-contract/directives/loader.directive",[],function(){"use strict";function e(e,t){return e.debug("Directive: hrjcLoader"),{link:function(e,t,n){function o(){var e=window.getComputedStyle(t[0]).position;return"relative"===e||"absolute"===e||"fixed"===e}function r(){o()||(t.css("position","relative"),s=!0),t.append(a),c=!0}function i(){c&&a.parentNode.removeChild(a),c=!1,s&&t.css("position","")}var a=document.createElement("div"),c=!1,s=!1;a.className="hrjc-loader spinner",n.hrjcLoaderShow&&r(),e.$on("hrjc-loader-show",function(){r()}),e.$on("hrjc-loader-hide",function(){i()})}}}return e.__name="hrjcLoader",e.$inject=["$log","$rootScope"],e}),define("job-contract/directives/number.directive",[],function(){"use strict";function e(e){return e.debug("Directive: hrjcNumber"),{require:"ngModel",link:function(e,t,n,o){var r=2,i=n.hrjcNumberFloat||!1,a=n.hrjcToHours||!1,c=n.hrjcNotNegative||!1;n.hrjcNumber&&"number"==typeof+n.hrjcNumber&&(r=n.hrjcNumber),t.bind("blur",function(){var e=parseFloat(o.$viewValue)||0;c&&e<0&&(e=0),a&&(e=.25*Math.ceil(e/.25)),o.$setViewValue(i?Math.round(100*e)/100:e.toFixed(r)),o.$render()})}}}return e.__name="hrjcNumber",e.$inject=["$log"],e}),define("job-contract/directives/validate.directive",["common/angular"],function(e){"use strict";function t(t){return t.debug("Directive: hrjcValidate"),{restrict:"A",require:"^form",scope:{isWarning:"=?hrjcValidateWarning"},link:function(t,n,o,r){function i(e,t){n.toggleClass("has-success",!e&&!t),f.toggleClass("glyphicon-ok",!e&&!t)}function a(e,t){n.toggleClass("has-warning",!e&&t),f.toggleClass("glyphicon-warning-sign",!e&&t)}function c(e){n.toggleClass("has-error",e),f.toggleClass("glyphicon-remove",e)}var s=n[0].querySelector("[name]"),l=e.element(s),u=l.attr("name"),d=document.createElement("span"),f=e.element(d);u&&(n.addClass("has-feedback"),f.addClass("glyphicon form-control-feedback"),l.after(f),t.$watch(function(){return r[u]&&r[u].$invalid},function(e){r[u].$dirty&&(i(e,t.isWarning),c(e))}),void 0!==t.isWarning&&t.$watch("isWarning",function(e){var t=r[u].$invalid;r[u].$dirty&&(i(t,e),a(t,e))}),l.bind("blur",function(){c(r[u].$invalid)}))}}}return t.__name="hrjcValidate",t.$inject=["$log"],t}),define("job-contract/modules/job-contract.directives",["common/angular","job-contract/directives/contact.directive","job-contract/directives/loader.directive","job-contract/directives/number.directive","job-contract/directives/validate.directive"],function(e,t,n,o,r){"use strict";return e.module("job-contract.directives",[]).directive(t.__name,t).directive(n.__name,n).directive(o.__name,o).directive(r.__name,r)}),define("job-contract/filters/capitalize.filter",[],function(){"use strict";function e(e){return e.debug("Filter: capitalize"),function(e){return e?e.replace(/([^\W_]+[^\s-]*) */g,function(e){
return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}):""}}return e.__name="capitalize",e.$inject=["$log"],e}),define("job-contract/filters/format-amount.filter",[],function(){"use strict";function e(e){return e.debug("Filter: formatAmount"),function(e){return e&&-1===e.indexOf(".")?e+".00":e}}return e.__name="formatAmount",e.$inject=["$log"],e}),define("job-contract/filters/format-period.filter",[],function(){"use strict";function e(e,t){return t.debug("Filter: formatPeriod"),function(t){return t?e("date")(t,"yyyy/MM/dd"):"Unspecified"}}return e.__name="formatPeriod",e.$inject=["$filter","$log"],e}),define("job-contract/filters/get-obj-by-id.filter",[],function(){"use strict";function e(e){return e.debug("Filter: getObjById"),function(e,t,n){if(!e)return null;for(var o=0,r=e.length;oCiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRMed
diff --git a/hrprofile/info.xml b/hrprofile/info.xml
index 28fff5a815c..5a69393d18f 100644
--- a/hrprofile/info.xml
+++ b/hrprofile/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRProfile
diff --git a/hrqual/info.xml b/hrqual/info.xml
index 4e6dcc3a743..90f47a8ec96 100644
--- a/hrqual/info.xml
+++ b/hrqual/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRQual
diff --git a/hrrecruitment/info.xml b/hrrecruitment/info.xml
index 0adbcb6c2dd..bd33b0c44d4 100644
--- a/hrrecruitment/info.xml
+++ b/hrrecruitment/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRRecruitment
diff --git a/hrreport/info.xml b/hrreport/info.xml
index 7f4ad9d5b82..5eacd53c769 100644
--- a/hrreport/info.xml
+++ b/hrreport/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRReport
diff --git a/hrstaffdir/info.xml b/hrstaffdir/info.xml
index cbfec84ab47..a377cca7dae 100644
--- a/hrstaffdir/info.xml
+++ b/hrstaffdir/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/Hrstaffdir
diff --git a/hrui/info.xml b/hrui/info.xml
index 4caf678024e..f50dd7776ea 100644
--- a/hrui/info.xml
+++ b/hrui/info.xml
@@ -8,13 +8,12 @@
CiviCRM LLC
info@civicrm.org
- 2018-02-26
- 1.7.4
- beta
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/HRUI
diff --git a/hrvisa/info.xml b/hrvisa/info.xml
index e4946ed0750..55e5dc10387 100644
--- a/hrvisa/info.xml
+++ b/hrvisa/info.xml
@@ -10,11 +10,10 @@
2017-08-22
1.7.0-RC
- beta
+ stable
4.7
- This is a new, undeveloped module
CRM/HRVisa
diff --git a/org.civicrm.bootstrapcivihr/info.xml b/org.civicrm.bootstrapcivihr/info.xml
index ba01c773394..ae09b9a9f74 100644
--- a/org.civicrm.bootstrapcivihr/info.xml
+++ b/org.civicrm.bootstrapcivihr/info.xml
@@ -5,12 +5,12 @@
A CiviHR extension of the CiviCRM Bootstrap theme
AGPL-3.0
- Alessandro Verdura
- alessandro@compucorp.co.uk
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
diff --git a/org.civicrm.hremergency/info.xml b/org.civicrm.hremergency/info.xml
index 80bf56b060b..6aaea248694 100644
--- a/org.civicrm.hremergency/info.xml
+++ b/org.civicrm.hremergency/info.xml
@@ -2,19 +2,19 @@
hremergency
Emergency Contacts (CiviHR)
-
+ Emergency Contacts extension for CiviHR
AGPL-3.0
- gregmeszaros
- meszaros275@gmail.com
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- Emergency Contacts extensions for CiviHR
+
CRM/Hremergency
diff --git a/org.civicrm.reqangular/info.xml b/org.civicrm.reqangular/info.xml
index 43c60e7738b..12c58d4887d 100755
--- a/org.civicrm.reqangular/info.xml
+++ b/org.civicrm.reqangular/info.xml
@@ -7,16 +7,15 @@
angularResource, angularBootstrap, angularFileUpload
AGPL-3.0
- Mateusz Cieplinski
- mateusz@coldrun.pl
+ Compucorp Ltd
+ info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
- This is a new, undeveloped module
CRM/Reqangular
diff --git a/uk.co.compucorp.civicrm.hrcomments/info.xml b/uk.co.compucorp.civicrm.hrcomments/info.xml
index 859798b1015..fec9297662c 100644
--- a/uk.co.compucorp.civicrm.hrcomments/info.xml
+++ b/uk.co.compucorp.civicrm.hrcomments/info.xml
@@ -8,9 +8,9 @@
Compucorp Ltd
info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.2
diff --git a/uk.co.compucorp.civicrm.hrcontactactionsmenu/info.xml b/uk.co.compucorp.civicrm.hrcontactactionsmenu/info.xml
index 52dcb1ded66..241605144c9 100644
--- a/uk.co.compucorp.civicrm.hrcontactactionsmenu/info.xml
+++ b/uk.co.compucorp.civicrm.hrcontactactionsmenu/info.xml
@@ -9,9 +9,9 @@
Compucorp Ltd
info@compucorp.co.uk
- 2017-12-20
- 1.7.2
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
diff --git a/uk.co.compucorp.civicrm.hrcore/info.xml b/uk.co.compucorp.civicrm.hrcore/info.xml
index c64d057d84e..aa25c303ad0 100644
--- a/uk.co.compucorp.civicrm.hrcore/info.xml
+++ b/uk.co.compucorp.civicrm.hrcore/info.xml
@@ -8,9 +8,9 @@
Compucorp Ltd
info@compucorp.co.uk
- 2018-02-26
- 1.7.4
- alpha
+ 2018-03-26
+ 1.7.5
+ stable
4.7
diff --git a/uk.co.compucorp.civicrm.hrcore/templates/CRM/HRCore/UserMenuMarkup.tpl b/uk.co.compucorp.civicrm.hrcore/templates/CRM/HRCore/UserMenuMarkup.tpl
index e1e251a9306..185637e274e 100644
--- a/uk.co.compucorp.civicrm.hrcore/templates/CRM/HRCore/UserMenuMarkup.tpl
+++ b/uk.co.compucorp.civicrm.hrcore/templates/CRM/HRCore/UserMenuMarkup.tpl
@@ -10,7 +10,7 @@