@extends('layouts.app')

@section('content')
<div class="panel panel-default">
    <div class="panel-heading">edit Billing service  {{$service->service_ref}}</div>


    <div class="panel-body">
        @if ($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div><br />
        @endif
        <form style="float: right;"  onsubmit="return confirm('Do you really want to delete this service?');" action="{{ route('billing-services.destroy', $service->id)}}" method="post" style="margin-bottom: 10px;">
          {{ csrf_field() }}
          {!! method_field('delete') !!}
          <button  class="btn btn-danger" type="submit">Delete</button>

        </form>
           <form method="post" class="edit_billing_form" action="{{ route('billing-services.update',$service->id)}}" >
            <input type="hidden" value="{{csrf_token()}}" name="_token" />
            <button type="submit" class="btn btn-primary">Save</button>
                <div class="form-group" style="margin-top: 15px;">
                    <label for="title">Customer:</label>
                    <select data-live-search="true" class="form-control" name="customer_id">
                        <option <?php if( $service->customer_id ==0 ) { ?> selected <?php } ?> value="0">None</option>
                        @foreach($customers as $customer)
                            <option data-tokens="{{$customer->xero_name}}" @if( $customer->id == $service->customer_id ) selected @endif value="{{$customer->id}}">{{$customer->xero_name}}</option>
                        @endforeach
                    </select>
                </div> 
                <div class="form-group">
                    <label for="title">Tax rate type :</label>
                    <select data-live-search="true" class="form-control" name="tax_type">
                         @foreach($xeroTaxes as $key => $rate)
                            <option <?php if( $key == $service->tax_type ) { ?> selected <?php } ?> data-tokens="{{$rate}}" value="{{$key}}">{{$rate}}</option>
                        @endforeach
                    </select>
                </div>
                
                <input type="hidden" class="form-control" name="service_ref" value="{{$service->service_ref}}"/>
                <div class="form-group">
                    <label for="title">setup date (format yyyy-mm-dd) :</label>
                    <input type="text" class="form-control datefield"  name="setup_date" value="{{$service->setup_date}}"/>
                </div>
                <div class="form-group">
                    <label for="title">last billed date  (format yyyy-mm-dd) :</label>
                    <input type="text" class="form-control datefield"  name="last_billed" value="{{$service->last_billed}}"/>
                </div>

                <div class="form-group">
                    <label for="title">next billed date  (format yyyy-mm-dd) :</label>
                    <input type="text" class="form-control datefield"  name="next_billed" value="{{$service->next_billed}}"/>
                </div>

                <div class="form-group">
                    <label for="title">cancelled date  (format yyyy-mm-dd) :</label>
                    <input type="text" class="form-control datefield"  name="canseled_date" value="{{$service->canseled_date}}"/>
                </div>

                <div class="form-group">
                    <label for="title">description :</label><br>
                    <input type="text" class="form-control" name="description" value="{{$service->description}}"/>
                </div>
                <div class="form-group">
                    <label for="title">do not bill :</label>
                    <input type="checkbox" value="1" class="" name="do_not_bill" <?php if( $service->do_not_bill == 1 ) { ?> checked="checked" <?php } ?> />
                </div>
                <div class="form-group">
                    <label for="title">fee :</label>
                    <input type="text" class="form-control" name="fee" value="{{$service->fee}}"/>
                </div>
                <div class="form-group">
                    <label for="title">renew :</label>
                    <select class="form-control" name="renew">
                        <option value="1" @if( $service->renew == 1 ) selected  @endif>Monthly</option>
                        <option value="2" @if( $service->renew == 2 ) selected  @endif>Quarterly</option>
                        <option value="3" @if( $service->renew == 3 ) selected  @endif>Annually</option>
                    </select>
                   
                </div>
                <div class="form-group">
                    <label for="title">username :</label>
                    <input type="text" class="form-control" name="username" value="{{$service->username}}"/>
                </div>
                <div class="form-group">
                    <label for="title">password :</label>
                    <input type="text" class="form-control" name="password" value="{{$service->password}}"/>
                </div>
                <div class="form-group">
                    <label for="title">agreement :</label>
                    <textarea style="width:100%;height: 75px" name="agreement">{{$service->agreement}}</textarea>
                    
                </div>
                 <div class="form-group">
                    <label for="title">notes :</label><br>
                    <textarea style="width:100%;height: 75px;" name="notes">{{$service->notes}}</textarea>
                </div>
                
                 <button type="submit" class="btn btn-primary">Save</button>
             </form>
    </div>
</div>
@endsection