function createSchedulePolicy($company_id, $meal_policy_id) { $spf = new SchedulePolicyFactory(); $spf->setCompany($company_id); $spf->setName('One Hour Lunch'); $spf->setMealPolicyID($meal_policy_id); $spf->setOverTimePolicyID(0); $spf->setAbsencePolicyID(0); $spf->setStartStopWindow(1800); if ($spf->isValid()) { $insert_id = $spf->Save(); Debug::Text('Schedule Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); return $insert_id; } Debug::Text('Failed Creating Schedule Policy!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
/* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'id', 'data'))); if (isset($data['start_stop_window'])) { $data['start_stop_window'] = TTDate::parseTimeUnit($data['start_stop_window']); } $spf = new SchedulePolicyFactory(); $action = Misc::findSubmitButton(); $action = strtolower($action); switch ($action) { case 'submit': Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); $spf->setId($data['id']); $spf->setCompany($current_company->getId()); $spf->setName($data['name']); $spf->setMealPolicyID($data['meal_policy_id']); $spf->setOverTimePolicyID($data['over_time_policy_id']); $spf->setAbsencePolicyID($data['absence_policy_id']); $spf->setStartStopWindow($data['start_stop_window']); if ($spf->isValid()) { $spf->Save(FALSE); if (isset($data['break_policy_ids'])) { $spf->setBreakPolicy($data['break_policy_ids']); } else { $spf->setBreakPolicy(array()); } Redirect::Page(URLBuilder::getURL(NULL, 'SchedulePolicyList.php')); break; } default: