-
Notifications
You must be signed in to change notification settings - Fork 1
/
refund.php
52 lines (42 loc) · 1.64 KB
/
refund.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
<?php
require_once('DBconnect.php');
session_start();
$phn = $_SESSION['phone'];
$tid = $_POST['rf'];
$sqlt = "SELECT * FROM ticket WHERE Ticket_ID = $tid";
$resultt = mysqli_query($conn, $sqlt);
$tici = mysqli_fetch_array($resultt);
$origin = date_create($tici["From_date"]);
$target = date_create(date('Y-m-d'));
$interval = date_diff($origin, $target);
$gap = $interval->format('%a');
if ($gap>=1){
$sqlrt = "SELECT * FROM reserved_ticket WHERE Ticket_ID = $tid";
$resultrt = mysqli_query($conn, $sqlrt);
$rowt = mysqli_fetch_array($resultrt);
$fare = $rowt[3];
$w = $rowt[5];
$count = $rowt['count'];
$cls = $tici['Class_ID'];
$fromd = $tici['From_date'];
$fs = $tici['From_station'];
$ts = $tici['To_station'];
$sq1 = "SELECT * FROM train WHERE start_station_code IN ('$fs','$ts') AND
end_station_code IN ('$fs','$ts')";
$result1 = mysqli_query($conn, $sq1);
$rowtr = mysqli_fetch_array($result1);
$trainc = $rowtr['Train_Code'];
$sqlrf = "UPDATE wallet SET wallet.balance = (wallet.balance+$fare) WHERE wallet.wallet_id = $w";
$sqlsc = "UPDATE seat_availability SET seat_count= (seat_count + $count) WHERE Class_ID = '$cls' AND Train_Code = '$trainc' AND date = '$fromd' ";
$sqltc = "DELETE FROM ticket WHERE Ticket_ID = $tid";
$sqlrc = "DELETE FROM reserved_ticket WHERE Ticket_ID = $tid";
$result = mysqli_query($conn, $sqlrf);
$result = mysqli_query($conn, $sqlsc);
$result = mysqli_query($conn, $sqltc);
$result = mysqli_query($conn, $sqlrc);
header('Location: refdone.php');
} else {
$_SESSION['referror']=true;
header('Location: refdone.php');;
}
?>