@extends('adminlte::page') @section('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">
                {!! Form::model($data, ['method' => 'PATCH', 'enctype'=>'multipart/form-data','route' => ['edit_house.update', $data->id]]) !!}
                    @csrf
                <div class="row">
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Client</label>
                        {!! 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>
                        {!! 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>
                        {!! 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>
                        {!! 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>
                        {!! 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>
                        {!! 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">
                                @foreach($data_detail as $key=>$value)
                                @if($key==0)
                                    <?php $btn_status = "disabled"; ?>
                                @else
                                    <?php $btn_status = ""; ?>
                                @endif
                                <tr>
                                    <td>{{ $key+1 }}</td>
                                    <td>
                                        {!! Form::textarea('description[]', $value->request_description, array('placeholder' => 'បរិយាយ','class' => 'form-control','rows'=>'3','required','readonly')) !!}
                                    </td>
                                    <td>
                                        {!! Form::text('unit[]', $value->unit,array('placeholder' => 'ខ្នាត','class' => 'form-control','required','readonly')) !!}
                                    </td>
                                    <td>
                                        {!! Form::text('qty[]', $value->qty, array('placeholder' => 'បរិមាណ','class' => 'form-control number-only','required','readonly')) !!}
                                    </td>
                                    <td>
                                        {!! Form::text('fee_price[]', $value->fee_price, array('placeholder' => 'តម្លៃ','class' => 'form-control number-only','required','readonly')) !!}
                                    </td>
                                </tr>
                                @endforeach
                            </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/>

                {!! Form::close() !!}
            </div>
        </div>
    </div>
</div>
@endsection @section('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>
                                    {!! Form::textarea('description[]', null, array('placeholder' => 'បរិយាយ','class' => 'form-control','rows'=>'3','required')) !!}
                                </td>
                                <td>
                                    {!! Form::text('unit[]',null,array('placeholder' => 'ខ្នាត','class' => 'form-control','required')) !!}
                                </td>
                                <td>
                                    {!! Form::text('qty[]', null, array('placeholder' => 'បរិមាណ','class' => 'form-control number-only','required')) !!}
                                </td>
                                <td>
                                    {!! 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>
@endsection