function loadPreviousPayStub() { if ($this->getUser() == FALSE or $this->getStartDate() == FALSE) { return FALSE; } //Grab last pay stub so we can use it for YTD calculations on this pay stub. $pslf = new PayStubListFactory(); $pslf->getLastPayStubByUserIdAndStartDate($this->getUser(), $this->getStartDate()); if ($pslf->getRecordCount() > 0) { $ps_obj = $pslf->getCurrent(); Debug::text('Loading Data from Pay Stub ID: ' . $ps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); $retarr = array('id' => $ps_obj->getId(), 'start_date' => $ps_obj->getStartDate(), 'end_date' => $ps_obj->getEndDate(), 'transaction_date' => $ps_obj->getTransactionDate(), 'entries' => NULL); // //If previous pay stub is in a different year, only carry forward the accrual accounts. // $new_year = FALSE; if (TTDate::getYear($this->getTransactionDate()) != TTDate::getYear($ps_obj->getTransactionDate())) { Debug::text('Pay Stub Years dont match!...', __FILE__, __LINE__, __METHOD__, 10); $new_year = TRUE; } //Get pay stub entries $pself = new PayStubEntryListFactory(); $pself->getByPayStubId($ps_obj->getID()); if ($pself->getRecordCount() > 0) { foreach ($pself as $pse_obj) { //Get PSE account type, group by that. $psea_arr = $this->getPayStubEntryAccountArray($pse_obj->getPayStubEntryNameId()); if (is_array($psea_arr)) { $type_id = $psea_arr['type_id']; } else { $type_id = NULL; } //If we're just starting a new year, only carry over //accrual balances, reset all YTD entries. if ($new_year == FALSE or $type_id == 50) { $pse_arr[] = array('id' => $pse_obj->getId(), 'pay_stub_entry_type_id' => $type_id, 'pay_stub_entry_account_id' => $pse_obj->getPayStubEntryNameId(), 'pay_stub_amendment_id' => $pse_obj->getPayStubAmendment(), 'rate' => $pse_obj->getRate(), 'units' => $pse_obj->getUnits(), 'amount' => $pse_obj->getAmount(), 'ytd_units' => $pse_obj->getYTDUnits(), 'ytd_amount' => $pse_obj->getYTDAmount()); } unset($type_id, $psea_obj); } if (isset($pse_arr)) { $retarr['entries'] = $pse_arr; $this->tmp_data['previous_pay_stub'] = $retarr; return TRUE; } } } Debug::text('Returning FALSE...', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }