<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\PenjajaController as PublicPenjajaController;
use App\Http\Controllers\Admin\PenjajaController as AdminPenjajaController;
use App\Http\Controllers\Admin\IkPenjajaController;
use App\Http\Controllers\Admin\PegawaiPenjajaController;
use App\Http\Controllers\Admin\DashboardController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\AuthenticatedSessionController;


Route::get('/', [AuthenticatedSessionController::class, 'create']);

Route::get('/dashboard', [PublicPenjajaController::class, 'list'])->middleware(['auth', 'verified'])->name('dashboard');

Route::get('/dashmin/{ctahun?}', [DashboardController::class, 'utama'])->middleware(['auth', 'verified'])->name('admin.dashboard');
Route::post('/dashmin', [DashboardController::class, 'carianutama'])->middleware(['auth', 'verified'])->name('admin.dashboard');

Route::get('/penjaja-baru', [AdminPenjajaController::class, 'senarai_pt'])->middleware(['auth', 'verified'])->name('pt.baru');

Route::get('/penjaja-baru-papar/{id}', [AdminPenjajaController::class, 'papar'])->middleware(['auth', 'verified'])->name('admin.penjaja-papar');
Route::get('/penjaja-baru-papar-lampiran/{id}', [AdminPenjajaController::class, 'paparLampiran'])->middleware(['auth', 'verified'])->name('pt.penjaja-papar-lampiran');
Route::get('/penjaja-papar-pemeriksaan/{id}', [IkPenjajaController::class, 'papar'])->middleware(['auth', 'verified'])->name('ik.papar-pemeriksaan');
Route::get('/penjaja-papar-pemeriksaan-map/{id}', [IkPenjajaController::class, 'papar_map'])->middleware(['auth', 'verified'])->name('ik.papar-pemeriksaan-map');

Route::get('/penjaja-papar-pemeriksaan-dokumen/{id}', [IkPenjajaController::class, 'papar_dokumen'])->middleware(['auth', 'verified'])->name('ik.papar-pemeriksaan-dokumen');
Route::get('/penjaja-papar-pemeriksaan-proses/{id}', [IkPenjajaController::class, 'papar_wangproses'])->middleware(['auth', 'verified'])->name('ik.papar-pemeriksaan-wangproses');

Route::get('/penjaja-papar-pemeriksaan-ulasan/{id}', [IkPenjajaController::class, 'papar_ulasan'])->middleware(['auth', 'verified'])->name('ik.papar-pemeriksaan-ulasan');




Route::post('/simpan_wangproses', [AdminPenjajaController::class, 'simpanWangProses'])->middleware(['auth', 'verified'])->name('pt.simpan_wangproses');

Route::get('/penjaja-proses', [AdminPenjajaController::class, 'senarai_pt_proses'])->middleware(['auth', 'verified'])->name('pt.proses');

Route::post('/simpan_nofail', [AdminPenjajaController::class, 'simpanNoFail'])->middleware(['auth', 'verified'])->name('pt.simpan_nofail');
Route::post('/hantar_ppk', [AdminPenjajaController::class, 'hantarPPK'])->middleware(['auth', 'verified'])->name('pt.hantar_ppk');

Route::get('/penjaja-pemeriksaan', [IkPenjajaController::class, 'senarai_ik'])->middleware(['auth', 'verified'])->name('ik.pemeriksaan');
Route::post('/ik-simpan-lokasi', [IkPenjajaController::class, 'simpanLokasi'])->middleware(['auth', 'verified'])->name('ik.simpan-lokasi');
Route::post('/ik-simpan-ulasan', [IkPenjajaController::class, 'simpanUlasan'])->middleware(['auth', 'verified'])->name('ik.simpan-ulasan');

Route::get('/penjaja-pegawai-ulasan', [PegawaiPenjajaController::class, 'senarai_pegawai'])->middleware(['auth', 'verified'])->name('pegawai.ulasan');

Route::get('/penjaja-bukafail', function () {
    return view('admin.penjaja.senaraibukafail');
})->middleware(['auth', 'verified'])->name('pt.bukafail');

Route::get('/penjaja-pengarah-sokong', function () {
    return view('admin.penjaja.senaraisokonganpengarah');
})->middleware(['auth', 'verified'])->name('pengarah.ulasan');

Route::get('/penjaja-minitmesyuarat', function () {
    return view('admin.penjaja.senaraibawamesyuarat');
})->middleware(['auth', 'verified'])->name('pt.bawamesyuarat');

Route::get('/penjaja-keputusanmesyuarat', function () {
    return view('admin.penjaja.keputusanmesyuarat');
})->middleware(['auth', 'verified'])->name('pt.keputusanmesyuarat');

Route::get('/penjaja-keluar-lesen', function () {
    return view('admin.penjaja.keputusanmesyuarat');
})->middleware(['auth', 'verified'])->name('pt.keluarlesen');

Route::get('/penjaja-selesai', function () {
    return view('admin.penjaja.keputusanmesyuarat');
})->middleware(['auth', 'verified'])->name('pt.selesai');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');

    
    Route::get('/mohon-penjaja', [PublicPenjajaController::class, 'create'])->name('penjaja-mohon');
    Route::post('/simpan-mohon-penjaja', [PublicPenjajaController::class, 'store'])->name('penjaja-simpan_mohon');
    Route::get('/mohon-penjaja-upload', [PublicPenjajaController::class, 'create_upload'])->name('penjaja-mohon-upload');
    Route::post('/simpan-mohon-penjaja-upload', [PublicPenjajaController::class, 'store_upload'])->name('penjaja-simpan_mohon_upload');

    Route::get('/mohon_hapus/{id}', [PublicPenjajaController::class, 'hapus_permohonan'])->middleware(['auth', 'verified'])->name('delete_mohon');
    Route::get('/mohon_edit/{id}', [PublicPenjajaController::class, 'edit_permohonan'])->middleware(['auth', 'verified'])->name('edit_mohon');
    Route::get('/mohon_hantar', [PublicPenjajaController::class, 'hantar_permohonan'])->middleware(['auth', 'verified'])->name('penjaja-mohon-hantar');

    
    /*Route::post('/pbtpay/checkout/{modul}/{id}', function () {
        return view('pbtpay.checkout');
    })->middleware(['auth', 'verified'])->name('pbtpay.bayar');*/
    Route::post('/pbtpay/checkout/{modul}/{id}', [PbtpayController::class, 'checkout'])->middleware(['auth', 'verified'])->name('pbtpay.bayar');
    
    Route::post('/pbtpay/callback', function () {
        return view('pbtpay.callback');
    })->middleware(['auth', 'verified'])->name('pbtpay.callback');
    Route::post('/pbtpay/indirect', function () {
        return view('pbtpay.indirect');
    })->middleware(['auth', 'verified'])->name('pbtpay.indirect');
});

require __DIR__.'/auth.php';
