query($sql_client_payments); $total_received = $result_client_payments->fetch_assoc()['total_received'] ?? 0; // Fetch total expenses from the database $sql_expenses = "SELECT SUM(amount) AS total_expenses FROM expenses"; $result_expenses = $con->query($sql_expenses); $total_expenses = $result_expenses->fetch_assoc()['total_expenses'] ?? 0; // Calculate net balance (Profit or Loss) $net_balance = $total_received - $total_expenses; // Fetch all client payment records with pagination $sql_all_client_payments = "SELECT * FROM clientspayment ORDER BY payment_date DESC LIMIT $start_from, $records_per_page"; $result_all_client_payments = $con->query($sql_all_client_payments); // Fetch all expense records with pagination $sql_all_expenses = "SELECT * FROM expenses ORDER BY date DESC LIMIT $start_from, $records_per_page"; $result_all_expenses = $con->query($sql_all_expenses); // Get total number of records for client payments and expenses $total_records_client_payments = $con->query("SELECT COUNT(*) FROM clientspayment")->fetch_row()[0]; $total_records_expenses = $con->query("SELECT COUNT(*) FROM expenses")->fetch_row()[0]; // Calculate total pages for pagination $total_pages_client_payments = ceil($total_records_client_payments / $records_per_page); $total_pages_expenses = ceil($total_records_expenses / $records_per_page); ?>
₹= number_format($total_received, 2) ?>
₹= number_format($total_expenses, 2) ?>
₹= number_format($net_balance, 2) ?> = $net_balance >= 0 ? ' Profit' : ' Loss' ?>
| Applicant ID | Total Payment | Paid Amount | Pending Amount | Payment Date | Installment No. | Installment Due Date | Due Date | Payment Message | Payment Time |
|---|---|---|---|---|---|---|---|---|---|
| = htmlspecialchars($row['applicant_id']) ?> | ₹= number_format($row['total_payment'], 2) ?> | ₹= number_format($row['paid_amount'], 2) ?> | ₹= number_format($row['pending_amount'], 2) ?> | = htmlspecialchars($row['payment_date']) ?> | = htmlspecialchars($row['installment_number']) ?> | = htmlspecialchars($row['installment_due_date']) ?> | = htmlspecialchars($row['due_date']) ?> | = htmlspecialchars($row['payment_message']) ?> | = htmlspecialchars($row['payment_time']) ?> |
| Category | Amount | Date | Description |
|---|---|---|---|
| = htmlspecialchars($row['expense_category']) ?> | ₹= number_format($row['amount'], 2) ?> | = htmlspecialchars($row['date']) ?> | = htmlspecialchars($row['description']) ?> |