<?php

if($_SESSION["type"] != 1){
	echo "No permission to access"; die();
	}

?>
<div class="row">
    <div class="col-lg-12" style="margin-top:-41px;margin-bottom:-13px;">
        <h1 class="page-header" style="font-size:19px; color:#09F;"><i class="fa fa-user fa-fw"></i>&nbsp;Category</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- Row -->
<div class="row">
	<div class="col-lg-12">
        <div class="panel panel-default" style="width:100%;">
            <div class="panel-body">
                <div class="row">
    				<div class="col-lg-6">
        				<div class="form-group">
                            <a href="?page=addnewcategory">
                            <input type="button" name="addnew" class="btn btn-primary" value="&nbsp;AddNew&nbsp;" title="AddNew Category"/>
                            </a>
        				</div>
    				</div>
    				<!-- /.col-lg-6 -->
                </div>
                <!-- Row -->
            </div>
        </div>
     </div>
     </div>
<!-- row -->

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default" style="width:100%;">
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th style="text-align:center">No</th>
                                <th style="text-align:center">
                                    Main Menu
                                </th>
                                <th style="text-align:center">
                                    Category Name
                                </th>
                                <th style="text-align:center">
                                    Order No
                                </th>
                                <th style="text-align:center" width="30">Edit</th>
                                <th style="text-align:center" width="30">Delete</th>
                                
                            </tr>
                        </thead>
                        <tbody>
                        	<?php
								function getcat($pr_id){
									global $conn;
									$sql2="select cat_title from tbl_category where cat_id = $pr_id";
									$res=mysqli_query($conn,$sql2);
									$row2 = mysqli_fetch_array($res);
									return $row2['cat_title']; 
								}
							?>
                        
                            <?php
								$user_id=$_SESSION["user_id"];
								mysqli_query($conn,'SET NAMES utf8');
								$sql="select * from tbl_category where cat_id !=0 and pr_id !=0 order by pr_id ASC";
								$res=mysqli_query($conn,$sql);
								$i=0;
								while($row=mysqli_fetch_array($res)){
									
										
							?> 
                            <tr>
                                <td style="font-size:12px; width:40px;" align="center"><?php echo $i+=1; ?></td>
                                <td style="font-size:12px;">
								<?php echo getcat($row['pr_id']); ?>
                                </td>
                                <td style="font-size:12px;"><?php echo $row['cat_title'];?></td>
                                <td style="font-size:12px; width:70px; text-align:center"><?php echo $row['cat_order'];?></td>         
                                <td align="center"><a href="?page=editcategory&cat_id=<?php echo $row['cat_id'] ?>" title="edit"><div class="fa fa-edit fa-fw"></div></a></td>
                                <td align="center"><a href="#myModal<?php echo $row['cat_id']; ?>" data-toggle="modal" title="delete"><div class="fa fa-trash-o fa-fw"></div></a></td>
                            </tr>
                            <div class="modal small fade" id="myModal<?php echo $row['cat_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                              <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                        <h3 id="myModalLabel">Tollay User Confirmation Delete</h3>
                                    </div>
                                    <div class="modal-body">
                                        <p class="error-text"><i class="fa fa-warning modal-icon"></i>Are you sure you want to delete this User?</p><br/>
                                        <label style="font-size:19px; color:#09F;">User Name : <?php echo $row['cat_title']; ?></label>
                                    </div>
                                    <div class="modal-footer">
                                        <a class="btn btn-danger" href="include/category/delete_category.php<?php echo '?cat_id='.$row['cat_id'];?>" ><i class="icon-check"></i>&nbsp;Yes</a>
                                        <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i> Close</button>
                                    </div>
                                  </div>
                                </div>
                            </div>
                            <?php } ?>
                           
                        </tbody>
                    </table>
                </div>
                <!-- /.table-responsive -->
                
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->
