<script>
	jQuery('body').on('change', '#idoutlet', function() {
		location.href = app_url + 'dstb_process/add/?idoutlet=' + jQuery(this).val()
	});

	jQuery('body').on('click', '.btn-detail-bill', function() {
		var code = jQuery(this).attr('data-code');
        var id = jQuery(this).attr('data-id');

        show_loading();
        jQuery.ajax({
            url: app_url + 'dstb_process/get_invoice',
            type: 'POST',
            dataType: 'JSON',
            data: {
                code: code,
                id: id
            },
            success: function(response) {
                if (response.err_code == 0) {
                    jQuery('.az-modal-detail .modal-body').html(response.data);
                    show_modal('detail');
                }
                else {
                    bootbox.alert({
                        title: "<?php echo azlang('Error');?>",
                        message: response.message
                    });
                }
                hide_loading();
            },
            error: function(response) {

            }
        });
	});

	jQuery('body').on('click', '.btn-save-dstb', function() {
		show_loading();
		jQuery.ajax({
		    url: app_url + 'dstb_process/save_dstb',
		    type: 'POST',
		    dataType: 'JSON',
		    data: jQuery('#form_dstb').serialize(),
		    success: function(response) {
		        if (response.err_code == 0) {
		            location.href = app_url + 'dstb_process';
		        	hide_loading();
		        }
		        else {
		        	hide_loading();
		            bootbox.alert(response.err_message);
		        }
		    },
		    error: function(res){}
		});
		      
	});