mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on replacing variables for templates
This commit is contained in:
parent
e4f33b06ba
commit
019cc09dbb
@ -13,6 +13,7 @@ namespace App\Models;
|
||||
|
||||
use App\Models\Currency;
|
||||
use App\Models\Filterable;
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -247,4 +248,92 @@ class Invoice extends BaseModel
|
||||
return $this->settings->design ?: 'pdf.design1';
|
||||
}
|
||||
|
||||
public function makeInvoiceValues()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$data['invoice'] = ;
|
||||
$data['invoice_date'] = $this->invoice_date;
|
||||
// $data['due_date'] = ;
|
||||
$data['invoice_number'] = $this->invoice_number;
|
||||
$data['po_number'] = $this->po_number;
|
||||
// $data['discount'] = ;
|
||||
// $data['taxes'] = ;
|
||||
// $data['tax'] = ;
|
||||
// $data['item'] = ;
|
||||
// $data['description'] = ;
|
||||
// $data['unit_cost'] = ;
|
||||
// $data['quantity'] = ;
|
||||
// $data['line_total'] = ;
|
||||
// $data['subtotal'] = ;
|
||||
// $data['paid_to_date'] = ;
|
||||
$data['balance_due'] = Number::formatMoney($this->balance, $this->client->currency, $this->client->country, $this->client->settings);
|
||||
$data['partial_due'] = Number::formatMoney($this->partial, $this->client->currency, $this->client->country, $this->client->settings);
|
||||
// $data['terms'] = $this->terms;
|
||||
// $data['your_invoice'] = ;
|
||||
// $data['quote'] = ;
|
||||
// $data['your_quote'] = ;
|
||||
// $data['quote_date'] = ;
|
||||
// $data['quote_number'] = ;
|
||||
$data['total'] = Number::formatMoney($this->amount, $this->client->currency, $this->client->country, $this->client->settings);
|
||||
// $data['invoice_issued_to'] = ;
|
||||
// $data['quote_issued_to'] = ;
|
||||
// $data['rate'] = ;
|
||||
// $data['hours'] = ;
|
||||
// $data['balance'] = ;
|
||||
// $data['from'] = ;
|
||||
// $data['to'] = ;
|
||||
// $data['invoice_to'] = ;
|
||||
// $data['quote_to'] = ;
|
||||
// $data['details'] = ;
|
||||
$data['invoice_no'] = $this->invoice_number;
|
||||
// $data['quote_no'] = ;
|
||||
// $data['valid_until'] = ;
|
||||
$data['client_name'] = $this->present()->clientName();
|
||||
$data['address1'] = $this->client->address1;
|
||||
$data['address2'] = $this->client->address2;
|
||||
$data['id_number'] = $this->client->id_number;
|
||||
$data['vat_number'] = $this->client->vat_number;
|
||||
$data['city_state_postal'] = ;
|
||||
$data['postal_city_state'] = ;
|
||||
$data['country'] = ;
|
||||
$data['email'] = ;
|
||||
$data['contact_nae'] = ;
|
||||
$data['company_name'] = ;
|
||||
$data['website'] = ;
|
||||
$data['phone'] = ;
|
||||
$data['blank'] = ;
|
||||
$data['surcharge'] = ;
|
||||
$data['tax_invoice'] =
|
||||
$data['tax_quote'] =
|
||||
$data['statement'] = ;
|
||||
$data['statement_date'] = ;
|
||||
$data['your_statement'] = ;
|
||||
$data['statement_issued_to'] = ;
|
||||
$data['statement_to'] = ;
|
||||
$data['credit_note'] = ;
|
||||
$data['credit_date'] = ;
|
||||
$data['credit_number'] = ;
|
||||
$data['credit_issued_to'] = ;
|
||||
$data['credit_to'] = ;
|
||||
$data['your_credit'] = ;
|
||||
$data['work_phone'] = ;
|
||||
$data['invoice_total'] = ;
|
||||
$data['outstanding'] = ;
|
||||
$data['invoice_due_date'] = ;
|
||||
$data['quote_due_date'] = ;
|
||||
$data['service'] = ;
|
||||
$data['product_key'] = ;
|
||||
$data['unit_cost'] = ;
|
||||
$data['custom_value1'] = ;
|
||||
$data['custom_value2'] = ;
|
||||
$data['delivery_note'] = ;
|
||||
$data['date'] = ;
|
||||
$data['method'] = ;
|
||||
$data['payment_date'] = ;
|
||||
$data['reference'] = ;
|
||||
$data['amount'] = ;
|
||||
$data['amount_paid'] =;
|
||||
}
|
||||
|
||||
}
|
@ -36,28 +36,30 @@ class InvoicePresenter extends EntityPresenter
|
||||
return $this->client->present()->address();
|
||||
}
|
||||
|
||||
public function shipping_address()
|
||||
public function shippingAddress()
|
||||
{
|
||||
return $this->client->present()->shipping_address();
|
||||
}
|
||||
|
||||
public function company_logo()
|
||||
public function companyLogo()
|
||||
{
|
||||
return $this->company->logo;
|
||||
}
|
||||
|
||||
public function client_logo()
|
||||
public function clientLogo()
|
||||
{
|
||||
return $this->client->logo;
|
||||
}
|
||||
|
||||
public function company_name()
|
||||
public function companyName()
|
||||
{
|
||||
return $this->company->present()->name()
|
||||
}
|
||||
|
||||
public function company_address()
|
||||
public function companyAddress()
|
||||
{
|
||||
return $this->company->present()->address();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
153
app/Utils/Traits/MakesInvoiceLabels.php
Normal file
153
app/Utils/Traits/MakesInvoiceLabels.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?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\Utils\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MakesInvoiceLabels
|
||||
* @package App\Utils\Traits
|
||||
*/
|
||||
trait MakesInvoiceLabels
|
||||
{
|
||||
private static $labels = [
|
||||
'invoice',
|
||||
'invoice_date',
|
||||
'due_date',
|
||||
'invoice_number',
|
||||
'po_number',
|
||||
'discount',
|
||||
'taxes',
|
||||
'tax',
|
||||
'item',
|
||||
'description',
|
||||
'unit_cost',
|
||||
'quantity',
|
||||
'line_total',
|
||||
'subtotal',
|
||||
'paid_to_date',
|
||||
'balance_due',
|
||||
'partial_due',
|
||||
'terms',
|
||||
'your_invoice',
|
||||
'quote',
|
||||
'your_quote',
|
||||
'quote_date',
|
||||
'quote_number',
|
||||
'total',
|
||||
'invoice_issued_to',
|
||||
'quote_issued_to',
|
||||
'rate',
|
||||
'hours',
|
||||
'balance',
|
||||
'from',
|
||||
'to',
|
||||
'invoice_to',
|
||||
'quote_to',
|
||||
'details',
|
||||
'invoice_no',
|
||||
'quote_no',
|
||||
'valid_until',
|
||||
'client_name',
|
||||
'address1',
|
||||
'address2',
|
||||
'id_number',
|
||||
'vat_number',
|
||||
'city_state_postal',
|
||||
'postal_city_state',
|
||||
'country',
|
||||
'email',
|
||||
'contact_name',
|
||||
'company_name',
|
||||
'website',
|
||||
'phone',
|
||||
'blank',
|
||||
'surcharge',
|
||||
'tax_invoice',
|
||||
'tax_quote',
|
||||
'statement',
|
||||
'statement_date',
|
||||
'your_statement',
|
||||
'statement_issued_to',
|
||||
'statement_to',
|
||||
'credit_note',
|
||||
'credit_date',
|
||||
'credit_number',
|
||||
'credit_issued_to',
|
||||
'credit_to',
|
||||
'your_credit',
|
||||
'work_phone',
|
||||
'invoice_total',
|
||||
'outstanding',
|
||||
'invoice_due_date',
|
||||
'quote_due_date',
|
||||
'service',
|
||||
'product_key',
|
||||
'unit_cost',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
'delivery_note',
|
||||
'date',
|
||||
'method',
|
||||
'payment_date',
|
||||
'reference',
|
||||
'amount',
|
||||
'amount_paid',
|
||||
];
|
||||
|
||||
public function invoice_number_label()
|
||||
{
|
||||
return ctrans('texts.invoice_number');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a single translated string which
|
||||
* has been appended with _label
|
||||
*
|
||||
* Used for design templates where we need both
|
||||
* the value and its _label
|
||||
*
|
||||
* ie: $invoice_number and $invoice_number_label
|
||||
*
|
||||
*
|
||||
* @param string $label The label to translate
|
||||
*
|
||||
* @return string The translated label
|
||||
*/
|
||||
public function makeLabel(string $label) :string
|
||||
{
|
||||
|
||||
if (in_array(str_replace("_label", "", $label), self::$labels))
|
||||
{
|
||||
return ctrans('texts.' . $label);
|
||||
}
|
||||
else
|
||||
return 'label does not exist';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates and translates all labels
|
||||
*
|
||||
* @return array returns an array of keyed labels (appended with _label)
|
||||
*/
|
||||
public function makeLabels() : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach(self::$labels as $label)
|
||||
$data[][$label . '_label'] = ctrans('texts'.$label);
|
||||
|
||||
return $data;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user