mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'add/lomo_redondo_service' into 'main'
Add/lomo redondo service See merge request jjimenez/safekat!576
This commit is contained in:
@ -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_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,
|
||||
'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
|
||||
|
||||
@ -1309,7 +1309,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if (intval($cubierta['acabado']) > 0) {
|
||||
|
||||
$modelServicioAcabado = model('App\Models\Tarifas\Acabados\TarifasAcabadoServiciosAcabadoModel');
|
||||
$serviciosAcabado = $modelServicioAcabado->getTarifasForServicio($sobrecubierta['acabado']);
|
||||
$serviciosAcabado = $modelServicioAcabado->getTarifasForServicio($cubierta['acabado']);
|
||||
|
||||
foreach ($serviciosAcabado as $service) {
|
||||
$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) {
|
||||
|
||||
@ -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) {
|
||||
$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
|
||||
$coste_sobrecubierta = 0.0;
|
||||
|
||||
@ -229,7 +229,7 @@
|
||||
<label id="label_compLomoRedondo" for="compLomoRedondo" class="form-label">
|
||||
<?= lang('Presupuestos.lomoRedondo') ?>*
|
||||
</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%;">
|
||||
<option value="0">
|
||||
<p>
|
||||
|
||||
@ -321,6 +321,18 @@ class Comparador {
|
||||
allowClear: false,
|
||||
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({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
@ -343,7 +355,7 @@ class Comparador {
|
||||
});
|
||||
this.papelSobrecubierta.init();
|
||||
this.gramajeSobrecubierta.init();
|
||||
this.papelSobrecubierta.item.on('select2:select', function() {
|
||||
this.papelSobrecubierta.item.on('select2:select', function () {
|
||||
self.gramajeSobrecubierta.empty()
|
||||
});
|
||||
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) {
|
||||
this.papelGuardas.init();
|
||||
this.gramajeGuardas.init();
|
||||
this.papelGuardas.item.on('select2:select', function() {
|
||||
this.papelGuardas.item.on('select2:select', function () {
|
||||
self.gramajeGuardas.empty()
|
||||
});
|
||||
}
|
||||
|
||||
this.papelNegro.item.on('select2:select', function() {
|
||||
self.gramajeNegro.empty()
|
||||
this.papelNegro.item.on('select2:select', function () {
|
||||
self.gramajeNegro.empty()
|
||||
});
|
||||
this.papelNegrohq.item.on('select2:select', function() {
|
||||
this.papelNegrohq.item.on('select2:select', function () {
|
||||
self.gramajeNegrohq.empty()
|
||||
});
|
||||
this.papelColor.item.on('select2:select', function(){
|
||||
this.papelColor.item.on('select2:select', function () {
|
||||
self.gramajeColor.empty()
|
||||
});
|
||||
this.papelColorhq.item.on('select2:select', function() {
|
||||
this.papelColorhq.item.on('select2:select', function () {
|
||||
self.gramajeColorhq.empty()
|
||||
});
|
||||
this.papelCubierta.item.on('select2:select', function() {
|
||||
this.papelCubierta.item.on('select2:select', function () {
|
||||
self.gramajeCubierta.empty()
|
||||
});
|
||||
|
||||
this.papelFaja.item.on('select2:select', function() {
|
||||
this.papelFaja.item.on('select2:select', function () {
|
||||
self.gramajeFaja.empty()
|
||||
});
|
||||
|
||||
@ -566,8 +578,8 @@ class Comparador {
|
||||
}
|
||||
}
|
||||
|
||||
updateComparador(){
|
||||
|
||||
updateComparador() {
|
||||
|
||||
if (this.paginasColor.val() > 0) {
|
||||
this.paginasColor.trigger('change');
|
||||
}
|
||||
@ -579,8 +591,8 @@ class Comparador {
|
||||
}
|
||||
else if (this.paginasNegrohq.val() > 0) {
|
||||
this.paginasNegrohq.trigger('change');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.paginasCubierta.trigger('change');
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
|
||||
this.carasGuardas.trigger('change');
|
||||
@ -1023,7 +1035,7 @@ class Comparador {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.cargando){
|
||||
if (!this.cargando) {
|
||||
$('#paginas').trigger('change');
|
||||
this.updateComparador();
|
||||
}
|
||||
@ -1031,7 +1043,7 @@ class Comparador {
|
||||
|
||||
getDataForComp(uso = 'interior') {
|
||||
|
||||
if(this.cargando)
|
||||
if (this.cargando)
|
||||
return { error: true, data: {} };
|
||||
|
||||
let ancho = 0;
|
||||
@ -1104,7 +1116,7 @@ class Comparador {
|
||||
|
||||
if (element.getVal() == 0 || element.getVal() == null) {
|
||||
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');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1136,7 +1148,7 @@ class Comparador {
|
||||
|
||||
}
|
||||
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');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1156,7 +1168,7 @@ class Comparador {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
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');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1168,11 +1180,11 @@ class Comparador {
|
||||
}
|
||||
|
||||
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');
|
||||
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');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
@ -1185,7 +1197,7 @@ class Comparador {
|
||||
}
|
||||
|
||||
else if (uso == 'guardas') {
|
||||
|
||||
|
||||
if ((this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) && !this.cargando) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
@ -1537,11 +1549,11 @@ class Comparador {
|
||||
|
||||
let datosComp = {};
|
||||
datosComp.sobrecubierta = this.getDataForComp('faja');
|
||||
if(datosComp.sobrecubierta.error){
|
||||
if (datosComp.sobrecubierta.error) {
|
||||
return;
|
||||
}
|
||||
datosComp.sobrecubierta.data['faja'] = 1; // se indica que es faja para el calculo de formas
|
||||
|
||||
|
||||
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
this.comparadorFajaRunning = true;
|
||||
new Ajax('/presupuestoadmin/comparadorexteriores',
|
||||
@ -1550,7 +1562,7 @@ class Comparador {
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
|
||||
|
||||
if (response.data.sobrecubierta && Object.keys(response.data.sobrecubierta).length > 0) {
|
||||
let sorted = Object.values(response.data.sobrecubierta).sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
@ -1580,7 +1592,7 @@ class Comparador {
|
||||
self.comparadorFajaRunning = false;
|
||||
}
|
||||
).post();
|
||||
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@ -164,6 +164,16 @@ class Servicios {
|
||||
const id = $('#solapas_grandes_faja').attr('service-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) {
|
||||
@ -305,6 +315,16 @@ class Servicios {
|
||||
};
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user