terminados envios

This commit is contained in:
2025-01-13 21:34:18 +01:00
parent 522e026ded
commit 28a133f687
6 changed files with 367 additions and 275 deletions

View File

@ -11,7 +11,7 @@
<div id='alert-envios'></div>
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
<table id="tableOfDireccionesEnvio" class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
<thead>
<tr>
<th class="lp-header">TARIFA ID</th>
@ -23,12 +23,13 @@
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th>Proveedor_id</th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.precio') ?></th>
<th><?= lang('Tarifaacabado.margen') ?></th>
<th>Pallets?</th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>

View File

@ -133,260 +133,3 @@
</div>
<?= $this->section("additionalInlineJs") ?>
/*
$('#cancelAdd').on('click', function(){
$('#addressForm').modal("hide");
})
$('#add_cantidad').on('change', function(){
if(parseInt($('#add_cantidad').val()) > $('#add_cantidad').attr('max-value'))
$('#add_cantidad').val($('#add_cantidad').attr('max-value'))
})
$('#saveDireccionEnvio').on('click', function(){
if(validate_fields()){
if($('#addressForm').attr('action')=='edit'){
tableEnvios.row( $("#addressForm").attr('row') )
.remove()
.draw();
}
var peso_total_libro = 0
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
peso_total_libro += parseFloat(rowData.peso)
})
const peso_envio = peso_total_libro*parseInt($('#add_cantidad').val())/1000.0
$.post( '<?= route_to('dataTableOfPresupuestoDirecciones') ?>',
{
tipo: "get_tarifa",
peso: peso_envio,
paisId: $("#add_pais_id").val(),
cp: $('#add_cp').val(),
tipo_envio: $('#add_entregaPieCalle').is(":checked")?'palets':'cajas',
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
})
.done(function( data ) {
if(data.length >0){
var precios = []
for (var i = 0; i < data.length; i++) {
if(peso_envio>data[i].peso_max || data[i].precio_max == 0){
data[i].precio = (parseFloat(data[i].precio_min) + (peso_envio-parseFloat(data[i].peso_min))*parseFloat(data[i].precio_adicional)).toFixed(2);
}
// si no se calcula linealmente
else{
m=((data[i].precio_max-data[i].precio_min)/(data[i].peso_max-data[i].peso_min))
b=data[i].precio_max-m*data[i].peso_max
data[i].precio = parseFloat(m*peso_envio+b).toFixed(2);
}
data[i].margen = data[i].margen
}
const tarifa_final = data.reduce((previous, current) => {
return current.precio < previous.precio ? current : previous;
});
tarifa_final.cantidad=parseInt($('#add_cantidad').val())
tarifa_final.peso=peso_envio
tableEnvios.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'paisId': $('#add_pais_id').val(),
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': tarifa_final.precio,
'margen': tarifa_final.margen,
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked")?1:0,
'actionBtns_direcciones': actionBtns_direcciones,
})
.draw();
// Se guarda la dirección
if($('#add_saveDirection').is(":checked") &&
$('#add_alias').val().length>0){
$.post( '/clientes/clientedirecciones/add',
{
cliente_id: $('#clienteId').val(),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'paisId': $('#add_pais_id').val(),
'telefono': $('#add_telefono').val(),
'alias': $('#add_alias').val(),
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
})
.done(function( data ) {
})
}
checkInsertar()
//updateTotales(false, false, true)
updatePresupuesto({
update_lineas: false,
update_servicios: true,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
})
$('#addressForm').modal("hide");
}
else{
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
}
});
}
})
function validate_fields(){
$( ".error-text-form" ).remove();
var returnValue = false
$("input.new-address").each( function() {
if($('#' + this.id).val().length == 0 && $('#' + this.id).css('display') != 'none'){
$('#' + this.id).after(
"<p style='font-size: 11px !important;" +
"padding: 0 !important; " +
"color: #b11f1f !important;' " +
"class='error-text-form'>" +'<?= lang('PresupuestosDirecciones.validation.required'); ?>' + '</p>')
}
returnValue = true
})
return returnValue
}
$('#add_saveDirection').change(function() {
if(this.checked) {
$('.save-alias').css('display', 'inline')
}
else{
$('.save-alias').css('display', 'none')
}
$('#add_saveDirection').val(this.checked);
});
$('#add_clientedAdd').select2({
allowClear: false,
minimumResultsForSearch: Infinity,
dropdownParent: $('#addressForm'),
ajax: {
url: '<?= route_to("menuItemsOfClienteDirecciones") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
cliente_id: $('#clienteId').val(),
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
})
$('#add_clientedAdd').on('select2:select', function (e) {
$('.save-alias').css('display', 'none')
$('#add_alias').val('')
$('#add_saveDirection').attr("disabled", true)
var data = e.params.data;
$.ajax({
type: "POST",
url: '<?=route_to('dataTableOfClienteDirecciones') ?>',
dataType: 'json',
data: {
tipo: 'direccion',
id: data.id,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
},
success: function (data) {
if(data.length>0){
$('#add_att').val(data[0].att)
$('#add_direccion').val(data[0].direccion)
$('#add_cp').val(data[0].cp)
$('#add_municipio').val(data[0].municipio)
$('#add_provincia').val(data[0].provincia)
$('#add_telefono').val(data[0].telefono)
$('#add_email').val(data[0].email)
$('#add_pais_id').val(data[0].pais_id).change();
}
yeniden(data.<?= csrf_token() ?>);
return true;
},
error: function(e){
return false;
}
})
return false;
});
$('.new-address').on('change', function(e){
if (e.originalEvent) {
// user-triggered event
$('#add_clientedAdd').val(null).trigger('change');
$('#add_saveDirection').removeAttr("disabled");
}
})
// clear modal items when close
$('#addressForm').on('hidden.bs.modal', function () {
$('#add_alias').val("")
$('#add_att').val("")
$('#add_email').val("")
$('#add_direccion').val("")
$("#add_pais_id").val(1).change()
$("#add_clientedAdd").val("").change()
$('#add_municipio').val("")
$('#add_provincia').val("")
$('#add_cp').val("")
$('#add_telefono').val("")
$('#add_saveDirection').prop('checked', false)
$('#add_entregaPieCalle').prop('checked', false)
})
*/
<?=$this->endSection() ?>