mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el back de las tiradas
This commit is contained in:
@ -12,15 +12,11 @@ const actionBtns_tiradasAlt = function (data) {
|
||||
|
||||
// Inicializaciones de la tabla de tiradas
|
||||
var tableTiradas;
|
||||
var editor;
|
||||
|
||||
|
||||
(async () => {
|
||||
while (!window.hasOwnProperty("editor_url") && !window.hasOwnProperty("editor_headers"))
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
initEditorTiradas()
|
||||
|
||||
while (!window.hasOwnProperty("datatable_lang_url"))
|
||||
while (!window.hasOwnProperty("datatable_lang_url") && !window.hasOwnProperty("datatable_TA_url"))
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
initTableTiradas();
|
||||
|
||||
@ -36,42 +32,69 @@ var editor;
|
||||
})();
|
||||
|
||||
|
||||
function initEditorTiradas() {
|
||||
$('#add_tirada_alt').on('click', function () {
|
||||
|
||||
editor = new $.fn.dataTable.Editor({
|
||||
ajax: {
|
||||
url: window.editor_url,
|
||||
headers: window.editor_headers,
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
let datos = {
|
||||
tirada: $('#tirada_alt').val(),
|
||||
merma: 20, ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>calcular merma
|
||||
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
||||
json_tiradas: generate_json_tiradas(),
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
cliente_id: $('#clienteId').find(":selected").val(),
|
||||
solapas_cubierta: $('#solapas').is(':checked')?1:0,
|
||||
solapas_cubierta_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0,
|
||||
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked')?1:0,
|
||||
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0,
|
||||
lomo: getLomoExterior(),
|
||||
};
|
||||
|
||||
datos = Object.assign(datos, window.token_ajax);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: window.get_tirada_url,
|
||||
data: datos,
|
||||
success: function (data) {
|
||||
|
||||
if(data.lineas.length >0){
|
||||
// Se cogen los valores de la linea con los datos correspondientes
|
||||
$.each(data.lineas, function(key, value) {
|
||||
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
yeniden(data[window.csrf_token]);
|
||||
|
||||
},
|
||||
table: "#tableTiradas",
|
||||
idSrc: 'id',
|
||||
fields: [
|
||||
{
|
||||
name: "tirada",
|
||||
}, {
|
||||
name: "coste_impresion",
|
||||
type: "hidden"
|
||||
}, {
|
||||
name: "coste_envio",
|
||||
type: "hidden"
|
||||
}, {
|
||||
name: "margen",
|
||||
type: "hidden"
|
||||
}, {
|
||||
name: "total_pedido",
|
||||
type: "hidden"
|
||||
}, {
|
||||
name: "precio_unidad",
|
||||
type: "hidden"
|
||||
}, {
|
||||
name: "json_tiradas",
|
||||
type: "hidden"
|
||||
},
|
||||
]
|
||||
error: function(e){
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getLomoExterior(){
|
||||
let lomoTotal = 0
|
||||
try{
|
||||
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
var rowData = this.data();
|
||||
if(rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
|
||||
lomoTotal += parseFloat(rowData.lomo)
|
||||
})
|
||||
}
|
||||
catch(error){
|
||||
lomoTotal = 0
|
||||
}
|
||||
return lomoTotal
|
||||
}
|
||||
|
||||
// Inicialización de la tabla de tiradas
|
||||
function initTableTiradas() {
|
||||
tableTiradas = $('#tableTiradas').DataTable({
|
||||
"language": {
|
||||
@ -83,7 +106,6 @@ function initTableTiradas() {
|
||||
"ordering": false,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
"dom": '<"mt-4"><"float-end"B><"float-start"l><t>', //"Blt",
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: false,
|
||||
@ -103,16 +125,6 @@ function initTableTiradas() {
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
"buttons": [{
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
text: '<i class="ti ti-circle-plus"></i>',
|
||||
extend: "createInline",
|
||||
editor: editor,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
@ -130,17 +142,35 @@ $(document).on('click', '.btn-delete-tirada', function (e) {
|
||||
|
||||
// Función para generar el JSON de las lineas de presupuesto para calcular las tiradas
|
||||
function generate_json_tiradas() {
|
||||
|
||||
const data = $('#tableLineasPresupuesto').DataTable().data().toArray();
|
||||
|
||||
return JSON.stringify(filterData(data,
|
||||
|
||||
//return data; // For debugging purposes
|
||||
json = filterData(data,
|
||||
['paginas',
|
||||
'numPagColor',
|
||||
'paginas_impresion',
|
||||
'papel_impresion_id',
|
||||
'papel', // papel generico
|
||||
'papel_impresion_id',
|
||||
'gramaje',
|
||||
'maquina_id',
|
||||
'maquinaTipo',
|
||||
'row_id']));
|
||||
'maquina_id',
|
||||
'aFavorFibra',
|
||||
'row_id',
|
||||
'check_papel_total',
|
||||
'check_impresion_total',
|
||||
'cobAmarillo', // tipologia de papel
|
||||
'cobCyan',
|
||||
'cobMagenta',
|
||||
'cobNegro',
|
||||
'cobCG',
|
||||
'gotaColor',
|
||||
'gotaNegro']);
|
||||
|
||||
json.forEach(element => {
|
||||
element['check_papel_total'] = $('#' + element['row_id'] + '_checkPapel').is(':checked') ? 1 : 0;
|
||||
element['check_impresion_total'] = $('#' + element['row_id'] + '_checkClicks').is(':checked') ? 1 : 0;
|
||||
});
|
||||
return JSON.stringify(json);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -15,7 +15,10 @@
|
||||
<div class="col-xl-12">
|
||||
<div class="border rounded p-4 mb-3 pb-3">
|
||||
<p><?= lang('Presupuestos.tiradasInfoIVA') ?></p>
|
||||
|
||||
<div class='d-flex justify-content-end '>
|
||||
<input id="tirada_alt" type="number" style="width: 10% !important; display: inline-flex !important" class="form-control" value="1" min="1" step="1">
|
||||
<button id="add_tirada_alt" type="button" class="btn btn-secondary waves-effect waves-light"><i class="ti ti-circle-plus"></i></button>
|
||||
</div>
|
||||
<table id="tableTiradas" class="comparator-table table dt-responsive dataTable" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -48,9 +51,13 @@
|
||||
<!------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
window.datatable_lang_url = "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json";
|
||||
window.editor_url = "<?= route_to('editorOfMaquinasTarifaImpresion') ?>";
|
||||
|
||||
window.datatable_TA_url = "<?= route_to('dataTableOfPresupuestoTiradasAlternativas') ?>";
|
||||
window.get_tirada_url = "<?= route_to('getTiradaData') ?>";
|
||||
|
||||
window.editor_headers= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
||||
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
||||
|
||||
window.csrf_token = '<?= csrf_token() ?>';
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user