Ejemplo n.º 1
0
 function createRoundingPolicy($company_id, $type)
 {
     $ripf = new RoundIntervalPolicyFactory();
     $ripf->setCompany($company_id);
     switch ($type) {
         case 10:
             //In
             $ripf->setName('5min');
             $ripf->setPunchType(40);
             //In
             $ripf->setRoundType(30);
             //Up
             $ripf->setInterval(60 * 5);
             //5mins
             $ripf->setGrace(60 * 3);
             //3min
             $ripf->setStrict(FALSE);
             break;
         case 20:
             //Out
             $ripf->setName('5min');
             $ripf->setPunchType(50);
             //In
             $ripf->setRoundType(10);
             //Down
             $ripf->setInterval(60 * 5);
             //5mins
             $ripf->setGrace(60 * 3);
             //3min
             $ripf->setStrict(FALSE);
             break;
         case 30:
             //Day total
             $ripf->setName('15min');
             $ripf->setPunchType(120);
             //In
             $ripf->setRoundType(10);
             //Down
             $ripf->setInterval(60 * 15);
             //15mins
             $ripf->setGrace(60 * 3);
             //3min
             $ripf->setStrict(FALSE);
             break;
         case 40:
             //Lunch total
             $ripf->setName('15min');
             $ripf->setPunchType(100);
             //In
             $ripf->setRoundType(10);
             //Down
             $ripf->setInterval(60 * 15);
             //15mins
             $ripf->setGrace(60 * 3);
             //3min
             $ripf->setStrict(FALSE);
             break;
         case 50:
             //Break total
             $ripf->setName('15min');
             $ripf->setPunchType(110);
             //In
             $ripf->setRoundType(10);
             //Down
             $ripf->setInterval(60 * 15);
             //15mins
             $ripf->setGrace(60 * 3);
             //3min
             $ripf->setStrict(FALSE);
             break;
     }
     if ($ripf->isValid()) {
         $insert_id = $ripf->Save();
         Debug::Text('Rounding Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         return $insert_id;
     }
     Debug::Text('Failed Creating Rounding Policy!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
 */
extract(FormVariables::GetVariables(array('action', 'id', 'data')));
if (isset($data['interval'])) {
    $data['interval'] = TTDate::parseTimeUnit($data['interval']);
    $data['grace'] = TTDate::parseTimeUnit($data['grace']);
}
$ripf = new RoundIntervalPolicyFactory();
$action = Misc::findSubmitButton();
$action = strtolower($action);
switch ($action) {
    case 'submit':
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $ripf->setId($data['id']);
        $ripf->setCompany($current_company->getId());
        $ripf->setName($data['name']);
        $ripf->setPunchType($data['punch_type_id']);
        $ripf->setRoundType($data['round_type_id']);
        $ripf->setInterval($data['interval']);
        $ripf->setGrace($data['grace']);
        if (isset($data['strict'])) {
            $ripf->setStrict(TRUE);
        } else {
            $ripf->setStrict(FALSE);
        }
        if ($ripf->isValid()) {
            $ripf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'RoundIntervalPolicyList.php'));
            break;
        }
    default:
        if (isset($id)) {