<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|	example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|	https://codeigniter.com/userguide3/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are three reserved routes:
|
|	$route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|	$route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
|	$route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples:	my-controller/index	-> my_controller/index
|		my-controller/my-method	-> my_controller/my_method
*/
$route['default_controller'] = 'auth';
$route['log-activity'] = 'LogActivity';
$route['log-activity/ajax_data'] = 'LogActivity/ajax_data';
$route['log-activity/bersihkan'] = 'LogActivity/bersihkan';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

// Auth
$route['login']     = 'auth/login';
$route['logout']    = 'auth/logout';
$route['dashboard'] = 'dashboard';

// =============================================
// Kartu Keluarga Routes
// =============================================
// $route['kartu-keluarga']                        = 'KartuKeluarga/index';
// $route['kartu-keluarga/tambah']                 = 'KartuKeluarga/tambah';
// $route['kartu-keluarga/detail/(:num)']          = 'KartuKeluarga/detail/$1';
// $route['kartu-keluarga/edit/(:num)']            = 'KartuKeluarga/edit/$1';
// $route['kartu-keluarga/hapus/(:num)']           = 'KartuKeluarga/hapus/$1';
// $route['kartu-keluarga/tambah_anggota/(:num)']  = 'KartuKeluarga/tambah_anggota/$1';
// $route['kartu-keluarga/edit_anggota/(:num)']    = 'KartuKeluarga/edit_anggota/$1';
// $route['kartu-keluarga/hapus_anggota/(:num)']   = 'KartuKeluarga/hapus_anggota/$1';
// $route['kartu-keluarga/ajax_cari_kk']           = 'KartuKeluarga/ajax_cari_kk';
// $route['kartu-keluarga/ajax_get_warga/(:num)']  = 'KartuKeluarga/ajax_get_warga/$1';

$route['kartu-keluarga']                                = 'KartuKeluarga/index';
$route['kartu-keluarga/tambah']                         = 'KartuKeluarga/tambah';
$route['kartu-keluarga/detail/(:num)']                  = 'KartuKeluarga/detail/$1';
$route['kartu-keluarga/edit/(:num)']                    = 'KartuKeluarga/edit/$1';
$route['kartu-keluarga/hapus/(:num)']                   = 'KartuKeluarga/hapus/$1';
$route['kartu-keluarga/tambah_anggota/(:num)']          = 'KartuKeluarga/tambah_anggota/$1';
$route['kartu-keluarga/edit_anggota/(:num)']            = 'KartuKeluarga/edit_anggota/$1';
$route['kartu-keluarga/hapus_anggota/(:num)']           = 'KartuKeluarga/hapus_anggota/$1';
$route['kartu-keluarga/tandai_meninggal/(:num)']        = 'KartuKeluarga/tandai_meninggal/$1';
$route['kartu-keluarga/hapus_warga_meninggal/(:num)']   = 'KartuKeluarga/hapus_warga_meninggal/$1';
$route['kartu-keluarga/upload_kk/(:num)']               = 'KartuKeluarga/upload_kk/$1';
$route['kartu-keluarga/upload_ktp/(:num)']              = 'KartuKeluarga/upload_ktp/$1';
$route['kartu-keluarga/hapus_dokumen_kk/(:num)']        = 'KartuKeluarga/hapus_dokumen_kk/$1';
$route['kartu-keluarga/hapus_dokumen_ktp/(:num)']       = 'KartuKeluarga/hapus_dokumen_ktp/$1';
$route['kartu-keluarga/ajax_cari_kk']                   = 'KartuKeluarga/ajax_cari_kk';
$route['kartu-keluarga/ajax_get_warga/(:num)']          = 'KartuKeluarga/ajax_get_warga/$1';
// =============================================
// Warga Routes
// =============================================
$route['warga']               = 'Warga/index';
$route['warga/tambah']        = 'Warga/tambah';
$route['warga/edit/(:num)']   = 'Warga/edit/$1';
$route['warga/hapus/(:num)']  = 'Warga/hapus/$1';
$route['warga/filter/(:any)'] = 'Warga/filter/$1';
$route['warga/pemilih']        = 'Warga/pemilih';
$route['warga/export_pemilih'] = 'Warga/export_pemilih';

