mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
funcionalidad completa de ferro prototipo en cliente a excepción de guardar los checks de usar la misma dirección
This commit is contained in:
@ -1561,11 +1561,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
if (count($direccionesFP1) > 0) {
|
||||
$this->guardarLineaEnvio($id, $direccionesFP1, $peso_libro, true);
|
||||
$this->guardarLineaEnvio($id, $direccionesFP1, $peso_libro, true, true, 1);
|
||||
|
||||
}
|
||||
if (count($direccionesFP2) > 0) {
|
||||
$this->guardarLineaEnvio($id, $direccionesFP2, $peso_libro, true);
|
||||
$this->guardarLineaEnvio($id, $direccionesFP2, $peso_libro, true, true, 2);
|
||||
}
|
||||
|
||||
if ($confirmar) {
|
||||
@ -1708,6 +1708,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$data['direcciones'] = $this->obtenerDireccionesEnvio($id);
|
||||
}
|
||||
|
||||
$direccionesFerroPrototipo = $this->obtenerDireccionesEnvioFerro($id);
|
||||
if($direccionesFerroPrototipo && count($direccionesFerroPrototipo) > 0) {
|
||||
$data['direccionesFerroPrototipo'] = $direccionesFerroPrototipo;
|
||||
}
|
||||
|
||||
if (intval($presupuesto->estado_id) == 2) {
|
||||
$data['resumen']['base'] = $presupuesto->total_antes_descuento;
|
||||
$data['resumen']['total_envio'] = round(
|
||||
@ -1871,7 +1876,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro, $coste_cero = false)
|
||||
protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro, $coste_cero = false, $is_ferro_prototipo = false, $num_ferro_prototipo = 0)
|
||||
{
|
||||
|
||||
$unidades = intval($direccion['unidades']);
|
||||
@ -1893,6 +1898,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
unset($data->id);
|
||||
if($coste_cero) {
|
||||
$data->coste = 0;
|
||||
if($is_ferro_prototipo){
|
||||
$data->is_ferro_prototipo = 1;
|
||||
$data->num_ferro_prototipo = $num_ferro_prototipo;
|
||||
}
|
||||
} else {
|
||||
$data->precio = $data->coste;
|
||||
}
|
||||
@ -3426,7 +3435,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$direcciones = $model->where('presupuesto_id', $id)
|
||||
->where('is_ferro_prototipo', 0)->asArray()->findAll();
|
||||
->where('is_ferro_prototipo', 1)->get()->getResultArray();
|
||||
|
||||
return $direcciones;
|
||||
}
|
||||
|
||||
@ -435,6 +435,9 @@ return [
|
||||
'paginas_multiplo_4' => 'El número total de páginas para <b>cosido</b> y <b>grapado</b> debe ser múltiplo de 4',
|
||||
'paginas_pares' => 'El número de páginas debe ser par',
|
||||
'extras_cubierta' => 'Rellene todos los campos',
|
||||
|
||||
'error_sameAddPrincipal_FP' => 'Debe añadir al menos una dirección en el envío para usarla',
|
||||
'error_sameAddFP1' => 'Debe añadir al menos una dirección en el envío del primer ferro para usarla.'
|
||||
],
|
||||
|
||||
'errores' => [
|
||||
|
||||
@ -68,6 +68,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="sk-alert-ferro-prototipo1">
|
||||
</div>
|
||||
<div id="direccionesFerroPrototipo" class="row col-sm-12 mb-5 justify-content-center d-none">
|
||||
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||
<h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo</h3>
|
||||
@ -101,11 +104,14 @@
|
||||
</div>
|
||||
|
||||
<div id="divDireccionesFerroPrototipo"
|
||||
class="calcular-presupuesto col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo">
|
||||
class="col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="sk-alert-ferro-prototipo2">
|
||||
</div>
|
||||
<div id="direccionesFerroPrototipo2" class="row col-sm-12 mb-5 justify-content-center d-none">
|
||||
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||
<h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo 2</h3>
|
||||
@ -146,7 +152,7 @@
|
||||
</div>
|
||||
|
||||
<div id="divDireccionesFerroPrototipo2"
|
||||
class="calcular-presupuesto col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo">
|
||||
class="col-sm-12 d-flex flex-column align-items-center div-direcciones-ferro-prototipo">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -105,27 +105,26 @@ class DatosGenerales {
|
||||
|
||||
// check ferro y prototipo
|
||||
this.domItem.on('change', 'input[type="checkbox"][data-tarifa-extra-excluyente="1"]', (e) => {
|
||||
if (!this.cargando) {
|
||||
const current = $(e.target);
|
||||
|
||||
if (current.is(':checked')) {
|
||||
this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]')
|
||||
.not(current)
|
||||
.prop('checked', false);
|
||||
const current = $(e.target);
|
||||
|
||||
if ((current.data('tarifa-nombre')?.toString().toLowerCase() || '').includes('2')) {
|
||||
$('#direccionesFerroPrototipo2').removeClass('d-none');
|
||||
}
|
||||
$('#direccionesFerroPrototipo').removeClass('d-none');
|
||||
if (current.is(':checked')) {
|
||||
this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]')
|
||||
.not(current)
|
||||
.prop('checked', false);
|
||||
|
||||
if ((current.data('tarifa-nombre')?.toString().toLowerCase() || '').includes('2')) {
|
||||
$('#direccionesFerroPrototipo2').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
if (this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]').prop('checked').length === 0) {
|
||||
$('#direccionesFerroPrototipo').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
if (this.domItem.find('input[type="checkbox"][data-tarifa-extra-excluyente="1"]').prop('checked').length === 0) {
|
||||
|
||||
$('#direccionesFerroPrototipo').addClass('d-none');
|
||||
$('#divDireccionesFerroPrototipo').empty();
|
||||
$('#direccionesFerroPrototipo2').addClass('d-none');
|
||||
$('#divDireccionesFerroPrototipo2').empty();
|
||||
}
|
||||
$('#direccionesFerroPrototipo').addClass('d-none');
|
||||
$('#divDireccionesFerroPrototipo').empty();
|
||||
$('#direccionesFerroPrototipo2').addClass('d-none');
|
||||
$('#divDireccionesFerroPrototipo2').empty();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -597,6 +596,7 @@ class DatosGenerales {
|
||||
|
||||
if (datos.serviciosExtra.includes(tarifaId)) {
|
||||
$(this).prop('checked', true);
|
||||
$(this).trigger('change');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ class Direcciones {
|
||||
|
||||
|
||||
|
||||
cargarDatos(datos, datosGenerales) {
|
||||
cargarDatos(datos, datosGenerales, direccionesFP = []) {
|
||||
|
||||
self = this;
|
||||
|
||||
@ -174,6 +174,30 @@ class Direcciones {
|
||||
this.direcciones.push(tarjeta);
|
||||
}
|
||||
}
|
||||
|
||||
if (direccionesFP.length > 0) {
|
||||
direccionesFP.forEach(element => {
|
||||
let divId = "dirEnvio-fp-" + element.num_ferro_prototipo;
|
||||
let containerId = element.num_ferro_prototipo == 1 ? "#divDireccionesFerroPrototipo" : "#divDireccionesFerroPrototipo2";
|
||||
let tarjeta = new tarjetaDireccion(containerId,
|
||||
divId, element, true, element.num_ferro_prototipo);
|
||||
tarjeta.setUnidades(1);
|
||||
tarjeta.setEntregaPalets(0);
|
||||
tarjeta.card.find('.direccion-eliminar').on('click', (event) => {
|
||||
this.#deleteDireccionFP(event, element.num_ferro_prototipo);
|
||||
$('.div-direcciones-fp' + element.num_ferro_prototipo).removeClass('d-none');
|
||||
});
|
||||
$(containerId).append(tarjeta.card);
|
||||
if (element.num_ferro_prototipo == 1) {
|
||||
this.direccionesFP1.push(tarjeta);
|
||||
}
|
||||
else {
|
||||
this.direccionesFP2.push(tarjeta);
|
||||
}
|
||||
$('.div-direcciones-fp' + element.num_ferro_prototipo).addClass('d-none');
|
||||
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
$('#loader').modal('hide');
|
||||
@ -356,10 +380,10 @@ class Direcciones {
|
||||
try {
|
||||
|
||||
let id = 0;
|
||||
if( num_ferroPrototipo === 1) {
|
||||
if (num_ferroPrototipo === 1) {
|
||||
id = this.direccionesClienteFP1.getVal();
|
||||
}
|
||||
if( num_ferroPrototipo === 2) {
|
||||
if (num_ferroPrototipo === 2) {
|
||||
id = this.direccionesClienteFP2.getVal();
|
||||
}
|
||||
let unidades = 1;
|
||||
@ -369,16 +393,23 @@ class Direcciones {
|
||||
|
||||
let divId = "dirEnvio-FP-" + num_ferroPrototipo;
|
||||
let containerId = num_ferroPrototipo === 1 ? "#divDireccionesFerroPrototipo" : "#divDireccionesFerroPrototipo2";
|
||||
let arrayName = num_ferroPrototipo === 1 ? this.direccionesFP1 : this.direccionesFP2;
|
||||
|
||||
|
||||
if (num_ferroPrototipo === 1) {
|
||||
this.direccionesFP1 = [];
|
||||
}
|
||||
if (num_ferroPrototipo === 2) {
|
||||
this.direccionesFP2 = [];
|
||||
}
|
||||
|
||||
this.#addTarjetaDireccion(
|
||||
$(containerId),
|
||||
arrayName,
|
||||
divId,
|
||||
id,
|
||||
1, false, true, num_ferroPrototipo);
|
||||
$(containerId),
|
||||
num_ferroPrototipo === 1 ? this.direccionesFP1 : this.direccionesFP2,
|
||||
divId,
|
||||
id,
|
||||
1, false, true, num_ferroPrototipo);
|
||||
|
||||
$('.div-direcciones-fp' + num_ferroPrototipo).addClass('d-none');
|
||||
$('#loader').modal('hide');
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@ -432,6 +463,7 @@ class Direcciones {
|
||||
container.append(tarjeta.card);
|
||||
addArray.push(tarjeta);
|
||||
container.trigger('change');
|
||||
$('#loader').modal('hide');
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error en petición Ajax:', err);
|
||||
@ -500,6 +532,17 @@ class Direcciones {
|
||||
|
||||
tarjeta.remove();
|
||||
this.divDirecciones.trigger('change');
|
||||
|
||||
if (this.direcciones.length === 0) {
|
||||
if (this.sameAddPrincipalFP1.is(':checked')) {
|
||||
this.sameAddPrincipalFP1.prop('checked', false);
|
||||
this.sameAddPrincipalFP1.trigger('change');
|
||||
}
|
||||
if (this.sameAddPrincipalFP2.is(':checked')) {
|
||||
this.sameAddPrincipalFP2.prop('checked', false);
|
||||
this.sameAddPrincipalFP2.trigger('change');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#deleteDireccionFP(event, num_ferroPrototipo = 1) {
|
||||
@ -512,12 +555,18 @@ class Direcciones {
|
||||
this.direccionesFP1 = [];
|
||||
this.sameAddPrincipalFP1.prop('checked', false);
|
||||
$('#divDireccionesFerroPrototipo1').trigger('change');
|
||||
if (this.sameAddFP1.is(':checked')) {
|
||||
this.sameAddFP1.prop('checked', false);
|
||||
this.sameAddFP1.trigger('change');
|
||||
}
|
||||
$('.div-direcciones-fp1').removeClass('d-none');
|
||||
}
|
||||
if (num_ferroPrototipo === 2) {
|
||||
this.direccionesFP2 = [];
|
||||
this.sameAddPrincipalFP2.prop('checked', false);
|
||||
this.sameAddFP1.prop('checked', false);
|
||||
$('#divDireccionesFerroPrototipo2').trigger('change');
|
||||
$('.div-direcciones-fp2').removeClass('d-none');
|
||||
}
|
||||
|
||||
tarjeta.remove();
|
||||
@ -542,7 +591,10 @@ class Direcciones {
|
||||
$('#divDireccionesFerroPrototipo').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
// mostrar alerta de que no hay direcciones
|
||||
popErrorAlert(window.translations["validation"].error_sameAddPrincipal_FP,
|
||||
'sk-alert-ferro-prototipo1', true);
|
||||
this.sameAddPrincipalFP1.prop('checked', false);
|
||||
$('#divDireccionesFerroPrototipo').empty();
|
||||
}
|
||||
|
||||
}
|
||||
@ -556,13 +608,13 @@ class Direcciones {
|
||||
#handleSameAddPrincipalFP2() {
|
||||
|
||||
if (this.sameAddPrincipalFP2.is(':checked')) {
|
||||
if(this.sameAddFP1.is(':checked')) {
|
||||
if (this.sameAddFP1.is(':checked')) {
|
||||
this.sameAddFP1.prop('checked', false);
|
||||
}
|
||||
$('.div-direcciones-fp2').addClass('d-none');
|
||||
$('#divDireccionesFerroPrototipo2').empty();
|
||||
if (this.direcciones.length > 0) {
|
||||
|
||||
|
||||
let data = this.direcciones[0].getDireccion();
|
||||
this.direccionesFP2 = [];
|
||||
this.#addTarjetaDireccion(
|
||||
@ -574,7 +626,10 @@ class Direcciones {
|
||||
$('#divDireccionesFerroPrototipo2').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
// mostrar alerta de que no hay direcciones
|
||||
popErrorAlert(window.translations["validation"].error_sameAddPrincipal_FP,
|
||||
'sk-alert-ferro-prototipo2', true);
|
||||
this.sameAddPrincipalFP2.prop('checked', false);
|
||||
$('#divDireccionesFerroPrototipo2').empty();
|
||||
}
|
||||
|
||||
}
|
||||
@ -588,7 +643,7 @@ class Direcciones {
|
||||
#handleSameAddFP1() {
|
||||
|
||||
if (this.sameAddFP1.is(':checked')) {
|
||||
if(this.sameAddPrincipalFP2.is(':checked')) {
|
||||
if (this.sameAddPrincipalFP2.is(':checked')) {
|
||||
this.sameAddPrincipalFP2.prop('checked', false);
|
||||
}
|
||||
$('.div-direcciones-fp2').addClass('d-none');
|
||||
@ -597,7 +652,7 @@ class Direcciones {
|
||||
|
||||
let data = this.direccionesFP1[0].getDireccion();
|
||||
|
||||
this.direccionesFP1 = [];
|
||||
this.direccionesFP2 = [];
|
||||
this.#addTarjetaDireccion(
|
||||
$("#divDireccionesFerroPrototipo2"),
|
||||
this.direccionesFP2,
|
||||
@ -608,7 +663,10 @@ class Direcciones {
|
||||
$('#divDireccionesFerroPrototipo2').removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
// mostrar alerta de que no hay direcciones
|
||||
popErrorAlert(window.translations["validation"].error_sameAddFP1,
|
||||
'sk-alert-ferro-prototipo2', true);
|
||||
this.sameAddPrincipalFP2.prop('checked', false);
|
||||
$('#divDireccionesFerroPrototipo2').empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -675,6 +675,12 @@ class PresupuestoCliente {
|
||||
if (datos_to_check.direcciones) {
|
||||
delete datos_to_check.direcciones;
|
||||
}
|
||||
if (datos_to_check.direccionesFP1) {
|
||||
delete datos_to_check.direccionesFP1;
|
||||
}
|
||||
if (datos_to_check.direccionesFP2) {
|
||||
delete datos_to_check.direccionesFP2;
|
||||
}
|
||||
if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
|
||||
delete datos_to_check.posPaginasColor;
|
||||
}
|
||||
@ -795,15 +801,12 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
if( this.direcciones.direccionesFP1.length > 0) {
|
||||
this.datos.direccionesFP1 = this.direcciones.direccionesFP1.map((direccion) => {
|
||||
return direccion.getFormData();
|
||||
});
|
||||
|
||||
this.datos.direccionesFP1 = this.direcciones.direccionesFP1[0].getFormData();
|
||||
}
|
||||
|
||||
if( this.direcciones.direccionesFP2.length > 0) {
|
||||
this.datos.direccionesFP2 = this.direcciones.direccionesFP2.map((direccion) => {
|
||||
return direccion.getFormData();
|
||||
});
|
||||
this.datos.direccionesFP2 = this.direcciones.direccionesFP2[0].getFormData();
|
||||
}
|
||||
|
||||
if (save) {
|
||||
@ -844,7 +847,10 @@ class PresupuestoCliente {
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
self.direcciones.handleChangeCliente();
|
||||
|
||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales,
|
||||
response.data.direccionesFerroPrototipo && response.data.direccionesFerroPrototipo.length > 0 ?
|
||||
response.data.direccionesFerroPrototipo : []
|
||||
);
|
||||
|
||||
try {
|
||||
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
|
||||
Reference in New Issue
Block a user