1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 16:42:48 +01:00

Adding configuration for first day of the week

- Fix #868 and resolves #868
- The first day of the week can be configured in localization settings,
which affects the Bootstrap date picker
This commit is contained in:
Holger Lösken 2016-07-04 16:20:22 +02:00
parent a114f60127
commit fcc8cac7b5
8 changed files with 179 additions and 69 deletions

View File

@ -394,6 +394,7 @@ class AccountController extends BaseController
'datetimeFormats' => Cache::get('datetimeFormats'), 'datetimeFormats' => Cache::get('datetimeFormats'),
'currencies' => Cache::get('currencies'), 'currencies' => Cache::get('currencies'),
'title' => trans('texts.localization'), 'title' => trans('texts.localization'),
'weekdays' => Utils::getTranslatedWeekdayNames(),
]; ];
return View::make('accounts.localization', $data); 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->language_id = Input::get('language_id') ? Input::get('language_id') : 1; // English
$account->military_time = Input::get('military_time') ? true : false; $account->military_time = Input::get('military_time') ? true : false;
$account->show_currency_code = Input::get('show_currency_code') ? 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(); $account->save();
event(new UserSettingsChanged()); event(new UserSettingsChanged());

View File

@ -21,6 +21,11 @@ use App\Models\Currency;
class Utils class Utils
{ {
private static $weekdayNames = [
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
];
public static function isRegistered() public static function isRegistered()
{ {
return Auth::check() && Auth::user()->registered; return Auth::check() && Auth::user()->registered;
@ -1013,4 +1018,28 @@ class Utils
return new WePay(null); 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));
});
}
} }

View File

@ -62,6 +62,7 @@ class Account extends Eloquent
'show_item_taxes', 'show_item_taxes',
'default_tax_rate_id', 'default_tax_rate_id',
'enable_second_tax_rate', 'enable_second_tax_rate',
'start_of_week',
]; ];
public static $basicSettings = [ public static $basicSettings = [
@ -811,6 +812,8 @@ class Account extends Eloquent
$format = str_replace('g:i a', 'H:i', $format); $format = str_replace('g:i a', 'H:i', $format);
} }
Session::put(SESSION_DATETIME_FORMAT, $format); Session::put(SESSION_DATETIME_FORMAT, $format);
Session::put('start_of_week', $this->start_of_week);
} }
public function getInvoiceLabels() public function getInvoiceLabels()

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Class AddStartOfWeekToAccountsTable
*/
class AddStartOfWeekToAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->integer('start_of_week');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn('start_of_week');
});
}
}

View File

@ -1362,6 +1362,7 @@ $LANG = array(
'failed_remove_payment_method' => 'Failed to remove the payment method', 'failed_remove_payment_method' => 'Failed to remove the payment method',
'gateway_exists' => 'This gateway already exists', 'gateway_exists' => 'This gateway already exists',
'manual_entry' => 'Manual entry', 'manual_entry' => 'Manual entry',
'start_of_week' => 'Erster Tag der Woche',
// Frequencies // Frequencies
'freq_weekly' => 'wöchentlich', 'freq_weekly' => 'wöchentlich',

View File

@ -1362,6 +1362,7 @@ $LANG = array(
'failed_remove_payment_method' => 'Failed to remove the payment method', 'failed_remove_payment_method' => 'Failed to remove the payment method',
'gateway_exists' => 'This gateway already exists', 'gateway_exists' => 'This gateway already exists',
'manual_entry' => 'Manual entry', 'manual_entry' => 'Manual entry',
'start_of_week' => 'First day of the week',
// Frequencies // Frequencies
'freq_weekly' => 'Weekly', 'freq_weekly' => 'Weekly',

View File

@ -30,6 +30,8 @@
->fromQuery($dateFormats) !!} ->fromQuery($dateFormats) !!}
{!! Former::select('datetime_format_id')->addOption('','') {!! Former::select('datetime_format_id')->addOption('','')
->fromQuery($datetimeFormats) !!} ->fromQuery($datetimeFormats) !!}
{!! Former::select('start_of_week')->addOption('','')
->fromQuery($weekdays) !!}
{!! Former::checkbox('military_time')->text(trans('texts.enable')) !!} {!! Former::checkbox('military_time')->text(trans('texts.enable')) !!}
{{-- Former::checkbox('show_currency_code')->text(trans('texts.enable')) --}} {{-- Former::checkbox('show_currency_code')->text(trans('texts.enable')) --}}

View File

