Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.84 KB | None | 0 0
  1. <?php include 'admin.php'?>
  2.  
  3. <tr>
  4. <td height="450" colspan="2" align="left" valign="top"><br />
  5. <table width="960" border="0">
  6. <tr>
  7. <td colspan="7" align="center" valign="middle">
  8.  
  9.  
  10.  
  11. <?php
  12. if (isset($_GET['updateid']))
  13. {
  14. $id = ($_GET['updateid']);
  15. echo 'Are you sure you want to accept add product request? '.$id.' ? <a
  16. href="addproductrequest.php?yesid='.$id.'">Yes!</a> |<a href="addproductrequest.php"> No</a>!';
  17. }
  18. ?>
  19. <?php
  20. include 'connectdb2.php';
  21. if (isset($_GET['yesid']))
  22. {
  23. $trans_id = $_GET['yesid'];
  24. $status = $_GET['status'];
  25.  
  26. $query = mysql_query("SELECT * FROM `addproduct_request` WHERE 'id'='$trans_id'");
  27. while($row = mysql_fetch_assoc($query))
  28. {
  29. $db_status = $row['status'];
  30. $db_id = $row['id'];
  31. }
  32.  
  33. if($status == $db_status)
  34. {
  35. $sql=mysql_query("SELECT * FROM addproduct_request WHERE id='$trans_id'");
  36. while($row = mysql_fetch_assoc($sql))
  37. {
  38. $status=$row['status'];
  39. //dagdag
  40. $prod_category=$row['category'];
  41. $prod_title=$row['pname'];
  42. $prod_desc=$row['description'];
  43. $price=$row['price'];
  44. $stock=$row['stock'];
  45. $image_ext=$row['ext'];
  46. $name=$row['staff'];
  47. $admin = $_SESSION['username'];
  48. }
  49. //dagdag ni jed
  50. mysql_query("UPDATE `addproduct_request` SET `status` = 'Complete', `date_request` =now(), `admin` = '$admin' WHERE `addproduct_request`.`id` = '$trans_id'");
  51. //dagdag ko from addproducts
  52.  
  53. mysql_query("INSERT INTO products (`id`, `category`, `pname`, `description`, `price`, `stock`, `ext`, `date_added`) VALUES('$trans_id', '$prod_category', '$prod_title', '$prod_desc', '$price','$stock', '$image_ext', now())");
  54.  
  55. mysql_query("INSERT INTO activity (`id`, `staff`, `date_log`, `category`, `pname`, `description`, `price`, `stock`, `ext`, `admin`) VALUES ('$trans_id','$name',now(),'$prod_category','$prod_title','$prod_desc', '$price', '$stock','$image_ext','$admin')");
  56. //end code
  57. }
  58. }
  59. ?>
  60.  
  61. <?php
  62. if (isset($_GET['declineid']))
  63. {
  64. $id = ($_GET['declineid']);
  65. echo 'Are you sure you want to decline the add product request? '.$id.' ? <a
  66. href="addproductrequest.php?noid='.$id.'">Yes!</a> |<a href="addproductrequest.php"> No</a>!';
  67. }
  68. ?>
  69. <?php
  70. include 'connectdb2.php';
  71. if (isset($_GET['noid']))
  72. {
  73. $trans_id = $_GET['noid'];
  74. $status = $_GET['status'];
  75.  
  76. $query = mysql_query("SELECT * FROM `addproduct_request` WHERE 'id'='$trans_id'");
  77. while($row = mysql_fetch_assoc($query))
  78. {
  79. $db_status = $row['status'];
  80. $db_id = $_row['id'];
  81. }
  82.  
  83. if($status == $db_status)
  84. {
  85. $sql=mysql_query("SELECT * FROM addproduct_request WHERE id='$trans_id'");
  86. while($row = mysql_fetch_assoc($sql))
  87.  
  88. mysql_query("UPDATE `addproduct_request` SET `status` = 'Declined' WHERE `addproduct_request`.`id` = '$trans_id'");
  89. }
  90. }
  91. ?>
  92. <?php
  93. include 'connectdb2.php';
  94. if (isset($_GET['id']))
  95. {
  96. $targetID = $_GET['id'];
  97. $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1");
  98. $productCount = mysql_num_rows($sql); // count the output amount
  99. if ($productCount > 0)
  100. {
  101. while($row = mysql_fetch_array($sql)){
  102. $stock = $row["stock"];
  103. $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
  104. }
  105. }
  106. else
  107. {
  108. echo "<div id='error'>Invalid Id</div>";
  109. }
  110. }
  111. ?>
  112. <?php
  113. if (isset($_POST['products']))
  114. {
  115. $pid = addslashes(strip_tags($_POST['id']));
  116. $ustock = addslashes(strip_tags($_POST['ustock']));
  117. $errors = array();
  118. if ($stock)
  119. {
  120. if ($stock > 9097152)
  121. {
  122. $errors[] = "<div id='error'>Too many stocks</div>";
  123. }
  124. if (!empty($errors))
  125. {
  126. foreach ($errors as $error)
  127. {
  128. echo $error, '<br/>';
  129. }
  130. }
  131. else
  132. {
  133. // include '../inc/connectdb2.php';
  134. $totalstock = $stock + $ustock;
  135. $sql = mysql_query("UPDATE products SET
  136. stock='$totalstock'
  137. WHERE id='$pid'");
  138. }
  139. }
  140. else
  141. {
  142. echo "<div id='error'>Please fill in all fields</div>";
  143. }
  144. }
  145. ?>
  146.  
  147. </td>
  148. </tr>
  149. <table width="960" border="0" align="center" style="background: 0 0 rgba(0, 0, 0, 0.14); box-shadow: 0 3px 1px rgba(0, 0, 0, 0.02) inset, 0 1px 0 white; -moz-border-radius: 15px; border-radius: 15px;">
  150.  
  151. <?php
  152. $sql1 = mysql_query("SELECT * FROM addproduct_request");//database
  153. $addproductrequestcount = mysql_num_rows($sql1); // count the output amount
  154.  
  155. if ($addproductrequestcount > 0) {
  156. echo "<table width='960' border='0' align='center' style='background: 0 0 rgba(0, 0, 0, 0.14); box-shadow: 0 3px 1px rgba(0, 0, 0, 0.02) inset, 0 1px 0 white; -moz-border-radius: 15px; border-radius: 15px;'>";
  157. echo " <tr>
  158. <td colspan='2' align='center' valign='top'>
  159. <tr>
  160. <td width='89' align='center' valign='middle'><strong >Product ID</td>
  161. <td width='89' align='center' valign='middle'><strong >Image</td>
  162. <td width='89' align='center' align='middle'><strong >Category</td>
  163. <td width='89' align='center' valign='middle'><strong >Product Name</td>
  164. <td width='350' align='center' valign='middle'><strong >Description</td>
  165. <td width='89' align='center' valign='middle'><strong >Price</td>
  166. <td width='89' align='center' valign='middle'><strong >Stock</td>
  167. <td width='89' align='center' valign='middle'><strong >Staff Requested</td>
  168. <td width='89' align='center' valign='middle'><strong >Date Requested</td>
  169. <td width='89' align='center' valign='middle'><strong >Date Assessed by Admin</td>
  170. <td width='89' align='center' valign='middle'><strong >Assessed by</td>
  171. <td width='89' align='center' valign='middle'><strong >Status</td>
  172. <td width='89' align='center' valign='middle'><strong >Action</td>
  173.  
  174. </tr>";
  175. while($row = mysql_fetch_array($sql1)){
  176.  
  177. $userid = $row['id'];
  178. $category = $row['category'];
  179. $pname = $row['pname'];
  180. $description = $row['description'];
  181. $price = $row['price'];
  182. $stock = $row['stock'];
  183. $date_requested = $row['date_added'];
  184. $admin = $row['admin'];
  185. $date_request = $row['date_request'];
  186. $status = $row['status'];
  187. $staff = $row['staff'];
  188.  
  189. $ext = $row["ext"];
  190. $date = strftime("%b %d, %Y", strtotime($row["date_added"]));
  191. echo'<tr>
  192. <td width="89" align="center" valign="middle" >'.$userid.'</td>
  193. <td width="89" align="center" valign="middle" > <div class="image"><img src="uploads/'.$userid.'.'.$ext.'" width="100" height="100" /></a> </div></td>
  194. <td width="89" align="center" valign="middle" >'.$category.'</td>
  195. <td width="89" align="center" valign="middle" >'.$pname.'</td>
  196. <td width="89" align="center" valign="middle" >'.$description.'</td>
  197. <td width="89" align="center" valign="middle" >'.$price.'</td>
  198. <td width="89" align="center" valign="middle" >'.$stock.'</td>
  199. <td width="89" align="center" valign="middle" >'.$staff.'</td>
  200. <td width="89" align="center" valign="middle" >'.$date_requested.'</td>
  201. <td width="89" align="center" valign="middle" >'.$date_request.'</td>
  202. <td width="89" align="center" valign="middle" >'.$admin.'</td>
  203. <td width="89" align="center" valign="middle" style="color: GREEN;
  204. text-shadow: 0 1px 0 #FFFF00;
  205. font-size: 18px;
  206. font-family:serif">'.$status.'</td>
  207.  
  208. <td width="89"><a href="addproductrequest.php?updateid='.$userid.'" style="font-family: verdana;border: 1px solid #1F79AE;
  209. background-color: #1F79AE;
  210. border-radius: 4px;
  211. box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  212. -o-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  213. -webkit-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #1F79AE, 0 0 3px #8ec1da;
  214. -moz-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  215. color: darkgreen;
  216. text-shadow: 0 1px #fff;
  217. padding: 2px 5px;">Accept</a><a
  218. href="addproductrequest.php?declineid='.$userid.'" style="font-family: verdana;border: 1px solid #1F79AE;
  219. background-color: #1F79AE;
  220. border-radius: 4px;
  221. box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  222. -o-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  223. -webkit-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #1F79AE, 0 0 3px #8ec1da;
  224. -moz-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  225. color: darkgreen;
  226. text-shadow: 0 1px #fff;
  227. padding: 2px 5px;">Decline</a>
  228.  
  229. <td width="15"><a
  230. href="addproductrequestedit.php?id='.$userid.'" style="font-family: verdana;border: 1px solid #1F79AE;
  231. background-color: #1F79AE;
  232. border-radius: 4px;
  233. box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  234. -o-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  235. -webkit-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #1F79AE, 0 0 3px #8ec1da;
  236. -moz-box-shadow: inset 0 1px 3px #fff, inset 0 -15px #cbe6f2, 0 0 3px #8ec1da;
  237. color: darkgreen;
  238. text-shadow: 0 1px #fff;
  239. padding: 2px 5px;">Edit</a>
  240.  
  241.  
  242. </td></tr></tr>';
  243.  
  244. }
  245. }
  246.  
  247.  
  248. else{
  249. echo 'No Request';
  250. }
  251.  
  252. ?>
  253. </td>
  254.  
  255. </table>
  256.  
  257. </table>
  258.  
  259. </td>
  260. </tr>
  261. </table>
  262. <center>
  263. <br>
  264.  
  265. </tr>
  266. </center>
  267. </body>
  268. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement