Merge branch 'add/lomo_redondo_service' into 'main'

Add/lomo redondo service

See merge request jjimenez/safekat!576
This commit is contained in:
2025-02-27 14:59:34 +00:00
5 changed files with 108 additions and 29 deletions

View File

@ -390,6 +390,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
'solapas_grandes_cubierta' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_cubierta')->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_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, 'solapas_grandes_faja' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value,
'lomo_redondo' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_lomo_redondo')->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

View File

@ -1309,7 +1309,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (intval($cubierta['acabado']) > 0) { if (intval($cubierta['acabado']) > 0) {
$modelServicioAcabado = model('App\Models\Tarifas\Acabados\TarifasAcabadoServiciosAcabadoModel'); $modelServicioAcabado = model('App\Models\Tarifas\Acabados\TarifasAcabadoServiciosAcabadoModel');
$serviciosAcabado = $modelServicioAcabado->getTarifasForServicio($sobrecubierta['acabado']); $serviciosAcabado = $modelServicioAcabado->getTarifasForServicio($cubierta['acabado']);
foreach ($serviciosAcabado as $service) { foreach ($serviciosAcabado as $service) {
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel'); $model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
@ -1321,8 +1321,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
} }
} }
} }
if (is_array($faja) && $faja !== [] && intval($faja['acabado']) > 0) { if (is_array($faja) && $faja !== [] && intval($faja['acabado']) > 0) {
@ -1340,6 +1338,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
} }
} }
if (intval($cubierta['lomoRedondo']) == 1) {
$tarifa_id = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_lomo_redondo')->value;
$serv_lomo = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => intval($tarifa_id),
'tirada' => $selected_tirada,
'POD' => $POD,
])[0];
$this->guardarServicio($id, $serv_lomo, 'manipulado');
}
foreach ($resultado_presupuesto['values']['serviciosDefecto']['encuadernacion'] as $servicio) { foreach ($resultado_presupuesto['values']['serviciosDefecto']['encuadernacion'] as $servicio) {
$this->guardarServicio($id, $servicio, 'encuadernacion'); $this->guardarServicio($id, $servicio, 'encuadernacion');
} }
@ -2182,6 +2190,44 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} }
if ($lomoRedondo) {
$tarifa = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_lomo_redondo')->value;
$resultado = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => intval($tarifa),
'tirada' => $datosPedido->tirada,
'POD' => $POD,
]);
if (count($resultado) > 0) {
if ($resultado[0]->total <= 0) {
$input_data['tarifa_manipulado'] = intval($tarifa);
$errorModel = new ErrorPresupuesto();
$errorModel->insertError(
$datos_entrada['id'],
auth()->user()->id,
'No se puede obtener servicio lomo redondo',
$input_data
);
$return_data = [
'errors' => (object) ([
'status' => 1
]),
];
return $return_data;
}
$coste_servicios += round(floatval($resultado[0]->total), 2);
if ($extra_info) {
$totalServicios += round(floatval($resultado[0]->total), 2);
$base = round(floatval($resultado[0]->total / (1 + $resultado[0]->margen / 100.0)), 2);
$base = round(floatval($base / $datosPedido->tirada), 2) * $datosPedido->tirada;
$margenServicios += round(floatval($resultado[0]->total - $base), 2);
}
}
}
// Sobrecubierta // Sobrecubierta
$coste_sobrecubierta = 0.0; $coste_sobrecubierta = 0.0;

View File

@ -229,7 +229,7 @@
<label id="label_compLomoRedondo" for="compLomoRedondo" class="form-label"> <label id="label_compLomoRedondo" for="compLomoRedondo" class="form-label">
<?= lang('Presupuestos.lomoRedondo') ?>* <?= lang('Presupuestos.lomoRedondo') ?>*
</label> </label>
<select id="compLomoRedondo" name="lomo_redondo" <select id="compLomoRedondo" name="lomo_redondo" service-id="<?= $serviciosAutomaticos['lomo_redondo'] ?>"
class="form-control select2bs2 comp_cubierta_items" style="width: 100%;"> class="form-control select2bs2 comp_cubierta_items" style="width: 100%;">
<option value="0"> <option value="0">
<p> <p>

View File

