From 5be79d4208a8a4e8486ccf1bfe043806d76d0204 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 23 Feb 2017 20:20:15 +0200 Subject: [PATCH] Added default payment method #1273 --- app/Http/Controllers/PaymentController.php | 3 + app/Models/Account.php | 1 + ...02_23_095934_add_custom_product_fields.php | 2 + resources/lang/en/texts.php | 6 +- resources/views/accounts/details.blade.php | 72 ++++++++++++++----- resources/views/payments/edit.blade.php | 4 ++ 6 files changed, 67 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 8afd5cedfe..3597c3f477 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -11,6 +11,7 @@ use App\Ninja\Datatables\PaymentDatatable; use App\Ninja\Mailers\ContactMailer; use App\Ninja\Repositories\PaymentRepository; use App\Services\PaymentService; +use Auth; use Cache; use DropdownButton; use Input; @@ -93,6 +94,7 @@ class PaymentController extends BaseController ->orderBy('invoice_number')->get(); $data = [ + 'account' => Auth::user()->account, 'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0), 'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : ($request->invoice_id ?: 0), 'invoice' => null, @@ -148,6 +150,7 @@ class PaymentController extends BaseController } $data = [ + 'account' => Auth::user()->account, 'client' => null, 'invoice' => null, 'invoices' => Invoice::scope() diff --git a/app/Models/Account.php b/app/Models/Account.php index 84e1156397..fb907d01c8 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -92,6 +92,7 @@ class Account extends Eloquent 'enable_email_markup', 'domain_id', 'payment_terms', + 'payment_type_id', ]; /** diff --git a/database/migrations/2017_02_23_095934_add_custom_product_fields.php b/database/migrations/2017_02_23_095934_add_custom_product_fields.php index e060f8be07..2d97141149 100644 --- a/database/migrations/2017_02_23_095934_add_custom_product_fields.php +++ b/database/migrations/2017_02_23_095934_add_custom_product_fields.php @@ -32,6 +32,7 @@ class AddCustomProductFields extends Migration Schema::table('accounts', function ($table) { $table->smallInteger('reset_counter_frequency_id')->nullable(); + $table->smallInteger('payment_type_id')->nullable(); }); DB::table('currencies')->where('code', '=', 'HKR')->update(['code' => 'HRK']); @@ -73,6 +74,7 @@ class AddCustomProductFields extends Migration Schema::table('accounts', function ($table) { $table->dropColumn('reset_counter_frequency_id'); + $table->dropColumn('payment_type_id'); }); DB::table('currencies')->where('code', '=', 'HRK')->update(['code' => 'HKR']); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 47443ab258..21eec3b8a5 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -614,7 +614,7 @@ $LANG = array( 'or' => 'or', 'email_error' => 'There was a problem sending the email', 'confirm_recurring_timing' => 'Note: emails are sent at the start of the hour.', - 'payment_terms_help' => 'Sets the default invoice due date', + 'payment_terms_help' => 'Sets the default invoice due date.', 'unlink_account' => 'Unlink Account', 'unlink' => 'Unlink', 'show_address' => 'Show Address', @@ -2378,7 +2378,9 @@ $LANG = array( 'custom_product_fields_help' => 'Add a field when creating a product or invoice and display the label and value on the PDF.', 'freq_two_months' => 'Two months', 'freq_yearly' => 'Annually', - + 'profile' => 'Profile', + 'payment_type_help' => 'Sets the default payment type.', + ); return $LANG; diff --git a/resources/views/accounts/details.blade.php b/resources/views/accounts/details.blade.php index 21b83738b2..d47dd2e14e 100644 --- a/resources/views/accounts/details.blade.php +++ b/resources/views/accounts/details.blade.php @@ -59,20 +59,6 @@ @endif - {!! Former::select('payment_terms') - ->addOption('','') - ->fromQuery(Cache::get('paymentTerms'), 'name', 'num_days') - ->help(trans('texts.payment_terms_help')) !!} - - {!! Former::select('size_id') - ->addOption('','') - ->fromQuery($sizes, 'name', 'id') !!} - - {!! Former::select('industry_id') - ->addOption('','') - ->fromQuery($industries, 'name', 'id') - ->help('texts.industry_help') !!} - @@ -96,14 +82,62 @@
-

{!! trans('texts.signature') !!}

+

{!! trans('texts.settings') !!}

-
+
+ +
+ +
+
+
+ +
 
+ {!! Former::select('payment_type_id') + ->addOption('','') + ->fromQuery(Cache::get('paymentTypes'), 'name', 'num_days') + ->help(trans('texts.payment_type_help')) !!} + + {!! Former::select('payment_terms') + ->addOption('','') + ->fromQuery(Cache::get('paymentTerms'), 'name', 'num_days') + ->help(trans('texts.payment_terms_help')) !!} + +
+
+ +
 
+ {!! Former::select('size_id') + ->addOption('','') + ->fromQuery($sizes, 'name', 'id') !!} + + {!! Former::select('industry_id') + ->addOption('','') + ->fromQuery($industries, 'name', 'id') + ->help('texts.industry_help') !!} + +
+
+ +
+ {!! Former::textarea('email_footer')->style('display:none')->raw() !!} +
+ @include('partials/quill_toolbar', ['name' => 'signature']) + +
+
- {!! Former::textarea('email_footer')->style('display:none')->raw() !!} -
- @include('partials/quill_toolbar', ['name' => 'signature'])
diff --git a/resources/views/payments/edit.blade.php b/resources/views/payments/edit.blade.php index 6647f5f545..21cf8108eb 100644 --- a/resources/views/payments/edit.blade.php +++ b/resources/views/payments/edit.blade.php @@ -26,6 +26,10 @@ @if ($payment) {!! Former::populate($payment) !!} + @else + @if ($account->payment_type_id) + {!! Former::populateField('payment_type_id', $account->payment_type_id) !!} + @endif @endif