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
|
/.phpstorm.meta.php
|
||||||
/_ide_helper.php
|
/_ide_helper.php
|
||||||
/.idea
|
/.idea
|
||||||
/.project
|
/.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
|
|
@ -233,7 +233,7 @@ class AccountController extends BaseController
|
|||||||
$data['invoice'] = $invoice;
|
$data['invoice'] = $invoice;
|
||||||
$data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
|
$data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
|
||||||
$data['title'] = trans('texts.invoice_design');
|
$data['title'] = trans('texts.invoice_design');
|
||||||
$data['invoiceDesigns'] = InvoiceDesign::availableDesigns($subSection == ACCOUNT_CUSTOMIZE_DESIGN);
|
$data['invoiceDesigns'] = InvoiceDesign::getDesigns($subSection == ACCOUNT_CUSTOMIZE_DESIGN);
|
||||||
|
|
||||||
$design = false;
|
$design = false;
|
||||||
foreach ($data['invoiceDesigns'] as $item) {
|
foreach ($data['invoiceDesigns'] as $item) {
|
||||||
|
@ -405,7 +405,7 @@ class InvoiceController extends BaseController
|
|||||||
'sizes' => Cache::get('sizes'),
|
'sizes' => Cache::get('sizes'),
|
||||||
'paymentTerms' => Cache::get('paymentTerms'),
|
'paymentTerms' => Cache::get('paymentTerms'),
|
||||||
'industries' => Cache::get('industries'),
|
'industries' => Cache::get('industries'),
|
||||||
'invoiceDesigns' => InvoiceDesign::availableDesigns(),
|
'invoiceDesigns' => InvoiceDesign::getDesigns(),
|
||||||
'frequencies' => array(
|
'frequencies' => array(
|
||||||
1 => 'Weekly',
|
1 => 'Weekly',
|
||||||
2 => 'Two weeks',
|
2 => 'Two weeks',
|
||||||
@ -646,7 +646,7 @@ class InvoiceController extends BaseController
|
|||||||
'invoice' => $invoice,
|
'invoice' => $invoice,
|
||||||
'versionsJson' => json_encode($versionsJson),
|
'versionsJson' => json_encode($versionsJson),
|
||||||
'versionsSelect' => $versionsSelect,
|
'versionsSelect' => $versionsSelect,
|
||||||
'invoiceDesigns' => InvoiceDesign::availableDesigns(),
|
'invoiceDesigns' => InvoiceDesign::getDesigns(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return View::make('invoices.history', $data);
|
return View::make('invoices.history', $data);
|
||||||
|
@ -156,7 +156,7 @@ class QuoteController extends BaseController
|
|||||||
'sizes' => Cache::get('sizes'),
|
'sizes' => Cache::get('sizes'),
|
||||||
'paymentTerms' => Cache::get('paymentTerms'),
|
'paymentTerms' => Cache::get('paymentTerms'),
|
||||||
'industries' => Cache::get('industries'),
|
'industries' => Cache::get('industries'),
|
||||||
'invoiceDesigns' => InvoiceDesign::availableDesigns(),
|
'invoiceDesigns' => InvoiceDesign::getDesigns(),
|
||||||
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
|
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ class StartupCheck
|
|||||||
'paymentTerms' => 'App\Models\PaymentTerm',
|
'paymentTerms' => 'App\Models\PaymentTerm',
|
||||||
'paymentTypes' => 'App\Models\PaymentType',
|
'paymentTypes' => 'App\Models\PaymentType',
|
||||||
'countries' => 'App\Models\Country',
|
'countries' => 'App\Models\Country',
|
||||||
|
'invoiceDesigns' => 'App\Models\InvoiceDesign',
|
||||||
];
|
];
|
||||||
foreach ($cachedTables as $name => $class) {
|
foreach ($cachedTables as $name => $class) {
|
||||||
if (Input::has('clear_cache')) {
|
if (Input::has('clear_cache')) {
|
||||||
|
@ -439,6 +439,7 @@ function otrans($text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Log all SQL queries to laravel.log
|
// Log all SQL queries to laravel.log
|
||||||
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
|
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);
|
Log::info($query, $data);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (Auth::check() && Auth::user()->id === 1)
|
if (Auth::check() && Auth::user()->id === 1)
|
||||||
|
@ -2,32 +2,38 @@
|
|||||||
|
|
||||||
use Eloquent;
|
use Eloquent;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Cache;
|
||||||
use App\Models\InvoiceDesign;
|
use App\Models\InvoiceDesign;
|
||||||
|
|
||||||
class InvoiceDesign extends Eloquent
|
class InvoiceDesign extends Eloquent
|
||||||
{
|
{
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public function scopeAvailableDesigns($query, $utf8 = false)
|
public static function getDesigns($forceUtf8 = false)
|
||||||
{
|
{
|
||||||
$account = Auth::user()->account;
|
$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) {
|
foreach ($designs as $design) {
|
||||||
$fileName = public_path(strtolower("js/templates/{$design->name}.js"));
|
if ($design->id > Auth::user()->maxInvoiceDesignId()) {
|
||||||
if (($utf8 || Auth::user()->account->utf8_invoices) && file_exists($fileName)) {
|
$designs->pull($design->id);
|
||||||
$design->javascript = file_get_contents($fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($utf8) {
|
||||||
|
$design->javascript = $design->pdfmake;
|
||||||
|
}
|
||||||
|
$design->pdfmake = null;
|
||||||
|
|
||||||
if ($design->id == CUSTOM_DESIGN) {
|
if ($design->id == CUSTOM_DESIGN) {
|
||||||
if ($account->utf8_invoices && $account->custom_design) {
|
if ($utf8 && $account->custom_design) {
|
||||||
$design->javascript = $account->custom_design;
|
$design->javascript = $account->custom_design;
|
||||||
} else {
|
} else {
|
||||||
$designs->pop();
|
$designs->pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $designs;
|
return $designs;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -73,6 +73,8 @@ class ContactMailer extends Mailer
|
|||||||
}
|
}
|
||||||
|
|
||||||
Event::fire(new InvoiceSent($invoice));
|
Event::fire(new InvoiceSent($invoice));
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendPaymentConfirmation(Payment $payment)
|
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;
|
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\Currency;
|
||||||
use App\Models\DateFormat;
|
use App\Models\DateFormat;
|
||||||
use App\Models\DatetimeFormat;
|
use App\Models\DatetimeFormat;
|
||||||
|
use App\Models\InvoiceDesign;
|
||||||
|
|
||||||
class PaymentLibrariesSeeder extends Seeder
|
class PaymentLibrariesSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -16,6 +17,7 @@ class PaymentLibrariesSeeder extends Seeder
|
|||||||
$this->createPaymentTerms();
|
$this->createPaymentTerms();
|
||||||
$this->createDateFormats();
|
$this->createDateFormats();
|
||||||
$this->createDatetimeFormats();
|
$this->createDatetimeFormats();
|
||||||
|
$this->createInvoiceDesigns();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createGateways() {
|
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);
|
//console.log(javascript);
|
||||||
var dd = JSON.parse(javascript, jsonCallBack);
|
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})
|
dd.footer.columns.push({image: logoImages.imageLogo1, alignment: 'right', width: 130})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ function GetPdfMake(invoice, javascript, callback) {
|
|||||||
//console.log(javascript);
|
//console.log(javascript);
|
||||||
var dd = JSON.parse(javascript, jsonCallBack);
|
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})
|
dd.footer.columns.push({image: logoImages.imageLogo1, alignment: 'right', width: 130})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,11 @@
|
|||||||
{
|
{
|
||||||
editorSection = section;
|
editorSection = section;
|
||||||
editor.set(customDesign[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)
|
function saveEditor(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user