001.
<?php
002.
session_start();
003.
error_reporting
(
error_reporting
() & ~E_NOTICE );
004.
require
'config.php'
;
005.
006.
if
(
$_SESSION
[
'userID'
] ==
""
)
007.
{
008.
echo
"<meta http-equiv=\"refresh\" content=\"0; URL=warning.php\">"
;
009.
exit
();
010.
}
011.
012.
if
(
$_SESSION
[
'status'
] !=
"ADMIN"
AND
$_SESSION
[
'status'
] !=
"MANAGE"
)
013.
{
014.
echo
"<meta http-equiv=\"refresh\" content=\"0; URL=warning.php\">"
;
015.
exit
();
016.
}
017.
$ss
=
$_SESSION
[
'userID'
];
018.
019.
$sql
=
"SELECT * FROM user_tpd WHERE userID = ?"
;
020.
$stm
=
$db
->prepare(
$sql
);
021.
$stm
->bindParam(
"1"
,
$ss
);
022.
$stm
-> execute();
023.
$resultUs
=
$stm
->fetch(PDO::FETCH_ASSOC);
024.
?>
025.
<!DOCTYPE html>
026.
<html lang=
"th"
dir=
"ltr"
>
027.
<head>
028.
<meta charset=
"utf-8"
>
029.
<title>โรงเรียนเทพผดุงศิษย์ศึกษา :: สินค้านักเรียน</title>
030.
<script language=
"JavaScript"
>
031.
var
HttPRequest = false;
032.
033.
function
doCallAjax(ProductID,Qty,productPrice) {
034.
HttPRequest = false;
035.
if
(window.XMLHttpRequest) {
036.
HttPRequest =
new
XMLHttpRequest();
037.
if
(HttPRequest.overrideMimeType) {
038.
HttPRequest.overrideMimeType(
'text/html'
);
039.
}
040.
}
else
if
(window.ActiveXObject) {
041.
try {
042.
HttPRequest =
new
ActiveXObject(
"Msxml2.XMLHTTP"
);
043.
} catch (e) {
044.
try {
045.
HttPRequest =
new
ActiveXObject(
"Microsoft.XMLHTTP"
);
046.
} catch (e) {}
047.
}
048.
}
049.
050.
if
(!HttPRequest) {
051.
alert(
'Cannot create XMLHTTP instance'
);
052.
return
false;
053.
}
054.
055.
var
url =
'product_s_cart.php'
;
056.
var
pmeters =
"tProductID="
+ ProductID+
057.
"&tproductPrice="
+ productPrice+
058.
"&tQty="
+ Qty;
059.
HttPRequest.open(
'POST'
,url,true);
060.
061.
HttPRequest.setRequestHeader(
"Content-type"
,
"application/x-www-form-urlencoded"
);
062.
HttPRequest.setRequestHeader(
"Content-length"
, pmeters.length);
063.
HttPRequest.setRequestHeader(
"Connection"
,
"close"
);
064.
HttPRequest.send(pmeters);
065.
066.
067.
HttPRequest.onreadystatechange =
function
()
068.
{
069.
070.
if
(HttPRequest.readyState == 3)
071.
{
072.
document.getElementById(
"mySpan"
).innerHTML =
"Now is Loading..."
;
073.
}
074.
075.
if
(HttPRequest.readyState == 4)
076.
{
077.
document.getElementById(
'mySpan'
).innerHTML = HttPRequest.responseText;
078.
}
079.
}
080.
081.
}
082.
083.
function
CheckOut()
084.
{
085.
window.location =
'product_s_save.php'
;
086.
}
087.
</script>
088.
<link rel=
"stylesheet"
type=
"text/css"
href=
"./css/laout_screen.css"
>
089.
<link rel=
"stylesheet"
type=
"text/css"
href=
"./css/library_screen.css"
>
090.
</head>
091.
<body onLoad=
"JavaScript:doCallAjax('','')"
>
092.
<table>
093.
<tr>
094.
<td>
095.
<div id=
"bs"
> <img src=
"./img/bs.gif"
height=
"100"
> </div>
096.
</td>
097.
</tr>
098.
</table>
099.
<table id=
"td001"
>
100.
<tr>
101.
<td><p id=
"txtUser"
><b><?php
echo
$resultUs
[
"username"
]; ?><b></p></td>
102.
<td> <a href=
"chk_logout.php"
><button type=
"button"
name=
"button"
id=
"but"
> <b>Logout</b> </button></a></td>
103.
</tr>
104.
</table>
105.
<table id=
"tb002"
>
106.
<tr>
107.
<td>
108.
<br><br><br>
109.
<center><label id=
"textheader"
>ระบบจำหน่าย สินค้าและอุปกรณ์นักเรียน</label></center>
110.
<br><br><br>
111.
<table width=
"1300"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
>
112.
<tr>
113.
<td width=
"500"
valign=
"top"
><center>
114.
<?php
115.
if
(
$_SESSION
[
'status'
] ==
"ADMIN"
)
116.
{
117.
?>
118.
<a href=
"showdata_price_product.php"
><button type=
"button"
name=
"button"
id=
"editdata"
><img src=
"./img/icon_showdisplay/icon_billprice.png"
alt=
"icon"
width=
"15"
height=
"16"
> แก้ไขข้อมูลสินค้านักเรียน </button></a>
119.
<?php
120.
}
121.
else
{
122.
echo
""
;
123.
}
124.
125.
?>
126.
<br><br><br>
127.
<?php
128.
$stm
=
$db
->prepare(
"SELECT * FROM product_student"
);
129.
$stm
-> execute();
130.
$count
=
$stm
->rowCount();
131.
echo
"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>"
;
132.
$intRows
= 0;
133.
while
(
$result
=
$stm
->fetch( PDO::FETCH_ASSOC ))
134.
{
135.
$intRows
++;
136.
echo
"<td>"
;
137.
?>
138.
<center>
139.
<img src=
"<?php echo $result["
productPicture
"]; ?>"
width=
"80"
>
140.
<br>
141.
<?php
echo
$result
[
"productName"
];?>
142.
<br>
143.
<b><?php
echo
$result
[
"productPrice"
].
" บาท"
;?></b>
144.
<br>
145.
จำนวน <input type=
"text"
id=
"txt<?php echo $intRows;?>"
class
=
"text002"
style=
"text-align:right;"
size=
"2"
maxlength=
"2"
value=
""
style=
"width:20px"
onkeypress=
"return numkey(event)"
> ชิ้น
146.
<br><br><input type=
"button"
id=
"adddata"
value=
"Add"
onClick=
"JavaScript:doCallAjax('<?php echo $result["
productID
"];?>' , document.getElementById('txt<?php echo $intRows;?>').value);"
>
147.
<br><br>
148.
</center>
149.
<?php
150.
echo
"</td>"
;
151.
if
((
$intRows
)%3==0)
152.
{
153.
echo
"</tr>"
;
154.
}
155.
else
156.
{
157.
echo
"<td>"
;
158.
}
159.
}
160.
echo
"</tr></table>"
;
161.
?>
162.
</center>
163.
<br><br>
164.
<div style=
"position: relative; left:60px;"
>
165.
<?php
166.
if
(
$_SESSION
[
'status'
] ==
"ADMIN"
)
167.
{
168.
?>
169.
<a href=
"admin_page.php"
onclick=
"window.close();"
><button type=
"button"
id=
"back2"
>กลับ</button></a>
170.
171.
<?php
172.
}
173.
else
{
174.
?>
175.
<a href=
"manage_page.php"
onclick=
"window.close();"
><button type=
"button"
id=
"back2"
>กลับ</button></a>
176.
<?php
177.
}
178.
?>
179.
</div>
180.
</td>
181.
<td width=
"800"
valign=
"top"
><center><span id=
"mySpan"
></span></center></td>
182.
</tr>
183.
</table>
184.
<br><br>
185.
</td>
186.
</tr>
187.
</table>
188.
189.
</div>
190.
<br><br>
191.
<table>
192.
<tr>
193.
<td>
194.
<div id=
"ft"
>
195.
<br>
196.
<b>Created by</b> Vitsava Vannavichitr.
197.
198.
<b>Contact :: </b>E-Mail : nicky.nicky1989@hotmail.com
199.
& nick.nick2532@gmail.com
200.
201.
Line ID : chicken-madmanmadoka
202.
<br><br>
203.
</div>
204.
</td>
205.
</tr>
206.
</table>
207.
</body>
208.
</html>
209.
<script type=
"text/javascript"
>
210.
function
numkey(event2){
211.
var
regex2 =
new
RegExp(
"^[0-9]"
);
212.
var
key2 = String.fromCharCode(event2.charCode ? event2.which : event2.charCode);
213.
if
(!regex2.test(key2)) {
214.
event2.preventDefault();
215.
return
false;
216.
}
217.
}
218.
</script>