<?php $__env->startSection('title'); ?>
    Receivables
<?php $__env->stopSection(); ?>

<?php $__env->startSection('style'); ?>
    <style>
        tr.group,
        tr.group:hover {
            background-color: #ddd !important;
        }
        /*filter on top*/
        tfoot {
            display: table-header-group;
        }
        thead {
            display: table-row-group;
        }
        /*hide show entries
        .dataTables_length {
            display: none;
        }
        .dataTables_filter {
            display: none;
        }*/
        select.fstyle { width: 50px }
        /*#user_table select
        {
            width:340px !important;
        }*/
        table.dataTable tr.odd { background-color: #E5F7FC; }
        table.dataTable tr.even { background-color: white; }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <span class="fa fa-bookmark-o"></span> Receivables
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-bookmark-o"></i> Admin Panel</a></li>
                <li class="active"> Receivables</li>
            </ol>
        </section>
        <input type="hidden" id="cmonth" name="cmonth" value="<?php echo e($cmonth); ?>" readonly>

        <!-- Main content -->
        <section class="content" style=" padding-bottom: 10%;">
            
            <div class="page-header">
                
                <div style="width: 280px;float:right;">
                    <div style="float:right;display: inline-block;font-size: 14px;">
                        Year:
                        <select name="yyear" id="yyear" class="form-control ddate">
                            <?php $__currentLoopData = $years; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($year->yyear); ?>"><?php echo e($year->yyear); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div style="float:right;display: inline-block;font-size: 14px;">
                        Month:
                        <select name="mmonth" id="mmonth" class="form-control ddate">
                            
                            <?php $__currentLoopData = $months; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $month): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($month->mmonth); ?>"><?php echo e($month->mmonth); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div style="float:right;display: inline-block;font-size: 14px;margin-top:20px;padding-right:5px;">
                        <button id="btnFilter" class="btn btn-info"><i class="fa fa-filter" aria-hidden="true"></i> Filter</button>
                    </div>
                </div>
            </div>

            <div style="padding-top:30px;"></div>
            <table class="table table-hover" id="user_table" width="100%">
                <thead>
                    <tr style="background: grey ;color:#fff; font-weight: bold">
                        <td>ID</td>
                        <td>Reserved Date</td>
                        <td>Developer</td>
                        <td>Project</td>
                        <td>Blk / Lot</td>
                        <td>Client</td>
                        <td style="text-align: center">Agent</td>
                        <td>Net Price</td>
                        
                        <td>Actions</td>
                    </tr>
                </thead>
                <?php $__currentLoopData = $comms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $comm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr >
                        
                        <td><a href="<?php echo e(route('receivables.edit',[$comm->rcvd_id])); ?>"><?php echo e($comm->rcvd_id); ?></a></td>
                        <td width="10%"><?php echo e(date("d-M-Y", strtotime($comm->created_at))); ?></td>
                        <td><?php echo e($comm->dev_name); ?></td>
                        <td><?php echo e($comm->prj_name); ?></td>
                        <td>Blk: <?php echo e($comm->blk); ?> / Lot: <?php echo e($comm->lot); ?></td>
                        <td><?php echo e($comm->client_name); ?></td>
                        <td><span class="label label-default"><?php echo e(strtoupper($comm->agent_code)); ?></span></td>
                        <td style="text-align: right"><?php echo e(number_format($comm->net_selling_price,2)); ?></td>
                        
                        <td class="btn btn-default ">
                            <a href="<?php echo e(route('receivables.edit',[$comm->rcvd_id])); ?>" class="btn btn-success btn-xs"><i class="fa fa-edit"></i></a>
                            <a href="#" data-toggle="modal" data-target="#d<?php echo e($comm->rcvd_id); ?>" class="text-danger btn btn-danger btn-xs"><i class="fa fa-trash"></i></a>
                            <!-- Delete Modal -->
                            <div class="modal fade" id="d<?php echo e($comm->rcvd_id); ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                <div class="modal-dialog" role="document">
                                    <form method="post" action="<?php echo e(route('user.delete')); ?>">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title" id="myModalLabel"><i class="fa fa-warning"></i> confirm deletion</h4>
                                        </div>
                                        <div class="modal-body text-danger">
                                            <input type="hidden" name="id" value="<?php echo e($comm->rcvd_id); ?>">
                                            Are you sure want to delete receivable <?php echo e($comm->rcvd_id); ?>?
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                            <button type="submit" class="btn btn-primary">Confirm</button>
                                        </div>

                                    </div>
                                        <?php echo e(csrf_field()); ?>

                                    </form>
                                </div>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  <tfoot>
                    <tr>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                    </tr>
                  </tfoot>
            </table>
            <?php if(Session('info')): ?>
                <div class="row">
                    <div class="col-md-6 col-md-offset-3 text-center">
                        <div class="tem alert alert-success navbar-fixed-bottom"><span class="glyphicon glyphicon-ok-circle"></span> <?php echo e(Session('info')); ?></div>
                    </div>
                </div>
            <?php endif; ?>
        </section>

    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script>
        $(document).ready(function() {
            /*$('#user_table').DataTable( {
                "bDestroy": true,
                "order": [[ 0, "desc" ]]
            });*/
            $("#user_table").dataTable().fnDestroy();
            $('#user_table').DataTable( {
            /*"columnDefs": [
                { "visible": false, "targets": [0,2,3] }
                ],*/
                "bDestroy": true,
                "order": [[ 0, "desc" ]],
                initComplete: function () {
                    this.api().columns([2,3,4,5]).every( function () {
                        var column = this;
                        var select = $('<select class="fstyle" id="lnOpt"><option value=""></option></p>')
                            .appendTo( $(column.footer()).empty() )
                            .on( 'change', function () {
                                var val = $.fn.dataTable.util.escapeRegex(
                                    $(this).val()
                                );
                                column
                                    .search( val ? '^'+val+'$' : '', true, false )
                                    .draw();
                            } );

                        column.data().unique().sort().each( function ( d, j ) {
                            select.append( '<option value="'+d+'">'+d+'</option>' )
                        } );
                    } );
                }
            } );
        });

        /*$('#mmonth').on('change', function () {
            var yy = $("#yyear").val();
            //alert(this.value+' '+yy);
            window.location.href = '/admin/receivables/month/'+this.value+'/'+yy;
            $('#mmonth').val(this.value);
        });

        $('#yyear').on('change', function () {
            var mm = $("#mmonth").val();
            window.location.href = '/admin/receivables/month/'+mm+'/'+this.value;
            //alert(mm+' ' +this.value);
        });*/

        /*$('.ddate').on('change', function () {
            alert(this.value);
        });*/

        /*$('#btnMonth').on('click', function () {
            var mm = $("#mmonth").val();
            var yy = $("#yyear").val();
            window.location.href = '/admin/receivables/month/'+mm+'/'+yy;
            //alert(mm+' ' +this.value);
        });*/

        $('#btnFilter').on('click', function () {
            //alert('ready');
            var mm = $("#mmonth").val();
            var yy = $("#yyear").val();

            //alert(mm +' - '+ yy);

            window.location.href = '/admin/receivables/month/'+mm+'/'+yy;

            //alert(cm +' - '+ yy);
            /*var cm = $("#cmonth").val();
            var yy = $("#yyear").val();
            window.location.href = '/sales/month/'+cm+'/'+yy;*/
            //alert(mm+' ' +this.value);
        });
        /*$("#btnAdd").on("click", function(){
            $('#addModal').modal('toggle');
        });*/
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>