Commit 93b52c70 by Muhammad Iskandar Java

Merge branch 'master' of http://git.unesa.ac.id/alfiro/simpmw

parents abe17d8f aea19bba
...@@ -15,6 +15,7 @@ use App\Models\Jenis; ...@@ -15,6 +15,7 @@ use App\Models\Jenis;
use Session; use Session;
use Alert; use Alert;
use App\Models\ProposalUrl;
use Auth; use Auth;
class ProposalController extends Controller class ProposalController extends Controller
...@@ -68,7 +69,8 @@ class ProposalController extends Controller ...@@ -68,7 +69,8 @@ class ProposalController extends Controller
public function lihat(Request $request) public function lihat(Request $request)
{ {
$item = Proposal::where('proposal_id', $request->proposal_id)->first(); $item['proposal'] = Proposal::where('proposal_id', $request->proposal_id)->first();
$item['url'] = ProposalUrl::where('proposal_id', $request->proposal_id)->all();
$data = ''; $data = '';
$no = 1; $no = 1;
...@@ -104,6 +106,10 @@ class ProposalController extends Controller ...@@ -104,6 +106,10 @@ class ProposalController extends Controller
<tr> <tr>
<td>Proposal</td> <td>Proposal</td>
<td>".$dokumen."</td> <td>".$dokumen."</td>
</tr>
<tr>
<td>Video Produk</td>
<td>".$item['url']->url."</td>
</tr> </tr>
"; ";
...@@ -136,5 +142,4 @@ class ProposalController extends Controller ...@@ -136,5 +142,4 @@ class ProposalController extends Controller
return redirect()->route('dosen.proposal.index'); return redirect()->route('dosen.proposal.index');
} }
} }
...@@ -120,7 +120,7 @@ class MonevController extends Controller ...@@ -120,7 +120,7 @@ class MonevController extends Controller
$file_nama = $proposal->rProposal->rPeriode->nama.'_'.$proposal->rProposal->proposal_id.'.'.$pro['file']->getClientOriginalExtension(); $file_nama = $proposal->rProposal->rPeriode->nama.'_'.$proposal->rProposal->proposal_id.'.'.$pro['file']->getClientOriginalExtension();
Storage::disk('static')->put('simpmw/monev/'.$pro['monev'].'/'.$pro['type'].'/'.$file_nama, file_get_contents($pro['file']->getRealPath())); Storage::disk('local')->put('simpmw/monev/'.$pro['monev'].'/'.$pro['type'].'/'.$file_nama, file_get_contents($pro['file']->getRealPath()));
if($pro['type'] == 'logbook'){ if($pro['type'] == 'logbook'){
$proposal->logbook_file = $file_nama; $proposal->logbook_file = $file_nama;
......
...@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Storage; ...@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Models\Proposal; use App\Models\Proposal;
use App\Models\ProposalUrl;
use App\Models\Kelompok; use App\Models\Kelompok;
use App\Models\Periode; use App\Models\Periode;
use App\Models\Jenis; use App\Models\Jenis;
...@@ -35,16 +36,16 @@ class ProposalController extends Controller ...@@ -35,16 +36,16 @@ class ProposalController extends Controller
$periode = Periode::query()->get(); $periode = Periode::query()->get();
$year = !is_null($request->year) ? $request->year : now()->year; $year = !is_null($request->year) ? $request->year : now()->year;
$proposal = Proposal::with(['rKelompok', 'rJenis']) $proposal = Proposal::with(['rKelompok', 'rJenis', 'rProposalUrl'])
->whereHas('rKelompok', function ($query) use($nim){ ->whereHas('rKelompok', function ($query) use($nim){
$query->whereHas('rAnggota', function ($query) use($nim){ $query->whereHas('rAnggota', function ($query) use($nim){
$query->where('nim', $nim); $query->where('nim', $nim);
}); });
}) })
->whereYear('created_at', $year) ->whereYear('proposal.created_at', $year)
->orderBy('kelompok_id') ->orderBy('kelompok_id')
->get(); ->get();
// dd($proposal->pluck('rProposalUrl.url')->toArray());
$data = [ $data = [
'proposal' => $proposal, 'proposal' => $proposal,
'title' => $title, 'title' => $title,
...@@ -121,11 +122,15 @@ class ProposalController extends Controller ...@@ -121,11 +122,15 @@ class ProposalController extends Controller
$this->validate($request, $this->validate($request,
[ [
'file' => 'required|mimes:pdf|max:5000' 'file' => 'required|mimes:pdf|max:5000',
'jenis' => 'required|not_in:Pilih Jenis',
], [ ], [
'file.required' => 'Tidak ada file yang di upload', 'file.required' => 'Tidak ada file yang diupload.',
'file.mimes' => 'File harus pdf', 'file.file' => 'File harus berupa file.',
'file.max' => 'File tidak boleh lebih dari 5 mb', 'file.mimes' => 'File harus berupa file PDF.',
'file.max' => 'Ukuran file maksimal adalah 5 MB.',
'jenis.required' => 'Harap pilih jenis PMW.',
'jenis.not_in' => 'Harap pilih jenis PMW yang valid.',
]); ]);
$periode = Periode::where('status', 1)->first(); $periode = Periode::where('status', 1)->first();
...@@ -133,7 +138,7 @@ class ProposalController extends Controller ...@@ -133,7 +138,7 @@ class ProposalController extends Controller
$file_nama = $periode->nama.'_'.$uuid.'.'.$proposal['file']->getClientOriginalExtension(); $file_nama = $periode->nama.'_'.$uuid.'.'.$proposal['file']->getClientOriginalExtension();
Storage::disk('static')->put('simpmw/proposal/'.$periode->nama.'/'.$file_nama, file_get_contents($proposal['file']->getRealPath())); Storage::disk('local')->put('simpmw/proposal/'.$periode->nama.'/'.$file_nama, file_get_contents($proposal['file']->getRealPath()));
$kel = Proposal::create([ $kel = Proposal::create([
'proposal_id' => $uuid, 'proposal_id' => $uuid,
...@@ -146,6 +151,17 @@ class ProposalController extends Controller ...@@ -146,6 +151,17 @@ class ProposalController extends Controller
'date_upload' => now(), 'date_upload' => now(),
'created_user' => Auth::user()->id 'created_user' => Auth::user()->id
]); ]);
if ($kel) {
ProposalUrl::create([
'id' => $uuid,
'url_name' => $proposal['url_name'],
'url' => $proposal['url'],
'deskripsi' => $proposal['deskripsi'],
'proposal_id' => $kel->proposal_id,
'created_at' => null,
'updated_at' => null
]);
}
return redirect()->route('mahasiswa.proposal.index')->with('success', 'Proposal Berhasil ditambahkan'); return redirect()->route('mahasiswa.proposal.index')->with('success', 'Proposal Berhasil ditambahkan');
} }
......
...@@ -73,6 +73,11 @@ class Proposal extends Model ...@@ -73,6 +73,11 @@ class Proposal extends Model
return $this->hasOne(Periode::class, 'periode_id', 'periode_id'); return $this->hasOne(Periode::class, 'periode_id', 'periode_id');
} }
public function rProposalUrl()
{
return $this->hasOne(ProposalUrl::class, 'proposal_id', 'proposal_id');
}
public function rLuaran() public function rLuaran()
{ {
return $this->hasMany(ProposalLuaran::class, 'proposal_id', 'proposal_id'); return $this->hasMany(ProposalLuaran::class, 'proposal_id', 'proposal_id');
......
...@@ -19,10 +19,15 @@ class ProposalUrl extends Model ...@@ -19,10 +19,15 @@ class ProposalUrl extends Model
protected $fillable = [ protected $fillable = [
'id', 'id',
'url', 'url',
'nama', 'url_name',
'deskripsi', 'deskripsi',
'proposal_id', 'proposal_id',
'created_at', 'created_at',
'updated_at', 'updated_at'
]; ];
public function rProposal()
{
return $this->belongsTo(Proposal::class, 'proposal_id', 'proposal_id');
}
} }
...@@ -38,30 +38,49 @@ ...@@ -38,30 +38,49 @@
<h4 class="card-title">{!! $title !!}</h4> <h4 class="card-title">{!! $title !!}</h4>
<p class="card-title-desc"></p> <p class="card-title-desc"></p>
<div class="row mb-3"> <div class="row mb-3">
<label for="kode" class="col-sm-2 col-form-label">Judul</label> <label for="kode" class="col-sm-2 col-form-label">Judul<span style="color: red;"> *</span></label>
<div class="col-sm-10"> <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="text" id="judul" name="judul" value="{{ old('judul', $proposal ? $proposal->judul : '') }}" placeholder="Judul Produk" 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="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 }}" > <input class="form-control" type="hidden" id="periode_id" name="periode_id" value="{{ $proposal ? $proposal->periode_id : $periode->periode_id }}" >
</div> </div>
</div> </div>
<div class=" row mb-3"> <div class=" row mb-3">
<label class="col-sm-2 col-form-label">Jenis PMW</label> <label class="col-sm-2 col-form-label">Jenis PMW<span style="color: red;"> *</span></label>
<div class="col-sm-10"> <div class="col-sm-10">
<select class="form-select select2" name="jenis"> <select class="form-select select2" name="jenis">
<option selected>Pilih Jenis</option> <option selected>Pilih Jenis</option>
@foreach($jenis as $item => $pkm) @foreach($jenis as $item => $pkm)
<option value="{{ $item }}" {{ $proposal ? $proposal->jenis_id == $item ? 'selected' : '' : '' }}>{{ $pkm }}</option> <option value="{{ $item }}" {{ $proposal ? $proposal->jenis_id == $item ? 'selected' : '' : '' }}>{{ $pkm }}</option>
@endforeach @endforeach
</select> </select>
@if ($errors->has('jenis')) <span class="text-danger"><i>{{ $errors->first('jenis') }}</i></span> @endif
</div> </div>
</div> </div>
<div class="row mb-3" class="dropzone"> <div class="row mb-3" class="dropzone">
<label for="kode" class="col-sm-2 col-form-label">Upload Proposal</label> <label for="kode" class="col-sm-2 col-form-label">Upload Proposal<span style="color: red;"> *</span></label>
<div class="col-sm-10"> <div class="col-sm-8 col-lg-8">
@if ($errors->has('file')) <span class="text-danger">{{ $errors->first('file') }}</span> @endif
<input type="file" name="file" class="form-control" id="input-file" accept="application/pdf"> <input type="file" name="file" class="form-control" id="input-file" accept="application/pdf">
<iframe id="view-pdf" width="80%" height="80%" frameborder="0" src="{{ $proposal ? 'https://statik.unesa.ac.id/simpmw/proposal/'.$proposal->rPeriode->nama.'/'.$proposal->upload_dokumen : '' }} "></iframe> @if ($errors->has('file')) <span class="text-danger"><i>{{ $errors->first('file') }}</i></span> @endif
{{-- <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>
<div class="col-sm-2 col-lg-2">
<button type="button" class="form-control btn btn-warning" id="btnPreview">Preview</button>
</div>
</div>
<div class="row mb-3">
<label for="kode" class="col-sm-2 col-form-label">URL Video Produk<span style="color: red;"> *</span></label>
<div class="col-sm-3 col-lg-3">
<input class="form-control" type="text" id="url_name" name="url_name" value="{{ old('url_name') }}" placeholder="Nama Video Produk" required>
</div>
<div class="col-sm-7 col-lg-7">
<input class="form-control" type="text" id="url" name="url" value="{{ old('url') }}" placeholder="URL Video Produk" required>
</div>
</div>
<div class="row mb-3">
<div class="col-sm-2 col-lg-2"></div>
<div class="col-sm-10 col-lg-10">
<textarea class="form-control" type="text" id="deskripsi" name="deskripsi" placeholder="Deskripsi..." required>{{ old('deskripsi') }}</textarea>
</div> </div>
</div> </div>
<div class="mb-0"> <div class="mb-0">
...@@ -78,11 +97,28 @@ ...@@ -78,11 +97,28 @@
</div> <!-- end col --> </div> <!-- end col -->
</div> <!-- end row --> </div> <!-- end row -->
<!-- Modal -->
<div class="modal fade" id="pdfModal" tabindex="-1" role="dialog" aria-labelledby="pdfModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content" style="height: 80vh;">
<div class="modal-header">
<h5 class="modal-title" id="pdfModalLabel">Preview PDF</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">{{-- <span aria-hidden="true">&times;</span> --}}</button>
</div>
<div class="modal-body">
{{-- <iframe id="pdfViewer" width="100%" height="100%" frameborder="0"></iframe> --}}
{{-- <iframe id="view-pdf" width="100%" height="450" frameborder="0" src="{{ $proposal ? 'https://statik.unesa.ac.id/simpkm/proposal/'.$proposal->rPeriode->nama.'/'.$proposal->upload_dokumen : '' }} "></iframe> --}}
<iframe id="view-pdf" width="100%" height="100%"></iframe>
</div>
</div>
</div>
</div>
@endsection @endsection
@section('js') @section('js')
<script> {{-- <script>
$(function(){ $(function(){
$('#input-file').change(function(){ $('#input-file').change(function(){
var input = this; var input = this;
...@@ -91,6 +127,92 @@ ...@@ -91,6 +127,92 @@
$('#view-pdf').attr('height','500px'); $('#view-pdf').attr('height','500px');
}) })
}) })
</script> </script> --}}
{{-- <script>
$(function(){
$('#input-file').change(function(){
var input = this;
var url = window.URL.createObjectURL(this.files[0]);
$('#pdfViewer').attr('src', url);
});
// Reset iframe saat modal ditutup
$('#pdfModal').on('hidden.bs.modal', function (e) {
$('#pdfViewer').attr('src', '');
});
});
</script> --}}
{{-- <script>
$(function(){
$('#btnPreview').click(function() {
// Ambil URL dari file yang dipilih
var url = window.URL.createObjectURL($('#input-file')[0].files[0]);
// Set iframe dengan URL file
$('#view-pdf').attr('src', url);
// Munculkan modal
$('#pdfModal').modal('show');
});
// Reset iframe saat modal ditutup
$('#pdfModal').on('hidden.bs.modal', function (e) {
$('#view-pdf').attr('src', '');
});
});
</script> --}}
<script>
$(document).ready(function () {
$('#input-file').on('change', function (e) {
var fileInput = e.target.files[0];
// Periksa apakah ada file yang dipilih
if (!fileInput) {
alert('Silakan pilih file PDF terlebih dahulu.');
return;
}
// Periksa tipe file (harus PDF)
if (fileInput.type !== 'application/pdf') {
alert('File harus berupa PDF.');
// Reset input file
$('#input-file').val('');
return;
}
// Periksa ukuran file (maksimal 5MB)
if (fileInput.size > 5 * 1024 * 1024) {
alert('Ukuran file maksimal adalah 5MB.');
// Reset input file
$('#input-file').val('');
return;
}
});
// Fungsi untuk tombol "Preview"
$('#btnPreview').click(function() {
var fileInput = $('#input-file')[0].files[0];
// Periksa apakah ada file yang dipilih
if (!fileInput) {
alert('Silakan pilih file PDF terlebih dahulu.');
return;
}
// Tampilkan pratinjau PDF di dalam modal jika file memenuhi syarat
var url = URL.createObjectURL(fileInput);
$('#view-pdf').attr('src', url);
$('#pdfModal').modal('show');
});
// Reset iframe saat modal ditutup
$('#pdfModal').on('hidden.bs.modal', function (e) {
$('#view-pdf').attr('src', '');
});
});
</script>
@endsection @endsection
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<link href="{{ asset('theme/libs/chartist/chartist.min.css') }}" rel="stylesheet"> <link href="{{ asset('theme/libs/chartist/chartist.min.css') }}" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
<!-- DataTables --> <!-- DataTables -->
<link href="{{ asset('theme/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css') }}" rel="stylesheet" <link href="{{ asset('theme/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css') }}" rel="stylesheet"
type="text/css"> type="text/css">
...@@ -49,5 +49,6 @@ ...@@ -49,5 +49,6 @@
<link href="{{ asset('theme/libs/dropzone/min/dropzone.min.css') }}" rel="stylesheet" type="text/css"> <link href="{{ asset('theme/libs/dropzone/min/dropzone.min.css') }}" rel="stylesheet" type="text/css">
<link href="{{ asset('theme/libs/select2/css/select2.min.css') }}" rel="stylesheet" type="text/css"> <link href="{{ asset('theme/libs/select2/css/select2.min.css') }}" rel="stylesheet" type="text/css">
@yield('css')
</head> </head>
@include('layouts.headpg') @include('layouts.headpg')
@yield('css')
<body data-sidebar="dark"> <body data-sidebar="dark">
...@@ -95,6 +96,7 @@ ...@@ -95,6 +96,7 @@
<!-- END layout-wrapper --> <!-- END layout-wrapper -->
@include('layouts.inijs') @include('layouts.inijs')
@yield('js')
<script> <script>
document.getElementById('vertical-menu-btn').addEventListener('click', function() { document.getElementById('vertical-menu-btn').addEventListener('click', function() {
var icon = this.querySelector('i'); var icon = this.querySelector('i');
......
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