diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index a300983f4e..74d57394f8 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -394,6 +394,7 @@ class AccountController extends BaseController 'datetimeFormats' => Cache::get('datetimeFormats'), 'currencies' => Cache::get('currencies'), 'title' => trans('texts.localization'), + 'weekdays' => Utils::getTranslatedWeekdayNames(), ]; return View::make('accounts.localization', $data); @@ -1124,6 +1125,7 @@ class AccountController extends BaseController $account->language_id = Input::get('language_id') ? Input::get('language_id') : 1; // English $account->military_time = Input::get('military_time') ? true : false; $account->show_currency_code = Input::get('show_currency_code') ? true : false; + $account->start_of_week = Input::get('start_of_week') ? Input::get('start_of_week') : 0; $account->save(); event(new UserSettingsChanged()); diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index ee50d23322..49bd546bfa 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -21,6 +21,11 @@ use App\Models\Currency; class Utils { + private static $weekdayNames = [ + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", + ]; + + public static function isRegistered() { return Auth::check() && Auth::user()->registered; @@ -1013,4 +1018,28 @@ class Utils return new WePay(null); } } + + /** + * Gets an array of weekday names (in English) + * + * @see getTranslatedWeekdayNames() + * + * @return \Illuminate\Support\Collection + */ + public static function getWeekdayNames() + { + return collect(static::$weekdayNames); + } + + /** + * Gets an array of translated weekday names + * + * @return \Illuminate\Support\Collection + */ + public static function getTranslatedWeekdayNames() + { + return collect(static::$weekdayNames)->transform(function ($day) { + return trans('texts.'.strtolower($day)); + }); + } } diff --git a/app/Models/Account.php b/app/Models/Account.php index 4a00da54c8..5e2f3db501 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -62,6 +62,7 @@ class Account extends Eloquent 'show_item_taxes', 'default_tax_rate_id', 'enable_second_tax_rate', + 'start_of_week', ]; public static $basicSettings = [ @@ -811,6 +812,8 @@ class Account extends Eloquent $format = str_replace('g:i a', 'H:i', $format); } Session::put(SESSION_DATETIME_FORMAT, $format); + + Session::put('start_of_week', $this->start_of_week); } public function getInvoiceLabels() diff --git a/database/migrations/2016_07_04_110152_add_start_of_week_to_accounts_table.php b/database/migrations/2016_07_04_110152_add_start_of_week_to_accounts_table.php new file mode 100644 index 0000000000..5c4eb858c8 --- /dev/null +++ b/database/migrations/2016_07_04_110152_add_start_of_week_to_accounts_table.php @@ -0,0 +1,34 @@ +integer('start_of_week'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function (Blueprint $table) { + $table->dropColumn('start_of_week'); + }); + } +} diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index 655902c0e9..5c88f25636 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -1362,6 +1362,7 @@ $LANG = array( 'failed_remove_payment_method' => 'Failed to remove the payment method', 'gateway_exists' => 'This gateway already exists', 'manual_entry' => 'Manual entry', + 'start_of_week' => 'Erster Tag der Woche', // Frequencies 'freq_weekly' => 'wöchentlich', diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 6929b6855a..fab146ffb4 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1362,6 +1362,7 @@ $LANG = array( 'failed_remove_payment_method' => 'Failed to remove the payment method', 'gateway_exists' => 'This gateway already exists', 'manual_entry' => 'Manual entry', + 'start_of_week' => 'First day of the week', // Frequencies 'freq_weekly' => 'Weekly', diff --git a/resources/views/accounts/localization.blade.php b/resources/views/accounts/localization.blade.php index ccca9f3c4e..1aa0722dcf 100644 --- a/resources/views/accounts/localization.blade.php +++ b/resources/views/accounts/localization.blade.php @@ -30,6 +30,8 @@ ->fromQuery($dateFormats) !!} {!! Former::select('datetime_format_id')->addOption('','') ->fromQuery($datetimeFormats) !!} + {!! Former::select('start_of_week')->addOption('','') + ->fromQuery($weekdays) !!} {!! Former::checkbox('military_time')->text(trans('texts.enable')) !!} {{-- Former::checkbox('show_currency_code')->text(trans('texts.enable')) --}} diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index db5e8f3665..c350ff29e6 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -5,35 +5,35 @@