<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\CashierController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\BrandController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\ExpenseController;
use App\Http\Controllers\IncomeController;
use App\Http\Controllers\StockController;
use App\Http\Controllers\SampleController;
use App\Http\Controllers\TrainingController;
use App\Http\Controllers\TestingController;
use App\Http\Controllers\HasilController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\PeringkatController;



/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', [LoginController::class, 'index'])->name('loginpage');
Route::post('/login', [LoginController::class, 'login'])->name('login');
Route::post('/logout', [LoginController::class, 'logout'])->name('logout');

// Group untuk route yang membutuhkan login
Route::middleware(['auth'])->group(function () {

    // Dashboard
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

    // Kasir
    Route::get('/cashier', [CashierController::class, 'index'])->name('cashier');
    Route::post('/cashier/store', [CashierController::class, 'store'])->name('cashier.store');

    // Penjualan
    Route::get('/income', [IncomeController::class, 'index'])->name('income');
    Route::get('/income/export', [IncomeController::class, 'export'])->name('income.export');

    // Pengeluaran
    Route::get('/expense', [ExpenseController::class, 'index'])->name('expense');
    Route::post('/storeexpense', [ExpenseController::class, 'store'])->name('expense.store');
    Route::put('/expense/update/{id}', [ExpenseController::class, 'update'])->name('expense.update');
    Route::delete('/expense/delete/{id}', [ExpenseController::class, 'destroy'])->name('expense.delete');

    // Manajemen Pengguna
    Route::get('/user', [UserController::class, 'index'])->name('user');
    Route::post('/store',[UserController::class, 'store'])->name('store');
    Route::put('/user/update/{id}', [UserController::class, 'update'])->name('user.update');
    Route::delete('/user/delete/{id}', [UserController::class, 'destroy'])->name('user.delete');

    // Manajemen Produk
    Route::get('/product', [ProductController::class, 'index'])->name('product');
    Route::post('/storeproduct',[ProductController::class, 'store'])->name('product.store');
    Route::put('/product/update/{id}', [ProductController::class, 'update'])->name('product.update');
    Route::delete('/product/delete/{id}', [ProductController::class, 'destroy'])->name('product.delete');

    // Kategori, Brand, Stok, Sampel, Training, Testing, Hasil, Peringkat
    Route::get('/category', [CategoryController::class, 'index'])->name('category');
    Route::post('/storecategory', [CategoryController::class, 'store'])->name('category.store');
    Route::put('/category/update/{id}', [CategoryController::class, 'update'])->name('category.update');
    Route::delete('/category/delete/{id}', [CategoryController::class, 'destroy'])->name('category.delete');

    Route::get('/brand', [BrandController::class, 'index'])->name('brand');
    Route::post('/storebrand',[BrandController::class, 'store'])->name('brand.store');
    Route::put('/brand/update/{id}', [BrandController::class, 'update'])->name('brand.update');
    Route::delete('/brand/delete/{id}', [BrandController::class, 'destroy'])->name('brand.delete');

    Route::get('/stock', [StockController::class, 'index'])->name('stock');
    Route::put('/stock/update/{id}', [StockController::class, 'update'])->name('stock.update');

    Route::get('/sample', [SampleController::class, 'index'])->name('sample.index');
    Route::post('/sample/generate', [SampleController::class, 'generate'])->name('sample.generate');
    Route::post('/sample/reset', [SampleController::class, 'reset'])->name('sample.reset');

    Route::get('/training', [TrainingController::class, 'index'])->name('training.index');
    Route::post('/training/generate', [TrainingController::class, 'generate'])->name('training.generate');
    Route::post('/training/reset', [TrainingController::class, 'reset'])->name('training.reset');

    Route::get('/testing', [TestingController::class, 'index'])->name('testing.index');
    Route::post('/testing/generate', [TestingController::class, 'generate'])->name('testing.generate');
    Route::post('/testing/reset', [TestingController::class, 'reset'])->name('testing.reset');

    Route::get('/hasil', [HasilController::class, 'index'])->name('hasil.index');
    Route::post('/hasil/proses', [HasilController::class, 'proses'])->name('hasil.proses');
    Route::post('/hasil/reset', [HasilController::class, 'reset'])->name('hasil.reset');

    Route::get('/peringkat', [PeringkatController::class, 'index'])->name('peringkat.index');
    Route::post('/peringkat/proses', [PeringkatController::class, 'proses'])->name('peringkat.proses');
    Route::post('/peringkat/reset', [PeringkatController::class, 'reset'])->name('peringkat.reset');


   Route::get('/income/export/excel', [IncomeController::class, 'exportExcel'])->name('income.export.excel');
   Route::get('/income/export/pdf', [IncomeController::class, 'exportPDF'])->name('income.export.pdf');


});
