Tul xxx Tul
User / IP
:
216.73.216.227
Host / Server
:
45.84.207.204 / aircan.me
System
:
Linux lt-bnk-web1726.main-hosting.eu 5.14.0-611.36.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 3 11:23:52 EST 2026 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
u931257429
/
domains
/
aircan.me
/
public_html
/
comercial
/
controllers
/
Viewing: Cotizaciones.php
<?php require 'vendor/autoload.php'; use Dompdf\Dompdf; class Cotizaciones extends Controller { private $id_sucursal; public function __construct() { parent::__construct(); session_start(); if (empty($_SESSION['id_usuario'])) { header('Location: ' . BASE_URL); exit; } $this->id_sucursal = $_SESSION['id_sucursal']; } public function index() { if (verificar('crear_cotizaciones') || verificar('ver_cotizaciones')) { $data['title'] = 'Cotizaciones'; $data['script'] = 'cotizaciones.js'; $data['busqueda'] = 'busqueda.js'; $data['carrito'] = 'posCotizaciones'; $data['modal'] = 'venta.php'; $data['empresa'] = $this->model->getEmpresa($this->id_sucursal); $this->views->getView('cotizaciones', 'index', $data); } else { header('Location: ' . BASE_URL . 'admin/permisos'); exit; } } public function addProduct($idProducto) { if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { if (is_numeric($idProducto)) { $producto = $this->model->getProducto($idProducto); $descuento = 0; $cantidad = 1; $caja = 0; $preciosVenta = json_decode($producto['precio_venta'], true); $precioSeleccionado = $preciosVenta[0]; $res = addToCartCaja( 'cotizaciones', $idProducto, $producto['descripcion'], $precioSeleccionado['monto'], $descuento, $cantidad, $caja, $preciosVenta, $precioSeleccionado ); echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } } } public function listarTbl($table) { $data['productos'] = $_SESSION[$table] ?? []; // Ordenar por timestamp descendente (si existe timestamp) usort($data['productos'], function ($a, $b) { return ($b['timestamp'] ?? 0) <=> ($a['timestamp'] ?? 0); }); $total = 0; foreach ($data['productos'] as $p) { $monto = isset($p['precio_seleccionado']['monto']) ? $p['precio_seleccionado']['monto'] : $p['price']; $cantidad = $p['quantity'] ?? 1; $total += $monto * $cantidad; } $data['total'] = number_format($total, 2, '.', ''); echo json_encode($data, JSON_UNESCAPED_UNICODE); die(); } public function cambiarPrecio() { if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $json = file_get_contents('php://input'); $data = json_decode($json, true); // Decodificar 'item' que es un JSON string if (isset($data['item'])) { $precio = json_decode($data['item'], true); } else { $precio = null; } if (is_array($data) && isset($data['id_producto']) && is_array($precio)) { $res = updatePriceCaja('cotizaciones', $data['id_producto'], $precio, 0); echo json_encode($res, JSON_UNESCAPED_UNICODE); } else { echo json_encode(['icono' => 'warning', 'msg' => 'Datos inválidos']); } } die(); } public function cambiarCantidad() { if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $json = file_get_contents('php://input'); $data = json_decode($json, true); if (is_array($data) && isset($data['id_producto'], $data['item'])) { $cantidad = max(1, intval($data['item'])); $res = updateCantidadCaja('cotizaciones', $data['id_producto'], $cantidad, 0); echo json_encode($res, JSON_UNESCAPED_UNICODE); } else { echo json_encode(['icono' => 'warning', 'msg' => 'Datos inválidos']); } } die(); } public function eliminarProducto() { if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $json = file_get_contents('php://input'); $data = json_decode($json, true); if (is_array($data) && isset($data['id_producto'])) { $res = removeFromCartCaja('cotizaciones', $data['id_producto'], 0); echo json_encode($res, JSON_UNESCAPED_UNICODE); } else { echo json_encode(['icono' => 'warning', 'msg' => 'Datos inválidos']); } } die(); } private function sendResponse(string $msg, string $type, array $data = []) { echo json_encode(array_merge(['msg' => $msg, 'type' => $type], $data)); die(); } private function procesarProductos(array $productos): array { $resultados = []; foreach ($productos as $producto) { $result = $this->model->getProducto($producto['id']); $resultados[] = [ 'id' => $result['id'], 'nombre' => $result['descripcion'] . ' - ' . $result['marca'], 'precio' => $producto['price'], 'cantidad' => $producto['quantity'], ]; } return $resultados; } public function registrarCotizacion() { if (verificar('crear_cotizaciones')) { $json = file_get_contents('php://input'); $datos = json_decode($json, true); $productos = $_SESSION['cotizaciones'] ?? []; if (!empty($productos)) { $fecha = date('Y-m-d'); $hora = date('H:i:s'); $metodo = $datos['metodo']; $validez = $datos['validez']; $moneda = (!empty($_SESSION['moneda'])) ? $_SESSION['moneda'] : MONEDA; $idCliente = $datos['idCliente']; if (empty($idCliente)) { $this->sendResponse('EL CLIENTE ES REQUERIDO', 'warning'); } if (empty($metodo)) { $this->sendResponse('EL METODO ES REQUERIDO', 'warning'); } if (empty($validez)) { $this->sendResponse('LA VALIDEZ ES REQUERIDO', 'warning'); } $descuento = (!empty($datos['descuento'])) ? floatval($datos['descuento']) : 0; $totalBruto = $this->calcularTotal($productos); // Validar descuento negativo if ($descuento < 0) { $this->sendResponse('EL DESCUENTO NO PUEDE SER NEGATIVO', 'warning'); } // Validar que descuento no sea mayor al total if ($descuento > $totalBruto) { $this->sendResponse('EL DESCUENTO NO PUEDE SER MAYOR AL TOTAL', 'warning'); } $impuesto = (!empty($datos['impuesto'])) ? $datos['impuesto'] : 0; $empresa = $this->model->getEmpresa($this->id_sucursal); $totalNeto = $totalBruto - $descuento; if ($impuesto == 1) { $igv = $totalNeto * ($empresa['impuesto'] / 100); $totalConImpuesto = $totalNeto + $igv; } else { $totalConImpuesto = $totalNeto; } $datosProductos = json_encode($this->procesarProductos($productos)); $cotizacion = $this->model->registrarCotizacion( $datosProductos, $totalNeto, $totalConImpuesto, $impuesto, $fecha, $hora, $metodo, $validez, $descuento, $moneda, $idCliente, $this->id_sucursal ); if ($cotizacion > 0) { unset($_SESSION['cotizaciones']); $res = array('msg' => 'COTIZACIÓN GENERADA', 'type' => 'success', 'idCotizacion' => $cotizacion); } else { $res = array('msg' => 'ERROR AL GENERAR LA COTIZACIÓN', 'type' => 'error'); } } else { $res = array('msg' => 'CARRITO VACIO', 'type' => 'warning'); } } else { $res = array('msg' => 'NO TIENES PERMISOS', 'type' => 'warning'); } echo json_encode($res); die(); } private function calcularTotal(array $productos): float { $total = 0; foreach ($productos as $producto) { $total += $producto['price'] * $producto['quantity']; } return $total; } public function reporte($datos) { ob_start(); $array = explode(',', $datos); $tipo = $array[0]; $idCotizacion = $array[1]; $data['title'] = 'Reporte'; $data['empresa'] = $this->model->getEmpresa($this->id_sucursal); $data['cotizacion'] = $this->model->getCotizacion($idCotizacion); if (empty($data['cotizacion'])) { echo 'Pagina no Encontrada'; exit; } $logoPath = 'assets/images/logo.png'; if (file_exists($logoPath)) { $data['logo'] = 'data:image/png;base64,' . base64_encode(file_get_contents($logoPath)); } else { $data['logo'] = null; } $this->views->getView('cotizaciones', $tipo, $data); $html = ob_get_clean(); $dompdf = new Dompdf(); $options = $dompdf->getOptions(); $options->set('isJavascriptEnabled', true); $options->set('isRemoteEnabled', true); $dompdf->setOptions($options); $dompdf->loadHtml($html); if ($tipo == 'ticked') { $dompdf->setPaper(array(0, 0, 200, 841), 'portrait'); } else { $dompdf->setPaper('A4', 'vertical'); } // Render the HTML as PDF $dompdf->render(); // Output the generated PDF to Browser $dompdf->stream('reporte.pdf', array('Attachment' => false)); } public function listar() { $data = []; if (verificar('ver_cotizaciones')) { $fechaInicio = !empty($_GET['fechaInicio']) ? $_GET['fechaInicio'] : null; $fechaFin = !empty($_GET['fechaFin']) ? $_GET['fechaFin'] : null; $data = $this->model->getCotizaciones($this->id_sucursal, $fechaInicio, $fechaFin); for ($i = 0; $i < count($data); $i++) { $data[$i]['acciones'] = '<a class="btn btn-danger" href="#" onclick="verReporte(' . $data[$i]['id'] . ')"><i class="fas fa-file-pdf"></i></a>'; } } echo json_encode($data, JSON_UNESCAPED_UNICODE); die(); } }
Coded With 💗 by
0x6ick