diff --git a/app/Http/Controllers/Admin/AdminInvoiceController.php b/app/Http/Controllers/Admin/AdminInvoiceController.php index 0209ff0..19d313e 100644 --- a/app/Http/Controllers/Admin/AdminInvoiceController.php +++ b/app/Http/Controllers/Admin/AdminInvoiceController.php @@ -26,15 +26,13 @@ class AdminInvoiceController extends Controller // ------------------------------------------------------------- public function popup($id) { - $invoice = Invoice::with(['items', 'order'])->findOrFail($id); + $invoice = Invoice::with(['items', 'order', 'installments'])->findOrFail($id); - // Find actual Shipment record - $shipment = \App\Models\Shipment::whereHas('items', function ($q) use ($invoice) { - $q->where('order_id', $invoice->order_id); - }) - ->first(); + $shipment = \App\Models\Shipment::whereHas('items', function ($q) use ($invoice) { + $q->where('order_id', $invoice->order_id); + })->first(); - return view('admin.popup_invoice', compact('invoice', 'shipment')); + return view('admin.popup_invoice', compact('invoice', 'shipment')); } // ------------------------------------------------------------- @@ -145,6 +143,22 @@ class AdminInvoiceController extends Controller $invoice->update(['pdf_path' => 'invoices/' . $fileName]); } + public function downloadInvoice($id) +{ + $invoice = Invoice::findOrFail($id); + + // Generate PDF if missing + if ( + !$invoice->pdf_path || + !file_exists(public_path($invoice->pdf_path)) + ) { + $this->generateInvoicePDF($invoice); + $invoice->refresh(); + } + + return response()->download(public_path($invoice->pdf_path)); +} + // ------------------------------------------------------------- // INSTALLMENTS (ADD/DELETE) // ------------------------------------------------------------- diff --git a/public/invoices/invoice-INV-2025-000029.pdf b/public/invoices/invoice-INV-2025-000029.pdf index 212a927..80c41f2 100644 Binary files a/public/invoices/invoice-INV-2025-000029.pdf and b/public/invoices/invoice-INV-2025-000029.pdf differ diff --git a/public/invoices/invoice-INV-2025-000031.pdf b/public/invoices/invoice-INV-2025-000031.pdf new file mode 100644 index 0000000..87950b3 Binary files /dev/null and b/public/invoices/invoice-INV-2025-000031.pdf differ diff --git a/resources/views/admin/popup_invoice.blade.php b/resources/views/admin/popup_invoice.blade.php index 51775be..b02a7b6 100644 --- a/resources/views/admin/popup_invoice.blade.php +++ b/resources/views/admin/popup_invoice.blade.php @@ -550,46 +550,71 @@ - -
-
-
- -
- Subtotal Amount - ₹{{ number_format($invoice->final_amount,2) }} -
- - -
- GST Amount - ₹{{ number_format($invoice->gst_amount, 2) }} -
- - -
- Total Payable Amount - ₹{{ number_format($invoice->final_amount_with_gst,2) }} -
-
-
+ @php + $totalAmount = $invoice->final_amount; + $gstAmount = $invoice->gst_amount; + $totalPayable = $invoice->final_amount_with_gst; + + $paidAmount = $invoice->totalPaid(); + $remaining = $invoice->remainingAmount(); + @endphp + +
+
+
+ +
+ Total Amount + ₹{{ number_format($totalAmount,2) }}
+ +
+ GST Amount + + + ₹{{ number_format($gstAmount,2) }} + +
+ +
+ Total Payable + + ₹{{ number_format($totalPayable,2) }} + +
+ +
+ Paid Amount + + − ₹{{ number_format($paidAmount,2) }} + +
+ +
+ Remaining Amount + + ₹{{ number_format($remaining,2) }} + +
+ +
+
+
+
- @if($invoice->pdf_path) - + + Download PDF - @endif +
@@ -599,12 +624,12 @@ - + + \ No newline at end of file diff --git a/resources/views/admin/shipments.blade.php b/resources/views/admin/shipments.blade.php index 6ee0a4f..a8953fe 100644 --- a/resources/views/admin/shipments.blade.php +++ b/resources/views/admin/shipments.blade.php @@ -741,6 +741,13 @@ margin: 1vh auto !important; } + /* UPDATED: Shipment Order Details Modal - ALSO EDGE-TO-EDGE */ + .modal-xl.edge-to-edge.order-details-modal { + max-width: 95vw !important; + width: 95vw !important; + margin: 1vh auto !important; + } + .shipment-details-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; @@ -1135,6 +1142,12 @@ margin: 2vh auto !important; } + .modal-xl.edge-to-edge.order-details-modal { + max-width: 96vw !important; + width: 96vw !important; + margin: 2vh auto !important; + } + .shipment-totals-row { grid-template-columns: repeat(4, 1fr); gap: 15px; @@ -1148,6 +1161,12 @@ margin: 2.5vh auto !important; } + .modal-xl.edge-to-edge.order-details-modal { + max-width: 95vw !important; + width: 95vw !important; + margin: 2.5vh auto !important; + } + .shipment-details-body { padding: 20px 25px; } @@ -1176,6 +1195,14 @@ max-height: 100vh !important; } + .modal-xl.edge-to-edge.order-details-modal { + max-width: 100vw !important; + width: 100vw !important; + margin: 0 !important; + height: 100vh !important; + max-height: 100vh !important; + } + .shipment-details-body { padding: 15px 20px; } @@ -1210,6 +1237,15 @@ .shipment-total-value { font-size: 16px; } + + /* Order details modal specific responsive styles */ + .order-details-content { + padding: 15px; + } + + .order-details-table { + min-width: 1000px; + } } @media (max-width: 576px) { @@ -1224,10 +1260,42 @@ overflow-y: auto; } + .modal-xl.edge-to-edge.order-details-modal .modal-content { + border-radius: 0; + height: 100vh; + overflow-y: auto; + } + .shipment-details-header { padding: 20px 25px 15px; border-radius: 0; } + + .order-details-header { + padding: 20px 15px 10px; + border-radius: 0; + } + + .order-details-body { + padding: 15px; + } + } + + @media (max-width: 480px) { + .modal-xl.edge-to-edge, + .modal-xl.edge-to-edge.order-details-modal { + margin: 0 !important; + padding: 0 !important; + } + + .modal-content { + border-radius: 0 !important; + } + + .shipment-details-body, + .order-details-body { + padding: 10px 15px; + } } @@ -1849,7 +1917,11 @@ function openShipmentDetails(id) { html += ` - ${order.order_id} + + ${order.order_id} + ${order.origin || 'N/A'} ${order.destination || 'N/A'} @@ -1962,6 +2034,46 @@ document.addEventListener('DOMContentLoaded', function() { }); }); }); + + + +function openShipmentOrderDetails(orderId) { + const modal = new bootstrap.Modal( + document.getElementById('shipmentOrderDetailsModal') + ); + + const body = document.getElementById('shipmentOrderDetailsBody'); + body.innerHTML = "

Loading...

"; + + modal.show(); + + fetch(`/admin/orders/view/${orderId}`) + .then(res => res.text()) + .then(html => { + body.innerHTML = html; + }) + .catch(() => { + body.innerHTML = + "

Failed to load order details.

"; + }); +} + + + + @endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index f79b3ce..5946d4f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -219,7 +219,11 @@ Route::prefix('admin') Route::post('/invoices/{id}/installment', [AdminInvoiceController::class, 'storeInstallment']) ->name('admin.invoice.installment.store'); - + Route::get( + '/admin/invoices/{id}/download', + [AdminInvoiceController::class, 'downloadInvoice'] +)->name('admin.invoices.download'); + Route::delete('/installment/{id}', [AdminInvoiceController::class, 'deleteInstallment']) ->name('admin.invoice.installment.delete');