function createMealPolicy($company_id)
 {
     $mpf = new MealPolicyFactory();
     $mpf->setCompany($company_id);
     $mpf->setName('One Hour Min.');
     $mpf->setType(20);
     $mpf->setTriggerTime(3600 * 5);
     $mpf->setAmount(3600);
     $mpf->setStartWindow(3600 * 4);
     $mpf->setWindowLength(3600 * 2);
     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;
 }
 function createMealPolicy($company_id, $type)
 {
     $mpf = new MealPolicyFactory();
     $mpf->setCompany($company_id);
     switch ($type) {
         case 100:
             //Normal 1hr lunch
             $mpf->setName('Normal');
             $mpf->setType(20);
             $mpf->setTriggerTime(3600 * 6);
             $mpf->setAmount(3600);
             $mpf->setIncludeLunchPunchTime(FALSE);
             break;
         case 110:
             //AutoAdd 1hr
             $mpf->setName('AutoAdd 1hr');
             $mpf->setType(15);
             $mpf->setTriggerTime(3600 * 6);
             $mpf->setAmount(3600);
             $mpf->setIncludeLunchPunchTime(FALSE);
             break;
         case 115:
             //AutoAdd 1hr
             $mpf->setName('AutoAdd 1hr');
             $mpf->setType(15);
             $mpf->setTriggerTime(3600 * 6);
             $mpf->setAmount(3600);
             $mpf->setIncludeLunchPunchTime(TRUE);
             break;
         case 120:
             //AutoDeduct 1hr
             $mpf->setName('AutoDeduct 1hr');
             $mpf->setType(10);
             $mpf->setTriggerTime(3600 * 6);
             $mpf->setAmount(3600);
             $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;
 }
 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['trigger_time'] = TTDate::parseTimeUnit($data['trigger_time']);
    $data['amount'] = TTDate::parseTimeUnit($data['amount']);
    $data['start_window'] = TTDate::parseTimeUnit($data['start_window']);
    $data['window_length'] = TTDate::parseTimeUnit($data['window_length']);
    $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();