@extends('layouts.layout')

@section('title', 'Contact Details')

@section('main')

<div class="row justify-content-center">
  <div class="col-12 col-md-12">
    <div class="card bg-white shadow border20 p-3 mb-3">
      <div>

        <h2>{{ $job[0]->title }}</h2>
        <small>Posted: {{ Carbon\Carbon::parse($job[0]->created_at)->format('Y-m-d') }}</small><br>
        <div>Category - <b>{{ $job[0]->cat_name }}</b></div>
        <br>
        <div>Required Skills :
          <?php $skills = explode(",", $job[0]->skills);
          foreach ($skills as $skill) { ?>
            <a href="#" class="badge badge-info badge-pill mr-1">{{ $skill }}</a>
          <?php } ?>
        </div>
        <br>
        <div>Budget - <b>{{ $job[0]->budget }} TK</b></div>
        <div>Your Bid - <b>{{ $hired->amount }} TK</b></div>

        <div class="collapse" id="collapse-detail">
          <br>
          <b>Brief:</b>
          <p>{{ $job[0]->job_desc }}</p>

          <br>
          <?php if ($job[0]->files != null && $job[0]->files != "") :
            $files = explode(",", $job[0]->files); ?>
            <b>Additional Attached Files:</b>
            <br>
            <ul>
              <?php foreach ($files as $file) : ?>
                <li><a href="/files/{{ $file }}" target="_blank"><u>{{ $file }}</u></a><br></li>
            <?php endforeach;
            endif ?>
            </ul>
        </div>

        <div class="text-blue mt-5" style="cursor:pointer" data-toggle="collapse" data-target="#collapse-detail" aria-expanded="false" aria-controls="collapse-detail">See More...</div>

        <br>
        <div>
          @if($hired->status == 0)
          <div class="text-right">
            <a href="/give-paid-worker/{{ $hired->id }}" class="btn btn-sm btn-warning jq-confirm-give-paid">
              <div class="d-flex align-items-center">
                <div><i class="ni ni-money-coins"></i></div>&nbsp; Give Paid <br>৳ {{ $hired->amount-$hired->paid }}
              </div>
            </a>
          </div>
          @endif
          @if($hired->status == 1)
          <b>Amount Paid :</b> {{ $hired->paid }}
          <br>
          <br>
          @endif
        </div>
        <h4>Contact Conversation</h4>
        <hr class="mt-0">
        <div id="chats-thread" class="card bg-lighter p-3 border-0 border20">
          <div class="row">
            <div class="col-12 col-md-6">
              <div class="d-flex align-items-center">
                <img class="bid-profile-img" src="https://admin.mali-mart.com/app-assets/images/members/avater_4.png" alt="profile image">
                <div class="d-flex" style="flex-direction:column">
                  &nbsp; You
                  <small class="text-gray ">&nbsp; Client</small>
                </div>
              </div>
              <div class="bg-white border20 p-2" id="chat" contenteditable="true"></div>
              <input id="hired_id" type="hidden" value="<?= $hired->id ?>">
              <button id="send-btn" class="btn btn-info btn-sm float-right shadow-none">Send <i class="ni ni-send"></i></button>
            </div>
          </div>

          <div id="recent_chat"></div>

          @foreach ($chats as $chat)
          @if($chat->workers_id == null)
          <div class="row mt-2">
            <div class="col-12 col-md-6">
              <div class="d-flex align-items-center justify-content-between">
                <div class="d-flex align-items-center">
                  <img class="bid-profile-img" src="https://admin.mali-mart.com/app-assets/images/members/avater_4.png" alt="profile image">
                  <div class="d-flex" style="flex-direction:column">
                    &nbsp; You
                    <small class="text-gray ">&nbsp; Client</small>
                  </div>
                </div>
                <div><small>{{ Carbon\Carbon::parse($job[0]->created_at)->format('h:i d-M') }}</small></div>
              </div>
              <div class="border20 bg-white p-2">{!! $chat->chat !!}</div>
            </div>
          </div>
          @endif
          @if($chat->clients_id == null)
          <div class="row justify-content-end mt-2">
            <div class="col-12 col-md-6">
              <div class="d-flex align-items-center justify-content-between">
                <div><small>{{ Carbon\Carbon::parse($job[0]->created_at)->format('h:i d-M') }}</small></div>
                <div class="d-flex align-items-center">
                  <div class="d-flex text-right" style="flex-direction:column">
                    <?= $hired->w_name ?> &nbsp;
                    <small class="text-gray ">Worker &nbsp;</small>
                  </div>
                  <img class="bid-profile-img" src="https://admin.mali-mart.com/app-assets/images/members/avater_4.png" alt="profile image">
                </div>
              </div>
              <div class="border20 bg-white p-2 text-right">{!! $chat->chat !!}</div>
            </div>
          </div>
          @endif
          @endforeach

        </div>
      </div>
    </div>


  </div>
</div>


@endsection