Merge branch 'mod/exceso_solapas_cubierta_sobrecubierta' into 'main'

Mod/exceso solapas cubierta sobrecubierta

See merge request jjimenez/safekat!494
This commit is contained in:
2025-01-23 13:30:32 +00:00
9 changed files with 347 additions and 124 deletions

View File

@ -328,12 +328,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$this->viewData['POD'] = $this->getPOD(); $this->viewData['POD'] = $this->getPOD();
$this->viewData['serviciosAutomaticos'] = [ $this->viewData['serviciosAutomaticos'] = [
'solapas_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_cubierta')->value,
'solapas_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_sobrecubierta')->value,
'solapas_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_faja')->value,
'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value, 'retractilado' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value,
'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value, 'retractilado5' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value,
'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value, 'ferro' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value,
'prototipo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value, 'prototipo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value,
'plegado_guardas' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value, 'plegado_guardas' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value,
'solapas_grandes' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas')->value, 'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value,
'solapas_grandes_sobrecubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value,
'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value,
]; ];
$this->viewData['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; // Cosido tapa blanda JJO $this->viewData['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; // Cosido tapa blanda JJO
@ -1574,6 +1579,11 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
{ {
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id); $lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
$modelPapel = new PapelGenericoModel();
foreach ($lineas as $linea) {
$linea->papel_generico = (new PapelGenericoModel())->find($linea->papel_id)->nombre;
}
$input_data = []; $input_data = [];
$input_data['presupuesto'] = $presupuestoEntity; $input_data['presupuesto'] = $presupuestoEntity;

View File

@ -758,7 +758,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$anchoTotal += $interior[1]['mano']; $anchoTotal += $interior[1]['mano'];
} else { } else {
if (count($interior) > 0) if (count($interior) > 0)
$anchoTotal += $interior['mano']; $anchoTotal += $interior[0]['mano'];
} }
@ -1300,20 +1300,69 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
foreach ($resultado_presupuesto['values']['serviciosDefecto']['manipulado'] as $servicio) { foreach ($resultado_presupuesto['values']['serviciosDefecto']['manipulado'] as $servicio) {
$this->guardarServicio($id, $servicio, 'manipulado'); $this->guardarServicio($id, $servicio, 'manipulado');
} }
$servicio_ferro = (object) [
'nombre' => 'ferro',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value
];
$servicio_prototipo = (object) [
'nombre' => 'prototipo',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_prototipo')->value
];
$servicio_retractilado = (object) [
'nombre' => 'retractilado',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado')->value
];
$servicio_retractilado5 = (object) [
'nombre' => 'retractilado5',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_retractilado5')->value
];
$servicio_plegado_guardas = (object) [
'nombre' => 'plegado_guardas',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value
];
$servicio_solapas_cubierta = (object) [
'nombre' => 'solapas_cubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_cubierta')->value
];
$servicio_solapas_sobrecubierta = (object) [
'nombre' => 'solapas_sobrecubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_sobrecubierta')->value
];
$servicio_solapas_faja = (object) [
'nombre' => 'solapas_faja',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_faja')->value
];
$servicio_solapas_grandes_cubierta = (object) [
'nombre' => 'solapas_grandes_cubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value
];
$servicio_solapas_grandes_sobrecubierta = (object) [
'nombre' => 'solapas_grandes_sobrecubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value
];
$servicio_solapas_grandes_faja = (object) [
'nombre' => 'solapas_grandes_faja',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value
];
foreach ($resultado_presupuesto['values']['servicios_automaticos'] as $servicio) { foreach ($resultado_presupuesto['values']['servicios_automaticos'] as $servicio) {
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) { if ($servicio->tarifa_id == $servicio_retractilado->id || $servicio->tarifa_id == $servicio_retractilado5->id) {
// Servicios acabado // Servicios acabado
$this->guardarServicio($id, $servicio, 'acabado'); $this->guardarServicio($id, $servicio, 'acabado');
} else if ($servicio->tarifa_id == 24) { } else if ($servicio->tarifa_id == $servicio_ferro->id || $servicio->tarifa_id == $servicio_prototipo->id) {
// Servicios preimpresion
$this->guardarServicio($id, $servicio, 'preimpresion');
} else if ($servicio->tarifa_id == 9) {
// Servicios extra // Servicios extra
$this->guardarServicio($id, $servicio, 'extra'); $this->guardarServicio($id, $servicio, 'extra');
} else if ($servicio->tarifa_id == 62) { } else if ($servicio->tarifa_id == $servicio_plegado_guardas->id) {
// Servicios manipulado // Servicios manipulado
$this->guardarServicio($id, $servicio, 'manipulado'); $this->guardarServicio($id, $servicio, 'manipulado');
} else if ($servicio->tarifa_id == 73) { } else if (
$servicio->tarifa_id == $servicio_solapas_cubierta->id ||
$servicio->tarifa_id == $servicio_solapas_sobrecubierta->id ||
$servicio->tarifa_id == $servicio_solapas_faja->id ||
$servicio->tarifa_id == $servicio_solapas_grandes_cubierta->id ||
$servicio->tarifa_id == $servicio_solapas_grandes_sobrecubierta->id ||
$servicio->tarifa_id == $servicio_solapas_grandes_faja->id
) {
// Servicios manipulado // Servicios manipulado
$this->guardarServicio($id, $servicio, 'manipulado'); $this->guardarServicio($id, $servicio, 'manipulado');
} }
@ -2287,12 +2336,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
// Servicios // Servicios
$serviciosAutomaticos = []; $serviciosAutomaticos = [];
$servicios = []; $servicios = [];
$servicio_ferro = (object) [ $servicio_ferro = (object) [
'nombre' => 'ferro', 'nombre' => 'ferro',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_ferro')->value
@ -2313,9 +2359,29 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'nombre' => 'plegado_guardas', 'nombre' => 'plegado_guardas',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_guardas')->value
]; ];
$servicio_solapas_grandes = (object) [ $servicio_solapas_cubierta = (object) [
'nombre' => 'solapas_grandes', 'nombre' => 'solapas_cubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas')->value 'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_cubierta')->value
];
$servicio_solapas_sobrecubierta = (object) [
'nombre' => 'solapas_sobrecubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_sobrecubierta')->value
];
$servicio_solapas_faja = (object) [
'nombre' => 'solapas_faja',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas_faja')->value
];
$servicio_solapas_grandes_cubierta = (object) [
'nombre' => 'solapas_grandes_cubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->value
];
$servicio_solapas_grandes_sobrecubierta = (object) [
'nombre' => 'solapas_grandes_sobrecubierta',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_sobrecubierta')->value
];
$servicio_solapas_grandes_faja = (object) [
'nombre' => 'solapas_grandes_faja',
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value
]; ];
// se comprueba si $datos guardas es un array // se comprueba si $datos guardas es un array
@ -2337,8 +2403,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
array_push($servicios, $servicio_prototipo); array_push($servicios, $servicio_prototipo);
if ($datos_entrada['servicios']['ferro']) // extra if ($datos_entrada['servicios']['ferro']) // extra
array_push($servicios, $servicio_ferro); array_push($servicios, $servicio_ferro);
/*if ($datos_entrada['servicios']['ferroDigital']) if ($input_data['datosPedido']->solapas_ancho > 0)
array_push($servicios, 29);*/ // Es gratis array_push($servicios, $servicio_solapas_cubierta);
if (!is_null($sobreCubierta) && $sobreCubierta) // Si hay sobrecubierta, siempre con solapas
array_push($servicios, $servicio_solapas_sobrecubierta);
/* TO-DO
if (!is_null($faja) && $faja) // Si hay faja, siempre con solapas
array_push($servicios, $servicio_solapas_faja);
*/
foreach ($servicios as $servicio) { foreach ($servicios as $servicio) {
if ($servicio->nombre == "retractilado" || $servicio->nombre == "retractilado5") { if ($servicio->nombre == "retractilado" || $servicio->nombre == "retractilado5") {
@ -2377,7 +2450,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$resultado = PresupuestoCLienteService::getServiciosExtra([ $resultado = PresupuestoCLienteService::getServiciosExtra([
'tarifa_id' => intval($servicio->id), 'tarifa_id' => intval($servicio->id),
]); ]);
array_push($serviciosAutomaticos, $resultado[0]);
if ($resultado[0]->precio <= 0) { if ($resultado[0]->precio <= 0) {
$errorModel = new ErrorPresupuesto(); $errorModel = new ErrorPresupuesto();
@ -2395,6 +2468,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return $return_data; return $return_data;
} }
array_push($serviciosAutomaticos, $resultado[0]);
$coste_servicios += floatval($resultado[0]->precio); $coste_servicios += floatval($resultado[0]->precio);
if ($extra_info) { if ($extra_info) {
@ -2402,21 +2476,49 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0; $margenServicios += floatval($resultado[0]->precio) * floatval($resultado[0]->margen) / 100.0;
} }
} }
else if ($servicio->nombre == 'solapas_cubierta' || $servicio->nombre == 'solapas_sobrecubierta' || $servicio->nombre == 'solapas_faja'){
// Servicios manipulado
$resultado = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => intval($servicio->id),
'tirada' => $datosPedido->tirada,
'POD' => $POD,
]);
if ($resultado[0]->total <= 0) {
$errorModel = new ErrorPresupuesto();
$errorModel->insertError(
$datos_entrada['id'],
auth()->user()->id,
'No se puede obtener servicio de manupulado con ' . ((string) $servicio->nombre),
$input_data
);
$return_data = [
'errors' => (object) ([
'status' => 1
]),
];
return $return_data;
} else {
array_push($serviciosAutomaticos, $resultado[0]);
}
$coste_servicios += floatval($resultado[0]->total);
if ($extra_info) {
$totalServicios += floatval($resultado[0]->total);
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
}
}
} }
// Plegado de solapas grandes // Plegado de solapas grandes
if ( if (intval($solapasCubierta) > 0 && intval($cubierta['dimension_desarrollo']['ancho']) > 630) {
(intval($solapasCubierta) > 0 && intval($cubierta['dimension_desarrollo']['ancho']) > 630) || // Servicios manipulado
(is_array($sobreCubierta) && ($sobreCubierta['solapas'] > 0 && intval($linea_sobrecubierta['dimension_desarrollo']['ancho']) > 630))
) {
// Servicios acabado
$resultado = PresupuestoCLienteService::getServiciosManipulado([ $resultado = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => intval($servicio_solapas_grandes->id), 'tarifa_id' => intval($servicio_solapas_grandes_cubierta->id),
'tirada' => $datosPedido->tirada, 'tirada' => $datosPedido->tirada,
'POD' => $POD, 'POD' => $POD,
]); ]);
array_push($serviciosAutomaticos, $resultado[0]);
if ($resultado[0]->total <= 0) { if ($resultado[0]->total <= 0) {
@ -2424,7 +2526,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$errorModel->insertError( $errorModel->insertError(
$datos_entrada['id'], $datos_entrada['id'],
auth()->user()->id, auth()->user()->id,
'No se puede obtener servicio de manupulado con id ' . ((string) $servicio), 'No se puede obtener servicio de manupulado con ' . ((string) $servicio->nombre),
$input_data $input_data
); );
$return_data = [ $return_data = [
@ -2433,6 +2535,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
]), ]),
]; ];
return $return_data; return $return_data;
} else {
array_push($serviciosAutomaticos, $resultado[0]);
} }
$coste_servicios += floatval($resultado[0]->total); $coste_servicios += floatval($resultado[0]->total);
@ -2440,9 +2544,45 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$totalServicios += floatval($resultado[0]->total); $totalServicios += floatval($resultado[0]->total);
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0; $margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
} }
} }
if (is_array($sobreCubierta) && ($sobreCubierta['solapas'] > 0 && intval($linea_sobrecubierta['dimension_desarrollo']['ancho']) > 630)) {
// Servicios manipulado
$resultado = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => intval($servicio_solapas_grandes_sobrecubierta->id),
'tirada' => $datosPedido->tirada,
'POD' => $POD,
]);
if ($resultado[0]->total <= 0) {
$errorModel = new ErrorPresupuesto();
$errorModel->insertError(
$datos_entrada['id'],
auth()->user()->id,
'No se puede obtener servicio de manupulado ' . ((string) $servicio->nombre),
$input_data
);
$return_data = [
'errors' => (object) ([
'status' => 1
]),
];
return $return_data;
} else {
array_push($serviciosAutomaticos, $resultado[0]);
}
$coste_servicios += floatval($resultado[0]->total);
if ($extra_info) {
$totalServicios += floatval($resultado[0]->total);
$margenServicios += floatval($resultado[0]->total) * floatval($resultado[0]->margen) / 100.0;
}
}
// TO-DO Faja
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4)); array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios) / $tirada[$t], 4));
array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2)); array_push($peso, round($peso_interior + $peso_cubierta + $peso_sobrecubierta + $peso_guardas, 2));

