<?php 
$customers = $db->selectAll('customer','where base_id='.$userData['base_id'],'id,name');
?>
<section class="mb-12">
<div class="card-header text-center py-3">
    <h5 class="mb-0 text-center">
        <strong>Customer statement</strong>
    </h5>
</div>
    <div class="row">
        <div class="col-md-2">
            <div class="col-sm-12 col-lg-12">   
                <h5 class="box-title">Date</h5>
                <input type="text" id="dRange" class="daterangepickerMulti form-control" value="">
            </div> 
        </div>
        <?php 
            $general->inputBoxSelectForReport($customers,'Customer','customer_id','id','name',@$_GET['customer-id']);
            ?>
        <div class="col-md-2">
            <h5 class="box-title">&nbsp</h5>
            <button class="btn btn-success" onclick="customer_statement()">Search</button>
            <script type="text/javascript">
                function customer_statement(){
                    let dRange  = $('#dRange').val();
                    let customer_id  = $('#customer_id').val();
                    let type_zero  = $('#type_zero').val();
                    let type  = $('#type').val();
                    $('#reportArea').html(loadingImage);
                    $.ajax({
                        type:'post',
                        url:ajUrl,
                        data:{module:'customer_statement',dRange,customer_id,type_zero,type},
                        success:function(data){
                            if(typeof(data.status)){
                                if(data.status==1){
                                    $('#reportArea').html(data.html);
                                }
                                swMessageFromJs(data.m);
                            }
                            else{
                                $('#reportArea').html('');
                                swMessage(AJAX_ERROR_MESSAGE); 
                            }

                        },
                        error:function(){
                            $('#reportArea').html('');
                             swMessage(AJAX_ERROR_MESSAGE); 
                        }
                    });
                }
                $(document).ready(function(){
                    customer_statement();
                });
            </script>
        </div>
    </div>

</section>
<section class="mb-12">
    <div class="card">
        
        <div class="card-body" id="reportArea">
            
        </div>
    </div>
</section>