IMMREX7
@extends('teachers.teacher_layout')
@section('content')
<div class="row clearfix">
<div class="col-sm-5">
<div class="card">
<div class="header">
<h2><strong>@if(isset($notice))Edit @else Add @endif</strong>Circular</h2>
</div>
<div class="body">
@if(isset($notice))
{!! Form::model($notice, ['method' => 'PATCH', 'action' => ['Teacher\NoticeboardController@update', $notice->idNoticeboard], 'class' => 'form-horizontal','files'=>true]) !!}
@else
{!! Form::open(['url' => 'teacher/noticeboards', 'class' => 'form-horizontal','id'=>'notice_form','files'=>true]) !!}
@endif
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Class</label>
</div>
<div class="col-sm-8">
<div class="form-group">
@if(isset($notice) && $notice->idClass == null)
<p class="form-control-static">ALL</p>
@else
{!! Form::select('idClass',$classes,null,['class' => 'form-control show-tick ms select2']) !!}
@endif
@if ($errors->has('idClass'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idClass') }}</strong>
</label>
@endif
<span id='classerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Select Section</label>
</div>
<div class="col-sm-8">
<div class="form-group">
@if(isset($notice) && $notice->idClass == null)
<p class="form-control-static">ALL</p>
@else @if(isset($notice))
{!! Form::select('idSection',$section,null,['class' => 'form-control show-tick ms select2']) !!}
@else
<div id="idSection" style="border:1px solid #ccc; width:200px; height: 110px; overflow-y: scroll;">
</div>
@endif
@endif
@if ($errors->has('idSection'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idSection') }}</strong>
</label>
@endif
<span id='sectionerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Subject</label>
</div>
<div class="col-sm-8">
<div class="form-group">
{!! Form::text('subject',null,['class' => 'form-control','minlength'=>'2','maxlength'=>'120']) !!}
@if ($errors->has('subject'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('subject') }}</strong>
</label>
@endif
<span id='subjecterror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Notice</label>
</div>
<div class="col-sm-8">
<div class="form-group">
{!! Form::textarea('notice',null,['class' => 'form-control','size'=>'30x2','minlength'=>'2','maxlength'=>'500']) !!}
@if ($errors->has('notice'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('notice') }}</strong>
</label>
@endif
<span id='noticeerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Upload</label>
</div>
<div class="col-sm-8">
<div class="form-group">
{!! Form::file('noticeFile',null,['class' => 'form-control']) !!}
@if ($errors->has('noticeFile'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('noticeFile') }}</strong>
</label>
@endif
<span id='noticefileerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Select Publish Date</label>
</div>
<div class="col-sm-5">
<div class="form-group">
{!! Form::text('publishDate',null,['class' => 'form-control datepicker']) !!}
@if ($errors->has('publishDate'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('publishDate') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-2">
<button class="btn btn-sm btn-success" style="font-size: 12px;" name='schedule'>Schedule</button>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($notice))
{!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
@else
{!! Form::submit('SAVE NOW',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
@endif
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<!--</div>
<div class="row clearfix">-->
<div class="col-sm-7">
<div class="card">
<div class="header">
<h2><strong>List Of Circular</strong></h2>
</div>
<div class="body table-responsive">
{!! Form::open(['method' => 'GET', 'action' => ['School\NoticeboardController@index'], 'class' => 'form-horizontal']) !!}
<div class="row clearfix">
<div class="col-sm-3 form-control-label">
<label for="classname">From Date</label>
</div>
<div class="col-sm-5">
<div class="form-group">
{!! Form::text('fromDate',null,['class' => 'form-control datepicker']) !!}
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3 form-control-label">
<label for="classname">To Date</label>
</div>
<div class="col-sm-5">
<div class="form-group">
{!! Form::text('toDate',null,['class' => 'form-control datepicker']) !!}
</div>
</div>
<div class="col-sm-2">
{!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
{!! Form::close() !!}
</div>
</div>
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Date</th>
<th>Class</th>
<th>Section</th>
<th>Subject</th>
<th>Notice</th>
<th>Notice Doc</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($notices as $value)
<tr>
<th scope="row">{{$i}}</th>
<td>{{$value->created_at->format('d-m-Y')}}</td>
<td>{{$value->classM->className or 'All'}}</td>
<td>{{$value->section->sectionName or 'All'}}</td>
<td>{{$value->subject}}</td>
<td style="word-wrap: break-word;">{{$value->notice}}</td>
<td><a href="{{url('/teacher/noticeboards/' . $value->idNoticeboard.'/viewdoc')}}" target="_blank">View</a></td>
<td>
<a href="{{ url('teacher/noticeboards/' . $value->idNoticeboard . '/edit') }}" class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idNoticeboard}}" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
$('select[name="idClass"]').on('change', function() {
var classID = $(this).val();
if(classID!='All') {
$.ajax({
url: "{{url('/teacher/class') }}"+'/' +classID + "/sections",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSection').empty();
$('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall" name="all"></div>');
$.each(data, function(key, value) {
$('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="sections[]" value="'+key+'" class="sectionclass"></div>');
});
}
});
}else{
$('select[name="idSection"]').empty();
}
});
});
$(document).on('click', '.select-all', function(){
var checkAll = this.checked;
if(checkAll === true){
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}else{
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}
});
// Delete Feehead
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Notice!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/teacher/noticeboards/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Notice has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
// Saving form data
$('#notice_form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#notice_form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "{{url('teacher/noticeboards') }}",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "{{url('teacher/noticeboards')}}";
}
else { //False Case: With error msg
$("#msg").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
$("#submit-btn").prop('disabled', false);
var errors = data.responseJSON.errors;
var errorHtml = '<div class="alert alert-danger"><ul>';
$('#formerrors').html(errorHtml);
if(errors['idClass']=== undefined){
$( '#classerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idClass']+'</strong></span>';
$( '#classerror' ).html( errorname );
}
if(errors['idSection']=== undefined){
$( '#sectionerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idSection']+'</strong></span>';
$( '#sectionerror' ).html( errorname );
}
if(errors['subject']=== undefined){
$( '#subjecterror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['subject']+'</strong></span>';
$( '#subjecterror' ).html( errorname );
}
if(errors['notice']=== undefined){
$( '#noticeerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['notice']+'</strong></span>';
$( '#noticeerror' ).html( errorname );
}
if(errors['noticeFile']=== undefined){
$( '#noticefileerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['noticeFile']+'</strong></span>';
$( '#noticefileerror' ).html( errorname );
}
}
}
});
return false;
});
</script>
@stop
Copyright © 2021 -