Esempio n. 1
0
 /**
  * Get timestamp of current day start
  *
  * @return integer
  */
 protected function getTodayStartTime()
 {
     return \XLite\Core\Converter::getDayStart();
 }
Esempio n. 2
0
 /**
  * getDateRange
  *
  * :FIXME: simplify
  *
  * @return \XLite\Core\CommonCell
  */
 protected function getDateRange()
 {
     $result = null;
     $paramDatePeriod = self::SEARCH_DATE_PERIOD;
     if (isset($this->currentSearchCnd->{$paramDatePeriod})) {
         $datePeriod = $this->currentSearchCnd->{$paramDatePeriod};
         $startDate = null;
         $endDate = \XLite\Core\Converter::time();
         if ('M' === $datePeriod) {
             $startDate = mktime(0, 0, 0, date('n', $endDate), 1, date('Y', $endDate));
         } elseif ('W' === $datePeriod) {
             $startDate = \XLite\Core\Converter::getDayStart($endDate - date('w', $endDate) * 86400);
         } elseif ('D' === $datePeriod) {
             $startDate = \XLite\Core\Converter::getDayStart($endDate);
         } elseif ('C' === $datePeriod) {
             $paramStartDate = static::SEARCH_START_DATE;
             $paramEndDate = static::SEARCH_END_DATE;
             $paramDateRange = static::SEARCH_DATE_RANGE;
             if (!empty($this->currentSearchCnd->{$paramStartDate}) && !empty($this->currentSearchCnd->{$paramEndDate})) {
                 $tmpDate = strtotime($this->currentSearchCnd->{$paramStartDate});
                 if (false !== $tmpDate) {
                     $startDate = \XLite\Core\Converter::getDayStart($tmpDate);
                 }
                 $tmpDate = strtotime($this->currentSearchCnd->{$paramEndDate});
                 if (false !== $tmpDate) {
                     $endDate = \XLite\Core\Converter::getDayEnd($tmpDate);
                 }
             } elseif (!empty($this->currentSearchCnd->{$paramDateRange})) {
                 list($startDate, $endDate) = \XLite\View\FormField\Input\Text\DateRange::convertToArray($this->currentSearchCnd->{$paramDateRange});
             }
         }
         if (null !== $startDate && false !== $startDate && false !== $endDate) {
             $result = new \XLite\Core\CommonCell();
             $result->startDate = $startDate;
             $result->endDate = $endDate;
         }
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Return params list to use for search
  *
  * @param \XLite\Core\CommonCell $cnd Initial search conditions
  *
  * @return \XLite\Core\CommonCell
  */
 protected function getSearchConditions(\XLite\Core\CommonCell $cnd)
 {
     $currentDate = static::getUserTime();
     $daysOffset = abs(intval(\XLite\Core\Config::getInstance()->CDev->ProductAdvisor->na_max_days)) ?: \XLite\Module\CDev\ProductAdvisor\Main::PA_MODULE_OPTION_DEFAULT_DAYS_OFFSET;
     $startDate = \XLite\Core\Converter::getDayStart($currentDate - $daysOffset * 24 * 60 * 60);
     $endDate = \XLite\Core\Converter::getDayEnd($currentDate);
     $cnd->{\XLite\Module\CDev\ProductAdvisor\Model\Repo\Product::P_ARRIVAL_DATE} = array($startDate, $endDate);
     $cnd->{\XLite\Model\Repo\Product::P_ORDER_BY} = array('p.arrivalDate', 'DESC');
     return $cnd;
 }