<?php
include("header.php");
include("left-nev.php");
$page_title="Page Management";
$page_subtitle="Manage Page";
$table="tbl_page";
$conn=db();
?>
<!--######## delete cancel ########-->
<script type="text/javascript" src="jsfiles/pagetransfer.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!--######## delete cancel ########-->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
    <?php echo $page_title;?>
    <small><?php echo $page_subtitle;?></small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> Home</a></li>
      <li><a href="dashboard.php">Dashboard</a></li>
      <li><a href="page-management.php"><?php echo $page_title;?></a></li>
      <li class="active"><?php echo $page_subtitle;?></li>
    </ol>
  </section>
  <?php
  if($_GET['action']=="Delete")
  {
  $selsql=$user->FetchPageEdit($table,$_REQUEST['id']);
  $res=mysqli_fetch_array($selsql);
  $filename= $res['image'];
  unlink('../upload/banner/'.DIRECTORY_SEPARATOR.$filename); //delete it
  mysqli_query($conn,"delete from ".$table." where pg_id='".$_REQUEST['id']."'");
  $_SESSION['page-msg']="Deleted Successfully";
  $selsql=$user->DelPage($table,$_REQUEST['id']);
  }
  $class="style='color:black;font-weight:bold'";
  if($_GET['status']=="Active")
  {
  mysqli_query($conn,"update ".$table." set pg_status='Inactive' where pg_id='".$_REQUEST['id']."'");
  $_SESSION['page-msg']="Status Updated Successfully";
  $class="style='color:red;font-weight:bold'";
  }
  if($_GET['status']=="Inactive")
  {
  mysqli_query($conn,"update ".$table." set pg_status='Active' where pg_id='".$_REQUEST['id']."'");
  $_SESSION['page-msg']="Status Updated Successfully";
  $class="style='color:green;font-weight:bold'";
  }
  ?>
  <!-- Main content -->
  <section class="content">
    <div class="row">
      <div class="col-xs-12">
        
        <div class="box">
          <div class="box-header">
            <button type="button" class="btn bg-navy margin" onclick="window.location.href='add-page.php'">Add Page</button>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <?php
            // strrev(base64_encode($inputdata));
            //$inputdata="==wMyETJtRWY";
            //echo $k=base64_decode(strrev($inputdata));
            ?>
            <script>
            $(document).ready(function(){
            $("#page-msg").fadeOut(2000)
            });
            </script>
            <center><?php
            if($_SESSION["page-msg"]!=""){
            ?>
            <div class="form-group has-success" id="page-msg">
              <label class="control-label" for="inputSuccess"><i class="fa fa-check"></i> <?php echo $_SESSION["page-msg"];?></label>
            </div>
            <?php
            unset($_SESSION["page-msg"]);
            }
            ?></center>
            <table id="example1" class="table table-bordered table-striped">
              <thead>
                <tr>
                  <th>Pg. Id</th>
                  <th>Heading</th>
                  <th>Page Url</th>
                  <th>Meta Keyword</th>
                  <th>Status</th>
                  <th>Action</th>
                </tr>
              </thead>
              <tbody>
                <?php
                $pi=1;
                $selsql=$user->FetchPage($table);
                while($respage=mysqli_fetch_object($selsql)){
                ?>
                <tr>
                  <td><?php echo $pi;?></td>
                  <td><?php echo str_replace("^","'",$respage->pg_name);?></td>
                  <td><?php echo $respage->pg_url;?>
                  </td>
                  <td><?php echo str_replace("^","'",$respage->pg_meta_keyword);?></td>
                  <td>
                    <a href="?status=<?php echo $respage->pg_status;?>&id=<?php echo $respage->pg_id;?>" <?php echo $class;?>>
                      
                    <?php echo $respage->pg_status;?></a></td>
                    
                    <td><a href="add-page.php?action=Edit&id=<?php echo $respage->pg_id;?>">
                      <button type="submit" style="width:30px; height:30px;margin-top:10px;" title="Edit"><i class="fa fa-refresh" aria-hidden="true"></i></button>
                    </a>
                    <!--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:void(0);" title="Delete" onclick="checkdelete('?action=Delete&id=<?php echo $respage->pg_id;?>')">
                      <button type="submit" style="width:30px; height:30px;margin-top:10px;" title="Delete"><i class="fa fa-trash" aria-hidden="true"></i></button>
                    </a>-->
                    
                  </td>
                </tr>
                <?php $pi++;} ?>
              </tbody>
              
            </table>
          </div>
          <!-- /.box-body -->
        </div>
        <!-- /.box -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </section>
  <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php include("footer.php");?>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
  <!-- Create the tabs -->
  <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
    <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
    <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
  </ul>
  <!-- Tab panes -->
  <div class="tab-content">
    <!-- Home tab content -->
    <div class="tab-pane" id="control-sidebar-home-tab">
      <h3 class="control-sidebar-heading">Recent Activity</h3>
      <ul class="control-sidebar-menu">
        <li>
          <a href="javascript:void(0)">
            <i class="menu-icon fa fa-birthday-cake bg-red"></i>
            <div class="menu-info">
              <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
              <p>Will be 23 on April 24th</p>
            </div>
          </a>
        </li>
        <li>
          <a href="javascript:void(0)">
            <i class="menu-icon fa fa-user bg-yellow"></i>
            <div class="menu-info">
              <h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>
              <p>New phone +1(800)555-1234</p>
            </div>
          </a>
        </li>
        <li>
          <a href="javascript:void(0)">
            <i class="menu-icon fa fa-envelope-o bg-light-blue"></i>
            <div class="menu-info">
              <h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>
              <p>nora@example.com</p>
            </div>
          </a>
        </li>
        <li>
          <a href="javascript:void(0)">
            <i class="menu-icon fa fa-file-code-o bg-green"></i>
            <div class="menu-info">
              <h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>
              <p>Execution time 5 seconds</p>
            </div>
          </a>
        </li>
      </ul>
      <!-- /.control-sidebar-menu -->
      <h3 class="control-sidebar-heading">Tasks Progress</h3>
      <ul class="control-sidebar-menu">
        <li>
          <a href="javascript:void(0)">
            <h4 class="control-sidebar-subheading">
            Custom Template Design
            <span class="label label-danger pull-right">70%</span>
            </h4>
            <div class="progress progress-xxs">
              <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
            </div>
          </a>
        </li>
        <li>
          <a href="javascript:void(0)">
            <h4 class="control-sidebar-subheading">
            Update Resume
            <span class="label label-success pull-right">95%</span>
            </h4>
            <div class="progress progress-xxs">
              <div class="progress-bar progress-bar-success" style="width: 95%"></div>
            </div>
          </a>
        </li>
        <li>
          <a href="javascript:void(0)">
            <h4 class="control-sidebar-subheading">
            Laravel Integration
            <span class="label label-warning pull-right">50%</span>
            </h4>
            <div class="progress progress-xxs">
              <div class="progress-bar progress-bar-warning" style="width: 50%"></div>
            </div>
          </a>
        </li>
        <li>
          <a href="javascript:void(0)">
            <h4 class="control-sidebar-subheading">
            Back End Framework
            <span class="label label-primary pull-right">68%</span>
            </h4>
            <div class="progress progress-xxs">
              <div class="progress-bar progress-bar-primary" style="width: 68%"></div>
            </div>
          </a>
        </li>
      </ul>
      <!-- /.control-sidebar-menu -->
    </div>
    <!-- /.tab-pane -->
    <!-- Stats tab content -->
    <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
    <!-- /.tab-pane -->
    <!-- Settings tab content -->
    <div class="tab-pane" id="control-sidebar-settings-tab">
      <form method="post">
        <h3 class="control-sidebar-heading">General Settings</h3>
        <div class="form-group">
          <label class="control-sidebar-subheading">
            Report panel usage
            <input type="checkbox" class="pull-right" checked>
          </label>
          <p>
            Some information about this general settings option
          </p>
        </div>
        <!-- /.form-group -->
        <div class="form-group">
          <label class="control-sidebar-subheading">
            Allow mail redirect
            <input type="checkbox" class="pull-right" checked>
          </label>
          <p>
            Other sets of options are available
          </p>
        </div>
        <!-- /.form-group -->
        <div class="form-group">
          <label class="control-sidebar-subheading">
            Expose author name in posts
            <input type="checkbox" class="pull-right" checked>
          </label>
          <p>
            Allow the user to show his name in blog posts
          </p>
        </div>
        <!-- /.form-group -->
        <h3 class="control-sidebar-heading">Chat Settings</h3>
        <div class="form-group">
          <label class="control-sidebar-subheading">
            Show me as online
            <input type="checkbox" class="pull-right" checked>
          </label>
        </div>
        <!-- /.form-group -->
        <div class="form-group">
          <label class="control-sidebar-subheading">
            Turn off notifications
            <input type="checkbox" class="pull-right">
          </label>
        </div>
        <!-- /.form-group -->
        <div class="form-group">
          <label class="control-sidebar-subheading">
            Delete chat history
            <a href="javascript:void(0)" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
          </label>
        </div>
        <!-- /.form-group -->
      </form>
    </div>
    <!-- /.tab-pane -->
  </div>
</aside>
<!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
<!-- jQuery 2.2.3 -->
<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- page script -->
<script>
$(function () {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
</body>
</html>