-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpayment-process.php
More file actions
36 lines (28 loc) · 984 Bytes
/
Copy pathpayment-process.php
File metadata and controls
36 lines (28 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require('./dashboardredirect.php');
require('./Classes/TransactionMonthHandler.php');
$dsn = 'mysql:host=localhost;dbname=guideme';
$username = 'root';
$password = '';
try {
$dbh = new PDO($dsn, $username, $password);
} catch (PDOException $e) {
die('Connection failed: ' . $e->getMessage());
}
$transactionHandler = new TransactionMonthHandler($dbh);
$paymentData = []; // Initialize the variable to avoid undefined variable error
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['selectedMonth'])) {
$selectedMonth = $_POST['selectedMonth'];
$paymentData = $transactionHandler->getTransactionDataForMonth($selectedMonth);
} else {
// Fetch all records when no month is selected
$paymentData = $transactionHandler->getAllTransactionData();
}
function calculateTotalPayments($paymentData) {
$totalPayments = 0;
foreach ($paymentData as $result) {
$totalPayments += $result['price'];
}
return $totalPayments;
}
?>