mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Moved invoice design files
This commit is contained in:
parent
76a53ed5dc
commit
ba8419356d
9
.gitignore
vendored
9
.gitignore
vendored
@ -28,11 +28,4 @@
|
||||
/.phpstorm.meta.php
|
||||
/_ide_helper.php
|
||||
/.idea
|
||||
/.project
|
||||
|
||||
/public/js/templates/business.js
|
||||
/public/js/templates/creative.js
|
||||
/public/js/templates/elegant.js
|
||||
/public/js/templates/hipster.js
|
||||
/public/js/templates/photo.js
|
||||
/public/js/templates/playful.js
|
||||
/.project
|
@ -233,7 +233,7 @@ class AccountController extends BaseController
|
||||
$data['invoice'] = $invoice;
|
||||
$data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
|
||||
$data['title'] = trans('texts.invoice_design');
|
||||
$data['invoiceDesigns'] = InvoiceDesign::availableDesigns($subSection == ACCOUNT_CUSTOMIZE_DESIGN);
|
||||
$data['invoiceDesigns'] = InvoiceDesign::getDesigns($subSection == ACCOUNT_CUSTOMIZE_DESIGN);
|
||||
|
||||
$design = false;
|
||||
foreach ($data['invoiceDesigns'] as $item) {
|
||||
|
@ -405,7 +405,7 @@ class InvoiceController extends BaseController
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'industries' => Cache::get('industries'),
|
||||
'invoiceDesigns' => InvoiceDesign::availableDesigns(),
|
||||
'invoiceDesigns' => InvoiceDesign::getDesigns(),
|
||||
'frequencies' => array(
|
||||
1 => 'Weekly',
|
||||
2 => 'Two weeks',
|
||||
@ -646,7 +646,7 @@ class InvoiceController extends BaseController
|
||||
'invoice' => $invoice,
|
||||
'versionsJson' => json_encode($versionsJson),
|
||||
'versionsSelect' => $versionsSelect,
|
||||
'invoiceDesigns' => InvoiceDesign::availableDesigns(),
|
||||
'invoiceDesigns' => InvoiceDesign::getDesigns(),
|
||||
];
|
||||
|
||||
return View::make('invoices.history', $data);
|
||||
|
@ -156,7 +156,7 @@ class QuoteController extends BaseController
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'industries' => Cache::get('industries'),
|
||||
'invoiceDesigns' => InvoiceDesign::availableDesigns(),
|
||||
'invoiceDesigns' => InvoiceDesign::getDesigns(),
|
||||
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
|
||||
];
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ class StartupCheck
|
||||
'paymentTerms' => 'App\Models\PaymentTerm',
|
||||
'paymentTypes' => 'App\Models\PaymentType',
|
||||
'countries' => 'App\Models\Country',
|
||||
'invoiceDesigns' => 'App\Models\InvoiceDesign',
|
||||
];
|
||||
foreach ($cachedTables as $name => $class) {
|
||||
if (Input::has('clear_cache')) {
|
||||
|
@ -439,6 +439,7 @@ function otrans($text)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Log all SQL queries to laravel.log
|
||||
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
|
||||
{
|
||||
@ -463,6 +464,8 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name)
|
||||
|
||||
Log::info($query, $data);
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
if (Auth::check() && Auth::user()->id === 1)
|
||||
|
@ -2,32 +2,38 @@
|
||||
|
||||
use Eloquent;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use App\Models\InvoiceDesign;
|
||||
|
||||
class InvoiceDesign extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
public function scopeAvailableDesigns($query, $utf8 = false)
|
||||
public static function getDesigns($forceUtf8 = false)
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$designs = $query->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
|
||||
$designs = Cache::get('invoiceDesigns');
|
||||
$utf8 = $forceUtf8 || $account->utf8_invoices;
|
||||
|
||||
foreach ($designs as $design) {
|
||||
$fileName = public_path(strtolower("js/templates/{$design->name}.js"));
|
||||
if (($utf8 || Auth::user()->account->utf8_invoices) && file_exists($fileName)) {
|
||||
$design->javascript = file_get_contents($fileName);
|
||||
if ($design->id > Auth::user()->maxInvoiceDesignId()) {
|
||||
$designs->pull($design->id);
|
||||
}
|
||||
|
||||
|
||||
if ($utf8) {
|
||||
$design->javascript = $design->pdfmake;
|
||||
}
|
||||
$design->pdfmake = null;
|
||||
|
||||
if ($design->id == CUSTOM_DESIGN) {
|
||||
if ($account->utf8_invoices && $account->custom_design) {
|
||||
if ($utf8 && $account->custom_design) {
|
||||
$design->javascript = $account->custom_design;
|
||||
} else {
|
||||
$designs->pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $designs;
|
||||
}
|
||||
}
|
||||
}
|
@ -73,6 +73,8 @@ class ContactMailer extends Mailer
|
||||
}
|
||||
|
||||
Event::fire(new InvoiceSent($invoice));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function sendPaymentConfirmation(Payment $payment)
|
||||
|
@ -30,7 +30,11 @@ class Mailer
|
||||
}
|
||||
}
|
||||
|
||||
$message->to($toEmail)->from($fromEmail, $fromName)->replyTo($replyEmail, $fromName)->subject($subject);
|
||||
$message->to($toEmail)
|
||||
->from($fromEmail, $fromName)
|
||||
->replyTo($replyEmail, $fromName)
|
||||
->subject($subject);
|
||||
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddPdfmakeSupport extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoice_designs', function($table)
|
||||
{
|
||||
$table->text('pdfmake')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoice_designs', function($table)
|
||||
{
|
||||
$table->dropColumn('pdfmake');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ use App\Models\PaymentTerm;
|
||||
use App\Models\Currency;
|
||||
use App\Models\DateFormat;
|
||||
use App\Models\DatetimeFormat;
|
||||
use App\Models\InvoiceDesign;
|
||||
|
||||
class PaymentLibrariesSeeder extends Seeder
|
||||
{
|
||||
@ -16,6 +17,7 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
$this->createPaymentTerms();
|
||||
$this->createDateFormats();
|
||||
$this->createDatetimeFormats();
|
||||
$this->createInvoiceDesigns();
|
||||
}
|
||||
|
||||
private function createGateways() {
|
||||
@ -131,4 +133,33 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
|
||||
private function createInvoiceDesigns() {
|
||||
$designs = [
|
||||
'Clean',
|
||||
'Bold',
|
||||
'Modern',
|
||||
'Plain',
|
||||
'Business',
|
||||
'Creative',
|
||||
'Elegant',
|
||||
'Hipster',
|
||||
'Playful',
|
||||
'Photo',
|
||||
];
|
||||
|
||||
foreach ($designs as $design) {
|
||||
$fileName = storage_path() . '/templates/' . strtolower($design) . '.js';
|
||||
$pdfmake = file_get_contents($fileName);
|
||||
if ($pdfmake) {
|
||||
$record = InvoiceDesign::whereName($design)->first();
|
||||
if (!$record) {
|
||||
$record = new InvoiceDesign;
|
||||
$record->name = $design;
|
||||
}
|
||||
$record->pdfmake = $pdfmake;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33294,7 +33294,7 @@ function GetPdfMake(invoice, javascript, callback) {
|
||||
//console.log(javascript);
|
||||
var dd = JSON.parse(javascript, jsonCallBack);
|
||||
|
||||
if (!invoice.is_pro && dd.footer.hasOwnProperty('columns')) {
|
||||
if (!invoice.is_pro && dd.hasOwnProperty('footer') && dd.footer.hasOwnProperty('columns')) {
|
||||
dd.footer.columns.push({image: logoImages.imageLogo1, alignment: 'right', width: 130})
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ function GetPdfMake(invoice, javascript, callback) {
|
||||
//console.log(javascript);
|
||||
var dd = JSON.parse(javascript, jsonCallBack);
|
||||
|
||||
if (!invoice.is_pro && dd.footer.hasOwnProperty('columns')) {
|
||||
if (!invoice.is_pro && dd.hasOwnProperty('footer') && dd.footer.hasOwnProperty('columns')) {
|
||||
dd.footer.columns.push({image: logoImages.imageLogo1, alignment: 'right', width: 130})
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,11 @@
|
||||
{
|
||||
editorSection = section;
|
||||
editor.set(customDesign[section]);
|
||||
editor.expandAll();
|
||||
|
||||
// the function throws an error if the editor is in code view
|
||||
try {
|
||||
editor.expandAll();
|
||||
} catch(err) {}
|
||||
}
|
||||
|
||||
function saveEditor(data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user