function postSave() { if ($this->getEnableTimeSheetVerificationCheck()) { //Check to see if schedule is verified, if so unverify it on modified punch. //Make sure exceptions are calculated *after* this so TimeSheet Not Verified exceptions can be triggered again. if (is_object($this->getUserDateObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()) and is_object($this->getUserDateObject()->getPayPeriodObject()->getPayPeriodScheduleObject()) and $this->getUserDateObject()->getPayPeriodObject()->getPayPeriodScheduleObject()->getTimeSheetVerifyType() != 10) { //Find out if timesheet is verified or not. $pptsvlf = TTnew('PayPeriodTimeSheetVerifyListFactory'); $pptsvlf->getByPayPeriodIdAndUserId($this->getUserDateObject()->getPayPeriod(), $this->getUserDateObject()->getUser()); if ($pptsvlf->getRecordCount() > 0) { //Pay period is verified, delete all records and make log entry. //These can be added during the maintenance jobs, so the audit records are recorded as user_id=0, check those first. Debug::text('Pay Period is verified, deleting verification records: ' . $pptsvlf->getRecordCount() . ' User ID: ' . $this->getUserDateObject()->getUser() . ' Pay Period ID: ' . $this->getUserDateObject()->getPayPeriod(), __FILE__, __LINE__, __METHOD__, 10); foreach ($pptsvlf as $pptsv_obj) { TTLog::addEntry($pptsv_obj->getId(), 500, TTi18n::getText('Schedule Modified After Verification') . ': ' . UserListFactory::getFullNameById($this->getUserDateObject()->getUser()) . ' ' . TTi18n::getText('Schedule') . ': ' . TTDate::getDate('DATE', $this->getStartTime()), NULL, $pptsvlf->getTable()); $pptsv_obj->setDeleted(TRUE); if ($pptsv_obj->isValid()) { $pptsv_obj->Save(); } } } } } if ($this->getEnableReCalculateDay() == TRUE) { //Calculate total time. Mainly for docked. //Calculate entire week as Over Schedule (Weekly) OT policy needs to be reapplied if the schedule changes. if (is_object($this->getUserDateObject()) and $this->getUserDateObject()->getUser() > 0) { //When shifts are assigned to different days, we need to calculate both days the schedule touches, as the shift could be assigned to either of them. UserDateTotalFactory::smartReCalculate($this->getUserDateObject()->getUser(), array($this->getUserDateID(), $this->getOldUserDateID(), UserDateFactory::findOrInsertUserDate($this->getUserDateObject()->getUser(), $this->getStartTime()), UserDateFactory::findOrInsertUserDate($this->getUserDateObject()->getUser(), $this->getEndTime())), TRUE, FALSE); } } return TRUE; }
function postSave() { $this->removeCache($this->getId()); $this->calcUserDate(); $this->calcUserDateTotal(); if ($this->getEnableCalcSystemTotalTime() == TRUE) { $this->old_user_date_ids[] = $this->getUserDateID(); if ($this->getUser() > 0) { //var_dump($this->old_user_date_ids); UserDateTotalFactory::smartReCalculate($this->getUser(), $this->old_user_date_ids, $this->getEnableCalcException(), $this->getEnablePreMatureException()); } } return TRUE; }