Commit 7182a9bd by Alfiro Pratama

Unduh Excel (Proposal - Operator)

parent bc7867ef
......@@ -27,56 +27,65 @@ class ProposalExport implements FromView,ShouldAutoSize
if($this->jenis != "0")
{
$statement .= " AND jenis_id = '".$this->jenis."'";
$statement .= " AND jenis_id = '{$this->jenis}'";
}
if($this->status != "0")
{
// dikurang 1 karena di view mulai dari 0 sedangkan 0 itu menunggu persetujuan
$status = $this->status - 1;
$statement .= " AND STATUS = '".$status."'";
$statement .= " AND STATUS = '{$status}'";
}
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 = [];
$no = 0;
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;
$urut = 1;
foreach ($value->rKelompokDetil as $keys => $detil) {
if($detil->status_ketua == '1')
{
$row = [
'kode' => $value->kode,
'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";
}
else
{
$keanggotaan = "Anggota ".$urut;
} else {
$keanggotaan = "Anggota " . $urut;
$urut++;
}
$result[$no]['rowspan'] = count($value->rKelompokDetil);
$result[$no]['kode'] = $value->kode;
$result[$no]['jenis'] = $value->jenis_pkm;
$result[$no]['fak'] = $detil->fakultas;
$result[$no]['nama'] = $detil->nama;
$result[$no]['nim'] = $detil->nim;
$result[$no]['keanggotaan'] = $keanggotaan;
$result[$no]['judul'] = $value->judul;
$result[$no]['dospem'] = $dospem;
$result[$no]['link'] = $url;
$no++;
$row['kelompok'][] = [
'fak' => $detil->fakultas,
'nama' => $detil->nama,
'nim' => $detil->nim,
'keanggotaan' => $keanggotaan,
];
}
$result[] = $row;
}
$datas['list_proposal'] = $result;
......
......@@ -19,6 +19,7 @@ use App\Models\DaftarProposal;
use App\Exports\ProposalExport;
use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Log;
class ProposalController extends Controller
{
......@@ -115,7 +116,7 @@ class ProposalController extends Controller
if($status == '1')
{
$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')
{
......@@ -125,11 +126,11 @@ class ProposalController extends Controller
else
{
$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'>Disetujui Dosen Pada : ".$date_approval." WIB</span>";
......@@ -218,7 +219,26 @@ class ProposalController extends Controller
$status = $request->status;
$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)
......
......@@ -88,7 +88,7 @@
<div class="col-sm-10 col-lg-10">
<div class="input-group">
<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>
<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>
......
<table border="1">
{{-- <!DOCTYPE html>
<html>
<body> --}}
<table>
<thead>
<tr>
<td style="border: 1px solid #000000;"><strong>No</strong></td>
<td style="border: 1px solid #000000;"><strong>Kode Kelompok</strong></td>
<td style="border: 1px solid #000000;"><strong>Kategori PMW</strong></td>
<td style="border: 1px solid #000000;"><strong>Fak.</strong></td>
<td style="border: 1px solid #000000;"><strong>Nama</strong></td>
<td style="border: 1px solid #000000;"><strong>NIM</strong></td>
<td style="border: 1px solid #000000;"><strong>Ketua/Anggota</strong></td>
<td style="border: 1px solid #000000;"><strong>Judul Proposal</strong></td>
<td style="border: 1px solid #000000;"><strong>Dosen Pembimbing</strong></td>
<td style="border: 1px solid #000000;"><strong>Link Proposal</strong></td>
<th colspan="3" style="font-size: 16;"><strong>DAFTAR PROPOSAL PMW MAHASISWA UNESA</strong></th>
<th></th>
<th></th>
<th><strong>Keterangan :</strong></th>
<th style="background-color: yellow; border: 1px solid black;"></th>
<th colspan="2"><strong>(Menunggu Persetujuan Dosen Pembimbing)</strong></th>
</tr>
</thead>
<tbody>
<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>
</thead>
<tbody>
@php
$no = 1;
$tempKode = '';
@endphp
@foreach ($list_proposal as $proposal)
@if($tempKode != $proposal['kode'])
<tr>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $no++ }}</th>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['kode'] }}</th>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['jenis'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['fak'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['nama'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['nim'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['keanggotaan'] }}</th>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['judul'] }}</th>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;">{{ $proposal['dospem'] }}</th>
<th rowspan="{{ $proposal['rowspan'] }}" style="vertical-align: top; border: 1px solid #000000;"><a href="{{ $proposal['link'] }}" target="_blank">Link</a></th>
{{-- @php
$bgColor = '';
if ($proposal['status'] == 2) {
$bgColor = "background-color: #FF0000";
} elseif ($proposal['status'] == 0) {
$bgColor = "background-color: #FFFF00";
}
@endphp --}}
@if ($proposal['status'] == 2)
<tr>
<td rowspan="{{ count($proposal['kelompok']) }}" style="background-color: red; vertical-align: top; text-align: right; border: 1px solid black;">{{ $no++ }}</td>
<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>
@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
<tr valign="top">
<th style="border: 1px solid #000000;">{{ $proposal['fak'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['nama'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['nim'] }}</th>
<th style="border: 1px solid #000000;">{{ $proposal['keanggotaan'] }}</th>
Rp{{ number_format($proposal['usulan'], 2, ',', '.') }}
@endif
</td>
<td rowspan="{{ count($proposal['kelompok']) }}" style="vertical-align: top; border: 1px solid black;">{!! nl2br(e($proposal['dospem'])) !!}</td>
<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>
@endif
@php
$tempKode = $proposal['kode'];
@endphp
@endforeach
@endif
@endforeach
</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