function getByCompanyIdAndStatusIdAndTypeIdArray($company_id, $status_id, $type_id, $include_blank = TRUE, $abbreviate_type = TRUE) { if ($type_id == '') { return FALSE; } $psealf = new PayStubEntryAccountListFactory(); $psealf->getByCompanyIdAndStatusIdAndTypeId($company_id, $status_id, $type_id); //$psenlf->getByTypeId($type_id); $entry_name_list = array(); if ($include_blank == TRUE) { $entry_name_list[0] = '--'; } $type_options = $this->getOptions('type'); if ($abbreviate_type == TRUE) { foreach ($type_options as $key => $val) { $type_options[$key] = str_replace(array('Employee', 'Employer', 'Deduction'), array('EE', 'ER', 'Ded'), $val); } unset($key, $val); } foreach ($psealf as $entry_name) { $entry_name_list[$entry_name->getID()] = $type_options[$entry_name->getType()] . ' - ' . $entry_name->getName(); } return $entry_name_list; }
static function releaseAllAccruals($user_id, $effective_date = NULL) { Debug::Text('Release 100% of all accruals!', __FILE__, __LINE__, __METHOD__, 10); if ($user_id == '') { return FALSE; } if ($effective_date == '') { $effective_date = TTDate::getTime(); } Debug::Text('Effective Date: ' . TTDate::getDate('DATE+TIME', $effective_date), __FILE__, __LINE__, __METHOD__, 10); $ulf = new UserListFactory(); $ulf->getById($user_id); if ($ulf->getRecordCount() > 0) { $user_obj = $ulf->getCurrent(); } else { return FALSE; } //Get all PSE acccount accruals $psealf = new PayStubEntryAccountListFactory(); $psealf->getByCompanyIdAndStatusIdAndTypeId($user_obj->getCompany(), 10, 50); if ($psealf->getRecordCount() > 0) { $ulf->StartTransaction(); foreach ($psealf as $psea_obj) { //Get PSE account that affects this accrual. $psealf_tmp = new PayStubEntryAccountListFactory(); $psealf_tmp->getByCompanyIdAndAccrualId($user_obj->getCompany(), $psea_obj->getId()); if ($psealf_tmp->getRecordCount() > 0) { $release_account_id = $psealf_tmp->getCurrent()->getId(); $psaf = new PayStubAmendmentFactory(); $psaf->setStatus(50); //Active $psaf->setType(20); //Percent $psaf->setUser($user_obj->getId()); $psaf->setPayStubEntryNameId($release_account_id); $psaf->setPercentAmount(100); $psaf->setPercentAmountEntryNameId($psea_obj->getId()); $psaf->setEffectiveDate($effective_date); $psaf->setDescription('Release Accrual Balance'); if ($psaf->isValid()) { Debug::Text('Release Accrual Is Valid!!: ', __FILE__, __LINE__, __METHOD__, 10); $psaf->Save(); } } else { Debug::Text('No Release Account for this Accrual!!', __FILE__, __LINE__, __METHOD__, 10); } } //$ulf->FailTransaction(); $ulf->CommitTransaction(); } else { Debug::Text('No Accruals to release...', __FILE__, __LINE__, __METHOD__, 10); } return FALSE; }