@extends('layouts.admin')
@section('content')

<div class="card">
    <div class="card-header">
        {{ trans('global.edit') }} {{ trans('cruds.asset.title_singular') }}
    </div>

    <div class="card-body">
        <form method="POST" action="{{ route("admin.assets.update", [$asset->id]) }}" enctype="multipart/form-data">
            @method('PUT')
            @csrf
            <div class="form-group">
                <label class="required" for="client_id">{{ trans('cruds.asset.fields.client') }}</label>
                <select class="form-control select2 {{ $errors->has('client') ? 'is-invalid' : '' }}" name="client_id" id="client_id" required>
                    @foreach($clients as $id => $entry)
                        <option value="{{ $id }}" {{ (old('client_id') ? old('client_id') : $asset->client->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('client'))
                    <div class="invalid-feedback">
                        {{ $errors->first('client') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.client_helper') }}</span>
            </div>

            <div class="form-group">
                <label class="required" for="commissioning">{{ trans('cruds.asset.fields.commissioning') }}</label>
                <input class="form-control {{ $errors->has('commissioning') ? 'is-invalid' : '' }}" type="text" name="commissioning" id="commissioning" value="{{ old('commissioning', $asset->commissioning) }}" required>
                @if($errors->has('commissioning'))
                    <div class="invalid-feedback">
                        {{ $errors->first('commissioning') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.commissioning_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_compressor_id">{{ trans('cruds.asset.fields.air_compressor') }}</label>
                <select class="form-control select2 {{ $errors->has('air_compressor') ? 'is-invalid' : '' }}" name="air_compressor_id" id="air_compressor_id">
                    @foreach($air_compressors as $id => $entry)
                        <option value="{{ $id }}" {{ (old('air_compressor_id') ? old('air_compressor_id') : $asset->air_compressor->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('air_compressor'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_compressor') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_compressor_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_compressor_serial_no">{{ trans('cruds.asset.fields.air_compressor_serial_no') }}</label>
                <input class="form-control {{ $errors->has('air_compressor_serial_no') ? 'is-invalid' : '' }}" type="text" name="air_compressor_serial_no" id="air_compressor_serial_no" value="{{ old('air_compressor_serial_no', $asset->air_compressor_serial_no) }}">
                @if($errors->has('air_compressor_serial_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_compressor_serial_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_compressor_serial_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_compressor_part_no">{{ trans('cruds.asset.fields.air_compressor_part_no') }}</label>
                <input class="form-control {{ $errors->has('air_compressor_part_no') ? 'is-invalid' : '' }}" type="text" name="air_compressor_part_no" id="air_compressor_part_no" value="{{ old('air_compressor_part_no', $asset->air_compressor_part_no) }}">
                @if($errors->has('air_compressor_part_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_compressor_part_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_compressor_part_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="airdryer_id">{{ trans('cruds.asset.fields.airdryer') }}</label>
                <select class="form-control select2 {{ $errors->has('airdryer') ? 'is-invalid' : '' }}" name="airdryer_id" id="airdryer_id">
                    @foreach($airdryers as $id => $entry)
                        <option value="{{ $id }}" {{ (old('airdryer_id') ? old('airdryer_id') : $asset->airdryer->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('airdryer'))
                    <div class="invalid-feedback">
                        {{ $errors->first('airdryer') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.airdryer_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="airdryer_serial_no">{{ trans('cruds.asset.fields.airdryer_serial_no') }}</label>
                <input class="form-control {{ $errors->has('airdryer_serial_no') ? 'is-invalid' : '' }}" type="text" name="airdryer_serial_no" id="airdryer_serial_no" value="{{ old('airdryer_serial_no', $asset->airdryer_serial_no) }}">
                @if($errors->has('airdryer_serial_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('airdryer_serial_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.airdryer_serial_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_dryer_part_no">{{ trans('cruds.asset.fields.air_dryer_part_no') }}</label>
                <input class="form-control {{ $errors->has('air_dryer_part_no') ? 'is-invalid' : '' }}" type="text" name="air_dryer_part_no" id="air_dryer_part_no" value="{{ old('air_dryer_part_no', $asset->air_dryer_part_no) }}">
                @if($errors->has('air_dryer_part_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_dryer_part_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_dryer_part_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="filter_id">{{ trans('cruds.asset.fields.filter') }}</label>
                <select class="form-control select2 {{ $errors->has('filter') ? 'is-invalid' : '' }}" name="filter_id" id="filter_id">
                    @foreach($filters as $id => $entry)
                        <option value="{{ $id }}" {{ (old('filter_id') ? old('filter_id') : $asset->filter->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('filter'))
                    <div class="invalid-feedback">
                        {{ $errors->first('filter') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.filter_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="filter_serial_no">{{ trans('cruds.asset.fields.filter_serial_no') }}</label>
                <input class="form-control {{ $errors->has('filter_serial_no') ? 'is-invalid' : '' }}" type="text" name="filter_serial_no" id="filter_serial_no" value="{{ old('filter_serial_no', $asset->filter_serial_no) }}">
                @if($errors->has('filter_serial_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('filter_serial_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.filter_serial_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="filter_part_no">{{ trans('cruds.asset.fields.filter_part_no') }}</label>
                <input class="form-control {{ $errors->has('filter_part_no') ? 'is-invalid' : '' }}" type="text" name="filter_part_no" id="filter_part_no" value="{{ old('filter_part_no', $asset->filter_part_no) }}">
                @if($errors->has('filter_part_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('filter_part_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.filter_part_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="eco_drain_id">{{ trans('cruds.asset.fields.eco_drain') }}</label>
                <select class="form-control select2 {{ $errors->has('eco_drain') ? 'is-invalid' : '' }}" name="eco_drain_id" id="eco_drain_id">
                    @foreach($eco_drains as $id => $entry)
                        <option value="{{ $id }}" {{ (old('eco_drain_id') ? old('eco_drain_id') : $asset->eco_drain->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('eco_drain'))
                    <div class="invalid-feedback">
                        {{ $errors->first('eco_drain') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.eco_drain_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="eco_drain_serial_no">{{ trans('cruds.asset.fields.eco_drain_serial_no') }}</label>
                <input class="form-control {{ $errors->has('eco_drain_serial_no') ? 'is-invalid' : '' }}" type="text" name="eco_drain_serial_no" id="eco_drain_serial_no" value="{{ old('eco_drain_serial_no', $asset->eco_drain_serial_no) }}">
                @if($errors->has('eco_drain_serial_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('eco_drain_serial_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.eco_drain_serial_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="eco_drain_part_no">{{ trans('cruds.asset.fields.eco_drain_part_no') }}</label>
                <input class="form-control {{ $errors->has('eco_drain_part_no') ? 'is-invalid' : '' }}" type="text" name="eco_drain_part_no" id="eco_drain_part_no" value="{{ old('eco_drain_part_no', $asset->eco_drain_part_no) }}">
                @if($errors->has('eco_drain_part_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('eco_drain_part_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.eco_drain_part_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_receiver_id">{{ trans('cruds.asset.fields.air_receiver') }}</label>
                <select class="form-control select2 {{ $errors->has('air_receiver') ? 'is-invalid' : '' }}" name="air_receiver_id" id="air_receiver_id">
                    @foreach($air_receivers as $id => $entry)
                        <option value="{{ $id }}" {{ (old('air_receiver_id') ? old('air_receiver_id') : $asset->air_receiver->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('air_receiver'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_receiver') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_receiver_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_receiver_serial_no">{{ trans('cruds.asset.fields.air_receiver_serial_no') }}</label>
                <input class="form-control {{ $errors->has('air_receiver_serial_no') ? 'is-invalid' : '' }}" type="text" name="air_receiver_serial_no" id="air_receiver_serial_no" value="{{ old('air_receiver_serial_no', $asset->air_receiver_serial_no) }}">
                @if($errors->has('air_receiver_serial_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_receiver_serial_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_receiver_serial_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="air_reciever_part_no">{{ trans('cruds.asset.fields.air_reciever_part_no') }}</label>
                <input class="form-control {{ $errors->has('air_reciever_part_no') ? 'is-invalid' : '' }}" type="text" name="air_reciever_part_no" id="air_reciever_part_no" value="{{ old('air_reciever_part_no', $asset->air_reciever_part_no) }}">
                @if($errors->has('air_reciever_part_no'))
                    <div class="invalid-feedback">
                        {{ $errors->first('air_reciever_part_no') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.air_reciever_part_no_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="commisioned_date">{{ trans('cruds.asset.fields.commisioned_date') }}</label>
                <input class="form-control date {{ $errors->has('commisioned_date') ? 'is-invalid' : '' }}" type="text" name="commisioned_date" id="commisioned_date" value="{{ old('commisioned_date',date('d-m-Y'), $asset->commisioned_date) }}">
                @if($errors->has('commisioned_date'))
                    <div class="invalid-feedback">
                        {{ $errors->first('commisioned_date') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.commisioned_date_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="warranty_start_date">{{ trans('cruds.asset.fields.warranty_start_date') }}</label>
                <input class="form-control date {{ $errors->has('warranty_start_date') ? 'is-invalid' : '' }}" type="text" name="warranty_start_date" id="warranty_start_date" value="{{ old('warranty_start_date',date('d-m-Y', strtotime('+1 day')), $asset->warranty_start_date) }}">
                @if($errors->has('warranty_start_date'))
                    <div class="invalid-feedback">
                        {{ $errors->first('warranty_start_date') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.warranty_start_date_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="warranty_end_date">{{ trans('cruds.asset.fields.warranty_end_date') }}</label>
                <input class="form-control date {{ $errors->has('warranty_end_date') ? 'is-invalid' : '' }}" type="text" name="warranty_end_date" id="warranty_end_date" value="{{ old('warranty_end_date',date('d-m-Y', strtotime('+1 year')), $asset->warranty_end_date) }}">
                @if($errors->has('warranty_end_date'))
                    <div class="invalid-feedback">
                        {{ $errors->first('warranty_end_date') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.warranty_end_date_helper') }}</span>
            </div>
            <div class="form-group">
                <label>{{ trans('cruds.asset.fields.commisioned_by') }}</label>
                <select class="form-control {{ $errors->has('commisioned_by') ? 'is-invalid' : '' }}" name="commisioned_by" id="commisioned_by">
                    <option value disabled {{ old('commisioned_by', null) === null ? 'selected' : '' }}>{{ trans('global.pleaseSelect') }}</option>
                    @foreach(App\Models\Asset::COMMISIONED_BY_SELECT as $key => $label)
                        <option value="{{ $key }}" {{ old('commisioned_by','fusion', $asset->commisioned_by) === (string) $key ? 'selected' : '' }}>{{ $label }}</option>
                    @endforeach
                </select>
                @if($errors->has('commisioned_by'))
                    <div class="invalid-feedback">
                        {{ $errors->first('commisioned_by') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.commisioned_by_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="commissioned_engineer_id">{{ trans('cruds.asset.fields.commissioned_engineer') }}</label>
                <select class="form-control select2 {{ $errors->has('commissioned_engineer') ? 'is-invalid' : '' }}" name="commissioned_engineer_id" id="commissioned_engineer_id">
                    @foreach($commissioned_engineers as $id => $entry)
                        <option value="{{ $id }}" {{ (old('commissioned_engineer_id') ? old('commissioned_engineer_id') : $asset->commissioned_engineer->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('commissioned_engineer'))
                    <div class="invalid-feedback">
                        {{ $errors->first('commissioned_engineer') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.commissioned_engineer_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="status_id">{{ trans('cruds.asset.fields.status') }}</label>
                <select class="form-control select2 {{ $errors->has('status') ? 'is-invalid' : '' }}" name="status_id" id="status_id">
                    @foreach($statuses as $id => $entry)
                        <option value="{{ $id }}" {{ (old('status_id') ? old('status_id') : $asset->status->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('status'))
                    <div class="invalid-feedback">
                        {{ $errors->first('status') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.status_helper') }}</span>
            </div>
            <!--
            <div class="form-group">
                <label for="start_of_work">{{ trans('cruds.asset.fields.start_of_work') }}</label>
                <input class="form-control {{ $errors->has('start_of_work') ? 'is-invalid' : '' }}" type="text" name="start_of_work" id="start_of_work" value="{{ old('start_of_work', $asset->start_of_work) }}">
                @if($errors->has('start_of_work'))
                    <div class="invalid-feedback">
                        {{ $errors->first('start_of_work') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.start_of_work_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="end_of_work">{{ trans('cruds.asset.fields.end_of_work') }}</label>
                <input class="form-control {{ $errors->has('end_of_work') ? 'is-invalid' : '' }}" type="text" name="end_of_work" id="end_of_work" value="{{ old('end_of_work', $asset->end_of_work) }}">
                @if($errors->has('end_of_work'))
                    <div class="invalid-feedback">
                        {{ $errors->first('end_of_work') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.end_of_work_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="travelling_time">{{ trans('cruds.asset.fields.travelling_time') }}</label>
                <input class="form-control {{ $errors->has('travelling_time') ? 'is-invalid' : '' }}" type="text" name="travelling_time" id="travelling_time" value="{{ old('travelling_time', $asset->travelling_time) }}">
                @if($errors->has('travelling_time'))
                    <div class="invalid-feedback">
                        {{ $errors->first('travelling_time') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.travelling_time_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="travelling_k_m">{{ trans('cruds.asset.fields.travelling_k_m') }}</label>
                <input class="form-control {{ $errors->has('travelling_k_m') ? 'is-invalid' : '' }}" type="text" name="travelling_k_m" id="travelling_k_m" value="{{ old('travelling_k_m', $asset->travelling_k_m) }}">
                @if($errors->has('travelling_k_m'))
                    <div class="invalid-feedback">
                        {{ $errors->first('travelling_k_m') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.travelling_k_m_helper') }}</span>
            </div>

            <div class="form-group">
                <label for="remarks">{{ trans('cruds.asset.fields.remarks') }}</label>
                <textarea class="form-control {{ $errors->has('remarks') ? 'is-invalid' : '' }}" name="remarks" id="remarks">{{ old('remarks', $asset->remarks) }}</textarea>
                @if($errors->has('remarks'))
                    <div class="invalid-feedback">
                        {{ $errors->first('remarks') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.remarks_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="pending_work">{{ trans('cruds.asset.fields.pending_work') }}</label>
                <textarea class="form-control {{ $errors->has('pending_work') ? 'is-invalid' : '' }}" name="pending_work" id="pending_work">{{ old('pending_work', $asset->pending_work) }}</textarea>
                @if($errors->has('pending_work'))
                    <div class="invalid-feedback">
                        {{ $errors->first('pending_work') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.pending_work_helper') }}</span>
            </div>
        -->
            <div class="form-group">
                <label for="asset_photos">{{ trans('cruds.asset.fields.asset_photos') }}</label>
                <div class="needsclick dropzone {{ $errors->has('asset_photos') ? 'is-invalid' : '' }}" id="asset_photos-dropzone">
                </div>
                @if($errors->has('asset_photos'))
                    <div class="invalid-feedback">
                        {{ $errors->first('asset_photos') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.asset.fields.asset_photos_helper') }}</span>
            </div>

<!-- Signature Block -->
<!-- Moved to Commission Datas Page -->
<!-- Signature Block -->
<br><br>

                <div class="form-group">
                    <button class="btn btn-danger btn-lg btn-block" id="save" type="submit">
                        {{ trans('global.save') }}
                    </button>
                </div>


<!-- Edit Option button only for Engineer Roles and not for other roles -->
@foreach(Auth::user()->roles as $key => $roles)
@if($roles->title == "Engineer")
    @if (!empty($asset->commissionCommissionDatas[0]['id']))
    <div class="form-group">
    <a href="/admin/commission-datas/{{ $asset->commissionCommissionDatas[0]['id'] }}/edit?comp_id={{ $asset->id }}">
        <button type="button" class="btn btn-primary btn-lg btn-block">Commission Service Report</button>
    </a>
    @endif
    </div>
@endif
@endforeach

                <div class="form-group">
                    <a href="/admin/assets/createcommissionpdf/{{ $asset->id }}">
                        <button type="button" class="btn btn-info btn-lg btn-block">Save as PDF</button>
                    </a>
                    </button>
                </div>
                <br>

        </form>


    </div>
</div>



@endsection

@section('scripts')
<script>
    var uploadedAssetPhotosMap = {}
Dropzone.options.assetPhotosDropzone = {
    url: '{{ route('admin.assets.storeMedia') }}',
    maxFilesize: 250, // MB
    acceptedFiles: '.jpeg,.jpg,.png,.gif',
    addRemoveLinks: true,
    headers: {
      'X-CSRF-TOKEN': "{{ csrf_token() }}"
    },
    params: {
      size: 250,
      width: 4096,
      height: 4096
    },
    success: function (file, response) {
      $('form').append('<input type="hidden" name="asset_photos[]" value="' + response.name + '">')
      uploadedAssetPhotosMap[file.name] = response.name
    },
    removedfile: function (file) {
      console.log(file)
      file.previewElement.remove()
      var name = ''
      if (typeof file.file_name !== 'undefined') {
        name = file.file_name
      } else {
        name = uploadedAssetPhotosMap[file.name]
      }
      $('form').find('input[name="asset_photos[]"][value="' + name + '"]').remove()
    },
    init: function () {
@if(isset($asset) && $asset->asset_photos)
      var files = {!! json_encode($asset->asset_photos) !!}
          for (var i in files) {
          var file = files[i]
          this.options.addedfile.call(this, file)
          this.options.thumbnail.call(this, file, file.preview ?? file.preview_url)
          file.previewElement.classList.add('dz-complete')
          $('form').append('<input type="hidden" name="asset_photos[]" value="' + file.file_name + '">')
        }
@endif
    },
     error: function (file, response) {
         if ($.type(response) === 'string') {
             var message = response //dropzone sends it's own error messages in string
         } else {
             var message = response.errors.file
         }
         file.previewElement.classList.add('dz-error')
         _ref = file.previewElement.querySelectorAll('[data-dz-errormessage]')
         _results = []
         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
             node = _ref[_i]
             _results.push(node.textContent = message)
         }

         return _results
     }
}

// Signature Block
var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
  backgroundColor: 'rgba(200, 200, 255, 0)',
  penColor: 'rgb(0, 0, 0)'
});
//Need this save button to get the signature value
//else the signature will not be POSTED to controller
var saveButton = document.getElementById('save');
var cancelButton = document.getElementById('clear');

saveButton.addEventListener('click', function (event) {
  var data = signaturePad.toDataURL('image/svg+xml');
  //signaturePad.toDataURL('image/png');
  // Send data to server instead...
  //window.open(data);
  //alert(data);

  //Sending client signature to Commissoin Datas - Commission_Customer_Signature id:608
  $('<input>', {
    type: 'hidden',
    id: 'client_signature',
    name: 'client_signature',
    value: data
}).appendTo('form');

});

cancelButton.addEventListener('click', function (event) {
  signaturePad.clear();
});

function clearsign(){
    signaturePad.clear();
}

function resizeCanvas() {
    const ratio =  Math.max(window.devicePixelRatio || 1, 1);
    canvas.width = canvas.offsetWidth * ratio;
    canvas.height = canvas.offsetHeight * ratio;
    canvas.getContext("2d").scale(ratio, ratio);
    signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
// Signature Block
</script>

@endsection
