Ejemplo n.º 1
0
 public function dispShopMyOrders(){
     $logged_user = Context::get('logged_info');
     if(!isset($logged_user)){
         $this->setTemplateFile('not_logged.html');
         return;
     }
     $orderRepository = $this->model->getOrderRepository();
     $extraParams['order_type'] = 'desc';
     $output = $orderRepository->getList($this->module_info->module_srl,$logged_user->member_srl, $extraParams, Context::get('page'));
     Context::set('orders',$output->data);
     Context::set('page_navigation',$output->page_navigation);
     $this->setTemplateFile('my_orders.html');
 }
Ejemplo n.º 2
0
        /**
         * insert shipment
         * @return Object
         * @throws ShopException
         */
        public function procShopToolInsertShipment(){
            $order_srl = Context::get('order_srl');
            $orderRepository = $this->model->getOrderRepository();
            $shipmentRepository = $this->model->getShipmentRepository();
            $order = $orderRepository->getOrderBySrl($order_srl);
            $args = Context::getRequestVars();
            $args->order_srl = $order_srl;
            $args->module_srl = $order->module_srl;
            $shipment = new Shipment($args);
            $shipment->order = $order;
            if(!isset($shipment->shipment_srl)) $insert = TRUE;
            try{
                if($insert) {
                    $productsEmptyStocks = $shipment->checkAndUpdateStocks();
                    $product_srls = array();
                    foreach($productsEmptyStocks as $product){
                        $products_srls[] = $product->product_srl;
                    }
                    $products_srls = implode(', ',$product_srls);
                }
                $shipment->save();
            }
            catch(Exception $e) {
                return new Object(-1, $e->getMessage());
            }
            if($shipment->shipment_srl){
                if(isset($order->invoice)) $order->order_status = Order::ORDER_STATUS_COMPLETED;
                else $order->order_status = Order::ORDER_STATUS_PROCESSING;
                try{
                    $order->save();
                }
                catch(Exception $e) {
                    return new Object(-1, $e->getMessage());
                }
                if($insert){
                    $this->setMessage("Shipment has been created. " . (isset($products_srls) ? "Stock empty for products: $products_srls":''));
                    $return_url = getNotEncodedUrl('', 'act','dispShopToolViewOrder','order_srl',$order_srl);
                    $this->setRedirectUrl($return_url);
                } else {
                    $this->setMessage("Shipment has been updated");
                    $return_url = getNotEncodedUrl('', 'act','dispShopToolManageShipments','order_srl',$order_srl);
                    $this->setRedirectUrl($return_url);
                }

            } else {
                throw new ShopException('Something whent wrong when adding shipment');
            }
        }