<?php

use CodeIgniter\Router\RouteCollection;
use App\Controllers\Auth;
use App\Controllers\Dashboard;

/**
 * @var RouteCollection $routes
 */

// ===============================
// AUTH
// ===============================
$routes->get('/', 'Auth::index');
$routes->get('login', 'Auth::index');
$routes->post('login', 'Auth::login');
$routes->get('register', 'Auth::register');
$routes->post('register', 'Auth::storeRegister');
$routes->get('logout', 'Auth::logout');

// ===============================
// KATALOG (GURU / SISWA)
// ===============================
$routes->get('katalog', 'Katalog::index');
$routes->get('katalog/ruang_baca', 'Katalog::ruangBaca');
$routes->get('katalog/daftar', 'Katalog::daftar');
$routes->post('katalog/store-daftar', 'Katalog::storeDaftar');

// ===============================
// DASHBOARD
// ===============================
$routes->get('dashboard', 'Dashboard::index');
$routes->get('dashboard/grafik', 'Dashboard::grafik');

// ===============================
// BUKU
// ===============================
$routes->get('buku', 'Buku::index');
$routes->get('buku/create', 'Buku::create');
$routes->post('buku/store', 'Buku::store');
$routes->get('buku/edit/(:num)', 'Buku::edit/$1');
$routes->post('buku/update/(:num)', 'Buku::update/$1');
$routes->get('buku/delete/(:num)', 'Buku::delete/$1');

// ===============================
// RUANG BACA
// ===============================
$routes->get('ruang_baca', 'RuangBaca::index');
$routes->get('ruang_baca/create', 'RuangBaca::create');
$routes->post('ruang_baca/store', 'RuangBaca::store');
$routes->get('ruang_baca/edit/(:num)', 'RuangBaca::edit/$1');
$routes->post('ruang_baca/update/(:num)', 'RuangBaca::update/$1');
$routes->get('ruang_baca/delete/(:num)', 'RuangBaca::delete/$1');
$routes->get('ruang_baca/download/(:num)', 'RuangBaca::download/$1');

// ===============================
// ANGGOTA
// ===============================
$routes->get('anggota', 'Anggota::index');
$routes->post('anggota/store', 'Anggota::store');
$routes->get('anggota/edit/(:num)', 'Anggota::edit/$1');
$routes->post('anggota/update/(:num)', 'Anggota::update/$1');
$routes->get('anggota/delete/(:num)', 'Anggota::delete/$1');

// ===============================
// PEMINJAMAN
// ===============================
$routes->get('peminjaman', 'Peminjaman::index');
$routes->post('peminjaman/store', 'Peminjaman::store');
$routes->get('peminjaman/edit/(:num)', 'Peminjaman::edit/$1');
$routes->post('peminjaman/update/(:num)', 'Peminjaman::update/$1');
$routes->get('peminjaman/delete/(:num)', 'Peminjaman::delete/$1');

// ===============================
// PENGEMBALIAN
// ===============================
$routes->get('pengembalian', 'Pengembalian::index');
$routes->post('pengembalian/store', 'Pengembalian::store');

// ===============================
// PENGUNJUNG
// ===============================
$routes->get('pengunjung', 'Pengunjung::index');
$routes->post('pengunjung/store', 'Pengunjung::store');
$routes->get('pengunjung/search', 'Pengunjung::search');
$routes->get('pengunjung/delete/(:num)', 'Pengunjung::delete/$1');

// ===============================
// LAPORAN
// ===============================
$routes->get('laporan', 'Laporan::index');
$routes->get('laporan/detail/(:num)', 'Laporan::detail/$1');
$routes->get('laporan/rekap-mingguan', 'Laporan::rekapMingguan');
$routes->get('laporan/rekap-bulanan', 'Laporan::rekapBulanan');
$routes->get('laporan/struk/(:num)', 'Laporan::cetakStruk/$1');
$routes->get('laporan/pengunjung', 'Laporan::pengunjung');
$routes->get('laporan/cetak', 'Laporan::cetak');
$routes->get('laporan/pdf', 'Laporan::exportPDF');
$routes->get('laporan/excel', 'Laporan::exportExcel');

// ===============================
// PENGATURAN
// ===============================

// Halaman utama
$routes->get('pengaturan', 'Pengaturan::index');


// ===============================
// PENGATURAN SEKOLAH
// ===============================

$routes->get(
    'pengaturan/sekolah',
    'Pengaturan::sekolah'
);


$routes->post(
    'pengaturan/sekolah/update',
    'Pengaturan::updateSekolah'
);


// ===============================
// AKUN
// ===============================
$routes->get(
    'pengaturan/akun',
    'Pengaturan::akun'
);

$routes->post(
    'pengaturan/password',
    'Pengaturan::updatePassword'
);


// ===============================
// ATURAN PEMINJAMAN
// ===============================
$routes->get(
    'pengaturan/peminjaman',
    'Pengaturan::peminjaman'
);

$routes->post(
    'pengaturan/peminjaman',
    'Pengaturan::updatePeminjaman'
);


// ===============================
// PENGATURAN CETAK
// ===============================
$routes->get(
    'pengaturan/cetak',
    'Pengaturan::cetak'
);

$routes->post(
    'pengaturan/cetak',
    'Pengaturan::updateCetak'
);


// ===============================
// PENGATURAN PROFIL
// ===============================
$routes->post(
    'pengaturan/profil/update',
    'Pengaturan::updateProfil'
);


// ===============================
// BACKUP DATABASE
// ===============================
$routes->get(
    'pengaturan/backup',
    'Pengaturan::backup'
);

$routes->get(
    'pengaturan/backup/download',
    'Pengaturan::downloadBackup'
);

$routes->post(
    'pengaturan/backup/restore',
    'Pengaturan::restoreBackup'
);
