pending customer po grouped by customer

This commit is contained in:
omair saleh
2020-12-07 11:41:52 +08:00
parent c2decffa86
commit c39e91fe5a
+26
View File
@@ -90,6 +90,32 @@ Route::group(['middleware' => ['role:admin']], function() {
})->name('po.approval');
Route::get('/po-pending-customers', function(){
$approvedInvoices = InvoiceStatuses::where('status', 'approve')->distinct()->get(['invoice_id'])->pluck('invoice_id');
$pendingChangeInvoices = InvoiceStatuses::where('status', 'request_change')->distinct()->get(['invoice_id'])->pluck('invoice_id');
$invoices = InvoiceStatuses::whereNotIn('invoice_id', $approvedInvoices)->whereNotIn('invoice_id', $pendingChangeInvoices)->get();
echo "<h1>Total PO Pending Approval: <b>".count($invoices)."</b></h1>";
foreach ($invoices as $invoice){
echo "<a target='_blank' href='https://exchange.cief-malaysia.com/booking/".$invoice->invoice->booking->id."/upload-invoice'>".$invoice->invoice->booking->id."</a><br>";
}
$bookings = Booking::where('admin_status', 6)->where(function($q){
$q->WhereDoesntHave('invoice')->WhereDoesntHave('purchaseOrder');
})->get();
$customers = $bookings->groupBy(function($item) {
return $item->user_id;
});
echo "<h1>Total Po Pending Customer Update: <b>".count($bookings)."</b></h1>";
foreach ($customers as $customer => $bookings) {
echo "<h3>".$bookings->user->marking."(".count($bookings).")</h3><br>";
foreach ($bookings as $booking) {
echo "<a target='_blank' href='https://exchange.cief-malaysia.com/booking/".$booking->id."/upload-invoice'>".$booking->id."</a> <small style='color: red;'>".$booking->user->marking."</small> / <small style='color: darkgrey;'>".$booking->created_at."</small><br>";
}
echo "<br><br><br>";
}
})->name('po.approval');
Route::get('/po-approved', function(){
$approvedInvoices = InvoiceStatuses::where('status', 'approve')->distinct()->get(['invoice_id'])->pluck('invoice_id');
$oldCompletedInvoices = Invoice::where('invoice_path', '!=', '')->orWhereNotNull('invoice_path')->get();