?
Path : /home/u949514618/domains/karmaasrconsultants.com/public_html/admin/ |
Current File : /home/u949514618/domains/karmaasrconsultants.com/public_html/admin/latestnews.php |
<?php include_once("tophead.php"); $session_username = $_SESSION['username']; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Admin | Dashboard</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <!-- Bootstrap 3.3.7 --> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"> <!-- Font Awesome --> <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css"> <!-- Ionicons --> <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css"> <!-- DataTables --> <link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css"> <!-- Theme style --> <link rel="stylesheet" href="dist/css/AdminLTE.min.css"> <!-- AdminLTE Skins. Choose a skin from the css/skins folder instead of downloading all of them to reduce the load. --> <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> <!-- Google Font --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic"> </head> <?php if(isset($_GET['del'])){ $del_id = $_GET['del']; if($_SESSION['role'] == 'admin'){ $del_check_query = "select * from latestnews where id = $del_id"; $delete_check_run = mysqli_query($con, $del_check_query); } else if($_SESSION['role'] == 'author'){ $del_check_query = "select * from latestnews where id = $del_id && author = '$session_username'"; $delete_check_run = mysqli_query($con, $del_check_query); } if(mysqli_num_rows($delete_check_run) > 0){ $del_query = "DELETE FROM `latestnews` WHERE `id` = $del_id"; if(mysqli_query($con, $del_query)){ $msg = "Post Has been deleted"; } else{ $error = "Post has not been deleted"; } } } if(isset($_POST['checkboxes'])){ foreach($_POST['checkboxes'] as $user_id){ $bulk_option = $_POST['bulk-options']; if($bulk_option == 'delete'){ $bulk_del_query = "DELETE FROM `latestnews` WHERE `id` = $user_id"; mysqli_query($con, $bulk_del_query); } else if($bulk_option == 'published'){ $bulk_author_query = "update `latestnews` set `status` = 'published' where `id` = $user_id"; mysqli_query($con, $bulk_author_query); } else if($bulk_option == 'draft'){ $bulk_admin_query = "update `latestnews` set `status` = 'draft' where `id` = $user_id"; mysqli_query($con, $bulk_admin_query); } } } ?> <body class="hold-transition skin-blue sidebar-mini"> <div class="wrapper"> <?php include_once("header.php"); ?> <!-- Left side column. contains the logo and sidebar --> <?php include_once("leftsidebar.php"); ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <form action="#" method="post"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> Offers </h1> <ol class="breadcrumb"> <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li> <li class="active">Offers</li> </ol> </section> <!-- Main content --> <section class="content"> <!-- Small boxes (Stat box) --> <div class="row"> <div class="col-xs-12"> <div class="box"> <?php if($_SESSION['role'] == 'admin'){ $query = "select * from latestnews order by id desc"; $run = mysqli_query($con, $query); } else if($_SESSION['role'] == 'author') { $query = "select * from latestnews where author = '$session_username' order by id desc"; $run = mysqli_query($con, $query); } if(mysqli_num_rows($run) > 0){ ?> <div class="box-header"> <h3 class="box-title">All Detail Here</h3> <div class="clear"></div> <div class="col-md-6"> <select name="bulk-options" class="form-control" id="" width="50%"> <option value="delete">Delete</option> <option value="published">Published</option> <option value="draft">Draft</option> </select> </div> <div class="col-md-3"><input type="submit" value="Apply" class="btn btn-block btn-primary"></div> <div class="col-md-3"><a href="add-latestnews.php" class="btn btn-block btn-primary">Add Post</a></div> </div> <!-- /.box-header --> <div class="box-body"> <?php if(isset($error)){ echo "<span style='color:red;' class='pull-right'>$error</span>"; } else if(isset($msg)){ echo "<span style='color:green;' class='pull-right'>$msg</span>"; } ?> <table id="example1" class="table table-bordered table-striped"> <thead> <tr> <th><input type="checkbox" id="selectallboxes" /></th> <th>Sr #</th> <th>Date</th> <th>Title</th> <th>Description</th> <th>Image</th> <th>Status</th> <th>Edit</th> <th>Del</th> </tr> </thead> <tbody> <?php while($row=mysqli_fetch_array($run)) { $id = $row['id']; $desc = $row['description']; $title = $row['title']; $image = $row['image']; $date = getdate($row['date']); $day = $date['mday']; $month = substr($date['month'],0,3); $year = $date['year']; $status = $row['status']; ?> <tr> <td><input type="checkbox" class="checkboxes" name="checkboxes[]" value="<?php echo $id; ?>" /></td> <td><?php echo $id; ?></td> <td><?php echo "$day $month $year"; ?></td> <td><?php echo $title; ?></td> <td><?php echo $desc; ?></td> <td><img src="latestnews/<?php echo $image; ?>" width="32px;"></td> <td><span style="color:<?php if($status == 'published'){ echo 'green'; } else if($status == 'draft'){ echo 'red';}?>;"><?php echo ucfirst($status);?></span></td> <td><a href="edit-latestnews.php?edit=<?php echo $id; ?>"><i class="fa fa-pencil"></i></a></td> <td><input type="button" name="delete" value="Delete" onclick="deleteme(<?php echo $id; ?>)"></td> </tr> <script type="text/javascript"> function deleteme(delid) { if(confirm("Do You Wanna Delete!")) { window.location.href='latestnews.php?del=' +delid+''; return true; } } </script> <?php } ?> </tbody> <tfoot> <tr> <th><input type="checkbox" /></th> <th>Sr #</th> <th>Date</th> <th>Title</th> <th>Description</th> <th>Image</th> <th>Status</th> <th>Edit</th> <th>Del</th> </tr> </tfoot> </table> </div> <!-- /.box-body --> <?php } else { echo "<center><h3>No Data available now!!</h3></center>"; } ?> </div> <!-- /.box --> </div> </div> <!-- /.row --> <!-- Main row --> <!-- /.row (main row) --> </section> <!-- /.content --> </form> </div> <!-- /.content-wrapper --> <?php include_once("footer.php"); ?> <!-- Control Sidebar --> <?php include_once("controlsidebar.php"); ?> <!-- /.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 3 --> <script src="bower_components/jquery/dist/jquery.min.js"></script> <!-- Bootstrap 3.3.7 --> <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <!-- DataTables --> <script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script> <script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script> <!-- SlimScroll --> <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script> <!-- FastClick --> <script src="bower_components/fastclick/lib/fastclick.js"></script> <!-- AdminLTE App --> <script src="dist/js/adminlte.min.js"></script> <!-- AdminLTE for demo purposes --> <script src="dist/js/demo.js"></script> <script src="dist/js/ownuse.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>