Support changing of first day of week for date picker(s)
MODIFY
app/Http/Controllers/SettingsController.php
app/Http/Controllers/SettingsController.php
@@ -30,7 +30,8 @@ class SettingsController extends Controller
'language' => 'nullable|in:' . implode(',', array_keys(config('app.locales'))),
'theme' => 'nullable|in:light,dark',
'weekly_report' => 'nullable|in:true,false',
- 'default_transaction_type' => 'nullable|in:earning,spending'
+ 'default_transaction_type' => 'nullable|in:earning,spending',
+ 'first_day_of_week' => 'nullable|in:sunday,monday'
]);
$user = Auth::user();
@@ -79,6 +80,10 @@ class SettingsController extends Controller
$user->default_transaction_type = $request->input('default_transaction_type');
}
+ if ($request->has('first_day_of_week')) {
+ $user->first_day_of_week = $request->input('first_day_of_week');
+ }
+
$user->save();
// Notify upon changing of password

MODIFY
app/Http/Controllers/TransactionController.php
app/Http/Controllers/TransactionController.php
@@ -54,6 +54,7 @@ class TransactionController extends Controller
'tags' => $tags,
'currencies' => $this->currencyRepository->getIfConversionRatePresent(),
'defaultTransactionType' => Auth::user()->default_transaction_type,
+ 'firstDayOfWeek' => Auth::user()->first_day_of_week,
'defaultCurrencyId' => Space::find(session('space_id'))->currency_id,
'recurringsIntervals' => $this->recurringRepository->getSupportedIntervals()
]);

ADD
database/migrations/2020_09_29_193515_add_first_day_of_week_column_to_users_table.php
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddFirstDayOfWeekColumnToUsersTable extends Migration
+{
+ public function up(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->string('first_day_of_week')->default('monday')->after('default_transaction_type');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('first_day_of_week');
+ });
+ }
+}

MODIFY
resources/assets/js/components/DatePicker.vue
resources/assets/js/components/DatePicker.vue
startDate: {
default: null
+ },
+
+ firstDayOfWeek: {
+ type: String
}
},
},
firstDayOffset: function () {
- return new Date(this.displayYear, this.displayMonth - 1, 1).getDay() - 1;
+ let offset = new Date(this.displayYear, this.displayMonth - 1, 1).getDay();
+
+ if (this.firstDayOfWeek === 'monday') {
+ offset -= 1;
+ }
+
+ return offset;
}
},

MODIFY
resources/assets/js/components/TransactionWizard.vue
resources/assets/js/components/TransactionWizard.vue
</div>
<div class="input">
<label>Date</label>
- <date-picker @DateUpdated="onDateUpdate"></date-picker>
+ <date-picker
+ :first-day-of-week="firstDayOfWeek"
+ @DateUpdated="onDateUpdate"></date-picker>
<div class="hint mt-05">YYYY-MM-DD</div>
<validation-error v-if="errors.date" :message="errors.date"></validation-error>
<validation-error v-if="errors.day" :message="errors.day"></validation-error>
</div>
<div class="row__column">
<label for="fixedEnd">Until</label>
- <date-picker name="end" :start-date="recurringEndDate" @DateUpdated="onEndUpdate"></date-picker>
+ <date-picker
+ name="end"
+ :start-date="recurringEndDate"
+ :first-day-of-week="firstDayOfWeek"
+ @DateUpdated="onEndUpdate"></date-picker>
<div class="hint mt-05">YYYY-MM-DD</div>
<validation-error v-if="errors.end" :message="errors.end"></validation-error>
</div>
'tags',
'currencies',
'defaultTransactionType',
+ 'firstDayOfWeek',
'defaultCurrencyId',
'recurringsIntervals'
],

MODIFY
resources/lang/de/fields.php
resources/lang/de/fields.php
return [
'default_transaction_type' => 'Standard transaktiontyp',
+ 'first_day_of_week' => 'Erster tag der woche',
'period' => 'Zeitraum'
];

MODIFY
resources/lang/en/fields.php
resources/lang/en/fields.php
@@ -11,6 +11,7 @@ return [
'currency' => 'Currency',
'weekly_report' => 'Weekly Report',
'default_transaction_type' => 'Default transactiontype',
+ 'first_day_of_week' => 'First day of the week',
'date' => 'Date',
'description' => 'Description',

MODIFY
resources/lang/nl/fields.php
resources/lang/nl/fields.php
@@ -11,6 +11,7 @@ return [
'currency' => 'Valuta',
'weekly_report' => 'Wekelijks Verslag',
'default_transaction_type' => 'Standaard transactietype',
+ 'first_day_of_week' => 'Eerste dag van de week',
'date' => 'Datum',
'description' => 'Omschrijving',

MODIFY
resources/views/settings/preferences.blade.php
resources/views/settings/preferences.blade.php
</div>
@include('partials.validation_error', ['payload' => 'default_transaction_type'])
</div>
+ <div class="input input--small">
+ <label>{{ __('fields.first_day_of_week') }}</label>
+ <div>
+ <input type="radio" name="first_day_of_week" value="sunday" {{ Auth::user()->first_day_of_week === 'sunday' ? 'checked' : '' }} /> {{ __('calendar.weekdays.6') }}
+ </div>
+ <div>
+ <input type="radio" name="first_day_of_week" value="monday" {{ Auth::user()->first_day_of_week === 'monday' ? 'checked' : '' }} /> {{ __('calendar.weekdays.0') }}
+ </div>
+ @include('partials.validation_error', ['payload' => 'first_day_of_week'])
+ </div>
<button class="button">{{ __('actions.save') }}</button>
</div>
</div>

MODIFY
resources/views/transactions/create.blade.php
resources/views/transactions/create.blade.php
:tags='@json($tags)'
:currencies='@json($currencies)'
default-transaction-type='{{ $defaultTransactionType }}'
+ first-day-of-week='{{ $firstDayOfWeek }}'
:default-currency-id='{{ $defaultCurrencyId }}'
:recurrings-intervals='@json($recurringsIntervals)'
></transaction-wizard>

Support changing of first day of week for date picker(s)