/**
  * view Holiday list
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     //Keep Menu in Leave/Config
     $request->setParameter('initialActionName', 'viewHolidayList');
     $this->searchForm = $this->getSearchForm();
     $dateRange = $this->getLeavePeriodService()->getCalenderYearByDate(time());
     $startDate = $dateRange[0];
     $endDate = $dateRange[1];
     if ($request->isMethod('post')) {
         $this->searchForm->bind($request->getParameter($this->searchForm->getName()));
         if ($this->searchForm->isValid()) {
             $values = $this->searchForm->getValues();
             $startDate = $values['calFromDate'];
             $endDate = $values['calToDate'];
         }
     }
     $this->daysLenthList = WorkWeek::getDaysLengthList();
     $this->yesNoList = WorkWeek::getYesNoList();
     $this->holidayList = $this->getHolidayService()->searchHolidays($startDate, $endDate);
     $this->setListComponent($this->holidayList);
     $message = $this->getUser()->getFlash('templateMessage');
     $this->messageType = isset($message[0]) ? strtolower($message[0]) : "";
     $this->message = isset($message[1]) ? $message[1] : "";
     if ($this->getUser()->hasFlash('templateMessage')) {
         $this->templateMessage = $this->getUser()->getFlash('templateMessage');
         $this->getUser()->setFlash('templateMessage', array());
     }
 }
Exemplo n.º 2
0
 /**
  * Get required days Length List ignore "Weekend"
  */
 public function getDaysLengthList()
 {
     $fullDaysLengthList = WorkWeek::getDaysLengthList();
     unset($fullDaysLengthList[8]);
     return $fullDaysLengthList;
 }
 /**
  * view Holiday list
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->searchForm = $this->getSearchForm();
     $leavePeriodService = $this->getLeavePeriodService();
     //retrieve current leave period id
     $leavePeriodId = !$leavePeriodService->getCurrentLeavePeriod() instanceof LeavePeriod ? 0 : $leavePeriodService->getCurrentLeavePeriod()->getLeavePeriodId();
     $startDate = date("Y-m-d");
     $endDate = date("Y-m-d");
     if ($leavePeriodService->getCurrentLeavePeriod() instanceof LeavePeriod) {
         $startDate = $leavePeriodService->getCurrentLeavePeriod()->getStartDate();
         $endDate = $leavePeriodService->getCurrentLeavePeriod()->getEndDate();
     }
     if ($request->isMethod('post')) {
         $this->searchForm->bind($request->getParameter($this->searchForm->getName()));
         if ($this->searchForm->isValid()) {
             $leavePeriodId = $this->searchForm->getValue('leave_period');
             $leavePeriod = $leavePeriodService->readLeavePeriod($leavePeriodId);
             if ($leavePeriod instanceof LeavePeriod) {
                 $startDate = $leavePeriod->getStartDate();
                 $endDate = $leavePeriod->getEndDate();
             }
         }
     }
     $this->leavePeriodId = $leavePeriodId;
     $this->daysLenthList = WorkWeek::getDaysLengthList();
     $this->yesNoList = WorkWeek::getYesNoList();
     $this->holidayList = $this->getHolidayService()->searchHolidays($startDate, $endDate);
     $this->setListComponent($this->holidayList);
     $message = $this->getUser()->getFlash('templateMessage');
     $this->messageType = isset($message[0]) ? strtolower($message[0]) : "";
     $this->message = isset($message[1]) ? $message[1] : "";
     if ($this->getUser()->hasFlash('templateMessage')) {
         $this->templateMessage = $this->getUser()->getFlash('templateMessage');
         $this->getUser()->setFlash('templateMessage', array());
     }
 }
Exemplo n.º 4
0
 protected final function getDayLengthValidators()
 {
     $formValidators = array();
     $daysOfWeek = WorkWeek::getDaysList();
     $choices = array_keys(WorkWeek::getDaysLengthList());
     foreach ($daysOfWeek as $day) {
         $validator = new sfValidatorChoice(array('choices' => $choices), array('invalid' => 'Invalid work week for ' . $day, 'required' => 'Value for ' . $day . ' is required'));
         $formValidators['day_length_' . $day] = $validator;
     }
     return $formValidators;
 }