Advertisement
Dinocanid

Myadoptsview sale setup

Dec 28th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1. //Sale start
  2.         $sale_lookup = $mysidia->db->select("adopt_stock", array("aid"), "aid='{$aid}'")->rowCount();
  3.         $adoptshop_lookup = $mysidia->db->select("user_shops", array("usid"), "manager_id='{$mysidia->user->uid}' AND type='adopt'")->rowCount();
  4.             if ($sale_lookup == NULL OR $sale_lookup == '0'){$sale_status = "not for sale"; $dont_sell = "checked"; $sell = " ";}
  5.             else{$sale_status = "for sale"; $sell = "checked"; $dont_sell = " ";}
  6.             if ($adoptshop_lookup == NULL OR $adoptshop_lookup == '0'){$sale_manage = "Sorry! You don't own an adopt shop. <a href='/shopcp'>Why not make one?</a>";}
  7.             else{
  8.                 $shop_id = $mysidia->db->select("user_shops", array("usid"), "manager_id = '{$mysidia->user->uid}'")->fetchColumn();
  9.                 $sale_manage = "<div class='card' style='text-align:center;'>
  10.             <div class='card-text'>
  11.                 <p><h2>This adopt is {$sale_status}.</h2></p>
  12.                 <form method='post' action='/myadopts/manage/{$aid}'>
  13.                 <p><div class='form-check form-check-inline'>
  14.                     Price:<label class='form-check-label'>
  15.                         <input type='number' class='form-control' value='1' min='1' max='100' name='price' id='price' style='width:70px;'>
  16.                     </label>
  17.                 </div>
  18.                 <div class='form-check form-check-inline'>
  19.                     Gem Price:<label class='form-check-label'>
  20.                         <input type='number' class='form-control' value='0' min='0' max='100' name='gem_price' id='gem_price' style='width:70px;'>
  21.                     </label>
  22.                 </div></p>
  23.                 <p><div class='form-check form-check-inline'>
  24.             For Sale:<label class='form-check-label'>
  25.                 <input class='form-check-input' type='radio' name='sell' id='sell' value='yes' {$sell}>&nbsp&nbsp&nbsp Yes
  26.             </label>
  27.         </div>
  28.         <div class='form-check form-check-inline'>
  29.             <label class='form-check-label'>
  30.                 <input class='form-check-input' type='radio' name='sell' id='sell' value='no' {$dont_sell}>&nbsp&nbsp&nbsp No
  31.             </label>
  32.         </div></p>
  33.                 <p><button type='submit' class='btn btn-primary'>Save changes</button></p>
  34.             </form>
  35.             </div>
  36.         </div>";}
  37.        
  38.         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  39.             $price = $_REQUEST["price"];
  40.             $gem_price = $_REQUEST["gem_price"];
  41.             $on_sale = $_REQUEST["sell"];          
  42.                 if($on_sale == "no"){ //delete pet from stock
  43.                     $mysidia->db->delete("adopt_stock", "aid = $aid");
  44.                 }
  45.                 else{
  46.                     if ($sale_lookup == NULL){ //Create row if one does not exist
  47.                         $mysidia->db->insert("adopt_stock", array("usid" => $shop_id, "aid" => $aid, "adopt_name" => $name, "price" => $price, "premium_price" => $gem_price));
  48.                     }
  49.                     else{ //Update row, since one already exists
  50.                         $mysidia->db->update("adopt_stock", array("price" => $price, "premium_price" => $gem_price), "aid = '{$aid}'");
  51.                     }
  52.                 }
  53.         }
  54.        
  55.          //Sale end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement