function Alta($IdComprobante, $SerialNum, $local, $documentoventa) { $this->IdComprobante = $IdComprobante; $almacenes = new almacenes(); $aPedidoDet = explode(",", $this->pedidodet); //IdPedidoDet:unidades:Serie;Serie,... $aStatus = explode("~", $this->status); //Serie~Lote~Vence... //Filas... foreach ($aPedidoDet as $xrow) { global $UltimaInsercion; $axrow = explode(":", $xrow); $idpedidodet = isset($axrow[1]) ? $axrow[0] : 0; $unidades = isset($axrow[1]) ? $axrow[1] : $this->unidades; $xnseries = isset($axrow[2]) ? $axrow[2] : false; $xnseries = isset($axrow[2]) ? str_replace(";", ",", $xnseries) : false; //$importe = ($this->importe)/$unidades; $importe = $unidades * $this->unidadimporte; //ComprobanteDet... $Keys = "IdComprobante,"; $Values = "'" . $IdComprobante . "',"; $Keys .= "IdProducto,"; $Values .= "'" . $this->idproducto . "',"; $Keys .= "IdPedidoDet,"; $Values .= "'" . $idpedidodet . "',"; $Keys .= "Cantidad,"; $Values .= "'" . $unidades . "',"; $Keys .= "Precio,"; $Values .= "'" . $this->precio . "',"; $Keys .= "CostoUnitario,"; $Values .= "'" . $this->costo . "',"; $Keys .= "Descuento,"; $Values .= "'" . $this->descuento . "',"; $Keys .= "Importe,"; $Values .= "'" . $importe . "',"; $Keys .= "Impuesto,"; $Values .= "'" . $this->impuesto . "',"; $Keys .= "Concepto,"; $Values .= "'" . $this->concepto . "',"; $Keys .= "Talla,"; $Values .= "'" . $this->talla . "',"; $Keys .= "Color,"; $Values .= "'" . $this->color . "',"; $Keys .= "Referencia,"; $Values .= "'" . $this->referencia . "',"; $Keys .= "CodigoBarras,"; $Values .= "'" . $this->codigobarras . "',"; $Keys .= "Oferta,"; $Values .= "'" . $this->oferta . "',"; $Keys .= "Serie,"; $Values .= "'" . $aStatus[0] . "',"; $Keys .= "Lote,"; $Values .= "'" . $aStatus[1] . "',"; $Keys .= "Vencimiento"; $Values .= "'" . $aStatus[2] . "'"; $sql = "insert into ges_comprobantesdet (" . $Keys . ") values (" . $Values . ")"; query($sql, "Detalle ticket"); $this->nticket = $SerialNum; $idcomprobantedet = $UltimaInsercion; //Existencias... $existencias = $almacenes->obtenerExistenciasKardex($this->idproducto, $local); if ($unidades > $existencias) { continue; } //Series... if (isset($axrow[2])) { registraSalidaSeriesPedidoDet($this->idproducto, $IdComprobante, $xnseries, $idpedidodet); } //Kardex... $Operacion = 2; //Venta if (isset($axrow[1])) { registrarSalidaKardexFifo($this->idproducto, $unidades, $this->costo, $Operacion, $local, $idpedidodet, $idcomprobantedet, $existencias, false, false, false); } //Almacen Kardex... $almacenes->actualizarCosto($this->idproducto, $local); $almacenes->actualizaOfertaUnidades($this->idproducto, $local, $this->oferta); actualizaResumenKardex($this->idproducto, $local); } }