001.
<?php
002.
session_start();
003.
session_register(
"sess_kindid"
);
004.
session_register(
"sess_kindname"
);
005.
session_register(
"sess_kindnum"
);
006.
session_register(
"sess_unit"
);
007.
008.
if
(
$_GET
[
'add'
]==
"new"
)
009.
{
010.
011.
echo
"<p><u>รายการสต๊อกวัสดุที่มี</u></p>"
;
012.
echo
"<select name=\"selectkind\" id=\"selectkind\" style=\"margin-left:5px;\" onclick=\"return selectKind();\"
>
013.
<option value=\
"\">- - - - - เลือกประเภทของวัสดุที่ท่านต้องการ - - - - -</option>"
;
014.
015.
$sql
=
"Select * From stock_tb_kind Order by kindid"
;
016.
mysql_query(
"SET NAMES utf8"
);
017.
$rs
=mysql_query(
$sql
);
018.
while
(
$row
=mysql_fetch_array(
$rs
))
019.
{
020.
echo
"<option value=\""
.
$row
[
'kindid'
].
"\">ประเภท : "
.
$row
[
'kindname'
].
"</option>"
;
021.
}
022.
echo
"</select> [ <img src=\"images/cart.gif\" width=\"17\" /> <a class=\"cout\" href=\"index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
[
'bk'
].
"\">ดูตระกร้าของคุณ</a> ]<br />"
;
023.
024.
echo
"<table width=\"580\" cellspacing=\"1\" cellpadding=\"1\" border=\"1\">"
;
025.
echo
"<tr>"
;
026.
echo
"<td width=\"400\" align=\"center\"><b>รายการวัสดุ</b></td>"
;
027.
028.
echo
"<td width=\"90\" align=\"center\"><b>จองวัสดุ</b></td>"
;
029.
echo
"</tr>"
;
030.
031.
$sql
=
"Select * From stock_tb_kind_type where kindid='"
.
$_GET
['kindid
']."'
Order by kindtypeid";
032.
mysql_query(
"SET NAMES utf8"
);
033.
$rs
=mysql_query(
$sql
);
034.
if
(mysql_num_rows(
$rs
)==0)
035.
{
036.
echo
"<tr height=\"25\" bgcolor=\"#FFFFFF\">"
;
037.
echo
"<td colspan=\"3\" align=\"center\">- - - - ยังไม่มีีข้อมูล - - - - </td>"
;
038.
echo
"</tr>"
;
039.
}
040.
while
(
$row
=mysql_fetch_array(
$rs
))
041.
{
042.
043.
echo
"<form id=\"form1\" name=\"form1\" method=\"post\" action=\"index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
[
'bk'
].
"&id="
.
$row
[
'kindtypeid'
].
"\">"
;
044.
echo
"<tr height=\"25\" bgcolor=\"#FFFFFF\" onMouseOver=\"switchBg(this, 'mOUT')\" onMouseOut=\"switchBg(this, 'mIN')\" >"
;
045.
echo
"<td> "
.
$row
[
'kindtypename'
].
"</td>"
;
046.
echo
"<td align=\"center\">"
;
047.
048.
echo
"<input name=\"data1\" type=\"checkbox\" value=\"kindtypeid\">"
;
049.
050.
051.
052.
echo
"</tr>"
;
053.
054.
}
055.
echo
"</table>"
;
056.
057.
echo
"<input type=\"submit\" name=\"continue_bt\" id=\"continue_bt\" value=\"ดำเนินการต่อ\" />"
;
058.
059.
060.
061.
062.
}
elseif
(isset(
$_POST
[
'savebeg'
]))
063.
064.
{
065.
for
(
$i
=0;
$i
<
count
(
$_POST
[
'beg_for'
]);
$i
++)
066.
{
067.
068.
069.
070.
071.
072.
073.
074.
075.
076.
077.
078.
079.
}
080.
if
(
$_POST
[
'txtdate'
]==
""
)
081.
{
082.
echo
"<p>กรุณากรอกข้อมูลเบื้องต้นให้ครบ</p>"
;
083.
echo
"<p><a href=\"javascript:window.history.back();\">ย้อนกลับ</a></p>"
;
084.
exit
();
085.
}
086.
if
(
count
(
$_SESSION
[
'sess_kindid'
])==0){
087.
echo
"<p>กรุณาเลือกรายการที่คุณต้องการ</p>"
;
088.
echo
"<p><a href=\"javascript:window.history.back();\">ย้อนกลับ</a></p>"
;
089.
exit
();
090.
}
091.
if
(
$_POST
[
'user_name'
]==
""
)
092.
{
093.
echo
"<p>กรุณากรอกข้อมูลผู้ขอเบิกให้ครบด้วยครับ</p>"
;
094.
echo
"<p><a href=\"javascript:window.history.back();\">ย้อนกลับ</a></p>"
;
095.
exit
();
096.
}
097.
098.
099.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
$e
=
explode
(
"-"
,
$_POST
[
'txtdate'
]);
113.
$d
=
$e
[2].
"-"
.
$e
[0].
"-"
.
$e
[1];
114.
$sql
=
"INSERT INTO stock_tb_beg_master(nobeg,begno,datedo,datebeg,iduser,statusbeg) Value("
;
115.
$sql
.=
"'"
.
$_GET
['bk
']."'
,
'".$_POST['
txtbegno
']."'
,
'$txtdate'
,
'$d'
,
'".$_SESSION['
iduser
']."'
,
'0'
)";
116.
mysql_query(
"SET NAMES utf8"
);
117.
$rs
=mysql_query(
$sql
);
118.
if
(
$rs
){
119.
$beg
=
$_POST
[
'beg_num'
];
120.
$for
=
$_POST
[
'beg_for'
];
121.
$i
=0;
122.
foreach
(
$_SESSION
[
'sess_kindid'
]
as
$kid
=>
$kvalue
){
123.
$sqldetail
=
"INSERT INTO stock_tb_beg_master_sub(nobeg,kindtypeid,total,forbeg,user_name) Value('"
.
$_GET
['bk
']."'
,
'".$_SESSION['
sess_kindid
'][$kid]."'
,
'".$beg[$i]."'
,
'".$for[$i]."'
,
'$user_name'
)";
124.
mysql_query(
"SET NAMES utf8"
);
125.
$rsdetail
=mysql_query(
$sqldetail
);
126.
$i
++;
127.
}
128.
session_unregister(
"sess_kindid"
);
129.
session_unregister(
"sess_kindname"
);
130.
session_unregister(
"sess_kindnum"
);
131.
session_unregister(
"sess_unit"
);
132.
133.
echo
"<p style=\"font-size:14px;margin:3px;\">บันทึกข้อมูลสำเร็จเรียบร้อยแล้วครับ<p>"
;
134.
echo
"<p style=\"font-size:14px;margin:3px;\">รหัสขอเบิกของท่านคือ : <font style=\"color:red;\"><b>"
.
$_GET
[
'bk'
].
"</b></font></p>"
;
135.
echo
"<p style=\"font-size:14px;margin:3px;\">กรุณาจดจำรหัสนี้เมื่อท่านได้ไปขอเบิกของ เพื่อยืนยันว่าท่านมารับของจริงครับ<p>"
;
136.
echo
"<p style=\"font-size:14px;margin:3px;\">กด <a class=\"cout2\" href=\"index.php\">ที่นี่</a> เพื่อออกจากหน้านี้</p>"
;
137.
}
else
{
138.
echo
"<p>"
.mysql_error().
"</p>"
;
139.
exit
();
140.
}
141.
}
else
{
142.
if
(isset(
$_GET
[
'id'
])){
143.
if
(existsCart(
$_SESSION
[
'sess_kindid'
],
$id
)){
144.
echo
"<script>"
;
145.
echo
"alert('คุณได้ทำการเลือกรายการนี้ไปแล้วครับ');"
;
146.
echo
"window.locaiton.href=window.history.back();"
;
147.
echo
"</script>"
;
148.
}
else
{
149.
$sqlk
=
"Select stock_tb_kind_type.*,stock_tb_unit.unitname From stock_tb_kind_type INNER JOIN stock_tb_unit ON stock_tb_kind_type.unitid=stock_tb_unit.unitid Where kindtypeid='"
.
$_GET
['id
']."'
";
150.
mysql_query(
"SET NAMES utf8"
);
151.
$rsk
=mysql_query(
$sqlk
);
152.
$arrk
=mysql_fetch_array(
$rsk
);
153.
$_SESSION
[
'sess_kindid'
][ ]=
$arrk
[
'kindtypeid'
];
154.
$_SESSION
[
'sess_kindname'
][ ]=
$arrk
[
'kindtypename'
];
155.
$_SESSION
[
'sess_kindnum'
][ ]=0;
156.
$_SESSION
[
'sess_unit'
][ ]=
$arrk
[
'unitname'
];
157.
echo
"<script>window.location.href='index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
['bk
']."'
</script>";
158.
}
159.
}
160.
echo
"<p><u>ขอเบิกวัสดุอุปกรณ์</u></p>"
;
161.
echo
"<form name=\"frmaddbeg\" action=\"\" method=\"POST\">"
;
162.
echo
"<table width=\"580\" cellspacing=\"1\" cellpadding=\"1\" border=\"0\" style=\"background:#FFFFFF;\">"
;
163.
echo
"<tr>"
;
164.
echo
"<td width=\"180\" align=\"right\">เลขที่ใบเบิก : </td>"
;
165.
echo
"<td><input class=\"ipstock\" type=\"text\" name=\"txtbegno\" id=\"txtbegno\" disabled=\"disabled\"/> ระบบจะออกเลขให้อัตโนมัติ</td>"
;
166.
echo
"</tr>"
;
167.
echo
"<tr>"
;
168.
echo
"<td align=\"right\">วันที่ทำรายการ : </td>"
;
169.
echo
"<td>"
.thaidate(
$timedate
).
"</td>"
;
170.
echo
"</tr>"
;
171.
echo
"<tr>"
;
172.
echo
"<td align=\"right\">วันที่ต้องการเบิก : </td>"
;
173.
echo
"<td><input class=\"ipstock\" type=\"text\" name=\"txtdate\" id=\"txtdate\" readonly=\"readonly\" onfocus=\"showCalendarControl(this);\" autocomplete=\"off\" style=\"width:30%;\" /> </td>"
;
174.
echo
"</tr>"
;
175.
176.
177.
178.
179.
180.
181.
echo
"<tr>"
;
182.
echo
"<td align=\"right\">ผู้ขอเบิก: </td>"
;
183.
echo
"<td><input name=\"user_name\" size=\"40\"></td>"
;
184.
echo
"</tr>"
;
185.
186.
187.
echo
"<tr>"
;
188.
echo
"<td> </td>"
;
189.
echo
"<td><input class=\"btadmin\" type=\"submit\" name=\"savebeg\" value=\"บันทึกข้อมูล\"/> <input class=\"btadmin\" type=\"button\" value=\"ยกเลิก\"/></td>"
;
190.
echo
"</tr>"
;
191.
echo
"</table>"
;
192.
echo
"<p><u>รายการที่คุณขอเบิก</u></p>"
;
193.
194.
if
(isset(
$_GET
[
'del'
]))
195.
{
196.
$id
=
$_GET
[
'del'
];
197.
198.
delCart(
$_SESSION
[
'sess_kindid'
],
$id
);
199.
}
200.
if
(isset(
$_GET
[
'delall'
]))
201.
{
202.
session_unregister(
"sess_kindid"
);
203.
session_unregister(
"sess_kindname"
);
204.
session_unregister(
"sess_kindnum"
);
205.
session_unregister(
"sess_unit"
);
206.
}
207.
echo
"<p style=\"text-align:left;margin-top:10px;margin-left:50px;\"><a class=\"bl\" href=\"index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
[
'bk'
].
"&add=new\"><img src=\"images/add_24.png\" border=\"0\" width=\"18\"/> เพิ่มรายการ</a> <a class=\"bl\" href=\"index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
[
'bk'
].
"&delall=true\" onclick=\"return confirm('คุณต้องการรายการทั้งหมดที่คุณเลือกหรือไม่ ?');\"><img src=\"images/del_24.png\" width=\"18\" border=\"0\"/> ลบรายการทั้งหมด</a></p><center>"
;
208.
209.
echo
"<table width=\"580\" cellspacing=\"1\" cellpadding=\"1\" border=\"1\" style=\"border:1px solid;background:#D0D0D0;\">"
;
210.
echo
"<tr height=\"30\" bgcolor=\"#00AEFF\">"
;
211.
echo
"<td colspan=\"2\" align=\"center\">รายการ</td>"
;
212.
213.
echo
"<td width=\"250\" align=\"center\">จำนวน</td>"
;
214.
echo
"<td align=\"center\">หน่วย</td>"
;
215.
echo
"</tr>"
;
216.
if
(
count
(
$_SESSION
[
'sess_kindid'
])==0){
217.
echo
"<tr height=\"30\" bgcolor=\"#FFFFFF\"><td colspan=\"5\" align=\"center\">คุณยังไม่มีการรายที่จะขอเบิก กรุณากด <a class=\"bl\" href=\"index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
[
'bk'
].
"&add=new\">ที่นี่</a> เพื่อขอเิบิกครับ</td></tr>"
;
218.
}
else
{
219.
foreach
(
$_SESSION
[
'sess_kindid'
]
as
$kid
=>
$kvalue
){
220.
echo
"<tr height=\"25\" bgcolor=\"#FFFFFF\" onMouseOver=\"switchBg(this, 'mOUT')\" onMouseOut=\"switchBg(this, 'mIN')\">"
;
221.
echo
"<td width=\"50\" align=\"center\"><a class=\"cout2\" href=\"index.php?option=hrstock&com_stock=begstock&bk="
.
$_GET
[
'bk'
].
"&del="
.
$_SESSION
[
'sess_kindid'
][
$kid
].
"&name="
.
$_SESSION
[
'sess_kindname'
][
$kid
].
"&total="
.
$_SESSION
[
'sess_kindnum'
][
$kid
].
"\" onclick=\"return confirm('คุณต้องการรายการ : "
.
$_SESSION
['sess_kindname
'][$kid]." นี้หรือไม่ ?'
);\"><img src=\"images/del_24.png\" width=\"15\" border=\"0\"/></a></td>";
222.
echo
"<td width=\"200\"> "
.
$_SESSION
[
'sess_kindname'
][
$kid
].
"</td>"
;
223.
224.
echo
"<td align=\"right\"><input class=\"ipstock\" type=\"text\" name=\"beg_num[]\" value=\""
.
$_SESSION
[
'sess_kindnum'
][
$kid
].
"\" style=\"text-align:right;padding-right:2px;width:98%;\" autocomplete=\"off\" /></td>"
;
225.
echo
"<td align=\"right\">"
.
$_SESSION
[
'sess_unit'
][
$kid
].
" </td>"
;
226.
echo
"</tr>"
;
227.
}
228.
}
229.
echo
"</table>"
;
230.
echo
"<br />"
;
231.
echo
"</center>"
;
232.
echo
"<br />"
;
233.
echo
"</form>"
;
234.
}
235.
?>