<?php include('site-header.php'); ?>

<!-- end of LOGO CONTAINER -->

<!-- - - - - - - - - - - - - -->

<!-- start of SIDEBAR        -->

<!-- - - - - - - - - - - - - -->

<?php include('left-nevigation.php'); ?>

<!-- - - - - - - - - - - - - -->

<!-- end of SIDEBAR          -->

<!-- - - - - - - - - - - - - -->

<script src="ckeditor/ckeditor.js"></script>  

<main id="playground">

<!-- - - - - - - - - - - - - -->

<!-- start of TOP NAVIGATION -->

<!-- - - - - - - - - - - - - -->

<?php include('site-top-header.php'); ?>

<!-- - - - - - - - - - - - - -->

<!-- end of TOP NAVIGATION   -->

<!-- - - - - - - - - - - - - -->

<!-- PAGE TITLE --> 

<section id="page-title" class="row">

   <div class="col-md-8">

      <h1>Dashboard</h1>

      <p class="lead">Add your E-Brachure Product</strong>.</p>

   </div>

   <div class="col-md-4">

      <ol class="breadcrumb pull-right no-margin-bottom">

         <li><a href="dashboard.php">Dashboard</a></li>

         <li class="active">Add E-Brachure</li>

      </ol>

   </div>

</section>

<!-- / PAGE TITLE -->

<?php

$id = mysqli_real_escape_string($link,$_GET['ebra']);

$tmp  = $_FILES['att']['tmp_name'];

$name = $_FILES['att']['name'];

$ext = pathinfo($name, PATHINFO_EXTENSION);

$_FILES['att']['type'];

$fnn = rand()."_".$name;

if(isset($_POST['upload']))

{

  $hiden_file = $_POST['hidden_file'];

  if($ext=="pdf"||$ext=="xlsx")

  {

    if(mysqli_query($link,"update tbl_product set ebra_name='$fnn' where pro_id='$id'"))

    {

      move_uploaded_file($tmp, "../pdf-product/$fnn");

      unlink("../pdf-product/$hiden_file");

      $msg = "<p style='color:green'>Successfylly Upload pdf!!!!!</p>";

    }

  }

  else

  {

    $msg = "<p style='color:red;'>Only Upload Pdf File!!!!</p>";

  }

}

//end if isset condition

?>

<!-- Delte Video -->

<?php

if(isset($_POST['delete']))

{

  $hiden_file = $_POST['hidden_file'];

  $file = "";

  if(mysqli_query($link,"update tbl_product set ebra_name='$file' where pro_id=$id"))

  {

    unlink("../pdf-product/$hiden_file");

    $msg = "<p style='color:red'>Delete Successfully pdf!!!</p>";

  }

  else

  {

    echo "Not Delete";

  }

}

?>



<?php

  $sel = mysqli_query($link,"select * from tbl_product where pro_id=$id");

  $fetch = mysqli_fetch_assoc($sel);

?>

<section>

   <div class="container-fluid">

      <div class="row">

        <a href="show-product.php" class="btn bnt-primary" style="margin-left:10  px;">Back</a>

      </div>

      <div class="row">

         <label><?=@$msg;?></label><br>

         <label style='margin-left: 12px;'>(Pdf File Upload ):<?php if($fetch['ebra_name']!=""){echo "<h1 style='background-color:green; color:black;'>(Yes)</h1>";}else{echo "<h1 style='background:red;color:black;'>(No)</h1>";}?></label>

      </div>

      <div class="row">

         <form method="post" enctype="multipart/form-data">

            <div class="col-md-6">

               <div class="form-group">

                  <label>E-Brachure:</label>

                  <input type="hidden" name="hidden_file" value="<?=$fetch['ebra_name'];?>">

                  <input type="file" name="att">

               </div>

               <input type="submit" name="upload" value="upload" class="btn btn-primary">

               <input type="submit" name="delete" value="Delete" class="btn btn-danger">

            </div>

         </form>

      </div>

   </div>

</section>

<script> CKEDITOR.replace(ckeditor1)</script>

<script src="ckeditor/ckeditor.js"></script>

<!-- / container-fluid -->

<?php include('site-footer.php'); ?>