Merge branch 'main' into 'dev/criba_tabla_presupuestos'

# Conflicts:
#   ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php
This commit is contained in:
Ignacio Martinez Navajas
2024-01-25 08:04:52 +00:00
18 changed files with 828 additions and 642 deletions

View File

@ -22,8 +22,8 @@ CI_ENVIRONMENT = development
# APP
#--------------------------------------------------------------------
#app.baseURL = 'https://sk-dev.imnavajas.es'
app.baseURL = 'https://sk-imn.imnavajas.es'
app.baseURL = 'https://sk-dev.imnavajas.es'
#app.baseURL = 'https://sk-imn.imnavajas.es'
# app.baseURL = 'https://sk-imn.imnavajas.es'
# app.baseURL = "http://safekat.test/"
# app.forceGlobalSecureRequests = false

View File

@ -202,7 +202,7 @@ $routes->group('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Conf
$routes->post('datatable_editor', 'Papelimpresionmargenes::datatable_editor', ['as' => 'editorOfPapelImpresionMargenes']);
$routes->get('delete/(:num)', 'Papelimpresionmargenes::delete/$1', ['as' => 'deletePapelImpresionMargen']);
});
$routes->resource('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelimpresionmargenes', 'except' => 'show,new,create,update']);
$routes->resource('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelimpresionmargenes', 'except' => 'show,new,create,update']);
$routes->group('tarifaacabadolineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
@ -453,21 +453,21 @@ $routes->group('tarifasenvios', ['namespace' => 'App\Controllers\Tarifas'], func
$routes->post('allmenuitems', 'Tarifasenvios::allItemsSelect', ['as' => 'select2ItemsOfTarifaEnvio']);
$routes->post('menuitems', 'Tarifasenvios::menuItems', ['as' => 'menuItemsOfTarifaEnvio']);
});
$routes->resource('tarifasenvios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvios', 'except' => 'show,new,create,update']);
$routes->resource('tarifasenvios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvios', 'except' => 'show,new,create,update']);
$routes->group('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
$routes->post('datatable', 'Tarifasenviosprecios::datatable', ['as' => 'dataTableOfTarifasEnvioPrecios']);
$routes->post('datatable_editor', 'Tarifasenviosprecios::datatable_editor', ['as' => 'editorOfTarifasEnvioPrecios']);
});
$routes->resource('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenviosprecios', 'except' => 'show,new,create,update']);
$routes->resource('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenviosprecios', 'except' => 'show,new,create,update']);
$routes->group('tarifasenvioszonas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
$routes->post('datatable', 'Tarifasenvioszonas::datatable', ['as' => 'dataTableOfTarifasEnvioZonas']);
$routes->post('datatable_editor', 'Tarifasenvioszonas::datatable_editor', ['as' => 'editorOfTarifasEnvioZonas']);
});
$routes->resource('tarifasenvioszonas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvioszonas', 'except' => 'show,new,create,update']);
$routes->resource('tarifasenvioszonas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvioszonas', 'except' => 'show,new,create,update']);
$routes->group('proveedores', ['namespace' => 'App\Controllers\Compras'], function ($routes) {
@ -513,9 +513,8 @@ $routes->group('clientedirecciones', ['namespace' => 'App\Controllers\Clientes']
$routes->resource('clientedirecciones', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clientedirecciones', 'except' => 'show,new,create,update']);
$routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
$routes->get('', 'Cosidotapablanda::index', ['as' => 'cosidotapablandaList']);
$routes->get('list/(:num)', 'Cosidotapablanda::list/$1', ['as' => 'cosidotapablandaList']); // HOMOGENIZAR CON ARGS DINAMICOS!!!
$routes->get('add', 'Cosidotapablanda::add', ['as' => 'newCosidotapablanda']);
$routes->post('add', 'Cosidotapablanda::add', ['as' => 'createCosidotapablanda']);
$routes->post('create', 'Cosidotapablanda::create', ['as' => 'ajaxCreateCosidotapablanda']);
@ -526,7 +525,7 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
$routes->post('allmenuitems', 'Cosidotapablanda::allItemsSelect', ['as' => 'select2ItemsOfCosidotapablanda']);
$routes->post('menuitems', 'Cosidotapablanda::menuItems', ['as' => 'menuItemsOfCosidotapablanda']);
});
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
$routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
@ -538,7 +537,7 @@ $routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Pre
$routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']);
$routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']);
$routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updatePresupuestoencuadernaciones']);
});
$routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
@ -555,10 +554,13 @@ $routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presup
$routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']);
});
$routes->group('printpresupuestos', ['namespace' => 'App\Controllers\Pdf'], function ($routes) {
$routes->get('', 'PrintPresupuestos::index', ['as' => 'viewPresupuesto']);
$routes->get('generar', 'PrintPresupuestos::generar', ['as' => 'presupuestoToPdf']);
});
$routes->group(
'printpresupuestos',
['namespace' => 'App\Controllers\Pdf'],
function ($routes) {
$routes->get('index/(:num)', 'PrintPresupuestos::index/$1', ['as' => 'viewPresupuesto']);
$routes->get('generar/(:num)', 'PrintPresupuestos::generar/$1', ['as' => 'presupuestoToPdf']);
});
/*

View File

@ -1,4 +1,5 @@
<?php
namespace App\Controllers\Pdf;
use App\Controllers\BaseController;
@ -6,22 +7,65 @@ use App\Controllers\BaseController;
class PrintPresupuestos extends BaseController
{
function __construct()
public function index($id_presupuesto)
{
$presupuestoModel = model('App\Models\Presupuestos\PresupuestoModel');
$lineasPresupuestoModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
$direccionesEnvioModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$data['presupuesto'] = $presupuestoModel->getResourceForPdf($id_presupuesto)->get()->getRow();
$data['lp_ByN'] = $lineasPresupuestoModel->getResourceByNForPdf($id_presupuesto)->get()->getRow();
$data['lp_Color'] = $lineasPresupuestoModel->getResourceColorForPdf($id_presupuesto)->get()->getRow();
$data['direccionesEnvio'] = $direccionesEnvioModel->getResourceForPdf($id_presupuesto)->get()->getResultObject();
return view(getenv('theme.path') . 'pdfs/presupuesto', $data);
}
public function index()
public function generar($presupuesto_id)
{
//return view('pdf_view');
return view(getenv('theme.path').'pdfs/presupuesto');
}
public function generar(){
$dompdf = new \Dompdf\Dompdf(['isRemoteEnabled' => true]);
//$dompdf->loadHtml(view('pdf_view'));
$dompdf->loadHtml(view(getenv('theme.path').'pdfs/presupuesto'));
// Cargar modelos
$presupuestoModel = model('App\Models\Presupuestos\PresupuestoModel');
$lineasPresupuestoModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
$direccionesEnvioModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
// Informacion del presupuesto
$data['presupuesto'] = $presupuestoModel->getResourceForPdf($presupuesto_id)->get()->getRow();
$data['lp_ByN'] = $lineasPresupuestoModel->getResourceByNForPdf($presupuesto_id)->get()->getRow();
$data['lp_Color'] = $lineasPresupuestoModel->getResourceColorForPdf($presupuesto_id)->get()->getRow();
$data['direccionesEnvio'] = $direccionesEnvioModel->getResourceForPdf($presupuesto_id)->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/presupuesto', $data));
// Establecer el tamaño del papel
$dompdf->setPaper('A4', 'portrait');
// Renderizar el PDF
$dompdf->render();
$dompdf->stream('presupuesto-demo.pdf');
// Obtener el contenido generado
$output = $dompdf->output();
// Establecer las cabeceras para visualizar en lugar de descargar
$file_name = "presupuesto-$presupuesto_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);
}
}

View File

@ -60,7 +60,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
// Breadcrumbs
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_presupuestos"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_libros_cosido_tapa_blanda"), 'route' => site_url('presupuestos/cosidotapablanda'), 'active' => true]
['title' => lang("App.menu_libros_cosido_tapa_blanda"), 'route' => site_url('presupuestos/cosidotapablanda/list/4'), 'active' => true]
];
parent::initController($request, $response, $logger);
@ -68,8 +68,18 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
}
public function index()
public function list($tipo_presupuesto = 4)
{
switch ($tipo_presupuesto){
case 4:
break;
default:
return "A IMPLEMENTAR!";
}
$viewData = [
'currentModule' => static::$controllerSlug,
@ -188,6 +198,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$postData['updated_at'] = gmdate('Y-m-d H:m:s', time());
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_updated_id'] = $session->id_user;
@ -197,7 +208,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
}
if ($this->request->getPost('retractilado5') == null) {
$sanitizedData['retractilado5'] = false;
}
}
if ($this->request->getPost('ferro') == null) {
$sanitizedData['ferro'] = false;
}
@ -213,29 +224,51 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
if ($this->request->getPost('faja_color') == null) {
$sanitizedData['faja_color'] = false;
}
if ($this->request->getPost('papel_formato_personalizado') == null) {
$sanitizedData['papel_formato_personalizado'] = false;
}
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if($sanitizedData['papel_formato_id'] == null && $sanitizedData['papel_formato_ancho'] == null
&& $sanitizedData['papel_formato_alto'] == null){
if ($this->request->isAJAX()) {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'errorMensaje' => lang('Presupuestos.errores.formato_papel'),
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else{
$this->session->setFlashData('errorMessage', lang('Presupuestos.errores.formato_papel'));
}
$successfulResult = false;
}
else{
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) )
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else :
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else :
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$presupuestoEntity->fill($sanitizedData);
$thenRedirect = false;
endif;
}
$presupuestoEntity->fill($sanitizedData);
$thenRedirect = false;
endif;
if ($noException && $successfulResult) :
$id = $presupuestoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.';
@ -279,6 +312,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
endif; // ($requestMethod === 'post')
$this->viewData['presupuestoId'] = $id;
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
$this->viewData['isCosido'] = (new TipoPresupuestoModel())->get_isCosido($presupuestoEntity->tipo_impresion_id);
@ -425,6 +459,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
'merma' => intval($reqData['merma']) ?? 0,
'ancho' => intval($reqData['ancho']) ?? 100000,
'alto' => intval($reqData['alto']) ?? 100000,
'a_favor_fibra' => $reqData['a_favor_fibra'] ?? 1,
'isCosido' => true, // JJO esto es custom por cada tipo de presupuesto
);
@ -502,7 +537,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$datosPedido->solapas = $reqData['solapas'];
$datosPedido->solapas_ancho = $reqData['solapas_ancho'];
$datosPedido->lomo = $reqData['lomo'];
if($type=='sobrecubierta')
$datosPedido->lomo_cubierta = $reqData['lomo_cubierta'];
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($datosPedido);
// Cubierta y sobrecubierta siempre color HQ
$resourceData = $this->getCompIntData($type, $datosPedido, $papel_generico, $gramaje, $isColor, 1, $cliente_id);
@ -752,15 +792,13 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
public function getCompIntRotData($datosPedido, $papel_generico, $gramaje, $paginas, $cliente_id, $datosTipolog = null)
{
$uso = 'interior';
$tipo = $paginas->color>0? 'color': 'negro';
$parametrosRotativa = (object)array(
'a_favor_fibra' => 0, // este parametro se cambia para comprobar
// en las dos direcciones (menos en rustica fresada que es siempre 1)
'a_favor_fibra' => $datosPedido->a_favor_fibra,
'bnPages' => $paginas->negro,
'colorPages' => $paginas->color,
'rotativa_gota_negro' => 0,
@ -773,12 +811,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$tipo = array();
if( $paginas->color > 0 ){
$tipo[] = 'color';
$tipo = 'color';
$opciones_papel['color'] = 1;
}
if( $paginas->negro > 0 ){
$opciones_papel['bn'] = 1;
$tipo[] = 'negro';
$tipo = 'negro';
}
// Se obtienen los papeles disponibles
@ -828,95 +866,90 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
// Se recorren las máquinas y se calcula el coste de linea por cada una
foreach ($maquinas as $maquina) {
for ($i = 1; $i <= 1; $i++) { // Para que por defecto salga sólo a favor de fibra
$parametrosRotativa->a_favor_fibra = $i;
$tarifamodel = new MaquinasTarifasImpresionModel();
[$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo);
if(!is_float($tarifa)){
continue;
}
// precio del pliego de impresion
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas);
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
$linea['fields']['precios_pliegos'] = $precio_pliego_impresion;
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $precio_pliego_impresion;
// Precio papel pedido
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro']*$margen_pliego_impresion* ($datosPedido->tirada + $datosPedido->merma); ;
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
$linea['fields']['maquina'] = $maquina->maquina;
$linea['fields']['maquina_id'] = $maquina->maquina_id;
$linea['fields']['maquina_velocidad'] = $maquina->velocidad;
$linea['fields']['tipo_maquina'] = 'inkjet';
$linea['fields']['papel_impresion'] = $papel->nombre;
$linea['fields']['papel_impresion_id'] = $papel->id;
$linea['fields']['paginas'] = $datosPedido->paginas;
$linea['fields']['paginas_color'] = $paginas->color;
$linea['fields']['gramaje'] = $gramaje;
$linea['fields']['papel_generico_id'] = $papel_generico['id'];
$linea['fields']['papel_generico'] = $papel_generico['nombre'];
$linea['fields']['posicion_formas'] = $parametrosRotativa->a_favor_fibra ? 'h' : 'v';
$linea['fields']['num_formas_horizontales'] = floor($linea['fields']['factor_anchura']);
$linea['fields']['num_formas_verticales'] = floor($linea['fields']['factor_altura']);
$linea['fields']['datosTipologias'] = $datosTipologias[0];
// impresion
$linea['fields']['precio_click'] = $tarifa;
$linea['fields']['precio_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click'];
$linea['fields']['tiempo_maquina'] = PresupuestoService::getTiempoMaquina(
$linea['fields']['precio_click_pedido'],
$linea['fields']['precio_click'],
$maquina->velocidad);
$clientePreciosModel = new ClientePreciosModel();
$config = (object)[
"tipo" => $uso,
"tipo_maquina" => 'inkjet',
"tipo_impresion" => $tipo
];
$tiempo = PresupuestoService::getHorasMaquina(
$linea['fields']['precio_click_pedido'],
$linea['fields']['precio_click'],
$maquina->velocidad);
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
if(is_null($precio_hora)){
continue;
}
$linea['fields']['precio_hora'] = $precio_hora*(1+$margen_precio_hora/100.0);
$linea['fields']['precio_hora_margen'] = $margen_precio_hora;
$linea['fields']['horas_maquina'] = $tiempo;
$linea['fields']['precio_impresion_horas'] = $precio_hora*(1+$margen_precio_hora/100.0)*$tiempo;
$linea['fields']['margen_impresion_horas'] = $precio_hora*($margen_precio_hora/100.0)*$tiempo;
// total linea rotativa
//$linea['fields']['total_impresion'] = $linea['fields']['precio_pedido'] + $linea['fields']['precio_click_pedido'] + $linea['fields']['precio_tinta'] +
// $linea['fields']['total_corte'];
$linea['fields']['total_impresion'] =
$linea['fields']['precio_pedido'] + // papel
$linea['fields']['precio_click_pedido'] + // precio clicks del pedido
$linea['fields']['precio_impresion_horas'] + // horas de maquina
$linea['fields']['precio_tinta'] + // tinta
$linea['fields']['total_corte']; // corte
array_push($lineas, $linea);
$tarifamodel = new MaquinasTarifasImpresionModel();
[$tarifaId, $tarifa] = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo)?'color':$tipo);
if(!is_float($tarifa)){
continue;
}
// precio del pliego de impresion
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas);
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
$linea['fields']['precios_pliegos'] = $precio_pliego_impresion;
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $precio_pliego_impresion;
// Precio papel pedido
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro']*$margen_pliego_impresion* ($datosPedido->tirada + $datosPedido->merma); ;
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
$linea['fields']['maquina'] = $maquina->maquina;
$linea['fields']['maquina_id'] = $maquina->maquina_id;
$linea['fields']['maquina_velocidad'] = $maquina->velocidad;
$linea['fields']['tipo_maquina'] = 'inkjet';
$linea['fields']['papel_impresion'] = $papel->nombre;
$linea['fields']['papel_impresion_id'] = $papel->id;
$linea['fields']['paginas'] = $datosPedido->paginas;
$linea['fields']['paginas_color'] = $paginas->color;
$linea['fields']['gramaje'] = $gramaje;
$linea['fields']['papel_generico_id'] = $papel_generico['id'];
$linea['fields']['papel_generico'] = $papel_generico['nombre'];
$linea['fields']['posicion_formas'] = $parametrosRotativa->a_favor_fibra ? 'h' : 'v';
$linea['fields']['num_formas_horizontales'] = floor($linea['fields']['factor_anchura']);
$linea['fields']['num_formas_verticales'] = floor($linea['fields']['factor_altura']);
$linea['fields']['datosTipologias'] = $datosTipologias[0];
// impresion
$linea['fields']['precio_click'] = $tarifa;
$linea['fields']['precio_click_pedido'] = $linea['fields']['clicks_pedido'] * $linea['fields']['precio_click'];
$linea['fields']['tiempo_maquina'] = PresupuestoService::getTiempoMaquina(
$linea['fields']['precio_click_pedido'],
$linea['fields']['precio_click'],
$maquina->velocidad);
$clientePreciosModel = new ClientePreciosModel();
$config = (object)[
"tipo" => $uso,
"tipo_maquina" => 'inkjet',
"tipo_impresion" => $tipo
];
$tiempo = PresupuestoService::getHorasMaquina(
$linea['fields']['precio_click_pedido'],
$linea['fields']['precio_click'],
$maquina->velocidad);
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
if(is_null($precio_hora)){
continue;
}
$linea['fields']['precio_hora'] = $precio_hora*(1+$margen_precio_hora/100.0);
$linea['fields']['precio_hora_margen'] = $margen_precio_hora;
$linea['fields']['horas_maquina'] = $tiempo;
$linea['fields']['precio_impresion_horas'] = $precio_hora*(1+$margen_precio_hora/100.0)*$tiempo;
$linea['fields']['margen_impresion_horas'] = $precio_hora*($margen_precio_hora/100.0)*$tiempo;
// total linea rotativa
//$linea['fields']['total_impresion'] = $linea['fields']['precio_pedido'] + $linea['fields']['precio_click_pedido'] + $linea['fields']['precio_tinta'] +
// $linea['fields']['total_corte'];
$linea['fields']['total_impresion'] =
$linea['fields']['precio_pedido'] + // papel
$linea['fields']['precio_click_pedido'] + // precio clicks del pedido
$linea['fields']['precio_impresion_horas'] + // horas de maquina
$linea['fields']['precio_tinta'] + // tinta
$linea['fields']['total_corte']; // corte
array_push($lineas, $linea);
}
}
return $lineas;

View File

@ -17,12 +17,18 @@ class Test extends BaseController
public function index()
{
/*
$maquina_id = 114;
echo '<pre>';
$maquina_id = 63;
$maquina_model = model('App\Models\Configuracion\MaquinaModel');
$maquina = $maquina_model->find($maquina_id);
$formas = PresupuestoService::getNumFormasPlana('interior', $maquina, 150, 210, true);
$formas = PresupuestoService::getNumFormasPlana('cubierta', $maquina, 493.2, 210, true);
var_dump($formas);
echo '</pre>';
/*
$linea = PresupuestoService::getCostesLinea('interior', $datosPedido, $maquina, $papel, $opciones_papel, $tarifa);
@ -30,14 +36,14 @@ class Test extends BaseController
var_dump($formas);
echo '</pre>';*/
echo '</pre>';
echo '<pre>';
$tarifa_value = $this->get_tarifa_enc(18,150,22,150,210);
var_dump($tarifa_value[0]);
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
$result = $model->calcularTarifa($tarifa_value[0], 150, true);
var_dump($result);
echo '</pre>';
echo '</pre>';*/
}
private function asignar_tarifa_defecto_todos_usuarios()

