mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
falta añadir guardas
This commit is contained in:
@ -635,130 +635,96 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController
|
||||
'cubierta' => "",
|
||||
'sobrecubierta' => "",
|
||||
'guardas' => "",
|
||||
'servicios' => "",
|
||||
'serviciosDefecto' => "",
|
||||
];
|
||||
$coste_servicios = 0.0;
|
||||
|
||||
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||
|
||||
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$tamanio = $reqData['tamanio'];
|
||||
$tipo_impresion_id = $this->getTipoImpresion($reqData['tipo'], $reqData['tapa']);
|
||||
$paginas_color = intval($reqData['paginasColor']) ?? 0;
|
||||
$is_cosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id);
|
||||
$precio_u = [];
|
||||
|
||||
$datosPedido = (object)array(
|
||||
'paginas' => intval($reqData['paginas']) ?? 0,
|
||||
'tirada' => $tirada[0],
|
||||
'merma' => $tirada[0] > $POD ? $this->calcular_merma($tirada[0], $POD) : 0,
|
||||
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
||||
'alto' => intval($tamanio['alto']) ?? 100000,
|
||||
'isCosido' => $is_cosido,
|
||||
);
|
||||
for($t=0; $t<count($tirada); $t++){
|
||||
$tirada[$t] = intval($tirada[$t]);
|
||||
|
||||
$paginas_color = intval($reqData['paginasColor']) ?? 0;
|
||||
$is_cosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id);
|
||||
|
||||
$papel_generico = [
|
||||
'id' => $reqData['papelInterior'] ?? 0,
|
||||
'nombre' => $reqData['papelInteriorNombre'] ?? "",
|
||||
];
|
||||
$gramaje = $reqData['gramajeInterior'] ?? 0;
|
||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
|
||||
$datosPedido = (object)array(
|
||||
'paginas' => intval($reqData['paginas']) ?? 0,
|
||||
'tirada' => $tirada[$t],
|
||||
'merma' => $tirada[$t] > $POD ? $this->calcular_merma($tirada[$t], $POD) : 0,
|
||||
'ancho' => intval($tamanio['ancho']) ?? 100000,
|
||||
'alto' => intval($tamanio['alto']) ?? 100000,
|
||||
'isCosido' => $is_cosido,
|
||||
);
|
||||
|
||||
$input_data = array(
|
||||
'uso' => 'interior',
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'datosPedido' => $datosPedido,
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'isColor' => intval($reqData['isColor']) ?? 0,
|
||||
'isHq' => intval($reqData['isHq']) ?? 0,
|
||||
'cliente_id' => $cliente_id,
|
||||
'paginas_color' => $paginas_color,
|
||||
'excluirRotativa' => $excluirRotativa,
|
||||
);
|
||||
$papel_generico = [
|
||||
'id' => $reqData['papelInterior'] ?? 0,
|
||||
'nombre' => $reqData['papelInteriorNombre'] ?? "",
|
||||
];
|
||||
$gramaje = $reqData['gramajeInterior'] ?? 0;
|
||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||
$excluirRotativa = $reqData['excluirRotativa'] ?? 0;
|
||||
|
||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
||||
|
||||
$costeInterior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($costeInterior <= 0) {
|
||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
||||
}
|
||||
|
||||
// Si es POD hay que volver a calcular para incluir la merma correcta
|
||||
if ($tirada[0] <= $POD) {
|
||||
$num_formas = [];
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$formas_linea = $is_cosido ? intval($linea['num_formas']['value']) / 2 : intval($linea['num_formas']['value']);
|
||||
array_push($num_formas, $formas_linea);
|
||||
}
|
||||
}
|
||||
$input_data['datosPedido']['merma'] = $this->calcular_merma($tirada[0], $POD, $num_formas);
|
||||
$input_data = array(
|
||||
'uso' => 'interior',
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'datosPedido' => $datosPedido,
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'isColor' => intval($reqData['isColor']) ?? 0,
|
||||
'isHq' => intval($reqData['isHq']) ?? 0,
|
||||
'cliente_id' => $cliente_id,
|
||||
'paginas_color' => $paginas_color,
|
||||
'excluirRotativa' => $excluirRotativa,
|
||||
);
|
||||
|
||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
||||
}
|
||||
|
||||
$costeInterior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
$costeInterior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($costeInterior <= 0)
|
||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
||||
else
|
||||
$error->interior = "";
|
||||
|
||||
if ($costeInterior <= 0) {
|
||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
||||
}
|
||||
|
||||
// Cubierta
|
||||
$papel_generico = [
|
||||
'id' => $reqData['papelCubierta'] ?? 0,
|
||||
'nombre' => $reqData['papelCubiertaNombre'] ?? "",
|
||||
];
|
||||
$input_data['papel_generico'] = $papel_generico;
|
||||
$input_data['gramaje'] = $reqData['gramajeCubierta'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = intval($reqData['carasCubierta'] ?? 0);
|
||||
$input_data['paginas_color'] = intval($reqData['carasCubierta'] ?? 0);
|
||||
$input_data['datosPedido']->solapas_ancho = intval($reqData['solapasCubierta'] ?? 0);
|
||||
$input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho>0 ? 1 : 0;
|
||||
$input_data['datosPedido']->lomo = $this->calcular_lomo($interior, 0);
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'cubierta';
|
||||
// Si es POD hay que volver a calcular para incluir la merma correcta
|
||||
if ($tirada[$t] <= $POD) {
|
||||
$num_formas = [];
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$formas_linea = $is_cosido ? intval($linea['num_formas']['value']) / 2 : intval($linea['num_formas']['value']);
|
||||
array_push($num_formas, $formas_linea);
|
||||
}
|
||||
}
|
||||
$input_data['datosPedido']->merma = $this->calcular_merma($tirada[$t], $POD, $num_formas);
|
||||
|
||||
$cubierta = PresupuestoClienteService::obtenerCubierta($input_data);
|
||||
$coste_cubierta = 0.0;
|
||||
if (count($cubierta) > 0) {
|
||||
$coste_cubierta += floatval($cubierta['total_impresion']);
|
||||
}
|
||||
if($coste_cubierta <= 0)
|
||||
$error->cubierta = lang('Presupuestos.errores.noCubierta');
|
||||
else
|
||||
$error->cubierta = "";
|
||||
$interior = PresupuestoClienteService::obtenerInterior($input_data);
|
||||
}
|
||||
|
||||
$tarifaAcabadoCubierta = intval($reqData['acabadoCubierta'] ?? 0);
|
||||
$acabadoCubierta = [];
|
||||
if($tarifaAcabadoCubierta > 0){
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$acabadoCubierta = $model->getPrecioTarifa($tarifaAcabadoCubierta, $datosPedido->tirada, $POD);
|
||||
}
|
||||
if(count($acabadoCubierta) > 0){
|
||||
if($acabadoCubierta[0]->total <= 0 )
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||
}
|
||||
$costeInterior = 0.0;
|
||||
foreach ($interior as $linea) {
|
||||
if (count($linea) > 0) {
|
||||
$costeInterior += floatval($linea['total_impresion']);
|
||||
}
|
||||
}
|
||||
|
||||
// Sobrecubierta
|
||||
$sobreCubierta = $reqData["sobreCubierta"] ?? null;
|
||||
if(!is_null($sobreCubierta)){
|
||||
if ($costeInterior <= 0)
|
||||
$error->interior = lang('Presupuestos.errores.noInterior');
|
||||
else
|
||||
$error->interior = "";
|
||||
|
||||
|
||||
// Cubierta
|
||||
$papel_generico = [
|
||||
'id' => $reqData['papelCubierta'] ?? 0,
|
||||
'nombre' => $reqData['papelCubiertaNombre'] ?? "",
|
||||
@ -780,7 +746,7 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController
|
||||
$coste_cubierta += floatval($cubierta['total_impresion']);
|
||||
}
|
||||
if($coste_cubierta <= 0)
|
||||
$error->cubierta = lang('Presupuestos.errores.noCubierta');
|
||||
$error->cubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
||||
else
|
||||
$error->cubierta = "";
|
||||
|
||||
@ -795,38 +761,87 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
$coste_servicios += floatval($acabadoCubierta[0]->total);
|
||||
}
|
||||
}
|
||||
|
||||
// Servicios defecto
|
||||
$servDefecto = PresupuestoCLienteService::getServiciosEncuadernacionDefault([
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'tirada' => $datosPedido->tirada,
|
||||
'paginas' => intval($reqData['paginas']) ?? 0,
|
||||
'ancho' => $datosPedido->ancho,
|
||||
'alto' => $datosPedido->alto,
|
||||
'POD' => $POD,
|
||||
'solapas' => intval($reqData['solapasCubierta'] ?? 0),
|
||||
]);
|
||||
$costeServiciosDefecto = 0.0;
|
||||
foreach ($servDefecto as $servicio) {
|
||||
if($servicio->total <= 0 )
|
||||
$error->serviciosDefecto = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
}
|
||||
|
||||
$precio_u = round(($costeInterior + $coste_cubierta + $costeServiciosDefecto + $coste_servicios)/$tirada[0], 4);
|
||||
// Sobrecubierta
|
||||
$coste_sobrecubierta = 0.0;
|
||||
$linea_sobrecubierta = [];
|
||||
$sobreCubierta = $reqData["sobrecubierta"] ?? null;
|
||||
if(!is_null($sobreCubierta)){
|
||||
|
||||
$papel_generico = [
|
||||
'id' => $sobreCubierta['papel'] ?? 0,
|
||||
'nombre' => $sobreCubierta['papel_nombre'] ?? "",
|
||||
];
|
||||
$input_data['papel_generico'] = $papel_generico;
|
||||
$input_data['gramaje'] = $sobreCubierta['gramaje'] ?? 0;
|
||||
$input_data['datosPedido']->paginas = 4;
|
||||
$input_data['paginas_color'] = 4;
|
||||
$input_data['datosPedido']->solapas_ancho = intval($sobreCubierta['solapas'] ?? 0);
|
||||
$input_data['datosPedido']->solapas = $input_data['datosPedido']->solapas_ancho>0 ? 1 : 0;
|
||||
$input_data['datosPedido']->lomo = $this->calcular_lomo([$cubierta], $input_data['datosPedido']->lomo);
|
||||
$input_data['isColor'] = 1;
|
||||
$input_data['isHq'] = 1;
|
||||
$input_data['uso'] = 'sobrecubierta';
|
||||
|
||||
$linea_sobrecubierta = PresupuestoClienteService::obtenerSobrecubierta($input_data);
|
||||
|
||||
if (count($linea_sobrecubierta) > 0) {
|
||||
$coste_sobrecubierta += floatval($linea_sobrecubierta['total_impresion']);
|
||||
}
|
||||
if($coste_sobrecubierta <= 0)
|
||||
$error->sobrecubierta = lang('Presupuestos.errores.noCubiertaSobrecubierta');
|
||||
else
|
||||
$error->sobrecubierta = "";
|
||||
|
||||
$tarifaAcabadoSobrecubierta = intval($sobreCubierta->acabado ?? 0);
|
||||
$acabadoSobrecubierta = [];
|
||||
if($tarifaAcabadoSobrecubierta > 0){
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$acabadoSobrecubierta = $model->getPrecioTarifa($tarifaAcabadoSobrecubierta, $datosPedido->tirada, $POD);
|
||||
}
|
||||
if(count($acabadoSobrecubierta) > 0){
|
||||
if($acabadoSobrecubierta[0]->total <= 0 )
|
||||
$error->servicios = lang('Presupuestos.errores.errorPresupuesto');
|
||||
$coste_servicios += floatval($acabadoSobrecubierta[0]->total);
|
||||
}
|
||||
}
|
||||
|
||||
// Servicios defecto
|
||||
$servDefecto = PresupuestoCLienteService::getServiciosEncuadernacionDefault([
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'tirada' => $datosPedido->tirada,
|
||||
'paginas' => intval($reqData['paginas']) ?? 0,
|
||||
'ancho' => $datosPedido->ancho,
|
||||
'alto' => $datosPedido->alto,
|
||||
'POD' => $POD,
|
||||
'solapas' => intval($reqData['solapasCubierta'] ?? 0),
|
||||
]);
|
||||
$costeServiciosDefecto = 0.0;
|
||||
foreach ($servDefecto as $servicio) {
|
||||
if($servicio->total <= 0 )
|
||||
$error->serviciosDefecto = lang('Presupuestos.errores.errorPresupuesto');
|
||||
|
||||
$costeServiciosDefecto += floatval($servicio->total);
|
||||
}
|
||||
|
||||
array_push($precio_u, round(($costeInterior + $coste_cubierta + $coste_sobrecubierta + $costeServiciosDefecto + $coste_servicios)/$tirada[$t], 4));
|
||||
foreach($error as $err){
|
||||
if($err != "")
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'errors' => $error,
|
||||
'total_lp' => $costeInterior+$coste_cubierta,
|
||||
'total_lp' => $costeInterior+$coste_cubierta+$coste_sobrecubierta,
|
||||
'acabadoCubierta' => $acabadoCubierta,
|
||||
'total_servicios_defecto' => $costeServiciosDefecto,
|
||||
'tiradas' => $tirada,
|
||||
'precio_u' => [$precio_u],
|
||||
'precio_u' => $precio_u,
|
||||
|
||||
'interior' => $interior,
|
||||
'cubierta' => $cubierta,
|
||||
'sobrecubierta' => $linea_sobrecubierta,
|
||||
'serviciosDefecto' => $servDefecto,
|
||||
];
|
||||
}
|
||||
|
||||
@ -299,6 +299,7 @@ return [
|
||||
'tirada_alt_duplicada' => 'Ya existe una tirada alternativa para ese valor',
|
||||
'tirada_alt_tipo' => 'No se puede calcular una tirada alternativa POD para una presupuesto no POD o viceversa',
|
||||
'noInterior' => 'No se hay resultados para el interior',
|
||||
'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',
|
||||
],
|
||||
];
|
||||
|
||||
@ -94,6 +94,58 @@ class PresupuestoClienteService extends BaseService
|
||||
return $lineas_cubierta;
|
||||
}
|
||||
|
||||
public static function obtenerSobrecubierta($data)
|
||||
{
|
||||
|
||||
$uso = $data['uso'];
|
||||
$tipo_impresion_id = $data['tipo_impresion_id'];
|
||||
$datosPedido = $data['datosPedido'];
|
||||
$papel_generico = $data['papel_generico'];
|
||||
$gramaje = $data['gramaje'];
|
||||
$isColor = $data['isColor'];
|
||||
$isHq = $data['isHq'];
|
||||
$cliente_id = $data['cliente_id'];
|
||||
$paginas_color = $data['paginas_color'];
|
||||
|
||||
$lineas_sobrecubierta = [];
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
|
||||
$lineas = PresupuestoService::obtenerComparadorPlana([
|
||||
'uso' => $uso,
|
||||
'tipo_impresion_id' => $tipo_impresion_id,
|
||||
'datosPedido' => $datosPedido,
|
||||
'papel_generico' => $papel_generico,
|
||||
'gramaje' => $gramaje,
|
||||
'isColor' => $isColor,
|
||||
'isHq' => $isHq,
|
||||
'cliente_id' => $cliente_id,
|
||||
'a_favor_fibra' => $i
|
||||
]);
|
||||
|
||||
if (count($lineas) > 0) {
|
||||
$lineas_sobrecubierta = array_merge($lineas_sobrecubierta, $lineas);
|
||||
}
|
||||
}
|
||||
if (count($lineas_sobrecubierta) > 0) {
|
||||
|
||||
usort(
|
||||
$lineas_sobrecubierta,
|
||||
function ($a, $b) {
|
||||
$result = 0;
|
||||
if (floatval($a['fields']['total_impresion']) > floatval($b['fields']['total_impresion']))
|
||||
$result = 1;
|
||||
else if (floatval($a['fields']['total_impresion']) < floatval($b['fields']['total_impresion']))
|
||||
$result = -1;
|
||||
return $result;
|
||||
}
|
||||
);
|
||||
$lineas_sobrecubierta = $lineas_sobrecubierta[0]['fields'];
|
||||
$lineas_sobrecubierta['tipo_linea'] = 'lp_sobrecubierta';
|
||||
}
|
||||
return $lineas_sobrecubierta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtiene las lineas de plana en el presupuesto de cliente
|
||||
|
||||
@ -351,6 +351,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="errorSobrecubierta" class="fv-plugins-message-container invalid-feedback" style="display: none;">
|
||||
<div>No existe combinación con las opciones seleccionadas. Pruebe con otro papel/gramaje</div>
|
||||
</div>
|
||||
|
||||
<div class="row sobrecubierta">
|
||||
<div class="col-sm-3 mb-md-0 mb-2 d-flex align-items-end">
|
||||
<div class="form-check form-switch mb-2">
|
||||
@ -365,7 +369,7 @@
|
||||
|
||||
<div class="col-sm-4 mb-md-0 mb-2">
|
||||
<label for="papelSobrecubierta" class="form-label">Tipo de papel</label>
|
||||
<select id="papelSobrecubierta" name="papelSobrecubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
|
||||
<select id="papelSobrecubierta" name="papelSobrecubierta" class="form-control select2bs2 calcular-presupuesto input-sobrecubierta" style="width: 100%;">
|
||||
<?php if (isset($datosPresupuesto->papelSobrecubierta) && is_array($datosPresupuesto->papelSobrecubierta) && !empty($datosPresupuesto->papelSobrecubierta)) :
|
||||
foreach ($datosPresupuesto->papelSobrecubierta as $k => $v) : ?>
|
||||
<option value="<?= $v->id ?>">
|
||||
@ -378,7 +382,7 @@
|
||||
|
||||
<div class="col-sm-2 mb-md-0 mb-2">
|
||||
<label for="gramajeSobrecubierta" class="form-label">Gramaje (g/m2)</label>
|
||||
<select id="gramajeSobrecubierta" name="gramajeSobrecubierta" class="form-control select2bs2 calcular-presupuesto" style="width: 100%;">
|
||||
<select id="gramajeSobrecubierta" name="gramajeSobrecubierta" class="form-control select2bs2 calcular-presupuesto input-sobrecubierta" style="width: 100%;">
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -390,14 +394,14 @@
|
||||
|
||||
<div class="col-sm-3 mb-md-0 mb-2">
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input calcular-presupuesto" type="checkbox" id="solapasSobrecubierta" name="solapasSobrecubierta" value="0">
|
||||
<input class="form-check-input calcular-presupuesto input-sobrecubierta" type="checkbox" id="solapasSobrecubierta" name="solapasSobrecubierta" value="0">
|
||||
<label class="form-check-label" for="solapasSobrecubierta">Solapas sobrecubierta</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tamanioSolapasSobrecubierta" class="col-sm-3 mb-md-0 mb-2" style="display: none;">
|
||||
<label for="anchoSolapasSobrecubierta" class="form-label">Tamaño</label>
|
||||
<input type="number" id="anchoSolapasSobrecubierta" name="anchoSolapasSobrecubierta" maxLength="8" step="1" class="form-control calcular-presupuesto" value="">
|
||||
<input type="number" id="anchoSolapasSobrecubierta" name="anchoSolapasSobrecubierta" maxLength="8" step="1" class="form-control input-sobrecubierta calcular-presupuesto" value="">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -134,7 +134,13 @@ $('#enableSobrecubierta').on('change', function () {
|
||||
if ($(this).is(":checked")) {
|
||||
$('.enable-sobrecubierta').show();
|
||||
} else {
|
||||
$('#gramajeSobrecubierta').val('').trigger('change');
|
||||
$('#paperSobrecubierta').val('').trigger('change');
|
||||
$('#acabadosSobrecubierta').val('').trigger('change');
|
||||
$('#solapasSobrecubierta').prop('checked', false).trigger('change');
|
||||
$('#tamanioSolapasSobrecubierta').val();
|
||||
$('.enable-sobrecubierta').hide();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -270,7 +276,7 @@ $('#papelCubierta').on('change', function () {
|
||||
isHq = true;
|
||||
|
||||
if ($('#papelCubierta option:selected').val() != undefined) {
|
||||
var uso = 'colorhq';
|
||||
var uso = 'cubierta';
|
||||
|
||||
datos = {
|
||||
tirada: $('#tirada').val(),
|
||||
@ -308,7 +314,7 @@ $('#papelSobrecubierta').on('change', function () {
|
||||
isHq = true;
|
||||
|
||||
if ($('#papelSobrecubierta option:selected').val() != undefined) {
|
||||
var uso = 'colorhq';
|
||||
var uso = 'sobrecubierta';
|
||||
|
||||
datos = {
|
||||
tirada: $('#tirada').val(),
|
||||
@ -562,6 +568,13 @@ function numCarasGuardas(numCaras) {
|
||||
|
||||
|
||||
$('.calcular-presupuesto').on('change', function () {
|
||||
|
||||
// se obtiene el id del elemento que ha disparado el evento
|
||||
if($(this).hasClass('input-sobrecubierta')){
|
||||
if($('#papelSobrecubierta option:selected').val() == '' || $('#gramajeSobrecubierta option:selected').val() == ''){
|
||||
return;
|
||||
}
|
||||
}
|
||||
calcularPresupuesto();
|
||||
});
|
||||
|
||||
@ -606,14 +619,17 @@ async function calcularPresupuesto() {
|
||||
|
||||
// Si hay sobrecubierta
|
||||
if ($('.enable-sobrecubierta').is(':visible')) {
|
||||
datos.sobrecubierta = {
|
||||
papel: $('#papelSobrecubierta option:selected').val(),
|
||||
papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
|
||||
gramaje: $('#gramajeSobrecubierta option:selected').text(),
|
||||
acabado: $('#acabadosSobrecubierta').val()
|
||||
}
|
||||
if ($('#solapasSobrecubierta').is(':checked')) {
|
||||
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
if($('#papelSobrecubierta option:selected').val()>0 && $('#gramajeSobrecubierta option:selected').val()>0){
|
||||
|
||||
datos.sobrecubierta = {
|
||||
papel: $('#papelSobrecubierta option:selected').val(),
|
||||
papel_nombre: $('#papelSobrecubierta option:selected').text().trim(),
|
||||
gramaje: $('#gramajeSobrecubierta option:selected').text(),
|
||||
acabado: $('#acabadosSobrecubierta').val()
|
||||
}
|
||||
if ($('#solapasSobrecubierta').is(':checked')) {
|
||||
datos.sobrecubierta.solapas = $('#anchoSolapasSobrecubierta').val()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -649,6 +665,14 @@ async function calcularPresupuesto() {
|
||||
else
|
||||
$('#errorCubierta').hide();
|
||||
|
||||
if(response.errors.sobrecubierta.length > 0){
|
||||
$('#errorSobrecubierta').show();
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
$('#errorSobrecubierta').hide();
|
||||
|
||||
|
||||
if(response.errors.servicios.length > 0 || response.errors.serviciosDefecto.length > 0){
|
||||
error = true;
|
||||
}
|
||||
|
||||
12919
xdebug.log
12919
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user