// =============================================
// Inventaris Routes
// =============================================
$route['inventaris']                = 'Inventaris/index';
$route['inventaris/tambah']         = 'Inventaris/tambah';
$route['inventaris/detail/(:num)']  = 'Inventaris/detail/$1';

// =============================================
// Rencana Pembelian Routes
// =============================================
$route['rencana-pembelian']         = 'RencanaPembelian/index';
$route['rencana-pembelian/tambah']  = 'RencanaPembelian/tambah';

// =============================================
// Pengaduan Routes
// =============================================
$route['pengaduan']                 = 'Pengaduan/index';
$route['pengaduan/tambah']          = 'Pengaduan/tambah';
$route['pengaduan/detail/(:num)']   = 'Pengaduan/detail/$1';
$route['pengaduan/balas/(:num)']    = 'Pengaduan/balas/$1';


// Users Routes
$route['users'] = 'users/index';
$route['users/tambah'] = 'users/tambah';
$route['users/edit/(:num)'] = 'users/edit/$1';
$route['users/hapus/(:num)'] = 'users/hapus/$1';
$route['users/detail/(:num)'] = 'users/detail/$1';

// import excell
// ✅ BENAR — sesuai nama file KartuKeluarga.php
$route['kartu-keluarga/proses_import_excel'] = 'KartuKeluarga/proses_import_excel';
$route['kartu-keluarga/download_template']   = 'KartuKeluarga/download_template';

// Reset Data Routes
$route['reset'] = 'reset';
$route['reset/warga-user'] = 'reset/reset_warga_user';
$route['reset/keuangan'] = 'reset/reset_keuangan';
$route['reset/iuran'] = 'reset/reset_iuran';
$route['reset/inventaris'] = 'reset/reset_inventaris';
$route['reset/arisan'] = 'reset/reset_arisan';
$route['reset/administrasi'] = 'reset/reset_administrasi';
$route['reset/log'] = 'reset/reset_log';
$route['reset/total'] = 'reset/reset_total';

// =============================================
// Pengumuman Routes
// =============================================
$route['pengumuman']                    = 'Pengumuman/index';
$route['pengumuman/tambah']             = 'Pengumuman/tambah';
$route['pengumuman/detail/(:num)']      = 'Pengumuman/detail/$1';
$route['pengumuman/edit/(:num)']        = 'Pengumuman/edit/$1';
$route['pengumuman/hapus/(:num)']       = 'Pengumuman/hapus/$1';
$route['pengumuman/download/(:num)']    = 'Pengumuman/download_lampiran/$1';

$route['peminjaman-inventaris']              = 'peminjaman_inventaris/index';
$route['peminjaman-inventaris/tambah']       = 'peminjaman_inventaris/tambah';
$route['peminjaman-inventaris/detail/(:num)']= 'peminjaman_inventaris/detail/$1';
$route['peminjaman-inventaris/kembali/(:num)']= 'peminjaman_inventaris/kembali/$1';
$route['peminjaman-inventaris/hapus/(:num)'] = 'peminjaman_inventaris/hapus/$1';
$route['peminjaman-inventaris/search-warga'] = 'peminjaman_inventaris/search_warga';

// =============================================
// Pengaturan Routes
// =============================================
$route['pengaturan']                        = 'Pengaturan/index';
$route['pengaturan/simpan']                 = 'Pengaturan/simpan';
$route['pengaturan/simpan_peraturan']       = 'Pengaturan/simpan_peraturan';
$route['pengaturan/hapus_foto/(:any)']      = 'Pengaturan/hapus_foto/$1';
$route['pengaturan/struktur']               = 'Pengaturan/struktur';
// Pengaturan — generate & test API Key
$route['pengaturan/generate_api_key'] = 'Pengaturan/generate_api_key';
$route['pengaturan/test_api']         = 'Pengaturan/test_api';
 

