 <?php $__env->startSection('content'); ?>
<style>
    input[readonly] {
        background-color: white !important;
    }
    textarea[readonly] {
        background-color: white !important;
    }
</style>
<?php Fun::lang() ?>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Edit House</a></li>
            <li><a href="#">Show</a></li>
        </ul>
    </div>
</div>
<div class="page">
    <div class="top-content">
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="title-page">
                    <div class="pull-left">
                        <h3>Show Edit House</h3>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 col-xs-12">

            <div class="form-wrapper">
                <?php echo Form::model($data, ['method' => 'PATCH', 'enctype'=>'multipart/form-data','route' => ['edit_house.update', $data->id]]); ?>

                    <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Client</label>
                        <?php echo Form::text('client_id',$data->client_fullname, array('class' => 'form-control select2','required','readonly')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Project</label>
                        <?php echo Form::text('project_id', $data->project_name, array('class' => 'form-control select2','required','readonly')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Item</label>
                        <?php echo Form::text('item', $sale_info->item_names, array('placeholder' => 'Item Name','class' => 'form-control','required','readonly')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Contract Number</label>
                        <?php echo Form::text('contract_number', null, array('placeholder' => 'Contract Number','class' => 'form-control','required','readonly')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Constract Date</label>
                        <?php echo Form::text('contract_date', date("d-m-Y",strtotime($data->contract_date)), array('placeholder'=>'Contract Date','class' => 'form-control date_picker','required','readonly')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Date</label>
                        <?php echo Form::text('date', date('d-m-Y',strtotime($data->date)), array('laceholder'=>'Date','class' => 'form-control date_picker','required','readonly')); ?>

                    </div>
                </div>
                <div id="bwi-append">
                    <br/>
                    <div class="row contract-constructor" style="padding: 15px;">
                        <table class="table table-striped table-bordered" width="100%">
                            <thead>
                                <tr>
                                    <th>
                                        ល.រ
                                    </th>
                                    <th>
                                        <label class="required">
                                            បរិយាយនៃការស្នើសុំ
                                        </label>
                                    </th>
                                    <th>
                                        <label class="required">
                                            ខ្នាត
                                        </label>
                                    </th>
                                    <th>
                                        <label class="required">
                                            បរិមាណ
                                        </label>
                                    </th>
                                    <th>
                                        <label class="required">
                                            តម្លៃ
                                        </label>
                                    </th>
                                </tr>
                            </thead>
                            <tbody class="tb_building_work">
                                <?php $__currentLoopData = $data_detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($key==0): ?>
                                    <?php $btn_status = "disabled"; ?>
                                <?php else: ?>
                                    <?php $btn_status = ""; ?>
                                <?php endif; ?>
                                <tr>
                                    <td><?php echo e($key+1); ?></td>
                                    <td>
                                        <?php echo Form::textarea('description[]', $value->request_description, array('placeholder' => 'បរិយាយ','class' => 'form-control','rows'=>'3','required','readonly')); ?>

                                    </td>
                                    <td>
                                        <?php echo Form::text('unit[]', $value->unit,array('placeholder' => 'ខ្នាត','class' => 'form-control','required','readonly')); ?>

                                    </td>
                                    <td>
                                        <?php echo Form::text('qty[]', $value->qty, array('placeholder' => 'បរិមាណ','class' => 'form-control number-only','required','readonly')); ?>

                                    </td>
                                    <td>
                                        <?php echo Form::text('fee_price[]', $value->fee_price, array('placeholder' => 'តម្លៃ','class' => 'form-control number-only','required','readonly')); ?>

                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12 col-xs-12">
                        <div class="form-group">
                            <button type="button" onClick="javascript:history.go(-1)" class="button_sm button_warning pull-right">
                                <span class=" fa fa-arrow-circle-left"></span> Back</button>
                        </div>
                    </div>
                </div>
                <br/>

                <?php echo Form::close(); ?>

            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?> <?php $__env->startSection('js'); ?>
<script>
    function remove(obj)
    {
        var index = 0;
        $(obj).closest('tr').remove();
        var tr_class =  $("tbody.tb_building_work").find('tr');
        $(tr_class).each(function(){
            $(this).find('td:eq(0)').html(`<span>${++index}</span>`);
        });
    }
    function add_new_request(obj)
    {
        var tr = `
                            <tr>
                                <td>${$("tbody.tb_building_work").find('tr').length+1}</td>
                                <td>
                                    <?php echo Form::textarea('description[]', null, array('placeholder' => 'បរិយាយ','class' => 'form-control','rows'=>'3','required')); ?>

                                </td>
                                <td>
                                    <?php echo Form::text('unit[]',null,array('placeholder' => 'ខ្នាត','class' => 'form-control','required')); ?>

                                </td>
                                <td>
                                    <?php echo Form::text('qty[]', null, array('placeholder' => 'បរិមាណ','class' => 'form-control number-only','required')); ?>

                                </td>
                                <td>
                                    <?php echo Form::text('fee_price[]', null, array('placeholder' => 'តម្លៃ','class' => 'form-control number-only','required')); ?>

                                </td>
                                <td>
                                    <button class="btn btn-sm btn-danger" onclick="remove(this)">
                                    <span class="fa fa-trash"></span></button>
                                </td>
                            </tr>
        `;
        $(obj).closest('table').find('tbody').append(tr);
        
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>