$filter_data['permission_children_ids'] = $permission_children_ids; } if ($permission->Check('schedule', 'edit_own')) { $filter_data['permission_children_ids'][] = $current_user->getId(); } } $sf = TTnew('ScheduleFactory'); $ulf = TTnew('UserListFactory'); $action = Misc::findSubmitButton(); $action = strtolower($action); switch ($action) { case 'submit': //Debug::setVerbosity(11); Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); $fail_transaction = FALSE; if (TTDate::getDayDifference($data['start_date_stamp'], $data['end_date_stamp']) > 31) { Debug::Text('Date Range Exceeds 31 days, truncating', __FILE__, __LINE__, __METHOD__, 10); $sf->Validator->isTrue('date_stamp', FALSE, TTi18n::getText('Date range exceeds the maximum of 31 days')); } if (!(isset($filter_user_id) and is_array($filter_user_id) and count($filter_user_id) > 0)) { $sf->Validator->isTrue('user_id', FALSE, TTi18n::getText('Please select at least one employee')); } if (!($data['start_full_time_stamp'] != '' and $data['end_full_time_stamp'] != '' and $data['start_full_time_stamp'] >= time() - 86400 * 365 and $data['end_full_time_stamp'] <= time() + 86400 * 365)) { $sf->Validator->isTrue('date_stamp', FALSE, TTi18n::getText('Start or End dates are invalid')); } if ($sf->Validator->isValid()) { Redirect::Page(URLBuilder::getURL(array('action' => 'add_mass_schedule', 'filter_user_id' => $filter_user_id, 'data' => $data), '../progress_bar/ProgressBarControl.php')); } default: if ($action != 'submit' and !is_array($data)) { Debug::Text(' ID was NOT passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
static function proRateSalary($salary, $wage_effective_date, $prev_wage_effective_date, $pp_start_date, $pp_end_date, $termination_date) { $prev_wage_effective_date = (int) $prev_wage_effective_date; if ($wage_effective_date < $pp_start_date) { $wage_effective_date = $pp_start_date; } $total_pay_period_days = ceil(TTDate::getDayDifference($pp_start_date, $pp_end_date)); if ($prev_wage_effective_date == 0) { //ProRate salary to termination date if its in the middle of a pay period. if ($termination_date != '' and $termination_date > 0 and $termination_date < $pp_end_date) { Debug::text(' Setting PP end date to Termination Date: ' . TTDate::GetDate('DATE', $termination_date), __FILE__, __LINE__, __METHOD__, 10); $pp_end_date = $termination_date; } Debug::text(' Using Pay Period End Date: ' . TTDate::GetDate('DATE', $pp_end_date), __FILE__, __LINE__, __METHOD__, 10); $total_wage_effective_days = ceil(TTDate::getDayDifference($wage_effective_date, $pp_end_date)); } else { Debug::text(' Using Prev Effective Date: ' . TTDate::GetDate('DATE', $prev_wage_effective_date), __FILE__, __LINE__, __METHOD__, 10); $total_wage_effective_days = ceil(TTDate::getDayDifference($wage_effective_date, $prev_wage_effective_date)); } Debug::text('Salary: ' . $salary . ' Total Pay Period Days: ' . $total_pay_period_days . ' Wage Effective Days: ' . $total_wage_effective_days, __FILE__, __LINE__, __METHOD__, 10); //$pro_rate_salary = $salary * ($total_wage_effective_days / $total_pay_period_days); $pro_rate_salary = bcmul($salary, bcdiv($total_wage_effective_days, $total_pay_period_days)); Debug::text('Pro Rate Salary: ' . $pro_rate_salary, __FILE__, __LINE__, __METHOD__, 10); return $pro_rate_salary; }