1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge pull request #4650 from turbo124/v5-develop

Add $entity.datetime variable for invoice designs
This commit is contained in:
David Bomba 2021-01-08 13:16:47 +11:00 committed by GitHub
commit bb8f628bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -113,6 +113,11 @@ class HtmlEngine
$data['$invoice.due_date'] = &$data['$due_date'];
$data['$invoice.number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
$data['$invoice.po_number'] = ['value' => $this->entity->po_number ?: ' ', 'label' => ctrans('texts.po_number')];
$data['$entity.datetime'] = ['value' => $this->formatDatetime($this->entity->created_at, $this->entity->client->date_format()), 'label' => ctrans('texts.date')];
$data['$invoice.datetime'] = &$data['$entity.datetime'];
$data['$quote.datetime'] = &$data['$entity.datetime'];
$data['$credit.datetime'] = &$data['$entity.datetime'];
// $data['$line_taxes'] = ['value' => $this->makeLineTaxes() ?: ' ', 'label' => ctrans('texts.taxes')];
// $data['$invoice.line_taxes'] = &$data['$line_taxes'];

View File

@ -71,6 +71,17 @@ trait MakesDates
return $date->format($format);
}
/**
* Formats a datedate.
* @param Carbon|string $date Carbon object or date string
* @param string $format The date display format
* @return string The formatted date
*/
public function formatDatetime($date, string $format) :string
{
return Carbon::createFromTimestamp($date)->format($format . " g:i a");
}
/**
* Formats a date.
* @param Carbon/String $date Carbon object or date string