mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Support background image on invoice
This commit is contained in:
parent
96c5e764b7
commit
7a5215e6a0
@ -1057,6 +1057,7 @@ class AccountController extends BaseController
|
||||
$account->quote_design_id = Input::get('quote_design_id');
|
||||
$account->font_size = intval(Input::get('font_size'));
|
||||
$account->page_size = Input::get('page_size');
|
||||
$account->background_image_id = Document::getPrivateId(request()->background_image_id);
|
||||
|
||||
$labels = [];
|
||||
foreach (Account::$customLabels as $field) {
|
||||
|
@ -382,6 +382,11 @@ class Account extends Eloquent
|
||||
return $this->hasMany('App\Models\Document')->whereIsDefault(true);
|
||||
}
|
||||
|
||||
public function background_image()
|
||||
{
|
||||
return $this->hasOne('App\Models\Document', 'id', 'background_image_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -356,6 +356,11 @@ class Document extends EntityModel
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
public function scopeProposalImages($query)
|
||||
{
|
||||
return $query->whereIsProposal(1);
|
||||
}
|
||||
}
|
||||
|
||||
Document::deleted(function ($document) {
|
||||
|
@ -108,7 +108,11 @@ class EntityModel extends Eloquent
|
||||
|
||||
$className = get_called_class();
|
||||
|
||||
return $className::scope($publicId)->withTrashed()->value('id');
|
||||
if (method_exists($className, 'trashed')) {
|
||||
return $className::scope($publicId)->withTrashed()->value('id');
|
||||
} else {
|
||||
return $className::scope($publicId)->value('id');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,6 +136,14 @@ class User extends Authenticatable
|
||||
return $this->account->isPro();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function isEnterprise()
|
||||
{
|
||||
return $this->account->isEnterprise();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -79,6 +79,7 @@ class AddMoreCustomFields extends Migration
|
||||
});
|
||||
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->unsignedInteger('background_image_id')->nullable();
|
||||
$table->mediumText('custom_messages')->nullable();
|
||||
});
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -189,6 +189,17 @@ function GetPdfMake(invoice, javascript, callback) {
|
||||
if(!dd.defaultStyle)dd.defaultStyle = {font:NINJA.bodyFont};
|
||||
else if(!dd.defaultStyle.font)dd.defaultStyle.font = NINJA.bodyFont;
|
||||
|
||||
if (window.accountBackground) {
|
||||
var origBackground = dd.background;
|
||||
dd.background = function(currentPage) {
|
||||
var allPages = origBackground.length && origBackground[0].pages == 'all';
|
||||
return currentPage == 1 || allPages ? origBackground : false;
|
||||
}
|
||||
} else {
|
||||
// prevent unnecessarily showing blank image
|
||||
dd.background = false;
|
||||
}
|
||||
|
||||
doc = pdfMake.createPdf(dd);
|
||||
doc.save = function(fileName) {
|
||||
this.download(fileName);
|
||||
@ -228,6 +239,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
||||
var json = {
|
||||
'accountName': account.name || ' ',
|
||||
'accountLogo': window.accountLogo ? window.accountLogo : blankImage,
|
||||
'accountBackground': window.accountBackground ? window.accountBackground : blankImage,
|
||||
'accountDetails': NINJA.accountDetails(invoice),
|
||||
'accountAddress': NINJA.accountAddress(invoice),
|
||||
'invoiceDetails': NINJA.invoiceDetails(invoice),
|
||||
|
@ -2831,6 +2831,10 @@ $LANG = array(
|
||||
'strength_strong' => 'Strong',
|
||||
'mark' => 'Mark',
|
||||
'updated_task_status' => 'Successfully update task status',
|
||||
'background_image' => 'Background Image',
|
||||
'background_image_help' => 'Use the :link to manage your images.',
|
||||
'proposal_editor' => 'proposal editor',
|
||||
'background' => 'Background',
|
||||
|
||||
);
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
var invoiceDesigns = {!! $invoiceDesigns !!};
|
||||
var invoiceFonts = {!! $invoiceFonts !!};
|
||||
var invoice = {!! json_encode($invoice) !!};
|
||||
var sections = ['content', 'styles', 'defaultStyle', 'pageMargins', 'header', 'footer'];
|
||||
var sections = ['content', 'styles', 'defaultStyle', 'pageMargins', 'header', 'footer', 'background'];
|
||||
var customDesign = origCustomDesign = {!! $customDesign ?: 'JSON.parse(invoiceDesigns[0].javascript);' !!};
|
||||
|
||||
function getPDFString(cb, force) {
|
||||
@ -185,6 +185,9 @@
|
||||
<li role="presentation"><a href="#margins" aria-controls="margins" role="tab" data-toggle="tab">{{ trans('texts.margins') }}</a></li>
|
||||
<li role="presentation"><a href="#header" aria-controls="header" role="tab" data-toggle="tab">{{ trans('texts.header') }}</a></li>
|
||||
<li role="presentation"><a href="#footer" aria-controls="footer" role="tab" data-toggle="tab">{{ trans('texts.footer') }}</a></li>
|
||||
@if ($account->isEnterprise() && $account->background_image_id)
|
||||
<li role="presentation"><a href="#background" aria-controls="footer" role="tab" data-toggle="tab">{{ trans('texts.background') }}</a></li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
<div id="jsoneditor" style="width: 100%; height: 814px;"></div>
|
||||
|
@ -154,6 +154,7 @@
|
||||
{!! Former::populateField('hide_paid_to_date', intval($account->hide_paid_to_date)) !!}
|
||||
{!! Former::populateField('all_pages_header', intval($account->all_pages_header)) !!}
|
||||
{!! Former::populateField('all_pages_footer', intval($account->all_pages_footer)) !!}
|
||||
{!! Former::populateField('background_image_id', $account->background_image ? $account->background_image->public_id : null) !!}
|
||||
|
||||
@foreach ($invoiceLabels as $field => $value)
|
||||
{!! Former::populateField("labels_{$field}", $value) !!}
|
||||
@ -292,24 +293,32 @@
|
||||
<div role="tabpanel" class="tab-pane" id="invoice_options">
|
||||
<div class="panel-body">
|
||||
|
||||
{!! Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help'))->value(1) !!}
|
||||
{!! Former::checkbox('invoice_embed_documents')->text(trans('texts.invoice_embed_documents_help'))->value(1) !!}
|
||||
@if (auth()->user()->isEnterprise())
|
||||
{!! Former::select('background_image_id')
|
||||
->label('background_image')
|
||||
->addOption('', '')
|
||||
->fromQuery(\App\Models\Document::scope()->proposalImages()->get(), 'name', 'public_id')
|
||||
->help(trans('texts.background_image_help', ['link' => link_to('/proposals/create?show_assets=true', trans('texts.proposal_editor'), ['target' => '_blank'])])) !!}
|
||||
@endif
|
||||
|
||||
<br/>
|
||||
{!! Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help'))->value(1) !!}
|
||||
{!! Former::checkbox('invoice_embed_documents')->text(trans('texts.invoice_embed_documents_help'))->value(1) !!}
|
||||
|
||||
{!! Former::inline_radios('all_pages_header')
|
||||
->label(trans('texts.all_pages_header'))
|
||||
->radios([
|
||||
trans('texts.first_page') => ['value' => 0, 'name' => 'all_pages_header'],
|
||||
trans('texts.all_pages') => ['value' => 1, 'name' => 'all_pages_header'],
|
||||
])->check($account->all_pages_header) !!}
|
||||
<br/>
|
||||
|
||||
{!! Former::inline_radios('all_pages_footer')
|
||||
->label(trans('texts.all_pages_footer'))
|
||||
->radios([
|
||||
trans('texts.last_page') => ['value' => 0, 'name' => 'all_pages_footer'],
|
||||
trans('texts.all_pages') => ['value' => 1, 'name' => 'all_pages_footer'],
|
||||
])->check($account->all_pages_footer) !!}
|
||||
{!! Former::inline_radios('all_pages_header')
|
||||
->label(trans('texts.all_pages_header'))
|
||||
->radios([
|
||||
trans('texts.first_page') => ['value' => 0, 'name' => 'all_pages_header'],
|
||||
trans('texts.all_pages') => ['value' => 1, 'name' => 'all_pages_header'],
|
||||
])->check($account->all_pages_header) !!}
|
||||
|
||||
{!! Former::inline_radios('all_pages_footer')
|
||||
->label(trans('texts.all_pages_footer'))
|
||||
->radios([
|
||||
trans('texts.last_page') => ['value' => 0, 'name' => 'all_pages_footer'],
|
||||
trans('texts.all_pages') => ['value' => 1, 'name' => 'all_pages_footer'],
|
||||
])->check($account->all_pages_footer) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -88,6 +88,10 @@
|
||||
}
|
||||
@endif
|
||||
|
||||
@if ($account->isEnterprise() && $account->background_image_id && $account->background_image)
|
||||
window.accountBackground = "{{ Form::image_data($account->background_image->getRaw(), true) }}";
|
||||
@endif
|
||||
|
||||
var NINJA = NINJA || {};
|
||||
@if ($account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN))
|
||||
NINJA.primaryColor = "{{ $account->primary_color }}";
|
||||
|
@ -259,6 +259,12 @@
|
||||
@if (! $proposal && $templatePublicId)
|
||||
loadTemplate();
|
||||
@endif
|
||||
|
||||
@if (request()->show_assets)
|
||||
setTimeout(function() {
|
||||
grapesjsEditor.runCommand('open-assets');
|
||||
}, 500);
|
||||
@endif
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -383,5 +383,11 @@
|
||||
80,
|
||||
0,
|
||||
40
|
||||
],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -247,5 +247,11 @@
|
||||
"color": "#737373"
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 40, 40, 40]
|
||||
"pageMargins": [40, 40, 40, 40],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -114,7 +114,7 @@
|
||||
]
|
||||
},
|
||||
"$signature",
|
||||
{
|
||||
{
|
||||
"stack":[
|
||||
"$invoiceDocuments"
|
||||
],
|
||||
@ -295,5 +295,11 @@
|
||||
40,
|
||||
40,
|
||||
60
|
||||
],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -218,5 +218,11 @@
|
||||
"color": "#737373"
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 40, 40, 40]
|
||||
"pageMargins": [40, 40, 40, 40],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -213,5 +213,11 @@
|
||||
"color": "#737373"
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 40, 40, 40]
|
||||
"pageMargins": [40, 40, 40, 40],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -215,5 +215,11 @@
|
||||
"color": "#737373"
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 40, 40, 40]
|
||||
"pageMargins": [40, 40, 40, 40],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -260,5 +260,11 @@
|
||||
"margin": [0, 10, 0, 10]
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 120, 40, 50]
|
||||
"pageMargins": [40, 120, 40, 50],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -178,5 +178,11 @@
|
||||
"color": "#737373"
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 30, 40, 30]
|
||||
"pageMargins": [40, 30, 40, 30],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -184,5 +184,11 @@
|
||||
"margin": [0, 10, 0, 10]
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 40, 40, 60]
|
||||
"pageMargins": [40, 40, 40, 60],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -269,5 +269,11 @@
|
||||
"color": "#737373"
|
||||
}
|
||||
},
|
||||
"pageMargins": [40, 40, 40, 40]
|
||||
"pageMargins": [40, 40, 40, 40],
|
||||
"background": [
|
||||
{
|
||||
"image": "$accountBackground",
|
||||
"alignment": "center"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user