Initial code for new budget report #426

This commit is contained in:
James Cole
2016-12-08 21:50:20 +01:00
parent ab9212a4c9
commit edb5b2ed5e
13 changed files with 177 additions and 4 deletions

View File

@@ -65,12 +65,22 @@ function getReportOptions() {
}
function setOptionalFromCookies() {
var arr;
// categories
if ((readCookie('report-categories') !== null)) {
var arr = readCookie('report-categories').split(',');
arr = readCookie('report-categories').split(',');
arr.forEach(function (val) {
$('input[class="category-checkbox"][type="checkbox"][value="' + val + '"]').prop('checked', true);
});
}
// and budgets!
if ((readCookie('report-budgets') !== null)) {
arr = readCookie('report-budgets').split(',');
arr.forEach(function (val) {
$('input[class="budget-checkbox"][type="checkbox"][value="' + val + '"]').prop('checked', true);
});
}
}
function catchSubmit() {
@@ -90,7 +100,6 @@ function catchSubmit() {
});
// all category ids:
//category-checkbox
var categories = [];
$.each($('.category-checkbox'), function (i, v) {
var c = $(v);
@@ -99,6 +108,15 @@ function catchSubmit() {
}
});
// all budget ids:
var budgets = [];
$.each($('.budget-checkbox'), function (i, v) {
var c = $(v);
if (c.prop('checked')) {
budgets.push(c.val());
}
});
// remember all
if (count > 0) {
@@ -106,6 +124,7 @@ function catchSubmit() {
createCookie('report-type', $('select[name="report_type"]').val(), 365);
createCookie('report-accounts', accounts, 365);
createCookie('report-categories', categories, 365);
createCookie('report-budgets', budgets, 365);
createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365);
createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365);
}