Add Header/Footer options to invoice design settings

This commit is contained in:
Hillel Coren 2016-01-31 23:42:20 +02:00
parent 13310a63d9
commit 387f89440c
14 changed files with 62 additions and 217 deletions

View File

@ -726,6 +726,8 @@ class AccountController extends BaseController
$account = Auth::user()->account;
$account->hide_quantity = Input::get('hide_quantity') ? true : false;
$account->hide_paid_to_date = Input::get('hide_paid_to_date') ? true : false;
$account->all_pages_header = Input::get('all_pages_header') ? true : false;
$account->all_pages_footer = Input::get('all_pages_footer') ? true : false;
$account->header_font_id = Input::get('header_font_id');
$account->body_font_id = Input::get('body_font_id');
$account->primary_color = Input::get('primary_color');

View File

@ -245,9 +245,14 @@ class AppController extends BaseController
Session::flush();
Artisan::call('optimize', array('--force' => true));
Artisan::call('migrate', array('--force' => true));
Artisan::call('db:seed', array('--force' => true, '--class' => 'PaymentLibrariesSeeder'));
Artisan::call('db:seed', array('--force' => true, '--class' => 'FontsSeeder'));
Artisan::call('db:seed', array('--force' => true, '--class' => 'BanksSeeder'));
foreach ([
'PaymentLibraries',
'Fonts',
'Banks',
'InvoiceStatus'
] as $seeder) {
Artisan::call('db:seed', array('--force' => true, '--class' => "{$seeder}Seeder"));
}
Event::fire(new UserSettingsChanged());
Session::flash('message', trans('texts.processed_updates'));
} catch (Exception $e) {

View File

@ -112,7 +112,7 @@ class DashboardController extends BaseController
->where('payments.account_id', '=', Auth::user()->account_id)
->where('payments.is_deleted', '=', false)
->where('invoices.is_deleted', '=', false)
->where('clients.deleted_at', '=', null)
->where('clients.is_deleted', '=', false)
->where('contacts.deleted_at', '=', null)
->where('contacts.is_primary', '=', true)
->select(['payments.payment_date', 'payments.amount', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id'])

View File

@ -429,6 +429,8 @@ class Invoice extends EntityModel implements BalanceAffecting
'secondary_color',
'hide_quantity',
'hide_paid_to_date',
'all_pages_header',
'all_pages_footer',
'custom_invoice_label1',
'custom_invoice_label2',
'pdf_email_attachment',

View File

@ -16,9 +16,7 @@ class DatabaseSeeder extends Seeder
$this->call('ConstantsSeeder');
$this->call('CountriesSeeder');
$this->call('PaymentLibrariesSeeder');
$this->call('FontsSeeder');
$this->call('BanksSeeder');
$this->call('FontsSeeder');
$this->call('InvoiceStatusSeeder');
}
}

View File

@ -1,187 +0,0 @@
<?php
/**
* Adds data to invitation for a user/client so that the
* public/payment/{aaabbb} page is accessable (aaabbb is the invitation_key)
**/
class SecurePaymentFormSeeder extends Seeder
{
public function run()
{
Eloquent::unguard();
//Delete table content
DB::table('invitations')->delete();
DB::table('invoices')->delete();
DB::table('contacts')->delete();
DB::table('clients')->delete();
DB::table('account_gateways')->delete();
//To reset the auto increment
$statement = "
ALTER TABLE invitations AUTO_INCREMENT = 1;
ALTER TABLE invoices AUTO_INCREMENT = 1;
ALTER TABLE contacts AUTO_INCREMENT = 1;
ALTER TABLE clients AUTO_INCREMENT = 1;
ALTER TABLE account_gateways AUTO_INCREMENT = 1;
";
DB::unprepared($statement);
//$firstName = 'Oscar';
// $lastName = 'Thompson';
// $firstName_2 = 'Philip';
// $lastName_2 = 'Jonsson';
//
// $user = AccountGateway::create(array(
// 'account_id' => 1,
// 'user_id' => 1,
// 'gateway_id' => 4,
// 'config' => '{"bla":"vla","bli":"cla"}',
// 'public_id' => 1,
// 'accepted_credit_cards' => 8
// ));
//
// $user2 = AccountGateway::create(array(
// 'account_id' => 2,
// 'user_id' => 2,
// 'gateway_id' => 5,
// 'config' => '{"bla":"vla","bli":"cla"}',
// 'public_id' => 2,
// 'accepted_credit_cards' => 7
// ));
//
// $client = Client::create(array(
// 'user_id' => 1,
// 'account_id' => 1,
// 'currency_id' => 1,
// 'name' => $firstName.' '.$lastName,
// 'address1' => '2119 Howe Course',
// 'address2' => '2118 Howe Course',
// 'city' => 'West Chazport',
// 'state' => 'Utah',
// 'postal_code' => '31572',
// 'country_id' => 752,
// 'work_phone' => '012-345678',
// 'private_notes' => 'bla bla bla bla bla bla bla',
// 'balance' => 10.4,
// 'paid_to_date' => 10.2,
// 'website' => 'awebsite.com',
// 'industry_id' => 8,
// 'is_deleted' => 0,
// 'payment_terms' => 2,
// 'public_id' => 1,
// 'custom_value1' => $firstName,
// 'custom_value2' => $firstName
// ));
//
// $client2 = Client::create(array(
// 'user_id' => 2,
// 'account_id' => 2,
// 'currency_id' => 1,
// 'name' => $firstName_2.' '.$lastName_2,
// 'address1' => '1118 Muma Road',
// 'address2' => '1118 Muma Road',
// 'city' => 'New Orleans',
// 'state' => 'Arizona',
// 'postal_code' => '31572',
// 'country_id' => 752,
// 'work_phone' => '012-345678',
// 'private_notes' => 'bla bla bla bla bla bla bla',
// 'balance' => 10.4,
// 'paid_to_date' => 10.2,
// 'website' => 'bodosite.com',
// 'industry_id' => 8,
// 'is_deleted' => 0,
// 'payment_terms' => 2,
// 'public_id' => 1,
// 'custom_value1' => $firstName_2,
// 'custom_value2' => $firstName_2
// ));
//
// $contact = Contact::create(array(
// 'account_id' => 1,
// 'user_id' => 1,
// 'client_id' => 1,
// 'is_primary' => 0,
// 'send_invoice' => 0,
// 'first_name' => $firstName,
// 'last_name' => $lastName,
// 'email' => 'an@email.com',
// 'phone' => '012-345678',
// 'public_id' => 1
// ));
//
// $contact2 = Contact::create(array(
// 'account_id' => 2,
// 'user_id' => 2,
// 'client_id' => 2,
// 'is_primary' => 0,
// 'send_invoice' => 0,
// 'first_name' => $firstName_2,
// 'last_name' => $lastName_2,
// 'email' => 'the@email.com',
// 'phone' => '012-345678',
// 'public_id' => 2
// ));
//
// $invoice = Invoice::create(array(
// 'client_id' => 1,
// 'user_id' => 1,
// 'account_id' => 1,
// 'invoice_number' => 1,
// 'discount' => 0.4,
// 'po_number' => $firstName,
// 'terms' => 'bla bla bla bla bla bla bla',
// 'public_notes' => 'bla bla bla bla bla bla bla',
// 'is_deleted' => 0,
// 'is_recurring' => 0,
// 'frequency_id' => 1,
// 'tax_name' => 'moms',
// 'tax_rate' => 33.0,
// 'amount' => 10.0,
// 'balance' => 8.0,
// 'public_id' => 1,
// 'is_quote' => 0
// ));
//
// $invoice2 = Invoice::create(array(
// 'client_id' => 2,
// 'user_id' => 2,
// 'account_id' => 2,
// 'invoice_number' => 2,
// 'discount' => 0.4,
// 'po_number' => $firstName_2,
// 'terms' => 'bla bla bla bla bla bla bla',
// 'public_notes' => 'bla bla bla bla bla bla bla',
// 'is_deleted' => 0,
// 'is_recurring' => 0,
// 'frequency_id' => 1,
// 'tax_name' => 'moms',
// 'tax_rate' => 33.0,
// 'amount' => 10.0,
// 'balance' => 8.0,
// 'public_id' => 2,
// 'is_quote' => 0
// ));
//
// $invitation = Invitation::create(array(
// 'account_id' => 1,
// 'user_id' => 1,
// 'contact_id' => 1,
// 'invoice_id' => 1,
// 'invitation_key' => 'aaabbb',
// 'transaction_reference' => 'bla bla bla bla bla bla bla',
// 'public_id' => 1
// ));
//
// $invitation2 = Invitation::create(array(
// 'account_id' => 2,
// 'user_id' => 2,
// 'contact_id' => 2,
// 'invoice_id' => 2,
// 'invitation_key' => 'cccddd',
// 'transaction_reference' => 'bla bla bla bla bla bla bla',
// 'public_id' => 2
// ));
}
}

View File

@ -30963,15 +30963,16 @@ function GetPdfMake(invoice, javascript, callback) {
}
}
// only show the header on the first page
// and the footer on the last page
if (key === 'header') {
return function(page, pages) {
return page === 1 ? val : '';
}
} else if (invoice.is_pro && key === 'footer') {
return function(page, pages) {
return page === pages ? val : '';
// determine whether or not to show the header/footer
if (invoice.is_pro) {
if (key === 'header') {
return function(page, pages) {
return page === 1 || account.all_pages_header ? val : '';
}
} else if (key === 'footer') {
return function(page, pages) {
return page === pages || account.all_pages_footer ? val : '';
}
}
}

View File

@ -54,15 +54,16 @@ function GetPdfMake(invoice, javascript, callback) {
}
}
// only show the header on the first page
// and the footer on the last page
if (key === 'header') {
return function(page, pages) {
return page === 1 ? val : '';
}
} else if (invoice.is_pro && key === 'footer') {
return function(page, pages) {
return page === pages ? val : '';
// determine whether or not to show the header/footer
if (invoice.is_pro) {
if (key === 'header') {
return function(page, pages) {
return page === 1 || account.all_pages_header ? val : '';
}
} else if (key === 'footer') {
return function(page, pages) {
return page === pages || account.all_pages_footer ? val : '';
}
}
}

View File

@ -1133,4 +1133,11 @@ return array(
'iframe_url_help3' => 'Note: if you plan on accepting credit cards we strongly recommend having HTTPS enabled on your site.',
'expense_error_multiple_currencies' => 'The expenses can\'t have different currencies.',
'expense_error_mismatch_currencies' => 'The client\'s currency does not match the expense currency.',
'trello_roadmap' => 'Trello Roadmap',
'header_footer' => 'Header/Footer',
'all_pages_header' => 'Header',
'all_pages_header_help' => 'Show on all pages',
'all_pages_footer' => 'Footer',
'all_pages_footer_help' => 'Show on all pages',
);

View File

@ -103,6 +103,8 @@
{!! Former::populate($account) !!}
{!! 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)) !!}
@foreach ($invoiceLabels as $field => $value)
{!! Former::populateField("labels_{$field}", $value) !!}
@ -119,6 +121,7 @@
<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>
</ul>
</div>
<div class="tab-content">
@ -194,6 +197,14 @@
</div>
</div>
<div role="tabpanel" class="tab-pane" id="headerFooter">
<div class="panel-body">
{!! Former::checkbox('all_pages_header')->text(trans('texts.all_pages_header_help')) !!}
{!! Former::checkbox('all_pages_footer')->text(trans('texts.all_pages_footer_help')) !!}
</div>
</div>
</div>
</div>
</div>

View File

@ -172,7 +172,11 @@
$(['current_password', 'newer_password', 'confirm_password']).each(function(i, field) {
var $input = $('form #'+field),
val = $.trim($input.val());
var isValid = val && val.length >= 6;
var isValid = val;
if (field != 'current_password') {
isValid = val.length >= 6;
}
if (isValid && field == 'confirm_password') {
isValid = val == $.trim($('#newer_password').val());

View File

@ -699,8 +699,9 @@
</div>
<p>&nbsp;</p>
<div class="container">
{{ trans('texts.powered_by') }} <a href="https://www.invoiceninja.com/?utm_source=powered_by" target="_blank">InvoiceNinja.com</a> -
{!! link_to(RELEASES_URL, 'v' . NINJA_VERSION, ['target' => '_blank']) !!} |
{{ trans('texts.powered_by') }}
{!! link_to('https://www.invoiceninja.com/?utm_source=powered_by', 'InvoiceNinja.com', ['target' => '_blank', 'title' => 'invoiceninja.com']) !!} -
{!! link_to(RELEASES_URL, 'v' . NINJA_VERSION, ['target' => '_blank', 'title' => trans('texts.trello_roadmap')]) !!} |
@if (Auth::user()->account->isWhiteLabel())
{{ trans('texts.white_labeled') }}
@else

View File

@ -40,7 +40,7 @@
)->split() !!}
{!! Button::primary(trans("texts.new_expense"))
->asLinkTo(URL::to("/expenses/create"))
->asLinkTo(URL::to("/expenses/create/{$vendor->public_id}"))
->appendIcon(Icon::create('plus-sign')) !!}
@endif
{!! Former::close() !!}

View File

@ -9,7 +9,7 @@
},
{
"stack": "$clientDetails",
"margin": [0, 80, 0, 0]
"margin": [0, 60, 0, 0]
}
]
},
@ -246,5 +246,5 @@
"color": "#737373"
}
},
"pageMargins": [40, 80, 40, 50]
"pageMargins": [40, 120, 40, 50]
}