<?php 
session_start();
include('../includes/dbcon.php');

$str=" ";
$email_edit=" ";




$loc_name= mysqli_real_escape_string($con,trim($_POST['loc_edit']));
$loc_id= mysqli_real_escape_string($con,trim($_POST['locid_edit']));
$loc_type= mysqli_real_escape_string($con,trim($_POST['loctype_edit']));
//$emp_id = mysqli_real_escape_string($con,trim($_POST['emp']));
 
 //echo $loc_type;
if (empty($loc_name)) {
    echo "<script type='text/javascript'>alert('Please Enter Location Name!');</script>";
	echo "<script>document.location='admin_location_view.php'</script>"; 
}

else {
    
    $query=mysqli_query($con," select * from stock_locations where loc_name='$loc_name'  ")or die(mysqli_error($con));
    $count=mysqli_num_rows($query);
if ($count>0)
{
	echo "<script type='text/javascript'>alert('Exsisting Name !');</script>";
	echo "<script>document.location='admin_location_view.php'</script>"; 
}
    
    
    
    else {
    
    
	if ( mysqli_query($con,"update stock_locations set loc_name = '$loc_name',loc_type='$loc_type'
	  where loc_id=$loc_id ")or die(mysqli_error($con)))
		{
			echo "<script>document.location='admin_location_view.php'</script>"; 
		}		
}
}

?>