falta botones exportar, etc

This commit is contained in:
Jaime Jimenez
2023-09-04 09:05:48 +02:00
parent 56b233af1f
commit 289d89851b
11 changed files with 112 additions and 76 deletions

View File

@ -1,8 +1,16 @@
<div class="row">
<div class="col-md-12 col-lg-12 px-4">
<div class="mb-3">
<label for="nombre" class="form-label">
<?=lang('TarifasEnvios.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaEnvioEntity->nombre) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="paisId" class="form-label">
<?=lang('TarifasEnvios.paisId') ?>
<?=lang('TarifasEnvios.paisId') ?>*
</label>
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('TarifasEnvios.paisId')]) ?></option>
@ -15,13 +23,6 @@
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="nombre" class="form-label">
<?=lang('TarifasEnvios.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaEnvioEntity->nombre) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->

View File

@ -45,6 +45,7 @@
<table id="tableOfZonas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('TarifasEnviosZonas.nombre') ?></th>
<th><?= lang('TarifasEnviosZonas.cpInicial') ?></th>
<th><?= lang('TarifasEnviosZonas.cpFinal') ?></th>
<th><?= lang('TarifasEnviosZonas.importeFijo') ?></th>
@ -81,6 +82,7 @@
<th><?= lang('TarifasEnviosPrecios.pesoMax') ?></th>
<th><?= lang('TarifasEnviosPrecios.precio') ?></th>
<th><?= lang('TarifasEnviosPrecios.precioAdicional') ?></th>
<th><?= lang('TarifasEnviosPrecios.margen') ?></th>
<th style="min-width:100px"></th>
</tr>
</thead>
@ -138,9 +140,7 @@
}
});
var selected_zona_id = -1;
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
@ -174,6 +174,8 @@
table : "#tableOfZonas",
idSrc: 'id',
fields: [ {
name: "nombre"
}, {
name: "cp_inicial"
}, {
name: "cp_final"
@ -224,14 +226,20 @@
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
order: [[ 0, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
paging: true,
select: true,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
"dom": 'lfBrtip',
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifasEnvioZonas') ?>',
data: {
@ -242,6 +250,7 @@
async: true,
}),
columns: [
{ 'data': 'nombre' },
{ 'data': 'cp_inicial' },
{ 'data': 'cp_final' },
{ 'data': 'importe_fijo' },
@ -256,7 +265,7 @@
searchable: false,
targets: [lastColNr]
},
{"orderData": [ 0, 1 ], "targets": 0 },
{"orderData": [ 0], "targets": 0 },
],
language: {
@ -309,22 +318,6 @@
});
}
theTable.on( 'select', function ( e, dt, type, indexes ) {
if ( type === 'row' ) {
selected_zona_id = parseInt(theTable.rows( indexes ).data().pluck( 'id' )[0]);
theTable2.clearPipeline();
theTable2.draw();
}
} );
theTable.on( 'deselect', function ( e, dt, type, indexes ) {
if ( theTable.rows( '.selected' ).count() == 0 ) {
selected_zona_id = -1;
theTable2.clearPipeline();
theTable2.draw();
}
} );
<?= $this->endSection() ?>
@ -357,9 +350,12 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
}, {
name: "precio"
}, {
name: "precio_adicional"
name: "precio_adicional",
def: 0
}, {
"name": "zona_envio_id",
name: "margen"
}, {
"name": "tarifa_envio_id",
"type": "hidden"
}, {
"name": "deleted_at",
@ -377,11 +373,11 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
editor2.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['zona_envio_id'] = selected_zona_id;
d.data[0]['tarifa_envio_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['zona_envio_id'] = selected_zona_id;
d.data[v]['tarifa_envio_id'] = id;
}
}
});
@ -390,7 +386,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
editor2.dependent('proveedor_id', function (val, data, callback, e ) {
var supplier = suppliersList.find(o => o.value === val);
values = [{label:'<?= lang('TarifasEnviosPrecios.aDomicilio') ?>', value: "a domicilio"}];
values = [];
if(supplier.options != null)
{
@ -424,7 +420,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25, 50, 100],
order: [[ 0, "asc" ], [ 1, "asc" ]],
order: [ 0, "asc" ],
pageLength: 25,
lengthChange: true,
searching: false,
@ -434,7 +430,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifasEnvioPrecios') ?>',
data: function ( d ) {
d.zona_envio_id = selected_zona_id;
d.tarifa_envio_id = id;
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
@ -448,9 +444,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
},
},
{ 'data': 'tipo_envio', "render": function ( data, type, row, meta ) {
if(data=='a domicilio')
return '<?= lang('TarifasEnviosPrecios.aDomicilio') ?>';
else if (data=='cajas')
if (data=='cajas')
return '<?= lang('TarifasEnviosPrecios.cajas') ?>';
else if (data=='palets')
return '<?= lang('TarifasEnviosPrecios.palets') ?>';
@ -460,6 +454,7 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
{ 'data': 'peso_max' },
{ 'data': 'precio' },
{ 'data': 'precio_adicional' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
@ -486,19 +481,6 @@ const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
},
action: function ( e, dt, node, config ) {
if(selected_zona_id == -1){
popErrorAlert("<?= lang('TarifasEnviosPrecios.validation.error_seleccion_zonas') ?>");
}
else{
formOptions= {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
};
editor2.inlineCreate(config.position, formOptions);
}
},
} ],
} );