<?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 include('site-top-header.php'); ?>
<!-- - - - - - - - - - - - - -->
<!-- end of TOP NAVIGATION   -->
<!-- - - - - - - - - - - - - -->
<!-- PAGE TITLE -->
<?php 
   $image_name=$_FILES['header_image_name']['name']; 
   $image_names= time()."_".$image_name;
   
   $del_image = $_REQUEST['del_image'];
   ?>
<?php
   if(isset($_REQUEST['Insert'])){
   $sqlinsrt="insert into header_flash set
   header_image_name='$image_names'";
      if(mysqli_query($link,$sqlinsrt))
                 {
                   move_uploaded_file($_FILES['header_image_name']['tmp_name'],"../header-image/".$image_names); 
                   $img = "<p style='color:green;'>Image Upload successfully!!!!!</p>";
                 }
   
   }
   ?> 
<?php
   if(isset($_REQUEST['Updt']))
   {
         $flash_title =$_REQUEST['flash_title'];
         $pro_name_one =$_REQUEST['pro_name_one'];
         $pro_name_two = $_REQUEST['pro_name_two'];
        if($_FILES['header_image_name']['name']!=="")
        { 
           $sqlUp = "UPDATE `header_flash` SET 
                     `header_image_name`='$image_names',
                     `flash_title`='$flash_title',
                     `pro_name_one`='$pro_name_one',
                     `pro_name_two`='$pro_name_two' 
                     WHERE `header_id`='$_REQUEST[img_id]'";  

            if(mysqli_query($link,$sqlUp))
                 {
                   unlink("../header-image/$del_image"); 
                   move_uploaded_file($_FILES['header_image_name']['tmp_name'],"../header-image/".$image_names); 
                   $img = "<p style='color:green;'>Image Upload successfully!!!!!</p>";
                 }
        }
        else
        {
            $sqlUp_t = "UPDATE `header_flash` SET 
                     `flash_title`='$flash_title',
                     `pro_name_one`='$pro_name_one',
                     `pro_name_two`='$pro_name_two' 
                     WHERE `header_id`='$_REQUEST[img_id]'"; 

            if(mysqli_query($link,$sqlUp_t))
                    {
                       $img = "<p style='color:green;'>update successfully!!!!!</p>";
                    }
        }
           
   }
   ?> 
<?php 
   if($_REQUEST['del_logo_id']!="")
   {
   $del_logo_id=$_REQUEST['del_logo_id'];
   $sql="delete from header_flash where header_id='$del_logo_id'";
   if(mysqli_query($link,$sql))
                 {
                   unlink("../header-image/$del_image"); 
                   $img = "<p style='color:green;'>Delete Image  successfully!!!!!</p>";
                 }
   }
   ?>
<?php
   $sql="select * from header_flash where 1";
   $data=mysqli_query($link,$sql);
   $count = mysqli_num_rows($data);
   ?> 
 <div class="container-fluid textsss">     
<section id="page-title" class="row">
   <div class="col-md-8">
      <h1>Flash Image</h1>
      <p class="lead">Update your flash image in home page</strong>.</p>
      <p style="font-weight: bold;font-size:18px;">flash Image Size(540 x 406)Pixel</p>
      <?=$img?>
   </div>
   <div class="col-md-4">
   </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-4">
            <section class="panel tasks-widget"> <img  src="../header-image/<?=$result['header_image_name'];?>" class="img-responsive" style="height:280px; width:100%;"> </section>
            <div class="text-center"><input type="file" name="header_image_name"></div>

      <input type="text" value="<?=$result['flash_title'];?>" name="flash_title" class="form-control" placeholder=" Title:.............">
           <!-- <input type="text" value="<?=$result['pro_name_two'];?>" name="pro_name_two" class="form-control" placeholder="Sub Title:"> -->
           <textarea name="pro_name_one" placeholder="Description" class="form-control" style="width: 100%; height: 100px;">
             <?=$result['pro_name_one'];?>
           </textarea>
             

            <input type="hidden" name="img_id" value="<?=$result['header_id'] ?>">
            <input type="hidden" name="del_image" value="<?=$result['header_image_name'] ?>">
            <div class="text-center"><button class="btn btn-primary" name="Updt" style="width:100%;">Update</button> </div>
      </form>
      <form method="post">
      <input type="hidden" name="del_logo_id" value="<?php echo $result['header_id'] ?>">
      <input type="hidden" name="del_image" value="<?=$result['header_image_name'] ?>">
      <div class="text-center"><button class="btn btn-primary" name="del" style="width:100%;">Delete</button> </div> 
      </form>
      </div>
      <?php } ?>
   </div>
   <!-- / row -->
</div>
<?php if($count>=100){ 
   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="header_image_name" class="btn btn-primary" > </div>
            <div class="text-center"> <button type="submit" name="Insert" class="btn btn-primary" style=" width:100%;">Add Image </button></div>
         </div>
      </form>
      <div class="col-md-4">
      </div>
   </div>
   <!-- / row -->
</div>
<?php } ?>
</div>
<!-- / container-fluid -->
<script type="text/javascript">
  $('document').ready(function()
{
    $('textarea').each(function(){
            $(this).val($(this).val().trim());
        }
    );
});
</script>
<?php include('site-footer.php'); ?>