<?php
include("header.php");
include("leftSideMenu.php");
include("../config.php");

if( isset($_GET['task']) && $_GET['task'] == 'delete' ){
	$pageId	= $_GET['id'];
	$result	= mysql_query("DELETE FROM menus WHERE id ='".$pageId."'");
	if($result){
		$redirectUrl = SITE_URL.'admin/leftMenuListing.php';
		echo "<script>window.location.href='$redirectUrl'</script>";
	}
}

?>

<script type="text/javascript">
function confirmDelete() {
	var agree = confirm("Are you sure to delete this user");
	if (agree) return true;
	else return false ;
}

function confirmDelete(){
  var agree = confirm("Are you sure to delete this user");
	if (agree) return true;
	else return false ;
}
</script>

<div id="main">
	<div class="full_w">
		<div class="h_title">Left Menu Listing</div>
		<p>List of all pages under Left Menu</p>
			
		<div class="entry">
			<div class="sep"></div>
		</div>
		<table>
			<thead>
				<tr>
					<th scope="col">Sr No.</th>
					<th scope="col">Page Name</th>
					<!--<th scope="col">Last Modified</th>-->
					<th scope="col">Action</th>
				</tr>
			</thead>
			
    <?php
      $sqlGetPages  = "SELECT * FROM menus WHERE menu_type = 'left'";
      $result       = mysql_query($sqlGetPages);
      if(count($result) > 0){
      $i = 1;
      while($pages = mysql_fetch_array($result)){
    ?>
      <tbody>
        <tr>
          <td><?php echo $i; ?></td>
          <td><?php echo $pages['page_name'];?></td>
          <!--<td></td>-->
          <td>
            <a href="addLeftMenu.php?editid=<?php echo $pages['id']?>" class="table-icon edit" title="Edit"></a>
            <a href="leftMenuListing.php?task=delete&id=<?php echo $pages['id']?>" class="table-icon delete" title="Delete" onClick="return confirmDelete()"></a>
          </td>
        </tr>
      </tbody>
    <?php
        $i++;
      }
      }
    ?>
		</table>

		<div class="entry">
			<div class="sep"></div>
			<a href="addLeftMenu.php" class="button add">Add New Page</a>
		</div>
		
	</div>

</div>
<div class="clear"></div>
</div>

<?php include("footer.php"); ?>