<?php if (!isset($_SESSION["cartn"])) { $product = array("product_id" => $_POST["product_id"], "q" => $_POST["q"]); $_SESSION["cartn"] = array($product); $cart = $_SESSION["cartn"]; /////////////////////////////////////////////////////////////////// $num_succ = 0; $process = false; $errors = array(); foreach ($cart as $c) { /// $q = OperationData::getQNoF($c["product_id"], $cut->id); print_r($c); echo ">>" . $q; if ($c["q"] <= $q) { $num_succ++; } else { $error = array("product_id" => $c["product_id"], "message" => "No hay suficiente cantidad de producto en inventario."); $errors[count($errors)] = $error; } } /////////////////////////////////////////////////////////////////// echo $num_succ; if ($num_succ == count($cart)) { $process = true; } if ($process == false) { unset($_SESSION["cartn"]); $_SESSION["errorsn"] = $errors; ?>
?> <h3>Resultados de la Busqueda</h3> <table class="table table-bordered table-hover"> <thead> <th>Codigo</th> <th>Nombre</th> <th>Unidad</th> <th>Precio unitario</th> <th>En inventario</th> <th>Cantidad</th> <th style="width:100px;"></th> </thead> <?php $products_in_cero = 0; foreach ($products as $product) { $q = OperationData::getQNoF($product->id, $cut->id); ?> <?php if ($q > 0) { ?> <form method="post" action="index.php?view=addtocartn"> <tr class="<?php if ($q <= 5) { echo "danger"; } ?> "> <td style="width:80px;"><?php echo $product->id; ?> </td>