<?php $__env->startSection('addCss'); ?>
    <style media="screen">
        #example2_filter input[type=search] {
            width: 200px;
        }
        table td { vertical-align: middle !important; }
        fieldset {
            border: 1px solid #ddd !important;
            padding: 10px;
            margin-bottom: 20px;
        }
        legend { font-size: 14px; border-bottom: 0; width: inherit; border: 1px solid #ddd; padding: 10px; margin-bottom: 0;}
    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <section class="content-header">
        <h1>
            <?php echo Trans("mortgages.menu"); ?>

            <small><?php echo $mortgage->exists ? trans('mortgages.edit') : trans('mortgages.add_new'); ?></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.crud.add"); ?></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">
                        <h3 class="box-title"><i class="fa fa-credit-card"></i> <?php echo $mortgage->exists ? trans("mortgages.form_edit") : trans("mortgages.form"); ?></h3>
                        <?php if($mortgage->exists): ?>
                            <a href="<?php echo route('mortgages.show', $mortgage->id); ?>" class="btn btn-sm btn-default pull-right"><i class="fa fa-th-list"></i> <?php echo trans("dashboard.others.show"); ?></a>
                        <?php endif; ?>
                    </div>
                    <div class="box-body">
                        <?php echo Form::model($mortgage, [
                            'method' => $mortgage->exists ? 'put' : 'post',
                            'route' => $mortgage->exists ? ['mortgages.update', $mortgage->id] : 'mortgages.store',
                            'files' => true
                        ]); ?>

                        <fieldset>
                            <legend><i class="fa fa-user-plus"></i> <?php echo trans("mortgages.customer_info"); ?></legend>
                            <div class="row">
                                <div class="form-group col-md-4 <?php echo $errors->has('fullname') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("fullname", trans("mortgages.fullname")); ?> <span class="required">*</span>
                                    <?php echo Form::text("fullname", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.fullname")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('fullname'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4 <?php echo $errors->has('tel') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("tel", trans("mortgages.tel")); ?> <span class="required">*</span>
                                    <?php echo Form::text("tel", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.tel")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('tel'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4 <?php echo $errors->has('id_card') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("id_card", trans("mortgages.id_card")); ?> <span class="required">*</span>
                                    <?php echo Form::text("id_card", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.id_card")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('id_card'); ?></small>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12 form-group">
                                    <?php echo Form::label("address", trans("mortgages.address")); ?>

                                    <?php echo Form::textarea("address", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans('mortgages.address'),
                                        'rows' => 2
                                    ]); ?>

                                </div>
                            </div>
                        </fieldset>
                        <fieldset>
                            <legend><i class="fa fa-mobile"></i> <?php echo trans("mortgages.product_info"); ?></legend>
                            <div class="row">
                                <div class="form-group col-md-4 <?php echo $errors->has('product_name') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("product_name", trans("mortgages.product_name")); ?> <span class="required">*</span>
                                    <?php echo Form::text("product_name", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.product_name")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('product_name'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4 <?php echo $errors->has('product_id') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("product_id", trans("mortgages.product_id")); ?> <span class="required">*</span>
                                    <?php echo Form::text("product_id", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.product_id")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('product_id'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <?php if($mortgage->exists == false): ?>
                                <div class="form-group col-md-4">
                                    <?php echo Form::label("photo", trans("mortgages.photo")); ?>

                                    <?php echo Form::file("photo[]", ['accept'=>"image/*",'capture'=>'camera',
                                        'class' => "form-control",
                                        'multiple' => true
                                    ]); ?>

                                </div>
                                <?php endif; ?>
                            </div>
                            <div class="row">
                                <div class="form-group col-md-4 <?php echo $errors->has('price') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("price", trans("mortgages.price")); ?> <span class="required">*</span>
                                    <?php echo Form::text("price", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.price")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('price'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4 <?php echo $errors->has('price_out') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("price_out", trans("mortgages.price_out")); ?> <span class="required">*</span>
                                    <?php echo Form::text("price_out", null, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.price_out")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('price_out'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4 <?php echo $errors->has('rate') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("rate", trans("mortgages.rate")); ?>  <span class="required">*</span>
                                    <?php $rate = get_config('mortgage_rate') ? get_config('mortgage_rate') : null; ?>
                                    <?php echo Form::text("rate", $rate, [
                                        'class' => 'form-control',
                                        'placeholder' => trans("mortgages.rate")
                                    ]); ?>

                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('rate'); ?></small>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group col-md-4 <?php echo $errors->has('start_date') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("start_date", trans("mortgages.start_date")); ?> <span class="required">*</span>
                                    <?php
                                    $selected = $mortgage->exists ? d_format($mortgage->start_date) : null;
                                    ?>
                                    <div class="input-group date">
                                        <?php echo Form::text("start_date", $selected, [
                                            'class' => 'form-control',
                                            'placeholder' => trans("mortgages.start_date"),
                                            'id' => 'start_date'
                                        ]); ?>

                                        <div class="input-group-addon">
                                            <i class="fa fa-calendar-o"></i>
                                        </div>
                                    </div>
                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('start_date'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4 <?php echo $errors->has('end_date') ? ' has-error' : ''; ?>">
                                    <?php echo Form::label("end_date", trans("mortgages.end_date")); ?> <span class="required">*</span>
                                    <?php
                                    $selected = $mortgage->exists ? d_format($mortgage->end_date) : null;
                                    ?>
                                    <div class="input-group date">
                                        <?php echo Form::text("end_date", $selected, [
                                            'class' => 'form-control',
                                            'placeholder' => trans("mortgages.end_date"),
                                            'id' => 'end_date'
                                        ]); ?>

                                        <div class="input-group-addon">
                                            <i class="fa fa-calendar-o"></i>
                                        </div>
                                    </div>
                                    <?php if(isset($errors)): ?>
                                        <small class="text-danger"><?php echo $errors->first('end_date'); ?></small>
                                    <?php endif; ?>
                                </div>
                                <div class="form-group col-md-4">
                                    <?php echo Form::label("note", trans("mortgages.note")); ?>

                                    <?php echo Form::textarea("note", null, [
                                        'class' => 'form-control',
                                        'rows' => 2,
                                        'placeholder' => trans("mortgages.note")
                                    ]); ?>

                                </div>
                            </div>
                        </fieldset>
                    </div>
                    <div class="box-footer">
                        <button type="submit" class="btn btn-success pull-right"><?php echo trans("mortgages.add_new"); ?></button>
                        <?php echo Form::close(); ?>

                    </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'); ?>

    <script>
        $(function () {
           $("#start_date, #end_date").datepicker({
               format: "dd/mm/yyyy",
               todayHighlight: true,
               autoclose: true
           });
           <?php if($mortgage->exists == false): ?>
            $("#start_date").datepicker("setDate", "0");
           <?php endif; ?>
        });
    </script>
<?php $__env->stopSection(); ?>

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