diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index ad5a94ccebcc..69383e337194 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -6,6 +6,7 @@ use App\Http\Requests\CreatePaymentRequest; use App\Http\Requests\PaymentRequest; use App\Http\Requests\UpdatePaymentRequest; use App\Models\Client; +use App\Models\Payment; use App\Models\Credit; use App\Models\Invoice; use App\Ninja\Datatables\PaymentDatatable; @@ -136,7 +137,10 @@ class PaymentController extends BaseController if ($payment->invoiceJsonBackup()) { $actions[] = ['url' => url("/invoices/invoice_history/{$payment->invoice->public_id}?payment_id={$payment->public_id}"), 'label' => trans('texts.view_invoice')]; } + $actions[] = ['url' => url("/invoices/{$payment->invoice->public_id}/edit"), 'label' => trans('texts.edit_invoice')]; + $actions[] = DropdownButton::DIVIDER; + $actions[] = ['url' => 'javascript:submitAction("email")', 'label' => trans('texts.email_payment')]; if ($payment->canBeRefunded()) { $actions[] = ['url' => "javascript:showRefundModal({$payment->public_id}, \"{$payment->getCompletedAmount()}\", \"{$payment->present()->completedAmount}\", \"{$payment->present()->currencySymbol}\")", 'label' => trans('texts.refund_payment')]; @@ -215,7 +219,7 @@ class PaymentController extends BaseController */ public function update(UpdatePaymentRequest $request) { - if (in_array($request->action, ['archive', 'delete', 'restore', 'refund'])) { + if (in_array($request->action, ['archive', 'delete', 'restore', 'refund', 'email'])) { return self::bulk(); } @@ -234,11 +238,17 @@ class PaymentController extends BaseController $action = Input::get('action'); $amount = Input::get('refund_amount'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids'); - $count = $this->paymentService->bulk($ids, $action, ['refund_amount' => $amount]); - if ($count > 0) { - $message = Utils::pluralize($action == 'refund' ? 'refunded_payment' : $action.'d_payment', $count); - Session::flash('message', $message); + if ($action === 'email') { + $payment = Payment::scope($ids)->first(); + $this->contactMailer->sendPaymentConfirmation($payment); + Session::flash('message', trans('texts.emailed_payment')); + } else { + $count = $this->paymentService->bulk($ids, $action, ['refund_amount' => $amount]); + if ($count > 0) { + $message = Utils::pluralize($action == 'refund' ? 'refunded_payment' : $action.'d_payment', $count); + Session::flash('message', $message); + } } return $this->returnBulk(ENTITY_PAYMENT, $action, $ids); diff --git a/app/Ninja/Datatables/PaymentDatatable.php b/app/Ninja/Datatables/PaymentDatatable.php index e09e1f8db8f8..2da386dc106d 100644 --- a/app/Ninja/Datatables/PaymentDatatable.php +++ b/app/Ninja/Datatables/PaymentDatatable.php @@ -122,6 +122,15 @@ class PaymentDatatable extends EntityDatatable return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]); }, ], + [ + trans('texts.email_payment'), + function ($model) { + return "javascript:submitForm_payment('email', {$model->public_id})"; + }, + function ($model) { + return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]); + }, + ], [ trans('texts.refund_payment'), function ($model) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 0f65924de8aa..68d19a4e536a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2246,7 +2246,8 @@ $LANG = array( 'plan_price' => 'Plan Price', 'wrong_confirmation' => 'Incorrect confirmation code', 'oauth_taken' => 'The account is already registered', - + 'emailed_payment' => 'Successfully emailed payment', + 'email_payment' => 'Email Payment', ); return $LANG;