1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 16:42:48 +01:00

Added default payment method #1273

This commit is contained in:
Hillel Coren 2017-02-23 20:20:15 +02:00
parent d89690ebe4
commit 5be79d4208
6 changed files with 67 additions and 21 deletions

View File

@ -11,6 +11,7 @@ use App\Ninja\Datatables\PaymentDatatable;
use App\Ninja\Mailers\ContactMailer; use App\Ninja\Mailers\ContactMailer;
use App\Ninja\Repositories\PaymentRepository; use App\Ninja\Repositories\PaymentRepository;
use App\Services\PaymentService; use App\Services\PaymentService;
use Auth;
use Cache; use Cache;
use DropdownButton; use DropdownButton;
use Input; use Input;
@ -93,6 +94,7 @@ class PaymentController extends BaseController
->orderBy('invoice_number')->get(); ->orderBy('invoice_number')->get();
$data = [ $data = [
'account' => Auth::user()->account,
'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0), 'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : ($request->invoice_id ?: 0), 'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : ($request->invoice_id ?: 0),
'invoice' => null, 'invoice' => null,
@ -148,6 +150,7 @@ class PaymentController extends BaseController
} }
$data = [ $data = [
'account' => Auth::user()->account,
'client' => null, 'client' => null,
'invoice' => null, 'invoice' => null,
'invoices' => Invoice::scope() 'invoices' => Invoice::scope()

View File

@ -92,6 +92,7 @@ class Account extends Eloquent
'enable_email_markup', 'enable_email_markup',
'domain_id', 'domain_id',
'payment_terms', 'payment_terms',
'payment_type_id',
]; ];
/** /**

View File

@ -32,6 +32,7 @@ class AddCustomProductFields extends Migration
Schema::table('accounts', function ($table) { Schema::table('accounts', function ($table) {
$table->smallInteger('reset_counter_frequency_id')->nullable(); $table->smallInteger('reset_counter_frequency_id')->nullable();
$table->smallInteger('payment_type_id')->nullable();
}); });
DB::table('currencies')->where('code', '=', 'HKR')->update(['code' => 'HRK']); DB::table('currencies')->where('code', '=', 'HKR')->update(['code' => 'HRK']);
@ -73,6 +74,7 @@ class AddCustomProductFields extends Migration
Schema::table('accounts', function ($table) { Schema::table('accounts', function ($table) {
$table->dropColumn('reset_counter_frequency_id'); $table->dropColumn('reset_counter_frequency_id');
$table->dropColumn('payment_type_id');
}); });
DB::table('currencies')->where('code', '=', 'HRK')->update(['code' => 'HKR']); DB::table('currencies')->where('code', '=', 'HRK')->update(['code' => 'HKR']);

View File

@ -614,7 +614,7 @@ $LANG = array(
'or' => 'or', 'or' => 'or',
'email_error' => 'There was a problem sending the email', 'email_error' => 'There was a problem sending the email',
'confirm_recurring_timing' => 'Note: emails are sent at the start of the hour.', '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 <b>invoice due date</b>.',
'unlink_account' => 'Unlink Account', 'unlink_account' => 'Unlink Account',
'unlink' => 'Unlink', 'unlink' => 'Unlink',
'show_address' => 'Show Address', 'show_address' => 'Show Address',
@ -2378,6 +2378,8 @@ $LANG = array(
'custom_product_fields_help' => 'Add a field when creating a product or invoice and display the label and value on the PDF.', '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_two_months' => 'Two months',
'freq_yearly' => 'Annually', 'freq_yearly' => 'Annually',
'profile' => 'Profile',
'payment_type_help' => 'Sets the default <b>payment type</b>.',
); );

View File

@ -59,20 +59,6 @@
</div> </div>
@endif @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') !!}
</div> </div>
</div> </div>
@ -96,14 +82,62 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.signature') !!}</h3> <h3 class="panel-title">{!! trans('texts.settings') !!}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body form-padding-right">
<div class="col-md-10 col-md-offset-1"> <div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active">
<a href="#defaults" aria-controls="client_fields" role="tab" data-toggle="tab">{{ trans('texts.defaults') }}</a>
</li>
<li role="presentation">
<a href="#profile" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.profile') }}</a>
</li>
<li role="presentation">
<a href="#signature" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.signature') }}</a>
</li>
</ul>
</div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="defaults">
<br/>&nbsp;<br/>
{!! 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')) !!}
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<br/>&nbsp;<br/>
{!! Former::select('size_id')
->addOption('','')
->fromQuery($sizes, 'name', 'id') !!}
{!! Former::select('industry_id')
->addOption('','')
->fromQuery($industries, 'name', 'id')
->help('texts.industry_help') !!}
</div>
<div role="tabpanel" class="tab-pane" id="signature">
<br/>
{!! Former::textarea('email_footer')->style('display:none')->raw() !!} {!! Former::textarea('email_footer')->style('display:none')->raw() !!}
<div id="signatureEditor" class="form-control" style="min-height:160px" onclick="focusEditor()"></div> <div id="signatureEditor" class="form-control" style="min-height:160px" onclick="focusEditor()"></div>
@include('partials/quill_toolbar', ['name' => 'signature']) @include('partials/quill_toolbar', ['name' => 'signature'])
</div>
</div>
<div class="col-md-10 col-md-offset-1">
</div> </div>
</div> </div>

View File

@ -26,6 +26,10 @@
@if ($payment) @if ($payment)
{!! Former::populate($payment) !!} {!! Former::populate($payment) !!}
@else
@if ($account->payment_type_id)
{!! Former::populateField('payment_type_id', $account->payment_type_id) !!}
@endif
@endif @endif
<span style="display:none"> <span style="display:none">