<?php 
	require_once('Connections/conn_ama.php');
	
	if(!isset($_SESSION)){
        session_start();
    }
    if(isset($_POST['deptid'])){
		$colname = $_POST['deptid'];
	}
	//echo "deptsubID: ".$colname;

    	//Retrieve Officers
    	$query_rsOfficers = "CALL department_officers('".$colname."')";//"SELECT deptID, `deptname`, subdeptdetailsID, dateadded  FROM v_depts ORDER BY dateadded DESC";
	    $rsOfficers = mysqli_query($conn_ama, $query_rsOfficers ) or die(mysqli_error($conn_ama));
	    $row_rsOfficers = mysqli_fetch_assoc($rsOfficers);
		$totalRows_rsOfficers = mysqli_num_rows($rsOfficers);/**/
		
		//echo $row_rsOfficers['subdeptdetailsID'];
 ?>
<!-- <div class="col-md-9 data-area"> -->
	<div class="mreport-steps">
		<?php //include("mreport-steps.inc.php"); ?>
	</div><!-- End .mreport-step-->
	<div class="data-area-wrap">
        
		<div class="form-wrapper">
			<h3 class="float-left"><?php echo $row_rsOfficers['department']; ?></h3>
			<div class="float-right">
				<span><a href="#" class="addofficer" data-dept="<?php echo $row_rsOfficers['department']; ?>" data-deptid="<?php echo $colname; ?>">Add Officer</a></span> |
				<span><a href="#" class="addsubunit" data-dept="<?php echo $row_rsOfficers['department']; ?>" data-deptid="<?php echo $row_rsOfficers['subdeptdetailsID']; ?>">Add Unit</a></span> |
				<span><a class=" listsubunits" href="#" data-dept="<?php echo $row_rsOfficers['department']; ?>" data-deptid="<?php echo $row_rsOfficers['subdeptdetailsID']; ?>">List Units</a></span> 
			</div>
			<br class="clearfix">
			<hr > 
			<table id="example" class="table" cellspacing="0" width="100%">
		        <thead>
		            <tr>
		                <th>Officer</th>
		                <th>Position</th>
		                <th>Image</th>
		                <!-- <th nowrap="nowrap">Date Added</th> -->
		                <!-- <th>Country</th> -->
		                <th>Edit</th>
		                <th>Delete</th>
		            </tr>
		        </thead>
		
		        <tbody>
		        <?php do { ?>
		            <tr>
						<td><?php echo $row_rsOfficers['officername']; ?></td>
						<td><?php echo $row_rsOfficers['position']; ?></td>
						<td><img class="img-fluid" src="_/components/php/manage-departments/deptofficers/thumbs/<?php echo $row_rsOfficers['thumbnail']; ?>" alt=""></td>
						<td><a href="#" 
							class="editdeptofficer" 
							data-deptofficer="<?php echo $row_rsOfficers['officerID']; ?>"
							><i class="fas fa-edit"></i></a>
						</td>
						<td><a href="#" 
							class="deletedeptofficer" 
							data-deletedeptofficer="<?php echo $row_rsOfficers['officerID']; ?>"
							><i class="fas fa-times-circle fa-1x"></i></a>
						</td>
		            </tr>
		        <?php } while($row_rsOfficers = mysqli_fetch_assoc($rsOfficers));?>
		            
		    	</tbody>
		    </table>
		</div><!-- End .form-wrapper-->
	</div><!-- End .data-area-wrap-->	
<!-- </div> -->

<script>

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