if (isset($data['accrual_policy_id']) and isset($data['start_date']) and isset($data['end_date'])) { if ($data['start_date'] <= $data['end_date']) { $start_date = TTDate::getBeginDayEpoch($data['start_date']); $end_date = TTDate::getBeginDayEpoch($data['end_date']); $total_days = TTDate::getDays($end_date - $start_date); $offset = 86400 / 2; $init_progress_bar = TRUE; if ($init_progress_bar == TRUE) { InitProgressBar(); $init_progress_bar = FALSE; } $progress_bar->setValue(0); $progress_bar->display(); $apf = new AccrualPolicyFactory(); $aplf = new AccrualPolicyListFactory(); $aplf->getByIdAndCompanyId((int) $data['accrual_policy_id'], $current_company->getId()); if ($aplf->getRecordCount() > 0) { foreach ($aplf as $ap_obj) { $aplf->StartTransaction(); TTLog::addEntry($current_user->getId(), 500, 'Recalculate Accrual Policy: ' . $ap_obj->getName() . ' Start Date: ' . TTDate::getDate('TIME', $data['start_date']) . ' End Date: ' . TTDate::getDate('TIME', $data['end_date']) . ' Total Days: ' . round($total_days), $current_user->getId(), $ap_obj->getTable()); $x = 0; for ($i = $start_date; $i < $end_date; $i += 86400) { Debug::Text('Recalculating Accruals for Date: ' . TTDate::getDate('DATE+TIME', $i), __FILE__, __LINE__, __METHOD__, 10); $ap_obj->addAccrualPolicyTime($i, $offset); $progress_bar->setValue(Misc::calculatePercent($x, $total_days)); $progress_bar->display(); $x++; } //$aplf->FailTransaction(); $aplf->CommitTransaction(); }
Debug::Arr($ids, 'Selected Objects', __FILE__, __LINE__, __METHOD__, 10); $action = Misc::findSubmitButton(); switch ($action) { case 'add': Redirect::Page(URLBuilder::getURL(NULL, 'EditAccrualPolicy.php', FALSE)); break; case 'delete': case 'undelete': if (strtolower($action) == 'delete') { $delete = TRUE; } else { $delete = FALSE; } $aplf = new AccrualPolicyListFactory(); foreach ($ids as $id) { $aplf->getByIdAndCompanyId($id, $current_company->getId()); $aplf->StartTransaction(); foreach ($aplf as $ap_obj) { $ap_obj->setDeleted($delete); if ($ap_obj->isValid()) { $ap_obj->Save(); } } $aplf->CommitTransaction(); } Redirect::Page(URLBuilder::getURL(NULL, 'AccrualPolicyList.php')); break; default: $aplf = new AccrualPolicyListFactory(); $aplf->getByCompanyId($current_company->getId()); $pager = new Pager($aplf);
function getAbsencePolicyData($absence_policy_id) { global $current_company; if (!is_object($current_company)) { return FALSE; } $aplf = new AbsencePolicyListFactory(); $aplf->getByIdAndCompanyId($absence_policy_id, $current_company->getId()); if ($aplf->getRecordCount() > 0) { $ap_obj = $aplf->getCurrent(); $ap_data = $ap_obj->getObjectAsArray(); $aplf = new AccrualPolicyListFactory(); $aplf->getByIdAndCompanyId($ap_obj->getAccrualPolicyID(), $current_company->getId()); if ($aplf->getRecordCount() > 0) { $ap_data['accrual_policy_name'] = $aplf->getCurrent()->getName(); } else { $ap_data['accrual_policy_name'] = 'None'; } return $ap_data; } return FALSE; }