index.blade.php 20.7 KB
Newer Older
Muhammad Iskandar Java committed
1
@extends('layouts.master')
2
@section('css')
3
    {{-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"> --}}
4
@endsection
Muhammad Iskandar Java committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

@section('title')
    Dashboard
@endsection

@section('header')
<div class="page-title">
    <h3>Dashboard</h3>
</div>
@endsection

@section('contents')
    <!-- start page title -->
    <div class="page-title-box">
        <div class="row align-items-center">
            <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">{!! $title !!}</li>
                </ol>
            </div>
            <div class="col-md-4">
28
                <div class="text-end d-flex justify-content-end">
Muhammad Iskandar Java committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
                    <a href="{{ URL::to('mahasiswa/proposal/create') }}" type="button" class="btn btn-primary waves-effect waves-light"> <i class="fas fa-plus-circle"></i> Tambah Data</a>
                </div>
            </div>
        </div>
    </div>
    <!-- end page title -->

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <form action="{{ route('mahasiswa.proposal.index') }}">
                        <div class="row">
                            <div class="col-md-8"></div>
                            <div class="col-md-4 text-right">
                                <div class="row">
                                    <label class="col-sm-3 col-form-label"></label>
                                    <label class="col-sm-3 col-form-label">Tahun : </label>
                                    <div class="col-sm-6">
                                        <select class="form-select" name="year" onchange="this.form.submit()">
                                        @foreach($periode as $per)
                                            <option value="{{ $per->nama }}" {{ $year == $per->nama ? 'selected' : '' }}>{{ $per->nama }}</option>
                                        @endforeach
                                    </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                    <br>
59 60
                    <div class="table-responsive">
                        <table id="datatable" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
Alfiro Pratama committed
61
                            <thead style="text-align: center; vertical-align: middle;">
62 63 64 65 66
                                <tr>
                                    <th>No</th>
                                    <th width="5%">Kode Kelompok</th>
                                    <th>Identitas Ketua</th>
                                    <th>Identitas Dosen Pembimbing</th>
67
                                    <th>Kategori PMW</th>
68
                                    <th>Judul Proposal</th>
69
                                    <th>Usulan Anggaran</th>
70 71 72 73 74 75 76 77
                                    <th>Status</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($proposal as $item)
                                @php $token = Str::random(30); @endphp
                                <tr id="row-{{ $token }}">
Alfiro Pratama committed
78 79
                                    <td style="text-align: center;">{{ $loop->iteration }}.</td>
                                    <td style="text-align: center;">{{ $item->rKelompok->kode }}</td>
80
                                    <td>{{ $item->rKelompok->rBiodata->name }} <br> {{ $item->rKelompok->rBiodata->noidentitas }} <br> {{ $item->rKelompok->rBiodata->fakultas }} <br> {{ $item->rKelompok->rBiodata->prodi }}</td>
Alfiro Pratama committed
81 82 83 84 85 86 87 88 89 90
                                    <td style="text-align: center;">{{ $item->rKelompok->nama_dosen }} <br> {{ $item->rKelompok->nidn_dosen }}</td>
                                    <td style="text-align: center;">{{ $item->rJenis->nama }}</td>
                                    <td style="text-align: center;">{{ $item->judul }}</td>
                                    <td style="text-align: center;">
                                        @if(substr(number_format($item->usulan_dana, 2, ',', '.'), -3) === ',00')
                                            Rp{{ substr(number_format($item->usulan_dana, 2, ',', '.'), 0, -3) }},-
                                        @else
                                            Rp{{ number_format($item->usulan_dana, 2, ',', '.') }}
                                        @endif
                                    </td>
91 92 93
                                    <td>
                                        @if(is_null($item->upload_dokumen))
                                            <span class="badge bg-danger">Belum Upload Proposal</span><br>
Alfiro Pratama committed
94
                                            <strong> Keterangan : </strong><br>
95 96
                                            Upload proposal pada : -<br>
                                            Disetujui proposal pada : -<br>
Muhammad Iskandar Java committed
97
                                        @else
98 99
                                            @if($item->status == '0')
                                                <span class="badge bg-warning">Menunggu Persetujuan Dosen</span><br>
Alfiro Pratama committed
100
                                                <strong> Keterangan : </strong><br>
101 102 103 104
                                                Upload proposal pada : <h6 class="text-primary"> {{ $item->date_upload }} </h6>
                                                Disetujui proposal pada : <h6 class="text-primary"> {{ $item->date_approval }} </h6>
                                            @elseif($item->status == '2')
                                                <span class="badge bg-danger">Ditolak Dosen</span><br>
Alfiro Pratama committed
105
                                                <strong> Keterangan : </strong><br>
106 107 108
                                                Upload proposal pada : <h6 class="text-primary"> {{ $item->date_upload }} </h6>
                                                Komentar : <h6 class="text-primary"> {{ $item->alasan_revisi }} </h6>
                                            @else
Alfiro Pratama committed
109
                                                <span class="badge bg-success">Sudah Disetujui Dosen</span><br>
110
                                                {{-- <span class="badge bg-warning">Menunggu Persetujuan Dosen</span> <br> --}}
Alfiro Pratama committed
111
                                                <strong> Keterangan : </strong><br>
112 113 114
                                                Upload proposal pada : <h6 class="text-primary"> {{ $item->date_upload }} </h6>
                                                Disetujui proposal pada : <h6 class="text-primary"> {{ $item->date_approval }} </h6>
                                            @endif
Muhammad Iskandar Java committed
115
                                        @endif
116
                                    </td>
Alfiro Pratama committed
117
                                    <td style="text-align: center;">
118
                                        <button data-bs-toggle="modal" data-bs-target="{{ '#lihat'.$item->proposal_id }}" href="{{ URL::to('mahasiswa/kelompok-new', encrypt($item->proposal_id)) }}" class="btn btn-info btn-sm"><i class="far fa-eye"></i> Lihat</button>
Muhammad Iskandar Java committed
119

120
                                        @if(is_null($item->status) || $item->status == '2')
Muhammad Iskandar Java committed
121
                                        <a href="{{ URL::to('mahasiswa/proposal/'.encrypt($item->proposal_id).'/edit') }}" class="btn btn-warning btn-sm">Revisi</a>
122 123
                                            <a onclick="hapus('{{ encrypt($item->proposal_id) }}', 'row-{{ $token }}')" class="btn btn-danger btn-sm">Hapus</a>
                                        @endif
Muhammad Iskandar Java committed
124

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                                        <div id="{{ 'lihat'.$item->proposal_id }}" class="modal fade" tabindex="-1" role="dialog"
                                            aria-labelledby="lihatLabel" aria-hidden="true">
                                            <div class="modal-dialog modal-lg modal-dialog-centered">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title" id="lihatLabel">Detail Proposal </h5>
                                                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                                    </div>
                                                    <div class="modal-body">
                                                        <p>
                                                            <div class="table-responsive">
                                                                <table class="table mb-0">
                                                                    <tr>
                                                                        <th>Judul Proposal</th>
                                                                        <td>{{ $item->judul }}</td>
                                                                    </tr>
                                                                    <tr>
142
                                                                        <th>Kategori PMW</th>
143 144 145 146 147 148
                                                                        <td>{{ $item->rJenis->nama }}</td>
                                                                    </tr>
                                                                    <tr>
                                                                        <th>Status</th>
                                                                        <td>
                                                                            @if(is_null($item->status) OR $item->status == '0')
Muhammad Iskandar Java committed
149
                                                                            <span class="badge bg-danger">Menunggu Persetujuan Dosen</span>
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
                                                                            @else
                                                                                <span class="badge bg-success">Sudah Disetujui Dosen</span>
                                                                            @endif
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <th>Proposal</th>
                                                                        <td>
                                                                            @if($item->upload_dokumen)
                                                                                <a href="https://statik.unesa.ac.id/simpmw/proposal/{{ $item->rPeriode->nama }}/{{ $item->upload_dokumen }}"  target="_blank" class="btn btn-success btn-sm"> <i class="far fa-eye"></i> Lihat Proposal</a>
                                                                                {{-- <iframe id="view-pdf" width="100%" height="400px" src="https://statik.unesa.ac.id/simpmw/proposal/{{ $item->rPeriode->nama }}/{{ $item->upload_dokumen }}" frameborder="0"></iframe> --}}
                                                                            @else
                                                                                <div class="alert alert-danger alert-dismissible fade show mb-0" role="alert">
                                                                                    <strong>Informasi!</strong> File tidak ditemukan.
                                                                                </div>
                                                                            @endif
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <th>Video Produk</th>
                                                                        <td>
                                                                            @if($item->upload_dokumen)
                                                                            {{-- @php
                                                                                @dd($item->rProposalUrl->url);
                                                                            @endphp --}}
                                                                                <button id="preview-video" class="btn btn-success btn-sm" data-video="{{ $item->rProposalUrl->url }}">
176
                                                                                {{-- <button id="preview-video" class="btn btn-success btn-sm" data-video="https://youtu.be/9CHu8iOsxDE?feature=shared"> --}}
177 178 179 180 181 182 183
                                                                                    <i class="far fa-eye"></i> Lihat Video
                                                                                </button>
                                                                            @else
                                                                                <div class="alert alert-danger alert-dismissible fade show mb-0" role="alert">
                                                                                    <strong>Informasi!</strong> File tidak ditemukan.
                                                                                </div>
                                                                            @endif
Muhammad Iskandar Java committed
184
                                                                        </td>
185 186 187 188 189
                                                                    </tr>
                                                                </table>
                                                            </div>
                                                        </p>
                                                    </div>
Muhammad Iskandar Java committed
190 191 192
                                                </div>
                                            </div>
                                        </div>
193 194 195 196 197 198
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
Muhammad Iskandar Java committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
                </div>
            </div>
        </div> <!-- end col -->
    </div> <!-- end row -->
@endsection

@section('js')
<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>
246 247

<!-- Kode JavaScript untuk Magnific Popup -->
Muhammad Iskandar Java committed
248 249 250
@if (count($proposal) > 0)
    <script>
    $(document).ready(function() {
Alfiro Pratama committed
251 252 253 254
    // Event handler untuk tombol "Lihat Video" dengan ID preview-video
    $('#preview-video').on('click', function() {
        var videoUrl = $(this).attr('data-video');
        // console.log(videoUrl);
255

Alfiro Pratama committed
256 257 258 259 260 261
        if (videoUrl) {
            // Buka video dalam Magnific Popup
            if (videoUrl.includes('youtu.be')) {
                // Konversi ke format youtube.com/watch?v=xxxxx
                videoUrl = videoUrl.replace('youtu.be/', 'youtube.com/watch?v=');
            }
Muhammad Iskandar Java committed
262

Alfiro Pratama committed
263 264 265 266 267 268
            // Menghapus parameter query dari URL
            if (videoUrl.includes('youtu.be')) {
                videoUrl = videoUrl.split('?')[0];
            } else if (videoUrl.includes('youtube.com/watch?v=')) {
                videoUrl = videoUrl.split('&')[0];
            }
269

Alfiro Pratama committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
            // Buka video dalam Magnific Popup jika valid, buka di tab baru jika tidak
            if (isValidYouTubeUrl(videoUrl)) {
                $.magnificPopup.open({
                    items: {
                        src: videoUrl
                    },
                    type: 'iframe',
                    iframe: {
                        markup: '<div class="mfp-iframe-scaler">'+
                                    '<div class="mfp-close"></div>'+
                                    '<iframe class="mfp-iframe" frameborder="0" allowfullscreen allow="autoplay"></iframe>'+
                                '</div>'
                    },
                    callbacks: {
                        open: function() {
                            // Sembunyikan modal lama saat Magnific Popup dibuka
                            $('#{{ 'lihat'.$item->proposal_id }}').modal('hide');
Muhammad Iskandar Java committed
287

Alfiro Pratama committed
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
                            // Mulai autoplay video setelah Magnific Popup dibuka
                            var iframe = this.content.find('iframe');
                            if (iframe.length > 0) {
                                var videoSrc = iframe.attr('src');
                                iframe.attr('src', videoSrc + '&autoplay=1'); // Tambahkan autoplay=1 ke URL video
                            }
                        },
                        close: function() {
                            // Tampilkan kembali modal lama setelah Magnific Popup ditutup
                            $('#{{ 'lihat'.$item->proposal_id }}').modal('show');

                            // Hentikan autoplay video saat Magnific Popup ditutup
                            var iframe = this.content.find('iframe');
                            if (iframe.length > 0) {
                                var videoSrc = iframe.attr('src');
                                iframe.attr('src', videoSrc.replace('&autoplay=1', '')); // Hapus autoplay=1 dari URL video
Muhammad Iskandar Java committed
304
                            }
305 306
                        }
                    }
Alfiro Pratama committed
307 308 309 310 311 312 313
                });
            } else {
                // Buka video di tab baru jika tidak valid
                window.open(videoUrl, '_blank');
            }
        } else {
            console.error('URL video tidak valid:', videoUrl);
Muhammad Iskandar Java committed
314 315
            }
        });
316

Alfiro Pratama committed
317 318 319 320 321 322 323
        function isValidYouTubeUrl(url) {
            // Lakukan validasi sederhana menggunakan ekspresi reguler
            return /^(http(s)?:\/\/)?((w){3}\.)?youtu(be|\.be)?(\.com)?\/.+/gm.test(url);
        }
    });

</script>
Muhammad Iskandar Java committed
324
@endif
325 326 327 328 329 330

{{-- <script>
    document.addEventListener("DOMContentLoaded", function() {
        var openModalBtn = document.getElementById("openModalBtn");
        var closeModalBtn = document.getElementById("closeModalBtn");
        var modal = document.getElementById("myModal");
Muhammad Iskandar Java committed
331

332 333
        openModalBtn.addEventListener("click", function() {
            modal.style.display = "block";
Muhammad Iskandar Java committed
334

335 336
            // Mengambil URL dari objek $item
            var proposalUrl = "{{ $item->rProposalUrl->url }}";
Muhammad Iskandar Java committed
337

338 339 340 341 342 343 344 345 346 347
            // Load konten eksternal ke dalam div modalContent
            var xhr = new XMLHttpRequest();
            xhr.open("GET", proposalUrl, true);
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    document.getElementById("externalContent").innerHTML = xhr.responseText;
                }
            };
            xhr.send();
        });
Muhammad Iskandar Java committed
348

349 350 351
        closeModalBtn.addEventListener("click", function() {
            modal.style.display = "none";
        });
Muhammad Iskandar Java committed
352

353 354 355 356 357 358 359
        window.addEventListener("click", function(event) {
            if (event.target == modal) {
                modal.style.display = "none";
            }
        });
    });
</script>     --}}
Muhammad Iskandar Java committed
360
@endsection