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: Apartados.php
<?php require 'vendor/autoload.php'; use Dompdf\Dompdf; class Apartados extends Controller { private $id_usuario, $id_sucursal; public function __construct() { parent::__construct(); session_start(); if (empty($_SESSION['id_usuario'])) { header('Location: ' . BASE_URL); exit; } $this->id_usuario = $_SESSION['id_usuario']; $this->id_sucursal = $_SESSION['id_sucursal']; } public function index() { if (!verificar('crear_apartados')) { header('Location: ' . BASE_URL . 'admin/permisos'); exit; } $data['script'] = 'apartados.js'; $data['title'] = 'Apartados'; $data['busqueda'] = 'busqueda.js'; $data['modal'] = 'apartado.php'; $data['carrito'] = 'posApartados'; $this->views->getView('apartados', 'index', $data); } 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); if (!$producto) { echo json_encode(['status' => 'error', 'msg' => 'Producto no encontrado'], JSON_UNESCAPED_UNICODE); die(); } $descuento = 0; $cantidad = 1; $caja = 0; // Si el producto NO es servicio, validar stock considerando el carrito 'apartados' if ($producto['servicio'] == 0) { $cantidadEnCarrito = 0; if (!empty($_SESSION['apartados'])) { foreach ($_SESSION['apartados'] as $item) { if ($item['id'] == $idProducto && $item['caja_id'] == 0) { // ajusta 'caja_id' si aplica $cantidadEnCarrito = $item['quantity']; break; } } } if ($producto['cantidad'] < ($cantidadEnCarrito + $cantidad)) { echo json_encode(['icono' => 'error', 'msg' => 'Stock insuficiente'], JSON_UNESCAPED_UNICODE); die(); } } $preciosVenta = json_decode($producto['precio_venta'], true); $precioSeleccionado = $preciosVenta[0]; $res = addToCartCaja( 'apartados', $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('apartados', $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'])); // Obtener información del producto $producto = $this->model->getProducto($data['id_producto']); if (!$producto) { echo json_encode(['icono' => 'error', 'msg' => 'Producto no encontrado'], JSON_UNESCAPED_UNICODE); die(); } // Validar stock si no es servicio if ($producto['servicio'] == 0) { // Ajustar la cantidad deseada si supera el stock if ($cantidad > $producto['cantidad']) { echo json_encode(['icono' => 'error', 'msg' => 'Stock insuficiente'], JSON_UNESCAPED_UNICODE); die(); } } // Actualizar la cantidad en el carrito $res = updateCantidadCaja('apartados', $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('apartados', $data['id_producto'], 0); echo json_encode($res, JSON_UNESCAPED_UNICODE); } else { echo json_encode(['icono' => 'warning', 'msg' => 'Datos inválidos']); } } die(); } public function registrarApartado() { if (!verificar('crear_apartados')) { echo json_encode(['msg' => 'NO TIENES PERMISOS', 'type' => 'warning']); die(); } $verificarCaja = $this->model->getCaja($this->id_sucursal); if (empty($verificarCaja['monto_inicial'])) { echo json_encode(['msg' => 'La CAJA ESTA CERRADA', 'type' => 'warning']); die(); } $json = file_get_contents('php://input'); $datos = json_decode($json, true); $productos = $_SESSION['apartados'] ?? []; $total = 0; if (!empty($productos)) { $fecha_create = date('Y-m-d'); $fecha_apartado = $datos['fecha_apartado'] . ' ' . date('H:i:s'); $fecha_retiro = $datos['fecha_retiro'] . ' 23:59:59'; $abono = $datos['abono']; $color = $datos['color']; $moneda = (!empty($_SESSION['moneda'])) ? $_SESSION['moneda'] : MONEDA; $idCliente = $datos['idCliente']; if (empty($idCliente)) { $res = ['msg' => 'EL CLIENTE ES REQUERIDO', 'type' => 'warning']; } elseif (empty($fecha_apartado)) { $res = ['msg' => 'FECHA APARTADO ES REQUERIDO', 'type' => 'warning']; } elseif (empty($fecha_retiro)) { $res = ['msg' => 'FECHA RETIRO ES REQUERIDO', 'type' => 'warning']; } elseif (empty($abono)) { $res = ['msg' => 'ABONO ES REQUERIDO', 'type' => 'warning']; } else { $productosProcesados = []; foreach ($productos as $producto) { $data = [ 'id' => $producto['id'], 'nombre' => $producto['name'], 'precio' => $producto['price'], 'cantidad' => $producto['quantity'] ]; $subTotal = $producto['price'] * $producto['quantity']; $productosProcesados[] = $data; $total += $subTotal; } $datosProductos = json_encode($productosProcesados); $apartado = $this->model->registrarApartado( $datosProductos, $fecha_create, $fecha_apartado, $fecha_retiro, $abono, $total, $color, $moneda, $idCliente, $this->id_usuario, $this->id_sucursal ); if ($apartado > 0) { foreach ($productosProcesados as $item) { $result = $this->model->getProducto($item['id']); // actualizar stock $nuevaCantidad = $result['cantidad'] - $item['cantidad']; $totalVentas = $result['ventas'] + $item['cantidad']; $this->model->actualizarStock($nuevaCantidad, $totalVentas, $result['id']); // movimientos $movimiento = 'Apartado N°: ' . $apartado; $this->model->registrarMovimiento($movimiento, 'salida', $item['cantidad'], $nuevaCantidad, $item['id'], $this->id_usuario, $this->id_sucursal); } $this->model->registrarDetalle($abono, $verificarCaja['id'], $apartado, $this->id_usuario); unset($_SESSION['apartados']); $res = ['msg' => 'PRODUCTOS APARTADOS', 'type' => 'success', 'idApartado' => $apartado]; } else { $res = ['msg' => 'ERROR AL APARTAR LOS PRODUCTOS', 'type' => 'error']; } } } else { $res = ['msg' => 'CARRITO VACIO', 'type' => 'warning']; } echo json_encode($res); die(); } public function reporte($datos) { ob_start(); $array = explode(',', $datos); $tipo = $array[0]; $idApartado = $array[1]; $data['title'] = 'Reporte'; $data['empresa'] = $this->model->getEmpresa($this->id_sucursal); $data['apartado'] = $this->model->getApartado($idApartado); if (empty($data['apartado'])) { 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('apartados', $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_apartados')) { $data = $this->model->getApartados($this->id_sucursal); for ($i = 0; $i < count($data); $i++) { $estado = ($data[$i]['estado'] == 0) ? 'Completado' : 'Pendiente'; $data[$i]['title'] = $estado . ' - ' . $data[$i]['nombre']; $data[$i]['start'] = $data[$i]['fecha_apartado']; $data[$i]['end'] = $data[$i]['fecha_retiro']; } } echo json_encode($data); die(); } public function verDatos($idApartado) { $data = $this->model->getApartado($idApartado); echo json_encode($data); die(); } public function procesarEntrega($idApartado) { if (verificar('entregar_apartados')) { $apartado = $this->model->getApartado($idApartado); $data = $this->model->procesarEntrega($apartado['total'], 0, $idApartado); if ($data == 1) { $this->model->actualizarDetalle($apartado['total'], $idApartado); $res = array('msg' => 'PROCESADO CON ÉXITO', 'type' => 'success'); } else { $res = array('msg' => 'ERROR AL PROCESAR', 'type' => 'error'); } } else { $res = array('msg' => 'NO TIENES PERMISOS', 'type' => 'error'); } echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function listarHistorial() { $data = []; if (verificar('ver_apartados')) { $fechaInicio = !empty($_GET['fechaInicio']) ? $_GET['fechaInicio'] : null; $fechaFin = !empty($_GET['fechaFin']) ? $_GET['fechaFin'] : null; // Pasar las fechas al modelo $data = $this->model->getApartados($this->id_sucursal, $fechaInicio, $fechaFin); for ($i = 0; $i < count($data); $i++) { if ($data[$i]['estado'] == 0) { $data[$i]['estado'] = '<span class="badge bg-success">Completado</span>'; } else { $data[$i]['estado'] = '<span class="badge bg-danger">Pendiente</span>'; } $data[$i]['cliente'] = '<span class="badge" style="background: ' . $data[$i]['color'] . ';">' . $data[$i]['nombre'] . '</span>'; $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); die(); } }
Coded With 💗 by
0x6ick