View File

@ -230,7 +230,8 @@ return [
'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto',
'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN',
'error_servicios_anadidos' => 'Hay servicios sin datos',
'error_servicios_duplicados' => 'El servicio seleccionado ya está añadido'
'error_servicios_duplicados' => 'El servicio seleccionado ya está añadido',
'formato_papel' => 'Debe seleccionar un formato de papel'
],
];

View File

@ -89,4 +89,28 @@ class PresupuestoDireccionesModel extends \App\Models\GoBaseModel
->orLike("t1.telefono", $search)
->groupEnd();
}
/**
* Get resource data for pdf generation.
*
* @param int $presupuesto_id
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResourceForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.direccion AS direccion, t2.nombre AS pais,
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono,
t1.cantidad AS cantidad"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
return $builder;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace App\Models\Presupuestos;
class PresupuestoLineaModel extends \App\Models\GoBaseModel
@ -307,17 +308,18 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
return $result;
}
public function createForPresupuesto($presupuesto_id){
public function createForPresupuesto($presupuesto_id)
{
$tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color'];
foreach($tipos as $tipo){
$tipos = ['bn', 'bnhq', 'color', 'colorhq', 'cubierta', 'sobrecubierta', 'rot_bn', 'rot_color'];
foreach ($tipos as $tipo) {
$builder = $this->db
->table($this->table . " t1");
->table($this->table . " t1");
$data = [
'presupuesto_id' => $presupuesto_id,
'tipo' => $tipo,
'presupuesto_id' => $presupuesto_id,
'tipo' => $tipo,
];
$builder->insert($data);
}
}
@ -330,30 +332,58 @@ class PresupuestoLineaModel extends \App\Models\GoBaseModel
"*"
)
->where("t1.presupuesto_id", $presupuesto_id);
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
}
public function deleteLineasPresupuesto($presupuesto_id){
public function deleteLineasPresupuesto($presupuesto_id)
{
$this->db
->table($this->table . " t1")
->where("presupuesto_id", $presupuesto_id)
->delete();
}
public function insertLineasPresupuesto($presupuesto_id = -1, $datos=[])
public function insertLineasPresupuesto($presupuesto_id = -1, $datos = [])
{
$this->deleteLineasPresupuesto($presupuesto_id);
foreach($datos as $linea){
foreach ($datos as $linea) {
$this->db
->table($this->table . " t1")
->where("t1.presupuesto_id", $presupuesto_id)
->insert($linea);
}
}
public function getResourceByNForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.paginas AS paginas, t1.papel_impresion AS papel, t1.gramaje AS gramaje"
)
->where("t1.presupuesto_id", $presupuesto_id)
->whereIn('t1.tipo', ['lp_bn', 'lp_bnhq', 'lp_rot_bn']);
return $builder;
}
public function getResourceColorForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.paginas AS paginas, t1.papel_impresion AS papel, t1.gramaje AS gramaje"
)
->where("t1.presupuesto_id", $presupuesto_id)
->whereIn('t1.tipo', ['lp_color', 'lp_colorhq', 'lp_rot_color']);
return $builder;
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace App\Models\Presupuestos;
class PresupuestoModel extends \App\Models\GoBaseModel
@ -159,7 +160,7 @@ class PresupuestoModel extends \App\Models\GoBaseModel
],
"inc_rei" => [
"integer" => "Presupuestos.validation.integer",
],
"coleccion" => [
"max_length" => "Presupuestos.validation.max_length",
@ -178,8 +179,9 @@ class PresupuestoModel extends \App\Models\GoBaseModel
],
"referencia_cliente" => [
"max_length" => "Presupuestos.validation.max_length",
],
],
];
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
{
$sql =
@ -235,14 +237,14 @@ class PresupuestoModel extends \App\Models\GoBaseModel
$builder->where("t1.is_deleted", 0);
if(empty($search))
if (empty($search))
return $builder;
else{
else {
$builder->groupStart();
foreach($search as $col_search){
if($col_search[0] != 1)
foreach ($search as $col_search) {
if ($col_search[0] != 1)
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
else{
else {
$dates = explode(" ", $col_search[2]);
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
@ -251,6 +253,43 @@ class PresupuestoModel extends \App\Models\GoBaseModel
$builder->groupEnd();
return $builder;
}
}
/**
* Get resource data for creating PDFs.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResourceForPdf($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.created_at AS fecha, t1.titulo AS titulo, t1.autor AS autor, t1.ferro AS ferro,
t1.ferro_digital AS ferro_digital, t1.prototipo AS prototipo, t1.solapas AS solapas,
t1.solapas_ancho AS solapas_ancho, t1.paginas AS paginas, t1.tirada AS tirada, t1.coleccion AS coleccion,
t1.retractilado AS retractilado, t1.guardas AS guardas, t1.marcapaginas AS marcapaginas,
t1.comentarios_pdf AS comentarios_pdf,
t1.total_presupuesto AS total_presupuesto, t1.total_precio_unidad AS total_precio_unidad,
t1.papel_formato_personalizado AS isPersonalizado, t1.envios_recoge_cliente AS recoge_cliente,
CONCAT(t1.papel_formato_ancho, 'x', t1.papel_formato_alto) AS formatoPersonalizado,
t2.nombre AS cliente,
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t3.email AS email_comercial,
CONCAT(t4.ancho, 'x', t4.alto) AS formato"
);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
$builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left");
$builder->join("lg_papel_formato t4", "t1.papel_formato_id = t4.id", "left");
$builder->where("t1.is_deleted", 0);
$builder->where("t1.id", $presupuesto_id);
return $builder;
}
}

View File

@ -43,7 +43,9 @@ class PresupuestoService extends BaseService
$response['fields'] = [];
if ($uso!='rotativa') {
$formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $datosPedido->ancho, $datosPedido->alto, $datosPedido->isCosido);
$ancho_calculo = ($uso=='cubierta' || $uso=='sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
$formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $ancho_calculo, $datosPedido->alto, $datosPedido->isCosido);
$response['fields'] = $formas;
}
@ -103,7 +105,7 @@ class PresupuestoService extends BaseService
$mano = PresupuestoService::computeLomoPortada($papel_impresion->espesor);
// peso
$ancho_total = $datosPedido->solapas? $datosPedido->ancho + $datosPedido->solapas_ancho:$datosPedido->ancho;
$ancho_total = $datosPedido->anchoExteriores + $mano;
$peso = PresupuestoService::computePeso($ancho_total, $datosPedido->alto, $papel_impresion->gramaje);
// impresion
@ -280,6 +282,7 @@ class PresupuestoService extends BaseService
$anchoLibro = $datosPedido->ancho;
$altoLibro = $datosPedido->alto;
if (!$parametrosRotativa->a_favor_fibra) {
$anchoLibro = $datosPedido->alto;
$altoLibro = $datosPedido->ancho;
@ -458,16 +461,18 @@ class PresupuestoService extends BaseService
if($uso == 'cubierta' || $uso == 'sobrecubierta') {
if(property_exists($maquina, 'forzar_num_formas_horizontales_cubierta') &&
property_exists($maquina, 'forzar_num_formas_horizontales_cubierta')){
property_exists($maquina, 'forzar_num_formas_verticales_cubierta')){
if($maquina->forzar_num_formas_horizontales_cubierta > 0 &&
$maquina->forzar_num_formas_horizontales_cubierta > 0){
$maquina->forzar_num_formas_verticales_cubierta > 0){
// Hay que comprobar que entran
$h1_temp = $maquina->forzar_num_formas_horizontales_cubierta;
$h2_temp = $maquina->forzar_num_formas_verticales_cubierta;
//$num_formas = $h1_temp * $h2_temp;
}
}
}
// No es cubierta ni sobrecubierta
else{
@ -475,14 +480,18 @@ class PresupuestoService extends BaseService
$h1_temp = floor($maquina->ancho_impresion / $anchoForCalculo);
$h2_temp = floor($maquina->ancho_impresion / $alto);
}
// horizontales
$calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina->maquina_id, $h1_temp);
// Si son mas de 2 formas
if(count($calles)>0)
$h1 = ($h1_temp * $anchoForCalculo + 2 * $calles[0]->externas + ($h1_temp - 1) * $calles[0]->internas < ($maquina->ancho)) ? $h1_temp : $h1_temp - 1;
else
$h1 = $h1_temp;
else{
$h1 = $anchoForCalculo<=$maquina->ancho_impresion?$h1_temp:0;
}
$v1 = floor($maquina->alto_impresion / $alto);
$formas_h = $h1 * $v1; //p1
@ -492,12 +501,14 @@ class PresupuestoService extends BaseService
$calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina->maquina_id, $h2_temp);
if(count($calles)>0)
$h2 = ($h2_temp * $alto + 2 * $calles[0]->externas + ($h2_temp - 1) * $calles[0]->internas < ($maquina->ancho)) ? $h2_temp : $h2_temp - 1;
else
$h2 = $h2_temp;
else{
$h2 = $alto<=$maquina->ancho_impresion?$h2_temp:0;
}
$v2 = floor($maquina->alto_impresion / $anchoForCalculo);
$formas_v = $h2 * $v2; //p2
// Se calcula el numero de formas
if($uso != 'cubierta' && $uso != 'sobrecubierta'){
$num_formas = ($formas_h > $formas_v) ? $formas_h : $formas_v;
@ -530,7 +541,7 @@ class PresupuestoService extends BaseService
$response['num_formas']['num_formas_verticales'] = $h2;
}
}
return $response;
}
@ -578,6 +589,26 @@ class PresupuestoService extends BaseService
}
/**
* Devuelve el ancho de la cubierta/sobrecubierta, incluido el lomo.
*/
public static function getAnchoTotalExteriores($datosPedido=null)
{
$ancho_total = 0;
if ($datosPedido) {
$ancho_total = floatval($datosPedido->ancho)*2 + floatval($datosPedido->lomo);
$ancho_total += property_exists($datosPedido, 'lomo_cubierta')?$datosPedido->lomo_cubierta:0;
// añadimos ancho de las solapas
// si se añaden solapas hay que sumar 3mm de los dobleces
if ($datosPedido->solapas) {
$ancho_total += (floatval($datosPedido->solapas_ancho) * 2) + 6;
}
}
return $ancho_total;
}
/**
* Devuelve la dimensión del lomo interior.
*/

