diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 8f6826186d35..d2417048c4e9 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -471,6 +471,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); @@ -1270,6 +1271,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 155739c84970..498196ae8b46 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -18,6 +18,11 @@ use WePay; class Utils { + private static $weekdayNames = [ + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", + ]; + + public static function isRegistered() { return Auth::check() && Auth::user()->registered; @@ -1020,4 +1025,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 4b765d544014..d940b108094e 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -79,6 +79,7 @@ class Account extends Eloquent 'show_item_taxes', 'default_tax_rate_id', 'enable_second_tax_rate', + 'start_of_week', ]; /** @@ -1063,6 +1064,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); } /** 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 000000000000..5c4eb858c852 --- /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 655902c0e914..5c88f25636a9 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 0e6d051fd192..084231ea7a7b 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 ccca9f3c4e20..1aa0722dcf2d 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 db5e8f366519..c350ff29e63d 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -5,35 +5,35 @@