$user_default_branch = NULL;
     $user_default_department = NULL;
     $pay_period_is_locked = FALSE;
     $time_stamp = $start_date_stamp = $end_date_stamp = TTDate::getBeginDayEpoch(TTDate::getTime()) + 3600 * 12;
     //Noon
     $data = array('start_date_stamp' => $start_date_stamp, 'end_date_stamp' => $end_date_stamp, 'start_time' => strtotime('08:00 AM'), 'parsed_start_time' => strtotime('08:00 AM'), 'end_time' => strtotime('05:00 PM'), 'parsed_end_time' => strtotime('05:00 PM'), 'total_time' => 3600 * 9, 'branch_id' => $user_default_branch, 'department_id' => $user_default_department, 'dow' => array(1 => TRUE, 2 => TRUE, 3 => TRUE, 4 => TRUE, 5 => TRUE));
 }
 //var_dump($data);
 $ulf = new UserListFactory();
 $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
 $src_user_options = UserListFactory::getArrayByListFactory($ulf, FALSE, FALSE);
 $user_options = Misc::arrayDiffByKey((array) $filter_user_id, $src_user_options);
 $filter_user_options = Misc::arrayIntersectByKey((array) $filter_user_id, $src_user_options);
 $prepend_array_option = array(0 => '--', -1 => TTi18n::gettext('-- Default --'));
 $splf = new SchedulePolicyListFactory();
 $schedule_policy_options = $splf->getByCompanyIdArray($current_company->getId());
 $aplf = new AbsencePolicyListFactory();
 $absence_policy_options = $aplf->getByCompanyIdArray($current_company->getId());
 $blf = new BranchListFactory();
 $blf->getByCompanyId($current_company->getId());
 $branch_options = Misc::prependArray($prepend_array_option, $blf->getArrayByListFactory($blf, FALSE, TRUE));
 $dlf = new DepartmentListFactory();
 $dlf->getByCompanyId($current_company->getId());
 $department_options = Misc::prependArray($prepend_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE));
 if ($current_company->getProductEdition() == 20) {
     $jlf = new JobListFactory();
     $jlf->getByStatusIdAndCompanyId(array(10, 20, 30, 40), $current_company->getId());
     //$jlf->getByCompanyIdAndUserIdAndStatus( $current_company->getId(),  $data['user_id'], array(10,20,30,40) );
     $data['job_options'] = $jlf->getArrayByListFactory($jlf, TRUE, TRUE);
     $data['job_manual_id_options'] = $jlf->getManualIDArrayByListFactory($jlf, TRUE);
     $jilf = new JobItemListFactory();
                 $rstf->preSave();
                 $week_rows[$week_row_id]['total_time'] = $rstf->getTotalTime();
                 if ($week_row_id == $lowest_id) {
                     $next_total_time = $week_rows[$week_row_id]['total_time'];
                 }
             }
         }
     }
     $week_rows[$next_blank_id] = array('id' => $next_blank_id, 'week' => $last_week + 1, 'start_time' => $week_rows[$lowest_id]['start_time'], 'end_time' => $week_rows[$lowest_id]['end_time'], 'total_time' => $next_total_time, 'schedule_policy_id' => $week_rows[$lowest_id]['schedule_policy_id'], 'branch_id' => $week_rows[$lowest_id]['branch_id'], 'department_id' => $week_rows[$lowest_id]['department_id'], 'mon' => @$week_rows[$lowest_id]['mon'], 'tue' => @$week_rows[$lowest_id]['tue'], 'wed' => @$week_rows[$lowest_id]['wed'], 'thu' => @$week_rows[$lowest_id]['thu'], 'fri' => @$week_rows[$lowest_id]['fri'], 'sat' => @$week_rows[$lowest_id]['sat'], 'sun' => @$week_rows[$lowest_id]['sun']);
 } elseif ($action != 'submit' and $action != 'delete') {
     $week_rows[-1] = array('id' => -1, 'week' => 1, 'mon' => TRUE, 'tue' => TRUE, 'wed' => TRUE, 'thu' => TRUE, 'fri' => TRUE, 'start_time' => strtotime('08:00'), 'end_time' => strtotime('17:00'), 'total_time' => 9 * 3600, 'branch_id' => -1, 'department_id' => -1, 'schedule_policy_id' => 0);
 }
 $prepend_array_option = array(0 => '--', -1 => TTi18n::gettext('-- Default --'));
 //Select box options;
 $splf = new SchedulePolicyListFactory();
 $data['schedule_options'] = $splf->getByCompanyIdArray($current_company->getId());
 $blf = new BranchListFactory();
 $blf->getByCompanyId($current_company->getId());
 $data['branch_options'] = Misc::prependArray($prepend_array_option, $blf->getArrayByListFactory($blf, FALSE, TRUE));
 //$data['branch_options']  = Misc::prependArray( array( -1 => '-- Default --' ), $blf->getByCompanyIdArray( $current_company->getId(), FALSE, FALSE ) );
 $dlf = new DepartmentListFactory();
 $dlf->getByCompanyId($current_company->getId());
 $data['department_options'] = Misc::prependArray($prepend_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE));
 //$data['department_options'] = $dlf->getByCompanyIdArray( $current_company->getId() );
 if ($current_company->getProductEdition() == 20) {
     $jlf = new JobListFactory();
     $data['job_options'] = $jlf->getByCompanyIdAndStatusArray($current_company->getId(), array(10, 20, 30, 40), TRUE);
     $jilf = new JobItemListFactory();
     $data['job_item_options'] = $jilf->getByCompanyIdArray($current_company->getId(), TRUE);
 }
 //var_dump($week_rows);