Commit 7182a9bd by Alfiro Pratama

Unduh Excel (Proposal - Operator)

parent bc7867ef
...@@ -27,56 +27,65 @@ class ProposalExport implements FromView,ShouldAutoSize ...@@ -27,56 +27,65 @@ class ProposalExport implements FromView,ShouldAutoSize
if($this->jenis != "0") if($this->jenis != "0")
{ {
$statement .= " AND jenis_id = '".$this->jenis."'"; $statement .= " AND jenis_id = '{$this->jenis}'";
} }
if($this->status != "0") if($this->status != "0")
{ {
// dikurang 1 karena di view mulai dari 0 sedangkan 0 itu menunggu persetujuan // dikurang 1 karena di view mulai dari 0 sedangkan 0 itu menunggu persetujuan
$status = $this->status - 1; $status = $this->status - 1;
$statement .= " AND STATUS = '".$status."'"; $statement .= " AND STATUS = '{$status}'";
} }
if($this->tahun != "0") if($this->tahun != "0")
{ {
$statement .= " AND PERIODE = '".$this->tahun."'"; $statement .= " AND PERIODE = '{$this->tahun}'";
} }
$data = DaftarProposal::with('rKelompokDetil')->whereRaw($statement)->get(); $data = DaftarProposal::with('rKelompokDetil')
->whereRaw($statement)
->orderBy('kode', 'ASC')
->get();
$result = []; $result = [];
$no = 0; $no = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$dospem = "(".str_replace("###",") ",$value->identitas_dospem); $dospem = str_replace("###","\n",$value->identitas_dospem);
$url = "https://statik.unesa.ac.id/simpmw/proposal/".$value->periode."/".$value->upload_dokumen; $url = "https://statik.unesa.ac.id/simpmw/proposal/".$value->periode."/".$value->upload_dokumen;
$urut = 1; $urut = 1;
foreach ($value->rKelompokDetil as $keys => $detil) { $row = [
'kode' => $value->kode,
if($detil->status_ketua == '1') 'jenis' => $value->jenis_pkm,
{ 'judul' => $value->judul,
'usulan' => $value->usulan_dana,
'dospem' => $dospem,
'link' => $url,
'video' => $value->url,
'periode' => $value->periode,
'status' => $value->status,
'kelompok' => [],
];
foreach ($value->rKelompokDetil as $detil) {
if ($detil->status_ketua == '1') {
$keanggotaan = "Ketua"; $keanggotaan = "Ketua";
} } else {
else $keanggotaan = "Anggota " . $urut;
{
$keanggotaan = "Anggota ".$urut;
$urut++; $urut++;
} }
$result[$no]['rowspan'] = count($value->rKelompokDetil); $row['kelompok'][] = [
$result[$no]['kode'] = $value->kode; 'fak' => $detil->fakultas,
$result[$no]['jenis'] = $value->jenis_pkm; 'nama' => $detil->nama,
$result[$no]['fak'] = $detil->fakultas; 'nim' => $detil->nim,
$result[$no]['nama'] = $detil->nama; 'keanggotaan' => $keanggotaan,
$result[$no]['nim'] = $detil->nim; ];
$result[$no]['keanggotaan'] = $keanggotaan;
$result[$no]['judul'] = $value->judul;
$result[$no]['dospem'] = $dospem;
$result[$no]['link'] = $url;
$no++;
} }
$result[] = $row;
} }
$datas['list_proposal'] = $result; $datas['list_proposal'] = $result;
......
...@@ -19,6 +19,7 @@ use App\Models\DaftarProposal; ...@@ -19,6 +19,7 @@ use App\Models\DaftarProposal;
use App\Exports\ProposalExport; use App\Exports\ProposalExport;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Log;
class ProposalController extends Controller class ProposalController extends Controller
{ {
...@@ -115,7 +116,7 @@ class ProposalController extends Controller ...@@ -115,7 +116,7 @@ class ProposalController extends Controller
if($status == '1') if($status == '1')
{ {
$keterangan = '<span class="badge bg-success">Disetujui Dosen</span>'; $keterangan = '<span class="badge bg-success">Disetujui Dosen</span>';
$aksi = '<a class="btn btn-warning btn-sm waves-effect waves-light aksi" role="button" data-ket="Proposal Kelompok yang dibatalkan status diterima akan otomatis menjadi status ditolak agar dapat menunggah ulang Proposal." data-id="'.Crypt::encrypt($proposal_id.'#2').'"><i class="fas fa-undo"></i></a>'; $aksi = '<a class="btn btn-warning btn-sm waves-effect waves-light aksi" role="button" data-toggle="tooltip" data-placement="bottom" title="Batalkan Status" data-ket="Proposal Kelompok yang dibatalkan status diterima akan otomatis menjadi status ditolak agar dapat menunggah ulang Proposal." data-id="'.Crypt::encrypt($proposal_id.'#2').'"><i class="fas fa-undo"></i></a>';
} }
elseif($status == '2') elseif($status == '2')
{ {
...@@ -125,11 +126,11 @@ class ProposalController extends Controller ...@@ -125,11 +126,11 @@ class ProposalController extends Controller
else else
{ {
$keterangan = '<span class="badge bg-warning">Menunggu Persetujuan Dosen</span>'; $keterangan = '<span class="badge bg-warning">Menunggu Persetujuan Dosen</span>';
$aksi = '<a class="btn btn-success btn-sm waves-effect waves-light aksi" role="button" data-ket="Proposal Kelompok disetujui" data-id="'.Crypt::encrypt($proposal_id.'#1').'"><i class="fas fa-check"></i></a> <a class="btn btn-danger btn-sm waves-effect waves-light aksi" role="button" data-ket="Proposal Kelompok ditolak" data-id="'.Crypt::encrypt($proposal_id.'#2').'"><i class="fas fa-times"></i></a>'; $aksi = '<a class="btn btn-success btn-sm waves-effect waves-light aksi" role="button" data-toggle="tooltip" data-placement="bottom" title="Setujui Proposal" data-ket="Proposal Kelompok disetujui" data-id="'.Crypt::encrypt($proposal_id.'#1').'"><i class="fas fa-check"></i></a> <a class="btn btn-danger btn-sm waves-effect waves-light aksi" role="button" data-toggle="tooltip" data-placement="bottom" title="Tolak Proposal" data-ket="Proposal Kelompok ditolak" data-id="'.Crypt::encrypt($proposal_id.'#2').'"><i class="fas fa-times"></i></a>';
} }
} }
$aksi .= ' <a href="'.$url.'" target="_blank" class="btn btn-primary btn-sm waves-effect waves-light" role="button"><i class="fas fa-search"></i></a>'; $aksi .= ' <a href="'.$url.'" target="_blank" class="btn btn-primary btn-sm waves-effect waves-light" role="button"data-toggle="tooltip" data-placement="bottom" title="Lihat Proposal"><i class="fas fa-search"></i></a>';
$keterangan .= "<br><span class='badge bg-info'>Upload Proposal Pada : ".$date_upload." WIB</span>"; $keterangan .= "<br><span class='badge bg-info'>Upload Proposal Pada : ".$date_upload." WIB</span>";
$keterangan .= "<br><span class='badge bg-info'>Disetujui Dosen Pada : ".$date_approval." WIB</span>"; $keterangan .= "<br><span class='badge bg-info'>Disetujui Dosen Pada : ".$date_approval." WIB</span>";
...@@ -218,7 +219,26 @@ class ProposalController extends Controller ...@@ -218,7 +219,26 @@ class ProposalController extends Controller
$status = $request->status; $status = $request->status;
$tahun= $request->tahun; $tahun= $request->tahun;
return Excel::download(new ProposalExport($jenis, $status, $tahun), 'proposal_export.xlsx'); // $export = new ProposalExport($jenis, $status, $tahun);
// return Excel::download(new ProposalExport($jenis, $status, $tahun), 'proposal_export.xlsx');
// return $export->view();
// Mulai pencatatan waktu
$startTime = microtime(true);
// Ekspor ke Excel
$response = Excel::download(new ProposalExport($jenis, $status, $tahun), 'daftar-proposal-pmw-'.$tahun.'_export.xlsx');
// Akhir pencatatan waktu
$endTime = microtime(true);
// Hitung waktu yang dibutuhkan dalam detik
$executionTime = $endTime - $startTime;
// Log waktu yang dibutuhkan
Log::info('Waktu yang dibutuhkan untuk proses ekspor: ' . $executionTime . ' detik');
return $response;
} }
public function prosesProposal(Request $request) public function prosesProposal(Request $request)
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<div class="col-sm-10 col-lg-10"> <div class="col-sm-10 col-lg-10">
<div class="input-group"> <div class="input-group">
<span class="input-group-text">Rp</span> <span class="input-group-text">Rp</span>
<input class="form-control" type="text" id="usulan_dana" name="usulan_dana" value="{{ old('usulan_dana') }}" placeholder="Dana yang ingin diajukan (cth: 950000 atau 950000.50 tanda (.) hanya untuk nominal desimal)" required onkeypress="return isNumberKey(event)" onkeyup="formatRupiah(this)"> <input class="form-control" type="text" id="usulan_dana" name="usulan_dana" value="{{ old('usulan_dana') }}" placeholder="Dana yang ingin diajukan (cth: 950000 atau 950000.50 | tanda (.) hanya untuk nominal desimal)" required onkeypress="return isNumberKey(event)" onkeyup="formatRupiah(this)">
</div> </div>
<small id="invalidInput" class="text-danger" style="display: none;">Harap masukkan angka atau desimal (contoh: 950000 atau 950000.50)</small> <small id="invalidInput" class="text-danger" style="display: none;">Harap masukkan angka atau desimal (contoh: 950000 atau 950000.50)</small>
<small id="dotWarning" style="display: none; color: red;">Simbol titik (.) tidak boleh diinputkan lebih dari 1</small> <small id="dotWarning" style="display: none; color: red;">Simbol titik (.) tidak boleh diinputkan lebih dari 1</small>
......
<table border="1"> {{-- <!DOCTYPE html>
<html>
<body> --}}
<table>
<thead> <thead>
<tr> <tr>
<td style="border: 1px solid #000000;"><strong>No</strong></td> <th colspan="3" style="font-size: 16;"><strong>DAFTAR PROPOSAL PMW MAHASISWA UNESA</strong></th>
<td style="border: 1px solid #000000;"><strong>Kode Kelompok</strong></td> <th></th>
<td style="border: 1px solid #000000;"><strong>Kategori PMW</strong></td> <th></th>
<td style="border: 1px solid #000000;"><strong>Fak.</strong></td> <th><strong>Keterangan :</strong></th>
<td style="border: 1px solid #000000;"><strong>Nama</strong></td> <th style="background-color: yellow; border: 1px solid black;"></th>
<td style="border: 1px solid #000000;"><strong>NIM</strong></td> <th colspan="2"><strong>(Menunggu Persetujuan Dosen Pembimbing)</strong></th>
<td style="border: 1px solid #000000;"><strong>Ketua/Anggota</strong></td> </tr>
<td style="border: 1px solid #000000;"><strong>Judul Proposal</strong></td> </thead>
<td style="border: 1px solid #000000;"><strong>Dosen Pembimbing</strong></td> <tbody>
<td style="border: 1px solid #000000;"><strong>Link Proposal</strong></td> <tr>
<td colspan="3" style="font-size: 14;"><strong>Periode : {{ $list_proposal[0]['periode'] }}</strong></td>
<td></td>
<td></td>
<td></td>
<td style="background-color: red; border: 1px solid black;"></td>
<td colspan="2"><strong>(Ditolak oleh Dosen Pembimbing)</strong></td>
</tr>
</tbody>
</table><br>
<table border="1">
<thead>
<tr>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>No.</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Kode Kelompok</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Kategori PMW</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Fakultas</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Nama</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>NIM</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Keanggotaan</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Judul Proposal</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Usulan Dana</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Dosen Pembimbing</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Link Proposal</strong></th>
<th valign="middle" style="background-color: orange; text-align: center; border: 1px solid black;"><strong>Link Video Produk</strong></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@php @php
$no = 1; $no = 1;
$tempKode = '';
@endphp @endphp
@foreach ($list_proposal as $proposal) @foreach ($list_proposal as $proposal)
@if($tempKode != $proposal['kode']) {{-- @php
<tr> $bgColor = '';
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $no++ }}</th> if ($proposal['status'] == 2) {
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['kode'] }}</th> $bgColor = "background-color: #FF0000";
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['jenis'] }}</th> } elseif ($proposal['status'] == 0) {
<th style="border: 1px solid #000000;">{{ $proposal['fak'] }}</th> $bgColor = "background-color: #FFFF00";
<th style="border: 1px solid #000000;">{{ $proposal['nama'] }}</th> }
<th style="border: 1px solid #000000;">{{ $proposal['nim'] }}</th> @endphp --}}
<th style="border: 1px solid #000000;">{{ $proposal['keanggotaan'] }}</th> @if ($proposal['status'] == 2)
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['judul'] }}</th> <tr>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['dospem'] }}</th> <td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: right; border: 1px solid black;">{{ $no++ }}</td>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;"><a href="{{ $proposal['link'] }}" target="_blank">Link</a></th> <td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: center; border: 1px solid black;">{{ $proposal['kode'] }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: center; border: 1px solid black;">{{ $proposal['jenis'] }}</td>
<td valign="middle" style="background-color: red; text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['fak'] }}</td>
<td valign="middle" style="background-color: red; border: 1px solid black;">{{ ucwords($proposal['kelompok'][0]['nama']) }}</td>
<td valign="middle" style="background-color: red; text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['nim'] }}</td>
<td valign="middle" style="background-color: red; text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['keanggotaan'] }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; border: 1px solid black;">{{ ucwords($proposal['judul']) }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: right; border: 1px solid black;">
@if(substr(number_format($proposal['usulan'], 2, ',', '.'), -3) === ',00')
Rp{{ substr(number_format($proposal['usulan'], 2, ',', '.'), 0, -3) }},-
@else
Rp{{ number_format($proposal['usulan'], 2, ',', '.') }}
@endif
</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; border: 1px solid black;">{!! nl2br(e($proposal['dospem'])) !!}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: center; border: 1px solid black;"><a href="{{ $proposal['link'] }}" target="_blank">Link</a></td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: center; border: 1px solid black;"><a href="{{ $proposal['video'] }}" target="_blank">Link Video</a></td>
</tr>
@foreach ($proposal['kelompok'] as $key => $member)
@if ($key != 0)
<tr>
<td valign="middle" style="background-color: red; text-align: center; border: 1px solid black;">{{ $member['fak'] }}</td>
<td valign="middle" style="background-color: red; border: 1px solid black;">{{ ucwords($member['nama']) }}</td>
<td valign="middle" style="background-color: red; text-align: center; border: 1px solid black;">{{ $member['nim'] }}</td>
<td valign="middle" style="background-color: red; text-align: center; border: 1px solid black;">{{ $member['keanggotaan'] }}</td>
</tr>
@endif
@endforeach
@elseif ($proposal['status'] == 0)
<tr>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; text-align: right; border: 1px solid black;">{{ $no++ }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; text-align: center; border: 1px solid black;">{{ $proposal['kode'] }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; text-align: center; border: 1px solid black;">{{ $proposal['jenis'] }}</td>
<td valign="middle" style="background-color: yellow; text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['fak'] }}</td>
<td valign="middle" style="background-color: yellow; border: 1px solid black;">{{ ucwords($proposal['kelompok'][0]['nama']) }}</td>
<td valign="middle" style="background-color: yellow; text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['nim'] }}</td>
<td valign="middle" style="background-color: yellow; text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['keanggotaan'] }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; border: 1px solid black;">{{ ucwords($proposal['judul']) }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; text-align: right; border: 1px solid black;">
@if(substr(number_format($proposal['usulan'], 2, ',', '.'), -3) === ',00')
Rp{{ substr(number_format($proposal['usulan'], 2, ',', '.'), 0, -3) }},-
@else
Rp{{ number_format($proposal['usulan'], 2, ',', '.') }}
@endif
</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; border: 1px solid black;">{!! nl2br(e($proposal['dospem'])) !!}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; text-align: center; border: 1px solid black;"><a href="{{ $proposal['link'] }}" target="_blank">Link</a></td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: yellow; vertical-align: top; text-align: center; border: 1px solid black;"><a href="{{ $proposal['video'] }}" target="_blank">Link Video</a></td>
</tr>
@foreach ($proposal['kelompok'] as $key => $member)
@if ($key != 0)
<tr>
<td valign="middle" style="background-color: yellow; text-align: center; border: 1px solid black;">{{ $member['fak'] }}</td>
<td valign="middle" style="background-color: yellow; border: 1px solid black;">{{ ucwords($member['nama']) }}</td>
<td valign="middle" style="background-color: yellow; text-align: center; border: 1px solid black;">{{ $member['nim'] }}</td>
<td valign="middle" style="background-color: yellow; text-align: center; border: 1px solid black;">{{ $member['keanggotaan'] }}</td>
</tr> </tr>
@endif
@endforeach
@else
<tr>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; text-align: right; border: 1px solid black;">{{ $no++ }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; text-align: center; border: 1px solid black;">{{ $proposal['kode'] }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; text-align: center; border: 1px solid black;">{{ $proposal['jenis'] }}</td>
<td valign="middle" style="text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['fak'] }}</td>
<td valign="middle" style="border: 1px solid black;">{{ ucwords($proposal['kelompok'][0]['nama']) }}</td>
<td valign="middle" style="text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['nim'] }}</td>
<td valign="middle" style="text-align: center; border: 1px solid black;">{{ $proposal['kelompok'][0]['keanggotaan'] }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; border: 1px solid black;">{{ ucwords($proposal['judul']) }}</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; text-align: right; border: 1px solid black;">
@if(substr(number_format($proposal['usulan'], 2, ',', '.'), -3) === ',00')
Rp{{ substr(number_format($proposal['usulan'], 2, ',', '.'), 0, -3) }},-
@else @else
<tr valign="top"> Rp{{ number_format($proposal['usulan'], 2, ',', '.') }}
<th style="border: 1px solid #000000;">{{ $proposal['fak'] }}</th> @endif
<th style="border: 1px solid #000000;">{{ $proposal['nama'] }}</th> </td>
<th style="border: 1px solid #000000;">{{ $proposal['nim'] }}</th> <td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; border: 1px solid black;">{!! nl2br(e($proposal['dospem'])) !!}</td>
<th style="border: 1px solid #000000;">{{ $proposal['keanggotaan'] }}</th> <td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; text-align: center; border: 1px solid black;"><a href="{{ $proposal['link'] }}" target="_blank">Link</a></td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; text-align: center; border: 1px solid black;"><a href="{{ $proposal['video'] }}" target="_blank">Link Video</a></td>
</tr>
@foreach ($proposal['kelompok'] as $key => $member)
@if ($key != 0)
<tr>
<td valign="middle" style="text-align: center; border: 1px solid black;">{{ $member['fak'] }}</td>
<td valign="middle" style="border: 1px solid black;">{{ ucwords($member['nama']) }}</td>
<td valign="middle" style="text-align: center; border: 1px solid black;">{{ $member['nim'] }}</td>
<td valign="middle" style="text-align: center; border: 1px solid black;">{{ $member['keanggotaan'] }}</td>
</tr> </tr>
@endif @endif
@php @endforeach
$tempKode = $proposal['kode']; @endif
@endphp
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
{{-- </body>
</html> --}}
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