<script type="text/javascript" src="../../js/plugins/pajinate/jquery.pajinate.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#paging_container').pajinate({
			items_per_page : 5,
			num_page_links_to_display : 5
					
		});
	});
</script>

<script type="text/javascript">
$(document).ready(function () {
    $('.addtoform').click(function(){
		var name = $(this).attr("id");
		$('#addimage').modal('hide');
		$('#picture').val(name);
    });
});
</script>

<?php
include_once '../../../po-library/po-database.php';
	echo "<div id='paging_container'>
		<table cellspacing='0' border='0' class='table table-hover'>
			<thead><tr>
				<th>Image Name</th>
				<th>Image</th>
				<th>Action</th>
			</tr></thead><tbody class='contentmed'>";
				$tablemedia = new PoTable('media');
				$medias = $tablemedia->findAll(id_media, DESC);
				foreach($medias as $media){
					$pecah = explode("/", $media->file_type);
					$fileType = $pecah[0];
					$cari = "$media->file_name";
					$tanda = "popoji";
					if ($fileType=='image'){
						echo "<tr>
							<td>$media->file_name</td>
							<td><img src='../po-content/po-upload/medium-$media->file_name' width='60' height='60' class='img-polaroid' /></td>
							<td>";
								if ($yangdicari = strstr($cari, $tanda)){
									echo "<a href='#' id='$media->file_name' class='addtoform'><span class='label label-info'><i class='icon-picture icon-white'></i> Add to Form</span></a>";
								}else{
									echo "<span class='label label-warning'><i class='icon-picture icon-white'></i> Can't Add</span>";
								}
							echo "</td>
						</tr>";
					}else{}
				}
			echo "</tbody></table>
		<div class='page_navigation'></div>
	</div>";
?>