mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-12-02 20:55:29 -05:00
76 lines
2.1 KiB
PHP
76 lines
2.1 KiB
PHP
<?php namespace App\Libraries\Skype;
|
|
|
|
use HTML;
|
|
use stdClass;
|
|
|
|
class InvoiceCard
|
|
{
|
|
public function __construct($invoice)
|
|
{
|
|
$this->contentType = 'application/vnd.microsoft.card.receipt';
|
|
$this->content = new stdClass;
|
|
$this->content->facts = [];
|
|
$this->content->items = [];
|
|
$this->content->buttons = [];
|
|
|
|
$this->setTitle('test');
|
|
|
|
$this->setTitle(trans('texts.invoice_for_client', [
|
|
'invoice' => link_to($invoice->getRoute(), $invoice->invoice_number),
|
|
'client' => link_to($invoice->client->getRoute(), $invoice->client->getDisplayName())
|
|
]));
|
|
|
|
$this->addFact(trans('texts.email'), HTML::mailto($invoice->client->contacts[0]->email)->toHtml());
|
|
|
|
if ($invoice->due_date) {
|
|
$this->addFact($invoice->present()->dueDateLabel, $invoice->present()->due_date);
|
|
}
|
|
|
|
if ($invoice->po_number) {
|
|
$this->addFact(trans('texts.po_number'), $invoice->po_number);
|
|
}
|
|
|
|
if ($invoice->discount) {
|
|
$this->addFact(trans('texts.discount'), $invoice->present()->discount);
|
|
}
|
|
|
|
foreach ($invoice->invoice_items as $item) {
|
|
$this->addItem($item, $invoice->account);
|
|
}
|
|
|
|
$this->setTotal($invoice->present()->requestedAmount);
|
|
|
|
$this->addButton('imBack', trans('texts.send_email'), 'send_email');
|
|
$this->addButton('imBack', trans('texts.download_pdf'), 'download_pdf');
|
|
}
|
|
|
|
public function setTitle($title)
|
|
{
|
|
$this->content->title = $title;
|
|
}
|
|
|
|
public function setTotal($value)
|
|
{
|
|
$this->content->total = $value;
|
|
}
|
|
|
|
public function addFact($key, $value)
|
|
{
|
|
$fact = new stdClass;
|
|
$fact->key = $key;
|
|
$fact->value = $value;
|
|
|
|
$this->content->facts[] = $fact;
|
|
}
|
|
|
|
public function addItem($item, $account)
|
|
{
|
|
$this->content->items[] = new InvoiceItemCard($item, $account);
|
|
}
|
|
|
|
public function addButton($type, $title, $value)
|
|
{
|
|
$this->content->buttons[] = new ButtonCard($type, $title, $value);
|
|
}
|
|
}
|