Ver Mensaje Individual
  #6 (permalink)  
Antiguo 07/11/2017, 14:34
elsaiya
 
Fecha de Ingreso: marzo-2012
Ubicación: El Vigia Edo Merida
Mensajes: 147
Antigüedad: 12 años, 11 meses
Puntos: 1
Respuesta: Descontar ingredientes a productos

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
  1. ################### CONSULTO LA TABLA PARA VERIFICAR SI EXISTEN PRODUCTOS REGISTRADOS #######################
  2. $sql = "select * from productosvsingredientes where codproducto = ?";
  3.         $stmt = $this->dbh->prepare($sql);
  4.         $stmt->execute( array( $venta[$i]['txtCodigo'] ) );
  5.         $num = $stmt->rowCount();
  6.         if($num>0)
  7.         {
  8.  
  9.  
  10.     $sql = "select * from productosvsingredientes LEFT JOIN ingredientes ON productosvsingredientes.codingrediente = ingredientes.codingrediente where productosvsingredientes.codproducto = '".$venta[$i]['txtCodigo']."'";
  11.         foreach ($this->dbh->query($sql) as $row)
  12.         {
  13.             $this->p[] = $row;
  14.  
  15.             $codproducto = $row['codproducto'];
  16.             $codingrediente = $row['codingrediente'];
  17.             $cantracion = $row['cantracion'];
  18.             $cantingrediente = $row['cantingrediente'];
  19.  
  20.  
  21.             $update = " update ingredientes set "
  22.             ." cantingrediente = ? "
  23.             ." where "
  24.             ." codingrediente = ?;
  25.             ";
  26.             $stmt = $this->dbh->prepare($update);
  27.             $stmt->bindParam(1, $cantidadracion);
  28.             $stmt->bindParam(2, $codingrediente);*/
  29.  
  30.             $racion = rount($cantracion*$cantidad,2);
  31.             $cantidadracion = rount($cantingrediente-$racion,2);
  32.             $stmt->execute();
  33.  
  34.  
  35. echo "SI ".$codproducto." - ".$codingrediente." - ".$cantingrediente." - ".$cantracion." * ".$cantidad." = ".$racion." = ".$cantidadracion."<br>";
  36.  
  37.  
  38.         }
  39. ################### FIN DE CONSULTO LA TABLA PARA VERIFICAR SI EXISTEN PRODUCTOS REGISTRADOS #######################