1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/resources/views/accounts/invoice_design.blade.php

285 lines
12 KiB
PHP
Raw Normal View History

2015-10-14 16:15:39 +02:00
@extends('header')
2015-03-16 22:45:25 +01:00
@section('head')
@parent
2015-12-10 12:03:45 +01:00
@include('money_script')
2016-01-07 08:08:30 +01:00
@foreach ($account->getFontFolders() as $font)
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
@endforeach
2016-02-25 11:16:27 +01:00
<script src="{{ asset('pdf.built.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/lightbox.min.js') }}" type="text/javascript"></script>
<link href="{{ asset('css/lightbox.css') }}" rel="stylesheet" type="text/css"/>
2015-04-27 14:28:40 +02:00
2015-03-16 22:45:25 +01:00
@stop
@section('content')
@parent
2015-10-14 16:15:39 +02:00
@include('accounts.nav', ['selected' => ACCOUNT_INVOICE_DESIGN, 'advanced' => true])
2015-03-16 22:45:25 +01:00
<script>
2015-04-01 21:57:02 +02:00
var invoiceDesigns = {!! $invoiceDesigns !!};
2016-01-07 08:08:30 +01:00
var invoiceFonts = {!! $invoiceFonts !!};
2015-04-01 21:57:02 +02:00
var invoice = {!! json_encode($invoice) !!};
2015-03-16 22:45:25 +01:00
function getDesignJavascript() {
var id = $('#invoice_design_id').val();
if (id == '-1') {
showMoreDesigns();
$('#invoice_design_id').val(1);
2016-01-07 08:08:30 +01:00
return invoiceDesigns[0].javascript;
2015-07-21 20:51:56 +02:00
} else {
var design = _.find(invoiceDesigns, function(design){ return design.id == id});
return design ? design.javascript : '';
2015-03-16 22:45:25 +01:00
}
}
2016-01-07 08:08:30 +01:00
function loadFont(fontId){
var fontFolder = '';
$.each(window.invoiceFonts, function(i, font){
if(font.id==fontId)fontFolder=font.folder;
});
if(!window.ninjaFontVfs[fontFolder]){
window.loadingFonts = true;
jQuery.getScript({!! json_encode(asset('js/vfs_fonts/%s.js')) !!}.replace('%s', fontFolder), function(){window.loadingFonts=false;ninjaLoadFontVfs();refreshPDF()})
}
}
function getPDFString(cb) {
invoice.features = {
customize_invoice_design:{{ Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
remove_created_by:{{ Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
invoice_settings:{{ Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
};
2015-03-16 22:45:25 +01:00
invoice.account.hide_quantity = $('#hide_quantity').is(":checked");
2016-03-23 23:40:42 +01:00
invoice.account.invoice_embed_documents = $('#invoice_embed_documents').is(":checked");
2015-03-16 22:45:25 +01:00
invoice.account.hide_paid_to_date = $('#hide_paid_to_date').is(":checked");
invoice.invoice_design_id = $('#invoice_design_id').val();
invoice.account.page_size = $('#page_size option:selected').text();
2015-09-07 11:07:55 +02:00
2015-03-16 22:45:25 +01:00
NINJA.primaryColor = $('#primary_color').val();
NINJA.secondaryColor = $('#secondary_color').val();
2015-05-22 09:22:24 +02:00
NINJA.fontSize = parseInt($('#font_size').val());
NINJA.headerFont = $('#header_font_id option:selected').text();
NINJA.bodyFont = $('#body_font_id option:selected').text();
2016-03-18 13:34:46 +01:00
var fields = [
'item',
'description',
'unit_cost',
'quantity',
'line_total',
'terms',
'balance_due',
'partial_due'
];
2015-10-16 07:32:02 +02:00
invoiceLabels.old = {};
for (var i=0; i<fields.length; i++) {
var field = fields[i];
var val = $('#labels_' + field).val();
if (invoiceLabels.old.hasOwnProperty(field)) {
invoiceLabels.old[field] = invoiceLabels[field];
}
if (val) {
invoiceLabels[field] = val;
}
2015-10-16 07:32:02 +02:00
}
2015-10-16 07:32:02 +02:00
generatePDF(invoice, getDesignJavascript(), true, cb);
2015-03-16 22:45:25 +01:00
}
$(function() {
var options = {
preferredFormat: 'hex',
disabled: {!! Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'false' : 'true' !!},
2015-03-16 22:45:25 +01:00
showInitial: false,
showInput: true,
allowEmpty: true,
clickoutFiresChange: true,
};
$('#primary_color').spectrum(options);
$('#secondary_color').spectrum(options);
2016-01-07 08:40:46 +01:00
$('#header_font_id').change(function(){loadFont($('#header_font_id').val())});
$('#body_font_id').change(function(){loadFont($('#body_font_id').val())});
2016-01-07 08:08:30 +01:00
2015-03-16 22:45:25 +01:00
refreshPDF();
});
</script>
<div class="row">
2015-10-15 21:37:01 +02:00
<div class="col-md-12">
2015-03-16 22:45:25 +01:00
2016-01-07 08:08:30 +01:00
{!! Former::open()->addClass('warn-on-exit')->onchange('if(!window.loadingFonts)refreshPDF()') !!}
{!! Former::populateField('invoice_design_id', $account->invoice_design_id) !!}
{!! Former::populateField('body_font_id', $account->body_font_id) !!}
{!! Former::populateField('header_font_id', $account->header_font_id) !!}
{!! Former::populateField('live_preview', intval($account->live_preview)) !!}
{!! Former::populateField('font_size', $account->font_size) !!}
{!! Former::populateField('page_size', $account->page_size) !!}
{!! Former::populateField('invoice_embed_documents', intval($account->invoice_embed_documents)) !!}
{!! Former::populateField('primary_color', $account->primary_color) !!}
{!! Former::populateField('secondary_color', $account->secondary_color) !!}
2015-04-01 21:57:02 +02:00
{!! Former::populateField('hide_quantity', intval($account->hide_quantity)) !!}
{!! 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)) !!}
2015-09-07 11:07:55 +02:00
@foreach ($invoiceLabels as $field => $value)
{!! Former::populateField("labels_{$field}", $value) !!}
@endforeach
2015-03-16 22:45:25 +01:00
2015-04-20 16:34:23 +02:00
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.invoice_design') !!}</h3>
</div>
2015-10-15 21:37:01 +02:00
<div class="panel-body form-padding-right">
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active"><a href="#generalSettings" aria-controls="generalSettings" role="tab" data-toggle="tab">{{ trans('texts.general_settings') }}</a></li>
<li role="presentation"><a href="#invoiceLabels" aria-controls="invoiceLabels" role="tab" data-toggle="tab">{{ trans('texts.invoice_labels') }}</a></li>
<li role="presentation"><a href="#invoiceOptions" aria-controls="invoiceOptions" role="tab" data-toggle="tab">{{ trans('texts.invoice_options') }}</a></li>
<li role="presentation"><a href="#headerFooter" aria-controls="headerFooter" role="tab" data-toggle="tab">{{ trans('texts.header_footer') }}</a></li>
2015-10-15 21:37:01 +02:00
</ul>
</div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="generalSettings">
<div class="panel-body">
2016-01-10 19:40:04 +01:00
<div class="row">
<div class="col-md-6">
@if (!Utils::hasFeature(FEATURE_MORE_INVOICE_DESIGNS) || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
2016-01-10 19:40:04 +01:00
{!! Former::select('invoice_design_id')
->fromQuery($invoiceDesigns, 'name', 'id')
->addOption(trans('texts.more_designs') . '...', '-1') !!}
@else
{!! Former::select('invoice_design_id')
->fromQuery($invoiceDesigns, 'name', 'id') !!}
@endif
{!! Former::select('body_font_id')
->fromQuery($invoiceFonts, 'name', 'id') !!}
{!! Former::select('header_font_id')
->fromQuery($invoiceFonts, 'name', 'id') !!}
{!! Former::checkbox('live_preview')->text(trans('texts.enable')) !!}
2016-01-10 19:40:04 +01:00
</div>
<div class="col-md-6">
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 6) }}
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 6) }}
{!! Former::select('page_size')
->options($pageSizes) !!}
2016-01-10 19:40:04 +01:00
{!! Former::text('font_size')
->type('number')
->min('0')
->step('1') !!}
{!! Former::text('primary_color') !!}
{!! Former::text('secondary_color') !!}
2016-01-10 19:40:04 +01:00
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 4) }}
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 4) }}
</div>
</div>
<div class="help-block">
{{ trans('texts.color_font_help') }}
</div>
2015-10-15 21:37:01 +02:00
</div>
</div>
<div role="tabpanel" class="tab-pane" id="invoiceLabels">
<div class="panel-body">
2015-11-21 22:10:26 +01:00
<div class="row">
<div class="col-md-6">
{!! Former::text('labels_item')->label(trans('texts.item')) !!}
{!! Former::text('labels_description')->label(trans('texts.description')) !!}
{!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!}
2016-03-18 13:34:46 +01:00
{!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!}
2015-11-21 22:10:26 +01:00
</div>
<div class="col-md-6">
{!! Former::text('labels_line_total')->label(trans('texts.line_total')) !!}
{!! Former::text('labels_terms')->label(trans('texts.terms')) !!}
2016-03-18 13:34:46 +01:00
{!! Former::text('labels_balance_due')->label(trans('texts.balance_due')) !!}
{!! Former::text('labels_partial_due')->label(trans('texts.partial_due')) !!}
2015-11-21 22:10:26 +01:00
</div>
</div>
2015-10-15 21:37:01 +02:00
</div>
</div>
<div role="tabpanel" class="tab-pane" id="invoiceOptions">
<div class="panel-body">
{!! Former::checkbox('hide_quantity')->text(trans('texts.hide_quantity_help')) !!}
{!! Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help')) !!}
2016-03-23 23:40:42 +01:00
{!! Former::checkbox('invoice_embed_documents')->text(trans('texts.invoice_embed_documents_help')) !!}
2015-10-15 21:37:01 +02:00
</div>
</div>
<div role="tabpanel" class="tab-pane" id="headerFooter">
<div class="panel-body">
{!! 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>
2015-10-15 21:37:01 +02:00
</div>
2015-04-20 16:34:23 +02:00
</div>
</div>
2015-03-16 22:45:25 +01:00
2015-10-16 07:32:02 +02:00
<br/>
{!! Former::actions(
2015-10-20 10:23:38 +02:00
Button::primary(trans('texts.customize'))
->appendIcon(Icon::create('edit'))
->asLinkTo(URL::to('/settings/customize_design'))
->large(),
Button::success(trans('texts.save'))
->submit()->large()
->appendIcon(Icon::create('floppy-disk'))
->withAttributes(['class' => 'save-button'])
2015-10-16 07:32:02 +02:00
) !!}
<br/>
@if (!Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN))
2015-09-07 11:07:55 +02:00
<script>
$(function() {
2015-10-16 07:32:02 +02:00
$('form.warn-on-exit input, .save-button').prop('disabled', true);
2015-09-07 11:07:55 +02:00
});
</script>
2015-03-16 22:45:25 +01:00
@endif
2015-04-01 21:57:02 +02:00
{!! Former::close() !!}
2015-03-16 22:45:25 +01:00
</div>
2015-10-15 21:37:01 +02:00
</div>
2015-03-16 22:45:25 +01:00
@include('invoices.pdf', ['account' => Auth::user()->account, 'pdfHeight' => 800])
@stop