1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Enabled sending payment confirmation email for manual payment entries

This commit is contained in:
Hillel Coren 2015-06-14 20:30:01 +03:00
parent 43556928ec
commit a301e58609
5 changed files with 27 additions and 4 deletions

View File

@ -733,14 +733,19 @@ class PaymentController extends BaseController
->withErrors($errors)
->withInput();
} else {
$this->paymentRepo->save($publicId, Input::all());
$payment = $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'));
if (Input::get('email_receipt')) {
$this->contactMailer->sendPaymentConfirmation($payment);
Session::flash('message', trans('texts.created_payment_emailed_client'));
} else {
Session::flash('message', trans('texts.created_payment'));
}
return Redirect::to('clients/'.Input::get('client'));
}

View File

@ -22,6 +22,11 @@ class Payment extends EntityModel
return $this->belongsTo('App\Models\Client')->withTrashed();
}
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
public function account()
{
return $this->belongsTo('App\Models\Account');

View File

@ -84,8 +84,15 @@ class ContactMailer extends Mailer
$data = ['body' => str_replace(array_keys($variables), array_values($variables), $emailTemplate)];
$user = $payment->invitation->user;
$this->sendTo($payment->contact->email, $user->email, $accountName, $subject, $view, $data);
if ($payment->invitation) {
$user = $payment->invitation->user;
$contact = $payment->contact->email;
} else {
$user = $payment->user;
$contact = $payment->client->contacts[0];
}
$this->sendTo($contact->email, $user->email, $accountName, $subject, $view, $data);
}
public function sendLicensePaymentConfirmation($name, $email, $amount, $license, $productId)

View File

@ -694,5 +694,7 @@ return array(
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
'email_receipt' => 'Email payment receipt to the client',
'created_payment_emailed_client' => 'Successfully created payment and emailed client',
);

View File

@ -32,6 +32,10 @@
{!! Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') !!}
{!! Former::text('transaction_reference') !!}
@if (!$payment)
{!! Former::checkbox('email_receipt')->label('&nbsp;')->text(trans('texts.email_receipt')) !!}
@endif
</div>
</div>