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 @@ {{ trans('texts.client_portal') }} @else {{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }} - + @endif - - + + - - - - - + + + + + - - - - - - - + + + + + + + - + @@ -55,9 +55,9 @@ // Use StackTraceJS to parse the error context if (error) { var message = error.message ? error.message : error; - StackTrace.fromError(error).then(function(result) { + StackTrace.fromError(error).then(function (result) { var gps = new StackTraceGPS(); - gps.findFunctionName(result[0]).then(function(result) { + gps.findFunctionName(result[0]).then(function (result) { logError(errorMsg + ': ' + JSON.stringify(result)); }); }); @@ -66,7 +66,8 @@ } trackEvent('/error', errorMsg); - } catch(err) {} + } catch (err) { + } return false; } @@ -75,12 +76,12 @@ $.ajax({ type: 'GET', url: '{{ URL::to('log_error') }}', - data: 'error='+encodeURIComponent(message)+'&url='+encodeURIComponent(window.location) + data: 'error=' + encodeURIComponent(message) + '&url=' + encodeURIComponent(window.location) }); } /* Set the defaults for DataTables initialisation */ - $.extend( true, $.fn.dataTable.defaults, { + $.extend(true, $.fn.dataTable.defaults, { "bSortClasses": false, "sDom": "t<'row-fluid'<'span6'i><'span6'p>>l", "sPaginationType": "bootstrap", @@ -90,45 +91,61 @@ 'sLengthMenu': '_MENU_ {{ trans('texts.rows') }}', 'sSearch': '' } - } ); + }); + + /* Set the defaults for Bootstrap datepicker */ + $.extend(true, $.fn.datepicker.defaults, { + weekStart: {{ Session::get('start_of_week') }} + }); /* This causes problems with some languages. ie, fr_CA - var appLocale = '{{App::getLocale()}}'; - $.extend( true, $.fn.datepicker.defaults, { - language: appLocale.replace("_", "-") - }); - */ + var appLocale = '{{App::getLocale()}}'; + */ @if (env('FACEBOOK_PIXEL')) - - !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? - n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; - n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; - t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, - document,'script','//connect.facebook.net/en_US/fbevents.js'); + + !function (f, b, e, v, n, t, s) { + if (f.fbq)return; + n = f.fbq = function () { + n.callMethod ? + n.callMethod.apply(n, arguments) : n.queue.push(arguments) + }; + if (!f._fbq)f._fbq = n; + n.push = n; + n.loaded = !0; + n.version = '2.0'; + n.queue = []; + t = b.createElement(e); + t.async = !0; + t.src = v; + s = b.getElementsByTagName(e)[0]; + s.parentNode.insertBefore(t, s) + }(window, + document, 'script', '//connect.facebook.net/en_US/fbevents.js'); - fbq('init', '{{ env('FACEBOOK_PIXEL') }}'); - fbq('track', "PageView"); + fbq('init', '{{ env('FACEBOOK_PIXEL') }}'); + fbq('track', "PageView"); - (function() { - var _fbq = window._fbq || (window._fbq = []); - if (!_fbq.loaded) { + (function () { + var _fbq = window._fbq || (window._fbq = []); + if (!_fbq.loaded) { var fbds = document.createElement('script'); fbds.async = true; fbds.src = '//connect.facebook.net/en_US/fbds.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(fbds, s); _fbq.loaded = true; - } - })(); + } + })(); @else - function fbq() { - // do nothing - }; + function fbq() { + // do nothing + } + ; @endif - window._fbq = window._fbq || []; + window._fbq = window._fbq || []; @@ -139,32 +156,49 @@ -@yield('head') + @yield('head') - @if (isset($_ENV['TAG_MANAGER_KEY']) && $_ENV['TAG_MANAGER_KEY']) +@if (isset($_ENV['TAG_MANAGER_KEY']) && $_ENV['TAG_MANAGER_KEY']) - - + + - @elseif (isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY']) +@elseif (isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY']) - @else +@else - @endif +@endif @yield('body')