Beispiel #1
0
 public function extractDateFormat($carrierRate, $locale)
 {
     $interim = isset($carrierRate->deliveryDateFormat) ? $carrierRate->deliveryDateFormat : self::DEFAULT_DATE_FORMAT;
     $dateFormat = $this->dateHelper->getCldrDateFormat($locale, $interim);
     return $dateFormat;
 }
 public function getCalendarDetailsArray($calendarDetails, $carrierGroupDetail, $carrierId, $carrierCode, $locale, $deliveryDateFormat, $defaultDate)
 {
     $calendarDetails['dateFormat'] = \ShipperHQ\Lib\Helper\Date::getDateFormat($locale);
     $calendarDetails['datepickerFormat'] = \ShipperHQ\Lib\Helper\Date::getDatepickerFormat($locale);
     $calendarDetails['displayDateFormat'] = \ShipperHQ\Lib\Helper\Date::getCldrDateFormat($locale, $deliveryDateFormat);
     $calendarDetails['timezone'] = $carrierGroupDetail['timezone'];
     if ($calendarDetails['startDate'] != '') {
         $calendarDetails['start'] = $calendarDetails['startDate'] / 1000;
     } else {
         $calendarDetails['start'] = $defaultDate;
     }
     $calendarDetails['carrier_id'] = $carrierId;
     $calendarDetails['carrier_code'] = $carrierCode;
     $dateOptions = $this->getDateOptions($calendarDetails);
     if (count($dateOptions) > 0) {
         $deliveryDatesAndTimes = array();
         if (isset($calendarDetails['timeSlots']) && !empty($calendarDetails['timeSlots'])) {
             foreach ($dateOptions as $dateKey => $date) {
                 //TODO account for selected date
                 //                    if(array_key_exists('date_selected', $resultSet) && $resultSet['date_selected'] != '') {
                 //                        if ($dateKey != $resultSet['date_selected']) continue;
                 //
                 //                    }
                 if ($slotsFound = $this->getDeliveryTimeSlots($calendarDetails, $dateKey)) {
                     $deliveryDatesAndTimes[$dateKey] = $slotsFound;
                     // break;
                 } else {
                     unset($dateOptions[$dateKey]);
                 }
             }
         }
         if (count($dateOptions) <= 0) {
             //TODO properly handle if no date options found
             $dateOptions = [];
         }
         if (count($deliveryDatesAndTimes) > 0) {
             $calendarDetails['display_time_slots'] = $deliveryDatesAndTimes;
             $calendarDetails['showTimeslots'] = true;
         } else {
             $calendarDetails['display_time_slots'] = false;
             $calendarDetails['showTimeslots'] = false;
         }
     }
     $calendarDetails['allowed_dates'] = $dateOptions;
     $keys = array_keys($dateOptions);
     $calendarDetails['min_date'] = $keys[0];
     $calendarDetails['max_date'] = end($keys);
     return $calendarDetails;
 }