mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en direcciones!
This commit is contained in:
@ -0,0 +1,125 @@
|
||||
import Ajax from "../../../components/ajax.js";
|
||||
import { getToken } from "../../../common/common.js";
|
||||
|
||||
class Envios {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.recogerTaller = $('#recoger_en_taller');
|
||||
|
||||
this.table = null;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const self = this;
|
||||
|
||||
this.table = $('#tableOfDireccionesEnvio').DataTable({
|
||||
draw: 5,
|
||||
serverSide: false,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
order: [[0, "asc"]],
|
||||
pageLength: 20,
|
||||
lengthChange: false,
|
||||
searching: false,
|
||||
paging: false,
|
||||
info: false,
|
||||
scrollX: true,
|
||||
|
||||
columns: [
|
||||
{ 'data': 'tarifa_id' },
|
||||
{ 'data': 'cantidad' },
|
||||
{ 'data': 'peso' },
|
||||
{ 'data': 'att' },
|
||||
{ 'data': 'email' },
|
||||
{ 'data': 'direccion' },
|
||||
{ 'data': 'cp' },
|
||||
{ 'data': 'municipio' },
|
||||
{ 'data': 'pais' },
|
||||
{ 'data': 'telefono' },
|
||||
{ 'data': 'proveedor' },
|
||||
{ 'data': 'proveedor_id' },
|
||||
{ 'data': 'precio' },
|
||||
{ 'data': 'margen' },
|
||||
{ 'data': 'entregaPieCalle' },
|
||||
{
|
||||
data: function (row, type, set, meta) {
|
||||
return `
|
||||
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${row.id}"></i></a></span>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
|
||||
`;
|
||||
},
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [$('#tableOfDireccionesEnvio').find("tr:first th").length - 1]
|
||||
},
|
||||
{ "orderData": [0], "targets": 0 },
|
||||
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
target: [11],
|
||||
visible: false,
|
||||
searchable: false
|
||||
},
|
||||
],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
|
||||
drawCallback: function (settings) {
|
||||
self.check_unidades_enviadas();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
cargar(datos) {
|
||||
if (datos.entrega_taller) {
|
||||
this.recogerTaller.prop('checked', true);
|
||||
}
|
||||
else {
|
||||
this.table.rows.add(datos).draw();
|
||||
}
|
||||
}
|
||||
|
||||
check_unidades_enviadas() {
|
||||
|
||||
var cantidad_total = 0
|
||||
this.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
cantidad_total += parseInt(this.data().cantidad)
|
||||
});
|
||||
|
||||
const tirada = parseInt($('#tirada').val());
|
||||
let htmlString = '';
|
||||
if (cantidad_total < tirada && this.recogerTaller.prop('checked') === false) {
|
||||
htmlString = `
|
||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-bell ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2">` +
|
||||
window.language.Presupuestos.validation.ejemplares_envio +
|
||||
`</h5>
|
||||
</div>
|
||||
</div>`;
|
||||
$('#alert-envios').html(htmlString);
|
||||
return false;
|
||||
}
|
||||
$('#alert-envios').html(htmlString);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export default Envios;
|
||||
Reference in New Issue
Block a user