mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added ability to edit payments
This commit is contained in:
parent
d57fe62c49
commit
dc23bad422
@ -71,7 +71,9 @@ class PaymentController extends \BaseController
|
|||||||
<ul class="dropdown-menu" role="menu">';
|
<ul class="dropdown-menu" role="menu">';
|
||||||
|
|
||||||
if (!$model->deleted_at || $model->deleted_at == '0000-00-00') {
|
if (!$model->deleted_at || $model->deleted_at == '0000-00-00') {
|
||||||
$str .= '<li><a href="javascript:archiveEntity('.$model->public_id.')">'.trans('texts.archive_payment').'</a></li>';
|
$str .= '<li><a href="payments/'.$model->public_id.'/edit">'.trans('texts.edit_payment').'</a></li>
|
||||||
|
<li class="divider"></li>
|
||||||
|
<li><a href="javascript:archiveEntity('.$model->public_id.')">'.trans('texts.archive_payment').'</a></li>';
|
||||||
} else {
|
} else {
|
||||||
$str .= '<li><a href="javascript:restoreEntity('.$model->public_id.')">'.trans('texts.restore_payment').'</a></li>';
|
$str .= '<li><a href="javascript:restoreEntity('.$model->public_id.')">'.trans('texts.restore_payment').'</a></li>';
|
||||||
}
|
}
|
||||||
@ -141,7 +143,7 @@ class PaymentController extends \BaseController
|
|||||||
'payment' => $payment,
|
'payment' => $payment,
|
||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'payments/'.$publicId,
|
'url' => 'payments/'.$publicId,
|
||||||
'title' => 'Edit Payment',
|
'title' => trans('texts.edit_payment'),
|
||||||
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
||||||
@ -687,7 +689,7 @@ class PaymentController extends \BaseController
|
|||||||
|
|
||||||
private function save($publicId = null)
|
private function save($publicId = null)
|
||||||
{
|
{
|
||||||
if ($errors = $this->paymentRepo->getErrors(Input::all())) {
|
if (!$publicId && $errors = $this->paymentRepo->getErrors(Input::all())) {
|
||||||
$url = $publicId ? 'payments/'.$publicId.'/edit' : 'payments/create';
|
$url = $publicId ? 'payments/'.$publicId.'/edit' : 'payments/create';
|
||||||
|
|
||||||
return Redirect::to($url)
|
return Redirect::to($url)
|
||||||
@ -696,11 +698,15 @@ class PaymentController extends \BaseController
|
|||||||
} else {
|
} else {
|
||||||
$this->paymentRepo->save($publicId, Input::all());
|
$this->paymentRepo->save($publicId, Input::all());
|
||||||
|
|
||||||
|
if ($publicId) {
|
||||||
|
Session::flash('message', trans('texts.updated_payment'));
|
||||||
|
return Redirect::to('payments/');
|
||||||
|
} else {
|
||||||
Session::flash('message', trans('texts.created_payment'));
|
Session::flash('message', trans('texts.created_payment'));
|
||||||
|
|
||||||
return Redirect::to('clients/'.Input::get('client'));
|
return Redirect::to('clients/'.Input::get('client'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function bulk()
|
public function bulk()
|
||||||
{
|
{
|
||||||
|
@ -497,4 +497,7 @@ return array(
|
|||||||
'select_versiony' => 'Select version',
|
'select_versiony' => 'Select version',
|
||||||
'view_history' => 'View History',
|
'view_history' => 'View History',
|
||||||
|
|
||||||
|
'edit_payment' => 'Edit Payment',
|
||||||
|
'updated_payment' => 'Successfully updated payment',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -94,6 +94,11 @@ class PaymentRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$paymentTypeId = $input['payment_type_id'] ? $input['payment_type_id'] : null;
|
$paymentTypeId = $input['payment_type_id'] ? $input['payment_type_id'] : null;
|
||||||
|
$payment->payment_type_id = $paymentTypeId;
|
||||||
|
$payment->payment_date = Utils::toSqlDate($input['payment_date']);
|
||||||
|
$payment->transaction_reference = trim($input['transaction_reference']);
|
||||||
|
|
||||||
|
if (!$publicId) {
|
||||||
$clientId = Client::getPrivateId($input['client']);
|
$clientId = Client::getPrivateId($input['client']);
|
||||||
$amount = Utils::parseFloat($input['amount']);
|
$amount = Utils::parseFloat($input['amount']);
|
||||||
|
|
||||||
@ -113,10 +118,9 @@ class PaymentRepository
|
|||||||
|
|
||||||
$payment->client_id = $clientId;
|
$payment->client_id = $clientId;
|
||||||
$payment->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null;
|
$payment->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null;
|
||||||
$payment->payment_type_id = $paymentTypeId;
|
|
||||||
$payment->payment_date = Utils::toSqlDate($input['payment_date']);
|
|
||||||
$payment->amount = $amount;
|
$payment->amount = $amount;
|
||||||
$payment->transaction_reference = trim($input['transaction_reference']);
|
}
|
||||||
|
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
|
||||||
return $payment;
|
return $payment;
|
||||||
|
@ -132,9 +132,6 @@ Route::group(array('before' => 'auth'), function() {
|
|||||||
Route::get('api/quotes/{client_id?}', array('as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable'));
|
Route::get('api/quotes/{client_id?}', array('as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable'));
|
||||||
Route::post('quotes/bulk', 'QuoteController@bulk');
|
Route::post('quotes/bulk', 'QuoteController@bulk');
|
||||||
|
|
||||||
Route::get('payments/{id}/edit', function() {
|
|
||||||
return View::make('header');
|
|
||||||
});
|
|
||||||
Route::resource('payments', 'PaymentController');
|
Route::resource('payments', 'PaymentController');
|
||||||
Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create');
|
Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create');
|
||||||
Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
|
Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
|
||||||
|
@ -14,12 +14,19 @@
|
|||||||
'amount' => 'required',
|
'amount' => 'required',
|
||||||
)); }}
|
)); }}
|
||||||
|
|
||||||
|
@if ($payment)
|
||||||
|
{{ Former::populate($payment) }}
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
|
|
||||||
|
@if (!$payment)
|
||||||
{{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }}
|
{{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }}
|
||||||
{{ Former::select('invoice')->addOption('', '')->addGroupClass('invoice-select') }}
|
{{ Former::select('invoice')->addOption('', '')->addGroupClass('invoice-select') }}
|
||||||
{{ Former::text('amount') }}
|
{{ Former::text('amount') }}
|
||||||
|
@endif
|
||||||
|
|
||||||
{{ Former::select('payment_type_id')->addOption('','')
|
{{ Former::select('payment_type_id')->addOption('','')
|
||||||
->fromQuery($paymentTypes, 'name', 'id') }}
|
->fromQuery($paymentTypes, 'name', 'id') }}
|
||||||
{{ Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
|
{{ Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }}
|
||||||
@ -35,7 +42,7 @@
|
|||||||
|
|
||||||
<center class="buttons">
|
<center class="buttons">
|
||||||
{{ Button::lg_primary_submit_success(trans('texts.save'))->append_with_icon('floppy-disk') }}
|
{{ Button::lg_primary_submit_success(trans('texts.save'))->append_with_icon('floppy-disk') }}
|
||||||
{{ Button::lg_default_link('payments/' . ($payment ? $payment->public_id : ''), trans('texts.cancel'))->append_with_icon('remove-circle'); }}
|
{{ Button::lg_default_link('payments/', trans('texts.cancel'))->append_with_icon('remove-circle'); }}
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
{{ Former::close() }}
|
{{ Former::close() }}
|
||||||
@ -47,10 +54,14 @@
|
|||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
@if ($payment)
|
||||||
|
$('#payment_date').datepicker('update', '{{ $payment->payment_date }}')
|
||||||
|
@else
|
||||||
|
$('#payment_date').datepicker('update', new Date());
|
||||||
populateInvoiceComboboxes({{ $clientPublicId }}, {{ $invoicePublicId }});
|
populateInvoiceComboboxes({{ $clientPublicId }}, {{ $invoicePublicId }});
|
||||||
|
@endif
|
||||||
|
|
||||||
$('#payment_type_id').combobox();
|
$('#payment_type_id').combobox();
|
||||||
$('#payment_date').datepicker('update', new Date());
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user