<?php

use Illuminate\Support\Facades\Route;
use Modules\Lpj\Http\Controllers\SpkController;
use Modules\Lpj\Http\Controllers\RegistrasiController;
use Modules\Lpj\Http\Controllers\ProsesPenawaranController;
use Modules\Lpj\Http\Controllers\RegistrasiFinalController;
use Modules\Lpj\Http\Controllers\OtorisasiPenawaranController;
use Modules\Lpj\Http\Controllers\ProsesPenawaranUlangController;
use Modules\Lpj\Http\Controllers\PembayaranController;

Route::middleware(['auth'])->group(function () {

    // andy add
    // Route::name('registrasi.')->prefix('registrasi')->group(function () {
    Route::controller(RegistrasiController::class)->group(function () {
        // Route::get('/', [RegistrasiController::class, 'index'])->name('registrasi.index');
        Route::get('/registrasi', 'index')->name('registrasi.index');
        Route::get('/registrasi/datatables', 'dataForDatatables')->name('registrasi.datatables');

        // show data
        Route::get('/registrasi/{registrasi}', 'show')->name('registrasi.show');
        Route::post('registrasi/showData', 'setData')->name('registrasi.showData');

        Route::post('registrasi/setData', 'setData')->name('registrasi.setData');
        Route::get('/registrasi/{registrasi}/edit', 'edit')->name('registrasi.edit');
        Route::put('/registrasi/{registrasi}', 'update')->name('registrasi.update');

    });
    // andy add

    Route::put('/store-revisi/{id}', [RegistrasiController::class, 'storeRevisi'])->name('storeRevisi');

    Route::name('tender.')->prefix('tender')->group(function () {

        // Proses Penawaran
        Route::controller(ProsesPenawaranController::class)->group(function () {

            Route::get('prosespenawaran', 'index')->name('prosespenawaran.index');
            Route::get('prosespenawaran/datatables', 'dataForDatatables')->name('prosespenawaran.datatables');
            Route::get('prosespenawaran/datatableskjppList_1', 'dataForDatatablesKJPPList_1')->name('prosespenawaran.datatableskjppList_1');
            Route::get('/prosespenawaran/{prosespenawaran}', 'show')->name('prosespenawaran.show');
            Route::get('prosespenawaran/{prosespenawaran}/edit', 'edit')->name('prosespenawaran.edit');

            Route::post('prosespenawaran/setData', 'setData')->name('prosespenawaran.setData');

            // update one
            Route::put('/prosespenawaran/{prosespenawaran}', 'update')->name('prosespenawaran.update');
            // update all
            Route::put('/prosespenawaranAll/{prosespenawaranAll}', 'updateAll')->name('prosespenawaran.updateAll');
            // update draft
            Route::put('/prosespenawaranDraft/{prosespenawaranDraft}', 'updateDraft')->name('prosespenawaran.updateDraft');
            // delete KJPP, status set = 0
            Route::put('/prosespenawaranKJPPStatus/{prosespenawaranKJPPStatus}', 'updateKJPPStatus')->name('prosespenawaran.updateKJPPStatus');

            // add KJPP to detail_penawaran
            Route::post('prosespenawaran/store', 'store')->name('prosespenawaran.store');
            Route::post('prosespenawaran/storeUlang', 'storeUlang')->name('prosespenawaran.storeUlang');

            // edit proses penawaran ulang
            Route::get('prosespenawaran/{prosespenawaran}/editulang', 'editulang')->name('prosespenawaran.editulang');
            Route::post('prosespenawaran/setDataUlang', 'setDataUlang')->name('prosespenawaran.setDataUlang');
            Route::put('/prosespenawaran2/{prosespenawaran2}', 'updateulang')->name('prosespenawaran.updateulang');
            Route::put('/prosespenawaranKJPPStatusUlang/{prosespenawaranKJPPStatusUlang}', 'updateKJPPStatusUlang')->name('prosespenawaran.updateKJPPStatusUlang');

            // merger penawaran
            Route::get('/prosespenawaran/{prosespenawaran}/showPermohonan', 'showPermohonan')->name('prosespenawaran.showPermohonan');
            Route::get('prosespenawaran/{prosespenawaran}/createPenawaran', 'createPenawaran')->name('prosespenawaran.createPenawaran');
            Route::post('prosespenawaran/{prosespenawaran}/storePenawaran', 'storePenawaran')->name('prosespenawaran.storePenawaran');
            // merger penawaran
        });

        // Proses Penawaran Ulang
        Route::controller(ProsesPenawaranUlangController::class)->group(function () {
            Route::get('prosespenawaranulang', 'index')->name('prosespenawaranulang.index');
            Route::get('prosespenawaranulang/datatables', 'dataForDatatables')->name('prosespenawaranulang.datatables');
            Route::get('prosespenawaranulang/{prosespenawaranulang}/edit', 'edit')->name('prosespenawaranulang.edit');

            // show data
            Route::get('/prosespenawaranulang/{prosespenawaranulang}', 'show')->name('prosespenawaranulang.show');
            Route::post('prosespenawaranulang/setData', 'setData')->name('prosespenawaranulang.setData');

            // update KJPP data, detail penawaran
            Route::put('/prosespenawaranulang/{prosespenawaranulang}', 'update')->name('prosespenawaranulang.update');
            // delete KJPP, status set = 0
            Route::put('/prosespenawaranulangKJPPStatus/{prosespenawaranulangKJPPStatus}', 'updateKJPPStatus')->name('prosespenawaranulang.updateKJPPStatus');
        });
    });

    Route::name('otorisasitender.')->prefix('otorisasitender')->group(function () {
        Route::controller(OtorisasiPenawaranController::class)->group(function () {
            Route::get('penawaran', 'index')->name('penawaran.index');
            Route::get('penawaran/datatables', 'dataForDatatables')->name('penawaran.datatables');
            Route::get('penawaran/{penawaran}/edit', 'edit')->name('penawaran.edit');

            // show data
            Route::get('/penawaran/{penawaran}', 'show')->name('penawaran.show');
            Route::post('penawaran/setData', 'setData')->name('penawaran.setData');

            // update KJPP data, detail penawaran
            Route::put('/otorisasiPenawaranKJPP/{penawaran}', 'otorisasiPenawaranKJPP')->name('penawaran.otorisasiPenawaranKJPP');

            // revisi penawaran ulang
            Route::put('/penawaranulang/{penawaranulang}', 'penawaranulang')->name('penawaran.penawaranulang');
        });
    });

    Route::controller(SpkController::class)->group(function () {
        Route::get('/spk/dokumennya', 'dokumennya')->name('spk.dokumennya');

        Route::get('/spk', 'index')->name('spk.index');
        Route::get('/spk/datatables', 'dataForDatatables')->name('spk.datatables');
        Route::POST('/spk/update-sla/{id}', 'updateSla')->name('spk.update-sla');
        Route::get('/spk/{spk}', 'show')->name('spk.show');
        Route::get('/spk/{spk}/edit', 'edit')->name('spk.edit');
        Route::put('/spk/{spk}', 'update')->name('spk.update');

        Route::get('spk/{spk}/download', 'download')->name('spk.download');
    });

    Route::controller(RegistrasiFinalController::class)->group(function () {
        Route::get('/registrasifinal', 'index')->name('registrasifinal.index');
        Route::get('/registrasifinal/datatables', 'dataForDatatables')->name('registrasifinal.datatables');
        Route::get('/registrasifinal/{registrasifinal}', 'show')->name('registrasifinal.show');

        Route::post('registrasifinal/setData', 'setData')->name('registrasifinal.setData');

        Route::get('/registrasifinal/{registrasifinal}/edit', 'edit')->name('registrasifinal.edit');
        Route::put('/registrasifinal/{registrasifinal}', 'update')->name('registrasifinal.update');
    });

    Route::controller(PembayaranController::class)->group(function () {
        Route::get('/pembayaran', 'index')->name('pembayaran.index');
        Route::get('/pembayaran/create', 'create')->name('pembayaran.create');
        Route::get('/pembayaran/kurang', 'kurang')->name('pembayaran.kurang.index');
        Route::get('/pembayaran/lebih', 'lebih')->name('pembayaran.lebih.index');
        Route::get('/pembayaran/{pembayaran}/edit', 'edit')->name('pembayaran.edit');
        Route::post('pembayaran','store')->name('pembayaran.store');
        Route::get('/pembayaran/datatables', 'dataForDatatables')->name('pembayaran.datatables');
        Route::get('/pembayaran/datatables-kurang','dataForDatatablesKurang')->name('pembayaran.kurang.datatables');
        Route::get('/pembayaran/datatables-lebih','dataForDatatablesLebih')->name('pembayaran.lebih.datatables');

        Route::get('/pembayaran/{pembayaran}/kurang', 'editKurang')->name('pembayaran.kurang');
        Route::get('/pembayaran/{pembayaran}/lebih', 'editLebih')->name('pembayaran.lebih');

        Route::put('/pembayaran/{pembayaran}', 'update')->name('pembayaran.update');

        Route::get('/pembayaran/approval', 'approval')->name('pembayaran.approval.index');
        Route::get('/pembayaran/datatables-approval', 'dataApprovalForDatatables')->name('pembayaran.approval.datatables');
    });
});
