# Changelog - Info Hadir

All notable changes to this project will be documented in this file.

## [3.0.0] - 2026-02-18 - Auto-Reset & 4 Status System

### 🎉 Added
- **Role-Based Redirect System** 🔀
  - Admin → Dashboard Desktop (dashboard.html)
  - User → Dashboard Mobile (dashboard-mobile.html)
  - Auto-redirect based on user role
  - Access control on dashboard pages
  - Session validation and role checking
  - Files: `check-access.php`, updated `login.php`, `index.php`
  - Documentation: `docs/ROLE_BASED_REDIRECT.md`

- **Dashboard Mobile** 📱
  - UI responsif dioptimalkan untuk smartphone
  - Touch-friendly interactions
  - **Stats cards sebagai tombol status untuk user** ⭐
    - User biasa: Tap card untuk ubah status (HADIR, CUTI, TUGAS LUAR, TIDAK HADIR)
    - Admin: Cards menampilkan total keseluruhan
    - Visual highlight pada status aktif (✓)
    - Loading state dan toast notifications
  - Bottom navigation untuk akses mudah
  - Side menu dengan slide animation
  - Real-time auto-refresh setiap 5 detik
  - Toast notifications untuk feedback
  - Dark theme dengan glassmorphism
  - Safe area support (iPhone notch, Android gesture)
  - Files: `dashboard-mobile.html`, `assets/app-mobile.js`
  - Documentation: `docs/MOBILE_DASHBOARD_GUIDE.md`

- **Auto-Reset Kehadiran Harian** ⭐
  - Cron job script untuk reset otomatis setiap jam 00:00
  - API endpoint `check_and_reset.php` untuk auto-reset on access
  - Frontend integration: otomatis cek dan reset saat aplikasi dibuka
  - Logging system untuk monitoring (`cron/reset_attendance.log`)
  - Auto-cleanup data lama (> 30 hari) untuk menghemat storage
  - Dokumentasi lengkap: `docs/CRON_SETUP_GUIDE.md`
  - Files: `cron/reset_attendance.php`, `api/check_and_reset.php`

