<div class="right_col" role="main">
	<div class="">
		<div class="page-title">
			<div class="title_left">
				<table>
					<tr>
						<td width="150px"><h3>Claim list</h3></td>
						<td><a href="index.php?pagecontent=claim_add"><button type="button" class="btn btn-dark">Add Claim</button></a></td>
					</tr>
				</table>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="row">
			<div class="col-md-12 col-sm-12 col-xs-12">
				<div class="x_panel">
					<div class="x_content">
						<table id="datatable" class="table table-striped table-bordered">
							<thead>
								<tr>
									<th>No</th>
									<th>Title</th>
                                    <th>Date</th>
                                    <th>Amount</th>
                                    <th>Status</th>
                                    <th>Admin</th>
                                    <th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$result = mysqli_query($conn,"SELECT * FROM claims");
									while($row = mysqli_fetch_assoc($result)){
								?>
								<tr>
                                	<td></td>
									<td><?php echo $row['c_title'];?></td>
									<td><?php echo $row['c_date'];?></td>
									<td>RM <?php echo $row['c_amount'];?></td>
									<td>
										<?php 
											switch($row['c_status']){
												case 0: echo "UNPAID"; break;
												case 1: echo "PAID"; break;
											}
										?>
									</td>
									<td><?php echo getDetailFromTable('admin',$row['a_id'])[1]; ?></td>
									<td>
										<a href="?pagecontent=claim_update&update=<?php echo $row['c_id']; ?>"><button class="btn btn-xs btn-primary">Update</button></a>
										
										<a href="?pagecontent=claims&delete=<?php echo $row['c_id']; ?>"><button class="btn btn-xs btn-danger">Delete</button></a>
									</td>
								</tr>
								<?php
									}
										?>
						</table>
					</div>
				</div>
			</div>
        </div>
    </div>
</div>

<?php
	if(isset($_REQUEST['delete'])){
		$claimId = $_REQUEST['delete'];
		mysqli_query($conn,"DELETE FROM claims WHERE c_id=$claimId");
		header("Location: ?pagecontent=claims");
	}
?>