diff --git a/app/Utilities/helpers.php b/app/Utilities/helpers.php index 9656aacea..3cbf6a166 100644 --- a/app/Utilities/helpers.php +++ b/app/Utilities/helpers.php @@ -23,6 +23,22 @@ if (!function_exists('user')) { } } +if (!function_exists('company_date_format')) { + /** + * Format the given date based on company settings. + * + * @return string + */ + function company_date_format() + { + $date_time = new class() { + use DateTime; + }; + + return $date_time->getCompanyDateFormat(); + } +} + if (!function_exists('company_date')) { /** * Format the given date based on company settings. diff --git a/resources/assets/js/components/AkauntingDate.vue b/resources/assets/js/components/AkauntingDate.vue index d7d94e1ef..a68b86e91 100644 --- a/resources/assets/js/components/AkauntingDate.vue +++ b/resources/assets/js/components/AkauntingDate.vue @@ -71,12 +71,23 @@ export default { icon: { type: String, description: "Prepend icon (left)" + }, + locale: { + type: String, + default: 'en', } }, data() { return { - real_model: this.model + real_model: this.model, + } + }, + + created() { + if (this.locale !== 'en') { + const lang = require(`flatpickr/dist/l10n/${this.locale}.js`).default[this.locale]; + this.config.locale = lang; } }, diff --git a/resources/views/banking/reconciliations/create.blade.php b/resources/views/banking/reconciliations/create.blade.php index 1e170db8f..7b148a1ff 100644 --- a/resources/views/banking/reconciliations/create.blade.php +++ b/resources/views/banking/reconciliations/create.blade.php @@ -16,9 +16,9 @@
- {{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('started_at', Date::now()->firstOfMonth()->toDateString()), 'col-xl-3') }} + {{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('started_at', Date::now()->firstOfMonth()->toDateString()), 'col-xl-3') }} - {{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('ended_at', Date::now()->endOfMonth()->toDateString()), 'col-xl-3') }} + {{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('ended_at', Date::now()->endOfMonth()->toDateString()), 'col-xl-3') }} {{ Form::moneyGroup('closing_balance', trans('reconciliations.closing_balance'), 'balance-scale', ['required' => 'required', 'autofocus' => 'autofocus', 'currency' => $currency, 'dynamic-currency' => 'currency', 'input' => 'onCalculate'], request('closing_balance', 0.00), 'col-xl-2') }} diff --git a/resources/views/banking/transfers/create.blade.php b/resources/views/banking/transfers/create.blade.php index 3a01d0f3c..bee9f75b2 100644 --- a/resources/views/banking/transfers/create.blade.php +++ b/resources/views/banking/transfers/create.blade.php @@ -23,7 +23,7 @@ {{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], 0) }} - {{ Form::dateGroup('transferred_at', trans('general.date'), 'calendar', ['id' => 'transferred_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::now()->toDateString()) }} + {{ Form::dateGroup('transferred_at', trans('general.date'), 'calendar', ['id' => 'transferred_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::now()->toDateString()) }} {{ Form::textareaGroup('description', trans('general.description')) }} diff --git a/resources/views/banking/transfers/edit.blade.php b/resources/views/banking/transfers/edit.blade.php index 722f762a1..96250b9a4 100644 --- a/resources/views/banking/transfers/edit.blade.php +++ b/resources/views/banking/transfers/edit.blade.php @@ -24,7 +24,7 @@ {{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], $transfer->amount) }} - {{ Form::dateGroup('transferred_at', trans('general.date'), 'calendar', ['id' => 'transferred_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::parse($transfer->transferred_at)->toDateString()) }} + {{ Form::dateGroup('transferred_at', trans('general.date'), 'calendar', ['id' => 'transferred_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::parse($transfer->transferred_at)->toDateString()) }} {{ Form::textareaGroup('description', trans('general.description')) }} diff --git a/resources/views/components/documents/form/metadata.blade.php b/resources/views/components/documents/form/metadata.blade.php index be7e1a753..b8f548fb1 100644 --- a/resources/views/components/documents/form/metadata.blade.php +++ b/resources/views/components/documents/form/metadata.blade.php @@ -22,7 +22,7 @@
@if (!$hideIssuedAt) - {{ Form::dateGroup('issued_at', trans($textIssuedAt), 'calendar', ['id' => 'issued_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], $issuedAt) }} + {{ Form::dateGroup('issued_at', trans($textIssuedAt), 'calendar', ['id' => 'issued_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], $issuedAt) }} @endif @if (!$hideDocumentNumber) @@ -30,7 +30,7 @@ @endif @if (!$hideDueAt) - {{ Form::dateGroup('due_at', trans($textDueAt), 'calendar', ['id' => 'due_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], $dueAt) }} + {{ Form::dateGroup('due_at', trans($textDueAt), 'calendar', ['id' => 'due_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], $dueAt) }} @else {{ Form::hidden('due_at', old('issued_at', $issuedAt), ['id' => 'due_at', 'v-model' => 'form.issued_at']) }} @endif diff --git a/resources/views/components/search-string.blade.php b/resources/views/components/search-string.blade.php index bf4d9d317..23101ab01 100644 --- a/resources/views/components/search-string.blade.php +++ b/resources/views/components/search-string.blade.php @@ -10,8 +10,8 @@ :date-config="{ allowInput: true, altInput: true, - altFormat: '{{ $date_format }}', - dateFormat: '{{ $date_format }}', + altFormat: '{{ company_date_format() }}', + dateFormat: '{{ company_date_format() }}', @if (!empty($attributes['min-date'])) minDate: {{ $attributes['min-date'] }} @endif diff --git a/resources/views/partials/form/date_group.blade.php b/resources/views/partials/form/date_group.blade.php index 150388039..8603b9c1a 100644 --- a/resources/views/partials/form/date_group.blade.php +++ b/resources/views/partials/form/date_group.blade.php @@ -40,6 +40,8 @@ maxDate: {{ $attributes['max-date'] }} @endif }" + + locale="{{ language()->getShortCode() }}" @if (!empty($attributes['v-model'])) @interface="form.errors.clear('{{ $attributes['v-model'] }}'); {{ $attributes['v-model'] . ' = $event' }}" diff --git a/resources/views/partials/form/date_time_group.blade.php b/resources/views/partials/form/date_time_group.blade.php index fe4881e87..43c1dcac3 100644 --- a/resources/views/partials/form/date_time_group.blade.php +++ b/resources/views/partials/form/date_time_group.blade.php @@ -43,6 +43,8 @@ maxDate: {{ $attributes['max-date'] }} @endif }" + + locale="{{ language()->getShortCode() }}" @if (!empty($attributes['v-model'])) @interface="form.errors.clear('{{ $attributes['v-model'] }}'); {{ $attributes['v-model'] . ' = $event' }}" diff --git a/resources/views/purchases/payments/create.blade.php b/resources/views/purchases/payments/create.blade.php index b9cc329c4..3b939f975 100644 --- a/resources/views/purchases/payments/create.blade.php +++ b/resources/views/purchases/payments/create.blade.php @@ -17,7 +17,7 @@
- {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request()->get('paid_at', Date::now()->toDateString())) }} + {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request()->get('paid_at', Date::now()->toDateString())) }} {!! Form::hidden('currency_code', $account_currency_code, ['id' => 'currency_code', 'class' => 'form-control', 'required' => 'required']) !!} {!! Form::hidden('currency_rate', '1', ['id' => 'currency_rate']) !!} diff --git a/resources/views/purchases/payments/edit.blade.php b/resources/views/purchases/payments/edit.blade.php index 933992f2b..09d043d85 100644 --- a/resources/views/purchases/payments/edit.blade.php +++ b/resources/views/purchases/payments/edit.blade.php @@ -36,7 +36,7 @@
- {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::parse($payment->paid_at)->toDateString()) }} + {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::parse($payment->paid_at)->toDateString()) }} {!! Form::hidden('currency_code', $payment->currency_code, ['id' => 'currency_code', 'class' => 'form-control', 'required' => 'required']) !!} {!! Form::hidden('currency_rate', null, ['id' => 'currency_rate']) !!} diff --git a/resources/views/sales/revenues/create.blade.php b/resources/views/sales/revenues/create.blade.php index d3bd3a409..5c3cbe51e 100644 --- a/resources/views/sales/revenues/create.blade.php +++ b/resources/views/sales/revenues/create.blade.php @@ -17,7 +17,7 @@
- {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request()->get('paid_at', Date::now()->toDateString())) }} + {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request()->get('paid_at', Date::now()->toDateString())) }} {!! Form::hidden('currency_code', $account_currency_code, ['id' => 'currency_code', 'class' => 'form-control', 'required' => 'required']) !!} {!! Form::hidden('currency_rate', '1', ['id' => 'currency_rate']) !!} diff --git a/resources/views/sales/revenues/edit.blade.php b/resources/views/sales/revenues/edit.blade.php index 8932d5570..3f5c5d696 100644 --- a/resources/views/sales/revenues/edit.blade.php +++ b/resources/views/sales/revenues/edit.blade.php @@ -36,7 +36,7 @@
- {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::parse($revenue->paid_at)->toDateString()) }} + {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::parse($revenue->paid_at)->toDateString()) }} {!! Form::hidden('currency_code', $revenue->currency_code, ['id' => 'currency_code', 'class' => 'form-control', 'required' => 'required']) !!} {!! Form::hidden('currency_rate', null, ['id' => 'currency_rate']) !!}