-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetch_challan_no_for_kits_issue.php
38 lines (34 loc) · 1.48 KB
/
fetch_challan_no_for_kits_issue.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
<?php
include './include/check_login.php';
include './include/connection.php';
include_once 'include/admin-main.php';
// Check if the necessary parameter (stitcher) is set
if (isset($_GET['stitcher'])) {
$selectedStitcher = mysqli_real_escape_string($con, $_GET['stitcher']);
// Check if the date range is provided
if (isset($_GET['from_date'], $_GET['to_date'])) {
$fromDate = mysqli_real_escape_string($con, $_GET['from_date']);
$toDate = mysqli_real_escape_string($con, $_GET['to_date']);
// Fetch the distinct challan numbers based on the selected stitcher and date range
$query = "SELECT DISTINCT challan_no FROM print_received WHERE stitcher_name = '$selectedStitcher' AND date_and_time BETWEEN '$fromDate' AND '$toDate'";
} else {
// Fetch the distinct challan numbers based on the selected stitcher without considering date range
$query = "SELECT DISTINCT challan_no FROM print_received WHERE stitcher_name = '$selectedStitcher'";
}
$result = mysqli_query($con, $query);
if ($result) {
$challanNumbers = array();
while ($row = mysqli_fetch_assoc($result)) {
$challanNumbers[] = $row['challan_no'];
}
// Output the array of challan numbers as JSON
echo json_encode($challanNumbers);
} else {
// Handle database query error
echo "Error: " . mysqli_error($con);
}
} else {
// Handle missing parameter
echo "Missing parameter: stitcher";
}
?>