2015-04-20 16:47:14 +02:00
|
|
|
<?php namespace app\Models;
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2015-03-27 06:02:19 +01:00
|
|
|
use Eloquent;
|
2015-04-20 16:47:14 +02:00
|
|
|
use Auth;
|
2015-07-28 09:00:00 +02:00
|
|
|
use Cache;
|
2015-07-21 20:51:56 +02:00
|
|
|
use App\Models\InvoiceDesign;
|
2015-03-27 06:02:19 +01:00
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
class InvoiceDesign extends Eloquent
|
|
|
|
{
|
|
|
|
public $timestamps = false;
|
2015-04-20 16:47:14 +02:00
|
|
|
|
2015-07-28 09:00:00 +02:00
|
|
|
public static function getDesigns($forceUtf8 = false)
|
2015-04-20 16:47:14 +02:00
|
|
|
{
|
2015-07-21 20:51:56 +02:00
|
|
|
$account = Auth::user()->account;
|
2015-07-28 09:00:00 +02:00
|
|
|
$designs = Cache::get('invoiceDesigns');
|
|
|
|
$utf8 = $forceUtf8 || $account->utf8_invoices;
|
2015-04-20 16:47:14 +02:00
|
|
|
|
2015-07-21 20:51:56 +02:00
|
|
|
foreach ($designs as $design) {
|
2015-07-28 09:00:00 +02:00
|
|
|
if ($design->id > Auth::user()->maxInvoiceDesignId()) {
|
|
|
|
$designs->pull($design->id);
|
2015-04-20 16:47:14 +02:00
|
|
|
}
|
2015-07-28 09:00:00 +02:00
|
|
|
|
|
|
|
if ($utf8) {
|
|
|
|
$design->javascript = $design->pdfmake;
|
|
|
|
}
|
|
|
|
$design->pdfmake = null;
|
|
|
|
|
2015-07-21 20:51:56 +02:00
|
|
|
if ($design->id == CUSTOM_DESIGN) {
|
2015-07-28 09:00:00 +02:00
|
|
|
if ($utf8 && $account->custom_design) {
|
2015-07-21 20:51:56 +02:00
|
|
|
$design->javascript = $account->custom_design;
|
|
|
|
} else {
|
|
|
|
$designs->pop();
|
|
|
|
}
|
|
|
|
}
|
2015-04-13 11:23:43 +02:00
|
|
|
}
|
2015-07-28 09:00:00 +02:00
|
|
|
|
2015-04-20 16:47:14 +02:00
|
|
|
return $designs;
|
2015-04-13 11:23:43 +02:00
|
|
|
}
|
2015-07-28 09:00:00 +02:00
|
|
|
}
|