<?php include('site-header.php'); ?>
  <!-- end of LOGO CONTAINER -->
  <!-- - - - - - - - - - - - - -->
  <!-- start of SIDEBAR        -->
  <!-- - - - - - - - - - - - - -->
  <?php include('left-nevigation.php'); ?>
  <!-- - - - - - - - - - - - - -->
  <!-- end of SIDEBAR          -->
  <!-- - - - - - - - - - - - - -->
  <main id="playground">
    <!-- - - - - - - - - - - - - -->
    <!-- start of TOP NAVIGATION -->
    <!-- - - - - - - - - - - - - -->
<?php 

$image_name=$_FILES['logo_image_name']['name']; 
$image_names= time()."_".$image_name;

?>    
<?php
if(isset($_REQUEST['Insert']))
{
      $sqlinsrt="insert into tbl_web_logo set
      logo_image_name='$image_names'";
      mysqli_query($link,$sqlinsrt);
      move_uploaded_file($_FILES['logo_image_name']['tmp_name'],"../header-image/".$image_names);         
}
?>     
<?php
if(isset($_POST['Updt']))
{
      $sqlinsrt="update tbl_web_logo set
      logo_image_name='$image_names'
      where logo_id='$_REQUEST[img_id]'";
      if(mysqli_query($link,$sqlinsrt))
              {
                unlink("../header-image/$pdf_name_del"); 
                move_uploaded_file($_FILES['logo_image_name']['tmp_name'],"../header-image/".$image_names);
                $img = "<p style='color:green;'>Update Logo successfully!!!!!</p>";
              }
     
              
}
?>
<?php
//New Update 

if(isset($_POST['Updt_new']))
{
      if($_FILES['pdf_name']['name']!=="")
      {
       $pdf_name=$_FILES['pdf_name']['name']; 
       $pdf_names= time()."_".$pdf_name;
       $pdf_name_del=$_POST['pdf_name_del'];
       $sqlUp ="UPDATE `tbl_web_logo` SET 
                      `new_and_update`='$pdf_names'
                       WHERE `logo_id`='$_REQUEST[img_id]'";
            $run=mysqli_query($link,$sqlUp);
            if($run)
              {
                unlink("../header-image/$pdf_name_del"); 
                move_uploaded_file($_FILES['pdf_name']['tmp_name'],"../header-image/".$pdf_names);
                 $img = "<p style='color:green;'>Update pdf successfully!!!!!</p>";
              }
      }
      else
      {
        $img = "<p style='color:red;'>Select Pdf !!!!!</p>";
      }
     
}
?>

<?php 
if($_REQUEST['del_id']!="")
{
    $del_id=$_REQUEST['del_id'];
    $sql="delete from tbl_web_logo where logo_id='$del_id'";
    $data=mysqli_query($link,$sql);
}
?> 
<?php
      $sql="select * from tbl_web_logo where 1";
      $data=mysqli_query($link,$sql);
      $count=mysqli_num_rows($data);
?>
<?php include('site-top-header.php'); ?>
    <!-- - - - - - - - - - - - - -->
    <!-- end of TOP NAVIGATION   -->
    <!-- - - - - - - - - - - - - -->
    <!-- PAGE TITLE -->
    <section id="page-title" class="row">
      <div class="col-md-8">
        <h1>Company Logo</h1>
        <p class="lead">Update your company logo.</p>
        <p>Image Size company logo(290 x 90)Pixel</p>
        <?=$img;?>
      </div>
      <div class="col-md-4">
       <!--  <ol class="breadcrumb pull-right no-margin-bottom">
         <li><a href="dashboard.php">Company Logo</a></li>
          <li class="active">Update Logo</li>
        </ol> -->
      </div>
    </section>
    <!-- / PAGE TITLE -->
    <div class="container-fluid">
      <div class="row">
        <?php while($result=mysqli_fetch_array($data)){ ?>
        <form enctype="multipart/form-data" method="post">
         <div class="col-md-5">
          <section class="panel tasks-widget"> <img  src="../header-image/<?php echo $result['logo_image_name']; ?>" class="img-responsive" style="width:100%; height:110px;"> </section>
          <div class="text-center">
            <input type="file" name="logo_image_name">
          </div>
          <input type="hidden" name="img_id" value="<?php echo $result['logo_id'] ?>">
          <div class="text-center"><button class="btn btn-primary" name="Updt" style="width:100%;">Update</button></a> </div>
          </form>
          <form method="post">
               <input type="hidden" name="del_id" value="<?php echo $result['logo_id'] ?>">
               <input type="hidden" name="pdf_name_del" value="<?php echo $result['new_and_update'] ?>">
            <div class="text-center"><button class="btn btn-primary" name="del" style="width:100%;">Delete</button></a> </div>
          
         </div>
        </form>
        <div class="col-md-2">
        </div>        
         <div class="col-md-5">
         <!-- <form enctype="multipart/form-data" method="post">
          <embed src="../header-image/<?php echo $result['new_and_update']; ?>" width="100%" height="200px" />
           <input type="file" name="pdf_name">
          <label>UPDATE NEWS</label>
          <input type="hidden" name="img_id" value="<?php echo $result['logo_id'] ?>">
          <input type="hidden" name="pdf_name_del" value="<?php echo $result['new_and_update'] ?>">
            <div class="text-center">
              <button class="btn btn-primary" name="Updt_new" style="width:100%;">Update</button>
            </div>          
          </form> -->  
        </div> 
        <?php } ?>
       
      </div>
      <!-- / row -->
    </div>
       <?php if($count>=1){
	echo "";
	}else{
		
		
		 ?>
    <div class="container-fluid" style="margin-top:80px;">
      <div class="row">
        <div class="col-md-4">
         
        </div>
        <form method="post" enctype="multipart/form-data">
        <div class="col-md-4">
      <div class="text-center"> <input type="file" name="logo_image_name" class="btn btn-primary"> </div>
          <div class="text-center"> <button type="submit" name="Insert" class="btn btn-primary" style=" width:100%;">Add Banner </button></div>
        </div>
        </form>
        <div class="col-md-4">
          
        </div>
      </div>
      <!-- / row -->
    </div>
    <?php } ?>
    <!-- / container-fluid -->


    <script type="text/javascript">
$('document').ready(function()
{
    $('textarea').each(function(){
            $(this).val($(this).val().trim());
        }
    );
});
</script>
<?php include('site-footer.php'); ?>