Ejemplo n.º 1
0
 /**
  * Display default page
  *
  * @return     void
  */
 public function homeTask()
 {
     // Incoming
     $this->view->filters = array('limit' => Request::getInt('limit', Config::get('list_limit')), 'start' => Request::getInt('limitstart', 0));
     $cart = new CurrentCart();
     // Get all completed transactions count
     $this->view->total = $cart->getTransactions(array('count' => true));
     // Get all completed transactions
     $transactions = $cart->getTransactions($this->view->filters);
     // Get transactions' info
     if ($transactions) {
         foreach ($transactions as $transaction) {
             $transactionInfo = Cart::getTransactionInfo($transaction->tId);
             // Figure out if the items int the transactions are still avaialble
             $tItems = unserialize($transactionInfo->tiItems);
             foreach ($tItems as $item) {
                 // Check if the product is still available
                 $warehouse = new Warehouse();
                 $skuInfo = $warehouse->getSkuInfo($item['info']->sId, false);
                 $item['info']->available = true;
                 if (!$skuInfo) {
                     // product no longer available
                     $item['info']->available = false;
                 }
             }
             $transactionInfo->tiItems = $tItems;
             $transaction->tInfo = $transactionInfo;
         }
     }
     $this->view->transactions = $transactions;
     if (Pathway::count() <= 0) {
         Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option);
         Pathway::append(Lang::txt('COM_CART_ORDERS'), 'index.php?option=' . $this->_option);
     }
     //print_r($transactions); die;
     $this->view->display();
 }
Ejemplo n.º 2
0
 /**
  * Gets all transaction related info about current cart transaction
  *
  * @param void
  * @return object, false on no results
  */
 public function getTransactionData()
 {
     // If session expired tId will not be saved
     if (empty($this->cart->tId)) {
         // Try to find if there is a pending transaction for this cart in DB and use it
         $sql = "SELECT `tId` FROM `#__cart_transactions` WHERE `crtId` = {$this->cart->crtId} AND `tStatus` = 'pending'";
         $this->_db->setQuery($sql);
         $tId = $this->_db->loadResult();
     } else {
         $tId = $this->cart->tId;
     }
     if (!$tId) {
         return false;
     }
     // Get info
     $transactionInfo = parent::getTransactionInfo($tId);
     if (!$transactionInfo) {
         return false;
     }
     // Set transaction id session value (needed for expired session)
     $this->cart->tId = $transactionInfo->tId;
     // Get steps
     $steps = $this->getCheckoutSteps();
     $transactionInfo->steps = $steps;
     return $transactionInfo;
 }
Ejemplo n.º 3
0
 /**
  * Download CSV report (default)
  *
  * @return     void
  */
 public function downloadOrdersTask()
 {
     // Get filters
     $filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'dDownloaded'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'));
     //print_r($filters); die;
     // Get orders, request array to be returned
     $orders = CartOrders::getItemsOrdered('list', $filters);
     foreach ($orders as $order) {
         $orderItems = unserialize(Cart::getTransactionInfo($order->tId)->tiItems);
         $order->itemInfo = $orderItems[$order->sId];
     }
     $rowsRaw = $orders;
     $date = date('d-m-Y');
     $rows = array();
     foreach ($rowsRaw as $row) {
         $itemInfo = $row->itemInfo['info'];
         $rows[] = array($row->sId, $itemInfo->pName . ', ' . $itemInfo->sSku, $row->tiQty, $row->tiPrice, $row->tId, $row->tLastUpdated, $row->Name, $row->uidNumber);
     }
     header("Content-Type: text/csv");
     header("Content-Disposition: attachment; filename=cart-items-ordered" . $date . ".csv");
     // Disable caching
     header("Cache-Control: no-cache, no-store, must-revalidate");
     // HTTP 1.1
     header("Pragma: no-cache");
     // HTTP 1.0
     header("Expires: 0");
     // Proxies
     $output = fopen("php://output", "w");
     $row = array('SKU ID', 'Product', 'QTY', 'Price', 'Order ID', 'Order Placed', 'Purchased By', 'Purchased By (userId)');
     fputcsv($output, $row);
     foreach ($rows as $row) {
         fputcsv($output, $row);
     }
     fclose($output);
     die;
 }