<div class="tabs-container">
	<ul class="nav nav-tabs">
		<li class="active"><a data-toggle="tab" href="#tab-1"> Direct upload</a></li>
		<li class=""><a data-toggle="tab" href="#tab-2"> Upload from mobile</a></li>
	</ul>
	<div class="tab-content">
		<div id="tab-1" class="tab-pane active">
			<div class="panel-body">
				<div id="upload-attachment-form"></div>
			</div>
		</div>
		<div id="tab-2" class="tab-pane">
			<div class="panel-body">
				<div id="scan-qr-form"></div>
			</div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function () {
		load_upload_form();
		load_scan_qr_form();
	});

	function load_upload_form(){
		var pk_data = $('.pk_data').val();
		pk_data = encode(pk_data);
		var attachment_description = encode('<?=$attachment_description?>');
		$.ajax({
			type: 'GET',
			url: site_url + "main/upload?key=" + pk_data + '&ism=1&' + 'ad=' + attachment_description,
			dataType: 'html',
			success: function(result) {
				$('#upload-attachment-form').html(result);
			}
		});
	}

	function load_scan_qr_form(){
		var pk_data = $('.pk_data').val();
		if (pk_data == '')
			alert('Upload attachment belum di setting');
		pk_data = encode(pk_data);
		token = encode('<?=date('h:i:s A', time()+3600)?>');
		$.ajax({
			type: 'GET',
			url: site_url + "main/upload/qr_scan?key=" + pk_data + '&t=' + token,
			dataType: 'html',
			success: function(result) {
				$('#scan-qr-form').html(result);
			}
		});
	}
</script>