diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 566a40b56c..33d337a58f 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -542,7 +542,6 @@ class AccountController extends BaseController $data = [ 'account' => Auth::user()->account, 'title' => trans('texts.payment_terms'), - 'taxRates' => PaymentTerm::scope()->get(['id', 'name', 'num_days']), ]; return View::make('accounts.payment_terms', $data); diff --git a/app/Http/Controllers/PaymentTermController.php b/app/Http/Controllers/PaymentTermController.php index 65037b0f08..ee215b1b64 100644 --- a/app/Http/Controllers/PaymentTermController.php +++ b/app/Http/Controllers/PaymentTermController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\PaymentTerm; use App\Services\PaymentTermService; +use Auth; use Input; use Redirect; use Session; @@ -43,7 +44,9 @@ class PaymentTermController extends BaseController */ public function getDatatable() { - return $this->paymentTermService->getDatatable(); + $accountId = Auth::user()->account_id; + + return $this->paymentTermService->getDatatable($accountId); } /** diff --git a/app/Http/routes.php b/app/Http/routes.php index 9f13388e53..04d17603ee 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -266,6 +266,14 @@ Route::group([ Route::get('api/gateways', 'AccountGatewayController@getDatatable'); Route::post('account_gateways/bulk', 'AccountGatewayController@bulk'); + Route::get('payment_terms', 'PaymentTermController@index'); + Route::get('api/payment_terms', 'PaymentTermController@getDatatable'); + Route::get('payment_terms/create', 'PaymentTermController@create'); + Route::post('payment_terms', 'PaymentTermController@store'); + Route::put('payment_terms/{payment_terms}', 'PaymentTermController@update'); + Route::get('payment_terms/{payment_terms}/edit', 'PaymentTermController@edit'); + Route::post('payment_terms/bulk', 'PaymentTermController@bulk'); + Route::get('bank_accounts/import_ofx', 'BankAccountController@showImportOFX'); Route::post('bank_accounts/import_ofx', 'BankAccountController@doImportOFX'); Route::resource('bank_accounts', 'BankAccountController'); diff --git a/app/Ninja/Datatables/PaymentTermDatatable.php b/app/Ninja/Datatables/PaymentTermDatatable.php new file mode 100644 index 0000000000..d250f2f094 --- /dev/null +++ b/app/Ninja/Datatables/PaymentTermDatatable.php @@ -0,0 +1,37 @@ +public_id}/edit", trans('texts.payment_terms_net') . ' ' . ($model->num_days == -1 ? 0 : $model->num_days))->toHtml(); + }, + ], + ]; + } + + public function actions() + { + return [ + [ + trans('texts.edit_payment_term'), + function ($model) { + return URL::to("payment_terms/{$model->public_id}/edit"); + }, + ], + ]; + } +} diff --git a/app/Ninja/Repositories/PaymentTermRepository.php b/app/Ninja/Repositories/PaymentTermRepository.php index 1632d14d4b..5562f68524 100644 --- a/app/Ninja/Repositories/PaymentTermRepository.php +++ b/app/Ninja/Repositories/PaymentTermRepository.php @@ -14,7 +14,7 @@ class PaymentTermRepository extends BaseRepository public function find($accountId = 0) { return DB::table('payment_terms') - //->where('payment_terms.account_id', '=', $accountId) + ->where('payment_terms.account_id', '=', $accountId) ->where('payment_terms.deleted_at', '=', null) ->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at'); } diff --git a/app/Services/PaymentTermService.php b/app/Services/PaymentTermService.php index 77dfc7c868..ae8a413b8e 100644 --- a/app/Services/PaymentTermService.php +++ b/app/Services/PaymentTermService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Ninja\Repositories\PaymentTermRepository; +use App\Ninja\Datatables\PaymentTermDatatable; use URL; class PaymentTermService extends BaseService @@ -37,9 +38,11 @@ class PaymentTermService extends BaseService */ public function getDatatable($accountId = 0) { - $query = $this->paymentTermRepo->find(); + $datatable = new PaymentTermDatatable(false); - return $this->datatableService->createDatatable(ENTITY_PAYMENT_TERM, $query, false); + $query = $this->paymentTermRepo->find($accountId); + + return $this->datatableService->createDatatable($datatable, $query); } public function columns($entityType, $hideClient) diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 37a5b6d4c6..c94a14ab03 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', @@ -912,7 +912,7 @@ $LANG = array( 'expense_error_multiple_clients' => 'The expenses can\'t belong to different clients', 'expense_error_invoiced' => 'Expense has already been invoiced', 'convert_currency' => 'Convert currency', - 'num_days' => 'Number of days', + 'num_days' => 'Number of Days', 'create_payment_term' => 'Create Payment Term', 'edit_payment_terms' => 'Edit Payment Term', 'edit_payment_term' => 'Edit Payment Term', @@ -2384,7 +2384,10 @@ $LANG = array( 'your_statement' => 'Your Statement', 'statement_issued_to' => 'Statement issued to', 'statement_to' => 'Statement to', - + 'customize_options' => 'Customize options', + 'created_payment_term' => 'Successfully created payment term', + 'updated_payment_term' => 'Successfully updated payment term', + 'archived_payment_term' => 'Successfully archived payment term', ); return $LANG; diff --git a/resources/views/accounts/details.blade.php b/resources/views/accounts/details.blade.php index ca551840d2..8c9c719d29 100644 --- a/resources/views/accounts/details.blade.php +++ b/resources/views/accounts/details.blade.php @@ -97,7 +97,7 @@ {!! Former::select('payment_terms') ->addOption('','') ->fromQuery(Cache::get('paymentTerms'), 'name', 'num_days') - ->help(trans('texts.payment_terms_help')) !!} + ->help(trans('texts.payment_terms_help') . ' | ' . link_to('/settings/payment_terms', trans('texts.customize_options'))) !!} diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index 0c304d09a6..2e13ec72f2 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -171,10 +171,10 @@ {{ trans('texts.company_fields') }}
  • - {{ trans('texts.invoice_fields') }} + {{ trans('texts.product_fields') }}
  • - {{ trans('texts.product_fields') }} + {{ trans('texts.invoice_fields') }}
  • {{ trans('texts.invoice_charges') }} @@ -209,17 +209,6 @@ -
    -
    - - {!! Former::text('custom_invoice_text_label1') - ->label(trans('texts.field_label')) !!} - {!! Former::text('custom_invoice_text_label2') - ->label(trans('texts.field_label')) - ->help(trans('texts.custom_invoice_fields_helps')) !!} - -
    -
    @@ -231,6 +220,17 @@
    +
    +
    + + {!! Former::text('custom_invoice_text_label1') + ->label(trans('texts.field_label')) !!} + {!! Former::text('custom_invoice_text_label2') + ->label(trans('texts.field_label')) + ->help(trans('texts.custom_invoice_fields_helps')) !!} + +
    +
    diff --git a/resources/views/accounts/payment_term.blade.php b/resources/views/accounts/payment_term.blade.php index a1939995dc..a555670e90 100644 --- a/resources/views/accounts/payment_term.blade.php +++ b/resources/views/accounts/payment_term.blade.php @@ -1,13 +1,12 @@ @extends('header') -@section('content') +@section('content') @parent @include('accounts.nav', ['selected' => ACCOUNT_PAYMENT_TERMS]) {!! Former::open($url)->method($method) ->rules([ - 'name' => 'required', 'num_days' => 'required' ]) ->addClass('warn-on-exit') !!} @@ -23,13 +22,15 @@ {{ Former::populate($paymentTerm) }} @endif - {!! Former::text('name')->label('texts.name') !!} - {!! Former::text('num_days')->label('texts.num_days') !!} + {!! Former::text('num_days') + ->type('number') + ->min(1) + ->label('texts.num_days') !!}
    - {!! Former::actions( + {!! Former::actions( Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/payment_terms'))->appendIcon(Icon::create('remove-circle')), Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) ) !!} @@ -44,4 +45,4 @@ -@stop \ No newline at end of file +@stop diff --git a/resources/views/accounts/payment_terms.blade.php b/resources/views/accounts/payment_terms.blade.php index f88016991f..a2f574883c 100644 --- a/resources/views/accounts/payment_terms.blade.php +++ b/resources/views/accounts/payment_terms.blade.php @@ -1,6 +1,6 @@ @extends('header') -@section('content') +@section('content') @parent @include('accounts.nav', ['selected' => ACCOUNT_PAYMENT_TERMS]) @@ -12,22 +12,21 @@ @include('partials.bulk_form', ['entityType' => ENTITY_PAYMENT_TERM]) - {!! Datatable::table() + {!! Datatable::table() ->addColumn( - trans('texts.name'), trans('texts.num_days'), trans('texts.action')) - ->setUrl(url('api/payment_terms/')) + ->setUrl(url('api/payment_terms/')) ->setOptions('sPaginationType', 'bootstrap') - ->setOptions('bFilter', false) - ->setOptions('bAutoWidth', false) - ->setOptions('aoColumns', [[ "sWidth"=> "40%" ], [ "sWidth"=> "40%" ], ["sWidth"=> "20%"]]) - ->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[2]]]) + ->setOptions('bFilter', false) + ->setOptions('bAutoWidth', false) + ->setOptions('aoColumns', [[ "sWidth"=> "50%" ], [ "sWidth"=> "50%" ]]) + ->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[1]]]) ->render('datatable') !!} + -@stop \ No newline at end of file +@stop