mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Localization of client not applied to :DATE variable #1565
This commit is contained in:
parent
1d2c5f5b59
commit
a596561f5f
@ -690,7 +690,7 @@ class Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function processVariables($str)
|
public static function processVariables($str, $client = false)
|
||||||
{
|
{
|
||||||
if (! $str) {
|
if (! $str) {
|
||||||
return '';
|
return '';
|
||||||
@ -718,7 +718,8 @@ class Utils
|
|||||||
$offset = intval($minArray[1]) * -1;
|
$offset = intval($minArray[1]) * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$val = self::getDatePart($variable, $offset);
|
$locale = $client && $client->language_id ? $client->language->locale : null;
|
||||||
|
$val = self::getDatePart($variable, $offset, $locale);
|
||||||
$str = str_replace($match, $val, $str);
|
$str = str_replace($match, $val, $str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -726,11 +727,11 @@ class Utils
|
|||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getDatePart($part, $offset)
|
private static function getDatePart($part, $offset, $locale)
|
||||||
{
|
{
|
||||||
$offset = intval($offset);
|
$offset = intval($offset);
|
||||||
if ($part == 'MONTH') {
|
if ($part == 'MONTH') {
|
||||||
return self::getMonth($offset);
|
return self::getMonth($offset, $locale);
|
||||||
} elseif ($part == 'QUARTER') {
|
} elseif ($part == 'QUARTER') {
|
||||||
return self::getQuarter($offset);
|
return self::getQuarter($offset);
|
||||||
} elseif ($part == 'YEAR') {
|
} elseif ($part == 'YEAR') {
|
||||||
@ -751,7 +752,7 @@ class Utils
|
|||||||
return $months;
|
return $months;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getMonth($offset)
|
private static function getMonth($offset, $locale)
|
||||||
{
|
{
|
||||||
$months = static::$months;
|
$months = static::$months;
|
||||||
$month = intval(date('n')) - 1;
|
$month = intval(date('n')) - 1;
|
||||||
@ -763,7 +764,7 @@ class Utils
|
|||||||
$month += 12;
|
$month += 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
return trans('texts.' . $months[$month]);
|
return trans('texts.' . $months[$month], [], null, $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getQuarter($offset)
|
private static function getQuarter($offset)
|
||||||
|
@ -996,8 +996,9 @@ class InvoiceRepository extends BaseRepository
|
|||||||
public function createRecurringInvoice(Invoice $recurInvoice)
|
public function createRecurringInvoice(Invoice $recurInvoice)
|
||||||
{
|
{
|
||||||
$recurInvoice->load('account.timezone', 'invoice_items', 'client', 'user');
|
$recurInvoice->load('account.timezone', 'invoice_items', 'client', 'user');
|
||||||
|
$client = $recurInvoice->client;
|
||||||
|
|
||||||
if ($recurInvoice->client->deleted_at) {
|
if ($client->deleted_at) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1020,9 +1021,9 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$invoice->invoice_date = date_create()->format('Y-m-d');
|
$invoice->invoice_date = date_create()->format('Y-m-d');
|
||||||
$invoice->discount = $recurInvoice->discount;
|
$invoice->discount = $recurInvoice->discount;
|
||||||
$invoice->po_number = $recurInvoice->po_number;
|
$invoice->po_number = $recurInvoice->po_number;
|
||||||
$invoice->public_notes = Utils::processVariables($recurInvoice->public_notes);
|
$invoice->public_notes = Utils::processVariables($recurInvoice->public_notes, $client);
|
||||||
$invoice->terms = Utils::processVariables($recurInvoice->terms ?: $recurInvoice->account->invoice_terms);
|
$invoice->terms = Utils::processVariables($recurInvoice->terms ?: $recurInvoice->account->invoice_terms, $client);
|
||||||
$invoice->invoice_footer = Utils::processVariables($recurInvoice->invoice_footer ?: $recurInvoice->account->invoice_footer);
|
$invoice->invoice_footer = Utils::processVariables($recurInvoice->invoice_footer ?: $recurInvoice->account->invoice_footer, $client);
|
||||||
$invoice->tax_name1 = $recurInvoice->tax_name1;
|
$invoice->tax_name1 = $recurInvoice->tax_name1;
|
||||||
$invoice->tax_rate1 = $recurInvoice->tax_rate1;
|
$invoice->tax_rate1 = $recurInvoice->tax_rate1;
|
||||||
$invoice->tax_name2 = $recurInvoice->tax_name2;
|
$invoice->tax_name2 = $recurInvoice->tax_name2;
|
||||||
@ -1032,8 +1033,8 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$invoice->custom_value2 = $recurInvoice->custom_value2 ?: 0;
|
$invoice->custom_value2 = $recurInvoice->custom_value2 ?: 0;
|
||||||
$invoice->custom_taxes1 = $recurInvoice->custom_taxes1 ?: 0;
|
$invoice->custom_taxes1 = $recurInvoice->custom_taxes1 ?: 0;
|
||||||
$invoice->custom_taxes2 = $recurInvoice->custom_taxes2 ?: 0;
|
$invoice->custom_taxes2 = $recurInvoice->custom_taxes2 ?: 0;
|
||||||
$invoice->custom_text_value1 = Utils::processVariables($recurInvoice->custom_text_value1);
|
$invoice->custom_text_value1 = Utils::processVariables($recurInvoice->custom_text_value1, $client);
|
||||||
$invoice->custom_text_value2 = Utils::processVariables($recurInvoice->custom_text_value2);
|
$invoice->custom_text_value2 = Utils::processVariables($recurInvoice->custom_text_value2, $client);
|
||||||
$invoice->is_amount_discount = $recurInvoice->is_amount_discount;
|
$invoice->is_amount_discount = $recurInvoice->is_amount_discount;
|
||||||
$invoice->due_date = $recurInvoice->getDueDate();
|
$invoice->due_date = $recurInvoice->getDueDate();
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
@ -1043,14 +1044,14 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$item->product_id = $recurItem->product_id;
|
$item->product_id = $recurItem->product_id;
|
||||||
$item->qty = $recurItem->qty;
|
$item->qty = $recurItem->qty;
|
||||||
$item->cost = $recurItem->cost;
|
$item->cost = $recurItem->cost;
|
||||||
$item->notes = Utils::processVariables($recurItem->notes);
|
$item->notes = Utils::processVariables($recurItem->notes, $client);
|
||||||
$item->product_key = Utils::processVariables($recurItem->product_key);
|
$item->product_key = Utils::processVariables($recurItem->product_key, $client);
|
||||||
$item->tax_name1 = $recurItem->tax_name1;
|
$item->tax_name1 = $recurItem->tax_name1;
|
||||||
$item->tax_rate1 = $recurItem->tax_rate1;
|
$item->tax_rate1 = $recurItem->tax_rate1;
|
||||||
$item->tax_name2 = $recurItem->tax_name2;
|
$item->tax_name2 = $recurItem->tax_name2;
|
||||||
$item->tax_rate2 = $recurItem->tax_rate2;
|
$item->tax_rate2 = $recurItem->tax_rate2;
|
||||||
$item->custom_value1 = Utils::processVariables($recurItem->custom_value1);
|
$item->custom_value1 = Utils::processVariables($recurItem->custom_value1, $client);
|
||||||
$item->custom_value2 = Utils::processVariables($recurItem->custom_value2);
|
$item->custom_value2 = Utils::processVariables($recurItem->custom_value2, $client);
|
||||||
$invoice->invoice_items()->save($item);
|
$invoice->invoice_items()->save($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user