-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkits_issue_data_print.php
146 lines (133 loc) · 4.91 KB
/
kits_issue_data_print.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
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
145
146
<?php
include './include/check_login.php';
include './include/connection.php';
include_once 'include/admin-main.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Football Query Print</title>
<link rel="icon" type="image/x-icon" href="assets/images/favicon.png">
<link href="assets/labels.css" rel="stylesheet" type="text/css">
<style>
page {
background: white;
display: block;
margin: 1.0cm;
}
@media print {
body, page {
margin: 0!important;
box-shadow: 0;
padding:0;
}
}
@page {
margin: 0;
box-shadow: 0;
}
.detail-table {
width: 100%;
border-collapse: collapse;
}
.detail-table th,
.detail-table td {
padding: 10px;
border: 1px solid #000; /* Set border to solid */
}
.main-heading {
font-weight: bold;
text-align: right;
width: 200px;
}
.separator {
border-top: 2px double #000;
margin-top: 10px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<center>
<page size="A4">
<?php
// Initialize serial number
$sn = 1;
// Initialize SQL query
$q = "SELECT `challan_no`, `stitcher_name`, `product_name`, `product_base`, `product_color`, `issue_quantity`, `date_and_time`, `bladder_name`, `bladder_quantity`, `thread_name`, `thread_quantity` FROM kits_issue";
// Check if the submit button is clicked and from_date and to_date are specified
if(isset($_POST['submit']) && !empty($_POST['from_date']) && !empty($_POST['to_date'])) {
$from_date = $_POST['from_date'];
$to_date = $_POST['to_date'];
$fdate = date('Y-m-d', strtotime($_POST['from_date']));
$tdate = date('Y-m-d', strtotime($_POST['to_date']));
// Add condition for date range
$q .= " WHERE date_and_time BETWEEN '$fdate' AND '$tdate'";
}
$q .= " ORDER BY date_and_time ASC";
$show = mysqli_query($con, $q);
// Check if there are rows returned
if(mysqli_num_rows($show) > 0) {
echo "<table class='detail-table'> <!-- Add class for the table -->
<tr>
<th>Serial No.</th>
<th>Challan No.</th>
<th>Stitcher Name</th>
<th>Product Name</th>
<th>Product Base</th>
<th>Product Color</th>
<th>Issue Quantity</th>
<th>Bladder Name</th>
<th>Bladder Quantity</th>
<th>Thread Name</th>
<th>Thread Quantity</th>
<th>Date And Time</th>
</tr>";
// Fetch and display data
while($data = mysqli_fetch_array($show)) {
echo "<tr>
<td>".$sn."</td>
<td>".$data['challan_no']."</td>
<td>".$data['stitcher_name']."</td>
<td>".$data['product_name']."</td>
<td>".$data['product_base']."</td>
<td>".$data['product_color']."</td>
<td>".$data['issue_quantity']."</td>
<td>".$data['bladder_name']."</td>
<td>".$data['bladder_quantity']."</td>
<td>".$data['thread_name']."</td>
<td>".$data['thread_quantity']."</td>
<td>".$data['date_and_time']."</td>
</tr>";
$sn++; // Increment serial number
}
echo "</table>";
} else {
// If no data found, display only the table headers
echo "<table class='detail-table'> <!-- Add class for the table -->
<tr>
<th>Serial No.</th>
<th>Challan No.</th>
<th>Stitcher Name</th>
<th>Product Name</th>
<th>Product Base</th>
<th>Product Color</th>
<th>Issue Quantity</th>
<th>Bladder Name</th>
<th>Bladder Quantity</th>
<th>Thread Name</th>
<th>Thread Quantity</th>
<th>Date/Time</th>
</tr>";
echo "</table>";
echo "<p>No data found</p>";
}
?>
</page>
</center>
<script type="text/javascript">
window.print();
</script>
</body>
</html>