Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admn_product.php
- __________________
- <?
- if($user_home->is_admin() || $user_home->is_auditor){
- ?>
- <div class="row">
- <div class="col-lg-8 col-lg-offset-2">
- <h2 class="section-heading">Add Product</h2>
- <div class="text-center" style="input, select, textarea{
- color: #000;
- }">
- </div><BR>
- <form role="form" class="userTrans" method="POST">
- <input type="hidden" value="iteminsert" name="act_userTrans">
- <div class="form-group">
- <label for="text">Item Name</label>
- <input type="text" class="form-control" id="itemInsert" name="itemname">
- </div>
- <div class="form-group">
- <label for="itemcategory">Item Category</label>
- <select id="itemcategory" class="form-control" name="itemcategory">
- <option value="Tarpaulin">Tarpaulin</option>
- <option value="Rush ID">Rush ID</option>
- <option value="Photocopy">Photocopy</option>
- <option value="Graphic Layout">Graphic Layout</option>
- <option value="Invitation">Invitation</option>
- <option value="Panaflex">Panaflex</option>
- <option value="Signages">Signages</option>
- <option value="Stickers">Stickers</option>
- <option value="Sintra board">Sintra board</option>
- <option value="Large Format Photo">Large Format Photo</option>
- <option value="PVC ID">PVC ID</option>
- <option value="Lamination">Lamination</option>
- <option value="Bag Tags">Bag Tags</option>
- <option value="Notary Public">Notary Public</option>
- <option value="Scan">Scan</option>
- </select>
- </div>
- <div class="form-group">
- <label for="text">Item Quantity</label>
- <input type="text" class="form-control" id="itemquantity" name="itemquantity">
- </div>
- <div class="form-group">
- <label for="text">Is Hidden</label>
- <input type="text" class="form-control" id="ishidden" name="ishidden">
- </div>
- <div class="form-group">
- <label for="text">Item Price</label>
- <input type="text" class="form-control" id="itemprice" name="itemprice">
- </div>
- <button type="submit" class="btn btn-default userTrans">Submit</button>
- </form>
- <?
- foreach ( $stmt as $rowItemz ){
- ?>
- <h3 class="section-heading">Modifying Item: <?=$rowItemz->title;?></h3>
- <form role="form" method="POST" class="userTrans">
- <input type="hidden" value="itemUpdate" name="act_userTrans">
- <div class="form-group">
- <label for="title">Title:</label>
- <input type="text" class="form-control" id="title" name="title" value="<?=$rowItemz->title;?>">
- </div>
- <div class="form-group">
- <label for="ctg">Category:</label>
- <select class="form-control" id="ctg" name="ctg">
- <option value="0" <?php if($rowItemz->ItemCategory==0) echo "selected";?>>Item Category 0</option>
- <option value="1" <?php if($rowItemz->ItemCategory==1) echo "selected";?>>Item Category 1</option>
- <option value="2" <?php if($rowItemz->ItemCategory==2) echo "selected";?>>Item Category 2</option>
- <option value="3" <?php if($rowItemz->ItemCategory==3) echo "selected";?>>Item Category 3</option>
- </select> <!--add more categs-->
- </div>
- <button type="submit" class="btn btn-default userTrans">Submit</button>
- </form>
- <?}?>
- <?php if($_GET['do']=="update"){
- $id = (int)$_GET['id'];
- $stmt = $user_home->getItemDetail($id);
- if($stmt->rowCount()>0){
- ?>
- <BR>
- <div class="panel panel-default">
- <!-- Default panel contents -->
- <div class="panel-heading">Item List</div>
- <!-- Table -->
- <table class="table bg-dark">
- <thead>
- <tr>
- <th>#</th>
- <th>Item Name</th>
- <th>Item Category</th>
- <th>Item Price</th>
- <th>Item Quantity</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $stmt = $user_home->getItemList();
- if($stmt->rowCount()>0){
- ?>
- <?
- foreach ( $stmt as $row ){
- ?>
- <tr>
- <th scope="row"><?echo $row->itemID?></th>
- <td><?echo $row->ItemName?></td>
- <td><?echo $row->ItemCategory?></td>
- <td><?echo $row->ItemPrice?></td>
- <td><?echo $row->ItemQuantity?></td>
- <td><a href="?p=adminpanel&action=item&do=update&id=<?echo $row->itemID?>">Edit</a> /
- <form method="POST" class="userTransdoConfirm">
- <input type="hidden" value="doDeleteItem" name="act_userTrans">
- <input type="hidden" value="<?echo $row->itemID?>" name="id">
- <button class='button' style='background-color: #B1221C;'><strong>Delete</strong></button>
- </form>
- </td> </tr>
- <?
- }
- }
- ?>
- </tbody> </table>
- </div>
- </div>
- </div>
- <?php } ?>
- class.user.php
- ________________
- public function itemUpdate($usersession,$itemquantity,$itemcategory,$itemname,$ishidden,$itemprice)//transform to item again, wait may asikasuhin ako saglit sa database, nagcrash e okss
- {
- try
- {
- $stmt = $this->conn->prepare("UPDATE tbl_product SET ItemName=:item_name,ItemCategory=:Item_Category,ItemQuantity=:item_quantity WHERE ItemID=:id");
- $stmt->bindparam(":itemname",$itemname);
- $stmt->bindparam(":itemcategory",$itemcategory);
- $stmt->bindparam(":itemquantity",$itemquantity);
- $stmt->bindparam(":ishidden",$ishidden);
- $stmt->bindparam(":itemprice",$itemprice);
- $stmt->execute();
- return $stmt;
- }
- catch(PDOException $ex)
- {
- echo $ex->getMessage();
- }
- }
- public function getItemDetail($id)
- {
- $id = (int)$id;
- $stmt = $this->conn->prepare("SELECT * from tbl_product WHERE ItemID=:id");
- $stmt->bindparam(":id",$id);
- $stmt->execute();
- return $stmt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement