-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkstock.php
111 lines (102 loc) · 4.47 KB
/
checkstock.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
<?php
include ('conn.php');
session_start();
if($_SESSION["Username"]=="") // ตรวจสอบว่าผ่านการ login หรือไม่
{
header('location:login.php');
exit();
}
$username=$_SESSION["Username"];
include 'header.php';
?>
<div class="container">
<div class="jumbotron">
<br>
<p>ตรวจสอบสต๊อก</p>
<?php
$num = 0;
$sql = "SELECT COUNT(id_stock) FROM stock";
$objQuery = mysql_query($sql,$connect1);
$row = mysql_fetch_array($objQuery);
$num = sprintf("%05d",$row['COUNT(id_stock)'] + 1);
$id_detail = 'ipdetail-'.$num;
$sql = "SELECT * FROM stock ORDER BY id_stock";
$objQuery = mysql_query($sql,$connect1);
?>
<div class="modal-body">
<form method="GET" action="#">
รหัสสต๊อกและชื่อสต๊อก :
<select class="" name="id_stock" required>
<?php
$sql = "SELECT * FROM stock";
$select = mysql_query($sql,$connect1);
while ($row = mysql_fetch_array($select)) {
if ($_GET['id_stock'] == $row['id_stock']) {
$selected = "selected";
}
else {
$selected = "";
}
?>
<option value="<?php echo $row['id_stock']; ?>" <?php echo $selected; ?> ><?php echo $row['id_stock'] ?> <?php echo $row['name_stock'] ?></option>
<?php
}
?>
</select>
</h4>
<div class="modal-footer">
<input type="submit" class="btn btn-success" value="ตรวจสอบ" name = "submit" onclick="">
<a href="stockanddetail.php"><button type="button" class="btn btn-danger" data-dismiss="modal" onclick="return confirm('ต้องการยกเลิกการตรวจสอบข้อมูลนี้?')">ยกเลิก</button></a>
</div>
</form>
</div>
</div>
<?php if ($_GET): ?>
<?php
$ID = $_GET['id_stock'];
$sql = "SELECT * FROM stock WHERE id_stock = '$ID'";
$query = mysql_query($sql,$connect1);
$result = mysql_fetch_array($query);
?>
<table class="table table-striped table-bordered">
<tr class="warning">
<th colspan="4"><div class="text-center">รหัสสต๊อก <?php echo $_GET['id_stock']; ?> : <?php echo $result['name_stock']; ?></div></th>
</tr>
<tr class="warning">
<th><div align="center">ลำดับ</div></th>
<th><div align="center">วัตถุดิบ</div></th>
<th><div align="center">จำนวน</div></th>
<th><div align="center">หน่วยนับ</div></th>
</tr>
<?
$sql = "SELECT SUM(count),stock_detail.mat_id,mat_name,feed_name,unit_name FROM stock_detail LEFT JOIN material ON stock_detail.mat_id = material.mat_id
LEFT JOIN feed ON stock_detail.mat_id = feed.feed_id JOIN unit ON unit.unit_id = stock_detail.unit_id
WHERE stock_id = '$ID' GROUP BY mat_name";
if ($ID == 'MT-06') {
$sql = "SELECT SUM(count),stock_detail.mat_id,feed_name,unit_name FROM stock_detail
JOIN feed ON stock_detail.mat_id = feed.feed_id JOIN unit ON unit.unit_id = stock_detail.unit_id
GROUP BY feed_name";
}
$objQuery = mysql_query($sql,$connect1);
$i = 1;
while ($objReSult = mysql_fetch_array($objQuery)) {
?>
<?php if ($objReSult["SUM(count)"] > 0): ?>
<tr class ="info">
<td><div class="text-center"><?php echo $i++; ?></div></td>
<?php if ($objReSult["feed_name"] != NULL): ?>
<td><div align = "left"><? echo $objReSult["feed_name"];?></div></td>
<?php else: ?>
<td><div align = "left"><? echo $objReSult["mat_name"];?></div></td>
<?php endif; ?>
<td><div align = "right"><? echo $objReSult["SUM(count)"];?></div></td>
<td><div align = "left"><? echo $objReSult["unit_name"];?></div></td>
</tr>
<?php endif; ?>
<?
}
?>
</table>
<?php endif; ?>
</div>
<?php include 'footer.php' ?>