{!! Form::model($model, [
	'route' => $model->exists ? ['kegiatan.update', $model->id] : 'kegiatan.store',
	'method' => $model->exists ? 'PUT' : 'POST',
	'enctype' => 'multipart/form-data',
  'id' => 'formSubmit'
]) !!}
<input type="hidden" name="_token" id="_token" value="{{csrf_token()}}">
<div class="form-group">
	<label for="" class="label-control">Title</label>
	{!! Form::text('title', null, ['class' => 'form-control', 'id' => 'title', 'placeholder' => 'Inputkan title kegiatan...']) !!}
</div>

<div class="form-group">
	<label for="" class="label-control">Caption</label>
	{!! Form::text('caption', null, ['class' => 'form-control', 'id' => 'caption', 'placeholder' => 'Isi konten disini...']) !!}
</div>

<div class="form-group">
	<label for="" class="label-control">Tanggal Kegiatan</label>

	<input type="text" class="form-control" id="tanggal_kegiatan" name="tanggal_kegiatan" <?php if($model->exists): ?> value="{{date('Y-m-d', strtotime($model->tanggal_kegiatan))}}" <?php endif; ?>>
</div>

<div class="form-group">
	<label for="" class="label-control">Lokasi Kegiatan</label>
	{!! Form::text('lokasi_kegiatan', null, ['class' => 'form-control', 'id' => 'lokasi_kegiatan', 'placeholder' => 'Isi lokasi kegiatan...']) !!}
</div>

{!! Form::close() !!}

@if($model->exists)
<a href="#" onclick="document.getElementById('picture-{{$model->id}}').click()" title="Klik untuk ganti gambar"><img src="<?php if($model->picture != NULL){ echo url('assets/files/kegiatan').'/'.$model->picture; }else{ echo url('assets/frontend/img/no-picture.png'); } ?>" width="100px"></a>
<p style="font-size: 10px; color:red;">Size gambar max: 500kb!</p>
<input type="hidden" name="id" value="{{ $model->id }}">
<input type="hidden" name="_token" id="_token" value="{{csrf_token()}}">
<input style="display: none;" type="file" name="picture" id="picture-{{$model->id}}" data-id="{{$model->id}}" class="uploadfoto" accept="image/*">
<br>
@if($model->picture != NULL)
<button class="btn btn-xs btn-warning" id="hapusGambar" data-id="{{$model->id}}"><i class="fa fa-close"> Hapus Gambar</i></button>
@endif
@endif

<script type="text/javascript">
	//Date picker
    $('#tanggal_kegiatan').datepicker({
      autoclose: true,
      format: 'yyyy-mm-dd'
    })
</script>
