<?php include('../../config/setup.php');?>
<?php
 if(isset($_POST['Lee_name_edit']))
 { 
 
$update_app_Name=mysqli_query($config,"update lee_master set Name='".$_POST['Edit_lee_name']."',Name_status='".$_POST['lee_name_status']."' where Site_id='".$_POST['Edit_lee_id']."'");
 if($update_app_Name==false)
{
echo "<script>window.location.href='../logo_name_Master.php?erro=0';</script>".mysqli_error();	 
}
else{
	
	echo "<script>window.location.href='../logo_name_Master.php?msg=100';</script>";	 

	
}

 }

?>
<?php
 if(isset($_POST['logo_image_change']))
 {
 
$timezone = new DateTimeZone("Asia/Kolkata" );
$date = new DateTime();
$date->setTimezone($timezone );
$today2=$date->format('s');	
$logoimage=$_FILES['Lee_logo']['name'];
$logophoto="../../../img/logo/".$logoimage;
move_uploaded_file($_FILES["Lee_logo"]["tmp_name"],$logophoto);
$imageediton=date('Y-m-d'); 
$update_service_photo=mysqli_query($config,"update lee_master set Logo_Path='$logophoto',logo_status='".$_POST['leelogostatus']."' where Site_id='".$_POST['lee_logo_id']."'");
 if($update_service_photo==false)
{
echo "<script>window.location.href='../logo_name_Master.php?erro=0';</script>".mysqli_error();	 
}
else{
	
	echo "<script>window.location.href='../logo_name_Master.php?msg=100';</script>";	 

	
}

 }
 
 
 if($_SERVER['REQUEST_METHOD'] == 'POST'){
    
    $action = $_POST['action'];

// logo_master
    // logo update query starts
    if($action == 'edit_logo'){
        $images = $_FILES['logo_image']['name'];
        $old_filename = $_POST['old_logo_image'];
        $update_filename = "";
        if($images != NULL){
            $image_extension = pathinfo($images,PATHINFO_EXTENSION);
            $filename = time().'.'.$image_extension;
            $update_filename = $filename;
        }else{
            $update_filename = $old_filename;
        }
        
        $sql = "UPDATE lee_master SET Logo_Path = '$update_filename' " ;
        if($config->query($sql) === TRUE){
            if($images != NULL){
                if(file_exists('../../img/logo/'.$old_filename)){
                    unlink('../../img/logo/'.$old_filename);
                }
                move_uploaded_file($_FILES['logo_image']['tmp_name'],'../../img/logo/'.$update_filename);
            }
            $status = "Updated successfully";
            $alert = "primary";
        }else{
            $status = "Update Failed";
            $alert = "primary";
            // $_SESSION['msg'] = "Something went wrong" ;
            // header("location:../dashboard.php");
        }
    }
    // logo update query ends

}

?>
