<?php $__env->startSection('content'); ?>
<div class="col-md-12 content-header" >
    <h1><i class="fa fa-quote-left"></i> Estimates</h1>
</div>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="row">
                    <div class="col-md-6" style="width:880px;margin-left:20px"><br/>
                        <a href="<?php echo e(route('estimates.index')); ?>" class="btn btn-info btn-sm"> <i class="fa fa-chevron-left"></i> Back</a>
                        <a href="<?php echo e(route('estimates.show', $estimate->id)); ?>" class="btn btn-primary btn-sm pull-right"> <i class="fa fa-search"></i> Preview</a>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="invoice">
                            <img src="<?php echo e(asset('assets/img/ajax-loader.gif')); ?>" class="loading"  />
                            <?php echo Form::model($estimate, ['route' => ['estimates.update', $estimate->id],  'method' => 'PATCH', 'id' => 'estimate_form', 'data-toggle'=>"validator", 'role' =>"form"]); ?>

                            <div class="col-md-12">
                                <div class="text-right"><h1>ESTIMATE</h1></div>
                                <div class="col-md-7" style="padding: 0px">
                                    <div class="contact to">
                                        <div class="form-group">
                                            <?php echo Form::label('client', 'Client'); ?>

                                            <div class="input-group col-md-7">
                                                <?php echo Form::select('client',$clients,$estimate->client_id, ['class' => 'form-control chosen', 'id' => 'client', 'required']); ?>

                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <?php echo Form::label('currency', 'Currency'); ?>

                                            <div class="input-group col-md-7">
                                                <?php echo Form::select('currency',$currencies,null, ['class' => 'form-control chosen', 'required']); ?>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-5" style="padding: 0px">
                                    <div class="form-group">
                                        <?php echo Form::label('estimate_no', 'Estimate Number'); ?>

                                        <?php echo Form::text('estimate_no',null, ['class' => 'form-control', 'id' => 'estimate_no', 'required']); ?>

                                    </div>
                                    <div class="form-group">
                                        <?php echo Form::label('estimate_date', 'Estimate Date'); ?>

                                        <?php echo Form::text('estimate_date',null, ['class' => 'form-control datepicker' , 'id' => 'estimate_date', 'required']); ?>

                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <table class="table table-striped" id="item_table">
                                    <thead style="background: #2e3e4e;color: #fff;">
                                    <tr>
                                        <th></th>
                                        <th width="40%">PRODUCT</th>
                                        <th width="15%">QTY</th>
                                        <th width="15%">PRICE</th>
                                        <th width="15%">TAX</th>
                                        <th width="15%"class="text-right">AMOUNT</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach($estimate->items as $item): ?>
                                    <tr class="item">
                                        <td>
                                            <span class="btn btn-danger btn-xs deleteItem" data-id="<?php echo e($item->id); ?>"><i class="fa fa-trash"></i></span>
                                            <?php echo Form::hidden('itemId',$item->id, ['id'=>'itemId', 'required']); ?>

                                        </td>
                                        <td>
                                            <div class="form-group"><?php echo Form::customSelect('product',$products,$item->product_id, ['class' => 'form-control product', 'id'=>"product", 'required' ]); ?></div>
                                        </td>
                                        <td class="text-center">
                                            <div class="form-group">
                                                <?php echo Form::input('number', 'quantity',$item->quantity, ['class' => 'form-control calcEvent quantity', 'id'=>"quantity" , 'required', 'step' => 'any', 'min' => '1']); ?>

                                            </div>
                                        </td>
                                        <td class="text-right">
                                            <div class="form-group"><?php echo Form::input('number','rate',$item->price, ['class' => 'form-control calcEvent rate', 'id'=>"rate", 'required', 'step' => 'any', 'min' => '1']); ?>

                                        </td>
                                        <td>
                                            <div class="form-group"><?php echo Form::customSelect('tax',$taxes,$item->tax_id, ['class' => 'form-control calcEvent tax', 'id'=>"tax"]); ?></div>
                                         </td>
                                        <td class="text-right"><span class="itemTotal"><?php echo e($estimate->totals[$item->id]['itemTotal']); ?></span></td>
                                    </tr>
                                    <?php endforeach; ?>

                                    </tbody>
                                </table>
                            </div><!-- /.col -->
                            <div class="col-md-6"></div><!-- /.col -->
                            <div class="col-md-6">
                                <table class="table">
                                    <tbody>
                                    <tr>
                                        <th style="width:50%">Subtotal</th>
                                        <td class="text-right">
                                            <span class="currencySymbol"><?php echo e($estimate->currency); ?></span>
                                            <span id="subTotal"><?php echo e($estimate->totals['subTotal']); ?></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>Tax</th>
                                        <td class="text-right">
                                            <span class="currencySymbol"><?php echo e($estimate->currency); ?></span>
                                            <span id="taxTotal"><?php echo e($estimate->totals['taxTotal']); ?></span>
                                        </td>
                                    </tr>
                                    <tr class="amount_due">
                                        <th>Total:</th>
                                        <td class="text-right">
                                            <span class="currencySymbol"><?php echo e($estimate->currency); ?></span>
                                            <span id="grandTotal"><?php echo e($estimate->totals['grandTotal']); ?></span>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div><!-- /.col -->

                            <div class="col-md-12">
                                <div class="form-group">
                                    <?php echo Form::label('notes', 'Notes'); ?>

                                    <?php echo Form::textarea('notes',$estimate->notes, ['class' => 'form-control','rows' =>  '2']); ?>

                                </div>
                                <div class="form-group">
                                    <?php echo Form::label('terms', 'Terms'); ?>

                                    <?php echo Form::textarea('terms',$estimate->terms, ['class' => 'form-control', 'rows' =>  '2']); ?>

                                </div>
                            </div>

                            <div class="col-md-12">
                                <span id="btn_add_row" class="btn btn-small btn-info "><i class="fa fa-plus"></i> Add Row</span>
                                <button type="submit" class="btn btn-success pull-right" id="saveEstimate"><i class="fa fa-save"></i> Save Estimate</button>
                            </div>
                            <?php echo Form::close(); ?>

                        </div>
                        </div>
                    </div>
                </div>
            </div>>
        </div>
</section>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
    <?php echo $__env->make('estimates.partials._estimatesjs', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>