<?php $__env->startSection('addCss'); ?>
    <style media="screen">
        table td { vertical-align: middle !important; }
    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <section class="content-header">
        <h1>
            <?php echo Trans("mortgages.menu"); ?>

            <small><?php echo trans('dashboard.others.show_all'); ?></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="<?php echo Route('mortgages.index'); ?>"><i class="fa fa-credit-card"></i> <?php echo Trans('mortgages.menu'); ?></a></li>
            <li class="active"><?php echo Trans("dashboard.others.show_all"); ?></li>
        </ol>
    </section>
    <!-- Main content -->

    <section class="content">
        <?php echo $__env->make('layouts.includes.message', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <div class="row">
                            <?php echo Form::open(['method' => 'get']); ?>

                            <div class="col-md-4">
                                <div class="form-group">
                                    <?php
                                    $value = Request::get('invoice_id') ? Request::get('invoice_id') : null;

                                    ?>
                                    <?php echo Form::label('invoice_id', trans('invoices.id')); ?>

                                    <?php echo Form::text('invoice_id', $value, [
                                      'class' => 'form-control',
                                      'placeholder' =>  trans('invoices.id')
                                    ]); ?>

                                </div>
                                <div class="form-group">
                                    <?php
                                    $value = Request::get('name') ? Request::get('name') : null;

                                    ?>
                                    <?php echo Form::label('name', trans('customers.menu')); ?>

                                    <?php echo Form::text('name', $value, [
                                      'class' => 'form-control',
                                      'placeholder' =>  trans('customers.menu')
                                    ]); ?>

                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <?php echo Form::label('start_date', trans('invoices.start_date')); ?>

                                    <div class="input-group date" data-provide="datepicker">
                                        <?php
                                        $value = Request::get('start_date') ? Request::get('start_date') : null;

                                        ?>

                                        <?php echo Form::text('start_date', $value, [
                                          'class' => "form-control",
                                          'placeholder' => Trans('invoices.start_date'),
                                          'autocomplete' => "off"
                                        ]); ?>

                                        <div class="input-group-addon">
                                            <i class="fa fa-calendar"></i>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <?php echo Form::label('end_date', trans('invoices.end_date')); ?>

                                    <div class="input-group date" data-provide="datepicker">
                                        <?php
                                        $value = Request::get('end_date') ? Request::get('end_date') : null;

                                        ?>

                                        <?php echo Form::text('end_date', $value, [
                                          'class' => "form-control",
                                          'placeholder' => Trans('invoices.end_date'),
                                          'autocomplete' => "off"
                                        ]); ?>

                                        <div class="input-group-addon">
                                            <i class="fa fa-calendar"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label for=""><?php echo trans("reports.show"); ?></label>
                                    <?php
                                    $selected = Input::get('paginate') ? Input::get('paginate') : 10;
                                    ?>
                                    <?php echo Form::select("paginate", [
                                        'all'   =>  "All",
                                        10      =>  10,
                                        15      =>  15,
                                        20      =>  20,
                                        25      =>  25,
                                        30      =>  30,
                                        50      =>  50,
                                        100     => 100
                                    ], $selected, [
                                        'class' => 'form-control select2',
                                      ]); ?>

                                </div>
                                <div class="form-group">
                                    <?php $selelcted = !empty(Input::get("status")) ? Input::get("status") : null; ?>
                                    <label for="status"><?php echo trans("installments.loan_status"); ?></label>
                                    <?php echo Form::select("status", [
                                      'all'       =>  "All",
                                      'pendding'  =>  trans("mortgages.pendding"),
                                      'progressing'     =>  trans("mortgages.progressing"),
                                      'completed'      => trans("mortgages.completed"),
                                      'is_expired' => trans("mortgages.expired")
                                    ], $selelcted, [
                                      'class' => "form-control select2"
                                    ]); ?>

                                </div>
                                <button type="submit" class="btn btn-info pull-right" name="search" value="true"><i class="fa fa-search"></i> <?php echo Trans('invoices.search'); ?></button>
                            </div>
                            <?php echo Form::close(); ?>

                        </div>
                    </div>
                    <div class="box-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th><?php echo trans('mortgages.id'); ?></th>
                                    <th><?php echo trans('mortgages.date'); ?></th>
                                    <th><?php echo trans('mortgages.customer'); ?></th>
                                    <th><?php echo trans('mortgages.product_name'); ?></th>
                                    <th><?php echo trans('mortgages.price_out'); ?></th>
                                    <th><?php echo trans('dashboard.others.status'); ?></th>
                                    <th><?php echo trans('dashboard.crud.actions'); ?></th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php if(count($mortgages) > 0): ?>
                                    <?php foreach($mortgages as $mortgage): ?>
                                        <tr>
                                            <td><?php echo convertInvoiceNumber($mortgage->id); ?></td>
                                            <td><?php echo format_date_installment($mortgage->start_date); ?></td>
                                            <td><?php echo $mortgage->fullname; ?> (<?php echo $mortgage->tel; ?>)</td>
                                            <td>
                                                <?php echo $mortgage->product_name; ?>

                                                <?php if($mortgage->is_expired): ?>
                                                    <span class="label label-danger"><?php echo trans("mortgages.expired"); ?></span>
                                                <?php endif; ?>
                                            </td>
                                            <td><?php echo money($mortgage->price_out); ?></td>
                                            <td>
                                                <?php if($mortgage->status == "pendding"): ?>
                                                    <span class="label label-warning"><?php echo trans("mortgages.".$mortgage->status); ?></span>
                                                <?php elseif($mortgage->status == "progressing"): ?>
                                                    <span class="label label-info"><?php echo trans("mortgages.".$mortgage->status); ?></span>
                                                <?php else: ?>
                                                    <span class="label label-success"><?php echo trans("mortgages.".$mortgage->status); ?></span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <a href="<?php echo route('mortgages.show', $mortgage->id); ?>" class="btn btn-sm btn-default"><i class="fa fa-th-list"></i></a>
                                                <?php if(get_config('allow_delete_mortgage_completed') == "yes" || $mortgage->status != "completed"): ?>
                                                <a href="#" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#myModal<?php echo $mortgage->id; ?>"><i class="fa fa-trash"></i></a>
                                                <?php echo $__env->make('layouts.includes.modals.danger', ['model' => $mortgage,'toRoute'=>'mortgages','attribute'=>'product_name'], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach; ?>
                                <?php else: ?>
                                    <tr>
                                        <td colspan="7" class="text-center">No record.........</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                        <?php if(empty(Input::get("paginate")) || Input::get("paginate") != "all"): ?>
                            <div class="row">
                                <div class="col-md-4">
                                    <p style="margin-top: 10px;">Total Records : <?php echo $mortgages->getTotal(); ?> Page <?php echo $mortgages->getCurrentPage(); ?> of <?php echo $mortgages->getLastPage(); ?></p>
                                </div>
                                <div class="col-md-8 text-right">
                                    <?php echo $mortgages->appends(Request::except('page'))->links(); ?>

                                </div>
                            </div>
                        <?php else: ?>
                            <?php if($mortgages->count() > 0): ?>
                                Total Records : <?php echo $mortgages->count(); ?>

                            <?php endif; ?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </section>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('addJs'); ?>
    <?php echo HTML::script('plugins/datepicker/bootstrap-datepicker.js'); ?>

    <?php echo HTML::script('plugins/datepicker/locales/bootstrap-datepicker.kh.js'); ?>

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

<?php echo $__env->make('layouts.production', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>