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/payment-add-api.php

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


// Customer Details Create, Update Starts Here 

if(isset($_POST['type']) && $_POST['type']=='purchase_payment'){
     try{
         
         $customer_id = $_POST['cus_id'];
         $sell_id = $_POST['sell_id'];
         $paid_date = $_POST['paid_date'];
         $paid_amount = $_POST['paid_amount'];
         $pay_term = $_POST['pay_type'];
         $pay_mode = $_POST['pay_mode'];
        
         
         $statement = $pdo->prepare("INSERT INTO `tbl_payment`(`pay_type`,`mode`,`customer_id`,`amount`,`pay_id`,`date`,`type`) VALUES (?,?,?,?,?,?,?)");
         $result = $statement->execute(array($pay_term,$pay_mode,$customer_id,$paid_amount,$sell_id,$paid_date,1));
         
         
         $statement1 = $pdo->prepare("UPDATE `tbl_purchase` SET `paid_amount`=paid_amount+$paid_amount WHERE `id`=$sell_id");
         $result1=$statement1->execute();
         
         
         
        if($result1){
            $return_arr['message']='Purchase Payment 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']=='sales_payment'){
     try{
         
         $customer_id = $_POST['cus_id'];
         $sell_id = $_POST['sell_id'];
         $paid_date = $_POST['paid_date'];
         $paid_amount = $_POST['paid_amount'];
         $pay_term = $_POST['pay_term'];
         $pay_mode = $_POST['pay_mode'];
        
         
         $statement = $pdo->prepare("INSERT INTO `tbl_payment`(`pay_type`,`mode`,`customer_id`,`amount`,`pay_id`,`date`,`type`) VALUES (?,?,?,?,?,?,?)");
         $result = $statement->execute(array($pay_mode,$pay_term,$customer_id,$paid_amount,$sell_id,$paid_date,2));
         
         $statement1 = $pdo->prepare("UPDATE `tbl_sell` SET `paid_amount`=paid_amount+$paid_amount WHERE `id`=$sell_id");
         $result1=$statement1->execute();
         
        if($result1){
            $return_arr['message']='Sales Payment 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_customer'){
     try{
         
         $name = $_POST['name'];
         $mobile_no = $_POST['mobile_no'];
         $mobile_no2 = $_POST['mobile_no2'];
         $mobile_no3 = $_POST['mobile_no3'];
         $mobile_no4 = $_POST['mobile_no4'];
         $mobile_no5 = $_POST['mobile_no5'];
         $address = $_POST['address'];
         $del_address = $_POST['del_address'];
         $location = $_POST['location'];
         $status = $_POST['status'];
         $ids = $_POST['ids'];
         
         
         $statement = $pdo->prepare("UPDATE `tbl_customer` SET `customer_name`=?,`mobile_number2`=?,`mobile_number3`=?,`mobile_number4`=?,`mobile_number5`=?,`mobile_number`=?,`address`=?,`del_address`=?,`location_id`=?,`status`=?,`cust_type`=? WHERE id=?");
         $result = $statement->execute(array($name,$mobile_no,$mobile_no,$mobile_no,$mobile_no,$mobile_no,$address,$del_address,$location,$status,1,$ids));
        
        if($result){    
            $return_arr['message']='Customer 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);
}
if(isset($_POST['type']) && $_POST['type']=='update_supplier'){
     try{
         
         $name = $_POST['name'];
         $mobile_no = $_POST['mobile_no'];
         $address = $_POST['address'];
         $location = $_POST['location'];
         $status = $_POST['status'];
         $ids = $_POST['ids'];
        $c_name = $_POST['c_name'];
        $mobile_no2 = $_POST['mobile_no2'];
        $mobile_no3 = $_POST['mobile_no3'];
        $mobile_no4 = $_POST['mobile_no4'];
        $mobile_no5 = $_POST['mobile_no5'];
        $f_address = $_POST['f_address'];
        
         
         $statement = $pdo->prepare("UPDATE `tbl_customer` SET `c_name`=?, `customer_name`=?,`mobile_number`=?,`mobile_number2`=?,`mobile_number3`=?,`mobile_number4`=?,`mobile_number5`=?,`address`=?,`location_id`=?,`f_address`=?,`status`=?,`cust_type`=? WHERE id=?");
         $result = $statement->execute(array($c_name,$name,$mobile_no,$mobile_no2,$mobile_no3,$mobile_no4,$mobile_no5,$address,$location,$f_address,$status,2,$ids));
        
        if($result){    
            $return_arr['message']='Supplier 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);
}

// City Details Create, Update Starts Here 

if(isset($_POST['type']) && $_POST['type']=='create_points'){

     try{
         
         $name = $_POST['name'];
         $quick_address = $_POST['quick_address'];
         $time = $_POST['time'];
         $city = $_POST['city'];
         $trip_id = $_POST['trip_id'];
         
         $statement = $pdo->prepare("INSERT INTO `tbl_points`(`name`, `quick_address`, `city`, `time`, `trip_id`) VALUES (?,?,?,?,?)");
         $result = $statement->execute(array($name, $quick_address, $city, $time, $trip_id));
        
        if($result){    
            $return_arr['message']='Points 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_points'){

     try{
         
         $ids = $_POST['ids'];
         $name = $_POST['name'];
         $quick_address = $_POST['quick_address'];
         $time = $_POST['time'];
         $city = $_POST['city'];
         $trip_id = $_POST['trip_id'];
         
         
         $statement = $pdo->prepare("UPDATE `tbl_points` SET `name`=?, `quick_address`=?, `city`=?, `time`=?, `trip_id`=? WHERE id=?");
         $result = $statement->execute(array($name, $quick_address, $city, $time, $trip_id, $ids));
        
        if($result){    
            $return_arr['message']='Points 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);
}


if(isset($_POST['type']) && $_POST['type']=='create_bus_details'){

     try{
         
         $bus_name = $_POST['bus_name'];
         $bus_code = $_POST['bus_code'];
         $bus_seats = $_POST['bus_seats'];
         $vehicle_number = $_POST['vehicle_number'];
         $status = $_POST['status'];
         
         
         $statement = $pdo->prepare("INSERT INTO `tbl_bus_details`(`bus_name`, `bus_code`, `bus_seats`, `bus_number`, `status`) VALUES (?,?,?,?,?)");
         $result = $statement->execute(array($bus_name, $bus_code, $bus_seats, $vehicle_number, $status));
        
        if($result){    
            $return_arr['message']='Bus 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_bus_details'){

     try{
         
         $bus_name = $_POST['bus_name'];
         $bus_code = $_POST['bus_code'];
         $bus_seats = $_POST['bus_seats'];
         $vehicle_number = $_POST['vehicle_number'];
         $status = $_POST['status'];
         $ids = $_POST['ids'];
         
         
         $statement = $pdo->prepare("UPDATE `tbl_bus_details` SET `bus_name`=?, `bus_code`=?, `bus_seats`=?, `bus_number`=?, `status`=? WHERE id=?");
         $result = $statement->execute(array($bus_name, $bus_code, $bus_seats, $vehicle_number, $status, $ids));
        
        if($result){    
            $return_arr['message']='Bus 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);
}

?>

Zerion Mini Shell 1.0