<?php 
	require_once('../Connections/conn_ama.php');
	
	if(!isset($_SESSION)){
        session_start();
    }
    if(isset($_POST['sdid'])){
        $colname = $_POST['sdid'];
        $deptname =$_POST['deptname'];
    }

    	//Retrieve SubUnitOfficers
    	$query_rsSubUnitOfficers = "CALL deptsub_officer('".$colname."')";//"SELECT deptID, `deptname`, subdeptdetailsID, dateadded  FROM v_depts ORDER BY dateadded DESC";
	    $rsSubUnitOfficers = mysqli_query($conn_ama, $query_rsSubUnitOfficers ) or die(mysqli_error($conn_ama));
	    $row_rsSubUnitOfficers = mysqli_fetch_assoc($rsSubUnitOfficers);
	    $totalRows_rsSubUnitOfficers = mysqli_num_rows($rsSubUnitOfficers);/**/
 ?>
<!-- <div class="col-md-9 data-area"> -->

	<div class="data-area-wrap">
        <h3></h3>
        <h3></h3>
		<div class="form-wrapper">
            <span><a href="#"><?php echo $deptname; ?></a></span> >>
			<span><?php echo $row_rsSubUnitOfficers['subunitname']; ?></span> 
			<span class="float-right">
				<a href="#" 
					class="btn btn-primary addunitofficer"
						data-unitid="<?php echo $row_rsSubUnitOfficers['subsubdeptID']; ?>"
						data-unitname="<?php echo $row_rsSubUnitOfficers['subunitname']; ?>"
						data-deptname="<?php echo $row_rsSubUnitOfficers['deptname']; ?>"

					 >Add Officer</a>
			</span>
			<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_rsSubUnitOfficers['subunitofficer']; ?></td>
						<td><?php echo $row_rsSubUnitOfficers['position']; ?></td>
						<td><img class="img-fluid" src="_/components/php/manage-departments/sub-units/subunitsofficers/thumbs/<?php echo $row_rsSubUnitOfficers['thumbnail']; ?>" alt=""></td>
						<td><a href="#" 
							class="editunitofficer" 
							data-unitofficer="<?php echo $row_rsSubUnitOfficers['officerID']; ?>"
							><i class="fas fa-edit"></i></a>
						</td>
		                <td><a href="#" 
							class="deleteunitofficer" 
							data-deleteunitofficer="<?php echo $row_rsSubUnitOfficers['officerID']; ?>"
							><i class="fas fa-times-circle fa-1x"></i></a>
						</td>
		            </tr>
		        <?php } while($row_rsSubUnitOfficers = mysqli_fetch_assoc($rsSubUnitOfficers));?>
		            
		    	</tbody>
		    </table>
		</div><!-- End .form-wrapper-->
	</div><!-- End .data-area-wrap-->	
<!-- </div> -->
<script>

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