mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadida funcionalidad de albaran anonimo y corregidos bugs
This commit is contained in:
@ -575,6 +575,7 @@ $routes->group(
|
||||
function ($routes) {
|
||||
$routes->get('index/(:num)', 'PrintAlbaranes::index/$1', ['as' => 'viewAlbaranPDF']);
|
||||
$routes->get('generar/(:num)', 'PrintAlbaranes::generar/$1', ['as' => 'albaranToPdf']);
|
||||
$routes->get('generar-anonimo/(:num)', 'PrintAlbaranes::generarAnonimo/$1', ['as' => 'albaranAnonimoToPdf']);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -71,4 +71,55 @@ class PrintAlbaranes extends BaseController
|
||||
->setHeader('Content-Length', strlen($output))
|
||||
->setBody($output);
|
||||
}
|
||||
|
||||
public function generarAnonimo($albaran_id)
|
||||
{
|
||||
|
||||
// Cargar modelos
|
||||
$albaranModel = model('App\Models\Albaranes\AlbaranModel');
|
||||
$lineasAlbaranModel = model('App\Models\Albaranes\AlbaranLineaModel');
|
||||
|
||||
// Informacion del presupuesto
|
||||
$data['albaran'] = $albaranModel->getResourceForPdf($albaran_id)->get()->getRow();
|
||||
$data['albaranLineas'] = $lineasAlbaranModel->getResourceForPdf($albaran_id)->get()->getResultObject();
|
||||
|
||||
|
||||
// Obtener contenido HTML de la vista
|
||||
$html = view(getenv('theme.path') . 'pdfs/albaran-anonimo', $data);
|
||||
|
||||
// Cargar CSS desde archivo local
|
||||
$css = file_get_contents(FCPATH . 'themes/vuexy/css/pdf.albaran.css');
|
||||
// Combinar CSS y HTML
|
||||
$html_con_css = "<style>$css</style>" . $html;
|
||||
|
||||
// Crear una instancia de Dompdf
|
||||
$options = new \Dompdf\Options();
|
||||
$options->set('isHtml5ParserEnabled', true);
|
||||
$options->set('isPhpEnabled', true);
|
||||
$options->set('isRemoteEnabled', true);
|
||||
$dompdf = new \Dompdf\Dompdf($options);
|
||||
|
||||
// Contenido HTML del documento
|
||||
$dompdf->loadHtml($html_con_css);
|
||||
|
||||
// Establecer el tamaño del papel
|
||||
$dompdf->setPaper('A4', 'portrait');
|
||||
|
||||
// Renderizar el PDF
|
||||
$dompdf->render();
|
||||
|
||||
// Obtener el contenido generado
|
||||
$output = $dompdf->output();
|
||||
|
||||
// Establecer las cabeceras para visualizar en lugar de descargar
|
||||
$file_name = "alabaran-$albaran_id.pdf";
|
||||
return $this->response
|
||||
->setStatusCode(200)
|
||||
->setHeader('Content-Type', 'application/pdf')
|
||||
->setHeader('Content-Disposition', 'inline; filename="' . $file_name . '"')
|
||||
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
|
||||
->setHeader('Pragma', 'public')
|
||||
->setHeader('Content-Length', strlen($output))
|
||||
->setBody($output);
|
||||
}
|
||||
}
|
||||
@ -28,6 +28,7 @@ return [
|
||||
'addIva' => 'Añadir IVA',
|
||||
'nuevaLinea' => 'Nueva línea',
|
||||
'imprimirAlbaran' => 'Imprimir albarán',
|
||||
'imprimirAlbaranAnonimo' => 'Imprimir albarán anónimo',
|
||||
'borrarAlbaran' => 'Borrar albarán',
|
||||
'borrarAlbaranConfirm' => '¿Está seguro de que desea borrar el albarán?',
|
||||
'borrar' => 'Borrar',
|
||||
|
||||
137
ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php
Normal file
137
ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php
Normal file
@ -0,0 +1,137 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/font-pdf.css') ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/pdf.albaran.css') ?>">
|
||||
<style>
|
||||
@page {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.espaciado-superior {
|
||||
margin-top: 80px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="body-class">
|
||||
<?php $mostrarPrecios = $albaran->mostrar_precios == 1; ?>
|
||||
|
||||
<div class="espaciado-superior"></div>
|
||||
|
||||
<table class="table table-striped lineas">
|
||||
<thead>
|
||||
<tr class="head-lineas">
|
||||
<th class="text-center num_unidades">Nº Unid.</th>
|
||||
<th class="concepto">Pedido</th>
|
||||
<th class="concepto">Título</th>
|
||||
<th class="concepto">ISBN</th>
|
||||
<th class="concepto">Ref. Cliente</th>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<th class="precio_unidad">€/ud.</th>
|
||||
<th class="subtotal">Subtotal</th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$total = 0;
|
||||
$total_precio = 0;
|
||||
foreach ($albaranLineas as $linea):
|
||||
?>
|
||||
|
||||
<?php
|
||||
$total += 1;
|
||||
$total_precio += $linea->total;
|
||||
?>
|
||||
<tr>
|
||||
<td class="text-center num_unidades">
|
||||
<?= $linea->unidades ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?= $linea->pedido ?>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->titulo ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->isbn ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->ref_cliente ?></div>
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="precio_unidad">
|
||||
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
||||
<div><?= number_format($linea->precio_unidad, 4, ',', '.') ?></div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="subtotal">
|
||||
<div><?= number_format($linea->total, 2, ',', '.') ?></div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($total < 5): ?>
|
||||
<?php for ($i = $total; $i < 7; $i++): ?>
|
||||
<tr>
|
||||
<td class="num_unidades">
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="precio_unidad">
|
||||
<div></div>
|
||||
</td>
|
||||
<td class="subtotal">
|
||||
<div></div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endfor; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table style="padding: 5px" class="total">
|
||||
<tr>
|
||||
<td class="intro_recibi">
|
||||
RECIBÍ
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="intro_total">
|
||||
TOTAL
|
||||
</td>
|
||||
<td class="subtotal">
|
||||
<?= ($total_precio) ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -192,6 +192,9 @@ class AlbaranComponent {
|
||||
<button id="imprimir_albaran_${id}" class="imprimir-albaran btn btn-sm btn-light" type="button">
|
||||
${window.language.Albaran.imprimirAlbaran} <i class="ti ti-printer"></i>
|
||||
</button>
|
||||
<button id="imprimir_albaran_anonimo_${id}" class="imprimir-albaran btn btn-sm btn-light" type="button">
|
||||
${window.language.Albaran.imprimirAlbaranAnonimo} <i class="ti ti-printer"></i>
|
||||
</button>
|
||||
<button id="borrar_albaran_${id}" class="borrar-albaran btn btn-sm btn-danger" type="button">
|
||||
${window.language.Albaran.borrarAlbaran} <i class="ti ti-trash"></i>
|
||||
</button>
|
||||
@ -600,7 +603,14 @@ class AlbaranComponent {
|
||||
var albaran_id = this.id;
|
||||
window.open('/print-albaran/generar/'+ albaran_id , '_blank');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('#imprimir_albaran_anonimo_' + this.id).on('click', (e) => {
|
||||
|
||||
var albaran_id = this.id;
|
||||
window.open('/print-albaran/generar-anonimo/'+ albaran_id , '_blank');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
_initAutoNumericInputs() {
|
||||
|
||||
Reference in New Issue
Block a user