mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en las direcciones ferro / prototipo
This commit is contained in:
@ -26,6 +26,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"margen" => null,
|
"margen" => null,
|
||||||
"entregaPieCalle" => null,
|
"entregaPieCalle" => null,
|
||||||
"is_ferro_prototipo" => null,
|
"is_ferro_prototipo" => null,
|
||||||
|
"num_ferro_prototipo" => null,
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
"presupuesto_id" => "int",
|
"presupuesto_id" => "int",
|
||||||
@ -40,6 +41,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity
|
|||||||
"proveedor_id" => "int",
|
"proveedor_id" => "int",
|
||||||
"entregaPieCalle" => "int",
|
"entregaPieCalle" => "int",
|
||||||
"is_ferro_prototipo" => "int",
|
"is_ferro_prototipo" => "int",
|
||||||
|
"num_ferro_prototipo" => "int",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,8 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
|||||||
"proveedor_id",
|
"proveedor_id",
|
||||||
"proveedor",
|
"proveedor",
|
||||||
"entregaPieCalle",
|
"entregaPieCalle",
|
||||||
"is_ferro_prototipo"
|
"is_ferro_prototipo",
|
||||||
|
"num_ferro_prototipo"
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity";
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity";
|
||||||
|
|||||||
@ -68,30 +68,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="direccionesFerroPrototipo" class="col-sm-12 d-flex flex-column align-items-center d-none">
|
<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">
|
<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>
|
<h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo</h3>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
|
|
||||||
<div class="row mb-3 justify-content-center div-direcciones-fp1">
|
<div class="row mb-3 justify-content-center div-direcciones-fp1">
|
||||||
<div class="col-sm-9 mb-3">
|
<!-- Select: Mis direcciones -->
|
||||||
<label for="direcciones" class="form-label">Mis direcciones</label>
|
<div class="col-sm-4 mb-3">
|
||||||
|
<label for="direccionesFP1" class="form-label">Mis direcciones</label>
|
||||||
<select id="direccionesFP1" name="direcciones" class="form-control select2bs2"
|
<select id="direccionesFP1" name="direcciones" class="form-control select2bs2"
|
||||||
style="width: 100%;"></select>
|
style="width: 100%;"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-3 mb-3 mt-auto mb-0">
|
<div class="col-sm-2 mb-3 mt-auto mb-0">
|
||||||
<button id="insertarDireccionFP1" type="button"
|
<button id="insertarDireccionFP1" type="button"
|
||||||
class="btn btn-secondary waves-effect waves-light">Insertar</button>
|
class="btn btn-secondary waves-effect waves-light">Insertar</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row mb-3 justify-content-center">
|
<div class="row mb-3 justify-content-center">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="col-sm-6 mb-3">
|
||||||
<input class="form-check-input" type="checkbox" id="sameAddPrincipalFP1" name="sameAddPrincipalFP1"
|
<div class="form-check form-switch mb-2">
|
||||||
value="1">
|
<input class="form-check-input" type="checkbox" id="sameAddPrincipalFP1" name="sameAddPrincipalFP1"
|
||||||
<label class="form-check-label"
|
value="1">
|
||||||
for="sameAddPrincipalFP1"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
|
<label class="form-check-label"
|
||||||
|
for="sameAddPrincipalFP1"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -101,38 +106,42 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="direccionesFerroPrototipo2" class="col-sm-12 d-flex flex-column align-items-center d-none">
|
<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">
|
<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>
|
<h3 class="mb-1 fw-bold"> Dirección de envío ferro/prototipo 2</h3>
|
||||||
</div><!--//.mb-3 -->
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
<div class="row mb-3 justify-content-center div-direcciones">
|
<div class="row mb-3 justify-content-center div-direcciones-fp2">
|
||||||
<div class="col-sm-6 mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<label for="direcciones" class="form-label">Mis direcciones</label>
|
<label for="direcciones" class="form-label">Mis direcciones</label>
|
||||||
<select id="direccionesFP1" name="direcciones" class="form-control select2bs2"
|
<select id="direccionesFP2" name="direccionesFP2" class="form-control select2bs2"
|
||||||
style="width: 100%;"></select>
|
style="width: 100%;"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-3 mb-3 mt-auto mb-0">
|
<div class="col-sm-2 mb-3 mt-auto mb-0">
|
||||||
<button id="insertarDireccionFP1" type="button"
|
<button id="insertarDireccionFP2" type="button"
|
||||||
class="btn btn-secondary waves-effect waves-light">Insertar</button>
|
class="btn btn-secondary waves-effect waves-light">Insertar</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3 justify-content-center">
|
<div class="row mb-3 justify-content-center">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="col-sm-6">
|
||||||
<input class="form-check-input" type="checkbox" id="sameAddPrincipalFP2" name="sameAddPrincipalFP2"
|
<div class="form-check form-switch mb-2">
|
||||||
value="1">
|
<input class="form-check-input" type="checkbox" id="sameAddPrincipalFP2" name="sameAddPrincipalFP2"
|
||||||
<label class="form-check-label"
|
value="1">
|
||||||
for="sameAddPrincipalFP2"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
|
<label class="form-check-label"
|
||||||
|
for="sameAddPrincipalFP2"><?= lang('PresupuestosDirecciones.sameAddPrincipal') ?></label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3 justify-content-center">
|
<div class="row mb-3 justify-content-center">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="col-sm-6 mb-3">
|
||||||
<input class="form-check-input" type="checkbox" id="sameAddFP1" name="sameAddFP1" value="1">
|
<div class="form-check form-switch mb-2">
|
||||||
<label class="form-check-label"
|
<input class="form-check-input" type="checkbox" id="sameAddFP1" name="sameAddFP1" value="1">
|
||||||
for="sameAddFP1"><?= lang('PresupuestosDirecciones.sameAddFP1') ?></label>
|
<label class="form-check-label"
|
||||||
|
for="sameAddFP1"><?= lang('PresupuestosDirecciones.sameAddFP1') ?></label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
class tarjetaDireccion {
|
class tarjetaDireccion {
|
||||||
|
|
||||||
constructor(container, id, direccion) {
|
constructor(container, id, direccion, isFerroPrototipo = false, numFerro = 0) {
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -9,6 +9,8 @@ class tarjetaDireccion {
|
|||||||
this.deleteBtn = this.card.find('.direccion-eliminar');
|
this.deleteBtn = this.card.find('.direccion-eliminar');
|
||||||
this.editBtn = this.card.find('.direccion-editar');
|
this.editBtn = this.card.find('.direccion-editar');
|
||||||
this.direccion = direccion;
|
this.direccion = direccion;
|
||||||
|
this.isFerroPrototipo = direccion.isFerroPrototipo;
|
||||||
|
this.numFerro = this.numFerro || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,6 +111,13 @@ class tarjetaDireccion {
|
|||||||
entregaPalets: this.getEntregaPalets()
|
entregaPalets: this.getEntregaPalets()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getIsFerroPrototipo() {
|
||||||
|
return this.isFerroPrototipo;
|
||||||
|
}
|
||||||
|
getNumFerro() {
|
||||||
|
return this.numFerro;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default tarjetaDireccion;
|
export default tarjetaDireccion;
|
||||||
@ -22,13 +22,21 @@ class Direcciones {
|
|||||||
this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
|
this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
|
||||||
|
|
||||||
this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2');
|
this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2');
|
||||||
|
this.direccionesClienteFP1 = new ClassSelect($("#direccionesFP1"), '/misdirecciones/getSelect2');
|
||||||
|
this.direccionesClienteFP2 = new ClassSelect($("#direccionesFP2"), '/misdirecciones/getSelect2');
|
||||||
|
|
||||||
this.divDirecciones = $(this.domItem.find('#divDirecciones'));
|
this.divDirecciones = $(this.domItem.find('#divDirecciones'));
|
||||||
this.divTiradas = this.domItem.find('#containerTiradasEnvios');
|
this.divTiradas = this.domItem.find('#containerTiradasEnvios');
|
||||||
|
|
||||||
|
this.sameAddPrincipalFP1 = this.domItem.find('#sameAddPrincipalFP1');
|
||||||
|
this.sameAddPrincipalFP2 = this.domItem.find('#sameAddPrincipalFP2');
|
||||||
|
this.sameAddFP1 = this.domItem.find('#sameAddFP1');
|
||||||
|
|
||||||
this.checksTiradasEnvio = $('.check-tirada-envio');
|
this.checksTiradasEnvio = $('.check-tirada-envio');
|
||||||
|
|
||||||
this.direcciones = [];
|
this.direcciones = [];
|
||||||
|
this.direccionesFP1 = [];
|
||||||
|
this.direccionesFP2 = [];
|
||||||
|
|
||||||
this.tiradaSeleccionada = null;
|
this.tiradaSeleccionada = null;
|
||||||
|
|
||||||
@ -57,6 +65,8 @@ class Direcciones {
|
|||||||
|
|
||||||
|
|
||||||
this.direccionesCliente.init();
|
this.direccionesCliente.init();
|
||||||
|
this.direccionesClienteFP1.init();
|
||||||
|
this.direccionesClienteFP2.init();
|
||||||
this.btnAdd.on('click', this.#insertDireccion.bind(this));
|
this.btnAdd.on('click', this.#insertDireccion.bind(this));
|
||||||
this.btnNew.on('click', this.#nuevaDireccion.bind(this));
|
this.btnNew.on('click', this.#nuevaDireccion.bind(this));
|
||||||
|
|
||||||
@ -80,9 +90,14 @@ class Direcciones {
|
|||||||
self.divTiradas.trigger('change');
|
self.divTiradas.trigger('change');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.sameAddPrincipalFP1.on('change', this.#handleSameAddPrincipalFP1.bind(this));
|
||||||
|
this.sameAddPrincipalFP2.on('change', this.#handleSameAddPrincipalFP2.bind(this));
|
||||||
|
this.sameAddFP1.on('change', this.#handleSameAddFP1.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cargarDatos(datos, datosGenerales) {
|
cargarDatos(datos, datosGenerales) {
|
||||||
|
|
||||||
self = this;
|
self = this;
|
||||||
@ -223,72 +238,6 @@ class Direcciones {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initValidation() {
|
|
||||||
|
|
||||||
const stepper = this.validatorStepper;
|
|
||||||
|
|
||||||
this.formValidation = FormValidation.formValidation(this.wizardStep, {
|
|
||||||
fields: {
|
|
||||||
div_error_envios: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: () => {
|
|
||||||
|
|
||||||
|
|
||||||
div.find('.fv-plugins-message-container').remove();
|
|
||||||
|
|
||||||
if ($('.check-tirada-envio:checked').length > 0) {
|
|
||||||
let unidades = parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada'));
|
|
||||||
let total_envio = 0;
|
|
||||||
// se recorre el array this.direcciones
|
|
||||||
this.direcciones.forEach(direccion => {
|
|
||||||
total_envio += parseInt(direccion.getUnidades());
|
|
||||||
});
|
|
||||||
if (total_envio <= unidades) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
div.append(`
|
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_tipo_cubierta" data-validator="callback">
|
|
||||||
El total de unidades enviadas no puede ser mayor que la tirada seleccionada
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
trigger: new FormValidation.plugins.Trigger(),
|
|
||||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
|
||||||
// Use this for enabling/changing valid/invalid class
|
|
||||||
// eleInvalidClass: '',
|
|
||||||
eleValidClass: '',
|
|
||||||
rowSelector: function (field, ele) {
|
|
||||||
// field is the field name
|
|
||||||
// ele is the field element
|
|
||||||
switch (field) {
|
|
||||||
case 'div_error_envios':
|
|
||||||
return '.col-sm-10';
|
|
||||||
default:
|
|
||||||
return '.col-sm-3';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
|
||||||
submitButton: new FormValidation.plugins.SubmitButton()
|
|
||||||
}
|
|
||||||
}).on('core.form.valid', () => {
|
|
||||||
if (this.allowNext)
|
|
||||||
stepper.next();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
insertTirada(tirada) {
|
insertTirada(tirada) {
|
||||||
|
|
||||||
@ -449,6 +398,10 @@ class Direcciones {
|
|||||||
|
|
||||||
this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
this.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
||||||
this.direccionesCliente.empty();
|
this.direccionesCliente.empty();
|
||||||
|
this.direccionesClienteFP1.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
||||||
|
this.direccionesClienteFP1.empty();
|
||||||
|
this.direccionesClienteFP2.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
||||||
|
this.direccionesClienteFP2.empty();
|
||||||
|
|
||||||
this.domItem.find('.direccion-cliente').remove();
|
this.domItem.find('.direccion-cliente').remove();
|
||||||
this.direcciones = [];
|
this.direcciones = [];
|
||||||
@ -500,6 +453,97 @@ class Direcciones {
|
|||||||
this.divDirecciones.trigger('change');
|
this.divDirecciones.trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#handleSameAddPrincipalFP1() {
|
||||||
|
|
||||||
|
if (this.sameAddPrincipalFP2.is(':checked')) {
|
||||||
|
$('.div-direcciones-fp1').addClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo').empty();
|
||||||
|
if (this.direcciones.length > 0) {
|
||||||
|
// get first element
|
||||||
|
let firstDireccion = this.direcciones[0];
|
||||||
|
let tarjeta = new tarjetaDireccion(
|
||||||
|
$("#divDireccionesFerroPrototipo"),
|
||||||
|
'dirEnvio-FP-1',
|
||||||
|
firstDireccion.getData(), true, 1);
|
||||||
|
tarjeta.setUnidades(1);
|
||||||
|
$('#divDireccionesFerroPrototipo').append(tarjeta.card);
|
||||||
|
this.direccionesFP1 = [];
|
||||||
|
this.direccionesFP1.push(tarjeta);
|
||||||
|
$('#divDireccionesFerroPrototipo').removeClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// mostrar alerta de que no hay direcciones
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.div-direcciones-fp1').removeClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo').removeClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo').empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#handleSameAddPrincipalFP2() {
|
||||||
|
|
||||||
|
if (this.sameAddPrincipalFP2.is(':checked')) {
|
||||||
|
$('.div-direcciones-fp2').addClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo2').empty();
|
||||||
|
if (this.direcciones.length > 0) {
|
||||||
|
// get first element
|
||||||
|
let firstDireccion = this.direcciones[0];
|
||||||
|
let tarjeta = new tarjetaDireccion(
|
||||||
|
$("#divDireccionesFerroPrototipo2"),
|
||||||
|
'dirEnvio-FP-2',
|
||||||
|
firstDireccion.getData(), true, 1);
|
||||||
|
tarjeta.setUnidades(1);
|
||||||
|
$('#divDireccionesFerroPrototipo2').append(tarjeta.card);
|
||||||
|
this.direccionesFP2 = [];
|
||||||
|
this.direccionesFP2.push(tarjeta);
|
||||||
|
$('#divDireccionesFerroPrototipo2').removeClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// mostrar alerta de que no hay direcciones
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.div-direcciones-fp2').removeClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo2').removeClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo2').empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#handleSameAddFP1() {
|
||||||
|
|
||||||
|
if (this.sameAddFP1.is(':checked')) {
|
||||||
|
$('.div-direcciones-fp2').addClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo2').empty();
|
||||||
|
if (this.direccionesFP1.length > 0) {
|
||||||
|
// get first element
|
||||||
|
let firstDireccion = this.direccionesFP1[0];
|
||||||
|
let tarjeta = new tarjetaDireccion(
|
||||||
|
$("#divDireccionesFerroPrototipo2"),
|
||||||
|
'dirEnvio-FP-2',
|
||||||
|
firstDireccion.getData(), true, 1);
|
||||||
|
tarjeta.setUnidades(1);
|
||||||
|
$('#divDireccionesFerroPrototipo2').append(tarjeta.card);
|
||||||
|
this.direccionesFP2 = [];
|
||||||
|
this.direccionesFP2.push(tarjeta);
|
||||||
|
$('#divDireccionesFerroPrototipo2').removeClass('d-none');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// mostrar alerta de que no hay direcciones
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.div-direcciones-fp2').removeClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo2').removeClass('d-none');
|
||||||
|
$('#divDireccionesFerroPrototipo2').empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
getSelectedTirada() {
|
getSelectedTirada() {
|
||||||
if ($('.check-tirada-envio:checked').length > 0)
|
if ($('.check-tirada-envio:checked').length > 0)
|
||||||
return parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada'));
|
return parseInt($($('.check-tirada-envio:checked')[0]).attr('tirada'));
|
||||||
|
|||||||
@ -86,6 +86,8 @@ class PresupuestoCliente {
|
|||||||
if (this.datosGenerales.excluirRotativa.length == 0) {
|
if (this.datosGenerales.excluirRotativa.length == 0) {
|
||||||
|
|
||||||
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
|
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
|
||||||
|
this.direcciones.direccionesClienteFP1.setParams({ 'cliente_id': $("#clienteId").val() })
|
||||||
|
this.direcciones.direccionesClienteFP2.setParams({ 'cliente_id': $("#clienteId").val() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user