<hr class="thick-line" style="clear:both;">
<div>
	<div style="padding:20px;"></div>
	<div class="detil" style="font-size:14px;margin-top:25px;width: 30%;margin: 0 auto;border-color: #FFFFFF;">
		<form id="frm_backup" style="background:white;margin:0;" method="post" action="<?php echo base_url().'backup/dobackup';?>">
			<table id="tableDetilPerkara" style="font-size:14px;">
				<col width="40%">
				<col width="60%">
				<tbody>
					<tr>
						<td>Current Date</td>
						<td><?php echo $this->tanggalhelper->convertDayDate(date('Y-m-d'));?></td>
					</tr>
					<tr style="border-bottom=0;">
						<td>Current Time</td>
						<td style="border-bottom=0;"><?php echo date('H:i:s');?>
							<input type="hidden" id="params" name="params" value="<?php echo $params;?>">
						</td>
					</tr>
					<tr style="border-bottom=0;">
						<td colspan="2" style="background:white;border-bottom:0;" align="center">
							<input type="hidden" id="refreshpage" class="btn">
							<input type="submit" value="backup Database" class="btn">
							<input type="button" id="doBackupApp" value="backup App" class="btn">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
</div>
<div style="padding:10px;"></div>
<div class="cssTable">
	<table id="tablePerkaraAll">
		<col width="5%">
		<col width="10%">
		<col width="20%">
		<col width="10%">
		<col width="35%">
		<col width="20%">
		<tr>
			<td>No</td>
			<td>Type</td>
			<td>Tanggal Backup</td>
			<td>Timestamp</td>
			<td>Filename</td>
			<td></td>
		</tr>
		<?php
		if($backupList!=''){
			if($backupList->num_rows>0){
				$i=1;
				foreach ($backupList->result() as $row) {
					echo "<tr>";
						echo '<td>'.$i.'</td>';
						$type = ($row->type==1)? 'Database':'Aplikasi';
						echo '<td>'.$type.'</td>';
						echo '<td>'.$this->tanggalhelper->convertDayDate($row->tanggal).'</td>';
						echo '<td style="text-align:center;">'.$row->jam.'</td>';
						echo '<td>'.$row->filename.'</td>';
						echo '<td style="text-align:center;">[<a href="#" onClick="doDownload(\''.base64_encode($this->encrypt->encode($row->id)).'\')">download</a>] || [<a href="#" onClick="doDelete(\''.base64_encode($this->encrypt->encode($row->id)).'\')">hapus</a>]</td>';
					echo "</tr>";
					$i++;
				}
			}else{
				echo '<td colspan="6" style="text-align:center;">No Database Backup Found</td>';
			}
		}else{
			echo '<td colspan="6" style="text-align:center;">No Database Backup Found</td>';
		}
		?>
	</table>
</div>

<script type="text/javascript">
$('#frm_backup').SubmitHandling({
   	refresh:'1',
    setRefresh:1,
    divRef:'#frm_backup',
    clicked:1,
    btnClicked:'#refreshpage',
    whenStatus:1,
});

$('#refreshpage').click(function() {
    location.reload();
});


$('#doBackupApp').click(function() {
    window.open("<?php echo base_url('backup/backupApp');?>")
});

function doDownload(param){
	window.open("<?php echo base_url('backup/doDownload/');?>"+'/'+param)
}


function doDelete(params){
	var values = $('form').serializeArray();
	values.push({
		name: 'params',
		value: params
	});
	values = jQuery.param(values);
	var url = "<?php echo base_url('backup/doDelete/');?>";
	$.post(url,values, function(json){
		closeLoading()
		if(json.st==1){
			$('<div id="popup_msg" class="popup"><div class="centering"><table class="pesan"><tr style="background-color: #5FB85C;"><td align="center" style="padding:5px;" id="test">Pesan</td><td id="tutup_windows" class="tutup_windows" align="center" style="padding:5px;" width="50">tutup</td></tr><tr><td style="padding:5px;" colspan="2"><div id="pesan-container"></div></td></tr></table></div></div>').appendTo( "body" );
			$('#tutup_windows').closingDiv({
				clicked:1,
				btnClicked:'#refreshpage',
				whenStatus:1,
				st:1
			});
			$('#pesan-container').html(json.msg);
			$('#popup_msg').show();
		}else{
			message_error_show_parent(json.msg);
		}
	},'json');
}
</script>