Commit f633d1be by Farendi Giotivano R.P

tambah pengumuman

parent a947814a
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Pengumuman;
use Illuminate\Http\Request;
class DashboardController extends Controller
......@@ -15,9 +16,11 @@ class DashboardController extends Controller
{
//
$title = 'Dashboard PKM';
$pengumuman = $pengumuman = Pengumuman::query()->first();
$data = [
'title' => $title,
'pengumuman' => $pengumuman,
];
return view('backend.index', $data);
......
......@@ -4,6 +4,14 @@ namespace App\Http\Controllers\Operator;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Models\Pengumuman;
use Session;
use Alert;
use Auth;
class PengumumanController extends Controller
{
......@@ -11,6 +19,16 @@ class PengumumanController extends Controller
public function index()
{
//
$title = 'Pengumuman';
$pengumuman = Pengumuman::query()->first();
$data = [
'pengumuman' => $pengumuman,
'title' => $title,
];
return view('backend.operator.pengumuman.index', $data);
}
public function create()
......@@ -36,6 +54,33 @@ class PengumumanController extends Controller
public function update(Request $request, $id)
{
//
$pengumuman = $request->except('_token');
$this->validate($request,
[
'file' => 'mimes:pdf|max:5000'
], [
'file.mimes' => 'File harus pdf',
'file.max' => 'File tidak boleh lebih dari 5 mb',
]);
$pro = Pengumuman::find($id);
if(!isset($pengumuman['file'])){
$file_nama = $pro->file;
} else {
// Storage::disk('static')->delete('simpkm/pengumuman/'.$pro->rPeriode->nama.'/'.$pro->upload_dokumen);
$file_nama = $pro->id.'.'.$pengumuman['file']->getClientOriginalExtension();
Storage::disk('static')->put('simpkm/pengumuman/'.$file_nama, file_get_contents($pengumuman['file']->getRealPath()));
}
$pro->pengumuman = $pengumuman['pengumuman'];
$pro->file = $file_nama;
$pro->save();
return redirect()->route('operator.pengumuman.index')->with('success', 'Pengumuman berhasil di Edit');
}
public function destroy($id)
......
......@@ -37,7 +37,7 @@
<div class="card">
<div class="card-body">
<h4 class="card-title">Pengumuman :</h4>
<h5> </h5>
<h5>{!! $pengumuman->pengumuman !!} </h5>
</div>
</div>
</div>
......
......@@ -17,62 +17,45 @@
<div class="col-md-8">
<h6 class="page-title">{!! $title !!}</h6>
<ol class="breadcrumb m-0">
<li class="breadcrumb-item">Mahasiswa</li>
<li class="breadcrumb-item">Operator</li>
<li class="breadcrumb-item">{!! $title !!}</li>
</ol>
</div>
<div class="col-md-4">
<div class="float-end d-none d-md-block">
{{-- --}}
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
@if ($proposal)
{!! Form::model($proposal, ['route' => ['mahasiswa.proposal.update', $proposal->proposal_id], 'method'=>'patch', 'files' => 'true', 'enctype'=>'multipart/form-data']) !!}
@else
{{ Form::open(['url' => route('mahasiswa.proposal.store'), 'method' => 'post', 'id' => 'proposal', 'files' => 'true', 'enctype'=>'multipart/form-data']) }}
@endif
{!! Form::model($pengumuman, ['route' => ['operator.pengumuman.update', $pengumuman->id], 'method'=>'patch', 'files' => 'true', 'enctype'=>'multipart/form-data']) !!}
@csrf
<h4 class="card-title">{!! $title !!}</h4>
<p class="card-title-desc"></p>
<div class="row mb-3">
<label for="kode" class="col-sm-2 col-form-label">Judul</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="judul" name="judul" value="{{ $proposal ? $proposal->judul : '' }}"required>
<input class="form-control" type="hidden" id="kode_kelompok" name="kode_kelompok" value="{{ $proposal ? $proposal->kelompok_id : $kelompok->kelompok_id }}" >
<input class="form-control" type="hidden" id="periode_id" name="periode_id" value="{{ $proposal ? $proposal->periode_id : $periode->periode_id }}" >
</div>
</div>
<div class=" row mb-3">
<label class="col-sm-2 col-form-label">Jenis PKM</label>
<div class="col-sm-10">
<select class="form-select select2" name="jenis">
<option selected>Pilih Jenis</option>
@foreach($jenis as $item => $pkm)
<option value="{{ $item }}" {{ $proposal ? $proposal->jenis_id == $item ? 'selected' : '' : '' }}>{{ $pkm }}</option>
@endforeach
</select>
</div>
</div>
<div class="row mb-3" class="dropzone">
<label for="kode" class="col-sm-2 col-form-label">Upload Proposal</label>
<div class="col-sm-10">
@if ($errors->has('file')) <span class="text-danger">{{ $errors->first('file') }}</span> @endif
<input type="file" name="file" class="form-control" id="input-file">
<iframe id="view-pdf" width="80%" height="80%" frameborder="0" src="{{ $proposal ? 'https://statik.unesa.ac.id/simpkm/proposal/'.$proposal->rPeriode->nama.'/'.$proposal->upload_dokumen : '' }} "></iframe>
<div class="row">
<label class="col-sm-3 col-form-label"></label>
<div class="col-sm-12">
<label for="kode" class="col-sm-2 col-form-label">Pengumuman</label>
<div class="col-sm-10">
<textarea id="elm1" name="pengumuman" name="area">{!! $pengumuman->pengumuman !!}</textarea>
<input class="form-control" type="hidden" id="peg_id" name="peg_id" value="{{ $pengumuman->id }}" >
</div>
<br/>
<label for="kode" class="col-sm-2 col-form-label">Pengumuman File</label>
<div class="col-sm-10">
@if ($errors->has('file')) <span class="text-danger">{{ $errors->first('file') }}</span> @endif
<input type="file" name="file" class="form-control" id="input-file">
<iframe id="view-pdf" width="80%" height="100%" src="{{ $pengumuman ? 'https://statik.unesa.ac.id/simpkm/pengumuman/'.$pengumuman->file : '' }}" frameborder="0"></iframe>
</div>
</div>
</div>
</div>
<div class="mb-0">
<div>
<button type="submit" class="btn btn-primary waves-effect waves-light me-1"> Submit </button>
<button type="reset" class="btn btn-secondary waves-effect"> Cancel </button>
</div>
</div>
{{ Form::close() }}
<br>
<h6 class="text-danger">* PASTIKAN FILE PROPOSAL SUDAH BENAR SEBELUM DISUBMIT</h6>
<button type="submit" class="btn btn-primary waves-effect waves-light me-1" id="btnSubmit"> Submit </button>
{{ Form::close() }}
</div>
</div>
</div> <!-- end col -->
......@@ -82,6 +65,9 @@
@section('js')
<script src="{{ asset('theme/libs/tinymce/tinymce.min.js') }}"></script>
<script src="{{ asset('theme/js/pages/form-editor.init.js') }}"></script>
<script>
$(function(){
$('#input-file').change(function(){
......@@ -91,6 +77,44 @@
$('#view-pdf').attr('height','500px');
})
})
</script>
function hapus(id, rowId){
Swal.fire({
title: 'Apakah anda yakin untuk menghapus usulan ini?',
text: "file yang sudah terupload juga terhapus",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'OK',
}).then((result) => {
if (result.isConfirmed) {
var token = '{{ csrf_token() }}';
var request = $.ajax({
url: '{{ route('mahasiswa.proposal.hapus') }}',
type: 'POST',
dataType: 'html',
data: {id:id, _token:token},
success: function(data){
Swal.fire({
title: 'Data Berhasil Di Hapus',
icon: 'success',
showConfirmButton: false,
timer: 1500
});
$('#'+rowId).remove();
},
error: function(xhr, status, error){
Swal.fire({
position: 'top-end',
icon: 'error',
title: xhr.responseText,
showConfirmButton: false,
timer: 3500
});
}
});
}
})
}
</script>
@endsection
......@@ -43,6 +43,12 @@
<span>Jadwal Kegiatan</span>
</a>
</li>
<li class="{{ (request()->is('operator/pengumuman/*')) ? 'mm-active' : '' }}">
<a href="{{ URL::to('operator/pengumuman') }}" class="waves-effect">
<i class="ti-home"></i>
<span>Pengumuman</span>
</a>
</li>
</ul>
</li>
<li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment