group(function () { Route::group(['as' => 'last_mile_delivery.'], function () { Route::get('/', function () { return view('pages.accounts.signup'); })->name('login'); Route::get('/dashboard', function () { return view('pages.delivery.dashboard'); })->name('dashboard'); Route::get('/orders/export', 'Delivery\ExportDeliveryOrdersToExcelController@lineClear')->name('order.export'); }); }); Route::group(['prefix'=> '/last_mile_delivery', 'as' => 'last_mile_delivery.'], function () { Route::get('/', function () { return view('pages.accounts.signup'); })->name('login'); Route::get('/dashboard', function () { return view('pages.delivery.dashboard'); })->name('dashboard'); Route::get('/orders/export', 'Delivery\ExportDeliveryOrdersToExcelController@lineClear')->name('order.export'); }); Route::group(['prefix'=> '/air_shipment', 'as' => 'air_shipment.'], function () { // Route::get('/', function () { // return view('pages.accounts.signup'); // })->name('login'); Route::get('/quotation', function () { return view('pages.airShipment.quotation'); })->name('quotation'); }); Route::get('', function () { return view('pages.accounts.login'); })->name('login'); Route::get('/signup', function () { return view('pages.accounts.sign_up'); })->name('signup'); Route::group(['prefix' => 'swagger'], function () { Route::get('/', function () { return view('swagger.index'); }); Route::get('/json', function () { return view('swagger.json'); }); }); Route::get('/business/claim/{hash}', function ($hash) { return view('pages.accounts.claim_business', ['id' => Crypt::decryptString($hash)]); })->name('company.claim'); Route::get('/account/email/verification/{token}', function ($token) { return view('pages.accounts.email_verified', ['token' => $token]); })->name('account.email.verification'); Route::get('/account/password/reset/{token}', function ($token) { return view('pages.accounts.reset_password', ['token' => $token]); })->name('account.password.reset'); Route::get('/dashboard', function () { return view('pages.dashboard'); })->name('dashboard'); Route::get('/customers', function () { return view('pages.admin.customers'); })->name('customers'); Route::get('/orders', function () { return view('pages.orders.index'); })->name('orders'); Route::get('/orders-table', function () { return view('pages.orders.table'); })->name('ordersTable'); Route::get('/order/show/{order_number}', function ($orderNumber) { return view('pages.orders.profile', ['id' => $orderNumber]); })->name('order.show'); Route::get('/address', function () { return view('pages.addresses.index'); })->name('address'); Route::get('/warehouse-list', function () { return view('pages.warehouse_list'); })->name('warehouse.list'); Route::get('/delivery-list', function () { return view('pages.delivery_list'); })->name('delivery.list'); Route::get('/unclaimed-packinglist', function () { return view('pages.unclaimed_packinglist'); })->name('unclaimed-packinglist.list'); Route::get('/containers', function () { return view('pages.containers'); })->name('containers'); Route::get('/container/show/{reference}', function ($reference) { $container = Container::where('reference', $reference)->first(); return view('pages.templates.warehouseFlow', ['id' => $container->id]); })->name('container.show'); Route::get('/customer/{marking}', function ($marking) { $connection = CompanyConnection::where('invitee_reference', $marking)->first(); $id = $connection->invitee->company->id; return view('pages.customers.profile', ['id' => $id]); })->name('customer.profile'); Route::get('/customer/{marking}/details', function ($marking) { $connection = CompanyConnection::where('invitee_reference', $marking)->first(); $id = $connection->invitee->company->id; return view('pages.customers.profile_details', ['id' => $id]); })->name('customer.profile.details'); Route::get('/orders/refresh', function(\Illuminate\Http\Request $request){ $packingLists = \App\Models\PackingList::where('type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get(); dd($packingLists); $packingLists->each(function (\App\Models\PackingList $packingList) { $packingList->containers()->detach(); }); FetchWarehouseReceiveListFromVTPortalJob::withChain([ new FetchLoadedContainersFromVTPortalJob, new FetchOrdersFromYDPortalJob ])->dispatch(); return redirect('orders'); })->name('orders.refresh'); Route::get('/containers/refresh', function(){ dd((App()->make(\App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor::class))->execute()); // FetchLoadedContainersFromVTPortalJob::dispatch(); // FetchContainersStatusUpdateFromVTPortalJob::dispatch(); return redirect('orders'); })->name('containers.refresh'); Route::get('/deliveries/refresh', function(){ FetchDeliveryListFromVTPortalJob::dispatch(); return redirect('orders'); })->name('deliveries.refresh'); Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download'); Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance'); Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/payments-and-billing', function () { return view('pages.templates.paymentsBilling'); })->name('payments-and-billing'); Route::get('/shipping-queue', function () { return view('pages.templates.shippingQueue'); })->name('shipping-queue'); }); Route::get('/yiwu', function () { $orders = \App\Models\Order::whereHas('OrderRoles', function($query){ return $query->where('role_id', \App\Classes\ValueObjects\Constants\OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 2358); })->get(); foreach ($orders as $order){ echo ''. $order->reference.' - '.$order->created_at.'
'; } }); Route::get('/guangzhou', function () { $orders = \App\Models\Order::whereHas('OrderRoles', function($query){ return $query->where('role_id', \App\Classes\ValueObjects\Constants\OrderRoleTypes::ORIGIN_WAREHOUSE)->where('company_module_id', 3); })->whereHas('addresses', function($query){ return $query->where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->whereIn('state_id', [5, 13, 14]); })->get(); foreach ($orders as $order){ echo ''. $order->reference.' - '.$order->created_at.'
'; } }); Route::get('/debug', function (){ $orders = \App\Models\Order::all(); $issues = []; foreach ($orders as $order){ $received = $order->parcels()->warehouseReceiveList()->sum('quantity'); $shipping = $order->parcels()->shippingList()->sum('quantity'); if( $received < $shipping){ $issues[] = [ 'order' => $order->reference, 'received' => $received, 'shipping' => $shipping ]; } } dd($issues); }); Route::get('/yd', function (\Illuminate\Http\Request $request){ $start = $request->input('start_date') ? \Carbon\Carbon::parse($request->input('start_date')): null; $end = $request->input('end_date') ? \Carbon\Carbon::parse($request->input('end_date')): null; (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute($start, $end); (App()->make(FetchPackingListFromVTPortalProcessor::class))->execute(); })->name('yd.refresh'); Route::get('/container/{reference}/refresh/', function (string $reference){ $container = Container::where('reference', $reference)->first(); $supplier = in_array($container->owner_id, [3, 4]) ? 'VT' : 'YD'; $arrivalDates = \App\Models\PackingList::whereIn('reference', $container->packingLists->pluck('reference'))->where('type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->get()->map(function($packingList){ return $packingList->transports()->first()->drop_date; })->sortBy(function($date){ return $date; }); $startDate = $arrivalDates->first()->subDay()->format('d-m-Y'); $endDate = $arrivalDates->last()->addDay()->format('d-m-Y'); if($supplier === 'VT'){ return (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchLoadedContainersFromVTPortalProcessor::class))->execute(\Carbon\Carbon::parse($endDate), \Carbon\Carbon::parse($endDate)->addDays(5)); } if($supplier === 'YD'){ return redirect(route('yd.refresh').'?start_date='.$startDate.'&end_date='.$endDate); } })->name('container.refresh'); Route::get('/min_cbm', function (){ $companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orders', function ($query){ return $query->whereHas('packingLists')->whereDoesntHave('packingLists', function($query){ return $query->whereHas('packages', function($query){ return $query->selectRaw('sum((width/100) * (height/100) * (length/100) * quantity) as cbm')->where('type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->where('status', '!=', 5)->having('cbm', '>', 0.3); }); }); })->limit(1)->get(); $i = 0; foreach ($companies as $company) { $marking = $company->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; echo ''.$i++.'. '.$marking.'
'; } }); Route::get('/warehouse', function () { return view('pages.warehouse'); })->name('warehouse'); Route::get('/warehouse/{id}/show', function ($id) { // $connection = CompanyConnection::where('invitee_reference', '2417MEN')->first(); // $id = $connection->invitee->company->id; return view('pages.templates.warehouseDetails', ['id' => $id]); })->name('warehouse.show'); Route::get('/export/customer-latest-order-date/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/packing-list/{id}', 'Exports\ExportContainerPackingListController@export')->name('container.packaging_list.export'); Route::get('/export/pending-arrangement-delivery-list', 'Exports\ExportPendingArrangementPackingListController@export')->name('packaging_list.pending_arrangement.export'); Route::get('/export/on-hold-packing-list', 'Exports\ExportPendingArrangementPackingListController@onHold')->name('packaging_list.on_hold.export'); Route::get('/export/arrived-parcel', 'Exports\ExportArrivedParcelController@export')->name('packing_list.arrived_parcel.export'); Route::get('/export/parcel-summary', 'Exports\ExportArrivedParcelController@summary'); Route::get('/export/parcel-postcode', 'Exports\ExportParcelPostcodesController@export'); Route::get('/settings', function () { return view('pages.settings'); })->name('settings'); Route::get('/settings', function () { return view('pages.settings'); })->name('settings'); Route::get('/customer/{company_module_id}/summary', 'Exports\ExportCompanyModuleSummaryController@export')->name('customer.summary.export'); Route::get('/customer/summary/monthly', function () { $containers = Container::whereMonth('loading_date', '>=', ((float)\Carbon\Carbon::now()->format('m') - 2))->whereYear('loading_date', (float)\Carbon\Carbon::now()->format('Y'))->get(); foreach ($containers as $container){ $packingLists = $container->packingLists()->get()->filter(function ($packingList) { return $packingList->owner->company_module_id === 248; }); if (!count($packingLists)) continue; echo ''; foreach ($packingLists as $packingList){ if($packingList->packingLists->first()){ $packingList = $packingList->packingLists->first(); } $packages = $packingList->packages; foreach ($packages as $package){ echo ''; } } echo '
Date Full Marking Container Description Ctns L (cm) H (cm) W (cm) CBM
'.$container->loading_date->format('d-m-Y').' MS/CIEF/769SMC/'.$packingList->owner->reference.' '.$container->reference.' '.$package->description.' '.$package->quantity.' '.$package->length.' '.$package->height.' '.$package->width.' '.((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity).'
'; } }); Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null, $with_cbm = false) { $activeCompanies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) { return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) { return $query->where('drop_date', '>=', \Carbon\Carbon::parse($inactive_start))->where('drop_date', '<=', \Carbon\Carbon::parse($inactive_end)->addDay()); }); })->pluck('id'); $companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) { return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) { return $query->whereDate('drop_date', '>=', \Carbon\Carbon::parse($active_start))->whereDate('drop_date', '<=', \Carbon\Carbon::parse($active_end)->addDay()); }); })->whereNotIn('id', $activeCompanies)->get(); echo '

List of customers active between '.\Carbon\Carbon::parse($active_start)->format('d/m/Y'). ' - '.\Carbon\Carbon::parse($active_end)->format('d/m/Y').' & inactive between '.\Carbon\Carbon::parse($inactive_start)->format('d/m/Y'). ' - '.\Carbon\Carbon::parse($inactive_end)->format('d/m/Y').'

'; echo ''; foreach ($companies as $key => $company){ $connection = $company->inviters()->withPivot('invitee_reference')->first(); $marking = $connection ? $connection->pivot->invitee_reference:''; $packingList = collect(); $totalCbm = 0; if($with_cbm){ $packingList = $company->orderPackingLists()->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get(); $totalCbm = $packingList->flatMap(function ($packingList) { return $packingList->packages; })->sum(function($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; }); } echo ''; } echo '
# marking Number of Orders CBM
'.$key.' '.$marking.' '. $packingList->count() .' '. $totalCbm .'
'; }); Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); Route::get('/order/{id}', function ($id) { return view('pages.orders.profile', ['id' => $id]); })->name('order.details'); Route::get('/payment-and-billing', function () { return view('pages.paymentAndBilling'); })->name('admin.payment-and-billing'); Route::get('/notifications/list', 'Notifications\ListNotificationsController@list')->name('notifications.list'); Route::get('billplz/bills/{bill_no}', function($bill_no){ return redirect(env('BILLPLZ_BASE_URL').'/bills/'.$bill_no); })->name('billplz.bill'); Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor')->name('newDebtor.export'); Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export'); Route::get('/delayed_container/customers', function(){ $containers = Container::whereHas('transports', function($query){ return $query->whereHas('Schedules', function($query){ return $query->where('etd', '>', \Carbon\Carbon::parse('15-10-2022')); }); })->get(); $orders = $containers->map(function($container){ return $container->orders; })->flatten()->unique(function($order){ return $order->company_module_id; }); $companies = CompanyModule::whereIn('id', $orders->pluck('company_module_id'))->get(); foreach ($companies as $company){ $marking = $company->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; echo ''.$marking.'
'; } }); Route::get('/container/billing/{month}/{year}', function($month, $year){ $containers = Container::whereDate('loading_date', '>=', Carbon::parse('01-'.$month.'-'.$year))->get(); $totalBillable = 0; $billed = 0; $totalBilled = 0; $totalPaid = 0; foreach($containers as $container) { $packingLists = $container->packingLists; $totalBillable += count($packingLists); echo '

'.$container->reference.'

'; foreach ($packingLists as $packingList) { $invoice = $packingList->transactions() ->where('type', \App\Classes\ValueObjects\Constants\TransactionType::SHIPPING_INVOICE)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED]) ->first(); if(!$invoice) { echo '

'.$packingList->reference .' Warning: no billing

'; continue; } $payments = $invoice->transactions() ->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED]) ->get(); $billed += 1; $totalBilled += $invoice->amount; $totalPaid += $payments->sum('amount'); echo $packingList->reference.' | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount'); } echo '


'; } echo '

Total Invoices: '.$billed.'/'.$totalBillable.'

'; echo '

Billed Total: '.$totalBilled.'

'; echo '

Total Paid: '.$totalPaid.'

'; echo '

Outstanding: '.($totalBilled - $totalPaid).'

'; });