<?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
    extract($_POST);
    if(isset($sub))
    {
         if(mysqli_query($link,"insert into tbl_application(app_name,app_desc) values('$app_name','$app_desc')"))
         {
          $msg = "<p style='color:green;'>Application Successfully Save!!!!</p>";
         }
         else
         {
          $msg = "<p style='color:red;'>Application Not Save Try Again!!!!</p>";
         }
     
    }
    ?>
    <!-- Update Query -->

    <?php
    if(isset($upd))
    {
        $id = mysqli_real_escape_string($link,$_GET['edit']);
         if(mysqli_query($link,"Update tbl_application set app_name='$app_name',app_desc='$app_desc' where app_id=$id"))
         {
          $msg = "<p style='color:green;'>Application Uppdate Successfully!!!!</p>";
         }
         else
         {
          $msg = "<p style='color:red;'>Application Not Upadate!!!!</p>";
         }
     
    }
    ?>
    <?php
    if(isset($_GET['edit']))
    {
      $id = mysqli_real_escape_string($link,$_GET['edit']);
      $sel = mysqli_query($link,"select * from tbl_application where app_id=$id");
      $edit = mysqli_fetch_assoc($sel);
    }
    ?>
    <section id="page-title" class="row">
      <div class="col-md-8">
        <h1>Dashboard</h1>
        <p class="lead">Add your Application below</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 Application</li>
        </ol>
      </div>
    </section>
    <!-- / PAGE TITLE -->
    <div class="container-fluid">
      <div>
        <a href="show-application.php" class="btn btn-primary" style="margin-left: 25px;">Back</a>
      </div>
      <div class="row">
      	<div class="col-md-6">
        <div class="panel-body">
              <form method="post" enctype="multipart/form-data">
                <div class="form-group">
                  <label class="text-danger"><?=$msg;?></label><br>
                  <label for="">Application Name</label>
                  <input type="text" class="form-control" name="app_name" value="<?=@$edit['app_name'];?>" placeholder="Enter Your Category Name">
                </div>
        </div>	
        </div>
      </div>
      <div class="col-md-12">
        <label>Application Desc</label>
        <textarea class="form-control" id="ckeditor1" name="app_desc" style="width:100%"><?=@$edit['app_desc'];?></textarea>
      </div>
      <div class="row">   
      <script>
      CKEDITOR.replace(ckeditor1)  
  	  </script>
      </div>
      <?php
      if(isset($_GET['edit']))
      {
        ?>
         <input type="submit" class="btn btn-primary" name="upd" value="Update" style="margin-left:3rem;">
        <?php
      }
      else
      {
        ?>
        <input type="submit" class="btn btn-primary" name="sub" value="Submit" style="margin-left:3rem;">
        <?php
      }
      ?>
     
      </form>
    </div>
  
    
    <!-- / container-fluid -->
 <?php include('site-footer.php'); ?>