View File

@ -385,6 +385,7 @@ return [
'noInterior' => 'No se hay resultados para el interior', 'noInterior' => 'No se hay resultados para el interior',
'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta', 'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta',
'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador', 'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador',
'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa'
], ],
]; ];

View File

@ -330,9 +330,8 @@ class PresupuestoLineaModel extends \App\Models\BaseModel
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"*, t2.nombre AS papel_generico" "*"
) )
->join("lg_papel_generico t2", "t1.papel_id = t2.id", "left")
->where("t1.presupuesto_id", $presupuesto_id); ->where("t1.presupuesto_id", $presupuesto_id);
return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); return $builder->orderBy("t1.id", "asc")->get()->getResultObject();

View File

@ -116,10 +116,9 @@
<div class="mb-1"> <div class="mb-1">
<div class="form-check form-switch mb-2"> <div class="form-check form-switch mb-2">
<input class="form-check-input solapas_sobrecubierta" type="checkbox" <input class="form-check-input solapas_sobrecubierta" type="checkbox"
id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1" id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1">
onclick="return false;">
<label class="form-check-label" <label class="form-check-label"
for="solapas_sobrecubierta"><?= lang('Presupuestos.solapasSobrecubierta') ?></label> for="solapas_sobrecubierta"><?= lang('Presupuestos.sobrecubierta') ?></label>
</div> </div>
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
</div> </div>
@ -301,12 +300,27 @@
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
</div><!--//.col --> </div><!--//.col -->
<input type="checkbox" id="serv_solapas_cubierta" name="serv_solapas_cubierta" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_cubierta'] ?>>
<input type="checkbox" id="serv_solapas_sobrecubierta" name="serv_solapas_sobrecubierta" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_sobrecubierta'] ?>>
<input type="checkbox" id="solapas_faja" name="solapas_faja" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_faja'] ?>>
<input type="checkbox" id="plegado_guardas" name="plegado_guardas" value="1" <input type="checkbox" id="plegado_guardas" name="plegado_guardas" value="1"
class="form-check-input d-none" service="manipulado" class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['plegado_guardas'] ?>> service-id=<?= $serviciosAutomaticos['plegado_guardas'] ?>>
<input type="checkbox" id="solapas_grandes" name="solapas_grandes" value="1" <input type="checkbox" id="solapas_grandes_cubierta" name="solapas_grandes_cubierta" value="1"
class="form-check-input d-none" service="manipulado" class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_grandes'] ?>> service-id=<?= $serviciosAutomaticos['solapas_grandes_cubierta'] ?>>
<input type="checkbox" id="solapas_grandes_sobrecubierta" name="solapas_grandes_sobrecubierta"
value="1" class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_grandes_sobrecubierta'] ?>>
<input type="checkbox" id="solapas_grandes_faja" name="solapas_grandes_faja" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_grandes_faja'] ?>>
</div> </div>

