mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added page size and live preview settings
This commit is contained in:
parent
0c27e22b51
commit
9f5fe33059
@ -390,6 +390,58 @@ class AccountController extends BaseController
|
||||
$data['invoiceFonts'] = Cache::get('fonts');
|
||||
$data['section'] = $section;
|
||||
|
||||
$pageSizes = [
|
||||
'A0',
|
||||
'A1',
|
||||
'A2',
|
||||
'A3',
|
||||
'A4',
|
||||
'A5',
|
||||
'A6',
|
||||
'A7',
|
||||
'A8',
|
||||
'A9',
|
||||
'A10',
|
||||
'B0',
|
||||
'B1',
|
||||
'B2',
|
||||
'B3',
|
||||
'B4',
|
||||
'B5',
|
||||
'B6',
|
||||
'B7',
|
||||
'B8',
|
||||
'B9',
|
||||
'B10',
|
||||
'C0',
|
||||
'C1',
|
||||
'C2',
|
||||
'C3',
|
||||
'C4',
|
||||
'C5',
|
||||
'C6',
|
||||
'C7',
|
||||
'C8',
|
||||
'C9',
|
||||
'C10',
|
||||
'RA0',
|
||||
'RA1',
|
||||
'RA2',
|
||||
'RA3',
|
||||
'RA4',
|
||||
'SRA0',
|
||||
'SRA1',
|
||||
'SRA2',
|
||||
'SRA3',
|
||||
'SRA4',
|
||||
'Executive',
|
||||
'Folio',
|
||||
'Legal',
|
||||
'Letter',
|
||||
'Tabloid',
|
||||
];
|
||||
$data['pageSizes'] = array_combine($pageSizes, $pageSizes);
|
||||
|
||||
$design = false;
|
||||
foreach ($data['invoiceDesigns'] as $item) {
|
||||
if ($item->id == $account->invoice_design_id) {
|
||||
@ -764,10 +816,9 @@ class AccountController extends BaseController
|
||||
$account->primary_color = Input::get('primary_color');
|
||||
$account->secondary_color = Input::get('secondary_color');
|
||||
$account->invoice_design_id = Input::get('invoice_design_id');
|
||||
|
||||
if (Input::has('font_size')) {
|
||||
$account->font_size = intval(Input::get('font_size'));
|
||||
}
|
||||
$account->page_size = Input::get('page_size');
|
||||
$account->live_preview = Input::get('live_preview') ? true : false;
|
||||
|
||||
$labels = [];
|
||||
foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms', 'balance_due', 'partial_due'] as $field) {
|
||||
|
@ -1110,17 +1110,6 @@ class Account extends Eloquent
|
||||
return $css;
|
||||
}
|
||||
|
||||
public function hasLargeFont()
|
||||
{
|
||||
foreach (['chinese', 'japanese'] as $language) {
|
||||
if (stripos($this->getBodyFontName(), $language) || stripos($this->getHeaderFontName(), $language)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFontsUrl($protocol = ''){
|
||||
$bodyFont = $this->getHeaderFontId();
|
||||
$headerFont = $this->getBodyFontId();
|
||||
|
@ -474,7 +474,8 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
'custom_invoice_text_label2',
|
||||
'custom_invoice_item_label1',
|
||||
'custom_invoice_item_label2',
|
||||
'invoice_embed_documents'
|
||||
'invoice_embed_documents',
|
||||
'page_size',
|
||||
]);
|
||||
|
||||
foreach ($this->invoice_items as $invoiceItem) {
|
||||
|
72
database/migrations/2016_04_18_174135_add_page_size.php
Normal file
72
database/migrations/2016_04_18_174135_add_page_size.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddPageSize extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->string('page_size')->default('A4');
|
||||
$table->boolean('live_preview')->default(true);
|
||||
$table->smallInteger('invoice_number_padding')->default(4);
|
||||
});
|
||||
|
||||
Schema::table('fonts', function ($table) {
|
||||
$table->dropColumn('is_early_access');
|
||||
});
|
||||
|
||||
Schema::create('expense_categories', function($table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->unsignedInteger('account_id')->index();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->string('name')->nullable();
|
||||
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
$table->unsignedInteger('public_id')->index();
|
||||
$table->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::table('expenses', function ($table) {
|
||||
$table->unsignedInteger('expense_category_id')->nullable()->index();
|
||||
|
||||
$table->foreign('expense_category_id')->references('id')->on('expense_categories')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->dropColumn('page_size');
|
||||
$table->dropColumn('live_preview');
|
||||
$table->dropColumn('invoice_number_padding');
|
||||
});
|
||||
|
||||
Schema::table('fonts', function ($table) {
|
||||
$table->boolean('is_early_access');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('expense_categories');
|
||||
|
||||
Schema::table('expenses', function ($table) {
|
||||
$table->dropColumn('expense_category_id');
|
||||
});
|
||||
}
|
||||
}
|
@ -246,7 +246,6 @@ class FontsSeeder extends Seeder
|
||||
|
||||
foreach ($fonts as $font) {
|
||||
if (!DB::table('fonts')->where('name', '=', $font['name'])->get()) {
|
||||
$font['is_early_access'] = false;
|
||||
Font::create($font);
|
||||
}
|
||||
}
|
||||
|
@ -31100,7 +31100,8 @@ function GetPdfMake(invoice, javascript, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set page size
|
||||
dd.pageSize = invoice.account.page_size;
|
||||
|
||||
pdfMake.fonts = {}
|
||||
fonts = window.invoiceFonts || invoice.invoice_fonts;
|
||||
|
@ -96,7 +96,8 @@ function GetPdfMake(invoice, javascript, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set page size
|
||||
dd.pageSize = invoice.account.page_size;
|
||||
|
||||
pdfMake.fonts = {}
|
||||
fonts = window.invoiceFonts || invoice.invoice_fonts;
|
||||
|
@ -976,9 +976,9 @@ $LANG = array(
|
||||
'expense_error_mismatch_currencies' => 'The client\'s currency does not match the expense currency.',
|
||||
'trello_roadmap' => 'Trello Roadmap',
|
||||
'header_footer' => 'Header/Footer',
|
||||
'first_page' => 'first page',
|
||||
'all_pages' => 'all pages',
|
||||
'last_page' => 'last page',
|
||||
'first_page' => 'First page',
|
||||
'all_pages' => 'All pages',
|
||||
'last_page' => 'Last page',
|
||||
'all_pages_header' => 'Show header on',
|
||||
'all_pages_footer' => 'Show footer on',
|
||||
'invoice_currency' => 'Invoice Currency',
|
||||
@ -1127,6 +1127,8 @@ $LANG = array(
|
||||
'enable_client_portal_dashboard' => 'Dashboard',
|
||||
'enable_client_portal_dashboard_help' => 'Show/hide the dashboard page in the client portal.',
|
||||
|
||||
'live_preview' => 'Live Preview',
|
||||
'page_size' => 'Page Size',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -51,16 +51,14 @@
|
||||
invoice.account.invoice_embed_documents = $('#invoice_embed_documents').is(":checked");
|
||||
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();
|
||||
|
||||
NINJA.primaryColor = $('#primary_color').val();
|
||||
NINJA.secondaryColor = $('#secondary_color').val();
|
||||
NINJA.fontSize = parseInt($('#font_size').val());
|
||||
@if (Auth::user()->isPro())
|
||||
NINJA.headerFont = $('#header_font_id option:selected').text();
|
||||
NINJA.bodyFont = $('#body_font_id option:selected').text();
|
||||
@else
|
||||
NINJA.headerFont = NINJA.bodyFont = 'Roboto';
|
||||
@endif
|
||||
|
||||
var fields = [
|
||||
'item',
|
||||
'description',
|
||||
@ -112,7 +110,16 @@
|
||||
<div class="col-md-12">
|
||||
|
||||
{!! Former::open()->addClass('warn-on-exit')->onchange('if(!window.loadingFonts)refreshPDF()') !!}
|
||||
{!! Former::populate($account) !!}
|
||||
|
||||
{!! 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) !!}
|
||||
{!! 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)) !!}
|
||||
@ -156,13 +163,17 @@
|
||||
{!! Former::select('header_font_id')
|
||||
->fromQuery($invoiceFonts, 'name', 'id') !!}
|
||||
|
||||
{!! Former::checkbox('live_preview')->text(trans('texts.enable')) !!}
|
||||
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 6) }}
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 6) }}
|
||||
|
||||
{!! Former::select('page_size')
|
||||
->options($pageSizes) !!}
|
||||
|
||||
{!! Former::text('font_size')
|
||||
->type('number')
|
||||
->min('0')
|
||||
@ -171,6 +182,7 @@
|
||||
{!! Former::text('primary_color') !!}
|
||||
{!! Former::text('secondary_color') !!}
|
||||
|
||||
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 4) }}
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 4) }}
|
||||
|
||||
|
@ -493,12 +493,6 @@
|
||||
{!! Former::text('pdfupload') !!}
|
||||
</div>
|
||||
|
||||
@if ($account->hasLargeFont())
|
||||
<label for="livePreview" class="control-label" style="padding-right:10px">
|
||||
<input id="livePreview" type="checkbox"/> {{ trans('texts.live_preview') }}
|
||||
</label>
|
||||
@endif
|
||||
|
||||
@if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') !!}
|
||||
@else
|
||||
@ -1097,8 +1091,8 @@
|
||||
|
||||
window.generatedPDF = false;
|
||||
function getPDFString(cb, force) {
|
||||
@if ($account->hasLargeFont())
|
||||
if (!$('#livePreview').is(':checked') && window.generatedPDF) {
|
||||
@if (!$account->live_preview)
|
||||
if (window.generatedPDF) {
|
||||
return;
|
||||
}
|
||||
@endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user