From 000f86d31872f93757ef9ad647756510eeb8ad9f Mon Sep 17 00:00:00 2001 From: Graham Miller Date: Sun, 24 Jan 2016 16:47:39 +1000 Subject: [PATCH] Added fiscal year start date stored in 'm-d' format to preferences. Displays YYYY-MM-DD for current year to get input. --- app/Http/Controllers/PreferencesController.php | 6 +++++- resources/lang/en_US/firefly.php | 1 + resources/views/preferences/index.twig | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 641a817fe0..461937a273 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -40,10 +40,12 @@ class PreferencesController extends Controller $language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data; $budgetMaximum = $budgetMax->data; $customFiscalYear = Preferences::get('customFiscalYear', 0)->data; + $fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data; + $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr; $showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', 'false') == 'true'; - return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange', 'customFiscalYear', 'showIncomplete')); + return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange', 'customFiscalYear', 'fiscalYearStart', 'showIncomplete')); } /** @@ -74,6 +76,8 @@ class PreferencesController extends Controller // custom fiscal year $customFiscalYear = (int) Input::get('customFiscalYear'); Preferences::set('customFiscalYear', $customFiscalYear); + $fiscalYearStart = date('m-d', strtotime(Input::get('fiscalYearStart'))); + Preferences::set('fiscalYearStart', $fiscalYearStart); // language: $lang = Input::get('language'); diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 2aaa1dbe18..fb8aaa0b34 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -172,6 +172,7 @@ return [ 'pref_custom_fiscal_year' => 'Fiscal year settings', 'pref_custom_fiscal_year_label' => 'Enabled', 'pref_custom_fiscal_year_help' => 'In countries that use a financial year other than January 1 to December 31, you can switch this on and specify start / end days of the fiscal year', + 'pref_fiscal_year_start_label' => 'Fiscal year start date', 'pref_save_settings' => 'Save settings', // profile: diff --git a/resources/views/preferences/index.twig b/resources/views/preferences/index.twig index 42aaba1292..30416d2918 100644 --- a/resources/views/preferences/index.twig +++ b/resources/views/preferences/index.twig @@ -55,6 +55,7 @@

{% set isCustomFiscalYear = customFiscalYear == 1 ? true : false %} {{ ExpandedForm.checkbox('customFiscalYear','1',isCustomFiscalYear,{ 'label' : 'pref_custom_fiscal_year_label'|_ }) }} + {{ ExpandedForm.date('fiscalYearStart',fiscalYearStart,{ 'label' : 'pref_fiscal_year_start_label'|_ }) }}