mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
test sending booking do to email
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Routing\ResponseFactory;
|
||||
@@ -349,18 +350,35 @@ class InvoiceController extends Controller
|
||||
$booking->admin_status = 7;
|
||||
$booking->save();
|
||||
|
||||
$zipname = 'do_'.Carbon::today()->format('Y_m_d').'.zip';
|
||||
$zip = new ZipArchive;
|
||||
$zip->open($zipname, ZipArchive::CREATE);
|
||||
$approvedInvoices = InvoiceStatuses::where('status', 'approve')->whereDate('created_at', Carbon::today())->distinct()->get(['invoice_id']);
|
||||
$bookings = [];
|
||||
foreach($approvedInvoices as $approved){
|
||||
$bookings[] = $approved->invoice->booking->id;
|
||||
}
|
||||
foreach ($bookings as $id) {
|
||||
$do = $this->generateSupplierDo($id);
|
||||
$zip->addFromString('do_'.Carbon::today()->format('Y_m_d').'_'.$id, $do->Output('do.pdf', 'S'));
|
||||
}
|
||||
|
||||
$do = $this->generateSupplierDo($booking->id);
|
||||
Mail::raw( 'DO for booking no'.$booking->id, function($message) use ($do, $booking){
|
||||
$zip->close();
|
||||
$attachment = base64_encode(File::get($zipname));
|
||||
|
||||
// $do = $this->generateSupplierDo($booking->id);
|
||||
Mail::raw( 'DO for bookings po approved on '.Carbon::today(), function($message) use ($attachment){
|
||||
$message->from('info@cief-malaysia.com');
|
||||
$message->to('uldvstar@gmail.com');
|
||||
$message->subject('DO for booking no'.$booking->id);
|
||||
$message->subject('DO for bookings on'.Carbon::today());
|
||||
//Attach PDF doc
|
||||
$message->attachData($do->Output('do.pdf', 'S'),'do_booking_no_'.$booking->id.'.pdf', [
|
||||
$message->attachData($attachment,'do_'.Carbon::today()->format('Y_m_d').'.zip', [
|
||||
'mime' => 'application/pdf',
|
||||
]);
|
||||
});
|
||||
|
||||
File::delete($zipname);
|
||||
|
||||
if(!$booking) {
|
||||
return response()->json(['message' => 'Unable to Complete Booking. Please Approve Again'], 500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user