src/Flowcode/ShopBundle/Controller/AdminProductController.php
/**
     * Finds and displays a Product entity.
     *
     * @Route("/{id}/stock_decrease", name="admin_product_stock_do_decrease", requirements={"id"="\d+"})
     * @Method("POST")
     * @Template()
     */
Finds and displays a Product entity.
Finds and displays a Product entity .
public function stockDecreaseDoAction(Request $request, Product $product)
    {
        if ($request->get('quantity')) {
            $em = $this->getDoctrine()->getManager();
            if ($request->get('affect_raw_materials')) {
                $affectRawMaterial = true;
            } else {
                $affectRawMaterial = false;
            }
            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');
                $stockService->exitStock($warehouse, $product, $request->get('quantity'), null, $affectRawMaterial, $request->get('comments'));
                return $this->redirect($this->generateUrl('admin_product_show', array('id' => $product->getId())));
            } else {
                $this->addFlash('warning', "Seleccione un deposito.");
            }
        }
        return $this->redirect($this->generateUrl('admin_product_stock_increase', array('id' => $product->getId())));
    }
public function stockDecreaseDoAction ( Request $ request , Product $ product ) { if ( $ request -> get ( 'quantity' ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( $ request -> get ( 'affect_raw_materials' ) ) { $ affectRawMaterial = true ; } else { $ affectRawMaterial = false ; } 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' ) ; $ stockService -> exitStock ( $ warehouse , $ product , $ request -> get ( 'quantity' ) , null , $ affectRawMaterial , $ request -> get ( 'comments' ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_product_show' , array ( 'id' => $ product -> getId ( ) ) ) ) ; } else { $ this -> addFlash ( 'warning' , " Seleccione un deposito. " ) ; } } 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 .