mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
x1 and x2 reports
This commit is contained in:
@@ -56,6 +56,10 @@ class Handler extends ExceptionHandler
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($exception->getCode() === 403) {
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
+80
-85
@@ -22,105 +22,100 @@ Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm
|
||||
Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset');
|
||||
|
||||
Route::group(['middleware' => ['role:admin']], function() {
|
||||
try {
|
||||
Route::get('/report/x1', function(){
|
||||
$bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x1_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
});
|
||||
|
||||
foreach($months as $month => $bookings){
|
||||
echo "<h1>".Carbon::parse($month)->format('m-Y').": <small style='color: green; font-size: larger'>".$bookings->sum('bia')." MYR</small></h1>";
|
||||
$days = $bookings->groupBy(function($item){
|
||||
return $item->created_at->format('Y-m-d');
|
||||
});
|
||||
|
||||
foreach($days as $day => $bookings ){
|
||||
echo "<p>".Carbon::parse($day)->format('d-m-Y').": <small style='color: green; font-size: large'>".$bookings->sum('bia')." MYR</small></p>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Route::get('/report/x1', function(){
|
||||
$bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x1_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
});
|
||||
Route::get('/report/x2', function(){
|
||||
$bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x2_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
|
||||
foreach($months as $month => $bookings){
|
||||
echo "<h1>".Carbon::parse($month)->format('m-Y').": <small style='color: green; font-size: larger'>".$bookings->sum('bia')." MYR</small></h1>";
|
||||
$days = $bookings->groupBy(function($item){
|
||||
return $item->created_at->format('Y-m-d');
|
||||
});
|
||||
|
||||
foreach($months as $month => $bookings){
|
||||
echo "<h1>".Carbon::parse($month)->format('m-Y').": <small style='color: green; font-size: larger'>".$bookings->sum('bia')." MYR</small></h1>";
|
||||
$days = $bookings->groupBy(function($item){
|
||||
return $item->created_at->format('Y-m-d');
|
||||
});
|
||||
|
||||
foreach($days as $day => $bookings ){
|
||||
echo "<p>".Carbon::parse($day)->format('d-m-Y').": <small style='color: green; font-size: large'>".$bookings->sum('bia')." MYR</small></p>";
|
||||
}
|
||||
|
||||
foreach($days as $day => $bookings ){
|
||||
echo "<p>".Carbon::parse($day)->format('d-m-Y').": <small style='color: green; font-size: large'>".$bookings->sum('bia')." MYR</small></p>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Route::get('/report/x2', function(){
|
||||
$bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x2_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
});
|
||||
Route::get('/po-approval', 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();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
foreach($months as $month => $bookings){
|
||||
echo "<h1>".Carbon::parse($month)->format('m-Y').": <small style='color: green; font-size: larger'>".$bookings->sum('bia')." MYR</small></h1>";
|
||||
$days = $bookings->groupBy(function($item){
|
||||
return $item->created_at->format('Y-m-d');
|
||||
});
|
||||
echo "<h1>Total Po Pending Customer Update: <b>".count($bookings)."</b></h1>";
|
||||
foreach ($months as $month => $bookings) {
|
||||
echo "<h3>".$month."(".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>";
|
||||
|
||||
foreach($days as $day => $bookings ){
|
||||
echo "<p>".Carbon::parse($day)->format('d-m-Y').": <small style='color: green; font-size: large'>".$bookings->sum('bia')." MYR</small></p>";
|
||||
}
|
||||
|
||||
})->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();
|
||||
$newCompletedInvoices = Invoice::whereIn('id', $approvedInvoices)->get();
|
||||
$total = count($oldCompletedInvoices) + count($newCompletedInvoices);
|
||||
echo "<h1>Total Po Approved: <b>".$total."</b></h1>";
|
||||
foreach ($newCompletedInvoices as $invoice){
|
||||
echo "<a target='_blank' href='https://exchange.cief-malaysia.com/booking/".$invoice->booking->id."/admin/complete'>".$invoice->booking->id."</a><br>";
|
||||
}
|
||||
foreach ($oldCompletedInvoices as $invoice){
|
||||
echo "<a target='_blank' href='https://exchange.cief-malaysia.com/booking/".$invoice->booking->id."/admin/complete'>".$invoice->booking->id."</a><br>";
|
||||
}
|
||||
})->name('po.approved');
|
||||
});
|
||||
Route::get('/po-approval', 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>";
|
||||
}
|
||||
|
||||
Route::get('/old-invoices', function(){
|
||||
$bookings = \App\Booking::where('status', 6)->where('user_id', '!=', 1)->whereHas('purchaseOrder', function($q){
|
||||
$q->whereNotNull('image_path');
|
||||
})->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
});
|
||||
echo "<h1>Total pending invoices:<b>".count($bookings)."</b></h1>";
|
||||
foreach ($months as $month => $bookings) {
|
||||
echo "<h3>".$month."(".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>date: ".$booking->created_at."</small><br>";
|
||||
}
|
||||
echo "<br><br><br>";
|
||||
$bookings = Booking::where('admin_status', 6)->where(function($q){
|
||||
$q->WhereDoesntHave('invoice')->WhereDoesntHave('purchaseOrder');
|
||||
})->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
});
|
||||
echo "<h1>Total Po Pending Customer Update: <b>".count($bookings)."</b></h1>";
|
||||
foreach ($months as $month => $bookings) {
|
||||
echo "<h3>".$month."(".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>";
|
||||
}
|
||||
})->name('invoice.old');
|
||||
} catch (\Exception $exception){
|
||||
return redirect('login');
|
||||
}
|
||||
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();
|
||||
$newCompletedInvoices = Invoice::whereIn('id', $approvedInvoices)->get();
|
||||
$total = count($oldCompletedInvoices) + count($newCompletedInvoices);
|
||||
echo "<h1>Total Po Approved: <b>".$total."</b></h1>";
|
||||
foreach ($newCompletedInvoices as $invoice){
|
||||
echo "<a target='_blank' href='https://exchange.cief-malaysia.com/booking/".$invoice->booking->id."/admin/complete'>".$invoice->booking->id."</a><br>";
|
||||
}
|
||||
foreach ($oldCompletedInvoices as $invoice){
|
||||
echo "<a target='_blank' href='https://exchange.cief-malaysia.com/booking/".$invoice->booking->id."/admin/complete'>".$invoice->booking->id."</a><br>";
|
||||
}
|
||||
})->name('po.approved');
|
||||
|
||||
Route::get('/old-invoices', function(){
|
||||
$bookings = \App\Booking::where('status', 6)->where('user_id', '!=', 1)->whereHas('purchaseOrder', function($q){
|
||||
$q->whereNotNull('image_path');
|
||||
})->get();
|
||||
$months = $bookings->groupBy(function($item) {
|
||||
return $item->created_at->format('Y-m');
|
||||
});
|
||||
echo "<h1>Total pending invoices:<b>".count($bookings)."</b></h1>";
|
||||
foreach ($months as $month => $bookings) {
|
||||
echo "<h3>".$month."(".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>date: ".$booking->created_at."</small><br>";
|
||||
}
|
||||
echo "<br><br><br>";
|
||||
}
|
||||
})->name('invoice.old');
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user