<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>

<?php
if ($level == '1')
{
    $title = "List Of Support Tickets";
}
else
{
    $title = "List Of My Support Tickets";
}
?>

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">

<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">

<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->
    
<!-- Start Page Content -->
<!-- ============================================================== -->
<div class="row">
<div class="col-lg-12">
    <div class="card">
        <div class="card-body">
            <h4 class="card-title"><?php echo $title; ?></h4>
            <h6 class="card-subtitle">Export data to Copy, CSV, Excel, PDF & Print</h6>
            <div class="table-responsive m-t-40">
                <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                <table id="example23"
                    class="display nowrap table table-hover table-striped table-bordered"
                    cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Subject</th>
                            <th>Priority</th>
                            <th>Category</th>
                            <th>Created Date</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>                                      
                    <tbody>
                        <?php
                        if ($level == '1')
                        {
                            $q = "SELECT *
                            FROM support_ticket  
                            order by id Desc ";
                        }
                        else
                        {
                            $q = "SELECT *
                            FROM support_ticket  
                            Where ref_code = '$ref_code'
                            order by id Desc ";
                        }                       

                        $result = $mysqli->query($q);
                        if ($result->num_rows > 0)
                        {
                            while($record = $result -> fetch_assoc())
                            {  						   
						        $id = $record['id'];
                                $subject = $record['subject'];
                                $priority = $record['priority'];
                                $category = $record['category'];
                                $comment = $record['comment'];
                                $status_1 = $record['status'];
                                $created_date = $record['created_date'];
                                $created_date = date('d-m-Y h:i:s a ', strtotime($created_date));

                                if ($status_1 == '0')
                                {
                                    $status = "No Reply Yet";
							    }
                                else
                                 if ($status_1 == '1')
                                {
                                    $status = "Replied";
							    }  
                        ?>
                        <tr>
                            <td>SPT00<?php echo $id ;?></td>
                            <td><?php echo $subject ;?></td>
                            <td><?php echo $priority ;?></td>
                            <td><?php echo $category ;?></td>
                            <td><?php echo $created_date;?></td>
							<td><?php echo $status ;?></td>
                            <td><a href="ticket_history_detail.php?id=<?php echo $id;?>" class="btn btn-success"><i class="fa fa-check"></i> View</a></td>                
                        </tr>
                        <?php 
                        }
                        }
                        ?>
                    </tbody>
                </table>
                </form>
            </div>
        </div>
    </div> 
</div>
</div>
                				
<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->


<!-- Footer Start-->
<?php include ("../Footer/footer.php"); ?>
<!-- Footer End-->

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

    

</body>

</html>