<style>
    #category_data{
        padding: 4px !important;
        font-size: 12px !important;
    }
</style>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title">
                <h4 class="bold"><?php echo CommonLanguage::getMessage($title); ?> </h4>
            </div>
            <div class="row">
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('Date') ?></label>
                    <div class="input-group">
                        <span class="input-group-addon bg-primary"><i class="fa fa-calendar"></i></span>
                        <input id="From_To_Date" type="text" class="form-control" name="From_To_Date" autocomplete="off" >
                    </div>
                </div> 
               
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('choose_customer') ?></label>
                    <input id="customer_id" type="hidden" class="full-width" name="customer_id" >
                </div> 
               

                <div class="col-md-1 <?php echo $permissions->hasPermission('show_all_subscriptions') ? '':'hidden'; ?>">
                    <label><?php echo CommonLanguage::getMessage('status') ?></label>
                    <select name="paid_status" id="paid_status" class="full-width" data-init-plugin="select2">
                        <option value=""><?php echo CommonLanguage::getMessage('All'); ?></option>
                        <option value="1"><?php echo CommonLanguage::getMessage('never_paid'); ?></option>
                        <option value="4"><?php echo CommonLanguage::getMessage('not_paid'); ?></option>
                        <option value="2"><?php echo CommonLanguage::getMessage('partially_paid'); ?></option>
                        <option value="3"><?php echo CommonLanguage::getMessage('paid'); ?></option>
                    </select>
                </div>
                <div class="col-md-1 <?php echo $permissions->hasPermission('show_all_subscriptions') ? '':'hidden'; ?>">
                    <label><?php echo CommonLanguage::getMessage('paid_type') ?></label>
                    <select name="paid_type" id="paid_type" class="full-width" data-init-plugin="select2">
                        <option value=""><?php echo CommonLanguage::getMessage('All'); ?></option>
                        <option value="0"><?php echo CommonLanguage::getMessage('paid_before'); ?></option>
                        <option value="1"><?php echo CommonLanguage::getMessage('paid_after'); ?></option>
                    </select>
                </div>
                <div class="col-md-2 <?php echo $permissions->hasPermission('show_all_subscriptions') ? '':'hidden'; ?>">
                    <label><?php echo CommonLanguage::getMessage('payment_type'); ?>
                        <span class="red-star">*</span>
                    </label>
                    <select id="payment_type" class="full-width " name="payment_type" data-init-plugin="select2">
                        <option value=""><?php  echo CommonLanguage::getMessage('select');?></option>
                        <?php foreach ($payment_type as $type): ?>
                        <option value="<?php echo $type['Account_ID']; ?>"><?php echo $type['Account_Code'] . ' - ' . $type['Account_Name']; ?></option>
                        <?php endforeach; ?>
                    </select>
                </div> 
                <div class="col-md-2 <?php echo $permissions->hasPermission('show_all_subscriptions') ? '':'hidden'; ?>">
                    <label><?php echo CommonLanguage::getMessage('payment_date'); ?>
                        <span class="red-star">*</span>
                    </label>
                    <input type="text" name="payment_date" id="payment_date" class="form-control" value="<?php echo date('Y-m-d');?>"/>
                </div>
            </div>
            <div class="row m-t-10">
                <div class="col-md-3">
                    <label><?php  echo CommonLanguage::getMessage('subscriptions');?></label>
                    <input type="hidden" name="subscription_id" id="subscription_id" class="full-width"/>
                </div>
                <div class="col-md-3">
                    <label><?php  echo CommonLanguage::getMessage('Category');?></label>
                    <input type="hidden" name="category_id" id="category_id" class="full-width"/>
                </div>
                <div class="col-md-3">
                    <label><?php  echo CommonLanguage::getMessage('main_block');?></label>
                    <select id="main_block_id" name="main_block_id" data-init-plugin="select2" class="full-width">
                        <option value=""><?php echo CommonLanguage::getMessage('select');?></option>
                        <?php  $main_blocks = explode(",",smc_session()['block_ids']);   foreach($main_block as $block){ if(empty(smc_session()['block_ids']) || in_array($block['block_id'],$main_blocks)){?>
                        <option value="<?php echo $block['block_id'];?>"><?php echo $block['block_name'];?></option>
                        <?php } }?>
                    </select>
                </div>
                <div class="col-md-3">
                    <label><?php  echo CommonLanguage::getMessage('block');?></label>
                    <input type="hidden" name="block_id" id="block_id" class="full-width"/>
                </div>
            </div>
            <div class="row m-t-10 <?php echo $permissions->hasPermission('show_all_subscriptions') ?'':'hidden'; ?>">
                    <div class="col-md-3">
                        <label><?php echo CommonLanguage::getMessage('salesman') ?></label>
                        <input id="salesman_id" type="hidden" class="full-width" name="salesman_id" >
                    </div> 
                    <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('paid_time') ?></label>
                    <div class="input-group">
                        <span class="input-group-addon bg-primary"><i class="fa fa-calendar"></i></span>
                        <input id="paid_date" type="text" class="form-control" name="paid_date" autocomplete="off" >
                    </div>
                </div> 
            </div>

        </div>
        <div class="panel-body">
            <div class="row ">
                <input type="hidden" id="act_cust_total_sub_fees" name="act_cust_total_sub_fees" value="<?php  echo smc_session()['default_setting']['act_cust_total_sub_fees'];?>"/>
                <div class="col-md-12 table-responsive">
                    <table class="table table-bordered inventory" id="tableWithSearch" >
                        <thead>
                            <tr>
                                <th class="text-center" style="width:5%" ><input type="checkbox" class="inv_check_all_td pull-left"/>#</th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('customer_name'); ?></th> 
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('paid_time'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('address'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('subscription_name'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('block'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('Date'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('total'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('already_paid'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('paid_amount'); ?></th>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('discount'); ?></th>
                                <?php  if(smc_session()['default_setting']['act_cust_total_sub_fees']  == 1){?>
                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('customer_total'); ?></th>
                                <?php }?>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                        <tfoot>
                            <th> 
                                <?php if($permissions->hasPermission('show_all_subscriptions')){?>                 
                                    <button class="btn btn-primary full-width " id="print_payment"><?php echo CommonLanguage::getMessage('print'); ?></button>
                                        <?php if ($permissions->hasPermission('subscription_paid_amount')) { ?>
                                        <button class="btn btn-primary full-width m-t-10 hidden sub_fees_btn " id="submit_payment"><?php echo CommonLanguage::getMessage('paid'); ?></button>
                                        <button class="btn btn-primary full-width m-t-10 hidden sub_fees_btn" id="submit_payment_with_print"><?php echo CommonLanguage::getMessage('paid_print'); ?></button>
                                    <?php } if ($permissions->hasPermission('delete_subscription_fees')) { ?>
                                    <button class="btn btn-primary full-width m-t-10 hidden sub_fees_btn " id="delete_all"><?php echo CommonLanguage::getMessage('delete'); ?></button>
                                    <?php }?>
                                    <?php if ($permissions->hasPermission('delete_payments')) { ?>
                                    <button class="btn btn-primary full-width m-t-10 hidden sub_fees_btn " id="delete_payments"><?php echo CommonLanguage::getMessage('delete_payments'); ?></button>
                                    <?php }?>
                                <?php }else{ ?>
                                    <button class="btn btn-primary full-width m-t-10 hidden sub_fees_btn" id="submit_payment_with_print"><?php echo CommonLanguage::getMessage('paid_print'); ?></button>

                                <?php } ?>
                            </th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th id="category_data"></th>
                            <th id="total_div"></th>
                            <th></th>
                            <th></th>
                            <th>
                                <?php if ($permissions->hasPermission('add_discount_on_subscription')) { ?>
                                <button class="btn btn-primary full-width m-t-10 hidden sub_fees_btn" id="submit_discount"><?php echo CommonLanguage::getMessage('discount'); ?></button>
                                <?php } ?>
                            </th>
                            <?php  if(smc_session()['default_setting']['act_cust_total_sub_fees']  == 1){?>
                            <th></th>
                            <?php }?>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
        <?php echo Forms::ModalLoader('fees_list_loader'); ?>
    </div>
</div>
<script>
    $(function () {
        $('#payment_date').datepicker({autoclose:true})
        build_select2($('#customer_id'), 'xhr/customerSearch?is_customer_group=1');
        build_select2($("#salesman_id"), "xhr/employeeSearch");

        build_select2($('#subscription_id'), 'xhr/commonSearch?table=tbl_subscription&col_id=subscription_id&col_name=subscription_name');
        build_select2($('#category_id'), 'xhr/commonSearch?table=tbl_subscription_category&col_id=category_id&col_name=category_name');
        build_select2($('#block_id'), 'xhr/searchSubscriptionBlocks?main_block_id='+$('#main_block_id').val());
        $("#paid_status").val("4").change();
        $("#payment_type").val("2097").change();
        ChangeTable();
        $('#main_block_id').on('change',function(){
            $('#block_id').val('');
            build_select2($('#block_id'), 'xhr/searchSubscriptionBlocks?main_block_id='+$('#main_block_id').val());
        });
        $("#tableWithSearch").on("click", "input.inv_check_all_td", function (e) {
            var is_checked = $(this).is(":checked");
            var row = $("#tableWithSearch").dataTable().fnGetNodes();
            for (var i = 0; i < row.length; i++) {
                $(row[i]).find("input.inv_td").prop("checked", is_checked);
            }
        });
        $("input[name=From_To_Date]").daterangepicker({
            ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month'), moment().endOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            }, locale: {
                cancelLabel: 'Clear'
            }, allowEmpty: false,
            autoUpdateInput: false
        });
        $("input[name=From_To_Date]").on('apply.daterangepicker', function (ev, picker) {
            window.startDate = picker.startDate.format('YYYY-MM-DD'),
                window.endDate = picker.endDate.format('YYYY-MM-DD');
            $(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
            ChangeTable();
        });
        $("input[name=From_To_Date]").on('cancel.daterangepicker', function (ev, picker) {
            window.startDate = ''
            window.endDate = ''
            $(this).val('');
            ChangeTable();
        });


        $("input[name=paid_date]").daterangepicker({
            ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month'), moment().endOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            }, locale: {
                cancelLabel: 'Clear'
            }, allowEmpty: false,
            autoUpdateInput: false
        });
        $("input[name=paid_date]").on('apply.daterangepicker', function (ev, picker) {
            window.startDatepaid = picker.startDate.format('YYYY-MM-DD'),
                window.endDatepaid = picker.endDate.format('YYYY-MM-DD');
            $(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
            ChangeTable();
        });
        $("input[name=paid_date]").on('cancel.daterangepicker', function (ev, picker) {
            window.startDatepaid = ''
            window.endDate = ''
            $(this).val('');
            ChangeTable();
        });


        $('#customer_id,#salesman_id,#paid_status,#paid_type,#subscription_id,#category_id,#block_id,#main_block_id').on('change', function () {
            ChangeTable();
        });
        $('#tableWithSearch').on('input','.disc_amount',function(){
            var discount_amount = parseFloat($(this).val()),
                current_total = parseFloat($(this).attr('data-total'));
            if(discount_amount > current_total || discount_amount < 0){
                $(this).val(current_total);
                toastr.error('<?php  echo CommonLanguage::getMessage('discount_alert');?>');
            }
        });
        $('#tableWithSearch').on('input','.remaining_amount',function(){
            var remaining_amount = parseFloat($(this).val()),
                current_remaining = parseFloat($(this).attr('data-remaining'));
            if(remaining_amount > current_remaining || remaining_amount< 0){
                $(this).val(current_remaining);
                toastr.error('<?php  echo CommonLanguage::getMessage('remaining_amount_alert');?>');
            }
        });
        
        $('#delete_all').on('click', function () {
            if ($('input.inv_td:checked').length == 0) {
                toastr.error('<?php echo CommonLanguage::getMessage('choose_entry'); ?>')
                return;
            }
            var row = $("#tableWithSearch").dataTable().fnGetNodes(), current_ids = [];
            for (var i = 0; i < row.length; i++) {
                if ($("input.inv_td", $(row[i])).is(":checked"))
                    current_ids.push({invoice_id:$("input.inv_td", $(row[i])).attr('data-inv'),
                                      main_id:$("input.inv_td", $(row[i])).attr('data-main-id'),
                                      customer_subscription_id:$("input.inv_td", $(row[i])).attr('data-customer-subscription-id'),
                                     });
            }
            IncludeDeleteModal(common_delete_modal, {subscription_fees: current_ids}, function () {
                toastr.success('<?php echo CommonLanguage::getMessage('Submitted_Successfully'); ?>')
                ChangeTable();
            }, "InventoryAjax/deleteSubscriptionFees");
        }); 
        $('#delete_payments').on('click', function () {
            if ($('input.inv_td:checked').length == 0) {
                toastr.error('<?php echo CommonLanguage::getMessage('choose_entry'); ?>')
                return;
            }
            var row = $("#tableWithSearch").dataTable().fnGetNodes(), current_ids = [];
            for (var i = 0; i < row.length; i++) {
                if ($("input.inv_td", $(row[i])).is(":checked"))
                    current_ids.push($("input.inv_td", $(row[i])).attr('data-main-id'));
            }
            IncludeDeleteModal(common_delete_modal, {main_ids: current_ids}, function () {
                toastr.success('<?php echo CommonLanguage::getMessage('Submitted_Successfully'); ?>')
                ChangeTable();
            }, "InventoryAjax/deleteSubscriptionFeesPayments");
        });
        $('#print_payment').on('click', function () {
            if ($('input.inv_td:checked').length == 0) {
                toastr.error('<?php echo CommonLanguage::getMessage('choose_entry'); ?>')
                return;
            }
            var row = $("#tableWithSearch").dataTable().fnGetNodes(), current_ids = [];
            for (var i = 0; i < row.length; i++) {
                if ($("input.inv_td", $(row[i])).is(":checked"))
                    current_ids.push($("input.inv_td", $(row[i])).attr('data-main-id'));
            }
            var myurl = "Inventory/view_subscription_fees?main_ids=" + current_ids.toString();
            printExternal(myurl)
        }); 
        $('#submit_payment').on('click', function () {
            if(!$('#payment_type').val()){
                toastr.error('<?php echo CommonLanguage::getMessage('pay_method_alert'); ?>')
                return;  
            } 
            if(!$('#payment_date').val()){
                toastr.error('<?php echo CommonLanguage::getMessage('pay_date_alert'); ?>')
                return;  
            }
            if ($('input.inv_td:checked').length == 0) {
                toastr.error('<?php echo CommonLanguage::getMessage('choose_entry'); ?>')
                return;
            }
            var Data = {invoice_list: [], payment_type: $('#payment_type').val(),
                        payment_date:$('#payment_date').val()},
                row = $("#tableWithSearch").dataTable().fnGetNodes();
            for (var i = 0; i < row.length; i++) {
                var current_row = $("input.inv_td", $(row[i]));
                if (current_row.is(":checked")) {
                    Data.invoice_list.push({main_id: current_row.attr('data-main-id'),
                                            currency_id: current_row.attr('data-currency-id'),
                                            current_remaining: $('input.remaining_amount',$(row[i])).attr('data-remaining'),
                                            net_total: $('input.remaining_amount',$(row[i])).val(),
                                            job_id: current_row.attr('data-job-id'),
                                            project_id: current_row.attr('data-project-id'),
                                            customer_id: current_row.attr('data-customer-id')});
                }
            }
            $('#fees_list_loader').removeClass('hidden');
            $('#submit_payment').prop("disabled",true)
            $('#submit_payment_with_print').prop("disabled",true)
            $.ajax({
                url: "InventoryAjax/submitSubscriptionMultiPayment",
                data: Data,
                dataType: "json",
                method: "POST",
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (v1.responseJSON[1] == 'success') {
                            toastr.success('<?php echo CommonLanguage::getMessage('Submitted_Successfully'); ?>');
                            ChangeTable();
                        } else {
                            toastr.error(v1.responseJSON[1]);
                        }
                        $('#fees_list_loader').addClass('hidden');
                    }
                }
            });
        });
        $('#submit_payment_with_print').on('click', function () {
            if(!$('#payment_type').val()){
                toastr.error('<?php echo CommonLanguage::getMessage('pay_method_alert'); ?>')
                return;  
            } 
            if(!$('#payment_date').val()){
                toastr.error('<?php echo CommonLanguage::getMessage('pay_date_alert'); ?>')
                return;  
            }
            if ($('input.inv_td:checked').length == 0) {
                toastr.error('<?php echo CommonLanguage::getMessage('choose_entry'); ?>')
                return;
            }
            var Data = {invoice_list: [], payment_type: $('#payment_type').val(),
                        payment_date:$('#payment_date').val()},
                row = $("#tableWithSearch").dataTable().fnGetNodes();
            for (var i = 0; i < row.length; i++) {
                var current_row = $("input.inv_td", $(row[i]));
                if (current_row.is(":checked")) {
                    Data.invoice_list.push({main_id: current_row.attr('data-main-id'),
                                            currency_id: current_row.attr('data-currency-id'),
                                            current_remaining: $('input.remaining_amount',$(row[i])).attr('data-remaining'),
                                            net_total: $('input.remaining_amount',$(row[i])).val(),
                                            job_id: current_row.attr('data-job-id'),
                                            project_id: current_row.attr('data-project-id'),
                                            customer_id: current_row.attr('data-customer-id')});
                }
            }
            $('#fees_list_loader').removeClass('hidden');
            $('#submit_payment').prop("disabled",true)
            $('#submit_payment_with_print').prop("disabled",true)
            $.ajax({
                url: "InventoryAjax/submitSubscriptionMultiPayment",
                data: Data,
                dataType: "json",
                method: "POST",
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (v1.responseJSON[1] == 'success') {
                            toastr.success('<?php echo CommonLanguage::getMessage('Submitted_Successfully'); ?>');
                            $('#payment_date').datepicker('setDate', null);
                            var row = $("#tableWithSearch").dataTable().fnGetNodes(), current_ids = [];
                            for (var i = 0; i < row.length; i++) {
                                if ($("input.inv_td", $(row[i])).is(":checked"))
                                    current_ids.push($("input.inv_td", $(row[i])).attr('data-main-id'));
                            }
                            var myurl = "Inventory/view_subscription_fees?main_ids=" + current_ids.toString();
                            printExternal(myurl)
                            ChangeTable();
                        } else {
                            toastr.error(v1.responseJSON[1]);
                        }
                        $('#fees_list_loader').addClass('hidden');
                    }
                }
            });
        });
        $('#submit_discount').on('click', function () {
            var Data = {invoices: []},
                row = $("#tableWithSearch").dataTable().fnGetNodes();
            for (var i = 0; i < row.length; i++) {
                var current_row = $("input.inv_td", $(row[i])),
                    old_discount = parseFloat($(row[i]).find("input.disc_amount").attr("data-disc")),
                    discount = $(row[i]).find("input.disc_amount").val()
                if (old_discount != discount) {
                    Data.invoices.push({
                        main_id: current_row.attr('data-main-id'),
                        inv_id: current_row.attr('data-inv'),
                        discount_amount: $(row[i]).find("input.disc_amount").val()
                    });
                }
            }
            if (Data.invoices.length == 0) {
                toastr.error('<?php echo CommonLanguage::getMessage('choose_entry'); ?>')
                return;
            }
            $('#fees_list_loader').removeClass('hidden');
            $.ajax({
                url: "InventoryAjax/submitSubscriptionMultiDiscount",
                data: Data,
                dataType: "json",
                method: "POST",
                complete: function (v1, v2) {
                    if (v2 == "success") {
                        if (v1.responseJSON[1] == 'success') {
                            toastr.success('<?php echo CommonLanguage::getMessage('Submitted_Successfully'); ?>')
                            ChangeTable();
                        } else {
                            toastr.error(v1.responseJSON[0]);
                        }
                        $('#fees_list_loader').addClass('hidden');
                    }
                }
            });
        });
        $('#tableWithSearch').on('click','input.cust_name_checkbox',function(){
            var customer_id = $(this).attr('data-customer-id');
            if($(this).is(":checked")){
                $('input.inv_td[data-customer-id='+customer_id+']').prop('checked',true); 
            }else{
                $('input.inv_td[data-customer-id='+customer_id+']').prop('checked',false); 
            }

        });
    });
    function ChangeTable() {
         var Data = {
            is_actual: 0,
            customer_id: $('#customer_id').val(),
            salesman_id: $('#salesman_id').val(),
            Date: $("input[name=From_To_Date]").val(),
            paid_date: $("input[name=paid_date]").val(),
            paid_status: $("#paid_status").val(),
            paid_type: $("#paid_type").val(),
            subscription_id: $("#subscription_id").val(),
            category_id: $("#category_id").val(),
            block_id: $("#block_id").val(),
            main_block_id: $("#main_block_id").val(),
            from_date: window.startDate,
            to_date: window.endDate,
            from_paid_date: window.startDatepaid,
            to_paid_date: window.endDatepaid
        }
         $('.sub_fees_btn').addClass('hidden');
        if($('#paid_status').val() == 1){
            $('#submit_payment,#submit_payment_with_print,#submit_discount,#delete_all').removeClass('hidden');
        }else if($('#paid_status').val() == 2){
            $('#submit_payment,#submit_payment_with_print,#delete_payments,#submit_discount').removeClass('hidden');
        }else if($('#paid_status').val() == 3){
            $('#delete_payments').removeClass('hidden');
        }else if($('#paid_status').val() == 4){
            $('#delete_payments,#submit_discount,#submit_payment,#submit_payment_with_print').removeClass('hidden');
        }
        $.ajax({
            url: "InventoryAjax/get_total_subscription_fees",
            data: Data,
            dataType:"json",
            complete: function (v1, v2) {
                if (v2 == "success") {
                    var optns = {
                        cb_ft: function (dt_optns) {
                            // stop sorting for column since on click on header checkbox the sorting is triggered
                            dt_optns.columnDefs.push({targets: [0], "orderable": false});
                        },
                    };
                    var rowspan_tab = '';
                    if($('#act_cust_total_sub_fees').val() == 1){
                        rowspan_tab = ['1','2','10'];
                    }
                    RebuildDataTable($('.panel-heading .panel-title').html(), [0, 1, 2, 3, 4, 5, 6], "InventoryAjax/SubscriptionFeesList", Data, '',rowspan_tab, optns);
                    $('#total_div').html(v1.responseJSON['total']);
                    $('#category_data').html(v1.responseJSON['category_data']);
                    $('#submit_payment').prop("disabled",false);
                }
            }
        })


    }
</script>