From 9799eb31fd4f050b6da716ad7c3ae5280c28ec09 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 15 Feb 2026 01:55:34 +0000
Subject: [PATCH 1/4] Initial plan
From c672d06ff5f10026a6649f233470b3667b8f7ecb Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 15 Feb 2026 01:59:37 +0000
Subject: [PATCH 2/4] Add comprehensive README, INSTALLATION, and ARCHITECTURE
documentation
Co-authored-by: backgroundcheck <18512725+backgroundcheck@users.noreply.github.com>
---
ARCHITECTURE.md | 615 ++++++++++++++++++++++++++++++++++++++++++++++++
INSTALLATION.md | 513 ++++++++++++++++++++++++++++++++++++++++
README.md | 228 +++++++++++++++++-
3 files changed, 1353 insertions(+), 3 deletions(-)
create mode 100644 ARCHITECTURE.md
create mode 100644 INSTALLATION.md
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
new file mode 100644
index 0000000..121762e
--- /dev/null
+++ b/ARCHITECTURE.md
@@ -0,0 +1,615 @@
+# Architecture Documentation - BackCheck.io Verify
+
+## Table of Contents
+- [System Overview](#system-overview)
+- [Technology Stack](#technology-stack)
+- [Application Architecture](#application-architecture)
+- [Database Design](#database-design)
+- [Security Architecture](#security-architecture)
+- [Integration Architecture](#integration-architecture)
+- [File Structure](#file-structure)
+- [Request Flow](#request-flow)
+- [Authentication & Authorization](#authentication--authorization)
+- [Performance Considerations](#performance-considerations)
+
+## System Overview
+
+BackCheck.io Verify is a **monolithic PHP web application** built on a traditional LAMP stack architecture. The system follows a **procedural programming paradigm** with heavy use of include files and global functions.
+
+### Architecture Pattern
+- **Pattern**: Monolithic, procedural PHP
+- **Design**: Include-based modular architecture
+- **Data Access**: Direct MySQL queries (legacy mysql_* extension)
+- **Session Management**: PHP native sessions
+- **State Management**: Server-side session storage
+
+### Key Characteristics
+- **Legacy Codebase**: Uses deprecated PHP mysql_* functions
+- **High Coupling**: Tight coupling between layers
+- **Action-Based Routing**: URL parameter-driven page routing
+- **Mixed Concerns**: HTML, PHP, and SQL often intermixed
+- **Global State**: Heavy reliance on global variables and sessions
+
+## Technology Stack
+
+### Server-Side
+```
+┌─────────────────────────────────────┐
+│ Web Server Layer │
+│ Apache 2.4+ / Nginx 1.14+ │
+└─────────────────────────────────────┘
+ ↓
+┌─────────────────────────────────────┐
+│ Application Layer (PHP) │
+│ PHP 5.6+ / 7.x │
+│ Extensions: mysql, gd, curl, xml │
+└─────────────────────────────────────┘
+ ↓
+┌─────────────────────────────────────┐
+│ Database Layer │
+│ MySQL 5.7+ / MariaDB │
+│ Character Set: UTF-8 │
+└─────────────────────────────────────┘
+```
+
+### Frontend
+- **JavaScript Library**: jQuery 1.x / 2.x
+- **UI Framework**: jQuery UI, Bootstrap 3.x
+- **File Upload**: Blueimp jQuery File Upload (v9.9.3)
+- **Rich Text**: TinyMCE editor
+- **AJAX**: jQuery Ajax for async operations
+
+### Third-Party Services
+- **CRM**: Bitrix24 (REST API integration)
+- **BPM**: Savvion Business Process Management
+- **Cloud Storage**: Google Sheets API
+- **Billing**: WHMCS API
+- **Email**: PHPMailer SMTP
+
+## Application Architecture
+
+### Layered Architecture
+
+```
+┌────────────────────────────────────────────────────────────┐
+│ Presentation Layer │
+│ (index.php, include_pages/*.php, dashboard/*.php) │
+│ - HTML Templates │
+│ - jQuery UI Components │
+│ - Form Handling │
+└────────────────────────────────────────────────────────────┘
+ ↓
+┌────────────────────────────────────────────────────────────┐
+│ Business Logic Layer │
+│ (functions/functions.php, actions.php) │
+│ - Verification Processing │
+│ - Workflow Management │
+│ - Report Generation │
+│ - Email Notifications │
+└────────────────────────────────────────────────────────────┘
+ ↓
+┌────────────────────────────────────────────────────────────┐
+│ Data Access Layer │
+│ (include/db_class.php) │
+│ - Database Connections │
+│ - Query Execution │
+│ - Result Processing │
+└────────────────────────────────────────────────────────────┘
+ ↓
+┌────────────────────────────────────────────────────────────┐
+│ Integration Layer │
+│ (functions/bitrix/, functions/savvion/, api_*.php) │
+│ - Bitrix CRM Integration │
+│ - Savvion BPM Integration │
+│ - Google Sheets Integration │
+│ - External API Calls │
+└────────────────────────────────────────────────────────────┘
+```
+
+### Component Diagram
+
+```
+┌─────────────────────────────────────────────────────────────┐
+│ Client Browser │
+│ (HTML/CSS/JavaScript - jQuery, Bootstrap) │
+└─────────────────────────────────────────────────────────────┘
+ ↑ ↓
+ │ │
+ HTTP Response HTTP Request
+ │ │
+ ↓ ↑
+┌─────────────────────────────────────────────────────────────┐
+│ Application Server │
+│ │
+│ ┌────────────┐ ┌────────────┐ ┌─────────────┐ │
+│ │ index.php │ │actions.php │ │ api_verify │ │
+│ │ (Router) │ │(AJAX Hub) │ │ .php │ │
+│ └────────────┘ └────────────┘ └─────────────┘ │
+│ │ │ │ │
+│ └───────────────┴────────────────┘ │
+│ ↓ │
+│ ┌──────────────────────────────────────────────┐ │
+│ │ Configuration Layer │ │
+│ │ (include/config_*.php, global_config.php) │ │
+│ └──────────────────────────────────────────────┘ │
+│ ↓ │
+│ ┌──────────────────────────────────────────────┐ │
+│ │ Core Functions │ │
+│ │ (functions/functions.php - 374KB) │ │
+│ └──────────────────────────────────────────────┘ │
+│ ↓ │
+│ ┌──────────────────────────────────────────────┐ │
+│ │ Database Access Layer │ │
+│ │ (include/db_class.php) │ │
+│ └──────────────────────────────────────────────┘ │
+└─────────────────────────────────────────────────────────────┘
+ ↓
+┌─────────────────────────────────────────────────────────────┐
+│ MySQL Database │
+│ (backglob_db) │
+└─────────────────────────────────────────────────────────────┘
+ ↑
+ │
+┌─────────────────────────────────────────────────────────────┐
+│ External Integrations │
+│ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌─────────┐ │
+│ │ Bitrix24 │ │ Savvion │ │ Google │ │ WHMCS │ │
+│ │ CRM │ │ BPM │ │ Sheets │ │ API │ │
+│ └──────────┘ └──────────┘ └───────────┘ └─────────┘ │
+└─────────────────────────────────────────────────────────────┘
+```
+
+## Database Design
+
+### Database Schema Overview
+
+```sql
+-- Core Tables
+users -- User accounts and authentication
+ver_data -- Main verification records
+checks -- Verification check assignments
+companies -- Client companies
+cases -- Case management
+
+-- Workflow Tables
+savvion_checks -- Savvion workflow instances
+bitrix_tasks -- Bitrix task tracking
+auth_token -- API authentication tokens
+
+-- Reference Tables
+categories -- Check categories/types
+statuses -- Status definitions
+countries -- Country data
+ratings -- Rating data
+
+-- Supporting Tables
+email_logs -- Email notification logs
+cron_logs -- Automated task logs
+user_sessions -- Session tracking
+uploads -- File upload tracking
+```
+
+### Key Table Structures
+
+#### users Table
+```sql
+users
+├── id (PK)
+├── username
+├── password (MD5 hash - legacy)
+├── email
+├── level (1-14, role identifier)
+├── company_id (FK)
+├── status (1=active, 0=inactive)
+├── created_date
+└── last_login
+```
+
+#### ver_data Table (Main verification records)
+```sql
+ver_data
+├── id (PK)
+├── client_ref_num
+├── applicant_name
+├── check_type
+├── status
+├── assigned_to (FK -> users.id)
+├── company_id (FK -> companies.id)
+├── created_date
+├── modified_date
+├── tat_date (turnaround time deadline)
+└── ... (50+ additional fields)
+```
+
+#### checks Table
+```sql
+checks
+├── id (PK)
+├── ver_data_id (FK -> ver_data.id)
+├── check_category
+├── analyst_id (FK -> users.id)
+├── status
+├── assigned_date
+└── completed_date
+```
+
+### Data Flow
+
+```
+Application Submission
+ ↓
+ Insert ver_data
+ ↓
+ Create checks
+ ↓
+ Assign to analyst (users)
+ ↓
+ Update status progressively
+ ↓
+ Generate final report
+```
+
+## Security Architecture
+
+### Authentication Flow
+
+```
+User Login Request
+ ↓
+Validate Credentials (MD5 hash - legacy)
+ ↓
+Check User Status & Level
+ ↓
+Create PHP Session
+ ↓
+Store Session Variables
+ - $_SESSION['userid']
+ - $_SESSION['username']
+ - $_SESSION['level']
+ - $_SESSION['company_id']
+ ↓
+Redirect to Dashboard
+```
+
+### Authorization Model
+
+**Role-Based Access Control (RBAC)**
+
+```php
+// Level-based permissions
+$LEVEL = $_SESSION['level'];
+
+switch($LEVEL) {
+ case 1: // Super Admin - Full access
+ case 2: // Admin - User/client management
+ case 3: // Team Lead - Team management
+ case 4: // Senior Analyst - Complex cases
+ case 5: // Analyst - Standard cases
+ case 6: // Quality Control - Review access
+ case 7: // Client Admin - Client portal
+ // ... etc
+}
+```
+
+### Security Concerns (Legacy)
+
+⚠️ **Known Security Issues**:
+1. **MD5 Password Hashing**: Weak, should use bcrypt/password_hash()
+2. **Direct MySQL Queries**: Using deprecated mysql_* functions
+3. **SQL Injection Risk**: Lack of prepared statements
+4. **XSS Vulnerabilities**: Limited output escaping
+5. **CSRF Protection**: No CSRF tokens implemented
+6. **Session Fixation**: No session regeneration on login
+
+**Recommended Improvements**:
+- Migrate to PDO with prepared statements
+- Implement password_hash() / password_verify()
+- Add CSRF token validation
+- Implement output escaping (htmlspecialchars)
+- Add input validation and sanitization
+- Enable HTTPS only with HSTS headers
+
+## Integration Architecture
+
+### Bitrix CRM Integration
+
+```
+BackCheck Application
+ ↓
+Bitrix Integration Layer
+(functions/bitrix/bitrix_functions.php)
+ ↓
+REST API Call
+https://my.backcheck.io/rest_api.php
+ ↓
+Bitrix24 CRM
+ ├── Lead Creation (insertleads2)
+ ├── Task Management (add_task, task_del)
+ ├── Work Group Assignment
+ └── Status Updates
+```
+
+**Key Functions**:
+- `insertleads2()`: Create leads with auto-assignment by country
+- `add_task()`: Create tasks with TAT and reminders
+- `getworkgroup()`: Retrieve work group information
+
+### Savvion BPM Integration
+
+```
+Verification Request
+ ↓
+Savvion Workflow Layer
+(functions/savvion/savvion_functions.php)
+ ↓
+Savvion BPM System
+ ├── Workflow Initiation
+ ├── Task Assignment
+ ├── Process Tracking
+ ├── Approval Routing
+ └── Completion Notification
+```
+
+**Workflow Types**:
+- Employment Verification Workflow
+- Education Verification Workflow
+- Complex Multi-Step Verifications
+
+### Google Sheets Integration
+
+```
+Report Generation Request
+ ↓
+Google Sheets API Layer
+(api_google.php)
+ ↓
+Google Sheets API v4
+ ↓
+Spreadsheet Creation/Update
+ ├── Export verification data
+ ├── Generate analytics reports
+ └── Timeline analysis
+```
+
+## File Structure
+
+### Directory Organization
+
+```
+/verify/
+├── index.php # Main entry point
+├── actions.php # AJAX handler
+├── api_verify.php # REST API endpoint
+│
+├── include/ # Core configuration
+│ ├── global_config.php # Database & constants
+│ ├── config_index.php # Index configuration
+│ ├── config_actions.php # Actions configuration
+│ ├── config_client.php # Client portal config
+│ ├── db_class.php # Database wrapper
+│ ├── paginator.class.php # Pagination utility
+│ └── search_cls.php # Search functionality
+│
+├── functions/ # Business logic
+│ ├── functions.php # Core functions (374KB)
+│ ├── class.phpmailer.php # Email handler
+│ ├── bitrix/ # Bitrix integration
+│ ├── savvion/ # Savvion integration
+│ ├── dashboard/ # Dashboard functions
+│ ├── advance_search/ # Search functions
+│ ├── bulkupload/ # Bulk upload handlers
+│ └── credits/ # Credits management
+│
+├── include_pages/ # Page templates (400+ files)
+│ ├── index_new_inc.php # Main dashboard
+│ ├── applicant_inc.php # Applicant pages
+│ ├── checks_inc.php # Check management
+│ ├── reports_inc.php # Report generation
+│ ├── rating_inc.php # Rating pages
+│ └── ... (many more)
+│
+├── dashboard/ # Dashboard modules
+│ ├── document_head.php # Dashboard header
+│ └── ... (dashboard components)
+│
+├── js/ # JavaScript files
+│ ├── ajax_script-2.js # AJAX functions
+│ ├── js_functions-2.js # Utility functions
+│ └── encoder.js # Encoding utilities
+│
+├── css/ # Stylesheets
+├── images/ # Static images
+│ ├── uploads/ # User uploads
+│ ├── case_uploads/ # Case documents
+│ └── profile_pics/ # Profile images
+│
+├── scripts/ # External libraries
+│ └── vendor/ # Third-party libraries
+│ └── tinymce/ # Rich text editor
+│
+└── formbuilder/ # Form builder module
+```
+
+## Request Flow
+
+### Page Request Flow
+
+```
+1. User Request
+ URL: https://backcheck.io/verify/?action=dashboard
+ ↓
+2. index.php
+ - Include config_index.php
+ - Authenticate user
+ - Check session
+ ↓
+3. Route Based on Action
+ - Load config_*.php based on user level
+ - Include document_head.php
+ - Load appropriate include_pages/*.php
+ ↓
+4. Page Processing
+ - Execute business logic
+ - Query database
+ - Generate HTML output
+ ↓
+5. Response
+ - Render page with sidebar
+ - Include JavaScript
+ - Send to browser
+```
+
+### AJAX Request Flow
+
+```
+1. Client JavaScript
+ $.ajax({ url: 'actions.php', data: {action: 'submit_check'} })
+ ↓
+2. actions.php
+ - Include config_actions.php
+ - Authenticate user
+ - Validate action parameter
+ ↓
+3. Action Routing
+ if($_REQUEST['action'] == 'submit_check') {
+ include 'include_pages/submit_check_inc.php';
+ }
+ ↓
+4. Process Request
+ - Execute business logic
+ - Update database
+ - Call external APIs (Bitrix, Savvion)
+ ↓
+5. JSON Response
+ echo json_encode(['status' => 'success', 'data' => $result]);
+ ↓
+6. Client Callback
+ success: function(response) { /* handle response */ }
+```
+
+### API Request Flow
+
+```
+1. External API Call
+ POST /api_verify.php
+ Authorization: Bearer {token}
+ ↓
+2. Token Validation
+ - Query auth_token table
+ - Verify token validity
+ - Check expiration
+ ↓
+3. Action Processing
+ switch($_REQUEST['action']) {
+ case 'create_check':
+ // Create verification
+ case 'get_status':
+ // Get status
+ }
+ ↓
+4. Business Logic
+ - Call functions from functions.php
+ - Database operations
+ ↓
+5. JSON Response
+ {
+ "status": "success",
+ "data": { ... },
+ "message": "Check created successfully"
+ }
+```
+
+## Authentication & Authorization
+
+### Session Management
+
+```php
+// Start session
+session_start();
+
+// Set session variables on login
+$_SESSION['userid'] = $user_id;
+$_SESSION['username'] = $username;
+$_SESSION['level'] = $user_level;
+$_SESSION['company_id'] = $company_id;
+$_SESSION['name'] = $full_name;
+
+// Check authentication on each request
+if(!isset($_SESSION['userid'])) {
+ header("Location: login.php");
+ exit;
+}
+
+// Check authorization
+$LEVEL = $_SESSION['level'];
+if($LEVEL != 1 && $LEVEL != 2) {
+ die("Access denied");
+}
+```
+
+### Permission Matrix
+
+| Level | Role | Permissions |
+|-------|------|-------------|
+| 1 | Super Admin | All permissions |
+| 2 | Admin | User/client management, reports |
+| 3 | Team Lead | Team management, assignment, review |
+| 4 | Senior Analyst | Complex verifications, mentoring |
+| 5 | Analyst | Standard verifications |
+| 6 | Quality Control | Review, approve/reject |
+| 7 | Client Admin | Client portal admin |
+| 8 | Client User | Submit requests, view status |
+| 9 | Finance | Billing, invoicing |
+| 10-14 | Custom | Specialized roles |
+
+## Performance Considerations
+
+### Current Limitations
+- **N+1 Query Problem**: Multiple database queries in loops
+- **Large File Sizes**: functions.php is 374KB (monolithic)
+- **No Caching**: No query caching or page caching
+- **Session Storage**: File-based sessions (slow at scale)
+- **No CDN**: Static assets served from application server
+
+### Optimization Opportunities
+1. **Database**:
+ - Add indexes on frequently queried columns
+ - Implement query caching
+ - Use connection pooling
+
+2. **Application**:
+ - Implement opcode caching (OPcache)
+ - Break down large functions file
+ - Add result caching (Redis/Memcached)
+
+3. **Frontend**:
+ - Minify CSS/JavaScript
+ - Implement CDN for static assets
+ - Enable browser caching
+
+4. **Infrastructure**:
+ - Load balancing for horizontal scaling
+ - Database replication (master-slave)
+ - File storage on S3/object storage
+
+## Scalability Considerations
+
+### Current Architecture Limitations
+- **Monolithic Design**: Tight coupling makes scaling difficult
+- **Shared Session State**: File-based sessions don't scale horizontally
+- **Direct Database Access**: No abstraction layer for sharding
+- **Synchronous Processing**: No background job processing
+
+### Recommended Improvements
+1. **Microservices**: Extract integrations into separate services
+2. **Message Queue**: Implement RabbitMQ/Redis for async tasks
+3. **API Gateway**: Centralized API management
+4. **Service-Oriented Architecture**: Break monolith into services
+5. **Containerization**: Docker for consistent deployment
+6. **Orchestration**: Kubernetes for container management
+
+---
+
+**Version**: 3.4
+**Last Updated**: 2026
+**Maintained by**: Background Check Development Team
diff --git a/INSTALLATION.md b/INSTALLATION.md
new file mode 100644
index 0000000..bb1d20b
--- /dev/null
+++ b/INSTALLATION.md
@@ -0,0 +1,513 @@
+# Installation Guide - BackCheck.io Verify
+
+This guide provides detailed instructions for installing and configuring the BackCheck.io Verify application.
+
+## Table of Contents
+- [System Requirements](#system-requirements)
+- [Pre-Installation Checklist](#pre-installation-checklist)
+- [Installation Steps](#installation-steps)
+- [Configuration](#configuration)
+- [Post-Installation](#post-installation)
+- [Troubleshooting](#troubleshooting)
+
+## System Requirements
+
+### Server Requirements
+- **Operating System**: Linux (Ubuntu 18.04+ or CentOS 7+)
+- **Web Server**: Apache 2.4+ or Nginx 1.14+
+- **PHP Version**: 5.6 or higher (PHP 7.2+ recommended)
+- **Database**: MySQL 5.7+ or MariaDB 10.2+
+- **Disk Space**: Minimum 2GB (recommended 10GB+ for document storage)
+- **Memory**: Minimum 512MB RAM (recommended 2GB+)
+
+### PHP Extensions Required
+```bash
+php-mysql
+php-gd
+php-mbstring
+php-curl
+php-xml
+php-json
+php-zip
+php-fileinfo
+```
+
+### PHP Configuration
+Update your `php.ini` with the following minimum values:
+
+```ini
+upload_max_filesize = 5M
+post_max_size = 8M
+max_execution_time = 300
+memory_limit = 256M
+session.gc_maxlifetime = 3600
+date.timezone = Asia/Karachi
+```
+
+### MySQL Configuration
+- Character Set: UTF-8 (utf8mb4 recommended)
+- Default Collation: utf8mb4_general_ci
+- InnoDB storage engine enabled
+
+## Pre-Installation Checklist
+
+- [ ] Server meets minimum requirements
+- [ ] Required PHP extensions installed
+- [ ] MySQL database created
+- [ ] Database user with appropriate privileges created
+- [ ] Web server configured (Apache/Nginx)
+- [ ] SSL certificate installed (recommended)
+- [ ] Domain name configured
+- [ ] Backup plan in place
+
+## Installation Steps
+
+### Step 1: Download and Extract
+
+```bash
+# Clone from repository
+cd /var/www/html
+git clone https://github.com/BackCheck/backcheck.io.verify.git verify
+cd verify
+
+# Or extract from archive
+tar -xzf backcheck-verify.tar.gz
+mv backcheck-verify verify
+```
+
+### Step 2: Set File Permissions
+
+```bash
+# Set ownership (replace www-data with your web server user)
+chown -R www-data:www-data /var/www/html/verify
+
+# Set directory permissions
+find /var/www/html/verify -type d -exec chmod 755 {} \;
+
+# Set file permissions
+find /var/www/html/verify -type f -exec chmod 644 {} \;
+
+# Set writable directories
+chmod -R 775 /var/www/html/verify/images/uploads
+chmod -R 775 /var/www/html/verify/images/case_uploads
+chmod -R 775 /var/www/html/verify/images/profile_pics
+```
+
+### Step 3: Database Setup
+
+```bash
+# Login to MySQL
+mysql -u root -p
+
+# Create database
+CREATE DATABASE backglob_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
+
+# Create database user
+CREATE USER 'backglob_user'@'localhost' IDENTIFIED BY 'your_secure_password';
+
+# Grant privileges
+GRANT ALL PRIVILEGES ON backglob_db.* TO 'backglob_user'@'localhost';
+FLUSH PRIVILEGES;
+EXIT;
+
+# Import database schema (contact administrator for SQL file)
+mysql -u backglob_user -p backglob_db < database_schema.sql
+```
+
+### Step 4: Configure Application
+
+Edit `/include/global_config.php`:
+
+```php
+
+```
+
+### Step 5: Web Server Configuration
+
+#### Apache Configuration
+
+Create `/etc/apache2/sites-available/backcheck-verify.conf`:
+
+```apache
+
+ ServerName your-domain.com
+ ServerAlias www.your-domain.com
+ DocumentRoot /var/www/html/verify
+
+
+ Options -Indexes +FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+
+ ErrorLog ${APACHE_LOG_DIR}/verify-error.log
+ CustomLog ${APACHE_LOG_DIR}/verify-access.log combined
+
+
+# SSL Configuration (recommended)
+
+ ServerName your-domain.com
+ ServerAlias www.your-domain.com
+ DocumentRoot /var/www/html/verify
+
+ SSLEngine on
+ SSLCertificateFile /path/to/certificate.crt
+ SSLCertificateKeyFile /path/to/private.key
+ SSLCertificateChainFile /path/to/chain.crt
+
+
+ Options -Indexes +FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+
+ ErrorLog ${APACHE_LOG_DIR}/verify-ssl-error.log
+ CustomLog ${APACHE_LOG_DIR}/verify-ssl-access.log combined
+
+```
+
+Enable the site and restart Apache:
+
+```bash
+a2ensite backcheck-verify
+a2enmod rewrite ssl
+systemctl restart apache2
+```
+
+#### Nginx Configuration
+
+Create `/etc/nginx/sites-available/backcheck-verify`:
+
+```nginx
+server {
+ listen 80;
+ listen [::]:80;
+ server_name your-domain.com www.your-domain.com;
+ root /var/www/html/verify;
+ index index.php index.html;
+
+ # Security headers
+ add_header X-Frame-Options "SAMEORIGIN" always;
+ add_header X-Content-Type-Options "nosniff" always;
+ add_header X-XSS-Protection "1; mode=block" always;
+
+ # File upload size
+ client_max_body_size 5M;
+
+ location / {
+ try_files $uri $uri/ /index.php?$query_string;
+ }
+
+ location ~ \.php$ {
+ fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ include fastcgi_params;
+ }
+
+ # Deny access to sensitive files
+ location ~ /\. {
+ deny all;
+ }
+
+ location ~ /include/ {
+ deny all;
+ }
+
+ access_log /var/log/nginx/verify-access.log;
+ error_log /var/log/nginx/verify-error.log;
+}
+
+# SSL Configuration
+server {
+ listen 443 ssl http2;
+ listen [::]:443 ssl http2;
+ server_name your-domain.com www.your-domain.com;
+ root /var/www/html/verify;
+
+ ssl_certificate /path/to/certificate.crt;
+ ssl_certificate_key /path/to/private.key;
+ ssl_protocols TLSv1.2 TLSv1.3;
+
+ # Same configuration as HTTP above
+ # ... (copy from above)
+}
+```
+
+Enable the site and restart Nginx:
+
+```bash
+ln -s /etc/nginx/sites-available/backcheck-verify /etc/nginx/sites-enabled/
+nginx -t
+systemctl restart nginx
+```
+
+### Step 6: Create Initial Admin User
+
+Login to MySQL and create an admin account:
+
+```sql
+USE backglob_db;
+
+INSERT INTO users (username, password, email, level, status)
+VALUES ('admin', MD5('temporary_password'), 'admin@your-domain.com', 1, 1);
+
+-- Note: Change password immediately after first login
+```
+
+## Configuration
+
+### Email Configuration
+
+Configure email settings in PHPMailer (in functions/functions.php or separate config):
+
+```php
+$mail->Host = 'smtp.your-domain.com';
+$mail->Port = 587;
+$mail->SMTPAuth = true;
+$mail->Username = 'noreply@your-domain.com';
+$mail->Password = 'your_email_password';
+$mail->SMTPSecure = 'tls';
+$mail->From = 'noreply@your-domain.com';
+$mail->FromName = 'BackCheck Verify';
+```
+
+### Bitrix CRM Integration
+
+To enable Bitrix integration:
+
+1. Obtain API credentials from your Bitrix instance
+2. Update `BITRIX_URL` in `global_config.php`
+3. Configure admin mappings in `/functions/bitrix/bitrix_functions.php`
+
+### Google Sheets Integration
+
+1. Create a Google Cloud Project
+2. Enable Google Sheets API
+3. Create service account and download JSON credentials
+4. Place credentials in secure location
+5. Update API configuration in `api_google.php`
+
+### Savvion BPM Integration
+
+Configure Savvion connection settings in `/functions/savvion/savvion_config.php` (if file exists) or contact administrator for configuration details.
+
+## Post-Installation
+
+### 1. Verify Installation
+
+Visit your installation URL and verify:
+- [ ] Application loads without errors
+- [ ] Login page is accessible
+- [ ] Can login with admin credentials
+- [ ] Dashboard loads correctly
+- [ ] File upload works
+- [ ] Email notifications work
+
+### 2. Security Hardening
+
+```bash
+# Remove installer files (if any)
+rm -f install.php setup.php
+
+# Secure configuration files
+chmod 640 /var/www/html/verify/include/global_config.php
+
+# Set up firewall rules
+ufw allow 80/tcp
+ufw allow 443/tcp
+ufw enable
+
+# Configure fail2ban for brute force protection
+apt-get install fail2ban
+systemctl enable fail2ban
+```
+
+### 3. Set Up Backups
+
+```bash
+# Database backup script
+#!/bin/bash
+BACKUP_DIR="/backup/mysql"
+DATE=$(date +%Y%m%d_%H%M%S)
+mysqldump -u backglob_user -p backglob_db > $BACKUP_DIR/backglob_db_$DATE.sql
+find $BACKUP_DIR -name "*.sql" -mtime +7 -delete
+
+# Files backup
+tar -czf /backup/files/verify_files_$DATE.tar.gz /var/www/html/verify/images/uploads
+
+# Add to crontab
+crontab -e
+# Add: 0 2 * * * /path/to/backup_script.sh
+```
+
+### 4. Configure Cron Jobs
+
+Set up automated tasks:
+
+```bash
+crontab -e
+
+# Daily digest notifications
+0 8 * * * /usr/bin/php /var/www/html/verify/daily_digest_insuff.php
+
+# Monthly invoice generation
+0 0 1 * * /usr/bin/php /var/www/html/verify/monthly_invoice_cron.php
+
+# Pre-employment verification cron
+0 */2 * * * /usr/bin/php /var/www/html/verify/pre_emp_send_and_repsone_cron.php
+
+# Bitrix sync (if enabled)
+*/30 * * * * /usr/bin/php /var/www/html/verify/auto_addtasks_to_bitrix2.php
+```
+
+### 5. Monitor Logs
+
+```bash
+# Application logs
+tail -f /var/log/apache2/verify-error.log
+# or
+tail -f /var/log/nginx/verify-error.log
+
+# PHP logs
+tail -f /var/log/php7.4-fpm.log
+
+# MySQL logs
+tail -f /var/log/mysql/error.log
+```
+
+## Troubleshooting
+
+### Common Issues
+
+#### 1. White Screen / 500 Error
+**Solution:**
+- Check PHP error logs
+- Verify file permissions
+- Ensure all PHP extensions are installed
+- Check database connection in global_config.php
+
+#### 2. Database Connection Failed
+**Solution:**
+```bash
+# Verify MySQL is running
+systemctl status mysql
+
+# Test connection
+mysql -u backglob_user -p -h localhost backglob_db
+
+# Check credentials in global_config.php
+```
+
+#### 3. File Upload Not Working
+**Solution:**
+- Check directory permissions (775)
+- Verify PHP upload settings in php.ini
+- Check available disk space
+- Review web server error logs
+
+#### 4. Session Timeout Issues
+**Solution:**
+```ini
+# In php.ini
+session.gc_maxlifetime = 3600
+session.cookie_lifetime = 0
+
+# Restart PHP-FPM
+systemctl restart php7.4-fpm
+```
+
+#### 5. Email Not Sending
+**Solution:**
+- Verify SMTP credentials
+- Check firewall rules for port 587/465
+- Test with mail() function
+- Review email logs
+
+#### 6. Permission Denied Errors
+**Solution:**
+```bash
+# Fix ownership
+chown -R www-data:www-data /var/www/html/verify
+
+# Fix permissions
+find /var/www/html/verify -type d -exec chmod 755 {} \;
+find /var/www/html/verify -type f -exec chmod 644 {} \;
+chmod -R 775 /var/www/html/verify/images/uploads
+```
+
+### Getting Help
+
+If you encounter issues not covered here:
+
+1. Check application error logs
+2. Review web server error logs
+3. Contact support: support@backcheckgroup.com
+4. Provide: error messages, server details, PHP version, steps to reproduce
+
+## Updating the Application
+
+```bash
+# Backup first
+mysqldump -u backglob_user -p backglob_db > backup.sql
+tar -czf backup_files.tar.gz /var/www/html/verify
+
+# Pull latest changes
+cd /var/www/html/verify
+git pull origin main
+
+# Update database if needed
+mysql -u backglob_user -p backglob_db < updates/update_schema.sql
+
+# Clear cache if applicable
+rm -rf /var/www/html/verify/cache/*
+
+# Restart services
+systemctl restart apache2 # or nginx
+```
+
+## Security Recommendations
+
+1. **Use HTTPS**: Always use SSL/TLS certificates
+2. **Strong Passwords**: Enforce strong password policy
+3. **Regular Updates**: Keep PHP, MySQL, and web server updated
+4. **Firewall**: Configure UFW or iptables
+5. **Backup**: Automate daily backups
+6. **Monitoring**: Set up monitoring and alerting
+7. **Code Updates**: Migrate from deprecated mysql_* functions to PDO
+8. **Input Validation**: Review and enhance input validation
+9. **SQL Injection**: Implement prepared statements throughout
+10. **File Upload Security**: Validate file types and scan for malware
+
+---
+
+**Support**: For installation support, contact support@backcheckgroup.com
diff --git a/README.md b/README.md
index 5cc91cf..12ad311 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,227 @@
-# backcheck.io.verify
- --> http://backcheck.io/verify
+# BackCheck.io Verify
+> A comprehensive background verification and document verification management system
-backcheck.io/verfiy application is for verify documents
+[](LICENSE)
+[](https://www.php.net/)
+[](https://www.mysql.com/)
+
+## 🔍 Overview
+
+**BackCheck.io Verify** is a full-featured background verification platform designed to streamline the process of employment verification, education verification, health checks, and other background screening services. The system provides a complete workflow from initial application submission through verification, quality control, and final report generation.
+
+**Live Application**: [https://backcheck.io/verify](https://backcheck.io/verify)
+
+## ✨ Key Features
+
+### Core Functionality
+- **Multi-Type Verification Support**
+ - Employment Verification
+ - Education Verification
+ - Health Verification
+ - Identity Verification
+ - Address Verification
+ - Reference Checks
+ - Criminal Record Checks
+
+### Workflow Management
+- **Role-Based Access Control**: 14+ user levels including Admin, Team Lead, Analysts, Quality Control, Clients
+- **Automated Task Assignment**: Intelligent distribution based on workload and expertise
+- **Multi-Stage Approval Process**: Initial Investigation → Analysis → Quality Control → Final Report
+- **Real-Time Status Tracking**: Complete visibility of verification progress
+- **SLA Management**: Configurable turnaround time (TAT) tracking with alerts
+
+### Integration Capabilities
+- **Bitrix CRM Integration**: Automatic lead and task creation
+- **Savvion BPM**: Structured workflow management for complex verifications
+- **Google Sheets API**: Automated reporting and data export
+- **WHMCS Integration**: Customer and billing management
+- **Email Notifications**: Automated stakeholder communication via PHPMailer
+
+### Document Management
+- **Multi-File Upload**: Support for PDF, DOC, DOCX, JPG, PNG (up to 5MB per file)
+- **Bulk Upload**: Batch processing for high-volume operations
+- **OCR Support**: Automated text extraction from documents
+- **Secure Storage**: Document versioning and audit trails
+
+### Reporting & Analytics
+- **Dashboard Views**: Customized dashboards for each user role
+- **Case Reports**: Detailed verification reports with evidence
+- **Certificates**: Official verification certificates
+- **Analytics**: Daily, weekly, and monthly performance reports
+- **Export Options**: Excel, PDF, CSV formats
+
+## 🏗️ Architecture
+
+### Technology Stack
+- **Backend**: PHP 5.6+ with MySQL database
+- **Frontend**: jQuery, jQuery UI, Bootstrap
+- **File Upload**: Blueimp jQuery File Upload (v9.9.3)
+- **PDF Generation**: PHP PDF libraries
+- **Email**: PHPMailer class
+
+### System Components
+
+```
+/verify/
+├── index.php # Main application entry point
+├── actions.php # AJAX request handler
+├── api_verify.php # Token-based REST API
+├── include/ # Core configuration and database classes
+│ ├── global_config.php # System constants and database config
+│ ├── config_*.php # Role-based configuration files
+│ └── db_class.php # MySQL database wrapper
+├── functions/ # Business logic and integrations
+│ ├── functions.php # Core utility functions (374KB)
+│ ├── bitrix/ # Bitrix CRM integration
+│ └── savvion/ # Savvion workflow functions
+├── include_pages/ # Page templates (400+ files)
+├── dashboard/ # Dashboard modules
+├── js/ # JavaScript files
+├── css/ # Stylesheets
+└── images/ # Static assets
+```
+
+## 🚀 Quick Start
+
+### Prerequisites
+- PHP 5.6 or higher
+- MySQL 5.7 or higher
+- Apache/Nginx web server
+- 256MB+ PHP memory limit
+- File upload enabled (5MB+ max file size)
+
+### Installation
+
+1. **Clone the repository**
+ ```bash
+ git clone https://github.com/BackCheck/backcheck.io.verify.git
+ cd backcheck.io.verify
+ ```
+
+2. **Configure database**
+ - Create a MySQL database
+ - Import the database schema (contact admin for schema)
+ - Update `/include/global_config.php` with your database credentials
+
+3. **Configure web server**
+ - Point document root to the project directory
+ - Ensure `.htaccess` is enabled for Apache
+ - Set proper file permissions (writable upload directories)
+
+4. **Update configuration**
+ - Edit `/include/global_config.php` with your site URL and settings
+ - Configure email settings for notifications
+ - Set up API keys for integrations (Bitrix, Google Sheets, etc.)
+
+5. **Access the application**
+ - Navigate to your configured URL
+ - Default admin credentials (contact system administrator)
+
+For detailed installation instructions, see [INSTALLATION.md](INSTALLATION.md)
+
+## 📚 Documentation
+
+- **[Installation Guide](INSTALLATION.md)** - Complete setup instructions
+- **[Architecture Documentation](ARCHITECTURE.md)** - Technical architecture details
+- **[API Documentation](API_DOCUMENTATION.md)** - API endpoints and usage
+- **[User Guide](USER_GUIDE.md)** - User roles, features, and workflows
+- **[Configuration Guide](CONFIGURATION.md)** - System configuration options
+- **[Integration Guide](INTEGRATIONS.md)** - Third-party integration setup
+- **[Development Guide](DEVELOPMENT.md)** - Development guidelines and best practices
+
+## 👥 User Roles
+
+The system supports multiple user levels with different permissions:
+
+| Level | Role | Description |
+|-------|------|-------------|
+| 1 | Super Admin | Full system access and configuration |
+| 2 | Admin | User and client management |
+| 3 | Team Lead | Team management and review |
+| 4 | Senior Analyst | Complex verification cases |
+| 5 | Analyst | Standard verification processing |
+| 6 | Quality Control | Report review and approval |
+| 7 | Client Admin | Client portal administration |
+| 8 | Client User | Submit and track verifications |
+| 9 | Finance | Billing and invoicing |
+| 10-14 | Specialized Roles | Custom role assignments |
+
+## 🔌 API Integration
+
+The system provides REST API endpoints for external integrations:
+
+```php
+// Token-based authentication
+POST /api_verify.php
+Headers: Authorization: Bearer {token}
+
+// Example: Create verification request
+POST /api_verify.php?action=create_check
+Body: {
+ "client_ref": "EMP001",
+ "applicant_name": "John Doe",
+ "check_type": "employment",
+ "documents": [...]
+}
+```
+
+See [API_DOCUMENTATION.md](API_DOCUMENTATION.md) for complete API reference.
+
+## 🔧 Configuration
+
+Key configuration constants in `/include/global_config.php`:
+
+```php
+define("SITE_URL", 'https://backcheck.io/verify/');
+define("DB", 'backglob_db');
+define("TAT", 10); // Turnaround time in days
+define("FILE_SIZE_ALLOWED", "5 MB");
+define("BITRIX_URL", "https://my.backcheck.io/rest_api.php");
+```
+
+## 🔐 Security Considerations
+
+- Session-based authentication
+- Role-based access control (RBAC)
+- Input validation and sanitization
+- SQL injection prevention (requires PDO migration)
+- File upload restrictions
+- HTTPS enforcement recommended
+
+**Note**: This is a legacy codebase using deprecated `mysql_*` functions. Migration to PDO/MySQLi is recommended for enhanced security.
+
+## 📊 Database
+
+- **Database**: MySQL (backglob_db)
+- **Key Tables**:
+ - `users` - User accounts and roles
+ - `ver_data` - Verification records
+ - `checks` - Check assignments
+ - `auth_token` - API authentication
+ - Additional tables for Bitrix/Savvion integration
+
+## 🤝 Contributing
+
+This is a proprietary system. For contribution guidelines, contact the development team.
+
+## 📝 License
+
+Proprietary - All rights reserved by Background Check (Private) Limited
+
+## 📞 Support
+
+- **Email**: support@backcheckgroup.com
+- **Phone**: +92-21-32863920-31
+- **Address**: 3rd Floor, GSA House, 19 Timber Pond, Karachi, Pakistan
+- **Website**: https://backcheckgroup.com
+
+## 🏢 About Background Check Group
+
+Background Check (Private) Limited is a leading background verification service provider based in Karachi, Pakistan. We provide comprehensive screening solutions for employment, education, identity, and other verification needs.
+
+---
+
+**Version**: 3.4
+**Last Updated**: 2026
+**Maintained by**: Background Check Development Team
From b048cc828c0ee13dae9a75e9553956fcf3472b4f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 15 Feb 2026 02:04:28 +0000
Subject: [PATCH 3/4] Add comprehensive documentation: API, User Guide,
Configuration, Integrations, and Development
Co-authored-by: backgroundcheck <18512725+backgroundcheck@users.noreply.github.com>
---
API_DOCUMENTATION.md | 694 +++++++++++++++++++++++++++++++++++++
CONFIGURATION.md | 626 +++++++++++++++++++++++++++++++++
DEVELOPMENT.md | 808 +++++++++++++++++++++++++++++++++++++++++++
INTEGRATIONS.md | 682 ++++++++++++++++++++++++++++++++++++
USER_GUIDE.md | 644 ++++++++++++++++++++++++++++++++++
5 files changed, 3454 insertions(+)
create mode 100644 API_DOCUMENTATION.md
create mode 100644 CONFIGURATION.md
create mode 100644 DEVELOPMENT.md
create mode 100644 INTEGRATIONS.md
create mode 100644 USER_GUIDE.md
diff --git a/API_DOCUMENTATION.md b/API_DOCUMENTATION.md
new file mode 100644
index 0000000..3ce8841
--- /dev/null
+++ b/API_DOCUMENTATION.md
@@ -0,0 +1,694 @@
+# API Documentation - BackCheck.io Verify
+
+## Table of Contents
+- [Overview](#overview)
+- [Authentication](#authentication)
+- [API Endpoints](#api-endpoints)
+- [Request/Response Format](#requestresponse-format)
+- [Error Handling](#error-handling)
+- [Rate Limiting](#rate-limiting)
+- [Code Examples](#code-examples)
+
+## Overview
+
+BackCheck.io Verify provides a REST API for programmatic access to the verification system. The API allows external systems to create verification requests, check status, upload documents, and retrieve reports.
+
+### Base URL
+```
+https://backcheck.io/verify/api_verify.php
+```
+
+### API Version
+Current Version: 1.0
+
+### Supported Formats
+- **Request**: JSON, Form Data (multipart for file uploads)
+- **Response**: JSON
+
+## Authentication
+
+### Token-Based Authentication
+
+All API requests require a valid authentication token passed in the Authorization header.
+
+#### Request Header
+```http
+Authorization: Bearer {your_api_token}
+```
+
+#### Obtaining an API Token
+
+Contact the system administrator to obtain an API token. Tokens are stored in the `auth_token` table with the following attributes:
+- Token string (unique)
+- User/Client association
+- Expiration date
+- Permissions/Scope
+
+#### Example Authentication
+```bash
+curl -X POST https://backcheck.io/verify/api_verify.php?action=get_status \
+ -H "Authorization: Bearer abc123def456ghi789" \
+ -H "Content-Type: application/json"
+```
+
+## API Endpoints
+
+### 1. Create Verification Request
+
+Create a new verification request in the system.
+
+**Endpoint**: `POST /api_verify.php?action=create_check`
+
+**Parameters**:
+```json
+{
+ "client_ref": "string (required) - Client reference number",
+ "applicant_name": "string (required) - Full name of applicant",
+ "email": "string (optional) - Applicant email",
+ "phone": "string (optional) - Applicant phone number",
+ "check_type": "string (required) - employment|education|criminal|identity|address",
+ "company_id": "integer (required) - Client company ID",
+ "priority": "string (optional) - normal|urgent|critical",
+ "tat_days": "integer (optional) - Turnaround time in days (default: 10)",
+ "documents": "array (optional) - Array of base64 encoded documents",
+ "custom_fields": "object (optional) - Additional custom fields"
+}
+```
+
+**Request Example**:
+```json
+{
+ "client_ref": "EMP-2026-001",
+ "applicant_name": "John Doe",
+ "email": "john.doe@example.com",
+ "phone": "+92-300-1234567",
+ "check_type": "employment",
+ "company_id": 87,
+ "priority": "normal",
+ "tat_days": 10,
+ "custom_fields": {
+ "position": "Software Engineer",
+ "department": "IT"
+ }
+}
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "message": "Verification request created successfully",
+ "data": {
+ "verification_id": 12345,
+ "client_ref": "EMP-2026-001",
+ "status": "submitted",
+ "created_date": "2026-02-15 10:30:00",
+ "tat_date": "2026-02-25 10:30:00"
+ }
+}
+```
+
+---
+
+### 2. Get Verification Status
+
+Retrieve the current status of a verification request.
+
+**Endpoint**: `GET /api_verify.php?action=get_status`
+
+**Parameters**:
+- `verification_id` (required) - Integer ID of the verification
+- `client_ref` (optional) - Alternative: search by client reference number
+
+**Request Example**:
+```bash
+GET /api_verify.php?action=get_status&verification_id=12345
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "data": {
+ "verification_id": 12345,
+ "client_ref": "EMP-2026-001",
+ "applicant_name": "John Doe",
+ "check_type": "employment",
+ "status": "in_progress",
+ "assigned_to": "Analyst Name",
+ "created_date": "2026-02-15 10:30:00",
+ "modified_date": "2026-02-16 14:20:00",
+ "tat_date": "2026-02-25 10:30:00",
+ "progress_percentage": 60,
+ "current_stage": "verification",
+ "timeline": [
+ {
+ "stage": "submitted",
+ "date": "2026-02-15 10:30:00",
+ "user": "System"
+ },
+ {
+ "stage": "assigned",
+ "date": "2026-02-15 11:00:00",
+ "user": "Team Lead"
+ },
+ {
+ "stage": "in_progress",
+ "date": "2026-02-16 09:00:00",
+ "user": "Analyst"
+ }
+ ]
+ }
+}
+```
+
+---
+
+### 3. Upload Documents
+
+Upload supporting documents for a verification request.
+
+**Endpoint**: `POST /api_verify.php?action=upload_document`
+
+**Parameters**:
+- `verification_id` (required) - Integer ID of the verification
+- `file` (required) - File upload (multipart/form-data)
+- `document_type` (optional) - Type of document (resume, certificate, id_card, etc.)
+- `description` (optional) - Document description
+
+**Request Example** (multipart/form-data):
+```bash
+curl -X POST https://backcheck.io/verify/api_verify.php?action=upload_document \
+ -H "Authorization: Bearer abc123def456ghi789" \
+ -F "verification_id=12345" \
+ -F "file=@/path/to/document.pdf" \
+ -F "document_type=certificate" \
+ -F "description=Education Certificate"
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "message": "Document uploaded successfully",
+ "data": {
+ "upload_id": 789,
+ "filename": "document.pdf",
+ "file_size": "245678",
+ "upload_date": "2026-02-15 10:35:00"
+ }
+}
+```
+
+---
+
+### 4. Get Verification Report
+
+Retrieve the completed verification report.
+
+**Endpoint**: `GET /api_verify.php?action=get_report`
+
+**Parameters**:
+- `verification_id` (required) - Integer ID of the verification
+- `format` (optional) - pdf|json (default: json)
+
+**Request Example**:
+```bash
+GET /api_verify.php?action=get_report&verification_id=12345&format=json
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "data": {
+ "verification_id": 12345,
+ "client_ref": "EMP-2026-001",
+ "applicant_name": "John Doe",
+ "check_type": "employment",
+ "final_status": "verified",
+ "completed_date": "2026-02-20 16:00:00",
+ "report": {
+ "summary": "Employment verification completed successfully",
+ "findings": [
+ {
+ "employer": "ABC Company",
+ "position": "Software Engineer",
+ "duration": "Jan 2020 - Dec 2023",
+ "verification_status": "confirmed",
+ "remarks": "All details verified with HR department"
+ }
+ ],
+ "recommendation": "Clear - No discrepancies found",
+ "verified_by": "Senior Analyst Name",
+ "qc_approved_by": "QC Manager Name"
+ },
+ "report_url": "https://backcheck.io/verify/reports/12345.pdf"
+ }
+}
+```
+
+---
+
+### 5. List Verifications
+
+List verification requests with filtering and pagination.
+
+**Endpoint**: `GET /api_verify.php?action=list_verifications`
+
+**Parameters**:
+- `company_id` (optional) - Filter by company
+- `status` (optional) - Filter by status
+- `from_date` (optional) - Start date (YYYY-MM-DD)
+- `to_date` (optional) - End date (YYYY-MM-DD)
+- `page` (optional) - Page number (default: 1)
+- `per_page` (optional) - Results per page (default: 20, max: 100)
+
+**Request Example**:
+```bash
+GET /api_verify.php?action=list_verifications&company_id=87&status=completed&page=1&per_page=20
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "data": {
+ "total_count": 145,
+ "page": 1,
+ "per_page": 20,
+ "total_pages": 8,
+ "verifications": [
+ {
+ "verification_id": 12345,
+ "client_ref": "EMP-2026-001",
+ "applicant_name": "John Doe",
+ "check_type": "employment",
+ "status": "completed",
+ "created_date": "2026-02-15 10:30:00",
+ "completed_date": "2026-02-20 16:00:00"
+ },
+ // ... more records
+ ]
+ }
+}
+```
+
+---
+
+### 6. Update Verification
+
+Update details of an existing verification request.
+
+**Endpoint**: `PUT /api_verify.php?action=update_check`
+
+**Parameters**:
+```json
+{
+ "verification_id": "integer (required) - Verification ID",
+ "priority": "string (optional) - Update priority",
+ "notes": "string (optional) - Add notes",
+ "custom_fields": "object (optional) - Update custom fields"
+}
+```
+
+**Request Example**:
+```json
+{
+ "verification_id": 12345,
+ "priority": "urgent",
+ "notes": "Client requested expedited processing"
+}
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "message": "Verification updated successfully",
+ "data": {
+ "verification_id": 12345,
+ "updated_fields": ["priority", "notes"],
+ "modified_date": "2026-02-16 11:00:00"
+ }
+}
+```
+
+---
+
+### 7. Cancel Verification
+
+Cancel a pending verification request.
+
+**Endpoint**: `DELETE /api_verify.php?action=cancel_check`
+
+**Parameters**:
+- `verification_id` (required) - Integer ID of the verification
+- `reason` (optional) - Cancellation reason
+
+**Request Example**:
+```json
+{
+ "verification_id": 12345,
+ "reason": "Applicant withdrew application"
+}
+```
+
+**Response Example**:
+```json
+{
+ "status": "success",
+ "message": "Verification cancelled successfully",
+ "data": {
+ "verification_id": 12345,
+ "previous_status": "in_progress",
+ "current_status": "cancelled",
+ "cancelled_date": "2026-02-16 12:00:00"
+ }
+}
+```
+
+---
+
+### 8. Get Webhook Status (Future Feature)
+
+Register a webhook URL for status updates.
+
+**Endpoint**: `POST /api_verify.php?action=register_webhook`
+
+**Parameters**:
+```json
+{
+ "url": "string (required) - Webhook URL",
+ "events": "array (required) - Events to subscribe to",
+ "secret": "string (optional) - Webhook secret for verification"
+}
+```
+
+## Request/Response Format
+
+### Standard Response Structure
+
+All API responses follow a consistent structure:
+
+**Success Response**:
+```json
+{
+ "status": "success",
+ "message": "Operation completed successfully",
+ "data": {
+ // Response data object
+ }
+}
+```
+
+**Error Response**:
+```json
+{
+ "status": "error",
+ "message": "Error description",
+ "error_code": "ERROR_CODE",
+ "details": {
+ // Additional error details
+ }
+}
+```
+
+### HTTP Status Codes
+
+| Code | Description |
+|------|-------------|
+| 200 | Success - Request completed successfully |
+| 201 | Created - Resource created successfully |
+| 400 | Bad Request - Invalid parameters or request format |
+| 401 | Unauthorized - Invalid or missing authentication token |
+| 403 | Forbidden - Insufficient permissions |
+| 404 | Not Found - Resource not found |
+| 422 | Unprocessable Entity - Validation errors |
+| 429 | Too Many Requests - Rate limit exceeded |
+| 500 | Internal Server Error - Server error occurred |
+| 503 | Service Unavailable - Service temporarily unavailable |
+
+## Error Handling
+
+### Error Response Structure
+
+```json
+{
+ "status": "error",
+ "message": "Human-readable error message",
+ "error_code": "UNIQUE_ERROR_CODE",
+ "details": {
+ "field": "Field that caused the error",
+ "reason": "Detailed reason for the error"
+ }
+}
+```
+
+### Common Error Codes
+
+| Error Code | Description |
+|------------|-------------|
+| `AUTH_TOKEN_INVALID` | Invalid or expired authentication token |
+| `AUTH_TOKEN_MISSING` | Authorization header not provided |
+| `PARAM_MISSING` | Required parameter is missing |
+| `PARAM_INVALID` | Parameter value is invalid |
+| `VERIFICATION_NOT_FOUND` | Verification ID not found |
+| `PERMISSION_DENIED` | User does not have permission for this action |
+| `FILE_TOO_LARGE` | Uploaded file exceeds size limit |
+| `FILE_TYPE_INVALID` | File type not allowed |
+| `RATE_LIMIT_EXCEEDED` | Too many requests - rate limit exceeded |
+| `SERVER_ERROR` | Internal server error occurred |
+
+### Error Examples
+
+**Missing Parameter**:
+```json
+{
+ "status": "error",
+ "message": "Required parameter missing",
+ "error_code": "PARAM_MISSING",
+ "details": {
+ "field": "client_ref",
+ "reason": "Client reference number is required"
+ }
+}
+```
+
+**Invalid Token**:
+```json
+{
+ "status": "error",
+ "message": "Authentication failed",
+ "error_code": "AUTH_TOKEN_INVALID",
+ "details": {
+ "reason": "Token has expired or is invalid"
+ }
+}
+```
+
+## Rate Limiting
+
+### Limits
+- **Rate Limit**: 100 requests per minute per API token
+- **Burst Limit**: 10 concurrent requests
+
+### Rate Limit Headers
+
+Response headers include rate limit information:
+
+```http
+X-RateLimit-Limit: 100
+X-RateLimit-Remaining: 95
+X-RateLimit-Reset: 1639584000
+```
+
+### Rate Limit Exceeded Response
+
+```json
+{
+ "status": "error",
+ "message": "Rate limit exceeded",
+ "error_code": "RATE_LIMIT_EXCEEDED",
+ "details": {
+ "limit": 100,
+ "reset_time": "2026-02-15T11:00:00Z",
+ "retry_after": 45
+ }
+}
+```
+
+## Code Examples
+
+### PHP Example
+
+```php
+ 'EMP-2026-001',
+ 'applicant_name' => 'John Doe',
+ 'email' => 'john.doe@example.com',
+ 'check_type' => 'employment',
+ 'company_id' => 87
+];
+
+$result = createVerification($api_url, $api_token, $verification_data);
+print_r($result);
+?>
+```
+
+### JavaScript (Node.js) Example
+
+```javascript
+const axios = require('axios');
+
+const API_URL = 'https://backcheck.io/verify/api_verify.php';
+const API_TOKEN = 'your_api_token_here';
+
+// Create verification request
+async function createVerification(data) {
+ try {
+ const response = await axios.post(
+ `${API_URL}?action=create_check`,
+ data,
+ {
+ headers: {
+ 'Authorization': `Bearer ${API_TOKEN}`,
+ 'Content-Type': 'application/json'
+ }
+ }
+ );
+ return response.data;
+ } catch (error) {
+ console.error('API Error:', error.response.data);
+ throw error;
+ }
+}
+
+// Usage
+const verificationData = {
+ client_ref: 'EMP-2026-001',
+ applicant_name: 'John Doe',
+ email: 'john.doe@example.com',
+ check_type: 'employment',
+ company_id: 87
+};
+
+createVerification(verificationData)
+ .then(result => console.log(result))
+ .catch(error => console.error(error));
+```
+
+### Python Example
+
+```python
+import requests
+import json
+
+API_URL = 'https://backcheck.io/verify/api_verify.php'
+API_TOKEN = 'your_api_token_here'
+
+def create_verification(data):
+ """Create a new verification request"""
+ headers = {
+ 'Authorization': f'Bearer {API_TOKEN}',
+ 'Content-Type': 'application/json'
+ }
+
+ response = requests.post(
+ f'{API_URL}?action=create_check',
+ headers=headers,
+ json=data
+ )
+
+ return response.json()
+
+# Usage
+verification_data = {
+ 'client_ref': 'EMP-2026-001',
+ 'applicant_name': 'John Doe',
+ 'email': 'john.doe@example.com',
+ 'check_type': 'employment',
+ 'company_id': 87
+}
+
+result = create_verification(verification_data)
+print(json.dumps(result, indent=2))
+```
+
+### cURL Example
+
+```bash
+# Create verification
+curl -X POST 'https://backcheck.io/verify/api_verify.php?action=create_check' \
+ -H 'Authorization: Bearer your_api_token_here' \
+ -H 'Content-Type: application/json' \
+ -d '{
+ "client_ref": "EMP-2026-001",
+ "applicant_name": "John Doe",
+ "email": "john.doe@example.com",
+ "check_type": "employment",
+ "company_id": 87
+ }'
+
+# Get status
+curl -X GET 'https://backcheck.io/verify/api_verify.php?action=get_status&verification_id=12345' \
+ -H 'Authorization: Bearer your_api_token_here'
+
+# Upload document
+curl -X POST 'https://backcheck.io/verify/api_verify.php?action=upload_document' \
+ -H 'Authorization: Bearer your_api_token_here' \
+ -F 'verification_id=12345' \
+ -F 'file=@document.pdf' \
+ -F 'document_type=certificate'
+```
+
+## Best Practices
+
+1. **Secure Token Storage**: Store API tokens securely, never in source code
+2. **Error Handling**: Always implement proper error handling
+3. **Retry Logic**: Implement exponential backoff for transient errors
+4. **Logging**: Log all API requests and responses for debugging
+5. **Timeout Handling**: Set appropriate timeout values for requests
+6. **Webhook Validation**: Verify webhook signatures when available
+7. **Rate Limit Awareness**: Monitor rate limit headers and adjust accordingly
+8. **Data Validation**: Validate data before sending to API
+9. **HTTPS Only**: Always use HTTPS for API communication
+10. **Token Rotation**: Regularly rotate API tokens for security
+
+## Support
+
+For API support or to request additional features:
+- **Email**: support@backcheckgroup.com
+- **Documentation**: https://backcheck.io/verify/api-docs
+- **Status Page**: https://status.backcheckgroup.com
+
+---
+
+**API Version**: 1.0
+**Last Updated**: 2026
+**Maintained by**: Background Check Development Team
diff --git a/CONFIGURATION.md b/CONFIGURATION.md
new file mode 100644
index 0000000..1e5a738
--- /dev/null
+++ b/CONFIGURATION.md
@@ -0,0 +1,626 @@
+# Configuration Guide - BackCheck.io Verify
+
+## Table of Contents
+- [Configuration Files](#configuration-files)
+- [Database Configuration](#database-configuration)
+- [Application Settings](#application-settings)
+- [Email Configuration](#email-configuration)
+- [File Upload Settings](#file-upload-settings)
+- [Integration Settings](#integration-settings)
+- [Security Settings](#security-settings)
+- [Performance Tuning](#performance-tuning)
+- [Environment-Specific Configuration](#environment-specific-configuration)
+
+## Configuration Files
+
+The system uses multiple configuration files located in the `/include/` directory:
+
+### Primary Configuration Files
+
+| File | Purpose |
+|------|---------|
+| `global_config.php` | Main configuration - database, URLs, constants |
+| `config_index.php` | Index page configuration and session handling |
+| `config_actions.php` | AJAX actions configuration |
+| `config_client.php` | Client portal configuration |
+| `config_admin.php` | Admin panel configuration |
+
+### Configuration File Locations
+
+```
+/verify/include/
+├── global_config.php # Main configuration (EDIT THIS)
+├── config_index.php # Index configuration
+├── config_actions.php # Actions configuration
+├── config_client.php # Client configuration
+└── config_admin.php # Admin configuration
+```
+
+## Database Configuration
+
+### global_config.php - Database Settings
+
+```php
+
+```
+
+### Database Connection Options
+
+**Local Development**:
+```php
+define("HOST", 'localhost');
+define("DB", 'backglob_dev');
+define("USER", 'dev_user');
+define("PASS", 'dev_password');
+```
+
+**Production**:
+```php
+define("HOST", 'production-db.example.com');
+define("DB", 'backglob_production');
+define("USER", 'prod_user');
+define("PASS", 'strong_production_password');
+```
+
+**Remote Database**:
+```php
+define("HOST", '192.168.1.100'); // Remote DB server IP
+define("DB", 'backglob_db');
+define("USER", 'remote_user');
+define("PASS", 'remote_password');
+```
+
+### Database Character Set
+
+The database should use UTF-8 encoding:
+
+```sql
+ALTER DATABASE backglob_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
+```
+
+## Application Settings
+
+### Site URLs
+
+```php
+// Main Site URLs
+define("SITE_URL", 'https://backcheck.io/verify/');
+define("SURL", 'https://backcheck.io/verify/');
+
+// For subdomain installations
+define("SITE_URL", 'https://verify.backcheck.io/');
+
+// For development/localhost
+define("SITE_URL", 'http://localhost/verify/');
+```
+
+### Site Information
+
+```php
+// Organization Details
+define("SITENM", 'BackgroundCheckGroup');
+define("PORTAL", 'BackgroundCheckGroup Verification System');
+
+// Email Addresses
+define("DEMAIL", 'noreply@backcheckgroup.com'); // Default sender
+define("SUPPORT_EMAIL", 'support@backcheckgroup.com');
+define("INFO_EMAIL", 'info@backcheckgroup.com');
+
+// Copyright Information
+define("COPYRIGHT_URL", 'https://backcheckgroup.com/');
+```
+
+### Business Settings
+
+```php
+// Turnaround Time (in days)
+define("TAT", 10); // Default turnaround time for verifications
+
+// Applicant Label
+define("APPLICANT", "Applicant"); // Can be customized to "Candidate", etc.
+
+// Company IDs for checks
+define("CHECK_COMIDS", serialize(array(87, 96)));
+```
+
+### Application Version
+
+```php
+// Version number (used for cache busting)
+$BCPV = 3.4; // Increment when deploying updates
+```
+
+### Office Address
+
+```php
+define("OFFICE_ADDRESS",
+ "Background Check (Private) Limited
+ 3rd Floor, GSA House, 19 Timber Pond,
+ Near KPT Overpass Bridge East Wharf,
+ Keamari, Karachi - Pakistan
+ Tel. : 92-21-32863920 - 31
+ Fax : 92-21-32863931
+ Email : info@backcheckgroup.com
+ SNTN: S2913136-7, NTN: 2913136-7"
+);
+```
+
+### Payment Information
+
+```php
+define("DECLARATION",
+ "Payment Instructions:
+ Name of Beneficiary: BackgroundCheckGroup
+ Account No: 08517900292703 (PKR)
+ IBAN: PKHABB0008577900292703
+ Bank: Habib Bank Limited, PNSC Karachi, Pakistan
+ Swift Code: HABBPKKA"
+);
+```
+
+## Email Configuration
+
+### PHPMailer Settings
+
+Edit in `/functions/functions.php` or create a separate email config file:
+
+```php
+// SMTP Configuration
+$mail->IsSMTP();
+$mail->Host = 'smtp.gmail.com'; // SMTP server
+$mail->Port = 587; // SMTP port (587 for TLS, 465 for SSL)
+$mail->SMTPAuth = true; // Enable authentication
+$mail->Username = 'noreply@backcheckgroup.com'; // SMTP username
+$mail->Password = 'your_smtp_password'; // SMTP password
+$mail->SMTPSecure = 'tls'; // Encryption (tls or ssl)
+
+// Email From Settings
+$mail->From = 'noreply@backcheckgroup.com';
+$mail->FromName = 'BackCheck Verify';
+
+// Additional Settings
+$mail->CharSet = 'UTF-8';
+$mail->IsHTML(true);
+```
+
+### Email Provider Configurations
+
+**Gmail/G Suite**:
+```php
+$mail->Host = 'smtp.gmail.com';
+$mail->Port = 587;
+$mail->SMTPSecure = 'tls';
+// Note: Enable "Less secure app access" or use App Password
+```
+
+**Office 365**:
+```php
+$mail->Host = 'smtp.office365.com';
+$mail->Port = 587;
+$mail->SMTPSecure = 'tls';
+```
+
+**AWS SES**:
+```php
+$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
+$mail->Port = 587;
+$mail->SMTPSecure = 'tls';
+$mail->Username = 'YOUR_SES_SMTP_USERNAME';
+$mail->Password = 'YOUR_SES_SMTP_PASSWORD';
+```
+
+**SendGrid**:
+```php
+$mail->Host = 'smtp.sendgrid.net';
+$mail->Port = 587;
+$mail->SMTPSecure = 'tls';
+$mail->Username = 'apikey';
+$mail->Password = 'YOUR_SENDGRID_API_KEY';
+```
+
+### Email Templates
+
+Email templates are located in `/include_pages/email_templates/` or embedded in functions. Customize as needed:
+
+```php
+// Example email template
+$email_body = "
+
+
+ Verification Request Submitted
+ Dear {applicant_name},
+ Your verification request has been submitted successfully.
+ Reference Number: {ref_number}
+ Expected Completion: {tat_date}
+
+
+";
+```
+
+## File Upload Settings
+
+### Upload Configuration
+
+```php
+// Allowed File Types
+define("FILE_TYPES_ALLOWED", "gif, jpeg, jpg, png, docx, doc, pdf");
+
+// Allowed File Types for Savvion Checks
+define("FILE_TYPES_ALLOWED_SAVVION",
+ "jpg,png,gif,bmp,jpeg,pdf,doc,docx,xls,csv,txt,pcx,svg,xlsx,xlm,msg,xps");
+
+// Maximum File Size
+define("FILE_SIZE_ALLOWED", "5 MB");
+```
+
+### PHP File Upload Settings
+
+Edit `php.ini` or `.htaccess`:
+
+**php.ini**:
+```ini
+upload_max_filesize = 5M
+post_max_size = 8M
+max_file_uploads = 20
+```
+
+**.htaccess** (for Apache):
+```apache
+php_value upload_max_filesize 5M
+php_value post_max_size 8M
+php_value max_file_uploads 20
+```
+
+### Upload Directory Configuration
+
+Ensure writable permissions:
+
+```bash
+chmod 775 /var/www/html/verify/images/uploads
+chmod 775 /var/www/html/verify/images/case_uploads
+chmod 775 /var/www/html/verify/images/profile_pics
+```
+
+### File Upload Security
+
+```php
+// Validate file types
+$allowed_types = array('pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png', 'gif');
+$file_ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION));
+
+if(!in_array($file_ext, $allowed_types)) {
+ die('Invalid file type');
+}
+
+// Validate file size (5MB = 5242880 bytes)
+if($_FILES['file']['size'] > 5242880) {
+ die('File too large');
+}
+
+// Generate unique filename
+$filename = uniqid() . '.' . $file_ext;
+```
+
+## Integration Settings
+
+### Bitrix CRM Integration
+
+```php
+// Bitrix API URL
+define("BITRIX_URL", "https://my.backcheck.io/rest_api.php");
+
+// Bitrix Admin Mappings (in functions/bitrix/bitrix_functions.php)
+$admin_mapping = array(
+ 'PK' => 529, // Pakistan - Sharjeel
+ 'UAE' => 591, // UAE - Other admin
+ 'default' => 480 // Default - Sadia
+);
+
+// Bitrix Task Settings
+$task_tat = 10; // Days
+$task_reminder = 1; // Day before deadline
+```
+
+### Google Sheets API
+
+```php
+// Google API Configuration (in api_google.php)
+$google_client_id = 'YOUR_CLIENT_ID';
+$google_client_secret = 'YOUR_CLIENT_SECRET';
+$google_redirect_uri = 'https://backcheck.io/verify/api_google.php';
+$google_api_key = 'YOUR_API_KEY';
+```
+
+### WHMCS Integration
+
+```php
+// WHMCS API URL
+define("WHMCS_APIURL", "https://backcheckgroup.com/support/includes/api.php");
+
+// WHMCS API Credentials (store securely)
+$whmcs_identifier = 'YOUR_API_IDENTIFIER';
+$whmcs_secret = 'YOUR_API_SECRET';
+```
+
+### Savvion BPM Configuration
+
+Configuration typically in `/functions/savvion/savvion_config.php`:
+
+```php
+// Savvion API Endpoint
+$savvion_url = 'https://savvion.example.com/api';
+
+// Savvion Credentials
+$savvion_username = 'api_user';
+$savvion_password = 'api_password';
+
+// Workflow IDs
+$workflows = array(
+ 'employment' => 'WF_EMP_001',
+ 'education' => 'WF_EDU_001'
+);
+```
+
+## Security Settings
+
+### Session Configuration
+
+```php
+// Session Settings (in config files)
+ini_set('session.gc_maxlifetime', 3600); // 1 hour
+session_set_cookie_params(0); // Expire on browser close
+session_start();
+
+// Regenerate session ID on login (recommended)
+session_regenerate_id(true);
+```
+
+### Password Hashing
+
+**Current (Legacy - MD5)**:
+```php
+$password_hash = md5($password); // NOT RECOMMENDED
+```
+
+**Recommended (Modern)**:
+```php
+// Hash password
+$password_hash = password_hash($password, PASSWORD_BCRYPT);
+
+// Verify password
+if(password_verify($input_password, $stored_hash)) {
+ // Password correct
+}
+```
+
+### HTTPS Configuration
+
+Force HTTPS in `.htaccess`:
+
+```apache
+RewriteEngine On
+RewriteCond %{HTTPS} off
+RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
+```
+
+### CORS Configuration
+
+If enabling API access from external domains:
+
+```php
+// Allow specific origins
+header('Access-Control-Allow-Origin: https://trusted-domain.com');
+header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
+header('Access-Control-Allow-Headers: Content-Type, Authorization');
+```
+
+## Performance Tuning
+
+### PHP Configuration
+
+```ini
+; Memory limit
+memory_limit = 256M
+
+; Execution time
+max_execution_time = 300
+max_input_time = 300
+
+; Opcache (PHP 5.5+)
+opcache.enable = 1
+opcache.memory_consumption = 128
+opcache.interned_strings_buffer = 8
+opcache.max_accelerated_files = 4000
+opcache.revalidate_freq = 60
+```
+
+### MySQL Optimization
+
+```ini
+# my.cnf / my.ini
+[mysqld]
+innodb_buffer_pool_size = 1G
+innodb_log_file_size = 256M
+innodb_flush_log_at_trx_commit = 2
+query_cache_type = 1
+query_cache_size = 64M
+```
+
+### Apache Configuration
+
+```apache
+# Enable compression
+
+ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
+
+
+# Enable caching
+
+ ExpiresActive On
+ ExpiresByType image/jpg "access plus 1 year"
+ ExpiresByType image/jpeg "access plus 1 year"
+ ExpiresByType image/gif "access plus 1 year"
+ ExpiresByType image/png "access plus 1 year"
+ ExpiresByType text/css "access plus 1 month"
+ ExpiresByType application/javascript "access plus 1 month"
+
+```
+
+## Environment-Specific Configuration
+
+### Development Environment
+
+```php
+
+```
+
+### Staging Environment
+
+```php
+
+```
+
+### Production Environment
+
+```php
+
+```
+
+## Custom Configuration
+
+### Company-Specific Constants
+
+```php
+// Custom field labels
+define("CLIENT_REF_NUM", "Client Reference Number");
+define("ID_CARD_NUM", "ID Card Number");
+
+// Add more as needed
+define("PASSPORT_NUM", "Passport Number");
+define("LICENSE_NUM", "License Number");
+```
+
+### Feature Toggles
+
+```php
+// Feature flags
+define("ENABLE_BULK_UPLOAD", true);
+define("ENABLE_SAVVION_CHECKS", true);
+define("ENABLE_INSTANT_REPORTS", true);
+define("ENABLE_LIVE_CHAT", false);
+```
+
+### Regional Settings
+
+```php
+// Timezone
+date_default_timezone_set('Asia/Karachi');
+
+// Currency
+define("CURRENCY", "PKR");
+define("CURRENCY_SYMBOL", "Rs.");
+
+// Date format
+define("DATE_FORMAT", "d-m-Y");
+define("DATETIME_FORMAT", "d-m-Y H:i:s");
+```
+
+## Configuration Best Practices
+
+1. **Never Commit Passwords**: Keep credentials out of version control
+2. **Use Environment Variables**: Store sensitive data in environment variables
+3. **Separate Configs**: Use different config files per environment
+4. **Document Changes**: Comment configuration changes
+5. **Backup Before Changes**: Always backup before modifying configs
+6. **Test After Changes**: Verify system works after configuration changes
+7. **Restrict Access**: Set proper file permissions (640 for config files)
+8. **Regular Review**: Periodically review and update configurations
+
+## Configuration Checklist
+
+Before deploying:
+
+- [ ] Database credentials configured correctly
+- [ ] Site URLs updated for environment
+- [ ] Email settings configured and tested
+- [ ] File upload directories writable
+- [ ] Integration credentials configured
+- [ ] HTTPS enabled in production
+- [ ] Error reporting appropriate for environment
+- [ ] Session timeout configured
+- [ ] Timezone set correctly
+- [ ] Backup strategy in place
+- [ ] Security settings reviewed
+- [ ] Performance settings optimized
+
+---
+
+**Last Updated**: 2026
+**Version**: 3.4
+**Maintained by**: Background Check Development Team
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
new file mode 100644
index 0000000..269c90e
--- /dev/null
+++ b/DEVELOPMENT.md
@@ -0,0 +1,808 @@
+# Development Guide - BackCheck.io Verify
+
+## Table of Contents
+- [Development Environment Setup](#development-environment-setup)
+- [Code Structure](#code-structure)
+- [Coding Standards](#coding-standards)
+- [Development Workflow](#development-workflow)
+- [Testing](#testing)
+- [Debugging](#debugging)
+- [Security Best Practices](#security-best-practices)
+- [Modernization Recommendations](#modernization-recommendations)
+- [Common Tasks](#common-tasks)
+
+## Development Environment Setup
+
+### Prerequisites
+
+- PHP 5.6+ (PHP 7.4+ recommended for development)
+- MySQL 5.7+ or MariaDB 10.2+
+- Apache/Nginx web server
+- Git for version control
+- Code editor (VS Code, PHPStorm, etc.)
+
+### Local Development Setup
+
+#### 1. Clone Repository
+
+```bash
+git clone https://github.com/BackCheck/backcheck.io.verify.git
+cd backcheck.io.verify
+```
+
+#### 2. Database Setup
+
+```bash
+# Create database
+mysql -u root -p
+CREATE DATABASE backglob_dev;
+USE backglob_dev;
+SOURCE database_schema.sql;
+EXIT;
+```
+
+#### 3. Configuration
+
+Copy and edit configuration:
+
+```bash
+cp include/global_config.php.example include/global_config.php
+```
+
+Edit `include/global_config.php`:
+
+```php
+
+```
+
+#### 4. Web Server Configuration
+
+**Apache + XAMPP/WAMP**:
+```apache
+
+ DocumentRoot "C:/xampp/htdocs/backcheck.io.verify"
+ ServerName backcheck.local
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+
+```
+
+**Nginx**:
+```nginx
+server {
+ listen 80;
+ server_name backcheck.local;
+ root /var/www/backcheck.io.verify;
+ index index.php;
+
+ location / {
+ try_files $uri $uri/ /index.php?$query_string;
+ }
+
+ location ~ \.php$ {
+ fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ include fastcgi_params;
+ }
+}
+```
+
+Add to `/etc/hosts`:
+```
+127.0.0.1 backcheck.local
+```
+
+#### 5. File Permissions
+
+```bash
+chmod 775 images/uploads
+chmod 775 images/case_uploads
+chmod 775 images/profile_pics
+chmod 640 include/global_config.php
+```
+
+## Code Structure
+
+### Directory Organization
+
+```
+/verify/
+├── index.php # Main entry point
+├── actions.php # AJAX request handler
+├── api_verify.php # REST API endpoint
+│
+├── include/ # Core configuration
+│ ├── global_config.php # Main config (sensitive)
+│ ├── db_class.php # Database wrapper
+│ └── config_*.php # Role-based configs
+│
+├── functions/ # Business logic
+│ ├── functions.php # Core functions (374KB - needs refactoring)
+│ ├── bitrix/ # Bitrix integration
+│ ├── savvion/ # Savvion workflow
+│ └── class.phpmailer.php # Email handling
+│
+├── include_pages/ # Page templates (400+ files)
+│ ├── index_new_inc.php # Dashboard
+│ ├── applicant_inc.php # Applicant pages
+│ ├── checks_inc.php # Check management
+│ └── reports_inc.php # Report generation
+│
+├── js/ # JavaScript
+│ ├── ajax_script-2.js # AJAX functions
+│ ├── js_functions-2.js # Utility functions
+│ └── encoder.js # Encoding utilities
+│
+├── css/ # Stylesheets
+├── images/ # Static assets
+└── scripts/ # External libraries
+```
+
+### Request Flow
+
+```
+User Request
+ ↓
+index.php (routing based on ?action= parameter)
+ ↓
+Load configuration (config_*.php based on user level)
+ ↓
+Include appropriate template (include_pages/*.php)
+ ↓
+Execute business logic (functions/functions.php)
+ ↓
+Query database (include/db_class.php)
+ ↓
+Render HTML response
+```
+
+### AJAX Flow
+
+```
+JavaScript (jQuery)
+ ↓
+$.ajax() → actions.php
+ ↓
+Load config_actions.php
+ ↓
+Route based on ?action= parameter
+ ↓
+Include appropriate handler (include_pages/*_inc.php)
+ ↓
+Process and return JSON response
+```
+
+## Coding Standards
+
+### PHP Coding Style
+
+**File Structure**:
+```php
+
+```
+
+**Naming Conventions**:
+- Variables: `$snake_case` (existing convention)
+- Functions: `camelCase()` or `snake_case()` (be consistent)
+- Constants: `UPPER_CASE`
+- Classes: `PascalCase`
+- Database tables: `lowercase_underscore`
+
+**Indentation**:
+- Use 4 spaces or 1 tab (be consistent)
+- Opening brace on same line for functions
+- Closing brace on new line
+
+**Example**:
+```php
+function getUserById($user_id) {
+ if($user_id > 0) {
+ $query = "SELECT * FROM users WHERE id = " . intval($user_id);
+ $result = mysql_query($query);
+
+ if(mysql_num_rows($result) > 0) {
+ return mysql_fetch_assoc($result);
+ }
+ }
+ return false;
+}
+```
+
+### SQL Best Practices
+
+**Current (Legacy - Unsafe)**:
+```php
+// DON'T DO THIS - SQL Injection Risk
+$query = "SELECT * FROM users WHERE username = '" . $_POST['username'] . "'";
+$result = mysql_query($query);
+```
+
+**Recommended (Safe)**:
+```php
+// Use prepared statements with PDO or MySQLi
+$query = "SELECT * FROM users WHERE username = ?";
+$stmt = $pdo->prepare($query);
+$stmt->execute([$_POST['username']]);
+$user = $stmt->fetch();
+```
+
+**Input Sanitization** (interim solution):
+```php
+// Escape input (better than nothing, but not as good as prepared statements)
+$username = mysql_real_escape_string($_POST['username']);
+$query = "SELECT * FROM users WHERE username = '$username'";
+```
+
+### JavaScript/jQuery Style
+
+```javascript
+// Use descriptive variable names
+var verificationId = 123;
+var applicantName = "John Doe";
+
+// Function declaration
+function submitVerification(data) {
+ $.ajax({
+ url: 'actions.php',
+ type: 'POST',
+ data: {
+ action: 'submit_check',
+ data: data
+ },
+ success: function(response) {
+ handleResponse(response);
+ },
+ error: function(xhr, status, error) {
+ console.error('Error:', error);
+ }
+ });
+}
+
+// Event handling
+$(document).ready(function() {
+ $('#submit-btn').on('click', function(e) {
+ e.preventDefault();
+ submitVerification(getFormData());
+ });
+});
+```
+
+### HTML/Template Style
+
+```php
+
+
+
+
+
+
+
= htmlspecialchars($ver['applicant_name']) ?>
+
Status: = htmlspecialchars($ver['status']) ?>
+
Date: = date('d-m-Y', strtotime($ver['created_date'])) ?>
+
+
+
+```
+
+## Development Workflow
+
+### Git Workflow
+
+```bash
+# Create feature branch
+git checkout -b feature/add-new-report
+
+# Make changes and commit frequently
+git add .
+git commit -m "Add: New monthly report feature"
+
+# Push to remote
+git push origin feature/add-new-report
+
+# Create pull request for review
+# After approval, merge to main branch
+```
+
+### Commit Message Guidelines
+
+**Format**:
+```
+Type: Brief description (50 chars or less)
+
+More detailed explanation if needed (wrap at 72 characters).
+Explain what changed and why, not how.
+```
+
+**Types**:
+- `Add:` - New feature
+- `Fix:` - Bug fix
+- `Update:` - Update existing feature
+- `Refactor:` - Code refactoring
+- `Doc:` - Documentation changes
+- `Style:` - Code style changes
+- `Security:` - Security improvements
+
+**Examples**:
+```bash
+git commit -m "Add: Bulk verification upload feature"
+git commit -m "Fix: File upload validation error for PDF files"
+git commit -m "Security: Implement prepared statements in user module"
+git commit -m "Refactor: Extract email functions into separate class"
+```
+
+### Code Review Checklist
+
+Before submitting for review:
+
+- [ ] Code follows project coding standards
+- [ ] All functions have descriptive names
+- [ ] Input validation implemented
+- [ ] SQL injection prevention (prepared statements or escaping)
+- [ ] XSS prevention (output escaping)
+- [ ] Error handling implemented
+- [ ] Comments added for complex logic
+- [ ] No hardcoded credentials
+- [ ] Tested in local environment
+- [ ] No debug code (var_dump, print_r, etc.)
+
+## Testing
+
+### Manual Testing
+
+#### Test Checklist for New Features
+
+1. **Functional Testing**:
+ - Feature works as expected
+ - All user flows complete successfully
+ - Error messages display correctly
+
+2. **UI Testing**:
+ - Layout displays correctly
+ - Responsive design works on mobile
+ - Forms validate input properly
+
+3. **Integration Testing**:
+ - External API calls work
+ - Database operations succeed
+ - File uploads/downloads work
+
+4. **Browser Testing**:
+ - Test in Chrome, Firefox, Safari
+ - Check console for JavaScript errors
+
+### Database Testing
+
+```sql
+-- Test data creation
+INSERT INTO ver_data (client_ref_num, applicant_name, check_type, status)
+VALUES ('TEST-001', 'Test Applicant', 'employment', 'submitted');
+
+-- Verify insertion
+SELECT * FROM ver_data WHERE client_ref_num = 'TEST-001';
+
+-- Cleanup after testing
+DELETE FROM ver_data WHERE client_ref_num LIKE 'TEST-%';
+```
+
+### API Testing
+
+Using cURL:
+
+```bash
+# Test API endpoint
+curl -X POST 'http://localhost/verify/api_verify.php?action=create_check' \
+ -H 'Authorization: Bearer test_token_123' \
+ -H 'Content-Type: application/json' \
+ -d '{
+ "client_ref": "TEST-001",
+ "applicant_name": "Test User",
+ "check_type": "employment",
+ "company_id": 87
+ }'
+```
+
+Using Postman:
+1. Create a new request
+2. Set method to POST
+3. Add Authorization header
+4. Add request body (JSON)
+5. Send and verify response
+
+## Debugging
+
+### Enable Error Reporting
+
+```php
+// In development config
+error_reporting(E_ALL);
+ini_set('display_errors', 1);
+ini_set('log_errors', 1);
+ini_set('error_log', '/var/log/php/errors.log');
+```
+
+### Debugging Techniques
+
+**1. var_dump() and print_r()**:
+```php
+// Output variable contents
+var_dump($user_data);
+print_r($verification_array);
+
+// Pretty print
+echo '' . print_r($data, true) . '
';
+```
+
+**2. Error Logging**:
+```php
+// Write to error log
+error_log("Debug: User ID = " . $user_id);
+error_log("Database query: " . $query);
+
+// Log arrays
+error_log("Post Data: " . print_r($_POST, true));
+```
+
+**3. MySQL Query Debugging**:
+```php
+$query = "SELECT * FROM users WHERE id = $user_id";
+$result = mysql_query($query);
+
+if(!$result) {
+ error_log("MySQL Error: " . mysql_error());
+ error_log("Query: " . $query);
+}
+```
+
+**4. AJAX Debugging**:
+```javascript
+// In JavaScript
+$.ajax({
+ url: 'actions.php',
+ data: {action: 'test'},
+ success: function(response) {
+ console.log('Response:', response);
+ },
+ error: function(xhr, status, error) {
+ console.error('Error:', error);
+ console.log('Response:', xhr.responseText);
+ }
+});
+```
+
+**5. Network Debugging**:
+- Use browser DevTools (F12)
+- Network tab to see AJAX requests
+- Console tab for JavaScript errors
+- Application tab for session/cookie inspection
+
+### Common Issues and Solutions
+
+**Issue**: White screen (no error message)
+**Solution**: Enable `display_errors` in php.ini or check error logs
+
+**Issue**: Database connection failed
+**Solution**: Verify credentials in global_config.php, check MySQL service
+
+**Issue**: File upload not working
+**Solution**: Check directory permissions, PHP upload settings
+
+**Issue**: Session not persisting
+**Solution**: Check session.save_path permissions, ensure session_start() called
+
+## Security Best Practices
+
+### Input Validation
+
+```php
+// Validate and sanitize user input
+function validateInput($data, $type) {
+ switch($type) {
+ case 'email':
+ return filter_var($data, FILTER_VALIDATE_EMAIL);
+ case 'int':
+ return filter_var($data, FILTER_VALIDATE_INT);
+ case 'string':
+ return htmlspecialchars(trim($data), ENT_QUOTES, 'UTF-8');
+ default:
+ return false;
+ }
+}
+
+// Usage
+$email = validateInput($_POST['email'], 'email');
+$user_id = validateInput($_POST['user_id'], 'int');
+$name = validateInput($_POST['name'], 'string');
+```
+
+### Output Escaping
+
+```php
+// Always escape output to prevent XSS
+echo htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');
+
+// In templates
+= htmlspecialchars($applicant_name) ?>
+```
+
+### File Upload Security
+
+```php
+function secureFileUpload($file) {
+ // Validate file type
+ $allowed_types = ['pdf', 'doc', 'docx', 'jpg', 'png'];
+ $file_ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
+
+ if(!in_array($file_ext, $allowed_types)) {
+ return ['error' => 'Invalid file type'];
+ }
+
+ // Validate file size (5MB)
+ if($file['size'] > 5242880) {
+ return ['error' => 'File too large'];
+ }
+
+ // Generate unique filename
+ $new_filename = uniqid('file_', true) . '.' . $file_ext;
+
+ // Move to secure directory
+ $upload_path = '/secure/uploads/' . $new_filename;
+ move_uploaded_file($file['tmp_name'], $upload_path);
+
+ return ['success' => true, 'filename' => $new_filename];
+}
+```
+
+### Password Security
+
+```php
+// NEVER store plain text passwords
+// Use password_hash() (PHP 5.5+)
+
+// Hash password
+$password_hash = password_hash($password, PASSWORD_BCRYPT);
+
+// Store $password_hash in database
+
+// Verify password
+if(password_verify($input_password, $stored_hash)) {
+ // Password correct
+} else {
+ // Password incorrect
+}
+```
+
+## Modernization Recommendations
+
+### Priority 1: Security Updates
+
+**1. Migrate from mysql_* to PDO**:
+```php
+// Old (deprecated)
+$result = mysql_query("SELECT * FROM users WHERE id = $id");
+
+// New (PDO)
+$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
+$stmt->execute([$id]);
+$result = $stmt->fetchAll();
+```
+
+**2. Implement Password Hashing**:
+```php
+// Replace MD5 with bcrypt
+$hash = password_hash($password, PASSWORD_BCRYPT);
+```
+
+**3. Add CSRF Protection**:
+```php
+// Generate token
+$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
+
+// Validate token
+if($_POST['csrf_token'] !== $_SESSION['csrf_token']) {
+ die('CSRF token validation failed');
+}
+```
+
+### Priority 2: Code Organization
+
+**1. Extract Functions into Classes**:
+```php
+// Instead of 374KB functions.php, create:
+class UserManager {
+ public function getUser($id) { }
+ public function createUser($data) { }
+}
+
+class VerificationManager {
+ public function createVerification($data) { }
+ public function updateStatus($id, $status) { }
+}
+```
+
+**2. Implement Autoloading**:
+```php
+// composer.json
+{
+ "autoload": {
+ "psr-4": {
+ "BackCheck\\": "src/"
+ }
+ }
+}
+```
+
+**3. Use Environment Variables**:
+```php
+// .env file
+DB_HOST=localhost
+DB_NAME=backglob_db
+DB_USER=user
+DB_PASS=password
+
+// Load with vlucas/phpdotenv
+$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
+$dotenv->load();
+
+$db_host = $_ENV['DB_HOST'];
+```
+
+### Priority 3: Framework Migration
+
+Consider migrating to a modern PHP framework:
+- **Laravel**: Full-featured MVC framework
+- **Symfony**: Enterprise-grade framework
+- **CodeIgniter 4**: Lightweight framework
+
+## Common Tasks
+
+### Adding a New Page
+
+1. Create template in `include_pages/`:
+```php
+// include_pages/new_feature_inc.php
+
+
+
New Feature
+
+
+```
+
+2. Add routing in `index.php`:
+```php
+if($_REQUEST['action'] == 'new_feature') {
+ include 'include_pages/new_feature_inc.php';
+}
+```
+
+### Adding an AJAX Endpoint
+
+1. Create handler in `include_pages/`:
+```php
+// include_pages/ajax_new_action_inc.php
+ 'success',
+ 'data' => $result
+]);
+?>
+```
+
+2. Add routing in `actions.php`:
+```php
+if($_REQUEST['action'] == 'new_action') {
+ include 'include_pages/ajax_new_action_inc.php';
+}
+```
+
+3. Call from JavaScript:
+```javascript
+$.ajax({
+ url: 'actions.php',
+ type: 'POST',
+ data: {action: 'new_action', param: 'value'},
+ success: function(response) {
+ console.log(response);
+ }
+});
+```
+
+### Adding a Database Table
+
+```sql
+CREATE TABLE IF NOT EXISTS new_table (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(255) NOT NULL,
+ description TEXT,
+ status TINYINT DEFAULT 1,
+ created_date DATETIME DEFAULT CURRENT_TIMESTAMP,
+ modified_date DATETIME ON UPDATE CURRENT_TIMESTAMP,
+ INDEX idx_status (status),
+ INDEX idx_created (created_date)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+```
+
+---
+
+## Resources
+
+### Documentation
+- [PHP Manual](https://www.php.net/manual/en/)
+- [MySQL Documentation](https://dev.mysql.com/doc/)
+- [jQuery Documentation](https://api.jquery.com/)
+
+### Tools
+- **PHPStorm**: IDE for PHP development
+- **VS Code**: Lightweight code editor
+- **Postman**: API testing
+- **MySQL Workbench**: Database management
+- **Git**: Version control
+
+### Learning Resources
+- [PHP The Right Way](https://phptherightway.com/)
+- [OWASP Security Guidelines](https://owasp.org/)
+- [PSR Standards](https://www.php-fig.org/psr/)
+
+---
+
+**Last Updated**: 2026
+**Version**: 3.4
+**Maintained by**: Background Check Development Team
diff --git a/INTEGRATIONS.md b/INTEGRATIONS.md
new file mode 100644
index 0000000..867918e
--- /dev/null
+++ b/INTEGRATIONS.md
@@ -0,0 +1,682 @@
+# Integration Guide - BackCheck.io Verify
+
+## Table of Contents
+- [Overview](#overview)
+- [Bitrix CRM Integration](#bitrix-crm-integration)
+- [Savvion BPM Integration](#savvion-bpm-integration)
+- [Google Sheets Integration](#google-sheets-integration)
+- [WHMCS Integration](#whmcs-integration)
+- [Third-Party APIs](#third-party-apis)
+- [Custom Integrations](#custom-integrations)
+- [Troubleshooting](#troubleshooting)
+
+## Overview
+
+BackCheck.io Verify integrates with multiple external systems to automate workflows, sync data, and enhance functionality. This guide covers the setup and usage of each integration.
+
+### Integration Architecture
+
+```
+┌─────────────────────────────────────┐
+│ BackCheck.io Verify Application │
+│ │
+│ ┌──────────────────────────────┐ │
+│ │ Integration Layer │ │
+│ │ /functions/bitrix/ │ │
+│ │ /functions/savvion/ │ │
+│ │ /api_google.php │ │
+│ └──────────────────────────────┘ │
+└─────────────────────────────────────┘
+ │ │ │
+ ▼ ▼ ▼
+┌─────────┐ ┌──────────┐ ┌─────────┐
+│ Bitrix │ │ Savvion │ │ Google │
+│ CRM │ │ BPM │ │ Sheets │
+└─────────┘ └──────────┘ └─────────┘
+```
+
+## Bitrix CRM Integration
+
+### Overview
+
+Bitrix24 is a CRM platform used for managing leads, tasks, and customer relationships. The integration automatically creates leads and tasks in Bitrix when verification requests are submitted.
+
+### Configuration
+
+#### 1. Bitrix API Setup
+
+**In Bitrix24**:
+1. Go to **Settings** → **Applications**
+2. Create a new **REST API** application
+3. Note the **Webhook URL** or **API credentials**
+4. Set permissions for Leads and Tasks
+
+**In BackCheck.io Verify**:
+
+Edit `/include/global_config.php`:
+```php
+define("BITRIX_URL", "https://my.backcheck.io/rest_api.php");
+```
+
+#### 2. Admin Mapping Configuration
+
+Edit `/functions/bitrix/bitrix_functions.php`:
+
+```php
+// Map countries to Bitrix admin IDs
+function getAdminByCountry($country) {
+ $admin_mapping = array(
+ 'Pakistan' => 529, // Sharjeel
+ 'India' => 529, // Sharjeel
+ 'UAE' => 591, // Other admin
+ 'Saudi Arabia' => 591,
+ 'default' => 480 // Sadia (default)
+ );
+
+ return isset($admin_mapping[$country])
+ ? $admin_mapping[$country]
+ : $admin_mapping['default'];
+}
+```
+
+### Key Functions
+
+#### insertleads2() - Create Lead
+
+Creates a new lead in Bitrix CRM with auto-assignment based on country.
+
+```php
+function insertleads2($data) {
+ $bitrix_url = BITRIX_URL;
+
+ $lead_data = array(
+ 'TITLE' => $data['title'],
+ 'NAME' => $data['name'],
+ 'EMAIL' => $data['email'],
+ 'PHONE' => $data['phone'],
+ 'ASSIGNED_BY_ID' => $data['admin_id'],
+ 'SOURCE_ID' => 'WEB',
+ 'COMMENTS' => $data['comments']
+ );
+
+ $response = sendBitrixRequest($bitrix_url, 'crm.lead.add', $lead_data);
+ return $response;
+}
+
+// Usage
+$result = insertleads2([
+ 'title' => 'Employment Verification - John Doe',
+ 'name' => 'John Doe',
+ 'email' => 'john@example.com',
+ 'phone' => '+92-300-1234567',
+ 'admin_id' => 529,
+ 'comments' => 'Verification request from client XYZ'
+]);
+```
+
+#### add_task() - Create Task
+
+Creates a task in Bitrix with TAT and reminders.
+
+```php
+function add_task($task_data) {
+ $bitrix_url = BITRIX_URL;
+
+ $tat_date = date('Y-m-d', strtotime('+10 days'));
+
+ $task = array(
+ 'TITLE' => $task_data['title'],
+ 'DESCRIPTION' => $task_data['description'],
+ 'RESPONSIBLE_ID' => $task_data['assigned_to'],
+ 'DEADLINE' => $tat_date,
+ 'GROUP_ID' => $task_data['group_id'],
+ 'PRIORITY' => 1 // 1=High, 2=Medium
+ );
+
+ // Add reminder 1 day before deadline
+ $reminder = array(
+ 'REMIND_DATE' => date('Y-m-d', strtotime($tat_date . ' -1 day'))
+ );
+
+ $response = sendBitrixRequest($bitrix_url, 'task.item.add', $task);
+ return $response;
+}
+```
+
+#### task_del() - Delete Task
+
+```php
+function task_del($task_id) {
+ $bitrix_url = BITRIX_URL;
+ $response = sendBitrixRequest($bitrix_url, 'task.item.delete', ['ID' => $task_id]);
+ return $response;
+}
+```
+
+#### getworkgroup() - Get Work Groups
+
+```php
+function getworkgroup() {
+ $bitrix_url = BITRIX_URL;
+ $response = sendBitrixRequest($bitrix_url, 'sonet_group.get', []);
+ return $response;
+}
+```
+
+### Workflow Integration
+
+```
+Verification Request Submitted
+ ↓
+Create Lead in Bitrix (insertleads2)
+ ↓
+Auto-assign based on country
+ ↓
+Create Task with TAT (add_task)
+ ↓
+Set reminder (1 day before deadline)
+ ↓
+Update task status as verification progresses
+```
+
+### Webhook Configuration
+
+To receive updates from Bitrix:
+
+```php
+// webhook_bitrix.php
+if($_POST['event'] == 'ONTASKUPDATE') {
+ $task_id = $_POST['data']['FIELDS_AFTER']['ID'];
+ $status = $_POST['data']['FIELDS_AFTER']['STATUS'];
+
+ // Update verification status in BackCheck
+ updateVerificationFromBitrix($task_id, $status);
+}
+```
+
+### Testing the Integration
+
+```php
+// Test Bitrix connection
+function testBitrixConnection() {
+ $bitrix_url = BITRIX_URL;
+
+ // Test with a simple API call
+ $response = sendBitrixRequest($bitrix_url, 'user.current', []);
+
+ if($response['error']) {
+ echo "Connection Failed: " . $response['error_description'];
+ } else {
+ echo "Connection Successful! User: " . $response['result']['NAME'];
+ }
+}
+```
+
+---
+
+## Savvion BPM Integration
+
+### Overview
+
+Savvion Business Process Management system handles structured workflows for complex verifications with multiple approval stages.
+
+### Configuration
+
+Edit `/functions/savvion/savvion_config.php` (or functions.php):
+
+```php
+// Savvion API Configuration
+define("SAVVION_URL", "https://savvion.example.com/api");
+define("SAVVION_USERNAME", "api_user");
+define("SAVVION_PASSWORD", "api_password");
+
+// Workflow Definitions
+$savvion_workflows = array(
+ 'employment' => 'EMP_VERIFICATION_WF',
+ 'education' => 'EDU_VERIFICATION_WF',
+ 'criminal' => 'CRIMINAL_CHECK_WF'
+);
+```
+
+### Key Functions
+
+#### addsavvioncheck() - Create Savvion Check
+
+```php
+function addsavvioncheck($check_data) {
+ $savvion_url = SAVVION_URL;
+
+ $workflow_data = array(
+ 'workflow_id' => $check_data['workflow_type'],
+ 'applicant_name' => $check_data['name'],
+ 'check_type' => $check_data['type'],
+ 'assigned_to' => $check_data['analyst_id'],
+ 'priority' => $check_data['priority'],
+ 'documents' => $check_data['documents']
+ );
+
+ $response = sendSavvionRequest($savvion_url, 'workflow/create', $workflow_data);
+ return $response['workflow_instance_id'];
+}
+```
+
+#### approvesavvioncheck() - Approve/Reject
+
+```php
+function approvesavvioncheck($workflow_id, $action, $comments) {
+ $savvion_url = SAVVION_URL;
+
+ $approval_data = array(
+ 'workflow_id' => $workflow_id,
+ 'action' => $action, // 'approve' or 'reject'
+ 'comments' => $comments,
+ 'approved_by' => $_SESSION['userid']
+ );
+
+ $response = sendSavvionRequest($savvion_url, 'workflow/approve', $approval_data);
+ return $response;
+}
+```
+
+#### assignSavvionChecks() - Assign to Analyst
+
+```php
+function assignSavvionChecks($workflow_ids, $analyst_id) {
+ foreach($workflow_ids as $workflow_id) {
+ $data = array(
+ 'workflow_id' => $workflow_id,
+ 'assigned_to' => $analyst_id,
+ 'assigned_by' => $_SESSION['userid'],
+ 'assigned_date' => date('Y-m-d H:i:s')
+ );
+
+ sendSavvionRequest(SAVVION_URL, 'workflow/assign', $data);
+ }
+}
+```
+
+#### delegateSavvionChecks() - Delegate/Reassign
+
+```php
+function delegateSavvionChecks($workflow_id, $from_analyst, $to_analyst) {
+ $data = array(
+ 'workflow_id' => $workflow_id,
+ 'from_user' => $from_analyst,
+ 'to_user' => $to_analyst,
+ 'delegated_by' => $_SESSION['userid'],
+ 'reason' => 'Workload rebalancing'
+ );
+
+ return sendSavvionRequest(SAVVION_URL, 'workflow/delegate', $data);
+}
+```
+
+### Savvion File Upload
+
+Supported file types:
+```php
+define("FILE_TYPES_ALLOWED_SAVVION",
+ "jpg,png,gif,bmp,jpeg,pdf,doc,docx,xls,csv,txt,pcx,svg,xlsx,xlm,msg,xps");
+```
+
+Upload files to Savvion workflow:
+
+```php
+function uploadToSavvion($workflow_id, $file) {
+ $savvion_url = SAVVION_URL;
+
+ $file_data = array(
+ 'workflow_id' => $workflow_id,
+ 'file_name' => $file['name'],
+ 'file_content' => base64_encode(file_get_contents($file['tmp_name'])),
+ 'file_type' => $file['type']
+ );
+
+ return sendSavvionRequest($savvion_url, 'workflow/upload', $file_data);
+}
+```
+
+### Workflow Status Tracking
+
+```php
+function getSavvionStatus($workflow_id) {
+ $savvion_url = SAVVION_URL;
+
+ $response = sendSavvionRequest($savvion_url, 'workflow/status', [
+ 'workflow_id' => $workflow_id
+ ]);
+
+ return [
+ 'status' => $response['status'],
+ 'current_stage' => $response['current_stage'],
+ 'assigned_to' => $response['assigned_to'],
+ 'completion' => $response['completion_percentage']
+ ];
+}
+```
+
+---
+
+## Google Sheets Integration
+
+### Overview
+
+Google Sheets API is used for automated data export, reporting, and analytics.
+
+### Setup
+
+#### 1. Create Google Cloud Project
+
+1. Go to [Google Cloud Console](https://console.cloud.google.com/)
+2. Create a new project: "BackCheck Verify"
+3. Enable **Google Sheets API**
+4. Create credentials (OAuth 2.0 Client ID)
+5. Download credentials JSON
+
+#### 2. Configure in Application
+
+Edit `/api_google.php`:
+
+```php
+// Google API Configuration
+$google_config = array(
+ 'client_id' => 'YOUR_CLIENT_ID.apps.googleusercontent.com',
+ 'client_secret' => 'YOUR_CLIENT_SECRET',
+ 'redirect_uri' => 'https://backcheck.io/verify/api_google.php',
+ 'api_key' => 'YOUR_API_KEY'
+);
+```
+
+#### 3. OAuth Authentication Flow
+
+```php
+// Redirect user to Google for authorization
+function getGoogleAuthUrl() {
+ $params = array(
+ 'client_id' => $GLOBALS['google_config']['client_id'],
+ 'redirect_uri' => $GLOBALS['google_config']['redirect_uri'],
+ 'response_type' => 'code',
+ 'scope' => 'https://www.googleapis.com/auth/spreadsheets',
+ 'access_type' => 'offline'
+ );
+
+ return 'https://accounts.google.com/o/oauth2/auth?' . http_build_query($params);
+}
+
+// Exchange code for access token
+function getGoogleAccessToken($code) {
+ $token_url = 'https://oauth2.googleapis.com/token';
+
+ $post_data = array(
+ 'code' => $code,
+ 'client_id' => $GLOBALS['google_config']['client_id'],
+ 'client_secret' => $GLOBALS['google_config']['client_secret'],
+ 'redirect_uri' => $GLOBALS['google_config']['redirect_uri'],
+ 'grant_type' => 'authorization_code'
+ );
+
+ $response = sendPostRequest($token_url, $post_data);
+ return json_decode($response, true);
+}
+```
+
+### Export Data to Google Sheets
+
+```php
+function exportToGoogleSheets($data, $spreadsheet_id, $access_token) {
+ $sheets_api = "https://sheets.googleapis.com/v4/spreadsheets/{$spreadsheet_id}/values:append";
+
+ $headers = array(
+ "Authorization: Bearer {$access_token}",
+ "Content-Type: application/json"
+ );
+
+ $body = array(
+ 'range' => 'Sheet1!A1',
+ 'majorDimension' => 'ROWS',
+ 'values' => $data
+ );
+
+ $ch = curl_init($sheets_api . '?valueInputOption=RAW');
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ return json_decode($response, true);
+}
+
+// Usage
+$verification_data = [
+ ['ID', 'Name', 'Type', 'Status', 'Date'],
+ [12345, 'John Doe', 'Employment', 'Completed', '2026-02-15'],
+ [12346, 'Jane Smith', 'Education', 'In Progress', '2026-02-16']
+];
+
+exportToGoogleSheets($verification_data, 'SPREADSHEET_ID', $access_token);
+```
+
+### Create New Spreadsheet
+
+```php
+function createGoogleSheet($title, $access_token) {
+ $sheets_api = "https://sheets.googleapis.com/v4/spreadsheets";
+
+ $headers = array(
+ "Authorization: Bearer {$access_token}",
+ "Content-Type: application/json"
+ );
+
+ $body = array(
+ 'properties' => array(
+ 'title' => $title
+ )
+ );
+
+ $ch = curl_init($sheets_api);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+ return json_decode($response, true);
+}
+```
+
+### Automated Reporting
+
+Schedule reports via cron:
+
+```bash
+# Daily export to Google Sheets
+0 2 * * * /usr/bin/php /var/www/html/verify/google-sheets.php
+```
+
+---
+
+## WHMCS Integration
+
+### Overview
+
+WHMCS is used for billing, customer management, and invoicing.
+
+### Configuration
+
+```php
+define("WHMCS_APIURL", "https://backcheckgroup.com/support/includes/api.php");
+define("WHMCS_IDENTIFIER", "YOUR_API_IDENTIFIER");
+define("WHMCS_SECRET", "YOUR_API_SECRET");
+```
+
+### API Functions
+
+#### Create Client
+
+```php
+function createWHMCSClient($client_data) {
+ $postfields = array(
+ 'identifier' => WHMCS_IDENTIFIER,
+ 'secret' => WHMCS_SECRET,
+ 'action' => 'AddClient',
+ 'firstname' => $client_data['firstname'],
+ 'lastname' => $client_data['lastname'],
+ 'email' => $client_data['email'],
+ 'address1' => $client_data['address'],
+ 'city' => $client_data['city'],
+ 'state' => $client_data['state'],
+ 'postcode' => $client_data['postcode'],
+ 'country' => $client_data['country'],
+ 'phonenumber' => $client_data['phone'],
+ 'password2' => $client_data['password']
+ );
+
+ $response = sendWHMCSRequest(WHMCS_APIURL, $postfields);
+ return $response['clientid'];
+}
+```
+
+#### Create Invoice
+
+```php
+function createWHMCSInvoice($client_id, $items) {
+ $postfields = array(
+ 'identifier' => WHMCS_IDENTIFIER,
+ 'secret' => WHMCS_SECRET,
+ 'action' => 'CreateInvoice',
+ 'userid' => $client_id,
+ 'date' => date('Y-m-d'),
+ 'duedate' => date('Y-m-d', strtotime('+30 days')),
+ 'itemdescription' => $items
+ );
+
+ $response = sendWHMCSRequest(WHMCS_APIURL, $postfields);
+ return $response['invoiceid'];
+}
+```
+
+---
+
+## Third-Party APIs
+
+### Piple API (Data Enrichment)
+
+Located in `piple_api.php` and `piple_api2.php`:
+
+```php
+function getPipleData($email_or_phone) {
+ $api_url = 'https://api.pipl.com/search/';
+ $api_key = 'YOUR_PIPL_API_KEY';
+
+ $params = array(
+ 'email' => $email_or_phone,
+ 'key' => $api_key
+ );
+
+ $response = file_get_contents($api_url . '?' . http_build_query($params));
+ return json_decode($response, true);
+}
+```
+
+---
+
+## Custom Integrations
+
+### Webhook Support
+
+Create a webhook endpoint for receiving external data:
+
+```php
+// webhook_endpoint.php
+$webhook_secret = 'your_secret_key';
+
+// Verify signature
+$received_signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'];
+$payload = file_get_contents('php://input');
+$calculated_signature = hash_hmac('sha256', $payload, $webhook_secret);
+
+if($received_signature !== $calculated_signature) {
+ http_response_code(401);
+ die('Invalid signature');
+}
+
+// Process webhook data
+$data = json_decode($payload, true);
+
+switch($data['event']) {
+ case 'verification.completed':
+ updateVerificationStatus($data['verification_id'], 'completed');
+ break;
+ case 'document.uploaded':
+ processDocument($data['document_id']);
+ break;
+}
+
+http_response_code(200);
+echo json_encode(['status' => 'success']);
+```
+
+---
+
+## Troubleshooting
+
+### Bitrix Integration Issues
+
+**Connection Failed**:
+- Verify BITRIX_URL is correct
+- Check API credentials
+- Ensure firewall allows outbound connections
+- Test with curl: `curl -X POST BITRIX_URL`
+
+**Lead Not Created**:
+- Check Bitrix permissions for API user
+- Verify all required fields are provided
+- Check Bitrix error logs
+
+### Google Sheets Issues
+
+**Authentication Failed**:
+- Verify OAuth credentials
+- Check redirect URI matches configuration
+- Ensure Google Sheets API is enabled
+- Refresh access token if expired
+
+**Export Failed**:
+- Check spreadsheet permissions
+- Verify access token is valid
+- Ensure data format is correct
+
+### General API Issues
+
+**Timeout Errors**:
+```php
+// Increase timeout
+ini_set('max_execution_time', 300);
+curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+```
+
+**SSL Certificate Errors**:
+```php
+// For development only (NOT recommended for production)
+curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+```
+
+**Debug API Calls**:
+```php
+function debugAPICall($url, $data, $response) {
+ error_log("API Call to: " . $url);
+ error_log("Request Data: " . print_r($data, true));
+ error_log("Response: " . print_r($response, true));
+}
+```
+
+---
+
+**Last Updated**: 2026
+**Version**: 3.4
+**Maintained by**: Background Check Development Team
diff --git a/USER_GUIDE.md b/USER_GUIDE.md
new file mode 100644
index 0000000..a480af9
--- /dev/null
+++ b/USER_GUIDE.md
@@ -0,0 +1,644 @@
+# User Guide - BackCheck.io Verify
+
+## Table of Contents
+- [Getting Started](#getting-started)
+- [User Roles and Permissions](#user-roles-and-permissions)
+- [Common Workflows](#common-workflows)
+- [Features by Role](#features-by-role)
+- [Frequently Asked Questions](#frequently-asked-questions)
+
+## Getting Started
+
+### Logging In
+
+1. Navigate to https://backcheck.io/verify
+2. Enter your username and password
+3. Click "Login"
+4. You will be redirected to your role-specific dashboard
+
+### Dashboard Overview
+
+After logging in, you'll see your personalized dashboard with:
+- **Quick Stats**: Summary of your active cases, pending tasks, and deadlines
+- **Recent Activity**: Latest verification requests and updates
+- **Action Items**: Tasks requiring your immediate attention
+- **Notifications**: System alerts and messages
+
+## User Roles and Permissions
+
+The system supports 14 different user levels, each with specific permissions and access rights.
+
+### 1. Super Admin (Level 1)
+
+**Responsibilities**:
+- Full system access and configuration
+- User management (create, edit, delete users)
+- System settings and configuration
+- Database maintenance
+- Integration management (Bitrix, Savvion, Google Sheets)
+
+**Key Features**:
+- Access to all modules and reports
+- User role assignment
+- System configuration
+- API token management
+- Audit log access
+
+**Common Tasks**:
+- Creating new user accounts
+- Configuring system settings
+- Managing integrations
+- Generating system-wide reports
+- Troubleshooting issues
+
+---
+
+### 2. Admin (Level 2)
+
+**Responsibilities**:
+- User and client management
+- Company/client account setup
+- Report generation and access
+- System monitoring
+
+**Key Features**:
+- User management (limited to non-admin users)
+- Client company management
+- Access to all verification reports
+- Dashboard analytics
+- Export functionality
+
+**Common Tasks**:
+- Adding new client companies
+- Creating client user accounts
+- Generating monthly reports
+- Monitoring verification progress
+- Client communication
+
+---
+
+### 3. Team Lead (Level 3)
+
+**Responsibilities**:
+- Team management and supervision
+- Work assignment and distribution
+- Quality review and approval
+- Performance monitoring
+
+**Key Features**:
+- Assign cases to analysts
+- Review completed verifications
+- Access team performance reports
+- Approve/reject reports
+- Re-assign cases
+
+**Common Tasks**:
+- Distributing new verification requests
+- Reviewing analyst work
+- Managing workload distribution
+- Conducting quality checks
+- Escalating complex cases
+
+---
+
+### 4. Senior Analyst (Level 4)
+
+**Responsibilities**:
+- Handle complex verification cases
+- Mentor junior analysts
+- Quality assurance
+- Special investigations
+
+**Key Features**:
+- Access to all case types
+- Priority case assignment
+- Mentor/training mode
+- Advanced search and filtering
+- Report approval capability
+
+**Common Tasks**:
+- Processing complex verifications
+- Assisting junior analysts
+- Handling escalated cases
+- Conducting detailed investigations
+- Generating comprehensive reports
+
+---
+
+### 5. Analyst (Level 5)
+
+**Responsibilities**:
+- Process standard verification requests
+- Document verification
+- Data collection and validation
+- Report preparation
+
+**Key Features**:
+- Case assignment view
+- Document upload and management
+- Status updates
+- Basic report generation
+- Communication tools
+
+**Common Tasks**:
+- Reviewing assigned verification requests
+- Contacting employers/institutions
+- Collecting supporting documents
+- Updating case status
+- Preparing verification reports
+
+---
+
+### 6. Quality Control (Level 6)
+
+**Responsibilities**:
+- Review and approve completed verifications
+- Ensure quality standards
+- Reject incomplete or inaccurate reports
+- Provide feedback to analysts
+
+**Key Features**:
+- QC queue view
+- Approve/reject interface
+- Feedback mechanism
+- Quality metrics dashboard
+- Report revision requests
+
+**Common Tasks**:
+- Reviewing completed reports
+- Checking data accuracy
+- Approving finalized reports
+- Requesting revisions
+- Maintaining quality standards
+
+---
+
+### 7. Client Admin (Level 7)
+
+**Responsibilities**:
+- Manage client company portal
+- Submit verification requests
+- Monitor team's verification status
+- Generate client reports
+
+**Key Features**:
+- Bulk upload capability
+- Client dashboard
+- User management (client users only)
+- Report access
+- Invoice/billing view
+
+**Common Tasks**:
+- Submitting new verification requests
+- Bulk uploading applicant data
+- Monitoring verification progress
+- Downloading reports
+- Managing client user accounts
+
+---
+
+### 8. Client User (Level 8)
+
+**Responsibilities**:
+- Submit individual verification requests
+- Track verification status
+- Download completed reports
+
+**Key Features**:
+- Submit verification form
+- Status tracking
+- Report download
+- Document upload
+- Limited dashboard view
+
+**Common Tasks**:
+- Creating new verification requests
+- Uploading applicant documents
+- Checking verification status
+- Downloading completed reports
+- Communicating with support
+
+---
+
+### 9. Finance (Level 9)
+
+**Responsibilities**:
+- Billing and invoicing
+- Payment tracking
+- Financial reporting
+- Credit management
+
+**Key Features**:
+- Billing dashboard
+- Invoice generation
+- Payment status tracking
+- Financial reports
+- Credit/debit notes
+
+**Common Tasks**:
+- Generating monthly invoices
+- Tracking payments
+- Managing client credits
+- Financial reconciliation
+- Generating financial reports
+
+---
+
+### 10-14. Specialized Roles
+
+Custom roles can be configured for specific organizational needs:
+- Regional managers
+- Compliance officers
+- Training coordinators
+- Support staff
+- Custom workflows
+
+## Common Workflows
+
+### Workflow 1: Submitting a Verification Request (Client User)
+
+1. **Login** to the client portal
+2. Navigate to **"New Verification"** or **"Submit Check"**
+3. Fill in the required information:
+ - Client Reference Number
+ - Applicant Name
+ - Contact Information (Email, Phone)
+ - Check Type (Employment, Education, etc.)
+ - Additional Details
+4. **Upload Documents** (if required):
+ - Resume/CV
+ - ID Card Copy
+ - Supporting certificates
+5. **Review** the information
+6. Click **"Submit"**
+7. **Receive Confirmation**: Note the verification ID for tracking
+
+**Tips**:
+- Keep your client reference numbers unique and consistent
+- Upload clear, legible document scans
+- Provide complete contact information for faster processing
+- Use bulk upload for multiple verifications
+
+---
+
+### Workflow 2: Processing a Verification (Analyst)
+
+1. **Login** to your analyst dashboard
+2. View **"Assigned Cases"** or **"My Queue"**
+3. **Select a Case** to work on
+4. **Review** applicant information and requirements
+5. **Collect Information**:
+ - Contact employer/institution
+ - Request verification documents
+ - Verify provided information
+6. **Update Status** as you progress:
+ - Initial Investigation
+ - Contact Attempted
+ - Information Received
+ - Verification in Progress
+7. **Upload Evidence**:
+ - Email correspondence
+ - Verification letters
+ - Supporting documents
+8. **Prepare Report**:
+ - Fill in verification form
+ - Add findings and observations
+ - Provide recommendation
+9. **Submit for QC Review**
+10. **Address QC Feedback** (if required)
+
+**Tips**:
+- Update case status regularly
+- Document all communication attempts
+- Upload all supporting evidence
+- Be thorough and accurate in your reports
+- Meet TAT (Turnaround Time) deadlines
+
+---
+
+### Workflow 3: Quality Control Review (QC)
+
+1. **Login** to QC dashboard
+2. View **"Pending QC"** queue
+3. **Select a Report** to review
+4. **Review All Sections**:
+ - Applicant information
+ - Verification details
+ - Supporting documents
+ - Analyst findings
+ - Conclusions
+5. **Check for**:
+ - Completeness
+ - Accuracy
+ - Supporting evidence
+ - Proper formatting
+ - Clear recommendations
+6. **Decision**:
+ - **Approve**: If report meets quality standards
+ - **Reject**: If revisions are needed
+7. **Provide Feedback** (if rejecting):
+ - Specify issues found
+ - Suggest improvements
+ - Set priority for revision
+8. **Approve Final Report**
+9. Report moves to **"Completed"** status
+
+**Tips**:
+- Use the QC checklist
+- Provide clear, constructive feedback
+- Check all uploaded documents
+- Verify data accuracy
+- Maintain consistency in standards
+
+---
+
+### Workflow 4: Bulk Upload (Client Admin)
+
+1. **Login** to client admin portal
+2. Navigate to **"Bulk Upload"**
+3. **Download Template**:
+ - Excel/CSV template with required fields
+4. **Fill Template**:
+ - Add all applicant details
+ - Ensure data format is correct
+ - Include all mandatory fields
+5. **Upload File**:
+ - Select filled template
+ - Click "Upload"
+6. **Review Validation**:
+ - Check for errors
+ - Fix any validation issues
+ - Re-upload if needed
+7. **Confirm Upload**:
+ - Review summary
+ - Confirm batch submission
+8. **Track Progress**:
+ - Monitor bulk upload status
+ - View individual case progress
+
+**Tips**:
+- Validate data before upload
+- Use the provided template exactly
+- Check for duplicate entries
+- Keep backup of your upload file
+- Large batches may take time to process
+
+---
+
+### Workflow 5: Report Generation and Download
+
+**For Clients**:
+1. **Login** to client portal
+2. Navigate to **"My Verifications"** or **"Reports"**
+3. **Search/Filter**:
+ - By date range
+ - By status
+ - By reference number
+4. **View Details** of completed verification
+5. **Download Report**:
+ - PDF format
+ - Certificate (if applicable)
+6. **Print** or **Save** for records
+
+**For Internal Users**:
+1. Access **"Reports"** module
+2. Select **Report Type**:
+ - Daily Analyst Report
+ - Case Status Report
+ - Monthly Summary
+ - Client-wise Report
+3. **Apply Filters**:
+ - Date range
+ - Client
+ - Status
+ - Analyst
+4. **Generate Report**
+5. **Export** (Excel, PDF, CSV)
+
+---
+
+## Features by Role
+
+### Document Upload
+
+**Who Can Upload**:
+- Client Users (applicant documents)
+- Analysts (verification evidence)
+- All internal users (supporting documents)
+
+**Allowed File Types**:
+- PDF, DOC, DOCX
+- JPG, PNG, GIF
+- Maximum size: 5 MB per file
+
+**Upload Process**:
+1. Click "Upload Document" or "Add File"
+2. Select file from your computer
+3. Choose document type (if prompted)
+4. Add description (optional)
+5. Click "Upload"
+6. Wait for confirmation
+
+---
+
+### Status Tracking
+
+**Verification Statuses**:
+1. **Submitted**: Verification request received
+2. **Assigned**: Assigned to an analyst
+3. **In Progress**: Analyst working on the case
+4. **Insufficient**: Additional information needed
+5. **QC Review**: Under quality control review
+6. **QC Rejected**: Sent back to analyst for revision
+7. **Completed**: Verification completed successfully
+8. **Closed**: Case finalized and archived
+9. **Cancelled**: Verification cancelled
+
+**Tracking Your Cases**:
+- Real-time status updates
+- Timeline view of progress
+- Email notifications on status change
+- Expected completion date (TAT)
+- Current stage indicator
+
+---
+
+### Communication Tools
+
+**Internal Communication**:
+- Case notes and comments
+- Analyst-to-analyst messaging
+- Team lead notifications
+- System alerts
+
+**External Communication**:
+- Email templates for verification requests
+- Client notifications
+- Insufficient information requests
+- Completion notifications
+
+---
+
+### Search and Filtering
+
+**Search Criteria**:
+- Verification ID
+- Client Reference Number
+- Applicant Name
+- Date Range
+- Status
+- Check Type
+- Assigned Analyst
+- Company/Client
+
+**Advanced Search**:
+- Multiple filter combination
+- Custom date ranges
+- Saved search criteria
+- Export search results
+
+---
+
+### Dashboard Analytics
+
+**Available Metrics**:
+- Total verifications (by status)
+- Pending cases
+- Overdue cases
+- Completion rate
+- Average TAT
+- Analyst performance
+- Client activity
+
+**Visualizations**:
+- Bar charts
+- Pie charts
+- Line graphs (trends)
+- Tables with sorting
+
+---
+
+## Frequently Asked Questions
+
+### General Questions
+
+**Q: How do I reset my password?**
+A: Contact your administrator or use the "Forgot Password" link on the login page.
+
+**Q: What is the turnaround time (TAT) for verifications?**
+A: Standard TAT is 10 business days, but can vary based on check type and complexity.
+
+**Q: Can I track multiple verifications at once?**
+A: Yes, use the dashboard or "My Verifications" page to view all your cases.
+
+**Q: What file formats are accepted for uploads?**
+A: PDF, DOC, DOCX, JPG, PNG, GIF (maximum 5 MB per file).
+
+---
+
+### Client Questions
+
+**Q: How do I submit a new verification request?**
+A: Login → Navigate to "New Verification" → Fill form → Upload documents → Submit.
+
+**Q: Can I upload multiple applicants at once?**
+A: Yes, Client Admins can use the bulk upload feature with the provided Excel template.
+
+**Q: How will I be notified when verification is complete?**
+A: You'll receive an email notification and can also check the dashboard for status updates.
+
+**Q: Can I cancel a verification request?**
+A: Contact support with the verification ID to cancel. Cancellation may not be possible if work has already started.
+
+**Q: How do I download completed reports?**
+A: Go to "My Verifications" → Select completed case → Click "Download Report".
+
+---
+
+### Analyst Questions
+
+**Q: How are cases assigned to me?**
+A: Cases are assigned by Team Leads or automatically based on workload and expertise.
+
+**Q: What should I do if I can't reach the employer/institution?**
+A: Document all contact attempts and escalate to your Team Lead after 3-4 attempts.
+
+**Q: How do I request additional information from the client?**
+A: Change status to "Insufficient" and use the "Request Info" button to send a notification.
+
+**Q: Can I reassign a case if I'm unable to complete it?**
+A: No, contact your Team Lead to reassign the case.
+
+**Q: What if I need more time to complete a verification?**
+A: Inform your Team Lead immediately to request a TAT extension.
+
+---
+
+### Technical Questions
+
+**Q: Why can't I upload a document?**
+A: Check file size (max 5 MB), file type (PDF, DOC, DOCX, JPG, PNG), and your internet connection.
+
+**Q: The page is not loading. What should I do?**
+A: Try refreshing the page, clearing your browser cache, or using a different browser.
+
+**Q: Can I use the system on mobile devices?**
+A: Yes, the system is accessible on mobile browsers, but desktop is recommended for full functionality.
+
+**Q: I'm getting an error message. What should I do?**
+A: Take a screenshot of the error and contact support at support@backcheckgroup.com.
+
+---
+
+## Tips for Effective Use
+
+### For Clients
+1. **Provide Complete Information**: More details = faster verification
+2. **Use Clear Document Scans**: Ensure documents are legible
+3. **Maintain Consistent References**: Use systematic reference numbering
+4. **Check Status Regularly**: Stay updated on progress
+5. **Respond Promptly**: Reply quickly to insufficient information requests
+
+### For Analysts
+1. **Organize Your Workflow**: Prioritize by TAT and complexity
+2. **Document Everything**: Keep detailed notes of all activities
+3. **Communicate Proactively**: Update Team Lead on challenges
+4. **Quality Over Speed**: Accuracy is more important than rushing
+5. **Use Templates**: Leverage email and report templates
+
+### For Team Leads
+1. **Balance Workload**: Distribute cases evenly among analysts
+2. **Monitor TAT**: Keep track of deadlines
+3. **Provide Feedback**: Regular feedback improves quality
+4. **Support Your Team**: Be available for questions and escalations
+5. **Review Trends**: Identify patterns and optimize processes
+
+---
+
+## Getting Help
+
+### Support Channels
+- **Email**: support@backcheckgroup.com
+- **Phone**: +92-21-32863920-31
+- **Live Chat**: Available during business hours
+- **Help Desk**: Submit ticket through the system
+
+### Support Hours
+- **Monday - Friday**: 9:00 AM - 6:00 PM (PKT)
+- **Saturday**: 9:00 AM - 2:00 PM (PKT)
+- **Sunday**: Closed
+- **Emergency Support**: Available for critical issues
+
+### What to Include in Support Requests
+1. Your username and company (if applicable)
+2. Verification ID (if applicable)
+3. Detailed description of the issue
+4. Screenshots (if relevant)
+5. Steps to reproduce the problem
+6. Browser and operating system information
+
+---
+
+**Last Updated**: 2026
+**Version**: 3.4
+**Maintained by**: Background Check Support Team
From a23a4065a427bbc59737e0477e840f90a7c0aa8e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 15 Feb 2026 02:05:24 +0000
Subject: [PATCH 4/4] Add documentation index and update README with
documentation links
Co-authored-by: backgroundcheck <18512725+backgroundcheck@users.noreply.github.com>
---
DOCS_INDEX.md | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 19 +++--
2 files changed, 230 insertions(+), 7 deletions(-)
create mode 100644 DOCS_INDEX.md
diff --git a/DOCS_INDEX.md b/DOCS_INDEX.md
new file mode 100644
index 0000000..348b357
--- /dev/null
+++ b/DOCS_INDEX.md
@@ -0,0 +1,218 @@
+# Documentation Index
+
+Welcome to the BackCheck.io Verify documentation. This index provides quick access to all available documentation.
+
+## 📚 Quick Links
+
+### Getting Started
+- **[README.md](README.md)** - Project overview, features, and quick start guide
+- **[INSTALLATION.md](INSTALLATION.md)** - Complete installation and setup instructions
+
+### User Documentation
+- **[USER_GUIDE.md](USER_GUIDE.md)** - User roles, features, workflows, and FAQs
+
+### Technical Documentation
+- **[ARCHITECTURE.md](ARCHITECTURE.md)** - System architecture, design patterns, and technical details
+- **[API_DOCUMENTATION.md](API_DOCUMENTATION.md)** - REST API endpoints, authentication, and examples
+- **[CONFIGURATION.md](CONFIGURATION.md)** - Configuration options and environment setup
+- **[INTEGRATIONS.md](INTEGRATIONS.md)** - Third-party integrations (Bitrix, Savvion, Google Sheets, WHMCS)
+- **[DEVELOPMENT.md](DEVELOPMENT.md)** - Development setup, coding standards, and best practices
+
+## 📖 Documentation by Audience
+
+### For End Users (Clients & Analysts)
+1. Start with [README.md](README.md) for an overview
+2. Read [USER_GUIDE.md](USER_GUIDE.md) for detailed usage instructions
+3. Check the FAQ section in the User Guide for common questions
+
+### For System Administrators
+1. [INSTALLATION.md](INSTALLATION.md) - Installing and configuring the system
+2. [CONFIGURATION.md](CONFIGURATION.md) - System configuration and tuning
+3. [INTEGRATIONS.md](INTEGRATIONS.md) - Setting up external integrations
+
+### For Developers
+1. [DEVELOPMENT.md](DEVELOPMENT.md) - Development environment and coding standards
+2. [ARCHITECTURE.md](ARCHITECTURE.md) - Understanding the system architecture
+3. [API_DOCUMENTATION.md](API_DOCUMENTATION.md) - Working with the API
+
+### For API Consumers
+1. [API_DOCUMENTATION.md](API_DOCUMENTATION.md) - Complete API reference
+2. [README.md](README.md#api-integration) - API integration overview
+
+## 📝 Documentation Overview
+
+### README.md
+**Size**: 8.5 KB | **Last Updated**: 2026-02-15
+
+Main project documentation covering:
+- Project overview and features
+- Technology stack
+- Quick start guide
+- User roles
+- API integration overview
+- Support information
+
+### INSTALLATION.md
+**Size**: 13 KB | **Last Updated**: 2026-02-15
+
+Complete installation guide including:
+- System requirements
+- Installation steps (database, web server, configuration)
+- Post-installation tasks
+- Security hardening
+- Backup configuration
+- Troubleshooting common issues
+
+### ARCHITECTURE.md
+**Size**: 23 KB | **Last Updated**: 2026-02-15
+
+Technical architecture documentation:
+- System overview and design patterns
+- Technology stack details
+- Component architecture
+- Database design
+- Security architecture
+- Integration architecture
+- Performance and scalability considerations
+
+### API_DOCUMENTATION.md
+**Size**: 17 KB | **Last Updated**: 2026-02-15
+
+Complete API reference:
+- Authentication (token-based)
+- 8 API endpoints with examples
+- Request/response formats
+- Error handling and codes
+- Rate limiting
+- Code examples (PHP, JavaScript, Python, cURL)
+
+### USER_GUIDE.md
+**Size**: 16 KB | **Last Updated**: 2026-02-15
+
+User documentation covering:
+- 14 user roles and permissions
+- 5 common workflows with step-by-step instructions
+- Features by role (document upload, status tracking, etc.)
+- Dashboard and analytics
+- FAQ section
+- Support information
+
+### CONFIGURATION.md
+**Size**: 15 KB | **Last Updated**: 2026-02-15
+
+Configuration guide including:
+- Configuration file structure
+- Database configuration
+- Application settings (URLs, business logic, etc.)
+- Email configuration (multiple providers)
+- File upload settings
+- Integration settings
+- Security settings
+- Performance tuning
+- Environment-specific configurations
+
+### INTEGRATIONS.md
+**Size**: 18 KB | **Last Updated**: 2026-02-15
+
+Integration documentation:
+- Bitrix CRM integration (lead/task management)
+- Savvion BPM integration (workflow management)
+- Google Sheets integration (reporting)
+- WHMCS integration (billing)
+- Third-party APIs
+- Custom integration development
+- Troubleshooting guides
+
+### DEVELOPMENT.md
+**Size**: 18 KB | **Last Updated**: 2026-02-15
+
+Developer documentation:
+- Development environment setup
+- Code structure and organization
+- Coding standards (PHP, JavaScript, SQL)
+- Development workflow (Git, commits)
+- Testing guidelines
+- Debugging techniques
+- Security best practices
+- Modernization recommendations
+- Common development tasks
+
+## 🔍 Finding What You Need
+
+### Common Topics
+
+**Installation & Setup**
+- New installation → [INSTALLATION.md](INSTALLATION.md)
+- Configuration → [CONFIGURATION.md](CONFIGURATION.md)
+- Environment setup → [DEVELOPMENT.md#development-environment-setup](DEVELOPMENT.md#development-environment-setup)
+
+**User Guides**
+- How to use the system → [USER_GUIDE.md](USER_GUIDE.md)
+- User roles → [USER_GUIDE.md#user-roles-and-permissions](USER_GUIDE.md#user-roles-and-permissions)
+- Workflows → [USER_GUIDE.md#common-workflows](USER_GUIDE.md#common-workflows)
+
+**Development**
+- Getting started → [DEVELOPMENT.md#development-environment-setup](DEVELOPMENT.md#development-environment-setup)
+- Coding standards → [DEVELOPMENT.md#coding-standards](DEVELOPMENT.md#coding-standards)
+- Adding features → [DEVELOPMENT.md#common-tasks](DEVELOPMENT.md#common-tasks)
+
+**API Integration**
+- API overview → [API_DOCUMENTATION.md](API_DOCUMENTATION.md)
+- Authentication → [API_DOCUMENTATION.md#authentication](API_DOCUMENTATION.md#authentication)
+- Endpoints → [API_DOCUMENTATION.md#api-endpoints](API_DOCUMENTATION.md#api-endpoints)
+- Examples → [API_DOCUMENTATION.md#code-examples](API_DOCUMENTATION.md#code-examples)
+
+**Integrations**
+- Bitrix CRM → [INTEGRATIONS.md#bitrix-crm-integration](INTEGRATIONS.md#bitrix-crm-integration)
+- Savvion BPM → [INTEGRATIONS.md#savvion-bpm-integration](INTEGRATIONS.md#savvion-bpm-integration)
+- Google Sheets → [INTEGRATIONS.md#google-sheets-integration](INTEGRATIONS.md#google-sheets-integration)
+
+**Troubleshooting**
+- Installation issues → [INSTALLATION.md#troubleshooting](INSTALLATION.md#troubleshooting)
+- Integration issues → [INTEGRATIONS.md#troubleshooting](INTEGRATIONS.md#troubleshooting)
+- Development issues → [DEVELOPMENT.md#debugging](DEVELOPMENT.md#debugging)
+
+## 📊 Documentation Statistics
+
+- **Total Documentation**: 8 files
+- **Total Size**: ~128 KB
+- **Total Lines**: ~4,850 lines
+- **Last Updated**: 2026-02-15
+- **Version**: 3.4
+
+## 🔄 Documentation Maintenance
+
+### How to Contribute
+
+1. Documentation is written in Markdown format
+2. Follow the existing structure and style
+3. Keep documentation up-to-date with code changes
+4. Test all examples and code snippets
+5. Submit changes via pull request
+
+### Documentation Standards
+
+- Use clear, concise language
+- Provide examples for complex topics
+- Include screenshots where helpful
+- Keep table of contents updated
+- Use proper markdown formatting
+- Maintain consistent structure across files
+
+## 📞 Getting Help
+
+If you can't find what you're looking for in the documentation:
+
+- **Email**: support@backcheckgroup.com
+- **Phone**: +92-21-32863920-31
+- **Website**: https://backcheckgroup.com
+
+## 📜 License
+
+This documentation is proprietary and confidential. All rights reserved by Background Check (Private) Limited.
+
+---
+
+**Documentation Version**: 1.0
+**Last Updated**: 2026-02-15
+**Maintained by**: Background Check Development Team
diff --git a/README.md b/README.md
index 12ad311..574fd89 100644
--- a/README.md
+++ b/README.md
@@ -122,13 +122,18 @@ For detailed installation instructions, see [INSTALLATION.md](INSTALLATION.md)
## 📚 Documentation
-- **[Installation Guide](INSTALLATION.md)** - Complete setup instructions
-- **[Architecture Documentation](ARCHITECTURE.md)** - Technical architecture details
-- **[API Documentation](API_DOCUMENTATION.md)** - API endpoints and usage
-- **[User Guide](USER_GUIDE.md)** - User roles, features, and workflows
-- **[Configuration Guide](CONFIGURATION.md)** - System configuration options
-- **[Integration Guide](INTEGRATIONS.md)** - Third-party integration setup
-- **[Development Guide](DEVELOPMENT.md)** - Development guidelines and best practices
+> **[📖 Complete Documentation Index](DOCS_INDEX.md)** - Quick access to all documentation
+
+### Core Documentation
+- **[Installation Guide](INSTALLATION.md)** - Complete setup instructions (13 KB)
+- **[Architecture Documentation](ARCHITECTURE.md)** - Technical architecture details (23 KB)
+- **[API Documentation](API_DOCUMENTATION.md)** - API endpoints and usage (17 KB)
+- **[User Guide](USER_GUIDE.md)** - User roles, features, and workflows (16 KB)
+- **[Configuration Guide](CONFIGURATION.md)** - System configuration options (15 KB)
+- **[Integration Guide](INTEGRATIONS.md)** - Third-party integration setup (18 KB)
+- **[Development Guide](DEVELOPMENT.md)** - Development guidelines and best practices (18 KB)
+
+**Total**: 8 comprehensive guides | ~128 KB of documentation | Last Updated: 2026-02-15
## 👥 User Roles