File "save_payment_details.php"
Full Path: /home/leadltht/fastlinkinternet.com/administrator/data-provider/admin/save_payment_details.php
File size: 2.55 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start();
// Enable error reporting for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Database connection
$conn = new mysqli("server329", "leadltht_prazey1982", "prazey1982123456", "leadltht_fastlinkinternet");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'];
$payment_date = $_POST['payment_date'];
$receipt_number = $_POST['receipt_number'];
$payment_method = $_POST['payment_method'];
$client_name = $_POST['client_name'];
$amount_paid = $_POST['amount_paid'];
$note = $_POST['note'];
$name_of_payment = $_POST['name_of_payment'];
$collected_by = $_SESSION['userdata']['firstname'] . ' ' . $_SESSION['userdata']['lastname'];
// Generate a unique code
$code = 'COL-' . uniqid();
// Update the pop table
$stmt = $conn->prepare("UPDATE pop SET PaymentDate = ?, ReceiptNumber = ?, PaymentMethod = ?, ClientName = ?, AmountPaid = ?, note = ?, name_of_payment = ?, collected_by = ?, Status = 'Approved' WHERE id = ?");
$stmt->bind_param('ssssisssi', $payment_date, $receipt_number, $payment_method, $client_name, $amount_paid, $note, $name_of_payment, $collected_by, $id);
if ($stmt->execute()) {
// Also insert/update the collection_list table
$collection_stmt = $conn->prepare("
INSERT INTO collection_list (date_collected, name_of_payment, total_amount, collection_method, member_id, receipt, collected_by, code)
VALUES (?, ?, ?, ?, (SELECT id FROM member_list WHERE CONCAT(firstname, ' ', lastname) = ?), ?, ?, ?)
ON DUPLICATE KEY UPDATE total_amount = VALUES(total_amount), collection_method = VALUES(collection_method), collected_by = VALUES(collected_by), code = VALUES(code), note = VALUES(note)
");
$collection_stmt->bind_param('ssisssss', $payment_date, $name_of_payment, $amount_paid, $payment_method, $client_name, $receipt_number, $collected_by, $code);
if ($collection_stmt->execute()) {
echo "<script>alert('Payment details saved successfully.'); window.location.href = 'https://fastlinkinternet.com/administrator/data-provider/admin/?page=payment_proof';</script>";
} else {
echo "Error updating collection list: " . $conn->error;
}
$collection_stmt->close();
} else {
echo "Error updating payment details: " . $conn->error;
}
$stmt->close();
}
$conn->close();
?>