<?php
// routes/web.php

// Landing Page (Public)
Router::get('/', ['HomeController', 'landing']);
Router::get('/register', ['HomeController', 'register']);
Router::post('/register', ['HomeController', 'submitRegister']);
Router::get('/register/pending', ['HomeController', 'pending']);
Router::post('/contact/submit', ['HomeController', 'submitContact']);

// Auth
Router::get('/login', ['AuthController', 'showLogin']);
Router::post('/login', ['AuthController', 'login']);
Router::get('/logout', ['AuthController', 'logout']);
Router::get('/expired', function() { require 'app/Views/auth/expired.php'; });
Router::get('/dashboard', ['DashboardController', 'index']);
Router::get('/superadmin/dashboard', ['DashboardController', 'index']);
Router::get('/admin/dashboard', ['DashboardController', 'index']);

// Admin Profile
Router::post('/admin/profile/update', ['AdminController', 'updateProfile']);
Router::get('/admin/settings', ['AdminController', 'settings']);
Router::post('/admin/settings/update', ['AdminController', 'updateSettings']);
Router::post('/admin/settings/check-slug', ['AdminController', 'checkSlug']);

// Super Admin Routes
// Restaurants
Router::get('/superadmin/restaurants', ['RestaurantController', 'index']);
Router::get('/superadmin/restaurants/create', ['RestaurantController', 'create']);
Router::post('/superadmin/restaurants/store', ['RestaurantController', 'store']);
Router::get('/superadmin/restaurants/edit', ['RestaurantController', 'edit']);
Router::post('/superadmin/restaurants/update', ['RestaurantController', 'update']);
Router::post('/superadmin/restaurants/delete', ['RestaurantController', 'delete']);
Router::get('/superadmin/restaurants/billing', ['RestaurantController', 'billing']);
// Packages
Router::get('/superadmin/packages', ['PackageController', 'index']);
Router::post('/superadmin/packages/store', ['PackageController', 'store']);
Router::get('/superadmin/packages/edit', ['PackageController', 'edit']);
Router::post('/superadmin/packages/update', ['PackageController', 'update']);
// Coupons
Router::get('/superadmin/coupons', ['CouponController', 'index']);
Router::post('/superadmin/coupons/store', ['CouponController', 'store']);
Router::post('/superadmin/coupons/toggle', ['CouponController', 'toggle']);
Router::post('/superadmin/coupons/delete', ['CouponController', 'delete']);

// Analytics
Router::get('/superadmin/analytics', ['SuperAdminController', 'analytics']);
Router::get('/superadmin/analytics/api', ['SuperAdminController', 'analyticsApi']);

// Super Admin Profile
Router::post('/superadmin/profile/update', ['SuperAdminController', 'updateProfile']);

// System Admins
Router::get('/superadmin/admins', ['SuperAdminController', 'admins']);
Router::post('/superadmin/admins/store', ['SuperAdminController', 'storeAdmin']);

// Subscriptions
Router::get('/superadmin/subscriptions', ['SuperAdminController', 'subscriptions']);
Router::post('/superadmin/subscriptions/renew', ['SuperAdminController', 'renewSubscription']);
Router::post('/superadmin/subscriptions/extend', ['SuperAdminController', 'extendSubscription']);
Router::post('/superadmin/subscriptions/assign', ['SuperAdminController', 'assignSubscription']);
Router::post('/superadmin/subscriptions/approve', ['SuperAdminController', 'approveSubscription']);
Router::post('/superadmin/subscriptions/reject', ['SuperAdminController', 'rejectSubscription']);
Router::get('/superadmin/sms', ['SuperAdminController', 'sms']);
Router::post('/superadmin/sms/send', ['SuperAdminController', 'sendPromotionalSMS']);
Router::get('/superadmin/settings', ['SuperAdminController', 'settings']);
Router::post('/superadmin/settings/update', ['SuperAdminController', 'updateSettings']);
Router::post('/superadmin/settings/landing', ['SuperAdminController', 'updateLandingSettings']);

// Restaurant Admin Routes
// Floors & Tables
Router::get('/admin/floors', ['FloorController', 'index']);
Router::post('/admin/floors/store', ['FloorController', 'store']);
Router::post('/admin/floors/delete', ['FloorController', 'deleteFloor']);
Router::post('/admin/tables/store', ['FloorController', 'storeTable']);
Router::post('/admin/tables/delete', ['FloorController', 'deleteTable']);

