diff --git a/app/Exports/OrdersExport.php b/app/Exports/OrdersExport.php index 44d5abf..486dd0e 100644 --- a/app/Exports/OrdersExport.php +++ b/app/Exports/OrdersExport.php @@ -6,10 +6,11 @@ use App\Models\Order; use Illuminate\Http\Request; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\WithHeadings; +use Carbon\Carbon; class OrdersExport implements FromCollection, WithHeadings { - protected $request; + protected Request $request; public function __construct(Request $request) { @@ -18,61 +19,99 @@ class OrdersExport implements FromCollection, WithHeadings private function buildQuery() { - $query = Order::with(['markList', 'invoice', 'shipments']); + $query = Order::query()->with([ + 'markList', + 'invoice', + 'shipments', + ]); + // SEARCH if ($this->request->filled('search')) { - $search = $this->request->search; - $query->where(function($q) use ($search) { - $q->where('order_id', 'like', "%{$search}%") - ->orWhereHas('markList', function($q2) use ($search) { + $search = trim($this->request->search); + + $query->where(function ($q) use ($search) { + $q->where('orders.order_id', 'like', "%{$search}%") + ->orWhereHas('markList', function ($q2) use ($search) { $q2->where('company_name', 'like', "%{$search}%") - ->orWhere('customer_id', 'like', "%{$search}%"); + ->orWhere('customer_id', 'like', "%{$search}%") + ->orWhere('origin', 'like', "%{$search}%") + ->orWhere('destination', 'like', "%{$search}%"); }) - ->orWhereHas('invoice', function($q3) use ($search) { + ->orWhereHas('invoice', function ($q3) use ($search) { $q3->where('invoice_number', 'like', "%{$search}%"); + }) + ->orWhereHas('shipments', function ($q4) use ($search) { + // ✅ FIXED + $q4->where('shipments.shipment_id', 'like', "%{$search}%"); }); }); } + // INVOICE STATUS + // INVOICE STATUS (FIXED) if ($this->request->filled('status')) { - $query->whereHas('invoice', function($q) { - $q->where('status', $this->request->status); + $query->where(function ($q) { + $q->whereHas('invoice', function ($q2) { + $q2->where('status', $this->request->status); + }) + ->orWhereDoesntHave('invoice'); }); } + + // SHIPMENT STATUS (FIXED) if ($this->request->filled('shipment')) { - $query->whereHas('shipments', function($q) { - $q->where('status', $this->request->shipment); + $query->where(function ($q) { + $q->whereHas('shipments', function ($q2) { + $q2->where('status', $this->request->shipment); + }) + ->orWhereDoesntHave('shipments'); }); } - return $query->latest('id'); + + // DATE RANGE + if ($this->request->filled('from_date')) { + $query->whereDate('orders.created_at', '>=', $this->request->from_date); + } + + if ($this->request->filled('to_date')) { + $query->whereDate('orders.created_at', '<=', $this->request->to_date); + } + + return $query->latest('orders.id'); } public function collection() { - $orders = $this->buildQuery()->get(); + return $this->buildQuery()->get()->map(function ($order) { - // Map to simple array rows suitable for Excel - return $orders->map(function($order) { - $mark = $order->markList; - $invoice = $order->invoice; - $shipment = $order->shipments->first() ?? null; + $mark = $order->markList; + $invoice = $order->invoice; + $shipment = $order->shipments->first(); return [ - 'Order ID' => $order->order_id, - 'Shipment ID' => $shipment->shipment_id ?? '-', - 'Customer ID' => $mark->customer_id ?? '-', - 'Company' => $mark->company_name ?? '-', - 'Origin' => $mark->origin ?? $order->origin ?? '-', - 'Destination' => $mark->destination ?? $order->destination ?? '-', - 'Order Date' => $order->created_at ? $order->created_at->format('d-m-Y') : '-', - 'Invoice No' => $invoice->invoice_number ?? '-', - 'Invoice Date' => $invoice?->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('d-m-Y') : '-', - 'Amount' => $invoice?->final_amount ? number_format($invoice->final_amount, 2) : '-', - 'Amount + GST' => $invoice?->final_amount_with_gst ? number_format($invoice->final_amount_with_gst, 2) : '-', - 'Invoice Status' => $invoice->status ? ucfirst($invoice->status) : 'Pending', - 'Shipment Status' => $shipment?->status ? ucfirst(str_replace('_', ' ', $shipment->status)) : 'Pending', + 'Order ID' => $order->order_id ?? '-', + 'Shipment ID' => $shipment?->shipment_id ?? '-', + 'Customer ID' => $mark?->customer_id ?? '-', + 'Company' => $mark?->company_name ?? '-', + 'Origin' => $mark?->origin ?? $order->origin ?? '-', + 'Destination' => $mark?->destination ?? $order->destination ?? '-', + 'Order Date' => $order->created_at + ? $order->created_at->format('d-m-Y') + : '-', + 'Invoice No' => $invoice?->invoice_number ?? '-', + 'Invoice Date' => $invoice?->invoice_date + ? Carbon::parse($invoice->invoice_date)->format('d-m-Y') + : '-', + 'Amount' => $invoice?->final_amount !== null + ? number_format($invoice->final_amount, 2) + : '0.00', + 'Amount + GST' => $invoice?->final_amount_with_gst !== null + ? number_format($invoice->final_amount_with_gst, 2) + : '0.00', + 'Invoice Status' => ucfirst($invoice?->status ?? 'pending'), + 'Shipment Status' => ucfirst(str_replace('_', ' ', $shipment?->status ?? 'pending')), ]; }); } diff --git a/app/Http/Controllers/Admin/AdminOrderController.php b/app/Http/Controllers/Admin/AdminOrderController.php index 245a6c9..7ecf7c8 100644 --- a/app/Http/Controllers/Admin/AdminOrderController.php +++ b/app/Http/Controllers/Admin/AdminOrderController.php @@ -365,6 +365,128 @@ class AdminOrderController extends Controller } + public function see($id) + { + $order = Order::with([ + 'markList', + 'items', + 'invoice.items', + 'shipments' => function ($q) use ($id) { + $q->whereHas('orders', function ($oq) use ($id) { + $oq->where('orders.id', $id) + ->whereNull('orders.deleted_at'); + })->with([ + 'orders' => function ($oq) use ($id) { + $oq->where('orders.id', $id) + ->whereNull('orders.deleted_at') + ->with('items'); + } + ]); + } + ])->findOrFail($id); + + /* ---------------- ORDER DATA ---------------- */ + $orderData = [ + 'order_id' => $order->order_id, + 'status' => $order->status, + 'totals' => [ + 'ctn' => $order->ctn, + 'qty' => $order->qty, + 'ttl_qty' => $order->ttl_qty, + 'cbm' => $order->cbm, + 'ttl_cbm' => $order->ttl_cbm, + 'kg' => $order->kg, + 'ttl_kg' => $order->ttl_kg, + 'amount' => $order->ttl_amount, + ], + 'items' => $order->items, + ]; + + /* ---------------- SHIPMENTS DATA ---------------- */ + $shipmentsData = []; + + foreach ($order->shipments as $shipment) { + + $shipmentOrders = []; + $totals = [ + 'ctn' => 0, 'qty' => 0, 'ttl_qty' => 0, + 'cbm' => 0, 'ttl_cbm' => 0, + 'kg' => 0, 'ttl_kg' => 0, + 'amount' => 0, + ]; + + foreach ($shipment->orders as $shipOrder) { + foreach ($shipOrder->items as $item) { + + $shipmentOrders[] = [ + 'order_id' => $shipOrder->order_id, + 'origin' => $shipOrder->origin, + 'destination' => $shipOrder->destination, + 'description' => $item->description, + 'ctn' => $item->ctn, + 'qty' => $item->qty, + 'ttl_qty' => $item->ttl_qty, + 'amount' => $item->ttl_amount, + ]; + + $totals['ctn'] += $item->ctn; + $totals['qty'] += $item->qty; + $totals['ttl_qty'] += $item->ttl_qty; + $totals['cbm'] += $item->cbm; + $totals['ttl_cbm'] += $item->ttl_cbm; + $totals['kg'] += $item->kg; + $totals['ttl_kg'] += $item->ttl_kg; + $totals['amount'] += $item->ttl_amount; + } + } + + if (empty($shipmentOrders)) { + continue; + } + + $shipmentsData[] = [ + 'shipment_id' => $shipment->shipment_id, + 'status' => $shipment->status, + 'date' => $shipment->shipment_date, + 'total_orders' => 1, + 'orders' => $shipmentOrders, + 'totals' => $totals, + ]; + } + + /* ---------------- INVOICE DATA ---------------- */ + $invoiceData = null; + if ($order->invoice) { + $invoice = $order->invoice; + $invoiceData = [ + 'invoice_no' => $invoice->invoice_number, + 'status' => $invoice->status, + 'invoice_date' => $invoice->invoice_date, + 'due_date' => $invoice->due_date, + 'customer' => [ + 'name' => $invoice->customer_name, + 'mobile' => $invoice->customer_mobile, + 'email' => $invoice->customer_email, + 'address' => $invoice->customer_address, + 'pincode' => $invoice->pincode, + ], + 'items' => $invoice->items, + 'summary' => [ + 'amount' => $invoice->final_amount, + 'cgst' => 0, + 'sgst' => 0, + 'total' => $invoice->final_amount_with_gst, + ], + ]; + } + + return view('admin.see_order', compact( + 'order', + 'orderData', + 'shipmentsData', + 'invoiceData' + )); + } public function resetTemp() @@ -375,89 +497,143 @@ class AdminOrderController extends Controller ->with('success', 'Order reset successfully.'); } - public function orderShow() - { - $orders = Order::with([ - 'markList', // company, customer, origin, destination, date - 'shipments', // shipment_id, shipment_date, status - 'invoice' // invoice number, dates, amounts, status - ]) - ->latest('id') // show latest orders first - ->get(); + public function orderShow() + { + $orders = Order::with([ + 'markList', // company, customer, origin, destination, date + 'shipments', // shipment_id, shipment_date, status + 'invoice' // invoice number, dates, amounts, status + ]) + ->latest('id') // show latest orders first + ->get(); - return view('admin.orders', compact('orders')); - } - - // inside AdminOrderController + return view('admin.orders', compact('orders')); + } + + // inside AdminOrderController private function buildOrdersQueryFromRequest(Request $request) - { - $query = Order::with(['markList', 'invoice', 'shipments']); + { + $query = Order::query() + ->with(['markList', 'invoice', 'shipments']); - // Search across order_id, markList.company_name, markList.customer_id, invoice.invoice_number - if ($request->filled('search')) { - $search = $request->search; - $query->where(function($q) use ($search) { - $q->where('order_id', 'like', "%{$search}%") - ->orWhereHas('markList', function($q2) use ($search) { - $q2->where('company_name', 'like', "%{$search}%") - ->orWhere('customer_id', 'like', "%{$search}%"); - }) - ->orWhereHas('invoice', function($q3) use ($search) { - $q3->where('invoice_number', 'like', "%{$search}%"); + /* ---------------------------------- + | SEARCH FILTER + |----------------------------------*/ + if ($request->filled('search')) { + $search = trim($request->search); + + $query->where(function ($q) use ($search) { + $q->where('orders.order_id', 'like', "%{$search}%") + + ->orWhereHas('markList', function ($q2) use ($search) { + $q2->where('company_name', 'like', "%{$search}%") + ->orWhere('customer_id', 'like', "%{$search}%") + ->orWhere('origin', 'like', "%{$search}%") + ->orWhere('destination', 'like', "%{$search}%"); + }) + + ->orWhereHas('invoice', function ($q3) use ($search) { + $q3->where('invoice_number', 'like', "%{$search}%"); + }) + + ->orWhereHas('shipments', function ($q4) use ($search) { + // ✅ VERY IMPORTANT: table name added + $q4->where('shipments.shipment_id', 'like', "%{$search}%"); + }); }); - }); + } + + /* ---------------------------------- + | INVOICE STATUS FILTER + |----------------------------------*/ + if ($request->filled('status')) { + $query->where(function ($q) use ($request) { + $q->whereHas('invoice', function ($q2) use ($request) { + $q2->where('status', $request->status); + }) + ->orWhereDoesntHave('invoice'); + }); + } + + /* ---------------------------------- + | SHIPMENT STATUS FILTER + |----------------------------------*/ + if ($request->filled('shipment')) { + $query->where(function ($q) use ($request) { + $q->whereHas('shipments', function ($q2) use ($request) { + $q2->where('status', $request->shipment); + }) + ->orWhereDoesntHave('shipments'); + }); + } + + /* ---------------------------------- + | DATE RANGE FILTER (🔥 FIXED) + |----------------------------------*/ + if ($request->filled('from_date')) { + $query->whereDate('orders.created_at', '>=', $request->from_date); + } + + if ($request->filled('to_date')) { + $query->whereDate('orders.created_at', '<=', $request->to_date); + } + + return $query->latest('orders.id'); } - // Invoice status filter - if ($request->filled('status')) { - $query->whereHas('invoice', function($q) use ($request) { - $q->where('status', $request->status); - }); - } - // Shipment status filter - if ($request->filled('shipment')) { - $query->whereHas('shipments', function($q) use ($request) { - $q->where('status', $request->shipment); - }); - } - // optional ordering - $query->latest('id'); - return $query; - } + public function downloadPdf(Request $request) + { + // Build same filtered query used for table + // $query = $this->buildOrdersQueryFromRequest($request); - public function downloadPdf(Request $request) - { - // Build same filtered query used for table - $query = $this->buildOrdersQueryFromRequest($request); + // $orders = $query->get(); - $orders = $query->get(); + // // optional: pass filters to view for header + // $filters = [ + // 'search' => $request->search ?? null, + // 'status' => $request->status ?? null, + // 'shipment' => $request->shipment ?? null, + // ]; + + // $pdf = PDF::loadView('admin.orders.pdf', compact('orders', 'filters')) + // ->setPaper('a4', 'landscape'); // adjust if needed + + // $fileName = 'orders-report' + // . ($filters['status'] ? "-{$filters['status']}" : '') + // . '-' . date('Y-m-d') . '.pdf'; + + // return $pdf->download($fileName); + $orders = $this->buildOrdersQueryFromRequest($request)->get(); - // optional: pass filters to view for header $filters = [ - 'search' => $request->search ?? null, - 'status' => $request->status ?? null, - 'shipment' => $request->shipment ?? null, + 'search' => $request->search, + 'status' => $request->status, + 'shipment' => $request->shipment, + 'from' => $request->from_date, + 'to' => $request->to_date, ]; $pdf = PDF::loadView('admin.orders.pdf', compact('orders', 'filters')) - ->setPaper('a4', 'landscape'); // adjust if needed + ->setPaper('a4', 'landscape'); - $fileName = 'orders-report' - . ($filters['status'] ? "-{$filters['status']}" : '') - . '-' . date('Y-m-d') . '.pdf'; + return $pdf->download( + 'orders-report-' . now()->format('Y-m-d') . '.pdf' + ); + } - return $pdf->download($fileName); - } - - public function downloadExcel(Request $request) - { - // pass request to OrdersExport which will build Filtered query internally - return Excel::download(new OrdersExport($request), 'orders-report-' . date('Y-m-d') . '.xlsx'); - } + public function downloadExcel(Request $request) + { + // pass request to OrdersExport which will build Filtered query internally + // return Excel::download(new OrdersExport($request), 'orders-report-' . date('Y-m-d') . '.xlsx'); + return Excel::download( + new OrdersExport($request), + 'orders-report-' . now()->format('Y-m-d') . '.xlsx' + ); + } public function addTempItem(Request $request) diff --git a/composer.json b/composer.json index d699067..2029920 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "laravel/framework": "^12.0", "laravel/reverb": "^1.6", "laravel/tinker": "^2.10.1", - "maatwebsite/excel": "^1.1", + "maatwebsite/excel": "^3.1", "mpdf/mpdf": "^8.2", "php-open-source-saver/jwt-auth": "2.8", "spatie/laravel-permission": "^6.23" diff --git a/composer.lock b/composer.lock index 5d8adea..39478ab 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0e6764a0918bf6d36999c1623fbd2efb", + "content-hash": "e0736d5bff7a8cfda1aa3e5e13b94eec", "packages": [ { "name": "barryvdh/laravel-dompdf", @@ -342,6 +342,162 @@ ], "time": "2025-01-03T16:18:33+00:00" }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-08-20T19:15:30+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -917,6 +1073,67 @@ }, "time": "2023-08-08T05:53:35+00:00" }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.19.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "b287d2a16aceffbf6e0295559b39662612b77fcf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/b287d2a16aceffbf6e0295559b39662612b77fcf", + "reference": "b287d2a16aceffbf6e0295559b39662612b77fcf", + "shasum": "" + }, + "require": { + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0" + }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, + "suggest": { + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.", + "ext-bcmath": "Used for unit conversion and imagecrash protection", + "ext-iconv": "Converts text to and from non-UTF-8 encodings", + "ext-tidy": "Used for pretty-printing HTML" + }, + "type": "library", + "autoload": { + "files": [ + "library/HTMLPurifier.composer.php" + ], + "psr-0": { + "HTMLPurifier": "library/" + }, + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/v4.19.0" + }, + "time": "2025-10-17T16:34:55+00:00" + }, { "name": "fruitcake/php-cors", "version": "v1.4.0", @@ -2582,48 +2799,58 @@ }, { "name": "maatwebsite/excel", - "version": "v1.1.5", + "version": "3.1.67", "source": { "type": "git", - "url": "https://github.com/Maatwebsite/Laravel-Excel.git", - "reference": "0c67aba8387726458d42461eae91a3415593bbc4" + "url": "https://github.com/SpartnerNL/Laravel-Excel.git", + "reference": "e508e34a502a3acc3329b464dad257378a7edb4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/0c67aba8387726458d42461eae91a3415593bbc4", - "reference": "0c67aba8387726458d42461eae91a3415593bbc4", + "url": "https://api.github.com/repos/SpartnerNL/Laravel-Excel/zipball/e508e34a502a3acc3329b464dad257378a7edb4d", + "reference": "e508e34a502a3acc3329b464dad257378a7edb4d", "shasum": "" }, "require": { - "php": ">=5.3.0", - "phpoffice/phpexcel": "~1.8.0" + "composer/semver": "^3.3", + "ext-json": "*", + "illuminate/support": "5.8.*||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0||^12.0", + "php": "^7.0||^8.0", + "phpoffice/phpspreadsheet": "^1.30.0", + "psr/simple-cache": "^1.0||^2.0||^3.0" }, "require-dev": { - "mockery/mockery": "~0.9", - "orchestra/testbench": "~2.2.0@dev", - "phpunit/phpunit": "~4.0" + "laravel/scout": "^7.0||^8.0||^9.0||^10.0", + "orchestra/testbench": "^6.0||^7.0||^8.0||^9.0||^10.0", + "predis/predis": "^1.1" }, "type": "library", + "extra": { + "laravel": { + "aliases": { + "Excel": "Maatwebsite\\Excel\\Facades\\Excel" + }, + "providers": [ + "Maatwebsite\\Excel\\ExcelServiceProvider" + ] + } + }, "autoload": { - "psr-0": { + "psr-4": { "Maatwebsite\\Excel\\": "src/" - }, - "classmap": [ - "src/Maatwebsite/Excel", - "tests/TestCase.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL" + "MIT" ], "authors": [ { - "name": "Maatwebsite.nl", - "email": "patrick@maatwebsite.nl" + "name": "Patrick Brouwers", + "email": "patrick@spartner.nl" } ], - "description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel", + "description": "Supercharged Excel exports and imports in Laravel", "keywords": [ "PHPExcel", "batch", @@ -2631,13 +2858,210 @@ "excel", "export", "import", - "laravel" + "laravel", + "php", + "phpspreadsheet" ], "support": { - "issues": "https://github.com/Maatwebsite/Laravel-Excel/issues", - "source": "https://github.com/Maatwebsite/Laravel-Excel/tree/master" + "issues": "https://github.com/SpartnerNL/Laravel-Excel/issues", + "source": "https://github.com/SpartnerNL/Laravel-Excel/tree/3.1.67" }, - "time": "2014-07-10T09:06:07+00:00" + "funding": [ + { + "url": "https://laravel-excel.com/commercial-support", + "type": "custom" + }, + { + "url": "https://github.com/patrickbrouwers", + "type": "github" + } + ], + "time": "2025-08-26T09:13:16+00:00" + }, + { + "name": "maennchen/zipstream-php", + "version": "3.1.2", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/aeadcf5c412332eb426c0f9b4485f6accba2a99f", + "reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-zlib": "*", + "php-64bit": "^8.2" + }, + "require-dev": { + "brianium/paratest": "^7.7", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.16", + "guzzlehttp/guzzle": "^7.5", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.5", + "phpunit/phpunit": "^11.0", + "vimeo/psalm": "^6.0" + }, + "suggest": { + "guzzlehttp/psr7": "^2.4", + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.2" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + } + ], + "time": "2025-01-27T12:07:53+00:00" + }, + { + "name": "markbaker/complex", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2" + }, + "time": "2022-12-06T16:21:08+00:00" + }, + { + "name": "markbaker/matrix", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1" + }, + "time": "2022-12-02T22:17:43+00:00" }, { "name": "masterminds/html5", @@ -3756,66 +4180,110 @@ "time": "2025-02-10T21:11:16+00:00" }, { - "name": "phpoffice/phpexcel", - "version": "1.8.1", + "name": "phpoffice/phpspreadsheet", + "version": "1.30.1", "source": { "type": "git", - "url": "https://github.com/PHPOffice/PHPExcel.git", - "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32" + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "fa8257a579ec623473eabfe49731de5967306c4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32", - "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/fa8257a579ec623473eabfe49731de5967306c4c", + "reference": "fa8257a579ec623473eabfe49731de5967306c4c", "shasum": "" }, "require": { + "composer/pcre": "^1||^2||^3", + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", "ext-xml": "*", + "ext-xmlreader": "*", "ext-xmlwriter": "*", - "php": ">=5.2.0" + "ext-zip": "*", + "ext-zlib": "*", + "ezyang/htmlpurifier": "^4.15", + "maennchen/zipstream-php": "^2.1 || ^3.0", + "markbaker/complex": "^3.0", + "markbaker/matrix": "^3.0", + "php": ">=7.4.0 <8.5.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "dompdf/dompdf": "^1.0 || ^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^8.5 || ^9.0", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" }, "type": "library", "autoload": { - "psr-0": { - "PHPExcel": "Classes/" + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL" + "MIT" ], "authors": [ { "name": "Maarten Balliauw", - "homepage": "http://blog.maartenballiauw.be" + "homepage": "https://blog.maartenballiauw.be" }, { - "name": "Mark Baker" + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" }, { "name": "Franck Lefevre", - "homepage": "http://blog.rootslabs.net" + "homepage": "https://rootslabs.net" }, { "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" } ], - "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", - "homepage": "http://phpexcel.codeplex.com", + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", "keywords": [ "OpenXML", "excel", + "gnumeric", + "ods", "php", "spreadsheet", "xls", "xlsx" ], "support": { - "issues": "https://github.com/PHPOffice/PHPExcel/issues", - "source": "https://github.com/PHPOffice/PHPExcel/tree/master" + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.30.1" }, - "abandoned": "phpoffice/phpspreadsheet", - "time": "2015-05-01T07:00:55+00:00" + "time": "2025-10-26T16:01:04+00:00" }, { "name": "phpoption/phpoption", diff --git a/resources/views/admin/orders.blade.php b/resources/views/admin/orders.blade.php index aa400f5..5e284a8 100644 --- a/resources/views/admin/orders.blade.php +++ b/resources/views/admin/orders.blade.php @@ -1,1098 +1,1195 @@ -@extends('admin.layouts.app') + @extends('admin.layouts.app') -@section('page-title', 'Orders') + @section('page-title', 'Orders') -@section('content') - -
-
- Orders Management -
+ .no-data i { + font-size: 48px; + color: #d1d5db; + } - -
-
-
{{ $orders->count() }}
-
Total Orders
+ /* RESPONSIVE ADJUSTMENTS */ + @media(max-width: 768px) { + .orders-title { + font-size: 24px; + } + + .orders-container { + padding: 16px; + } + + .stats-container { + grid-template-columns: 1fr; + } + + .stat-card { + padding: 16px; + } + + .stat-value { + font-size: 24px; + } + + .download-section { + justify-content: stretch; + } + + .download-btn { + flex: 1; + justify-content: center; + } + } + + /* ---------- Enhanced Pagination Styles ---------- */ + .pagination-container { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 20px; + padding: 16px 0; + border-top: 1px solid #eef3fb; + } + + .pagination-info { + font-size: 14px; + color: #6b7280; + font-weight: 500; + } + + .pagination-controls { + display: flex; + align-items: center; + gap: 8px; + } + + .pagination-img-btn { + background: white; + border: 1px solid #e3eaf6; + border-radius: 8px; + cursor: pointer; + transition: all 0.3s ease; + display: flex; + align-items: center; + justify-content: center; + width: 40px; + height: 40px; + padding: 0; + box-shadow: var(--shadow-sm); + } + + .pagination-img-btn:hover:not(:disabled) { + background: var(--primary-color); + border-color: var(--primary-color); + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); + } + + .pagination-img-btn:disabled { + background: #f8fafc; + border-color: #e2e8f0; + cursor: not-allowed; + opacity: 0.5; + } + + .pagination-page-btn { + background: white; + border: 1px solid #e3eaf6; + color: #1a2951; + padding: 8px 12px; + border-radius: 8px; + font-size: 14px; + font-weight: 600; + cursor: pointer; + transition: all 0.3s ease; + min-width: 40px; + text-align: center; + box-shadow: var(--shadow-sm); + } + + .pagination-page-btn:hover { + background: var(--primary-color); + color: white; + border-color: var(--primary-color); + transform: translateY(-2px); + } + + .pagination-page-btn.active { + background: var(--primary-color); + color: white; + border-color: var(--primary-color); + box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); + } + + .pagination-pages { + display: flex; + gap: 4px; + align-items: center; + } + + .pagination-ellipsis { + color: #9ba5bb; + font-size: 14px; + padding: 0 8px; + } + + /* Search and Filter Bar */ + .filter-bar { + display: flex; + gap: 16px; + margin-bottom: 24px; + flex-wrap: wrap; + align-items: center; + } + + .search-box { + flex: 1; + min-width: 300px; + position: relative; + } + + .search-input { + width: 100%; + padding: 12px 16px 12px 44px; + border: 1px solid var(--border-light); + border-radius: 10px; + font-size: 14px; + transition: all 0.3s ease; + background: white; + box-shadow: var(--shadow-sm); + } + + .search-input:focus { + outline: none; + border-color: var(--primary-color); + box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); + } + + .search-icon { + position: absolute; + left: 16px; + top: 50%; + transform: translateY(-50%); + color: var(--text-muted); + } + + .filter-select { + padding: 12px 16px; + border: 1px solid var(--border-light); + border-radius: 10px; + font-size: 14px; + background: white; + box-shadow: var(--shadow-sm); + cursor: pointer; + min-width: 160px; + } + + .date-range { + display: flex; + gap: 12px; + align-items: center; + } + + .date-input { + padding: 12px 16px; + border: 1px solid var(--border-light); + border-radius: 10px; + font-size: 14px; + background: white; + box-shadow: var(--shadow-sm); + min-width: 150px; + } + + .date-label { + font-size: 14px; + color: var(--text-muted); + font-weight: 500; + white-space: nowrap; + } + + @media (max-width: 768px) { + .filter-bar { + flex-direction: column; + align-items: stretch; + } + + .search-box { + min-width: 100%; + } + + .filter-select, + .date-input { + width: 100%; + } + + .date-range { + flex-direction: column; + align-items: stretch; + } + + .pagination-container { + flex-direction: column; + gap: 16px; + } + } + + +
+
+ Orders Management
- -
-
{{ $orders->where('invoice.status', 'pending')->count() }}
-
Pending Invoices
-
-
-
{{ $orders->where('invoice.status', 'overdue')->count() }}
-
Overdue Invoices
-
-
- -
- - -
- - -
- - - -
- - @if(isset($orders) && $orders->count() > 0) -
- - - - - - - - - - - - - - - - - - - - - - @foreach($orders as $order) - @php - $mark = $order->markList ?? null; - $invoice = $order->invoice ?? null; - $shipment = $order->shipments->first() ?? null; - $invoiceStatus = strtolower($invoice->status ?? ''); - $shipmentStatus = strtolower(str_replace('_', ' ', $shipment->status ?? '')); - @endphp - - - - - - - - - - - - - - - - - - - - - - - - - @endforeach - -
Order IDShipment IDCustomer IDCompanyOriginDestinationOrder DateInvoice NoInvoice DateAmountAmount + GSTInvoice StatusShipment StatusAction
{{ $order->order_id ?? '-' }}{{ $shipment->shipment_id ?? '-' }}{{ $mark->customer_id ?? '-' }}{{ $mark->company_name ?? '-' }}{{ $mark->origin ?? $order->origin ?? '-' }}{{ $mark->destination ?? $order->destination ?? '-' }}{{ $order->created_at ? $order->created_at->format('d-m-Y') : '-' }}{{ $invoice->invoice_number ?? '-' }} - {{ $invoice?->invoice_date ? date('d-m-Y', strtotime($invoice->invoice_date)) : '-' }} - - {{ $invoice?->final_amount ? '₹'.number_format($invoice->final_amount, 2) : '-' }} - - {{ $invoice?->final_amount_with_gst ? '₹'.number_format($invoice->final_amount_with_gst, 2) : '-' }} - - @if($invoice?->status) - - {{ ucfirst($invoice->status) }} - - @else - Pending - @endif - - @if($shipment?->status) - - {{ ucfirst($shipmentStatus) }} - - @else - Pending - @endif - - - - -
-
{{-- End table-wrapper --}} - - -
-
Showing 1 to {{ min(10, count($orders)) }} of {{ count($orders) }} entries
-
- -
- -
- + +
+ @php + $totalOrders = $orders->count(); + $paidInvoices = $orders->filter(function($order) { + $status = $order->invoice?->status ?? 'pending'; + return strtolower($status) === 'paid'; + })->count(); + $pendingInvoices = $orders->filter(function($order) { + $status = $order->invoice?->status ?? 'pending'; + return strtolower($status) === 'pending'; + })->count(); + $overdueInvoices = $orders->filter(function($order) { + $status = $order->invoice?->status ?? 'pending'; + return strtolower($status) === 'overdue'; + })->count(); + @endphp + +
+
{{ $totalOrders }}
+
Total Orders
+
+ +
+
{{ $pendingInvoices }}
+
Pending Invoices
+
+
+
{{ $overdueInvoices }}
+
Overdue Invoices
- @else -
- -
No orders found
-

There are currently no orders in the system.

+ + +
+ +
- @endif -
- - + + if (type === 'info') { + notification.style.background = 'linear-gradient(135deg, #3b82f6, #1d4ed8)'; + } else if (type === 'warning') { + notification.style.background = 'linear-gradient(135deg, #f59e0b, #d97706)'; + } else if (type === 'success') { + notification.style.background = 'linear-gradient(135deg, #10b981, #059669)'; + } + + notification.textContent = message; + document.body.appendChild(notification); + + setTimeout(() => { + notification.style.animation = 'slideOut 0.3s ease'; + setTimeout(() => notification.remove(), 300); + }, 3000); + } -@endsection \ No newline at end of file + // Add CSS for notifications + const style = document.createElement('style'); + style.textContent = ` + @keyframes slideIn { + from { transform: translateX(100%); opacity: 0; } + to { transform: translateX(0); opacity: 1; } + } + @keyframes slideOut { + from { transform: translateX(0); opacity: 1; } + to { transform: translateX(100%); opacity: 0; } + } + `; + document.head.appendChild(style); + + + @endsection \ No newline at end of file diff --git a/resources/views/admin/orders/pdf.blade.php b/resources/views/admin/orders/pdf.blade.php index e2bb0fa..82bac12 100644 --- a/resources/views/admin/orders/pdf.blade.php +++ b/resources/views/admin/orders/pdf.blade.php @@ -11,60 +11,64 @@ -

Orders Report

- @if(!empty($filters)) -

- @if($filters['search']) Search: {{ $filters['search'] }} @endif - @if($filters['status'])   | Status: {{ ucfirst($filters['status']) }} @endif - @if($filters['shipment'])   | Shipment: {{ ucfirst($filters['shipment']) }} @endif -

- @endif +

Orders Report

- - +@if(!empty($filters)) +

+ @if(!empty($filters['search'])) Search: {{ $filters['search'] }} @endif + @if(!empty($filters['status'])) | Status: {{ ucfirst($filters['status']) }} @endif + @if(!empty($filters['shipment'])) | Shipment: {{ ucfirst($filters['shipment']) }} @endif +

+@endif + +
+ + + + + + + + + + + + + + + + + + + @forelse($orders as $order) + @php + $mark = $order->markList; + $invoice = $order->invoice; + $shipment = $order->shipments->first(); + @endphp - - - - - - - - - - - - - + + + + + + + + + + + + + - - - @forelse($orders as $order) - @php - $mark = $order->markList ?? null; - $invoice = $order->invoice ?? null; - $shipment = $order->shipments->first() ?? null; - @endphp - - - - - - - - - - - - - - - - @empty - - @endforelse - -
Order IDShipment IDCustomer IDCompanyOriginDestinationOrder DateInvoice NoInvoice DateAmountAmount + GSTInvoice StatusShipment Status
Order IDShipment IDCustomer IDCompanyOriginDestinationOrder DateInvoice NoInvoice DateAmountAmount + GSTInvoice StatusShipment Status{{ $order->order_id }}{{ $shipment?->shipment_id ?? '-' }}{{ $mark?->customer_id ?? '-' }}{{ $mark?->company_name ?? '-' }}{{ $mark?->origin ?? $order->origin ?? '-' }}{{ $mark?->destination ?? $order->destination ?? '-' }}{{ $order->created_at?->format('d-m-Y') ?? '-' }}{{ $invoice?->invoice_number ?? '-' }}{{ $invoice?->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('d-m-Y') : '-' }}{{ $invoice?->final_amount !== null ? number_format($invoice->final_amount, 2) : '-' }}{{ $invoice?->final_amount_with_gst !== null ? number_format($invoice->final_amount_with_gst, 2) : '-' }}{{ ucfirst($invoice?->status ?? 'Pending') }}{{ ucfirst(str_replace('_',' ', $shipment?->status ?? 'Pending')) }}
{{ $order->order_id }}{{ $shipment->shipment_id ?? '-' }}{{ $mark->customer_id ?? '-' }}{{ $mark->company_name ?? '-' }}{{ $mark->origin ?? $order->origin ?? '-' }}{{ $mark->destination ?? $order->destination ?? '-' }}{{ $order->created_at ? $order->created_at->format('d-m-Y') : '-' }}{{ $invoice->invoice_number ?? '-' }}{{ $invoice?->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('d-m-Y') : '-' }}{{ $invoice?->final_amount ? number_format($invoice->final_amount, 2) : '-' }}{{ $invoice?->final_amount_with_gst ? number_format($invoice->final_amount_with_gst, 2) : '-' }}{{ $invoice->status ? ucfirst($invoice->status) : 'Pending' }}{{ $shipment?->status ? ucfirst(str_replace('_',' ',$shipment->status)) : 'Pending' }}
No orders found
+ @empty + + No orders found + + @endforelse + + + diff --git a/resources/views/admin/see_order.blade.php b/resources/views/admin/see_order.blade.php new file mode 100644 index 0000000..033068f --- /dev/null +++ b/resources/views/admin/see_order.blade.php @@ -0,0 +1,1370 @@ +@extends('admin.layouts.app') + +@section('page-title', 'Order Details') + +@section('content') + + +
+
+ {{-- ===================================================== + HEADER WITH CLOSE BUTTON + ====================================================== --}} +
+
+ + Order #{{ $orderData['order_id'] }} +
+ + + +
+ + {{-- ===================================================== + TABS NAVIGATION + ====================================================== --}} +
+ + + +
+ +
+ {{-- ===================================================== + ORDER DETAILS TAB + ====================================================== --}} +
+ {{-- Order Summary --}} +
+

{{ $orderData['order_id'] }}

+
+ + {{ ucfirst($orderData['status']) }} + + + + {{ $order->created_at?->format('d-m-Y') }} + +
+ +
+
+
Total Orders
+
+ {{ $order->shipments->sum(function($shipment) { + return $shipment->orders->count(); + }) ?: 1 }} +
+
+
+
Origin
+
{{ $order->origin ?? 'N/A' }}
+
+
+
Destination
+
{{ $order->destination ?? 'N/A' }}
+
+
+
Mark No
+
{{ $order->mark_no ?? 'N/A' }}
+
+
+
+ + {{-- Order Items Table --}} +
+
+ Order Items + {{ count($orderData['items']) }} items +
+
+ @if(count($orderData['items']) > 0) + + + + + + + + + + + + + + + + + + + + @foreach($orderData['items'] as $index => $item) + + + + + + + + + + + + + + + + @endforeach + +
#DescriptionCTNQTYTTL/QTYUnitPrice (₹)TTL Amount (₹)CBMTTL CBMKGTTL KGShop No
{{ $index + 1 }}{{ $item->description }}{{ $item->ctn }}{{ $item->qty }}{{ $item->ttl_qty }}{{ $item->unit }}₹{{ number_format($item->price ?? 0, 2) }}₹{{ number_format($item->ttl_amount ?? 0, 2) }}{{ number_format($item->cbm ?? 0, 3) }}{{ number_format($item->ttl_cbm ?? 0, 3) }}{{ number_format($item->kg ?? 0, 3) }}{{ number_format($item->ttl_kg ?? 0, 3) }}{{ $item->shop_no ?? '-' }}
+ @else +
+ +

No order items found.

+
+ @endif +
+
+ + {{-- Order Totals --}} +
+
+
Total CTN
+
{{ $orderData['totals']['ctn'] }}
+
+
+
Total QTY
+
{{ $orderData['totals']['qty'] }}
+
+
+
Total TTL/QTY
+
{{ $orderData['totals']['ttl_qty'] }}
+
+
+
Total TTL KG
+
{{ number_format($orderData['totals']['ttl_kg'], 3) }}
+
+
+
Total Amount
+
₹{{ number_format($orderData['totals']['amount'], 2) }}
+
+
+
Total CBM
+
{{ number_format($orderData['totals']['cbm'], 3) }}
+
+
+
Total TTL CBM
+
{{ number_format($orderData['totals']['ttl_cbm'], 3) }}
+
+
+
Total KG
+
{{ number_format($orderData['totals']['kg'], 3) }}
+
+
+
+ + {{-- ===================================================== + SHIPMENT DETAILS TAB - CORRECTED + ====================================================== --}} +
+ @if(count($shipmentsData) > 0) + @foreach($shipmentsData as $shipment) +
+
+

+ {{ $shipment['shipment_id'] }} +

+
+
+
Orders in Shipment
+
{{ $shipment['total_orders'] }}
+
+ + {{ ucfirst($shipment['status']) }} + +
+
+ +
+
+
Shipment Date
+
+ @if($shipment['date']) + {{ \Carbon\Carbon::parse($shipment['date'])->format('d-m-Y') }} + @else + N/A + @endif +
+
+
+
Orders in Shipment
+
{{ $shipment['total_orders'] }}
+
+
+
Total CTN
+
{{ $shipment['totals']['ctn'] }}
+
+
+
Total Amount
+
₹{{ number_format($shipment['totals']['amount'], 2) }}
+
+
+ + {{-- Show ONLY orders that are ACTUALLY in this shipment --}} + @if(count($shipment['orders']) > 0) +
+
+ Orders in This Shipment + {{ count($shipment['orders']) }} orders +
+
+ + + + + + + + + + + + + + + + + @foreach($shipment['orders'] as $index => $orderItem) + + + + + + + + + + + + + @endforeach + +
#Order IDOriginDestinationDescriptionCTNQTYTTL/QTYAmount (₹)Status
{{ $index + 1 }} + {{ $orderItem['order_id'] ?? '-' }} + @if($orderItem['order_id'] == $orderData['order_id']) + Current + @endif + {{ $orderItem['origin'] ?? '-' }}{{ $orderItem['destination'] ?? '-' }}{{ $orderItem['description'] ?? '-' }}{{ $orderItem['ctn'] ?? '-' }}{{ $orderItem['qty'] ?? '-' }}{{ $orderItem['ttl_qty'] ?? '-' }}₹{{ number_format($orderItem['amount'] ?? 0, 2) }} + In Shipment +
+
+
+ @else +
+ + No orders found in this shipment. +
+ @endif + + {{-- Shipment Totals --}} +
+
+
Total CTN in Shipment
+
{{ $shipment['totals']['ctn'] }}
+
+
+
Total QTY in Shipment
+
{{ $shipment['totals']['qty'] }}
+
+
+
Total TTL/QTY
+
{{ $shipment['totals']['ttl_qty'] }}
+
+
+
Total CBM
+
{{ number_format($shipment['totals']['cbm'], 3) }}
+
+
+
Total KG
+
{{ number_format($shipment['totals']['kg'], 3) }}
+
+
+
Total TTL CBM
+
{{ number_format($shipment['totals']['ttl_cbm'], 3) }}
+
+
+
Total TTL KG
+
{{ number_format($shipment['totals']['ttl_kg'], 3) }}
+
+
+
Total Amount
+
₹{{ number_format($shipment['totals']['amount'], 2) }}
+
+
+
+ @endforeach + @else +
+ +

This order is not part of any shipment.

+
+ @endif +
+ + {{-- ===================================================== + INVOICE DETAILS TAB + ====================================================== --}} +
+ @if($invoiceData) +
+
+

TAX INVOICE

+

INVOICE NO: {{ $invoiceData['invoice_no'] }}

+
+ +
+
+

From:

+

Kent Logistic
+ 123 Logistics Street
+ Mumbai, Maharashtra 400001
+ Email: support@kentlogistic.com
+ Phone: +91 1234567890

+
+ +
+

To:

+

{{ $invoiceData['customer']['name'] }}
+ {{ $invoiceData['customer']['address'] }}
+ Pincode: {{ $invoiceData['customer']['pincode'] }}
+ Email: {{ $invoiceData['customer']['email'] }}
+ Phone: {{ $invoiceData['customer']['mobile'] }}

+
+
+ +
+
+
Invoice ID
+
{{ $invoiceData['invoice_no'] }}
+
+
+
Status
+
+ + {{ ucfirst($invoiceData['status']) }} + +
+
+
+
Belongs to Shipment
+
{{ $order->invoice->shipment_id ?? 'N/A' }}
+
+
+
Order ID
+
{{ $orderData['order_id'] }}
+
+
+
Invoice Date
+
+ @if($invoiceData['invoice_date']) + {{ \Carbon\Carbon::parse($invoiceData['invoice_date'])->format('d-m-Y') }} + @else + N/A + @endif +
+
+
+
Due Date
+
+ @if($invoiceData['due_date']) + {{ \Carbon\Carbon::parse($invoiceData['due_date'])->format('d-m-Y') }} + @else + N/A + @endif +
+
+
+ + {{-- Invoice Items Table --}} +
+
+ Invoice Items + {{ count($invoiceData['items']) }} items +
+
+ + + + + + + + + + + + + + + + + + + + @foreach($invoiceData['items'] as $index => $item) + + + + + + + + + + + + + + + + @endforeach + +
#DescriptionCTNQTYTTL/QTYUnitPrice (₹)TTL Amount (₹)CBMTTL CBMKGTTL KGShop No
{{ $index + 1 }}{{ $item->description }}{{ $item->ctn ?? '-' }}{{ $item->qty }}{{ $item->qty }}{{ $item->unit ?? '-' }}₹{{ number_format($item->rate, 2) }}₹{{ number_format($item->amount, 2) }}{{ number_format($item->cbm ?? 0, 3) }}{{ number_format(($item->cbm ?? 0) * $item->qty, 3) }}{{ number_format($item->kg ?? 0, 3) }}{{ number_format(($item->kg ?? 0) * $item->qty, 3) }}{{ $item->shop_no ?? '-' }}
+
+
+ + {{-- Invoice Totals --}} +
+
+
+
Amount:
+
₹{{ number_format($invoiceData['summary']['amount'], 2) }}
+
+
+
CGST (0%):
+
₹{{ number_format($invoiceData['summary']['cgst'], 2) }}
+
+
+
SGST (0%):
+
₹{{ number_format($invoiceData['summary']['sgst'], 2) }}
+
+
+ +
+
Total Payable:
+
₹{{ number_format($invoiceData['summary']['total'], 2) }}
+
+
+ + +
+ @else +
+ +

No invoice generated for this order.

+

An invoice can be generated from the orders list.

+
+ @endif +
+
+
+
+ + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 5a67036..f79b3ce 100644 --- a/routes/web.php +++ b/routes/web.php @@ -132,7 +132,11 @@ Route::prefix('admin') Route::get('/orders/view/{id}', [AdminOrderController::class, 'popup']) ->name('admin.orders.popup'); - + + // Route::get('/orders/{id}', [AdminOrderController::class, 'view']) + // ->name('admin.orders.view'); + Route::get('/orders/{order:order_id}/see', [AdminOrderController::class, 'see']) + ->name('admin.orders.see'); // --------------------------- // ORDERS (FIXED ROUTES) // ---------------------------