public function registrarOrden(OrdenesDeCompraDTO $dto, PDO $cnn) { try { $valor = $cnn->prepare("select ValorTotalCotizacion as 'valor' from Cotizaciones where IdCotizacion=? "); $valor->bindParam(1, $dto->getCotizacionId()); $valor->execute(); $totalcoti = $valor->fetch(); $query = $cnn->prepare("INSERT INTO OrdenesDeCompra VALUES (DEFAULT,?,?,now(),?,?,?,?)"); $query->bindParam(1, $dto->getCotizacionId()); $query->bindParam(2, $dto->getEstado()); $query->bindParam(3, $totalcoti['valor']); $query->bindParam(4, $dto->getDescuentoTotal()); $query->bindParam(5, $dto->getGranTotal()); $query->bindParam(6, $dto->getObservaciones()); $query->execute(); $estado = $cnn->prepare("Update Cotizaciones set EstadoCotización='OC' where IdCotizacion=?"); $estado->bindParam(1, $dto->getCotizacionId()); $estado->execute(); return "Orden de compra registrada, Cotizacion cambiada"; } catch (Exception $ex) { $mensaje = '&detalleerror=' . $ex->getMessage() . '&error=1&mensaje=La orden de compra NO pudo ser registrada'; } $cnn = null; return $mensaje; }
public function ModificarOrdenDeCompra(OrdenesDeCompraDTO $ordenDeCompraDTO, PDO $cnn) { try { $query = $cnn->prepare("UPDATE OrdenDeCompra SET Estado=?, Fecha=?, Total=?, Descuento=?, GranTotal=?, Observaciones=? WHERE IdOrden=?"); $query->bindParam(1, $ordenDeCompraDTO->getEstado()); $query->bindParam(2, $ordenDeCompraDTO->getFecha()); $query->bindParam(3, $ordenDeCompraDTO->getTotal()); $query->bindParam(4, $ordenDeCompraDTO->getDescuento()); $query->bindParam(5, $ordenDeCompraDTO->getGranTotal()); $query->bindParam(6, $ordenDeCompraDTO->getObservaciones()); $query->bindParam(7, $ordenDeCompraDTO->getIdOrden()); $query->execute(); $mensaje = "OK ModificarOrdenDeCompra"; } catch (Exception $ex) { $mensaje = $ex->getMessage(); } $cnn = null; return $mensaje; }
public function ConvertirAOrden(OrdenesDeCompraDTO $ordenesDeCompraDTO, PDO $cnn) { try { $query = $cnn->prepare("INSERT INTO OrdenesDeCompra VALUES (?,?,?,?,?,?) WHERE IdCotizacion=?"); $query->bindParam(1, $ordenesDeCompraDTO->getEstado()); $query->bindParam(2, $ordenesDeCompraDTO->getFecha()); $query->bindParam(3, $ordenesDeCompraDTO->getTotalCotizacion()); $query->bindParam(4, $ordenesDeCompraDTO->getDescuentoTotal()); $query->bindParam(5, $ordenesDeCompraDTO->getGranTotal()); $query->bindParam(6, $ordenesDeCompraDTO->getObservaciones()); $query->bindParam(7, $ordenesDeCompraDTO->getIdCotizacion()); $query->execute(); $mensaje = "OK ConvertirOrdenCompra"; } catch (Exception $ex) { $mensaje = $ex->getMessage(); } $cnn = null; return $mensaje; }