ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/www/vijay-gases/apis/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/www/vijay-gases/apis/sales-add-api1.php

<?php 
ob_start();
session_start();
include "../config/config.php";
$session_id = $_SESSION['vijay_gases']['id'];


// Product Details Create, Update Starts Here 

if(isset($_POST['type']) && $_POST['type']=='create_product'){
     try{
        
         $statement = $pdo->prepare("INSERT INTO `tbl_product`(`product_name`,`sku`,`purchase_price`,`sell_price`,`default_purchase_location`,`current_stock`) VALUES (?,?,?,?,?,?)");
         $result = $statement->execute(array($_POST['product_name'],$_POST['sku_no'],$_POST['purchase_price'],$_POST['sell_price'],$_POST['location_id'],$_POST['stock']));
        
        if($result){    
            $return_arr['message']='Product Details Added Successfully...';
            $return_arr['status']=200;
        } 
        else{
            $return_arr['message']='Something Went Wrong..';
            $return_arr['status']=400;
        }
         
    }catch(PDOException $e){
        $return_arr['message']="$e";
        $return_arr['status']=500;
        }   
    echo json_encode($return_arr);
}


if(isset($_POST['type']) && $_POST['type']=='update_product'){
     try{
        error_log('hello');
        
         $statement = $pdo->prepare("UPDATE `tbl_product` SET `product_type`=3 WHERE id=?");
         $result = $statement->execute(array($_POST['ids']));
        
        if($result){    
            $return_arr['message']='Product Details Updated Successfully...';
            $return_arr['status']=200;
        } 
        else{
            $return_arr['message']='Something Went Wrong..';
            $return_arr['status']=400;
        }
         
    }catch(PDOException $e){
        $return_arr['message']="$e";
        $return_arr['status']=500;
        }   
    echo json_encode($return_arr);
}



// Product Details Create, Update Ends Here
?>

Zerion Mini Shell 1.0