-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloans-return.php
80 lines (68 loc) · 2.01 KB
/
loans-return.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
session_start();
if((!isset($_SESSION["login"]))||($_SESSION["auth"]=="0")){
?>
<meta http-equiv="refresh" content="0;URL=login.php">
<?php
} else
{
?>
<?php include("header.php") ?>
<section id="content">
<?php
$productId=$_GET['productId'];
$type=$_GET['type'];
$loanId=$_GET['loanId'];
$situation=$connection->query("UPDATE loans set returnAccepterId='".$_SESSION['personnelId']."',returnDate='".date("Y-m-d")."' where loanId='$loanId'") or die ($lang["Something_bad_happened"]);
if($type==1){
$pullBook=$connection->query("select * from books where bookId='$productId' ")->fetchAll(PDO::FETCH_ASSOC);
foreach ($pullBook as $pulledBook)
{
if($pulledBook['status']=='1')
{
$situation3=$connection->query("UPDATE books set status='0' where bookId='$productId'") or die ($lang["Something_bad_happened"]);
}
else
{
echo" <meta http-equiv=\"refresh\" content=\"0;url=loans.php?returned=true\"> ";
}
}
}
if($type==2){
$pullComputer=$connection->query("select * from computers where computerId='$productId'")->fetchAll(PDO::FETCH_ASSOC);
foreach ($pullComputer as $pulledComputer)
{
if($pulledComputer['status']=='1')
{
$situation1=$connection->query("UPDATE computers set status='0' where computerId='$productId'") or die ($lang["Something_bad_happened"]);
}
else
{
echo" <meta http-equiv=\"refresh\" content=\"0;url=loans.php?returned=true\"> ";
}
}
}
if($type==3){
$pullKey=$connection->query("select * from roomkeys where keyId='$productId'")->fetchAll(PDO::FETCH_ASSOC);
foreach ($pullKey as $pulledKey)
{
if($pulledKey['status']=='1')
{
$situation2=$connection->query("UPDATE roomkeys set status='0' where keyId='$productId'") or die ($lang["Something_bad_happened"]);
}
else
{
echo" <meta http-equiv=\"refresh\" content=\"0;url=loans.php?returned=true\"> ";
}
}
}
if($situation){
$status="<h2>".$lang["Process_Successful"]."</h2>";
}else{
$status="<h2>".$lang["Process_Failed"]."</h2>";
}
echo"$status";
?>
</section>
<?php include("footer.php"); ?>
<?php } ?>