View File

@ -31,7 +31,7 @@
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="solapas" name="solapas" tabindex="6" value="1" <?= $presupuestoEntity->solapas == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="papelFormatoPersonalizado"><?= lang('Presupuestos.solapasCubierta') ?></label>
<label class="form-check-label" for="solapas"><?= lang('Presupuestos.solapasCubierta') ?></label>
</div>
</div><!--//.mb-3 -->
@ -70,13 +70,13 @@
<div class="row">
<div class="col-md-12 col-lg-6">
<div class="mb-3">
<input style="display: none" type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control" value="<?= old('papel_formato_ancho', $presupuestoEntity->papel_formato_ancho) ?>">
<input <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control" value="<?= old('papel_formato_ancho', $presupuestoEntity->papel_formato_ancho) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6">
<div class="mb-3">
<input style="display: none" type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control" value="<?= old('papel_formato_alto', $presupuestoEntity->papel_formato_alto) ?>">
<div class="mb-3">
<input <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control" value="<?= old('papel_formato_alto', $presupuestoEntity->papel_formato_alto) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div>
@ -341,6 +341,13 @@ $('#papelFormatoId').select2({
allowClear: false,
});
let initTamanioPersonalizado = <?php echo ($presupuestoEntity->papel_formato_personalizado==true?1:0); ?>;
if(initTamanioPersonalizado != null){
if ( initTamanioPersonalizado){
$('#papelFormatoId').next(".select2-container").hide();
}
}
$('#papelFormatoPersonalizado').on("click",function(){
var checkbox = document.getElementById('papelFormatoPersonalizado');
if(checkbox.checked == true){

View File

@ -995,6 +995,7 @@
color: 1,
ancho: dimension.ancho,
alto: dimension.alto,
lomo: getLomoLineasPresupuesto(),
solapas: $('#solapas').is(':checked')?1:0,
solapas_ancho: parseInt($('#solapas_ancho').val()),
papel_generico_id: $('#compPapelCubierta').select2('data')[0].id,
@ -1082,6 +1083,10 @@
$('#compPaginasNegrohq').val('0');
$('#compPaginasNegro').val($('#paginas').val())
if($('#tipoImpresion').select2('data')[0].id == 'negro'){
$('#compGramajeColor').val('').trigger('change')
$('#compPapelColor').val(0).trigger('change')
}
if( $('#tableCompIntPlana').DataTable().rows().count() > 0 &&
$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) {
@ -1101,6 +1106,11 @@
$('#compPaginasColor').val('0')
$('#compPaginasNegro').val('0')
$('#compPaginasNegrohq').val($('#paginas').val())
if($('#tipoImpresion').select2('data')[0].id == 'negrohq'){
$('#compGramajeColorhq').val('').trigger('change')
$('#compPapelColorhq').val(0).trigger('change')
}
if($('#tableCompIntPlana').DataTable().rows().count() > 0 &&
!$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) {
@ -1117,7 +1127,7 @@
})
function checkComparadorInt(is_color, is_hq, actualizarLinea=false) {
function checkComparadorInt(is_color, is_hq, actualizarLineaPlana=false, actualizarLineaRot=false) {
try{
@ -1130,26 +1140,26 @@
if ($(''+ elementos.papel).select2('data').length > 0 &&
$(''+ elementos.gramaje).select2('data').length > 0 &&
parseInt($(''+ elementos.paginas).val()) > 0 &&
parseInt($(''+ elementos.paginas).val()) >= 0 &&
checkDatosPedidoForComp()) {
getLineasIntPlana(is_color, is_hq, actualizarLinea).then((result) =>{
getLineasIntPlana(is_color, is_hq, actualizarLineaPlana).then((result) =>{
// Para rotativa, si es color el papel y el gramaje tiene que ser igual
if(!is_color)
{
getLineasIntRot(is_hq, actualizarLinea);
getLineasIntRot(is_hq, actualizarLineaRot);
}
else
{
if(!is_hq){
if ($('#compPapelNegro').select2('data')>0 && $('#compPapelColor').select2('data')>0 &&
$('#compGramajeNegro').select2('data')>0 && $('#compGramajeColor').select2('data')>0)
if ($('#compPapelNegro').select2('data').length>0 && $('#compPapelColor').select2('data').length>0 &&
$('#compGramajeNegro').select2('data').length>0 && $('#compGramajeColor').select2('data').length>0)
{
if(($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()))
{
getLineasIntRot(is_hq, actualizarLinea);
getLineasIntRot(is_hq, actualizarLineaRot);
}
else
{

View File

@ -26,6 +26,7 @@
<th></th>
<th></th>
<th></th>
<th></th>
<th class="lp-header" width="33px"></th>
<th class="lp-header" style="max-width:80px;"><?= lang('Presupuestos.paginas') ?></th>
<th class="lp-header"><?= lang('Presupuestos.papel') ?></th>
@ -158,7 +159,7 @@ function format(d) {
'</div>'+
'<div class="col-md-12 col-lg-1">' +
'<?= lang('Presupuestos.numPagColor') ?>' +
'<input type="text" id="' + d.row_id +'_numPagColor" name="' + d.row_id +'_numPagColor" class="lp-cell lp-input lp-cell-disabled" readonly value="' + d.numPagColor +'">' +
'<input type="text" id="' + d.row_id +'_numPagColor" name="' + d.row_id +'_numPagColor" class="lp-cell lp-input' + (d.row_id.includes('color')?'" ':' lp-cell-disabled" readonly ') + ' value="' + d.numPagColor +'">' +
'</div>' +
'<div class="col-md-12 col-lg-1">' +
'<?= lang('Presupuestos.saturacion') ?>' +
@ -365,7 +366,7 @@ const actionBtns_lp = function(data) {
searching: false,
paging: false,
info: false,
ordering: false,
ordering: true,
responsive: true,
select: false,
rowId: 'row_id',
@ -385,6 +386,15 @@ const actionBtns_lp = function(data) {
orderable: false,
visible: false,
},
{
targets: [11,12,13,14,15,16,17,18,19,20],
orderable: false,
},
{
targets: [10],
orderable: true,
visible: false,
},
{
orderable: false,
searchable: false,
@ -402,6 +412,23 @@ const actionBtns_lp = function(data) {
{data: 'formas_v'},
{data: 'formas_h'},
{data: 'formas_orientacion'},
{data: 'position',
type: "num" ,
render: function (data, type, row, meta){
if(row.row_id.includes('_bn')){
return 0;
}
else if(row.row_id.includes('_color')){
return 1;
}
else if(row.row_id.includes('_cubierta')){
return 2;
}
else if(row.row_id.includes('_sobrecubierta')){
return 3;
}
}
},
{data: 'icon',
render: function ( data, type, row, meta ){
return '<img style="padding: 0; margin:0;" src="' + data + '" />'
@ -537,7 +564,8 @@ const actionBtns_lp = function(data) {
data: actionBtns_lp,
className: 'row-edit dt-center'
}
]
],
"order": [ 10, 'asc' ]
});
tableLineasPresupuesto.on( 'draw.dt', function () {
@ -554,6 +582,9 @@ $(document).on('click', '.btn-delete-lp', function(e) {
.draw();
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
})
@ -861,7 +892,7 @@ $('.insertarLinea').on("click", function (e) {
$('#addLineasPresupuesto').on("change", function (e) {
var data = tableLineasPresupuesto
var dataRows = tableLineasPresupuesto
.rows()
.data();
@ -870,101 +901,148 @@ $('#addLineasPresupuesto').on("change", function (e) {
// (solo una de cada en interior)
case 'lp_bn':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_bn').length>0 ||
data.filter(x => x.row_id === 'lp_bnhq').length>0 ||
data.filter(x => x.row_id === 'lp_rot_bn').length>0 )
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_bn' ||
dataRows[number].row_id == 'lp_bnhq' ||
dataRows[number].row_id == 'lp_rot_bn'){
hayLinea = true
continue
}
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_bn', 'lp-bn');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_bn()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_bn', 'lp-bn');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_bn()
break
case 'lp_bnhq':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_bn').length>0 ||
data.filter(x => x.row_id === 'lp_bnhq').length>0 ||
data.filter(x => x.row_id === 'lp_rot_bn').length>0 )
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_bn' ||
dataRows[number].row_id == 'lp_bnhq' ||
dataRows[number].row_id == 'lp_rot_bn'){
hayLinea = true
continue
}
}
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_bnhq', 'lp-bnhq');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_bnhq()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_bnhq', 'lp-bnhq');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_bnhq()
break
case 'lp_color':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_color').length>0 ||
data.filter(x => x.row_id === 'lp_colorhq').length>0 ||
data.filter(x => x.row_id === 'lp_rot_color').length>0 )
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_color' ||
dataRows[number].row_id == 'lp_colorhq' ||
dataRows[number].row_id == 'lp_rot_color'){
hayLinea = true
continue
}
}
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_color', 'lp-color');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_color()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_color', 'lp-color');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_color()
break
case 'lp_colorhq':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_color').length>0 ||
data.filter(x => x.row_id === 'lp_colorhq').length>0 ||
data.filter(x => x.row_id === 'lp_rot_color').length>0 )
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_color' ||
dataRows[number].row_id == 'lp_colorhq' ||
dataRows[number].row_id == 'lp_rot_color'){
hayLinea = true
continue
}
}
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_colorhq', 'lp-colorhq');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_colorhq()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_colorhq', 'lp-colorhq');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_colorhq()
break
case 'lp_rot_bn':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_bn').length>0 ||
data.filter(x => x.row_id === 'lp_bnhq').length>0 ||
data.filter(x => x.row_id === 'lp_rot_bn').length>0 )
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_bn' ||
dataRows[number].row_id == 'lp_bnhq' ||
dataRows[number].row_id == 'lp_rot_bn'){
hayLinea = true
continue
}
}
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_rot_bn', 'lp-rot-bn');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_rot_bn()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_rot_bn', 'lp-rot-bn');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_rot_bn()
break
case 'lp_rot_color':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_color').length>0 ||
data.filter(x => x.row_id === 'lp_colorhq').length>0 ||
data.filter(x => x.row_id === 'lp_rot_color').length>0 )
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_color' ||
dataRows[number].row_id == 'lp_colorhq' ||
dataRows[number].row_id == 'lp_rot_color'){
hayLinea = true
continue
}
}
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_rot_color', 'lp-rot-color');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_rot_color()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_rot_color', 'lp-rot-color');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_rot_color()
break
case 'lp_cubierta':
if(data.length>0){
if( data.filter(x => x.row_id === 'lp_cubierta').length>0)
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
case 'lp_cubierta':
var hayLinea = false
for(let number=0;number<dataRows.length;number++){
if(dataRows[number].row_id == 'lp_cubierta'){
hayLinea = true
continue
}
}
else{
var data = processRowData({tipo_maquina: 'toner'}, 'lp_cubierta', 'lp-cubierta');
tableLineasPresupuesto.row.add(data).draw(true)
eventos_lp_cubierta()
if(hayLinea){
popErrorAlert('<?=lang('Presupuestos.errores.lineaDuplicada') ?>', 'divAlarmasLineasPresupuesto');
break
}
var data = processRowData({tipo_maquina: 'toner'}, 'lp_cubierta', 'lp-cubierta');
tableLineasPresupuesto.row.add(data).draw()
eventos_lp_cubierta()
break
default:
break
@ -1240,9 +1318,9 @@ function fill_lp_bn(row, fromComparator=false){
var row = tableLineasPresupuesto.row('#lp_bn');
if(row.length>0)
tableLineasPresupuesto.row('#lp_bn').data(data).draw(true)
tableLineasPresupuesto.row('#lp_bn').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_bn');
}
row.child(format(row.data())).show();
@ -1254,6 +1332,9 @@ function fill_lp_bn(row, fromComparator=false){
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
}
$("#tableLineasPresupuesto").DataTable().columns.adjust();
@ -1531,9 +1612,9 @@ function fill_lp_color(row, fromComparator=false){
var row = tableLineasPresupuesto.row('#lp_color');
if(row.length>0)
tableLineasPresupuesto.row('#lp_color').data(data).draw(true)
tableLineasPresupuesto.row('#lp_color').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_color');
}
row.child(format(row.data())).show();
@ -1545,6 +1626,9 @@ function fill_lp_color(row, fromComparator=false){
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
}
$("#tableLineasPresupuesto").DataTable().columns.adjust();
@ -1825,9 +1909,9 @@ function fill_lp_bnhq(row, fromComparator=false){
var row = tableLineasPresupuesto.row('#lp_bnhq');
if(row.length>0)
tableLineasPresupuesto.row('#lp_bnhq').data(data).draw(true)
tableLineasPresupuesto.row('#lp_bnhq').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_bnhq');
}
row.child(format(row.data())).show();
@ -1839,6 +1923,9 @@ function fill_lp_bnhq(row, fromComparator=false){
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
}
$("#tableLineasPresupuesto").DataTable().columns.adjust();
@ -2119,9 +2206,9 @@ function fill_lp_colorhq(row, fromComparator=false){
var row = tableLineasPresupuesto.row('#lp_colorhq');
if(row.length>0)
tableLineasPresupuesto.row('#lp_colorhq').data(data).draw(true)
tableLineasPresupuesto.row('#lp_colorhq').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_colorhq');
}
row.child(format(row.data())).show();
@ -2133,6 +2220,9 @@ function fill_lp_colorhq(row, fromComparator=false){
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
}
$("#tableLineasPresupuesto").DataTable().columns.adjust();
@ -2268,7 +2358,7 @@ function clear_lp_rot_bn(clear_selectors){
function change_lp_rot_bn_maquina(){
if(parseInt($('#lp_rot_bn_paginas').val())>0){
calcularPresupuesto_rot_bn();
calcularPresupuesto_rot_bn(true,false);
}
}
@ -2294,6 +2384,10 @@ function change_lp_rot_bn_aFavorFibra(){
$('#lp_rot_bn_gramaje option:selected').text().length>0 &&
parseInt($('#lp_rot_bn_papelImpresion option:selected').val())>0
){
var rowData = tableLineasPresupuesto.row('#lp_rot_bn').data()
rowData.aFavorFibra = $('#lp_rot_bn_aFavorFibra').prop('checked')
tableLineasPresupuesto.row('#lp_rot_bn').data(rowData).draw(false)
calcularPresupuesto_rot_bn(false, true);
}
@ -2313,7 +2407,7 @@ function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=fals
gramaje: $('#lp_rot_bn_gramaje option:selected').text().trim(),
maquina_id: $('#lp_rot_bn_maquina option:selected').val(),
papel_impresion_id: $('#lp_rot_bn_papelImpresion option:selected').val(),
fibra: $('#lp_rot_bn_aFavorFibra').prop('checked')
fibra: fromComparador==false? ($('#lp_rot_bn_aFavorFibra').prop('checked')?1:0):1
}
}
@ -2332,6 +2426,7 @@ function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=fals
papel_generico: input_data.papel_generico,
gramaje: input_data.gramaje,
cliente_id: $('#clienteId').find(":selected").val(),
a_favor_fibra: fromComparador==false? ($('#lp_rot_bn_aFavorFibra').prop('checked')?1:0):1,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
@ -2429,7 +2524,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
gramaje: row.gramaje,
papel_impresion_id: row.papelImpresionId,
maquina_id: row.maquinaId,
fibra: row.aFavorFibra=='no'?false:true
fibra: row.aFavorFibra=='no'?0:1
}
calcularPresupuesto_rot_bn(true, false, input_data);
@ -2442,9 +2537,9 @@ function fill_lp_rot_bn(row, fromComparador=false){
var row = tableLineasPresupuesto.row('#lp_rot_bn');
if(row.length>0)
tableLineasPresupuesto.row('#lp_rot_bn').data(data).draw(true)
tableLineasPresupuesto.row('#lp_rot_bn').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_rot_bn');
}
row.child(format(row.data())).show();
@ -2456,6 +2551,9 @@ function fill_lp_rot_bn(row, fromComparador=false){
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
}
$('.lp_rot_bn').css('display', '')
@ -2592,7 +2690,8 @@ function clear_lp_rot_color(clear_selectors){
function change_lp_rot_color_maquina(){
if(parseInt($('#lp_rot_color_paginas').val())>0){
calcularPresupuesto_rot_color();
calcularPresupuesto_rot_color(true,false);
}
}
@ -2617,7 +2716,10 @@ function change_lp_rot_color_aFavorFibra(){
$('#lp_rot_color_gramaje option:selected').text().length>0 &&
parseInt($('#lp_rot_color_papelImpresion option:selected').val())>0
){
var rowData = tableLineasPresupuesto.row('#lp_rot_color').data()
rowData.aFavorFibra = $('#lp_rot_color_aFavorFibra').prop('checked')
tableLineasPresupuesto.row('#lp_rot_color').data(rowData).draw(false)
calcularPresupuesto_rot_color(false, true);
}
}
@ -2636,17 +2738,19 @@ function calcularPresupuesto_rot_color(fromComparador=false, updatedTipologias=f
gramaje: $('#lp_rot_color_gramaje option:selected').text().trim(),
maquina_id: $('#lp_rot_color_maquina option:selected').val(),
papel_impresion_id: $('#lp_rot_color_papelImpresion option:selected').val(),
fibra: $('#lp_rot_bn_aFavorFibra').prop('checked')
fibra: fromComparador==false? ($('#lp_rot_color_aFavorFibra').prop('checked')?1:0):1
}
}
paginas_color = isNaN(parseInt($('#lp_rot_color_numPagColor').val()))?input_data.paginas:parseInt($('#lp_rot_color_numPagColor').val())
let datos = {
type: 'interior_rot',
color: 1,
hq: 0,
hq: 0,
paginas: input_data.paginas,
paginas_negro: input_data.paginas-parseInt($('#lp_rot_color_numPagColor').val()),
paginas_color: parseInt($('#lp_rot_color_numPagColor').val()),
paginas_negro: input_data.paginas-paginas_color,
paginas_color: paginas_color,
tirada: parseInt($('#tirada').val()),
merma: parseInt($('#merma').val()),
ancho: dimension.ancho,
@ -2655,6 +2759,7 @@ function calcularPresupuesto_rot_color(fromComparador=false, updatedTipologias=f
papel_generico: input_data.papel_generico,
gramaje: input_data.gramaje,
cliente_id: $('#clienteId').find(":selected").val(),
a_favor_fibra: fromComparador==false? ($('#lp_rot_color_aFavorFibra').prop('checked')?1:0):1,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
@ -2699,7 +2804,7 @@ function calcularPresupuesto_rot_color(fromComparador=false, updatedTipologias=f
value.fields.a_favor_fibra == input_data.fibra) {
value.fields.check_papel_total = $('#lp_rot_color' + '_checkPapel').is(":checked")?1:0
value.fields.check_impresion_total = $('#lp_rot_bn' + '_checkClicks').is(":checked")?1:0
value.fields.check_impresion_total = $('#lp_rot_color' + '_checkClicks').is(":checked")?1:0
fill_lp_rot_color(value.fields);
return false;
@ -2756,7 +2861,7 @@ function fill_lp_rot_color(row, fromComparador=false){
gramaje: row.gramaje,
papel_impresion_id: row.papelImpresionId,
maquina_id: row.maquinaId,
fibra: row.aFavorFibra=='no'?false:true
fibra: row.aFavorFibra=='no'?0:1
}
calcularPresupuesto_rot_color(true, false, input_data);
@ -2768,9 +2873,9 @@ function fill_lp_rot_color(row, fromComparador=false){
var row = tableLineasPresupuesto.row('#lp_rot_color');
if(row.length>0)
tableLineasPresupuesto.row('#lp_rot_color').data(data).draw(true)
tableLineasPresupuesto.row('#lp_rot_color').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_rot_color');
}
row.child(format(row.data())).show();
@ -2782,6 +2887,9 @@ function fill_lp_rot_color(row, fromComparador=false){
calcular_mermas()
updateTotales(true, false, false)
updateTablaEnvios()
// Si existe cubierta, hay que actualizar con el valor del lomo
check_update_cubierta()
}
$("#tableLineasPresupuesto").DataTable().columns.adjust();
@ -2795,6 +2903,7 @@ function eventos_lp_rot_color(){
$('#lp_rot_color_maquina').bind("focus", set_lp_rot_color_maquina);
$('#lp_rot_color_maquina').bind("change", change_lp_rot_color_maquina);
$('#lp_rot_color_paginas').bind("change", change_lp_rot_color_paginas);
$('#lp_rot_color_numPagColor').bind("change", change_lp_rot_color_paginas);
$('#lp_rot_color_vercalculos').bind("click", {rowId: 'lp_rot_color'}, verCalculosInkjet);
$('#lp_rot_color_aFavorFibra').bind("change", change_lp_rot_color_aFavorFibra);
$('.lp-rot-color-tipologia').bind("change", change_lp_rot_color_tipologia);
@ -2949,6 +3058,7 @@ function calcularPresupuesto_cubierta(fromComparador=false, input_data={}){
}
}
let datos = {
type: 'cubierta',
color: 1,
@ -2962,6 +3072,7 @@ function calcularPresupuesto_cubierta(fromComparador=false, input_data={}){
merma: parseInt($('#mermacubierta').val()),
ancho: dimension.ancho,
alto: dimension.alto,
lomo: getLomoLineasPresupuesto(),
papel_generico_id: input_data.papel_generico_id,
papel_generico: input_data.papel_generico,
gramaje: input_data.gramaje,
@ -3040,9 +3151,9 @@ function fill_lp_cubierta(row, fromComparador=false){
var row = tableLineasPresupuesto.row('#lp_cubierta');
if(row.length>0)
tableLineasPresupuesto.row('#lp_cubierta').data(data).draw(true)
tableLineasPresupuesto.row('#lp_cubierta').data(data).draw()
else{
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row('#lp_cubierta');
}
row.child(format(row.data())).show();
@ -3074,6 +3185,35 @@ function eventos_lp_cubierta(){
$('#lp_cubierta_checkClicks').bind("change", {id_linea: 'lp_cubierta'}, update_total_linea);
}
function check_update_cubierta(){
let row = tableLineasPresupuesto.row('#lp_cubierta');
if(row.length>0){
calcularPresupuesto_cubierta()
}
}
function getLomoLineasPresupuesto(){
let lomoTotal = 0
try{
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
lomoTotal += parseFloat(rowData.lomo)
})
}
catch(error){
lomoTotal = 0
}
return lomoTotal
}
fill_lp_from_bbdd()
function fill_lp_from_bbdd(){
@ -3170,7 +3310,7 @@ function fill_lp_from_bbdd(){
var row = tableLineasPresupuesto.row("#" + lp.tipo);
tableLineasPresupuesto.row.add(data).draw(true)
tableLineasPresupuesto.row.add(data).draw()
row = tableLineasPresupuesto.row("#" + lp.tipo);
row.child(format(row.data())).show();
@ -3314,6 +3454,7 @@ async function fill_bbdd_from_lp(presupuesto_id){
linea_data.rotativa_precio_hora_corte = rowData.precioHoraCorte
linea_data.rotativa_tiempo_corte = rowData.tiempoCorte
linea_data.rotativa_total_corte = rowData.totalCorte
linea_data.rotativa_a_favor_fibra = rowData.aFavorFibra==true?1:0
}
data.push(linea_data)
@ -3347,23 +3488,23 @@ function updateLineasPresupuesto(){
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
if(this.id.endsWith('_bn')){
checkComparadorInt(false, false, true);
if(this.id.endsWith('lp_bn')){
checkComparadorInt(false, false, true, false);
}
else if(this.id.endsWith('_bnhq')){
checkComparadorInt(false, true, true);
else if(this.id.endsWith('lp_bnhq')){
checkComparadorInt(false, true, true, false);
}
else if(this.id.endsWith('_color')){
checkComparadorInt(true, false, true);
else if(this.id.endsWith('lp_color')){
checkComparadorInt(true, false, true, false);
}
else if(this.id.endsWith('_colorhq')){
checkComparadorInt(true, true, true);
else if(this.id.endsWith('lp_colorhq')){
checkComparadorInt(true, true, true, false);
}
else if(this.id.endsWith('_rot_bn')){
checkComparadorInt(false, false, true)
else if(this.id.endsWith('lp_rot_bn')){
checkComparadorInt(false, false, false, true)
}
else if(this.id.endsWith('_rot_color')){
checkComparadorInt(false,true, true);
else if(this.id.endsWith('lp_rot_color')){
checkComparadorInt(false,true, false, true);
}
else if(this.id.endsWith('_cubierta')){
checkComparadorCubierta(true)

View File

@ -37,10 +37,10 @@
value="<?= lang("Basic.global.Save") ?>"
/>
<?php if (str_contains($formAction, 'edit')): ?>
<?= anchor(route_to("presupuestoToPdf"), lang("Basic.global.Print"), ["class" => "btn btn-dark float-start me-sm-3 me-1",]) ?>
<?= anchor(route_to("presupuestoToPdf", $presupuestoId), lang("Basic.global.Print"), ["class" => "btn btn-dark float-start me-sm-3 me-1",'target' => '_blank']) ?>
<?= anchor(route_to("#"), lang("Basic.global.Clone"), ["class" => "btn btn-info float-start me-sm-3 me-1",]) ?>
<?php endif; ?>
<?= anchor(route_to("cosidotapablandaList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
<?= anchor(route_to("cosidotapablandaList", $tipo_impresion_id), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div>
</form>
@ -142,17 +142,20 @@
type: "POST",
url: "<?php echo $formAction; ?>",
data: form,
success: function(data) {
yeniden(data. < ? = csrf_token() ? > )
popSuccessAlert(data.mensaje)
success: function (data) {
yeniden(data.<?= csrf_token() ?>)
if('errorMensaje' in data)
popErrorAlert(data.errorMensaje)
else
popSuccessAlert(data.mensaje)
}
}).fail(function(jqXHR, textStatus, error) {
}).fail(function (jqXHR, textStatus, error) {
// Handle error here
console.log(jqXHR)
});;
}))
return false; //stop the actual form post !important!
return false; //stop the actual form post !important!
});

View File

@ -52,12 +52,12 @@
}
// SOLO PARA TEST
$(document).on("keypress", function(event) {
/*$(document).on("keypress", function(event) {
if (event.keyCode === 112) {
event.preventDefault();
showBreadCrumbSaveButton(true);
}
});
});*/
$('#bc-save').on( "click", function() {
showBreadCrumbSaveButton(false);

View File

@ -94,7 +94,7 @@
<?php if (count($temp = getArrayItem($menus, 'name', 'Fresadotapablanda')) > 0): ?>
<?php if (count(getArrayItem($temp, 'methods', 'index', true)) > 0): ?>
<li class="menu-item">
<a href="<?= site_url("presupuestos/fresadotapablanda") ?>" class="menu-link">
<a href="<?= site_url("presupuestos/cosidotapablanda/list/2") ?>" class="menu-link">
<div data-i18n="<?= lang("App.menu_libros_fresasdo_tapa_blanda") ?>"><?= lang("App.menu_libros_fresasdo_tapa_blanda") ?></div>
</a>
</li>
@ -114,7 +114,7 @@
<?php if (count($temp = getArrayItem($menus, 'name', 'Cosidotapablanda')) > 0): ?>
<?php if (count(getArrayItem($temp, 'methods', 'index', true)) > 0): ?>
<li class="menu-item">
<a href="<?= site_url("presupuestos/cosidotapablanda") ?>" class="menu-link">
<a href="<?= site_url("presupuestos/cosidotapablanda/list/4") ?>" class="menu-link">
<div data-i18n="<?= lang("App.menu_libros_cosido_tapa_blanda") ?>"><?= lang("App.menu_libros_cosido_tapa_blanda") ?></div>
</a>
</li>

View File

@ -4,17 +4,16 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= "Presupuesto " . "TBC" ?></title>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/font-pdf.css') ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/all.css') ?>">
<!-- <link rel="stylesheet" href="--><?php //= site_url('themes/vuexy/css/all.css') ?><!--">-->
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/pdf.presupuesto.css') ?>">
<style>
@page {
margin: 18px;
margin: 10px;
}
body {
margin: 18px;
margin: 10px;
}
</style>
@ -37,34 +36,34 @@
PRESUPUESTO :
</th>
<th class="num_presupuesto">
<?= "obj->id" ?>
<?= $presupuesto->id ?>
</th>
<th class="intro_cliente">
CLIENTE:
</th>
<th class="cliente letra">
<?= "obj->customer->name" ?>
<?= $presupuesto->cliente ?>
</th>
<th class="intro_fecha">
FECHA:
</th>
<th class="fecha">
<?= date("d/m/Y") ?>
<?= date('d/m/Y', strtotime($presupuesto->fecha)); ?>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="6" class="titulo">
<span style="font-weight: bold">Título:</span> <?= "obj->titulo" ?>
<span style="font-weight: bold">Título:</span> <?= $presupuesto->titulo ?>
</td>
</tr>
<tr>
<td colspan="3" class="coleccion">
<span style="font-weight: bold">Colección:</span> <?= "obj->coleccion" ?>
<span style="font-weight: bold">Colección:</span> <?= $presupuesto->coleccion ?>
</td>
<td colspan="3" class="autor">
<span style="font-weight: bold">Autor:</span> <?= "obj->autor" ?>
<span style="font-weight: bold">Autor:</span> <?= $presupuesto->autor ?>
</td>
</tr>
</tbody>
@ -83,37 +82,39 @@
</tr>
<tr>
<td class="t">Ferro</td>
<td class="v">TBD</td>
<td class="v"><?php echo(($presupuesto->ferro == 1) ? "SI" : "NO"); ?></td>
<td class="t-first">Prototipo</td>
<td class="v-first">SI</td>
<td class="v-first"><?php echo(($presupuesto->prototipo == 1) ? "SI" : "NO"); ?></td>
<td class="t-second">Ferro Digital</td>
<td class="v-second">SI</td>
<td class="v-second"><?php echo(($presupuesto->ferro_digital == 1) ? "SI" : "NO"); ?></td>
</tr>
<tr>
<td class="t">Formato</td>
<td class="v" colspan="5">
<?= "obj->papel_formato->format()" ?> mm.
<?= (($presupuesto->isPersonalizado) ? $presupuesto->formatoPersonalizado : $presupuesto->formato) ?> mm
</td>
</tr>
<tr>
<td class="t">Nº de páginas totales</td>
<td class="v" colspan="5"><?= "obj->paginas" ?></td>
<td class="v" colspan="5"><?= $presupuesto->paginas ?></td>
</tr>
<tr>
<td class="t">Nº de páginas ByN</td>
<td class="v"><?= "paginas_negro" ?></td>
<td class="v"><?= $lp_ByN->paginas ?></td>
<td class="t-first">Papel</td>
<td class="v-first"><?= "papel_negro" ?></td>
<td class="v-first"><?= $lp_ByN->papel ?></td>
<td class="t-second">Gramaje</td>
<td class="v-second"><?= "gramaje_negro" ?></td>
<td class="v-second"><?= $lp_ByN->gramaje ?></td>
</tr>
<tr>
<td class="t">Nº de páginas Color</td>
<td class="v"><?= "paginas_color" ?></td>
<td class="v"><?= $lp_Color->paginas ?></td>
<td class="t-first">Papel</td>
<td class="v-first"><?= "papel_color" ?></td>
<td class="v-first"><?= $lp_Color->papel ?></td>
<td class="t-second">Gramaje</td>
<td class="v-second"><?= "gramaje_color" ?></td>
<td class="v-second"><?= $lp_Color->gramaje ?></td>
</tr>
</tbody>
</table>
@ -169,9 +170,9 @@
<td class="t">Tipo</td>
<td class="v"><?= "encuardernado" ?></td>
<td class="t-first">Solapas</td>
<td class="v-first"><?= "solapas_portada" ?></td>
<td class="v-first"><?php echo(($presupuesto->solapas == 1) ? "SI" : "NO"); ?></td>
<td class="t-second">Ancho</td>
<td class="v-second">TBD cm</td>
<td class="v-second"><?= $presupuesto->solapas_ancho ?> cm</td>
</tr>
</tbody>
</table>
@ -185,15 +186,15 @@
<tbody>
<tr>
<td class="t">Retractilado</td>
<td class="v" colspan="5">NO</td>
<td class="v" colspan="5"><?php echo(($presupuesto->retractilado == 1) ? "SI" : "NO"); ?></td>
</tr>
<tr>
<td class="t">Guardas</td>
<td class="v" colspan="5">NO</td>
<td class="v" colspan="5"><?php echo(($presupuesto->guardas == 1) ? "SI" : "NO"); ?></td>
</tr>
<tr>
<td class="t">Marcapáginas</td>
<td class="v" colspan="5">NO</td>
<td class="v" colspan="5"><?php echo(($presupuesto->marcapaginas == 1) ? "SI" : "NO"); ?></td>
</tr>
</tbody>
</table>
@ -204,45 +205,56 @@
<th class="intro_envio" colspan="10">ENVÍO</th>
</tr>
</thead>
<?php if (isset($envios_recogeCliente)) { ?>
<?php
if ($presupuesto->recoge_cliente == 1) { ?>
<tbody>
<tr>
<td colspan="10">El pedido será recogido por el cliente</td>
</tr>
</tbody>
<?php } else { ?>
<?php
} else {
if (count($direccionesEnvio) != 0) {
?>
<tbody>
<tbody>
<tr>
<td class="t-ejemplares">Ejemplares</td>
<td class="v-ejemplares"><?= "TBD" ?></td>
<td class="t-first-direccion">Dirección</td>
<td class="v-first-direccion" colspan="7"><?= "TBC" ?></td>
</tr>
<tr>
<td class="t">País</td>
<td class="v"><?= "TBC" ?></td>
<td class="t-first">Provincia</td>
<td class="v-first"><?= "TBC" ?></td>
<td class="t-second">C.P.</td>
<td class="v-second"><?= "TBC" ?></td>
<td class="t-third">Ciudad</td>
<td class="v-third"><?= "TBC" ?></td>
<td class="t-fourth">Telf.</td>
<td class="v-fourth"><?= "TBC" ?></td>
</tr>
</tbody>
<?php } ?>
<?php foreach ($direccionesEnvio as $direccionEnvio) { ?>
<tr>
<td class="t-ejemplares">Ejemplares</td>
<td class="v-ejemplares"><?= $direccionEnvio->cantidad ?></td>
<td class="t-first-direccion">Dirección</td>
<td class="v-first-direccion" colspan="7"><?= $direccionEnvio->direccion ?></td>
</tr>
<tr>
<td class="t">País</td>
<td class="v"><?= $direccionEnvio->pais ?></td>
<td class="t-first">Provincia</td>
<td class="v-first"><?= $direccionEnvio->provincia ?></td>
<td class="t-second">C.P.</td>
<td class="v-second"><?= $direccionEnvio->cp ?></td>
<td class="t-third">Ciudad</td>
<td class="v-third"><?= $direccionEnvio->municipio ?></td>
<td class="t-fourth">Telf.</td>
<td class="v-fourth"><?= $direccionEnvio->telefono ?></td>
</tr>
<?php } ?>
</tbody>
<?php
} else { ?>
<tbody>
<tr>
<td colspan="10">No hay definidos envíos</td>
</tr>
</tbody>
<?php
}
} ?>
</table>
<table class="totales" align="right">
<table class="totales">
<thead>
<tr>
<th class="hidden"></th>
<th class="hidden"></th>
<th>Tirada</th>
<th>U.Impresión 4%</th>
<th>U.Envío 21%</th>
<th>Precio**</th>
<th>Precio UD.</th>
<th>TOTAL CON IVA</th>
@ -250,45 +262,45 @@
</thead>
<tbody>
<tr>
<td class="hidden"></td>
<td class="hidden"></td>
<td class="tirada">TBD uds.</td>
<td class="precio">TBD €</td>
<td class="precio">TBD €</td>
<td class="precio">TBD €</td>
<td class="precio">TBD €</td>
<td class="precio">TBD €</td>
<td class="tirada"><?= $presupuesto->tirada ?> uds.</td>
<td class="precio"><?= $presupuesto->total_presupuesto ?> €</td>
<td class="precio"><?= $presupuesto->total_precio_unidad ?> €</td>
<td class="precio"><?= $presupuesto->total_presupuesto * 1.04 ?> €</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="iva" colspan="5">Estos precios no incluyen I.V.A.</td>
</tr>
</tfoot>
</table>
<?php if (isset($obj->comentarios_pdf)) { ?>
<h6 class="observaciones">OBSERVACIONES</h6>
<div class="comentarios">{!! nl2br($obj->comentarios_pdf) !!}</div>
<?php if (!empty($presupuesto->comentarios_pdf)) { ?>
<div class="observaciones">
<h6 class="observaciones">OBSERVACIONES</h6>
<div class="comentarios">
<?= nl2br($presupuesto->comentarios_pdf); ?>
</div>
</div>
<?php } ?>
<div class="footer" style="margin-top: 70px">
<p>Por la grave crisis de papel que está sufriendo el sector, este presupuesto deberá ser confirmado con su
<div class="footer">
<p class="texto-info">Por la grave crisis de papel que está sufriendo el sector, este presupuesto deberá ser
confirmado con su
comercial el día que se oficialice el pedido, dado que pueda darse la situación de que no haya stock
disponible o que su precio haya variado considerablemente, para así poder ofrecerle alternativas.</p>
<p class="texto-email">Esperando que los precios se ajusten a sus necesidades,<br/>
<?= "obj->customer->salesman->name" ?> <?= "obj->customer->salesman->lastname" ?> &bull;
email: <?= "obj->customer->salesman->email" ?></p>
<p class="texto-asteriscos">(*) En el formato de desarrollo de cubierta están contemplados los 3 mm. de vuelta
de solapas en caso de llevarlas.<br/>
(**) Estos precios están sujetos a análisis de cobertura de tinta del archivo PDF de interior.</p>
disponible o que su precio haya variado considerablemente, para así poder ofrecerle alternativas.
</p>
<p class="texto-email">
Esperando que los precios se ajusten a sus necesidades,<br/>
<?= $presupuesto->comercial ?> &bull; email: <?= $presupuesto->email_comercial ?>
</p>
<p class="texto-asteriscos">
(*) En el formato de desarrollo de cubierta están contemplados los 3 mm. de vuelta de solapas en caso de
llevarlas.<br/>
(**) Estos precios están sujetos a análisis de cobertura de tinta del archivo PDF de interior.
</p>
<span class="texto-presupuesto">
Este presupuesto se calcula en base a los datos aportados, por lo que su importe puede variar a la vista del original definitivo a imprimir si éste difiere de los datos inicialmente incluidos, en cuyo caso se le facilitará un nuevo presupuesto corregido para que lo apruebe antes de realizar el pedido.
<br/>
Este presupuesto es válido durante 30 días.</span>
Este presupuesto se calcula en base a los datos aportados, por lo que su importe puede variar a la vista del
original definitivo a imprimir si éste difiere de los datos inicialmente incluidos, en cuyo caso se le
facilitará un nuevo presupuesto corregido para que lo apruebe antes de realizar el pedido.<br/>
Este presupuesto es válido durante 30 días.
</span>
</div>
</main>
</body>
</html>

View File

@ -1,21 +1,46 @@
/* Presupuesto 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;
}
body table.presupuesto-data {
width: 100%;
font-size: 12px;
margin-top: -22px;
}
body table.presupuesto-data th {
@ -83,8 +108,6 @@ body table.presupuesto-data td.autor {
body table.impresion {
width: 100%;
font-size: 11px;
margin-bottom: 9px;
margin-top: 8px;
}
body table.impresion th {
@ -137,7 +160,7 @@ body table.impresion td.v-first {
body table.cubierta {
width: 100%;
font-size: 11px;
margin-bottom: 9px;
margin-top: -2px;
}
body table.cubierta th {
@ -185,7 +208,7 @@ body table.cubierta td.v-first {
body table.encuadernacion {
width: 100%;
font-size: 11px;
margin-bottom: 9px;
margin-top: -2px;
}
body table.encuadernacion th {
@ -218,7 +241,7 @@ body table.encuadernacion td.v-first {
border-right: 1px dotted black;
}
body table.encuadernacion tdv.second {
body table.encuadernacion td.v.second {
width: 8%;
border-left: 1px dotted black;
border-right: 1px dotted black;
@ -240,7 +263,7 @@ body table.encuadernacion td.t-second {
body table.extras {
width: 100%;
font-size: 11px;
margin-bottom: 9px;
margin-top: -2px;
}
body table.extras th {
@ -266,7 +289,8 @@ body table.extras td.t {
body table.envio {
width: 100%;
font-size: 11px;
margin-bottom: 9px;
margin-top: -2px;
margin-bottom: 5px;
}
body table.envio th {
@ -328,30 +352,24 @@ body table.envio td.t-first {
}
body table.totales {
width: 64%;
margin-left: auto;
margin-right: 0;
width: 50%;
text-align: center;
}
body table.totales th {
width: 12%;
width: 16%;
font-weight: bold;
font-size: 12px;
font-size: 11px;
text-align: center;
color: white;
background: #0C2C84;
padding: 3px;
}
body table.totales th.u_envio_21 {
width: 16%;
}
body table.totales th.hidden {
background: none;
}
body table.totales td {
font-size: 12px;
font-size: 11px;
font-weight: bold;
text-align: center;
border: 1px dotted #4e4e4e;
@ -360,29 +378,13 @@ body table.totales td {
}
body table.totales td.tirada {
width: 12%;
border-left: none;
}
body table.totales td.precio,
body table.totales td.u_impresion_4 {
width: 12%;
body table.totales td.precio {
}
body table.totales td.precio_ud {
width: 12%;
border-right: none;
}
body table.totales td.iva {
border: none;
text-align: right;
font-size: 10px;
}
body table.totales td.hidden {
border: none !important;
}
/* Presupuesto Manual */
@ -491,9 +493,21 @@ div.comentarios {
padding-right: 10px;
}
div.observaciones {
padding: 15px;
}
div.footer {
font-size: 10pt;
text-align: left;
padding: 15px;
position: fixed;
bottom: 0;
font-size: 12px;
text-align: justify;
}
div.footer .taxto-info {
}
div.footer .texto-email {
@ -501,6 +515,7 @@ div.footer .texto-email {
}
div.footer .texto-asteriscos {
margin-top: 20px;
font-size: 11px;
}
@ -541,215 +556,3 @@ table.pedido-maquetacion-totales td.iva_right {
font-size: 10px;
margin-top: 2px;
}
#tablacentral {
border-top-width: 0;
border-left-width: 1px;
border-right-width: 1px;
border-bottom-width: 0;
text-align: center;
font-size: 9pt;
}
#tablanoborde {
border-top-width: 0;
border-left-width: 0;
border-right-width: 0;
border-bottom-width: 0;
}
#tabla {
border-style: solid;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
font-size: 7pt;
font-weight: bold;
}
#tabladato {
font-size: 9pt;
font-weight: normal;
float: center;
}
#tablaesquina {
border-style: solid;
border-top-width: 0;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 0;
}
#tdinteriorabajo {
border-top: none;
border-bottom: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
text-align: center;
font-size: 10px;
height: -40px;
}
#tdinteriorarriba {
border-bottom: none;
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
font-weight: bold;
font-size: 12px;
height: -40px;
padding-left: 2px;
padding-top: 1px;
}
#tdinteriorarribacliente {
border-top: 1px solid;
border-left: 1px solid;
border-bottom: 1px solid;
border-right: none;
font-weight: bold;
font-size: 12px;
height: -40px;
padding-left: 2px;
padding-top: 1px;
}
#tdinteriorarribaclientedato {
border-top: 1px solid;
border-left: none;
border-bottom: 1px solid;
border-right: 1px solid;
font-size: 12px;
height: -40px;
padding-left: 2px;
padding-top: 1px;
}
#tdniarribaniabajo {
border-bottom: none;
border-top: none;
border-left: 1px solid;
border-right: 1px solid;
font-size: 12px;
text-align: center;
}
#tdniarribaniabajoopciones {
border-bottom: none;
border-top: none;
border-left: 1px solid;
border-right: 1px solid;
font-size: 10px;
}
#tdniarribaniabajo2 {
border-bottom: none;
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
font-size: 12px;
text-align: center;
font-weight: bold;
}
#tdniarribaniabajo3 {
border-bottom: 1px solid;
border-top: none;
border-left: 1px solid;
border-right: 1px solid;
font-size: 12px;
text-align: center;
}
#subtdabajocentro {
border-bottom: 1px solid;
border-top: none;
border-left: 1px solid;
border-right: 1px solid;
text-align: center;
font-size: 9pt;
}
#subtd {
border-top: none;
border-bottom: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
text-align: center;
font-size: 12px;
}
#subtdcen {
border-top: none;
border-bottom: 1px solid #919191;
border-left: 1px solid #919191;
border-right: 1px solid #919191;
text-align: center;
font-size: 12px;
background-color: #77B2D0;
color: white;
}
#subtdizq {
border-top: none;
border-bottom: 1px solid #919191;
border-right: 1px solid #919191;
text-align: center;
font-size: 12px;
color: white;
background-color: #77B2D0;
}
#subtdder {
border-top: none;
border-bottom: 1px solid #919191;
border-left: 1px solid #919191;
text-align: center;
font-size: 12px;
color: white;
background-color: #77B2D0;
}
#tdarriba {
border-bottom: none;
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
font-size: 12px;
}
#tdarribaopciones {
border-bottom: none;
border-top: 1px solid;
border-left: 1px solid;
border-right: 1px solid;
font-size: 10px;
}
#tdabajo {
border-bottom: 1px solid;
border-top: none;
border-left: 1px solid;
border-right: 1px solid;
font-size: 12px;
}
#dato {
text-align: center;
font-size: 9pt;
}
#subrayado {
font-size: 9pt;
border-bottom: 1px solid;
}
#td {
font-size: 12px;
}
#tdopciones {
font-size: 10px;
}