<?php
session_start();
include_once "../config.php";
require_once '../database1.php';
require_once "../check_admin.php";

class Tickets extends database
{
    public function index()
    { 
		//return $this->fetchAll('tb_ticket');
        $sql = ' SELECT t.*, u.cl_name, u.cl_surname, u.cl_phone, u.username FROM tb_ticket t INNER JOIN user u ON t.cl_user_id=u.id WHERE t.cl_deleted_at IS NULL ';
        return $this->callQuery($sql);
	}
}
$msg='';
if(isset($_GET['message']))
{
	$msg=$_GET['message'];
}

$obj = new Tickets();	
$tickets = $obj->index();
include '../header.php';
?>
            <!-- MAIN CONTENT-->
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">All Tickets</h2>
                                    
                                </div>
								
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row">
							<div class="col-lg-12">
                                
                              <!--  <a href="add" class="btn btn-success pull-right">Add Ticket</a> -->
                                <div class=" table--no-card m-b-30 top-margin pull-left col-sm-12">
                                     <div class="table-responsive" style="width:100%">
                                    <table class="table table-borderless table-data3 ACP_table" style="width: 100%">
                                        <thead>
                                            <tr>
                                                <th>
                                                    User
                                                </th>
                                               <th>Image</th>
                                                <th>Name</th>
												<th>Description</th>
												<th>Status</th>
												<th data-priority="1">Actions</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                           <?php
											foreach($tickets AS $ticket)
											{
											?>
											<tr class="action-container">
                                                <td>
                                                    <?php echo htmlspecialchars($ticket['cl_name']) . ' ' . htmlspecialchars($ticket['cl_surname']) ?><br/>
                                                    Phone : <?php echo htmlspecialchars($ticket['cl_phone']) ?><br/>
                                                    Email : <?php echo htmlspecialchars($ticket['username']) ?><br/>
                                                </td>
											   <td><img src="<?php echo MAIN_DOMAIN ?>/uploads/ticket/<?php echo htmlspecialchars($ticket['cl_image']);?>" style="max-width: 100px"/></td>
												<td><?php echo htmlspecialchars($ticket['cl_title']);?></td>
												<td><?php echo htmlspecialchars($ticket['cl_description']);?></td>
													<td><?php echo htmlspecialchars($ticket['cl_status']);?></td>
												<td>
                                                    
                                                    <a id="edit" href="edit.php?id=<?php  echo htmlspecialchars($ticket['cl_id']); ?>" class="btn btn-primary"><i class="fa fa-edit"></i></a>
												<button type="button" cluster-href="../ajax/ticket/delete_ajax?id=<?php  echo htmlspecialchars($ticket['cl_id']); ?>" class="remove btn btn-danger btn-delete"><i class="fa fa-trash"></i></button>
                                                <div class="error-input"></div>

                                            </td>
											</tr>
											<?php
											}
											?>
                                           
                                        </tbody>
                                    </table>
									</div>
                                </div>
                            </div>
                            
                          
                        </div>
                        
                       <script>
						$(document).ready(function(){
							$('.active').removeClass('active');
							$('#customer-menu').addClass('active');
						}); 
						</script>               

  <?php
  include '../footer.php';
  ?>