Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sale start
- $sale_lookup = $mysidia->db->select("adopt_stock", array("aid"), "aid='{$aid}'")->rowCount();
- $adoptshop_lookup = $mysidia->db->select("user_shops", array("usid"), "manager_id='{$mysidia->user->uid}' AND type='adopt'")->rowCount();
- if ($sale_lookup == NULL OR $sale_lookup == '0'){$sale_status = "not for sale"; $dont_sell = "checked"; $sell = " ";}
- else{$sale_status = "for sale"; $sell = "checked"; $dont_sell = " ";}
- 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>";}
- else{
- $shop_id = $mysidia->db->select("user_shops", array("usid"), "manager_id = '{$mysidia->user->uid}'")->fetchColumn();
- $sale_manage = "<div class='card' style='text-align:center;'>
- <div class='card-text'>
- <p><h2>This adopt is {$sale_status}.</h2></p>
- <form method='post' action='/myadopts/manage/{$aid}'>
- <p><div class='form-check form-check-inline'>
- Price:<label class='form-check-label'>
- <input type='number' class='form-control' value='1' min='1' max='100' name='price' id='price' style='width:70px;'>
- </label>
- </div>
- <div class='form-check form-check-inline'>
- Gem Price:<label class='form-check-label'>
- <input type='number' class='form-control' value='0' min='0' max='100' name='gem_price' id='gem_price' style='width:70px;'>
- </label>
- </div></p>
- <p><div class='form-check form-check-inline'>
- For Sale:<label class='form-check-label'>
- <input class='form-check-input' type='radio' name='sell' id='sell' value='yes' {$sell}>    Yes
- </label>
- </div>
- <div class='form-check form-check-inline'>
- <label class='form-check-label'>
- <input class='form-check-input' type='radio' name='sell' id='sell' value='no' {$dont_sell}>    No
- </label>
- </div></p>
- <p><button type='submit' class='btn btn-primary'>Save changes</button></p>
- </form>
- </div>
- </div>";}
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $price = $_REQUEST["price"];
- $gem_price = $_REQUEST["gem_price"];
- $on_sale = $_REQUEST["sell"];
- if($on_sale == "no"){ //delete pet from stock
- $mysidia->db->delete("adopt_stock", "aid = $aid");
- }
- else{
- if ($sale_lookup == NULL){ //Create row if one does not exist
- $mysidia->db->insert("adopt_stock", array("usid" => $shop_id, "aid" => $aid, "adopt_name" => $name, "price" => $price, "premium_price" => $gem_price));
- }
- else{ //Update row, since one already exists
- $mysidia->db->update("adopt_stock", array("price" => $price, "premium_price" => $gem_price), "aid = '{$aid}'");
- }
- }
- }
- //Sale end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement