mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add Payment Emailed Activity
This commit is contained in:
parent
4add5be307
commit
200bcd80b7
@ -11,33 +11,47 @@
|
||||
|
||||
namespace App\Listeners\Payment;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
|
||||
class PaymentEmailedActivity implements ShouldQueue
|
||||
{
|
||||
|
||||
use UserNotifies;
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
* @param ActivityRepository $activity_repo
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(ActivityRepository $activity_repo)
|
||||
{
|
||||
$this->activity_repo = $activity_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return bool
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
MultiDB::setDb($event->company->db);
|
||||
$payment = $event->payment;
|
||||
|
||||
$fields = new \stdClass();
|
||||
|
||||
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->payment->user_id;
|
||||
|
||||
$fields->user_id = $user_id;
|
||||
$fields->client_id = $event->payment->client_id;
|
||||
$fields->company_id = $event->payment->company_id;
|
||||
$fields->activity_type_id = Activity::PAYMENT_EMAILED;
|
||||
$fields->payment_id = $event->payment->id;
|
||||
|
||||
$this->activity_repo->save($fields, $event->payment, $event->event_vars);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +284,8 @@ class Activity extends StaticModel
|
||||
|
||||
const ACCEPT_PURCHASE_ORDER = 137;
|
||||
|
||||
const PAYMENT_EMAILED = 138;
|
||||
|
||||
protected $casts = [
|
||||
'is_system' => 'boolean',
|
||||
'updated_at' => 'timestamp',
|
||||
|
@ -171,6 +171,7 @@ use App\Listeners\Activity\VendorUpdatedActivity;
|
||||
use App\Listeners\Contact\UpdateContactLastLogin;
|
||||
use App\Listeners\Invoice\InvoiceDeletedActivity;
|
||||
use App\Listeners\Payment\PaymentBalanceActivity;
|
||||
use App\Listeners\Payment\PaymentEmailedActivity;
|
||||
use App\Listeners\Quote\QuoteCreatedNotification;
|
||||
use App\Listeners\Quote\QuoteEmailedNotification;
|
||||
use App\Events\Invoice\InvoiceWasEmailedAndFailed;
|
||||
@ -454,7 +455,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
InvitationViewedListener::class,
|
||||
],
|
||||
PaymentWasEmailed::class => [
|
||||
// PaymentEmailedActivity::class,
|
||||
PaymentEmailedActivity::class,
|
||||
],
|
||||
PaymentWasEmailedAndFailed::class => [
|
||||
// PaymentEmailFailureActivity::class,
|
||||
|
@ -11,9 +11,11 @@
|
||||
|
||||
namespace App\Services\Payment;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Payment;
|
||||
use App\Models\ClientContact;
|
||||
use App\Jobs\Payment\EmailPayment;
|
||||
use App\Events\Payment\PaymentWasEmailed;
|
||||
|
||||
class SendEmail
|
||||
{
|
||||
@ -36,6 +38,8 @@ class SendEmail
|
||||
// $invoice->invitations->each(function ($invitation) {
|
||||
// if (!$invitation->contact->trashed() && $invitation->contact->email) {
|
||||
EmailPayment::dispatch($this->payment, $this->payment->company, $this->contact);
|
||||
|
||||
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
@ -5024,6 +5024,8 @@ $LANG = array(
|
||||
'number_of_payments' => 'Number of payments',
|
||||
'number_of_payments_helper' => 'The number of times this payment will be made',
|
||||
'pre_payment_indefinitely' => 'Continue until cancelled',
|
||||
'notification_payment_emailed' => 'Payment :payment was emailed to :client',
|
||||
'notification_payment_emailed_subject' => 'Payment :payment was emailed',
|
||||
);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user