<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 = 'tag';
				var act =  'delete';
				var dataString = 'id='+ id + '&mod='+ mod + '&act='+ act;
				$.ajax({
					type: "POST",
					url: "po-component/po-tag/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-tag/proses.php";
?>
	<div class="contentTop">
        <span class="pageTitle"><span class="icon-tag"></span><?php echo $langtag1; ?></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 $langtag2; ?></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 $langtag1; ?></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="tag">
					<input type="hidden" name="act" value="multidelete">
					<input type="hidden" value="0" name="totaldata" id="totaldata">
<?php
				$tabletag = new PoTable('tag');
				$tags = $tabletag->findAll(id_tag, 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>$langtag3</th>
							<th>$langtag4</th>
							<th>$langtag5</th>
						</tr></thead><tbody>"; 
						$no=1;
						foreach($tags as $tag){
							echo "<tr class='gradeA' id='del$tag->id_tag'>
								<td><input type='checkbox' id='titleCheckdel'></td>
								<input type='hidden' class='deldata' name='item[$no][deldata]' value='$tag->id_tag' disabled>
								<td>$no</td>
								<td>$tag->tag_title</td>
								<td>$tag->count</td>
								<td class='tableActs' align='center'>
									<span id='$tag->id_tag' class='alertdel'><a href='#delete$tag->id_tag' 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; ?>" 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="tag">
					<input type="hidden" name="act" value="input">
                    <div class="formRow">
                        <div class="grid3"><label>Please enter tags</label></div>
                        <div class="grid9"><input style="display: none;" id="tag" name="tag" class="tags" type="text" required><p><i>Can input more than one tag (,)</i></p></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;  
}
?>
	</div>
<?php
}
?>