001.
<?php
require_once
(
'Connections/MyConnect.php'
); ?>
002.
<?php
003.
if
(!isset(
$_SESSION
)) {
004.
session_start();
005.
}
006.
$MM_authorizedUsers
=
""
;
007.
$MM_donotCheckaccess
=
"true"
;
008.
009.
010.
function
isAuthorized(
$strUsers
,
$strGroups
,
$UserName
,
$UserGroup
) {
011.
012.
$isValid
= False;
013.
014.
015.
016.
if
(!
empty
(
$UserName
)) {
017.
018.
019.
$arrUsers
=
Explode
(
","
,
$strUsers
);
020.
$arrGroups
=
Explode
(
","
,
$strGroups
);
021.
if
(in_array(
$UserName
,
$arrUsers
)) {
022.
$isValid
= true;
023.
}
024.
025.
if
(in_array(
$UserGroup
,
$arrGroups
)) {
026.
$isValid
= true;
027.
}
028.
if
((
$strUsers
==
""
) && true) {
029.
$isValid
= true;
030.
}
031.
}
032.
return
$isValid
;
033.
}
034.
035.
$MM_restrictGoTo
=
"admin/index.php"
;
036.
if
(!((isset(
$_SESSION
[
'MM_Username'
])) && (isAuthorized(
""
,
$MM_authorizedUsers
,
$_SESSION
[
'MM_Username'
],
$_SESSION
[
'MM_UserGroup'
])))) {
037.
$MM_qsChar
=
"?"
;
038.
$MM_referrer
=
$_SERVER
[
'PHP_SELF'
];
039.
if
(
strpos
(
$MM_restrictGoTo
,
"?"
))
$MM_qsChar
=
"&"
;
040.
if
(isset(
$_SERVER
[
'QUERY_STRING'
]) &&
strlen
(
$_SERVER
[
'QUERY_STRING'
]) > 0)
041.
$MM_referrer
.=
"?"
.
$_SERVER
[
'QUERY_STRING'
];
042.
$MM_restrictGoTo
=
$MM_restrictGoTo
.
$MM_qsChar
.
"accesscheck="
. urlencode(
$MM_referrer
);
043.
header(
"Location: "
.
$MM_restrictGoTo
);
044.
exit
;
045.
}
046.
?>
047.
<?php
048.
if
(!function_exists(
"GetSQLValueString"
)) {
049.
function
GetSQLValueString(
$theValue
,
$theType
,
$theDefinedValue
=
""
,
$theNotDefinedValue
=
""
)
050.
{
051.
if
(PHP_VERSION < 6) {
052.
$theValue
= get_magic_quotes_gpc() ?
stripslashes
(
$theValue
) :
$theValue
;
053.
}
054.
055.
$theValue
= function_exists(
"mysql_real_escape_string"
) ? mysql_real_escape_string(
$theValue
) : mysql_escape_string(
$theValue
);
056.
057.
switch
(
$theType
) {
058.
case
"text"
:
059.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
060.
break
;
061.
case
"long"
:
062.
case
"int"
:
063.
$theValue
= (
$theValue
!=
""
) ?
intval
(
$theValue
) :
"NULL"
;
064.
break
;
065.
case
"double"
:
066.
$theValue
= (
$theValue
!=
""
) ? doubleval(
$theValue
) :
"NULL"
;
067.
break
;
068.
case
"date"
:
069.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
070.
break
;
071.
case
"defined"
:
072.
$theValue
= (
$theValue
!=
""
) ?
$theDefinedValue
:
$theNotDefinedValue
;
073.
break
;
074.
}
075.
return
$theValue
;
076.
}
077.
}
078.
079.
$editFormAction
=
$_SERVER
[
'PHP_SELF'
];
080.
if
(isset(
$_SERVER
[
'QUERY_STRING'
])) {
081.
$editFormAction
.=
"?"
. htmlentities(
$_SERVER
[
'QUERY_STRING'
]);
082.
}
083.
084.
if
((isset(
$_POST
[
"MM_insert"
])) && (
$_POST
[
"MM_insert"
] ==
"form1"
)) {
085.
$insertSQL
= sprintf(
"INSERT INTO purchase_detail (pur_detail_date, pur_detail_principal, pur_detail_productqty) VALUES (%s, %s, %s)"
,
086.
GetSQLValueString(
$_POST
[
'pur_detail_date'
],
"date"
),
087.
GetSQLValueString(
$_POST
[
'pur_detail_principal'
],
"double"
),
088.
GetSQLValueString(
$_POST
[
'pur_detail_productqty'
],
"int"
));
089.
090.
mysql_select_db(
$database_MyConnect
,
$MyConnect
);
091.
$Result1
= mysql_query(
$insertSQL
,
$MyConnect
)
or
die
(mysql_error());
092.
093.
$insertGoTo
=
"Purchase_detail.php"
;
094.
if
(isset(
$_SERVER
[
'QUERY_STRING'
])) {
095.
$insertGoTo
.= (
strpos
(
$insertGoTo
,
'?'
)) ?
"&"
:
"?"
;
096.
$insertGoTo
.=
$_SERVER
[
'QUERY_STRING'
];
097.
}
098.
header(sprintf(
"Location: %s"
,
$insertGoTo
));
099.
}
100.
?>
103.
<head>
104.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
105.
<title>addpurchase_detail</title>
106.
<?php
107.
$jquery_ui_v
=
"1.8.5"
;
108.
$theme
=
array
(
109.
"0"
=>
"base"
,
110.
"1"
=>
"black-tie"
,
111.
"2"
=>
"blitzer"
,
112.
"3"
=>
"cupertino"
,
113.
"4"
=>
"dark-hive"
,
114.
"5"
=>
"dot-luv"
,
115.
"6"
=>
"eggplant"
,
116.
"7"
=>
"excite-bike"
,
117.
"8"
=>
"flick"
,
118.
"9"
=>
"hot-sneaks"
,
119.
"10"
=>
"humanity"
,
120.
"11"
=>
"le-frog"
,
121.
"12"
=>
"mint-choc"
,
122.
"13"
=>
"overcast"
,
123.
"14"
=>
"pepper-grinder"
,
124.
"15"
=>
"redmond"
,
125.
"16"
=>
"smoothness"
,
126.
"17"
=>
"south-street"
,
127.
"18"
=>
"start"
,
128.
"19"
=>
"sunny"
,
129.
"20"
=>
"swanky-purse"
,
130.
"21"
=>
"trontastic"
,
131.
"22"
=>
"ui-darkness"
,
132.
"23"
=>
"ui-lightness"
,
133.
"24"
=>
"vader"
134.
);
135.
$jquery_ui_theme
=
$theme
[22];
136.
?>
138.
<style type=
"text/css"
>
139.
140.
141.
142.
.ui-tabs{
143.
font-family:tahoma;
144.
font-size:11px;
145.
}
146.
</style>
147.
<style type=
"text/css"
>
148.
149.
.ui-datepicker{
150.
width:220px;
151.
font-family:tahoma;
152.
font-size:11px;
153.
text-align:center;
154.
}
155.
</style>
156.
157.
<style type=
"text/css"
>
158.
#MenuBar1 {
159.
font-size: 230%;
160.
font-family:
"Courier New"
, Courier, monospace;
161.
}
162.
body p {
163.
font-size: 18px;
164.
text-align: center;
165.
color: #000;
166.
}
167.
body h2 {
168.
text-align: center;
169.
}
170.
</style>
171.
<script src=
"js/jquery.js"
type=
"text/javascript"
></script>
172.
<link href=
"css/bootstrap.min.css"
rel=
"stylesheet"
type=
"text/css"
/>
173.
</head>
174.
175.
<body
class
=
'container'
>
176.
<p><img src=
"shop.jpg"
width=
"1117"
height=
"149"
/>
177.
</p>
178.
<h3>ร้านเกสร
179.
</h3>
180.
<p>ระบบจัดการฐานข้อมูลสำหรับร้านค้าปลีก</p>
181.
182.
<div
class
=
"btn-group"
>
183.
<button
class
=
"btn"
>ขายสินค้า</button>
184.
</div>
185.
186.
<div
class
=
"btn-group"
>
187.
<button
class
=
"btn"
>ข้อมูลพื้นฐาน</button>
188.
<button
class
=
"btn dropdown-toggle"
data-toggle=
"dropdown"
>
189.
<span
class
=
"caret"
></span>
190.
</button>
191.
<ul
class
=
"dropdown-menu"
>
192.
<li><a href=
"Product.php"
>ข้อมูลสินค้า</a></li>
193.
<li><a href=
"Category.php"
>ข้อมูลประเภทสินค้า</a></li>
194.
<li><a href=
"Supplier.php"
>ข้อมูลผู้จัดจำหน่าย</a></li>
195.
<!-- dropdown menu links -->
196.
</ul>
197.
</div>
198.
199.
<div
class
=
"btn-group"
>
200.
<button
class
=
"btn"
><a href=
"Unit.php"
>หน่วยสินค้า</a></button>
201.
</div>
202.
203.
<div
class
=
"btn-group"
>
204.
<button
class
=
"btn"
>จัดการลูกหนี้</button>
205.
</div>
206.
207.
<div
class
=
"btn-group"
>
208.
<button
class
=
"btn"
>เพิ่มเติม</button>
209.
<button
class
=
"btn dropdown-toggle"
data-toggle=
"dropdown"
>
210.
<span
class
=
"caret"
></span>
211.
</button>
212.
<ul
class
=
"dropdown-menu"
>
213.
<li><a href=
"#"
>ดูสินค้าใกล้หมด</a></li>
214.
<li><a href=
"#"
>เช็คสต๊อกสินค้า</a></li>
215.
<!-- dropdown menu links -->
216.
</ul>
217.
</div>
218.
219.
<div
class
=
"btn-group"
>
220.
<button
class
=
"btn"
><a href=
"edit-profile.php"
>แก้ไขข้อมูลส่วนตัว</a></button>
221.
</div>
222.
223.
<div
class
=
"btn-group"
>
224.
<button
class
=
"btn"
><a href=
"admin/index.php"
>ออกจากระบบ</a></button>
225.
</div>
226.
<p> </p>
227.
<script language=
"javascript"
>
228.
function
fncSubmit()
229.
{
230.
if
(document.form1.pur_detail_date.value ==
""
)
231.
{
232.
alert(
"กรุณากรอกข้อมูล วัน เดือน ปี"
);
233.
document.form1.pur_detail_date.focus();
234.
return
false;
235.
}
236.
if
(document.form1.pur_detail_principal.value ==
""
)
237.
{
238.
alert(
"กรุณากรอกข้อมูลให้ครบ"
);
239.
document.form1.pur_detail_principal.focus();
240.
return
false;
241.
}
242.
if
(document.form1.pur_detail_productqty.value ==
""
)
243.
{
244.
alert(
"กรุณากรอกข้อมูลให้ครบ"
);
245.
document.form1.pur_detail_productqty.focus();
246.
return
false;
247.
}
248.
document.form1.submit();
249.
}
250.
</script>
251.
<form action=
"<?php echo $editFormAction; ?>"
method=
"post"
name=
"form1"
id=
"form1"
onSubmit=
"JavaScript:return fncSubmit();"
>
252.
<table align=
"center"
>
253.
<tr valign=
"baseline"
>
254.
<td nowrap=
"nowrap"
align=
"right"
> </td>
255.
<td>เพิ่มรายละเอียดการซื้อเข้า</td>
256.
</tr>
257.
<tr valign=
"baseline"
>
258.
<tr valign=
"baseline"
>
259.
<td nowrap=
"nowrap"
align=
"right"
>วันที่ซื้อเข้า:</td>
260.
<td><input name=
"pur_detail_date"
type=
"text"
id=
"pur_detail_date"
value=
""
/></td>
261.
</tr>
262.
<tr valign=
"baseline"
>
263.
<td nowrap=
"nowrap"
align=
"right"
>ราคาต้นทุน:</td>
264.
<td><input type=
"text"
name=
"pur_detail_principal"
onKeyUp=
"if(isNaN(this.value)){ alert('กรุณากรอกข้อมูลเป็นตัวเลขเท่านั้น'); this.value='';}"
size=
"32"
/></td>
265.
</tr>
266.
<tr valign=
"baseline"
>
267.
<td nowrap=
"nowrap"
align=
"right"
>จำนวนสินค้าที่ซื้อเข้า:</td>
268.
<td><input type=
"text"
name=
"pur_detail_productqty"
onKeyUp=
"if(isNaN(this.value)){ alert('กรุณากรอกข้อมูลเป็นตัวเลขเท่านั้น'); this.value='';}"
size=
"32"
/></td>
269.
</tr>
270.
<tr valign=
"baseline"
>
271.
<td nowrap=
"nowrap"
align=
"right"
> </td>
272.
<td><input type=
"submit"
value=
"ตกลง"
/> <input type=
"submit"
name=
"btn"
id=
"btn"
value=
"ยกเลิก"
/></td>
273.
</tr>
274.
</table>
275.
<input type=
"hidden"
name=
"MM_insert"
value=
"form1"
/>
276.
</form>
277.
<p> </p>
278.
<p> </p>
279.
280.
<script src=
"js/jquery.js"
></script>
281.
<script src=
"js/bootstrap.min.js"
></script>
282.
283.
<script src=
"//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
></script>
284.
<script src=
"//ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"
></script>
285.
<script type=
"text/javascript"
>
286.
$(
function
(){
287.
var
dateBefore=null;
288.
$(
"#pur_detail_date"
).datepicker({
289.
dateFormat:
'yy-mm-dd'
,
290.
showOn:
'button'
,
291.
292.
buttonImageOnly: false,
293.
dayNamesMin: [
'อา'
,
'จ'
,
'อ'
,
'พ'
,
'พฤ'
,
'ศ'
,
'ส'
],
294.
monthNamesShort: [
'มกราคม'
,
'กุมภาพันธ์'
,
'มีนาคม'
,
'เมษายน'
,
'พฤษภาคม'
,
'มิถุนายน'
,
'กรกฎาคม'
,
'สิงหาคม'
,
'กันยายน'
,
'ตุลาคม'
,
'พฤศจิกายน'
,
'ธันวาคม'
],
295.
changeMonth: true,
296.
changeYear: true,
297.
beforeShow:
function
(){
298.
if
($(this).val()!=
""
){
299.
var
arrayDate=$(this).val().split(
"-"
);
300.
arrayDate[2]=parseInt(arrayDate[2])-543;
301.
$(this).val(arrayDate[0]+
"-"
+arrayDate[1]+
"-"
+arrayDate[2]);
302.
}
303.
setTimeout(
function
(){
304.
$.each($(
".ui-datepicker-year option"
),
function
(j,k){
305.
var
textYear=parseInt($(
".ui-datepicker-year option"
).eq(j).val())+543;
306.
$(
".ui-datepicker-year option"
).eq(j).text(textYear);
307.
});
308.
},50);
309.
},
310.
onChangeMonthYear:
function
(){
311.
setTimeout(
function
(){
312.
$.each($(
".ui-datepicker-year option"
),
function
(j,k){
313.
var
textYear=parseInt($(
".ui-datepicker-year option"
).eq(j).val())+543;
314.
$(
".ui-datepicker-year option"
).eq(j).text(textYear);
315.
});
316.
},50);
317.
},
318.
onClose:
function
(){
319.
if
($(this).val()!=
""
&& $(this).val()==dateBefore){
320.
var
arrayDate=dateBefore.split(
"-"
);
321.
arrayDate[2]=parseInt(arrayDate[2])+543;
322.
$(this).val(arrayDate[0]+
"-"
+arrayDate[1]+
"-"
+arrayDate[2]);
323.
}
324.
},
325.
onSelect:
function
(dateText, inst){
326.
dateBefore=$(this).val();
327.
var
arrayDate=dateText.split(
"-"
);
328.
arrayDate[2]=parseInt(arrayDate[2])+543;
329.
$(this).val(arrayDate[0]+
"-"
+arrayDate[1]+
"-"
+arrayDate[2]);
330.
}
331.
332.
});
333.
334.
});
335.
</script>
336.
</body>
337.
</html>