IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="header">
<h2><strong>@if(isset($gallery))Edit @else Add @endif</strong> Gallery</h2>
<a href="{{url('school/galleries')}}" class="btn btn-sm btn-success" style="float: right;">View Uploaded Photo</a>
<a href="{{url('school/gfolders')}}" class="btn btn-sm btn-info" style="float: right;">Create Folder</a>
</div>
<div class="body">
@if(isset($gallery))
{!! Form::model($gallery, ['method' => 'PATCH', 'action' => ['School\GalleryController@update', $gallery->idGallery], 'class' => 'form-horizontal']) !!}
@else
{!! Form::open(['url' => 'school/galleries', 'class' => 'form-horizontal','files'=>'true']) !!}
@endif
{{ csrf_field() }}
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname" class="required">Select Class</label>
</div>
<div class="col-sm-4">
<div class="form-group">
{!! Form::select('idClass',$classes,null,['class' => 'form-control show-tick ms','id'=>'idClass']) !!}
@if ($errors->has('idClass'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idClass') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname" class="required">Select Folder</label>
</div>
<div class="col-sm-4">
<div class="form-group">
{!! Form::select('idFolder',$folders,null,['class' => 'form-control show-tick ms select2','id'=>'idFolder']) !!}
@if ($errors->has('idFolder'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idFolder') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Photo Title</label>
</div>
<div class="col-sm-4">
<div class="form-group">
{!! Form::text('imageTitle',null,['class' => 'form-control','id'=>'image_title']) !!}
@if ($errors->has('imageTitle'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('imageTitle') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname">Image</label>
</div>
<div class="col-sm-10">
<div class="dropzone" id='frmFileUpload'>
<div class="dz-message">
<div class="drag-icon-cph"> <i class="material-icons">touch_app</i> </div>
<h3>Drop files here or click to upload.</h3>
<div class="fallback" id="dz-error-message">
<input name="file" type="file" multiple />
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($gallery))
{!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
@else
{!! Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-all']) !!}
@endif
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
Dropzone.options.frmFileUpload= {
autoProcessQueue: false,
url: "{{url('school/galleries')}}",
uploadMultiple: true,
parallelUploads: 50,
maxFiles: 20,
maxFilesize: 10,
acceptedFiles: 'image/*',
addRemoveLinks: true,
init: function() {
dzClosure = this; // Makes sure that 'this' is understood inside the functions below.
// for Dropzone to process the queue (instead of default form behavior):
document.getElementById("submit-all").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
e.preventDefault();
e.stopPropagation();
dzClosure.processQueue();
});
//send all the form data along with the files:
this.on("sendingmultiple", function(data, xhr, formData) {
// _token: $('[name="_token"]').val()
formData.append("_token", $('meta[name="csrf-token"]').attr('content'));
formData.append("idFolder", $( "#idFolder option:selected" ).val());
formData.append("idClass", $("#idClass").val());
formData.append("imageTitle", $("#image_title").val());
});
this.on("error", function(file, response, xhr) {
if (response.hasOwnProperty('errors')) {
// Validation error
for (const error in response.errors) {
this.emit("error", file, response.errors[error].join(' '));
}
}
});
this.on('success', function(){
//if (this.getQueuedFiles().length == 0 && this.getUploadingFiles().length == 0) {
location.reload();
// }
});
}
}
</script>
@stop
Copyright © 2021 -