Add configurable role management, expanded project permission coverage, secured module routes, and single-active-session enforcement with online user administration.
Integrate Final Diagnosis with canonical disease master data and add reusable My/Master template CRUD for discharge narrative sections, including summary investigations, course, other advice, and discharge summary.
Restore surgery and procedure bindings after SPA updates, validate procedure dates without SQL errors, and prevent medicine autocomplete Enter from submitting while preserving layout and autofill.
Load referral master data into patient registration/edit screens, persist patient referby, expose searchable referral inputs in patient and IPD forms, and make referral title editable as free text in referral master CRUD.
- Add checkForUpdates() with 10-minute cached GitHub API check
- Add fetchLatestCommitInfo() to get latest commit SHA + message from GitHub API
- Save deployed commit SHA to writable/deployed_commit.txt after each deploy
- Invalidate update cache on successful deploy so next check is always fresh
- Button turns yellow + red NEW badge when update available
- Show commit message and short SHA diff (deployed → latest) in alert
- Show green 'Up to date' with deployed SHA when already current
- GitHub API rate limit safe: checks once per 10 mins via file cache
- Remove initial 'running' history entry (orphans when PHP times out)
- Add purgeStaleRunning() to mark old 'running' entries as 'timeout' on next deploy
- Add set_time_limit(300) to prevent PHP timeout during large ZIP download
- Add timestamps to log file entries for easier debugging
- Include ZIP size and source URL in success detail
- History now keeps last 20 entries (was 12)
- Show dash instead of blank for entries with no detail
- Style 'timeout' status same as 'failed' (red pill)
- Move detail modal from system_ops_panel.php to system_ops.php
- Modal is now outside #systemOpsPanel so panel refresh never destroys it
- Skip refreshPanel() while modal is open (prevents backdrop desync)
- Add hidden.bs.modal handler to clean up lingering backdrop and body classes
- Fix show.bs.modal handler to correctly read data-detail via jQuery .data()
- Add white-space:pre-wrap to detail content for readable log output
- readNetworkStatus() now returns array of all interfaces instead of single string
- Parses 'ip addr' output (with ifconfig fallback) for all IPv4 interfaces
- Each interface classified as LAN / VPN / Public by name and IP range
- VPN detected by interface prefix: wg*, tun*, tap*, vpn*
- RFC1918 ranges (192.168.x, 10.x, 172.16-31.x) shown as LAN
- Display: icon + IP + interface name badge + type label per row
- Handles NAT servers showing both local LAN and VPN IPs simultaneously
- Remove Restart Web, Restart PHP-FPM, Shutdown, Reboot buttons
- Remove runServerAction() library method and action() controller
- Remove /system-ops/action route (no longer needed)
- Parse /proc/mdstat into structured array (name, level, health, drives)
- Show each RAID array as a card with colored drive icons per-slot
- Green drive = healthy, red = failed, blue = spare
- Show rebuild progress bar when array is rebuilding
- Internet status shown as colored badge with wifi icon
- Services shown as colored badges (green=running, grey=other)
- Remove 'Update HMS (Git)' button and related functionality
- Remove runUpdate() method from SystemOperations
- Remove update() controller method
- Remove /setting/admin/system-ops/update route
- Remove setup_git_config.sh (no longer needed)
- Keep 'Deploy from GitHub' button as the only update method
- Rationale: Direct GitHub deployment is more reliable and requires no git config
Result: Single, simpler deployment method that always works
- Add POST route for /setting/admin/system-ops/updateDirect
- Add GET route for /setting/admin/system-ops/diagnose
- Both endpoints were implemented but routes were missing
This fixes 'Request failed' error on Deploy from GitHub button
- New 'Deploy from GitHub' button downloads latest code directly
- No git configuration required - more reliable for git-unfriendly servers
- Automatically syncs changed files (skips .git, vendor, writable)
- Both methods available: git pull (if configured) or direct GitHub download
- Each has a clear confirmation dialog explaining the method
- Handles temporary extraction and cleanup automatically
This solves HMS deployment when git is not accessible to PHP process
Enhanced error reporting:
- Show detailed diagnostic information: git version, user config, email, remote, branch
- Check .git directory and config file existence
- Detect if repository has uncommitted changes
- Error categorization: PERMISSION, CONFIG, REPO, NETWORK, SSL, GIT errors
- Actionable error messages with command suggestions
- Report raw error output to log file for debugging
Added setup_git_config.sh script:
- Automated configuration for www-data user
- Creates .ssh directory with proper permissions
- Sets git user.name and user.email globally
- Disables SSL verification (for HTTPS repos)
- Configures git to use HTTPS remote URL
- Fixes directory ownership and permissions
- Tests git status to verify configuration
Usage on live server:
sudo bash setup_git_config.sh
This script handles the common git configuration issues
that prevent 'Update HMS' button from working.
- Added findGitCommand() method to check for git in common locations:
* /usr/bin/git (standard Linux)
* /bin/git (alternative location)
* /usr/local/bin/git (compiled from source)
* Falls back to 'which git' and 'command -v git'
- Uses absolute git path in all shell commands
- Fixes 'Git command not found' error on systems where git is not in PATH
- No dependencies added, uses PHP file_exists() + is_executable() checks
Pre-checks before git pull:
- Verify .git directory exists
- Check if git command is available
- Run git status to detect permission/connectivity issues
Better error messages for common failures:
- Permission denied → 'Git directory may not be writable'
- Authentication failed → 'SSH keys may not be configured for www-data'
- Connection refused → 'GitHub server unreachable'
- fatal errors → Parse and return specific error details
Returns actual error message instead of generic 'Check logs for details'
- Method 1: ping to Google DNS (8.8.8.8)
- Method 2: DNS resolution via nslookup
- Method 3: DNS query using dig
- Method 4: curl HTTP HEAD to google.com
- Method 5: wget --spider
- Method 6: fsockopen to Google DNS (8.8.8.8:53)
- Method 7: curl to Cloudflare DNS (1.1.1.1)
- Method 8: PHP gethostbyname() for DNS resolution
Tries multiple DNS providers (Google, Cloudflare, Quad9)
Falls back to 'Offline' only if all methods fail
Handles firewalls, ICMP blocks, and missing commands
- Method 1: \['SERVER_ADDR'] from Apache/Nginx (most reliable)
- Method 2: /sbin/ip (absolute path, works if ip not in PATH)
- Method 3: Parse /proc/net/route for default gateway interface + IP
- Method 4: hostname -I (space-separated IPs)
- Method 5: ifconfig (fallback for older systems)
- Method 6: Socket connection to 8.8.8.8 (pure PHP, no shell commands)
Each method validates IP and skips loopback (127.x, ::1, ::ffff:127.x)
Fixes 'Unavailable' when shell commands fail or aren't available
- Changed primary method to: ip -4 addr show scope global (gets public/private IPs only)
- Added isLoopbackIp() helper to filter out loopback addresses (127.* and ::1)
- Fallback: hostname -I with loopback filtering
- Last resort: gethostbyname() with loopback check
- On remote server with eth0: 159.89.175.190, will now show public IP instead of 127.0.0.1
Three-level fallback chain:
1. gethostbyname(gethostname()) - PHP built-in, works on Linux and Windows
2. ip -4 addr show scope global | grep inet - Linux shell fallback
3. hostname -I - Linux shell secondary fallback
All results validated with FILTER_VALIDATE_IP before display.
- Added "View HMS Features & Capabilities" link below the login card
- Copied HMS_FEATURES_PRESENTATION.html to public/ so it is accessible
via base_url without auth (same pattern as software-use-license.html)
- Link opens in a new tab
- HMS_FEATURES_PRESENTATION.html: full styled presentation with cover,
professional introduction, 11 feature sections, tech stack, compliance,
print/PDF button, and proper @media print A4 layout
- HMS_FEATURES_PRESENTATION.md: plain Markdown version of the same content
- system_ops.php: fix confirm dialog text for Update HMS button
- Added "Details" column to Update History table
- Shows info icon button when error details are available
- Clicking button opens a modal with full error message
- Details displayed in pre-formatted text for easy reading
- Helps diagnose why HMS updates failed or timed out
When an update fails, users can now click the info icon to see the exact
git error output, making troubleshooting much easier.
Update improvements:
- Renamed button from "Update System" to "Update HMS"
- Changed update to run only 'git pull' (removed database migrations)
- Added 60-second timeout to prevent system hangup
- Better error messages for timeouts and failures
- Logs update status (running/success/failed/timeout) to history
- Confirmation dialog now says "Pull latest HMS code from repository?"
This ensures quick updates without long-running migrations that could hang
the admin interface. Database migrations can be run separately as needed.
Resource Usage improvements:
- Added visual progress bars for CPU, RAM, and Disk usage
- Progress bars use Bootstrap styling (success/info/warning colors)
- Display percentage and detailed metrics (e.g., RAM 4 / 128 MB (3%))
- Bars animate smoothly with CSS transitions
CPU detection enhancements:
- Added fallback to /proc/stat parsing when shell commands unavailable
- Added fallback to PHP getrusage() for CPU time estimation
- CPU now displays even when shell_exec is disabled
- Graceful fallback chain ensures data is always available
Progress bar styling:
- Success (green) for CPU
- Info (blue) for RAM
- Warning (orange/yellow) for Disk
- All bars styled with height, rounded corners, and smooth transitions
When shell_exec() is disabled on the server (common in production), the system
operations panel now gracefully falls back to PHP built-in functions:
- gethostname() for hostname instead of shell 'hostname' command
- php_uname() for OS info instead of shell 'uname -a' command
- /proc/uptime parsing or unavailable status for uptime
- disk_free_space() and disk_total_space() for disk usage
- memory_get_usage() and PHP memory limit for memory usage
- Improved parsePhpMemoryLimit() to handle memory limit parsing
This ensures the admin panel shows meaningful information even in restricted
production environments where shell_exec is disabled for security reasons.
- Added System Operations link to Admin dashboard (app/Views/Setting/Admin/index.php)
- Uses load_form_div to load the system operations page inline
- Added SystemOperations library for server status collection and actions
- Tile uses server icon (bi-server) and appears in the admin panel grid
- Link: javascript:load_form_div(base_url('setting/admin/system-ops'), 'maindiv', 'System Operations')
- Added SystemOps controller with index and panel endpoints for dynamic content refresh
- Created system_ops_panel.php fragment for AJAX-based UI updates (no full page reload)
- Implemented 30-second auto-refresh using AJAX instead of location.reload()
- Fixed health badge contrast by adding explicit dark text color (#1f2937)
- Added jQuery availability checks to prevent script errors on page load
- Included server overview, resource usage, services, events, and update history
- Integrated delegated event handlers for action buttons (Update, Restart, Reboot, Shutdown)
- All buttons are protected with confirmation dialogs
- Layout maintains NiceAdmin card styling and responsive design
Routes added:
- GET /admin/system-ops/panel - returns panel fragment for refresh
- Diagnosis.php: resolve doctor mapping via ABDM Report Doctor Mapping,
compile pathology/diagnosis reports into separate Letter Head and
Plain Paper PDFs, add compiled-pdf-links endpoint
- Routes.php: add diagnosis/compiled-pdf-links route
- pathology_detail.php: render/persist dual compiled PDF buttons
- Setting/Template.php: per-modality Letter Head / Plain Paper template
mapping via hospital_setting keys
- Setting/Template/index.php: fix tile links using load_form (which only
replaces #main) instead of load_form_div, which broke every internal
AJAX reload (template type switch, modality switch, reset) on the
diagnosis/discharge/document print template settings pages
- diagnosis_print_settings.php: fix corrupted watermark_alpha number
input (missing step attribute) that silently blocked form submission
for templates with non-integer-step legacy values