email payment proof

This commit is contained in:
edmondlang
2023-06-03 15:48:33 +08:00
parent 4bd28e3cca
commit 6b73f31993
5 changed files with 146 additions and 2 deletions
@@ -0,0 +1,42 @@
<?php
namespace App\Classes\Jobs;
use App\Classes\Notifications\PaymentProofUploadedEmail;
use App\Models\Booking;
use App\Models\User;
use App\Models\UserEmailVerification;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SendUserPaymentProofUploadedEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** @var User */
private $user;
/** @var Booking */
private $booking;
/**
* SendUserVerificationEmail constructor.
* @param User $user
* @param UserEmailVerification $attempt
*/
public function __construct(User $user, Booking $booking)
{
$this->user = $user;
$this->booking = $booking;
}
public function handle()
{
$this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking));
}
}
@@ -14,6 +14,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\CompanyType;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\Jobs\SendUserPaymentProofUploadedEmail;
use App\Models\Company;
use App\Models\Document;
use Illuminate\Http\JsonResponse;
@@ -50,6 +51,9 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
/** @var CreateInvoiceTransactionProcessor */
private $createInvoiceTransactionProcessor;
/** @var SendUserPaymentProofUploadedEmail */
private $sendUserPaymentProofUploadedEmail;
/**
* CreatePaymentProofDocumentLogic constructor.
* @param FetchesTransaction $fetchesTransaction
@@ -58,13 +62,14 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
* @param UpdatesTransactionStatus $updatesTransactionStatus
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
*/
public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor)
public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor, SendUserPaymentProofUploadedEmail $sendUserPaymentProofUploadedEmail)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->createsDocument = $createsDocument;
$this->createsFile = $createsFile;
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor;
$this->sendUserPaymentProofUploadedEmail = $sendUserPaymentProofUploadedEmail;
}
/**
@@ -88,6 +93,14 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
$this->createInvoiceTransactionProcessor->execute($transaction->owner->booking);
// send email to customer
// todo: send them the file also
// todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order
$companyEmployee = $transaction->owner->booking->company->employees;
foreach ($companyEmployee as $employee) {
$this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking);
}
return $this->response([]);
}
@@ -0,0 +1,41 @@
<?php
namespace App\Classes\Notifications;
use App\Models\Booking;
use App\Models\User;
use App\Models\UserEmailVerification;
use Illuminate\Notifications\Messages\MailMessage;
class PaymentProofUploadedEmail extends AbstractEmail
{
/** @var User */
private $user;
/** @var Booking */
private $booking;
/**
* UserVerificationEmail constructor.
* @param User $user
* @param UserEmailVerification $attempt
*/
public function __construct(User $user, Booking $booking)
{
$this->user = $user;
$this->booking = $booking;
}
public function toMail()
{
return (new MailMessage)
->subject('Transfer Completed (REF: ' . $this->booking->marking . ')')
->to('edmond.wuiming2021@gmail.com') // testing email
// ->attach('/path/to/file') // todo-new: add attachement
->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]);
}
}
@@ -0,0 +1,12 @@
@extends('emails.layout.base')
@section('content')
<h4 style="font-size: 1em;">Dear {{$user->name}},</h4>
<p style="font-size: 0.9em">Thank you for using CIEF Exchange service!</p>
<p style="margin-top: 30px; font-size: 0.8em">We have completed your RMB transfer transaction for the ref. no {{$booking->marking}}. The RMB bank slip has been attached to this email. If you would like to view the transaction, please click on the following link:</p>
<div style="margin-top: 20px;">
<a href="{{route('booking.details', $booking->marking)}}"><button class="btn all-caps bg-primary no-border text-white pointer" style="font-size: 0.8em" >View</button></a>
</div>
<!-- todo-new: check if this is needed, confirm on customer support contact information -->
<!-- <div class="all-caps hint-text" style="margin-top: 20px;"><small style="font-size: 0.7em">If you have questions, contact us at [customer support contact information]. We truly appreciate your trust in our services and look forward to serving you in the future.</small></div> -->
@endsection
+37 -1
View File
@@ -600,4 +600,40 @@ Route::get('/po/outsource/check', function(){
Route::get('/upload-honey-trap', function () {
return view('pages.honey_trap');
})->name('upload_honey_trap');
})->name('upload_honey_trap');
Route::get('/text-transfer-email', function () {
$booking = Booking::where('marking', '25760')->first();
$mployee = $booking->company->employees->first();
return view('emails.accounts.payment_proof_email', ['booking' => $booking, 'user' => $mployee, ]);
});
use Illuminate\Support\Facades\Mail;
Route::get('/show-email', function () {
// Send some emails using MailMessage
// Retrieve the Swift Mailer instance
$mailer = Mail::getSwiftMailer();
// Retrieve the Transport instance
$transport = $mailer->getTransport();
// Retrieve the sent messages
$messages = $transport->getMessages();
// Loop through the sent messages
foreach ($messages as $message) {
// Access the email details
$subject = $message->getSubject();
$from = $message->getFrom();
$to = $message->getTo();
$cc = $message->getCc();
$bcc = $message->getBcc();
// ...and so on
// Output the email details
echo "Subject: $subject\n";
echo "From: $from\n";
echo "To: $to\n";
echo "Cc: $cc\n";
echo "Bcc: $bcc\n";
echo "\n";
}
});