78 lines
2.0 KiB
PHP
78 lines
2.0 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
|
$manufacturer_id = $_POST['manufacturer_id'];
|
|
$manufacturer_name =$_POST['manufacturer_name'];
|
|
$manufacturer_address = $_POST['manufacturer_address'];
|
|
$manufacturer_code = $_POST['manufacturer_code'];
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
|
|
|
|
|
|
|
|
|
if(!empty($manufacturer_id)){
|
|
$query = "update manufacturer set manufacturer_name = '$manufacturer_name', manufacturer_address = '$manufacturer_address', manufacturer_code = '$manufacturer_code',modified_by = '".$_SESSION['user_id']."' where manufacturer_id =
|
|
'".$manufacturer_id."'";
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
$check_query = "select * from manufacturer where manufacturer_name = '$manufacturer_name'";
|
|
//echo $check_query;
|
|
$result = mysqli_query($conn,$check_query);
|
|
$checkrows=mysqli_num_rows($result);
|
|
if( $checkrows>0){
|
|
$data = "This manufacturer already exist";
|
|
}
|
|
else{
|
|
$query = "insert into manufacturer(manufacturer_name,manufacturer_address,manufacturer_code,modified_by)
|
|
values ('$manufacturer_name','$manufacturer_address','$manufacturer_code','".$_SESSION['user_id']."' ); ";
|
|
}
|
|
}
|
|
$data=array();
|
|
$manufacturer_id_max="";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
$query = "select max(manufacturer_id) manufacturer_id from manufacturer ";
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$manufacturer_id_max = $row['manufacturer_id'];
|
|
}
|
|
}
|
|
|
|
|
|
$query = "select * from manufacturer where manufacturer_id='".$manufacturer_id_max."'";
|
|
//echo $query;
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$data=$row;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
if(data==null)
|
|
{
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
|
|
echo json_encode($data);
|
|
?>
|