From 8daccbfbb420422ab77f29371c621b4557b4f5c8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 18:22:41 +0200 Subject: [PATCH 01/30] Add JSHint stuff. [skip ci] --- .jshintrc | 22 ++++++++++++++++++++++ public/js/accounts.js | 33 ++++++++++++++++----------------- public/js/bills.js | 12 +++++++----- public/js/budgets.js | 14 +++++++++++--- public/js/categories.js | 3 ++- public/js/firefly.js | 11 ++++------- public/js/gcharts.js | 12 +++++++++++- public/js/gcharts.options.js | 6 ++++-- public/js/help.js | 11 +++++++---- public/js/index.js | 20 ++++++++++++++------ public/js/piggy-banks.js | 22 ++++++++++++---------- public/js/reports.js | 2 +- public/js/transactions.js | 2 +- 13 files changed, 112 insertions(+), 58 deletions(-) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000000..e6395a276a --- /dev/null +++ b/.jshintrc @@ -0,0 +1,22 @@ +{ + "undef": true, + "unused": false, + "strict": true, + "browser": true, + "jquery": true, + "devel": true, + "globals": [ + "language", + "token", + "currencyCode", + "$", + "token", + "accountID", + "billID", + "currentMonthName", + "previousMonthName", + "nextMonthName", + "everything", + "moment" + ] +} \ No newline at end of file diff --git a/public/js/accounts.js b/public/js/accounts.js index 5435c2d6b9..ae240b8500 100644 --- a/public/js/accounts.js +++ b/public/js/accounts.js @@ -1,11 +1,23 @@ -$(function () { +/* global $ */ + +// Return a helper with preserved width of cells +var fixHelper = function (e, ui) { + "use strict"; + ui.children().each(function () { + $(this).width($(this).width()); + }); + return ui; +}; + +$(function () { + "use strict"; if (typeof(googleLineChart) === "function" && typeof accountID !== 'undefined') { googleLineChart('chart/account/' + accountID, 'overview-chart'); } // sortable! - if (typeof $(".sortable-table tbody").sortable != "undefined") { + if (typeof $(".sortable-table tbody").sortable !== "undefined") { $(".sortable-table tbody").sortable( { helper: fixHelper, @@ -19,23 +31,14 @@ $(function () { }); -// Return a helper with preserved width of cells -var fixHelper = function (e, ui) { - ui.children().each(function () { - $(this).width($(this).width()); - }); - return ui; -}; - function sortStop(event, ui) { + "use strict"; var current = $(ui.item); var thisDate = current.data('date'); var originalBG = current.css('backgroundColor'); - if (current.prev().data('date') != thisDate && current.next().data('date') != thisDate) { - //console.log('False!'); - //console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']'); + if (current.prev().data('date') !== thisDate && current.next().data('date') !== thisDate) { // animate something with color: current.animate({ backgroundColor: "#d9534f" @@ -59,10 +62,6 @@ function sortStop(event, ui) { // do extra animation when done? $.post('/transaction/reorder', {items: submit, date: thisDate, _token: token}); - console.log(submit); - - //console.log('TRUE!'); - //console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']'); current.animate({ backgroundColor: "#5cb85c" diff --git a/public/js/bills.js b/public/js/bills.js index 5f45f2a90b..58dd7ae943 100644 --- a/public/js/bills.js +++ b/public/js/bills.js @@ -1,7 +1,9 @@ -$(document).ready(function () { +/* global googleComboChart, billID */ - if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') { - googleComboChart('chart/bill/' + billID, 'bill-overview'); - } - } +$(document).ready(function () { + "use strict"; + if (typeof(googleComboChart) === 'function' && typeof(billID) !== 'undefined') { + googleComboChart('chart/bill/' + billID, 'bill-overview'); + } + } ); \ No newline at end of file diff --git a/public/js/budgets.js b/public/js/budgets.js index 1ab91d8b23..0c8f20f43f 100644 --- a/public/js/budgets.js +++ b/public/js/budgets.js @@ -1,4 +1,7 @@ +/* globals $, token, budgetID, repetitionID */ + $(function () { + "use strict"; updateRanges(); //$('input[type="range"]').change(updateSingleRange); $('input[type="range"]').on('input', updateSingleRange); @@ -18,6 +21,7 @@ $(function () { function updateSingleRange(e) { + "use strict"; // get some values: var input = $(e.target); var id = input.data('id'); @@ -63,6 +67,7 @@ function updateSingleRange(e) { } function updateTotal() { + "use strict"; var sum = 0; $('input[type="range"]').each(function (i, v) { // get some values: @@ -94,7 +99,8 @@ function updateTotal() { } -function updateIncome(e) { +function updateIncome() { + "use strict"; $('#monthlyBudgetModal').empty().load('budgets/income', function () { $('#monthlyBudgetModal').modal('show'); }); @@ -103,6 +109,7 @@ function updateIncome(e) { } function updateRanges() { + "use strict"; /** * Update all ranges. */ @@ -133,8 +140,9 @@ function updateRanges() { * Update total sum: */ var totalAmount = parseInt($('#totalAmount').data('value')); + var pct; if (sum <= totalAmount) { - var pct = sum / totalAmount * 100; + pct = sum / totalAmount * 100; $('#progress-bar-default').css('width', pct + '%'); $('#progress-bar-warning').css('width', '0'); $('#progress-bar-danger').css('width', '0'); @@ -142,7 +150,7 @@ function updateRanges() { } else { // we gaan er X overheen, - var pct = totalAmount / sum * 100; + pct = totalAmount / sum * 100; var danger = 100 - pct; var err = 100 - danger; $('#progress-bar-default').css('width', 0); diff --git a/public/js/categories.js b/public/js/categories.js index d4fb5c692f..073b8e2355 100644 --- a/public/js/categories.js +++ b/public/js/categories.js @@ -1,5 +1,6 @@ +/* globals $, categoryID */ $(function () { - + "use strict"; if (typeof categoryID !== 'undefined') { googleColumnChart('chart/category/' + categoryID + '/all', 'all'); googleColumnChart('chart/category/' + categoryID + '/month', 'month'); diff --git a/public/js/firefly.js b/public/js/firefly.js index a8c075a761..c01a3269c7 100644 --- a/public/js/firefly.js +++ b/public/js/firefly.js @@ -1,8 +1,9 @@ +/* globals start, end, dateRangeURL, everything, firstDate, moment, currentMonthName, $, previousMonthName, nextMonthName, applyLabel, cancelLabel, toLabel, customRangeLabel, fromLabel, */ $(function () { - + "use strict"; $('.currencySelect').click(currencySelect); - ranges = {}; + var ranges = {}; ranges[currentMonthName] = [moment().startOf('month'), moment().endOf('month')]; ranges[previousMonthName] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]; ranges[nextMonthName] = [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')]; @@ -10,11 +11,6 @@ $(function () { $('#daterange').daterangepicker( { - //View::share('currentMonthName', $current); - //View::share('previousMonthName', $prev); - //View::share('nextMonthName', $next); - - ranges: ranges, opens: 'left', locale: { @@ -54,6 +50,7 @@ $(function () { }); function currencySelect(e) { + "use strict"; var target = $(e.target); var symbol = target.data('symbol'); var code = target.data('code'); diff --git a/public/js/gcharts.js b/public/js/gcharts.js index 065c4975ad..c51700d9b9 100644 --- a/public/js/gcharts.js +++ b/public/js/gcharts.js @@ -1,13 +1,16 @@ +/* globals currencyCode, language, defaultPieChartOptions, defaultLineChartOptions, defaultColumnChartOptions, defaultBarChartOptions, defaultStackedColumnChartOptions, defaultComboChartOptions */ +/* exported googleLineChart, googleBarChart, googleColumnChart, googleStackedColumnChart, googleComboChart, googlePieChart */ var google = google || {}; google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'line'],'language': language }); function googleChart(chartType, URL, container, options) { + "use strict"; if ($('#' + container).length === 1) { $.getJSON(URL).success(function (data) { /* Get the data from the JSON */ - gdata = new google.visualization.DataTable(data); + var gdata = new google.visualization.DataTable(data); /* Format as money @@ -67,25 +70,32 @@ function googleChart(chartType, URL, container, options) { function googleLineChart(URL, container, options) { + "use strict"; return googleChart('line', URL, container, options); } + function googleBarChart(URL, container, options) { + "use strict"; return googleChart('bar', URL, container, options); } function googleColumnChart(URL, container, options) { + "use strict"; return googleChart('column', URL, container, options); } function googleStackedColumnChart(URL, container, options) { + "use strict"; return googleChart('stackedColumn', URL, container, options); } function googleComboChart(URL, container, options) { + "use strict"; return googleChart('combo', URL, container, options); } function googlePieChart(URL, container, options) { + "use strict"; return googleChart('pie', URL, container, options); } diff --git a/public/js/gcharts.options.js b/public/js/gcharts.options.js index b6cd11b95b..996c2849b8 100644 --- a/public/js/gcharts.options.js +++ b/public/js/gcharts.options.js @@ -1,3 +1,5 @@ +/* exported defaultLineChartOptions, defaultBarChartOptions, defaultComboChartOptions, defaultColumnChartOptions, defaultStackedColumnChartOptions, defaultPieChartOptions */ + var defaultLineChartOptions = { curveType: 'function', legend: { @@ -69,7 +71,7 @@ var defaultBarChartOptions = { legend: { position: 'none' - }, + } }; var defaultComboChartOptions = { @@ -127,7 +129,7 @@ var defaultColumnChartOptions = { }, legend: { position: 'none' - }, + } }; var defaultStackedColumnChartOptions = { diff --git a/public/js/help.js b/public/js/help.js index cfe25448b4..d4762b43e8 100644 --- a/public/js/help.js +++ b/public/js/help.js @@ -1,13 +1,16 @@ $(function () { + "use strict"; $('#help').click(showHelp); $(function () { - $('[data-toggle="tooltip"]').tooltip() - }) + + $('[data-toggle="tooltip"]').tooltip(); + }); }); function showHelp(e) { - target = $(e.target); - route = target.data('route'); + "use strict"; + var target = $(e.target); + var route = target.data('route'); // $('#helpBody').html(''); $('#helpTitle').html('Please hold...'); diff --git a/public/js/index.js b/public/js/index.js index ec5579ee23..d1291a77a4 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,3 +1,4 @@ +/* globals google */ google.setOnLoadCallback(drawChart); @@ -12,13 +13,20 @@ function drawChart() { } function getBoxAmounts() { + "use strict"; var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid']; - for (x in boxes) { + for (var x in boxes) { var box = boxes[x]; - $.getJSON('/json/box/' + box).success(function (data) { - $('#box-' + data.box).html(data.amount); - }).fail(function () { - console.log('Failed to get box!') - }); + $.getJSON('/json/box/' + box).success(putData).fail(failData); } } + +function putData(data) { + "use strict"; + $('#box-' + data.box).html(data.amount); +} + +function failData() { + "use strict"; + console.log('Failed to get box!'); +} \ No newline at end of file diff --git a/public/js/piggy-banks.js b/public/js/piggy-banks.js index cefb43d0f6..d34bf49760 100644 --- a/public/js/piggy-banks.js +++ b/public/js/piggy-banks.js @@ -1,3 +1,14 @@ +// Return a helper with preserved width of cells +var fixHelper = function(e, tr) { + var $originals = tr.children(); + var $helper = tr.clone(); + $helper.children().each(function (index) { + // Set helper cell sizes to match the original sizes + $(this).width($originals.eq(index).width()); + }); + return $helper; +}; + $(function () { $('.addMoney').on('click', addMoney); $('.removeMoney').on('click', removeMoney); @@ -31,16 +42,7 @@ $(function () { ); }); -// Return a helper with preserved width of cells -var fixHelper = function(e, tr) { - var $originals = tr.children(); - var $helper = tr.clone(); - $helper.children().each(function (index) { - // Set helper cell sizes to match the original sizes - $(this).width($originals.eq(index).width()); - }); - return $helper; -} + function addMoney(e) { var pigID = parseInt($(e.target).data('id')); diff --git a/public/js/reports.js b/public/js/reports.js index 0517d4951d..dfcbee44a1 100644 --- a/public/js/reports.js +++ b/public/js/reports.js @@ -1,4 +1,4 @@ -if (typeof(google) != 'undefined') { +if (typeof(google) !== 'undefined') { google.setOnLoadCallback(drawChart); } diff --git a/public/js/transactions.js b/public/js/transactions.js index 20e7b6eaee..446bde7043 100644 --- a/public/js/transactions.js +++ b/public/js/transactions.js @@ -28,7 +28,7 @@ $(document).ready(function () { }); } - if ($('input[name="description"]').length > 0 && what != undefined) { + if ($('input[name="description"]').length > 0 && what !== undefined) { $.getJSON('json/transaction-journals/' + what).success(function (data) { $('input[name="description"]').typeahead({source: data}); }); From 860a0f790e23c8e766389a04bc35984209d0a47a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 20:41:14 +0200 Subject: [PATCH 02/30] Update js [skip ci] --- gulpfile.js | 2 ++ public/js/budgets.js | 9 ++------- public/js/piggy-banks.js | 15 ++++++++++----- public/js/reports.js | 24 +++++++++++++++--------- public/js/tags.js | 7 +++++-- public/js/transactions.js | 6 ++---- 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 7cf626734f..14dd43eabf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,4 @@ +/* globals require */ var elixir = require('laravel-elixir'); /* @@ -12,5 +13,6 @@ var elixir = require('laravel-elixir'); */ elixir(function(mix) { + "use strict"; mix.less('app.less'); }); diff --git a/public/js/budgets.js b/public/js/budgets.js index 0c8f20f43f..e49c874624 100644 --- a/public/js/budgets.js +++ b/public/js/budgets.js @@ -53,7 +53,7 @@ function updateSingleRange(e) { // update the link if relevant: $('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition); }); - if (input.attr('type') == 'number') { + if (input.attr('type') === 'number') { // update the range-input: $('#budget-range-' + id).val(value); } else { @@ -126,13 +126,8 @@ function updateRanges() { // update small display: $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2)); - // update progress bar (if relevant) - var barHolder = $('#budget-progress-' + id); - var spent = parseFloat(barHolder.data('spent')); - // send a post to Firefly to update the amount: - $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) { - }); + $.post('budgets/amount/' + id, {amount: value, _token: token}); }); diff --git a/public/js/piggy-banks.js b/public/js/piggy-banks.js index d34bf49760..4e32a77eee 100644 --- a/public/js/piggy-banks.js +++ b/public/js/piggy-banks.js @@ -1,5 +1,8 @@ +/* globals $, googleLineChart, token */ + // Return a helper with preserved width of cells -var fixHelper = function(e, tr) { +var fixHelper = function (e, tr) { + "use strict"; var $originals = tr.children(); var $helper = tr.clone(); $helper.children().each(function (index) { @@ -10,6 +13,7 @@ var fixHelper = function(e, tr) { }; $(function () { + "use strict"; $('.addMoney').on('click', addMoney); $('.removeMoney').on('click', removeMoney); @@ -43,8 +47,8 @@ $(function () { }); - function addMoney(e) { + "use strict"; var pigID = parseInt($(e.target).data('id')); $('#moneyManagementModal').empty().load('piggy-banks/add/' + pigID, function () { $('#moneyManagementModal').modal('show'); @@ -54,6 +58,7 @@ function addMoney(e) { } function removeMoney(e) { + "use strict"; var pigID = parseInt($(e.target).data('id')); $('#moneyManagementModal').empty().load('piggy-banks/remove/' + pigID, function () { $('#moneyManagementModal').modal('show'); @@ -62,15 +67,15 @@ function removeMoney(e) { return false; } function stopSorting() { + "use strict"; $('.loadSpin').addClass('fa fa-refresh fa-spin'); var order = []; - $.each($('#sortable>tbody>tr'), function(i,v) { + $.each($('#sortable>tbody>tr'), function (i, v) { var holder = $(v); var id = holder.data('id'); order.push(id); }); - $.post('/piggy-banks/sort',{_token: token, order: order}).success(function(data) { - "use strict"; + $.post('/piggy-banks/sort', {_token: token, order: order}).success(function () { $('.loadSpin').removeClass('fa fa-refresh fa-spin'); }); } \ No newline at end of file diff --git a/public/js/reports.js b/public/js/reports.js index dfcbee44a1..36845910f6 100644 --- a/public/js/reports.js +++ b/public/js/reports.js @@ -1,9 +1,11 @@ +/* globals expenseRestShow:true, incomeRestShow:true, year, shared, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, googleColumnChart, googleLineChart, googleStackedColumnChartg */ if (typeof(google) !== 'undefined') { google.setOnLoadCallback(drawChart); } function drawChart() { + "use strict"; googleColumnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart'); googleColumnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart'); @@ -13,16 +15,8 @@ function drawChart() { googleLineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart'); } -$(function () { - $('.openModal').on('click', openModal); - // click open the top X income list: - $('#showIncomes').click(showIncomes); - // click open the top X expense list: - $('#showExpenses').click(showExpenses); -}); - function openModal(e) { "use strict"; var target = $(e.target).parent(); @@ -61,6 +55,7 @@ function showIncomes() { } function showExpenses() { + "use strict"; if (expenseRestShow) { // hide everything, make button say "show" $('#showExpenses').text(showTheRestExpense); @@ -78,4 +73,15 @@ function showExpenses() { } return false; -} \ No newline at end of file +} + +$(function () { + "use strict"; + $('.openModal').on('click', openModal); + + + // click open the top X income list: + $('#showIncomes').click(showIncomes); + // click open the top X expense list: + $('#showExpenses').click(showExpenses); +}); \ No newline at end of file diff --git a/public/js/tags.js b/public/js/tags.js index f099ec1ee2..c87f6b8cb7 100644 --- a/public/js/tags.js +++ b/public/js/tags.js @@ -1,5 +1,6 @@ +/* globals zoomLevel, token, google, latitude, longitude */ $(function () { - + "use strict"; /* Hide and show the tag index help. */ @@ -47,7 +48,7 @@ function clearLocation() { } function initialize() { - + "use strict"; /* Create new map: */ @@ -91,6 +92,7 @@ function saveZoomLevel() { * @param event */ function placeMarker(event) { + "use strict"; deleteMarkers(); var marker = new google.maps.Marker({position: event.latLng, map: map}); $('input[name="latitude"]').val(event.latLng.lat()); @@ -105,6 +107,7 @@ function placeMarker(event) { * Deletes all markers in the array by removing references to them. */ function deleteMarkers() { + "use strict"; for (var i = 0; i < markers.length; i++) { markers[i].setMap(null); } diff --git a/public/js/transactions.js b/public/js/transactions.js index 446bde7043..b9cee1ded4 100644 --- a/public/js/transactions.js +++ b/public/js/transactions.js @@ -1,8 +1,6 @@ +/* globals what, $ */ $(document).ready(function () { - if (typeof googleTablePaged != 'undefined') { - googleTablePaged('table/transactions/' + what, 'transaction-table'); - } - + "use strict"; if ($('input[name="expense_account"]').length > 0) { $.getJSON('json/expense-accounts').success(function (data) { $('input[name="expense_account"]').typeahead({source: data}); From 42799b9273c3f1b11251b7dc859fff68fe9e5fef Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 20:48:31 +0200 Subject: [PATCH 03/30] Some JS cleanup. --- public/js/budgets.js | 5 ++--- public/js/index.js | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/budgets.js b/public/js/budgets.js index e49c874624..e558d3dcce 100644 --- a/public/js/budgets.js +++ b/public/js/budgets.js @@ -110,9 +110,8 @@ function updateIncome() { function updateRanges() { "use strict"; - /** - * Update all ranges. - */ + + var sum = 0; $('input[type="range"]').each(function (i, v) { // get some values: diff --git a/public/js/index.js b/public/js/index.js index d1291a77a4..6ca893aa6b 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -3,6 +3,7 @@ google.setOnLoadCallback(drawChart); function drawChart() { + "use strict"; googleLineChart('chart/account/frontpage', 'accounts-chart'); googlePieChart('chart/bill/frontpage', 'bills-chart'); googleStackedColumnChart('chart/budget/frontpage', 'budgets-chart'); From b7433683d8abae36e335760e914cd43ddb151223 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 20:57:27 +0200 Subject: [PATCH 04/30] Cleanup cleanup [skip ci] --- app/Http/Middleware/Cleanup.php | 278 +++++++++++++++++++------------- 1 file changed, 162 insertions(+), 116 deletions(-) diff --git a/app/Http/Middleware/Cleanup.php b/app/Http/Middleware/Cleanup.php index f502d99183..bb90b9754f 100644 --- a/app/Http/Middleware/Cleanup.php +++ b/app/Http/Middleware/Cleanup.php @@ -56,131 +56,177 @@ class Cleanup public function handle(Request $request, Closure $next) { if ($this->auth->guest()) { - if ($request->ajax()) { - return response('Unauthorized.', 401); - } else { - return redirect()->guest('auth/login'); - } + return response('Unauthorized.', 401); } - $run = env('RUNCLEANUP') == 'true' ? true : false; - $count = 0; + $count = -1; - if ($run) { - // encrypt account name - $set = Account::where('encrypted', 0)->take(5)->get(); - /** @var Account $entry */ - foreach ($set as $entry) { - $count++; - $name = $entry->name; - $entry->name = $name; - $entry->save(); - } - unset($set, $entry, $name); + bcscale(0); - // encrypt bill name - $set = Bill::where('name_encrypted', 0)->take(5)->get(); - /** @var Bill $entry */ - foreach ($set as $entry) { - $count++; - $name = $entry->name; - $entry->name = $name; - $entry->save(); - } - unset($set, $entry, $name); - - // encrypt bill match - $set = Bill::where('match_encrypted', 0)->take(5)->get(); - /** @var Bill $entry */ - foreach ($set as $entry) { - $match = $entry->match; - $entry->match = $match; - $entry->save(); - } - unset($set, $entry, $match); - - // encrypt budget name - $set = Budget::where('encrypted', 0)->take(5)->get(); - /** @var Budget $entry */ - foreach ($set as $entry) { - $count++; - $name = $entry->name; - $entry->name = $name; - $entry->save(); - } - unset($set, $entry, $name); - - // encrypt category name - $set = Category::where('encrypted', 0)->take(5)->get(); - /** @var Category $entry */ - foreach ($set as $entry) { - $count++; - $name = $entry->name; - $entry->name = $name; - $entry->save(); - } - unset($set, $entry, $name); - - // encrypt piggy bank name - $set = PiggyBank::where('encrypted', 0)->take(5)->get(); - /** @var PiggyBank $entry */ - foreach ($set as $entry) { - $count++; - $name = $entry->name; - $entry->name = $name; - $entry->save(); - } - unset($set, $entry, $name); - - // encrypt transaction journal description - $set = TransactionJournal::where('encrypted', 0)->take(5)->get(); - /** @var TransactionJournal $entry */ - foreach ($set as $entry) { - $count++; - $description = $entry->description; - $entry->description = $description; - $entry->save(); - } - unset($set, $entry, $description); - - // encrypt reminder metadata - $set = Reminder::where('encrypted', 0)->take(5)->get(); - /** @var Reminder $entry */ - foreach ($set as $entry) { - $count++; - $metadata = $entry->metadata; - $entry->metadata = $metadata; - $entry->save(); - } - unset($set, $entry, $metadata); - - //encrypt preference name - $set = Preference::whereNull('name_encrypted')->take(5)->get(); - /** @var Preference $entry */ - foreach ($set as $entry) { - $count++; - $name = $entry->name; - $entry->name = $name; - $entry->save(); - } - unset($set, $entry, $name); - - //encrypt preference data - $set = Preference::whereNull('data_encrypted')->take(5)->get(); - /** @var Preference $entry */ - foreach ($set as $entry) { - $count++; - $data = $entry->data; - $entry->data = $data; - $entry->save(); - } - unset($set, $entry, $data); + if (env('RUNCLEANUP') == 'true') { + $count = 0; + $count = bcadd($count, $this->encryptAccountAndBills()); + $count = bcadd($count, $this->encryptBudgetsAndCategories()); + $count = bcadd($count, $this->encryptPiggiesAndJournals()); + $count = bcadd($count, $this->encryptRemindersAndPreferences()); } - if ($count == 0 && $run) { + if ($count == 0) { Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false'); } return $next($request); + + } + + /** + * @return int + */ + protected function encryptAccountAndBills() + { + $count = 0; + // encrypt account name + $set = Account::where('encrypted', 0)->take(5)->get(); + /** @var Account $entry */ + foreach ($set as $entry) { + $count++; + $name = $entry->name; + $entry->name = $name; + $entry->save(); + } + unset($set, $entry, $name); + + // encrypt bill name + $set = Bill::where('name_encrypted', 0)->take(5)->get(); + /** @var Bill $entry */ + foreach ($set as $entry) { + $count++; + $name = $entry->name; + $entry->name = $name; + $entry->save(); + } + unset($set, $entry, $name); + + // encrypt bill match + $set = Bill::where('match_encrypted', 0)->take(5)->get(); + /** @var Bill $entry */ + foreach ($set as $entry) { + $match = $entry->match; + $entry->match = $match; + $entry->save(); + } + unset($set, $entry, $match); + + + return $count; + + } + + /** + * @return int + */ + protected function encryptBudgetsAndCategories() + { + $count = 0; + + // encrypt budget name + $set = Budget::where('encrypted', 0)->take(5)->get(); + /** @var Budget $entry */ + foreach ($set as $entry) { + $count++; + $name = $entry->name; + $entry->name = $name; + $entry->save(); + } + unset($set, $entry, $name); + + // encrypt category name + $set = Category::where('encrypted', 0)->take(5)->get(); + /** @var Category $entry */ + foreach ($set as $entry) { + $count++; + $name = $entry->name; + $entry->name = $name; + $entry->save(); + } + unset($set, $entry, $name); + + return $count; + } + + /** + * @return int + */ + protected function encryptPiggiesAndJournals() + { + $count = 0; + + + // encrypt piggy bank name + $set = PiggyBank::where('encrypted', 0)->take(5)->get(); + /** @var PiggyBank $entry */ + foreach ($set as $entry) { + $count++; + $name = $entry->name; + $entry->name = $name; + $entry->save(); + } + unset($set, $entry, $name); + + // encrypt transaction journal description + $set = TransactionJournal::where('encrypted', 0)->take(5)->get(); + /** @var TransactionJournal $entry */ + foreach ($set as $entry) { + $count++; + $description = $entry->description; + $entry->description = $description; + $entry->save(); + } + unset($set, $entry, $description); + + return $count; + } + + /** + * @return int + */ + protected function encryptRemindersAndPreferences() + { + $count = 0; + + // encrypt reminder metadata + $set = Reminder::where('encrypted', 0)->take(5)->get(); + /** @var Reminder $entry */ + foreach ($set as $entry) { + $count++; + $metadata = $entry->metadata; + $entry->metadata = $metadata; + $entry->save(); + } + unset($set, $entry, $metadata); + + //encrypt preference name + $set = Preference::whereNull('name_encrypted')->take(5)->get(); + /** @var Preference $entry */ + foreach ($set as $entry) { + $count++; + $name = $entry->name; + $entry->name = $name; + $entry->save(); + } + unset($set, $entry, $name); + + //encrypt preference data + $set = Preference::whereNull('data_encrypted')->take(5)->get(); + /** @var Preference $entry */ + foreach ($set as $entry) { + $count++; + $data = $entry->data; + $entry->data = $data; + $entry->save(); + } + unset($set, $entry, $data); + + return $count; } } From 60f7f1fc1695c3459ad4aba4d512a8f3a2979216 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 21:07:22 +0200 Subject: [PATCH 05/30] New build routine. --- .coveralls.yml | 4 +-- .travis.yml | 5 +-- app/Http/Middleware/Cleanup.php | 4 --- build/logs/.gitignore | 2 ++ composer.json | 4 ++- composer.lock | 59 ++++++++++++++++++++++++++++++++- phpunit.xml | 2 +- 7 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 build/logs/.gitignore diff --git a/.coveralls.yml b/.coveralls.yml index 06571ec196..7b7d1beb5f 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,3 +1,3 @@ src_dir: . -coverage_clover: storage/coverage/clover.xml -json_path: storage/coverage/coveralls-upload.json +coverage_clover: build/logs/clover.xml +json_path: build/logs/coveralls-upload.json diff --git a/.travis.yml b/.travis.yml index 81cac8830e..f0dd69b122 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,6 @@ php: - 5.5 - 5.6 -addons: - code_climate: - repo_token: 26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 - install: - composer update - php artisan env @@ -20,3 +16,4 @@ script: after_script: - php vendor/bin/coveralls + - CODECLIMATE_REPO_TOKEN=26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 ./vendor/bin/test-reporter \ No newline at end of file diff --git a/app/Http/Middleware/Cleanup.php b/app/Http/Middleware/Cleanup.php index bb90b9754f..6a4cc4467a 100644 --- a/app/Http/Middleware/Cleanup.php +++ b/app/Http/Middleware/Cleanup.php @@ -127,7 +127,6 @@ class Cleanup protected function encryptBudgetsAndCategories() { $count = 0; - // encrypt budget name $set = Budget::where('encrypted', 0)->take(5)->get(); /** @var Budget $entry */ @@ -159,8 +158,6 @@ class Cleanup protected function encryptPiggiesAndJournals() { $count = 0; - - // encrypt piggy bank name $set = PiggyBank::where('encrypted', 0)->take(5)->get(); /** @var PiggyBank $entry */ @@ -192,7 +189,6 @@ class Cleanup protected function encryptRemindersAndPreferences() { $count = 0; - // encrypt reminder metadata $set = Reminder::where('encrypted', 0)->take(5)->get(); /** @var Reminder $entry */ diff --git a/build/logs/.gitignore b/build/logs/.gitignore new file mode 100644 index 0000000000..67c51fe2b0 --- /dev/null +++ b/build/logs/.gitignore @@ -0,0 +1,2 @@ +*.xml +*.json diff --git a/composer.json b/composer.json index 5bbf617f3b..3a3e55afc2 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,9 @@ "phpspec/phpspec": "~2.1", "satooshi/php-coveralls": "0.6.1", "mockery/mockery": "0.9.*", - "league/factory-muffin": "~2.1" + "league/factory-muffin": "~2.1", + "codeclimate/php-test-reporter": "^0.1.2" + }, diff --git a/composer.lock b/composer.lock index 14ab11d0c9..36256fec53 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e3e90dd365b74f4878cf3b5b4a1c4007", + "hash": "5c085b2cc90ffa610e386897066315a7", "packages": [ { "name": "classpreloader/classpreloader", @@ -2689,6 +2689,63 @@ ], "time": "2015-03-17 08:00:28" }, + { + "name": "codeclimate/php-test-reporter", + "version": "v0.1.2", + "source": { + "type": "git", + "url": "https://github.com/codeclimate/php-test-reporter.git", + "reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/8ed24ff30f3663ecf40f1c12d6c97eb56c69e646", + "reference": "8ed24ff30f3663ecf40f1c12d6c97eb56c69e646", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3", + "satooshi/php-coveralls": "0.6.*", + "symfony/console": ">=2.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@stable" + }, + "bin": [ + "composer/bin/test-reporter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "CodeClimate\\Component": "src/", + "CodeClimate\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Code Climate", + "email": "hello@codeclimate.com", + "homepage": "https://codeclimate.com" + } + ], + "description": "PHP client for reporting test coverage to Code Climate", + "homepage": "https://github.com/codeclimate/php-test-reporter", + "keywords": [ + "codeclimate", + "coverage" + ], + "time": "2014-07-23 13:42:41" + }, { "name": "doctrine/instantiator", "version": "1.0.4", diff --git a/phpunit.xml b/phpunit.xml index bf13ff1240..4f2b91ded5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -22,7 +22,7 @@ - + From 59ee153375b793aaa39be6dd7aa31707d31894f4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 21:11:37 +0200 Subject: [PATCH 06/30] Fixed test. --- resources/lang/en/firefly.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 585b498ff9..85fa92a8cb 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -57,9 +57,9 @@ return [ 'update_expense_account' => 'Update expense account', 'update_revenue_account' => 'Update revenue account', - 'make_new_asset_account' => 'New asset account', - 'make_new_expense_account' => 'New expense account', - 'make_new_revenue_account' => 'New revenue account', + 'make_new_asset_account' => 'Create a new asset account', + 'make_new_expense_account' => 'Create a new expense account', + 'make_new_revenue_account' => 'Create a new revenue account', // categories: 'new_category' => 'New category', From 8e1f493daff7c6c5f80dff03b8128cb4e6f43086 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 21:45:10 +0200 Subject: [PATCH 07/30] Another build routine. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0dd69b122..6d80082009 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,5 @@ script: after_script: - php vendor/bin/coveralls - - CODECLIMATE_REPO_TOKEN=26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 ./vendor/bin/test-reporter \ No newline at end of file + - CODECLIMATE_REPO_TOKEN=26489f9e854fcdf7e7660ba29c1455694685465b1f90329a79f7d2bf448acb61 ./vendor/bin/test-reporter --stdout > codeclimate.json + - "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports" \ No newline at end of file From 4a93bb35f8726a3191703e4ebc7579bdc9cfe2c2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 22:54:59 +0200 Subject: [PATCH 08/30] Cleanup budget view. --- app/Http/Controllers/BudgetController.php | 44 +-- public/js/budgets.js | 352 ++++++++++++++-------- resources/twig/budgets/index.twig | 137 ++++----- 3 files changed, 302 insertions(+), 231 deletions(-) diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 6bd50a4360..966df042ab 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -1,5 +1,6 @@ startOfMonth()); $limitRepetition = $repository->updateLimitAmount($budget, $date, $amount); + if ($amount == 0) { + $limitRepetition = null; + } return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]); @@ -126,7 +130,9 @@ class BudgetController extends Controller { $budgets = $repository->getActiveBudgets(); $inactive = $repository->getInactiveBudgets(); - + $spent = '0'; + $budgeted = '0'; + bcscale(2); /** * Do some cleanup: */ @@ -134,24 +140,28 @@ class BudgetController extends Controller // loop the budgets: - $budgets->each( - function (Budget $budget) use ($repository) { - $date = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); - $budget->spent = $repository->spentInPeriodCorrected($budget, $date, $end); - $budget->currentRep = $repository->getCurrentRepetition($budget, $date); + /** @var Budget $budget */ + foreach ($budgets as $budget) { + $date = Session::get('start', Carbon::now()->startOfMonth()); + $end = Session::get('end', Carbon::now()->endOfMonth()); + $budget->spent = $repository->spentInPeriodCorrected($budget, $date, $end); + $budget->currentRep = $repository->getCurrentRepetition($budget, $date); + if ($budget->currentRep) { + $budgeted = bcadd($budgeted, $budget->currentRep->amount); } + $spent = bcadd($spent, $budget->spent); + + } + + $dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); + $budgetIncomeTotal = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data; + $spentPercentage = ($spent > $budgeted) ? ceil($budgeted / $spent * 100) : ceil($spent / $budgeted * 100); + $budgetMaximum = Preferences::get('budgetMaximum', 1000)->data; + $defaultCurrency = Amount::getDefaultCurrency(); + + return view( + 'budgets.index', compact('budgetMaximum', 'budgetIncomeTotal', 'defaultCurrency', 'inactive', 'budgets', 'spent', 'spentPercentage', 'budgeted') ); - - $dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); - $spent = $budgets->sum('spent'); - $amount = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data; - $overspent = $spent > $amount; - $spentPCT = $overspent ? ceil($amount / $spent * 100) : ceil($spent / $amount * 100); - $budgetMax = Preferences::get('budgetMaximum', 1000); - $budgetMaximum = $budgetMax->data; - - return view('budgets.index', compact('budgetMaximum', 'inactive', 'budgets', 'spent', 'spentPCT', 'overspent', 'amount')); } /** diff --git a/public/js/budgets.js b/public/js/budgets.js index e558d3dcce..ccac9aac9e 100644 --- a/public/js/budgets.js +++ b/public/js/budgets.js @@ -1,15 +1,101 @@ -/* globals $, token, budgetID, repetitionID */ +/* globals $, budgeted, currencySymbol, overspent, budgetIncomeTotal ,budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, budgeted, overspent, spentPercentage */ + +function drawSpentBar() { + "use strict"; + + if (overspent) { + // draw overspent bar + $('.spentBar .progress-bar-warning').css('width', spentPercentage + '%'); + $('.spentBar .progress-bar-danger').css('width', (100 - spentPercentage) + '%'); + } else { + // draw normal bar: + $('.spentBar .progress-bar-info').css('width', spentPercentage + '%'); + } +} + +function drawBudgetedBar() { + "use strict"; + var budgetedMuch = budgeted > budgetIncomeTotal; + + // recalculate percentage: + + var pct; + if (budgetedMuch) { + // budgeted too much. + pct = (budgetIncomeTotal / budgeted) * 100; + console.log('Budgeted TOO much. Pct is ' + pct) + $('.budgetedBar .progress-bar-warning').css('width', pct + '%'); + $('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%'); + $('.budgetedBar .progress-bar-info').css('width', 0); + } else { + pct = (budgeted / budgetIncomeTotal) * 100; + console.log('Not budgeted too much. Pct is ' + pct) + $('.budgetedBar .progress-bar-warning').css('width', 0); + $('.budgetedBar .progress-bar-danger').css('width', 0); + $('.budgetedBar .progress-bar-info').css('width', pct + '%'); + } + + $('#budgetedAmount').html(currencySymbol + ' ' + budgeted.toFixed(2)); +} + +function updateBudgetedAmounts(e) { + "use strict"; + var target = $(e.target); + var id = target.data('id'); + var value = target.val(); + var original = target.data('original'); + var difference = value - original; + if (difference !== 0) { + // add difference to 'budgeted' var + budgeted = budgeted + difference; + + // update original: + target.data('original', value); + // run drawBudgetedBar() again: + drawBudgetedBar(); + + // send a post to Firefly to update the amount: + $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) { + // update the link if relevant: + if (data.repetition > 0) { + $('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition); + } else { + $('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id); + } + }); + } + + + console.log('Budget id is ' + id); + console.log('Difference = ' + (value - original )); + +} $(function () { "use strict"; - updateRanges(); - //$('input[type="range"]').change(updateSingleRange); - $('input[type="range"]').on('input', updateSingleRange); - //$('input[type="number"]').on('change', updateSingleRange); - $('input[type="number"]').on('input', updateSingleRange); + $('.updateIncome').on('click', updateIncome); + /* + On start, fill the "spent"-bar using the content from the page. + */ + drawSpentBar(); + drawBudgetedBar(); + /* + When the input changes, update the percentages for the budgeted bar: + */ + $('input[type="number"]').on('input', updateBudgetedAmounts); + + + //updateRanges(); + //$('input[type="range"]').on('input', updateSingleRange); + //$('input[type="number"]').on('input', updateSingleRange); + + + /* + Draw the charts, if necessary: + */ if (typeof budgetID !== 'undefined' && typeof repetitionID === 'undefined') { googleColumnChart('chart/budget/' + budgetID, 'budgetOverview'); } @@ -20,85 +106,85 @@ $(function () { }); -function updateSingleRange(e) { - "use strict"; - // get some values: - var input = $(e.target); - var id = input.data('id'); - var value = parseInt(input.val()); - var spent = parseFloat($('#spent-' + id).data('value')); - - // update small display: - if (value > 0) { - // show the input: - $('#budget-info-' + id + ' span').show(); - $('#budget-info-' + id + ' input').show(); - - // update the text: - $('#budget-description-' + id).text('Budgeted: '); - } else { - // hide the input: - $('#budget-info-' + id + ' span').hide(); - $('#budget-info-' + id + ' input').hide(); - - // update the text: - $('#budget-description-' + id).html('No budget'); - } - - // update the range display text: - $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2)); - - // send a post to Firefly to update the amount: - $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) { - // update the link if relevant: - $('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition); - }); - if (input.attr('type') === 'number') { - // update the range-input: - $('#budget-range-' + id).val(value); - } else { - // update the number-input: - $('#budget-info-' + id + ' input').val(value); - } - - // update or hide the bar, whichever is necessary. - updateTotal(); - return value; -} - -function updateTotal() { - "use strict"; - var sum = 0; - $('input[type="range"]').each(function (i, v) { - // get some values: - sum += parseInt($(v).val()); - }); - - /** - * Update total sum: - */ - var totalAmount = parseInt($('#totalAmount').data('value')); - var pct; - if (sum <= totalAmount) { - pct = sum / totalAmount * 100; - $('#progress-bar-default').css('width', pct + '%'); - $('#progress-bar-warning').css('width', '0'); - $('#progress-bar-danger').css('width', '0'); - $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger'); - } else { - // we gaan er X overheen, - - pct = totalAmount / sum * 100; - var danger = 100 - pct; - var err = 100 - danger; - $('#progress-bar-default').css('width', 0); - $('#progress-bar-warning').css('width', err + '%'); - $('#progress-bar-danger').css('width', danger + '%'); - $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success'); - } - -} - +//function updateSingleRange(e) { +// "use strict"; +// // get some values: +// var input = $(e.target); +// var id = input.data('id'); +// var value = parseInt(input.val()); +// var spent = parseFloat($('#spent-' + id).data('value')); +// +// // update small display: +// if (value > 0) { +// // show the input: +// $('#budget-info-' + id + ' span').show(); +// $('#budget-info-' + id + ' input').show(); +// +// // update the text: +// $('#budget-description-' + id).text('Budgeted: '); +// } else { +// // hide the input: +// $('#budget-info-' + id + ' span').hide(); +// $('#budget-info-' + id + ' input').hide(); +// +// // update the text: +// $('#budget-description-' + id).html('No budget'); +// } +// +// // update the range display text: +// $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2)); +// +// // send a post to Firefly to update the amount: +// $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) { +// // update the link if relevant: +// $('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition); +// }); +// if (input.attr('type') === 'number') { +// // update the range-input: +// $('#budget-range-' + id).val(value); +// } else { +// // update the number-input: +// $('#budget-info-' + id + ' input').val(value); +// } +// +// // update or hide the bar, whichever is necessary. +// updateTotal(); +// return value; +//} +// +//function updateTotal() { +// "use strict"; +// var sum = 0; +// $('input[type="range"]').each(function (i, v) { +// // get some values: +// sum += parseInt($(v).val()); +// }); +// +// /** +// * Update total sum: +// */ +// var totalAmount = parseInt($('#totalAmount').data('value')); +// var pct; +// if (sum <= totalAmount) { +// pct = sum / totalAmount * 100; +// $('#progress-bar-default').css('width', pct + '%'); +// $('#progress-bar-warning').css('width', '0'); +// $('#progress-bar-danger').css('width', '0'); +// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger'); +// } else { +// // we gaan er X overheen, +// +// pct = totalAmount / sum * 100; +// var danger = 100 - pct; +// var err = 100 - danger; +// $('#progress-bar-default').css('width', 0); +// $('#progress-bar-warning').css('width', err + '%'); +// $('#progress-bar-danger').css('width', danger + '%'); +// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success'); +// } +// +//} +// function updateIncome() { "use strict"; $('#monthlyBudgetModal').empty().load('budgets/income', function () { @@ -107,51 +193,51 @@ function updateIncome() { return false; } - -function updateRanges() { - "use strict"; - - - var sum = 0; - $('input[type="range"]').each(function (i, v) { - // get some values: - var input = $(v); - var id = input.data('id'); - var value = parseInt(input.val()); - - // calculate sum: - sum += value; - - // update small display: - $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2)); - - // send a post to Firefly to update the amount: - $.post('budgets/amount/' + id, {amount: value, _token: token}); - - }); - - /** - * Update total sum: - */ - var totalAmount = parseInt($('#totalAmount').data('value')); - var pct; - if (sum <= totalAmount) { - pct = sum / totalAmount * 100; - $('#progress-bar-default').css('width', pct + '%'); - $('#progress-bar-warning').css('width', '0'); - $('#progress-bar-danger').css('width', '0'); - $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger'); - } else { - // we gaan er X overheen, - - pct = totalAmount / sum * 100; - var danger = 100 - pct; - var err = 100 - danger; - $('#progress-bar-default').css('width', 0); - $('#progress-bar-warning').css('width', err + '%'); - $('#progress-bar-danger').css('width', danger + '%'); - $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success'); - } - - -} \ No newline at end of file +// +//function updateRanges() { +// "use strict"; +// +// +// var sum = 0; +// $('input[type="range"]').each(function (i, v) { +// // get some values: +// var input = $(v); +// var id = input.data('id'); +// var value = parseInt(input.val()); +// +// // calculate sum: +// sum += value; +// +// // update small display: +// $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2)); +// +// // send a post to Firefly to update the amount: +// $.post('budgets/amount/' + id, {amount: value, _token: token}); +// +// }); +// +// /** +// * Update total sum: +// */ +// var totalAmount = parseInt($('#totalAmount').data('value')); +// var pct; +// if (sum <= totalAmount) { +// pct = sum / totalAmount * 100; +// $('#progress-bar-default').css('width', pct + '%'); +// $('#progress-bar-warning').css('width', '0'); +// $('#progress-bar-danger').css('width', '0'); +// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger'); +// } else { +// // we gaan er X overheen, +// +// pct = totalAmount / sum * 100; +// var danger = 100 - pct; +// var err = 100 - danger; +// $('#progress-bar-default').css('width', 0); +// $('#progress-bar-warning').css('width', err + '%'); +// $('#progress-bar-danger').css('width', danger + '%'); +// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success'); +// } +// +// +//} \ No newline at end of file diff --git a/resources/twig/budgets/index.twig b/resources/twig/budgets/index.twig index 6de86a80d3..380fc5cbdc 100644 --- a/resources/twig/budgets/index.twig +++ b/resources/twig/budgets/index.twig @@ -11,23 +11,20 @@
- {{ 'budgeted'|_ }}: + {{ 'budgeted'|_ }}: {{ budgeted|formatAmountPlain }}
{{ trans('firefly.availableIn',{date : Session.get('start').formatLocalized(monthFormat) }) }}: - {{ amount|formatAmount }} + {{ budgetIncomeTotal|formatAmount }}
-
-
-
-
+
+
+
+
@@ -38,16 +35,10 @@
-
- {% if overspent %} -
-
- {% else %} -
- {% endif %} +
+
+
+
@@ -80,76 +71,48 @@
+ {% if budget.currentRep %} - {{ budget.name }} + {{ budget.name }} {% else %} - {{ budget.name }} + {{ budget.name }} {% endif %} -
-
- - +
+
+ + +
+
+ + + + + + + + + +
{{ 'budgeted'|_ }} +
+
+
{{ defaultCurrency.symbol|raw }}
+ + +
+
+
{{ 'spent'|_ }}{{ budget.spent|formatAmount }}
- -
-
- -

- {% if budget.currentRep %} - - {% else %} - - {% endif %} -

- -

- - - {% if budget.currentRep %} - - Budgeted: - - - {% if budget.currentRep.amount > budget.spent %} - {{ getCurrencySymbol()|raw }} - {% else %} - {{ getCurrencySymbol()|raw }} - {% endif %} - - {% else %} - No budget - - - - {% endif %} - -

- -

- {{ 'spent'|_ }}: {{ budget.spent|formatAmount }} -

-
-
-
+
{% endfor %}
@@ -191,5 +154,17 @@ {% endblock %} {% block scripts %} + + {% endblock %} From 352b996ad279f2dc1510cc4770a76d352d812b2d Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 24 May 2015 22:59:48 +0200 Subject: [PATCH 09/30] Cleanup some code. --- app/Http/Controllers/BudgetController.php | 3 +-- public/js/budgets.js | 15 +++++++++------ resources/twig/budgets/index.twig | 2 -- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 966df042ab..a36079cd12 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -155,12 +155,11 @@ class BudgetController extends Controller $dateAsString = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); $budgetIncomeTotal = Preferences::get('budgetIncomeTotal' . $dateAsString, 1000)->data; - $spentPercentage = ($spent > $budgeted) ? ceil($budgeted / $spent * 100) : ceil($spent / $budgeted * 100); $budgetMaximum = Preferences::get('budgetMaximum', 1000)->data; $defaultCurrency = Amount::getDefaultCurrency(); return view( - 'budgets.index', compact('budgetMaximum', 'budgetIncomeTotal', 'defaultCurrency', 'inactive', 'budgets', 'spent', 'spentPercentage', 'budgeted') + 'budgets.index', compact('budgetMaximum', 'budgetIncomeTotal', 'defaultCurrency', 'inactive', 'budgets', 'spent', 'budgeted') ); } diff --git a/public/js/budgets.js b/public/js/budgets.js index ccac9aac9e..3493c81fc0 100644 --- a/public/js/budgets.js +++ b/public/js/budgets.js @@ -1,15 +1,20 @@ -/* globals $, budgeted, currencySymbol, overspent, budgetIncomeTotal ,budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, budgeted, overspent, spentPercentage */ +/* globals $, budgeted:false, currencySymbol, budgetIncomeTotal ,budgetedMuch, budgetedPercentage, token, budgetID, repetitionID, spent, budgeted*/ function drawSpentBar() { "use strict"; + var overspent = spent > budgeted; + var pct; + if (overspent) { // draw overspent bar - $('.spentBar .progress-bar-warning').css('width', spentPercentage + '%'); - $('.spentBar .progress-bar-danger').css('width', (100 - spentPercentage) + '%'); + pct = (budgeted / spent) * 100; + $('.spentBar .progress-bar-warning').css('width', pct + '%'); + $('.spentBar .progress-bar-danger').css('width', (100 - pct) + '%'); } else { // draw normal bar: - $('.spentBar .progress-bar-info').css('width', spentPercentage + '%'); + pct = (spent / budgeted) * 100; + $('.spentBar .progress-bar-info').css('width', pct + '%'); } } @@ -23,13 +28,11 @@ function drawBudgetedBar() { if (budgetedMuch) { // budgeted too much. pct = (budgetIncomeTotal / budgeted) * 100; - console.log('Budgeted TOO much. Pct is ' + pct) $('.budgetedBar .progress-bar-warning').css('width', pct + '%'); $('.budgetedBar .progress-bar-danger').css('width', (100 - pct) + '%'); $('.budgetedBar .progress-bar-info').css('width', 0); } else { pct = (budgeted / budgetIncomeTotal) * 100; - console.log('Not budgeted too much. Pct is ' + pct) $('.budgetedBar .progress-bar-warning').css('width', 0); $('.budgetedBar .progress-bar-danger').css('width', 0); $('.budgetedBar .progress-bar-info').css('width', pct + '%'); diff --git a/resources/twig/budgets/index.twig b/resources/twig/budgets/index.twig index 380fc5cbdc..5601d04dc3 100644 --- a/resources/twig/budgets/index.twig +++ b/resources/twig/budgets/index.twig @@ -157,8 +157,6 @@ + + From fb2481ebaa0e9053148c661b3c2373d77483e5de Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 25 May 2015 07:26:19 +0200 Subject: [PATCH 14/30] Add some GA events. --- app/Http/Controllers/ProfileController.php | 2 ++ resources/twig/layout/guest.twig | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index af7c07bdd5..6b46ed2a03 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -109,6 +109,8 @@ class ProfileController extends Controller // DELETE! Auth::user()->delete(); Session::flush(); + Session::flash('gaEventCategory', 'user'); + Session::flash('gaEventAction', 'delete-account'); return Redirect::route('index'); } diff --git a/resources/twig/layout/guest.twig b/resources/twig/layout/guest.twig index 1d81e22141..90a026e44d 100644 --- a/resources/twig/layout/guest.twig +++ b/resources/twig/layout/guest.twig @@ -58,5 +58,28 @@ + + From dfa6bdbcb8054a5af65152aacb9b5125cc654036 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 25 May 2015 07:53:13 +0200 Subject: [PATCH 15/30] Fixed menu for mobile screens [skip ci] --- resources/twig/layout/default.twig | 2 +- resources/twig/partials/menu.twig | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig index c79316bc88..d6eb987e74 100644 --- a/resources/twig/layout/default.twig +++ b/resources/twig/layout/default.twig @@ -170,7 +170,7 @@ // send an event if relevant: {% if Session.has('gaEventCategory') and Session.has('gaEventAction') %} - ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}'); + ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}'); {% endif %} diff --git a/resources/twig/partials/menu.twig b/resources/twig/partials/menu.twig index 2ab8cf2e02..15779368bf 100644 --- a/resources/twig/partials/menu.twig +++ b/resources/twig/partials/menu.twig @@ -171,7 +171,24 @@ - + + + + + + + +
From 8ece341467d7fab499c4efa80fdc5b564fb8830d Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 25 May 2015 08:01:06 +0200 Subject: [PATCH 16/30] Add GA events [skip ci] --- app/Http/Controllers/AccountController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 35333b78f9..a95ec4799d 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -46,6 +46,8 @@ class AccountController extends Controller Session::put('accounts.create.url', URL::previous()); } Session::forget('accounts.create.fromStore'); + Session::flash('gaEventCategory', 'accounts'); + Session::flash('gaEventAction', 'create-' . $what); return view('accounts.create', compact('subTitleIcon', 'what', 'subTitle')); @@ -63,6 +65,8 @@ class AccountController extends Controller // put previous url in session Session::put('accounts.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'accounts'); + Session::flash('gaEventAction', 'delete-' . $typeName); return view('accounts.delete', compact('account', 'subTitle')); } @@ -126,6 +130,8 @@ class AccountController extends Controller 'virtualBalance' => floatval($account->virtual_balance) ]; Session::flash('preFilled', $preFilled); + Session::flash('gaEventCategory', 'accounts'); + Session::flash('gaEventAction', 'edit-' . $what); return view('accounts.edit', compact('account', 'subTitle', 'subTitleIcon', 'openingBalance', 'what')); } From 60fe8ce011dae28aa2bbf9429e65f159a11fde18 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 25 May 2015 08:12:31 +0200 Subject: [PATCH 17/30] New GA events [skip ci] --- app/Http/Controllers/BillController.php | 6 ++++++ app/Http/Controllers/BudgetController.php | 7 +++++++ app/Http/Controllers/CategoryController.php | 6 ++++++ app/Http/Controllers/CurrencyController.php | 6 ++++++ app/Http/Controllers/PiggyBankController.php | 6 ++++++ app/Http/Controllers/ReportController.php | 8 ++++++++ app/Http/Controllers/TagController.php | 6 ++++++ app/Http/Controllers/TransactionController.php | 6 ++++++ resources/twig/layout/default.twig | 5 ++++- 9 files changed, 55 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 9b2dc01c64..e7573965ad 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -43,6 +43,8 @@ class BillController extends Controller Session::put('bills.create.url', URL::previous()); } Session::forget('bills.create.fromStore'); + Session::flash('gaEventCategory', 'bills'); + Session::flash('gaEventAction', 'create'); $subTitle = 'Create new bill'; return view('bills.create', compact('periods', 'subTitle')); @@ -57,6 +59,8 @@ class BillController extends Controller { // put previous url in session Session::put('bills.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'bills'); + Session::flash('gaEventAction', 'delete'); $subTitle = 'Delete "' . e($bill->name) . '"'; return view('bills.delete', compact('bill', 'subTitle')); @@ -93,6 +97,8 @@ class BillController extends Controller Session::put('bills.edit.url', URL::previous()); } Session::forget('bills.edit.fromUpdate'); + Session::flash('gaEventCategory', 'bills'); + Session::flash('gaEventAction', 'edit'); return view('bills.edit', compact('subTitle', 'periods', 'bill')); } diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index a36079cd12..bd9364310d 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -64,6 +64,8 @@ class BudgetController extends Controller Session::put('budgets.create.url', URL::previous()); } Session::forget('budgets.create.fromStore'); + Session::flash('gaEventCategory', 'budgets'); + Session::flash('gaEventAction', 'create'); $subTitle = trans('firefly.create_new_budget'); return view('budgets.create', compact('subTitle')); @@ -80,6 +82,8 @@ class BudgetController extends Controller // put previous url in session Session::put('budgets.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'budgets'); + Session::flash('gaEventAction', 'delete'); return view('budgets.delete', compact('budget', 'subTitle')); } @@ -99,6 +103,7 @@ class BudgetController extends Controller Session::flash('success', 'The budget "' . e($name) . '" was deleted.'); + return Redirect::to(Session::get('budgets.delete.url')); } @@ -116,6 +121,8 @@ class BudgetController extends Controller Session::put('budgets.edit.url', URL::previous()); } Session::forget('budgets.edit.fromUpdate'); + Session::flash('gaEventCategory', 'budgets'); + Session::flash('gaEventAction', 'edit'); return view('budgets.edit', compact('budget', 'subTitle')); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 7904a6adce..ba55ae289e 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -40,6 +40,8 @@ class CategoryController extends Controller Session::put('categories.create.url', URL::previous()); } Session::forget('categories.create.fromStore'); + Session::flash('gaEventCategory', 'categories'); + Session::flash('gaEventAction', 'create'); $subTitle = 'Create a new category'; return view('categories.create', compact('subTitle')); @@ -56,6 +58,8 @@ class CategoryController extends Controller // put previous url in session Session::put('categories.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'categories'); + Session::flash('gaEventAction', 'delete'); return view('categories.delete', compact('category', 'subTitle')); } @@ -91,6 +95,8 @@ class CategoryController extends Controller Session::put('categories.edit.url', URL::previous()); } Session::forget('categories.edit.fromUpdate'); + Session::flash('gaEventCategory', 'categories'); + Session::flash('gaEventAction', 'edit'); return view('categories.edit', compact('category', 'subTitle')); diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 2ede528fa2..0e93e5ba35 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -45,6 +45,8 @@ class CurrencyController extends Controller Session::put('currency.create.url', URL::previous()); } Session::forget('currency.create.fromStore'); + Session::flash('gaEventCategory', 'currency'); + Session::flash('gaEventAction', 'create'); return view('currency.create', compact('subTitleIcon', 'subTitle')); } @@ -84,6 +86,8 @@ class CurrencyController extends Controller // put previous url in session Session::put('currency.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'currency'); + Session::flash('gaEventAction', 'delete'); return view('currency.delete', compact('currency')); @@ -127,6 +131,8 @@ class CurrencyController extends Controller Session::put('currency.edit.url', URL::previous()); } Session::forget('currency.edit.fromUpdate'); + Session::flash('gaEventCategory', 'currency'); + Session::flash('gaEventAction', 'edit'); return view('currency.edit', compact('currency', 'subTitle', 'subTitleIcon')); diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index bd9b3043e0..16535314b6 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -72,6 +72,8 @@ class PiggyBankController extends Controller Session::put('piggy-banks.create.url', URL::previous()); } Session::forget('piggy-banks.create.fromStore'); + Session::flash('gaEventCategory', 'piggy-banks'); + Session::flash('gaEventAction', 'create'); return view('piggy-banks.create', compact('accounts', 'periods', 'subTitle', 'subTitleIcon')); } @@ -87,6 +89,8 @@ class PiggyBankController extends Controller // put previous url in session Session::put('piggy-banks.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'piggy-banks'); + Session::flash('gaEventAction', 'delete'); return view('piggy-banks.delete', compact('piggyBank', 'subTitle')); } @@ -138,6 +142,8 @@ class PiggyBankController extends Controller 'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false ]; Session::flash('preFilled', $preFilled); + Session::flash('gaEventCategory', 'piggy-banks'); + Session::flash('gaEventAction', 'edit'); // put previous url in session if not redirect from store (not "return_to_edit"). if (Session::get('piggy-banks.edit.fromUpdate') !== true) { diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 49f9b11f98..d776a58e1a 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -90,6 +90,10 @@ class ReportController extends Controller $balance = $this->helper->getBalanceReport($start, $end, $shared); $bills = $this->helper->getBillReport($start, $end, $shared); + Session::flash('gaEventCategory', 'report'); + Session::flash('gaEventAction', 'month'); + Session::flash('gaEventLabel', $start->format('F Y')); + return view( 'reports.month', @@ -133,6 +137,10 @@ class ReportController extends Controller $incomes = $this->helper->getIncomeReport($start, $end, $shared); $expenses = $this->helper->getExpenseReport($start, $end, $shared); + Session::flash('gaEventCategory', 'report'); + Session::flash('gaEventAction', 'year'); + Session::flash('gaEventLabel', $start->format('Y')); + return view( 'reports.year', diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 95e3fbdacd..5b572dd869 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -70,6 +70,8 @@ class TagController extends Controller Session::put('tags.create.url', URL::previous()); } Session::forget('tags.create.fromStore'); + Session::flash('gaEventCategory', 'tags'); + Session::flash('gaEventAction', 'create'); return view('tags.create', compact('subTitle', 'subTitleIcon')); } @@ -85,6 +87,8 @@ class TagController extends Controller // put previous url in session Session::put('tags.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'tags'); + Session::flash('gaEventAction', 'delete'); return view('tags.delete', compact('tag', 'subTitle')); } @@ -141,6 +145,8 @@ class TagController extends Controller Session::put('tags.edit.url', URL::previous()); } Session::forget('tags.edit.fromUpdate'); + Session::flash('gaEventCategory', 'tags'); + Session::flash('gaEventAction', 'edit'); return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'tagOptions')); } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index c34cdfed54..4c88f3106b 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -62,6 +62,8 @@ class TransactionController extends Controller Session::put('transactions.create.url', URL::previous()); } Session::forget('transactions.create.fromStore'); + Session::flash('gaEventCategory', 'transactions'); + Session::flash('gaEventAction', 'create-' . $what); asort($piggies); @@ -83,6 +85,8 @@ class TransactionController extends Controller // put previous url in session Session::put('transactions.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'transactions'); + Session::flash('gaEventAction', 'delete-' . $type); return view('transactions.delete', compact('journal', 'subTitle')); @@ -158,6 +162,8 @@ class TransactionController extends Controller $preFilled['account_to_id'] = $transactions[0]->account->id; Session::flash('preFilled', $preFilled); + Session::flash('gaEventCategory', 'transactions'); + Session::flash('gaEventAction', 'edit-' . $what); // put previous url in session if not redirect from store (not "return_to_edit"). if (Session::get('transactions.edit.fromUpdate') !== true) { diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig index d6eb987e74..6f88f5131a 100644 --- a/resources/twig/layout/default.twig +++ b/resources/twig/layout/default.twig @@ -169,9 +169,12 @@ ga('send', 'pageview'); // send an event if relevant: - {% if Session.has('gaEventCategory') and Session.has('gaEventAction') %} + {% if Session.has('gaEventCategory') and Session.has('gaEventAction') and not Session.has('gaEventLabel') %} ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}'); {% endif %} + {% if Session.has('gaEventCategory') and Session.has('gaEventAction') and Session.has('gaEventLabel') %} + ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}','{{ Session.get('gaEventLabel') }}'); + {% endif %} From af838e4ed1a896c930d07277696439fe9ce70d68 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 25 May 2015 09:23:45 +0200 Subject: [PATCH 18/30] New translations. --- app/Http/Controllers/PiggyBankController.php | 2 +- resources/lang/en/firefly.php | 62 +++++++++------- resources/lang/nl/firefly.php | 75 ++++++++++++-------- resources/twig/piggy-banks/add.twig | 6 +- resources/twig/piggy-banks/edit.twig | 2 +- resources/twig/piggy-banks/index.twig | 16 ++--- resources/twig/piggy-banks/remove.twig | 6 +- 7 files changed, 99 insertions(+), 70 deletions(-) diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 16535314b6..943293a26b 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -122,7 +122,7 @@ class PiggyBankController extends Controller $periods = Config::get('firefly.piggy_bank_periods'); $accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account'])); - $subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"'; + $subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]); $subTitleIcon = 'fa-pencil'; /* diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php index 85fa92a8cb..a0dd4ba845 100644 --- a/resources/lang/en/firefly.php +++ b/resources/lang/en/firefly.php @@ -1,29 +1,31 @@ 'You have selected English.', 'close' => 'Close', 'pleaseHold' => 'Please hold...', - 'mandatoryFields' => 'Mandatory fields', - 'optionalFields' => 'Optional fields', - 'options' => 'Options', - 'something' => 'Something!', 'actions' => 'Actions', 'edit' => 'Edit', 'delete' => 'Delete', 'welcomeBack' => 'What\'s playing?', - 'everything' => 'Everything', 'customRange' => 'Custom range', 'apply' => 'Apply', 'cancel' => 'Cancel', 'from' => 'From', 'to' => 'To', - 'showEverything' => 'Show everything', + + // forms: + 'mandatoryFields' => 'Mandatory fields', + 'optionalFields' => 'Optional fields', + 'options' => 'Options', + 'something' => 'Something!', + + // budgets: 'create_new_budget' => 'Create a new budget', 'store_new_budget' => ' Store new budget', - 'availableIn' => 'Available in :date', 'transactionsWithoutBudget' => 'Expenses without budget', 'transactionsWithoutBudgetDate' => 'Expenses without budget in :date', @@ -31,7 +33,6 @@ return [ 'inactiveBudgets' => 'Inactive budgets', // accounts: - 'details_for_asset' => 'Details for asset account ":name"', 'details_for_expense' => 'Details for expense account ":name"', 'details_for_revenue' => 'Details for revenue account ":name"', @@ -61,6 +62,14 @@ return [ 'make_new_expense_account' => 'Create a new expense account', 'make_new_revenue_account' => 'Create a new revenue account', + 'asset_accounts' => 'Asset accounts', + 'expense_accounts' => 'Expense accounts', + 'revenue_accounts' => 'Revenue accounts', + + 'accountExtraHelp_asset' => '', + 'accountExtraHelp_expense' => '', + 'accountExtraHelp_revenue' => '', + // categories: 'new_category' => 'New category', 'without_category' => 'Without a category', @@ -71,7 +80,8 @@ return [ // new user: 'welcome' => 'Welcome to Firefly!', - 'createNewAsset' => 'Create a new asset account to get started. This will allow you to create transactions and start your financial management', + 'createNewAsset' => 'Create a new asset account to get started. ' . + 'This will allow you to create transactions and start your financial management', 'createNewAssetButton' => 'Create new asset account', // home page: @@ -122,11 +132,12 @@ return [ 'createNew' => 'Create new', 'withdrawal' => 'Withdrawal', 'deposit' => 'Deposit', + 'account' => 'Account', 'transfer' => 'Transfer', 'Withdrawal' => 'Withdrawal', 'Deposit' => 'Deposit', 'Transfer' => 'Transfer', - 'bill' => 'Rekening', + 'bill' => 'Bill', 'yes' => 'Yes', 'no' => 'No', 'amount' => 'Amount', @@ -141,6 +152,7 @@ return [ 'half-year' => 'Every six months', 'yearly' => 'Yearly', + // reports: 'reportForYear' => 'Yearly report for :year', 'reportForYearShared' => 'Yearly report for :year (including shared accounts)', 'reportForMonth' => 'Montly report for :year', @@ -151,15 +163,10 @@ return [ 'balanceEndOfYear' => 'Balance at end of year', 'balanceStartOfMonth' => 'Balance at end of month', 'balanceEndOfMonth' => 'Balance at end of month', - 'balanceStart' => 'Balance at end of period', 'balanceEnd' => 'Balance at end of period', - 'reportsOwnAccounts' => 'Reports for your own accounts', 'reportsOwnAccountsAndShared' => 'Reports for your own accounts and shared accounts', - - 'account' => 'Account', - 'splitByAccount' => 'Split by account', 'balancedByTransfersAndTags' => 'Balanced by transfers and tags', 'coveredWithTags' => 'Covered with tags', @@ -167,11 +174,9 @@ return [ 'expectedBalance' => 'Expected balance', 'outsideOfBudgets' => 'Outside of budgets', 'leftInBudget' => 'Left in budget', - 'sumOfSums' => 'Sum of sums', 'notCharged' => 'Not charged (yet)', 'inactive' => 'Inactive', - 'difference' => 'Difference', 'in' => 'In', 'out' => 'Out', @@ -203,12 +208,21 @@ return [ 'average' => 'Average', 'balanceFor' => 'Balance for :name', - 'asset_accounts' => 'Asset accounts', - 'expense_accounts' => 'Expense accounts', - 'revenue_accounts' => 'Revenue accounts', + // piggy banks: + 'new_piggy_bank' => 'Create new piggy bank', + 'account_status' => 'Account status', + 'left_for_piggy_banks' => 'Left for piggy banks', + 'sum_of_piggy_banks' => 'Sum of piggy banks', + 'saved_so_far' => 'Saved so far', + 'left_to_save' => 'Left to save', + 'add_money_to_piggy_title' => 'Add money to piggy bank ":name"', + 'remove_money_from_piggy_title' => 'Remove money from piggy bank ":name"', + 'add' => 'Add', + 'remove' => 'Remove', + 'max_amount_add' => 'The maximum amount you can add is', + 'max_amount_remove' => 'The maximum amount you can remove is', + 'update_piggy_button' => 'Update piggy bank', + 'update_piggy_title' => 'Update piggy bank ":name"', + - // some extra help: - 'accountExtraHelp_asset' => '', - 'accountExtraHelp_expense' => '', - 'accountExtraHelp_revenue' => '', ]; diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php index ebdec72321..5dbda15d35 100644 --- a/resources/lang/nl/firefly.php +++ b/resources/lang/nl/firefly.php @@ -1,29 +1,31 @@ 'Nederlands geselecteerd!', 'close' => 'Sluiten', 'pleaseHold' => 'Momentje...', - 'mandatoryFields' => 'Verplichte velden', - 'optionalFields' => 'Optionele velden', - 'options' => 'Opties', - 'something' => 'Iets!', 'actions' => 'Acties', 'edit' => 'Wijzig', 'delete' => 'Verwijder', 'welcomeBack' => 'Hoe staat het er voor?', - 'everything' => 'Alles', 'customRange' => 'Zelf bereik kiezen', 'apply' => 'Go', 'cancel' => 'Annuleren', 'from' => 'Van', 'to' => 'Tot', - 'showEverything' => 'Laat alles zien', + + // forms: + 'mandatoryFields' => 'Verplichte velden', + 'optionalFields' => 'Optionele velden', + 'options' => 'Opties', + 'something' => 'Iets!', + + // budgets: 'create_new_budget' => 'Maak een nieuw budget', 'store_new_budget' => 'Sla nieuw budget op', - 'availableIn' => 'Beschikbaar in :date', 'transactionsWithoutBudget' => 'Uitgaven zonder budget', 'transactionsWithoutBudgetDate' => 'Uitgaven zonder budget in :date', @@ -31,7 +33,6 @@ return [ 'inactiveBudgets' => 'Inactieve budgetten', // accounts: - 'details_for_asset' => 'Overzicht voor betaalrekening ":name"', 'details_for_expense' => 'Overzicht voor crediteur ":name"', 'details_for_revenue' => 'Overzicht voor debiteur ":name"', @@ -61,6 +62,23 @@ return [ 'make_new_expense_account' => 'Nieuwe crediteur', 'make_new_revenue_account' => 'Nieuwe debiteur', + 'asset_accounts' => 'Betaalrekeningen', + 'expense_accounts' => 'Crediteuren', + 'revenue_accounts' => 'Debiteuren', + + // some extra help: + 'accountExtraHelp_asset' => '', + 'accountExtraHelp_expense' => + 'Een crediteur is een persoon of een bedrijf waar je geld aan moet betalen. Je staat bij ze in het krijt. Een verwarrende' . + ' term misschien, maar zo werkt het nou eenmaal. De supermarkt, je huurbaas of de bank zijn crediteuren. Jouw ' . + 'geld (krediet) gaat naar hen toe. De term komt uit de wereld van de boekhouding. De uitgaves die je hier ziet zijn ' . + 'positief, want je kijkt uit hun perspectief. Zodra jij afrekent in een winkel, komt het geld er bij hen bij (positief).', + 'accountExtraHelp_revenue' => 'Als je geld krijgt van een bedrijf of een persoon is dat een debiteur. ' . + 'Dat kan salaris zijn, of een andere betaling. ' . + ' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' . + ' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' . + 'overmaakt gaat het er bij hen af (negatief).', + // categories: 'new_category' => 'Nieuwe categorie', 'without_category' => 'Zonder categorie', @@ -74,6 +92,7 @@ return [ 'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.', 'createNewAssetButton' => 'Maak een nieuwe betaalrekening', + // home page: 'yourAccounts' => 'Je betaalrekeningen', 'budgetsAndSpending' => 'Budgetten en uitgaven', @@ -122,6 +141,7 @@ return [ 'createNew' => 'Nieuw', 'withdrawal' => 'Uitgave', 'deposit' => 'Inkomsten', + 'account' => 'Rekening', 'transfer' => 'Overschrijving', 'Withdrawal' => 'Uitgave', 'Deposit' => 'Inkomsten', @@ -141,6 +161,7 @@ return [ 'half-year' => 'Elk half jaar', 'yearly' => 'Jaarlijks', + // reports: 'reportForYear' => 'Jaaroverzicht :year', 'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)', 'reportForMonth' => 'Maandoverzicht van :date', @@ -151,15 +172,10 @@ return [ 'balanceEndOfYear' => 'Saldo aan het einde van het jaar', 'balanceStartOfMonth' => 'Saldo aan het begin van de maand', 'balanceEndOfMonth' => 'Saldo aan het einde van de maand', - 'balanceStart' => 'Saldo aan het begin van de periode', 'balanceEnd' => 'Saldo aan het einde van de periode', - 'reportsOwnAccounts' => 'Overzichten voor je eigen betaalrekeningen', 'reportsOwnAccountsAndShared' => 'Overzichten voor je eigen betaalrekeningen en gedeelde rekeningen', - - 'account' => 'Rekening', - 'splitByAccount' => 'Per betaalrekening', 'balancedByTransfersAndTags' => 'Gecorrigeerd met overschrijvingen en tags', 'coveredWithTags' => 'Gecorrigeerd met tags', @@ -167,11 +183,9 @@ return [ 'expectedBalance' => 'Verwacht saldo', 'outsideOfBudgets' => 'Buiten budgetten', 'leftInBudget' => 'Over van budget', - 'sumOfSums' => 'Alles bij elkaar', 'notCharged' => '(Nog) niet betaald', 'inactive' => 'Niet actief', - 'difference' => 'Verschil', 'in' => 'In', 'out' => 'Uit', @@ -203,20 +217,21 @@ return [ 'average' => 'Gemiddeld', 'balanceFor' => 'Saldo op :name', - 'asset_accounts' => 'Betaalrekeningen', - 'expense_accounts' => 'Crediteuren', - 'revenue_accounts' => 'Debiteuren', + // piggy banks: + 'new_piggy_bank' => 'Nieuw spaarpotje', + 'account_status' => 'Rekeningoverzicht', + 'left_for_piggy_banks' => 'Over voor spaarpotjes', + 'sum_of_piggy_banks' => 'Som van spaarpotjes', + 'saved_so_far' => 'Gespaard', + 'left_to_save' => 'Te sparen', + 'add_money_to_piggy_title' => 'Stop geld in spaarpotje ":name"', + 'remove_money_from_piggy_title' => 'Haal geld uit spaarpotje ":name"', + 'add' => 'Toevoegen', + 'remove' => 'Verwijderen', + 'max_amount_add' => 'Hooguit toe te voegen', + 'max_amount_remove' => 'Hooguit te verwijderen', + 'update_piggy_button' => 'Wijzig spaarpotje', + 'update_piggy_title' => 'Wijzig spaarpotje ":name"', + - // some extra help: - 'accountExtraHelp_asset' => '', - 'accountExtraHelp_expense' => - 'Een crediteur is een persoon of een bedrijf waar je geld aan moet betalen. Je staat bij ze in het krijt. Een verwarrende' . - ' term misschien, maar zo werkt het nou eenmaal. De supermarkt, je huurbaas of de bank zijn crediteuren. Jouw ' . - 'geld (krediet) gaat naar hen toe. De term komt uit de wereld van de boekhouding. De uitgaves die je hier ziet zijn ' . - 'positief, want je kijkt uit hun perspectief. Zodra jij afrekent in een winkel, komt het geld er bij hen bij (positief).', - 'accountExtraHelp_revenue' => 'Als je geld krijgt van een bedrijf of een persoon is dat een debiteur. ' . - 'Dat kan salaris zijn, of een andere betaling. ' . - ' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' . - ' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' . - 'overmaakt gaat het er bij hen af (negatief).', ]; diff --git a/resources/twig/piggy-banks/add.twig b/resources/twig/piggy-banks/add.twig index 5efa39cc9b..1a3f3f0f49 100644 --- a/resources/twig/piggy-banks/add.twig +++ b/resources/twig/piggy-banks/add.twig @@ -2,12 +2,12 @@