switch ($action) {
    case 'add':
        //Redirect::Page( URLBuilder::getURL(array('user_id' => $user_id), 'EditUserWage.php', FALSE) );
        break;
    case 'delete' or 'undelete':
        if (strtolower($action) == 'delete') {
            $delete = TRUE;
        } else {
            $delete = FALSE;
        }
        $udtlf = new UserDateTotalListFactory();
        if (is_array($ids)) {
            $id_count = count($ids) - 1;
            $i = 0;
            foreach ($ids as $tmp_id) {
                $udtlf->getById($tmp_id);
                foreach ($udtlf as $udt_obj) {
                    $udt_obj->setDeleted($delete);
                    if ($id_count == $i) {
                        $udt_obj->setEnableCalcSystemTotalTime(TRUE);
                    }
                    $udt_obj->Save();
                }
                $i++;
            }
        }
        Redirect::Page(URLBuilder::getURL(array('user_id' => $user_id, 'filter_date' => $filter_date), 'UserDateTotalList.php'));
        break;
    default:
        if ((!isset($user_date_id) or isset($user_date_id) and $user_date_id == '') and $user_id != '' and $filter_date != '') {
            Debug::Text('User Date ID not passed, inserting one.', __FILE__, __LINE__, __METHOD__, 10);
     } else {
         $udtf->setOverride(FALSE);
     }
     if ($udtf->isValid()) {
         $udtf->setEnableCalcSystemTotalTime(TRUE);
         $udtf->setEnableCalcWeeklySystemTotalTime(TRUE);
         $udtf->setEnableCalcException(TRUE);
         $udtf->Save();
         Redirect::Page(URLBuilder::getURL(array('refresh' => TRUE), '../CloseWindow.php'));
         break;
     }
 default:
     if ($id != '') {
         Debug::Text(' ID was passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
         $udtlf = new UserDateTotalListFactory();
         $udtlf->getById($id);
         foreach ($udtlf as $udt_obj) {
             //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
             $udt_data = array('id' => $udt_obj->getId(), 'user_date_id' => $udt_obj->getUserDateId(), 'date_stamp' => $udt_obj->getUserDateObject()->getDateStamp(), 'user_id' => $udt_obj->getUserDateObject()->getUser(), 'user_full_name' => $udt_obj->getUserDateObject()->getUserObject()->getFullName(), 'status_id' => $udt_obj->getStatus(), 'type_id' => $udt_obj->getType(), 'total_time' => $udt_obj->getTotalTime(), 'branch_id' => $udt_obj->getBranch(), 'department_id' => $udt_obj->getDepartment(), 'job_id' => $udt_obj->getJob(), 'job_item_id' => $udt_obj->getJobItem(), 'quantity' => $udt_obj->getQuantity(), 'bad_quantity' => $udt_obj->getBadQuantity(), 'punch_control_id' => $udt_obj->getPunchControlID(), 'absence_policy_id' => $udt_obj->getAbsencePolicyID(), 'over_time_policy_id' => $udt_obj->getOverTimePolicyID(), 'premium_policy_id' => $udt_obj->getPremiumPolicyID(), 'meal_policy_id' => $udt_obj->getMealPolicyID(), 'override' => $udt_obj->getOverride(), 'created_date' => $udt_obj->getCreatedDate(), 'created_by' => $udt_obj->getCreatedBy(), 'updated_date' => $udt_obj->getUpdatedDate(), 'updated_by' => $udt_obj->getUpdatedBy(), 'deleted_date' => $udt_obj->getDeletedDate(), 'deleted_by' => $udt_obj->getDeletedBy(), 'override' => $udt_obj->getOverride());
         }
     } elseif ($action != 'submit') {
         Debug::Text(' ID was NOT passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
         //UserID has to be set at minimum
         if ($user_date_id != '') {
             $udlf = new UserDateListFactory();
             $udlf->getById($user_date_id);
             if ($udlf->getRecordCount() > 0) {
                 $udt_obj = $udlf->getCurrent();
                 $udt_data = array('user_date_id' => $user_date_id, 'date_stamp' => $udt_obj->getDateStamp(), 'user_id' => $udt_obj->getUser(), 'user_full_name' => $udt_obj->getUserObject()->getFullName(), 'branch_id' => $udt_obj->getUserObject()->getDefaultBranch(), 'department_id' => $udt_obj->getUserObject()->getDefaultDepartment(), 'total_time' => 0, 'status_id' => 20, 'quantity' => 0, 'bad_quantity' => 0, 'punch_control_id' => 0, 'override' => FALSE);
             }
         }