<script>
	jQuery('body').on('click', '.btn-excel-import', function() {
		show_modal('import');
		jQuery('.container-report').html('');
	});

	jQuery('body').on('click', '#process_import', function() {
		var formdata = new FormData();
		var data_file = jQuery('#form_import').find('input[type="file"]');
	    jQuery(data_file).each(function(adata, bdata) {
	        var file_id = jQuery(bdata).attr('id');
	        var file_name = jQuery(bdata).attr('name');
	        var file = jQuery(bdata)[0].files[0];
	        if (file_name.length > 0) {
	            file_id = file_name;
	        }
	        formdata.append(file_id, file);
	    });

	    show_loading();
		jQuery.ajax({
			url: app_url + 'product/import_excel',
			type: 'POST',
			dataType: 'JSON',
			data: formdata,
	        processData: false,
	        contentType: false,
			success: function(response) {
				if (response.err_code == 0) {
					// location.reload();
					var table = jQuery('#product').dataTable({bRetrieve: true});
					table.fnDraw(false);

					hide_loading();
					jQuery('.container-report').html(response.data);
				}
				else {
					hide_loading();
					bootbox.alert(response.err_message);
				}
			},
			error: function(response) {

			}
		});
	});