Support sending payment email #1477

This commit is contained in:
Hillel Coren 2017-05-16 13:13:53 +03:00
parent 432e3cf3ab
commit ec56df33ce
3 changed files with 26 additions and 6 deletions

View File

@ -6,6 +6,7 @@ use App\Http\Requests\CreatePaymentRequest;
use App\Http\Requests\PaymentRequest; use App\Http\Requests\PaymentRequest;
use App\Http\Requests\UpdatePaymentRequest; use App\Http\Requests\UpdatePaymentRequest;
use App\Models\Client; use App\Models\Client;
use App\Models\Payment;
use App\Models\Credit; use App\Models\Credit;
use App\Models\Invoice; use App\Models\Invoice;
use App\Ninja\Datatables\PaymentDatatable; use App\Ninja\Datatables\PaymentDatatable;
@ -136,7 +137,10 @@ class PaymentController extends BaseController
if ($payment->invoiceJsonBackup()) { 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/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[] = ['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()) { if ($payment->canBeRefunded()) {
$actions[] = ['url' => "javascript:showRefundModal({$payment->public_id}, \"{$payment->getCompletedAmount()}\", \"{$payment->present()->completedAmount}\", \"{$payment->present()->currencySymbol}\")", 'label' => trans('texts.refund_payment')]; $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) 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(); return self::bulk();
} }
@ -234,11 +238,17 @@ class PaymentController extends BaseController
$action = Input::get('action'); $action = Input::get('action');
$amount = Input::get('refund_amount'); $amount = Input::get('refund_amount');
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->paymentService->bulk($ids, $action, ['refund_amount' => $amount]);
if ($count > 0) { if ($action === 'email') {
$message = Utils::pluralize($action == 'refund' ? 'refunded_payment' : $action.'d_payment', $count); $payment = Payment::scope($ids)->first();
Session::flash('message', $message); $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); return $this->returnBulk(ENTITY_PAYMENT, $action, $ids);

View File

@ -122,6 +122,15 @@ class PaymentDatatable extends EntityDatatable
return Auth::user()->can('editByOwner', [ENTITY_PAYMENT, $model->user_id]); 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'), trans('texts.refund_payment'),
function ($model) { function ($model) {

View File

@ -2246,7 +2246,8 @@ $LANG = array(
'plan_price' => 'Plan Price', 'plan_price' => 'Plan Price',
'wrong_confirmation' => 'Incorrect confirmation code', 'wrong_confirmation' => 'Incorrect confirmation code',
'oauth_taken' => 'The account is already registered', 'oauth_taken' => 'The account is already registered',
'emailed_payment' => 'Successfully emailed payment',
'email_payment' => 'Email Payment',
); );
return $LANG; return $LANG;