<?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 --> 

    <?php

    date_default_timezone_set('Asia/Kolkata');

    extract($_POST);

    if(isset($sub))

    {

      $datee  = date("d-m-y m:s");

      $que = "INSERT INTO `tbl_certification`(`certificationNumber`, `companyName`, `address`, `scheme`,`validTill`,`createdOn`) VALUES ('$cer_name','$com_name','$address','$scheme','$cer_date','$datee')";

      if(mysqli_query($link,$que))

      {

        $msg = "<p style='color:green;'>Save Certification Successfully!!!</p>";

      }

      else

      {

        $msg = "Not Inserted your Certification";

      }

    }

    ?>    

    <!-- Updata Product -->

    <?php

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

    if(isset($upd))

    {

      $datee  = date("y-m-d m:s");

      $que = "UPDATE  tbl_certification SET certificationNumber='$cer_name', `companyName`='$com_name',`address`='$address',`scheme`='$scheme',`validTill`='$cer_date',`updatedOn`='$datee'  WHERE id=$id";

        if(mysqli_query($link,$que))

        {

          $msg = "<p style='color:green;'>Update Certification Successfully!!!</p>";

        }

    }

?>

<!-- Fetching these product -->

  <?php

    if(isset($_GET['edit']))

    {

      $sel = mysqli_query($link,"select * from tbl_certification where id=$id")or die("not Allow");

      $arr =  mysqli_fetch_assoc($sel);

    }

  ?>

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

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

        <h1>Add Certification</h1>

        <p class="lead"><?php if($_GET['edit']==""){echo 'Add';}else{echo 'Update';}?> your product below</strong>.</p>

      </div>

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

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

          <li><a href="dashboard.php">Add Certification</a></li>

          <li class="active"><?php if($_GET['edit']==""){echo 'Add';}else{echo 'Update';}?>Products</li>

        </ol>

      </div>

    </section>

    <!-- / PAGE TITLE -->

    <section>

      <div class="container-fluid">

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

        <div class="row">

          <form method="post">

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

              <a href="show-product.php" class="btn btn-primary">Back</a>

            </div>

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

              <div class="form-group">

                <label>Certificate Number</label><br>

                <input class="form-control" type="text"  name="cer_name" value="<?=$arr['certificationNumber'];?>">

              </div>

              <div class="form-group">

                <label>Company Name</label><br>

                <input class="form-control" type="text"  name="com_name" value="<?=$arr['companyName'];?>">

              </div>

              <div class="form-group">

                <label>Address</label><br>

                <textarea class="form-control"  name="address"><?=$arr['address'];?></textarea>

              </div>

              <div class="form-group">

                <label>Scheme</label><br>

                <input class="form-control" type="text"  name="scheme" value="<?=$arr['scheme'];?>">

              </div>

               <div class="form-group">

                <label>Valid Upto!</label><br>

                <?php

                if(isset($_GET['edit']))

                {

                ?>

                <valid><input type="text" value="<?=$arr['validTill'];?>" disabled style="background:red;color:white;"></valid>

                <?php

                }

                ?>

                <input class="form-control" type="date" name="cer_date">

              </div>

            </div>

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

              <div class="form-group">

                <?php

                if($_GET['edit']=="")

                {

                ?>

                  <input class="btn btn-primary text-center" type="submit" name="sub" value="SUBMIT">

                <?php

                }

                else

                {

                  ?>

                   <input class="btn btn-primary text-center" type="submit" name="upd" value="UPDATE">

                  <?php

                }

                ?>

              </div>

            </div>

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

            </div>

          </form>

        </div>

      </div>

    </section>

  <script> 

    CKEDITOR.replace(ckeditor1)

    CKEDITOR.replace(ckeditor2)

    CKEDITOR.replace(ckeditor3)

</script>

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

  </script>

    <!-- / container-fluid -->

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