Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class iHRIS_Intervention_A1_management extends iHRIS_Intervention {
- /**
- * Get the field names that are yearly inputs
- * @returns array of string
- */
- public function yearlyInputs() {
- return array('manager_time','support_staff_time','other_staff_time');
- }
- /**
- * Get the cost of the salaries for the indicated year
- * @return total cost for salaries
- */
- public function costSalaries($start_year,$year_offset,$salary,$time) {
- $year = $start_year + $year_offset;
- $sal_cost = 0;
- if (!array_key_exists($salary,$this->fields) || ! $this->fields[$salary] instanceof I2CE_FormField_INT) {
- I2CE::raiseError("Field $salary is not an INT");
- return 0;
- }
- if (!array_key_exists($time,$this->fields) || ! $this->fields[$time] instanceof I2CE_FormField_ASSOC_INT) {
- I2CE::raiseError("Field $time is not an ASSOC_INT");
- return 0;
- }
- $time = 0;
- if (array_key_exists($time,$this->fields) && $this->fields[$time] instanceof I2CE_FormField_ASSOC_INT && $this->fields[$time]->keyIsSet($year)) {
- $time = max(0,$this->fields[$time]->getValueOfKey($year));
- }
- return (($this->inflateCosts($year_offset,max(0,$this->fields[$salary]->getValue())))*12*(( $time /100)));
- }
- /**
- * Get the cost for the indicated year
- * @param int $start_year
- * @param int $year
- */
- protected function _getCostByYear($start_year,$year_offset) {
- $cost = 0;
- foreach ( array('supplies','communications','other') as $cost) {
- $costField = $this->getField($cost);
- if (!array_key_exists($cost,$this->fields) || ! $this->fields[$cost] instanceof I2CE_FormField_INT) {
- I2CE::raiseError("Field $cost is not an INT");
- continue;
- }
- $cost += $this->inflateCosts($year_offset,max(0,$this->fields[$cost]->getValue()));
- }
- $salaries_cost = 0;
- $salaries = array ('manager_time'=>'manager_salary','support_staff_time'=>'support_staff_salary','other_staff_time'=>'other_staff_salary');
- foreach ($salaries as $time=>$salary) {
- $salaries_cost += $this->costSalary($start_year,$year_offset,$salary,$time);
- }
- return $salaries_cost + $cost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement