IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card">
<div class="header">
<h2><strong>@if(isset($newsletter))Edit @else Add @endif</strong>Newsletter</h2>
</div>
<div class="body">
@if(isset($newsletter))
{!! Form::model($newsletter, ['method' => 'PATCH', 'action' => ['School\NewsLetterController@update', $newsletter->idNewsletter], 'class' => 'form-horizontal']) !!}
@else
{!! Form::open(['url' => 'school/newsletters', 'class' => 'form-horizontal','files'=>true,]) !!}
@endif
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname" class="required">Select Class</label>
</div>
<div class="col-sm-8">
<div class="form-group">
@if(isset($newsletter) && $newsletter->idClass == null)
<p class="form-control-static">All</p>
@else @if(isset($newsletter))
{!! Form::select('idClass',$class,null,['class' => 'form-control show-tick ms']) !!}
@else
<div style="border:1px solid #ccc; width:250px; height: 110px; overflow-y: scroll;">
<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" name='all'>
@foreach($classes as $key=>$value)
<div class="checkbox-inline" style="padding-left:5px;">
<label style="margin-right:10px;">{{$value}}</label>
<input type="checkbox" name="classes[]" value="{{$key}}" class="chkall">
</div>
@endforeach
</div>
</div>
@endif
@endif
@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-4 form-control-label">
<label for="classname" class="required">Subject</label>
</div>
<div class="col-sm-8">
<div class="form-group">
@if(isset($newsletter) && $newsletter->subjectName != "NA")
<p>Subject : {{$newsletter->subjectName}}</p>
@endif
{!! Form::select('subject',$subjects,null,['class' => 'form-control show-tick ms']) !!}
@if ($errors->has('subject'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('title') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname" class="required">Title</label>
</div>
<div class="col-sm-8">
<div class="form-group">
{!! Form::text('title',null,['class' => 'form-control']) !!}
@if ($errors->has('title'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('title') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname" class="required">Description</label>
</div>
<div class="col-sm-8">
<div class="form-group">
{!! Form::textarea('description',null,['class' => 'form-control','size'=>'30x2']) !!}
@if ($errors->has('description'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('description') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname">Image</label>
</div>
<div class="col-sm-6">
<div class="form-group">
{!! Form::file('image',null,['class' => 'form-control']) !!}
@if ($errors->has('image'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('image') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label">
<label for="classname" >Video Link(Key Only)</label>
</div>
<div class="col-sm-6">
<div class="form-group">
{!! Form::text('videoLink',null,['class' => 'form-control']) !!}
@if ($errors->has('videoLink'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('videoLink') }}</strong>
</label>
@endif
</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>
@if(isset($newsletter))
@else
<!-- <div class="col-sm-2">
<button class="btn btn-sm btn-success" style="font-size: 12px;" name='schedule'>Schedule</button>
</div>-->
@endif
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($newsletter))
{!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
@else
{!! Form::submit('PUBLISH NOW',['class' => 'btn btn-raised btn-warning btn-round waves-effect']) !!}
@endif
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-7">
<div class="card">
@foreach($newsletters as $val)
<div class="body">
<ul class="cbp_tmtimeline">
<li>
<time class="cbp_tmtime" datetime="#"><span class="hidden">{{$val->publishDate}}</span> <span class="large"></span></time>
<div class="cbp_tmicon"><i class="zmdi zmdi-account"></i></div>
<div class="cbp_tmlabel">
<h2><a href="javascript:void(0);">{{$val->title}}</a> <span></span></h2>
<p>
<a href="{{ url('school/newsletters/' . $val->idNewsletter . '/edit') }}" class="btn btn-sm btn-info waves-effect waves-float waves-red"><i class="zmdi zmdi-edit"></i></a>
<a href="#" class="btn btn-sm btn-danger waves-effect waves-float waves-red js-sweetalert" data-id="{{$val->idNewsletter}}" data-type="confirm"><i class="zmdi zmdi-delete"></i></a>
</p>
@if($val->subjectName != "NA")
<p>{{$val->subjectName}}</p>
@endif
<p>{{$val->description}}</p>
@if($val->image!=null)
<img src="{{ asset('storage/schools/'.$val->idSchool.'/newsletters/'.$val->image)}}">
@else
<iframe width="360" height="315" src="https://www.youtube.com/embed/{{$val->videoLink}}" frameborder="0" allowfullscreen></iframe>
@endif
</div>
</li>
</ul>
</div>
@endforeach
<div class="body">
<?php echo $newsletters->render(); ?>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).on('click', '.select-all', function(){
var checkAll = this.checked;
if(checkAll === true){
$('.chkall').each(function () {
this.checked = checkAll;
});
}else{
$('.chkall').each(function () {
this.checked = checkAll;
});
}
});
$(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 Newsletter!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/newsletters/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Newsletter has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
</script>
@stop
Copyright © 2021 -