@extends('layouts.app')

@section('content')
<div class="card">
    <div class="card-body">
    <h4 class="card-title">Update Projects</h4>
    <h6 class="card-subtitle"></h6>
      <div class="x_content">
        <form id="demo-form2" action="{{ url('/admin/projects/'.$project->id) }}" method="post" data-parsley-validate class="form-horizontal form-label-left" enctype="multipart/form-data">
          {{ 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="first-name">Title <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="first-name" name="name" required="required" class="form-control col-md-7 col-xs-12" value="{{ $project->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="description">Description
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <textarea id="description" name="description" class="form-control col-md-7 col-xs-12">{{ $project->description }}</textarea>
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="description">Brochure
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="file" id="brochure" name="brochure" class="form-control col-md-7 col-xs-12">
            </div>
            @if(!empty($project->brochure))
            <span class="help-block">
                <strong><a href="{{ url('/').'/uploads/projects/'.$project->brochure }}" target="_blank">{{$project->brochure}}</a></strong>
            </span>
            @endif
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="description">Map
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="file" id="project_map" name="project_map" class="form-control col-md-7 col-xs-12">
            </div>
            @if(!empty($project->project_map))
            <span class="help-block">
                <strong><a href="{{ url('/').'/uploads/projects/'.$project->project_map }}" target="_blank">{{$project->project_map}}</a></strong>
            </span>
            @endif
          </div>

          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="type">Project Type<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              {!! Form::select('type', ['Residential Plots'=>'Residential Plots','Flats'=>'Flats', 'Commercial'=>'Commercial', 'Farm House'=>'Farm House'], [$project->type], ['class' => 'form-control form-control-normal col-md-7 col-xs-12', 'id'=>'type']) !!}
              @if ($errors->has('type'))
                  <span class="help-block">
                      <strong>{{ $errors->first('type') }}</strong>
                  </span>
              @endif
            </div>
          </div>

          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="rate">Price (BSP)<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="rate" name="rate" required="required" class="form-control col-md-7 col-xs-12" value="{{ $project->rate }}">
              @if ($errors->has('rate'))
                  <span class="help-block">
                      <strong>{{ $errors->first('rate') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="unit">Per? sq.ft./sq.yd.<span class="required">*</span>
            </label>
            <div class="col-md-3 col-sm-3 col-xs-12">
              {!! Form::select('unit', $unit, [$project->unit], ['class' => 'form-control form-control-normal col-md-7 col-xs-12', 'id'=>'unit']) !!}

              @if ($errors->has('unit'))
                  <span class="help-block">
                      <strong>{{ $errors->first('unit') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="weightage">Weightage in %<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="weightage" name="weightage" required="required" class="form-control col-md-7 col-xs-12" value="{{$project->weightage}}">
              @if ($errors->has('weightage'))
                  <span class="help-block">
                      <strong>{{ $errors->first('weightage') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="developer_charge">Development Charge<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="developer_charge" name="developer_charge" required="required" class="form-control col-md-7 col-xs-12" value="{{$project->developer_charge}}">
              @if ($errors->has('developer_charge'))
                  <span class="help-block">
                      <strong>{{ $errors->first('developer_charge') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="developer_charge_type">Dev Charge Type<span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              {!! Form::select('developer_charge_type', $developer_charge_type, $project->developer_charge_type, ['class' => 'form-control form-control-normal col-md-7 col-xs-12', 'id'=>'developer_charge_type']) !!}
              @if ($errors->has('developer_charge_type'))
                  <span class="help-block">
                      <strong>{{ $errors->first('developer_charge_type') }}</strong>
                  </span>
              @endif
            </div>
          </div>

          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="location">Location
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="location" name="location" class="form-control col-md-7 col-xs-12" value="{{$project->location}}">
              @if ($errors->has('location'))
                  <span class="help-block">
                      <strong>{{ $errors->first('location') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="developer">Developer
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="developer" name="developer" class="form-control col-md-7 col-xs-12" value="{{$project->developer}}">
              @if ($errors->has('developer'))
                  <span class="help-block">
                      <strong>{{ $errors->first('developer') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="coupons_enabled">Coupon<span class="required">*</span>
            </label>
            <div class="col-md-3 col-sm-3 col-xs-12">
              {!! Form::select('coupons_enabled', [0=>'disabled', 1=>'enabled'], [$project->coupons_enabled], ['class' => 'form-control form-control-normal col-md-7 col-xs-12', 'id'=>'coupons_enabled']) !!}

              @if ($errors->has('coupons_enabled'))
                  <span class="help-block">
                      <strong>{{ $errors->first('coupons_enabled') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-6 col-sm-6 col-xs-12">
            <input type="checkbox" name="status" class="" id="status_checkbox" @if($project->status) checked="checked" @endif />
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="status_checkbox">Status <span class="required">*</span>
            </label>
             @if ($errors->has('status'))
                  <span class="help-block">
                      <strong>{{ $errors->first('status') }}</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>Unit</th>
              <th>Status</th>
              <th>Created at</th>
              <th>Action</th>
            </tr>
          </thead>


          <tbody>
          @foreach ($projects as $project)
            <tr>
              <td>{{ $project->name }}</td>
              <td>{{ $project->unit }}</td>
              <td>{{ $project->status }}</td>
              <td>{{ $project->created_at }}</td>
              <td>
                <a type="button" class="btn btn-success" href="{{ url('/admin/projects'.'/'.$project->id) }}">Edit</a>
                <a type="button" class="btn btn-danger" href="{{ url('/admin/deleteprojects'.'/'.$project->id) }}">Delete</a>
              </td>
            </tr>
          @endforeach
          </tbody>
        </table>
      </div>
    </div>
  </div>
@endsection
@section('javascript')
<script>
  jQuery(document).ready(function() {
   jQuery('#datatable-fixed-header').DataTable({
      fixedHeader: true
    });
  });
</script>
<script src="{{url('/')}}/tinymce/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
  selector: '#description'
});
</script>

@endsection