예제 #1
0
 public function view()
 {
     $dateFrom = $this->post('dateFrom');
     $dateTo = $this->post('dateTo');
     if (!$dateFrom) {
         $dateFrom = OrderList::getDateOfFirstOrder();
     }
     if (!$dateTo) {
         $dateTo = date('Y-m-d');
     }
     $pr = new ProductReport($dateFrom, $dateTo);
     $orderBy = $this->post('orderBy');
     if (!$orderBy) {
         $orderBy = 'quantity';
     }
     if ($orderBy == 'quantity') {
         $pr->sortByPopularity();
     } else {
         $pr->sortByTotal();
     }
     //$products = $pr->getProducts();
     $this->set('dateFrom', $dateFrom);
     $this->set('dateTo', $dateTo);
     $pr->setItemsPerPage(10);
     $paginator = $pr->getPagination();
     $pagination = $paginator->renderDefaultView();
     $this->set('products', $paginator->getCurrentPageResults());
     $this->set('pagination', $pagination);
     $this->set('paginator', $paginator);
 }
예제 #2
0
 public function setOrderItemsByRange($from = null, $to = null)
 {
     if (!isset($from)) {
         $from = OrderList::getDateOfFirstOrder();
     }
     if (!$to) {
         $to = date('Y-m-d');
     }
     $orders = new OrderList();
     $orders->setFromDate($from);
     $orders->setToDate($to);
     $this->orderItems = $orders->getOrderItems();
 }