Repository navigation
Expand file tree
/
Copy pathrequisition_details.php
More file actions
145 lines (121 loc) · 4.44 KB
/
Copy pathrequisition_details.php
File metadata and controls
145 lines (121 loc) · 4.44 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
session_start();
include("connection.php");
// Retrieve the requisition number from the query parameter
$requisitionNumber = $_GET['requisition_number'];
// Retrieve the requisition details from the database based on the requisition number
$sql = "SELECT * FROM requisitions WHERE requisition_number = '$requisitionNumber'";
$result = $conn2->query($sql);
if ($result->num_rows > 0) {
// Fetch the requisition details
$requisition = $result->fetch_assoc();
// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Check if the "Approve" button is clicked
if (isset($_POST['approve-btn'])) {
// Update the approval status to "Approved" in the database
$approvalStatus = "Approved";
$sql = "UPDATE requisitions SET approval_status = '$approvalStatus' WHERE requisition_number = '$requisitionNumber'";
$conn2->query($sql);
}
// Check if the "Deny" button is clicked
elseif (isset($_POST['deny-btn'])) {
// Update the approval status to "Denied" in the database
$approvalStatus = "Denied";
$sql = "UPDATE requisitions SET approval_status = '$approvalStatus' WHERE requisition_number = '$requisitionNumber'";
$conn2->query($sql);
}
// Redirect back to the requisition_details.php page to reflect the updated status
header("Location: requisition_details.php?requisition_number=$requisitionNumber");
exit();
}
} else {
echo "No Requisition Details found.";
}
// ... Your existing code for approving the requisition ...
// After approving the requisition, update the budgets table
$updateBudgetSql = "UPDATE budgets SET spending_to_date = spending_to_date + ?, remaining_balance = remaining_balance - ? WHERE department = ?";
$updateBudgetStmt = $conn2->prepare($updateBudgetSql);
$updateBudgetStmt->bind_param("dds", $amount, $amount, $department);
// Set the department and amount based on the approved requisition details
$department = $requisition['department'];
//$amount = $requisition['amount'];
$updateBudgetStmt->execute();
$updateBudgetStmt->close();
// Close the database connection
$conn2->close();
?>
<!-- HTML and CSS for displaying the requisition details and the buttons -->
<!DOCTYPE html>
<html>
<head>
<title>Requisition Details</title>
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 15;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 24px;
margin-bottom: 20px;
}
p {
font-size: 16px;
margin-bottom: 10px;
}
strong {
font-weight: bold;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin-right: 10px;
}
button.approve {
background-color: #27ae60;
color: #fff;
}
button.deny {
background-color: #e74c3c;
color: #fff;
}
button.approve:hover, button.deny:hover {
opacity: 0.8;
}
</style>
</head>
<body>
<h1>Requisition Details</h1>
<?php if (isset($requisition)): ?>
<p><strong>Requisition Number:</strong> <?php echo $requisition['requisition_number']; ?></p>
<p><strong>Requester Name:</strong> <?php echo $requisition['requester_name']; ?></p>
<p><strong>Product Details:</strong> <?php echo $requisition['product_details']; ?></p>
<p><strong>Quantity:</strong> <?php echo $requisition['quantity']; ?></p>
<p><strong>Price:</strong> <?php echo $requisition['price']; ?></p>
<p><strong>Delivery Date:</strong> <?php echo $requisition['delivery_date']; ?></p>
<p><strong>Department:</strong> <?php echo $requisition['department']; ?></p>
<p><strong>Additional Info:</strong> <?php echo $requisition['additional_info']; ?></p>
<p><strong>Approval Status:</strong> <?php echo $requisition['approval_status']; ?></p>
<!-- Add buttons for Approve and Deny -->
<!--<form method="post">
<input type="hidden" name="requisition_number" value="<?php echo $requisition['requisition_number']; ?>">
<button type="submit" name="approve-btn">Approve</button>
<button type="submit" name="deny-btn">Deny</button>
</form>*-->
<?php endif; ?>
</body>
</html>