<?php Fun::lang() ?>


<?php $__env->startSection('content'); ?>

<div class="page">
    <div class="top-content">
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="title-add">
                    <div class="pull-left">
                        <h3><?php echo e(__('administrator.income_statement')); ?></h3>
                    </div>
                    <div class="pull-right">
                    </div>
                </div>
            </div>
            <form action="<?php echo e(route('print.income-statement')); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <?php echo e(method_field('POST')); ?>

                <div class="title-bar col-sm-12">
                    <?php
                    $start  = new DateTime('first day of this month');
                    $from   = $start->format('d-m-Y');
                    $end    = new DateTime('last day of this month');
                    $to     = $end->format('d-m-Y');
                    ?>
                        <br>
                    <span class="title-tab">
                        <span class="text-tab"> Income Statement >> <span id="start_date"><?php echo e($from); ?></span> >> <span id="end_date"><?php echo e($to); ?></span> </span>

                        <button type="submit" class="btn btn-tab btn-xs btn-warning pull-right"><i class="fa fa-print"></i></button>
                        
                        <span class="btn-toggle btn btn-primary btn-xs pull-right" style="margin-left:5px"><i class="fa fa-caret-down"></i></span>
                        <input type="hidden" name="report" value="Trial Balance">
                    </span>
                    <!-- <button type="submit" class="pull-right btn btn-xs btn-warning" data-toggle="tooltip" data-placement="top" title="Print Voucher"><i class="fa fa-print" aria-hidden="true"></i></button> -->
                </div>

                <div class="row">
                    <div class="col-sm-12 toggle-div" style="display:none">

                        <div class="col-sm-12">
                            <hr>
                            
                                
                                
                            
                            <div class="col-sm-4">
                                <label for="">Start Date</label>
                                <div class="form-group">
                                    <input type="text" name="from" class="form-control date_picker start_date">
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <label for="">End Date</label>
                                <div class="form-group">
                                    <input type="text" name="to" class="form-control date_picker end_date">
                                </div>
                            </div>
                            <div class="col-sm-12" style="text-align: right">
                                <label for="">&nbsp;</label>
                                <div class="form-group">
                                    <button type="button" class="btn-warning btn btn-md" onclick="search()"><i class="fa fa-search"></i> Search</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 col-xs-12">
            <div class="form-wrapper">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-responsive">
                            <table id="table_journal" class="table table-bordered table-striped table table-condensed table-hover">
                                <thead>
                                    <tr>
                                        <th>No</th>
                                        <th><?php echo e(__('administrator.account_name')); ?></th>
                                        <th><?php echo e(__('administrator.total')); ?></th>
                                    </tr>
                                </thead>
                                <tbody id="tbody"></tbody>

                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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

<?php $__env->startSection('js'); ?>
<script type="text/javascript">
    $(document).ready(function() {
        $.ajax({
            url: "<?php echo e(route('accounting-report.get-income-statement')); ?>",
            method: "get",
            dataType: "text",
            data: {
                _token: '<?php echo e(csrf_token()); ?>',
            },
            success: function(data) {
                $('#tbody').append(data);
            }
        });
    });
    $(document).on('click', '.clickable-row', function() {
        window.location = $(this).data("href");
    });
    $(document).on('click', '.btn-toggle', function() {
        $('.toggle-div').toggle('fast');
    });

    function search() {
        var from = $('.start_date').val();
        var to = $('.end_date').val();
        var project = $('#project_id').val();
        if (from == "" || to == "") {
            $.alert({
                title: 'Error',
                icon: 'fa fa-warning',
                type: 'orange',
                content: 'Something went wrong, please retry again.' +
                    '<hr>' +
                    'Note: No Date Selected',
            });
            return false;
        } else {
            $.ajax({
                url: "<?php echo e(route('accounting-report.get-income-statement')); ?>",
                method: "POST",
                dataType: "text",
                data: {
                    from: from,
                    to: to,
                    project: project,
                    _token: '<?php echo e(csrf_token()); ?>',
                },
                success: function(data) {
                    $('#start_date').text(from);
                    $('#end_date').text(to);
                    $('#tbody').empty();
                    $('#tbody').append(data);
                }
            });
        }
    }
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app-accounting', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/Accounting/reports/income-statement.blade.php ENDPATH**/ ?>