<?php
    $general->pageHeader($rModule['title']);
    $empDatas=array();
    $employees=$db->selectAll($general->table(74)); 
    $general->arrayIndexChange($employees,'eID'); 
    $tBalance=0;
    $scID=SECTION_DEALER;
    $designations=$db->selectAll($general->table(72));
    $general->arrayIndexChange($designations,'edID');

    foreach($employees as $eID=>$e){
        $balance=$acc->employeeDueBalance($e['eID'],$scID);
        $tBalance+=$balance;
        $data=[
            'eName'     => $e['eName'], 
            'edTitle'   => $designations[$e['edID']]['edTitle'],
            'balance'   => $balance
        ];
        $empDatas[$eID]=$data;
    }
?>
<script type="text/javascript">
    <?php echo 'var empDatas='.json_encode($empDatas).';';?>
</script>
<div class="row">
    <div class="col-sm-12">
        <div class="white-box">
            <div class="row">
                <div class="col-sm-12 col-lg-12">
                    <input type="hidden" id="scID" value="<?php echo $scID;?>">
                    <div class="col-md-2">
                        <h5 class="box-title">Name</h5>  
                        <input type="text" class="form-control" id="eName" name="eName" value="" >  
                    </div>


                    <div class="col-md-2">
                        <h5 class="box-title">Search </h5>
                        <input type="submit" value="Search" class="btn btn-success" name="s" onclick="dealerDueCollect();">
                    </div>

                    <script>
                        $(document).ready(function(){
                            dealerDueCollect();
                        });
                        function dealerDueCollect(){
                            var scID   = parse_int($('#scID').val());
                            var eName   = $('#eName').val();
                            $('#reportArea').html(loadingImage);
                            $.ajax({
                                type:'post',
                                url:ajUrl,
                                data:{dealerDueCollect:1,eName:eName,scID:scID},
                                success:function(data){
                                    $('#reportArea').html('');
                                    if(data.status==1){
                                        $('#reportArea').html(data.html);
                                    }
                                    swMessageFromJs(data.m);
                                }
                            });
                        }
                    </script>
                </div>
                <div class="col-sm-12 col-lg-12"><?php show_msg();?></div>
                <div class="col-sm-12 col-lg-12" id="reportArea"></div>
            </div>
        </div>
    </div>
</div>
<div style="display: none;">
    <a href="javascript:void()" data-toggle="modal" data-target="#payEmployeeSalaryModel" id="payEmployeeSalaryModelAct"></a>
</div>
<div class="modal fade" id="payEmployeeSalaryModel" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="modalTitle">Due Collect</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="receiveAmount">
                    <input type="hidden" value="" id="eIDe">
                    <?php $general->inputBoxText('employe','Employee','','','','disabled');?>
                    <?php $general->inputBoxText('employeDesignation','Designation','','','','disabled');?>
                    <?php $general->inputBoxText('employeeBalance','Balance','','','amount_td','disabled');?>
                    <?php $general->inputBoxText('payAmount','Amount','','','amount_td');?>
                    <?php $general->inputBoxText('payNote','Note');?>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                    <button type="button" onclick="dueCollect()" class="btn btn-info" id="salaryPayBtn">Submit</button>
                </div>
            </div>
        </div>
    </div>
</div>  