ok
Direktori : /home2/selectio/www/vijay-gases/apis/ |
Current File : //home2/selectio/www/vijay-gases/apis/customer-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']=='create_customer'){ try{ $customer_name = $_POST['customer_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']; $aadhar_no = $_POST['aadhar_no']; $location_id = $_POST['location_id']; $cus_company_name = $_POST['cus_company_name']; $cus_gst_no = $_POST['cus_gst_no']; $cus_deposit_amt = $_POST['cus_deposit_amt']; $cus_date = $_POST['cus_date']; $receipt_no = $_POST['receipt_no']; $statement = $pdo->prepare("INSERT INTO `tbl_customer`(`customer_name`,`mobile_number`,`mobile_number2`,`mobile_number3`,`mobile_number4`,`mobile_number5`,`address`,`del_address`,`status`,`location_id`,`cust_type`,`deposit_amount`,`cus_company_name`,`gst_no`,`cus_date`,`aadhar_no`,`receipt_no`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $result = $statement->execute(array($customer_name,$mobile_no,$mobile_no2,$mobile_no3,$mobile_no4,$mobile_no5,$address,$del_address,1,$location_id,1,$cus_deposit_amt,$cus_company_name,$cus_gst_no,$cus_date,$aadhar_no,$receipt_no)); $customer_last_id = $pdo->lastInsertId(); if($result){ $return_arr['id']=$customer_last_id; $return_arr['last_name']=$customer_name; $return_arr['message']='Customer 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']=='create_supplier'){ try{ $c_name = $_POST['c_name']; $customer_name = $_POST['customer_name']; $customer_name2 = $_POST['customer_name2']; $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']; $sup_gst_no = $_POST['sup_gst_no']; $f_address = $_POST['f_address']; $checkboxValues = isset($_POST['location_id']) ? $_POST['location_id'] : []; // Convert the array to a comma-separated string $checkboxString = implode(',', $checkboxValues); $statement = $pdo->prepare("INSERT INTO `tbl_customer`(`c_name`,`customer_name`,`mobile_number`,`mobile_number2`,`mobile_number3`,`mobile_number4`,`mobile_number5`,`address`,`f_address`,`status`,`location_id`,`cust_type`,`gst_no`,`customer_name2`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $result = $statement->execute(array($c_name,$customer_name,$mobile_no,$mobile_no2,$mobile_no3,$mobile_no4,$mobile_no5,$address,$f_address,1,$checkboxString,2,$sup_gst_no,$customer_name2)); $supplier_last_id = $pdo->lastInsertId(); if($result){ $return_arr['id']=$supplier_last_id; $return_arr['last_name']=$customer_name; $return_arr['message']='Purchaser 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_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']; $cus_company_name = $_POST['cus_company_name']; $cus_gst_no = $_POST['cus_gst_no']; $cus_date = $_POST['cus_date']; $cus_dep_amt = $_POST['cus_dep_amt']; $aadhar_no = $_POST['aadhar_no']; $receipt_no = $_POST['receipt_no']; $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`=?,`gst_no`=?,`deposit_amount`=?,`cus_company_name`=?,`cus_date`=?,`aadhar_no`=?,`aadhar_no`=?,`receipt_no`=? WHERE id=?"); $result = $statement->execute(array($name,$mobile_no2,$mobile_no3,$mobile_no4,$mobile_no5,$mobile_no,$address,$del_address,$location,$status,1,$cus_gst_no,$cus_dep_amt,$cus_company_name,$cus_date,$aadhar_no,$receipt_no,$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']; $owner_name2 = $_POST['owner_name2']; $mobile_no = $_POST['mobile_no']; $address = $_POST['address']; $location = $_POST['location']; $status = $_POST['status']; $ids = $_POST['ids']; $c_name = $_POST['c_name']; $sup_gst_no = $_POST['sup_gst_no']; $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`=?,`gst_no`=?,`customer_name2`=? 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,$sup_gst_no,$owner_name2,$ids)); if($result){ $return_arr['message']='Purchaser 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); } // Gas Type Add,Update Details Update Here if(isset($_POST['type']) && $_POST['type']=='create_gas_type'){ try{ $gas_type = $_POST['gas_type']; $cube = $_POST['cube']; $hsn_code = $_POST['hsn_code']; $statement = $pdo->prepare("INSERT INTO `tbl_gas`(`gas_name`,`cube_no`,`hsn_code`,`status`) VALUES (?,?,?,?)"); $result = $statement->execute(array($gas_type,$cube,$hsn_code,1)); $customer_last_id = $pdo->lastInsertId(); if($result){ $return_arr['message']='Gas Type 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_gas_type'){ try{ $gas_name = $_POST['gas_name']; $cube_no = $_POST['cube_no']; $hsn_code = $_POST['hsn_code']; $status = $_POST['status']; $ids = $_POST['ids']; $statement = $pdo->prepare("UPDATE `tbl_gas` SET `gas_name`=?,`cube_no`=?,`hsn_code`=?,`status`=? WHERE id=?"); $result = $statement->execute(array($gas_name,$cube_no,$hsn_code,$status,$ids)); if($result){ $return_arr['message']='Gas Type 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); } // GST ADD and UPDATE API STARTS HERE if(isset($_POST['type']) && $_POST['type']=='create_gst'){ try{ $gst_percentage = $_POST['gst_percentage']; $statement = $pdo->prepare("INSERT INTO `tbl_gst`(`gst_percentage`,`status`) VALUES (?,?)"); $result = $statement->execute(array($gst_percentage,1)); $customer_last_id = $pdo->lastInsertId(); if($result){ $return_arr['message']='GST 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_gst'){ try{ $gst_percentage = $_POST['gst_percentage']; $status = $_POST['status']; $ids = $_POST['ids']; $statement = $pdo->prepare("UPDATE `tbl_gst` SET `gst_percentage`=?,`status`=? WHERE id=?"); $result = $statement->execute(array($gst_percentage,$status,$ids)); if($result){ $return_arr['message']='GST 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); } // GST ADD and UPDATE API STARTS HERE // LOCATION ADD and UPDATE API STARTS HERE if(isset($_POST['type']) && $_POST['type']=='create_location'){ try{ $location = $_POST['location']; $address = $_POST['address']; $reg_office = $_POST['reg_office']; $statement = $pdo->prepare("INSERT INTO `tbl_location`(`name`,`address`,`factory_address`,`status`) VALUES (?,?,?,?)"); $result = $statement->execute(array($location,$address,$reg_office,1)); $customer_last_id = $pdo->lastInsertId(); if($result){ $return_arr['message']='Location 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_location'){ try{ $location_name = $_POST['location_name']; $address = $_POST['address']; $reg_office = $_POST['reg_address']; $status = $_POST['status']; $ids = $_POST['ids']; $statement = $pdo->prepare("UPDATE `tbl_location` SET `name`=?,`status`=?,`address`=?,`factory_address`=? WHERE id=?"); $result = $statement->execute(array($location_name,$status,$address,$reg_office,$ids)); if($result){ $return_arr['message']='Location 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); } // LOCATION ADD and UPDATE API STARTS HERE ?>