// Categories
Router::get('/admin/categories', ['CategoryController', 'index']);
Router::post('/admin/categories/store', ['CategoryController', 'store']);
Router::post('/admin/categories/update', ['CategoryController', 'update']);
Router::post('/admin/categories/delete', ['CategoryController', 'delete']);

// Products
Router::get('/admin/products', ['ProductController', 'index']);
Router::get('/admin/products/create', ['ProductController', 'create']);
Router::post('/admin/products/store', ['ProductController', 'store']);
Router::get('/admin/products/edit', ['ProductController', 'edit']);
Router::post('/admin/products/update', ['ProductController', 'update']);
Router::post('/admin/products/delete', ['ProductController', 'delete']);

// Staff
Router::get('/admin/staff', ['StaffController', 'index']);
Router::post('/admin/staff/store', ['StaffController', 'store']);
Router::get('/admin/staff/edit', ['StaffController', 'edit']);
Router::post('/admin/staff/update', ['StaffController', 'update']);
Router::post('/admin/staff/delete', ['StaffController', 'delete']);

// POS / Cashier
Router::get('/pos', ['PosController', 'index']);
Router::post('/pos/session/open', ['PosController', 'openSession']);
Router::post('/pos/session/close', ['PosController', 'closeSession']);
Router::get('/pos/api/data', ['PosController', 'getPosData']); 
Router::post('/pos/api/order', ['PosController', 'placeOrder']);
Router::post('/pos/api/pay', ['PosController', 'processPayment']);
Router::post('/pos/api/accept', ['PosController', 'acceptOrder']);
Router::post('/pos/api/add-items', ['PosController', 'addItems']);
Router::post('/pos/api/print-kot', ['PosController', 'printKot']);
Router::post('/pos/api/void', ['PosController', 'voidOrder']);
Router::post('/pos/api/assign-coupon', ['PosController', 'assignCoupon']);

// Waiter
Router::get('/waiter', ['WaiterController', 'index']);
Router::get('/waiter/api/data', ['WaiterController', 'getData']);
Router::post('/waiter/api/order', ['WaiterController', 'placeOrder']);

// QR Ordering (Public - No Auth Required)
Router::get('/menu', ['QrController', 'menu']);
Router::post('/menu/lookup', ['QrController', 'lookupCode']);
Router::post('/qr/order', ['QrController', 'placeOrder']);

// QR Admin Management
Router::get('/admin/qr', ['QrController', 'manage']);

// Subscription & Billing Management
Router::get('/admin/subscription', ['SubscriptionController', 'index']);
Router::post('/admin/subscription/purchase', ['SubscriptionController', 'purchase']);
Router::get('/admin/subscription/payment', ['SubscriptionController', 'payment']);
Router::post('/admin/subscription/payment/submit', ['SubscriptionController', 'submitPayment']);
Router::get('/admin/subscription/invoice', ['SubscriptionController', 'invoice']);
Router::get('/admin/subscription/invoices', ['SubscriptionController', 'allInvoices']);
Router::post('/admin/subscription/payment/validate-coupon', ['SubscriptionController', 'validateCoupon']);

// Restaurant Coupons Management
Router::get('/admin/coupons', ['CouponController', 'adminIndex']);
Router::post('/admin/coupons/store', ['CouponController', 'adminStore']);
Router::post('/admin/coupons/toggle', ['CouponController', 'adminToggle']);
Router::post('/admin/coupons/delete', ['CouponController', 'adminDelete']);

// Restaurant Feedback Management
Router::get('/admin/feedback', ['AdminController', 'feedback']);
Router::post('/admin/feedback/delete', ['AdminController', 'deleteFeedback']);

// Guest Feedback Submission (Public)
Router::post('/menu/feedback', ['QrController', 'submitFeedback']);