@ -5,35 +5,35 @@
<title>{{ trans('texts.client_portal') }}</title> <title>{{ trans('texts.client_portal') }}</title>
@else @else
<title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}</title> <title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}</title>
<meta name="description" content="{{ isset($description) ? $description : trans('texts.app_description') }}" /> <meta name="description" content="{{ isset($description) ? $description : trans('texts.app_description') }}"/>
<link href="{{ asset('favicon-v2.png') }}" rel="shortcut icon" type="image/png"> <link href="{{ asset('favicon-v2.png') }}" rel="shortcut icon" type="image/png">
@endif @endif
<!-- Source: https://github.com/invoiceninja/invoiceninja --> <!-- Source: https://github.com/invoiceninja/invoiceninja -->
<!-- Version: {{ NINJA_VERSION }} --> <!-- Version: {{ NINJA_VERSION }} -->
<meta charset="utf-8"> <meta charset="utf-8">
<meta property="og:site_name" content="Invoice Ninja" /> <meta property="og:site_name" content="Invoice Ninja"/>
<meta property="og:url" content="{{ SITE_URL }}" /> <meta property="og:url" content="{{ SITE_URL }}"/>
<meta property="og:title" content="Invoice Ninja" /> <meta property="og:title" content="Invoice Ninja"/>
<meta property="og:image" content="{{ SITE_URL }}/images/round_logo.png" /> <meta property="og:image" content="{{ SITE_URL }}/images/round_logo.png"/>
<meta property="og:description" content="Simple, Intuitive Invoicing." /> <meta property="og:description" content="Simple, Intuitive Invoicing."/>
<!-- http://stackoverflow.com/questions/19012698/browser-cache-issues-in-laravel-4-application --> <!-- http://stackoverflow.com/questions/19012698/browser-cache-issues-in-laravel-4-application -->
<meta http-equiv="cache-control" content="max-age=0" /> <meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="cache-control" content="no-store" /> <meta http-equiv="cache-control" content="no-store"/>
<meta http-equiv="cache-control" content="must-revalidate" /> <meta http-equiv="cache-control" content="must-revalidate"/>
<meta http-equiv="expires" content="0" /> <meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="pragma" content="no-cache"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="msapplication-config" content="none"/> <meta name="msapplication-config" content="none"/>
<link rel="canonical" href="{{ NINJA_APP_URL }}/{{ Request::path() }}" /> <link rel="canonical" href="{{ NINJA_APP_URL }}/{{ Request::path() }}"/>
<script src="{{ asset('built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script> <script src="{{ asset('built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
@ -55,9 +55,9 @@
// Use StackTraceJS to parse the error context // Use StackTraceJS to parse the error context
if (error) { if (error) {
var message = error.message ? error.message : error; var message = error.message ? error.message : error;
StackTrace.fromError(error).then(function(result) { StackTrace.fromError(error).then(function (result) {
var gps = new StackTraceGPS(); var gps = new StackTraceGPS();
gps.findFunctionName(result[0]).then(function(result) { gps.findFunctionName(result[0]).then(function (result) {
logError(errorMsg + ': ' + JSON.stringify(result)); logError(errorMsg + ': ' + JSON.stringify(result));
}); });
}); });
@ -66,7 +66,8 @@
} }
trackEvent('/error', errorMsg); trackEvent('/error', errorMsg);
} catch(err) {} } catch (err) {
}
return false; return false;
} }
@ -75,12 +76,12 @@
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '{{ URL::to('log_error') }}', 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 */ /* Set the defaults for DataTables initialisation */
$.extend( true, $.fn.dataTable.defaults, { $.extend(true, $.fn.dataTable.defaults, {
"bSortClasses": false, "bSortClasses": false,
"sDom": "t<'row-fluid'<'span6'i><'span6'p>>l", "sDom": "t<'row-fluid'<'span6'i><'span6'p>>l",
"sPaginationType": "bootstrap", "sPaginationType": "bootstrap",
@ -90,45 +91,61 @@
'sLengthMenu': '_MENU_ {{ trans('texts.rows') }}', 'sLengthMenu': '_MENU_ {{ trans('texts.rows') }}',
'sSearch': '' '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 /* This causes problems with some languages. ie, fr_CA
var appLocale = '{{App::getLocale()}}'; var appLocale = '{{App::getLocale()}}';
$.extend( true, $.fn.datepicker.defaults, { */
language: appLocale.replace("_", "-")
});
*/
@if (env('FACEBOOK_PIXEL')) @if (env('FACEBOOK_PIXEL'))
<!-- Facebook Pixel Code --> <!-- Facebook Pixel Code -->
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? !function (f, b, e, v, n, t, s) {
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; if (f.fbq)return;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; n = f.fbq = function () {
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, n.callMethod ?
document,'script','//connect.facebook.net/en_US/fbevents.js'); 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('init', '{{ env('FACEBOOK_PIXEL') }}');
fbq('track', "PageView"); fbq('track', "PageView");
(function() { (function () {
var _fbq = window._fbq || (window._fbq = []); var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) { if (!_fbq.loaded) {
var fbds = document.createElement('script'); var fbds = document.createElement('script');
fbds.async = true; fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js'; fbds.src = '//connect.facebook.net/en_US/fbds.js';
var s = document.getElementsByTagName('script')[0]; var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(fbds, s); s.parentNode.insertBefore(fbds, s);
_fbq.loaded = true; _fbq.loaded = true;
} }
})(); })();
@else @else
function fbq() { function fbq() {
// do nothing // do nothing
}; }
;
@endif @endif
window._fbq = window._fbq || []; window._fbq = window._fbq || [];
</script> </script>
@ -139,32 +156,49 @@
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]--> <![endif]-->
@yield('head') @yield('head')
</head> </head>
<body class="body"> <body class="body">
@if (isset($_ENV['TAG_MANAGER_KEY']) && $_ENV['TAG_MANAGER_KEY']) @if (isset($_ENV['TAG_MANAGER_KEY']) && $_ENV['TAG_MANAGER_KEY'])
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={{ $_ENV['TAG_MANAGER_KEY'] }}" <noscript>
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <iframe src="//www.googletagmanager.com/ns.html?id={{ $_ENV['TAG_MANAGER_KEY'] }}"
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': height="0" width="0" style="display:none;visibility:hidden"></iframe>
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], </noscript>
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= <script>(function (w, d, s, l, i) {
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); w[l] = w[l] || [];
})(window,document,'script','dataLayer','{{ $_ENV['TAG_MANAGER_KEY'] }}');</script> w[l].push({
'gtm.start': new Date().getTime(), event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'//www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '{{ $_ENV['TAG_MANAGER_KEY'] }}');</script>
<!-- End Google Tag Manager --> <!-- End Google Tag Manager -->
<script> <script>
function trackEvent(category, action) {} function trackEvent(category, action) {
}
</script> </script>
@elseif (isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY']) @elseif (isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY'])
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function (i, s, o, g, r, a, m) {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), i['GoogleAnalyticsObject'] = r;
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) i[r] = i[r] || function () {
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); (i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', '{{ $_ENV['ANALYTICS_KEY'] }}', 'auto'); ga('create', '{{ $_ENV['ANALYTICS_KEY'] }}', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
@ -173,36 +207,40 @@
ga('send', 'event', category, action, this.src); ga('send', 'event', category, action, this.src);
} }
</script> </script>
@else @else
<script> <script>
function trackEvent(category, action) {} function trackEvent(category, action) {
}
</script> </script>
@endif @endif
@yield('body') @yield('body')
<script type="text/javascript"> <script type="text/javascript">
NINJA.formIsChanged = {{ isset($formIsChanged) && $formIsChanged ? 'true' : 'false' }}; NINJA.formIsChanged = {{ isset($formIsChanged) && $formIsChanged ? 'true' : 'false' }};
$(function() { $(function () {
$('form.warn-on-exit input, form.warn-on-exit textarea, form.warn-on-exit select').change(function() { $('form.warn-on-exit input, form.warn-on-exit textarea, form.warn-on-exit select').change(function () {
NINJA.formIsChanged = true; NINJA.formIsChanged = true;
}); });
@if (Session::has('trackEventCategory') && Session::has('trackEventAction')) @if (Session::has('trackEventCategory') && Session::has('trackEventAction'))
@if (Session::get('trackEventAction') === '/buy_pro_plan') @if (Session::get('trackEventAction') === '/buy_pro_plan')
window._fbq.push(['track', '{{ env('FACEBOOK_PIXEL_BUY_PRO') }}', {'value':'{{ session('trackEventAmount') }}','currency':'USD'}]); window._fbq.push(['track', '{{ env('FACEBOOK_PIXEL_BUY_PRO') }}', {
@endif 'value': '{{ session('trackEventAmount') }}',
'currency': 'USD'
}]);
@endif
@endif @endif
@if (Session::has('onReady')) @if (Session::has('onReady'))
{{ Session::get('onReady') }} {{ Session::get('onReady') }}
@endif @endif
}); });
$('form').submit(function() { $('form').submit(function () {
NINJA.formIsChanged = false; NINJA.formIsChanged = false;
}); });
$(window).on('beforeunload', function() { $(window).on('beforeunload', function () {
if (NINJA.formIsChanged) { if (NINJA.formIsChanged) {
return "{{ trans('texts.unsaved_changes') }}"; return "{{ trans('texts.unsaved_changes') }}";
} else { } else {