Commit f633d1be by Farendi Giotivano R.P

tambah pengumuman

parent a947814a
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Pengumuman;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class DashboardController extends Controller class DashboardController extends Controller
...@@ -15,9 +16,11 @@ class DashboardController extends Controller ...@@ -15,9 +16,11 @@ class DashboardController extends Controller
{ {
// //
$title = 'Dashboard PKM'; $title = 'Dashboard PKM';
$pengumuman = $pengumuman = Pengumuman::query()->first();
$data = [ $data = [
'title' => $title, 'title' => $title,
'pengumuman' => $pengumuman,
]; ];
return view('backend.index', $data); return view('backend.index', $data);
......
...@@ -4,6 +4,14 @@ namespace App\Http\Controllers\Operator; ...@@ -4,6 +4,14 @@ namespace App\Http\Controllers\Operator;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Models\Pengumuman;
use Session;
use Alert;
use Auth;
class PengumumanController extends Controller class PengumumanController extends Controller
{ {
...@@ -11,6 +19,16 @@ class PengumumanController extends Controller ...@@ -11,6 +19,16 @@ class PengumumanController extends Controller
public function index() public function index()
{ {
// //
$title = 'Pengumuman';
$pengumuman = Pengumuman::query()->first();
$data = [
'pengumuman' => $pengumuman,
'title' => $title,
];
return view('backend.operator.pengumuman.index', $data);
} }
public function create() public function create()
...@@ -36,6 +54,33 @@ class PengumumanController extends Controller ...@@ -36,6 +54,33 @@ class PengumumanController extends Controller
public function update(Request $request, $id) 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) public function destroy($id)
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="card-title">Pengumuman :</h4> <h4 class="card-title">Pengumuman :</h4>
<h5> </h5> <h5>{!! $pengumuman->pengumuman !!} </h5>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -17,62 +17,45 @@ ...@@ -17,62 +17,45 @@
<div class="col-md-8"> <div class="col-md-8">
<h6 class="page-title">{!! $title !!}</h6> <h6 class="page-title">{!! $title !!}</h6>
<ol class="breadcrumb m-0"> <ol class="breadcrumb m-0">
<li class="breadcrumb-item">Mahasiswa</li> <li class="breadcrumb-item">Operator</li>
<li class="breadcrumb-item">{!! $title !!}</li> <li class="breadcrumb-item">{!! $title !!}</li>
</ol> </ol>
</div> </div>
<div class="col-md-4">
<div class="float-end d-none d-md-block">
{{-- --}}
</div> </div>
</div> </div>
</div>
</div>
<!-- end page title --> <!-- end page title -->
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@if ($proposal) {!! Form::model($pengumuman, ['route' => ['operator.pengumuman.update', $pengumuman->id], 'method'=>'patch', 'files' => 'true', 'enctype'=>'multipart/form-data']) !!}
{!! 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
@csrf @csrf
<h4 class="card-title">{!! $title !!}</h4> <div class="row">
<p class="card-title-desc"></p> <label class="col-sm-3 col-form-label"></label>
<div class="row mb-3"> <div class="col-sm-12">
<label for="kode" class="col-sm-2 col-form-label">Judul</label> <label for="kode" class="col-sm-2 col-form-label">Pengumuman</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"> <div class="col-sm-10">
<select class="form-select select2" name="jenis"> <textarea id="elm1" name="pengumuman" name="area">{!! $pengumuman->pengumuman !!}</textarea>
<option selected>Pilih Jenis</option> <input class="form-control" type="hidden" id="peg_id" name="peg_id" value="{{ $pengumuman->id }}" >
@foreach($jenis as $item => $pkm)
<option value="{{ $item }}" {{ $proposal ? $proposal->jenis_id == $item ? 'selected' : '' : '' }}>{{ $pkm }}</option>
@endforeach
</select>
</div>
</div> </div>
<div class="row mb-3" class="dropzone"> <br/>
<label for="kode" class="col-sm-2 col-form-label">Upload Proposal</label> <label for="kode" class="col-sm-2 col-form-label">Pengumuman File</label>
<div class="col-sm-10"> <div class="col-sm-10">
@if ($errors->has('file')) <span class="text-danger">{{ $errors->first('file') }}</span> @endif @if ($errors->has('file')) <span class="text-danger">{{ $errors->first('file') }}</span> @endif
<input type="file" name="file" class="form-control" id="input-file"> <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> <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> </div>
<button type="submit" class="btn btn-primary waves-effect waves-light me-1" id="btnSubmit"> Submit </button>
{{ Form::close() }} {{ Form::close() }}
<br>
<h6 class="text-danger">* PASTIKAN FILE PROPOSAL SUDAH BENAR SEBELUM DISUBMIT</h6>
</div> </div>
</div> </div>
</div> <!-- end col --> </div> <!-- end col -->
...@@ -82,6 +65,9 @@ ...@@ -82,6 +65,9 @@
@section('js') @section('js')
<script src="{{ asset('theme/libs/tinymce/tinymce.min.js') }}"></script>
<script src="{{ asset('theme/js/pages/form-editor.init.js') }}"></script>
<script> <script>
$(function(){ $(function(){
$('#input-file').change(function(){ $('#input-file').change(function(){
...@@ -91,6 +77,44 @@ ...@@ -91,6 +77,44 @@
$('#view-pdf').attr('height','500px'); $('#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 @endsection
...@@ -43,6 +43,12 @@ ...@@ -43,6 +43,12 @@
<span>Jadwal Kegiatan</span> <span>Jadwal Kegiatan</span>
</a> </a>
</li> </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> </ul>
</li> </li>
<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