// Admin Reports
Router::get('/admin/reports', ['ReportController', 'index']);
Router::get('/admin/reports/download-customers', ['ReportController', 'downloadCustomers']);
Router::get('/admin/reports/session-orders', ['ReportController', 'getSessionOrdersJson']);
Router::get('/admin/reports/cashier-orders', ['ReportController', 'getCashierOrdersJson']);
Router::post('/admin/reports/expenses/store', ['ReportController', 'storeExpense']);
Router::post('/admin/reports/expenses/delete', ['ReportController', 'deleteExpense']);
Router::post('/admin/reports/voids/delete', ['ReportController', 'deleteVoidOrder']);
Router::post('/admin/reports/voids/delete-all', ['ReportController', 'deleteAllVoidOrders']);
// Legacy aliases
Router::get('/reports', ['ReportController', 'index']);
Router::post('/reports/expenses/store', ['ReportController', 'storeExpense']);
Router::post('/reports/expenses/delete', ['ReportController', 'deleteExpense']);

// Module 6: Kitchen Display System (KDS)
Router::get('/kitchen', ['KitchenController', 'index']);
Router::get('/kitchen/api/queue', ['KitchenController', 'getQueue']);
Router::post('/kitchen/api/status', ['KitchenController', 'updateStatus']);

// Module 7: Inventory Management
// Admin-accessed inventory (uses admin layout)
Router::get('/admin/inventory', ['InventoryController', 'index']);
Router::post('/admin/inventory/store', ['InventoryController', 'store']);
Router::post('/admin/inventory/stock-in', ['InventoryController', 'stockIn']);
Router::post('/admin/inventory/stock-out', ['InventoryController', 'stockOut']);
Router::post('/admin/inventory/adjust', ['InventoryController', 'adjust']);
Router::post('/admin/inventory/waste', ['InventoryController', 'waste']);
Router::post('/admin/inventory/update', ['InventoryController', 'update']);
Router::post('/admin/inventory/delete', ['InventoryController', 'delete']);
Router::get('/admin/inventory/logs', ['InventoryController', 'logs']);

Router::get('/admin/inventory/categories', ['InventoryController', 'categories']);
Router::post('/admin/inventory/categories/store', ['InventoryController', 'categoryStore']);
Router::post('/admin/inventory/categories/update', ['InventoryController', 'categoryUpdate']);
Router::post('/admin/inventory/categories/delete', ['InventoryController', 'categoryDelete']);

Router::get('/admin/inventory/suppliers', ['InventoryController', 'suppliers']);
Router::post('/admin/inventory/suppliers/store', ['InventoryController', 'supplierStore']);
Router::post('/admin/inventory/suppliers/update', ['InventoryController', 'supplierUpdate']);
Router::post('/admin/inventory/suppliers/delete', ['InventoryController', 'supplierDelete']);

Router::get('/admin/inventory/reports', ['InventoryController', 'reports']);
Router::get('/admin/inventory/reports/export', ['InventoryController', 'reportsExport']);

// Inventory manager role (uses inventory layout)
Router::get('/inventory', ['InventoryController', 'index']);
Router::post('/inventory/store', ['InventoryController', 'store']);
Router::post('/inventory/stock-in', ['InventoryController', 'stockIn']);
Router::post('/inventory/stock-out', ['InventoryController', 'stockOut']);
Router::post('/inventory/adjust', ['InventoryController', 'adjust']);
Router::post('/inventory/waste', ['InventoryController', 'waste']);
Router::post('/inventory/update', ['InventoryController', 'update']);
Router::post('/inventory/delete', ['InventoryController', 'delete']);
Router::get('/inventory/logs', ['InventoryController', 'logs']);

Router::get('/inventory/categories', ['InventoryController', 'categories']);
Router::post('/inventory/categories/store', ['InventoryController', 'categoryStore']);
Router::post('/inventory/categories/update', ['InventoryController', 'categoryUpdate']);
Router::post('/inventory/categories/delete', ['InventoryController', 'categoryDelete']);

Router::get('/inventory/suppliers', ['InventoryController', 'suppliers']);
Router::post('/inventory/suppliers/store', ['InventoryController', 'supplierStore']);
Router::post('/inventory/suppliers/update', ['InventoryController', 'supplierUpdate']);
Router::post('/inventory/suppliers/delete', ['InventoryController', 'supplierDelete']);

Router::get('/inventory/reports', ['InventoryController', 'reports']);
Router::get('/inventory/reports/export', ['InventoryController', 'reportsExport']);

