<script type="text/javascript">
$(document).ready( function() {
var oTable = $('.dTable').dataTable();
    $('#alertdel').dialog({
		autoOpen: false,
		width: 400,
		modal: true,
		buttons: {
			"<?php echo $langdelete3; ?>": function() {
				var id = $('#delid').val();
				var mod = 'library';
				var act =  'delete';
				var dataString = 'id='+ id + '&mod='+ mod + '&act='+ act;
				$.ajax({
					type: "POST",
					url: "po-component/po-library/proses.php",
					data: dataString,
					cache: false,
					success: function(){
						$('#del'+id).slideUp('slow', function() {$(this).remove();});
				}
				});
				$( this ).dialog( "close" );
			},
			"<?php echo $langdelete4; ?>": function() {
				$( this ).dialog( "close" );
			}
		}
	});
    oTable.$('.alertdel').click(function () {
		var id = $(this).attr("id");
        $('#alertdel').dialog('open');
		$('#delid').val(id);
        return false;
    });
});
</script>
<?php
session_start();
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
	header('location:404.php');
}else{
$aksi="po-component/po-library/proses.php";
?>
	<div class="contentTop">
        <span class="pageTitle"><span class="icon-picture"></span><?php echo $langlibrary1; ?></span>
    </div>
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="admin.php?mod=home"><?php echo $langmenu1; ?></a></li>
                <li class="current"><a><?php echo $langlibrary2; ?></a></li>
            </ul>
        </div>
    </div>
    <!-- Main content -->
    <div class="wrapper">
<?php
switch($_GET[act]){
  default:
?>
	<div class="widget">
		<div class="whead"><span class="titleIcon check"><input type="checkbox" id="titleCheck" name="titleCheck" /></span><h6><?php echo $langlibrary1; ?></h6><div class="clear"></div></div>
			<div id="dyn" class="hiddenpars">
                <a class="tOptions" title="Options"><img src="images/icons/options" alt="" /></a>
				<form method="post" action="<?php echo $aksi; ?>">
					<input type="hidden" name="mod" value="library">
					<input type="hidden" name="act" value="multidelete">
					<input type="hidden" value="0" name="totaldata" id="totaldata">
<?php
				$tablemedia = new PoTable('media');
				$medias = $tablemedia->findAll(id_media, DESC);
				echo "<table cellpadding='0' cellspacing='0' border='0' class='dTable checkAll check' id='dynamic'>
						<thead><tr>
							<th><img src='images/elements/other/tableArrows.png' /></th>
							<th>No</th>
							<th>$langlibrary3</th>
							<th>$langlibrary4</th>
							<th>$langlibrary5</th>
							<th>$langlibrary6</th>
							<th>$langlibrary7</th>
						</tr></thead><tbody>"; 
						$no=1;
						foreach($medias as $media){
							$pecah = explode(".", $media->file_name);
							$fileName = $pecah[0];
							$pecah2 = explode("/", $media->file_type);
							$fileType = $pecah2[0];
							echo "<tr class='gradeA' id='del$media->id_media'>
								<td><input type='checkbox' id='titleCheckdel'></td>
								<input type='hidden' class='deldata' name='item[$no][deldata]' value='$media->id_media' disabled>
								<td>$no</td>
								<td>$fileName</td>
								<td>";
									if ($fileType=='image'){
										echo "<div id='gallery'><i class='icon-picture'></i> <a class='lightbox' rel='group' href='../po-content/po-upload/$media->file_name'>$langlibrary8</a></div>";
									}else{
										echo "<i class='icon-documents'></i> $langlibrary9";
									}
								echo "</td>
								<td>$media->file_size Byte</td>
								<td>$media->date</td>
								<td class='tableActs' align='center'>
									<span id='$media->id_media' class='alertdel'><a href='#delete$media->id_media' class='tablectrl_small bDefault tipS' title='$langaction2'><span class='iconb' data-icon='&#xe136;'></span></a></span>
								</td>
							</tr>";
						$no++;
						}
					echo "</tbody>
					<tfoot>
						<tr><td colspan='6'><div class='itemActions'><input class='buttonS bRed' type='submit' value='Delete Selected Item' onClick=\"return confirm('$langdelete2')\"></div></td></tr>
					</tfoot>
				</table>";
?>
				</form>
			</div>
		<div class="clear"></div>
	</div>
	<div id="alertdel" title="<?php echo $langdelete1; ?>" style="display:none;">
		<p><input type='hidden' id='delid' name='delid'><span class='icon-warning'></span> <?php echo $langdelete2; ?></p>
	</div>
<?php
    break;


	case "addnew":
?>
		<form id="usualValidate" class="main" method="post" action="<?php echo $aksi; ?>" enctype="multipart/form-data" autocomplete="off">
            <fieldset>
				<div class="widget fluid">
				<div class="whead"><h6>Add New</h6><div class="clear"></div></div>
					<input type="hidden" name="mod" value="library">
					<input type="hidden" name="act" value="input">
					<div class="formRow">
						<div class="grid3"><label>Please select file</label></div>
						<div class="grid9"><input style="opacity: 0;" size="24" class="fileInput" id="fileInput" name="fupload" type="file" required></div>
						<div class="clear"></div>
					</div>
					<div class="formRow">
						<input class="buttonM bBlue" type="submit" value="Submit">
						<input class="buttonM bRed formSubmit" type="button" value="Cancel" onclick=self.history.back()><div class="clear"></div>
					</div>
				</div>
            </fieldset>
		</form>
<?php
    break;


	case "addnewmultiple":
?>
        <div class="widget">    
            <div class="whead"><h6>Multiple Files Uploader</h6><div class="clear"></div></div>
            <div id="uploader">You browser doesn't have HTML 4 support.</div>                    
        </div>
<?php
    break;  
}
?>
	</div>
<?php
}
?>