-- =====================================================================
-- 0015_role_assignment.sql
-- Penetapan role aplikasi (Sanggraloka One: FIX/CREW/SELL) untuk 92 KARYAWAN
-- NYATA yang sudah di-seed di 0006_seed_real_users.sql, berdasarkan analisa
-- struktur organisasi (sanggraloka.md #4) + posisi aktual per
-- docs/USERNAME-KARYAWAN-SANGGRALOKA.xlsx (kolom Jabatan) + ENUM role final
-- di 0014_crew_sell_role_enum_seed.sql.
--
-- >>> DRAFT -- dibuat oleh analisa PM/DB Engineer, BUKAN keputusan final HR. <<<
-- Koreksi HR dipersilakan: setiap baris = SATU UPDATE per user (WHERE via
-- subquery/join username) dengan komentar posisi/departemen -- tinggal edit
-- nilai role di baris yang salah, tidak perlu ubah struktur file.
--
-- ATURAN PEMETAAN dipakai (ringkas -- lihat perintah tugas utk detail lengkap):
--   GM->gm, FC->fc, HC/HRD Manager->hr_admin, staf HRD admin->hr_staff,
--   Sales Manager->sales_manager, Sales Coordinator/Admin/Reservation-Ecom->sales,
--   Asst Event & Wedding Manager->ewm, Graphic Design->design,
--   HOD operasional (EHK/FBD/ChiefEng/FOM) tetap dept_head,
--   Level Coordinator (HK/Bar/FBS/Spa/Sec/Wel/Grd) -> supervisor,
--   Teknisi ENG (Gardener/Engineering/Pool Attendant) tetap technician,
--   Staf umum (RA/Waiter/GSA/Cook/Therapist/Security Guard/dst) -> employee
--   (Acl employee sudah mencakup report.php + self-service -- diverifikasi dari
--   src/Auth/Acl.php baris 244-249, tidak ada gap dibanding 'reporter' lama).
--   property_admin & super_admin existing seharusnya TIDAK diubah -- SATU
--   pengecualian sadar: Human Capital Manager (lihat catatan di bawah).
--
-- RINGKASAN DISTRIBUSI ROLE (92 user, dari 6 role lama -> 12 role):
--   gm 1 - fc 1 - hr_admin 1 - hr_staff 1 - sales_manager 1 - sales 3 - ewm 1 -
--   design 1 - dept_head 5 - supervisor 10 - technician 17 - employee 50
--   (total 92; 70 baris berubah dari role lama, 22 tidak berubah)
--
-- CATATAN KHUSUS (baca juga komentar inline di baris terkait):
--   1) Human Capital Manager (putu.suyantiari) property_admin->hr_admin: satu
--      pengecualian sadar dari aturan 'property_admin jangan diubah' (lihat baris).
--   2) IT Coordinator, 3x Steward: role LAMA dipertahankan + TODO HR (posisi tidak
--      eksplisit tercakup aturan pemetaan / berisiko mengurangi akses FIX).
--   3) Spa Coordinator & Security Coordinator: turun dept_head->supervisor sesuai
--      aturan literal (Spa/Sec Coordinator ada di daftar) -- GAP AKSES FIX dicatat
--      di baris terkait (kehilangan admin.php/parts.php/vendors.php/dst milik dept_head).
--
-- Jalankan setelah 0014.
-- =====================================================================

