function createMealPolicy($company_id, $type) { $mpf = new MealPolicyFactory(); $mpf->setCompany($company_id); switch ($type) { case 100: //Normal 1hr lunch: Detect by Time Window $mpf->setName('Normal - Time Window'); $mpf->setType(20); $mpf->setTriggerTime(3600 * 6); $mpf->setAmount(3600); $mpf->setAutoDetectType(10); $mpf->setStartWindow(3 * 3600); $mpf->setWindowLength(2 * 3600); $mpf->setIncludeLunchPunchTime(FALSE); break; case 110: //Normal 1hr lunch: Detect by Punch Time $mpf->setName('Normal - Punch Time'); $mpf->setType(20); $mpf->setTriggerTime(3600 * 6); $mpf->setAmount(3600); $mpf->setAutoDetectType(20); $mpf->setMinimumPunchTime(60 * 30); ///0.5hr $mpf->setMaximumPunchTime(60 * 75); //1.25hr $mpf->setIncludeLunchPunchTime(FALSE); break; } if ($mpf->isValid()) { $insert_id = $mpf->Save(); Debug::Text('Meal Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); return $insert_id; } Debug::Text('Failed Creating Meal Policy!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
$data['minimum_punch_time'] = TTDate::parseTimeUnit($data['minimum_punch_time']); $data['maximum_punch_time'] = TTDate::parseTimeUnit($data['maximum_punch_time']); } $mpf = new MealPolicyFactory(); $action = Misc::findSubmitButton(); $action = strtolower($action); switch ($action) { case 'submit': Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); $mpf->setId($data['id']); $mpf->setCompany($current_company->getId()); $mpf->setName($data['name']); $mpf->setType($data['type_id']); $mpf->setTriggerTime($data['trigger_time']); $mpf->setAmount($data['amount']); $mpf->setAutoDetectType($data['auto_detect_type_id']); $mpf->setStartWindow($data['start_window']); $mpf->setWindowLength($data['window_length']); $mpf->setMinimumPunchTime($data['minimum_punch_time']); $mpf->setMaximumPunchTime($data['maximum_punch_time']); if (isset($data['include_lunch_punch_time'])) { $mpf->setIncludeLunchPunchTime(TRUE); } else { $mpf->setIncludeLunchPunchTime(FALSE); } if ($mpf->isValid()) { $mpf->Save(); Redirect::Page(URLBuilder::getURL(NULL, 'MealPolicyList.php')); break; } default: