Compare commits
20 Commits
178fbb224c
...
main
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
0a65d5f596 | ||
|
|
0a1d0a9c55 | ||
|
|
409a854d7b | ||
|
|
4dab96b8d1 | ||
|
|
e7fef314fc | ||
|
|
5114357ff2 | ||
|
|
0afcb23511 | ||
|
|
340c2b2132 | ||
|
|
44b8299b0e | ||
|
|
9b8c50fcec | ||
|
|
7a814dff1d | ||
|
|
f4730a81d8 | ||
|
|
3b24ee860a | ||
|
|
2dcd9fe332 | ||
|
|
922539844d | ||
|
|
3845972c5c | ||
|
|
64d8939208 | ||
|
|
ec2a0baceb | ||
|
|
68bfd180ed | ||
|
|
aa616fcf61 |
98
app/Exports/OrdersExport.php
Normal file
98
app/Exports/OrdersExport.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class OrdersExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
private function buildQuery()
|
||||
{
|
||||
$query = Order::with(['markList', 'invoice', 'shipments']);
|
||||
|
||||
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) {
|
||||
$q2->where('company_name', 'like', "%{$search}%")
|
||||
->orWhere('customer_id', 'like', "%{$search}%");
|
||||
})
|
||||
->orWhereHas('invoice', function($q3) use ($search) {
|
||||
$q3->where('invoice_number', 'like', "%{$search}%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->request->filled('status')) {
|
||||
$query->whereHas('invoice', function($q) {
|
||||
$q->where('status', $this->request->status);
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->request->filled('shipment')) {
|
||||
$query->whereHas('shipments', function($q) {
|
||||
$q->where('status', $this->request->shipment);
|
||||
});
|
||||
}
|
||||
|
||||
return $query->latest('id');
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$orders = $this->buildQuery()->get();
|
||||
|
||||
// Map to simple array rows suitable for Excel
|
||||
return $orders->map(function($order) {
|
||||
$mark = $order->markList;
|
||||
$invoice = $order->invoice;
|
||||
$shipment = $order->shipments->first() ?? null;
|
||||
|
||||
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',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Order ID',
|
||||
'Shipment ID',
|
||||
'Customer ID',
|
||||
'Company',
|
||||
'Origin',
|
||||
'Destination',
|
||||
'Order Date',
|
||||
'Invoice No',
|
||||
'Invoice Date',
|
||||
'Amount',
|
||||
'Amount + GST',
|
||||
'Invoice Status',
|
||||
'Shipment Status',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,16 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AdminAccountController extends Controller
|
||||
{
|
||||
public function updateEntry(Request $request)
|
||||
public function updateEntry(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->validate([
|
||||
'entry_no' => 'required|exists:entries,entry_no',
|
||||
'description' => 'required|string|max:255',
|
||||
'order_quantity' => 'required|numeric|min:0',
|
||||
'entry_no' => 'required|exists:entries,entry_no',
|
||||
'description' => 'required|string|max:255',
|
||||
'order_quantity' => 'required|numeric|min:0',
|
||||
'region' => 'required|string|max:50',
|
||||
'amount' => 'required|numeric|min:0',
|
||||
//'payment_status' => 'required|string|max:50',
|
||||
]);
|
||||
|
||||
$entry = Entry::where('entry_no', $data['entry_no'])->first();
|
||||
@@ -31,6 +34,10 @@ class AdminAccountController extends Controller
|
||||
|
||||
$entry->description = $data['description'];
|
||||
$entry->order_quantity = $data['order_quantity'];
|
||||
$entry->region = $data['region'];
|
||||
$entry->amount = $data['amount'];
|
||||
//$entry->payment_status = $data['payment_status'];
|
||||
|
||||
$entry->save();
|
||||
|
||||
return response()->json([
|
||||
@@ -46,36 +53,6 @@ class AdminAccountController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteEntry(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->validate([
|
||||
'entry_no' => 'required|exists:entries,entry_no',
|
||||
]);
|
||||
|
||||
$entry = Entry::where('entry_no', $data['entry_no'])->first();
|
||||
|
||||
if (!$entry) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry not found.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$entry->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Entry deleted successfully.',
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Server error: '.$e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 🚀 1. Get dashboard entries
|
||||
*/
|
||||
@@ -96,16 +73,18 @@ public function deleteEntry(Request $request)
|
||||
*/
|
||||
public function getAvailableOrders()
|
||||
{
|
||||
|
||||
$orders = Order::whereDoesntHave('entries')
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'orders' => $orders
|
||||
'orders' => $orders,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 🚀 3. Create new entry
|
||||
*/
|
||||
@@ -325,10 +304,9 @@ public function deleteEntry(Request $request)
|
||||
return DB::transaction(function () use ($data) {
|
||||
$entry = Entry::where('entry_no', $data['entry_no'])->firstOrFail();
|
||||
|
||||
// आधीचे orders काढू नका, फक्त नवीन add करा
|
||||
|
||||
$entry->orders()->syncWithoutDetaching($data['order_ids']);
|
||||
|
||||
// इथे quantity auto update
|
||||
$entry->order_quantity = $entry->orders()->count();
|
||||
$entry->save();
|
||||
|
||||
@@ -387,5 +365,35 @@ public function removeOrderFromEntry(Request $request)
|
||||
]);
|
||||
});
|
||||
}
|
||||
public function deleteEntry(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->validate([
|
||||
'entry_no' => 'required|exists:entries,entry_no',
|
||||
]);
|
||||
|
||||
$entry = Entry::where('entry_no', $data['entry_no'])->first();
|
||||
|
||||
if (!$entry) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry not found.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$entry->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Entry deleted successfully.',
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Server error: '.$e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,50 +5,52 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\Admin;
|
||||
|
||||
|
||||
|
||||
class AdminAuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the admin login page
|
||||
*/
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('admin.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle admin login
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
'login' => 'required',
|
||||
'password' => 'required|string|min:6',
|
||||
]);
|
||||
|
||||
// Try to log in using the 'admin' guard
|
||||
if (Auth::guard('admin')->attempt($request->only('email', 'password'))) {
|
||||
return redirect()->route('admin.dashboard')->with('success', 'Welcome back, Admin!');
|
||||
$loginInput = $request->input('login');
|
||||
|
||||
if (filter_var($loginInput, FILTER_VALIDATE_EMAIL)) {
|
||||
$field = 'email';
|
||||
} elseif (preg_match('/^EMP\d+$/i', $loginInput)) {
|
||||
$field = 'employee_id';
|
||||
} else {
|
||||
$field = 'username';
|
||||
}
|
||||
|
||||
return back()->withErrors(['email' => 'Invalid email or password.']);
|
||||
$credentials = [
|
||||
$field => $loginInput,
|
||||
'password' => $request->password,
|
||||
];
|
||||
|
||||
// attempt login
|
||||
if (Auth::guard('admin')->attempt($credentials)) {
|
||||
$request->session()->regenerate();
|
||||
$user = Auth::guard('admin')->user();
|
||||
|
||||
return redirect()->route('admin.dashboard')->with('success', 'Welcome back, ' . $user->name . '!');
|
||||
}
|
||||
|
||||
return back()->withErrors(['login' => 'Invalid login credentials.']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout admin
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::guard('admin')->logout();
|
||||
|
||||
// Destroy the session completely
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('admin.login')->with('success', 'Logged out successfully.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,458 @@ use Illuminate\Http\Request;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\MarkList;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceItem;
|
||||
use App\Models\User;
|
||||
use PDF; // barryvdh/laravel-dompdf facade
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\OrdersExport;
|
||||
|
||||
|
||||
class AdminOrderController extends Controller
|
||||
{
|
||||
// ---------------------------
|
||||
// LIST / DASHBOARD
|
||||
// ---------------------------
|
||||
public function index()
|
||||
{
|
||||
// raw list for admin dashboard (simple)
|
||||
$orders = Order::latest()->get();
|
||||
$markList = MarkList::where('status', 'active')->get();
|
||||
|
||||
return view('admin.dashboard', compact('orders', 'markList'));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// STEP 1 : ADD TEMPORARY ITEM
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Orders list (detailed)
|
||||
*/
|
||||
// public function orderShow()
|
||||
// {
|
||||
// $orders = Order::with(['markList', 'shipments', 'invoice'])
|
||||
// ->latest('id')
|
||||
// ->get();
|
||||
|
||||
// return view('admin.orders', compact('orders'));
|
||||
// }
|
||||
|
||||
// ---------------------------
|
||||
// CREATE NEW ORDER (simple DB flow)
|
||||
// ---------------------------
|
||||
/**
|
||||
* Show create form (you can place create UI on separate view or dashboard)
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// return a dedicated create view - create it at resources/views/admin/orders_create.blade.php
|
||||
// If you prefer create UI on dashboard, change this to redirect route('admin.orders.index') etc.
|
||||
$markList = MarkList::where('status', 'active')->get();
|
||||
return view('admin.orders_create', compact('markList'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new order and optionally create initial invoice
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'mark_no' => 'required|string',
|
||||
'origin' => 'nullable|string',
|
||||
'destination' => 'nullable|string',
|
||||
// totals optional when creating without items
|
||||
'ctn' => 'nullable|numeric',
|
||||
'qty' => 'nullable|numeric',
|
||||
'ttl_qty' => 'nullable|numeric',
|
||||
'ttl_amount' => 'nullable|numeric',
|
||||
'cbm' => 'nullable|numeric',
|
||||
'ttl_cbm' => 'nullable|numeric',
|
||||
'kg' => 'nullable|numeric',
|
||||
'ttl_kg' => 'nullable|numeric',
|
||||
]);
|
||||
|
||||
$order = Order::create([
|
||||
'order_id' => $this->generateOrderId(),
|
||||
'mark_no' => $data['mark_no'],
|
||||
'origin' => $data['origin'] ?? null,
|
||||
'destination' => $data['destination'] ?? null,
|
||||
'ctn' => $data['ctn'] ?? 0,
|
||||
'qty' => $data['qty'] ?? 0,
|
||||
'ttl_qty' => $data['ttl_qty'] ?? 0,
|
||||
'ttl_amount' => $data['ttl_amount'] ?? 0,
|
||||
'cbm' => $data['cbm'] ?? 0,
|
||||
'ttl_cbm' => $data['ttl_cbm'] ?? 0,
|
||||
'kg' => $data['kg'] ?? 0,
|
||||
'ttl_kg' => $data['ttl_kg'] ?? 0,
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
//If you want to auto-create an invoice at order creation, uncomment:
|
||||
$this->createInvoice($order);
|
||||
|
||||
return redirect()->route('admin.orders.show', $order->id)
|
||||
->with('success', 'Order created successfully.');
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// SHOW / POPUP
|
||||
// ---------------------------
|
||||
public function show($id)
|
||||
{
|
||||
$order = Order::with('items', 'markList')->findOrFail($id);
|
||||
$user = $this->getCustomerFromOrder($order);
|
||||
|
||||
return view('admin.orders_show', compact('order', 'user'));
|
||||
}
|
||||
|
||||
// public function popup($id)
|
||||
// {
|
||||
// $order = Order::with(['items', 'markList'])->findOrFail($id);
|
||||
// $user = $this->getCustomerFromOrder($order);
|
||||
|
||||
// return view('admin.popup', compact('order', 'user'));
|
||||
// }
|
||||
|
||||
// ---------------------------
|
||||
// ORDER ITEM MANAGEMENT (DB)
|
||||
// ---------------------------
|
||||
/**
|
||||
* Add an item to an existing order
|
||||
*/
|
||||
public function addItem(Request $request, $orderId)
|
||||
{
|
||||
$order = Order::findOrFail($orderId);
|
||||
|
||||
$data = $request->validate([
|
||||
'description' => 'required|string',
|
||||
'ctn' => 'nullable|numeric',
|
||||
'qty' => 'nullable|numeric',
|
||||
'ttl_qty' => 'nullable|numeric',
|
||||
'unit' => 'nullable|string',
|
||||
'price' => 'nullable|numeric',
|
||||
'ttl_amount' => 'nullable|numeric',
|
||||
'cbm' => 'nullable|numeric',
|
||||
'ttl_cbm' => 'nullable|numeric',
|
||||
'kg' => 'nullable|numeric',
|
||||
'ttl_kg' => 'nullable|numeric',
|
||||
'shop_no' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$data['order_id'] = $order->id;
|
||||
|
||||
OrderItem::create($data);
|
||||
|
||||
// recalc totals and save to order
|
||||
$this->recalcTotals($order);
|
||||
$this->updateInvoiceFromOrder($order); // <-- NEW
|
||||
|
||||
return redirect()->back()->with('success', 'Item added and totals updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft-delete an order item and recalc totals
|
||||
*/
|
||||
public function deleteItem($id)
|
||||
{
|
||||
$item = OrderItem::findOrFail($id);
|
||||
$order = $item->order;
|
||||
|
||||
$item->delete(); // soft delete
|
||||
|
||||
// recalc totals
|
||||
$this->recalcTotals($order);
|
||||
$this->updateInvoiceFromOrder($order);
|
||||
|
||||
|
||||
return redirect()->back()->with('success', 'Item deleted and totals updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore soft-deleted item and recalc totals
|
||||
*/
|
||||
public function restoreItem($id)
|
||||
{
|
||||
$item = OrderItem::withTrashed()->findOrFail($id);
|
||||
$order = Order::findOrFail($item->order_id);
|
||||
|
||||
$item->restore();
|
||||
|
||||
// recalc totals
|
||||
$this->recalcTotals($order);
|
||||
$this->updateInvoiceFromOrder($order);
|
||||
|
||||
|
||||
return redirect()->back()->with('success', 'Item restored and totals updated.');
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// ORDER CRUD: update / destroy
|
||||
// ---------------------------
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$order = Order::findOrFail($id);
|
||||
|
||||
$data = $request->validate([
|
||||
'mark_no' => 'required|string',
|
||||
'origin' => 'nullable|string',
|
||||
'destination' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$order->update([
|
||||
'mark_no' => $data['mark_no'],
|
||||
'origin' => $data['origin'] ?? null,
|
||||
'destination' => $data['destination'] ?? null,
|
||||
]);
|
||||
|
||||
// optionally recalc totals (not necessary unless you change item-level fields here)
|
||||
$this->recalcTotals($order);
|
||||
|
||||
return redirect()->route('admin.orders.show', $order->id)
|
||||
->with('success', 'Order updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft-delete whole order and its items (soft-delete items first then order)
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$order = Order::findOrFail($id);
|
||||
|
||||
// soft-delete items first (so they show up in onlyTrashed for restore)
|
||||
OrderItem::where('order_id', $order->id)->delete();
|
||||
|
||||
// then soft-delete order
|
||||
$order->delete();
|
||||
|
||||
return redirect()->route('admin.orders.index')
|
||||
->with('success', 'Order deleted successfully.');
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// HELPERS
|
||||
// ---------------------------
|
||||
/**
|
||||
* Recalculate totals for the order from current (non-deleted) items
|
||||
*/
|
||||
private function recalcTotals(Order $order)
|
||||
{
|
||||
// make sure we re-query live items (non-deleted)
|
||||
$items = $order->items()->get();
|
||||
|
||||
$order->update([
|
||||
'ctn' => (int) $items->sum(fn($i) => (int) ($i->ctn ?? 0)),
|
||||
'qty' => (int) $items->sum(fn($i) => (int) ($i->qty ?? 0)),
|
||||
'ttl_qty' => (int) $items->sum(fn($i) => (int) ($i->ttl_qty ?? 0)),
|
||||
'ttl_amount'=> (float) $items->sum(fn($i) => (float) ($i->ttl_amount ?? 0)),
|
||||
'cbm' => (float) $items->sum(fn($i) => (float) ($i->cbm ?? 0)),
|
||||
'ttl_cbm' => (float) $items->sum(fn($i) => (float) ($i->ttl_cbm ?? 0)),
|
||||
'kg' => (float) $items->sum(fn($i) => (float) ($i->kg ?? 0)),
|
||||
'ttl_kg' => (float) $items->sum(fn($i) => (float) ($i->ttl_kg ?? 0)),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate order id (keeps old format)
|
||||
*/
|
||||
private function generateOrderId()
|
||||
{
|
||||
$year = date('y');
|
||||
$prefix = "KNT-$year-";
|
||||
|
||||
$lastOrder = Order::latest('id')->first();
|
||||
$nextNumber = $lastOrder ? intval(substr($lastOrder->order_id, -8)) + 1 : 1;
|
||||
|
||||
return $prefix . str_pad($nextNumber, 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
// INVOICE CREATION (optional helper used by store/finish)
|
||||
// ---------------------------
|
||||
private function createInvoice(Order $order)
|
||||
{
|
||||
$invoiceNumber = $this->generateInvoiceNumber();
|
||||
$customer = $this->getCustomerFromMarkList($order->mark_no);
|
||||
$totalAmount = $order->ttl_amount;
|
||||
|
||||
$invoice = Invoice::create([
|
||||
'order_id' => $order->id,
|
||||
'customer_id' => $customer->id ?? null,
|
||||
'mark_no' => $order->mark_no,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_date' => now(),
|
||||
'due_date' => now()->addDays(10),
|
||||
'payment_method' => null,
|
||||
'reference_no' => null,
|
||||
'status' => 'pending',
|
||||
'final_amount' => $totalAmount,
|
||||
'gst_percent' => 0,
|
||||
'gst_amount' => 0,
|
||||
'final_amount_with_gst' => $totalAmount,
|
||||
'customer_name' => $customer->customer_name ?? null,
|
||||
'company_name' => $customer->company_name ?? null,
|
||||
'customer_email' => $customer->email ?? null,
|
||||
'customer_mobile' => $customer->mobile_no ?? null,
|
||||
'customer_address' => $customer->address ?? null,
|
||||
'pincode' => $customer->pincode ?? null,
|
||||
'notes' => null,
|
||||
'pdf_path' => null,
|
||||
]);
|
||||
|
||||
// clone order items into invoice items
|
||||
foreach ($order->items as $item) {
|
||||
InvoiceItem::create([
|
||||
'invoice_id' => $invoice->id,
|
||||
'description' => $item->description,
|
||||
'ctn' => $item->ctn,
|
||||
'qty' => $item->qty,
|
||||
'ttl_qty' => $item->ttl_qty,
|
||||
'unit' => $item->unit,
|
||||
'price' => $item->price,
|
||||
'ttl_amount' => $item->ttl_amount,
|
||||
'cbm' => $item->cbm,
|
||||
'ttl_cbm' => $item->ttl_cbm,
|
||||
'kg' => $item->kg,
|
||||
'ttl_kg' => $item->ttl_kg,
|
||||
'shop_no' => $item->shop_no,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function generateInvoiceNumber()
|
||||
{
|
||||
$lastInvoice = Invoice::latest()->first();
|
||||
$nextInvoice = $lastInvoice ? $lastInvoice->id + 1 : 1;
|
||||
|
||||
return 'INV-' . date('Y') . '-' . str_pad($nextInvoice, 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
private function getCustomerFromMarkList($markNo)
|
||||
{
|
||||
$markList = MarkList::where('mark_no', $markNo)->first();
|
||||
|
||||
if ($markList && $markList->customer_id) {
|
||||
return User::where('customer_id', $markList->customer_id)->first();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getCustomerFromOrder($order)
|
||||
{
|
||||
if ($order->markList && $order->markList->customer_id) {
|
||||
return User::where('customer_id', $order->markList->customer_id)->first();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function popup($id)
|
||||
{
|
||||
// Load order with items + markList
|
||||
$order = Order::with(['items', 'markList'])->findOrFail($id);
|
||||
|
||||
// Fetch user based on markList customer_id (same as show method)
|
||||
$user = null;
|
||||
if ($order->markList && $order->markList->customer_id) {
|
||||
$user = \App\Models\User::where('customer_id', $order->markList->customer_id)->first();
|
||||
}
|
||||
|
||||
return view('admin.popup', compact('order', 'user'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function resetTemp()
|
||||
{
|
||||
session()->forget(['temp_order_items', 'mark_no', 'origin', 'destination']);
|
||||
|
||||
return redirect()->to(route('admin.orders.index') . '#createOrderForm')
|
||||
->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();
|
||||
|
||||
return view('admin.orders', compact('orders'));
|
||||
}
|
||||
|
||||
// inside AdminOrderController
|
||||
|
||||
private function buildOrdersQueryFromRequest(Request $request)
|
||||
{
|
||||
$query = Order::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}%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
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 addTempItem(Request $request)
|
||||
{
|
||||
@@ -67,31 +505,8 @@ class AdminOrderController extends Controller
|
||||
session()->push('temp_order_items', $item);
|
||||
|
||||
return redirect()->to(route('admin.orders.index') . '#createOrderForm')
|
||||
->with('success', 'Item added.');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// STEP 2 : DELETE TEMPORARY ITEM
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function deleteTempItem(Request $request)
|
||||
{
|
||||
$index = $request->index;
|
||||
|
||||
$items = session('temp_order_items', []);
|
||||
|
||||
if (isset($items[$index])) {
|
||||
unset($items[$index]);
|
||||
session(['temp_order_items' => array_values($items)]);
|
||||
}
|
||||
|
||||
// If no items left → reset mark_no lock
|
||||
if (empty($items)) {
|
||||
session()->forget(['mark_no', 'origin', 'destination']);
|
||||
}
|
||||
|
||||
return redirect()->to(route('admin.orders.index') . '#createOrderForm')
|
||||
->with('success', 'Item removed successfully.');
|
||||
->with('success', 'Item added.');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -99,256 +514,228 @@ class AdminOrderController extends Controller
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function finishOrder(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'mark_no' => 'required',
|
||||
'origin' => 'required',
|
||||
'destination' => 'required',
|
||||
]);
|
||||
{
|
||||
$request->validate([
|
||||
'mark_no' => 'required',
|
||||
'origin' => 'required',
|
||||
'destination' => 'required',
|
||||
]);
|
||||
|
||||
$items = session('temp_order_items', []);
|
||||
$items = session('temp_order_items', []);
|
||||
|
||||
if (empty($items)) {
|
||||
return redirect()->to(route('admin.orders.index') . '#createOrderForm')
|
||||
->with('error', 'Add at least one item before finishing.');
|
||||
}
|
||||
if (empty($items)) {
|
||||
return redirect()->to(route('admin.orders.index') . '#createOrderForm')
|
||||
->with('error', 'Add at least one item before finishing.');
|
||||
}
|
||||
|
||||
// =======================
|
||||
// GENERATE ORDER ID
|
||||
// =======================
|
||||
$year = date('y');
|
||||
$prefix = "KNT-$year-";
|
||||
// =======================
|
||||
// GENERATE ORDER ID
|
||||
// =======================
|
||||
$year = date('y');
|
||||
$prefix = "KNT-$year-";
|
||||
|
||||
$lastOrder = Order::latest('id')->first();
|
||||
$nextNumber = $lastOrder ? intval(substr($lastOrder->order_id, -8)) + 1 : 1;
|
||||
$lastOrder = Order::latest('id')->first();
|
||||
$nextNumber = $lastOrder ? intval(substr($lastOrder->order_id, -8)) + 1 : 1;
|
||||
|
||||
$orderId = $prefix . str_pad($nextNumber, 8, '0', STR_PAD_LEFT);
|
||||
$orderId = $prefix . str_pad($nextNumber, 8, '0', STR_PAD_LEFT);
|
||||
|
||||
// =======================
|
||||
// TOTAL SUMS
|
||||
// =======================
|
||||
$total_ctn = array_sum(array_column($items, 'ctn'));
|
||||
$total_qty = array_sum(array_column($items, 'qty'));
|
||||
$total_ttl_qty = array_sum(array_column($items, 'ttl_qty'));
|
||||
$total_amount = array_sum(array_column($items, 'ttl_amount'));
|
||||
$total_cbm = array_sum(array_column($items, 'cbm'));
|
||||
$total_ttl_cbm = array_sum(array_column($items, 'ttl_cbm'));
|
||||
$total_kg = array_sum(array_column($items, 'kg'));
|
||||
$total_ttl_kg = array_sum(array_column($items, 'ttl_kg'));
|
||||
// =======================
|
||||
// TOTAL SUMS
|
||||
// =======================
|
||||
$total_ctn = array_sum(array_column($items, 'ctn'));
|
||||
$total_qty = array_sum(array_column($items, 'qty'));
|
||||
$total_ttl_qty = array_sum(array_column($items, 'ttl_qty'));
|
||||
$total_amount = array_sum(array_column($items, 'ttl_amount'));
|
||||
$total_cbm = array_sum(array_column($items, 'cbm'));
|
||||
$total_ttl_cbm = array_sum(array_column($items, 'ttl_cbm'));
|
||||
$total_kg = array_sum(array_column($items, 'kg'));
|
||||
$total_ttl_kg = array_sum(array_column($items, 'ttl_kg'));
|
||||
|
||||
// =======================
|
||||
// CREATE ORDER
|
||||
// =======================
|
||||
$order = Order::create([
|
||||
'order_id' => $orderId,
|
||||
'mark_no' => $request->mark_no,
|
||||
'origin' => $request->origin,
|
||||
'destination' => $request->destination,
|
||||
'ctn' => $total_ctn,
|
||||
'qty' => $total_qty,
|
||||
'ttl_qty' => $total_ttl_qty,
|
||||
'ttl_amount' => $total_amount,
|
||||
'cbm' => $total_cbm,
|
||||
'ttl_cbm' => $total_ttl_cbm,
|
||||
'kg' => $total_kg,
|
||||
'ttl_kg' => $total_ttl_kg,
|
||||
'status' => 'pending',
|
||||
]);
|
||||
// =======================
|
||||
// CREATE ORDER
|
||||
// =======================
|
||||
$order = Order::create([
|
||||
'order_id' => $orderId,
|
||||
'mark_no' => $request->mark_no,
|
||||
'origin' => $request->origin,
|
||||
'destination' => $request->destination,
|
||||
'ctn' => $total_ctn,
|
||||
'qty' => $total_qty,
|
||||
'ttl_qty' => $total_ttl_qty,
|
||||
'ttl_amount' => $total_amount,
|
||||
'cbm' => $total_cbm,
|
||||
'ttl_cbm' => $total_ttl_cbm,
|
||||
'kg' => $total_kg,
|
||||
'ttl_kg' => $total_ttl_kg,
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
// SAVE ORDER ITEMS
|
||||
foreach ($items as $item) {
|
||||
OrderItem::create([
|
||||
// SAVE ORDER ITEMS
|
||||
foreach ($items as $item) {
|
||||
OrderItem::create([
|
||||
'order_id' => $order->id,
|
||||
'description' => $item['description'],
|
||||
'ctn' => $item['ctn'],
|
||||
'qty' => $item['qty'],
|
||||
'ttl_qty' => $item['ttl_qty'],
|
||||
'unit' => $item['unit'],
|
||||
'price' => $item['price'],
|
||||
'ttl_amount' => $item['ttl_amount'],
|
||||
'cbm' => $item['cbm'],
|
||||
'ttl_cbm' => $item['ttl_cbm'],
|
||||
'kg' => $item['kg'],
|
||||
'ttl_kg' => $item['ttl_kg'],
|
||||
'shop_no' => $item['shop_no'],
|
||||
]);
|
||||
}
|
||||
|
||||
// =======================
|
||||
// INVOICE CREATION START
|
||||
// =======================
|
||||
|
||||
// 1. Auto-generate invoice number
|
||||
$lastInvoice = \App\Models\Invoice::latest()->first();
|
||||
$nextInvoice = $lastInvoice ? $lastInvoice->id + 1 : 1;
|
||||
$invoiceNumber = 'INV-' . date('Y') . '-' . str_pad($nextInvoice, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
// 2. Fetch customer (using mark list → customer_id)
|
||||
$markList = MarkList::where('mark_no', $order->mark_no)->first();
|
||||
$customer = null;
|
||||
|
||||
if ($markList && $markList->customer_id) {
|
||||
$customer = \App\Models\User::where('customer_id', $markList->customer_id)->first();
|
||||
}
|
||||
|
||||
// 3. Create Invoice Record
|
||||
$invoice = \App\Models\Invoice::create([
|
||||
'order_id' => $order->id,
|
||||
'description' => $item['description'],
|
||||
'ctn' => $item['ctn'],
|
||||
'qty' => $item['qty'],
|
||||
'ttl_qty' => $item['ttl_qty'],
|
||||
'unit' => $item['unit'],
|
||||
'price' => $item['price'],
|
||||
'ttl_amount' => $item['ttl_amount'],
|
||||
'cbm' => $item['cbm'],
|
||||
'ttl_cbm' => $item['ttl_cbm'],
|
||||
'kg' => $item['kg'],
|
||||
'ttl_kg' => $item['ttl_kg'],
|
||||
'shop_no' => $item['shop_no'],
|
||||
'customer_id' => $customer->id ?? null,
|
||||
'mark_no' => $order->mark_no,
|
||||
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_date' => now(),
|
||||
'due_date' => now()->addDays(10),
|
||||
|
||||
'payment_method' => null,
|
||||
'reference_no' => null,
|
||||
'status' => 'pending',
|
||||
|
||||
'final_amount' => $total_amount,
|
||||
'gst_percent' => 0,
|
||||
'gst_amount' => 0,
|
||||
'final_amount_with_gst' => $total_amount,
|
||||
|
||||
// snapshot customer fields
|
||||
'customer_name' => $customer->customer_name ?? null,
|
||||
'company_name' => $customer->company_name ?? null,
|
||||
'customer_email' => $customer->email ?? null,
|
||||
'customer_mobile' => $customer->mobile_no ?? null,
|
||||
'customer_address' => $customer->address ?? null,
|
||||
'pincode' => $customer->pincode ?? null,
|
||||
|
||||
'notes' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
// =======================
|
||||
// INVOICE CREATION START
|
||||
// =======================
|
||||
|
||||
// 1. Auto-generate invoice number
|
||||
$lastInvoice = \App\Models\Invoice::latest()->first();
|
||||
$nextInvoice = $lastInvoice ? $lastInvoice->id + 1 : 1;
|
||||
$invoiceNumber = 'INV-' . date('Y') . '-' . str_pad($nextInvoice, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
// 2. Fetch customer (using mark list → customer_id)
|
||||
$markList = MarkList::where('mark_no', $order->mark_no)->first();
|
||||
$customer = null;
|
||||
|
||||
if ($markList && $markList->customer_id) {
|
||||
$customer = \App\Models\User::where('customer_id', $markList->customer_id)->first();
|
||||
}
|
||||
|
||||
// 3. Create Invoice Record
|
||||
$invoice = \App\Models\Invoice::create([
|
||||
'order_id' => $order->id,
|
||||
'customer_id' => $customer->id ?? null,
|
||||
'mark_no' => $order->mark_no,
|
||||
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_date' => now(),
|
||||
'due_date' => now()->addDays(10),
|
||||
|
||||
'payment_method' => null,
|
||||
'reference_no' => null,
|
||||
'status' => 'pending',
|
||||
|
||||
'final_amount' => $total_amount,
|
||||
'gst_percent' => 0,
|
||||
'gst_amount' => 0,
|
||||
'final_amount_with_gst' => $total_amount,
|
||||
|
||||
// snapshot customer fields
|
||||
'customer_name' => $customer->customer_name ?? null,
|
||||
'company_name' => $customer->company_name ?? null,
|
||||
'customer_email' => $customer->email ?? null,
|
||||
'customer_mobile' => $customer->mobile_no ?? null,
|
||||
'customer_address' => $customer->address ?? null,
|
||||
'pincode' => $customer->pincode ?? null,
|
||||
|
||||
'notes' => null,
|
||||
]);
|
||||
|
||||
// 4. Clone order items into invoice_items
|
||||
foreach ($order->items as $item) {
|
||||
\App\Models\InvoiceItem::create([
|
||||
'invoice_id' => $invoice->id,
|
||||
'description' => $item->description,
|
||||
'ctn' => $item->ctn,
|
||||
'qty' => $item->qty,
|
||||
'ttl_qty' => $item->ttl_qty,
|
||||
'unit' => $item->unit,
|
||||
'price' => $item->price,
|
||||
'ttl_amount' => $item->ttl_amount,
|
||||
'cbm' => $item->cbm,
|
||||
'ttl_cbm' => $item->ttl_cbm,
|
||||
'kg' => $item->kg,
|
||||
'ttl_kg' => $item->ttl_kg,
|
||||
'shop_no' => $item->shop_no,
|
||||
]);
|
||||
}
|
||||
|
||||
// 5. TODO: PDF generation (I will add this later)
|
||||
$invoice->pdf_path = null; // placeholder for now
|
||||
$invoice->save();
|
||||
|
||||
// =======================
|
||||
// END INVOICE CREATION
|
||||
// =======================
|
||||
|
||||
// CLEAR TEMP DATA
|
||||
session()->forget(['temp_order_items', 'mark_no', 'origin', 'destination']);
|
||||
|
||||
return redirect()->route('admin.orders.index')
|
||||
->with('success', 'Order + Invoice created successfully.');
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ORDER SHOW PAGE
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$order = Order::with('items', 'markList')->findOrFail($id);
|
||||
|
||||
$user = null;
|
||||
if ($order->markList && $order->markList->customer_id) {
|
||||
$user = \App\Models\User::where('customer_id', $order->markList->customer_id)->first();
|
||||
// 4. Clone order items into invoice_items
|
||||
foreach ($order->items as $item) {
|
||||
\App\Models\InvoiceItem::create([
|
||||
'invoice_id' => $invoice->id,
|
||||
'description' => $item->description,
|
||||
'ctn' => $item->ctn,
|
||||
'qty' => $item->qty,
|
||||
'ttl_qty' => $item->ttl_qty,
|
||||
'unit' => $item->unit,
|
||||
'price' => $item->price,
|
||||
'ttl_amount' => $item->ttl_amount,
|
||||
'cbm' => $item->cbm,
|
||||
'ttl_cbm' => $item->ttl_cbm,
|
||||
'kg' => $item->kg,
|
||||
'ttl_kg' => $item->ttl_kg,
|
||||
'shop_no' => $item->shop_no,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('admin.orders_show', compact('order', 'user'));
|
||||
}
|
||||
// 5. TODO: PDF generation (I will add this later)
|
||||
$invoice->pdf_path = null; // placeholder for now
|
||||
$invoice->save();
|
||||
|
||||
public function popup($id)
|
||||
{
|
||||
// Load order with items + markList
|
||||
$order = Order::with(['items', 'markList'])->findOrFail($id);
|
||||
// =======================
|
||||
// END INVOICE CREATION
|
||||
// =======================
|
||||
|
||||
// Fetch user based on markList customer_id (same as show method)
|
||||
$user = null;
|
||||
if ($order->markList && $order->markList->customer_id) {
|
||||
$user = \App\Models\User::where('customer_id', $order->markList->customer_id)->first();
|
||||
}
|
||||
|
||||
return view('admin.popup', compact('order', 'user'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function resetTemp()
|
||||
{
|
||||
// CLEAR TEMP DATA
|
||||
session()->forget(['temp_order_items', 'mark_no', 'origin', 'destination']);
|
||||
|
||||
return redirect()->to(route('admin.orders.index') . '#createOrderForm')
|
||||
->with('success', 'Order reset successfully.');
|
||||
return redirect()->route('admin.orders.index')
|
||||
->with('success', 'Order + Invoice created successfully.');
|
||||
}
|
||||
|
||||
public function orderShow()
|
||||
// ---------------------------
|
||||
// ORDER CRUD: update / destroy
|
||||
// ---------------------------
|
||||
public function updateItem(Request $request, $id)
|
||||
{
|
||||
$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();
|
||||
$item = OrderItem::findOrFail($id);
|
||||
$order = $item->order;
|
||||
|
||||
return view('admin.orders', compact('orders'));
|
||||
$item->update([
|
||||
'description' => $request->description,
|
||||
'ctn' => $request->ctn,
|
||||
'qty' => $request->qty,
|
||||
'ttl_qty' => $request->ttl_qty,
|
||||
'unit' => $request->unit,
|
||||
'price' => $request->price,
|
||||
'ttl_amount' => $request->ttl_amount,
|
||||
'cbm' => $request->cbm,
|
||||
'ttl_cbm' => $request->ttl_cbm,
|
||||
'kg' => $request->kg,
|
||||
'ttl_kg' => $request->ttl_kg,
|
||||
'shop_no' => $request->shop_no,
|
||||
]);
|
||||
|
||||
$this->recalcTotals($order);
|
||||
$this->updateInvoiceFromOrder($order); // <-- NEW
|
||||
|
||||
return back()->with('success', 'Item updated successfully');
|
||||
}
|
||||
|
||||
public function downloadPdf(Request $request)
|
||||
{
|
||||
$query = Order::with(['markList', 'invoice', 'shipments']);
|
||||
|
||||
// Apply filters
|
||||
if ($request->has('search') && $request->search) {
|
||||
$search = $request->search;
|
||||
$query->where(function($q) use ($search) {
|
||||
$q->where('order_id', 'like', "%{$search}%")
|
||||
->orWhereHas('markList', function($q) use ($search) {
|
||||
$q->where('company_name', 'like', "%{$search}%");
|
||||
})
|
||||
->orWhereHas('invoice', function($q) use ($search) {
|
||||
$q->where('invoice_number', 'like', "%{$search}%");
|
||||
});
|
||||
});
|
||||
private function updateInvoiceFromOrder(Order $order)
|
||||
{
|
||||
$invoice = Invoice::where('order_id', $order->id)->first();
|
||||
|
||||
if (!$invoice) {
|
||||
return; // No invoice exists (should not happen normally)
|
||||
}
|
||||
|
||||
// Update invoice totals
|
||||
$invoice->final_amount = $order->ttl_amount;
|
||||
$invoice->gst_percent = 0;
|
||||
$invoice->gst_amount = 0;
|
||||
$invoice->final_amount_with_gst = $order->ttl_amount;
|
||||
$invoice->save();
|
||||
|
||||
// Delete old invoice items
|
||||
InvoiceItem::where('invoice_id', $invoice->id)->delete();
|
||||
|
||||
// Re-create invoice items from updated order items
|
||||
foreach ($order->items as $item) {
|
||||
InvoiceItem::create([
|
||||
'invoice_id' => $invoice->id,
|
||||
'description' => $item->description,
|
||||
'ctn' => $item->ctn,
|
||||
'qty' => $item->qty,
|
||||
'ttl_qty' => $item->ttl_qty,
|
||||
'unit' => $item->unit,
|
||||
'price' => $item->price,
|
||||
'ttl_amount' => $item->ttl_amount,
|
||||
'cbm' => $item->cbm,
|
||||
'ttl_cbm' => $item->ttl_cbm,
|
||||
'kg' => $item->kg,
|
||||
'ttl_kg' => $item->ttl_kg,
|
||||
'shop_no' => $item->shop_no,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->has('status') && $request->status) {
|
||||
$query->whereHas('invoice', function($q) use ($request) {
|
||||
$q->where('status', $request->status);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('shipment') && $request->shipment) {
|
||||
$query->whereHas('shipments', function($q) use ($request) {
|
||||
$q->where('status', $request->shipment);
|
||||
});
|
||||
}
|
||||
|
||||
$orders = $query->get();
|
||||
|
||||
$pdf = PDF::loadView('admin.orders.pdf', compact('orders'));
|
||||
return $pdf->download('orders-report-' . date('Y-m-d') . '.pdf');
|
||||
}
|
||||
|
||||
public function downloadExcel(Request $request)
|
||||
{
|
||||
return Excel::download(new OrdersExport($request), 'orders-report-' . date('Y-m-d') . '.xlsx');
|
||||
}
|
||||
|
||||
}
|
||||
179
app/Http/Controllers/Admin/AdminStaffController.php
Normal file
179
app/Http/Controllers/Admin/AdminStaffController.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\Admin;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AdminStaffController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$staff = Admin::where('type', 'staff')->orderBy('id', 'DESC')->get();
|
||||
return view('admin.staff.index', compact('staff'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$permissions = Permission::where('guard_name', 'admin')->get()->groupBy(function ($p) {
|
||||
return explode('.', $p->name)[0];
|
||||
});
|
||||
|
||||
return view('admin.staff.create', compact('permissions'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
// Personal Info
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:admins,email',
|
||||
'phone' => 'required|string|max:20',
|
||||
'emergency_phone' => 'nullable|string|max:20',
|
||||
'address' => 'nullable|string|max:255',
|
||||
|
||||
// Professional info
|
||||
'role' => 'nullable|string|max:100',
|
||||
'department' => 'nullable|string|max:100',
|
||||
'designation' => 'nullable|string|max:100',
|
||||
'joining_date' => 'nullable|date',
|
||||
'status' => 'required|string|in:active,inactive',
|
||||
'additional_info' => 'nullable|string',
|
||||
|
||||
// System access
|
||||
'username' => 'nullable|string|unique:admins,username',
|
||||
'password' => 'required|string|min:6',
|
||||
|
||||
// Permissions
|
||||
'permissions' => 'nullable|array',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$admin = Admin::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'phone' => $request->phone,
|
||||
'emergency_phone' => $request->emergency_phone,
|
||||
'address' => $request->address,
|
||||
|
||||
'role' => $request->role,
|
||||
'department' => $request->department,
|
||||
'designation' => $request->designation,
|
||||
'joining_date' => $request->joining_date,
|
||||
'status' => $request->status,
|
||||
'additional_info' => $request->additional_info,
|
||||
|
||||
'username' => $request->username,
|
||||
'password' => Hash::make($request->password),
|
||||
'type' => 'staff',
|
||||
]);
|
||||
|
||||
// Generate EMPLOYEE ID using admin ID (safe)
|
||||
$employeeId = 'EMP' . str_pad($admin->id, 4, '0', STR_PAD_LEFT);
|
||||
$admin->update(['employee_id' => $employeeId]);
|
||||
|
||||
// Assign permissions (if any)
|
||||
if ($request->permissions) {
|
||||
$admin->givePermissionTo($request->permissions);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return redirect()->route('admin.staff.index')
|
||||
->with('success', 'Staff created successfully.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return back()->withErrors(['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$staff = Admin::where('type', 'staff')->findOrFail($id);
|
||||
|
||||
$permissions = Permission::where('guard_name', 'admin')->get()->groupBy(function ($p) {
|
||||
return explode('.', $p->name)[0];
|
||||
});
|
||||
|
||||
$staffPermissions = $staff->permissions->pluck('name')->toArray();
|
||||
|
||||
return view('admin.staff.edit', compact('staff', 'permissions', 'staffPermissions'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$staff = Admin::where('type', 'staff')->findOrFail($id);
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:admins,email,' . $staff->id,
|
||||
'phone' => 'required|string|max:20',
|
||||
'emergency_phone' => 'nullable|string|max:20',
|
||||
'address' => 'nullable|string|max:255',
|
||||
|
||||
'role' => 'nullable|string|max:100',
|
||||
'department' => 'nullable|string|max:100',
|
||||
'designation' => 'nullable|string|max:100',
|
||||
'joining_date' => 'nullable|date',
|
||||
'status' => 'required|string|in:active,inactive',
|
||||
'additional_info' => 'nullable|string',
|
||||
|
||||
'username' => 'nullable|string|unique:admins,username,' . $staff->id,
|
||||
'password' => 'nullable|string|min:6',
|
||||
|
||||
'permissions' => 'nullable|array',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$staff->update([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'phone' => $request->phone,
|
||||
'emergency_phone' => $request->emergency_phone,
|
||||
'address' => $request->address,
|
||||
|
||||
'role' => $request->role,
|
||||
'department' => $request->department,
|
||||
'designation' => $request->designation,
|
||||
'joining_date' => $request->joining_date,
|
||||
'status' => $request->status,
|
||||
'additional_info' => $request->additional_info,
|
||||
|
||||
'username' => $request->username,
|
||||
]);
|
||||
|
||||
if ($request->password) {
|
||||
$staff->update(['password' => Hash::make($request->password)]);
|
||||
}
|
||||
|
||||
$staff->syncPermissions($request->permissions ?? []);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return redirect()->route('admin.staff.index')
|
||||
->with('success', 'Staff updated successfully.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return back()->withErrors(['error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$staff = Admin::where('type', 'staff')->findOrFail($id);
|
||||
$staff->delete();
|
||||
|
||||
return redirect()->route('admin.staff.index')
|
||||
->with('success', 'Staff removed successfully.');
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class ShipmentController extends Controller
|
||||
/**
|
||||
* Show shipment page (Create Shipment + Shipment List)
|
||||
*/
|
||||
public function index()
|
||||
public function index()
|
||||
{
|
||||
// 1) Get all used order IDs
|
||||
$usedOrderIds = ShipmentItem::pluck('order_id')->toArray();
|
||||
@@ -29,8 +29,6 @@ class ShipmentController extends Controller
|
||||
return view('admin.shipments', compact('availableOrders', 'shipments'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store new shipment
|
||||
*/
|
||||
@@ -115,8 +113,6 @@ class ShipmentController extends Controller
|
||||
return redirect()->back()->with('success', "Shipment $newShipmentId created successfully!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show shipment details (for modal popup)
|
||||
*/
|
||||
@@ -135,8 +131,6 @@ class ShipmentController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update Shipment status from action button
|
||||
*/
|
||||
@@ -164,5 +158,71 @@ class ShipmentController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update shipment details
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$shipment = Shipment::findOrFail($id);
|
||||
|
||||
$data = $request->validate([
|
||||
'origin' => 'required|string',
|
||||
'destination' => 'required|string',
|
||||
'shipment_date' => 'required|date',
|
||||
'status' => 'required|string',
|
||||
]);
|
||||
|
||||
$shipment->update($data);
|
||||
|
||||
// If it's an AJAX request, return JSON response
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Shipment updated successfully.'
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Shipment updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete shipment permanently
|
||||
*/
|
||||
public function destroy($id, Request $request)
|
||||
{
|
||||
$shipment = Shipment::findOrFail($id);
|
||||
|
||||
// Delete shipment items
|
||||
ShipmentItem::where('shipment_id', $shipment->id)->delete();
|
||||
|
||||
// Delete shipment itself
|
||||
$shipment->delete();
|
||||
|
||||
// If it's an AJAX request, return JSON response
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Shipment deleted successfully.'
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('admin.shipments')
|
||||
->with('success', 'Shipment deleted successfully.');
|
||||
}
|
||||
|
||||
public function dummy($id)
|
||||
{
|
||||
// Load shipment
|
||||
$shipment = Shipment::with('orders')->findOrFail($id);
|
||||
|
||||
// Dummy data (you can modify anytime)
|
||||
$dummyData = [
|
||||
'title' => 'Dummy Shipment Preview',
|
||||
'generated_on' => now()->format('d M Y h:i A'),
|
||||
'note' => 'This is dummy shipment information for testing page layout.'
|
||||
];
|
||||
|
||||
return view('admin.view_shipment', compact('shipment', 'dummyData'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,4 +65,52 @@ class UserRequestController extends Controller
|
||||
|
||||
return redirect()->back()->with('info', 'Request rejected successfully.');
|
||||
}
|
||||
|
||||
public function profileUpdateRequests()
|
||||
{
|
||||
$requests = \App\Models\UpdateRequest::where('status', 'pending')
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
return view('admin.profile_update_requests', compact('requests'));
|
||||
}
|
||||
|
||||
public function approveProfileUpdate($id)
|
||||
{
|
||||
$req = \App\Models\UpdateRequest::findOrFail($id);
|
||||
$user = \App\Models\User::findOrFail($req->user_id);
|
||||
|
||||
// FIX: Ensure data is array
|
||||
$newData = is_array($req->data) ? $req->data : json_decode($req->data, true);
|
||||
|
||||
foreach ($newData as $key => $value) {
|
||||
if ($value !== null && $value !== "") {
|
||||
if (in_array($key, ['customer_name','company_name','designation','email','mobile_no','address','pincode'])) {
|
||||
$user->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
$req->status = 'approved';
|
||||
$req->admin_note = 'Approved by admin on ' . now();
|
||||
$req->save();
|
||||
|
||||
return back()->with('success', 'Profile updated successfully.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function rejectProfileUpdate($id)
|
||||
{
|
||||
$req = \App\Models\UpdateRequest::findOrFail($id);
|
||||
$req->status = 'rejected';
|
||||
$req->admin_note = 'Rejected by admin on ' . now();
|
||||
$req->save();
|
||||
|
||||
return back()->with('info', 'Profile update request rejected.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,74 @@ use App\Models\User;
|
||||
|
||||
class UserAuthController extends Controller
|
||||
{
|
||||
|
||||
public function refreshToken()
|
||||
{
|
||||
\Log::info('🔄 refreshToken() called');
|
||||
|
||||
try {
|
||||
// Get current token
|
||||
$currentToken = JWTAuth::getToken();
|
||||
|
||||
if (!$currentToken) {
|
||||
\Log::warning('⚠ No token provided in refreshToken()');
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token not provided',
|
||||
], 401);
|
||||
}
|
||||
|
||||
\Log::info('📥 Current Token:', ['token' => (string) $currentToken]);
|
||||
|
||||
// Try refreshing token
|
||||
$newToken = JWTAuth::refresh($currentToken);
|
||||
|
||||
\Log::info('✅ Token refreshed successfully', ['new_token' => $newToken]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'token' => $newToken,
|
||||
]);
|
||||
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
\Log::error('❌ TokenExpiredException in refreshToken()', [
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token expired, cannot refresh.',
|
||||
], 401);
|
||||
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
|
||||
\Log::error('❌ TokenInvalidException in refreshToken()', [
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid token.',
|
||||
], 401);
|
||||
|
||||
} catch (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
||||
\Log::error('❌ JWTException in refreshToken()', [
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Could not refresh token.',
|
||||
], 401);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('❌ General Exception in refreshToken()', [
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unexpected error while refreshing token.',
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User Login
|
||||
*/
|
||||
@@ -60,6 +128,8 @@ class UserAuthController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* User Logout
|
||||
*/
|
||||
|
||||
296
app/Http/Controllers/user/UserOrderController.php
Normal file
296
app/Http/Controllers/user/UserOrderController.php
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth;
|
||||
|
||||
class UserOrderController extends Controller
|
||||
{
|
||||
public function orderSummary()
|
||||
{
|
||||
// Authenticate user via JWT
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Get all orders
|
||||
// -------------------------------------
|
||||
$orders = $user->orders()->with('invoice')->get();
|
||||
|
||||
// -------------------------------------
|
||||
// Counts
|
||||
// -------------------------------------
|
||||
$totalOrders = $orders->count();
|
||||
$delivered = $orders->where('status', 'delivered')->count();
|
||||
$inTransit = $orders->where('status', '!=', 'delivered')->count();
|
||||
$active = $totalOrders;
|
||||
|
||||
// -------------------------------------
|
||||
// Total Amount = Invoice.total_with_gst
|
||||
// -------------------------------------
|
||||
$totalAmount = $orders->sum(function ($o) {
|
||||
return $o->invoice->final_amount_with_gst ?? 0;
|
||||
});
|
||||
|
||||
// Format total amount in K, L, Cr
|
||||
$formattedAmount = $this->formatIndianNumber($totalAmount);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
|
||||
'summary' => [
|
||||
'active_orders' => $active,
|
||||
'in_transit_orders' => $inTransit,
|
||||
'delivered_orders' => $delivered,
|
||||
'total_value' => $formattedAmount, // formatted value
|
||||
'total_raw' => $totalAmount // original value
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert number into Indian Format:
|
||||
* 1000 -> 1K
|
||||
* 100000 -> 1L
|
||||
* 10000000 -> 1Cr
|
||||
*/
|
||||
private function formatIndianNumber($num)
|
||||
{
|
||||
if ($num >= 10000000) {
|
||||
return round($num / 10000000, 1) . 'Cr';
|
||||
}
|
||||
|
||||
if ($num >= 100000) {
|
||||
return round($num / 100000, 1) . 'L';
|
||||
}
|
||||
|
||||
if ($num >= 1000) {
|
||||
return round($num / 1000, 1) . 'K';
|
||||
}
|
||||
|
||||
return (string)$num;
|
||||
}
|
||||
|
||||
public function allOrders()
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Fetch orders for this user
|
||||
$orders = $user->orders()
|
||||
->with(['invoice', 'shipments'])
|
||||
->orderBy('id', 'desc')
|
||||
->get()
|
||||
->map(function ($o) {
|
||||
return [
|
||||
'order_id' => $o->order_id,
|
||||
'status' => $o->status,
|
||||
'amount' => $o->ttl_amount,
|
||||
'description'=> "Order from {$o->origin} to {$o->destination}",
|
||||
'created_at' => $o->created_at,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'orders' => $orders
|
||||
]);
|
||||
}
|
||||
|
||||
public function orderDetails($order_id)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
$order = $user->orders()
|
||||
->with(['items'])
|
||||
->where('order_id', $order_id)
|
||||
->first();
|
||||
|
||||
if (!$order) {
|
||||
return response()->json(['success' => false, 'message' => 'Order not found'], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'order' => $order
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function orderShipment($order_id)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
// Get order
|
||||
$order = $user->orders()->where('order_id', $order_id)->first();
|
||||
|
||||
if (!$order) {
|
||||
return response()->json(['success' => false, 'message' => 'Order not found'], 404);
|
||||
}
|
||||
|
||||
// Find shipment only for this order
|
||||
$shipment = $order->shipments()
|
||||
->with(['items' => function ($q) use ($order) {
|
||||
$q->where('order_id', $order->id);
|
||||
}])
|
||||
->first();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'shipment' => $shipment
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function orderInvoice($order_id)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
$order = $user->orders()
|
||||
->with('invoice.items')
|
||||
->where('order_id', $order_id)
|
||||
->first();
|
||||
|
||||
if (!$order) {
|
||||
return response()->json(['success' => false, 'message' => 'Order not found'], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'invoice' => $order->invoice
|
||||
]);
|
||||
}
|
||||
|
||||
public function trackOrder($order_id)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
$order = $user->orders()
|
||||
->with('shipments')
|
||||
->where('order_id', $order_id)
|
||||
->first();
|
||||
|
||||
if (!$order) {
|
||||
return response()->json(['success' => false, 'message' => 'Order not found'], 404);
|
||||
}
|
||||
|
||||
$shipment = $order->shipments()->first();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'track' => [
|
||||
'order_id' => $order->order_id,
|
||||
'shipment_status' => $shipment->status ?? 'pending',
|
||||
'shipment_date' => $shipment->shipment_date ?? null,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function allInvoices()
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Fetch all invoices of customer
|
||||
$invoices = $user->invoices()
|
||||
->withCount('installments')
|
||||
->orderBy('id', 'desc')
|
||||
->get()
|
||||
->map(function ($invoice) {
|
||||
return [
|
||||
'invoice_id' => $invoice->id,
|
||||
'invoice_number' => $invoice->invoice_number,
|
||||
'invoice_date' => $invoice->invoice_date,
|
||||
'status' => $invoice->status,
|
||||
'amount' => $invoice->final_amount_with_gst,
|
||||
'formatted_amount' => $this->formatIndianNumber($invoice->final_amount_with_gst),
|
||||
'pdf_url' => $invoice->pdf_path ? url($invoice->pdf_path) : null,
|
||||
'installment_count' => $invoice->installments_count,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'invoices' => $invoices
|
||||
]);
|
||||
}
|
||||
|
||||
public function invoiceInstallmentsById($invoice_id)
|
||||
{
|
||||
$user = \PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (! $user) {
|
||||
return response()->json(['success' => false, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
// Find invoice by numeric id and ensure it belongs to logged-in user (invoice.customer_id = user.id)
|
||||
$invoice = \App\Models\Invoice::where('id', (int)$invoice_id)
|
||||
->where('customer_id', $user->id)
|
||||
->with(['installments' => function($q){
|
||||
$q->orderBy('installment_date', 'ASC')->orderBy('id', 'ASC');
|
||||
}])
|
||||
->first();
|
||||
|
||||
if (! $invoice) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invoice not found for this customer'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'invoice_id' => $invoice->id,
|
||||
'invoice_number' => $invoice->invoice_number,
|
||||
'installments' => $invoice->installments
|
||||
]);
|
||||
}
|
||||
|
||||
public function invoiceDetails($invoice_id)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (! $user) {
|
||||
return response()->json(['success' => false, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$invoice = \App\Models\Invoice::where('id', $invoice_id)
|
||||
->where('customer_id', $user->id)
|
||||
->with('items')
|
||||
->first();
|
||||
|
||||
if (! $invoice) {
|
||||
return response()->json(['success' => false, 'message' => 'Invoice not found'], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'invoice' => $invoice
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
149
app/Http/Controllers/user/UserProfileController.php
Normal file
149
app/Http/Controllers/user/UserProfileController.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UpdateRequest;
|
||||
use PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth;
|
||||
|
||||
class UserProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get user profile
|
||||
*/
|
||||
public function profile()
|
||||
{
|
||||
try {
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token invalid or expired',
|
||||
], 401);
|
||||
}
|
||||
|
||||
if (! $user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'customer_id' => $user->customer_id,
|
||||
'customer_name' => $user->customer_name,
|
||||
'company_name' => $user->company_name,
|
||||
'designation' => $user->designation,
|
||||
'email' => $user->email,
|
||||
'mobile' => $user->mobile_no,
|
||||
'address' => $user->address,
|
||||
'pincode' => $user->pincode,
|
||||
'status' => $user->status,
|
||||
'customer_type' => $user->customer_type,
|
||||
'profile_image' => $user->profile_image ? url($user->profile_image) : null,
|
||||
'date' => $user->date,
|
||||
'created_at' => $user->created_at,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update profile IMAGE only (no admin approval)
|
||||
*/
|
||||
public function updateProfileImage(Request $request)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (! $user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'profile_image' => 'required|image|mimes:jpg,jpeg,png|max:2048'
|
||||
]);
|
||||
|
||||
// DELETE OLD IMAGE
|
||||
if ($user->profile_image && file_exists(public_path($user->profile_image))) {
|
||||
@unlink(public_path($user->profile_image));
|
||||
}
|
||||
|
||||
// SAVE NEW IMAGE
|
||||
$file = $request->file('profile_image');
|
||||
$filename = 'profile_' . time() . '.' . $file->getClientOriginalExtension();
|
||||
$folder = 'profile_upload/';
|
||||
$file->move(public_path($folder), $filename);
|
||||
|
||||
$user->profile_image = $folder . $filename;
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Profile image updated successfully',
|
||||
'data' => [
|
||||
'customer_id' => $user->customer_id,
|
||||
'customer_name' => $user->customer_name,
|
||||
'company_name' => $user->company_name,
|
||||
'designation' => $user->designation,
|
||||
'email' => $user->email,
|
||||
'mobile' => $user->mobile_no,
|
||||
'address' => $user->address,
|
||||
'pincode' => $user->pincode,
|
||||
'status' => $user->status,
|
||||
'customer_type' => $user->customer_type,
|
||||
'profile_image' => url($user->profile_image),
|
||||
'date' => $user->date,
|
||||
]
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Submit profile update request (requires admin approval)
|
||||
*/
|
||||
public function updateProfileRequest(Request $request)
|
||||
{
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
if (! $user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Validate input
|
||||
$request->validate([
|
||||
'customer_name' => 'nullable|string|max:255',
|
||||
'company_name' => 'nullable|string|max:255',
|
||||
'designation' => 'nullable|string|max:255',
|
||||
'email' => 'nullable|email',
|
||||
'mobile_no' => 'nullable|string|max:15',
|
||||
'address' => 'nullable|string',
|
||||
'pincode' => 'nullable|string|max:10'
|
||||
]);
|
||||
|
||||
// SAVE AS ARRAY (NOT JSON STRING!)
|
||||
$updateReq = \App\Models\UpdateRequest::create([
|
||||
'user_id' => $user->id,
|
||||
'data' => $request->all(), // <---- FIXED
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Profile update request submitted. Waiting for admin approval.',
|
||||
'request_id' => $updateReq->id
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
36
app/Http/Middleware/JwtRefreshMiddleware.php
Normal file
36
app/Http/Middleware/JwtRefreshMiddleware.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
|
||||
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
|
||||
class JwtRefreshMiddleware
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
try {
|
||||
JWTAuth::parseToken()->authenticate();
|
||||
} catch (TokenExpiredException $e) {
|
||||
try {
|
||||
$newToken = JWTAuth::refresh(JWTAuth::getToken());
|
||||
auth()->setToken($newToken);
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
return $response->header('Authorization', 'Bearer ' . $newToken);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['message' => 'Session expired, please login again'], 401);
|
||||
}
|
||||
} catch (TokenInvalidException $e) {
|
||||
return response()->json(['message' => 'Invalid token'], 401);
|
||||
} catch (JWTException $e) {
|
||||
return response()->json(['message' => 'Token missing'], 401);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,43 @@
|
||||
<?php
|
||||
|
||||
// app/Models/Admin.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class Admin extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
use HasFactory, Notifiable, HasRoles;
|
||||
|
||||
protected $guard = 'admin';
|
||||
protected $guard_name = 'admin';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password', 'role',
|
||||
'name', 'email', 'password', 'username',
|
||||
'phone', 'emergency_phone', 'address',
|
||||
'role', 'department', 'designation', 'joining_date',
|
||||
'status', 'additional_info', 'type', // admin/staff indicator
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
public function setPasswordAttribute($value)
|
||||
{
|
||||
if (!$value) return;
|
||||
|
||||
if (Hash::needsRehash($value)) {
|
||||
$this->attributes['password'] = Hash::make($value);
|
||||
} else {
|
||||
$this->attributes['password'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDisplayNameAttribute()
|
||||
{
|
||||
return "{$this->name}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory,SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'order_id',
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class OrderItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'order_id',
|
||||
|
||||
@@ -11,12 +11,27 @@ class ShipmentItem extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'shipment_id',
|
||||
'order_id',
|
||||
'order_ctn',
|
||||
'order_qty',
|
||||
'order_ttl_qty',
|
||||
'order_ttl_amount',
|
||||
'order_ttl_kg',
|
||||
'order_id',
|
||||
|
||||
// OLD fields (keep them if old data exists)
|
||||
'order_ctn',
|
||||
'order_qty',
|
||||
'order_ttl_qty',
|
||||
'order_ttl_amount',
|
||||
'order_ttl_kg',
|
||||
|
||||
// NEW fields (added for correct shipments)
|
||||
'ctn',
|
||||
'qty',
|
||||
'ttl_qty',
|
||||
|
||||
'cbm',
|
||||
'ttl_cbm',
|
||||
|
||||
'kg',
|
||||
'ttl_kg',
|
||||
|
||||
'ttl_amount',
|
||||
];
|
||||
|
||||
// ---------------------------
|
||||
@@ -36,11 +51,11 @@ class ShipmentItem extends Model
|
||||
// Helper: return order data with fallback to snapshot
|
||||
public function getDisplayQty()
|
||||
{
|
||||
return $this->order->qty ?? $this->order_qty;
|
||||
return $this->qty;
|
||||
}
|
||||
|
||||
public function getDisplayAmount()
|
||||
{
|
||||
return $this->order->ttl_amount ?? $this->order_ttl_amount;
|
||||
return $this->ttl_amount;
|
||||
}
|
||||
}
|
||||
|
||||
81
app/Models/Staff.php
Normal file
81
app/Models/Staff.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class Staff extends Authenticatable
|
||||
{
|
||||
use Notifiable, HasRoles, SoftDeletes;
|
||||
|
||||
/**
|
||||
* The guard name used by Spatie.
|
||||
* Make sure this matches the guard you'll use for admin/staff auth (usually 'web' or 'admin').
|
||||
*/
|
||||
protected $guard_name = 'admin';
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
'name',
|
||||
'email',
|
||||
'phone',
|
||||
'emergency_phone',
|
||||
'address',
|
||||
'role', // business role/title (not Spatie role)
|
||||
'department',
|
||||
'designation',
|
||||
'joining_date',
|
||||
'status',
|
||||
'additional_info',
|
||||
'username',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* Hidden attributes (not returned in arrays / JSON).
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* Casts
|
||||
*/
|
||||
protected $casts = [
|
||||
'joining_date' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Mutator: automatically hash password when set.
|
||||
* Accepts plain text and hashes it with bcrypt.
|
||||
*/
|
||||
public function setPasswordAttribute($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If already hashed (starts with $2y$), don't double-hash
|
||||
if (Hash::needsRehash($value)) {
|
||||
$this->attributes['password'] = Hash::make($value);
|
||||
} else {
|
||||
$this->attributes['password'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional helper to get display name (useful in views/logs).
|
||||
*/
|
||||
public function getDisplayNameAttribute()
|
||||
{
|
||||
return $this->name . ' (' . $this->employee_id . ')';
|
||||
}
|
||||
}
|
||||
30
app/Models/UpdateRequest.php
Normal file
30
app/Models/UpdateRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UpdateRequest extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'update_requests';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'data',
|
||||
'status',
|
||||
'admin_note',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'array', // converts JSON to array automatically
|
||||
];
|
||||
|
||||
// Relationship: request belongs to a user
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -89,4 +89,11 @@ class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Invoice::class, 'customer_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
40
app/Providers/AuthServiceProvider.php
Normal file
40
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
// SUPER ADMIN bypass
|
||||
Gate::before(function ($user, $ability) {
|
||||
if ($user->hasRole('super-admin')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// ADMIN bypass
|
||||
Gate::before(function ($user, $ability) {
|
||||
if ($user->hasRole('admin')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,5 @@
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
];
|
||||
|
||||
@@ -7,10 +7,13 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"barryvdh/laravel-dompdf": "^3.1",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"maatwebsite/excel": "^1.1",
|
||||
"mpdf/mpdf": "^8.2",
|
||||
"php-open-source-saver/jwt-auth": "2.8"
|
||||
"php-open-source-saver/jwt-auth": "2.8",
|
||||
"spatie/laravel-permission": "^6.23"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
||||
1268
composer.lock
generated
1268
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -85,6 +85,11 @@ return [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
'staff' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Staff::class,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
202
config/permission.php
Normal file
202
config/permission.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, // default 'role_id',
|
||||
'permission_pivot_key' => null, // default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||
*/
|
||||
'register_octane_reset_listener' => false,
|
||||
|
||||
/*
|
||||
* Events will fire when a role or permission is assigned/unassigned:
|
||||
* \Spatie\Permission\Events\RoleAttached
|
||||
* \Spatie\Permission\Events\RoleDetached
|
||||
* \Spatie\Permission\Events\PermissionAttached
|
||||
* \Spatie\Permission\Events\PermissionDetached
|
||||
*
|
||||
* To enable, set to true, and then create listeners to watch these events.
|
||||
*/
|
||||
'events_enabled' => false,
|
||||
|
||||
/*
|
||||
* Teams Feature.
|
||||
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||
* If you want the migrations to register the 'team_foreign_key', you must
|
||||
* set this to true before doing the migration.
|
||||
* If you already did the migration then you must make a new migration to also
|
||||
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||
* (view the latest version of this package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* The class to use to resolve the permissions team id
|
||||
*/
|
||||
'team_resolver' => \Spatie\Permission\DefaultTeamResolver::class,
|
||||
|
||||
/*
|
||||
* Passport Client Credentials Grant
|
||||
* When set to true the package will use Passports Client to check permissions
|
||||
*/
|
||||
|
||||
'use_passport_client_credentials' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
* See documentation to understand supported syntax.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => false,
|
||||
|
||||
/*
|
||||
* The class to use for interpreting wildcard permissions.
|
||||
* If you need to modify delimiters, override the class and specify its name here.
|
||||
*/
|
||||
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||
|
||||
/* Cache-specific settings */
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
||||
@@ -8,23 +8,16 @@ return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('invoice_installments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('invoice_id');
|
||||
$table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
|
||||
|
||||
$table->date('installment_date');
|
||||
$table->string('payment_method')->nullable(); // cash, bank, UPI, cheque, etc
|
||||
$table->string('reference_no')->nullable();
|
||||
$table->decimal('amount', 10, 2);
|
||||
|
||||
$table->timestamps();
|
||||
// Table already exists. Add updates here if needed.
|
||||
Schema::table('invoice_installments', function (Blueprint $table) {
|
||||
// nothing to update
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoice_installments');
|
||||
Schema::table('invoice_installments', function (Blueprint $table) {
|
||||
// nothing to rollback
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('order_items', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('order_items', function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('order_items', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('order_items', 'deleted_at')) {
|
||||
$table->softDeletes(); // adds deleted_at (nullable timestamp)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('order_items', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('order_items', 'deleted_at')) {
|
||||
$table->dropSoftDeletes(); // drops deleted_at
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->softDeletes(); // creates deleted_at column
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropColumn('deleted_at');
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUpdateRequestsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('update_requests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// The user who is requesting profile update
|
||||
$table->unsignedBigInteger('user_id');
|
||||
|
||||
// JSON data of the requested profile changes
|
||||
$table->json('data')->nullable();
|
||||
|
||||
// pending / approved / rejected
|
||||
$table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
|
||||
|
||||
// Optional message (admin notes)
|
||||
$table->text('admin_note')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign key constraint
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('update_requests');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shipment_items', function (Blueprint $table) {
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'ctn')) {
|
||||
$table->integer('ctn')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'qty')) {
|
||||
$table->integer('qty')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'ttl_qty')) {
|
||||
$table->integer('ttl_qty')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'cbm')) {
|
||||
$table->double('cbm')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'ttl_cbm')) {
|
||||
$table->double('ttl_cbm')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'kg')) {
|
||||
$table->double('kg')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'ttl_kg')) {
|
||||
$table->double('ttl_kg')->default(0);
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('shipment_items', 'ttl_amount')) {
|
||||
$table->double('ttl_amount')->default(0);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shipment_items', function (Blueprint $table) {
|
||||
// safely remove columns (optional)
|
||||
$columns = [
|
||||
'ctn', 'qty', 'ttl_qty', 'cbm',
|
||||
'ttl_cbm', 'kg', 'ttl_kg', 'ttl_amount'
|
||||
];
|
||||
|
||||
foreach ($columns as $col) {
|
||||
if (Schema::hasColumn('shipment_items', $col)) {
|
||||
$table->dropColumn($col);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), Exception::class, 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
// $table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
// $table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
50
database/migrations/2025_12_04_071300_create_staff_table.php
Normal file
50
database/migrations/2025_12_04_071300_create_staff_table.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('staff', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Personal Information
|
||||
$table->string('employee_id')->unique();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('phone');
|
||||
$table->string('emergency_phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
|
||||
// Professional Information
|
||||
$table->string('role')->nullable(); // Job title
|
||||
$table->string('department')->nullable();
|
||||
$table->string('designation')->nullable();
|
||||
$table->date('joining_date')->nullable();
|
||||
$table->string('status')->default('active'); // active/inactive
|
||||
$table->text('additional_info')->nullable();
|
||||
|
||||
// System Access
|
||||
$table->string('username')->unique();
|
||||
$table->string('password');
|
||||
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('staff');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('admins', function (Blueprint $table) {
|
||||
$table->string('employee_id')->unique()->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->string('emergency_phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
|
||||
$table->string('department')->nullable();
|
||||
$table->string('designation')->nullable();
|
||||
$table->date('joining_date')->nullable();
|
||||
$table->enum('status', ['active','inactive'])->default('active');
|
||||
$table->text('additional_info')->nullable();
|
||||
|
||||
$table->string('username')->unique()->nullable();
|
||||
$table->enum('type', ['admin','staff'])->default('staff');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('admins', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::table('admins', function (Blueprint $table) {
|
||||
$table->string('role')->nullable()->change(); // <-- Fix problem
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('admins', function (Blueprint $table) {
|
||||
$table->enum('role', ['admin', 'super-admin'])->nullable()->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('support_tickets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id'); // user who owns the chat
|
||||
$table->string('status')->default('open'); // open / closed
|
||||
$table->timestamps();
|
||||
|
||||
// foreign key constraint (optional but recommended)
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('support_tickets');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('chat_messages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('ticket_id'); // support ticket ID
|
||||
$table->unsignedBigInteger('sender_id'); // user or admin/staff
|
||||
$table->text('message')->nullable(); // message content
|
||||
$table->string('file_path')->nullable(); // image/pdf/video
|
||||
$table->string('file_type')->default('text'); // text/image/pdf/video
|
||||
$table->timestamps();
|
||||
|
||||
// foreign keys
|
||||
$table->foreign('ticket_id')->references('id')->on('support_tickets')->onDelete('cascade');
|
||||
$table->foreign('sender_id')->references('id')->on('users')->onDelete('cascade'); // admin also stored in users table? If admin separate, change later.
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('chat_messages');
|
||||
}
|
||||
};
|
||||
103
database/seeders/PermissionSeeder.php
Normal file
103
database/seeders/PermissionSeeder.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
// ------------------------------------------------------
|
||||
// FINAL PERMISSION LIST (YOUR DATA)
|
||||
// ------------------------------------------------------
|
||||
|
||||
$permissions = [
|
||||
|
||||
// ORDER
|
||||
'order.view',
|
||||
'order.create',
|
||||
'order.edit',
|
||||
'order.delete',
|
||||
|
||||
// EXTRA (ORDERS)
|
||||
'orders.view', // you added this separately
|
||||
|
||||
// SHIPMENT
|
||||
'shipment.view',
|
||||
'shipment.create',
|
||||
'shipment.delete',
|
||||
|
||||
// INVOICE
|
||||
'invoice.view',
|
||||
'invoice.edit',
|
||||
'invoice.add_installment',
|
||||
|
||||
// CUSTOMER
|
||||
'customer.view',
|
||||
'customer.create',
|
||||
|
||||
// REQUEST
|
||||
'request.view',
|
||||
'request.update_profile',
|
||||
|
||||
|
||||
|
||||
// @can('')
|
||||
// @endcan
|
||||
|
||||
|
||||
|
||||
|
||||
// ACCOUNT
|
||||
'account.view',
|
||||
'account.create_order',
|
||||
'account.edit_order',
|
||||
'account.delete_order',
|
||||
'account.toggle_payment_status',
|
||||
'account.add_installment',
|
||||
'account.view_installments',
|
||||
|
||||
// REPORT
|
||||
'report.view',
|
||||
|
||||
// MARK LIST
|
||||
'mark_list.view',
|
||||
];
|
||||
|
||||
// ------------------------------------------------------
|
||||
// CREATE PERMISSIONS
|
||||
// ------------------------------------------------------
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::firstOrCreate(
|
||||
['name' => $permission, 'guard_name' => 'admin']
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
// ROLES
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Create super-admin role
|
||||
$superAdminRole = Role::firstOrCreate(
|
||||
['name' => 'super-admin', 'guard_name' => 'admin']
|
||||
);
|
||||
|
||||
// Create admin role
|
||||
$adminRole = Role::firstOrCreate(
|
||||
['name' => 'admin', 'guard_name' => 'admin']
|
||||
);
|
||||
|
||||
// ------------------------------------------------------
|
||||
// ASSIGN ALL PERMISSIONS TO BOTH ROLES
|
||||
// ------------------------------------------------------
|
||||
|
||||
$allPermissions = Permission::where('guard_name', 'admin')->get();
|
||||
|
||||
$superAdminRole->syncPermissions($allPermissions);
|
||||
$adminRole->syncPermissions($allPermissions);
|
||||
}
|
||||
}
|
||||
BIN
public/invoices/invoice-INV-2025-000017.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000017.pdf
Normal file
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000019.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000019.pdf
Normal file
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000023.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000023.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000028.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000028.pdf
Normal file
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000029.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000029.pdf
Normal file
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000030.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000030.pdf
Normal file
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000032.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000032.pdf
Normal file
Binary file not shown.
BIN
public/invoices/invoice-INV-2025-000033.pdf
Normal file
BIN
public/invoices/invoice-INV-2025-000033.pdf
Normal file
Binary file not shown.
BIN
public/profile_upload/profile_1764645094.jpg
Normal file
BIN
public/profile_upload/profile_1764645094.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
public/profile_upload/profile_1764743106.jpg
Normal file
BIN
public/profile_upload/profile_1764743106.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 209 KiB |
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,14 @@
|
||||
@section('content')
|
||||
|
||||
<style>
|
||||
/* Import Inter font */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
overflow-x: hidden; /* Prevent horizontal scroll on body */
|
||||
}
|
||||
|
||||
.glass-card {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(20px);
|
||||
@@ -14,71 +22,171 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.stats-card {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
/* New Stats Container */
|
||||
.stats-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 12px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
|
||||
padding: 16px;
|
||||
border-radius: 12px;
|
||||
padding: 15px;
|
||||
color: white;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-left: 4px solid #4f46e5;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
transition: transform 0.3s ease;
|
||||
min-height: 80px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-height: 70px;
|
||||
}
|
||||
|
||||
.stats-card:hover {
|
||||
transform: translateY(-3px);
|
||||
.stat-card:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.stats-count {
|
||||
font-size: 1.4rem;
|
||||
.stat-card.warning {
|
||||
border-left-color: #f59e0b;
|
||||
background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
|
||||
}
|
||||
|
||||
.stat-card.success {
|
||||
border-left-color: #10b981;
|
||||
background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
|
||||
}
|
||||
|
||||
.stat-card.danger {
|
||||
border-left-color: #ef4444;
|
||||
background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
|
||||
}
|
||||
|
||||
.stat-card.info {
|
||||
border-left-color: #3b82f6;
|
||||
background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
|
||||
}
|
||||
|
||||
.stat-card.secondary {
|
||||
border-left-color: #8b5cf6;
|
||||
background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(79, 70, 229, 0.1);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.stat-icon i {
|
||||
font-size: 18px;
|
||||
color: #4f46e5;
|
||||
}
|
||||
|
||||
.stat-card.warning .stat-icon {
|
||||
background: rgba(245, 158, 11, 0.1);
|
||||
}
|
||||
|
||||
.stat-card.warning .stat-icon i {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.stat-card.success .stat-icon {
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
|
||||
.stat-card.success .stat-icon i {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.stat-card.danger .stat-icon {
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
}
|
||||
|
||||
.stat-card.danger .stat-icon i {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.stat-card.info .stat-icon {
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
|
||||
.stat-card.info .stat-icon i {
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
.stat-card.secondary .stat-icon {
|
||||
background: rgba(139, 92, 246, 0.1);
|
||||
}
|
||||
|
||||
.stat-card.secondary .stat-icon i {
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
.stat-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: #1a202c;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.stats-label {
|
||||
font-size: 0.75rem;
|
||||
opacity: 0.9;
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: #718096;
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.stats-icon {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
font-size: 1.2rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* Updated Search Container - Wider with icon on left */
|
||||
.search-container {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 10px;
|
||||
padding: 8px 15px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
width: 100%;
|
||||
width: 350px; /* Increased width */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 5px 10px;
|
||||
padding: 4px 8px;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.search-input::placeholder {
|
||||
color: #9ca3af;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.filter-btn {
|
||||
background: rgba(102, 126, 234, 0.1);
|
||||
border: 2px solid transparent;
|
||||
color: #667eea;
|
||||
padding: 6px 15px;
|
||||
padding: 5px 12px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
margin: 0 5px;
|
||||
margin: 0 3px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 0.8rem;
|
||||
font-size: 0.75rem;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.filter-btn.active {
|
||||
@@ -91,45 +199,106 @@
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 8px 20px;
|
||||
padding: 6px 16px;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 0.8rem;
|
||||
font-size: 0.75rem;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
/* Updated Table Styles - Fixed horizontal scroll */
|
||||
.table-glass {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
/* Single gradient for entire header - Blue to Purple */
|
||||
.table thead {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
||||
color: white !important;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
padding: 12px 15px !important;
|
||||
position: relative;
|
||||
font-size: 0.85rem;
|
||||
padding: 14px 12px !important;
|
||||
border: none;
|
||||
font-family: 'Inter', sans-serif;
|
||||
position: relative;
|
||||
background: linear-gradient(135deg, #667eea 0%);;
|
||||
|
||||
}
|
||||
|
||||
/* Curved borders for table headers */
|
||||
/* Remove individual curved borders */
|
||||
.table-header:first-child {
|
||||
border-top-left-radius: 10px;
|
||||
border-top-left-radius: 0;
|
||||
}
|
||||
|
||||
.table-header:last-child {
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
/* Apply rounded corners to the entire header container */
|
||||
.table-container thead tr:first-child th:first-child {
|
||||
border-top-left-radius: 10px;
|
||||
}
|
||||
|
||||
.table-container thead tr:first-child th:last-child {
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
/* Updated Table Column Alignment */
|
||||
.table > :not(caption) > * > * {
|
||||
padding: 12px 15px;
|
||||
padding: 14px 12px;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
||||
font-size: 14px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Center align specific columns */
|
||||
.table > :not(caption) > * > *:nth-child(2), /* Customer ID */
|
||||
.table > :not(caption) > * > *:nth-child(3), /* Orders */
|
||||
.table > :not(caption) > * > *:nth-child(4), /* Total */
|
||||
.table > :not(caption) > * > *:nth-child(5) { /* Create Date */
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Customer Info column should remain left-aligned */
|
||||
.table > :not(caption) > * > *:first-child {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Status and Actions columns should remain as is */
|
||||
.table > :not(caption) > * > *:nth-child(6), /* Status */
|
||||
.table > :not(caption) > * > *:nth-child(7) { /* Actions */
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Updated header alignment to match */
|
||||
.table-header:nth-child(2),
|
||||
.table-header:nth-child(3),
|
||||
.table-header:nth-child(4),
|
||||
.table-header:nth-child(5) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Customer Info header stays left */
|
||||
.table-header:first-child {
|
||||
text-align: Center;
|
||||
}
|
||||
|
||||
/* Status and Actions headers stay centered */
|
||||
.table-header:nth-child(6),
|
||||
.table-header:nth-child(7) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.customer-avatar {
|
||||
@@ -165,7 +334,7 @@
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 4px 10px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 8px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
@@ -203,15 +372,9 @@
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.stats-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.customer-info-column {
|
||||
min-width: 300px;
|
||||
min-width: 220px;
|
||||
max-width: 220px; /* Added max-width to prevent overflow */
|
||||
}
|
||||
|
||||
.table tbody tr {
|
||||
@@ -228,44 +391,28 @@
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.customer-stats {
|
||||
font-size: 0.75rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
/* Remove customer-stats since we're adding columns */
|
||||
|
||||
/* Enhanced table styling */
|
||||
/* Enhanced table styling - Fixed horizontal scroll */
|
||||
.table-container {
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
width: 100%; /* Ensure container takes full width */
|
||||
}
|
||||
|
||||
.table-header-container {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 10px 10px 0 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Remove horizontal scroll */
|
||||
/* Fix table responsiveness */
|
||||
.table-responsive {
|
||||
overflow-x: visible !important;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.container-fluid {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adjust table layout to fit without scroll */
|
||||
/* Ensure table doesn't exceed container */
|
||||
.table {
|
||||
width: 100%;
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
/* Ensure proper column sizing */
|
||||
.table th,
|
||||
.table td {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
margin-bottom: 0;
|
||||
table-layout: auto; /* Changed to auto for better column distribution */
|
||||
}
|
||||
|
||||
/* Fix for search and filter section */
|
||||
@@ -275,21 +422,43 @@
|
||||
justify-content: space-between;
|
||||
flex-wrap: nowrap;
|
||||
gap: 15px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search-section {
|
||||
flex: 1;
|
||||
min-width: 300px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ---------- Pagination Styles (Same as Account Dashboard) ---------- */
|
||||
/* New columns styling */
|
||||
.orders-column, .total-column, .customer-id-column, .create-date-column {
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
min-width: 80px; /* Added minimum widths for consistency */
|
||||
}
|
||||
|
||||
.orders-count {
|
||||
font-size: 14px;
|
||||
color: #1a202c;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-size: 14px;
|
||||
color: #10b981;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ---------- Pagination Styles ---------- */
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -297,18 +466,23 @@
|
||||
margin-top: 15px;
|
||||
padding: 12px 0;
|
||||
border-top: 1px solid #eef3fb;
|
||||
font-family: 'Inter', sans-serif;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pagination-info {
|
||||
font-size: 13px;
|
||||
color: #9ba5bb;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pagination-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pagination-btn {
|
||||
@@ -354,6 +528,8 @@
|
||||
transition: all 0.3s ease;
|
||||
min-width: 36px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.pagination-page-btn:hover {
|
||||
@@ -372,6 +548,7 @@
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pagination-ellipsis {
|
||||
@@ -422,14 +599,46 @@
|
||||
filter: brightness(0) saturate(100%) invert(84%) sepia(8%) saturate(165%) hue-rotate(179deg) brightness(89%) contrast(86%);
|
||||
}
|
||||
|
||||
/* Mobile responsive fixes */
|
||||
@media (max-width: 1200px) {
|
||||
.table > :not(caption) > * > * {
|
||||
padding: 12px 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.customer-info-column {
|
||||
min-width: 180px;
|
||||
max-width: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.search-container {
|
||||
width: 280px;
|
||||
}
|
||||
|
||||
.stats-container {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.stats-container {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.search-filter-container {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.search-section {
|
||||
min-width: auto;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
@@ -446,63 +655,127 @@
|
||||
.pagination-controls {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.table > :not(caption) > * > * {
|
||||
padding: 10px 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.customer-info-column {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
}
|
||||
|
||||
.customer-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.stats-container {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.customer-info-column {
|
||||
min-width: 120px;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
.premium-badge,
|
||||
.regular-badge,
|
||||
.status-badge {
|
||||
font-size: 0.6rem;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
<!-- Header -->
|
||||
<!-- Header - Removed gradient -->
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h4 style="color: #2c3e50; font-weight: 700;">Customer List</h4>
|
||||
<h4 style="color: #2c3e50; font-weight: 700; font-family: 'Inter', sans-serif;">Customer List</h4>
|
||||
</div>
|
||||
|
||||
<!-- Stats Cards with REAL DATA -->
|
||||
<div class="stats-row">
|
||||
<div class="stats-card">
|
||||
<div class="stats-count">{{ $allCustomers->count() }}</div>
|
||||
<div class="stats-label">Total Customers</div>
|
||||
<i class="bi bi-people-fill stats-icon"></i>
|
||||
<!-- Stats Cards with NEW DESIGN -->
|
||||
<div class="stats-container">
|
||||
<!-- Total Customers -->
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ $allCustomers->count() }}</div>
|
||||
<div class="stat-label">Total Customers</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats-card" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
|
||||
<div class="stats-count">
|
||||
@php
|
||||
$newThisMonth = $allCustomers->filter(function($customer) {
|
||||
return $customer->created_at->format('Y-m') === now()->format('Y-m');
|
||||
})->count();
|
||||
@endphp
|
||||
{{ $newThisMonth }}
|
||||
<!-- New This Month -->
|
||||
<div class="stat-card warning">
|
||||
<div class="stat-icon">
|
||||
<i class="bi bi-person-plus"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">
|
||||
@php
|
||||
$newThisMonth = $allCustomers->filter(function($customer) {
|
||||
return $customer->created_at->format('Y-m') === now()->format('Y-m');
|
||||
})->count();
|
||||
@endphp
|
||||
{{ $newThisMonth }}
|
||||
</div>
|
||||
<div class="stat-label">New This Month</div>
|
||||
</div>
|
||||
<div class="stats-label">New This Month</div>
|
||||
<i class="bi bi-person-plus stats-icon"></i>
|
||||
</div>
|
||||
|
||||
<div class="stats-card" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">
|
||||
<div class="stats-count">
|
||||
@php
|
||||
$activeCustomers = $allCustomers->where('status', 'active')->count();
|
||||
@endphp
|
||||
{{ $activeCustomers }}
|
||||
<!-- Active Customers -->
|
||||
<div class="stat-card success">
|
||||
<div class="stat-icon">
|
||||
<i class="bi bi-activity"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">
|
||||
@php
|
||||
$activeCustomers = $allCustomers->where('status', 'active')->count();
|
||||
@endphp
|
||||
{{ $activeCustomers }}
|
||||
</div>
|
||||
<div class="stat-label">Active Customers</div>
|
||||
</div>
|
||||
<div class="stats-label">Active Customers</div>
|
||||
<i class="bi bi-activity stats-icon"></i>
|
||||
</div>
|
||||
|
||||
<div class="stats-card" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);">
|
||||
<div class="stats-count">
|
||||
@php
|
||||
$premiumCount = $allCustomers->where('customer_type', 'premium')->count();
|
||||
@endphp
|
||||
{{ $premiumCount }}
|
||||
<!-- Premium Customers -->
|
||||
<div class="stat-card secondary">
|
||||
<div class="stat-icon">
|
||||
<i class="bi bi-award-fill"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">
|
||||
@php
|
||||
$premiumCount = $allCustomers->where('customer_type', 'premium')->count();
|
||||
@endphp
|
||||
{{ $premiumCount }}
|
||||
</div>
|
||||
<div class="stat-label">Premium Customers</div>
|
||||
</div>
|
||||
<div class="stats-label">Premium Customers</div>
|
||||
<i class="bi bi-award-fill stats-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search and Filter Section - FIXED LAYOUT -->
|
||||
<!-- Search and Filter Section -->
|
||||
<div class="glass-card p-3 mb-3">
|
||||
<div class="search-filter-container">
|
||||
<!-- Search Section -->
|
||||
<!-- Search Section - Wider with icon on left -->
|
||||
<div class="search-section">
|
||||
<form method="GET" action="{{ route('admin.customers.index') }}" class="d-flex align-items-center">
|
||||
<div class="search-container">
|
||||
@@ -511,7 +784,7 @@
|
||||
name="search"
|
||||
value="{{ $search ?? '' }}"
|
||||
class="search-input"
|
||||
placeholder="Search Customer Name, Email, or Phone...">
|
||||
placeholder="Search customers by name, email, or phone...">
|
||||
@if(!empty($status))
|
||||
<input type="hidden" name="status" value="{{ $status }}">
|
||||
@endif
|
||||
@@ -536,9 +809,11 @@
|
||||
All
|
||||
</a>
|
||||
|
||||
@can('customer.create')
|
||||
<a href="{{ route('admin.customers.add') }}" class="add-customer-btn">
|
||||
<i class="bi bi-plus-circle me-1"></i>Add Customer
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -547,13 +822,15 @@
|
||||
<div class="table-container">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead>
|
||||
<thead class="gradient-table-header">
|
||||
<tr>
|
||||
<th class="table-header">Customer Info</th>
|
||||
<th class="table-header">Customer ID</th>
|
||||
<th class="table-header">Orders</th>
|
||||
<th class="table-header">Total</th>
|
||||
<th class="table-header">Create Date</th>
|
||||
<th class="table-header">Status</th>
|
||||
<th class="table-header" width="120">Actions</th>
|
||||
<th class="table-header" width="100">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="customersTableBody">
|
||||
@@ -576,20 +853,27 @@
|
||||
{{ $c->email }}<br>
|
||||
{{ $c->mobile_no }}
|
||||
</div>
|
||||
<div class="customer-stats mt-1">
|
||||
{{ $c->orders->count() }} orders • ₹{{ number_format($c->orders->sum('ttl_amount'), 2) }} total
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<!-- Customer ID -->
|
||||
<td>
|
||||
<td class="customer-id-column">
|
||||
<span class="fw-bold text-primary">{{ $c->customer_id }}</span>
|
||||
</td>
|
||||
|
||||
<!-- Orders Column -->
|
||||
<td class="orders-column">
|
||||
<span class="orders-count">{{ $c->orders->count() }}</span>
|
||||
</td>
|
||||
|
||||
<!-- Total Column -->
|
||||
<td class="total-column">
|
||||
<span class="total-amount">₹{{ number_format($c->orders->sum('ttl_amount'), 2) }}</span>
|
||||
</td>
|
||||
|
||||
<!-- Create Date -->
|
||||
<td>
|
||||
<td class="create-date-column">
|
||||
<span class="text-muted">{{ $c->created_at ? $c->created_at->format('d-m-Y') : '-' }}</span>
|
||||
</td>
|
||||
|
||||
@@ -604,7 +888,7 @@
|
||||
|
||||
<!-- Actions -->
|
||||
<td>
|
||||
<div class="d-flex">
|
||||
<div class="d-flex justify-content-center">
|
||||
<a href="{{ route('admin.customers.view', $c->id) }}"
|
||||
class="action-btn" title="View">
|
||||
<i class="bi bi-eye"></i>
|
||||
@@ -622,7 +906,7 @@
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="text-center py-4">
|
||||
<td colspan="7" class="text-center py-4">
|
||||
<i class="bi bi-people display-4 text-muted d-block mb-2"></i>
|
||||
<span class="text-muted">No customers found.</span>
|
||||
</td>
|
||||
|
||||
@@ -12,6 +12,7 @@ html, body {
|
||||
|
||||
body, .container-fluid {
|
||||
background: #f4f7fc;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
}
|
||||
|
||||
.container-fluid {
|
||||
@@ -34,6 +35,7 @@ body, .container-fluid {
|
||||
letter-spacing: .018em;
|
||||
color: #18213e;
|
||||
margin-bottom: 2px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.dash-title-desc {
|
||||
@@ -42,6 +44,7 @@ body, .container-fluid {
|
||||
margin-bottom: 5px;
|
||||
font-weight: 500;
|
||||
letter-spacing: .01em;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
/* ===== STATS CARDS - RESPONSIVE GRID ===== */
|
||||
@@ -127,12 +130,14 @@ body, .container-fluid {
|
||||
color:#63709b;
|
||||
font-weight:600;
|
||||
letter-spacing:.28px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.stats-value {
|
||||
font-size:1.25rem;
|
||||
font-weight:700;
|
||||
color:#194073;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.stats-card:hover .stats-icon {
|
||||
@@ -170,6 +175,7 @@ body, .container-fluid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.order-mgmt-title i {
|
||||
@@ -191,6 +197,7 @@ body, .container-fluid {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-family: inherit;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-btn:hover {
|
||||
@@ -201,7 +208,7 @@ body, .container-fluid {
|
||||
.card-body, .order-mgmt-main {
|
||||
background: #fff;
|
||||
border-radius: 0 0 17px 17px;
|
||||
padding:25px;
|
||||
padding:20px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
@@ -213,7 +220,7 @@ body, .container-fluid {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
/* ===== TABLE STYLES ===== */
|
||||
/* ===== IMPROVED TABLE STYLES ===== */
|
||||
.table thead tr {
|
||||
background: #feebbe !important;
|
||||
border-radius: 12px 12px 0 0;
|
||||
@@ -226,9 +233,10 @@ body, .container-fluid {
|
||||
font-weight: 700;
|
||||
color: #343535;
|
||||
letter-spacing: 0.02em;
|
||||
font-size:15px;
|
||||
padding-top: 12px;
|
||||
padding-bottom: 10px;
|
||||
font-size: 15px;
|
||||
padding: 16px 12px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
border-bottom: 2px solid #e9ecef;
|
||||
}
|
||||
|
||||
.table thead th:first-child { border-radius: 9px 0 0 0;}
|
||||
@@ -239,20 +247,24 @@ body, .container-fluid {
|
||||
border-radius:9px;
|
||||
box-shadow:0 2px 12px #e2ebf941;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 2px;
|
||||
border-spacing: 0 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.table-striped tbody tr {
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
|
||||
margin-bottom: 2px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.04);
|
||||
margin-bottom: 8px;
|
||||
transition: all 0.3s ease;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.table-striped tbody tr:hover {
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
||||
transform: translateY(-2px);
|
||||
background: #f8fafd;
|
||||
}
|
||||
|
||||
.table-striped tbody tr:nth-of-type(odd) {
|
||||
@@ -264,39 +276,110 @@ body, .container-fluid {
|
||||
}
|
||||
|
||||
.table td {
|
||||
padding: 12px 6px;
|
||||
padding: 14px 12px;
|
||||
border: none;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #495057;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #f1f3f4;
|
||||
}
|
||||
|
||||
.table td:first-child {
|
||||
border-radius: 6px 0 0 6px;
|
||||
border-radius: 8px 0 0 8px;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.table td:last-child {
|
||||
border-radius: 0 6px 6px 0;
|
||||
border-radius: 0 8px 8px 0;
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
border-radius:10px;
|
||||
}
|
||||
|
||||
/* ===== UPDATED STATUS BADGE STYLES ===== */
|
||||
.badge {
|
||||
font-size:13px;
|
||||
font-weight:600;
|
||||
padding:7px 17px;
|
||||
border-radius:12px;
|
||||
padding: 7px 17px !important;
|
||||
border-radius: 20px !important;
|
||||
font-weight: 600 !important;
|
||||
font-size: 13px !important;
|
||||
border: 2px solid transparent !important;
|
||||
min-width: 40px !important;
|
||||
text-align: center !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1.2 !important;
|
||||
font-family: 'Inter', sans-serif;
|
||||
gap: 6px;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.bg-info {
|
||||
background-color:#22cbfa!important;
|
||||
color:#fff!important;
|
||||
.status-icon {
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Pending Status - SAME SIZE WITH CLOCK ICON */
|
||||
.badge-pending {
|
||||
background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
|
||||
color: #d97706 !important;
|
||||
border-color: #f59e0b !important;
|
||||
}
|
||||
|
||||
/* In Transit Status - SAME SIZE WITH TRUCK ICON */
|
||||
.badge-in_transit {
|
||||
background: linear-gradient(135deg, #dbeafe, #93c5fd) !important;
|
||||
color: #1e40af !important;
|
||||
border-color: #3b82f6 !important;
|
||||
}
|
||||
|
||||
/* Dispatched Status - SAME SIZE WITH BOX ICON */
|
||||
.badge-dispatched {
|
||||
background: linear-gradient(135deg, #e9d5ff, #c4b5fd) !important;
|
||||
color: #6b21a8 !important;
|
||||
border-color: #8b5cf6 !important;
|
||||
}
|
||||
|
||||
/* Delivered Status - SAME SIZE WITH CHECK ICON */
|
||||
.badge-delivered {
|
||||
background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
|
||||
color: #065f46 !important;
|
||||
border-color: #10b981 !important;
|
||||
}
|
||||
|
||||
/* Default badge styles - SAME SIZE */
|
||||
.badge.bg-info {
|
||||
background: linear-gradient(135deg, #4cc9f0, #4361ee) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.badge.bg-success {
|
||||
background: linear-gradient(135deg, #4ade80, #22c55e) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.badge.bg-warning {
|
||||
background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.badge.bg-danger {
|
||||
background: linear-gradient(135deg, #f87171, #ef4444) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-weight:600;
|
||||
color:#1d3159;
|
||||
font-size:15px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.form-control, .form-select {
|
||||
@@ -305,6 +388,7 @@ body, .container-fluid {
|
||||
background: #f7f9fe;
|
||||
border:1.2px solid #c7dbfa;
|
||||
font-weight:500;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.form-control:focus, .form-select:focus {
|
||||
@@ -316,6 +400,7 @@ body, .container-fluid {
|
||||
color:#2469d6;
|
||||
font-weight:600;
|
||||
text-decoration:underline;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
/* ===== HORIZONTAL SCROLL CONTAINER ===== */
|
||||
@@ -327,7 +412,7 @@ body, .container-fluid {
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
|
||||
padding: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.table-wrapper::-webkit-scrollbar {
|
||||
@@ -348,7 +433,7 @@ body, .container-fluid {
|
||||
}
|
||||
|
||||
.table {
|
||||
min-width: 1200px;
|
||||
min-width: 2000px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
@@ -394,6 +479,7 @@ body, .container-fluid {
|
||||
font-size: 1.4rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .close-btn {
|
||||
@@ -425,6 +511,7 @@ body, .container-fluid {
|
||||
color: #1d3159;
|
||||
font-size: 15px;
|
||||
margin-bottom: 5px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .form-control,
|
||||
@@ -435,6 +522,7 @@ body, .container-fluid {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
padding: 8px 12px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .form-control:focus,
|
||||
@@ -449,6 +537,7 @@ body, .container-fluid {
|
||||
padding: 10px 20px;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .btn-info:hover {
|
||||
@@ -461,6 +550,7 @@ body, .container-fluid {
|
||||
padding: 12px 30px;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .btn-success:hover {
|
||||
@@ -472,6 +562,7 @@ body, .container-fluid {
|
||||
border: none;
|
||||
color: #000;
|
||||
font-weight: 600;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .btn-warning:hover {
|
||||
@@ -481,6 +572,7 @@ body, .container-fluid {
|
||||
.create-order-modal .btn-danger {
|
||||
background: #dc3545;
|
||||
border: none;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.create-order-modal .btn-danger:hover {
|
||||
@@ -505,6 +597,7 @@ body, .container-fluid {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
/* ===== ORDER DETAILS MODAL STYLES ===== */
|
||||
@@ -536,6 +629,7 @@ body, .container-fluid {
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.modal-header .btn-close {
|
||||
@@ -554,6 +648,7 @@ body, .container-fluid {
|
||||
background: #f8fafc;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
/* ===== PAGINATION STYLES ===== */
|
||||
@@ -570,6 +665,7 @@ body, .container-fluid {
|
||||
font-size: 13px;
|
||||
color: #9ba5bb;
|
||||
font-weight: 600;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.pagination-controls {
|
||||
@@ -593,6 +689,7 @@ body, .container-fluid {
|
||||
justify-content: center;
|
||||
min-width: 40px;
|
||||
height: 32px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.pagination-btn:hover:not(:disabled) {
|
||||
@@ -621,6 +718,7 @@ body, .container-fluid {
|
||||
transition: all 0.3s ease;
|
||||
min-width: 36px;
|
||||
text-align: center;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.pagination-page-btn:hover {
|
||||
@@ -645,6 +743,7 @@ body, .container-fluid {
|
||||
color: #9ba5bb;
|
||||
font-size: 13px;
|
||||
padding: 0 4px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.pagination-img-btn {
|
||||
@@ -728,7 +827,7 @@ body, .container-fluid {
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 10px 5px;
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
@@ -811,7 +910,7 @@ body, .container-fluid {
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px 4px;
|
||||
padding: 10px 6px;
|
||||
}
|
||||
|
||||
.badge {
|
||||
@@ -913,7 +1012,7 @@ body, .container-fluid {
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 6px 3px;
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
.form-control, .form-select {
|
||||
@@ -1032,9 +1131,12 @@ body, .container-fluid {
|
||||
<div class="order-mgmt-box">
|
||||
<div class="order-mgmt-bar">
|
||||
<span class="order-mgmt-title"><i class="bi bi-table"></i> Order Management</span>
|
||||
<button class="create-order-btn" id="openCreateOrderModal">
|
||||
<i class="bi bi-plus-circle"></i> Create Order
|
||||
</button>
|
||||
@can('order.create')
|
||||
<button class="create-order-btn" id="openCreateOrderModal">
|
||||
<i class="bi bi-plus-circle"></i> Create Order
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
</div>
|
||||
|
||||
<div class="order-mgmt-main">
|
||||
@@ -1047,67 +1149,80 @@ body, .container-fluid {
|
||||
</span>
|
||||
</div>
|
||||
<div class="card-body table-responsive">
|
||||
<table class="table table-striped table-bordered align-middle text-center">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Order ID</th>
|
||||
<th>Mark No</th>
|
||||
<th>Origin</th>
|
||||
<th>Destination</th>
|
||||
<th>Total CTN</th>
|
||||
<th>Total QTY</th>
|
||||
<th>Total TTL/QTY</th>
|
||||
<th>Total Amount (₹)</th>
|
||||
<th>Total CBM</th>
|
||||
<th>Total TTL CBM</th>
|
||||
<th>Total KG</th>
|
||||
<th>Total TTL KG</th>
|
||||
<th>Status</th>
|
||||
<th>Date</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ordersTableBody">
|
||||
@forelse($orders as $order)
|
||||
<tr>
|
||||
<td>{{ $order->id }}</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"
|
||||
class="fw-semibold text-primary open-order-modal"
|
||||
data-id="{{ $order->id }}">
|
||||
{{ $order->order_id }}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td>{{ $order->mark_no }}</td>
|
||||
<td>{{ $order->origin }}</td>
|
||||
<td>{{ $order->destination }}</td>
|
||||
<td>{{ $order->ctn }}</td>
|
||||
<td>{{ $order->qty }}</td>
|
||||
<td>{{ $order->ttl_qty }}</td>
|
||||
<td>₹{{ number_format($order->ttl_amount, 2) }}</td>
|
||||
<td>{{ $order->cbm }}</td>
|
||||
<td>{{ $order->ttl_cbm }}</td>
|
||||
<td>{{ $order->kg }}</td>
|
||||
<td>{{ $order->ttl_kg }}</td>
|
||||
<div class="table-wrapper">
|
||||
<table class="table table-striped table-bordered align-middle text-center">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Order ID</th>
|
||||
<th>Mark No</th>
|
||||
<th>Origin</th>
|
||||
<th>Destination</th>
|
||||
<th>Total CTN</th>
|
||||
<th>Total QTY</th>
|
||||
<th>Total TTL/QTY</th>
|
||||
<th>Total Amount (₹)</th>
|
||||
<th>Total CBM</th>
|
||||
<th>Total TTL CBM</th>
|
||||
<th>Total KG</th>
|
||||
<th>Total TTL KG</th>
|
||||
<th>Status</th>
|
||||
<th>Date</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ordersTableBody">
|
||||
@forelse($orders as $order)
|
||||
<tr>
|
||||
<td>{{ $order->id }}</td>
|
||||
<td>
|
||||
<span class="badge bg-info text-dark">{{ ucfirst($order->status) }}</span>
|
||||
</td>
|
||||
<td>{{ $order->created_at->format('d-m-Y') }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.orders.show', $order->id) }}" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-eye"></i> View
|
||||
<a href="javascript:void(0)"
|
||||
class="fw-semibold text-primary open-order-modal"
|
||||
data-id="{{ $order->id }}">
|
||||
{{ $order->order_id }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="16" class="text-muted">No orders found</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<td>{{ $order->mark_no }}</td>
|
||||
<td>{{ $order->origin }}</td>
|
||||
<td>{{ $order->destination }}</td>
|
||||
<td>{{ $order->ctn }}</td>
|
||||
<td>{{ $order->qty }}</td>
|
||||
<td>{{ $order->ttl_qty }}</td>
|
||||
<td>₹{{ number_format($order->ttl_amount, 2) }}</td>
|
||||
<td>{{ $order->cbm }}</td>
|
||||
<td>{{ $order->ttl_cbm }}</td>
|
||||
<td>{{ $order->kg }}</td>
|
||||
<td>{{ $order->ttl_kg }}</td>
|
||||
<td>
|
||||
<span class="badge badge-{{ $order->status }}">
|
||||
@if($order->status == 'pending')
|
||||
<i class="bi bi-clock-fill status-icon"></i>
|
||||
@elseif($order->status == 'in_transit')
|
||||
<i class="bi bi-truck status-icon"></i>
|
||||
@elseif($order->status == 'dispatched')
|
||||
<i class="bi bi-box-seam status-icon"></i>
|
||||
@elseif($order->status == 'delivered')
|
||||
<i class="bi bi-check-circle-fill status-icon"></i>
|
||||
@endif
|
||||
{{ ucfirst(str_replace('_', ' ', $order->status)) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ $order->created_at->format('d-m-Y') }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.orders.show', $order->id) }}" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-eye"></i> View
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="16" class="text-muted">No orders found</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination Controls -->
|
||||
<div class="pagination-container">
|
||||
@@ -1566,7 +1681,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
<td>${order.kg || ''}</td>
|
||||
<td>${order.ttl_kg || ''}</td>
|
||||
<td>
|
||||
<span class="badge bg-info text-dark">${order.status ? order.status.charAt(0).toUpperCase() + order.status.slice(1) : ''}</span>
|
||||
<span class="badge badge-${order.status}">
|
||||
${order.status === 'pending' ? '<i class="bi bi-clock-fill status-icon"></i>' : ''}
|
||||
${order.status === 'in_transit' ? '<i class="bi bi-truck status-icon"></i>' : ''}
|
||||
${order.status === 'dispatched' ? '<i class="bi bi-box-seam status-icon"></i>' : ''}
|
||||
${order.status === 'delivered' ? '<i class="bi bi-check-circle-fill status-icon"></i>' : ''}
|
||||
${order.status ? order.status.charAt(0).toUpperCase() + order.status.slice(1).replace('_', ' ') : ''}
|
||||
</span>
|
||||
</td>
|
||||
<td>${new Date(order.created_at).toLocaleDateString('en-GB')}</td>
|
||||
<td>
|
||||
@@ -1605,4 +1726,16 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("hidden.bs.modal", function () {
|
||||
// Remove Bootstrap backdrops
|
||||
document.querySelectorAll(".modal-backdrop").forEach(el => el.remove());
|
||||
|
||||
// Fix page scroll locking
|
||||
document.body.classList.remove("modal-open");
|
||||
document.body.style.overflow = "";
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@endsection
|
||||
File diff suppressed because it is too large
Load Diff
@@ -452,9 +452,11 @@ body {
|
||||
</div>
|
||||
|
||||
<div class="text-end mt-3">
|
||||
@can('invoice.edit')
|
||||
<button type="submit" class="btn-success-compact btn-compact">
|
||||
<i class="fas fa-save me-2"></i>Update Invoice
|
||||
</button>
|
||||
@endcan
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -541,11 +543,13 @@ body {
|
||||
<h4>
|
||||
<i class="fas fa-credit-card me-2"></i>Installment Payments
|
||||
</h4>
|
||||
@if($remaining > 0)
|
||||
<button id="toggleInstallmentForm" class="btn-primary-compact btn-compact">
|
||||
<i class="fas fa-plus-circle me-2"></i>Add Installment
|
||||
</button>
|
||||
@endif
|
||||
@can('invoice.add_installment')
|
||||
@if($remaining > 0)
|
||||
<button id="toggleInstallmentForm" class="btn-primary-compact btn-compact">
|
||||
<i class="fas fa-plus-circle me-2"></i>Add Installment
|
||||
</button>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="card-body-compact">
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
font-family: 'Inter', Arial, sans-serif;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
/* ✨ Sidebar Glass + Animated Highlight Effect */
|
||||
@@ -36,7 +37,13 @@
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
/* Sidebar collapsed state */
|
||||
.sidebar.collapsed {
|
||||
transform: translateX(-100%);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.sidebar .logo {
|
||||
@@ -73,7 +80,6 @@
|
||||
overflow: hidden;
|
||||
transition: all 0.25s ease;
|
||||
z-index: 0;
|
||||
|
||||
}
|
||||
|
||||
/* Background Animation */
|
||||
@@ -151,6 +157,39 @@
|
||||
flex-direction: column;
|
||||
width: calc(100vw - 190px);
|
||||
margin-left: 190px;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
/* Main content when sidebar is collapsed */
|
||||
.main-content.expanded {
|
||||
margin-left: 0;
|
||||
width: 100vw;
|
||||
}
|
||||
|
||||
/* Header hamburger button */
|
||||
.header-toggle {
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
margin-right: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: transform 0.3s ease;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.header-toggle:hover {
|
||||
transform: scale(1.1);
|
||||
background: rgba(43, 92, 182, 0.1);
|
||||
}
|
||||
|
||||
.header-toggle i {
|
||||
font-size: 1.6rem;
|
||||
color: #2b5cb6;
|
||||
}
|
||||
|
||||
header {
|
||||
@@ -165,6 +204,11 @@
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
padding: 18px 16px 16px 16px;
|
||||
flex-grow: 1;
|
||||
@@ -184,47 +228,96 @@
|
||||
<div class="word"><strong>KENT</strong><br /><small>International Pvt. Ltd.</small></div>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.dashboard') }}" class="{{ request()->routeIs('admin.dashboard') ? 'active' : '' }}"><i class="bi bi-house"></i> Dashboard</a>
|
||||
<a href="{{ route('admin.shipments') }}" class="{{ request()->routeIs('admin.shipments') ? 'active' : '' }}"><i class="bi bi-truck"></i> Shipments</a>
|
||||
<a href="{{ route('admin.invoices.index') }}"
|
||||
class="{{ request()->routeIs('admin.invoices.index') ? 'active' : '' }}">
|
||||
{{-- Dashboard (requires order.view) --}}
|
||||
@can('order.view')
|
||||
<a href="{{ route('admin.dashboard') }}" class="{{ request()->routeIs('admin.dashboard') ? 'active' : '' }}">
|
||||
<i class="bi bi-house"></i> Dashboard
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Shipments --}}
|
||||
@can('shipment.view')
|
||||
<a href="{{ route('admin.shipments') }}" class="{{ request()->routeIs('admin.shipments') ? 'active' : '' }}">
|
||||
<i class="bi bi-truck"></i> Shipments
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Invoice --}}
|
||||
@can('invoice.view')
|
||||
<a href="{{ route('admin.invoices.index') }}" class="{{ request()->routeIs('admin.invoices.index') ? 'active' : '' }}">
|
||||
<i class="bi bi-receipt"></i> Invoice
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
<a href="{{ route('admin.customers.index') }}"
|
||||
class="{{ request()->routeIs('admin.customers.index') ? 'active' : '' }}">
|
||||
{{-- Customers --}}
|
||||
@can('customer.view')
|
||||
<a href="{{ route('admin.customers.index') }}" class="{{ request()->routeIs('admin.customers.index') ? 'active' : '' }}">
|
||||
<i class="bi bi-people"></i> Customers
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
<a href="{{ route('admin.reports') }}"
|
||||
class="{{ request()->routeIs('admin.reports') ? 'active' : '' }}">
|
||||
{{-- Reports --}}
|
||||
@can('report.view')
|
||||
<a href="{{ route('admin.reports') }}" class="{{ request()->routeIs('admin.reports') ? 'active' : '' }}">
|
||||
<i class="bi bi-graph-up"></i> Reports
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Chat Support (NO PERMISSION REQUIRED) --}}
|
||||
<a href="{{ route('admin.chat_support') }}" class="{{ request()->routeIs('admin.chat_support') ? 'active' : '' }}">
|
||||
<i class="bi bi-chat-dots"></i> Chat Support
|
||||
</a>
|
||||
|
||||
<a href="{{ route('admin.chat_support') }}" class="{{ request()->routeIs('admin.chat_support') ? 'active' : '' }}"><i class="bi bi-chat-dots"></i> Chat Support</a>
|
||||
<!-- <a href="{{ route('admin.orders.index') }}"
|
||||
class="{{ request()->routeIs('admin.orders.*') ? 'active' : '' }}">
|
||||
<i class="bi bi-bag"></i> Orders
|
||||
</a> -->
|
||||
<a href="{{ route('admin.orders') }}"
|
||||
class="{{ request()->routeIs('admin.orders') ? 'active' : '' }}">
|
||||
<i class="bi bi-bag"></i> Orders
|
||||
</a>
|
||||
<a href="{{ route('admin.requests') }}" class="{{ request()->routeIs('admin.requests') ? 'active' : '' }}"><i class="bi bi-envelope"></i> Requests</a>
|
||||
<a href="{{ route('admin.staff') }}" class="{{ request()->routeIs('admin.staff') ? 'active' : '' }}"><i class="bi bi-person-badge"></i> Staff</a>
|
||||
<a href="{{ route('admin.account') }}" class="{{ request()->routeIs('admin.account') ? 'active' : '' }}"><i class="bi bi-gear"></i> Account</a>
|
||||
<a href="{{ route('admin.marklist.index') }}" class="{{ request()->routeIs('admin.marklist.index') ? 'active' : '' }}"><i class="bi bi-list-check"></i> Mark List</a>
|
||||
{{-- Orders --}}
|
||||
@can('orders.view')
|
||||
<a href="{{ route('admin.orders') }}" class="{{ request()->routeIs('admin.orders') ? 'active' : '' }}">
|
||||
<i class="bi bi-bag"></i> Orders
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Requests --}}
|
||||
@can('request.view')
|
||||
<a href="{{ route('admin.requests') }}" class="{{ request()->routeIs('admin.requests') ? 'active' : '' }}">
|
||||
<i class="bi bi-envelope"></i> Requests
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Profile Update Requests --}}
|
||||
@can('request.update_profile')
|
||||
<a href="{{ route('admin.profile.requests') }}">
|
||||
<i class="bi bi-person-lines-fill"></i> Profile Update Requests
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Staff (NO PERMISSION REQUIRED) --}}
|
||||
<a href="{{ route('admin.staff.index') }}" class="{{ request()->routeIs('admin.staff.*') ? 'active' : '' }}">
|
||||
<i class="bi bi-person-badge"></i> Staff
|
||||
</a>
|
||||
|
||||
{{-- Account Section --}}
|
||||
@can('account.view')
|
||||
<a href="{{ route('admin.account') }}" class="{{ request()->routeIs('admin.account') ? 'active' : '' }}">
|
||||
<i class="bi bi-gear"></i> Account
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
{{-- Mark List --}}
|
||||
@can('mark_list.view')
|
||||
<a href="{{ route('admin.marklist.index') }}" class="{{ request()->routeIs('admin.marklist.index') ? 'active' : '' }}">
|
||||
<i class="bi bi-list-check"></i> Mark List
|
||||
</a>
|
||||
@endcan
|
||||
|
||||
<form method="POST" action="{{ route('admin.logout') }}" class="mt-4 px-3">
|
||||
@csrf
|
||||
<!-- <button type="submit" class="btn btn-danger w-100"><i class="bi bi-box-arrow-right"></i> Logout</button>-->
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
<header>
|
||||
<h5>@yield('page-title')</h5>
|
||||
<div class="header-left">
|
||||
<button class="header-toggle" id="headerToggle">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
<h5 class="mb-0">@yield('page-title')</h5>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<i class="bi bi-bell position-relative fs-4">
|
||||
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">2</span>
|
||||
@@ -253,5 +346,23 @@
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const headerToggle = document.getElementById('headerToggle');
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
const mainContent = document.querySelector('.main-content');
|
||||
|
||||
// Function to toggle sidebar
|
||||
function toggleSidebar() {
|
||||
sidebar.classList.toggle('collapsed');
|
||||
mainContent.classList.toggle('expanded');
|
||||
}
|
||||
|
||||
// Header toggle button click event
|
||||
if (headerToggle) {
|
||||
headerToggle.addEventListener('click', toggleSidebar);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -120,19 +120,33 @@
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.login.submit') }}">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label>Email</label>
|
||||
<input type="email" name="email" class="form-control" value="{{ old('email') }}" required>
|
||||
</div>
|
||||
@csrf
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Password</label>
|
||||
<input type="password" name="password" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label>Username / Email / Employee ID</label>
|
||||
<input
|
||||
type="text"
|
||||
name="login"
|
||||
class="form-control"
|
||||
value="{{ old('login') }}"
|
||||
placeholder="Enter Email or Username or EMP ID"
|
||||
required
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Password</label>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="form-control"
|
||||
required
|
||||
>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100">Login</button>
|
||||
</form>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100">Login</button>
|
||||
</form>
|
||||
|
||||
<div class="secure-encrypted">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="green" class="bi bi-lock-fill" viewBox="0 0 16 16">
|
||||
|
||||
@@ -748,10 +748,13 @@
|
||||
|
||||
<script>
|
||||
// Pagination state
|
||||
let currentPage = 1;
|
||||
const itemsPerPage = 10;
|
||||
let allOrders = @json($orders);
|
||||
let filteredOrders = [...allOrders];
|
||||
let currentPage = 1;
|
||||
const itemsPerPage = 10;
|
||||
let allOrders = @json($orders);
|
||||
let filteredOrders = [...allOrders];
|
||||
console.log('ORDERS SAMPLE:', allOrders[0]);
|
||||
|
||||
|
||||
|
||||
// Status icon helper functions
|
||||
function getInvoiceStatusIcon(status) {
|
||||
@@ -932,9 +935,10 @@
|
||||
|
||||
filteredOrders = allOrders.filter(order => {
|
||||
const matchesSearch = !searchTerm ||
|
||||
(order.order_id && order.order_id.toLowerCase().includes(searchTerm)) ||
|
||||
(order.markList?.company_name && order.markList.company_name.toLowerCase().includes(searchTerm)) ||
|
||||
(order.invoice?.invoice_number && order.invoice.invoice_number.toLowerCase().includes(searchTerm));
|
||||
order.order_id?.toLowerCase().includes(searchTerm) ||
|
||||
order.mark_list?.company_name?.toLowerCase().includes(searchTerm) ||
|
||||
order.invoice?.invoice_number?.toLowerCase().includes(searchTerm);
|
||||
|
||||
|
||||
const matchesStatus = !statusFilter ||
|
||||
(order.invoice?.status && order.invoice.status.toLowerCase() === statusFilter);
|
||||
@@ -1049,7 +1053,7 @@
|
||||
const paginatedItems = filteredOrders.slice(startIndex, endIndex);
|
||||
|
||||
paginatedItems.forEach(order => {
|
||||
const mark = order.markList || null;
|
||||
const mark = order.mark_list || null;
|
||||
const invoice = order.invoice || null;
|
||||
const shipment = order.shipments?.[0] || null;
|
||||
const invoiceStatus = (invoice?.status || '').toLowerCase();
|
||||
|
||||
70
resources/views/admin/orders/pdf.blade.php
Normal file
70
resources/views/admin/orders/pdf.blade.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Orders Report</title>
|
||||
<style>
|
||||
body { font-family: DejaVu Sans, sans-serif; font-size:12px; }
|
||||
table { width:100%; border-collapse: collapse; }
|
||||
th, td { border: 1px solid #ddd; padding: 6px; text-align: left; }
|
||||
th { background: #f2f2f2; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Orders Report</h3>
|
||||
|
||||
@if(!empty($filters))
|
||||
<p>
|
||||
@if($filters['search']) Search: <strong>{{ $filters['search'] }}</strong> @endif
|
||||
@if($filters['status']) | Status: <strong>{{ ucfirst($filters['status']) }}</strong> @endif
|
||||
@if($filters['shipment']) | Shipment: <strong>{{ ucfirst($filters['shipment']) }}</strong> @endif
|
||||
</p>
|
||||
@endif
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Shipment ID</th>
|
||||
<th>Customer ID</th>
|
||||
<th>Company</th>
|
||||
<th>Origin</th>
|
||||
<th>Destination</th>
|
||||
<th>Order Date</th>
|
||||
<th>Invoice No</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Amount</th>
|
||||
<th>Amount + GST</th>
|
||||
<th>Invoice Status</th>
|
||||
<th>Shipment Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($orders as $order)
|
||||
@php
|
||||
$mark = $order->markList ?? null;
|
||||
$invoice = $order->invoice ?? null;
|
||||
$shipment = $order->shipments->first() ?? null;
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $order->order_id }}</td>
|
||||
<td>{{ $shipment->shipment_id ?? '-' }}</td>
|
||||
<td>{{ $mark->customer_id ?? '-' }}</td>
|
||||
<td>{{ $mark->company_name ?? '-' }}</td>
|
||||
<td>{{ $mark->origin ?? $order->origin ?? '-' }}</td>
|
||||
<td>{{ $mark->destination ?? $order->destination ?? '-' }}</td>
|
||||
<td>{{ $order->created_at ? $order->created_at->format('d-m-Y') : '-' }}</td>
|
||||
<td>{{ $invoice->invoice_number ?? '-' }}</td>
|
||||
<td>{{ $invoice?->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('d-m-Y') : '-' }}</td>
|
||||
<td>{{ $invoice?->final_amount ? number_format($invoice->final_amount, 2) : '-' }}</td>
|
||||
<td>{{ $invoice?->final_amount_with_gst ? number_format($invoice->final_amount_with_gst, 2) : '-' }}</td>
|
||||
<td>{{ $invoice->status ? ucfirst($invoice->status) : 'Pending' }}</td>
|
||||
<td>{{ $shipment?->status ? ucfirst(str_replace('_',' ',$shipment->status)) : 'Pending' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="13" style="text-align:center">No orders found</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,20 +5,92 @@
|
||||
@section('content')
|
||||
<div class="container py-4">
|
||||
|
||||
{{-- Header --}}
|
||||
{{-- HEADER --}}
|
||||
<div class="card shadow-sm rounded-3 border-0">
|
||||
<div class="card-body">
|
||||
|
||||
{{-- TOP BAR --}}
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h4 class="fw-bold mb-0">Order Details</Details></h4>
|
||||
<h4 class="fw-bold mb-0">Order Details</h4>
|
||||
<small class="text-muted">Detailed view of this shipment order</small>
|
||||
</div>
|
||||
|
||||
{{-- ADD ITEM --}}
|
||||
@can('order.create')
|
||||
<button class="btn btn-add-item" data-bs-toggle="modal" data-bs-target="#addItemModal">
|
||||
<i class="fas fa-plus-circle me-2"></i>Add New Item
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
<a href="{{ route('admin.dashboard') }}" class="btn-close"></a>
|
||||
</div>
|
||||
|
||||
<!-- {{-- ACTION BUTTONS --}}
|
||||
<div class="mt-3 d-flex gap-2">
|
||||
|
||||
|
||||
|
||||
{{-- EDIT ORDER --}} -->
|
||||
<!-- @if($order->status === 'pending')
|
||||
<button class="btn btn-edit-order" onclick="document.getElementById('editOrderForm').style.display='block'">
|
||||
<i class="fas fa-edit me-2"></i>Edit Order
|
||||
</button>
|
||||
@else
|
||||
<button class="btn btn-edit-order" disabled><i class="fas fa-edit me-2"></i>Edit Order</button>
|
||||
@endif -->
|
||||
|
||||
<!-- {{-- DELETE ORDER --}}
|
||||
@if($order->status === 'pending')
|
||||
<form action="{{ route('admin.orders.destroy', $order->id) }}"
|
||||
method="POST"
|
||||
onsubmit="return confirm('Delete this entire order?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-delete-order">
|
||||
<i class="fas fa-trash-alt me-2"></i>Delete Order
|
||||
</button>
|
||||
</form>
|
||||
@endif -->
|
||||
|
||||
<!-- </div> -->
|
||||
|
||||
<hr>
|
||||
|
||||
{{-- Customer Info --}}
|
||||
{{-- EDIT ORDER FORM --}}
|
||||
<div id="editOrderForm" class="p-3 bg-light rounded mb-4 shadow-sm" style="display:none;">
|
||||
<h5 class="fw-bold mb-3">Edit Order</h5>
|
||||
|
||||
<form action="{{ route('admin.orders.updateItem', $order->id) }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label>Mark No</label>
|
||||
<input type="text" name="mark_no" value="{{ $order->mark_no }}" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<label>Origin</label>
|
||||
<input type="text" name="origin" value="{{ $order->origin }}" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<label>Destination</label>
|
||||
<input type="text" name="destination" value="{{ $order->destination }}" class="form-control custom-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-save-changes">Save Changes</button>
|
||||
<button type="button"
|
||||
class="btn btn-cancel"
|
||||
onclick="document.getElementById('editOrderForm').style.display='none'">
|
||||
Cancel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{-- CUSTOMER INFO --}}
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8 d-flex">
|
||||
<div class="me-3">
|
||||
@@ -27,6 +99,7 @@
|
||||
{{ strtoupper(substr($user->customer_name ?? 'U', 0, 1)) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h5 class="mb-0">{{ $user->customer_name ?? 'Unknown Customer' }}</h5>
|
||||
<p class="mb-0">{{ $user->company_name ?? 'N/A' }}</p>
|
||||
@@ -34,13 +107,14 @@
|
||||
<p class="mb-0 text-muted">{{ $user->mobile_no ?? '' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 text-end">
|
||||
<p class="mb-0">{{ $user->address ?? '' }}</p>
|
||||
<small class="text-muted">{{ $user->pincode ?? '' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Order Summary --}}
|
||||
{{-- ORDER SUMMARY --}}
|
||||
<div class="bg-light rounded p-3 mb-3">
|
||||
<div class="row text-center">
|
||||
<div class="col-md-3 border-end">
|
||||
@@ -65,7 +139,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Origin - Destination --}}
|
||||
{{-- ORIGIN / DESTINATION --}}
|
||||
<div class="row text-center mb-4">
|
||||
<div class="col-md-6">
|
||||
<p class="mb-1 fw-semibold text-muted">Origin</p>
|
||||
@@ -77,7 +151,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Order Items Table --}}
|
||||
{{-- ITEMS TABLE --}}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered align-middle text-center">
|
||||
<thead class="table-light">
|
||||
@@ -88,15 +162,17 @@
|
||||
<th>QTY</th>
|
||||
<th>TTL/QTY</th>
|
||||
<th>Unit</th>
|
||||
<th>Price (₹)</th>
|
||||
<th>TTL Amount (₹)</th>
|
||||
<th>Price</th>
|
||||
<th>Total Amount</th>
|
||||
<th>CBM</th>
|
||||
<th>TTL CBM</th>
|
||||
<th>KG</th>
|
||||
<th>TTL KG</th>
|
||||
<th>Shop No</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach($order->items as $index => $item)
|
||||
<tr>
|
||||
@@ -113,38 +189,733 @@
|
||||
<td>{{ $item->kg }}</td>
|
||||
<td>{{ $item->ttl_kg }}</td>
|
||||
<td>{{ $item->shop_no }}</td>
|
||||
|
||||
<td class="d-flex justify-content-center gap-2">
|
||||
|
||||
{{-- EDIT BUTTON --}}
|
||||
@can('order.edit')
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-edit-item"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#editItemModal{{ $item->id }}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
@can('order.delete')
|
||||
{{-- DELETE BUTTON --}}
|
||||
<form action="{{ route('admin.orders.deleteItem', $item->id) }}"
|
||||
method="POST"
|
||||
onsubmit="return confirm('Delete this item?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-sm btn-delete-item">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
@endcan
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{{-- Totals --}}
|
||||
|
||||
@foreach($order->items as $item)
|
||||
<div class="modal fade" id="editItemModal{{ $item->id }}" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content custom-modal">
|
||||
|
||||
<div class="modal-header modal-gradient-header">
|
||||
<h5 class="modal-title text-white">
|
||||
<i class="fas fa-edit me-2"></i>Edit Item
|
||||
</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<form action="{{ route('admin.orders.updateItem', $item->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Description</label>
|
||||
<input type="text" name="description"
|
||||
value="{{ $item->description }}"
|
||||
class="form-control custom-input" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">CTN</label>
|
||||
<input type="number" name="ctn"
|
||||
value="{{ $item->ctn }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">QTY</label>
|
||||
<input type="number" name="qty"
|
||||
value="{{ $item->qty }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TTL QTY</label>
|
||||
<input type="number" name="ttl_qty"
|
||||
value="{{ $item->ttl_qty }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Unit</label>
|
||||
<input type="text" name="unit"
|
||||
value="{{ $item->unit }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Price</label>
|
||||
<input type="number" name="price"
|
||||
value="{{ $item->price }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Total Amount</label>
|
||||
<input type="number" name="ttl_amount"
|
||||
value="{{ $item->ttl_amount }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">CBM</label>
|
||||
<input type="number" name="cbm"
|
||||
value="{{ $item->cbm }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TTL CBM</label>
|
||||
<input type="number" name="ttl_cbm"
|
||||
value="{{ $item->ttl_cbm }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">KG</label>
|
||||
<input type="number" name="kg"
|
||||
value="{{ $item->kg }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TTL KG</label>
|
||||
<input type="number" name="ttl_kg"
|
||||
value="{{ $item->ttl_kg }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Shop No</label>
|
||||
<input type="text" name="shop_no"
|
||||
value="{{ $item->shop_no }}"
|
||||
class="form-control custom-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-modal-close" data-bs-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-modal-add">Edit Item</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
|
||||
{{-- TOTALS --}}
|
||||
<div class="row text-center mt-4">
|
||||
<div class="col-md-3">
|
||||
<h6 class="fw-bold text-primary">{{ $order->ctn }}</h6>
|
||||
<small class="text-muted">Total CTN</small>
|
||||
<small>Total CTN</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<h6 class="fw-bold text-primary">{{ $order->qty }}</h6>
|
||||
<small class="text-muted">Total QTY</small>
|
||||
<small>Total QTY</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<h6 class="fw-bold text-success">{{ $order->ttl_kg }}</h6>
|
||||
<small class="text-muted">Total TTL KG</small>
|
||||
<small>Total KG</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<h6 class="fw-bold text-danger">₹{{ number_format($order->ttl_amount, 2) }}</h6>
|
||||
<small class="text-muted">Total Amount</small>
|
||||
<small>Total Amount</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
{{-- ADD ITEM MODAL --}}
|
||||
<div class="modal fade" id="addItemModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content custom-modal">
|
||||
|
||||
<div class="modal-header modal-gradient-header">
|
||||
<h5 class="modal-title text-white"><i class="fas fa-cube me-2"></i>Add Item To Order</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
|
||||
<form id="addItemForm" action="{{ route('admin.orders.addItem', $order->id) }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
{{-- DELETED ITEMS --}}
|
||||
@php
|
||||
$deletedItems = \App\Models\OrderItem::onlyTrashed()
|
||||
->where('order_id', $order->id)
|
||||
->get();
|
||||
@endphp
|
||||
|
||||
<h5 class="section-title">Deleted Items (Use / Restore)</h5>
|
||||
|
||||
<div class="table-responsive mb-4">
|
||||
<table class="table table-bordered align-middle text-center">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Description</th>
|
||||
<th>CTN</th>
|
||||
<th>QTY</th>
|
||||
<th>TTL QTY</th>
|
||||
<th>Unit</th>
|
||||
<th>Price</th>
|
||||
<th>TTL Amount</th>
|
||||
<th>CBM</th>
|
||||
<th>TTL CBM</th>
|
||||
<th>KG</th>
|
||||
<th>TTL KG</th>
|
||||
<th>Shop No</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@forelse($deletedItems as $key => $deleted)
|
||||
<tr>
|
||||
<td>{{ $key + 1 }}</td>
|
||||
<td>{{ $deleted->description }}</td>
|
||||
<td>{{ $deleted->ctn }}</td>
|
||||
<td>{{ $deleted->qty }}</td>
|
||||
<td>{{ $deleted->ttl_qty }}</td>
|
||||
<td>{{ $deleted->unit }}</td>
|
||||
<td>{{ number_format($deleted->price, 2) }}</td>
|
||||
<td>{{ number_format($deleted->ttl_amount, 2) }}</td>
|
||||
<td>{{ $deleted->cbm }}</td>
|
||||
<td>{{ $deleted->ttl_cbm }}</td>
|
||||
<td>{{ $deleted->kg }}</td>
|
||||
<td>{{ $deleted->ttl_kg }}</td>
|
||||
<td>{{ $deleted->shop_no }}</td>
|
||||
|
||||
<td class="d-flex justify-content-center gap-2">
|
||||
|
||||
{{-- USE THIS ITEM --}}
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-use-item"
|
||||
onclick="fillFormFromDeleted({{ json_encode($deleted) }})">
|
||||
Use
|
||||
</button>
|
||||
|
||||
{{-- RESTORE ITEM --}}
|
||||
<form action="{{ route('admin.orders.restoreItem', $deleted->id) }}" method="POST">
|
||||
@csrf
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-restore js-restore-item"
|
||||
data-id="{{ $deleted->id }}"
|
||||
data-url="{{ route('admin.orders.restoreItem', $deleted->id) }}">
|
||||
Restore
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="14" class="text-muted">No deleted items.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- ADD FORM --}}
|
||||
<div class="row g-3">
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Description</label>
|
||||
<input type="text" name="description" class="form-control custom-input" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">CTN</label>
|
||||
<input type="number" name="ctn" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">QTY</label>
|
||||
<input type="number" name="qty" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TTL QTY</label>
|
||||
<input type="number" name="ttl_qty" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Unit</label>
|
||||
<input type="text" name="unit" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Price</label>
|
||||
<input type="number" name="price" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Total Amount</label>
|
||||
<input type="number" name="ttl_amount" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">CBM</label>
|
||||
<input type="number" name="cbm" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TTL CBM</label>
|
||||
<input type="number" name="ttl_cbm" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">KG</label>
|
||||
<input type="number" name="kg" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">TTL KG</label>
|
||||
<input type="number" name="ttl_kg" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Shop No</label>
|
||||
<input type="text" name="shop_no" class="form-control custom-input">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-modal-close" data-bs-dismiss="modal">Close</button>
|
||||
<button class="btn btn-modal-add">Add Item</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const token = '{{ csrf_token() }}';
|
||||
|
||||
document.querySelectorAll('.js-restore-item').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
if (!confirm('Restore this item?')) return;
|
||||
|
||||
const url = this.dataset.url;
|
||||
const row = this.closest('tr');
|
||||
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': token,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({})
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error('Restore failed');
|
||||
return response.json().catch(() => ({}));
|
||||
})
|
||||
.then(() => {
|
||||
row.remove();
|
||||
location.reload(); // 🔥 refresh UI so restored item appears
|
||||
})
|
||||
.catch(() => {
|
||||
alert('Could not restore item. Please try again.');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{{-- AUTO-FILL SCRIPT --}}
|
||||
<script>
|
||||
function fillFormFromDeleted(item) {
|
||||
let form = document.getElementById('addItemForm');
|
||||
|
||||
form.querySelector('input[name="description"]').value = item.description;
|
||||
form.querySelector('input[name="ctn"]').value = item.ctn;
|
||||
form.querySelector('input[name="qty"]').value = item.qty;
|
||||
form.querySelector('input[name="ttl_qty"]').value = item.ttl_qty;
|
||||
form.querySelector('input[name="unit"]').value = item.unit;
|
||||
form.querySelector('input[name="price"]').value = item.price;
|
||||
form.querySelector('input[name="ttl_amount"]').value = item.ttl_amount;
|
||||
form.querySelector('input[name="cbm"]').value = item.cbm;
|
||||
form.querySelector('input[name="ttl_cbm"]').value = item.ttl_cbm;
|
||||
form.querySelector('input[name="kg"]').value = item.kg;
|
||||
form.querySelector('input[name="ttl_kg"]').value = item.ttl_kg;
|
||||
form.querySelector('input[name="shop_no"]').value = item.shop_no;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* Custom Button Styles */
|
||||
.btn-add-item {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 6px 14px;
|
||||
border-radius: 10px;
|
||||
font-weight: 600;
|
||||
font-size: 0.85rem;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 15px 0 rgba(102, 126, 234, 0.3);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
margin-right: -800px;
|
||||
}
|
||||
|
||||
.btn-add-item:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px 0 rgba(102, 126, 234, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-add-item::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
|
||||
transition: 0.5s;
|
||||
}
|
||||
|
||||
.btn-add-item:hover::before {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
.btn-edit-order {
|
||||
background: linear-gradient(135deg, #4776E6 0%, #8E54E9 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 10px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 15px 0 rgba(71, 118, 230, 0.3);
|
||||
}
|
||||
|
||||
.btn-edit-order:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px 0 rgba(71, 118, 230, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-edit-order:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-delete-order {
|
||||
background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 10px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 15px 0 rgba(255, 65, 108, 0.3);
|
||||
}
|
||||
|
||||
.btn-delete-order:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px 0 rgba(255, 65, 108, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-delete-item {
|
||||
background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 6px;
|
||||
padding: 6px 12px;
|
||||
transition: all 0.3s ease;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-delete-item:hover {
|
||||
transform: scale(1.05);
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Form Buttons */
|
||||
.btn-save-changes {
|
||||
background: linear-gradient(135deg, #00b09b 0%, #96c93d 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 12px rgba(0, 176, 155, 0.2);
|
||||
}
|
||||
|
||||
.btn-save-changes:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 6px 20px rgba(0, 176, 155, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: linear-gradient(135deg, #8e9eab 0%, #eef2f3 100%);
|
||||
border: none;
|
||||
color: #2c3e50;
|
||||
padding: 10px 20px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-cancel:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(142, 158, 171, 0.3);
|
||||
}
|
||||
|
||||
/* Modal Styles */
|
||||
.custom-modal {
|
||||
border-radius: 15px;
|
||||
border: none;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-gradient-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-bottom: none;
|
||||
padding: 20px 25px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
color: #2c3e50;
|
||||
font-weight: 600;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid #667eea;
|
||||
}
|
||||
|
||||
.custom-input {
|
||||
border: 2px solid #e9ecef;
|
||||
border-radius: 8px;
|
||||
padding: 10px 15px;
|
||||
transition: all 0.3s ease;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.custom-input:focus {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-use-item {
|
||||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 6px;
|
||||
padding: 5px 15px;
|
||||
font-size: 0.875rem;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn-use-item:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-restore {
|
||||
background: linear-gradient(135deg, #00b09b 0%, #96c93d 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 6px;
|
||||
padding: 5px 15px;
|
||||
font-size: 0.875rem;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn-restore:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(0, 176, 155, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-modal-close {
|
||||
background: linear-gradient(135deg, #8e9eab 0%, #eef2f3 100%);
|
||||
border: none;
|
||||
color: #2c3e50;
|
||||
padding: 10px 25px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-modal-close:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(142, 158, 171, 0.3);
|
||||
}
|
||||
|
||||
.btn-modal-add {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 10px 25px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 15px 0 rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.btn-modal-add:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px 0 rgba(102, 126, 234, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Animation for the Add Item Button */
|
||||
@keyframes pulse-glow {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-add-item {
|
||||
animation: pulse-glow 2s infinite;
|
||||
}
|
||||
|
||||
/* List group items */
|
||||
.list-group-item {
|
||||
border: 1px solid #e9ecef;
|
||||
margin-bottom: 8px;
|
||||
border-radius: 8px !important;
|
||||
transition: all 0.3s ease;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.list-group-item:hover {
|
||||
border-color: #667eea;
|
||||
transform: translateX(5px);
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
|
||||
/* Enhanced table styling */
|
||||
.table {
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table thead th {
|
||||
background: #667eea ;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 15px 10px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.table tbody tr {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.table tbody tr:hover {
|
||||
background-color: rgba(102, 126, 234, 0.05);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
/* Badge styling */
|
||||
.badge {
|
||||
font-size: 0.85em;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* Card enhancements */
|
||||
.card {
|
||||
border: none;
|
||||
box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.btn-add-item,
|
||||
.btn-edit-order,
|
||||
.btn-delete-order {
|
||||
padding: 10px 15px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.modal-gradient-header {
|
||||
padding: 15px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@endsection
|
||||
111
resources/views/admin/profile_update_requests.blade.php
Normal file
111
resources/views/admin/profile_update_requests.blade.php
Normal file
@@ -0,0 +1,111 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('page-title', 'Profile Update Requests')
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid px-0">
|
||||
|
||||
@php
|
||||
$perPage = 5;
|
||||
$currentPage = request()->get('page', 1);
|
||||
$currentPage = max(1, (int)$currentPage);
|
||||
$total = $requests->count();
|
||||
$totalPages = ceil($total / $perPage);
|
||||
$currentItems = $requests->slice(($currentPage - 1) * $perPage, $perPage);
|
||||
@endphp
|
||||
|
||||
<style>
|
||||
.old-value { color: #6b7280; font-weight: 600; }
|
||||
.new-value { color: #111827; font-weight: 700; }
|
||||
.changed { background: #fef3c7; padding: 6px; border-radius: 6px; }
|
||||
.box { padding: 10px 14px; border-radius: 8px; background: #f8fafc; margin-bottom: 10px; }
|
||||
.diff-label { font-size: 13px; font-weight: 700; }
|
||||
.actions { display: flex; gap: 10px; }
|
||||
</style>
|
||||
|
||||
<h4 class="fw-bold my-3">Profile Update Requests ({{ $total }})</h4>
|
||||
|
||||
<div class="card mb-4 shadow-sm">
|
||||
<div class="card-body pb-1">
|
||||
|
||||
<div class="table-responsive custom-table-wrapper">
|
||||
<table class="table align-middle mb-0 custom-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>User</th>
|
||||
<th>Requested Changes</th>
|
||||
<th>Status</th>
|
||||
<th>Requested At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach($currentItems as $index => $req)
|
||||
@php
|
||||
$user = $req->user;
|
||||
// FIX: Convert string to array
|
||||
$newData = is_array($req->data) ? $req->data : json_decode($req->data, true);
|
||||
@endphp
|
||||
|
||||
<tr>
|
||||
<td><strong>{{ ($currentPage - 1) * $perPage + $index + 1 }}</strong></td>
|
||||
|
||||
<td>
|
||||
<strong>{{ $user->customer_name }}</strong><br>
|
||||
<small>{{ $user->email }}</small><br>
|
||||
<small>ID: {{ $user->customer_id }}</small>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@foreach($newData as $key => $newValue)
|
||||
@php
|
||||
$oldValue = $user->$key ?? '—';
|
||||
$changed = $oldValue != $newValue;
|
||||
@endphp
|
||||
|
||||
<div class="box {{ $changed ? 'changed' : '' }}">
|
||||
<span class="diff-label">{{ ucfirst(str_replace('_',' ', $key)) }}:</span><br>
|
||||
<span class="old-value">Old: {{ $oldValue }}</span><br>
|
||||
<span class="new-value">New: {{ $newValue ?? '—' }}</span>
|
||||
</div>
|
||||
@endforeach
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if($req->status == 'pending')
|
||||
<span class="badge badge-pending">Pending</span>
|
||||
@elseif($req->status == 'approved')
|
||||
<span class="badge badge-approved">Approved</span>
|
||||
@else
|
||||
<span class="badge badge-rejected">Rejected</span>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<td>{{ $req->created_at->format('d M Y, h:i A') }}</td>
|
||||
|
||||
<td class="actions">
|
||||
@if($req->status == 'pending')
|
||||
<a href="{{ route('admin.profile.approve', $req->id) }}" class="btn btn-success btn-sm">
|
||||
<i class="bi bi-check-circle"></i> Approve
|
||||
</a>
|
||||
|
||||
<a href="{{ route('admin.profile.reject', $req->id) }}" class="btn btn-danger btn-sm">
|
||||
<i class="bi bi-x-circle"></i> Reject
|
||||
</a>
|
||||
@else
|
||||
<span class="text-muted">Completed</span>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -6,20 +6,28 @@
|
||||
<style>
|
||||
/* ===== GLOBAL RESPONSIVE STYLES ===== */
|
||||
html, body {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100%;
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Use Inter globally (keeps your existing @import too) */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
||||
|
||||
/* Apply Inter globally but keep specificity low so your component styles still work */
|
||||
:root { --admin-font: 'Inter', sans-serif; }
|
||||
body, input, select, textarea, button, table, th, td, .report-container {
|
||||
font-family: var(--admin-font);
|
||||
}
|
||||
|
||||
.report-container {
|
||||
|
||||
background: #ffffff;
|
||||
padding: 25px;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
|
||||
margin: 20px auto;
|
||||
max-width: 100%;
|
||||
font-family: 'Inter', sans-serif;
|
||||
/* font-family now coming from :root */
|
||||
border: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
@@ -69,18 +77,21 @@
|
||||
.stats-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: 15px;
|
||||
gap: 12px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
|
||||
padding: 18px 15px;
|
||||
padding: 16px;
|
||||
border-radius: 12px;
|
||||
border-left: 4px solid #4f46e5;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
transition: transform 0.3s ease;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-height: 70px;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
@@ -112,7 +123,16 @@
|
||||
background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
|
||||
}
|
||||
|
||||
|
||||
.stat-icon {
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(79, 70, 229, 0.1);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.stat-icon i {
|
||||
font-size: 18px;
|
||||
@@ -143,9 +163,9 @@
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
/* .stat-card.info .stat-icon {
|
||||
.stat-card.info .stat-icon {
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
} */
|
||||
}
|
||||
|
||||
.stat-card.info .stat-icon i {
|
||||
color: #3b82f6;
|
||||
@@ -159,16 +179,20 @@
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
.stat-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: #1a202c;
|
||||
margin-bottom: 4px;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
color: #718096;
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
@@ -216,10 +240,10 @@
|
||||
border-radius: 8px;
|
||||
border: 1.5px solid #e5e7eb;
|
||||
background: #ffffff;
|
||||
font-size: 13px;
|
||||
font-size: 14px; /* increased to match global font sizing */
|
||||
color: #1f2937;
|
||||
transition: all 0.3s ease;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-family: var(--admin-font);
|
||||
}
|
||||
|
||||
.filter-control:focus {
|
||||
@@ -242,12 +266,15 @@
|
||||
/* Ensure table takes full width and doesn't wrap */
|
||||
.report-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
/* keep your collapse behavior but update spacing to match Orders page */
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
min-width: 1200px; /* Minimum width to prevent squeezing */
|
||||
table-layout: auto; /* Allow columns to adjust based on content */
|
||||
font-size: 14px; /* unified table font size */
|
||||
}
|
||||
|
||||
/* Table header styling - CENTER ALIGNED */
|
||||
/* Table header styling - CENTER ALIGNED (keep your gradient & sticky) */
|
||||
.report-table thead {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
position: sticky;
|
||||
@@ -255,10 +282,11 @@
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* Adjusted header padding to match Orders spacing */
|
||||
.report-table th {
|
||||
padding: 15px 12px;
|
||||
padding: 16px 20px; /* changed from 15px 12px to match Orders' spacing */
|
||||
text-align: center; /* Center align header text */
|
||||
font-size: 13px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
border-bottom: none;
|
||||
@@ -280,8 +308,8 @@
|
||||
|
||||
/* Table cell styling with proper text handling - CENTER ALIGNED */
|
||||
.report-table td {
|
||||
padding: 12px;
|
||||
font-size: 13px;
|
||||
padding: 14px 20px; /* changed from 12px to match Orders' td padding */
|
||||
font-size: 14px; /* unified */
|
||||
color: #374151;
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
vertical-align: middle;
|
||||
@@ -292,12 +320,13 @@
|
||||
min-width: 120px; /* Minimum column width */
|
||||
text-align: center; /* Center align all table data */
|
||||
}
|
||||
|
||||
/* Specific column width adjustments */
|
||||
.report-table th:nth-child(1), /* Order ID */
|
||||
.report-table td:nth-child(1) {
|
||||
min-width: 100px;
|
||||
max-width: 150px;
|
||||
min-width: 200px !important;
|
||||
max-width: 200px !important;
|
||||
padding-left: 20px !important;
|
||||
|
||||
}
|
||||
|
||||
.report-table th:nth-child(2), /* Shipment ID */
|
||||
@@ -411,8 +440,12 @@
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.status-badge i {
|
||||
font-size: 8px;
|
||||
/* Status icons */
|
||||
.status-icon {
|
||||
font-size: 11px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
@@ -469,19 +502,18 @@
|
||||
}
|
||||
|
||||
.data-highlight {
|
||||
font-weight: 600;
|
||||
font-weight: 400;
|
||||
color: #1a202c;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center; /* Center content */
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin: 0 auto; /* Center the highlight container */
|
||||
}
|
||||
|
||||
.data-highlight i {
|
||||
color: #4f46e5;
|
||||
font-size: 11px;
|
||||
@@ -706,11 +738,21 @@
|
||||
|
||||
.stats-container {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 12px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
padding: 15px 12px;
|
||||
padding: 14px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.stat-icon i {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
@@ -755,7 +797,7 @@
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
padding: 15px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.report-table {
|
||||
@@ -794,43 +836,55 @@
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-box-open"></i>
|
||||
</div>
|
||||
<div class="stat-value" id="totalShipments">{{ count($reports) }}</div>
|
||||
<div class="stat-label">Total Shipments</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="totalShipments">{{ count($reports) }}</div>
|
||||
<div class="stat-label">Total Shipments</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card warning">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-clock"></i>
|
||||
</div>
|
||||
<div class="stat-value" id="pendingShipments">0</div>
|
||||
<div class="stat-label">Pending Shipments</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="pendingShipments">0</div>
|
||||
<div class="stat-label">Pending Shipments</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card info">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-truck-moving"></i>
|
||||
</div>
|
||||
<div class="stat-value" id="inTransitShipments">0</div>
|
||||
<div class="stat-label">In Transit</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="inTransitShipments">0</div>
|
||||
<div class="stat-label">In Transit</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card secondary">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-shipping-fast"></i>
|
||||
</div>
|
||||
<div class="stat-value" id="dispatchedShipments">0</div>
|
||||
<div class="stat-label">Dispatched</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="dispatchedShipments">0</div>
|
||||
<div class="stat-label">Dispatched</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card success">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
</div>
|
||||
<div class="stat-value" id="deliveredShipments">0</div>
|
||||
<div class="stat-label">Delivered</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="deliveredShipments">0</div>
|
||||
<div class="stat-label">Delivered</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card danger">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
</div>
|
||||
<div class="stat-value" id="overdueInvoices">0</div>
|
||||
<div class="stat-label">Overdue Invoices</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="overdueInvoices">0</div>
|
||||
<div class="stat-label">Overdue Invoices</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -879,24 +933,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABLE SECTION -->
|
||||
<div class="table-container">
|
||||
<table class="report-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><i class="fas fa-hashtag"></i> Order ID</th>
|
||||
<th><i class="fas fa-barcode"></i> Shipment ID</th>
|
||||
<th><i class="fas fa-building"></i> Company Name</th>
|
||||
<th><i class="fas fa-user"></i> User Name</th>
|
||||
<th>Order ID</th>
|
||||
<th>Shipment ID</th>
|
||||
<th>Company Name</th>
|
||||
<th>User Name</th>
|
||||
<th><i class="fas fa-map-marker-alt"></i> Origin</th>
|
||||
<th><i class="fas fa-location-arrow"></i> Destination</th>
|
||||
<th><i class="fas fa-calendar"></i> Date</th>
|
||||
<th><i class="fas fa-file-invoice"></i> Invoice ID</th>
|
||||
<th><i class="fas fa-calendar-day"></i> Invoice Date</th>
|
||||
<th><i class="fas fa-money-bill-wave"></i> Invoice Amount</th>
|
||||
<th><i class="fas fa-receipt"></i> Invoice Status</th>
|
||||
<th><i class="fas fa-shipping-fast"></i> Shipment Status</th>
|
||||
<th>Date</th>
|
||||
<th>Invoice ID</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Invoice Amount</th>
|
||||
<th>Invoice Status</th>
|
||||
<th>Shipment Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="reportTableBody">
|
||||
@@ -904,13 +957,11 @@
|
||||
<tr data-status="{{ $r->shipment_status }}" data-invoice-status="{{ strtolower($r->invoice_status) }}" data-company="{{ $r->company_name ?? '' }}" data-date="{{ $r->shipment_date }}">
|
||||
<td>
|
||||
<span class="data-highlight" title="{{ $r->order_id }}">
|
||||
<i class="fas fa-hashtag"></i>
|
||||
{{ $r->order_id }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="{{ $r->shipment_id }}">
|
||||
<i class="fas fa-barcode"></i>
|
||||
{{ $r->shipment_id }}
|
||||
</span>
|
||||
</td>
|
||||
@@ -919,9 +970,10 @@
|
||||
<td>
|
||||
<span class="data-highlight" title="{{ $r->origin }}">
|
||||
<i class="fas fa-map-marker-alt"></i>
|
||||
{{ $r->origin }}
|
||||
{{ $r->origin ?? '-' }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span class="data-highlight" title="{{ $r->destination }}">
|
||||
<i class="fas fa-location-arrow"></i>
|
||||
@@ -931,31 +983,43 @@
|
||||
<td>{{ \Carbon\Carbon::parse($r->shipment_date)->format('d/m/Y') }}</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="{{ $r->invoice_number }}">
|
||||
<i class="fas fa-file-invoice"></i>
|
||||
{{ $r->invoice_number }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ \Carbon\Carbon::parse($r->invoice_date)->format('d/m/Y') }}</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="₹{{ number_format($r->final_amount) }}">
|
||||
<i class="fas fa-rupee-sign"></i>
|
||||
{{ number_format($r->final_amount) }}
|
||||
₹{{ number_format($r->final_amount) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
@php $ist = strtolower($r->invoice_status); @endphp
|
||||
@php $ist = strtolower($r->invoice_status ?? ''); @endphp
|
||||
<span class="status-badge
|
||||
@if($ist === 'paid') status-paid
|
||||
@elseif($ist === 'pending') status-pending
|
||||
@elseif($ist === 'overdue') status-overdue
|
||||
@endif">
|
||||
<i class="fas fa-circle"></i>
|
||||
@if($ist === 'paid')
|
||||
<i class="bi bi-check-circle-fill status-icon"></i>
|
||||
@elseif($ist === 'pending')
|
||||
<i class="bi bi-clock-fill status-icon"></i>
|
||||
@elseif($ist === 'overdue')
|
||||
<i class="bi bi-exclamation-triangle-fill status-icon"></i>
|
||||
@endif
|
||||
{{ ucfirst($ist) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="status-badge ship-{{ $r->shipment_status }}">
|
||||
<i class="fas fa-circle"></i>
|
||||
@if($r->shipment_status === 'pending')
|
||||
<i class="bi bi-clock-fill status-icon"></i>
|
||||
@elseif($r->shipment_status === 'in_transit')
|
||||
<i class="bi bi-truck status-icon"></i>
|
||||
@elseif($r->shipment_status === 'dispatched')
|
||||
<i class="bi bi-send-fill status-icon"></i>
|
||||
@elseif($r->shipment_status === 'delivered')
|
||||
<i class="bi bi-check-circle-fill status-icon"></i>
|
||||
@endif
|
||||
{{ ucfirst(str_replace('_',' ', $r->shipment_status)) }}
|
||||
</span>
|
||||
</td>
|
||||
@@ -999,7 +1063,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Pagination state
|
||||
let currentPage = 1;
|
||||
@@ -1007,6 +1070,35 @@
|
||||
let allReports = @json($reports);
|
||||
let filteredReports = [...allReports];
|
||||
|
||||
// Status icon helper functions
|
||||
function getInvoiceStatusIcon(status) {
|
||||
switch(status) {
|
||||
case 'paid':
|
||||
return '<i class="bi bi-check-circle-fill status-icon"></i>';
|
||||
case 'pending':
|
||||
return '<i class="bi bi-clock-fill status-icon"></i>';
|
||||
case 'overdue':
|
||||
return '<i class="bi bi-exclamation-triangle-fill status-icon"></i>';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function getShipmentStatusIcon(status) {
|
||||
switch(status) {
|
||||
case 'pending':
|
||||
return '<i class="bi bi-clock-fill status-icon"></i>';
|
||||
case 'in_transit':
|
||||
return '<i class="bi bi-truck status-icon"></i>';
|
||||
case 'dispatched':
|
||||
return '<i class="bi bi-send-fill status-icon"></i>';
|
||||
case 'delivered':
|
||||
return '<i class="bi bi-check-circle-fill status-icon"></i>';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize statistics and pagination
|
||||
updateStatistics();
|
||||
@@ -1021,18 +1113,25 @@
|
||||
return date.toISOString().split('T')[0];
|
||||
};
|
||||
|
||||
document.getElementById('fromDate').value = formatDate(lastMonth);
|
||||
document.getElementById('toDate').value = formatDate(today);
|
||||
if (document.getElementById('fromDate')) document.getElementById('fromDate').value = formatDate(lastMonth);
|
||||
if (document.getElementById('toDate')) document.getElementById('toDate').value = formatDate(today);
|
||||
|
||||
// Add event listeners for filters
|
||||
document.getElementById('fromDate').addEventListener('change', filterTable);
|
||||
document.getElementById('toDate').addEventListener('change', filterTable);
|
||||
document.getElementById('companyFilter').addEventListener('change', filterTable);
|
||||
document.getElementById('statusFilter').addEventListener('change', filterTable);
|
||||
const fd = document.getElementById('fromDate');
|
||||
const td = document.getElementById('toDate');
|
||||
const cf = document.getElementById('companyFilter');
|
||||
const sf = document.getElementById('statusFilter');
|
||||
|
||||
if(fd) fd.addEventListener('change', filterTable);
|
||||
if(td) td.addEventListener('change', filterTable);
|
||||
if(cf) cf.addEventListener('change', filterTable);
|
||||
if(sf) sf.addEventListener('change', filterTable);
|
||||
|
||||
// Bind pagination events
|
||||
document.getElementById('prevPageBtn').addEventListener('click', goToPreviousPage);
|
||||
document.getElementById('nextPageBtn').addEventListener('click', goToNextPage);
|
||||
const prevBtn = document.getElementById('prevPageBtn');
|
||||
const nextBtn = document.getElementById('nextPageBtn');
|
||||
if(prevBtn) prevBtn.addEventListener('click', goToPreviousPage);
|
||||
if(nextBtn) nextBtn.addEventListener('click', goToNextPage);
|
||||
|
||||
function updateStatistics() {
|
||||
const rows = document.querySelectorAll('#reportTableBody tr');
|
||||
@@ -1062,12 +1161,18 @@
|
||||
});
|
||||
|
||||
// Update statistics cards
|
||||
document.getElementById('totalShipments').textContent = totalShipments;
|
||||
document.getElementById('pendingShipments').textContent = pendingShipments;
|
||||
document.getElementById('inTransitShipments').textContent = inTransitShipments;
|
||||
document.getElementById('dispatchedShipments').textContent = dispatchedShipments;
|
||||
document.getElementById('deliveredShipments').textContent = deliveredShipments;
|
||||
document.getElementById('overdueInvoices').textContent = overdueInvoices;
|
||||
const elTotal = document.getElementById('totalShipments');
|
||||
if(elTotal) elTotal.textContent = totalShipments;
|
||||
const elPending = document.getElementById('pendingShipments');
|
||||
if(elPending) elPending.textContent = pendingShipments;
|
||||
const elInTransit = document.getElementById('inTransitShipments');
|
||||
if(elInTransit) elInTransit.textContent = inTransitShipments;
|
||||
const elDispatched = document.getElementById('dispatchedShipments');
|
||||
if(elDispatched) elDispatched.textContent = dispatchedShipments;
|
||||
const elDelivered = document.getElementById('deliveredShipments');
|
||||
if(elDelivered) elDelivered.textContent = deliveredShipments;
|
||||
const elOverdue = document.getElementById('overdueInvoices');
|
||||
if(elOverdue) elOverdue.textContent = overdueInvoices;
|
||||
}
|
||||
|
||||
// Pagination Functions
|
||||
@@ -1095,16 +1200,16 @@
|
||||
const pageInfo = document.getElementById('pageInfo');
|
||||
const paginationPages = document.getElementById('paginationPages');
|
||||
|
||||
prevBtn.disabled = currentPage === 1;
|
||||
nextBtn.disabled = currentPage === totalPages || totalPages === 0;
|
||||
if(prevBtn) prevBtn.disabled = currentPage === 1;
|
||||
if(nextBtn) nextBtn.disabled = currentPage === totalPages || totalPages === 0;
|
||||
|
||||
// Update page info text
|
||||
const startIndex = (currentPage - 1) * itemsPerPage + 1;
|
||||
const endIndex = Math.min(currentPage * itemsPerPage, filteredReports.length);
|
||||
pageInfo.textContent = `Showing ${startIndex} to ${endIndex} of ${filteredReports.length} entries`;
|
||||
if(pageInfo) pageInfo.textContent = `Showing ${startIndex} to ${endIndex} of ${filteredReports.length} entries`;
|
||||
|
||||
// Generate page numbers
|
||||
paginationPages.innerHTML = '';
|
||||
if(paginationPages) paginationPages.innerHTML = '';
|
||||
|
||||
if (totalPages <= 7) {
|
||||
// Show all pages
|
||||
@@ -1116,7 +1221,7 @@
|
||||
addPageButton(1, paginationPages);
|
||||
|
||||
if (currentPage > 3) {
|
||||
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
if(paginationPages) paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
}
|
||||
|
||||
const start = Math.max(2, currentPage - 1);
|
||||
@@ -1127,7 +1232,7 @@
|
||||
}
|
||||
|
||||
if (currentPage < totalPages - 2) {
|
||||
paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
if(paginationPages) paginationPages.innerHTML += '<span class="pagination-ellipsis">...</span>';
|
||||
}
|
||||
|
||||
addPageButton(totalPages, paginationPages);
|
||||
@@ -1135,6 +1240,7 @@
|
||||
}
|
||||
|
||||
function addPageButton(pageNumber, container) {
|
||||
if(!container) return;
|
||||
const button = document.createElement('button');
|
||||
button.className = 'pagination-page-btn';
|
||||
if (pageNumber === currentPage) {
|
||||
@@ -1152,6 +1258,7 @@
|
||||
// Render Table Function
|
||||
function renderTable() {
|
||||
const tbody = document.getElementById('reportTableBody');
|
||||
if(!tbody) return;
|
||||
tbody.innerHTML = '';
|
||||
|
||||
if (filteredReports.length === 0) {
|
||||
@@ -1187,42 +1294,38 @@
|
||||
row.innerHTML = `
|
||||
<td>
|
||||
<span class="data-highlight" title="${report.order_id}">
|
||||
<i class="fas fa-hashtag"></i>
|
||||
${report.order_id}
|
||||
${report.order_id || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="${report.shipment_id}">
|
||||
<i class="fas fa-barcode"></i>
|
||||
${report.shipment_id}
|
||||
${report.shipment_id || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td title="${report.company_name || '-'}">${report.company_name || '-'}</td>
|
||||
<td title="${report.customer_name || '-'}">${report.customer_name || '-'}</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="${report.origin}">
|
||||
<span class="data-highlight" title="${report.origin || '-'}">
|
||||
<i class="fas fa-map-marker-alt"></i>
|
||||
${report.origin}
|
||||
${report.origin || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="${report.destination}">
|
||||
<span class="data-highlight" title="${report.destination || '-'}">
|
||||
<i class="fas fa-location-arrow"></i>
|
||||
${report.destination}
|
||||
${report.destination || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td>${new Date(report.shipment_date).toLocaleDateString('en-GB')}</td>
|
||||
<td>${report.shipment_date ? new Date(report.shipment_date).toLocaleDateString('en-GB') : '-'}</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="${report.invoice_number}">
|
||||
<i class="fas fa-file-invoice"></i>
|
||||
${report.invoice_number}
|
||||
<span class="data-highlight" title="${report.invoice_number || '-'}">
|
||||
${report.invoice_number || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td>${new Date(report.invoice_date).toLocaleDateString('en-GB')}</td>
|
||||
<td>${report.invoice_date ? new Date(report.invoice_date).toLocaleDateString('en-GB') : '-'}</td>
|
||||
<td>
|
||||
<span class="data-highlight" title="₹${Number(report.final_amount).toLocaleString('en-IN')}">
|
||||
<i class="fas fa-rupee-sign"></i>
|
||||
${Number(report.final_amount).toLocaleString('en-IN')}
|
||||
<span class="data-highlight" title="₹${Number(report.final_amount || 0).toLocaleString('en-IN')}">
|
||||
₹${Number(report.final_amount || 0).toLocaleString('en-IN')}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
@@ -1230,14 +1333,14 @@
|
||||
${ist === 'paid' ? 'status-paid' : ''}
|
||||
${ist === 'pending' ? 'status-pending' : ''}
|
||||
${ist === 'overdue' ? 'status-overdue' : ''}">
|
||||
<i class="fas fa-circle"></i>
|
||||
${ist.charAt(0).toUpperCase() + ist.slice(1)}
|
||||
${getInvoiceStatusIcon(ist)}
|
||||
${ist ? ist.charAt(0).toUpperCase() + ist.slice(1) : '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="status-badge ship-${report.shipment_status}">
|
||||
<i class="fas fa-circle"></i>
|
||||
${report.shipment_status.charAt(0).toUpperCase() + report.shipment_status.slice(1).replace('_', ' ')}
|
||||
<span class="status-badge ship-${report.shipment_status || ''}">
|
||||
${getShipmentStatusIcon(report.shipment_status)}
|
||||
${report.shipment_status ? (report.shipment_status.charAt(0).toUpperCase() + report.shipment_status.slice(1)).replace('_',' ') : '-'}
|
||||
</span>
|
||||
</td>
|
||||
`;
|
||||
@@ -1246,10 +1349,10 @@
|
||||
}
|
||||
|
||||
function filterTable() {
|
||||
const fromDate = document.getElementById('fromDate').value;
|
||||
const toDate = document.getElementById('toDate').value;
|
||||
const companyFilter = document.getElementById('companyFilter').value;
|
||||
const statusFilter = document.getElementById('statusFilter').value;
|
||||
const fromDate = document.getElementById('fromDate')?.value;
|
||||
const toDate = document.getElementById('toDate')?.value;
|
||||
const companyFilter = document.getElementById('companyFilter')?.value;
|
||||
const statusFilter = document.getElementById('statusFilter')?.value;
|
||||
|
||||
filteredReports = allReports.filter(report => {
|
||||
let include = true;
|
||||
@@ -1285,7 +1388,7 @@
|
||||
updateStatistics();
|
||||
}
|
||||
|
||||
// Add hover effects to table rows
|
||||
// Add hover effects to table rows (for rows present initially in DOM — dynamic rows handled in renderTable)
|
||||
const tableRows = document.querySelectorAll('.report-table tbody tr');
|
||||
tableRows.forEach(row => {
|
||||
row.addEventListener('mouseenter', function() {
|
||||
|
||||
@@ -365,7 +365,22 @@
|
||||
@elseif($req->status == 'rejected')<span class="badge badge-rejected"><i class="bi bi-x-circle-fill status-icon"></i>Rejected</span>
|
||||
@else<span class="badge badge-pending"><i class="bi bi-clock-fill status-icon"></i>Pending</span>@endif
|
||||
</td>
|
||||
<td>N/A</td>
|
||||
<td>
|
||||
@if($req->status == 'pending')
|
||||
<a href="{{ route('admin.requests.approve', $req->id) }}"
|
||||
class="btn btn-success btn-sm">
|
||||
<i class="bi bi-check-circle"></i> Approve
|
||||
</a>
|
||||
|
||||
<a href="{{ route('admin.requests.reject', $req->id) }}"
|
||||
class="btn btn-danger btn-sm">
|
||||
<i class="bi bi-x-circle"></i> Reject
|
||||
</a>
|
||||
@else
|
||||
<span class="text-muted">No Action</span>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="11" class="text-center text-muted py-4">No records found.</td></tr>
|
||||
|
||||
@@ -258,6 +258,14 @@
|
||||
line-height: 1.2 !important;
|
||||
}
|
||||
|
||||
/* Loading Status - PROPER */
|
||||
.badge-loading {
|
||||
background: linear-gradient(135deg, #e3f2fd, #90caf9) !important;
|
||||
color: #1565c0 !important;
|
||||
border-color: #2196f3 !important;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
/* Pending Status - SAME SIZE */
|
||||
.badge-pending {
|
||||
background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
|
||||
@@ -320,7 +328,30 @@
|
||||
padding: 6px 12px !important;
|
||||
}
|
||||
|
||||
/* NEW: Action Button Styles */
|
||||
/* Eye Button Style - PROPER */
|
||||
.btn-eye {
|
||||
background: linear-gradient(135deg, #4cc9f0, #4361ee);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btn-eye:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(76, 201, 240, 0.3);
|
||||
background: linear-gradient(135deg, #38bdf8, #3a56d4);
|
||||
}
|
||||
|
||||
/* Action Button Styles */
|
||||
.action-container {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
@@ -368,6 +399,16 @@
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Loading Status Option - PROPER */
|
||||
.status-option.loading {
|
||||
background: rgba(33, 150, 243, 0.1);
|
||||
color: #2196f3;
|
||||
}
|
||||
|
||||
.status-option.loading:hover {
|
||||
background: rgba(33, 150, 243, 0.2);
|
||||
}
|
||||
|
||||
.status-option {
|
||||
padding: 10px 12px;
|
||||
border: none;
|
||||
@@ -431,6 +472,11 @@
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Loading Status Indicator - PROPER */
|
||||
.status-indicator.loading {
|
||||
background: #2196f3;
|
||||
}
|
||||
|
||||
.status-indicator.pending {
|
||||
background: #f8961e;
|
||||
}
|
||||
@@ -1083,15 +1129,13 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- ============================= -->
|
||||
<!-- SEARCH BAR AND ADD BUTTON -->
|
||||
<!-- ============================= -->
|
||||
<div class="search-shipment-bar">
|
||||
<span class="search-icon">🔍</span>
|
||||
<input type="text" id="searchInput" placeholder="Search Shipments...">
|
||||
<div class="status-filter-container">
|
||||
<select id="statusFilter" class="status-filter-select">
|
||||
<option value="all">All Status</option>
|
||||
<option value="loading">Loading</option>
|
||||
<option value="pending">Pending</option>
|
||||
<option value="in_transit">In Transit</option>
|
||||
<option value="dispatched">Dispatched</option>
|
||||
@@ -1110,9 +1154,6 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ============================= -->
|
||||
<!-- CREATE SHIPMENT MODAL -->
|
||||
<!-- ============================= -->
|
||||
<div class="modal fade" id="createShipmentModal" tabindex="-1" aria-labelledby="createShipmentModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
@@ -1204,9 +1245,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============================= -->
|
||||
<!-- SHIPMENT LIST TABLE -->
|
||||
<!-- ============================= -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0"><i class="bi bi-truck me-2"></i> Shipments List</h5>
|
||||
@@ -1227,6 +1265,7 @@
|
||||
<th>Total Amount</th>
|
||||
<th>Status</th>
|
||||
<th>Date</th>
|
||||
<th>View</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -1257,6 +1296,12 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ \Carbon\Carbon::parse($ship->shipment_date)->format('d M Y') }}</td>
|
||||
<td>
|
||||
<button type="button" class="btn-eye" onclick="openShipmentDetails({{ $ship->id }})" title="View Shipment">
|
||||
<i class="bi bi-eye"></i>
|
||||
</button>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="action-container">
|
||||
<button type="button" class="btn-edit-status" onclick="toggleStatusDropdown(this, {{ $ship->id }})" title="Edit Status">
|
||||
@@ -1266,6 +1311,10 @@
|
||||
<form action="{{ route('admin.shipments.updateStatus') }}" method="POST" class="status-form">
|
||||
@csrf
|
||||
<input type="hidden" name="shipment_id" value="{{ $ship->id }}">
|
||||
<button type="submit" name="status" value="loading" class="status-option loading">
|
||||
<span class="status-indicator loading"></span>
|
||||
Loading
|
||||
</button>
|
||||
<button type="submit" name="status" value="pending" class="status-option pending">
|
||||
<span class="status-indicator pending"></span>
|
||||
Pending
|
||||
@@ -1289,7 +1338,7 @@
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="11" class="text-center py-5 text-muted">
|
||||
<td colspan="12" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-inbox display-4 d-block mb-3"></i>
|
||||
No shipments found
|
||||
</td>
|
||||
@@ -1299,21 +1348,17 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination Controls -->
|
||||
<div class="pagination-container">
|
||||
<div class="pagination-info" id="pageInfo">Showing 1 to {{ $shipments->count() }} of {{ $shipments->count() }} entries</div>
|
||||
<div class="pagination-controls">
|
||||
<button class="pagination-img-btn" id="prevPageBtn" title="Previous page" disabled>
|
||||
<!-- Left arrow SVG -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 12L6 8L10 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="pagination-pages" id="paginationPages">
|
||||
<!-- Page numbers will be inserted here -->
|
||||
</div>
|
||||
</div>
|
||||
<button class="pagination-img-btn" id="nextPageBtn" title="Next page" disabled>
|
||||
<!-- Right arrow SVG -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6 4L10 8L6 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
@@ -1323,9 +1368,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============================= -->
|
||||
<!-- SHIPMENT DETAILS MODAL -->
|
||||
<!-- ============================= -->
|
||||
{{-- SHIPMENT DETAILS MODAL --}}
|
||||
<div class="modal fade" id="shipmentDetailsModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
@@ -1348,9 +1391,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ========================= -->
|
||||
<!-- MODAL LOAD SCRIPT (AJAX) -->
|
||||
<!-- ========================= -->
|
||||
<script>
|
||||
// Pagination state
|
||||
let currentPage = 1;
|
||||
@@ -1503,7 +1543,7 @@ function renderTable() {
|
||||
if (filteredShipments.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="11" class="text-center py-5 text-muted">
|
||||
<td colspan="12" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-search display-4 d-block mb-3"></i>
|
||||
No shipments found matching your criteria
|
||||
</td>
|
||||
@@ -1529,6 +1569,12 @@ function renderTable() {
|
||||
row.setAttribute('data-status', shipment.status);
|
||||
row.setAttribute('data-shipment-id', shipment.shipment_id);
|
||||
|
||||
// Function to format status string
|
||||
const formatStatus = (status) => {
|
||||
if (!status) return '';
|
||||
return status.charAt(0).toUpperCase() + status.slice(1).replace(/_/g, ' ');
|
||||
};
|
||||
|
||||
row.innerHTML = `
|
||||
<td class="fw-bold">${displayIndex}</td>
|
||||
<td>
|
||||
@@ -1544,10 +1590,19 @@ function renderTable() {
|
||||
<td class="fw-bold text-success">₹${parseFloat(shipment.total_amount).toLocaleString('en-IN', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
|
||||
<td>
|
||||
<span class="badge badge-${shipment.status}">
|
||||
${shipment.status.charAt(0).toUpperCase() + shipment.status.slice(1).replace('_', ' ')}
|
||||
${formatStatus(shipment.status)}
|
||||
</span>
|
||||
</td>
|
||||
<td>${new Date(shipment.shipment_date).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' })}</td>
|
||||
|
||||
<td>
|
||||
<a href="{{ route('admin.shipments.dummy', $ship->id) }}"
|
||||
class="btn-view-details">
|
||||
<i class="bi bi-eye"></i>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<div class="action-container">
|
||||
<button type="button" class="btn-edit-status" onclick="toggleStatusDropdown(this, ${shipment.id})" title="Edit Status">
|
||||
@@ -1557,6 +1612,10 @@ function renderTable() {
|
||||
<form action="/admin/shipments/update-status" method="POST" class="status-form">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="shipment_id" value="${shipment.id}">
|
||||
<button type="submit" name="status" value="loading" class="status-option loading">
|
||||
<span class="status-indicator loading"></span>
|
||||
Loading
|
||||
</button>
|
||||
<button type="submit" name="status" value="pending" class="status-option pending">
|
||||
<span class="status-indicator pending"></span>
|
||||
Pending
|
||||
@@ -1582,6 +1641,9 @@ function renderTable() {
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Function: Open Consolidated Shipment Details Modal
|
||||
// --------------------------------------------------------------------
|
||||
function openShipmentDetails(id) {
|
||||
let modal = new bootstrap.Modal(document.getElementById('shipmentDetailsModal'));
|
||||
let content = document.getElementById('shipmentDetailsContent');
|
||||
@@ -1609,8 +1671,13 @@ function openShipmentDetails(id) {
|
||||
year: 'numeric'
|
||||
});
|
||||
|
||||
// Function to format status string
|
||||
const formatStatus = (status) => {
|
||||
if (!status) return 'N/A';
|
||||
return status.charAt(0).toUpperCase() + status.slice(1).replace(/_/g, ' ');
|
||||
};
|
||||
|
||||
let html = `
|
||||
<!-- Shipment Basic Info -->
|
||||
<div class="shipment-info-row">
|
||||
<div class="shipment-info-item">
|
||||
<div class="shipment-info-label">Shipment ID</div>
|
||||
@@ -1622,7 +1689,7 @@ function openShipmentDetails(id) {
|
||||
</div>
|
||||
<div class="shipment-info-item">
|
||||
<div class="shipment-info-label">Status</div>
|
||||
<div class="shipment-info-value">${data.shipment.status}</div>
|
||||
<div class="shipment-info-value">${formatStatus(data.shipment.status)}</div>
|
||||
</div>
|
||||
<div class="shipment-info-item">
|
||||
<div class="shipment-info-label">Date</div>
|
||||
@@ -1657,7 +1724,9 @@ function openShipmentDetails(id) {
|
||||
data.orders.forEach(order => {
|
||||
html += `
|
||||
<tr>
|
||||
<td class="fw-bold text-primary">${order.order_id}</td>
|
||||
<td class="fw-bold">
|
||||
${order.order_id}
|
||||
</td>
|
||||
<td>${order.origin || 'N/A'}</td>
|
||||
<td>${order.destination || 'N/A'}</td>
|
||||
<td>${order.mark_no || 'ITEM001'}</td>
|
||||
@@ -1679,7 +1748,6 @@ function openShipmentDetails(id) {
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Totals Section -->
|
||||
<div class="shipment-totals">
|
||||
<div class="shipment-totals-row">
|
||||
<div class="shipment-total-item">
|
||||
|
||||
187
resources/views/admin/staff/create.blade.php
Normal file
187
resources/views/admin/staff/create.blade.php
Normal file
@@ -0,0 +1,187 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('page-title', 'Account Dashboard')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.card { background:#fff; border:1px solid #eaeaea; padding:1rem; border-radius:6px; }
|
||||
.field { margin-bottom:.8rem; }
|
||||
label { display:block; font-weight:600; margin-bottom:.25rem; }
|
||||
input[type="text"], input[type="email"], input[type="date"], input[type="password"], textarea, select {
|
||||
width:100%; padding:.5rem; border:1px solid #ddd; border-radius:4px;
|
||||
}
|
||||
.stages { display:flex; gap:.5rem; margin-bottom:1rem; }
|
||||
.stage-ind { padding:.35rem .6rem; border-radius:4px; background:#f3f3f3; }
|
||||
.stage { display:none; }
|
||||
.stage.active { display:block; }
|
||||
.btn { padding:.5rem .8rem; border-radius:5px; border:1px solid #ccc; background:#f6f6f6; cursor:pointer; }
|
||||
.btn.primary { background:#0b74de; color:#fff; border-color:#0b74de; }
|
||||
.perm-group { border:1px dashed #eee; padding:.6rem; margin-bottom:.6rem; border-radius:4px; }
|
||||
.perm-list { display:flex; flex-wrap:wrap; gap:.5rem; }
|
||||
.perm-item { min-width:200px; }
|
||||
.error { color:#b00020; font-size:.95rem; margin-top:.25rem; }
|
||||
</style>
|
||||
|
||||
<div class="card">
|
||||
<h3>Add Staff</h3>
|
||||
|
||||
@if($errors->any())
|
||||
<div style="background:#fff0f0; padding:.6rem; border:1px solid #f3c6c6; margin-bottom:1rem;">
|
||||
<strong>There were some problems with your input:</strong>
|
||||
<ul>
|
||||
@foreach($errors->all() as $err)
|
||||
<li>{{ $err }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.staff.store') }}">
|
||||
@csrf
|
||||
|
||||
<div class="stages">
|
||||
<div class="stage-ind">1. Personal</div>
|
||||
<div class="stage-ind">2. Professional</div>
|
||||
<div class="stage-ind">3. System</div>
|
||||
<div class="stage-ind">4. Permissions</div>
|
||||
</div>
|
||||
|
||||
{{-- Stage 1 --}}
|
||||
<div id="stage-1" class="stage active">
|
||||
<div class="field">
|
||||
<label>Name *</label>
|
||||
<input type="text" name="name" value="{{ old('name') }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Email *</label>
|
||||
<input type="email" name="email" value="{{ old('email') }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Phone *</label>
|
||||
<input type="text" name="phone" value="{{ old('phone') }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Emergency Phone</label>
|
||||
<input type="text" name="emergency_phone" value="{{ old('emergency_phone') }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Address</label>
|
||||
<textarea name="address" rows="3">{{ old('address') }}</textarea>
|
||||
</div>
|
||||
|
||||
<div style="display:flex; justify-content:flex-end; gap:.5rem;">
|
||||
<button type="button" class="btn" onclick="showStage(2)">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Stage 2 --}}
|
||||
<div id="stage-2" class="stage">
|
||||
<div class="field">
|
||||
<label>Role (Business role)</label>
|
||||
<input type="text" name="role" value="{{ old('role') }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Department</label>
|
||||
<input type="text" name="department" value="{{ old('department') }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Designation</label>
|
||||
<input type="text" name="designation" value="{{ old('designation') }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Joining Date</label>
|
||||
<input type="date" name="joining_date" value="{{ old('joining_date') }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Status</label>
|
||||
<select name="status">
|
||||
<option value="active" {{ old('status')=='active'?'selected':'' }}>Active</option>
|
||||
<option value="inactive" {{ old('status')=='inactive'?'selected':'' }}>Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Additional Info</label>
|
||||
<textarea name="additional_info" rows="3">{{ old('additional_info') }}</textarea>
|
||||
</div>
|
||||
|
||||
<div style="display:flex; justify-content:space-between; gap:.5rem;">
|
||||
<button type="button" class="btn" onclick="showStage(1)">Back</button>
|
||||
<button type="button" class="btn" onclick="showStage(3)">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Stage 3 --}}
|
||||
<div id="stage-3" class="stage">
|
||||
<div class="field">
|
||||
<label>Username *</label>
|
||||
<input type="text" name="username" value="{{ old('username') }}" placeholder="leave blank to use EMPxxxx">
|
||||
<div class="muted" style="font-size:.9rem; margin-top:.25rem;">If left blank employee id will be used.</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Password *</label>
|
||||
<input type="password" name="password" required>
|
||||
</div>
|
||||
|
||||
<div style="display:flex; justify-content:space-between; gap:.5rem;">
|
||||
<button type="button" class="btn" onclick="showStage(2)">Back</button>
|
||||
<button type="button" class="btn" onclick="showStage(4)">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Stage 4 --}}
|
||||
<div id="stage-4" class="stage">
|
||||
<div style="margin-bottom:.5rem; font-weight:700;">Permissions</div>
|
||||
|
||||
@foreach($permissions as $group => $groupPerms)
|
||||
<div class="perm-group">
|
||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
||||
<div style="font-weight:600;">{{ ucfirst($group) }}</div>
|
||||
<div>
|
||||
<button type="button" class="btn" onclick="toggleGroup('{{ $group }}')">Toggle group</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="perm-list" id="group-{{ $group }}">
|
||||
@foreach($groupPerms as $perm)
|
||||
<label class="perm-item">
|
||||
<input type="checkbox" name="permissions[]" value="{{ $perm->name }}"> {{ $perm->name }}
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div style="display:flex; justify-content:space-between; gap:.5rem;">
|
||||
<button type="button" class="btn" onclick="showStage(3)">Back</button>
|
||||
<button type="submit" class="btn primary">Create Staff</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showStage(n){
|
||||
document.querySelectorAll('.stage').forEach(s=>s.classList.remove('active'));
|
||||
document.getElementById('stage-'+n).classList.add('active');
|
||||
window.scrollTo({top:0, behavior:'smooth'});
|
||||
}
|
||||
|
||||
function toggleGroup(group){
|
||||
const el = document.getElementById('group-'+group);
|
||||
if(!el) return;
|
||||
const inputs = el.querySelectorAll('input[type="checkbox"]');
|
||||
const anyUnchecked = Array.from(inputs).some(i => !i.checked);
|
||||
inputs.forEach(i => i.checked = anyUnchecked);
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
156
resources/views/admin/staff/edit.blade.php
Normal file
156
resources/views/admin/staff/edit.blade.php
Normal file
@@ -0,0 +1,156 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('page-title', 'Account Dashboard')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.card { background:#fff; border:1px solid #eaeaea; padding:1rem; border-radius:6px; }
|
||||
.field { margin-bottom:.8rem; }
|
||||
label { display:block; font-weight:600; margin-bottom:.25rem; }
|
||||
input[type="text"], input[type="email"], input[type="date"], input[type="password"], textarea, select {
|
||||
width:100%; padding:.5rem; border:1px solid #ddd; border-radius:4px;
|
||||
}
|
||||
.perm-group { border:1px dashed #eee; padding:.6rem; margin-bottom:.6rem; border-radius:4px; }
|
||||
.perm-list { display:flex; flex-wrap:wrap; gap:.5rem; }
|
||||
.perm-item { min-width:200px; }
|
||||
.btn { padding:.5rem .8rem; border-radius:5px; border:1px solid #ccc; background:#f6f6f6; cursor:pointer; }
|
||||
.btn.primary { background:#0b74de; color:#fff; border-color:#0b74de; }
|
||||
</style>
|
||||
|
||||
<div class="card">
|
||||
<h3>Edit Staff — {{ $staff->display_name ?? $staff->name }}</h3>
|
||||
|
||||
@if($errors->any())
|
||||
<div style="background:#fff0f0; padding:.6rem; border:1px solid #f3c6c6; margin-bottom:1rem;">
|
||||
<strong>There were some problems with your input:</strong>
|
||||
<ul>
|
||||
@foreach($errors->all() as $err)
|
||||
<li>{{ $err }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.staff.update', $staff->id) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="field">
|
||||
<label>Employee ID</label>
|
||||
<input type="text" value="{{ $staff->employee_id }}" disabled>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Name *</label>
|
||||
<input type="text" name="name" value="{{ old('name', $staff->name) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Email *</label>
|
||||
<input type="email" name="email" value="{{ old('email', $staff->email) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Phone *</label>
|
||||
<input type="text" name="phone" value="{{ old('phone', $staff->phone) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Emergency Phone</label>
|
||||
<input type="text" name="emergency_phone" value="{{ old('emergency_phone', $staff->emergency_phone) }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Address</label>
|
||||
<textarea name="address" rows="3">{{ old('address', $staff->address) }}</textarea>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="field">
|
||||
<label>Role</label>
|
||||
<input type="text" name="role" value="{{ old('role', $staff->role) }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Department</label>
|
||||
<input type="text" name="department" value="{{ old('department', $staff->department) }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Designation</label>
|
||||
<input type="text" name="designation" value="{{ old('designation', $staff->designation) }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Joining Date</label>
|
||||
<input type="date" name="joining_date" value="{{ old('joining_date', optional($staff->joining_date)->format('Y-m-d')) }}">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Status</label>
|
||||
<select name="status">
|
||||
<option value="active" {{ old('status', $staff->status)=='active'?'selected':'' }}>Active</option>
|
||||
<option value="inactive" {{ old('status', $staff->status)=='inactive'?'selected':'' }}>Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Additional Info</label>
|
||||
<textarea name="additional_info" rows="3">{{ old('additional_info', $staff->additional_info) }}</textarea>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="field">
|
||||
<label>Username *</label>
|
||||
<input type="text" name="username" value="{{ old('username', $staff->username) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>New Password (leave blank to keep existing)</label>
|
||||
<input type="password" name="password" autocomplete="new-password">
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div style="margin-bottom:.5rem; font-weight:700;">Permissions</div>
|
||||
|
||||
@foreach($permissions as $group => $groupPerms)
|
||||
<div class="perm-group">
|
||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
||||
<div style="font-weight:600;">{{ ucfirst($group) }}</div>
|
||||
<div>
|
||||
<button type="button" class="btn" onclick="toggleGroup('{{ $group }}')">Toggle group</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="perm-list" id="group-{{ $group }}">
|
||||
@foreach($groupPerms as $perm)
|
||||
<label class="perm-item">
|
||||
<input type="checkbox" name="permissions[]" value="{{ $perm->name }}"
|
||||
{{ in_array($perm->name, old('permissions', $staffPermissions)) ? 'checked' : '' }}>
|
||||
{{ $perm->name }}
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div style="display:flex; justify-content:flex-end; gap:.5rem;">
|
||||
<a href="{{ route('admin.staff.index') }}" class="btn">Cancel</a>
|
||||
<button type="submit" class="btn primary">Update Staff</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleGroup(group){
|
||||
const el = document.getElementById('group-'+group);
|
||||
if(!el) return;
|
||||
const inputs = el.querySelectorAll('input[type="checkbox"]');
|
||||
const anyUnchecked = Array.from(inputs).some(i => !i.checked);
|
||||
inputs.forEach(i => i.checked = anyUnchecked);
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
65
resources/views/admin/staff/index.blade.php
Normal file
65
resources/views/admin/staff/index.blade.php
Normal file
@@ -0,0 +1,65 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('page-title', 'Account Dashboard')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.top-bar { display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem; }
|
||||
.card { background:#fff; border:1px solid #e4e4e4; border-radius:6px; padding:1rem; box-shadow:0 1px 3px rgba(0,0,0,.03); }
|
||||
table { width:100%; border-collapse:collapse; }
|
||||
th, td { padding:.6rem .75rem; border-bottom:1px solid #f1f1f1; text-align:left; }
|
||||
.btn { padding:.45rem .75rem; border-radius:4px; border:1px solid #ccc; background:#f7f7f7; cursor:pointer; }
|
||||
.btn.primary { background:#0b74de; color:#fff; border-color:#0b74de; }
|
||||
.actions a { margin-right:.5rem; color:#0b74de; text-decoration:none; }
|
||||
.muted { color:#666; font-size:.95rem; }
|
||||
</style>
|
||||
|
||||
<div class="top-bar">
|
||||
<h2>Staff</h2>
|
||||
<a href="{{ route('admin.staff.create') }}" class="btn primary">Add Staff</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
@if(session('success'))
|
||||
<div style="padding:.5rem; background:#e6ffed; border:1px solid #b6f0c6; margin-bottom:1rem;">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Employee ID</th>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th>Role</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($staff as $s)
|
||||
<tr>
|
||||
<td>{{ $s->id }}</td>
|
||||
<td class="muted">{{ $s->employee_id }}</td>
|
||||
<td>{{ $s->name }}</td>
|
||||
<td>{{ $s->email }}</td>
|
||||
<td>{{ $s->phone }}</td>
|
||||
<td>{{ $s->role ?? '-' }}</td>
|
||||
<td>{{ ucfirst($s->status) }}</td>
|
||||
<td class="actions">
|
||||
<a href="{{ route('admin.staff.edit', $s->id) }}">Edit</a>
|
||||
<form action="{{ route('admin.staff.destroy', $s->id) }}" method="POST" style="display:inline" onsubmit="return confirm('Delete this staff?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn" type="submit">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="8" class="muted">No staff found.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
128
resources/views/admin/view_shipment.blade.php
Normal file
128
resources/views/admin/view_shipment.blade.php
Normal file
@@ -0,0 +1,128 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('page-title', 'Shipment Preview')
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="container py-4">
|
||||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-box-seam me-2"></i>
|
||||
Shipment Preview: {{ $shipment->shipment_id }}
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<!-- Dummy Info -->
|
||||
<div class="alert alert-info">
|
||||
<strong>{{ $dummyData['title'] }}</strong><br>
|
||||
Generated On: {{ $dummyData['generated_on'] }} <br>
|
||||
Note: {{ $dummyData['note'] }}
|
||||
</div>
|
||||
|
||||
<!-- Shipment Basic Details -->
|
||||
<h5 class="fw-bold mt-3">Shipment Details</h5>
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th>Shipment ID</th>
|
||||
<td>{{ $shipment->shipment_id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Origin</th>
|
||||
<td>{{ $shipment->origin }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Destination</th>
|
||||
<td>{{ $shipment->destination }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<td>{{ ucfirst($shipment->status) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<td>{{ \Carbon\Carbon::parse($shipment->shipment_date)->format('d M Y') }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- Orders in Shipment -->
|
||||
<h5 class="fw-bold mt-4">Orders Contained in Shipment</h5>
|
||||
|
||||
@if($shipment->orders->isEmpty())
|
||||
<p class="text-muted">No orders found.</p>
|
||||
@else
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Origin</th>
|
||||
<th>Destination</th>
|
||||
<th>CTN</th>
|
||||
<th>QTY</th>
|
||||
<th>TTL/QTY</th>
|
||||
<th>KG</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($shipment->orders as $order)
|
||||
<tr>
|
||||
<td>{{ $order->order_id }}</td>
|
||||
<td>{{ $order->origin }}</td>
|
||||
<td>{{ $order->destination }}</td>
|
||||
<td>{{ $order->ctn }}</td>
|
||||
<td>{{ $order->qty }}</td>
|
||||
<td>{{ $order->ttl_qty }}</td>
|
||||
<td>{{ $order->ttl_kg }}</td>
|
||||
<td>₹{{ number_format($order->ttl_amount, 2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Shipment Totals -->
|
||||
<h5 class="fw-bold mt-4">Shipment Totals</h5>
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th>Total CTN</th>
|
||||
<td>{{ $shipment->total_ctn }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total Quantity</th>
|
||||
<td>{{ $shipment->total_qty }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total TTL Quantity</th>
|
||||
<td>{{ $shipment->total_ttl_qty }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total CBM</th>
|
||||
<td>{{ $shipment->total_cbm }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total KG</th>
|
||||
<td>{{ $shipment->total_kg }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total Amount</th>
|
||||
<td class="fw-bold text-success">
|
||||
₹{{ number_format($shipment->total_amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a href="{{ route('admin.shipments') }}" class="btn btn-secondary mt-3">
|
||||
← Back to Shipments
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@@ -4,17 +4,46 @@ use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\RequestController;
|
||||
use App\Http\Controllers\UserAuthController;
|
||||
use App\Http\Controllers\MarkListController;
|
||||
use App\Http\Controllers\User\UserOrderController;
|
||||
use App\Http\Controllers\User\UserProfileController;
|
||||
|
||||
|
||||
//user send request
|
||||
Route::post('/signup-request', [RequestController::class, 'usersignup']);
|
||||
|
||||
//login / logout
|
||||
Route::post('/user/login', [UserAuthController::class, 'login']);
|
||||
Route::post('/user/logout', [UserAuthController::class, 'logout'])->middleware('auth:api');
|
||||
|
||||
|
||||
|
||||
Route::middleware(['auth:api'])->group(function () {
|
||||
Route::get('/show-mark-list', [MarkListController::class, 'showmarklist']); // Fetch all marks by user
|
||||
Route::post('/add-mark-no', [MarkListController::class, 'addmarkno']); // Create new mark
|
||||
//Route::post('/user/refresh', [UserAuthController::class, 'refreshToken']);
|
||||
|
||||
Route::post('/user/logout', [UserAuthController::class, 'logout']);
|
||||
|
||||
// Marklist
|
||||
Route::get('/show-mark-list', [MarkListController::class, 'showmarklist']);
|
||||
Route::post('/add-mark-no', [MarkListController::class, 'addmarkno']);
|
||||
|
||||
// Orders
|
||||
Route::get('/user/order-summary', [UserOrderController::class, 'orderSummary']);
|
||||
Route::get('/user/orders', [UserOrderController::class, 'allOrders']);
|
||||
Route::get('/user/order/{order_id}/details', [UserOrderController::class, 'orderDetails']);
|
||||
Route::get('/user/order/{order_id}/shipment', [UserOrderController::class, 'orderShipment']);
|
||||
Route::get('/user/order/{order_id}/invoice', [UserOrderController::class, 'orderInvoice']);
|
||||
Route::get('/user/order/{order_id}/track', [UserOrderController::class, 'trackOrder']);
|
||||
Route::get('/user/invoice/{invoice_id}/details', [UserOrderController::class, 'invoiceDetails']);
|
||||
|
||||
// Invoice List
|
||||
Route::get('/user/invoices', [UserOrderController::class, 'allInvoices']);
|
||||
Route::get('/user/invoice/{invoice_id}/installments', [UserOrderController::class, 'invoiceInstallmentsById']);
|
||||
|
||||
// Profile
|
||||
|
||||
|
||||
Route::get('/user/profile', [UserProfileController::class, 'profile']);
|
||||
Route::post('/user/profile-image', [UserProfileController::class, 'updateProfileImage']);
|
||||
Route::post('/user/profile-update-request', [UserProfileController::class, 'updateProfileRequest']);
|
||||
|
||||
// Route::post('/user/profile/update', [UserProfileController::class, 'updateProfile']);
|
||||
});
|
||||
|
||||
272
routes/web.php
272
routes/web.php
@@ -10,6 +10,7 @@ use App\Http\Controllers\Admin\AdminInvoiceController;
|
||||
use App\Http\Controllers\Admin\AdminCustomerController;
|
||||
use App\Http\Controllers\Admin\AdminAccountController;
|
||||
use App\Http\Controllers\Admin\AdminReportController;
|
||||
use App\Http\Controllers\Admin\AdminStaffController;
|
||||
|
||||
// ---------------------------
|
||||
// Public Front Page
|
||||
@@ -21,19 +22,11 @@ Route::get('/', function () {
|
||||
// ---------------------------
|
||||
// ADMIN LOGIN ROUTES
|
||||
// ---------------------------
|
||||
// login routes (public)
|
||||
Route::prefix('admin')->group(function () {
|
||||
|
||||
// MUST have route name "login" for session redirect
|
||||
Route::get('/login', [AdminAuthController::class, 'showLoginForm'])
|
||||
->name('admin.login');
|
||||
|
||||
Route::post('/login', [AdminAuthController::class, 'login'])
|
||||
->name('admin.login.submit');
|
||||
|
||||
Route::post('/logout', [AdminAuthController::class, 'logout'])
|
||||
->name('admin.logout');
|
||||
|
||||
|
||||
Route::get('/login', [AdminAuthController::class, 'showLoginForm'])->name('admin.login');
|
||||
Route::post('/login', [AdminAuthController::class, 'login'])->name('admin.login.submit');
|
||||
Route::post('/logout', [AdminAuthController::class, 'logout'])->name('admin.logout');
|
||||
});
|
||||
|
||||
|
||||
@@ -66,171 +59,218 @@ Route::prefix('admin')
|
||||
// ---------------------------
|
||||
// USER REQUESTS
|
||||
// ---------------------------
|
||||
Route::get('/requests', [UserRequestController::class, 'index'])
|
||||
->name('admin.requests');
|
||||
Route::get('/requests', [UserRequestController::class, 'index'])
|
||||
->name('admin.requests');
|
||||
|
||||
Route::get('/requests/approve/{id}', [UserRequestController::class, 'approve'])
|
||||
->name('admin.requests.approve');
|
||||
Route::get('/requests/approve/{id}', [UserRequestController::class, 'approve'])
|
||||
->name('admin.requests.approve');
|
||||
|
||||
Route::get('/requests/reject/{id}', [UserRequestController::class, 'reject'])
|
||||
->name('admin.requests.reject');
|
||||
|
||||
// PROFILE UPDATE REQUESTS
|
||||
Route::get('/profile-update-requests',
|
||||
[UserRequestController::class, 'profileUpdateRequests']
|
||||
)->name('admin.profile.requests');
|
||||
|
||||
Route::get('/profile-update/approve/{id}',
|
||||
[UserRequestController::class, 'approveProfileUpdate']
|
||||
)->name('admin.profile.approve');
|
||||
|
||||
Route::get('/profile-update/reject/{id}',
|
||||
[UserRequestController::class, 'rejectProfileUpdate']
|
||||
)->name('admin.profile.reject');
|
||||
|
||||
Route::get('/requests/reject/{id}', [UserRequestController::class, 'reject'])
|
||||
->name('admin.requests.reject');
|
||||
|
||||
|
||||
// ---------------------------
|
||||
// MARK LIST
|
||||
// ---------------------------
|
||||
Route::get('/mark-list', [AdminMarkListController::class, 'index'])
|
||||
->name('admin.marklist.index');
|
||||
Route::get('/mark-list', [AdminMarkListController::class, 'index'])
|
||||
->name('admin.marklist.index');
|
||||
|
||||
Route::get('/mark-list/status/{id}', [AdminMarkListController::class, 'toggleStatus'])
|
||||
->name('admin.marklist.toggle');
|
||||
Route::get('/mark-list/status/{id}', [AdminMarkListController::class, 'toggleStatus'])
|
||||
->name('admin.marklist.toggle');
|
||||
|
||||
|
||||
// ---------------------------
|
||||
// ORDERS
|
||||
// ---------------------------
|
||||
Route::get('/orders', [AdminOrderController::class, 'orderShow'])
|
||||
->name('admin.orders');
|
||||
Route::get('/orders', [AdminOrderController::class, 'orderShow'])
|
||||
->name('admin.orders');
|
||||
|
||||
|
||||
Route::get('/orders/list', [AdminOrderController::class, 'index'])
|
||||
->name('admin.orders.index');
|
||||
Route::get('/orders/list', [AdminOrderController::class, 'index'])
|
||||
->name('admin.orders.index');
|
||||
|
||||
Route::get('/orders/{id}', [AdminOrderController::class, 'show'])
|
||||
->name('admin.orders.show');
|
||||
Route::get('/orders/{id}', [AdminOrderController::class, 'show'])
|
||||
->name('admin.orders.show');
|
||||
|
||||
Route::post('/orders/temp/add', [AdminOrderController::class, 'addTempItem'])
|
||||
->name('admin.orders.temp.add');
|
||||
Route::post('/orders/temp/add', [AdminOrderController::class, 'addTempItem'])
|
||||
->name('admin.orders.temp.add');
|
||||
|
||||
Route::post('/orders/temp/delete', [AdminOrderController::class, 'deleteTempItem'])
|
||||
->name('admin.orders.temp.delete');
|
||||
Route::post('/orders/temp/delete', [AdminOrderController::class, 'deleteTempItem'])
|
||||
->name('admin.orders.temp.delete');
|
||||
|
||||
Route::post('/orders/temp/reset', [AdminOrderController::class, 'resetTemp'])
|
||||
->name('admin.orders.temp.reset');
|
||||
Route::post('/orders/temp/reset', [AdminOrderController::class, 'resetTemp'])
|
||||
->name('admin.orders.temp.reset');
|
||||
|
||||
Route::post('/orders/finish', [AdminOrderController::class, 'finishOrder'])
|
||||
->name('admin.orders.finish');
|
||||
|
||||
Route::get('/orders/view/{id}', [AdminOrderController::class, 'popup'])
|
||||
->name('admin.orders.popup');
|
||||
Route::post('/orders/finish', [AdminOrderController::class, 'finishOrder'])
|
||||
->name('admin.orders.finish');
|
||||
|
||||
Route::get('/orders/view/{id}', [AdminOrderController::class, 'popup'])
|
||||
->name('admin.orders.popup');
|
||||
|
||||
// ---------------------------
|
||||
// SHIPMENTS
|
||||
// ORDERS (FIXED ROUTES)
|
||||
// ---------------------------
|
||||
Route::get('/shipments', [ShipmentController::class, 'index'])
|
||||
->name('admin.shipments');
|
||||
// Add item to order
|
||||
Route::post('/orders/{order}/item', [AdminOrderController::class, 'addItem'])
|
||||
->name('admin.orders.addItem');
|
||||
// Delete item from order
|
||||
Route::delete('/orders/item/{id}', [AdminOrderController::class, 'deleteItem'])
|
||||
->name('admin.orders.deleteItem');
|
||||
// Restore deleted item
|
||||
Route::post('/orders/item/{id}/restore', [AdminOrderController::class, 'restoreItem'])
|
||||
->name('admin.orders.restoreItem');
|
||||
// Update main order fields
|
||||
Route::put('/admin/orders/item/update/{id}', [AdminOrderController::class, 'updateItem'])
|
||||
->name('admin.orders.updateItem');
|
||||
// Delete full order
|
||||
Route::delete('/orders/{id}/delete', [AdminOrderController::class, 'destroy'])
|
||||
->name('admin.orders.destroy');
|
||||
|
||||
Route::post('/shipments/store', [ShipmentController::class, 'store'])
|
||||
->name('admin.shipments.store');
|
||||
// ---------------------------
|
||||
// SHIPMENTS (FIXED ROUTES)
|
||||
// ---------------------------
|
||||
Route::get('/shipments', [ShipmentController::class, 'index'])
|
||||
->name('admin.shipments');
|
||||
|
||||
Route::post('/shipments/update-status', [ShipmentController::class, 'updateStatus'])
|
||||
->name('admin.shipments.updateStatus');
|
||||
Route::post('/shipments', [ShipmentController::class, 'store'])
|
||||
->name('admin.shipments.store');
|
||||
|
||||
Route::get('/shipments/{id}', [ShipmentController::class, 'show'])
|
||||
->name('admin.shipments.show');
|
||||
Route::post('/shipments/update-status', [ShipmentController::class, 'updateStatus'])
|
||||
->name('admin.shipments.updateStatus');
|
||||
|
||||
// Get shipment orders for modal (AJAX)
|
||||
Route::get('/shipments/{id}/orders', [ShipmentController::class, 'getShipmentOrders'])
|
||||
->name('admin.shipments.orders');
|
||||
|
||||
// Get shipment details for edit (AJAX)
|
||||
Route::get('/shipments/{id}', [ShipmentController::class, 'show'])
|
||||
->name('admin.shipments.show');
|
||||
|
||||
// Shipment Update
|
||||
Route::put('/shipments/{id}', [ShipmentController::class, 'update'])
|
||||
->name('admin.shipments.update');
|
||||
|
||||
// Shipment Delete
|
||||
Route::delete('/shipments/{id}', [ShipmentController::class, 'destroy'])
|
||||
->name('admin.shipments.destroy');
|
||||
|
||||
Route::get('/shipment/dummy/{id}', [ShipmentController::class, 'dummy'])
|
||||
->name('admin.shipments.dummy');
|
||||
|
||||
|
||||
// ---------------------------
|
||||
// INVOICES
|
||||
// ---------------------------
|
||||
Route::get('/invoices', [AdminInvoiceController::class, 'index'])
|
||||
->name('admin.invoices.index');
|
||||
Route::get('/invoices', [AdminInvoiceController::class, 'index'])
|
||||
->name('admin.invoices.index');
|
||||
|
||||
Route::get('/invoices/{id}/popup', [AdminInvoiceController::class, 'popup'])
|
||||
->name('admin.invoices.popup');
|
||||
Route::get('/invoices/{id}/popup', [AdminInvoiceController::class, 'popup'])
|
||||
->name('admin.invoices.popup');
|
||||
|
||||
Route::get('/invoices/{id}/edit', [AdminInvoiceController::class, 'edit'])
|
||||
->name('admin.invoices.edit');
|
||||
Route::get('/invoices/{id}/edit', [AdminInvoiceController::class, 'edit'])
|
||||
->name('admin.invoices.edit');
|
||||
|
||||
Route::post('/invoices/{id}/update', [AdminInvoiceController::class, 'update'])
|
||||
->name('admin.invoices.update');
|
||||
Route::post('/invoices/{id}/update', [AdminInvoiceController::class, 'update'])
|
||||
->name('admin.invoices.update');
|
||||
|
||||
Route::post('/invoices/{invoice}/installments', [AdminInvoiceController::class, 'storeInstallment'])
|
||||
Route::post('/invoices/{invoice}/installments', [AdminInvoiceController::class, 'storeInstallment'])
|
||||
->name('admin.invoice.installment.store');
|
||||
|
||||
Route::post('/invoices/{id}/installment', [AdminInvoiceController::class, 'storeInstallment'])
|
||||
->name('admin.invoice.installment.store');
|
||||
|
||||
Route::post('/invoices/{id}/installment', [AdminInvoiceController::class, 'storeInstallment'])
|
||||
->name('admin.invoice.installment.store');
|
||||
|
||||
|
||||
Route::delete('/installment/{id}', [AdminInvoiceController::class, 'deleteInstallment'])
|
||||
->name('admin.invoice.installment.delete');
|
||||
|
||||
|
||||
|
||||
|
||||
//Add New Invoice
|
||||
Route::get('/admin/invoices/create', [InvoiceController::class, 'create'])->name('admin.invoices.create');
|
||||
|
||||
//Add New Invoice
|
||||
Route::get('/admin/invoices/create', [InvoiceController::class, 'create'])->name('admin.invoices.create');
|
||||
|
||||
|
||||
// ---------------------------
|
||||
// CUSTOMERS
|
||||
// ---------------------------
|
||||
Route::get('/customers', [AdminCustomerController::class, 'index'])
|
||||
->name('admin.customers.index');
|
||||
Route::get('/customers', [AdminCustomerController::class, 'index'])
|
||||
->name('admin.customers.index');
|
||||
|
||||
Route::get('/customers/add', [AdminCustomerController::class, 'create'])
|
||||
->name('admin.customers.add');
|
||||
Route::get('/customers/add', [AdminCustomerController::class, 'create'])
|
||||
->name('admin.customers.add');
|
||||
|
||||
Route::post('/customers/store', [AdminCustomerController::class, 'store'])
|
||||
->name('admin.customers.store');
|
||||
Route::post('/customers/store', [AdminCustomerController::class, 'store'])
|
||||
->name('admin.customers.store');
|
||||
|
||||
Route::get('/customers/{id}/view', [AdminCustomerController::class, 'view'])
|
||||
->name('admin.customers.view');
|
||||
Route::get('/customers/{id}/view', [AdminCustomerController::class, 'view'])
|
||||
->name('admin.customers.view');
|
||||
|
||||
Route::post('/customers/{id}/status', [AdminCustomerController::class, 'toggleStatus'])
|
||||
->name('admin.customers.status');
|
||||
});
|
||||
Route::post('/customers/{id}/status', [AdminCustomerController::class, 'toggleStatus'])
|
||||
->name('admin.customers.status');
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// ADMIN ACCOUNT (AJAX) ROUTES
|
||||
// ==========================================
|
||||
Route::prefix('admin/account')
|
||||
->middleware('auth:admin')
|
||||
->name('admin.account.')
|
||||
->group(function () {
|
||||
Route::prefix('admin/account')
|
||||
->middleware('auth:admin')
|
||||
->name('admin.account.')
|
||||
->group(function () {
|
||||
|
||||
Route::get('/dashboard', [AdminAccountController::class, 'getDashboardData'])
|
||||
->name('dashboard');
|
||||
Route::get('/dashboard', [AdminAccountController::class, 'getDashboardData'])
|
||||
->name('dashboard');
|
||||
|
||||
Route::get('/available-orders', [AdminAccountController::class, 'getAvailableOrders'])
|
||||
->name('orders.available');
|
||||
Route::get('/available-orders', [AdminAccountController::class, 'getAvailableOrders'])
|
||||
->name('orders.available');
|
||||
|
||||
Route::post('/create-order', [AdminAccountController::class, 'accountCreateOrder'])
|
||||
->name('create');
|
||||
Route::post('/create-order', [AdminAccountController::class, 'accountCreateOrder'])
|
||||
->name('create');
|
||||
|
||||
Route::post('/toggle-payment', [AdminAccountController::class, 'togglePayment'])
|
||||
->name('toggle');
|
||||
Route::post('/toggle-payment', [AdminAccountController::class, 'togglePayment'])
|
||||
->name('toggle');
|
||||
|
||||
Route::post('/installment/create', [AdminAccountController::class, 'addInstallment'])
|
||||
->name('installment.create');
|
||||
Route::post('/installment/create', [AdminAccountController::class, 'addInstallment'])
|
||||
->name('installment.create');
|
||||
|
||||
Route::post('/installment/update-status', [AdminAccountController::class, 'updateInstallmentStatus'])
|
||||
->name('installment.update');
|
||||
Route::post('/installment/update-status', [AdminAccountController::class, 'updateInstallmentStatus'])
|
||||
->name('installment.update');
|
||||
|
||||
Route::get('/entry/{entry_no}', [AdminAccountController::class, 'getEntryDetails'])
|
||||
->name('entry.details');
|
||||
Route::get('/entry/{entry_no}', [AdminAccountController::class, 'getEntryDetails'])
|
||||
->name('entry.details');
|
||||
|
||||
// ⬇⬇ NEW ROUTES FOR EDIT + DELETE ⬇⬇
|
||||
Route::post('/update-entry', [AdminAccountController::class, 'updateEntry'])
|
||||
->name('update.entry');
|
||||
// ⬇⬇ NEW ROUTES FOR EDIT + DELETE ⬇⬇
|
||||
Route::post('/update-entry', [AdminAccountController::class, 'updateEntry'])
|
||||
->name('update.entry');
|
||||
|
||||
Route::post('/delete-entry', [AdminAccountController::class, 'deleteEntry'])
|
||||
->name('delete.entry');
|
||||
Route::post('/delete-entry', [AdminAccountController::class, 'deleteEntry'])
|
||||
->name('delete.entry');
|
||||
|
||||
|
||||
// ===== Associated Orders Routes (EDIT MODAL साठी) =====
|
||||
Route::post('/add-orders-to-entry', [AdminAccountController::class, 'addOrdersToEntry'])
|
||||
->name('add.orders.to.entry');
|
||||
// ===== Associated Orders Routes (EDIT MODAL साठी) =====
|
||||
Route::post('/add-orders-to-entry', [AdminAccountController::class, 'addOrdersToEntry'])
|
||||
->name('add.orders.to.entry');
|
||||
|
||||
Route::get('/entry-orders/{entry_no}', [AdminAccountController::class, 'getEntryOrders'])
|
||||
->name('entry.orders');
|
||||
Route::get('/entry-orders/{entry_no}', [AdminAccountController::class, 'getEntryOrders'])
|
||||
->name('entry.orders');
|
||||
|
||||
Route::post('/remove-order-from-entry', [AdminAccountController::class, 'removeOrderFromEntry'])
|
||||
->name('remove.order.from.entry');
|
||||
Route::post('/remove-order-from-entry', [AdminAccountController::class, 'removeOrderFromEntry'])
|
||||
->name('remove.order.from.entry');
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -238,11 +278,27 @@ Route::prefix('admin')
|
||||
// ---------------------------
|
||||
// REPORTS DOWNLOAD ROUTES
|
||||
// ---------------------------
|
||||
Route::get('/admin/orders/download/pdf', [OrderController::class, 'downloadPdf'])->name('admin.orders.download.pdf');
|
||||
Route::get('/admin/orders/download/excel', [OrderController::class, 'downloadExcel'])->name('admin.orders.download.excel');
|
||||
Route::get('/admin/orders/download/pdf', [AdminOrderController::class, 'downloadPdf'])
|
||||
->name('admin.orders.download.pdf');
|
||||
|
||||
Route::get('/admin/orders/download/excel', [AdminOrderController::class, 'downloadExcel'])
|
||||
->name('admin.orders.download.excel');
|
||||
|
||||
|
||||
Route::prefix('admin/account')->middleware('auth:admin')->name('admin.account.')->group(function () {
|
||||
Route::post('/toggle-payment', [AdminAccountController::class, 'togglePayment'])->name('toggle');
|
||||
});
|
||||
|
||||
//---------------------------
|
||||
//Edit Button Route
|
||||
//---------------------------
|
||||
// protected admin routes
|
||||
Route::middleware(['auth:admin'])
|
||||
->prefix('admin')
|
||||
->name('admin.')
|
||||
->group(function () {
|
||||
|
||||
|
||||
// staff resource
|
||||
Route::resource('staff', AdminStaffController::class);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user