-- ---- A&G -- Finance, Purchasing, IT (10 orang) ----------------------------
-- I Komang Kariyana - General Manager (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'gm' WHERE u.username = 'komang.kariyana' AND upa.property_id = 1;

-- Agus Putra Kirana SE - Financial Controller (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'fc' WHERE u.username = 'agus.kirana' AND upa.property_id = 1;

-- I Kadek Yudiarta - Cost Control (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.yudiarta' AND upa.property_id = 1;

-- Moza Audina Sopharia - Bookkeeper & Tax (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'moza.sopharia' AND upa.property_id = 1;

-- Ni Wayan Sri Utami - Account Payable (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.utami' AND upa.property_id = 1;

-- I Nyoman Arya Candrayana - IT Coordinator (A&G)
-- TODO HR: jabatan IT Coordinator tidak eksplisit di aturan pemetaan (bukan HOD op. EHK/FBD/ChiefEng/FOM, juga bukan di daftar Coordinator->supervisor). Role lama (dept_head) DIPERTAHANKAN sementara -- mohon konfirmasi apakah tetap dept_head (utk akses FIX admin aset/vendor IT) atau turun ke supervisor spt Coordinator lain.
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'dept_head' WHERE u.username = 'nyoman.candrayana' AND upa.property_id = 1;

-- Fenny Handayani - General Cashier (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'fenny.handayani' AND upa.property_id = 1;

-- Ni Kadek Dwi Supriyanti - Purchasing Coordinator (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'kadek.supriyanti' AND upa.property_id = 1;

-- I Putu Oka Mardita - Receiving (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'putu.mardita' AND upa.property_id = 1;

-- I Dewa Gede Janu Hartono - Purchasing Officer (A&G)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'dewa.hartono' AND upa.property_id = 1;


-- ---- HRD -- HRD (+ Security) (8 orang) ----------------------------
-- Putu Dwika Suyantiari - Human Capital Manager (HRD)
-- CATATAN: posisi = Human Capital Manager -- per aturan HC/HRD Manager jadi hr_admin. Role lama property_admin nampak placeholder pra-CREW (pola sama dgn GM/FC yg dulu viewer) -- DIUBAH ke hr_admin. Deviasi sadar dari aturan property_admin existing jangan diubah -- mohon HR/GM konfirmasi.
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'hr_admin' WHERE u.username = 'putu.suyantiari' AND upa.property_id = 1;

-- I Gusti Ngurah Agung Army Dwijaya - Security Guard (HRD)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'gusti.dwijaya' AND upa.property_id = 1;

-- I Made Darmayasa - Security Guard (HRD)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'made.darmayasa' AND upa.property_id = 1;

-- Ni Komang Safitri - Human Capital Admin (HRD)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'hr_staff' WHERE u.username = 'komang.safitri' AND upa.property_id = 1;

-- Gusti Ngurah Agung Juniawan - Security Coordinator (HRD)
-- PERUBAHAN: Security Coordinator eksplisit masuk daftar Level Coordinator -> supervisor (turun dari dept_head). GAP ACL: kehilangan akses FIX admin.php/parts.php/vendors.php/asset-health.php/compliance.php/energy.php milik dept_head -- perlu keputusan HR/GM (catatan: Security memang di bawah HRD, bukan divisi mandiri, sesuai sanggraloka.md #4).
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'gusti.juniawan' AND upa.property_id = 1;

-- I Wayan Yadnya Putra - Security Guard (HRD)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.putra' AND upa.property_id = 1;

-- I Wayan Putra - Security Guard (HRD)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.putra2' AND upa.property_id = 1;

-- Anak Agung Raka Darma Putrawan - Security Guard (HRD)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'anak.putrawan' AND upa.property_id = 1;


-- ---- FO -- Front Office (10 orang) ----------------------------
-- Kadek Yunita Tira Kusumadewi - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.kusumadewi' AND upa.property_id = 1;

-- Ni Kadek Sintya Dewi - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.dewi' AND upa.property_id = 1;

-- Jhon Ayung Gideon Belopa - Bell Driver (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'jhon.belopa' AND upa.property_id = 1;

-- Ngakan Made Wityadnya - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'ngakan.wityadnya' AND upa.property_id = 1;

-- I Kadek Kayobi Sudarsana - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.sudarsana' AND upa.property_id = 1;

-- Sang Putu Tirtayana - Bell Driver (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'sang.tirtayana' AND upa.property_id = 1;

-- I Komang Sukra - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.sukra' AND upa.property_id = 1;

-- Ni Wayan Novi Yanti - Front Office Manager (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'dept_head' WHERE u.username = 'wayan.yanti' AND upa.property_id = 1;

-- Ni Wayan Eva Yama Yanti - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.yanti2' AND upa.property_id = 1;

-- Wayan Yuda Antara - Guest Service Agent (FO)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.antara2' AND upa.property_id = 1;


-- ---- HK -- Housekeeping (9 orang) ----------------------------
-- I Putu Ngurah Sanglah - Executive HouseKeeper (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'dept_head' WHERE u.username = 'putu.sanglah' AND upa.property_id = 1;

-- I Made Tapan Prawita - Public Area Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'made.prawita' AND upa.property_id = 1;

-- I Wayan Arsa Wijaya - HK Coordinator (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'wayan.wijaya' AND upa.property_id = 1;

-- Putu Agus Rama Raysaka - Room Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'putu.raysaka' AND upa.property_id = 1;

-- I Wayan Merta Nugraha - Room Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.nugraha' AND upa.property_id = 1;

-- I Putu Angga Ardita - Room Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'putu.ardita' AND upa.property_id = 1;

-- Ni Luh Made Satya Utami Putri - Linen Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'luh.putri' AND upa.property_id = 1;

-- I Komang Purnairawan - Public Area Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.purnairawan' AND upa.property_id = 1;

-- I Wayan Wisna - Room Attendant (HK)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.wisna' AND upa.property_id = 1;


-- ---- F&B -- Service + Bar + Kitchen (22 orang) ----------------------------
-- I Wayan Eka Arsana - F&B Director (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'dept_head' WHERE u.username = 'wayan.arsana' AND upa.property_id = 1;

-- Ni Kadek Diah Sukryaningsih - Waitres (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.sukryaningsih' AND upa.property_id = 1;

-- I Kadek Sudiantara - Steward (F&B)
-- TODO HR: jabatan Steward saat ini role=technician meski bukan ENG/IT (aturan Teknisi ENG & IT tetap technician scr literal hanya sebut ENG/IT). Role lama DIPERTAHANKAN (tidak diturunkan ke employee) supaya tidak kehilangan akses today.php/meter.php/logbook.php tanpa konfirmasi -- mohon HR pastikan Steward butuh akses maintenance-log tsb atau cukup employee.
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'kadek.sudiantara' AND upa.property_id = 1;

-- I Made Suwana Putra - Hot & Cold Kitchen CDP (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'made.putra' AND upa.property_id = 1;

-- I Wayan Ariyasa - F&B Service Coordinator (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'wayan.ariyasa' AND upa.property_id = 1;

-- I Ketut Suryanto - Bar Coordinator (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'ketut.suryanto' AND upa.property_id = 1;

-- Ni Nyoman Trisna - FB Service Coordinator (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'nyoman.trisna' AND upa.property_id = 1;

-- Ni Nyoman Kartini - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'nyoman.kartini' AND upa.property_id = 1;

-- I Putu Tegar Mahesaputra - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'putu.mahesaputra' AND upa.property_id = 1;

-- I Komang Ery Sancahya Pramana - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.pramana' AND upa.property_id = 1;

-- Ni Kadek Dwiyani - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.dwiyani' AND upa.property_id = 1;

-- I Desak Gede Sri Mahayani - Waitres (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'desak.mahayani' AND upa.property_id = 1;

-- I Nyoman Sugi Nandika Putra - Bartender (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'nyoman.putra' AND upa.property_id = 1;

-- I Wayan Muliada Artawan - Steward (F&B)
-- TODO HR: sama dgn Steward lain (lihat catatan kadek.sudiantara) -- role dipertahankan technician, mohon konfirmasi.
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.artawan' AND upa.property_id = 1;

-- I Kadek Yogi Suarmana - Steward (F&B)
-- TODO HR: sama dgn Steward lain (lihat catatan kadek.sudiantara) -- role dipertahankan technician, mohon konfirmasi.
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'kadek.suarmana' AND upa.property_id = 1;

-- I Made Arindia - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'made.arindia' AND upa.property_id = 1;

-- I Wayan Wira Adnyana - Bartender (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.adnyana' AND upa.property_id = 1;

-- I Made Sutapa - Waiter (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'made.sutapa' AND upa.property_id = 1;

-- Ni Komang Juni Ari - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.ari' AND upa.property_id = 1;

-- I Putu Suardika - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'putu.suardika' AND upa.property_id = 1;

-- Anak Agung Ayu Rai Asti - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'anak.asti' AND upa.property_id = 1;

-- Bertrand Arion Jinarakshita - Cook (F&B)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'bertrand.jinarakshita' AND upa.property_id = 1;


-- ---- ENG -- Engineering (+ Garden & Pool) (16 orang) ----------------------------
-- I Nyoman Suamba - Chief Engineering (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'dept_head' WHERE u.username = 'nyoman.suamba' AND upa.property_id = 1;

-- I Nengah Nari - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'nengah.nari' AND upa.property_id = 1;

-- I Wayan Karta - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.karta' AND upa.property_id = 1;

-- Ida Bagus Putu Yasa - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'ida.yasa' AND upa.property_id = 1;

-- Sabariyanto - Gardener & Pool Coordinator (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'sabariyanto' AND upa.property_id = 1;

-- I Nyoman Yogi Putra - Engineering Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'nyoman.putra2' AND upa.property_id = 1;

-- I Wayan Suta Maryawan - Pool Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.maryawan' AND upa.property_id = 1;

-- I Ketut Agus Adi Pranata - Engineering Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'ketut.pranata' AND upa.property_id = 1;

-- I Wayan Suartana - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.suartana' AND upa.property_id = 1;

-- Ni Wayan Rupiani - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.rupiani' AND upa.property_id = 1;

-- I Kadek Windu Saputra - Engineering Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'kadek.saputra' AND upa.property_id = 1;

-- I Komang Diantara - Engineering Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'komang.diantara' AND upa.property_id = 1;

-- I Komang Budha Galung - Pool Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'komang.galung' AND upa.property_id = 1;

-- Ni Made Srinadi - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'made.srinadi' AND upa.property_id = 1;

-- Ni Wayan Yutini - Gardener Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.yutini' AND upa.property_id = 1;

-- I Wayan Eka Sutarajaya - Engineering Attendant (ENG)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'technician' WHERE u.username = 'wayan.sutarajaya' AND upa.property_id = 1;


-- ---- SPA -- Spa (+ Activities) (11 orang) ----------------------------
-- I Wayan Mumendra - Activities Coordinator (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'wayan.mumendra' AND upa.property_id = 1;

-- Ni Wayan Nanik Rudasni - Activities Attendant (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.rudasni' AND upa.property_id = 1;

-- Ni Wayan Ariani Dewi - Activities Attendant (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.dewi' AND upa.property_id = 1;

-- I Komang Selamet Gunawan - Activities Attendant (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.gunawan' AND upa.property_id = 1;

-- Desak Made Alit Puspitawati - Spa Coordinator (SPA)
-- PERUBAHAN: Spa Coordinator eksplisit masuk daftar Level Coordinator -> supervisor (turun dari dept_head). GAP ACL: kehilangan akses FIX admin.php/parts.php/vendors.php/asset-health.php/compliance.php/energy.php milik dept_head -- perlu keputusan HR/GM apakah Spa perlu representasi dept_head tersendiri utk FIX.
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'supervisor' WHERE u.username = 'desak.puspitawati' AND upa.property_id = 1;

-- Ni Komang Erawati - Spa Therapist (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.erawati' AND upa.property_id = 1;

-- I Wayan Balik Antara - Spa Therapist (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'wayan.antara' AND upa.property_id = 1;

-- Gede Angga Prawira - Activities Attendant (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'gede.prawira' AND upa.property_id = 1;

-- Ni Putu Eka Sumartini - Spa Therapist (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'putu.sumartini' AND upa.property_id = 1;

-- Ni Kadek Wahyuni - Activities Attendant (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'kadek.wahyuni' AND upa.property_id = 1;

-- Ni Komang Patmawati - Spa Therapist (SPA)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'employee' WHERE u.username = 'komang.patmawati' AND upa.property_id = 1;


-- ---- S&M -- Sales & Marketing (6 orang) ----------------------------
-- Ni Komang Ayu Widyastuti - Sales Admin (S&M)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'sales' WHERE u.username = 'komang.widyastuti' AND upa.property_id = 1;

-- Ni Wayan Sri Rahyuni - Sales Coordinator (S&M)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'sales' WHERE u.username = 'wayan.rahyuni' AND upa.property_id = 1;

-- I Ketut Agus Darmika - Graphic Design (S&M)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'design' WHERE u.username = 'ketut.darmika' AND upa.property_id = 1;

-- Ni Wayan Ratni - Sales Manager (S&M)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'sales_manager' WHERE u.username = 'wayan.ratni' AND upa.property_id = 1;

-- Ni Kadek Rita Juliana - Reservation & E-commerce Officer (S&M)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'sales' WHERE u.username = 'kadek.juliana' AND upa.property_id = 1;

-- Dewa Ayu Ari Sulasmi - Asst. Event & Wedding Manager (S&M)
UPDATE user_property_access upa JOIN users u ON u.id = upa.user_id SET upa.role = 'ewm' WHERE u.username = 'dewa.sulasmi' AND upa.property_id = 1;


-- =====================================================================
-- END 0015_role_assignment.sql
-- =====================================================================