mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Working on Formatting data in client timezone
This commit is contained in:
parent
0af0d9786d
commit
e5b60195d8
@ -33,8 +33,8 @@ class ClientSettings extends BaseSettings
|
||||
* Settings which also have a parent company setting
|
||||
*/
|
||||
public $timezone_id;
|
||||
public $date_format_id;
|
||||
public $datetime_format_id;
|
||||
public $date_format;
|
||||
public $datetime_format;
|
||||
public $military_time;
|
||||
public $start_of_week;
|
||||
public $financial_year_start;
|
||||
|
@ -20,8 +20,8 @@ class CompanySettings extends BaseSettings
|
||||
{
|
||||
|
||||
public $timezone_id;
|
||||
public $date_format_id;
|
||||
public $datetime_format_id;
|
||||
public $date_format;
|
||||
public $datetime_format;
|
||||
public $military_time;
|
||||
public $start_of_week;
|
||||
public $financial_year_start;
|
||||
@ -139,9 +139,9 @@ class CompanySettings extends BaseSettings
|
||||
'currency_id' => config('ninja.i18n.currency_id'),
|
||||
'precision' => 2,
|
||||
'payment_terms' => config('ninja.i18n.payment_terms'),
|
||||
'datetime_format_id' => config('ninja.i18n.datetime_format'),
|
||||
'datetime_format' => config('ninja.i18n.datetime_format'),
|
||||
'military_time' => config('ninja.i18n.military_time'),
|
||||
'date_format_id' => config('ninja.i18n.date_format'),
|
||||
'date_format' => config('ninja.i18n.date_format'),
|
||||
'start_of_week' => config('ninja.i18n.start_of_week'),
|
||||
'financial_year_start' => config('ninja.i18n.financial_year_start'),
|
||||
'default_task_rate' => 0,
|
||||
|
64
app/DataMapper/Statics.php
Normal file
64
app/DataMapper/Statics.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\DataMapper;
|
||||
|
||||
/**
|
||||
* Statics
|
||||
*/
|
||||
class Statics
|
||||
{
|
||||
/**
|
||||
* Date format types
|
||||
* @var array
|
||||
*/
|
||||
public static $date = [
|
||||
['format' => 'd/M/Y', 'picker_format' => 'dd/M/yyyy', 'format_moment' => 'DD/MMM/YYYY', 'format_dart' => 'dd/MMM/yyyy'],
|
||||
['format' => 'd-M-Y', 'picker_format' => 'dd-M-yyyy', 'format_moment' => 'DD-MMM-YYYY', 'format_dart' => 'dd-MMM-yyyy'],
|
||||
['format' => 'd/F/Y', 'picker_format' => 'dd/MM/yyyy', 'format_moment' => 'DD/MMMM/YYYY', 'format_dart' => 'dd/MMMM/yyyy'],
|
||||
['format' => 'd-F-Y', 'picker_format' => 'dd-MM-yyyy', 'format_moment' => 'DD-MMMM-YYYY', 'format_dart' => 'dd-MMMM-yyyy'],
|
||||
['format' => 'M j, Y', 'picker_format' => 'M d, yyyy', 'format_moment' => 'MMM D, YYYY', 'format_dart' => 'MMM d, yyyy'],
|
||||
['format' => 'F j, Y', 'picker_format' => 'MM d, yyyy', 'format_moment' => 'MMMM D, YYYY', 'format_dart' => 'MMMM d, yyyy'],
|
||||
['format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy', 'format_moment' => 'ddd MMM Do, YYYY', 'format_dart' => 'EEE MMM d, yyyy'],
|
||||
['format' => 'Y-m-d', 'picker_format' => 'yyyy-mm-dd', 'format_moment' => 'YYYY-MM-DD', 'format_dart' => 'yyyy-MM-dd'],
|
||||
['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy', 'format_moment' => 'DD-MM-YYYY', 'format_dart' => 'dd-MM-yyyy'],
|
||||
['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy', 'format_moment' => 'MM/DD/YYYY', 'format_dart' => 'MM/dd/yyyy'],
|
||||
['format' => 'd.m.Y', 'picker_format' => 'dd.mm.yyyy', 'format_moment' => 'D.MM.YYYY', 'format_dart' => 'dd.MM.yyyy'],
|
||||
['format' => 'j. M. Y', 'picker_format' => 'd. M. yyyy', 'format_moment' => 'DD. MMM. YYYY', 'format_dart' => 'd. MMM. yyyy'],
|
||||
['format' => 'j. F Y', 'picker_format' => 'd. MM yyyy', 'format_moment' => 'DD. MMMM YYYY', 'format_dart' => 'd. MMMM yyyy'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Date Time Format types
|
||||
* @var array
|
||||
*/
|
||||
public static $date_time = [
|
||||
['format' => 'd/M/Y g:i a', 'format_moment' => 'DD/MMM/YYYY h:mm:ss a', 'format_dart' => 'dd/MMM/yyyy h:mm a'],
|
||||
['format' => 'd-M-Y g:i a', 'format_moment' => 'DD-MMM-YYYY h:mm:ss a', 'format_dart' => 'dd-MMM-yyyy h:mm a'],
|
||||
['format' => 'd/F/Y g:i a', 'format_moment' => 'DD/MMMM/YYYY h:mm:ss a', 'format_dart' => 'dd/MMMM/yyyy h:mm a'],
|
||||
['format' => 'd-F-Y g:i a', 'format_moment' => 'DD-MMMM-YYYY h:mm:ss a', 'format_dart' => 'dd-MMMM-yyyy h:mm a'],
|
||||
['format' => 'M j, Y g:i a', 'format_moment' => 'MMM D, YYYY h:mm:ss a', 'format_dart' => 'MMM d, yyyy h:mm a'],
|
||||
['format' => 'F j, Y g:i a', 'format_moment' => 'MMMM D, YYYY h:mm:ss a', 'format_dart' => 'MMMM d, yyyy h:mm a'],
|
||||
['format' => 'D M jS, Y g:i a', 'format_moment' => 'ddd MMM Do, YYYY h:mm:ss a', 'format_dart' => 'EEE MMM d, yyyy h:mm a'],
|
||||
['format' => 'Y-m-d g:i a', 'format_moment' => 'YYYY-MM-DD h:mm:ss a', 'format_dart' => 'yyyy-MM-dd h:mm a'],
|
||||
['format' => 'd-m-Y g:i a', 'format_moment' => 'DD-MM-YYYY h:mm:ss a', 'format_dart' => 'dd-MM-yyyy h:mm a'],
|
||||
['format' => 'm/d/Y g:i a', 'format_moment' => 'MM/DD/YYYY h:mm:ss a', 'format_dart' => 'MM/dd/yyyy h:mm a'],
|
||||
['format' => 'd.m.Y g:i a', 'format_moment' => 'D.MM.YYYY h:mm:ss a', 'format_dart' => 'dd.MM.yyyy h:mm a'],
|
||||
['format' => 'j. M. Y g:i a', 'format_moment' => 'DD. MMM. YYYY h:mm:ss a', 'format_dart' => 'd. MMM. yyyy h:mm a'],
|
||||
['format' => 'j. F Y g:i a', 'format_moment' => 'DD. MMMM YYYY h:mm:ss a', 'format_dart' => 'd. MMMM yyyy h:mm a'],
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -57,7 +57,9 @@ class InvoiceController extends Controller
|
||||
return Invoice::badgeForStatus($invoice->status);
|
||||
})
|
||||
->editColumn('invoice_date', function ($invoice){
|
||||
return $this->createClientDate($invoice->due_date, $invoice->client->timezone()->name)->format('MM-dd-YYYY');
|
||||
return $this->createClientDate($invoice->invoice_date, $invoice->client->timezone()->name)->format($invoice->client->date_format());
|
||||
})->editColumn('due_date', function ($invoice){
|
||||
return $this->createClientDate($invoice->due_date, $invoice->client->timezone()->name)->format($invoice->client->date_format());
|
||||
})
|
||||
->rawColumns(['checkbox', 'action', 'status_id'])
|
||||
->make(true);
|
||||
|
@ -121,6 +121,16 @@ class Client extends BaseModel
|
||||
return Timezone::find($this->getMergedSettings()->timezone_id);
|
||||
}
|
||||
|
||||
public function date_format()
|
||||
{
|
||||
return $this->getMergedSettings()->date_format;
|
||||
}
|
||||
|
||||
public function datetime_format()
|
||||
{
|
||||
return $this->getMergedSettings()->datetime_format;
|
||||
}
|
||||
|
||||
public function getMergedSettings()
|
||||
{
|
||||
return ClientSettings::buildClientSettings(new CompanySettings($this->company->settings), new ClientSettings($this->settings));
|
||||
|
Loading…
Reference in New Issue
Block a user