@extends('layouts.app')

@section('content')

<div class="container-fluid">
    <div class="row my-3">
        <div class="col-lg-6">
            <div class="card h-100">
                <div class="card-header text-right">
                    <button type="button" class="btn btn-default xs-toggle" data-toggle="collapse" data-target="#assetTab">
                        <span class="sr-only">Toggle Navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <ul class="nav nav-pills card-header-pills nav-justified xs-collapse collapse" id="assetTab" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" id="assetinfo-tab" data-toggle="pill" href="#assetinfo" role="tab" aria-controls="assetinfo" aria-selected="true">Hardware</a>
                        </li>
                        @if($workOrder->asset->group !== null)
                        <li class="nav-item">
                            <a class="nav-link" id="group-tab" data-toggle="pill" href="#group" role="tab" aria-controls="group" aria-selected="false">Group</a>
                        </li>
                        @endif
                        <li class="nav-item">
                            <a class="nav-link" id="credentials-tab" data-toggle="pill" href="#credentials" role="tab" aria-controls="credentials" aria-selected="false">Credentials</a>
                        </li>
                    </ul>
                </div>
                <div class="card-body">
                    <div class="tab-content">
                        <div class="tab-pane active" id="assetinfo" role="tabpanel" aria-labelledby="assetinfo-tab">
                            <assetinfo asset="{{$workOrder->asset}}" pcextra-start="{{json_encode(unserialize($workOrder->asset->pcextra))}}"></assetinfo>
                        </div>
                        @if($workOrder->asset->group !== null)
                        <div class="tab-pane" id="group" role="tabpanel" aria-labelledby="group-tab">
                            Name: {{$workOrder->asset->group->pcgroupname}}
                        </div>
                        @endif
                        <div class="tab-pane" id="credentials" role="tabpanel" aria-labelledby="credentials-tab">
                            <credential-list :credential-list="{{$workOrder->asset->credentials->sortByDesc('creddate')->values()}}" :descriptions="{{App\CredDesc::all()}}" :pcid="{{$workOrder->asset->pcid}}"></credential-list>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="card h-100">
                <div class="card-header text-right">
                    <button type="button" class="btn btn-default xs-toggle" data-toggle="collapse" data-target="#workorderTab">
                        <span class="sr-only">Toggle Navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <ul class="nav nav-pills card-header-pills nav-justified xs-collapse collapse" id="workorderTab" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" id="workordersumm-tab" data-toggle="pill" href="#workordersumm" role="tab" aria-controls="workordersumm" aria-selected="true">Summary</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" id="attachments-tab" data-toggle="pill" href="#attachments" role="tab" aria-controls="attachments" aria-selected="false">Attachments</a>
                        </li>
                    </ul>
                </div>
                <div class='card-body'>
                    <div class='tab-content'>
                        <div class="tab-pane active" id="workordersumm" role="tabpanel" aria-labelledby="workordersumm-tab">
                            <woinfo work-order="{{$workOrder}}" stores="{{App\Store::all()}}"></woinfo>
                        </div>
                        <div class="tab-pane" id="attachments" role="tabpanel" aria-labelledby="attachments-tab">
                            TODO 2
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row my-3 no-gutters">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">Customer Notes</h5>
                    <notes :initialnotes='{{ $workOrder->notes->where('notetype', '0')->values() }}' authusername="{{Auth::user()->username}}" :note-type="0" :woid="{{$workOrder->woid}}"></notes>
                </div>
            </div>
        </div>
    </div>
    <div class="row my-3 no-gutters">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">Private/Billing Notes</h5>
                    <notes :initialnotes='{{ $workOrder->notes->where('notetype', '1')->values() }}' authusername="{{Auth::user()->username}}" :note-type="1" :woid="{{$workOrder->woid}}"></notes>
                </div>
            </div>
        </div>
    </div>
</div>

@endsection