}
            $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);
        $smarty->assign_by_ref('data', $data);
        $smarty->assign_by_ref('week_rows', $week_rows);
        break;
}
$smarty->assign_by_ref('rstcf', $rstcf);
$smarty->assign_by_ref('rstf', $rstf);
$smarty->display('schedule/EditRecurringScheduleTemplate.tpl');