private static function GetCerrarVentaParams($id_venta) { $ventaVo = VentaDAO::getByPK($id_venta); $resultArray = $ventaVo->asArray(); //buscar su cliente $result["cliente"] = self::GetUsuarioArray($ventaVo->getIdCompradorVenta()); //agente de venta $result["agente"] = self::GetUsuarioArray($ventaVo->getIdUsuario()); //buscar sus productos y ordenes $result["contenido"] = array_merge(VentaProductoDAO::search(new VentaProducto(array("id_venta" => $id_venta))), VentaOrdenDAO::search(new VentaOrden(array("id_venta" => $id_venta)))); //direccion //buscar su agente //buscar sucursal //buscar empresa return $result; }
public static function ActualizarTotales($id_venta) { Logger::log("actualizando el total de la venta " . $id_venta); $v = VentaDAO::getByPK($id_venta); if (is_null($v)) { throw new InvalidDataException("Esta venta no existe"); } //iniciar valores $subtotal = 0; //buscar los productos $vp = VentaProductoDAO::search(new VentaProducto(array("id_venta" => $id_venta))); for ($i = 0; $i < sizeof($vp); $i++) { Logger::log("prioducto" . $vp[$i]->getPrecio()); $subtotal += $vp[$i]->getPrecio() * $vp[$i]->getCantidad(); } //buscar los servicios $vo = VentaOrdenDAO::search(new VentaOrden(array("id_venta" => $id_venta))); for ($i = 0; $i < sizeof($vo); $i++) { $subtotal += $vo[$i]->getPrecio(); Logger::log("servicio" . $vo[$i]->getPrecio()); } //buscar los ipouestos $im = ImpuestoDAO::search(new Impuesto(array())); $iporcentaje = 0; for ($i = 0; $i < sizeof($im); $i++) { $iporcentaje += $im[$i]->getImporte(); } $itotal = $subtotal * $iporcentaje; $total = $itotal + $subtotal; //itotal, total, subtotal $v->setSubtotal($subtotal); $v->setImpuesto($itotal); $v->setTotal($total); try { VentaDAO::save($v); } catch (Exception $e) { Logger::error($e); throw $e; } return true; }
public static function Venta($id_venta) { $ventaDao = VentaDAO::getByPK($id_venta); if ($ventaDao === null) { throw new InvalidDataException("Esta venta no existe"); } $clienteDao = UsuarioDAO::getByPK($ventaDao->getIdCompradorVenta()); $agenteDao = UsuarioDAO::getByPK($ventaDao->getIdUsuario()); if ($ventaDao->getEsCotizacion()) { $pdf = self::createPdf("Cotizacion"); } else { $pdf = self::createPdf("Nota de venta"); } $opciones_tabla = array(); $opciones_tabla['showLines'] = 0; $opciones_tabla['showHeadings'] = 0; $opciones_tabla['shaded'] = 0; $opciones_tabla['fontSize'] = 8; $opciones_tabla['xOrientation'] = 'right'; $opciones_tabla['xPos'] = self::puntos_cm(7.5); $opciones_tabla['width'] = self::puntos_cm(11); $opciones_tabla['textCol'] = array(0, 0, 0); $opciones_tabla['titleFontSize'] = 12; $opciones_tabla['rowGap'] = 3; $opciones_tabla['colGap'] = 3; $f = date("d/m/y", $ventaDao->getFecha()) . " " . date("H:i:s", $ventaDao->getFecha()); if ($ventaDao->getEsCotizacion()) { $datos = array(array("col" => "<b>Cotizacion</b>"), array("col" => $ventaDao->getIdVenta()), array("col" => "<b>Numero de orden</b>"), array("col" => ""), array("col" => "<b>Fecha de venta</b>"), array("col" => $f), array("col" => "<b>Agente que cotizo</b>"), array("col" => self::readableText($agenteDao->getNombre()))); } else { $datos = array(array("col" => "<b>Venta</b>"), array("col" => $ventaDao->getIdVenta()), array("col" => "<b></b>"), array("col" => ""), array("col" => "<b>Fecha de venta</b>"), array("col" => $f), array("col" => "<b>Agente de venta</b>"), array("col" => self::readableText($agenteDao->getNombre()))); } $pdf->ezSetY(self::puntos_cm(26.8)); $opciones_tabla['xPos'] = self::puntos_cm(14.2); $opciones_tabla['width'] = self::puntos_cm(4); $opciones_tabla['showLines'] = 0; $opciones_tabla['shaded'] = 2; $opciones_tabla['shadeCol'] = array(1, 1, 1); $opciones_tabla['shadeCol2'] = array(0.8984375, 0.95703125, 0.99609375); $pdf->ezTable($datos, "", "", $opciones_tabla); $ventaProducto = VentaProductoDAO::search(new VentaProducto(array("id_venta" => $id_venta))); $ventaOrden = VentaOrdenDAO::search(new VentaOrden(array("id_venta" => $id_venta))); $prods = array_merge($ventaProducto, $ventaOrden); array_push($prods, $ventaDao); self::printProducts($pdf, $prods); self::printClient($pdf, $clienteDao); self::drawBasicGuide($pdf); $pdf->ezStream(); }
$form->hideField("saldo"); } $page->addComponent($form); function function_importe($foo, $obj) { return FormatMoney((double) $obj["precio"] * (double) $obj["cantidad"]); } if (sizeof($productos = VentaProductoDAO::search(new VentaProducto(array("id_venta" => $_GET["vid"])))) > 0) { $page->addComponent(new TitleComponent("Productos en esta venta", 3)); $tabla = new TableComponent(array("id_producto" => "Producto", "cantidad" => "Cantidad", "precio" => "Precio Unitario", "id_unidad" => "Importe"), $productos); $tabla->addColRender("id_unidad", "function_importe"); $tabla->addColRender("id_producto", "funcion_producto"); //$tabla->addColRender("cantidad", "FormatMoney"); $tabla->addColRender("precio", "FormatMoney"); $page->addComponent($tabla); } if (sizeof($v = VentaOrdenDAO::search(new VentaOrden(array("id_venta" => $_GET["vid"])))) > 0) { $page->addComponent(new TitleComponent("Ordenes de servicio de esta venta", 3)); $tabla = new TableComponent(array("id_orden_de_servicio" => "Orden de Servicio", "precio" => "Precio", "descuento" => "Descuento"), $v); $tabla->addColRender("id_orden_de_servicio", "funcion_orden_de_servicio"); $page->addComponent($tabla); } $page->addComponent(new TitleComponent("Abonos a esta venta", 3)); $tabla_abonos = new TableComponent(array("monto" => "Monto", "id_receptor" => "Recibio", "nota" => "Nota", "fecha" => "Fecha", "tipo_de_pago" => "Tipo de Pago"), AbonoVentaDAO::search(new AbonoVenta(array("id_venta" => $_GET["vid"])))); $tabla_abonos->addColRender("monto", "isCancelado"); $tabla_abonos->addColRender("id_receptor", "nombre_receptor"); $tabla_abonos->addColRender("nota", "isCancelado"); $tabla_abonos->addColRender("fecha", "isCancelado"); $tabla_abonos->addColRender("tipo_de_pago", "isCancelado"); $page->addComponent($tabla_abonos); $page->render();