Example #1
0
 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;
     }
 }
Example #2
0
        
        </table>

 		</div>
		</div>
		<?php 
}
if ($active_tab == 'addproduct') {
    $product_id = 0;
    if (isset($_REQUEST['product_id'])) {
        $product_id = $_REQUEST['product_id'];
    }
    $edit = 0;
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $edit = 1;
        $result = $obj_product->get_single_product($product_id);
    }
    ?>
		
       <div class="panel-body">
        <form name="product_form" action="" method="post" class="form-horizontal" id="product_form">
         <?php 
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'insert';
    ?>
		<input type="hidden" name="action" value="<?php 
    echo $action;
    ?>
">
		<input type="hidden" name="product_id" value="<?php 
    echo $product_id;
    ?>
Example #3
0
    ?>
</th>
            </tr>
        </tfoot>
 
        <tbody>
         <?php 
    $storedata = $obj_store->get_all_selling();
    if (!empty($storedata)) {
        foreach ($storedata as $retrieved_data) {
            ?>
            <tr><td class="productname"><a href="?dashboard=user&page=store&tab=sellproduct&action=edit&sell_id=<?php 
            echo $retrieved_data->id;
            ?>
"><?php 
            $product = $obj_product->get_single_product($retrieved_data->product_id);
            echo $product->product_name;
            ?>
</a></td>
			<td class="membername"><?php 
            $userdata = get_userdata($retrieved_data->member_id);
            echo $userdata->display_name;
            ?>
</td>
				
				<td class="productquentity"><?php 
            echo $retrieved_data->quentity;
            ?>
</td>
                <td class="action"> <a href="?dashboard=user&page=store&tab=sellproduct&action=edit&sell_id=<?php 
            echo $retrieved_data->id;