@extends('layouts.app')

@section('content')
<div class="card">
    <div class="card-body">
    <h4 class="card-title">Update PLC</h4>
    <h6 class="card-subtitle"></h6>
      <div class="x_content">
        <form id="demo-form2" action="{{ url('/admin/plc/'.$plc->id) }}" method="post" data-parsley-validate class="form-horizontal form-label-left">
          {{ csrf_field() }}
          <input name="_method" type="hidden" value="PUT">
          <div class="form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="project_id">Project*</label>
              <div class="col-md-6 col-sm-6 col-xs-12">
              {{$plot->projectName}}
            </div>
          </div>
          <div class="form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="sector_id">Sector*</label>
              <div class="col-md-6 col-sm-6 col-xs-12">
              {{$plot->sectorName}}
            </div>
          </div>
          <div class="form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="block_id">Block*</label>
              <div class="col-md-6 col-sm-6 col-xs-12">
              {{$plot->blockName}}
            </div>
          </div>
          <div class="form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="block_id">Plot*</label>
              <div class="col-md-6 col-sm-6 col-xs-12">
              {{$plot->name}}
            </div>
          </div>

          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Name<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="name" name="name" required="required" class="form-control col-md-7 col-xs-12" value="{{ $plc->name }}">
              @if ($errors->has('name'))
                  <span class="help-block">
                      <strong>{{ $errors->first('name') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="amount">Amount<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="amount" name="amount" required="required" class="form-control col-md-7 col-xs-12" value="{{ $plc->amount }}">
              @if ($errors->has('amount'))
                  <span class="help-block">
                      <strong>{{ $errors->first('amount') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="type">Type<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <select id="type" name="type" required="required" class="form-control col-md-7 col-xs-12">
                <option value="0" @if($plc->type==0) selected @endif>Percentage</option>
                <option value="1" @if($plc->type==1) selected @endif>Amount</option>
              </select>
              @if ($errors->has('type'))
                  <span class="help-block">
                      <strong>{{ $errors->first('type') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="ln_solid"></div>
          <div class="form-group">
            <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
              <button type="submit" class="btn btn-success">Submit</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
<div class="card">
  <div class="card-body">
    <h4 class="card-title">Projects</h4>
      <div class="x_content">
        <table id="datatable-fixed-header" class="table table-striped table-bordered">
          <thead>
            <tr>
              <th>Title</th>
              <th>Amount</th>
              <th>Project</th>
              <th>Sector</th>
              <th>Block</th>
              <th>Plot</th>
              <th>Created at</th>
              <th>Action</th>
            </tr>
          </thead>


          <tbody>
          @foreach ($plcs as $plc)
            <tr>
              <td>{{ $plc->name }}</td>
              <td>{{ $plc->amount }}@if($plc->type==0) % @else /- @endif</td>
              <td>{{ $plc->projectName }}</td>
              <td>{{ $plc->sectorName }}</td>
              <td>{{ $plc->blockName }}</td>
              <td>{{ $plc->plotName }}</td>
              <td>{{ $plc->created_at }}</td>
              <td>
                @if($plc->id!=1)
                  <a type="button" class="btn btn-success" href="{{ url('/admin/plc'.'/'.$plc->id) }}">Edit</a>
                  <a type="button" class="btn btn-danger" href="{{ url('/admin/deleteplc'.'/'.$plc->id) }}">Delete</a>
                @endif
              </td>
            </tr>
          @endforeach
          </tbody>
        </table>
      </div>
    </div>
  </div>
@endsection
@section('javascript')
<script>
  jQuery(document).ready(function() {
   jQuery('#datatable-fixed-header').DataTable({
      fixedHeader: true
    });
  });
</script>
@endsection