-
Notifications
You must be signed in to change notification settings - Fork 1
/
out_stock.php
125 lines (117 loc) · 5.99 KB
/
out_stock.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
<?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_outputmat) FROM output_material";
$objQuery = mysql_query($sql,$connect1);
$row = mysql_fetch_array($objQuery);
$num = sprintf("%05d",$row['COUNT(id_outputmat)'] + 1);
$id_output = "OPMAT-$num";
$sql = "SELECT * FROM output_material ORDER BY output_material.date DESC";
$objQuery = mysql_query($sql,$connect1);
date_default_timezone_set("Asia/Bangkok") ;
$datethis = date("Y-m-d H:i:s");
$strDate=date('d-m-Y');
$strYear = date("Y",strtotime($strDate))+543;
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strDays= date("l",strtotime($strDate));
$strDayCut = Array("Monday"=>"วันจันทร์ที่","Tuesday"=>"วันอังคารที่","Wednesday"=>"วันพุธที่","Thursday"=>"วันพฤหัสบดีที่","Friday"=>"วันศุกร์ที่","Saturday"=>"วันเสาร์ที่","Sunday"=>"วันอาทิตย์ที่");
$strMonthCut = Array("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม");
$strMonthThai=$strMonthCut[$strMonth];
$strDaysThai = $strDayCut[$strDays];
$date=$strDaysThai." ".$strDay." ".$strMonthThai." ".$strYear;
?>
<div class="modal-body">
<form method="POST" action="#" onsubmit="return confirm('ต้องการเพิ่มข้อมูลนี้?');">
<h4> รหัสการเบิก : <?php echo $id_output; ?><input type="hidden" name="id" value="<?php echo $id_output; ?>" readonly=""></h4>
<h4> วันที่การเบิก : <?php echo $date; ?><input type="hidden" name="date" required value="<?php echo $datethis; ?>" > </h4>
<h4> รหัสเจ้าหน้าที่ : <? echo $_SESSION["fnname"];?><input type="hidden" name="username" value="<? echo $_SESSION["fnname"];?>" readonly=""></h4>
<div class="modal-footer" style="padding-bottom : 0px;">
<input type="submit" class="btn btn-success" value="เพิ่มข้อมูล" name = "submit" >
<a href="index.php"><button type="button" class="btn btn-danger" data-dismiss="modal">ย้อนกลับ</button></a>
</div>
</form>
</div>
<?php
if($_POST){
$id_output = $_POST['id'];
$id_mat = $_POST['id_mat'];
do {
$pname = $_POST['username'];
$date = $_POST['date'];
$sql = "INSERT INTO output_material (id_outputmat,user,date) VALUES ('$id_output','$pname','$date')";
$objQuery = mysql_query($sql,$connect1);
} while (!$objQuery);
header("Location:out_to_stock.php?idoutputmat=$id_output");
}
?>
</div>
<br>
<table class="table table-striped table-bordered">
<tr class="warning">
<th>ลำดับ</th>
<th>วันทีเบิก</th>
<th>รหัสการเบิก</th>
<th>เจ้าหน้าที่</th>
<th><div align = "center">ดูข้อมูล</div></th>
<th><div align = "center">พิมพ์</div></th>
</tr>
<?php
$perpage = 20;
if (isset($_GET['page']) && $_GET['page'] != 0) {
$page = $_GET['page'];
} else {
$page = 1;
}
$start = ($page - 1) * $perpage;
$idedit = $id_output;
$table = "SELECT * FROM output_material ORDER BY output_material.id_outputmat DESC LIMIT {$start},{$perpage}";
$result = mysql_query($table,$connect1);
$i = 0;
while ($row = mysql_fetch_array($result)){
$id = $row['id_outputmat'];
$i++;
?>
<tr class ="info">
<td><?php echo $i; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['id_outputmat']; ?></td>
<td><?php echo $row['user']; ?></td>
<td><div align = "center"><a href="select_mat_out_stock.php?id=<?php echo $id; ?>" ><img src='img/sssss.png' width=25></a></div></td>
<td><div align = "center"><a target="_blank" href="print_output.php?id=<? echo $row['id_outputmat'];?>"><img src='img/print.png' width=25></a></div></td>
</tr>
<?php
}
?>
</table>
<?php
$sql2 = "SELECT * FROM output_material";
$query2 = mysql_query($sql2, $connect1);
$total_record = mysql_num_rows($query2);
$total_page = ceil($total_record / $perpage);
?>
<nav align="center" aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="out_stock.php?page=<?php echo ($page-1); ?>" aria-label="Previous"><span aria-hidden="true"><<</span></a></li>
<?php for($i=1;$i<=$total_page;$i++){ ?>
<li><a href="out_stock.php?page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
<?php } ?>
<li class="page-item"><a class="page-link" href="out_stock.php?page=<?php echo ($page+1); ?>" aria-label="Next"><span aria-hidden="true">>></span></a></li>
</ul>
</nav>
</div>
<?php include 'footer.php'; ?>