@extends('layouts.admin')
@section('content')

<div class="card">
    <div class="card-header">
        {{ trans('global.show') }} {{ trans('cruds.asset.title') }}
    </div>

    <div class="card-body">
        <div class="form-group">
            <div class="form-group">
                <a class="btn btn-default" href="{{ route('admin.assets.index') }}">
                    {{ trans('global.back_to_list') }}
                </a>
            </div>
            <table class="table table-bordered table-striped">
                <tbody>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.id') }}
                        </th>
                        <td>
                            {{ $asset->id }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.client') }}
                        </th>
                        <td>
                            {{ $asset->client->company_name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.location') }}
                        </th>
                        <td>
                            @foreach($asset->locations as $key => $location)
                                <span class="label label-info">{{ $location->location }}</span>
                            @endforeach
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.commissioning') }}
                        </th>
                        <td>
                            {{ $asset->commissioning }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_compressor') }}
                        </th>
                        <td>
                            {{ $asset->air_compressor->name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_compressor_serial_no') }}
                        </th>
                        <td>
                            {{ $asset->air_compressor_serial_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_compressor_part_no') }}
                        </th>
                        <td>
                            {{ $asset->air_compressor_part_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.airdryer') }}
                        </th>
                        <td>
                            {{ $asset->airdryer->name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.airdryer_serial_no') }}
                        </th>
                        <td>
                            {{ $asset->airdryer_serial_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_dryer_part_no') }}
                        </th>
                        <td>
                            {{ $asset->air_dryer_part_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.filter') }}
                        </th>
                        <td>
                            {{ $asset->filter->name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.filter_serial_no') }}
                        </th>
                        <td>
                            {{ $asset->filter_serial_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.filter_part_no') }}
                        </th>
                        <td>
                            {{ $asset->filter_part_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.eco_drain') }}
                        </th>
                        <td>
                            {{ $asset->eco_drain->name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.eco_drain_serial_no') }}
                        </th>
                        <td>
                            {{ $asset->eco_drain_serial_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.eco_drain_part_no') }}
                        </th>
                        <td>
                            {{ $asset->eco_drain_part_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_receiver') }}
                        </th>
                        <td>
                            {{ $asset->air_receiver->name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_receiver_serial_no') }}
                        </th>
                        <td>
                            {{ $asset->air_receiver_serial_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.air_reciever_part_no') }}
                        </th>
                        <td>
                            {{ $asset->air_reciever_part_no }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.commisioned_date') }}
                        </th>
                        <td>
                            {{ $asset->commisioned_date }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.warranty_start_date') }}
                        </th>
                        <td>
                            {{ $asset->warranty_start_date }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.warranty_end_date') }}
                        </th>
                        <td>
                            {{ $asset->warranty_end_date }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.commisioned_by') }}
                        </th>
                        <td>
                            {{ App\Models\Asset::COMMISIONED_BY_SELECT[$asset->commisioned_by] ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.commissioned_engineer') }}
                        </th>
                        <td>
                            {{ $asset->commissioned_engineer->name ?? '' }}
                        </td>
                    </tr>
            <!--
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.start_of_work') }}
                        </th>
                        <td>
                            {{ $asset->start_of_work }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.end_of_work') }}
                        </th>
                        <td>
                            {{ $asset->end_of_work }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.travelling_time') }}
                        </th>
                        <td>
                            {{ $asset->travelling_time }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.travelling_k_m') }}
                        </th>
                        <td>
                            {{ $asset->travelling_k_m }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.status') }}
                        </th>
                        <td>
                            {{ $asset->status->name ?? '' }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.remarks') }}
                        </th>
                        <td>
                            {{ $asset->remarks }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.pending_work') }}
                        </th>
                        <td>
                            {{ $asset->pending_work }}
                        </td>
                    </tr>
                -->
                    <tr>
                        <th>
                            {{ trans('cruds.asset.fields.asset_photos') }}
                        </th>
                        <td>
                            @foreach($asset->asset_photos as $key => $media)
                                <a href="{{ $media->getUrl() }}" target="_blank" style="display: inline-block">
                                    <img src="{{ $media->getUrl('thumb') }}">
                                </a>
                            @endforeach
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="form-group">
                <a class="btn btn-default" href="{{ route('admin.assets.index') }}">
                    {{ trans('global.back_to_list') }}
                </a>
            </div>
        </div>
    </div>
</div>


<div class="card-header">
    @if (!empty($asset->commissionCommissionDatas[0]['id']))
    <a href="/admin/commission-datas/{{ $asset->commissionCommissionDatas[0]['id'] }}/edit?comp_id={{ $asset->id }}">
        <button type="button" class="btn btn-primary btn-lg btn-block">Commission Service Report</button>
    </a>
    {{ $asset->commissionCommissionDatas[0]['id'] }}
    @endif
</div>
<!-- Edit Option button only for Engineer Roles and not for other roles -->
@foreach(Auth::user()->roles as $key => $roles)
@if($roles->title == "Engineer")
<div class="card-header">
    @if (!empty($asset->commissionCommissionDatas[0]['id']))
    <a href="/admin/commission-datas/{{ $asset->commissionCommissionDatas[0]['id'] }}/edit?comp_id={{ $asset->id }}">
        <button type="button" class="btn btn-primary btn-lg btn-block">Commission Service Report</button>
    </a>
    {{ $asset->commissionCommissionDatas[0]['id'] }}

    @endif
</div>
@endif
@endforeach
<div class="form-group">
    <a href="/admin/assets/createcommissionpdf/{{ $asset->id }}">
        <button type="button" class="btn btn-info btn-lg btn-block">Save as PDF</button>
    </a>
    </button>
</div>
<div class="card">
    <div class="card-header">
        {{ trans('global.relatedData') }}
    </div>
    <ul class="nav nav-tabs" role="tablist" id="relationship-tabs">
        <li class="nav-item">
            <a class="nav-link" href="#asset_service_complaints" role="tab" data-toggle="tab">
                {{ trans('cruds.serviceComplaint.title') }}
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#commission_commission_datas" role="tab" data-toggle="tab">
                {{ trans('cruds.commissionData.title') }}
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#asset_amc_contracts" role="tab" data-toggle="tab">
                {{ trans('cruds.amcContract.title') }}
            </a>
        </li>
    </ul>
    <div class="tab-content">

        <div class="tab-pane active" role="tabpanel" id="commission_commission_datas">
            @includeIf('admin.assets.relationships.commissionCommissionDatas', ['commissionDatas' => $asset->commissionCommissionDatas])
        </div>
        <div class="tab-pane" role="tabpanel" id="asset_service_complaints">
            @includeIf('admin.assets.relationships.assetServiceComplaints', ['serviceComplaints' => $asset->assetServiceComplaints])
        </div>
        <div class="tab-pane" role="tabpanel" id="asset_amc_contracts">
            @includeIf('admin.assets.relationships.assetAmcContracts', ['amcContracts' => $asset->assetAmcContracts])
        </div>
    </div>
</div>

@endsection
