diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 6fe75a63363c..407db691b75e 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -389,6 +389,58 @@ class AccountController extends BaseController $data['invoiceDesigns'] = InvoiceDesign::getDesigns(); $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) { @@ -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->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) { diff --git a/app/Models/Account.php b/app/Models/Account.php index f50ed2cec1fa..351901d3fa6c 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -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(); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 4d9b82c79416..c40f22d34ad3 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -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) { diff --git a/database/migrations/2016_04_18_174135_add_page_size.php b/database/migrations/2016_04_18_174135_add_page_size.php new file mode 100644 index 000000000000..d5bbb86f64bc --- /dev/null +++ b/database/migrations/2016_04_18_174135_add_page_size.php @@ -0,0 +1,72 @@ +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'); + }); + } +} diff --git a/database/seeds/FontsSeeder.php b/database/seeds/FontsSeeder.php index 6f27ffa0be02..de67f441ced5 100644 --- a/database/seeds/FontsSeeder.php +++ b/database/seeds/FontsSeeder.php @@ -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); } } diff --git a/public/built.js b/public/built.js index 327b7e5fb2ae..2547d7804ce2 100644 --- a/public/built.js +++ b/public/built.js @@ -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; diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index afabd47f8875..09d01f7470e2 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -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; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 799cf6cbaab2..748a2eb3fb0a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -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', @@ -1126,7 +1126,9 @@ $LANG = array( 'enable_client_portal_help' => 'Show/hide the client portal.', '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; diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 9576afbf1d92..e7d21e685ffc 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -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 + NINJA.headerFont = $('#header_font_id option:selected').text(); + NINJA.bodyFont = $('#body_font_id option:selected').text(); + var fields = [ 'item', 'description', @@ -112,7 +110,16 @@