src/Flowcode/ShopBundle/Controller/AdminProductController.php
/**
     * Finds and displays a Product entity.
     *
     * @Route("/{id}/stock_increase", name="admin_product_stock_do_increase", requirements={"id"="\d+"})
     * @Method("POST")
     * @Template()
     */
Finds and displays a Product entity.
Finds and displays a Product entity .
public function stockIncreaseDoAction(Request $request, Product $product)
    {
        $em = $this->getDoctrine()->getManager();
        $quantity = $request->get('quantity');
        $affectRawMaterial = $request->get('affect_raw_materials');
        if ($quantity && $quantity > 0) {
            if ($request->get('warehouse')) {
                $warehouse = $em->getRepository(Warehouse::class)->find($request->get('warehouse'));
            } else {
                $warehouse = $product->getWarehouse();
            }
            if ($warehouse) {
                $stockService = $this->get('amulen.shop.service.stock');
                $valid = $stockService->entryStock($warehouse, $product, $quantity, $affectRawMaterial, $request->get('comments'));
                return $this->redirect($this->generateUrl('admin_product_show', array('id' => $product->getId())));
            } else {
                $this->addFlash('warning', "Seleccione un deposito.");
            }
        } else {
            $this->addFlash('warning', "La cantidad no es válida.");
        }
        return $this->redirect($this->generateUrl('admin_product_stock_increase', array('id' => $product->getId())));
    }
public function stockIncreaseDoAction ( Request $ request , Product $ product ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ quantity = $ request -> get ( 'quantity' ) ; $ affectRawMaterial = $ request -> get ( 'affect_raw_materials' ) ; if ( $ quantity && $ quantity > 0 ) { if ( $ request -> get ( 'warehouse' ) ) { $ warehouse = $ em -> getRepository ( Warehouse :: class ) -> find ( $ request -> get ( 'warehouse' ) ) ; } else { $ warehouse = $ product -> getWarehouse ( ) ; } if ( $ warehouse ) { $ stockService = $ this -> get ( 'amulen.shop.service.stock' ) ; $ valid = $ stockService -> entryStock ( $ warehouse , $ product , $ quantity , $ affectRawMaterial , $ request -> get ( 'comments' ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_product_show' , array ( 'id' => $ product -> getId ( ) ) ) ) ; } else { $ this -> addFlash ( 'warning' , " Seleccione un deposito. " ) ; } } else { $ this -> addFlash ( 'warning' , " La cantidad no es válida." ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_product_stock_increase' , array ( 'id' => $ product -> getId ( ) ) ) ) ; }
Finds and displays a Product entity.
Finds and displays a Product entity .