// Module 8: HR / Staff Management
// Admin-accessed HR (uses admin layout)
Router::get('/admin/hr',                    ['HrController', 'index']);
Router::get('/admin/hr/attendance',         ['HrController', 'attendance']);
Router::post('/admin/hr/attendance/mark',   ['HrController', 'markAttendance']);
Router::get('/admin/hr/payroll',            ['HrController', 'payroll']);
Router::post('/admin/hr/payroll/generate',  ['HrController', 'generatePayroll']);
Router::post('/admin/hr/payroll/update',    ['HrController', 'updatePayroll']);
Router::post('/admin/hr/payroll/pay',       ['HrController', 'markPaid']);
Router::post('/admin/hr/payroll/pay-all',   ['HrController', 'payAll']);
Router::post('/admin/hr/payroll/delete',    ['HrController', 'deletePayroll']);
Router::post('/admin/hr/payroll/unpay',     ['HrController', 'markDraft']);
Router::get('/admin/hr/payslip',            ['HrController', 'payslip']);
Router::post('/admin/hr/staff/store',       ['HrController', 'staffStore']);
Router::post('/admin/hr/staff/add',         ['HrController', 'addStaff']);
Router::post('/admin/hr/shift/store',       ['HrController', 'storeShift']);
Router::post('/admin/hr/shift/delete',      ['HrController', 'deleteShift']);
Router::get('/admin/hr/payroll',            ['HrController', 'payrollPage']);

// HR Manager role routes (uses hr layout)
Router::get('/hr',                    ['HrController', 'index']);
Router::get('/hr/attendance',         ['HrController', 'attendance']);
Router::post('/hr/attendance/mark',   ['HrController', 'markAttendance']);
Router::get('/hr/payroll',            ['HrController', 'payrollPage']);
Router::post('/hr/payroll/generate',  ['HrController', 'generatePayroll']);
Router::post('/hr/payroll/update',    ['HrController', 'updatePayroll']);
Router::post('/hr/payroll/pay',       ['HrController', 'markPaid']);
Router::post('/hr/payroll/pay-all',   ['HrController', 'payAll']);
Router::post('/hr/payroll/delete',    ['HrController', 'deletePayroll']);
Router::post('/hr/payroll/unpay',     ['HrController', 'markDraft']);
Router::get('/hr/payslip',            ['HrController', 'payslip']);
Router::post('/hr/staff/store',       ['HrController', 'staffStore']);
Router::post('/hr/staff/add',         ['HrController', 'addStaff']);
Router::post('/hr/shift/store',       ['HrController', 'storeShift']);
Router::post('/hr/shift/delete',      ['HrController', 'deleteShift']);

// Public Clock-In/Out Routes
Router::get('/clock',                 ['HrController', 'showClockPage']);
Router::post('/clock/submit',          ['HrController', 'submitClock']);

// Cashier Geofencing Configuration
Router::post('/admin/hr/cashier-location/store', ['HrController', 'storeCashierLocation']);
Router::post('/hr/cashier-location/store',       ['HrController', 'storeCashierLocation']);
Router::get('/admin/hr/cashier/qr-card',         ['HrController', 'showQrCard']);
Router::get('/hr/cashier/qr-card',               ['HrController', 'showQrCard']);

// Super Admin – Registrations, Contacts, Reviews
Router::get('/superadmin/registrations',            ['SuperAdminController', 'registrations']);
Router::post('/superadmin/registrations/approve',   ['SuperAdminController', 'approveRegistration']);
Router::post('/superadmin/registrations/callback',  ['SuperAdminController', 'callbackRegistration']);
Router::post('/superadmin/registrations/delete',    ['SuperAdminController', 'deleteRegistration']);
Router::get('/superadmin/contacts',                 ['SuperAdminController', 'contacts']);
Router::post('/superadmin/contacts/delete',         ['SuperAdminController', 'deleteContact']);
Router::get('/superadmin/reviews',                  ['SuperAdminController', 'reviews']);
Router::post('/superadmin/reviews/store',           ['SuperAdminController', 'storeReview']);
Router::post('/superadmin/reviews/update',          ['SuperAdminController', 'updateReview']);
Router::post('/superadmin/reviews/delete',          ['SuperAdminController', 'deleteReview']);
