<?php include('../../config/setup.php');?>
<?php 


if(isset($_POST['leadership_add'])){
    // $timezone = new DateTimeZone("Asia/Kolkata" );
    // $date = new DateTime();
    // $date->setTimezone($timezone );
    // $today2=$date->format('s');	
    $title = $_POST['leadership_title'];
    $position = $_POST['leadership_position'];
    $desc = $_POST['leadership_desc'];
    $status = $_POST['leadership_status'];
    $addsugcatephoto=$_FILES['leadership_img']['name'];
    $addsubphoto="../../../img/leadership/".$addsugcatephoto;
    move_uploaded_file($_FILES["leadership_img"]["tmp_name"],$addsubphoto);
    $maincate=date('Y-m-d');
    $addsubcate=mysqli_query($config,"INSERT INTO leadership_master(leadership_title,leadership_position,leadership_desc,leadership_img,leadership_status)
                                    VALUES('$title','$position','$desc','$addsugcatephoto','$status')");	
    if($addsubcate==false)
    {
        
        echo "<script>window.location.href='../leadership_master.php?erro=0';</script>".mysqli_error();	 
    }
    else{
        
        echo "<script>window.location.href='../leadership_master.php';</script>";	 

        
    }	

}


 if(isset($_POST['leadership_pro']))
	{  $lid = $_POST['leadership_id'];
		$title = $_POST['leadership_title'];
		$position = $_POST['leadership_position'];
		$desc = $_POST['leadership_desc'];
		$status = $_POST['leadership_status'];
	$sql = "UPDATE leadership_master SET leadership_title = '$title' ,leadership_position = '$position',leadership_desc = '$desc',leadership_status = '$status' WHERE leadership_id = '$lid' ";

	if($config->query($sql) == false)
	{
	echo mysqli_error();	 
	}
	else{
		
		echo "<script>window.location.href='../leadership_master.php?msg=100';</script>";	 
		
	}

 }

 if(isset($_POST['Edit_leadership_img']))
 {
// 	 $up_main_cate=mysqli_query($config,"select Sub_Category_image from slider_master where slider_id='".$_POST['Edit_pro_slider_id']."'");
// $up_cate=mysqli_fetch_array($up_main_cate);
// unlink($up_cate[0]);
// $timezone = new DateTimeZone("Asia/Kolkata" );
// $date = new DateTime();
// $date->setTimezone($timezone );
// $today2=$date->format('s');	
$lid = $_POST['leadership_id'];
$subimage=$_FILES['leadership_img']['name'];
$subcatephoto="../../../img/leadership/".$subimage;
move_uploaded_file($_FILES["leadership_img"]["tmp_name"],$subcatephoto);
$imageediton=date('Y-m-d'); 
 $sql = "UPDATE leadership_master SET leadership_img='$subimage' WHERE leadership_id = '$lid' ";

$update_service_photo=mysqli_query($config,$sql);
 if($update_service_photo==false)
{
echo "<script>window.location.href='../leadership_master.php?erro=0';</script>".mysqli_error();	 
}
else{
	
	echo "<script>window.location.href='../leadership_master.php?msg=100';</script>";	 

	
}

 }

?>