@ -321,6 +321,18 @@ class Comparador {
allowClear: false, allowClear: false,
minimumResultsForSearch: Infinity, minimumResultsForSearch: Infinity,
}); });
this.lomoRedondo.on('change', function () {
if (!self.cargando && self.lomoRedondo.select2('data').length > 0) {
if (self.lomoRedondo.select2('data')[0].id == 1) {
$(document).trigger('add-servicio-lineas', 'lomo_redondo');
}
else {
$(document).trigger('remove-servicio-lineas', 'lomo_redondo');
}
}
});
this.cabezada.select2({ this.cabezada.select2({
allowClear: false, allowClear: false,
minimumResultsForSearch: Infinity, minimumResultsForSearch: Infinity,
@ -343,7 +355,7 @@ class Comparador {
}); });
this.papelSobrecubierta.init(); this.papelSobrecubierta.init();
this.gramajeSobrecubierta.init(); this.gramajeSobrecubierta.init();
this.papelSobrecubierta.item.on('select2:select', function() { this.papelSobrecubierta.item.on('select2:select', function () {
self.gramajeSobrecubierta.empty() self.gramajeSobrecubierta.empty()
}); });
this.sobrecubierta.on('change', () => { this.sobrecubierta.on('change', () => {
@ -391,28 +403,28 @@ 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) {
this.papelGuardas.init(); this.papelGuardas.init();
this.gramajeGuardas.init(); this.gramajeGuardas.init();
this.papelGuardas.item.on('select2:select', function() { this.papelGuardas.item.on('select2:select', function () {
self.gramajeGuardas.empty() self.gramajeGuardas.empty()
}); });
} }
this.papelNegro.item.on('select2:select', function() { this.papelNegro.item.on('select2:select', function () {
self.gramajeNegro.empty() self.gramajeNegro.empty()
}); });
this.papelNegrohq.item.on('select2:select', function() { this.papelNegrohq.item.on('select2:select', function () {
self.gramajeNegrohq.empty() self.gramajeNegrohq.empty()
}); });
this.papelColor.item.on('select2:select', function(){ this.papelColor.item.on('select2:select', function () {
self.gramajeColor.empty() self.gramajeColor.empty()
}); });
this.papelColorhq.item.on('select2:select', function() { this.papelColorhq.item.on('select2:select', function () {
self.gramajeColorhq.empty() self.gramajeColorhq.empty()
}); });
this.papelCubierta.item.on('select2:select', function() { this.papelCubierta.item.on('select2:select', function () {
self.gramajeCubierta.empty() self.gramajeCubierta.empty()
}); });
this.papelFaja.item.on('select2:select', function() { this.papelFaja.item.on('select2:select', function () {
self.gramajeFaja.empty() self.gramajeFaja.empty()
}); });
@ -566,7 +578,7 @@ class Comparador {
} }
} }
updateComparador(){ updateComparador() {
if (this.paginasColor.val() > 0) { if (this.paginasColor.val() > 0) {
this.paginasColor.trigger('change'); this.paginasColor.trigger('change');
@ -1023,7 +1035,7 @@ class Comparador {
} }
} }
if (!this.cargando){ if (!this.cargando) {
$('#paginas').trigger('change'); $('#paginas').trigger('change');
this.updateComparador(); this.updateComparador();
} }
@ -1031,7 +1043,7 @@ class Comparador {
getDataForComp(uso = 'interior') { getDataForComp(uso = 'interior') {
if(this.cargando) if (this.cargando)
return { error: true, data: {} }; return { error: true, data: {} };
let ancho = 0; let ancho = 0;
@ -1104,7 +1116,7 @@ class Comparador {
if (element.getVal() == 0 || element.getVal() == null) { if (element.getVal() == 0 || element.getVal() == null) {
const tipo = element.item.attr('id').split('Gramaje')[1]; const tipo = element.item.attr('id').split('Gramaje')[1];
if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) { if ($('#compPaginas' + tipo).val() > 0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1136,7 +1148,7 @@ class Comparador {
} }
else if (uso == 'cubierta') { else if (uso == 'cubierta') {
if ((this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) && !this.cargando) { if ((this.papelCubierta.getVal() == 0 || this.papelCubierta.getVal() == null) && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1156,7 +1168,7 @@ class Comparador {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
if ((this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) && !this.cargando) { if ((this.gramajeSobrecubierta.getVal() == 0 || this.gramajeSobrecubierta.getVal() == null) && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1168,11 +1180,11 @@ class Comparador {
} }
else if (uso == 'faja') { else if (uso == 'faja') {
if (this.papelFaja.getText() == "" && this.faja.val()>0 && !this.cargando) { if (this.papelFaja.getText() == "" && this.faja.val() > 0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
if (this.gramajeFaja.getText() == "" && this.faja.val()>0 && !this.cargando) { if (this.gramajeFaja.getText() == "" && this.faja.val() > 0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador'); popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} }; return { error: true, data: {} };
} }
@ -1537,7 +1549,7 @@ class Comparador {
let datosComp = {}; let datosComp = {};
datosComp.sobrecubierta = this.getDataForComp('faja'); datosComp.sobrecubierta = this.getDataForComp('faja');
if(datosComp.sobrecubierta.error){ if (datosComp.sobrecubierta.error) {
return; return;
} }
datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas

View File

@ -164,6 +164,16 @@ class Servicios {
const id = $('#solapas_grandes_faja').attr('service-id'); const id = $('#solapas_grandes_faja').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id); this.ServiciosManipulado.getPresupuestoManipulado(id);
} }
else if (servicio == 'lomo_redondo'){
const id = $('#compLomoRedondo').attr('service-id');
for(let i = 0; i < this.ServiciosManipulado.table.rows().count(); i++){
var data = this.ServiciosManipulado.table.row(i).data();
if (data.tarifa_id == id) {
return;
}
};
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
} }
removeServicio(event, servicio) { removeServicio(event, servicio) {
@ -305,6 +315,16 @@ class Servicios {
}; };
this.serviciosAcabado.table.draw(); this.serviciosAcabado.table.draw();
} }
else if (servicio == 'lomo_redondo'){
const id = $('#compLomoRedondo').attr('service-id');
for(let i = this.ServiciosManipulado.table.rows().count(); i >= 0; i--){
var data = this.ServiciosManipulado.table.row(i).data();
if (data && data.tarifa_id == id) {
this.ServiciosManipulado.table.row(i).remove();
}
};
this.ServiciosManipulado.table.draw();
}
} }
async updateServicios() { async updateServicios() {