function handlePayStubAmendmentStatuses() { //Mark all PS amendments as 'PAID' if this status is paid. //Mark as NEW if the PS is deleted? if ($this->getStatus() == 40) { $ps_amendment_status_id = 55; //PAID } else { $ps_amendment_status_id = 52; //INUSE } //Loop through each entry in current pay stub, if they have //a PS amendment ID assigned to them, change the status. if (is_array($this->tmp_data['current_pay_stub'])) { foreach ($this->tmp_data['current_pay_stub'] as $entry_arr) { if (isset($entry_arr['pay_stub_amendment_id']) and $entry_arr['pay_stub_amendment_id'] != '') { Debug::Text('aFound PS Amendments to change status on...', __FILE__, __LINE__, __METHOD__, 10); $ps_amendment_ids[] = $entry_arr['pay_stub_amendment_id']; } } unset($entry_arr); } elseif ($this->getStatus() != 10) { //Instead of loading the current pay stub entries, just run a query instead. $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($this->getId()); foreach ($pself as $pay_stub_entry_obj) { if ($pay_stub_entry_obj->getPayStubAmendment() != FALSE) { Debug::Text('bFound PS Amendments to change status on...', __FILE__, __LINE__, __METHOD__, 10); $ps_amendment_ids[] = $pay_stub_entry_obj->getPayStubAmendment(); } } } if (isset($ps_amendment_ids) and is_array($ps_amendment_ids)) { Debug::Text('cFound PS Amendments to change status on...', __FILE__, __LINE__, __METHOD__, 10); foreach ($ps_amendment_ids as $ps_amendment_id) { //Set PS amendment status to match Pay stub. $psalf = new PayStubAmendmentListFactory(); $psalf->getById($ps_amendment_id); if ($psalf->getRecordCount() == 1) { Debug::Text('Changing Status of PS Amendment: ' . $ps_amendment_id, __FILE__, __LINE__, __METHOD__, 10); $ps_amendment_obj = $psalf->getCurrent(); $ps_amendment_obj->setStatus($ps_amendment_status_id); $ps_amendment_obj->Save(); unset($ps_amendment_obj); } unset($psalf); } unset($ps_amendment_ids); } return TRUE; }
function getAmountSumByUserIdAndTypeIdAndAuthorizedAndStartDateAndEndDate($user_id, $type_id, $authorized, $start_date, $end_date, $where = NULL, $order = NULL) { $psalf = new PayStubAmendmentListFactory(); $psalf->getByUserIdAndTypeIdAndAuthorizedAndStartDateAndEndDate($user_id, $type_id, $authorized, $start_date, $end_date, $where, $order); if ($psalf->getRecordCount() > 0) { $sum = 0; Debug::text('Record Count: ' . $psalf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); foreach ($psalf as $psa_obj) { $amount = $psa_obj->getCalculatedAmount(); Debug::text('PS Amendment Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); $sum += $amount; } return $sum; } Debug::text('No PS Amendments found...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }