forked from k493r0/EqManage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
return-process.php
53 lines (32 loc) · 1.44 KB
/
return-process.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
<?php
session_start();
include('serverconnect.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$loginuser = $_SESSION['id'];
$equipmentID = $_POST['equipment'];
$equser = $_POST['userid'];
$date = date('Y-m-d H:i:s');
$checkoutRequestsID = $_POST['checkoutRequestsID'];
echo $equipmentID;
echo "loginuser", $loginuser;
echo "Eq", $equser;
echo $checkoutRequestsID;
if ($loginuser == $equser) {
$checkQtyQuery = "Select * from EqManage.equipment where id = '$equipmentID'";
$checkQtyResult = mysqli_query($db, $checkQtyQuery);
$checkQtyArray = mysqli_fetch_assoc($checkQtyResult);
$leftQty = $checkQtyArray['leftQuantity'];
echo $leftQty;
$checkoutQtyQuery = "select * from EqManage.requests where id='$checkoutRequestsID'";
$checkoutQtyResult = mysqli_query($db, $checkoutQtyQuery);
$checkoutQtyArray = mysqli_fetch_assoc($checkoutQtyResult);
$checkoutQty = $checkoutQtyArray['checkoutQty'];
$newQty = $leftQty + 1;
$statusupdate = "UPDATE EqManage.equipment SET leftQuantity='$checkoutQty' where id='$equipmentID'";
$loginsert = "update EqManage.log set returnDate = '$date' where checkoutRequests_id='$checkoutRequestsID'";
mysqli_query($db, $statusupdate);
mysqli_query($db, $loginsert);
header('Location: index.php?return=1');
} else header('Location: index.php?return=0');
}
?>