File: /var/www/ivs.kaunokolegija.lt/laravel/resources/views/admin/activityEntries/create.blade.php
@extends('layouts.admin')
@section('content')
<div class="card">
<div class="card-header">
{{ trans('global.add') }}
</div>
<div class="card-body">
<form method="POST" action="{{ route("admin.activity-entries.store") }}" enctype="multipart/form-data">
@csrf
<div class="form-group">
<label class="required" for="social_partner_id">{{ trans('cruds.activityEntry.fields.social_partner') }}</label>
<select class="form-control select2 {{ $errors->has('social_partner') ? 'is-invalid' : '' }}" name="social_partner_id" id="social_partner_id" required>
@foreach($social_partners as $id => $entry)
<option value="{{ $id }}" {{ old('social_partner_id') == $id ? 'selected' : '' }}>{{ $entry }}</option>
@endforeach
</select>
@if($errors->has('social_partner'))
<span class="text-danger">{{ $errors->first('social_partner') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.social_partner_helper') }}</span>
</div>
<div class="form-group">
<label class="required" for="activity_start">{{ trans('cruds.activityEntry.fields.activity_start') }}</label>
<input class="form-control datetime {{ $errors->has('activity_start') ? 'is-invalid' : '' }}" type="text" name="activity_start" id="activity_start" value="{{ old('activity_start') }}" required>
@if($errors->has('activity_start'))
<span class="text-danger">{{ $errors->first('activity_start') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.activity_start_helper') }}</span>
</div>
<div class="form-group">
<label for="activity_end">{{ trans('cruds.activityEntry.fields.activity_end') }}</label>
<input class="form-control datetime {{ $errors->has('activity_end') ? 'is-invalid' : '' }}" type="text" name="activity_end" id="activity_end" value="{{ old('activity_end') }}">
@if($errors->has('activity_end'))
<span class="text-danger">{{ $errors->first('activity_end') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.activity_end_helper') }}</span>
</div>
<div class="form-group">
<label class="required" for="activitytypes">{{ trans('cruds.activityEntry.fields.activitytype') }}</label>
<div style="padding-bottom: 4px">
<span class="btn btn-info btn-xs select-all" style="border-radius: 0">{{ trans('global.select_all') }}</span>
<span class="btn btn-info btn-xs deselect-all" style="border-radius: 0">{{ trans('global.deselect_all') }}</span>
</div>
<select class="form-control select2 {{ $errors->has('activitytypes') ? 'is-invalid' : '' }}" name="activitytypes[]" id="activitytypes" multiple required>
@foreach($activitytypes as $id => $activitytype)
<option value="{{ $id }}" {{ in_array($id, old('activitytypes', [])) ? 'selected' : '' }}>{{ $activitytype }}</option>
@endforeach
</select>
@if($errors->has('activitytypes'))
<span class="text-danger">{{ $errors->first('activitytypes') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.activitytype_helper') }}</span>
</div>
<div class="form-group">
<label for="activitysubtypes">{{ trans('cruds.activityEntry.fields.activitysubtype') }}</label>
<div style="padding-bottom: 4px">
<span class="btn btn-info btn-xs select-all" style="border-radius: 0">{{ trans('global.select_all') }}</span>
<span class="btn btn-info btn-xs deselect-all" style="border-radius: 0">{{ trans('global.deselect_all') }}</span>
</div>
<select class="form-control select2 {{ $errors->has('activitysubtypes') ? 'is-invalid' : '' }}" name="activitysubtypes[]" id="activitysubtypes" multiple>
@foreach($activitysubtypes as $id => $activitysubtype)
<option value="{{ $id }}" {{ in_array($id, old('activitysubtypes', [])) ? 'selected' : '' }}>{{ $activitysubtype }}</option>
@endforeach
</select>
@if($errors->has('activitysubtypes'))
<span class="text-danger">{{ $errors->first('activitysubtypes') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.activitysubtype_helper') }}</span>
</div>
<div class="form-group">
<label for="description">{{ trans('cruds.activityEntry.fields.description') }}</label>
<textarea class="form-control {{ $errors->has('description') ? 'is-invalid' : '' }}" name="description" id="description">{{ old('description') }}</textarea>
@if($errors->has('description'))
<span class="text-danger">{{ $errors->first('description') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.description_helper') }}</span>
</div>
<div class="form-group">
<label for="departments">{{ trans('cruds.activityEntry.fields.department') }}</label>
<div style="padding-bottom: 4px">
<span class="btn btn-info btn-xs select-all" style="border-radius: 0">{{ trans('global.select_all') }}</span>
<span class="btn btn-info btn-xs deselect-all" style="border-radius: 0">{{ trans('global.deselect_all') }}</span>
</div>
<select class="form-control select2 {{ $errors->has('departments') ? 'is-invalid' : '' }}" name="departments[]" id="departments" multiple>
@foreach($departments as $id => $department)
<option value="{{ $id }}" {{ in_array($id, old('departments', [])) ? 'selected' : '' }}>{{ $department }}</option>
@endforeach
</select>
@if($errors->has('departments'))
<span class="text-danger">{{ $errors->first('departments') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.department_helper') }}</span>
</div>
<div class="form-group">
<label for="departmentsubs">{{ trans('cruds.activityEntry.fields.departmentsub') }}</label>
<div style="padding-bottom: 4px">
<span class="btn btn-info btn-xs select-all" style="border-radius: 0">{{ trans('global.select_all') }}</span>
<span class="btn btn-info btn-xs deselect-all" style="border-radius: 0">{{ trans('global.deselect_all') }}</span>
</div>
<select class="form-control select2 {{ $errors->has('departmentsubs') ? 'is-invalid' : '' }}" name="departmentsubs[]" id="departmentsubs" multiple>
@foreach($departmentsubs as $id => $departmentsub)
<option value="{{ $id }}" {{ in_array($id, old('departmentsubs', [])) ? 'selected' : '' }}>{{ $departmentsub }}</option>
@endforeach
</select>
@if($errors->has('departmentsubs'))
<span class="text-danger">{{ $errors->first('departmentsubs') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.departmentsub_helper') }}</span>
</div>
<div class="form-group">
<label for="raised_funds">{{ trans('cruds.activityEntry.fields.raised_funds') }}</label>
<input class="form-control {{ $errors->has('raised_funds') ? 'is-invalid' : '' }}" type="number" name="raised_funds" id="raised_funds" value="{{ old('raised_funds', '0') }}" step="0.01">
@if($errors->has('raised_funds'))
<span class="text-danger">{{ $errors->first('raised_funds') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.raised_funds_helper') }}</span>
</div>
<div class="form-group">
<label for="attachments">{{ trans('cruds.activityEntry.fields.attachments') }}</label>
<div class="needsclick dropzone {{ $errors->has('attachments') ? 'is-invalid' : '' }}" id="attachments-dropzone">
</div>
@if($errors->has('attachments'))
<span class="text-danger">{{ $errors->first('attachments') }}</span>
@endif
<span class="help-block">{{ trans('cruds.activityEntry.fields.attachments_helper') }}</span>
</div>
<div class="form-group">
<button class="btn btn-success" type="submit">
{{ trans('global.save') }}
</button>
</div>
</form>
</div>
</div>
@endsection
@section('scripts')
<script>
var uploadedAttachmentsMap = {}
Dropzone.options.attachmentsDropzone = {
url: '{{ route('admin.activity-entries.storeMedia') }}',
maxFilesize: 10, // MB
addRemoveLinks: true,
headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}"
},
params: {
size: 10
},
success: function (file, response) {
$('form').append('<input type="hidden" name="attachments[]" value="' + response.name + '">')
uploadedAttachmentsMap[file.name] = response.name
},
removedfile: function (file) {
file.previewElement.remove()
var name = ''
if (typeof file.file_name !== 'undefined') {
name = file.file_name
} else {
name = uploadedAttachmentsMap[file.name]
}
$('form').find('input[name="attachments[]"][value="' + name + '"]').remove()
},
init: function () {
@if(isset($activityEntry) && $activityEntry->attachments)
var files =
{!! json_encode($activityEntry->attachments) !!}
for (var i in files) {
var file = files[i]
this.options.addedfile.call(this, file)
file.previewElement.classList.add('dz-complete')
$('form').append('<input type="hidden" name="attachments[]" 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
}
}
</script>
@endsection