PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Quản lý website bán áo đồng phục PHP/lamao/admins/modules/viewtbl.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 424 lines | 390 code | 12 blank | 22 comment | 34 complexity | 5424a3ce5867ee8b6a411b8785b0523a MD5 | raw file
  1. <form name="goback" method="get" action="">
  2. <input type="hidden" name="module" value="categories">
  3. <input type="hidden" name="tblname" value="">
  4. </form>
  5. <script language="JavaScript">
  6. function takeback(name)
  7. {
  8. document.goback.tblname.value=name;
  9. document.goback.submit();
  10. }
  11. </script>
  12. <form name="img_mng" method="get" action="img_mng.php">
  13. <input type="hidden" name="tblname" value="">
  14. <input type="hidden" name="id" value="">
  15. <input type="hidden" name="catname" value="">
  16. <input type="hidden" name="catID" value="">
  17. </form>
  18. <form name="viewnedit" method="get" action="">
  19. <input type="hidden" name="module" value="viewrec">
  20. <input type="hidden" name="tblname" value="">
  21. <input type="hidden" name="catID" value="">
  22. <input type="hidden" name="catname" value="">
  23. <input type="hidden" name="id" value="">
  24. <input type="hidden" name="seriid" value="">
  25. </form>
  26. <form name="del" method="get" action="">
  27. <input type="hidden" name="module" value="delete">
  28. <input type="hidden" name="tblname" value="">
  29. </form>
  30. <script language="JavaScript">
  31. function img_mng(tblname,id,cname,cid)
  32. {
  33. document.img_mng.tblname.value=tblname;
  34. document.img_mng.id.value=id;
  35. document.img_mng.catname.value=cname;
  36. document.img_mng.catID.value=cid;
  37. document.img_mng.submit();
  38. }
  39. function view(tblname,id,cname,cid,seriid)
  40. {
  41. document.viewnedit.tblname.value=tblname
  42. document.viewnedit.id.value=id
  43. document.viewnedit.catID.value=cid
  44. document.viewnedit.catname.value=cname
  45. document.viewnedit.seriid.value=seriid
  46. document.viewnedit.submit()
  47. }
  48. function dodelete()
  49. {
  50. var isvalid=false
  51. for (var counter=0; counter < data_table.length; counter++)
  52. {
  53. if (data_table.elements[counter].checked == true)
  54. {
  55. isvalid=true;
  56. }
  57. }
  58. if (isvalid==true)
  59. {
  60. if (confirm('<?php echo $strDelete; ?> ?!!'))
  61. {
  62. if (confirm("<?php echo $strConfirm.' '.$strAgain; ?> !!!"))
  63. {
  64. document.data_table.submit();
  65. }
  66. }
  67. }
  68. else
  69. alert('Bạn phải chọn ít nhất một thông tin')
  70. }
  71. </script>
  72. <table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/tablebg.gif">
  73. <tr>
  74. <td align="center" valign="middle" colspan="3">
  75. <table width="100%" height="30" border="0" cellpadding="2" cellspacing="2">
  76. <tr>
  77. <td bgcolor="#E1E1E1">&nbsp;</td>
  78. <!--
  79. <td width="90" onClick="javascript: document.data_table.submit();" style="cursor: hand; border: 1px solid #E1E1E1" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  80. <p class="buttontext"><img align="absmiddle" src="images/mail.gif" width="22" height="22">
  81. &nbsp;&nbsp;G&#7917;i Email</p>
  82. </td>-->
  83. <?php
  84. if (isset($_SESSION['userID']))
  85. {
  86. $allow_edit=true;
  87. ?>
  88. <td width="100" onClick="window.history.go(-1)" style="cursor: hand; border: 1px solid #E1E1E1" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  89. <p class="buttontext"><img align="absmiddle" src="images/previous.gif" width="24" height="24">&nbsp;&nbsp;<?php echo $strBack; ?></p>
  90. </td>
  91. <td width="90" onClick="document.addnew.submit();" style="cursor: hand; border: 1px solid #E1E1E1" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  92. <p class="buttontext"><img align="absmiddle" src="images/filenew.gif" width="22" height="22">&nbsp;&nbsp;<?php echo $strAdd; ?></p>
  93. </td>
  94. <!--
  95. <td width="150" onClick="setdisplay('edit_list','change');" style="cursor: hand; border: 1px solid #E1E1E1" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  96. <p class="buttontext"><img align="absmiddle" src="images/move_user.gif" width="22" height="22">
  97. &nbsp;&nbsp;<?php echo $strChangeCat; ?></p>
  98. </td>-->
  99. <td width="100" style="cursor: hand; border: 1px solid #E1E1E1" onClick="dodelete('data_table')" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  100. <p class="buttontext"><img align="absmiddle" src="images/cancel.gif" width="22" height="22">&nbsp;&nbsp;<?php echo $strDelete; ?></p>
  101. </td>
  102. <?php
  103. }
  104. else
  105. {
  106. ?>
  107. <td width="400" style="cursor: hand; border: 1px solid #E1E1E1" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  108. <p class="buttontext">&nbsp;&nbsp;<?php echo $strNotice['208']; ?></p>
  109. </td>
  110. <?php
  111. }
  112. ?>
  113. <td bgcolor="#E1E1E1">&nbsp;</td>
  114. </tr>
  115. </table>
  116. </td>
  117. </tr>
  118. <tr><td height="40">
  119. <p class="bigtitle" style="text-align: left; margin: 0 0 0 36;">
  120. <img src="images/bs_forward.gif" width="16" height="16" align="absmiddle">
  121. <?php
  122. if (isset($_REQUEST['catname']) and $_REQUEST['catname']!='')
  123. echo $_REQUEST['catname'];
  124. else
  125. echo $_REQUEST['tblname'];
  126. ?></p>
  127. </td></tr>
  128. <tr align="center" valign="top">
  129. <td colspan="3" align="center" valign="top">
  130. <?php
  131. $havedata=false;
  132. if (!isset($_REQUEST['tblname']))
  133. {
  134. echo '<tr><td>';
  135. echo '<p class="bigtitle">No selected table !</p>';
  136. echo '</td></tr>';
  137. }
  138. else
  139. {
  140. $tblname=$_REQUEST['tblname'];
  141. //echo $tblname;
  142. // Khai bao thong tin ve bang
  143. //Thong tin ve cac cot cua bang
  144. @$open_file=fopen($db_dir.$tblname.'.'.$db_fileex,'r',1);
  145. if (!$open_file)
  146. {
  147. echo '<tr><td><p>';
  148. echo 'Can not retrieve Table field !';
  149. echo '</td></tr></p>';
  150. }
  151. else
  152. {
  153. //Khoi tao
  154. $start=0;
  155. $real_colum=1;
  156. $line=0;
  157. $title_array=array();
  158. $field_array=array();
  159. //Doc noi dung tung dong
  160. while($cur_line=fgets($open_file))
  161. {
  162. $line+=1;
  163. //echo $line;
  164. //Neu gap dong trong
  165. if (strlen($cur_line)==2)
  166. {
  167. $start=1;
  168. $start_line=$line+1;
  169. //echo $start_line;
  170. $index=$real_colum;
  171. $dimension=0;
  172. }
  173. //Bat dau lay DL
  174. if ($start==1 && $line>=$start_line)
  175. {
  176. $line_array=explode('-',$cur_line);
  177. $title_array[$index]=$line_array[0];
  178. $dimension+=round(strlen(trim($title_array[$index]))*12,0);
  179. $field_array[$index]=$line_array[1];
  180. //echo $field_array[$index];
  181. $index+=1;
  182. $havedata=true;
  183. }
  184. }
  185. }
  186. $title_array[0]='<input name="cbxSelectAll" style="display: ; margin: 0;" type="checkbox" onclick="javascript: checkAll(this.form);">';
  187. $field_array[0]='id';
  188. // So dong hien thi
  189. $max=100;
  190. //So cot hien thi
  191. $colum=5;
  192. //Kich thuoc chung cho moi cot
  193. //$dimension=100;
  194. $bordercolor='#336699';
  195. $titlecolor='#FFCC33';
  196. $hightlightcolor='#EEEEEE';
  197. $div_height=400;
  198. //show_datatbl($list,'datatbl','','dataTable',$title_array,$dimension,$field_array);
  199. ?>
  200. <!-- Data Table -->
  201. <DIV style="WIDTH: 900px; HEIGHT: <?php echo $div_height;?>px; OVERFLOW: auto; border: solid 1px <?php echo $bordercolor; ?>">
  202. <form name='addnew' method="get" action="">
  203. <input type="hidden" name="module" value="addnew">
  204. <input type="hidden" name="tblname" value="<?php echo $tblname; ?>">
  205. <?php
  206. if (isset($_REQUEST['catID']))
  207. {
  208. ?>
  209. <input type="hidden" name="catID" value="<?php echo $_REQUEST['catID']; ?>">
  210. <?php
  211. }
  212. if (isset($_REQUEST['catname']))
  213. {
  214. ?>
  215. <input type="hidden" name="catname" value="<?php echo $_REQUEST['catname']; ?>">
  216. <?php
  217. }
  218. ?>
  219. </form>
  220. <form name="data_table" method="post" action="">
  221. <input type="hidden" name="module" value="delete">
  222. <TABLE id="dataTable" cellSpacing="1" cellPadding="0" border="0" width="1200">
  223. <TR bgcolor="<?php echo $titlecolor; ?>">
  224. <?php
  225. $i=0;
  226. while (isset($title_array[$i]))
  227. {
  228. echo '<td ';
  229. //echo 'width="" ';
  230. //echo $dimension;
  231. echo 'class="tdtitle">';
  232. echo $title_array[$i];
  233. echo '</td>';
  234. $i++;
  235. }
  236. ?>
  237. </TR>
  238. <?php
  239. //Thong tin Browse
  240. if (isset($_POST['found']))
  241. $found=$_POST['found'];
  242. if (isset($_POST['totalpage']))
  243. $totalpage=$_POST['totalpage'];
  244. if (isset($_POST['curpage']))
  245. {
  246. $curpage=$_POST['curpage'];
  247. $from=($curpage-1)*$max;
  248. $to=$from+$max;
  249. $range=' limit '.$from.','.$to;
  250. }
  251. else
  252. $curpage=1;
  253. $list='select * from '.$tblname.' where';
  254. if (isset($_REQUEST['catID']) and $_REQUEST['catID']!='')
  255. $list.=' category="'.$_REQUEST['catID'].'" and';
  256. $list.=' lang="'.get_langID().'"';
  257. $list.=' order by id ASC';
  258. if (isset($range))
  259. $list.=$range;
  260. //echo $list;
  261. $doview=mysql_query($list,$link);
  262. //$doview=mysql_query($view,$link);
  263. $counter=1;
  264. if ($doview and mysql_num_rows($doview)>0)
  265. {
  266. $return_rows=mysql_num_rows($doview);
  267. //for ($i=0; $i<30000; $i++)
  268. while ($result=mysql_fetch_array($doview))
  269. {
  270. //$result=mysql_fetch_array($doview);
  271. $x=0;
  272. while (isset($field_array[$x]))
  273. {
  274. $$field_array[$x]=stripslashes(strip_tags(chop($result[$field_array[$x]])));
  275. $x++;
  276. }
  277. ?>
  278. <TR id="dataRow<?php echo $id; ?>" onMouseOver="change(this,'<?php echo $hightlightcolor; ?>')" onMouseOut="undo(this)" style="cursor: hand">
  279. <TD TF_colKey="check" align="center" class="tdtext">
  280. <input type="checkbox" name="chkbox<?php echo $counter; ?>" value="<?php echo $id; ?>" onClick="javascript:colorRow(this);">
  281. </TD>
  282. <?php
  283. $j=$real_colum;
  284. while (isset($field_array[$j]))
  285. {
  286. $$field_array[$j]=get($$field_array[$j],20);
  287. echo '<TD width="';
  288. if ( strlen($title_array[$j]) < strlen($$field_array[$j]) )
  289. echo (strlen($$field_array[$j])*15);
  290. else
  291. echo (strlen($title_array[$j])*15);
  292. echo '" TF_colKey="'.$field_array[$j].'" class="tdtext" onClick="javascript: view(\''.$tblname.'\','.$result[0].'';
  293. if (isset($_REQUEST['catname']))
  294. echo ',\''.$_REQUEST['catname'].'\'';
  295. else
  296. echo ",''";
  297. if (isset($_REQUEST['catID']))
  298. echo ',\''.$_REQUEST['catID'].'\'';
  299. else
  300. echo ",''";
  301. if (isset($result['manufacturer']))
  302. {
  303. $seriid=$result['manufacturer'];
  304. echo ',\''.$seriid.'\'';
  305. }
  306. else
  307. echo ",''";
  308. echo ');">';
  309. echo $$field_array[$j];
  310. echo '</TD>';
  311. $j++;
  312. }
  313. ?>
  314. </TR>
  315. <?php
  316. $counter++;
  317. }
  318. }
  319. ?>
  320. </TABLE>
  321. <input type="hidden" name="tblname" value="<?php echo $tblname; ?>">
  322. <?php
  323. if (isset($_REQUEST['catname']))
  324. echo '<input type="hidden" name="catname" value="'.$_REQUEST['catname'].'">';
  325. if (isset($_REQUEST['catname']))
  326. echo '<input type="hidden" name="catID" value="'.$_REQUEST['catID'].'">';
  327. ?>
  328. <input type="hidden" name="total_rows" value="<?php echo $return_rows; ?>">
  329. </form>
  330. </DIV>
  331. <!-- End Data Table -->
  332. <?php
  333. }
  334. ?>
  335. </td>
  336. </tr>
  337. <tr align="center" valign="top">
  338. <td colspan="3" bordercolor="#FF3300" style="border-bottom-style: solid; border-bottom-width: 2">
  339. <!-- Filter -->
  340. <table width="100%" cellpadding="0" cellspacing="0" align="center">
  341. <tr>
  342. <td align="center" valign="middle">
  343. <table width="100%" height="30" border="0" cellpadding="2" cellspacing="2">
  344. <tr>
  345. <td bgcolor="#E1E1E1">&nbsp;</td>
  346. <td width="200" style="border: 1px solid #E1E1E1">
  347. <p class="buttontext">
  348. <INPUT onclick="TF_enableFilter(dataTable, filter, this)" type="checkbox">
  349. &nbsp;&nbsp;Enable / Disable Filter</p></td>
  350. <td width="80" onclick="filter.reset()" style="cursor: hand; border: 1px solid #E1E1E1" onMouseOver="changebd(this,'#336699')" onMouseOut="undobd(this)">
  351. <p class="buttontext"><img align="absmiddle" src="images/reset.gif" width="22" height="22">
  352. &nbsp;&nbsp;Reset</p></td>
  353. <td bgcolor="#E1E1E1">&nbsp;</td>
  354. </tr>
  355. </table>
  356. </td>
  357. </tr>
  358. <tr>
  359. <td align="center" valign="top">
  360. <form name="filter" onsubmit="TF_filterTable(dataTable, filter);return false" onreset="_TF_showAll(dataTable)" style="display: none">
  361. <DIV style="WIDTH: 650px; HEIGHT: 80; OVERFLOW: auto; border: solid 1px #336699; display: block">
  362. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  363. <?php
  364. if ($havedata==true)
  365. {
  366. $itemonrow=4;
  367. $width=100/$itemonrow;
  368. $counter=$itemonrow;
  369. $i=1;
  370. echo '<tr>';
  371. while (isset($field_array[$i]))
  372. {
  373. if ($counter==$itemonrow)
  374. {
  375. echo '</tr><tr>';
  376. $counter=0;
  377. }
  378. ?>
  379. <td onMouseOver="change(this,'#EEEEEE')" onMouseOut="undo(this)">
  380. <p class="formtitle"><?php echo $title_array[$i]; ?></p>
  381. <p class="formindex"><?php echo $strAll; ?>
  382. <input type="text" onkeyup="TF_filterTable(dataTable, filter)" name="s<?php echo $field_array[$i]; ?>" TF_colKey="<?php echo $field_array[$i]; ?>" TF_searchType="substring1" class="shortinput">
  383. <br><?php echo $strHavein; ?>
  384. <input type="text" onkeyup="TF_filterTable(dataTable, filter)" name="s<?php echo $field_array[$i]; ?>" TF_colKey="<?php echo $field_array[$i]; ?>" TF_searchType="substring" class="shortinput"></p>
  385. </td>
  386. <?php
  387. $counter++;
  388. $i++;
  389. }
  390. ?>
  391. </table>
  392. </div>
  393. </form>
  394. </td>
  395. </tr>
  396. <?php
  397. }
  398. else
  399. {
  400. echo '<tr>';
  401. echo '<td align="center" valign="top">';
  402. echo '<br><br>';
  403. echo '<p class="bigtitle">M&#7901;i ch&#7885;n nhm c&#7847;n xem b&#7857;ng cch ch&#7885;n m&#7897;t nhm trong s&#7889; CC NHM HI&#7878;N C v click XEM !</p>';
  404. echo '</td>';
  405. echo '</tr>';
  406. }
  407. ?>
  408. </table>
  409. </td>
  410. </tr>
  411. <!-- End of Filter -->
  412. </table>