<script language="javascript">
$(document).ready( function() {
	$("#btnalertdel").click(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();});
				$('#alertdel').modal('hide');
			}
		});
		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";
switch($_GET[act]){
  default:
?>
<script language="javascript">
$(document).ready( function() {
var oTable = $('#tableboot').dataTable();
	oTable.$(".alertdel").click(function(){
		var id = $(this).attr("id");
		$('#alertdel').modal('show');
		$('#delid').val(id);
	});
});
</script>
<?php
	echo "<div class='page-header'>
		<div class='icon'>
			<span class='ico-pen-2'></span>
		</div>
		<h1>$langtag1<small><span class='text-info'>$langtag2</span></small></h1>
	</div>
	<div class='row-fluid'>
		<div class='span12'>
			<div class='block'>";
				$tabletag = new PoTable('tag');
				$tags = $tabletag->findAll(id_tag, DESC);
				echo "<div class='data-fluid'>
				<a class='btn btn-inverse' href='?mod=tag&act=addnew'><i class='icon-pencil icon-white'></i> $langtag6</a>
				<p>&nbsp</p>
					<table cellspacing='0' border='0' class='table table-hover' id='tableboot'>
						<thead><tr>
							<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>$no</td>
								<td>$tag->tag_title</td>
								<td>$tag->count</td>
								<td>
								<a href='#delete$tag->id_tag' class='alertdel' id='$tag->id_tag'><span class='label label-important'><i class='icon-remove icon-white'></i>$langaction2</span></a>
							</td>
						</tr>";
						$no++;
						}
					echo "</tbody></table>
				</div>
			</div>
			<div style='width:100%; height:500px;'>&nbsp;</div>
		</div>
	</div>

	<div id='alertdel' class='modal hide fade' tabindex='-1' role='dialog' aria-labelledby='myModalLabel2' aria-hidden='true' style='width:570px;'>
		<div class='modal-header'>
			<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>
			<h3 id='myModalLabel2'>$langdelete1</h3>
		</div>
		<div class='modal-body'>
			<input type='hidden' id='delid' name='delid'>
			<span class='ico-warning'></span> $langdelete2
		</div>
		<div class='modal-footer'>
			<button id='btnalertdel' class='btn btn-danger'>$langdelete3</button>
			<button class='btn' data-dismiss='modal' aria-hidden='true'>$langdelete4</button>
		</div>
	</div>";
    break;


	case "addnew":
	echo "<div class='row-fluid'>
		<div class='span12'>
			<div class='block'>
				<legend><i class='icon-pencil'></i> Add New</legend>
				<form method='post' action='$aksi' autocomplete='off'>
					<input type='hidden' name='mod' value='tag'>
					<input type='hidden' name='act' value='input'>
					<fieldset>
						<p>&nbsp</p>
						<p>&nbsp</p>
						<label>Please enter tags <i>(can input more than one tag)</i></label><input class='tags input-xxlarge' type='text' id='tag' name='tag' required>
						<p>&nbsp</p>
						<input class='btn btn-large' type='submit' value='Submit'>
						<input class='btn btn-large btn-inverse' type='button' value='Cancel' onclick=self.history.back()>
						<p>&nbsp</p>
						<p>&nbsp</p>
					</fieldset>
				</form>
			</div>
		</div>
	</div>
	<div style='width:100%; height:600px;'>&nbsp;</div>";
	break;
}
}
?>