<?php $ingredients = IngredientData::getAll(); $operations = ProductIngredientData::getAllByProductId($_GET["id"]); ?> <div class="content"> <h1>Ingredientes</h1> <?php if (isset($_GET["id"]) && $_GET["id"] != "") { ?> <a data-toggle="modal" href="#myModal" class="btn btn-default"><i class="glyphicon glyphicon-plus-sign"></i> Agregar Ingrediente</a> <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Agregar Ingrediente</h4> </div> <div class="modal-body"> <form class="form-horizontal" method="post" action="index.php?view=addproductingredient" role="form"> <div class="form-group"> <label for="inputEmail1" class="col-lg-2 control-label">Ingrediente</label> <div class="col-lg-10"> <select name="ingredient_id" class="form-control" required> <option value="">-- INGREDIENTES -- </option> <?php foreach ($ingredients as $product) { ?>
<?php $sell = Selldata::getById($_GET["id"]); $sell->cajero_id = Session::getUID(); $sell2 = new Sell2Data(); $sell2->user_id = $_SESSION["user_id"]; $s = $sell2->add_re_out(); $products = OperationData::getAllProductsBySellId($sell->id); foreach ($products as $prod) { $product = ProductData::getById($prod->product_id); if ($product->use_ingredient) { $ingredients = ProductIngredientData::getAllByProductId($prod->product_id); foreach ($ingredients as $ing) { $ingredient = IngredientData::getById($ing->ingredient_id); $q = Operation2Data::getQYesF($ing->ingredient_id); if ($q > 0) { $op = new Operation2Data(); $op->ingredient_id = $ingredient->id; $op->operation_type_id = 2; // 2 - salida $op->sell_id = $s[1]; $op->q = $prod->q * $ing->q; $add = $op->add(); } } } # code... } // inventariemos //print_r(expression) $sell->apply();