View File

@ -85,8 +85,8 @@ class PresupuestoAdminEdit {
alto: () => this.getDimensionLibro().alto, alto: () => this.getDimensionLibro().alto,
lomo: () => $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()), lomo: () => $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
lomoSobrecubierta: () => $('#lomo_sobrecubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_sobrecubierta').val()), lomoSobrecubierta: () => $('#lomo_sobrecubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_sobrecubierta').val()),
solapa: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0, solapas: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0,
solapa_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0, solapas_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0,
lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0, lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0,
} }
); );
@ -113,6 +113,9 @@ class PresupuestoAdminEdit {
$(document).on('update-presupuesto', this.updatePresupuesto.bind(this)); $(document).on('update-presupuesto', this.updatePresupuesto.bind(this));
this.guardar.on('click', this.guardarPresupuesto.bind(this)); this.guardar.on('click', this.guardarPresupuesto.bind(this));
$('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta);
$('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta);
} }

View File

@ -244,7 +244,11 @@ class Comparador {
this.gramajeSobrecubierta.init(); this.gramajeSobrecubierta.init();
this.papelSobrecubierta.onChange(() => self.gramajeSobrecubierta.empty()); this.papelSobrecubierta.onChange(() => self.gramajeSobrecubierta.empty());
this.sobrecubierta.on('change', () => { this.sobrecubierta.on('change', () => {
if (this.sobrecubierta.val() == 1) { if (this.sobrecubierta.select2('data')[0].id == 1) {
if($('#solapas_sobrecubierta').prop('checked') == false){
this.sobrecubierta.val(0);
popErrorAlert(window.language.Presupuestos.errores.error_sobrecubierta_sin_solapas, 'divAlarmasComparador')
}
$('#solapas_sobrecubierta').prop('checked', true); $('#solapas_sobrecubierta').prop('checked', true);
$('#div_solapas_ancho_sobrecubierta').removeClass('d-none'); $('#div_solapas_ancho_sobrecubierta').removeClass('d-none');
$('#solapas_ancho_sobrecubierta').val(60); $('#solapas_ancho_sobrecubierta').val(60);
@ -316,7 +320,6 @@ class Comparador {
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) { if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
$('.comp_guardas_items').on('change', this.obtenerComparadorGuardas.bind(this)); $('.comp_guardas_items').on('change', this.obtenerComparadorGuardas.bind(this));
} }
} }
#changePaginasComparador(element) { #changePaginasComparador(element) {

View File

@ -89,6 +89,9 @@ class DatosLibro {
this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this)); this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this));
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this)); this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
this.anchoSolapasCubierta.on('change', this.changeAnchoSolapasCubierta.bind(this));
this.anchoSolapasSobrecubierta.on('change', this.changeAnchoSolapasSobrecubierta.bind(this));
this.paginas.on('change', this.changePaginas.bind(this)); this.paginas.on('change', this.changePaginas.bind(this));
this.tirada.on('change', this.changeTirada.bind(this)); this.tirada.on('change', this.changeTirada.bind(this));
} }
@ -211,21 +214,30 @@ class DatosLibro {
setTimeout(() => { setTimeout(() => {
if (this.solapasCubierta.prop('checked')) { if (this.solapasCubierta.prop('checked')) {
$('#div_solapas_ancho').removeClass('d-none'); $('#div_solapas_ancho').removeClass('d-none');
$(document).trigger('add-servicio-lineas', 'solapas'); $(document).trigger('add-servicio-lineas', 'solapas_cubierta');
} }
else { else {
$('#div_solapas_ancho').addClass('d-none'); $('#div_solapas_ancho').addClass('d-none');
this.anchoSolapasCubierta.val(60); $(document).trigger('remove-servicio-lineas', 'solapas_cubierta');
$(document).trigger('remove-servicio-lineas', 'solapas'); $(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
} }
}, 100); }, 100);
$(document).trigger('update-presupuesto', {
update_lineas : false, // para que se actualice el comparador
update_servicios : true, $('paginas').trigger('change');
update_envios: false, }
update_resumen: false,
update_tiradas_alternativas: false changeAnchoSolapasCubierta(){
});
if(this.checkSolapasGrandes('cubierta')){
$(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta');
}
else{
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta');
}
// para que se actualice el comparador
$('paginas').trigger('change');
} }
@ -233,21 +245,53 @@ class DatosLibro {
if (this.solapasSobrecubierta.prop('checked')) { if (this.solapasSobrecubierta.prop('checked')) {
this.divSolapasSobrecubierta.removeClass('d-none'); this.divSolapasSobrecubierta.removeClass('d-none');
$(document).trigger('remove-servicio-lineas', 'solapas'); $(document).trigger('add-servicio-lineas', 'solapas_sobrecubierta');
} }
else { else {
this.divSolapasSobrecubierta.addClass('d-none'); this.divSolapasSobrecubierta.addClass('d-none');
this.anchoSolapasSobrecubierta.val(60); $(document).trigger('remove-servicio-lineas', 'solapas_sobrecubierta');
$(document).trigger('add-servicio-lineas', 'solapas'); $(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
if ($('#compSobrecubierta').length) {
$('#compSobrecubierta').val(0).trigger('change');
}
} }
$(document).trigger('update-presupuesto', { }
update_lineas : false,
update_servicios : true,
update_envios: false,
update_resumen: false,
update_tiradas_alternativas: false
});
changeAnchoSolapasSobrecubierta(){
if(this.checkSolapasGrandes('cubierta')){
$(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta');
}
else{
$(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta');
}
// para que se actualice el comparador
$('paginas').trigger('change');
}
checkSolapasGrandes(elemento) {
const ancho_libro = 2 * this.getDimensionLibro().ancho;
let ancho_solapas = 0.0;
let lomo = 0.0;
if(elemento == 'cubierta'){
ancho_solapas = 2 * parseFloat($('solapas_ancho').val());
lomo = parseFloat($('lomo_cubierta').val());
}
else if (elemento == 'sobrecubierta'){
ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val());
lomo = parseFloat($('lomo_sobrecubierta').val());
}
else
return false;
if (ancho_libro + ancho_solapas + lomo > 630)
return true;
else
return false
} }
changePaginas() { changePaginas() {
@ -389,7 +433,7 @@ class DatosLibro {
if (datos.solapasCubierta) { if (datos.solapasCubierta) {
this.solapasCubierta.prop('checked', true); this.solapasCubierta.prop('checked', true);
this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho); this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho);
this.divSolapasSobrecubierta.removeClass('d-none'); this.divSolapasCubierta.removeClass('d-none');
} }
else { else {
this.solapasCubierta.prop('checked', false); this.solapasCubierta.prop('checked', false);

View File

@ -110,9 +110,6 @@ class Servicios {
else if (servicio == 'acabadoSobrecubierta') { else if (servicio == 'acabadoSobrecubierta') {
this.serviciosAcabado.updateAcabadosExteriores(0, 1); this.serviciosAcabado.updateAcabadosExteriores(0, 1);
} }
else if (servicio == 'solapas') {
this.ServiciosManipulado.addSolapas();
}
else if (servicio == 'ferro'){ else if (servicio == 'ferro'){
const id = $('#ferro').attr('service-id'); const id = $('#ferro').attr('service-id');
this.serviciosExtra.getPresupuestoExtra(id); this.serviciosExtra.getPresupuestoExtra(id);
@ -139,56 +136,115 @@ class Servicios {
}; };
this.ServiciosManipulado.getPresupuestoManipulado(id); this.ServiciosManipulado.getPresupuestoManipulado(id);
} }
else if (servicio == 'solapas_cubierta'){
const id = $('#serv_solapas_cubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_sobrecubierta'){
const id = $('#serv_solapas_sobrecubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_grandes_cubierta'){
const id = $('#solapas_grandes_cubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_grandes_sobrecubierta'){
const id = $('#solapas_grandes_sobrecubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
} }
removeServicio(event, servicio) { removeServicio(event, servicio) {
if (servicio == 'solapas') {
this.ServiciosManipulado.removeSolapas(); if (servicio == 'ferro'){
}
else if (servicio == 'ferro'){
const id = $('#ferro').attr('service-id'); const id = $('#ferro').attr('service-id');
this.serviciosExtra.table.rows().every(function () { this.serviciosExtra.table.rows().every(function () {
var data = this.data(); let data = this.data();
if (data.tarifa_id == id) { if (data.tarifa_id == id) {
this.remove().draw(); this.remove();
} }
}); });
this.serviciosExtra.table.draw();
} }
else if (servicio == 'prototipo'){ else if (servicio == 'prototipo'){
const id = $('#prototipo').attr('service-id'); const id = $('#prototipo').attr('service-id');
this.serviciosExtra.table.rows().every(function () { this.serviciosExtra.table.rows().every(function () {
var data = this.data(); var data = this.data();
if (data.tarifa_id == id) { if (data.tarifa_id == id) {
this.remove().draw(); this.remove();
} }
}); });
this.serviciosExtra.table.draw();
} }
else if (servicio == 'retractilado'){ else if (servicio == 'retractilado'){
const id = $('#retractilado').attr('service-id'); const id = $('#retractilado').attr('service-id');
this.serviciosAcabado.table.rows().every(function () { this.serviciosAcabado.table.rows().every(function () {
var data = this.data(); let data = this.data();
if (data.tarifa_id == id) { if (data.tarifa_id == id) {
this.remove().draw(); this.remove();
} }
}); });
this.serviciosAcabado.table.draw();
} }
else if (servicio == 'retractilado5'){ else if (servicio == 'retractilado5'){
const id = $('#retractilado5').attr('service-id'); const id = $('#retractilado5').attr('service-id');
this.serviciosAcabado.table.rows().every(function () { this.serviciosAcabado.table.rows().every(function () {
var data = this.data(); let data = this.data();
if (data.tarifa_id == id) { if (data.tarifa_id == id) {
this.remove().draw(); this.remove().draw();
} }
}); });
this.serviciosAcabado.table.draw();
} }
else if(servicio == 'plegado_guardas'){ else if(servicio == 'plegado_guardas'){
const id = $('#plegado_guardas').attr('service-id'); const id = $('#plegado_guardas').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () { this.ServiciosManipulado.table.rows().every(function () {
var data = this.data(); var data = this.data();
if (data.tarifa_id == id) { if (data && data.tarifa_id == id) {
this.remove().draw(); this.remove();
} }
}); });
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_cubierta'){
const id = $('#serv_solapas_cubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
if (data && parseInt(data.tarifa_id) == id) {
this.remove();
}
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_sobrecubierta'){
const id = $('#serv_solapas_sobrecubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
if (data && data.tarifa_id == id) {
this.remove();
}
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_grandes_cubierta'){
const id = $('#solapas_grandes_cubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
if (data && data.tarifa_id == id) {
this.remove();
}
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_grandes_sobrecubierta'){
const id = $('#solapas_grandes_sobrecubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
var data = this.data();
if (data && data.tarifa_id == id) {
this.remove();
}
});
this.ServiciosManipulado.table.draw();
} }
} }
@ -1318,53 +1374,7 @@ class ServiciosManipulado {
showBreadCrumbSaveButton(true); showBreadCrumbSaveButton(true);
} }
addSolapas() {
const self = this;
new Ajax('/serviciosmanipulados/serviciosolapas', {}, {},
function (response) {
if (response.service) {
const tarifa_id = response.service;
var rows = self.table.rows().data().toArray();
var found = rows.some(row => row.tarifa_id === tarifa_id);
if (!found)
self.getPresupuestoManipulado(tarifa_id);
}
},
function (error) {
console.error(error);
}
).get();
}
removeSolapas() {
const self = this;
new Ajax('/serviciosmanipulados/serviciosolapas', {}, {},
function (response) {
if (response.service) {
const tarifa_id = response.service;
var rows = self.table.rows().data().toArray();
for (let i = 0; i < rows.length; i++) {
if (rows[i]['tarifa_id'] == tarifa_id) {
self.table.row(i).remove().draw();
break;
}
}
}
},
function (error) {
console.error(error);
}
).get();
}
updateServicios() { updateServicios() {
const self = this; const self = this;
@ -1380,7 +1390,6 @@ class ServiciosManipulado {
if (tarifa_ids.length > 0) { if (tarifa_ids.length > 0) {
const data = { const data = {
datos: tarifa_ids, datos: tarifa_ids,
solapas: $('#solapas').is(':checked') ? 1 : 0,
tirada: tirada tirada: tirada
}; };
new Ajax('/serviciosmanipulados/update/' + id, data, {}, new Ajax('/serviciosmanipulados/update/' + id, data, {},