Effettuato modifiche al report annuale e alla lista movimenti per problema ISSUE#3
This commit is contained in:
@@ -1,162 +1,87 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#listamovimenti').DataTable({
|
||||
"responsive": true,
|
||||
columnDefs: [
|
||||
{
|
||||
target: 0,
|
||||
render: DataTable.render.date(),
|
||||
}
|
||||
],
|
||||
"order": [[0, "desc"]]
|
||||
responsive: true,
|
||||
columnDefs: [{
|
||||
target: 0,
|
||||
render: DataTable.render.date(),
|
||||
}],
|
||||
order: [[0, "desc"]]
|
||||
});
|
||||
|
||||
// $('.select2').select2();
|
||||
});
|
||||
|
||||
|
||||
$(".draggable").draggable();
|
||||
|
||||
var d = new Date();
|
||||
var month = d.getMonth()+1;
|
||||
var month = d.getMonth() + 1;
|
||||
var day = d.getDate();
|
||||
var strDate = d.getFullYear() + '-' +
|
||||
(month<10 ? '0' : '') + month + '-' +
|
||||
(day<10 ? '0' : '') + day;
|
||||
var strDate = d.getFullYear() + '-' + (month < 10 ? '0' : '') + month + '-' + (day < 10 ? '0' : '') + day;
|
||||
|
||||
function fillSelect(url, selectName, selectedValue) {
|
||||
$(selectName).empty();
|
||||
$.getJSON(url, {}, function(items) {
|
||||
$.each(items, function(i, item) {
|
||||
var label = item.cat_name || item.tag_name || item.nomeConto;
|
||||
$(selectName).append(new Option(label, item.id));
|
||||
});
|
||||
if (selectedValue) {
|
||||
$(selectName).val(selectedValue).trigger('change');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetForm(formSelector, dateValue) {
|
||||
$(formSelector).find('input[type="text"], textarea, input[type="number"], input[type="date"], option').val('');
|
||||
$(formSelector).find('input[type="date"]').val(dateValue);
|
||||
}
|
||||
|
||||
function openModal(tipo, actionUrl, catUrl, tagUrl, contoUrl, modalTitle) {
|
||||
resetForm('#form', strDate);
|
||||
$('#myModal').modal('show');
|
||||
$('.modal-title').text(modalTitle);
|
||||
$('#form').attr('action', actionUrl);
|
||||
fillSelect(catUrl, "select[name='mov_fk_categoria']");
|
||||
fillSelect(tagUrl, "select[name='mov_fk_tags']");
|
||||
fillSelect(contoUrl, "select[name='conto_id']");
|
||||
}
|
||||
|
||||
|
||||
$(document).on('click', '.open_modal_spesa', function() {
|
||||
console.log(strDate);
|
||||
$("#categoria").empty();
|
||||
$("#tags").empty();
|
||||
$('#form').find('input[type="text"], textarea, input[type="number"],input[type="date"],option').val("");
|
||||
$('#form').find('input[type="date"]').val(strDate);
|
||||
$('#myModal').modal('show');
|
||||
$('.modal-title').text(' Nuovo movimento in uscita');
|
||||
$('#form').attr('action', '/admin/movimenti/spesa');
|
||||
$.getJSON("/admin/service/catlistSpesa", {}, function(cats) {
|
||||
$.each(cats, function(i, cat) {
|
||||
$("select[name='mov_fk_categoria']").append(
|
||||
new Option(cat.cat_name, cat.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
$.getJSON("/admin/service/taglist", {}, function(tags) {
|
||||
$.each(tags, function(i, tag) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(tag.tag_name, tag.id)
|
||||
)
|
||||
});
|
||||
});
|
||||
$.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
$.each(contis, function(i, conto) {
|
||||
$("select[name='conto_id']").append(
|
||||
new Option(conto.nomeConto, conto.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
openModal('spesa', '/admin/movimenti/spesa', '/admin/service/catlistSpesa', '/admin/service/taglist', '/admin/service/contolist', 'Nuovo movimento in uscita');
|
||||
$('#importo').attr('name', 'mov_importo_dare');
|
||||
});
|
||||
|
||||
$(document).on('click', '.open_modal_entrata', function() {
|
||||
console.log(strDate);
|
||||
$("#categoria").empty();
|
||||
$("#tags").empty();
|
||||
$('#form').find('input[type="text"], textarea, input[type="number"],option').val("");
|
||||
$('#form').find('input[type="date"]').val(strDate);
|
||||
$('#myModal').modal('show');
|
||||
$('.modal-title').text('Nuovo movimento in entrata');
|
||||
$('#form').attr('action', '/admin/movimenti/entrata');
|
||||
$.getJSON("/admin/service/catlistEntrata", {}, function(data) {
|
||||
$.each(data, function(i, item) {
|
||||
$("select[name='mov_fk_categoria']").append(
|
||||
new Option(item.cat_name, item.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
$.getJSON("/admin/service/taglist", {}, function(data) {
|
||||
$.each(data, function(i, item) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(item.tag_name, item.id)
|
||||
)
|
||||
});
|
||||
});
|
||||
$.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
$.each(contis, function(i, conto) {
|
||||
$("select[name='conto_id']").append(
|
||||
new Option(conto.nomeConto, conto.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
openModal('entrata', '/admin/movimenti/entrata', '/admin/service/catlistEntrata', '/admin/service/taglist', '/admin/service/contolist', 'Nuovo movimento in entrata');
|
||||
$('#importo').attr('name', 'mov_importo_avere');
|
||||
});
|
||||
|
||||
// Modifica movimento
|
||||
|
||||
$(document).on('click', '.open_modal_modifica', function() {
|
||||
var url = "/admin/movimenti/modify";
|
||||
var riga_id = $(this).val();
|
||||
$("#categoria").empty();
|
||||
$("#tags").empty();
|
||||
$.getJSON(url + '/' + riga_id, function(data) {
|
||||
// success data
|
||||
console.log(data[0]);
|
||||
$.getJSON("/admin/service/taglist", {}, function(tags) {
|
||||
$.each(tags, function(i, tag) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(tag.tag_name, tag.id)
|
||||
)
|
||||
$('#tags')
|
||||
.find('option:contains(' + data[0].tag_name + ')')
|
||||
.prop('selected', true)
|
||||
.trigger('change');
|
||||
});
|
||||
});
|
||||
$.getJSON("/admin/service/catlist", {}, function(cats) {
|
||||
$.each(cats, function(i, cat) {
|
||||
$("select[name='mov_fk_categoria']").append(
|
||||
new Option(cat.cat_name, cat.id)
|
||||
)
|
||||
$('#categoria')
|
||||
.find('option:contains(' + data[0].cat_name + ')')
|
||||
.prop('selected', true)
|
||||
.trigger('change');
|
||||
}
|
||||
);
|
||||
});
|
||||
$.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
$.each(contis, function(i, conto) {
|
||||
$("select[name='conto_id']").append(
|
||||
new Option(conto.nomeConto, conto.id)
|
||||
)
|
||||
$('#conto_id')
|
||||
.find('option:contains(' + data[0].nomeConto + ')')
|
||||
.prop('selected', true)
|
||||
.trigger('change');
|
||||
}
|
||||
);
|
||||
});
|
||||
$('.modal-title').text('Modifica movimento');
|
||||
$('#data').val(data[0].mov_data.substring(0,10));
|
||||
$.getJSON('/admin/movimenti/modify/' + riga_id, function(data) {
|
||||
resetForm('#form', data[0].mov_data.substring(0, 10));
|
||||
fillSelect('/admin/service/catlist', "select[name='mov_fk_categoria']", data[0].cat_name);
|
||||
fillSelect('/admin/service/taglist', "select[name='mov_fk_tags']", data[0].tag_name);
|
||||
fillSelect('/admin/service/contolist', "select[name='conto_id']", data[0].nomeConto);
|
||||
$('#descrizione').val(data[0].mov_descrizione);
|
||||
$('#importo').val(data[0].mov_importo_dare);
|
||||
|
||||
$('#myModal').modal('show');
|
||||
// $('.panel-heading').text('Modifica movimento');
|
||||
// Imposta importo e name in base a DARE/AVERE
|
||||
if (data[0].mov_importo_dare && parseFloat(data[0].mov_importo_dare) !== 0) {
|
||||
$('#importo').val(data[0].mov_importo_dare);
|
||||
$('#importo').attr('name', 'mov_importo_dare');
|
||||
} else if (data[0].mov_importo_avere && parseFloat(data[0].mov_importo_avere) !== 0) {
|
||||
$('#importo').val(data[0].mov_importo_avere);
|
||||
$('#importo').attr('name', 'mov_importo_avere');
|
||||
} else {
|
||||
$('#importo').val('');
|
||||
$('#importo').attr('name', 'mov_importo');
|
||||
}
|
||||
|
||||
$('.modal-title').text('Modifica movimento');
|
||||
$('#form').attr('action', '/admin/movimenti/modify');
|
||||
$('#form').append('<input type="hidden" name="id" value="' + riga_id + '">');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
$.getJSON("/admin/service/taglist", {}, function(data) {
|
||||
$.each(data, function(i, item) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(item.tag_name, item.id)
|
||||
)
|
||||
$('#myModal').modal('show');
|
||||
});
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user