Пример #1
0
 public function ajaxAction()
 {
     $ajax = new AjaxLibrary();
     $ajax->init($this->getRequest());
     switch ($ajax->getPost('process')) {
         case 'getOrderProducts':
             $orderID = $ajax->getPost('id');
             $orderID = (int) str_replace('order-', '', $orderID);
             $serviceLocator = $this->getServiceLocator();
             $productsModel = new ProductsModel($serviceLocator);
             $products = $productsModel->getProductsByOrder($orderID);
             $stations = new PickingStationsLibrary($serviceLocator);
             $orderPickingStation = $stations->getOrderPickingStation($orderID);
             echo json_encode(array('products' => $products, 'orderPickingStation' => $orderPickingStation));
             exit;
             break;
             // getOrderProducts
         // getOrderProducts
         case 'setPickingStation':
             $stationID = (int) $ajax->getPost('id');
             $stations = new PickingStationsLibrary($this->getServiceLocator());
             $newStation = $stations->getPickingStationByID($stationID);
             if ($newStation !== false) {
                 echo json_encode($newStation);
             } else {
                 $ajax->bye();
             }
             exit;
             break;
             // setPickingStation
         // setPickingStation
         default:
             $ajax->bye();
             break;
             // default
     }
     // switch
     $ajax->bye();
 }
Пример #2
0
 /**
  * Resolves all the AJAX calls from the products page 
  *
  * @return string
  * 
  */
 public function ajaxAction()
 {
     $ajax = new AjaxLibrary();
     $ajax->init($this->getRequest());
     switch ($ajax->getPost('process')) {
         case 'getProduct':
             $productID = (int) $ajax->getPost('id');
             $productsModel = new ProductsModel($this->getServiceLocator());
             $product = $productsModel->getProductByID($productID);
             echo json_encode($product);
             exit;
             break;
             // getOrderProducts
         // getOrderProducts
         case 'setPickingStation':
             $stationID = (int) $ajax->getPost('id');
             $stations = new PickingStationsLibrary($this->getServiceLocator());
             $newStation = $stations->getPickingStationByID($stationID);
             if ($newStation !== false) {
                 echo json_encode($newStation);
             } else {
                 $ajax->bye();
             }
             exit;
             break;
             // setPickingStation
         // setPickingStation
         default:
             $ajax->bye();
             break;
             // default
     }
     // switch
     $ajax->bye();
 }