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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
<?php $rowPerPage=20; if((!$_GET['page'])||($_GET['page']==1)){ $_GET['page']=1; $startRow=0; }else{ $startRow=($_GET['page']-1)*$rowPerPage; } #################################################### //--------------------------------------------------------- $monthArray = array("01"=>"มกราคม","02"=>"กุมภาพันธ์","03"=>"มีนาคม","04"=>"เมษายน", "05"=>"พฤษภาคม","06"=>"มิถุนายน","07"=>"กรกฏาคม","08"=>"สิงหาคม","09"=>"กันยายน","10"=>"ตุลาคม","11"=>"พฤศจิกายน","12"=>"ธันวาคม"); $currentDate=date("d"); $currentMonth= date("m"); $currentMonthname= date("m"); $currentYear= date("Y"); //------------------------------------------------------------------------ if($_GET['currentID']){ $_POST['currentID']=$_GET['currentID']; } if($_GET['currentTypeID']){ $_POST['currentTypeID']=$_GET['currentTypeID']; } //-----------------------------Date------------------------------------ setlocale (LC_TIME, 'th'); if(!$sdate) { $sdate= strftime("%Y-%m-%d"); }else{ $sdate=$sdate; } $time=strftime("%H:%M:%S"); $time_sec=explode(":",$time); $time_array = explode(":",$time); ########################################################################## //echo $_POST['action']." >> ".$_POST['toSort']; if($_POST['action']=='Sort') { switch($_POST['toSort']) { case "up" : $numberUpDate=$_POST['number']-1; $query="UPDATE IGNORE tbl_banner SET num = num+1 WHERE num='".$numberUpDate."' "; // echo $query."<br>"; mysql_query($query); $query="UPDATE IGNORE tbl_banner SET num = num-1 WHERE id='".$_POST['EditID']."' "; mysql_query($query); // echo $query."<br>"; break; case "down" : $numberUpDate=$_POST['number']+1; $query="UPDATE IGNORE tbl_banner SET num =num-1 WHERE num='".$numberUpDate."' "; //echo $query."<br>"; mysql_query($query); $query="UPDATE IGNORE tbl_banner SET num =num+1 WHERE id='".$_POST['EditID']."' "; mysql_query($query); //echo $query."<br>"; break; } }//end Sort
####################################################- //---------------------------UPDATE STATUS------------------- if($_POST['action']=='updateStatus'){ $_POST['date_start']=date("Y-m-d"); $query="UPDATE IGNORE tbl_banner SET banner_status ='".$_POST['first_page'][$_POST['EditID']]."' WHERE id= '".$_POST['EditID']."' "; mysql_query($query); } ####################################################-DELETE IMAGEs FILE //--------------------------------------------------------------------- if($_POST['action2']=='DeleteBanner'){ if(file_exists($path_product_thb.$_POST['RemoveFile'])){ @unlink ($path_product_thb.$_POST['RemoveFile']); } if(file_exists($path_product."/".$_POST['RmPic'])){ @unlink ($path_product."/".$_POST['RmPic']); } $query = "DELETE IGNORE FROM tbl_banner WHERE id = '".$_POST['dataID']."' "; if( mysql_query($query)){ //-------------resort-----------------------------------------number $query="UPDATE tbl_banner SET num=num-1 WHERE num > '".$_POST['number']."' "; mysql_query($query); ?> <script language="javascript"> window.location.href='main.php?work=<?php echo $_GET['work']?>&type=<?php echo $_GET['type']?>&MenuID=<?php echo $_GET['MenuID']?>'; </script> <?php } } ######################### PROJECT PLAN IMAGE############################ if($_POST['action']=='Add'){ if($_POST['currentID']==''){ $query="SELECT MAX(num) Maxnum FROM tbl_banner "; $result=mysql_query($query); $max=mysql_fetch_assoc($result); $maxNum=$max['Maxnum']+1; if($_FILES['uploadfile']['name']!=""){ $tempFileName = $_FILES['uploadfile']['name']; GetNewFileName($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name'],$i); move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path_product.$_FILES['uploadfile']['name']); $query="INSERT T IGNORE INTO `tbl_banner` ( `id` ,`pic_name` ,`banner_type` ,`oldFilename` ,`title_img` ,`title_img2` " ." ,`links` ,`banner_desc` ,`banner_status` ,`num`) " ." VALUES ('', '".$_FILES['uploadfile']['name']."' , '".$_GET['type']."' , '".$tempFileName."', '".$_POST['title_img']."', '".$_POST['title_img2']."', '".$_POST['links']."', '', '".$_POST['banner_status']."' , '".$maxNum."') "; mysql_query($query); } }else{ if($_FILES['uploadfile']['name']!=""){ $tempFileName = $_FILES['uploadfile']['name']; GetNewFileName($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name'],$i); move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path_product.$_FILES['uploadfile']['name']); @unlink($path_product.$_POST['OldChkPic']); @unlink($path_product_thb.$_POST['OldChkPic']); }else{ $_FILES['uploadfile']['name']=$_POST['OldChkPic']; } $query="UPDATE IGNORE `tbl_banner` SET `pic_name`= '".$_FILES['uploadfile']['name']."' ,`banner_type`='".$_GET['type']."' ,`oldFilename`= '".$tempFileName."' ,`title_img`='".$_POST['title_img']."' ,`title_img2` ='".$_POST['title_img2']."' " ." ,`links` = '".$_POST['links']."' ,`banner_desc`='' ,`banner_status`='".$_POST['banner_status']."' " ." WHERE id = '".$_POST['currentID']."' "; if(mysql_query($query)){ ?> <script language="javascript"> window.location.href='main.php?work=<?php echo $_GET['work']?>&type=<?php echo $_GET['type']?>&MenuID=<?php echo $_GET['MenuID']?>'; </script> <?php } } } ####################################################-SELECTD DATA $query="SELECT * FROM tbl_banner WHERE banner_type ='".$_GET['type']."' ORDER BY num ASC"; $resultBanner=mysql_query($query); $Xrow =mysql_num_rows($resultBanner); if($_GET['currentID']){ $query="SELECT * FROM tbl_banner WHERE id ='".$_GET['currentID']."' "; $result=mysql_query($query); $currentData=mysql_fetch_assoc($result); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script language="javascript"> //-------------------------------- function FormValid(){ document.form1.action.value = 'Add'; } //----------------------------------------------- function GetSubCate(MainCateID, SubCate){ var str=Math.random(); var isNS4 = (navigator.appName=="Netscape")?1:0; var mydata='MainCateID='+MainCateID+'&SubCate='+SubCate+'&str='+str; ajax = new sack('getSubCate.php'); ajax.element ="showSubCate"; ajax.runAJAX(mydata) } //------------------------------------------------- function removePic(pic, pictype){ if(confirm('ต้องการลบรุปนี้')){ document.form1.RmPic.value=pic; document.form1.action2.value=pictype; document.form1.submit(); }else{ return false; } } //------------------------------------------------- function removeDoc(pic){ if(confirm('ต้องการลบไฟล์นี้')){ document.form1.RmPic.value=pic; document.form1.action2.value='deleteDoc'; document.form1.submit(); }else{ return false; } } //---------------------------------------- function DeleteThis(ids,filename,ids){ if(confirm('ต้องการลบรายการนี้ ?')){ document.form2.action2.value='DeleteBanner'; document.form2.dataID.value=ids; document.form2.RemoveFile.value=filename; document.form2.number.value=ids; document.form2.submit(); }else{ return false; } } //--------------------- function sortThis(number, toSort , ids , subcateID ){ document.form1.number.value=number; document.form1.toSort.value=toSort; document.form1.EditID.value=ids; document.form1.subcateID.value=subcateID; document.form1.action.value='Sort'; document.form1.submit(); } //-------------------------------------------------- function DeleteThis2(ids){ if(confirm('ตอ้งการลบรายการนี้')){ document.form1.action.value = 'delete'; document.form1.ids.value = ids; document.form1.submit(); } } </script> </head>
<body><form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" onSubmit="return FormValid();" enctype="multipart/form-data"> <table width="99%" border="0" align="center" cellpadding="2" cellspacing="2"> <tr class="red"> <td width="4%" height="25" align="center" bgcolor="#D9D9B3"><img src="images/black_icon/16x16/app_window.png" width="16" height="16" /></td> <td width="96%" bgcolor="#D9D9B3">เพิม / แก้ไข banner
</td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" class="txt10-black"><table width="100%" border="0" cellspacing="3" cellpadding="3"> <tr> <td width="22%" height="-2" align="right"><span class="txt10-black">ไฟล์ banner</span></td> <td width="78%" align="left" class="txt-8-red"> <span class="txt10-black"> <?php if($_GET['currentID']){ ?> <img src="<?php echo $path_product_thb.$currentData['pic_name']?>" alt="" border ="0" /> <br /> <?php }?> <input name="uploadfile" type="file" id="uploadfile" size="20" /> </span></td> </tr> <?php if($_GET['type']==1){?> <!--<tr> <td height="-3" align="right">word 1</td> <td width="78%" align="left" class="txt-8-red"><input name="title_img" type="text" id="title_img" value="<?php echo $currentData['title_img']?>" size="50" /></td> </tr> <tr> <td height="-2" align="right">word 2</td> <td width="78%" align="left" class="txt-8-red"><label for="title_img2"></label> <input name="title_img2" type="text" id="title_img2" value="<?php echo $currentData['title_img2']?>" size="50" /></td> </tr> --> <?php }?> <tr> <td height="-2" align="right"><span class="txt10-black">link</span></td> <td width="78%" align="left" class="txt-8-red"><span class="txt10-black"> <input name="links" type="text" id="links" size="50" maxlength="100" value="<?php echo $currentData['links']?>" /> **ใส่ http://</span></td> </tr> <tr> <td height="-2" align="right"><span class="txt10-black">แสดงผล</span></td> <td width="78%" align="left" class="h1"><span class="txt10-black"> <select name="banner_status" id="first_page"> <option value="1" <?php if($currentData['banner_status']=='1') echo "selected";?>>แสดงทันที</option> <option value="0" <?php if($currentData['banner_status']=='0') echo "selected";?>>ไม่แสดง</option> </select> </span></td> </tr> <tr> <td height="25" align="right"><span class="txt10-black"> <input type="hidden" name="OldChkPic" value="<?php echo $currentData['pic_name']?>" /> <input type="hidden" name="action" id="action" value="Add" /> <input type="hidden" name="currentID" id="currentID" value="<?php echo $_GET['currentID']?>" /> <input type="hidden" name="banner_type" value="<?php echo $_POST['type']?>" /> <input type="hidden" name="ids" id="ids" /> <input type="hidden" name="number" /> <input type="hidden" name="toSort" /> <input type="hidden" name="EditID" /> <input type="hidden" name="subcateID" /> </span></td> <td height="25" align="left"> <span class="red"> <input name="Button2" type="submit" value=" เพิ่ม/แก้ไข banner " /> <br /> รูปภาพสูงไม่เกิน 122 pixel (รองรับไฟล์ .jpg .gif .png );<br /> </span></td> </tr> <tr> <td height="25" colspan="2" align="left"><span class="txt10-black"><br /> </span></td> </tr> <tr> <td height="25" colspan="2" align="left" bgcolor="#EEEEEE"><span class="txt10-black"><img src="images/black_icon/16x16/picture.png" alt="" width="16" height="16" hspace="3" vspace="3" align="absmiddle" />Banner List</span></td> </tr> <tr> <td height="25" colspan="2" align="left"><table width="100%" border="0"> <?php while($pic=mysql_fetch_assoc($resultBanner)){ $n_width=300;$n_height=110; $info = pathinfo($path_product."/".$pic['pic_name']); $info[extension]=strtolower($info[extension]); if(($info[extension]=='pjpeg') || ($info[extension]=='gif') || ($info[extension]=='png') || ($info[extension]=='x-png') || ($info[extension]=='jpeg') || ($info[extension]=='jpg')){ // if(!file_exists($path_product_thb.$pic['pic_name'])){ list($width, $height, $type, $attr) = getimagesize($path_product.$pic['pic_name']); create_thub($path_product."/",$pic['pic_name'],$n_width,$n_height); // } } ?> <tr> <td width="8%" bgcolor="#EFEFDE"><span class="txt10-black"> <a href="<?php echo $path_product.$pic['pic_name']?>" target="_blank"><?php echo "<img src='".$path_product_thb.$pic['pic_name']."' border =0>";?></a></span></td> <td bgcolor="#EFEFDE"><span class="txt10-black"> <?php echo $pic['links']?></span></td> <td width="3%" bgcolor="#EFEFDE"><span class="txt10-black"> <?php if($pic['num']>1){?> <a href="javascript:void(0)" onClick="sortThis('<?php echo $pic['num'];?>', 'up' , '<?php echo $pic['id'];?>','<?php echo $pic['mainCateId'];?>' )"> <img src="images/black_icon/16x16/sq_br_up.png" alt="" width="16" height="16" border="0" /></a> <?php } ?> </span></td> <td width="3%" bgcolor="#EFEFDE"><span class="txt10-black"> <?php if($Xrow > $pic['num']){?> <a href="javascript:void(0)" onClick="sortThis('<?php echo $pic['num'];?>', 'down' , '<?php echo $pic['id'];?>','<?php echo $pic['mainCateId'];?>' )"> <img src="images/black_icon/16x16/sq_br_down.png" alt="" width="16" height="16" border="0" /></a> <?php } ?> </span></td> <td width="13%" align="center" bgcolor="#EFEFDE"><span class="txt10-black"> <select name="first_page[<?php echo $pic['id']?>]" onchange="document.form1.action.value='updateStatus';document.form1.EditID.value='<?php echo $pic['id']?>';document.form1.submit();"> <option value="1" <?php if($pic['banner_status']=='1') echo "selected";?>>แสดงทันที</option> <option value="0" <?php if($pic['banner_status']=='0') echo "selected";?>>ไม่แสดง</option> </select> </span></td> <td width="3%" align="center" bgcolor="#EFEFDE"><span class="txt10-black"><a href="main.php?work=<?php echo $_GET['work']?>&type=<?php echo $_GET['type']?>&MenuID=<?php echo $_GET['MenuID']?>&currentID=<?php echo $pic['id']?>" title="แก้ไข banner"> <img src="images/black_icon/16x16/doc_edit.png" alt="" width="16" height="16" border="0" /></a></span></td> <td width="5%" align="center" bgcolor="#EFEFDE"><span class="txt10-black"><a href="javascript:void(0)" onClick="DeleteThis('<?php echo $pic['id']?>','<?php echo $pic['pic_name']?>','<?php echo $pic['num']?>')" title="ลบ รายการนี้"><img src="images/black_icon/16x16/delete.png" alt="" width="16" height="16" border="0" /></a></span></td> </tr> <?php } ?> </table></td> </tr> <tr> <td height="25" colspan="2" align="left"> </td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> <form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form2" id="form2"> <input type="hidden" name="action2" /> <input type="hidden" name="RemoveFile" /> <input type="hidden" name="dataID" /> <input type="hidden" name="number" /> </form> </body> </html>
|