PageRenderTime 26ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/Order.php

http://cp3046team07bj.codeplex.com
PHP | 301 lines | 262 code | 37 blank | 2 comment | 13 complexity | 977577db366660802fed474cef16a59f MD5 | raw file
  1. <?php
  2. session_start();
  3. include_once 'include/functions.php';
  4. include_once 'include/placeorder.php';
  5. require_once "cart.class.php";
  6. include('gloable.php');
  7. $cart = new cart();
  8. $cartsum=$_GET["cartsum"];
  9. $user = new User();
  10. $order = new Order();
  11. $uid = $_SESSION['uid'];
  12. if (!$user->get_session())
  13. {
  14. header("location:log in.php");
  15. }
  16. if ($_GET['q'] == 'logout')
  17. {
  18. $user->user_logout();
  19. header("location:log in.php");
  20. }
  21. if($_POST['order']) {
  22. $getarr = $cart->getItems();
  23. if(is_array($getarr)&&!empty($getarr))
  24. {
  25. $totalprice = $_POST['totalprice'];
  26. $date_time = time();
  27. $username = $_POST['name'];
  28. $address = $_POST['address'];
  29. $tel = $_POST['tel'];
  30. $remark = $_POST['remark'];
  31. $orderdate = $_POST['textfield8'];
  32. $date = $_POST['date'];
  33. $delivery = $_POST['radiobutton'];
  34. $db->insertAll('orders',"null','$uid','$username','$address','$tel','$totalprice','$date','$remark','$delivery");
  35. $sql = "select Order_id from orders order by Order_id DESC limit 0,1";
  36. $no_rows = $db->fetch_array($db->query($sql));
  37. $no_rows = $no_rows['Order_id'];
  38. foreach($getarr as $pkey=>$pval)
  39. {
  40. $shop_nums += $pval['num'];
  41. $total_price +=$pval['num']*$pval['Product_price'];
  42. if($pkey!=null)
  43. {
  44. $db->insertAll('order_detail',"null','$no_rows','".$pval['Product_name']."','".$pval['Product_images']."','".$pval['Product_infomation']."','".$pval['Product_price']."','".
  45. $pkey."','".$pval['num']."','$uid");
  46. }
  47. }
  48. unset($_SESSION['cart']);
  49. $db->Get_admin_msg("eshop.php",'add success');
  50. }
  51. }
  52. ?>
  53. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  54. <html xmlns="http://www.w3.org/1999/xhtml">
  55. <head>
  56. <link rel="stylesheet" href="feature.css" type="text/css">
  57. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  58. <title>Order</title>
  59. </head>
  60. <body>
  61. <table width="101%" border="0" height="30" bgcolor="#FFFFFF">
  62. <tr>
  63. <td width="16%">Welcome to pets family! </td>
  64. <td width="7%"><a href="Register.php" style=" color:#3366CC;">Register</a></td>
  65. <td width="6%"><a href="log in.php" style=" color:#3366CC;">Sign in </a></td>
  66. <td width="61%"><a href="?q=logout" style=" color:#3366CC;">Sign out </a></td>
  67. <td width="10%"><a href="PersonalCenter.php" style=" color:#3366CC;">Personal Center </a></td>
  68. </tr>
  69. </table>
  70. <table width="100%" border="0">
  71. <tr>
  72. <td><a href="index.php"><img src="Untitled-2_??.gif" width=100% height="250" /></a>
  73. <?php include('header.php');?></td>
  74. </tr>
  75. </table>
  76. <h1 style=" color:#3366CC;"> Hello <?php $user->get_fullname($uid); ?></h1>
  77. <p >&nbsp;</p>
  78. <p align="center">
  79. <?php if ($_SERVER["REQUEST_METHOD"] == "POST")
  80. {
  81. $store = $order->orderuser($uid,$_POST['name'],$_POST['address'], $_POST['tel'], $_POST['remark'],$cartsum,$_POST['date'],$_POST['delivery']);
  82. if ($store)
  83. {
  84. // Registration Success
  85. echo 'Order submission successful !';
  86. } else
  87. {
  88. // Registration Failed
  89. echo 'Order is failed, please try again';
  90. }
  91. } ?>
  92. </p>
  93. <p>&nbsp;</p>
  94. <h1 align="center" style=" color:#3366CC;" >Make new order </h1>
  95. <p align="center" >&nbsp;</p>
  96. <form id="form2" name="form2" method="post" action="">
  97. <table width="65%" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFCC">
  98. <tr>
  99. <th height="349" colspan="2" scope="col"><table width="300" height="30" border="1" align="left" cellpadding="1" cellspacing="0" bordercolor="#554840">
  100. <tr>
  101. <th>Consignee Information:</th>
  102. </tr>
  103. </table>
  104. <p>&nbsp;</p>
  105. <p>&nbsp;</p>
  106. <table style="border:1px solid gray;" width="65%" cellpadding="3">
  107. <tr>
  108. <td width="20%" >Name:</td>
  109. <td width="80%" ><input name="name" type="text" size="30" maxlength="50" /> </td>
  110. </tr>
  111. <tr>
  112. <td >Address:</td>
  113. <td ><input name="address" type="text" size="30" />
  114. </span></td>
  115. </tr>
  116. <tr>
  117. <td >Tel:</td>
  118. <td >
  119. <input name="tel" type="text" size="30" />
  120. </span></td>
  121. </tr>
  122. <tr>
  123. <td height="87" class="STYLE8">Remark:</td>
  124. <td><strong>
  125. <label>
  126. <textarea name="remark" cols="35" rows="3"></textarea>
  127. </label>
  128. </strong></td>
  129. </tr>
  130. </table>
  131. <p>&nbsp;</p></th>
  132. </tr>
  133. <tr>
  134. <th height="222" colspan="2" scope="col"><table width="172" border="0" align="left" cellpadding="1" cellspacing="1">
  135. <tr>
  136. <th width="179" >Date:</th>
  137. </tr>
  138. </table>
  139. <p>&nbsp;</p>
  140. <p>&nbsp;</p>
  141. <p>If you not sure, we will start after we got your money. And always finish in 3 days. </p>
  142. <table width="65%" height="142" align="center" style="border:1px solid gray;">
  143. <tr>
  144. <th width="42%" height="45" >Order date:</th>
  145. <th width="58%" > <div align="left">
  146. <?php echo date("Y-m-d",time()+8*3600); ?>
  147. </div></th>
  148. </tr>
  149. <tr>
  150. <th height="89"><p >Require date(when you want your product): </p></th>
  151. <th scope="col"><p align="left" >
  152. <label>
  153. <input name="date" type="text" size="30" />
  154. </label>
  155. </p></th>
  156. </tr>
  157. </table></th>
  158. </tr>
  159. <tr>
  160. <th height="300" colspan="2" scope="col"><table width="278" border="0" align="left" cellpadding="1" cellspacing="0">
  161. <tr>
  162. <th width="276" scope="col">List of products:</th>
  163. </tr>
  164. </table>
  165. <p>&nbsp;</p>
  166. <p align="right">Now we have 9.5 discount if you bought over 100RMB </p>
  167. <table width="85%" border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFCC">
  168. <tr>
  169. <th width="104" height="28" bordercolor="#FF6600" scope="col"><div align="center" >
  170. <div align="center">Product ID </div>
  171. </div></th>
  172. <th width="104" height="28" bordercolor="#FF6600" scope="col"><div align="center" >
  173. <div align="center">images</div>
  174. </div></th>
  175. <th width="155" bordercolor="#FF6600" scope="col"><div align="center" >Product Name </div></th>
  176. <th width="124" bordercolor="#FF6600" scope="col"><div align="center" >Price</div></th>
  177. <th width="92" bordercolor="#FF6600" scope="col">Number</th>
  178. <th bordercolor="#FF6600" scope="col">Account</th>
  179. </tr>
  180. <?php
  181. $getarr = $_SESSION['cart'];;
  182. if(is_array($getarr)&&!empty($getarr))
  183. {
  184. $shop_nums = 0;
  185. $total_price= 0;
  186. foreach($getarr as $pkey=>$pval)
  187. {
  188. if($pkey!=null)
  189. {
  190. $shop_nums += $pval['num'];
  191. $total_price +=$pval['num']*$pval['Product_price'];
  192. ?>
  193. <tr>
  194. <td height="32" bordercolor="#FF6600"><div align="center"><?php echo $pkey?>&nbsp;</div></td>
  195. <td height="32" bordercolor="#FF6600"><div align="center"><img src="<?php echo $pval['Product_images']?>" width="100" height="100"/>&nbsp;</div></td>
  196. <td bordercolor="#FF6600"><div align="center"><?php echo $pval['Product_name']?>&nbsp;</div></td>
  197. <td bordercolor="#FF6600"><div align="center"><?php echo $pval['Product_price']?>&nbsp;</div></td>
  198. <th bordercolor="#FF6600" scope="col"><?php echo $pval['num']?>&nbsp;</th>
  199. <th bordercolor="#FF6600" scope="col"><?php echo $pval['Product_price']*$pval['num']?>&nbsp;</th>
  200. </tr>
  201. <?php
  202. }
  203. }
  204. }
  205. ?>
  206. <tr>
  207. <td height="32" colspan="4" bordercolor="#FF6600"></td>
  208. <td width="100" bordercolor="#FF6600" >&nbsp;</td>
  209. <input type="hidden" value="<?php echo $total_price;?>" name="totalprice">
  210. <td width="133" bordercolor="#FF6600"><div align="center">Total:<?php if($total_price >100) echo $total_price*0.95; else echo $total_price;?></div></td>
  211. </tr>
  212. </table></th>
  213. </tr>
  214. <tr>
  215. <th height="538" colspan="2" scope="col"><table width="310" border="0" align="left">
  216. <tr>
  217. <td width="304"><div align="center" >
  218. <div align="center"><span leftzone="0|9" rightzone="0|9" space="space">Payment and</span><span leftzone="9|12" rightzone="9|12" space="0| "> delivery:</span></div></td>
  219. </tr>
  220. </table>
  221. <p align="left" >&nbsp;</p>
  222. <p align="left" >&nbsp;</p>
  223. <p align="left" >In order to makesure products you already bought will not be making in time. Please pay 50% of totel money by remittance. You can see the Account Number in <a href="contactus.php" style=" color:#CC0033">contact us</a>.</p>
  224. <p align="left" >&nbsp;</p>
  225. <table width="85%" border="0" align="center"style="border:1px solid gray;">
  226. <tr>
  227. <td width="46%">
  228. <input type="radio" name="radiobutton" value="Get it by yourself" />
  229. Get it by yourself </td>
  230. <td width="54%" height="66" >
  231. You can pay remain money to us, see our address in <a href="contactus.php" style=" color:#CC0033">contact us</a> page. Please call us before you come. </td>
  232. </tr>
  233. <tr>
  234. <td class="STYLE8"><label>
  235. <input type="radio" name="radiobutton" value="Delivery company" />
  236. Delivery company
  237. </label></td>
  238. <td height="63" >
  239. We will help you call delivery company, you can pay the remain money to deliver. </td>
  240. </tr>
  241. </table>
  242. <p align="left" >&nbsp;</p>
  243. <p align="left" >&nbsp;</p>
  244. <p align="left" >&nbsp;</p>
  245. <h1 align="center" style=" color:#CC0033">We will make your products as soon as possible!</h1> </th>
  246. </tr>
  247. <tr>
  248. <th width="392" scope="col"> <input name="order" type="submit" value="Place the order!" /></th>
  249. <th width="459" scope="col"><input name="Submit" type="reset" value="Reset" /></th>
  250. </tr>
  251. </table>
  252. </form>
  253. <p>&nbsp;</p>
  254. <p>&nbsp;</p>
  255. <table width="95%" border="0" align="center" >
  256. <tr>
  257. <td width="53%" ><div align="right">Copyright 2011 Pets Family </div></td>
  258. <td width="16%" ><div align="center"><a href="sitemap.php" style=" color:#3366CC;">SITE MAP</a></div></td>
  259. <td width="31%" >e-mail: <a href="mailto:petsfamily@gmail.com" style=" color:#3366CC;">petsfamily@gmail.com</a></td>
  260. </tr>
  261. </table>
  262. <p>&nbsp;</p>
  263. </body>
  264. </html>