- **Status "Tugas Luar"** - Status keempat untuk kehadiran
  - Status sekarang: ADA (hijau), CUTI (kuning), TUGAS LUAR (biru), TIDAK ADA (merah)
  - Cycling system: ADA → CUTI → TUGAS LUAR → TIDAK ADA
  - Badge color: Cyan/blue (#4dd4e8) untuk TUGAS LUAR
  - Migration: `database/migration_add_tugas_luar.sql`

- **Admin Panel Redesign**
  - Desain selaras dengan dashboard (dark theme, glassmorphism)
  - Background animation matching dashboard
  - Fully responsive untuk mobile, tablet, desktop
  - Improved UX dengan smooth animations
  - Better color scheme consistency
  - Modal dengan backdrop blur effect

### 🔄 Changed
- **Database Schema**
  - `attendance.status` ENUM: `('present', 'absent', 'cuti')` → `('present', 'absent', 'cuti', 'tugas_luar')`
  - Migration: `database/migration_add_tugas_luar.sql`

- **API**
  - `api/attendance.php` - Validasi status untuk 4 status
  - New endpoint: `api/check_and_reset.php` untuk auto-reset

- **Frontend**
  - `assets/app.js` - Support 4 status dengan cycle system
  - `assets/display.js` - Display mode dengan 4 status
  - `assets/api-client.js` - Added AutoResetAPI class
  - Auto-reset check on page load
  - Improved badge styling dengan forced colors

- **Admin Panel**
  - Complete UI overhaul matching dashboard design
  - Dark theme dengan gradient background
  - Glassmorphism effects
  - Responsive design untuk semua device
  - Fixed user creation bug (password field error)

- **Table Styling**
  - Larger fonts: header 1.4rem, cells 1.25rem
  - Uppercase jabatan names
  - Vertical column lines
  - Narrower number column (50px)
  - Disabled row entrance animations
  - "Kepala Bidang" → "Kabid"

### 🐛 Fixed
- Admin panel user creation error: "Field 'password' doesn't have a default value"
  - Fixed by filling both `password` and `password_hash` columns
- TUGAS LUAR badge color forced to cyan/blue with `!important`
- Table refresh animation removed for cleaner look
- Password minimum length requirement removed

### 🗑️ Removed
- 17 unused test and backup files
- Unused display versions (only display3.html remains)
- Test API files

### 📝 Documentation
- `docs/CRON_SETUP_GUIDE.md` - Panduan lengkap setup cron job
- `cron/README.md` - Quick reference untuk cron folder
- Updated `CHANGELOG.md` - File ini

---

## [2.0.0] - 2024 - Status "Cuti" Added

### 🎉 Added
- **Status "Cuti"** - Menambahkan status ketiga untuk kehadiran
  - Status sekarang: ADA (hijau), CUTI (kuning), TIDAK ADA (merah)
  - Cycling system: Klik badge untuk cycle melalui 3 status
  - Visual feedback dengan warna yang berbeda untuk setiap status

### 🔄 Changed
- **Database Schema**
  - `attendance.status` ENUM updated: `('present', 'absent')` → `('present', 'absent', 'cuti')`
  - Migration script: `database/migration_add_cuti.sql`

- **API**
  - `api/attendance.php` - Validasi status updated untuk menerima 'cuti'
  - Response format tetap sama, hanya nilai status yang bertambah

- **Frontend**
  - `assets/app-v2.js` - New version dengan support 3 status
  - `assets/display-v2.js` - Display mode dengan support 3 status
  - `assets/styles.css` - Added `.badge.warning` style untuk status cuti
  - Badge cycling: ADA → CUTI → TIDAK ADA → ADA

### 📝 Documentation
- `UPGRADE_GUIDE.md` - Panduan lengkap untuk upgrade dari v1 ke v2
- `CHANGELOG.md` - File ini
- Updated `DOKUMENTASI.md` dengan informasi status baru
- Updated `docs/API_GUIDE.md` dengan contoh status 'cuti'
- Updated `docs/USER_MANUAL.md` dengan cara penggunaan 3 status

### 🎨 UI/UX Improvements
- Badge kuning untuk status CUTI dengan visibility tinggi
- Animation untuk setiap perubahan status (bump + glow)
- Loading indicator saat update status
- Smooth transition antar status

### 🔧 Technical Details
- LocalStorage key updated: `info-hadir-statuses-v1` → `info-hadir-statuses-v2`
- Status constants: `STATUS.PRESENT`, `STATUS.ABSENT`, `STATUS.CUTI`
- Backward compatible dengan fallback ke 'absent' jika status tidak valid

---

## [1.0.0] - 2024 - Initial Release

### ✨ Features
- **Authentication System**
  - Login dengan username & password
  - Role-based access (Admin & User)
  - Session management dengan token

- **Attendance Management**
  - 2 status: ADA (present) dan TIDAK ADA (absent)
  - Real-time updates setiap 5 detik
  - Toggle status dengan klik badge

- **Dashboard**
  - User dashboard: Hanya tampilkan status sendiri
  - Admin dashboard: Tampilkan dan edit semua status
  - Analog clock dengan tanggal/waktu real-time
  - User info display

- **Display Mode**
  - Read-only mode untuk TV/monitor
  - No authentication required
  - Auto-refresh setiap 5 detik
  - Optimized untuk layar besar

- **API**
  - RESTful API dengan JSON
  - Endpoints: auth, attendance, positions
  - CORS support
  - Error handling

- **Database**
  - MySQL dengan PDO
  - 3 tables: positions, users, attendance
  - Foreign key constraints
  - Unique constraints untuk data integrity

- **UI/UX**
  - Responsive design
  - 3D background animation
  - Smooth animations
  - Modern gradient design
  - Badge system dengan warna

### 🛠️ Technical Stack
- **Backend:** PHP 7.4+, MySQL 5.7+
- **Frontend:** Vanilla JavaScript (ES6+), CSS3
- **Server:** Apache/Nginx
- **Architecture:** REST API

### 📦 Included Files
- Database schema & sample data
- API endpoints (auth, attendance, positions)
- Frontend assets (JS, CSS, images)
- Configuration files
- Documentation (README, API Guide, User Manual)

---

## Version Comparison

| Feature | v1.0.0 | v2.0.0 |
|---------|--------|--------|
| Status Options | 2 (ADA, TIDAK ADA) | 3 (ADA, CUTI, TIDAK ADA) |
| Badge Colors | 2 (Hijau, Merah) | 3 (Hijau, Kuning, Merah) |
| Status Update | Toggle | Cycling |
| Database ENUM | 2 values | 3 values |
| API Validation | 2 statuses | 3 statuses |
| LocalStorage Key | v1 | v2 |

---

## Migration Path

### From v1.0.0 to v2.0.0

**Required Steps:**
1. Backup database
2. Run migration script: `database/migration_add_cuti.sql`
3. Update frontend files: `app.js`, `display.js`
4. Clear browser cache
5. Test all features

**Estimated Time:** 10-15 minutes

**Rollback:** Restore database from backup and revert files

See `UPGRADE_GUIDE.md` for detailed instructions.

---

## Upcoming Features (Roadmap)

### v2.1.0 (Planned)
- [ ] History kehadiran (view past attendance)
- [ ] Export data ke Excel/PDF
- [ ] Filter by date range
- [ ] Statistics dashboard

### v2.2.0 (Planned)
- [ ] Notifikasi push untuk perubahan status
- [ ] Email notifications
- [ ] SMS integration (optional)

### v3.0.0 (Future)
- [ ] Mobile app (Android/iOS)
- [ ] Multi-language support
- [ ] Advanced reporting
- [ ] User management UI
- [ ] Audit log

---

## Breaking Changes

### v2.0.0
- **Database Schema:** ENUM values changed, requires migration
- **LocalStorage Key:** Changed from `v1` to `v2`, old data won't be read
- **API:** Status validation updated, old clients may fail if sending invalid status

**Mitigation:** Follow upgrade guide for smooth migration

---

## Bug Fixes

### v2.0.0
- Fixed: Badge animation not working on rapid clicks
- Fixed: Display mode not updating on some browsers
- Fixed: Session validation timing issue
- Improved: Error handling in API calls
- Improved: Loading state feedback

### v1.0.0
- Initial release, no bugs to fix yet

---

## Security Updates

### v2.0.0
- Enhanced input validation for new status value
- Updated SQL queries to prevent injection
- Improved session token validation

### v1.0.0
- Password hashing with bcrypt
- SQL injection prevention with PDO prepared statements
- XSS protection with input sanitization
- CORS configuration

---

## Performance Improvements

### v2.0.0
- Optimized status cycling logic
- Reduced DOM manipulation in render functions
- Improved animation performance
- Better cache management

### v1.0.0
- Auto-refresh interval: 5 seconds
- Efficient database queries with indexes
- Minimal JavaScript bundle size
- CSS animations with GPU acceleration

---

## Contributors

- **yhy_** - Initial development and v2.0.0 update

---

## License

Proprietary - Dinas Pendidikan dan Kebudayaan Kabupaten Balangan

---

**Last Updated:** 2024
**Current Version:** 2.0.0
