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

	if(!isset($_SESSION)){
        session_start();
    }
    if(isset($_POST['gah'])){
		$colname = $_POST['gah'];
	}
	//echo "deptsubID: ".$colname;

    	//Retrieve Officers
    	$query_rsGalleryPictures = "CALL project_album_pictures('".$colname."')";//"SELECT deptID, `deptname`, subdeptdetailsID, dateadded  FROM v_depts ORDER BY dateadded DESC";
	    $rsGalleryPictures = mysqli_query($conn_ama, $query_rsGalleryPictures ) or die(mysqli_error($conn_ama));
	    $row_rsGalleryPictures = mysqli_fetch_assoc($rsGalleryPictures);
		$totalRows_rsGalleryPictures = mysqli_num_rows($rsGalleryPictures);/**/

		//echo $row_rsGalleryPictures['subdeptdetailsID'];
 ?>
<!-- <div class="col-md-9 data-area"> -->
	<div class="data-area-wrap">
        <!-- <h3><?php echo $row_rsGalleryPictures['gallerytitle']; ?></h3> -->
		<div class="form-wrapper">
		<h3 class="float-left"><?php echo $row_rsGalleryPictures['projtitle']; ?></h3>
		<h4 class="float-right"><a href="#" class="addpictures btn btn-primary" data-addpictures="<?php echo $colname; ?>"><i class="far fa-image"></i> Add pictures</a></h4>
			<table id="example" class="table" cellspacing="0" width="100%">
		        <thead>
		            <tr>
		                <th>Picture</th>
						<th>File Name</th>
						<th>Date Added</th>
		                <!-- <th>Edit</th> -->
		                <th>Delete</th>
		            </tr>
		        </thead>

		        <tbody>
		        <?php do { ?>
		            <tr>
		                <td>
							<a href="#" >
								<img src="_/components/php/manage-projects/projects/thumbs/<?php echo $row_rsGalleryPictures['thumbnail']; ?>" alt="" class="img-fluid">
							</a>
						</td>
		                <td><?php echo ucwords($row_rsGalleryPictures['image']); ?></td>
	                  	<td><?php echo date('d-m-Y', strtotime($row_rsGalleryPictures['imgdate'])); ?></td>
	                    <!-- <td><a href="#">Edit</a></td> -->
						<td><a href="#"
								class="picturedelete"
								data-picturedelete="<?php echo $row_rsGalleryPictures['imageID']; ?>"
								><i class="fas fa-times-circle fa-1x"></i></a></td>
		            </tr>
		        <?php } while($row_rsGalleryPictures = mysqli_fetch_assoc($rsGalleryPictures));?>

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

<script>

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