<?php
	require_once('Connections/conn_ama.php');

	if(!isset($_SESSION)){
        session_start();
    }


    	//Retrieve departments
    	$query_rsDepartments = "CALL departments_list()";//"SELECT deptID, `deptname`, subdeptdetailsID, dateadded  FROM v_depts ORDER BY dateadded DESC";
	    $rsDepartments = mysqli_query($conn_ama, $query_rsDepartments ) or die(mysqli_error($conn_ama));
	    $row_rsDepartments = mysqli_fetch_assoc($rsDepartments);
	    $totalRows_rsDepartments = mysqli_num_rows($rsDepartments);/**/
 ?>
<!-- <div class="col-md-9 data-area"> -->
	<div class="data-area-wrap">
		<div class="form-wrapper">
			<table id="example" class="table" cellspacing="0" width="100%">
		        <thead>
		            <tr>
		                <th>Name</th>
		                <!-- <th>Category</th> -->
		                <!-- <th>Postion</th> -->
		                <th nowrap="nowrap">Date Added</th>
		                <!-- <th>Country</th> -->
		                <th>Edit</th>
		                <th>Delete</th>
		            </tr>
		        </thead>

		        <tbody>
		        <?php do { ?>
		            <tr>
						<td><a href="#" class="deptid"
								data-deptid="<?php echo $row_rsDepartments['subdeptdetailsID']; ?>"
								><?php echo $row_rsDepartments['deptname']; ?>
							</a>
						</td>

	                  	<td><?php echo $row_rsDepartments['dateadded']; ?></td>
						  <td><a href="#"
								class="editdept"
								data-editdept="<?php echo $row_rsDepartments['subdeptdetailsID']; ?>"
								data-deptname="<?php echo $row_rsDepartments['deptname']; ?>"
							><i class="fas fa-edit"></i></a></td>
						<td><a href="#"
								class="deletedept"
								data-deletedept="<?php echo $row_rsDepartments['deptID']; ?>"
							><i class="fas fa-times-circle fa-1x"></i></a>
						</td>
		            </tr>
		        <?php } while($row_rsDepartments = mysqli_fetch_assoc($rsDepartments));?>

		    	</tbody>
		    </table>
		</div><!-- End .form-wrapper-->
	</div><!-- End .data-area-wrap-->
<!-- </div> -->

<script>

    $(document).ready( function() {
        $('#example').dataTable({
        	"pageLength": 10,
        	"order": []
        });
    });
</script>
