requireLogin(); $page_title = 'Finance Management'; $error_message = ''; // Test database connection and table existence try { // Test if tables exist $tables_check = []; $stmt = $pdo->query("SHOW TABLES LIKE 'investments'"); $tables_check['investments'] = $stmt->rowCount() > 0; $stmt = $pdo->query("SHOW TABLES LIKE 'withdrawals'"); $tables_check['withdrawals'] = $stmt->rowCount() > 0; $stmt = $pdo->query("SHOW TABLES LIKE 'emi_schedule'"); $tables_check['emi_schedule'] = $stmt->rowCount() > 0; $stmt = $pdo->query("SHOW TABLES LIKE 'loan_payments'"); $tables_check['loan_payments'] = $stmt->rowCount() > 0; } catch (Exception $e) { $error_message = 'Database connection error: ' . $e->getMessage(); $tables_check = []; } include 'includes/header.php'; ?>

System Status

'Store investment records', 'withdrawals' => 'Store withdrawal records', 'emi_schedule' => 'Store EMI payment schedules', 'loan_payments' => 'Store loan payment history' ]; $all_tables_exist = true; foreach ($required_tables as $table => $description): $exists = $tables_check[$table] ?? false; if (!$exists) $all_tables_exist = false; ?>
Database Table Status Action Required

✅ EXISTS ❌ MISSING Create table using SQL script Ready to use

⚠️ Setup Required

Database Tables Missing

The finance system requires additional database tables to function properly. Please follow these steps to set up the database:

Step 1: Access your database

Log into phpMyAdmin or your database management tool

Step 2: Run the SQL script

Execute the following SQL commands:

Step 3: Refresh this page

After running the SQL script, refresh this page to continue with the finance setup.

✅ System Ready

Finance System Initialized

All required database tables are present. The finance system is ready to use!

🚀 Launch Finance System

What's Next?

1. Database Setup

Create the required database tables using the SQL script above.

2. Add Investments

Record your business investments and capital contributions.

3. Track Loans

Manage EMI loans and interest-based loans with payment tracking.

4. Balance Reports

Generate comprehensive financial statements and profit/loss reports.

Debug Information

PHP Version
Database Connection
Current User getUserName()); ?> (getUserRole()); ?>)
Server Time