ELMS — Employee Lifecycle Management System
A full-stack HRIS covering the entire employee lifecycle from recruitment to confirmation. Built with PHP 8 + MySQL + vanilla JavaScript.
9
Core Modules
22+
Database Tables
40+
API Endpoints
System Flow
Architecture
Backend
- PHP 8.x with PDO/MySQL
- RESTful JSON API endpoints
- Transaction support for multi-step operations
- Lifecycle logging via
addCandidateLog()
Frontend
- Vanilla JavaScript (no framework)
apiGet()/apiPost()fromajax/common.js- Quill.js rich-text editor for letters
- Modal system, accordion, step wizard
Key Patterns
- Shared endpoint:
list_offers.phpserves offer_letter, response, approval, and employee modules with query param filters - Template engine:
templates/ajax/render.phpresolves{{TAG}}placeholders via module-specific render files - Step wizard:
employee/create.phpuses a 6-step non-interactive stepper with auto-fill from candidate data - Salary auto-calc: Basic=57.1425%, House Rent=50% of Basic, Medical=10%, Conveyance=15%; tax fetched via AJAX
Database — Entity Relationship Diagram
Database: elms | Engine: InnoDB | Charset: utf8mb4
┌─────────────────────┐ ┌──────────────────────┐
│ departments │ │ candidate_statuses │
├─────────────────────┤ ├──────────────────────┤
│ PK id │ │ PK id │
│ name │ │ code (UNI) │
│ code │ │ name │
└────────┬────────────┘ │ sort_order │
│ 1:N └────────┬─────────────┘
┌────┴──────────────┐ │ 1:N
│ designations │ ┌───┴──────────────────┐
├───────────────────┤ │ candidates │
│ PK id │ ├───────────────────────┤
│ FK dept_id ───────┼──┐ │ PK id │
└───────────────────┘ │ │ FK job_id → requisitions
│ │ FK status_id → statuses
┌─────────────────────┐ │ │ first_name, last_name
│ requisitions │ │ │ email, phone, nid
├─────────────────────┤ │ │ gender, dob
│ PK id │ │ │ present_address
│ FK dept_id ─────────┼───┘ │ permanent_address
│ title, vacancies │ │ current_salary
│ salary_min/max │ │ expected_salary
└─────────────────────┘ └───────────┬───────────┘
│ 1:N
┌──────────────────┬───────────────┼──────────────┐
│ │ │ │
┌────┴─────────┐ ┌────┴──────┐ ┌─────┴─────┐ ┌────┴──────────┐
│candidate_logs│ │screenings│ │interview_log│ │salary_proposals│
├──────────────┤ ├───────────┤ ├───────────┤ ├───────────────┤
│FK candidate_id│ │FK cand_id │ │FK cand_id │ │FK candidate_id│
│ action │ │ rating │ │ round │ │ proposed_sal │
│ from/to_status│ │ result │ │ scores │ │ salary_breakd │
└──────────────┘ └───────────┘ │ decision │ │ (JSON) │
└───────────┘ │ status │
└───────┬───────┘
│
┌─────────────────────────────────────┘
│
┌─────────────────────┴────────────────────────────────────────────┐
│ offers │
├──────────────────────────────────────────────────────────────────┤
│ PK id │ FK candidate_id │ FK designation_id │ FK dept_id │
│ salary │ joining_date │ probation_months │ status │
│ response_status │ responded_at │ response_notes │
│ sent_at │ accepted_at │
└──────────┬──────────────────────────┬───────────────────────────┘
│ 1:N │ 1:N
┌──────────┴───────────┐ ┌──────────┴─────────────────────┐
│ offer_letters │ │ offer_approvals │
│ FK offer_id │ │ FK offer_id │
│ letter_content │ │ level, approver, status │
│ status: Draft→Gen→Sent│ └───────────────────────────────┘
│ generated_at, sent_at │
│ sent_to_email │ ┌───────────────────────────────┐
└───────────────────────┘ │ offer_email_log │
│ FK offer_id, recipient │
│ subject, body, sent_at │
└───────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ TEMPLATE SYSTEM │
├─────────────────────────────────────────────────────────────────┤
│ template_modules: module_name, render_file │
│ letter_templates: name, type (=module), content (HTML+{{TAGS}}) │
│ merge_tags: type, tag, label │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ PROBATION MODULE │
├─────────────────────────────────────────────────────────────────┤
│ probation_appraisals: employee_id → PBI_ID │
│ end_date, overall_score, recommendation, status │
│ probation_categories: name, weight % │
│ probation_scores: appraisal_id + category_id → score │
│ probation_workflow: appraisal_id + level + status │
│ Levels: Self Assessment → Supervisor → Dept Head │
│ → HR Review → GM → Managing Director │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ EMPLOYEE / CONFIRMATION │
├─────────────────────────────────────────────────────────────────┤
│ personnel_basic_info: PBI_ID, PBI_CODE, PBI_NAME, offer_id │
│ EMPLOYMENT_TYPE, dept_id, DESG_ID, 70+ fields │
│ salary_info: PBI_ID, offer_id, 50+ salary fields │
│ confirmation_letters: employee_id → PBI_ID │
│ letter_content, employment_type, status │
│ Draft → Generated → Approved → Sent │
└─────────────────────────────────────────────────────────────────┘
Module 1: Recruitment & Candidate Pipeline
Purpose
Manage job requisitions and track candidates through the hiring pipeline with full audit logging.
Workflow
Key Tables
| Table | Purpose | Key Fields |
|---|---|---|
departments | Org departments | id, name, code |
designations | Job designations | id, name, code, dept_id FK |
requisitions | Job postings | title, dept_id, vacancies, salary_min/max, skills, status |
candidates | Applicants | job_id FK, first_name, last_name, email, phone, nid, gender, dob, status_id FK |
candidate_statuses | Lookup statuses | code (UNI), name, sort_order |
candidate_logs | Audit trail | candidate_id FK, action, from_status, to_status, notes, created_by |
Status Flow
Applied → Screened → Shortlisted → Interviewed → Selected → Offered → Hired
│ │ │ │
└─────────┴────────────┴──────────────┴→ Rejected (at any stage)
Module 2: Screening & Interview
Workflow
Key Tables
| Table | Purpose |
|---|---|
screenings | FK candidate_id, screened_by, rating, comm_score, exp/skill/edu_match, result |
interview_log | FK candidate_id, round, type, interviewer, 4 scores, rating, decision, is_final_round |
Module 3: Salary Proposal
Workflow
Salary Breakdown JSON
{
"gross_salary": 50000,
"basic": 28571.25,
"house_rent": 14285.63,
"medical_allowance": 2857.13,
"conveyance_allowance": 4285.69,
"total_salary": 50000,
"personal_pf": 0,
"pf_deductible": 0,
"monthly_income_tax": 0,
"total_payable": 50000
}
Key Files
| File | Purpose |
|---|---|
offer_management/salary_breakdown.php | Interactive salary calculator UI |
offer_management/proposal.php | Proposal list page |
offer_management/ajax/proposal_create.php | Save proposal with salary_breakdown JSON |
offer_management/ajax/proposal_submit.php | Submit for approval |
offer_management/ajax/proposal_approve.php | Approve/reject/finalize proposal |
offer_management/ajax/proposal_finalize.php | Finalize → creates offer |
offer_management/ajax/get_taxinfo_ajx.php | Bangladesh tax calculator (FY 2024-25) |
Module 4: Offer Management
Workflow
Offer Status Flow
Pending → Approved → (letter generated/sent) → Accepted / Rejected
↘ Rejected
Key Tables
| Table | Purpose |
|---|---|
offers | candidate_id FK, salary, joining_date, designation_id FK, dept_id FK, probation_months, status, response_status, response_notes |
offer_approvals | offer_id FK, level, approver, status (Pending/Approved/Rejected), comment |
Key Files
| File | Purpose |
|---|---|
offer_management/approval.php | Offer approval page (Pending/Ready/History tabs) |
offer_management/ajax/create.php | Creates offer + first approval level, updates candidate to "Offered" |
offer_management/ajax/approve.php | Approve/reject offer at each level |
offer_management/ajax/list_offers.php | Central query — supports status, response_status, letter_status, with_letter filters |
Module 5: Offer Letter Generation & Send
Workflow
Template Merge Tags (Offer)
| Tag | Source |
|---|---|
| {{CANDIDATE_NAME}} | candidates.first_name + last_name |
| {{DESIGNATION}} | designations.name |
| {{JOB_TITLE}} | requisitions.title |
| {{DEPARTMENT}} | departments.name |
| {{SALARY}} | offers.salary |
| {{JOINING_DATE}} | offers.joining_date |
| {{PROBATION_MONTHS}} | offers.probation_months |
| {{COMPANY_NAME}} | Hardcoded: TechCorp International |
| {{HR_NAME}} | Hardcoded: HR Department |
| {{DATE}} | Current date |
| {{RESPONSE_DATE}} | Current date + 14 days |
| {{SALARY_BREAKDOWN}} | HTML table from salary_proposals.salary_breakdown JSON |
Module 6: Candidate Response
Workflow
Response Status Flow
Pending → Accepted → (ready for employee creation)
↘ Rejected
Module 7: Employee Creation (6-Step Wizard)
Workflow
Step 6: Salary Setup
Employment Types
Casual | Apprentice | Probationer (default) | Temporary | Replace | Permanent | Seasonal | Contractual | Regular
Key Tables
| Table | Purpose |
|---|---|
personnel_basic_info | 70+ employee fields: PBI_CODE, PBI_NAME, PBI_EMAIL, EMPLOYMENT_TYPE, dept_id, DESG_ID, offer_id, candidate_id |
salary_info | 50+ salary fields: gross_salary, basic_salary, house_rent, total_payable, m_income_tex, pf, pf_deductible, ac_no, etc. |
Module 8: Probation Appraisal
Workflow
Multi-Level Workflow
| Level | Order | Action |
|---|---|---|
| Self Assessment | 1 | Employee self-review |
| Supervisor | 2 | Direct manager evaluation |
| Dept Head | 3 | Department head review |
| HR Review | 4 | HR department assessment |
| GM | 5 | General Manager approval |
| Managing Director | 6 | Final approval (last level) |
Key Tables
| Table | Purpose |
|---|---|
probation_appraisals | employee_id (→PBI_ID), joining_date, probation_months, end_date, overall_score, recommendation, status |
probation_categories | name, weight %, sort_order |
probation_scores | appraisal_id FK, category_id FK, score, comments |
probation_workflow | appraisal_id FK, level, status (Pending/Approved/Sent Back/Rejected), approved_by, comments |
Key Files
| File | Purpose |
|---|---|
probation/list.php | Appraisal list page |
probation/approve.php | Multi-level approval page with accordion UI |
probation/ajax/eligible_employees.php | Employees where candidate_id IS NOT NULL AND EMPLOYMENT_TYPE='Probationer' |
probation/ajax/employees_list.php | Same filter + appraisal count |
probation/ajax/appraisals_get.php | Full join through PBI + offers, screenings via pbi.candidate_id |
probation/ajax/appraisals_submit.php | Submits scores + advances workflow |
probation/ajax/approval_action.php | Approve/sendback/reject workflow level |
probation/ajax/approval_list.php | Pending approvals with next workflow level |
Module 9: Confirmation
Workflow
Template Merge Tags (Confirmation)
| Tag | Source |
|---|---|
| {{EMPLOYEE_NAME}} | pbi.PBI_NAME + last_name |
| {{EMPLOYEE_CODE}} | pbi.PBI_CODE |
| {{DESIGNATION}} | designations.name |
| {{DEPARTMENT}} | departments.name |
| {{SALARY}} | offers.salary or salary_info.gross_salary |
| {{JOINING_DATE}} | offers.joining_date or PBI_DOJ |
| {{CONFIRMATION_DATE}} | joining_date + probation_months |
| {{PROBATION_MONTHS}} | offers.probation_months |
| {{COMPANY_NAME}} | Hardcoded: TechCorp International |
| {{HR_NAME}} | Hardcoded: HR Department |
| {{DATE}} | Current date |
| {{PHONE}} | pbi.PBI_MOBILE |
| {{EMAIL}} | pbi.PBI_EMAIL |
| {{GENDER}} | pbi.PBI_SEX |
| {{SALARY_BREAKDOWN}} | HTML table from salary_info |
Confirmation Status Flow
Draft → Generated → Approved → Sent
Key Files
| File | Purpose |
|---|---|
confirmation/list.php | Eligible employees (probation completed) |
confirmation/generate.php | Letter generation with Quill + template + employee type |
confirmation/confirmation_letters.php | Letter list with Preview/Approve/Send actions |
confirmation/ajax/migrate.php | Creates confirmation_letters table |
confirmation/ajax/list_eligible.php | Completed probation employees |
confirmation/ajax/list_letters.php | Confirmation letters with employee data |
confirmation/ajax/letter_generate.php | Save/update generated letter |
confirmation/ajax/letter_view.php | Fetch letter for preview |
confirmation/ajax/letter_approve.php | Approve/reject letter |
confirmation/ajax/letter_send.php | Mark as sent with email |
confirmation/ajax/render_template.php | Resolve {{TAGS}} for confirmation |
templates/render/confirmation.php | getConfirmationTagMap() — 15 tags |
Template Engine System
Architecture
Registered Modules
| Module | Render File | Function | Tags |
|---|---|---|---|
Offer | templates/render/offer.php | getOfferTagMap() | 12 tags |
Confirmation | templates/render/confirmation.php | getConfirmationTagMap() | 15 tags |
Probation | templates/render/probation.php | getProbationTagMap() | TBD |
General | templates/render/general.php | getGeneralTagMap() | TBD |
Default Templates
| Name | Type | Seeded By |
|---|---|---|
| Standard Offer Letter | Offer | templates/ajax/migrate.php |
| Confirmation Letter Template | Confirmation | templates/ajax/seed_confirmation.php |
Salary Calculation Logic
Auto-Calculation Formula
| Component | Formula | Example (Gross=50,000) |
|---|---|---|
| Basic Salary | Gross × 0.571425 | 28,571.25 |
| House Rent | Basic × 0.5 | 14,285.63 |
| Medical Allowance | Basic × 0.1 | 2,857.13 |
| Conveyance Allowance | Basic × 0.15 | 4,285.69 |
| Total Salary | = Gross | 50,000.00 |
| Total Payable | Total Salary − Personal PF − PF Deductible − Monthly Tax | Varies |
Tax Calculation (Bangladesh FY 2024-25)
Endpoint: GET offer_management/ajax/get_taxinfo_ajx.php?gross_salary=X&basic_salary=Y&gender=male|female
Response
{ "success": true, "tax": 500.00, "annual_tax": 6000.00, "taxable_income": 60000.00 }
Logic
- Annual taxable income = Gross × 12 − exemptions (10% of basic, 30% of basic, 10% of basic = 50% of basic total)
- Minimum taxable: 3,50,000 BDT for males, 4,00,000 for females
- Tax slabs: First 3.5L = 0%, 3.5-5L = 5%, 5-8L = 10%, 8-12L = 15%, 12-16L = 20%, 16-20L = 25%, 20L+ = 30%
- Minimum annual tax: 5,000 BDT
- Monthly tax = annual_tax / 12
Lifecycle Logging
All key actions are logged via addCandidateLog($pdo, $candidateId, $action, $from, $to, $notes) in includes/functions.php.
| Action | Module | When |
|---|---|---|
offer_created | Offer | Offer created for candidate |
offer_approved | Offer | All approval levels passed |
offer_rejected | Offer | Rejected at any approval level |
offer_letter_generated | Letter | Letter content saved |
offer_sent | Letter | Email logged as sent |
offer_accepted | Response | Candidate accepted offer |
offer_rejected_candidate | Response | Candidate rejected offer |
probation_approved | Probation | Approved at a workflow level |
probation_completed | Probation | All levels approved |
probation_sentback | Probation | Sent back to previous level |
probation_rejected | Probation | Rejected at any level |
Lifecycle timeline viewable at lifecycle/view.php.
API Endpoints Reference
Offer Management
offer_management/ajax/create.php — Create offer + first approvaloffer_management/ajax/approve.php — Approve/reject offeroffer_management/ajax/list_offers.php — Central offer list (status, response_status, letter_status, with_letter params)offer_management/ajax/letter_generate.php — Save offer letteroffer_management/ajax/letter_view.php — Preview offer letteroffer_management/ajax/letter_send.php — Send offer letter emailoffer_management/ajax/respond.php — Record candidate responseoffer_management/ajax/proposal_create.php — Create salary proposaloffer_management/ajax/proposal_submit.php — Submit for approvaloffer_management/ajax/proposal_approve.php — Approve/reject proposaloffer_management/ajax/proposal_finalize.php — Finalize proposaloffer_management/ajax/get_taxinfo_ajx.php — Tax calculationEmployee
employee/ajax/save.php — Create employee (personnel_basic_info)employee/ajax/save_salary.php — Save salary infoemployee/ajax/get_candidate.php — Get offer + employee + salary dataemployee/ajax/list_offers.php — List accepted offers ready for employee creationProbation
probation/ajax/eligible_employees.php — Probationer employeesprobation/ajax/employees_list.php — Employees + appraisal countprobation/ajax/appraisals_list.php — Appraisals with scoresprobation/ajax/appraisals_get.php — Full appraisal detailprobation/ajax/appraisals_submit.php — Submit scores + advance workflowprobation/ajax/appraisals_update.php — Update scoresprobation/ajax/approval_action.php — Approve/sendback/reject levelprobation/ajax/approval_list.php — Pending approvalsConfirmation
confirmation/ajax/list_eligible.php — Completed probation employeesconfirmation/ajax/letter_generate.php — Generate confirmation letterconfirmation/ajax/list_letters.php — List confirmation lettersconfirmation/ajax/letter_view.php — Preview confirmation letterconfirmation/ajax/letter_approve.php — Approve/reject letterconfirmation/ajax/letter_send.php — Send confirmation letterconfirmation/ajax/render_template.php — Resolve confirmation tagsTemplates
templates/ajax/templates_list.php — List templates (type param)templates/ajax/render.php — Render template tags (module, record_id, content)File Structure
ELMS-final/
├── ajax/common.js # apiGet(), apiPost(), formatCurrency(), filterTable()
├── includes/
│ ├── config.php # getDB(), ROOT_PATH, APP_SHORT
│ ├── functions.php # addCandidateLog()
│ ├── layout.php # Master layout (sidebar + content)
│ └── sidebar.php # Navigation with all modules
├── candidates/ # Candidate CRUD
├── screening/ # Screening forms
├── interview/ # Interview rounds
├── requisition/ # Job requisitions
├── offer_management/
│ ├── index.php # Overview dashboard
│ ├── proposal.php # Salary proposal list
│ ├── salary_breakdown.php # Interactive salary calculator
│ ├── proposal_approval.php # Proposal approval (Pending/Finalized/Rejected)
│ ├── approval.php # Offer approval (Pending/Ready/History)
│ ├── letter.php # Offer letter list + send
│ ├── generate_letter.php # Letter generation (Quill + templates)
│ ├── response.php # Candidate response (Pending/Responded)
│ └── ajax/ # 12+ AJAX endpoints
├── employee/
│ ├── list.php # Offers ready for employee creation
│ ├── create.php # 6-step wizard
│ ├── view.php # Employee profile (6 tabs including Salary)
│ ├── salary_information.php # Standalone salary form
│ └── ajax/ # save.php, save_salary.php, get_candidate.php
├── probation/
│ ├── list.php # Appraisal list
│ ├── approve.php # Multi-level approval
│ └── ajax/ # 8 AJAX endpoints
├── confirmation/
│ ├── list.php # Eligible employees
│ ├── generate.php # Letter generation (Quill + templates + emp type)
│ ├── confirmation_letters.php # Letter list (Preview/Approve/Send)
│ └── ajax/ # 7 AJAX endpoints
├── templates/
│ ├── list.php # Template CRUD
│ ├── tags.php # Merge tag management
│ ├── render/ # Module-specific tag resolvers
│ │ ├── offer.php # getOfferTagMap() — 12 tags
│ │ ├── confirmation.php # getConfirmationTagMap() — 15 tags
│ │ └── probation.php # getProbationTagMap()
│ └── ajax/ # render.php, templates_list.php, migrate.php
├── lifecycle/
│ └── view.php # Timeline view of all candidate actions
└── docs/
├── system-logic.md # Phase-by-phase system logic
├── database-erd.md # Full ERD + table schemas
├── elms-erd.dbml # DBML format ERD
└── documentation.html # This file
Status State Machines
Candidate Status
Applied → Screened → Shortlisted → Interviewed → Selected → Offered → Hired ↗ Rejected (at any stage)
Offer Status
Pending → Approved → (letter flow)
↘ Rejected
Offer Response
Pending → Accepted
↘ Rejected
Offer Letter
Draft → Generated → Sent
Salary Proposal
Draft → Proposed → Pending_Approval → Approved → Finalized ↗ Rejected (can revise)
Probation Appraisal
Draft → In Progress → Completed
↘ Rejected
↗ Sent Back (to Draft)
Probation Workflow
Pending → Approved
↘ Rejected
↘ Sent Back
Confirmation Letter
Draft → Generated → Approved → Sent
↘ Rejected
Documentation Files
Download or view the full documentation files for deeper reference. These files contain detailed schemas, complete system logic diagrams, and importable ERD definitions.
System Logic Diagram
MarkdownPhase-by-phase system flow with ASCII diagrams covering all 9 modules: Recruitment, Screening, Salary Proposal, Offer, Letter Generation, Response, Template Engine, Probation, and Confirmation.
- 9 phase diagrams with file references
- Data flow summary
- All status state machines
Database ERD
MarkdownFull entity relationship diagram with all 23 tables, complete field schemas, foreign key constraints, and ASCII ERD visualization.
- 23 table schemas with types and keys
- 20 foreign key constraints
- ASCII ERD with relationships
DBML ERD Definition
DBMLImportable DBML file for dbdiagram.io. Paste this code to generate a visual, shareable ERD diagram instantly.
- All 23 tables with column types
- FK references between tables
- Ready to paste into dbdiagram.io
For more details, download and view the files above. The DBML file can be imported directly into dbdiagram.io to generate an interactive ERD.
ELMS Documentation — Generated July 2026