// =============================================
// Cuaca Routes (BMKG)  ← tambahan baru
// =============================================
$route['cuaca/test']    = 'Cuaca/test';

$route['video']         = 'youtube/index';
$route['video/(:any)']  = 'youtube/$1';

// Rencana Pembelian — mapping URL dengan dash ke controller
$route['rencana-pembelian']                        = 'rencana_pembelian/index';
$route['rencana-pembelian/tambah']                 = 'rencana_pembelian/tambah';
$route['rencana-pembelian/edit/(:num)']            = 'rencana_pembelian/edit/$1';
$route['rencana-pembelian/hapus/(:num)']           = 'rencana_pembelian/hapus/$1';
$route['rencana-pembelian/realisasi/(:num)']       = 'rencana_pembelian/realisasi/$1';
$route['rencana-pembelian/proses-realisasi/(:num)']= 'rencana_pembelian/proses_realisasi/$1';
$route['rencana-pembelian/setujui/(:num)']         = 'rencana_pembelian/setujui/$1';
$route['rencana-pembelian/batalkan/(:num)']        = 'rencana_pembelian/batalkan/$1';

// =============================================
// Struktur RT Routes
// =============================================
$route['struktur-rt'] = 'Pengaturan/struktur';

// Menu Management — Admin only
$route['menu-management']                     = 'MenuManagement/index';
$route['menu-management/tambah-module']       = 'MenuManagement/tambah_module';
$route['menu-management/edit-module/(:num)']  = 'MenuManagement/edit_module/$1';
$route['menu-management/hapus-module/(:num)'] = 'MenuManagement/hapus_module/$1';
$route['menu-management/save-permission']     = 'MenuManagement/save_permission';
$route['menu-management/save-role']           = 'MenuManagement/save_role';
$route['menu-management/save-matrix']         = 'MenuManagement/save_matrix';   // <-- baru
$route['menu-management/toggle-module']       = 'MenuManagement/toggle_module';
$route['menu-management/copy-permission']     = 'MenuManagement/copy_permission';
$route['menu-management/reset-permission']    = 'MenuManagement/reset_permission';

// API — integrasi aplikasi RW
$route['api/info']       = 'api/info';
$route['api/warga']      = 'api/warga';
$route['api/keuangan']   = 'api/keuangan';
$route['api/iuran']      = 'api/iuran';
$route['api/pinjaman']   = 'api/pinjaman';
$route['api/tabungan']   = 'api/tabungan';
$route['api/inventaris'] = 'api/inventaris';
$route['api/pengumuman'] = 'api/pengumuman';
$route['api/kegiatan']   = 'api/kegiatan';
$route['api/dashboard']  = 'api/dashboard';

$route['iuran/cetak/(:num)'] = 'Iuran/cetak/$1';

// =============================================
// Master Pendidikan Routes
// =============================================
$route['master-pendidikan']                         = 'Master_pendidikan/index';
$route['master-pendidikan/tambah']                  = 'Master_pendidikan/tambah';
$route['master-pendidikan/edit/(:num)']             = 'Master_pendidikan/edit/$1';
$route['master-pendidikan/hapus/(:num)']            = 'Master_pendidikan/hapus/$1';
$route['master-pendidikan/toggle-status/(:num)']    = 'Master_pendidikan/toggle_status/$1';
$route['master-pendidikan/ajax-get/(:num)']         = 'Master_pendidikan/ajax_get/$1';

// =============================================
// Master Pekerjaan Routes
// =============================================
$route['master-pekerjaan']                          = 'Master_pekerjaan/index';
$route['master-pekerjaan/tambah']                   = 'Master_pekerjaan/tambah';
$route['master-pekerjaan/edit/(:num)']              = 'Master_pekerjaan/edit/$1';
$route['master-pekerjaan/hapus/(:num)']             = 'Master_pekerjaan/hapus/$1';
$route['master-pekerjaan/toggle-status/(:num)']     = 'Master_pekerjaan/toggle_status/$1';
$route['master-pekerjaan/ajax-get/(:num)']          = 'Master_pekerjaan/ajax_get/$1';

