samigo es descontar las unidades, de ingredientes a los productos, ya logre descontar la racion que lleva el producto a la unidad en ingredientes, pero ahora el problema es por ejemplo una hamburgueza tiene lechuga y el perro caliente tambien, entonces como haria para poder descontar esas dos raciones a una misma unidad
Código PHP:
Ver original################### CONSULTO LA TABLA PARA VERIFICAR SI EXISTEN PRODUCTOS REGISTRADOS #######################
$sql = "select * from productosvsingredientes where codproducto = ?";
$stmt = $this->dbh->prepare($sql);
$stmt->execute( array( $venta[$i]['txtCodigo'] ) ); $num = $stmt->rowCount();
if($num>0)
{
$sql = "select * from productosvsingredientes LEFT JOIN ingredientes ON productosvsingredientes.codingrediente = ingredientes.codingrediente where productosvsingredientes.codproducto = '".$venta[$i]['txtCodigo']."'";
foreach ($this->dbh->query($sql) as $row)
{
$this->p[] = $row;
$codproducto = $row['codproducto'];
$codingrediente = $row['codingrediente'];
$cantracion = $row['cantracion'];
$cantingrediente = $row['cantingrediente'];
$update = " update ingredientes set "
." cantingrediente = ? "
." where "
." codingrediente = ?;
";
$stmt = $this->dbh->prepare($update);
$stmt->bindParam(1, $cantidadracion);
$stmt->bindParam(2, $codingrediente);*/
$racion = rount($cantracion*$cantidad,2);
$cantidadracion = rount($cantingrediente-$racion,2);
$stmt->execute();
echo "SI ".$codproducto." - ".$codingrediente." - ".$cantingrediente." - ".$cantracion." * ".$cantidad." = ".$racion." = ".$cantidadracion."<br>";
}
################### FIN DE CONSULTO LA TABLA PARA VERIFICAR SI EXISTEN PRODUCTOS REGISTRADOS #######################