Skip to content

pasmin401/absencsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AttendTrack – Attendance Management System

A full-stack PHP attendance management app with GPS check-in, selfie capture, overtime tracking, and admin reporting. Deployed on Vercel with Vercel Postgres (Neon).


🌐 Live URL

https://absencsm.vercel.app


πŸ—‚οΈ Project Structure

vercel-app/
β”œβ”€β”€ vercel.json                  ← Vercel routing config
β”œβ”€β”€ api/                         ← All PHP files (serverless functions)
β”‚   β”œβ”€β”€ config.php               ← DB connection, sessions, auth helpers
β”‚   β”œβ”€β”€ functions.php            ← All app functions
β”‚   β”œβ”€β”€ index.php                ← Login page
β”‚   β”œβ”€β”€ dashboard.php            ← User attendance panel
β”‚   β”œβ”€β”€ register.php             ← New account registration
β”‚   β”œβ”€β”€ logout.php               ← Session destroy + redirect
β”‚   β”œβ”€β”€ profile.php              ← Edit username / password / photo
β”‚   β”œβ”€β”€ forgot-password.php      ← Token-based password reset
β”‚   β”œβ”€β”€ install.php              ← One-click DB table installer
β”‚   β”œβ”€β”€ attendance-action.php    ← JSON API for check-in/out
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”œβ”€β”€ index.php            ← Admin dashboard (Chart.js)
β”‚   β”‚   β”œβ”€β”€ users.php            ← User CRUD + work schedule
β”‚   β”‚   └── reports.php          ← Reports + CSV / Excel export
β”‚   └── includes/
β”‚       └── nav.php              ← Shared sidebar + topbar
└── public/
    └── assets/
        β”œβ”€β”€ css/style.css        ← Full stylesheet (responsive)
        └── logo.svg             ← App logo

βš™οΈ Tech Stack

Layer Technology
Backend PHP 8.2 (Vercel serverless via vercel-php@0.7.2)
Database PostgreSQL (Vercel Postgres / Neon)
Frontend Vanilla JS + Chart.js
Hosting Vercel
Auth PHP sessions stored in Postgres
Styling Custom CSS (DM Sans + DM Mono)

πŸ—„οΈ Database Schema

Tables

Table Description
users Employees and admins
attendance Check-in/out records per day
password_resets Password reset tokens
php_sessions Server-side session storage (required for Vercel)

Key columns β€” users

Column Type Notes
id SERIAL Primary key
username VARCHAR(30) Unique
email VARCHAR(100) Unique
password VARCHAR(255) bcrypt hashed
role VARCHAR(10) user or admin
work_start TIME Scheduled start time
work_end TIME Scheduled end time
is_active SMALLINT 1 = active, 0 = disabled

Key columns β€” attendance

Column Type Notes
user_id INT FK β†’ users.id
work_date DATE Unique per user per day
checkin_time TIME Regular check-in
checkin_lat/lng DECIMAL GPS coordinates
checkin_photo VARCHAR Saved filename
ot_checkin_time TIME Overtime check-in
status VARCHAR present, absent, leave, holiday

πŸš€ Deployment Guide

1. Clone and push to GitHub

git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourname/attendtrack.git
git push -u origin main

2. Import to Vercel

  1. Go to vercel.com β†’ Add New Project
  2. Import your GitHub repo
  3. Vercel auto-detects vercel.json β€” click Deploy

3. Add Vercel Postgres

  1. Vercel Dashboard β†’ Storage β†’ Create Database β†’ Postgres
  2. Connect it to your project
  3. Environment variables (PGHOST, PGDATABASE, etc.) are injected automatically

4. Run the database schema

  1. Vercel Dashboard β†’ Storage β†’ your DB β†’ Query tab
  2. Paste and run schema_postgres.sql

πŸ”‘ Default Accounts

Role Username Password
Admin admin Admin@123
User john_doe User@123
User jane_smith User@123
User ali_rahman User@123
User siti_nurhaliza User@123
User budi_santoso User@123

⚠️ Change all passwords after first login.


✨ Features

User

  • πŸ” Login / Register / Forgot Password
  • πŸ“ GPS-verified Check-In & Check-Out
  • πŸ“Έ Selfie photo at every check-in
  • ⏱️ Overtime Check-In & Check-Out
  • πŸ• Live clock display
  • πŸ‘€ Edit profile, change password, upload photo

Admin

  • πŸ“Š Dashboard with Chart.js weekly trend
  • πŸ‘₯ User Management (create, edit, delete, set work schedule)
  • πŸ“‘ Attendance Reports with filters
  • πŸ“₯ Export to CSV and Excel
  • πŸ”’ Role-based access control

🌍 URL Routes

URL Page
/ Login
/dashboard User dashboard
/register Register
/profile My profile
/forgot-password Password reset
/logout Logout
/admin/index Admin dashboard
/admin/users User management
/admin/reports Reports & export
/api/attendance-action Check-in/out API (POST)

πŸ”§ Configuration

All settings are in api/config.php:

define('APP_NAME',       'AttendTrack');
define('SESSION_TIMEOUT', 3600);        // 1 hour
define('TIMEZONE',        'Asia/Jakarta');

Database credentials are read from Vercel environment variables automatically:

$host     = $_ENV['PGHOST'];
$dbname   = $_ENV['PGDATABASE'];
$user     = $_ENV['PGUSER'];
$password = $_ENV['PGPASSWORD'];

⚠️ Known Limitations

Issue Reason Workaround
Photo uploads are temporary Vercel filesystem is read-only (uses /tmp) Integrate Cloudinary or AWS S3
Cold starts Vercel spins up containers on demand Normal for serverless β€” first load may be slow
Sessions stored in DB Vercel containers don't share /tmp Already implemented via php_sessions table

πŸ“¦ Local Development

# Requires PHP 8.x + PostgreSQL
php -S localhost:8000 -t api/

# Or use Laravel Valet / XAMPP with a local Postgres DB
# Update config.php with local DB credentials

πŸ“„ License

MIT β€” free to use and modify.