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

/Quản lý website công ty xây dựng PHP/xaydungsonha.com/admin/shoppingCart.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 196 lines | 155 code | 41 blank | 0 comment | 9 complexity | 65ddffa79a497e4be61ecdb92f359833 MD5 | raw file
  1. <? include "check.php";?>
  2. <div style="width:96%" align="center" ><strong>QUẢN ĐƠN HÀNG:</strong></div>
  3. <?
  4. if($_POST['ItemDel']) {
  5. $action='';
  6. if($_POST['element']=='') {
  7. echo '<script>alert(\'Mời bạn chọn ít nhất 1 bản tin\')</script>';
  8. $action=true;
  9. }
  10. if($action=='') {
  11. mysql_query("DELETE FROM ".shoppingCart." WHERE id in (".implode(",",$_POST['element']).")");
  12. }
  13. }
  14. ?>
  15. <? if($_GET['view']!='') {?>
  16. <?
  17. function showCart($view) {
  18. $sqlstr = 'SELECT * FROM '.shoppingCart.' WHERE id='.intval($view).'';
  19. $resultstr =mysql_query($sqlstr);
  20. $rowstr = mysql_fetch_array($resultstr);
  21. $cart = $rowstr['masp'];
  22. if ($cart) {
  23. $items = explode(',',$cart);
  24. $contents = array();
  25. foreach ($items as $item) {
  26. $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
  27. }
  28. $output[] = '<table align="center" style="border-collapse: collapse;" width="99%" border="1" bordercolor="#bbbbbb" cellpadding="1" cellspacing="1" >';
  29. $output[] = '<tr style="background-color:#CCCCCC;font-weight:bold;height:23px">';
  30. $output[] = '<td style="padding-left:10px">Tên sản phẩm</td>';
  31. $output[] = '<td align="center">Đơn giá</td>';
  32. $output[] = '<td align="center">Số lượng</td>';
  33. $output[] = '<td align="center">Tổng</td>';
  34. $output[] = '</tr>';
  35. foreach ($contents as $id=>$qty) {
  36. if($id!='1'&&$id!='') {
  37. $sql = 'SELECT * FROM '.product.' WHERE id = '.intval($id);
  38. $result =mysql_query($sql);
  39. $row = mysql_fetch_array($result);
  40. $output[] = '<tr height=25px>';
  41. $output[] = '<td style="padding-left:10px">'.$row['title'].'</td>';
  42. $output[] = '<td align="center">'.number_format($row['price'],0,",",".").' VND</td>';
  43. $output[] = '<td align="center">'.$qty.'</td>';
  44. $output[] = '<td align="center">'.number_format(($row['price'] * $qty),0,",",".").' VND</td>';
  45. $total += ($row['price'] * $qty);
  46. $output[] = '</tr>';
  47. }
  48. }
  49. $output[] = '<tr style="background-color:#CCCCCC;font-weight:bold;height:23px">';
  50. $output[] = '<td style="padding-left:10px" colspan="4"><b>Tổng đơn giá:</b> <font color=#FF0000><strong>'.number_format($total,0,",",".").' VND</strong></font></td>';
  51. $output[] = '</tr>';
  52. $output[] = '</table>';
  53. } else {
  54. $output[] = '<p>You shopping cart is empty.</p>';
  55. }
  56. return join('',$output);
  57. }
  58. ?>
  59. <table align="center" width="750" border="0" bordercolor="#bbbbbb" cellpadding="1" cellspacing="1" >
  60. <tr >
  61. <td colspan="2" ><?php
  62. echo showCart($_GET['view']);
  63. ?>
  64. </td>
  65. <tr >
  66. <td colspan="2" height="30" >
  67. </td>
  68. </tr> </table>
  69. <?
  70. $sqlstr=mysql_query("SELECT * FROM ".shoppingCart." WHERE id=".intval($view)."" );
  71. mysql_query("UPDATE ".shoppingCart." SET status='true' WHERE id=".intval($view)."" );
  72. if(mysql_num_rows($sqlstr)>0) {
  73. $row=mysql_fetch_array($sqlstr);
  74. ?>
  75. <table style="border-collapse: collapse;" align="center" width="750" border="1" bordercolor="#bbbbbb" cellpadding="1" cellspacing="1" >
  76. <tr id="tieude">
  77. <td colspan="2" ><div align="center">Thông tin người gửi đơn hàng:</div></td>
  78. </tr>
  79. <tr>
  80. <td width="30%"><div align="right">Người gửi</div></td>
  81. <td width="70%"><?=$row['fullname']?>&nbsp;</td>
  82. </tr>
  83. <tr>
  84. <td><div align="right">Email</div></td>
  85. <td><?=$row['email']?>&nbsp;</td>
  86. </tr>
  87. <tr>
  88. <td><div align="right">Địa chỉ </div></td>
  89. <td><?=$row['address']?>&nbsp;</td>
  90. </tr>
  91. <tr>
  92. <td><div align="right">CMTND </div></td>
  93. <td><?=$row['cmtnd']?>&nbsp;</td>
  94. </tr>
  95. <tr>
  96. <td><div align="right">Điện thoại</div></td>
  97. <td><?=$row['telephone']?>&nbsp;</td>
  98. </tr>
  99. <tr>
  100. <td><div align="right">Hình thức thanh toán</div></td>
  101. <td><?=$row['bank']?>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td><div align="right">Ghi chú thêm</div></td>
  105. <td><?=$row['detail']?>&nbsp;</td>
  106. </tr>
  107. <tr>
  108. <td><div align="right">Ngày gửi</div></td>
  109. <td><?=date("d/m/Y",$row['postdate'])?>&nbsp;</td>
  110. </tr>
  111. </table>
  112. <? } }?>
  113. <br />
  114. <form method="post" action="">
  115. <table style="border-collapse: collapse;" align="center" width="750" border="1" bordercolor="#bbbbbb" cellpadding="1" cellspacing="1" >
  116. <tr id="tieude">
  117. <td width="5%" height="27" ><div align="center">#ID</div></td>
  118. <td width="61%" >Người gửi</td>
  119. <td width="17%" ><div align="center">Ngày gửi </div></td>
  120. <td width="17%" ><div align="center">Trang thái </div></td>
  121. </tr>
  122. <?
  123. $p=10;
  124. $sqlstr="SELECT * FROM ".shoppingCart."";
  125. $page=mysql_query($sqlstr);
  126. $n_record=mysql_num_rows($page);
  127. num_page();
  128. $link="index.php?menu=".$_GET['menu']."&site=".$_GET['site']."";
  129. $page=$_GET['page']?intval($_GET['page']):1;
  130. $s=($page-1)*$p;
  131. $sqlstr.=" order by ID DESC limit $s,$p";
  132. $sqlstr=mysql_query($sqlstr);
  133. if(mysql_num_rows($sqlstr)>0) {
  134. while($row=mysql_fetch_array($sqlstr)) {
  135. ?>
  136. <tr >
  137. <td width="20" height="15" align="center" bgcolor="#EEEEEE">
  138. <input type="checkbox" name="element[]" value="<?=$row['id']?>" /> </td>
  139. <td ><a href="index.php?site=<?=$_GET['site']?>&view=<?=$row['id']?>"><?=$row['fullname']?></a></td>
  140. <td width="112" style="cursor:pointer" ><div align="center"><?=date("d/m/Y",$row['postdate'])?></div></td>
  141. <td width="100" style="cursor:pointer" ><div align="center"><? echo $row['status']=='true'?'Đã xem':'Chưa xem';?></div></td>
  142. </tr>
  143. <? }
  144. }
  145. ?>
  146. <tr>
  147. <td colspan="5" align="right"><? view_page($link)?></td>
  148. </tr>
  149. <tr>
  150. <td colspan="5" >
  151. <input type="submit" onClick="return confirm('Bạn có chắc không ?');" value="Xóa đơn hàng này" name="ItemDel" ></td>
  152. </tr>
  153. </table>
  154. </form>
  155. </div>