$pedido->insertarRegistro($valores); $codpedido = $pedido->ultimo(); foreach ($dat as $d) { $i++; $valores = array("codpedido" => "'{$codpedido}'", "codproducto" => "'" . $d['codproducto'] . "'", "cantidad" => "'" . $d['cantidad'] . "'"); $pedidodetalle->insertarRegistro($valores); $codpedidodetalle = $pedidodetalle->ultimo(); $promatpri = $productomateriaprima->mostrarTodoRegistro("codproducto=" . $d['codproducto'], 1, ""); foreach ($promatpri as $pmp) { $cantidadproducto = $d['cantidad'] * $pmp['cantidad']; //echo $cantidadproducto; /*echo "<pre>"; print_r($pmp); echo "</pre>";*/ /*Comienza a Descontar*/ $inv = $inventario->SumaTotal($pmp['codmateriaprima']); $inv = array_shift($inv); $totalproducto = $inv['cantidadstocktotal']; $cantidad = $cantidadproducto; $fechasalida = date("Y-m-d"); if ($totalproducto < $cantidad) { $mensaje[] = "No Existe en Inventario la Cantidad que Solicita<hr><strong><br>Nombre Producto: {$nombreproducto}<br>Cantidad de Inventario: {$totalproducto}<br>Cantidad de Solicitada: {$cantidad}</strong>"; } else { $inventario->campos = array("*"); foreach ($inventario->mostrarTodoRegistro("codmateriaprima=" . $pmp['codmateriaprima'] . " and cantidadstock>0", 1, "fecha") as $inv) { if ((double) $cantidad <= (double) $inv['cantidadstock']) { //echo "Si"; $mensaje[] = "La Salida del producto <b>" . mb_strtoupper($nombreproducto, "utf8") . " </b>se registro correctamente"; $cantidad = $inv['cantidadstock'] - $cantidad; $valores = array("cantidadstock" => "{$cantidad}", "fechasalida" => "'{$fechasalida}'"); $inventario->actualizarRegistro($valores, "codinventario=" . $inv["codinventario"]);
echo "<pre>"; print_r($totales); echo "</pre>";*/ $i = 0; $anular = 'no'; ?> <table class="table table-bordered table-striped table-hover"> <thead> <tr><th width="15">Nº</th><th width="50">Código</th><th>Producto</th><th>Unidad</th><th width="100">Total a Usar</th><th width="100">Stock Disponible</th></tr> </thead> <?php foreach ($totales as $codmateriaprima => $v) { $i++; $mp = $materiaprima->mostrarTodoRegistro("codmateriaprima=" . $codmateriaprima); $mp = array_shift($mp); $inv = $inventario->SumaTotal($codmateriaprima); $inv = array_shift($inv); $totalstock = (double) $inv['cantidadstocktotal']; $error = $v['totales'] > $totalstock ? 'error' : 'correcto'; if ($anular == 'no') { if ($v['totales'] > $totalstock) { $anular = 'si'; } } ?> <tr class=""> <td class="der"><?php echo $i; ?> </td> <td><?php