x1 and x2 reports

This commit is contained in:
omair saleh
2020-12-05 13:17:50 +08:00
parent aa60a587ca
commit 43558afc57
+13 -25
View File
@@ -23,25 +23,21 @@ Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('p
Route::get('/report/x1', function(){
if($this->middleware('role:admin')){
$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');
$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($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>";
}
} else {
return redirect('/');
}
});
@@ -68,9 +64,6 @@ Route::get('/report/x2', function(){
});
Route::get('/po-approval', function(){
if(Auth()::user()->role !== 'admin'){
return redirect('/');
}
$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();
@@ -97,9 +90,6 @@ Route::get('/po-approval', function(){
})->name('po.approval');
Route::get('/po-approved', function(){
if(Auth()::user()->role !== 'admin'){
return redirect('/');
}
$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();
@@ -114,9 +104,7 @@ Route::get('/po-approved', function(){
})->name('po.approved');
Route::get('/old-invoices', function(){
if(Auth()::user()->role !== 'admin'){
return redirect('/');
}
$bookings = \App\Booking::where('status', 6)->where('user_id', '!=', 1)->whereHas('purchaseOrder', function($q){
$q->whereNotNull('image_path');
})->get();