$udtf->setId($udt_data['id']); } else { Debug::Text('Editing absence, absence policy changed, deleting old record ID: ' . $udt_data['id'], __FILE__, __LINE__, __METHOD__, 10); $udtlf = new UserDateTotalListFactory(); $udtlf->getById($udt_data['id']); if ($udtlf->getRecordCount() == 1) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setDeleted(TRUE); if ($udt_obj->isValid()) { $udt_obj->Save(); } } unset($udtlf, $udt_obj); } } $udtf->setUserDateId(UserDateFactory::findOrInsertUserDate($udt_data['user_id'], $date_stamp)); $udtf->setStatus(30); //Absence $udtf->setType(10); //Total $udtf->setAbsencePolicyID($udt_data['absence_policy_id']); //Total $udtf->setBranch($udt_data['branch_id']); $udtf->setDepartment($udt_data['department_id']); $udtf->setTotalTime($udt_data['total_time']); if (isset($udt_data['override'])) { $udtf->setOverride(TRUE); } else { $udtf->setOverride(FALSE); } if ($udtf->isValid()) {
* Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'id', 'user_date_id', 'user_id', 'date', 'udt_data'))); if (isset($udt_data)) { if ($udt_data['total_time'] != '') { $udt_data['total_time'] = TTDate::parseTimeUnit($udt_data['total_time']); } } $udtf = new UserDateTotalFactory(); $action = strtolower($action); switch ($action) { case 'submit': Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); //Debug::setVerbosity(11); $udtf->setId($udt_data['id']); $udtf->setUserDateId($udt_data['user_date_id']); $udtf->setStatus($udt_data['status_id']); $udtf->setType($udt_data['type_id']); $udtf->setBranch($udt_data['branch_id']); $udtf->setDepartment($udt_data['department_id']); if (isset($udt_data['job_id'])) { $udtf->setJob($udt_data['job_id']); } if (isset($udt_data['job_item_id'])) { $udtf->setJobItem($udt_data['job_item_id']); } if (isset($udt_data['quantity'])) { $udtf->setQuantity($udt_data['quantity']); } if (isset($udt_data['bad_quantity'])) { $udtf->setBadQuantity($udt_data['bad_quantity']);
static function reCalculateDay($user_date_id, $enable_exception = FALSE, $enable_premature_exceptions = FALSE, $enable_future_exceptions = TRUE, $enable_holidays = FALSE) { Debug::text('Re-calculating User Date ID: ' . $user_date_id . ' Enable Exception: ' . (int) $enable_exception, __FILE__, __LINE__, __METHOD__, 10); $udtf = new UserDateTotalFactory(); $udtf->setUserDateId($user_date_id); $udtf->calcSystemTotalTime(); if ($enable_holidays == TRUE) { $holiday_user_date_ids = $udtf->getHolidayUserDateIDs(); //var_dump($holiday_user_date_ids); if (is_array($holiday_user_date_ids)) { foreach ($holiday_user_date_ids as $holiday_user_date_id) { Debug::Text('reCalculating Holiday...', __FILE__, __LINE__, __METHOD__, 10); UserDateTotalFactory::reCalculateDay($holiday_user_date_id, FALSE, FALSE, FALSE, FALSE); } } unset($holiday_user_date_ids, $holiday_user_date_id); } if (!isset(self::$calc_exception) and $enable_exception == TRUE) { ExceptionPolicyFactory::calcExceptions($user_date_id, $enable_premature_exceptions, $enable_future_exceptions); } return TRUE; }