/var/www/enzatesting.onesolution.hk/finances_delete_fullPayment.php


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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php 


// Make sure you have a PDO connection here.
require_once "inc/configure.php";
    

// Retrieve the paymentId from the POST request.


$ivc_nbr $_GET["ivc_nb"];
$fullPaymentId $_GET["fullPaymentId"];
$refidPass $_GET["refidPass"];
$fullPaymentReference $_GET['fullPaymentRef'];


if (
in_array($_SESSION['user'], array('jmcenza''Linda''Christine Mung''ITDept'))) {

// Vérifier si la référence du dépôt existe dans la table ivc_cus_payment
    
$sql_check_fullPayment_reference "SELECT COUNT(reference) FROM ivc_cus_payment WHERE reference = :fullPayment_reference";
    
$sth_check_fullPayment_reference $dbh->prepare($sql_check_fullPayment_reference);
    
$sth_check_fullPayment_reference->bindParam(':fullPayment_reference'$fullPaymentReferencePDO::PARAM_STR);
    
$sth_check_fullPayment_reference->execute();
    
$fullPaymentReferenceCount $sth_check_fullPayment_reference->fetchColumn();

    if (
$fullPaymentReferenceCount 0) {
        
// La référence du dépôt correspond à une référence dans la table ivc_cus_payment, ne pas permettre la suppression.
        
echo '<script>window.location.href = "finances_individual_cus1.php?refid=' $refidPass '&existing_ref=true";</script>';
        exit;
    } else {

        
// Delete the payment from the database.
        
try {


            
$sql "DELETE FROM cus_payments WHERE refid = :fullPaymentId";
            
$stmt $dbh->prepare($sql);
            
$stmt->bindParam(':fullPaymentId'$fullPaymentIdPDO::PARAM_INT);


            if (
$stmt->execute()) {


                echo 
"The payment was removed successfully.";
                echo 
'<script>setTimeout(function(){ window.location.href = "finances_individual_cus1.php?refid=' $refidPass '"; });</script>';


            } else {
                
$errorInfo $stmt->errorInfo();
                echo 
"Error deleting payment. Error code : " $errorInfo[1] . "<br>";
                echo 
"Error message : " $errorInfo[2];
            }


        } catch (
PDOException $e) {
            echo 
"Error : " $e->getMessage();
        }

    }


}else{
    echo 
'<script>setTimeout(function(){ window.location.href = "finances_individual_cus1.php?refid=' $refidPass '"; });</script>';
}

?>