Yes. Since your entire operation is already being driven from **department_schedules**, this is actually the best foundation for payroll.

Your flow becomes:

```text
Department Timetable
        ↓
department_schedules
        ↓
Attendance Records
        ↓
Worked Hours
        ↓
Payroll
        ↓
Payslips
```

For your system I would add these tables.

---

# 1. Employee Salary Table

```sql
CREATE TABLE employee_salary (
    id INT AUTO_INCREMENT PRIMARY KEY,

    employee_id INT NOT NULL UNIQUE,

    salary_type ENUM(
        'monthly',
        'daily',
        'hourly'
    ) NOT NULL DEFAULT 'monthly',

    basic_salary DECIMAL(12,2) DEFAULT 0,

    overtime_rate DECIMAL(12,2) DEFAULT 0,

    tax_percent DECIMAL(5,2) DEFAULT 0,

    pension_percent DECIMAL(5,2) DEFAULT 0,

    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```

---

# 2. Payroll Runs

```sql
CREATE TABLE payroll_runs (

    id INT AUTO_INCREMENT PRIMARY KEY,

    payroll_month VARCHAR(20),

    payroll_year INT,

    generated_by INT,

    generated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```

---

# 3. Payroll Details

```sql
CREATE TABLE payroll_details (

    id INT AUTO_INCREMENT PRIMARY KEY,

    payroll_run_id INT,

    employee_id INT,

    days_worked INT DEFAULT 0,

    hours_worked DECIMAL(10,2) DEFAULT 0,

    overtime_hours DECIMAL(10,2) DEFAULT 0,

    gross_salary DECIMAL(12,2) DEFAULT 0,

    tax_amount DECIMAL(12,2) DEFAULT 0,

    pension_amount DECIMAL(12,2) DEFAULT 0,

    net_salary DECIMAL(12,2) DEFAULT 0
);
```

---

# 4. Add Salary Menu

In sidebar.php

```php
<li>
    <a href="payroll.php">
        Payroll
    </a>
</li>

<li>
    <a href="salary_settings.php">
        Salary Settings
    </a>
</li>
```

---

# 5. Salary Settings Page

This page lets HR set:

```text
Employee
Salary Type
Basic Salary
Overtime Rate
Tax %
Pension %
```

Example:

| Employee | Type    | Salary  |
| -------- | ------- | ------- |
| John     | Monthly | 250,000 |
| Mary     | Monthly | 180,000 |
| James    | Daily   | 8,500   |

---

# 6. Payroll Calculation Logic

Using your attendance table.

Example:

```php
SELECT
employee_id,
COUNT(*) as days_worked
FROM attendance
WHERE status='Present'
AND attendance_date BETWEEN '$start' AND '$end'
GROUP BY employee_id
```

---

Monthly Salary:

```php
$grossSalary = $basicSalary;
```

---

Daily Salary:

```php
$grossSalary = $daysWorked * $dailyRate;
```

---

Hourly Salary:

```php
$grossSalary = $hoursWorked * $hourlyRate;
```

---

Overtime:

```php
$overtimePay =
$overtimeHours * $overtimeRate;
```

---

Gross:

```php
$grossSalary += $overtimePay;
```

---

Tax:

```php
$taxAmount =
($grossSalary * $taxPercent) / 100;
```

---

Pension:

```php
$pensionAmount =
($grossSalary * $pensionPercent) / 100;
```

---

Net Salary:

```php
$netSalary =
$grossSalary
-
$taxAmount
-
$pensionAmount;
```

---

# 7. Use Department Schedule

You already store:

```php
department_schedules
```

with:

```text
employee_id
shift_id
schedule_date
```

and shifts already contain:

```text
checkin
checkout
```

So worked hours can be calculated directly.

Example:

```php
$hours =
(
strtotime($shift['checkout'])
-
strtotime($shift['checkin'])
)
/
3600;
```

For every scheduled day:

```php
total_hours += hours;
```

This means payroll can be generated even before attendance closes.

Then attendance can adjust:

```text
Absent
Late
Half Day
Overtime
```

before final payroll approval.

---

# 8. Payroll Dashboard

I would build:

```text
+------------------------------------------------+
| Payroll Dashboard                              |
+------------------------------------------------+

Total Staff: 120

Total Gross Salary:
₦12,500,000

Total Tax:
₦850,000

Total Pension:
₦625,000

Net Payroll:
₦11,025,000

[Generate Payroll]
```

---

# 9. Payroll Table

```text
Employee
Department
Days Worked
Hours Worked
Gross
Tax
Pension
Net Salary
Status
```

Example:

```text
John Doe
Front Office
26
208
₦250,000
₦18,750
₦20,000
₦211,250
Approved
```

---

# 10. Payslip Generator

Generate:

```text
BEST WESTERN PLUS

PAYSLIP
May 2026

Employee:
John Doe

Department:
Front Office

Days Worked:
26

Gross Salary:
₦250,000

Tax:
₦18,750

Pension:
₦20,000

Net Salary:
₦211,250
```

Export:

```text
PDF
Excel
Print
```

---

# Recommended Build Order

1. Create `employee_salary` table.
2. Build `salary_settings.php`.
3. Build `payroll.php`.
4. Auto-calculate using attendance + department_schedules.
5. Add payroll approval.
6. Add PDF payslip generation.
7. Add payroll percentage/compliance dashboard.

Since your `department_schedule.php` is already complete and scheduling staff correctly, the next file to build should be **salary_settings.php** because payroll depends on salary data being available first.
