示例#1
0
 function run()
 {
     //get date value from url through get method
     $date = CRM_Utils_Request::retrieve('date', 'Positive', $this, FALSE, 0);
     //convert javascript.getTime() to PHP date format
     $date = date('m/d/Y', round($date / 1000));
     //get resources information by selected date
     $from = CRM_Utils_Date::processDate($date);
     $resources = CRM_Booking_BAO_Slot::getSlotDetailsOrderByResourceBetweenDate($from, $from);
     $values = array();
     //put resources result to values, being ready to display.
     $values['resources'] = $resources;
     //Convert date to compile with crmDate
     $values['dayview_select_date'] = DateTime::createFromFormat('m/d/Y', $date)->format('Y-m-d');
     //assign variables for use in a template
     $this->assign($values);
     // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
     CRM_Utils_System::setTitle(ts('DayViewPrint'));
     parent::run();
 }
示例#2
0
 function postProcess()
 {
     $values = $this->exportValues();
     $selectedDate = CRM_Utils_Array::value('dayview_select_date', $values);
     //get booking slots from selected date
     $from = CRM_Utils_Date::processDate($selectedDate);
     $resources = CRM_Booking_BAO_Slot::getSlotDetailsOrderByResourceBetweenDate($from, $from);
     //put resources result to values, being ready to display.
     $values['resources'] = $resources;
     if (empty($resources)) {
         //check empty result
         //Convert date to show on no match found view
         $values['dayview_select_date'] = DateTime::createFromFormat('m/d/Y', $selectedDate)->format('d/m/Y');
     } else {
         //Convert date to compile with crmDate
         $values['dayview_select_date'] = DateTime::createFromFormat('m/d/Y', $selectedDate)->format('Y-m-d');
     }
     //assign values to show on template
     $this->assign($values);
     //parent::postProcess();
 }