@extends('layouts.layout')

@section('title', 'Job 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>
        <a href="/job/del/{{ base64_encode($job[0]->id) }}" class="btn jq-confrm-del btn-icon btn-outline-secondary p-2 float-right "><i class="fa fa-trash fa-2x"></i></a>
        <a href="/job/edit/{{ base64_encode($job[0]->id) }}" class="btn jq-confrm-edit btn-icon btn-outline-secondary p-2 float-right "><i class="fa fa-pencil-alt fa-2x"></i></a>
        <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>

        <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>

    <h3>Bids</h3>
    <hr class="mt-0">
    @if($bids == null)
    <p class="text-center">No Bids Available</p>
    @endif
    @foreach ($bids as $index=>$bid)
    <div class="card border20 shadow p-3" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse-{{ $index }}" aria-expanded="false" aria-controls="collapse-{{ $index }}">
      <div class="d-flex justify-content-between align-items-center">
        <div class="d-flex align-items-center">
          <img class="bid-profile-img" src="https://admin.mali-mart.com/app-assets/images/members/{{ $bid->picture }}" alt="profile image">
          <div class="d-flex" style="flex-direction:column">
            &nbsp; {{ $bid->name }}
            <small class="text-gray ">&nbsp; Worker</small>
          </div>
        </div>
        <div class="mr-2"><b>{{ $bid->amount }} TK</b> &nbsp;&nbsp; <i class="fa fa-angle-down"></i></div>
      </div>
      <div class="collapse border20 mt-2" id="collapse-{{ $index }}">
        <div class="card border20 card-body">
          {{ $bid->cv }}
          @if($bid->status ==0)
          <div>
            <form id="bid-form" method="POST" action="/hire-worker">
              @csrf
              <input type="hidden" name="bid_id" value="<?= $bid->id ?>">
              <input type="hidden" name="job_id" value="<?= $bid->job_id ?>">
              <input type="hidden" name="worker_id" value="<?= $bid->worker_id ?>">
              <button type="button" class="btn btn-sm jq-confirm-bid btn-success float-right p-2"><i class="fa fa-handshake"></i> Hire This Worker</button>
            </form>
          </div>
          @endif
          @if($bid->status==1)
          <div>
            <button disabled type="button" class="btn btn-sm btn-success float-right p-2"><i class="fa fa-handshake"></i> Already Hired</button>
          </div>
          @endif
        </div>
      </div>
    </div>

    <br>
    @endforeach

  </div>
</div>


@endsection