Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. admn_product.php
  2. __________________
  3. <?
  4. if($user_home->is_admin() || $user_home->is_auditor){
  5.  
  6.  
  7.  
  8.  
  9. ?>
  10. <div class="row">
  11. <div class="col-lg-8 col-lg-offset-2">
  12. <h2 class="section-heading">Add Product</h2>
  13. <div class="text-center" style="input, select, textarea{
  14. color: #000;
  15. }">
  16.  
  17.  
  18. </div><BR>
  19.  
  20. <form role="form" class="userTrans" method="POST">
  21. <input type="hidden" value="iteminsert" name="act_userTrans">
  22.  
  23.  
  24. <div class="form-group">
  25. <label for="text">Item Name</label>
  26. <input type="text" class="form-control" id="itemInsert" name="itemname">
  27. </div>
  28.  
  29.  
  30.  
  31. <div class="form-group">
  32. <label for="itemcategory">Item Category</label>
  33. <select id="itemcategory" class="form-control" name="itemcategory">
  34. <option value="Tarpaulin">Tarpaulin</option>
  35. <option value="Rush ID">Rush ID</option>
  36. <option value="Photocopy">Photocopy</option>
  37. <option value="Graphic Layout">Graphic Layout</option>
  38. <option value="Invitation">Invitation</option>
  39. <option value="Panaflex">Panaflex</option>
  40. <option value="Signages">Signages</option>
  41. <option value="Stickers">Stickers</option>
  42. <option value="Sintra board">Sintra board</option>
  43. <option value="Large Format Photo">Large Format Photo</option>
  44. <option value="PVC ID">PVC ID</option>
  45. <option value="Lamination">Lamination</option>
  46. <option value="Bag Tags">Bag Tags</option>
  47. <option value="Notary Public">Notary Public</option>
  48. <option value="Scan">Scan</option>
  49. </select>
  50. </div>
  51.  
  52.  
  53.  
  54.  
  55. <div class="form-group">
  56. <label for="text">Item Quantity</label>
  57. <input type="text" class="form-control" id="itemquantity" name="itemquantity">
  58. </div>
  59. <div class="form-group">
  60. <label for="text">Is Hidden</label>
  61. <input type="text" class="form-control" id="ishidden" name="ishidden">
  62. </div>
  63. <div class="form-group">
  64. <label for="text">Item Price</label>
  65. <input type="text" class="form-control" id="itemprice" name="itemprice">
  66. </div>
  67.  
  68.  
  69. <button type="submit" class="btn btn-default userTrans">Submit</button>
  70. </form>
  71.  
  72.  
  73.  
  74. <?
  75. foreach ( $stmt as $rowItemz ){
  76. ?>
  77. <h3 class="section-heading">Modifying Item: <?=$rowItemz->title;?></h3>
  78. <form role="form" method="POST" class="userTrans">
  79. <input type="hidden" value="itemUpdate" name="act_userTrans">
  80.  
  81. <div class="form-group">
  82. <label for="title">Title:</label>
  83. <input type="text" class="form-control" id="title" name="title" value="<?=$rowItemz->title;?>">
  84. </div>
  85.  
  86. <div class="form-group">
  87. <label for="ctg">Category:</label>
  88. <select class="form-control" id="ctg" name="ctg">
  89. <option value="0" <?php if($rowItemz->ItemCategory==0) echo "selected";?>>Item Category 0</option>
  90. <option value="1" <?php if($rowItemz->ItemCategory==1) echo "selected";?>>Item Category 1</option>
  91. <option value="2" <?php if($rowItemz->ItemCategory==2) echo "selected";?>>Item Category 2</option>
  92. <option value="3" <?php if($rowItemz->ItemCategory==3) echo "selected";?>>Item Category 3</option>
  93. </select> <!--add more categs-->
  94. </div>
  95.  
  96.  
  97. <button type="submit" class="btn btn-default userTrans">Submit</button>
  98. </form>
  99. <?}?>
  100. <?php if($_GET['do']=="update"){
  101. $id = (int)$_GET['id'];
  102. $stmt = $user_home->getItemDetail($id);
  103. if($stmt->rowCount()>0){
  104. ?>
  105.  
  106.  
  107. <BR>
  108. <div class="panel panel-default">
  109. <!-- Default panel contents -->
  110. <div class="panel-heading">Item List</div>
  111.  
  112. <!-- Table -->
  113. <table class="table bg-dark">
  114. <thead>
  115. <tr>
  116. <th>#</th>
  117. <th>Item Name</th>
  118. <th>Item Category</th>
  119. <th>Item Price</th>
  120. <th>Item Quantity</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124.  
  125. <?php
  126. $stmt = $user_home->getItemList();
  127.  
  128. if($stmt->rowCount()>0){
  129. ?>
  130. <?
  131. foreach ( $stmt as $row ){
  132.  
  133. ?>
  134. <tr>
  135. <th scope="row"><?echo $row->itemID?></th>
  136. <td><?echo $row->ItemName?></td>
  137. <td><?echo $row->ItemCategory?></td>
  138. <td><?echo $row->ItemPrice?></td>
  139. <td><?echo $row->ItemQuantity?></td>
  140. <td><a href="?p=adminpanel&action=item&do=update&id=<?echo $row->itemID?>">Edit</a> /
  141. <form method="POST" class="userTransdoConfirm">
  142. <input type="hidden" value="doDeleteItem" name="act_userTrans">
  143. <input type="hidden" value="<?echo $row->itemID?>" name="id">
  144. <button class='button' style='background-color: #B1221C;'><strong>Delete</strong></button>
  145. </form>
  146. </td> </tr>
  147. <?
  148. }
  149. }
  150.  
  151. ?>
  152.  
  153.  
  154.  
  155.  
  156. </tbody> </table>
  157. </div>
  158.  
  159. </div>
  160. </div>
  161. <?php } ?>
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. class.user.php
  169. ________________
  170. public function itemUpdate($usersession,$itemquantity,$itemcategory,$itemname,$ishidden,$itemprice)//transform to item again, wait may asikasuhin ako saglit sa database, nagcrash e okss
  171. {
  172. try
  173. {
  174. $stmt = $this->conn->prepare("UPDATE tbl_product SET ItemName=:item_name,ItemCategory=:Item_Category,ItemQuantity=:item_quantity WHERE ItemID=:id");
  175.  
  176. $stmt->bindparam(":itemname",$itemname);
  177. $stmt->bindparam(":itemcategory",$itemcategory);
  178. $stmt->bindparam(":itemquantity",$itemquantity);
  179. $stmt->bindparam(":ishidden",$ishidden);
  180. $stmt->bindparam(":itemprice",$itemprice);
  181. $stmt->execute();
  182. return $stmt;
  183. }
  184. catch(PDOException $ex)
  185. {
  186. echo $ex->getMessage();
  187. }
  188. }
  189.  
  190. public function getItemDetail($id)
  191. {
  192. $id = (int)$id;
  193. $stmt = $this->conn->prepare("SELECT * from tbl_product WHERE ItemID=:id");
  194. $stmt->bindparam(":id",$id);
  195. $stmt->execute();
  196. return $stmt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement