public function gmgt_sell_product($data) { global $wpdb; $table_sell = $wpdb->prefix . 'gmgt_store'; //-------usersmeta table data-------------- $storedata['member_id'] = $data['member_id']; $storedata['sell_date'] = $data['sell_date']; $storedata['product_id'] = $data['product_id']; $storedata['quentity'] = $data['quentity']; $storedata['sell_by'] = get_current_user_id(); if ($data['action'] == 'edit') { $sellid['id'] = $data['sell_id']; $result = $wpdb->update($table_sell, $storedata, $sellid); return $result; } else { $obj_product = new Gmgtproduct(); $product = $obj_product->get_single_product($data['product_id']); $quentity = $product->quentity; if ($quentity >= $data['quentity'] && $quentity > 0) { $result = $wpdb->insert($table_sell, $storedata); $remainig_quentiy = $quentity - $data['quentity']; $productdata['quentity'] = $remainig_quentiy; $productid['id'] = $data['product_id']; $table_product = $wpdb->prefix . 'gmgt_product'; $wpdb->update($table_product, $productdata, $productid); } else { $result = 'no_stock'; } return $result; } }
<?php $curr_user_id = get_current_user_id(); $obj_gym = new Gym_management($curr_user_id); $obj_product = new Gmgtproduct(); $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'productlist'; if (isset($_POST['save_product'])) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { $result = $obj_product->gmgt_add_product($_POST); if ($result) { wp_redirect(home_url() . '?dashboard=user&page=product&tab=productlist&message=2'); } } else { $result = $obj_product->gmgt_add_product($_POST); if ($result) { wp_redirect(home_url() . '?dashboard=user&page=product&tab=productlist&message=1'); } } } if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { $result = $obj_product->delete_product($_REQUEST['product_id']); if ($result) { wp_redirect(home_url() . '?dashboard=user&page=product&tab=productlist&message=3'); } } if (isset($_REQUEST['message'])) { $message = $_REQUEST['message']; if ($message == 1) { ?> <div id="message" class="updated below-h2 "> <p>
<?php $curr_user_id = get_current_user_id(); $obj_gym = new Gym_management($curr_user_id); $obj_product = new Gmgtproduct(); $obj_store = new Gmgtstore(); $obj_class = new Gmgtclassschedule(); $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'store'; if (isset($_POST['save_selling'])) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { $result = $obj_store->gmgt_sell_product($_POST); if ($result) { wp_redirect(home_url() . '?dashboard=user&page=store&tab=store&message=2'); } } else { $result = $obj_store->gmgt_sell_product($_POST); if ($result != 'no_stock') { wp_redirect(home_url() . '?dashboard=user&page=store&tab=store&message=1'); } else { wp_redirect(home_url() . '?dashboard=user&page=store&tab=sellproduct&message=4'); } } } if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { $result = $obj_store->delete_selling($_REQUEST['sell_id']); if ($result) { wp_redirect(home_url() . '?dashboard=user&page=store&tab=store&message=3'); } } if (isset($_REQUEST['message'])) { $message = $_REQUEST['message'];