BGI HRMS Payroll & Attendance - Phase 3
=======================================

This patch adds payroll processing on top of Phase 1 attendance and Phase 2 leave workflow.

Modules included
----------------
1. Salary Components
2. Staff Salary Structure
3. Monthly Salary Process
4. Attendance-based absent deduction
5. Loan deduction
6. Hold Salary
7. Salary Sheet
8. Salary Slip print
9. Bank Export Excel
10. Staff portal salary slips
11. Payroll dashboard
12. Payroll audit log entries

Installation
------------
1. Take full database and file backup.
2. Make sure Phase 1 is already uploaded because this patch uses admin/hrms/_functions.php.
3. Import phase3_schema.sql in your ERP database.
4. Upload folders from this ZIP into your project root.
5. Open /admin/hrms/phase3_dashboard.php
6. Open Salary Components and verify default components.
7. Open Staff Salary Structure and set Basic Salary / Allowances / Deductions staff-wise.
8. Finalize attendance month.
9. Open Process Salary and process salary month.
10. Review Salary Sheet, Salary Slip and Bank Export.

Important Payroll Logic
-----------------------
- Calendar days are used as total salary days.
- Absent = 1 unpaid day.
- Half Day = 0.50 unpaid day.
- Present, Late, Leave, Holiday, OD, CH and Manual are paid days.
- Absent deduction is calculated on earning total.
- Hold salary stays as payment status Hold and is excluded from bank export.
- Loan installments are added during salary process and finalized when month is marked paid.

Suggested workflow
------------------
Raw Punch -> Daily Attendance -> Leave/Correction Approval -> Salary Structure -> Hold/Loan -> Process Salary -> Salary Sheet -> Bank Export -> Mark Paid

Files
-----
phase3_schema.sql
admin/hrms/_phase3_functions.php
admin/hrms/phase3_dashboard.php
admin/hrms/salary_components.php
admin/hrms/staff_salary_structure.php
admin/hrms/salary_process.php
admin/hrms/salary_sheet.php
admin/hrms/salary_hold.php
admin/hrms/loan_management.php
admin/hrms/salary_slip.php
admin/hrms/bank_export.php
staff/hrms/salary_slips.php
cron/hrms_payroll_monthly_process.php
MENU_PATCH_SNIPPETS.txt

Notes
-----
- All PHP code is written in English and kept PHP 5.6 friendly.
- Bank account columns are shown in export as placeholders. Add bank fields to hr_staff in a later phase if required.
- Overtime and arrear fields are reserved in salary process details; full overtime/arrear engine comes in Phase 4.
