From 32d5a25f61db9edbb72dfb3af23c7e3759bd589c Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 19 Apr 2016 14:26:42 +0300 Subject: [PATCH] Enabled specifying invoice padding --- app/Http/Controllers/AccountController.php | 1 + app/Models/Account.php | 4 ++-- resources/lang/en/texts.php | 2 ++ resources/views/accounts/invoice_settings.blade.php | 9 +++++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 074e03d9e38d..099f252ca3b8 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -753,6 +753,7 @@ class AccountController extends BaseController $account->custom_invoice_item_label1 = trim(Input::get('custom_invoice_item_label1')); $account->custom_invoice_item_label2 = trim(Input::get('custom_invoice_item_label2')); + $account->invoice_number_padding = Input::get('invoice_number_padding'); $account->invoice_number_counter = Input::get('invoice_number_counter'); $account->quote_number_prefix = Input::get('quote_number_prefix'); $account->share_counter = Input::get('share_counter') ? true : false; diff --git a/app/Models/Account.php b/app/Models/Account.php index 351901d3fa6c..8d1261d92884 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -551,7 +551,7 @@ class Account extends Eloquent $replace = [date('Y')]; $search[] = '{$counter}'; - $replace[] = str_pad($this->getCounter($invoice->is_quote), 4, '0', STR_PAD_LEFT); + $replace[] = str_pad($this->getCounter($invoice->is_quote), $this->invoice_number_padding, '0', STR_PAD_LEFT); if (strstr($pattern, '{$userId}')) { $search[] = '{$userId}'; @@ -617,7 +617,7 @@ class Account extends Eloquent // confirm the invoice number isn't already taken do { - $number = $prefix . str_pad($counter, 4, '0', STR_PAD_LEFT); + $number = $prefix . str_pad($counter, $this->invoice_number_padding, '0', STR_PAD_LEFT); $check = Invoice::scope(false, $this->id)->whereInvoiceNumber($number)->withTrashed()->first(); $counter++; $counterOffset++; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 94f7734a74cd..88009352202a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1130,6 +1130,8 @@ $LANG = array( 'live_preview' => 'Live Preview', 'page_size' => 'Page Size', 'live_preview_disabled' => 'Live preview has been disabled to support selected font', + 'invoice_number_padding' => 'Padding', + ); return $LANG; diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index 09b730737e0d..ed8498143b09 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -59,12 +59,13 @@ {!! Former::text('invoice_number_prefix') ->addGroupClass('invoice-prefix') - ->label(' ') !!} + ->label(trans('texts.prefix')) !!} {!! Former::text('invoice_number_pattern') ->appendIcon('question-sign') ->addGroupClass('invoice-pattern') - ->label(' ') + ->label(trans('texts.pattern')) ->addGroupClass('number-pattern') !!} + {!! Former::text('invoice_number_padding') !!} {!! Former::text('invoice_number_counter') ->label(trans('texts.counter')) ->help(trans('texts.invoice_number_help') . ' ' . @@ -84,12 +85,12 @@ {!! Former::text('quote_number_prefix') ->addGroupClass('quote-prefix') - ->label(' ') !!} + ->label(trans('texts.prefix')) !!} {!! Former::text('quote_number_pattern') ->appendIcon('question-sign') ->addGroupClass('quote-pattern') ->addGroupClass('number-pattern') - ->label(' ') !!} + ->label(trans('texts.pattern')) !!} {!! Former::text('quote_number_counter') ->label(trans('texts.counter')) ->addGroupClass('pad-checkbox')