mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into feat/xml-pedido
This commit is contained in:
@ -701,6 +701,15 @@ $routes->group(
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'print-factura',
|
||||
['namespace' => 'App\Controllers\Pdf'],
|
||||
function ($routes) {
|
||||
$routes->get('index/(:num)', 'PrintFacturas::index/$1', ['as' => 'viewFacturaPDF']);
|
||||
$routes->get('generar/(:num)', 'PrintFacturas::generar/$1', ['as' => 'facturaToPdf']);
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'export-giros',
|
||||
['namespace' => 'App\Controllers\Excel'],
|
||||
@ -709,6 +718,14 @@ $routes->group(
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'export-lineas',
|
||||
['namespace' => 'App\Controllers\Excel'],
|
||||
function ($routes) {
|
||||
$routes->get('generar/(:num)', 'PrintLineas::generateExcel/$1', ['as' => 'lineasToExcel']);
|
||||
}
|
||||
);
|
||||
|
||||
$routes->group(
|
||||
'buscadorpresupuestos',
|
||||
['namespace' => 'App\Controllers\Presupuestos'],
|
||||
|
||||
70
ci4/app/Controllers/Excel/PrintLineas.php
Normal file
70
ci4/app/Controllers/Excel/PrintLineas.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Excel;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
|
||||
class PrintLineas extends BaseController
|
||||
{
|
||||
public function generateExcel($factura_id = null)
|
||||
{
|
||||
|
||||
// Modelos
|
||||
$lineasFacturaModel = model('App\Models\Facturas\FacturaLineaModel');
|
||||
$infoLineasFactura = $lineasFacturaModel->getResourceForExcel($factura_id)->get()->getResultObject();
|
||||
|
||||
|
||||
// Crear un nuevo Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Especificar encabezados
|
||||
$headers = [
|
||||
'Factura',
|
||||
'ID Pedido',
|
||||
'Ref. Cliente',
|
||||
'Base'
|
||||
];
|
||||
|
||||
// Establecer los encabezados en la primera fila
|
||||
$column = 'A';
|
||||
foreach ($headers as $header) {
|
||||
$sheet->setCellValue($column . '1', $header);
|
||||
$column++;
|
||||
}
|
||||
|
||||
// Rellenar las filas con datos
|
||||
$rowNumber = 2; // Empezar en la segunda fila
|
||||
foreach ($infoLineasFactura as $infoLineaFactura) {
|
||||
$column = 'A';
|
||||
foreach ($infoLineaFactura as $cell) {
|
||||
$sheet->setCellValue($column . $rowNumber, $cell);
|
||||
$column++;
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
// Ajustar automáticamente el tamaño de las columnas
|
||||
foreach (range('A', $column) as $col) {
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Crear un escritor para guardar el archivo
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
// Configurar la respuesta para descarga
|
||||
$fileName = 'lineas-pedido.xlsx';
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="' . $fileName . '"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
// Escribir el archivo a la salida
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
65
ci4/app/Controllers/Pdf/PrintFacturas.php
Normal file
65
ci4/app/Controllers/Pdf/PrintFacturas.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Pdf;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
|
||||
class PrintFacturas extends BaseController
|
||||
{
|
||||
|
||||
public function index($id_factura)
|
||||
{
|
||||
|
||||
$facturaModel = model('App\Models\Facturas\FacturaModel');
|
||||
$lineasFacturaModel = model('App\Models\Facturas\FacturaLineaModel');
|
||||
$data['factura'] = $facturaModel->getResourceForPdf($id_factura)->get()->getRow();
|
||||
$data['lineas_factura'] = $lineasFacturaModel->getResourceForPdf($id_factura)->get()->getResultObject();
|
||||
$data['resumen_por_iva'] = $lineasFacturaModel->getResourceResumenIVAsForPdf($id_factura)->get()->getResultObject();
|
||||
|
||||
return view(getenv('theme.path') . 'pdfs/factura', $data);
|
||||
}
|
||||
|
||||
public function generar($id_factura)
|
||||
{
|
||||
|
||||
// Cargar modelos
|
||||
$facturaModel = model('App\Models\Facturas\FacturaModel');
|
||||
$lineasFacturaModel = model('App\Models\Facturas\FacturaLineaModel');
|
||||
|
||||
// Informacion del presupuesto
|
||||
$data['factura'] = $facturaModel->getResourceForPdf($id_factura)->get()->getRow();
|
||||
$data['lineas_factura'] = $lineasFacturaModel->getResourceForPdf($id_factura)->get()->getResultObject();
|
||||
$data['resumen_por_iva'] = $lineasFacturaModel->getResourceResumenIVAsForPdf($id_factura)->get()->getResultObject();
|
||||
|
||||
// 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(view(getenv('theme.path').'pdfs/factura', $data));
|
||||
|
||||
// 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 = $data['factura']->numero . ".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);
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datosPresupuesto->tapa = 'blanda';
|
||||
|
||||
$datosPresupuesto->clienteList = $this->getClienteListItems($clienteId ?? null);
|
||||
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20 , 16];
|
||||
$presupuestoEntity->estado_id = 1;
|
||||
$presupuestoEntity->paginas_por_cuadernillo = 32;
|
||||
|
||||
$this->viewData['formAction'] = 'add';
|
||||
|
||||
@ -185,6 +187,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if($presupuestoEntity->estado_id == 2){
|
||||
$this->generarResumen($presupuestoEntity);
|
||||
}
|
||||
|
||||
$datosPresupuesto->paginasCuadernillo = [32, 28, 24, 20 , 16];
|
||||
$presupuestoEntity->paginas_por_cuadernillo = $this->obtenerPaginasCuadernillo($presupuestoEntity);
|
||||
|
||||
$this->viewData['formAction'] = 'edit';
|
||||
|
||||
@ -371,6 +376,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$servicios = $reqData['servicios'] ?? [];
|
||||
|
||||
$paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null;
|
||||
|
||||
$datos_presupuesto = array(
|
||||
'tirada' => $tirada,
|
||||
'tamanio' => $tamanio,
|
||||
@ -378,6 +385,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'clienteId' => $cliente_id,
|
||||
'isColor' => $isColor,
|
||||
'isHq' => $isHq,
|
||||
'paginasCuadernillo' => $paginasCuadernillo,
|
||||
|
||||
'interior' => array(
|
||||
'papel_generico' => $papel_generico,
|
||||
@ -600,6 +608,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$cliente_id = $reqData['datos_libro']['clienteId'] ?? -1;
|
||||
$isColor = intval($reqData['datos_libro']['isColor']) ?? 0;
|
||||
$isHq = intval($reqData['datos_libro']['isHq']) ?? 0;
|
||||
$paginasCuadernillo = $reqData['datos_libro']['paginasCuadernillo'] ?? null;
|
||||
|
||||
// Interior
|
||||
$papel_generico = [
|
||||
@ -637,6 +646,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'clienteId' => $cliente_id,
|
||||
'isColor' => $isColor,
|
||||
'isHq' => $isHq,
|
||||
'paginasCuadernillo' => $paginasCuadernillo,
|
||||
|
||||
'interior' => array(
|
||||
'papel_generico' => $papel_generico,
|
||||
@ -983,6 +993,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'precio_unidad' => $servicio->precio_unidad,
|
||||
'margen' => $servicio->margen,
|
||||
];
|
||||
|
||||
// Se comprueba que $servicio tiene paginasCuadernillo
|
||||
if (isset($servicio->paginas_por_cuadernillo)) {
|
||||
$data['paginas_por_cuadernillo'] = $servicio->paginas_por_cuadernillo;
|
||||
}
|
||||
|
||||
$model->insert($data);
|
||||
} else if ($tipo == 'extra') {
|
||||
$model = new PresupuestoServiciosExtraModel();
|
||||
@ -1086,6 +1102,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$cliente_id = $datos_entrada['clienteId'] ?? -1;
|
||||
$isColor = $datos_entrada['isColor'];
|
||||
$isHq = $datos_entrada['isHq'];
|
||||
$paginasCuadernillo = $datos_entrada['paginasCuadernillo'] ?? null;
|
||||
|
||||
// Interior
|
||||
$papel_generico = $datos_entrada['interior']['papel_generico'];
|
||||
@ -1429,6 +1446,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'alto' => $datosPedido->alto,
|
||||
'POD' => $POD,
|
||||
'solapas' => intval($solapasCubierta) > 0 ? 1 : 0,
|
||||
'paginasCuadernillo' => $paginasCuadernillo,
|
||||
]);
|
||||
$costeServiciosDefecto = 0.0;
|
||||
foreach ($servDefecto as $servicio) {
|
||||
@ -1996,4 +2014,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$tipo = "" . ($isColor ? "Color" : "Negro") . " " . ($isHq ? "premium" : "estándar");
|
||||
return $tipo;
|
||||
}
|
||||
|
||||
protected function obtenerPaginasCuadernillo($presupuestoEntity){
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
$lineas = $model->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||
|
||||
foreach ($lineas as $linea){
|
||||
// check if exist
|
||||
if($linea->paginas_por_cuadernillo != null)
|
||||
return $linea->paginas_por_cuadernillo;
|
||||
}
|
||||
return 32; // valor por defecto
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,6 +118,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
$alto = $reqData['alto'] ?? 0;
|
||||
|
||||
$POD = $reqData['POD'] ?? 0;
|
||||
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? null;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -125,7 +126,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
if(is_null($tipo)){
|
||||
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD);
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
||||
}else{
|
||||
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"tarifa_encuadernado_id" => null,
|
||||
"proveedor_id" => null,
|
||||
"precio_unidad" => null,
|
||||
"paginas_por_cuadernillo" => null,
|
||||
"tiempo" => null,
|
||||
"precio_total" => null,
|
||||
"margen" => null,
|
||||
@ -22,6 +23,7 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"tarifa_encuadernado_id" => "int",
|
||||
"proveedor_id" => "int",
|
||||
"precio_unidad" => "float",
|
||||
"paginas_por_cuadernillo" => "int",
|
||||
"tiempo" => "float",
|
||||
"precio_total" => "float",
|
||||
"margen" => "float",
|
||||
|
||||
@ -247,6 +247,7 @@ return [
|
||||
'precio' => 'Precio',
|
||||
'precioUnidad' => 'Precio unidad',
|
||||
'tiempo' => 'Tiempo',
|
||||
"paginasCuadernillo" => "Páginas/cuadernillo",
|
||||
'precioTotal' => 'Precio total',
|
||||
'serviciosDefault' => 'Servicios por defecto',
|
||||
'tarifa' => 'Tarifa',
|
||||
|
||||
@ -6,8 +6,8 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Acabado Líneas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
|
||||
@ -6,8 +6,8 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Manipulado Lineas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
|
||||
@ -10,8 +10,8 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifas Encuadernación',
|
||||
'nombre' => 'Nombre',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
'tarifaencuadernacion' => 'Tarifa Encuadernación',
|
||||
'tarifaencuadernacionList' => 'Lista Tarifas Encuadernación',
|
||||
|
||||
@ -10,8 +10,8 @@ return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifas Manipulado',
|
||||
'nombre' => 'Nombre',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioMax' => 'Precio T. Mín',
|
||||
'precioMin' => 'Precio T. Máx',
|
||||
'importeFijo' => 'Importe Fijo',
|
||||
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',
|
||||
'tarifamanipulado' => 'Tarifa Manipulado',
|
||||
|
||||
@ -54,6 +54,76 @@ class FacturaLineaModel extends \App\Models\BaseModel {
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getResourceResumenIVAsForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.iva,
|
||||
ROUND(SUM(t1.base), 2) AS base,
|
||||
ROUND(SUM(t1.total_iva), 2) AS total_iva,
|
||||
ROUND(SUM(t1.total), 2) AS total"
|
||||
)
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null)
|
||||
->groupBy('t1.iva')
|
||||
->orderBy('t1.iva', 'ASC'); // Ordena por iva en forma ascendente
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.factura_id AS factura_id,
|
||||
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
|
||||
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
|
||||
t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data"
|
||||
)
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForExcel($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.numero AS ref_factura,
|
||||
t3.pedido_id AS pedido_id,
|
||||
t4.referencia_cliente AS referencia_cliente,
|
||||
t1.base AS base"
|
||||
)
|
||||
->join("facturas t2", "t2.id = t1.factura_id", "left")
|
||||
->join("pedidos_linea t3", "t3.id = t1.pedido_linea_impresion_id", "left")
|
||||
->join("presupuestos t4", "t4.id = t3.presupuesto_id", "left")
|
||||
->where("t1.factura_id", $factura_id)
|
||||
->where("t1.deleted_at", null);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function addFacturaPedidoLinea($factura_id, $pedido_linea_id, $cantidad)
|
||||
{
|
||||
$data = [
|
||||
|
||||
@ -102,6 +102,41 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($factura_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.numero AS numero, DATE_FORMAT(t1.fecha_factura_at, '%d/%m/%Y') AS fecha_factura_at,
|
||||
t1.base AS base, t1.total AS total, t1.pendiente AS pendiente,
|
||||
t1.creditoAsegurado AS creditoAsegurado, t1.estado AS estado, t1.estado_pago AS estado_pago,
|
||||
t4.nombre AS forma_pago,
|
||||
DATE_FORMAT(MIN(CASE WHEN t3.fecha_vencimiento_at != '0000-00-00 00:00:00' THEN t3.fecha_vencimiento_at ELSE NULL END), '%d/%m/%Y') AS vencimiento,
|
||||
t2.nombre AS cliente, t2.direccion AS cliente_direccion, t2.ciudad AS cliente_ciudad,
|
||||
t2.cp AS cliente_cp, t2.cif AS cliente_cif, t2.vencimiento AS dias_vencimiento, t2.ccc AS cliente_ccc,
|
||||
t5.nombre AS cliente_pais"
|
||||
);
|
||||
|
||||
$builder->join("clientes t2", "t2.id = t1.cliente_id", "left");
|
||||
$builder->join("facturas_pagos t3", "t3.factura_id = t1.id", "left");
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
$builder->join("lg_paises t5", "t2.pais_id = t5.id", "left");
|
||||
|
||||
$builder->where("t1.id", $factura_id);
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function getResourcePedidos($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
|
||||
@ -21,7 +21,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
4 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "tiempo", "margen"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "proveedor_id", "nombre", "precio_total", "precio_unidad", "paginas_por_cuadernillo", "tiempo", "margen"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -48,7 +48,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
|
||||
|
||||
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $paginas, $ancho, $alto, $POD){
|
||||
public function initPresupuesto($tipo_presupuesto, $solapas, $tirada, $paginas, $ancho, $alto, $POD, $paginasCuadernillo = 32){
|
||||
|
||||
$model = model('App\Models\Presupuestos\TipoPresupuestoServiciosDefectoModel');
|
||||
$tarifas_procesar = $model->get_tarifas($tipo_presupuesto, $solapas, "encuadernacion");
|
||||
@ -60,7 +60,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
|
||||
if($modelTarifa->isTarifaPorHoras($tarifa['tarifa_id'])){
|
||||
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
if($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14){ // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginasCuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
else{
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa['tarifa_id'], $tiempo, $tirada);
|
||||
if (count($tarifa_value)>0) {
|
||||
@ -76,8 +81,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||
|
||||
array_push($result_array,
|
||||
(object)[
|
||||
$datos = [
|
||||
'tarifa_id'=> $tarifa['tarifa_id'],
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
@ -86,7 +90,14 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
'proveedor_id' => $tarifa_proveedor->proveedor_id,
|
||||
]);
|
||||
];
|
||||
|
||||
if($tarifa['tarifa_id'] == 2 || $tarifa['tarifa_id'] == 14){
|
||||
$datos['paginas_por_cuadernillo'] = $paginasCuadernillo;
|
||||
}
|
||||
|
||||
array_push($result_array,
|
||||
(object)$datos);
|
||||
}
|
||||
|
||||
usort($result_array, function($a, $b) {
|
||||
@ -237,11 +248,16 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD){
|
||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo = null){
|
||||
|
||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
if($tarifa_encuadernacion_id == 2 || $tarifa_encuadernacion_id == 14){ // Rústica cosido hilo vegetal y Rústica cosido hilo vegetal solapas
|
||||
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginas_cuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
else{
|
||||
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||
}
|
||||
|
||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada, $proveedor_id);
|
||||
if (count($tarifa_value)>0) {
|
||||
@ -256,6 +272,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||
$result_data[1] = $precio_total;
|
||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||
|
||||
|
||||
array_push($ret_array,
|
||||
(object)[
|
||||
@ -263,6 +280,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
|
||||
'precio_unidad'=> $result_data[0],
|
||||
'tiempo' => $tiempo,
|
||||
'paginas_por_cuadernillo' => $paginas_cuadernillo,
|
||||
'total'=> $result_data[1],
|
||||
'margen' => $result_data[2],
|
||||
'proveedor' => $tarifa_proveedor->proveedor_nombre,
|
||||
@ -287,6 +305,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||
'precio_unidad'=> 0,
|
||||
'tiempo' => null,
|
||||
'paginas_por_cuadernillo' => null,
|
||||
'total'=> 0,
|
||||
'margen' => 0,
|
||||
];
|
||||
@ -355,6 +374,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$builder->where('presupuesto_id', $presupuesto_id);
|
||||
$builder->where('tarifa_encuadernado_id', $tarifa->tarifa_id);
|
||||
$result = $builder->get()->getResultObject();
|
||||
$paginas_cuadernillo = $tarifa->paginas_por_cuadernillo??null;
|
||||
if(count($result)>0){
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
@ -365,6 +385,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
->set('tiempo', $tarifa->tiempo)
|
||||
->set('precio_total', $tarifa->precio_total)
|
||||
->set('margen', $tarifa->margen)
|
||||
->set('paginas_por_cuadernillo', $paginas_cuadernillo)
|
||||
->update();
|
||||
|
||||
|
||||
@ -397,7 +418,8 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_encuadernado_id AS tarifa_encuadernado_id, t1.precio_unidad AS precio_unidad, t1.tiempo AS tiempo,
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor"
|
||||
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,
|
||||
t1.paginas_por_cuadernillo AS paginas_por_cuadernillo"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
@ -415,4 +437,13 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id);
|
||||
return round($cuadernillos_pedido/($velocidad*60.0), 2);
|
||||
}
|
||||
|
||||
private function calcularTiempoCosido($maquina_id, $paginas, $tirada, $cuadernillos_por_pagina = 32){
|
||||
|
||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
||||
$velocidad = $maquinaModel->getVelocidad($maquina_id); // cuadernillos por minuto
|
||||
$cuadernillos_libro = ceil($paginas/intval($cuadernillos_por_pagina));
|
||||
$cuadernillos_pedido = $cuadernillos_libro*$tirada;
|
||||
return round($cuadernillos_pedido/($velocidad*60.0), 2); // tiempo en segundos
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,9 +341,10 @@ class PresupuestoClienteService extends BaseService
|
||||
$alto = $data['alto'] ?? -1;
|
||||
$POD = $data['POD'] ?? -1;
|
||||
$solapas = $data['solapas'] ?? -1;
|
||||
$paginasCuadernillo = $data['paginasCuadernillo'] ?? null;
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
$values = $model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD);
|
||||
$values = $model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD, $paginasCuadernillo);
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
@ -1421,12 +1421,14 @@ class PresupuestoService extends BaseService
|
||||
// Si es un presupuesto duplicado hay que buscar el proveedor más barato
|
||||
if($input_data['is_duplicado']){
|
||||
if($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)){
|
||||
$paginas_cuadernillo = $servicio->paginas_por_cuadernillo??null;
|
||||
$nueva_tarifa = $model->getPrecioTarifaHoras(
|
||||
$servicio->tarifa_encuadernado_id,
|
||||
$input_data['paginas'],
|
||||
$input_data['tirada'],
|
||||
-1,
|
||||
$input_data['POD']);
|
||||
$input_data['POD'],
|
||||
$paginas_cuadernillo);
|
||||
}else{
|
||||
$nueva_tarifa = $model->getPrecioTarifa(
|
||||
$servicio->tarifa_encuadernado_id,
|
||||
@ -1443,12 +1445,14 @@ class PresupuestoService extends BaseService
|
||||
// con el mismo proveedor
|
||||
else{
|
||||
if($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)){
|
||||
$paginas_cuadernillo = $servicio->paginas_por_cuadernillo??null;
|
||||
$nueva_tarifa = $model->getPrecioTarifaHoras(
|
||||
$servicio->tarifa_encuadernado_id,
|
||||
$input_data['paginas'],
|
||||
$input_data['tirada'],
|
||||
$servicio->proveedor_id,
|
||||
$input_data['POD']);
|
||||
$input_data['POD'],
|
||||
$paginas_cuadernillo);
|
||||
}else{
|
||||
$nueva_tarifa = $model->getPrecioTarifa(
|
||||
$servicio->tarifa_encuadernado_id,
|
||||
|
||||
@ -191,15 +191,15 @@
|
||||
<?= lang("Basic.global.edit") ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-label-primary float-start me-sm-3 me-1"
|
||||
name="exportar_lineas"
|
||||
id="exportar_lineas" >
|
||||
<span class="ti-xs ti ti-file-spreadsheet me-1"></span>
|
||||
<?= lang("Facturas.exportarLineas") ?>
|
||||
</button>
|
||||
|
||||
<?= anchor(
|
||||
route_to("lineasToExcel", $facturaEntity->id),
|
||||
'<span class="ti-xs ti ti-file-spreadsheet me-1"></span>' .
|
||||
lang("Facturas.exportarLineas"),
|
||||
[
|
||||
"class" => "btn btn-label-primary float-start me-sm-3 me-1",
|
||||
]
|
||||
) ?>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@ -44,13 +44,21 @@
|
||||
value="<?= lang("Facturas.borrarFactura") ?>"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
<input type="button"
|
||||
class="btn btn-info float-start me-sm-3 me-1"
|
||||
id="imprimirFactura"
|
||||
name="imprimirFactura"
|
||||
value="<?= lang("Facturas.imprimirFactura") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("facturasList"), lang("Basic.global.back"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
<?= anchor(
|
||||
route_to("facturaToPdf", $facturaEntity->id),
|
||||
lang("Facturas.imprimirFactura"),
|
||||
[
|
||||
"class" => "btn btn-info float-start me-sm-3 me-1",
|
||||
"target" => "_blank"
|
||||
]
|
||||
) ?>
|
||||
<?= anchor(
|
||||
route_to("facturasList"),
|
||||
lang("Basic.global.back"),
|
||||
[
|
||||
"class" => "btn btn-secondary float-start"
|
||||
]
|
||||
) ?>
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
|
||||
@ -78,11 +78,60 @@
|
||||
pageLength: 250,
|
||||
lengthChange: true,
|
||||
"dom": 'lfBrtip',
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
buttons: [
|
||||
{
|
||||
text: 'Exportar Excel Contaplus',
|
||||
action: function (e, dt, button, config) {
|
||||
var searchValue = theTable.search(); // Captura el valor del campo de búsqueda
|
||||
var ajaxParams = theTable.ajax.params(); // Captura otros parámetros de la tabla
|
||||
|
||||
console.log(searchValue);
|
||||
|
||||
/*
|
||||
$.ajax({
|
||||
url: '/ruta/exportarExcel', // URL del servidor para manejar la exportación
|
||||
type: 'POST',
|
||||
data: {
|
||||
search: searchValue,
|
||||
extraParams: ajaxParams
|
||||
},
|
||||
xhrFields: {
|
||||
responseType: 'blob' // Para manejar la descarga del archivo
|
||||
},
|
||||
success: function(blob, status, xhr) {
|
||||
// Crear un enlace temporal para descargar el archivo
|
||||
var link = document.createElement('a');
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
link.href = url;
|
||||
link.download = 'datos_personalizados.xlsx';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Exportar Lineas a Excel',
|
||||
action: function (e, dt, button, config) {
|
||||
var searchValue = theTable.search(); // Captura el valor del campo de búsqueda
|
||||
var ajaxParams = theTable.ajax.params(); // Captura otros parámetros de la tabla
|
||||
|
||||
console.log(searchValue);
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Exportar Girosgit ',
|
||||
action: function (e, dt, button, config) {
|
||||
var searchValue = theTable.search(); // Captura el valor del campo de búsqueda
|
||||
var ajaxParams = theTable.ajax.params(); // Captura otros parámetros de la tabla
|
||||
|
||||
console.log(searchValue);
|
||||
|
||||
}
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
|
||||
@ -173,7 +173,7 @@ theTable = $('#tableOfPresupuestos').DataTable({
|
||||
}
|
||||
],
|
||||
stateSave: false,
|
||||
order: [[1, 'asc']],
|
||||
order: [[1, 'desc']],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
|
||||
@ -128,6 +128,21 @@
|
||||
<input type="number" class="calcular-presupuesto" id="paginas" name="paginas" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->paginas) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div id="div_pagCuadernillo" class="col-sm-3 mb-3">
|
||||
<label for="paginas_por_cuadernillo" class="form-label">
|
||||
<?= lang('Presupuestos.paginasCuadernillo') ?>
|
||||
</label>
|
||||
<select id="paginasCuadernillo" name="paginas_por_cuadernillo" class="calcular-presupuesto form-control select2bs2" style="width: 100%;">
|
||||
<?php if (isset($datosPresupuesto->paginasCuadernillo) && is_array($datosPresupuesto->paginasCuadernillo) && !empty($datosPresupuesto->paginasCuadernillo)) :
|
||||
foreach ($datosPresupuesto->paginasCuadernillo as $value) : ?>
|
||||
<option value="<?= $value ?>" <?= $value == $presupuestoEntity->paginas_por_cuadernillo ? ' selected' : '' ?>>
|
||||
<?= $value ?>
|
||||
</option>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
</select>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div> <!--//.row -->
|
||||
|
||||
<div class="row">
|
||||
|
||||
@ -646,11 +646,18 @@ async function calcularPresupuesto() {
|
||||
clienteId: $('#clienteId').val(),
|
||||
servicios: servicios,
|
||||
}
|
||||
|
||||
// Si es cosido, se añade el número de páginas del cuadernillo
|
||||
if ($('#cosidoDiv').hasClass('checked')) {
|
||||
datos.paginasCuadernillo = $('#paginasCuadernillo').val();
|
||||
}
|
||||
// Si hay solapas de cubierta
|
||||
if ($('#solapasCubierta').is(':checked')) {
|
||||
datos.solapasCubierta = $('#anchoSolapasCubierta').val()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Si hay sobrecubierta
|
||||
if ($('#enableSobrecubierta').is(':checked')) {
|
||||
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
|
||||
|
||||
@ -218,6 +218,12 @@ function finalizarPresupuesto(confirmar){
|
||||
clienteId: $('#clienteId').val(),
|
||||
servicios: servicios,
|
||||
};
|
||||
|
||||
// Si es cosido, se añade el número de páginas del cuadernillo
|
||||
if ($('#cosidoDiv').hasClass('checked')) {
|
||||
datos_libro.paginasCuadernillo = $('#paginasCuadernillo').val();
|
||||
}
|
||||
|
||||
// Si hay solapas de cubierta
|
||||
if ($('#solapasCubierta').is(':checked')) {
|
||||
datos_libro.solapasCubierta = $('#anchoSolapasCubierta').val()
|
||||
|
||||
@ -33,6 +33,12 @@ function updateTipoLibroCheck(el)
|
||||
else {
|
||||
$('#tapaDuraDiv').show();
|
||||
}
|
||||
if(el.closest('.custom-option-tipo').id == 'cosidoDiv') {
|
||||
$('#div_pagCuadernillo').show();
|
||||
}
|
||||
else {
|
||||
$('#div_pagCuadernillo').hide();
|
||||
}
|
||||
} else {
|
||||
el.closest('.custom-option-tipo').classList.remove('checked')
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ function init_servicio_encuadernado(){
|
||||
const tarifa_id = element.tarifa_encuadernado_id
|
||||
var proveedor_nombre = element.proveedor===null? window.Presupuestos.no_disponible: element.proveedor
|
||||
|
||||
tableServiciosEnc.row.add([
|
||||
var linea = [
|
||||
element.tarifa_encuadernado_id,
|
||||
element.nombre,
|
||||
'<select id="proveedor_enc_' + element.tarifa_encuadernado_id + '" class="proveedor_enc select2bs2" style="width: 100%;">' +
|
||||
@ -527,11 +527,14 @@ function init_servicio_encuadernado(){
|
||||
'</option>' +
|
||||
'</select>',
|
||||
'<span id="precio_unidad_encuadernado_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
|
||||
'<span id="tiempo_encuadernado_' + element.tiempo + '">' + convertirTiempo(element.tiempo) + '</span>',
|
||||
(element.hasOwnProperty('paginas_por_cuadernillo') && element.paginas_por_cuadernillo!=null)?selectForCuadernillos(element.tarifa_encuadernado_id, element.paginas_por_cuadernillo):'',
|
||||
'<span id="tiempo_encuadernado_' + element.tarifa_encuadernado_id + '">' + convertirTiempo(element.tiempo) + '</span>',
|
||||
'<input class="update-totales-servicios" id="precio_total_encuadernado_' + element.tarifa_encuadernado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<span style="display: none;" class="update-totales" id="enc_margen_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_encuadernado_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
]
|
||||
|
||||
tableServiciosEnc.row.add(linea).draw(false)
|
||||
|
||||
$('#precio_total_encuadernado_' + element.tarifa_encuadernado_id).on('change', function(){
|
||||
updatePresupuesto({
|
||||
@ -583,14 +586,40 @@ function init_servicio_encuadernado(){
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
$('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', proveedor_enc_event)
|
||||
$('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', select_enc_event)
|
||||
|
||||
if(element.hasOwnProperty('paginas_por_cuadernillo') && element.paginas_por_cuadernillo!=null){
|
||||
|
||||
$('#cuadernillos_' + element.tarifa_encuadernado_id).select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: -1,
|
||||
});
|
||||
|
||||
$('#cuadernillos_' + element.tarifa_encuadernado_id).on('change', select_enc_event)
|
||||
}
|
||||
|
||||
});
|
||||
check_serv_enc_error()
|
||||
|
||||
}
|
||||
|
||||
function selectForCuadernillos(tarifa_id, select_value){
|
||||
const value_list = [32, 28, 24, 20, 16];
|
||||
var string =
|
||||
'<select id="cuadernillos_' + tarifa_id + '" class="cuadernillo_enc select2bs2" style="width: 50%;">';
|
||||
|
||||
for (let i = 0; i < value_list.length; i++) {
|
||||
string +=
|
||||
'<option value="' + value_list[i] + '" ' + (value_list[i]==select_value?'selected':'') +'>' +
|
||||
value_list[i] +
|
||||
'</option>';
|
||||
}
|
||||
string += '</select>';
|
||||
return string;
|
||||
}
|
||||
|
||||
function convertirTiempo(horas){
|
||||
if(horas != null && horas.length>0){
|
||||
if(horas != null){
|
||||
if(parseFloat(horas)>0){
|
||||
const seconds = parseFloat(horas) * 3600;
|
||||
// se convierte a formato hh:mm:ss
|
||||
@ -598,32 +627,49 @@ function convertirTiempo(horas){
|
||||
const minutos = Math.floor((seconds % 3600) / 60);
|
||||
const segundos = seconds % 60;
|
||||
return h + ':' + minutos + ':' + segundos;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function proveedor_enc_event(){
|
||||
function select_enc_event(){
|
||||
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
if(parseInt($('#tirada').val())>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
var tirada = parseInt($('#tirada').val()) + parseInt($('#merma').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
}
|
||||
|
||||
var tarifa_id = null;
|
||||
if(this.id.includes('proveedor_enc')){
|
||||
tarifa_id = this.id.split('_')[2];
|
||||
}
|
||||
else{
|
||||
tarifa_id = this.id.split('_')[1];
|
||||
}
|
||||
// se checkea si el elemento #cuadernillos_ + tarifa_id existe
|
||||
var paginas_por_cuadernillo = null;
|
||||
if($('#cuadernillos_' + tarifa_id).length){
|
||||
paginas_por_cuadernillo = parseInt($('#cuadernillos_' + tarifa_id).select2('data')[0].id);
|
||||
}
|
||||
|
||||
var datos = {
|
||||
tarifa_encuadernacion_id: this.id.split('_')[2],
|
||||
tarifa_encuadernacion_id: tarifa_id,
|
||||
paginas: parseInt($('#paginas').val())>0?parseInt($('#paginas').val()):0,
|
||||
tirada: tirada,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
proveedor_id: parseInt($('#' + this.id).select2('data')[0].id),
|
||||
paginas_por_cuadernillo: paginas_por_cuadernillo,
|
||||
proveedor_id: parseInt($('#proveedor_enc_' + tarifa_id).select2('data')[0].id),
|
||||
POD: parseInt($('#POD').val())
|
||||
};
|
||||
datos = Object.assign(datos, window.token_ajax);
|
||||
@ -677,7 +723,7 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
if(parseInt($('#tirada').val())>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
var tirada = parseInt($('#tirada').val()) + parseInt($('#merma').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
@ -719,7 +765,8 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
'</option>' +
|
||||
'</select>',
|
||||
'<span id="precio_unidad_encuadernado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
|
||||
'<span id="tiempo_encuadernado_' + row.tiempo + '">' + convertirTiempo(row.tiempo) + '</span>',
|
||||
(row.hasOwnProperty('paginas_por_cuadernillo') && row.paginas_por_cuadernillo!=null)?selectForCuadernillos(row.tarifa_id, 32):'',
|
||||
'<span id="tiempo_encuadernado_' + row.tarifa_id + '">' + convertirTiempo(row.tiempo) + '</span>',
|
||||
'<input class="update-totales-servicios" id="precio_total_encuadernado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||
'<span style="display: none;" class="update-totales" id="enc_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
|
||||
@ -745,7 +792,7 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
data: function (params) {
|
||||
|
||||
if( parseInt( $('#tirada').val() )>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
var tirada = parseInt($('#tirada').val()) + parseInt($('#merma').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
@ -755,8 +802,8 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
tarifa_id: row.tarifa_id,
|
||||
paginas: parseInt($('#paginas').val())>0?parseInt($('#paginas').val()):0,
|
||||
tirada: tirada,
|
||||
ancho: ancho_libro,
|
||||
alto: alto_libro,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
searchtxt: params.term, // search term
|
||||
}
|
||||
return_data = Object.assign(return_data, window.token_ajax);
|
||||
@ -773,9 +820,17 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
}
|
||||
});
|
||||
|
||||
$('#proveedor_enc_' + row.tarifa_id).on('change', proveedor_enc_event)
|
||||
|
||||
$('#proveedor_enc_' + row.tarifa_id).on('change', select_enc_event)
|
||||
|
||||
|
||||
if(row.hasOwnProperty('paginas_por_cuadernillo') && row.paginas_por_cuadernillo!=null){
|
||||
$('#cuadernillos_' + row.tarifa_id).select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: -1,
|
||||
});
|
||||
|
||||
$('#cuadernillos_' + row.tarifa_id).on('change', select_enc_event)
|
||||
}
|
||||
});
|
||||
check_serv_enc_error()
|
||||
yeniden(data[window.csrf_token]);
|
||||
@ -821,16 +876,21 @@ function get_datos_encuadernacion(){
|
||||
case 3:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 4:
|
||||
case 4:
|
||||
values['paginas_por_cuadernillo'] = $(this).children(":first").val()
|
||||
// Si el valor es "undefined" se pone a null
|
||||
if(values['paginas_por_cuadernillo'] == "undefined")
|
||||
values['paginas_por_cuadernillo'] = null
|
||||
case 5:
|
||||
values['tiempo'] = $(this).text()
|
||||
// se pasa el string hh:mm:ss a horas
|
||||
if(values['tiempo'] != null)
|
||||
values['tiempo'] = parseInt(values['tiempo'].split(':')[0]) + parseInt(values['tiempo'].split(':')[1])/60 + parseInt(values['tiempo'].split(':')[2])/3600
|
||||
break
|
||||
case 5:
|
||||
case 6:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 6:
|
||||
case 7:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
@ -1709,7 +1769,7 @@ async function actualizar_servicios(update_preimpresion=false){
|
||||
$('#precio_unidad_encuadernado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2))
|
||||
$('#precio_total_encuadernado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
|
||||
$('#enc_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2))
|
||||
$('#proveedor_enc_' + line[0].tarifa_id).on('change', proveedor_enc_event)
|
||||
$('#proveedor_enc_' + line[0].tarifa_id).on('change', select_enc_event)
|
||||
});
|
||||
check_serv_enc_error()
|
||||
yeniden(data[window.csrf_token]);
|
||||
|
||||
@ -167,6 +167,7 @@
|
||||
<th><?= lang('Presupuestos.tarifa') ?></th>
|
||||
<th><?= lang('Proveedores.proveedor') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.paginasCuadernillo') ?></th>
|
||||
<th><?= lang('Presupuestos.tiempo') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th></th>
|
||||
|
||||
193
ci4/app/Views/themes/vuexy/pdfs/factura.php
Normal file
193
ci4/app/Views/themes/vuexy/pdfs/factura.php
Normal file
File diff suppressed because one or more lines are too long
313
httpdocs/themes/vuexy/css/pdf.factura.css
Normal file
313
httpdocs/themes/vuexy/css/pdf.factura.css
Normal file
@ -0,0 +1,313 @@
|
||||
/* Facturas Safekat */
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.42857143;
|
||||
color: #333;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
table {
|
||||
border-spacing: 0;
|
||||
background-color: transparent;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body table.logo {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
color: black;
|
||||
}
|
||||
|
||||
body table.logo td.logo img {
|
||||
width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* Estilos intro-factura */
|
||||
body table.intro-factura {
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
margin-top: -22px;
|
||||
}
|
||||
|
||||
body table.intro-factura th {
|
||||
background: black;
|
||||
color: white;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
body table.intro-factura th.intro_num_factura {
|
||||
width: 20%;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
body table.intro-factura th.num_factura {
|
||||
width: 47%;
|
||||
font-weight: lighter;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
body table.intro-factura th.intro_fecha {
|
||||
width: 17%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
body table.intro-factura th.fecha {
|
||||
width: 15%;
|
||||
text-align: right;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
body table.intro-factura td {
|
||||
background: #e3e4e7;
|
||||
padding-left: 15px;
|
||||
color: black;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
body table.intro-factura td.intro_direccion {
|
||||
padding-top: 10px;
|
||||
padding-right: 8px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
body table.intro-factura td.direccion {
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
/* Estilos cuerpo factura */
|
||||
div.cuerpo-factura {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
table.factura-data-superior {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.factura-data-superior th {
|
||||
padding: 5px !important;
|
||||
background: #0C2C84;
|
||||
color: white;
|
||||
padding-left: 10px;
|
||||
font-weight: lighter;
|
||||
font-size: 12px;
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
|
||||
table.factura-data-superior td {
|
||||
border: 1px dotted #4e4e4e;
|
||||
border-top: none;
|
||||
padding: 5px !important;
|
||||
text-align: right;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
table.factura-data-superior td.tipo_trabajo {
|
||||
border-left: none;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
table.factura-data-superior td.subtotal {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
/* Estilos para el sello de Solunion */
|
||||
.sello-solunion {
|
||||
float: left; /* Hace que el sello flote a la izquierda */
|
||||
margin-left: 100px; /* Espacio entre el sello y la tabla */
|
||||
}
|
||||
|
||||
.sello-solunion img {
|
||||
display: block; /* Asegura que la imagen se comporte como un bloque dentro del div */
|
||||
width: 80px; /* Ajusta el tamaño de la imagen según sea necesario */
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* Contenedor para manejar el flujo de contenido */
|
||||
.container {
|
||||
overflow: hidden; /* Asegura que el contenedor se ajuste al contenido flotante */
|
||||
}
|
||||
|
||||
/* Estilos para la tabla de precios inferior */
|
||||
table.factura-precio-inferior {
|
||||
width: 60%; /* Ajusta el ancho de la tabla al 100% del contenedor */
|
||||
text-align: right;
|
||||
border-collapse: collapse; /* Asegura que los bordes se colapsen para evitar espacio extra */
|
||||
margin-bottom: 0; /* Elimina el margen inferior para evitar espacio extra */
|
||||
}
|
||||
|
||||
table.factura-precio-inferior th, table.factura-precio-inferior td {
|
||||
padding: 5px;
|
||||
border-bottom: 1px dotted #4e4e4e;
|
||||
}
|
||||
|
||||
table.factura-precio-inferior th.intro_base,
|
||||
table.factura-precio-inferior th.intro_iva,
|
||||
table.factura-precio-inferior th.intro_total {
|
||||
background: #0C2C84;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
table.factura-precio-inferior td.base,
|
||||
table.factura-precio-inferior td.iva,
|
||||
table.factura-precio-inferior td.value_iva,
|
||||
table.factura-precio-inferior td.total {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* Estilos para la tabla de totales */
|
||||
table.totales {
|
||||
width: 28%; /* Ajusta el ancho de la tabla según sea necesario */
|
||||
background: #0C2C84;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
border-collapse: collapse; /* Asegura que los bordes se colapsen para evitar espacio extra */
|
||||
margin-top: 0; /* Elimina el margen superior para evitar espacio extra */
|
||||
margin-bottom: 0; /* Elimina el margen inferior para evitar espacio extra */
|
||||
}
|
||||
|
||||
table.totales td.intro_total_factura {
|
||||
width: 20%;
|
||||
text-align: right;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
table.totales td.total_factura {
|
||||
width: 15%;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* Estilos factura-data-inferior-iva */
|
||||
table.factura-data-inferior-iva {
|
||||
width: 100%;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
table.factura-data-inferior-iva th {
|
||||
padding: 5px !important;
|
||||
background: rgb(233, 240, 255);
|
||||
font-weight: lighter;
|
||||
font-size: 12px;
|
||||
padding-left: 7px;
|
||||
color: black;
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
|
||||
table.factura-data-inferior-iva th.intro_vencimiento,
|
||||
table.factura-data-inferior-iva th.inferior_intro_fecha {
|
||||
width: 15%;
|
||||
}
|
||||
|
||||
table.factura-data-inferior-iva th.intro_forma_pago {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
table.factura-data-inferior-iva th.intro_bic {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
table.factura-data-inferior-iva td {
|
||||
border-bottom: 1px dotted #4e4e4e;
|
||||
border-top: none;
|
||||
padding-left: 8px;
|
||||
padding: 3px !important;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
table.factura-data-inferior-iva td.vencimiento,
|
||||
table.factura-data-inferior-iva td.inferior_fecha,
|
||||
table.factura-data-inferior-iva td.forma_pago {
|
||||
border-right: 1px dotted black;
|
||||
}
|
||||
|
||||
/* Estilos factura-precio-inferior */
|
||||
table.factura-data-inferior {
|
||||
width: 100%;
|
||||
background: #e3e4e7;
|
||||
font-size: 12px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
table.factura-data-inferior th {
|
||||
padding-top: 2px;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
table.factura-data-inferior th.intro_vencimiento,
|
||||
table.factura-data-inferior th.intro_base,
|
||||
table.factura-data-inferior th.base {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
table.factura-data-inferior th.intro_vencimiento,
|
||||
table.factura-data-inferior th.inferior_intro_fecha,
|
||||
table.factura-data-inferior th.intro_forma_pago,
|
||||
table.factura-data-inferior th.intro_bic {
|
||||
font-weight: bold;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
table.factura-data-inferior th.intro_base,
|
||||
table.factura-data-inferior th.intro_value_iva,
|
||||
table.factura-data-inferior th.intro_iva,
|
||||
table.factura-data-inferior th.intro_total {
|
||||
color: #0C2C84;
|
||||
text-align: right;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
table.factura-data-inferior th.base,
|
||||
table.factura-data-inferior th.iva,
|
||||
table.factura-data-inferior th.value_iva,
|
||||
table.factura-data-inferior th.total {
|
||||
border-left: 1px dashed grey;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
width: 15%;
|
||||
}
|
||||
|
||||
table.factura-data-inferior th.intro_bic,
|
||||
table.factura-data-inferior th.intro_total,
|
||||
table.factura-data-inferior th.total {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
/* Estilos para el pie de página */
|
||||
.footer {
|
||||
width: 95%;
|
||||
position: fixed; /* Fija el pie de página en la parte inferior */
|
||||
bottom: 15px; /* Coloca el pie de página en la parte inferior de la página */
|
||||
}
|
||||
|
||||
/* Estilos pie */
|
||||
div.pie {
|
||||
font-family: sans-serif;
|
||||
font-size: 7px;
|
||||
margin: 5mm 0 5mm 0;
|
||||
}
|
||||
|
||||
/* Estilos pie-pagina */
|
||||
table.pie-pagina {
|
||||
font-family: sans-serif;
|
||||
color: #0C2C84;
|
||||
float: left;
|
||||
vertical-align: bottom;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
Reference in New Issue
Block a user