Tul xxx Tul
User / IP
:
216.73.216.183
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
/
vendefacilfra
/
controllers
/
Viewing: Egresos.php
<?php require 'vendor/autoload.php'; use Dompdf\Dompdf; class Egresos 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('ver_gastos')) { header('Location: ' . BASE_URL . 'admin/permisos'); exit; } $data['title'] = 'Egresos'; $data['script'] = 'egresos.js'; $empresa = $this->model->getEmpresa($this->id_sucursal); $data['porcentaje_impuesto'] = (!empty($empresa['impuesto'])) ? (float)$empresa['impuesto'] : 0; $this->views->getView('egresos', 'index', $data); } public function listar() { $data = []; if (verificar('ver_gastos')) { $desde = !empty($_GET['desde']) ? $_GET['desde'] : null; $hasta = !empty($_GET['hasta']) ? $_GET['hasta'] : null; $data = $this->model->getEgresos($this->id_sucursal, $desde, $hasta); for ($i = 0; $i < count($data); $i++) { $subtotal = isset($data[$i]['subtotal']) ? (float)$data[$i]['subtotal'] : 0; $ivaMonto = isset($data[$i]['iva_monto']) ? (float)$data[$i]['iva_monto'] : 0; $retencionMonto = isset($data[$i]['retencion_monto']) ? (float)$data[$i]['retencion_monto'] : 0; $montoFinal = isset($data[$i]['monto']) ? (float)$data[$i]['monto'] : 0; $codigoCategoria = !empty($data[$i]['codigo_cuenta_categoria']) ? $data[$i]['codigo_cuenta_categoria'] : '--'; $codigoSubcategoria = !empty($data[$i]['codigo_cuenta_subcategoria']) ? $data[$i]['codigo_cuenta_subcategoria'] : $codigoCategoria; if ($subtotal <= 0 && $montoFinal > 0) { if ($ivaMonto > 0 || $retencionMonto > 0) { $subtotal = max(0, ($montoFinal - $ivaMonto) + $retencionMonto); } else { $subtotal = $montoFinal; } } $data[$i]['subtotal'] = number_format($subtotal, 2); $data[$i]['iva_monto'] = number_format($ivaMonto, 2); $data[$i]['retencion_monto'] = number_format($retencionMonto, 2); $data[$i]['monto'] = number_format($montoFinal, 2); $data[$i]['fecha'] = date('Y-m-d H:i', strtotime($data[$i]['fecha'])); $data[$i]['codigo_cuenta'] = ''; $data[$i]['categoria'] = !empty($data[$i]['categoria']) ? '<span class="badge bg-primary">' . $data[$i]['categoria'] . '<br><small>' . $codigoCategoria . '</small></span>' : ''; $data[$i]['subcategoria'] = !empty($data[$i]['subcategoria']) ? '<span class="badge bg-secondary">' . $data[$i]['subcategoria'] . '<br><small>' . $codigoSubcategoria . '</small></span>' : ''; if (!empty($data[$i]['foto'])) { $url = BASE_URL . $data[$i]['foto']; $data[$i]['foto'] = '<button class="btn btn-outline-secondary btn-sm" type="button" data-url="' . $url . '" onclick="verImagenEgreso(this.getAttribute(\'data-url\'))"><i class="fas fa-image"></i></button>'; } else { $data[$i]['foto'] = ''; } $acciones = '<div class="btn-group" role="group">'; if (verificar('crear_gastos')) { $acciones .= '<button class="btn btn-info btn-sm" type="button" onclick="editarEgreso(' . $data[$i]['id'] . ')"><i class="fas fa-edit"></i></button>'; } $acciones .= '<button class="btn btn-secondary btn-sm" type="button" onclick="imprimirEgreso(' . $data[$i]['id'] . ')"><i class="fas fa-print"></i></button>'; if (verificar('eliminar_gastos')) { $acciones .= '<button class="btn btn-danger btn-sm" type="button" onclick="eliminarEgreso(' . $data[$i]['id'] . ')"><i class="fas fa-trash"></i></button>'; } $acciones .= '</div>'; $data[$i]['acciones'] = $acciones; } } echo json_encode($data, JSON_UNESCAPED_UNICODE); die(); } public function resumen() { $response = [ 'ingresos' => 0, 'egresos' => 0, 'utilidad' => 0, 'ingresosDecimal' => '0.00', 'egresosDecimal' => '0.00', 'utilidadDecimal' => '0.00', 'moneda' => MONEDA, ]; if (verificar('ver_gastos')) { $desde = !empty($_GET['desde']) ? $_GET['desde'] : date('Y-m-01'); $hasta = !empty($_GET['hasta']) ? $_GET['hasta'] : date('Y-m-t'); $ingresos = $this->model->getTotalIngresos($this->id_sucursal, $desde, $hasta); $egresos = $this->model->getTotalEgresos($this->id_sucursal, $desde, $hasta); $totalIngresos = (!empty($ingresos['total'])) ? (float)$ingresos['total'] : 0; $totalEgresos = (!empty($egresos['total'])) ? (float)$egresos['total'] : 0; $utilidad = $totalIngresos - $totalEgresos; $response['ingresos'] = number_format($totalIngresos, 2, '.', ''); $response['egresos'] = number_format($totalEgresos, 2, '.', ''); $response['utilidad'] = number_format($utilidad, 2, '.', ''); $response['ingresosDecimal'] = number_format($totalIngresos, 2); $response['egresosDecimal'] = number_format($totalEgresos, 2); $response['utilidadDecimal'] = number_format($utilidad, 2); } echo json_encode($response, JSON_UNESCAPED_UNICODE); die(); } public function editar($id) { if (!verificar('ver_gastos')) { echo json_encode([], JSON_UNESCAPED_UNICODE); die(); } if (!isset($id) || !is_numeric($id)) { echo json_encode([], JSON_UNESCAPED_UNICODE); die(); } $data = $this->model->getEgreso($id, $this->id_sucursal); echo json_encode($data, JSON_UNESCAPED_UNICODE); die(); } public function actualizar() { if (!verificar('crear_gastos')) { echo json_encode(['msg' => 'NO TIENES PERMISOS', 'type' => 'warning']); die(); } if (isset($_POST['id']) && isset($_POST['descripcion'])) { $id = strClean($_POST['id']); $subtotal = (isset($_POST['monto']) && $_POST['monto'] !== '') ? (float)strClean($_POST['monto']) : 0; $codigoCuenta = isset($_POST['codigo_cuenta']) ? strClean($_POST['codigo_cuenta']) : ''; $categoria = isset($_POST['categoria']) ? strClean($_POST['categoria']) : ''; $subcategoria = isset($_POST['subcategoria']) ? strClean($_POST['subcategoria']) : ''; $descripcion = strClean($_POST['descripcion']); $ivaMonto = isset($_POST['iva_monto']) && $_POST['iva_monto'] !== '' ? (float)strClean($_POST['iva_monto']) : 0; $aplicaIva = ($ivaMonto > 0) ? 1 : 0; $retencionMonto = 0; // Eliminado del frontend if ($subtotal < 0) { $subtotal = 0; } if ($ivaMonto < 0) { $ivaMonto = 0; } $montoFinal = ($subtotal + $ivaMonto); if ($montoFinal < 0) { $montoFinal = 0; } if (empty($id) || !is_numeric($id)) { $res = array('msg' => 'ID NO VÁLIDO', 'type' => 'warning'); } elseif (empty($_POST['monto'])) { $res = array('msg' => 'EL SUBTOTAL ES REQUERIDO', 'type' => 'warning'); } elseif (empty($codigoCuenta)) { $res = array('msg' => 'DEBES CONFIGURAR EL CÓDIGO INTERNO EN LA CATEGORÍA O SUBCATEGORÍA', 'type' => 'warning'); } elseif (empty($categoria)) { $res = array('msg' => 'LA CATEGORÍA ES REQUERIDA', 'type' => 'warning'); } elseif (empty($subcategoria)) { $res = array('msg' => 'LA SUBCATEGORÍA ES REQUERIDA', 'type' => 'warning'); } elseif (empty($descripcion)) { $res = array('msg' => 'LA DESCRIPCION ES REQUERIDO', 'type' => 'warning'); } else { $egresoActual = $this->model->getEgreso($id, $this->id_sucursal); if (empty($egresoActual)) { $res = array('msg' => 'EGRESO NO ENCONTRADO', 'type' => 'error'); } else { $foto = isset($_FILES['foto']) ? $_FILES['foto'] : null; $destino = $egresoActual['foto']; if ($foto && !empty($foto['name'])) { if (!empty($destino) && file_exists($destino)) { unlink($destino); } $fecha = date('YmdHis'); $destino = 'assets/images/gastos/' . $fecha . '.jpg'; } $subtotalDb = number_format($subtotal, 2, '.', ''); $ivaMontoDb = number_format($ivaMonto, 2, '.', ''); $retencionMontoDb = number_format($retencionMonto, 2, '.', ''); $montoFinalDb = number_format($montoFinal, 2, '.', ''); $data = $this->model->actualizarEgreso($montoFinalDb, $subtotalDb, $aplicaIva, $ivaMontoDb, $retencionMontoDb, $codigoCuenta, $categoria, $subcategoria, $descripcion, $destino, $id, $this->id_sucursal); if ($data == 1) { if ($foto && !empty($foto['name'])) { move_uploaded_file($foto['tmp_name'], $destino); } $res = array('msg' => 'EGRESO MODIFICADO', 'type' => 'success'); } else { $res = array('msg' => 'ERROR AL MODIFICAR EGRESO', 'type' => 'error'); } } } } else { $res = array('msg' => 'DATOS INCOMPLETOS', 'type' => 'warning'); } echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function resumenDetalles() { $response = [ 'subtotal' => '0.00', 'iva' => '0.00', 'total' => '0.00' ]; if (verificar('ver_gastos')) { $desde = !empty($_GET['desde']) ? $_GET['desde'] : null; $hasta = !empty($_GET['hasta']) ? $_GET['hasta'] : null; $data = $this->model->getEgresos($this->id_sucursal, $desde, $hasta); $sumSubtotal = 0; $sumIva = 0; $sumTotal = 0; foreach ($data as $row) { // Misma logica que en listar() $subt = isset($row['subtotal']) ? (float)$row['subtotal'] : 0; $iva = isset($row['iva_monto']) ? (float)$row['iva_monto'] : 0; $ret = isset($row['retencion_monto']) ? (float)$row['retencion_monto'] : 0; $t = isset($row['monto']) ? (float)$row['monto'] : 0; if ($subt <= 0 && $t > 0) { if ($iva > 0 || $ret > 0) { $subt = max(0, ($t - $iva) + $ret); } else { $subt = $t; } } $sumSubtotal += $subt; $sumIva += $iva; $sumTotal += $t; } $response['subtotal'] = number_format($sumSubtotal, 2, '.', ''); $response['iva'] = number_format($sumIva, 2, '.', ''); $response['total'] = number_format($sumTotal, 2, '.', ''); } echo json_encode($response, JSON_UNESCAPED_UNICODE); die(); } public function eliminar($id) { if (!verificar('eliminar_gastos')) { echo json_encode(['msg' => 'NO TIENES PERMISOS', 'type' => 'error']); die(); } if (!isset($id) || !is_numeric($id)) { echo json_encode(['msg' => 'ID NO VÁLIDO', 'type' => 'error']); die(); } $egreso = $this->model->getEgreso($id, $this->id_sucursal); if (empty($egreso)) { echo json_encode(['msg' => 'EGRESO NO ENCONTRADO', 'type' => 'error']); die(); } $data = $this->model->eliminarEgreso($id, $this->id_sucursal); if ($data == 1) { if (!empty($egreso['foto']) && file_exists($egreso['foto'])) { unlink($egreso['foto']); } $res = array('msg' => 'EGRESO ELIMINADO', 'type' => 'success'); } else { $res = array('msg' => 'ERROR AL ELIMINAR EGRESO', 'type' => 'error'); } echo json_encode($res, JSON_UNESCAPED_UNICODE); die(); } public function ticket($id) { if (!verificar('ver_gastos')) { echo 'NO TIENES PERMISOS'; exit; } if (!isset($id) || !is_numeric($id)) { echo 'ID NO VÁLIDO'; exit; } $egreso = $this->model->getEgresoTicket($id, $this->id_sucursal); if (empty($egreso)) { echo 'EGRESO NO ENCONTRADO'; exit; } $data['title'] = 'Ticket de Egreso'; $data['empresa'] = $this->model->getEmpresa($this->id_sucursal); $data['egreso'] = $egreso; $data['moneda'] = MONEDA; ob_start(); $this->views->getView('egresos', 'ticket', $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); $ticket = TICKETEGRESO; $width_mm = $ticket['width']; $height_mm = $ticket['height']; $width_pt = mmToPoints($width_mm); $height_pt = mmToPoints($height_mm); $dompdf->setPaper([0, 0, $width_pt, $height_pt]); $dompdf->render(); $dompdf->stream('ticket_egreso.pdf', ['Attachment' => false]); } }
Coded With 💗 by
0x6ick