<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 = 'contact';
				var act =  'delete';
				var dataString = 'id='+ id + '&mod='+ mod + '&act='+ act;
				$.ajax({
					type: "POST",
					url: "po-component/po-contact/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>

<script type="text/javascript">
$(document).ready( function() {
var oTable = $('.dTable').dataTable();
    // Dialog Link
    oTable.$('.tblview').click(function () {
		var idisi = $(this).attr('id');
        $('#viewdata'+idisi).dialog('open');
        return false;
    });
});
</script>
<?php
//Author  	= 'Jenuar Dwi Putra Dalapang';
//Contact 	= 'mailto:djenuar@gmail.com';

session_start();
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
	header('location:404.php');
}else{
$aksi="po-component/po-contact/proses.php";
?>
	<div class="contentTop">
        <span class="pageTitle"><span class="icon-phone"></span>Contact Management</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>View and delete contact management</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>Contact Management</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="contact">
					<input type="hidden" name="act" value="multidelete">
					<input type="hidden" value="0" name="totaldata" id="totaldata">
<?php
				$tablecontact = new PoTable('contact');
				$contacts = $tablecontact->findAll(id_contact, 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>Sender Name</th>
							<th>Email</th>
							<th>Subjek</th>
							<th>Action</th>
						</tr></thead><tbody>";
						$no=1;
						foreach($contacts as $contact){
						echo "<tr class='gradeA' id='del$contact->id_contact'>
							<td><input type='checkbox' id='titleCheckdel'></td>
							<input type='hidden' class='deldata' name='item[$no][deldata]' value='$contact->id_contact' disabled>
							<td>$no</td>
							<td>$contact->name_contact</td>
							<td>$contact->email_contact</td>
							<td>$contact->subjek_contact</td>
							<td class='tableActs' align='center'>
								<span id='$contact->id_contact' class='tblview'><a href='#viewdata$contact->id_contact' class='tablectrl_small bDefault tipS' title='View Contact'><span class='iconb' data-icon='&#xe1db;'></span></a></span>
								<span id='$contact->id_contact' class='alertdel'><a href='#delete$contact->id_contact' class='tablectrl_small bDefault tipS' title='$langaction2'><span class='iconb' data-icon='&#xe136;'></span></a></span>
							</td>
						</tr>";
						?>
						<div id="viewdata<?php echo $contact->id_contact; ?>" class="viewdata" title="View Contact">
							<p><?php echo $contact->message_contact; ?></p>
						</div>
						<?php
						$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;
}
?>
	</div>
<?php
}
?>