Salary Slip Generator (with PDF & WhatsApp Integration)
✅ Features Overview
- Employee Management
- Salary Structure Setup
- Salary Slip Generation
- PDF Generation
- Send PDF via WhatsApp
- Admin Panel
📁 Folder Structure
/salary_slip_system/ ├── db.php ├── index.php (login) ├── dashboard.php ├── employees/ │ ├── add_employee.php │ └── list_employees.php ├── salary/ │ ├── generate.php │ ├── slips/ │ └── send_whatsapp.php ├── pdf/ │ └── salary_slip.php ├── assets/ │ └── (CSS, JS, Bootstrap)
📄 Step-by-Step Setup
1️⃣ Database Connection (`db.php`)
<?php
$conn = new mysqli("localhost", "root", "", "salary_db");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
2️⃣ SQL Table Structure
CREATE TABLE employees (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
mobile VARCHAR(15),
uan_number VARCHAR(20),
bank_account VARCHAR(30),
basic DECIMAL(10,2),
hra DECIMAL(10,2),
allowance DECIMAL(10,2),
pf DECIMAL(10,2),
esi DECIMAL(10,2),
pt DECIMAL(10,2)
);
CREATE TABLE salary_slips (
id INT AUTO_INCREMENT PRIMARY KEY,
employee_id INT,
month_year VARCHAR(10),
total_days INT,
present_days INT,
overtime_hours DECIMAL(5,2),
overtime_rate DECIMAL(10,2),
gross_salary DECIMAL(10,2),
net_salary DECIMAL(10,2),
pdf_path VARCHAR(255),
FOREIGN KEY (employee_id) REFERENCES employees(id)
);
3️⃣ Salary Slip Generator (generate.php)
This page:
- Fetches employee data
- Allows entry for present days and overtime
- Calculates salary
- Saves slip to database
- Generates PDF
4️⃣ PDF Generator (pdf/salary_slip.php using DOMPDF)
require 'vendor/autoload.php'; // DOMPDF
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$html = "<h2>Salary Slip - $month_year</h2>
<table>
<tr><td>Name</td><td>$employee_name</td></tr>
<tr><td>Basic</td><td>$basic</td></tr>
...
<tr><td>Net Salary</td><td>$net_salary</td></tr>
</table>";
$dompdf->loadHtml($html);
$dompdf->setPaper('A4');
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents("salary/slips/slip_$id.pdf", $pdf);
5️⃣ WhatsApp Integration (send_whatsapp.php via UltraMsg API)
$instanceId = "YOUR_INSTANCE_ID";
$token = "YOUR_TOKEN";
$to = "91" . $mobile;
$file = "https://yourdomain.com/salary/slips/slip_$id.pdf";
$url = "https://api.ultramsg.com/$instanceId/messages/document";
$data = [
'token' => $token,
'to' => $to,
'filename' => "Salary_Slip_$month_year.pdf",
'document' => $file
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded",
'method' => 'POST',
'content' => http_build_query($data),
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
🛡️ Admin Panel Features
- Add/Edit Employees
- Generate Slips by Month
- View/Download Previous Slips
- Send All Slips via WhatsApp
- Filter by Employee or Date
📦 Final Notes
You can implement this with Bootstrap for frontend, PHP for backend, and integrate any WhatsApp API provider. The slip can be generated with DOMPDF or TCPDF libraries.
Need help setting this up completely? You can request a full ZIP with everything pre-built including login, admin dashboard, database setup, and ready-to-deploy WhatsApp integration.