mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
haciendo los eventos
This commit is contained in:
@ -147,7 +147,7 @@ function generarAlbaran(item){
|
||||
<label><?= lang('Pedidos.att') ?>:</label>
|
||||
</div>
|
||||
<div class="col-11">
|
||||
<input id="att_" + ${item.albaran.id} value=${item.albaran.att_albaran} class="form-control"></input>
|
||||
<input id="att_${item.albaran.id}" class="cambios-albaran form-control" albaran_id=${item.albaran.id} value=${item.albaran.att_albaran} class="form-control"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 d-flex justify-content-between mb-3">
|
||||
@ -155,13 +155,13 @@ function generarAlbaran(item){
|
||||
<label><?= lang('Pedidos.direccion') ?>:</label>
|
||||
</div>
|
||||
<div class="col-11">
|
||||
<input id="att_" + ${item.albaran.id} value=${item.albaran.direccion_albaran} class="form-control"></input>
|
||||
<input id="direccion_${item.albaran.id}" albaran_id=${item.albaran.id} value=${item.albaran.direccion_albaran} class="cambios-albaran form-control"></input>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const table = $('<table>',
|
||||
{ id: 'tablaAlbaran' + item.albaran_linea.id, width:'100%', class: 'table table-responsive table-striped table-hover' })
|
||||
{ id: 'tablaAlbaran' + item.albaran.id, width:'100%', class: 'table table-responsive table-striped table-hover' })
|
||||
.css({
|
||||
'width': '100%',
|
||||
}).append(
|
||||
@ -187,25 +187,36 @@ function generarAlbaran(item){
|
||||
),
|
||||
);
|
||||
|
||||
let isChecked = item.albaran.mostrar_precios == 1 ? 'checked' : '';
|
||||
const botones_albaran =
|
||||
`
|
||||
<div id="bonotes_albaran" + ${item.albaran.id} class="col-12 d-flex flex-row-reverse mt-4 gap-2">
|
||||
<div id="borrar_albaran" + ${item.albaran.id} class="btn mt-3 button-albaran btn-label-danger waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.borrarAlbaran') ?></span>
|
||||
<i class="ti ti-trash ti-xs"></i>
|
||||
`
|
||||
<div class="row mt-1">
|
||||
<div id="div_mostrar_precios_${item.albaran.id}" class="col-2 d-flex flex-row gap-2">
|
||||
<div class="d-flex align-items-center">
|
||||
<label><?= lang('Pedidos.mostrarPrecios') ?>:</label>
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<input type="checkbox" id="mostrar_precios" name="mostrar_precios" albaran_id=${item.albaran.id} class="mostrar-precios custom-control-input" ${isChecked} >
|
||||
</div>
|
||||
</div>
|
||||
<div id="bonotes_albaran_${item.albaran.id}" class="col-10 d-flex flex-row-reverse gap-2">
|
||||
<div id="borrar_albaran_${item.albaran.id}" class="btn mt-3 button-albaran btn-label-danger waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.borrarAlbaran') ?></span>
|
||||
<i class="ti ti-trash ti-xs"></i>
|
||||
</div>
|
||||
|
||||
<div id="borrar_albaran" + ${item.albaran.id} class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.imprimirAlbaran') ?></span>
|
||||
<i class="ti ti-printer ti-xs"></i>
|
||||
</div>
|
||||
<div id="nueva_linea_albaran" + ${item.albaran.id} class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.nuevaLinea') ?></span>
|
||||
<i class="ti ti-plus ti-xs"></i>
|
||||
</div>
|
||||
<div id="add_iva_albaran" + ${item.albaran.id} class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.addIva') ?></span>
|
||||
<i class="ti ti-plus ti-xs"></i>
|
||||
<div id="borrar_albaran_${item.albaran.id}" class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.imprimirAlbaran') ?></span>
|
||||
<i class="ti ti-printer ti-xs"></i>
|
||||
</div>
|
||||
<div id="nueva_linea_albaran_${item.albaran.id}" class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.nuevaLinea') ?></span>
|
||||
<i class="ti ti-plus ti-xs"></i>
|
||||
</div>
|
||||
<div id="add_iva_albaran_${item.albaran.id}" class="btn mt-3 btn-label-secondary button-albaran waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('Pedidos.addIva') ?></span>
|
||||
<i class="ti ti-plus ti-xs"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@ -226,7 +237,7 @@ function generarAlbaran(item){
|
||||
|
||||
|
||||
|
||||
const datatableAlbaran = new DataTable('#tablaAlbaran' + item.albaran_linea.id,{
|
||||
const datatableAlbaran = new DataTable('#tablaAlbaran' + item.albaran.id,{
|
||||
scrollX: true,
|
||||
searching: false,
|
||||
paging: false,
|
||||
@ -402,14 +413,18 @@ function generarAlbaran(item){
|
||||
{ targets: [1], orderable: false },
|
||||
{ targets: [2, 3, 4, 5, 6, 7, 8, 9], className: 'dt-center' }
|
||||
],
|
||||
});
|
||||
initComplete: function(settings){
|
||||
var numColumns = this.api().columns().count();
|
||||
if(item.albaran.mostrar_precios == 0){
|
||||
this.api().column(numColumns - 1).visible(false);
|
||||
this.api().column(numColumns - 2).visible(false);
|
||||
} else {
|
||||
this.api().column(numColumns - 1).visible(true);
|
||||
this.api().column(numColumns - 2).visible(true);
|
||||
}
|
||||
|
||||
|
||||
/*var nuevaFila = [
|
||||
item.algunDato1, // Reemplaza estos valores con los datos reales de tu objeto
|
||||
item.algunDato2,
|
||||
// Añade tantos elementos como columnas tenga tu tabla
|
||||
];*/
|
||||
}
|
||||
});
|
||||
|
||||
// Añadir la nueva fila a la tabla
|
||||
datatableAlbaran.row.add(item.albaran_linea).draw();
|
||||
@ -417,4 +432,66 @@ function generarAlbaran(item){
|
||||
|
||||
}
|
||||
|
||||
$(document).on('change', '.cambios-albaran', function(){
|
||||
var elementId = $(this).attr('id');
|
||||
|
||||
data = {
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
};
|
||||
data[elementId.split('_')[0] + '_albaran'] = $(this).val();
|
||||
|
||||
var albaran_id = $(this).attr('albaran_id');
|
||||
var url = '<?= route_to('actualizarAlbaran', ':id') ?>';
|
||||
url = url.replace(':id', albaran_id );
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response){
|
||||
|
||||
if('error' in response){
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).on('change', '.mostrar-precios', function(){
|
||||
|
||||
var checked = $(this).prop('checked');
|
||||
|
||||
var albaran_id = $(this).attr('albaran_id');
|
||||
var table = $('#tablaAlbaran' + albaran_id).DataTable();
|
||||
|
||||
var url = '<?= route_to('actualizarAlbaran', ':id') ?>';
|
||||
url = url.replace(':id', albaran_id );
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
mostrar_precios: checked?1:0,
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
},
|
||||
success: function(response){
|
||||
|
||||
if('error' in response){
|
||||
if(response.error == 0){
|
||||
if(checked){
|
||||
table.column(9).visible(true);
|
||||
table.column(8).visible(true);
|
||||
} else {
|
||||
table.column(9).visible(false);
|
||||
table.column(8).visible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
Reference in New Issue
Block a user