Commit ad07dac1 by novanbagus

tambahan download excel proposal

parent a9606001
<?php
namespace App\Exports;
use App\User;
use App\Models\Kota;
use App\Models\Provinsi;
use App\Models\Kecamatan;
use App\Models\Kelurahan;
use App\Models\Kuesioner;
use App\Models\UsersDetil;
use App\Models\KuesionerPage;
use App\Models\KuesionerField;
use App\Models\KuesionerAnswer;
use App\Models\KuesionerSection;
use Illuminate\Support\Facades\DB;
use App\Models\KuesionerAnswerDetil;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
class KelompokExport implements FromCollection,WithHeadings,ShouldAutoSize,WithTitle
{
/**
* @return \Illuminate\Support\Collection
*/
public function __construct($fakultas,$prodi,$lulusan,$group)
{
$this->fakultas = $fakultas;
$this->prodi = $prodi;
$this->lulusan = $lulusan;
$this->group = $group;
}
public function title(): string
{
return 'Users';
}
public function collection()
{
$statement = " IS_ACTIVE = '1' ";
if($this->fakultas != "0")
{
$statement .= " AND b.fakultas_id = '".$this->fakultas."'";
}
if($this->prodi != "0" && $this->prodi != "")
{
$statement .= " AND b.prodi_id = '".$this->prodi."'";
}
if($this->lulusan != "0")
{
$statement .= " AND b.tahun_lulus = '".$this->lulusan."'";
}
if($this->group != "0")
{
$statement .= " AND role = '".$this->group."'";
}
$data = User::join('users_detil as b', 'users.id', '=', 'b.users_id')
->join('users_group as e', 'users.role', '=', 'e.nama')
->leftjoin('fakultas as c', 'b.fakultas_id', '=', 'c.id')
->leftjoin('prodi as d', 'b.prodi_id', '=', 'd.id')
->whereRaw($statement)
->select('nim', 'users.email', 'users.name', 'c.nama as nama_fakultas', 'd.nama as nama_prodi', 'tahun_lulus', 'b.no_tlp')
->get();
return collect($data);
}
public function headings(): array
{
return ["NIM", "Email", "Nama", "Fakultas", "Prodi", "Lulusan", "No HP"];
}
}
<?php
namespace App\Exports;
use App\Models\DaftarProposal;
use Illuminate\Support\Facades\DB;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
class ProposalExport implements FromView,ShouldAutoSize
{
/**
* @return \Illuminate\Support\Collection
*/
public function __construct($jenis,$status,$tahun)
{
$this->jenis= $jenis;
$this->status = $status;
$this->tahun= $tahun;
}
public function view(): View
{
$data = DaftarProposal::with('rKelompokDetil')->get();
$result = [];
$no = 0;
foreach ($data as $key => $value) {
$dospem = "(".str_replace("###",") ",$value->identitas_dospem);
$url = "https://statik.unesa.ac.id/simpkm/proposal/".$value->periode."/".$value->upload_dokumen;
$urut = 1;
foreach ($value->rKelompokDetil as $keys => $detil) {
if($detil->status_ketua == '1')
{
$keanggotaan = "Ketua";
}
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++;
}
}
$datas['list_proposal'] = $result;
return view('backend.operator.proposal.excel', $datas);
}
}
...@@ -15,7 +15,9 @@ use App\Models\Jenis; ...@@ -15,7 +15,9 @@ use App\Models\Jenis;
use App\Models\Periode; use App\Models\Periode;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\DaftarProposal; use App\Models\DaftarProposal;
use App\Exports\ProposalExport;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;
class ProposalController extends Controller class ProposalController extends Controller
{ {
...@@ -193,4 +195,14 @@ class ProposalController extends Controller ...@@ -193,4 +195,14 @@ class ProposalController extends Controller
{ {
} }
public function cetak_proposal(Request $request)
{
ini_set('max_execution_time', 0);
$jenis = $request->jenis;
$status = $request->status;
$tahun= $request->tahun;
return Excel::download(new ProposalExport($jenis, $status, $tahun), 'proposal_export.xlsx');
}
} }
...@@ -13,4 +13,9 @@ class DaftarProposal extends Model ...@@ -13,4 +13,9 @@ class DaftarProposal extends Model
protected $fillable = [ protected $fillable = [
'proposal_id', 'jenis_id', 'kode', 'jenis_pkm', 'judul', 'status', 'status_hapus', 'status_administrasi_1', 'status_administrasi_2', 'nilai_1', 'nilai_2', 'reviewer_id_1', 'reviewer_id_2', 'status_final', 'nidn_reviewer_id_1', 'nidn_reviewer_id_2', 'upload_dokumen', 'date_upload', 'date_approval', 'identitas_ketua', 'identitas_dospem', 'periode' 'proposal_id', 'jenis_id', 'kode', 'jenis_pkm', 'judul', 'status', 'status_hapus', 'status_administrasi_1', 'status_administrasi_2', 'nilai_1', 'nilai_2', 'reviewer_id_1', 'reviewer_id_2', 'status_final', 'nidn_reviewer_id_1', 'nidn_reviewer_id_2', 'upload_dokumen', 'date_upload', 'date_approval', 'identitas_ketua', 'identitas_dospem', 'periode'
]; ];
public function rKelompokDetil()
{
return $this->hasMany(\App\Models\KelompokDetail::class, 'kelompok_id', 'kelompok_id');
}
} }
...@@ -188,15 +188,5 @@ ...@@ -188,15 +188,5 @@
}); });
}); });
function cetak() {
var _token = $('input[name="_token"]').val();
var fakultas = $("#reqFakultas").val();
var prodi = $("#reqProdi").val();
var lulusan = $("#reqLulusan").val();
var group = $("#reqGroup").val();
window.open('{{url("/admin/cetak_users/")}}?fakultas='+fakultas+'&prodi='+prodi+'&lulusan='+lulusan+'&group='+group+'&_token='+_token, '_blank');
};
</script> </script>
@endsection @endsection
<table border="1">
<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>Jenis PKM</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>
</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>
</tr>
@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>
</tr>
@endif
@php
$tempKode = $proposal['kode'];
@endphp
@endforeach
</tbody>
</table>
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
<li class="breadcrumb-item">{!! $title !!}</li> <li class="breadcrumb-item">{!! $title !!}</li>
</ol> </ol>
</div> </div>
{{-- <div class="col-md-4"> <div class="col-md-4">
<div class="float-end d-none d-md-block"> <div class="float-end d-none d-md-block">
<a href="{{ URL::to('operator/user-external/create') }}" type="button" class="btn btn-primary waves-effect waves-light"> <i class="fas fa-plus-circle"></i> Tambah Data</a> <button onclick="cetak()" class="btn btn-primary waves-effect waves-light"> <i class="fas fa-file-excel"></i> Unduh</button>
</div>
</div> </div>
</div> --}}
</div> </div>
</div> </div>
<!-- end page title --> <!-- end page title -->
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
{!! csrf_field() !!}
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<div class="row"> <div class="row">
...@@ -178,5 +179,14 @@ ...@@ -178,5 +179,14 @@
}); });
}); });
function cetak() {
var _token = $('input[name="_token"]').val();
var jenis = $("#reqJenisPkm").val();
var status = $("#reqStatus").val();
var tahun = $("#reqTahun").val();
window.open('{{url("/operator/cetak-proposal/")}}?jenis='+jenis+'&tahun='+tahun+'&status='+status+'&_token='+_token, '_blank');
};
</script> </script>
@endsection @endsection
...@@ -142,11 +142,11 @@ Route::group(['middleware' => ['auth:sanctum', 'verified']], function () { ...@@ -142,11 +142,11 @@ Route::group(['middleware' => ['auth:sanctum', 'verified']], function () {
Route::resource('kelompok', KelompokController::class); Route::resource('kelompok', KelompokController::class);
Route::get('getKelompok', [KelompokController::class, 'getData'])->name('getKelompok'); Route::get('getKelompok', [KelompokController::class, 'getData'])->name('getKelompok');
Route::get('getDetilKelompok', [KelompokController::class, 'getDetil'])->name('getDetilKelompok'); Route::get('getDetilKelompok', [KelompokController::class, 'getDetil'])->name('getDetilKelompok');
Route::get('cetak_kelompok', [KelompokController::class, 'cetak_kelompok'])->name('cetak_users');
Route::resource('proposal', ProposalController::class); Route::resource('proposal', ProposalController::class);
Route::get('getProposal', [ProposalController::class, 'getData'])->name('getProposal'); Route::get('getProposal', [ProposalController::class, 'getData'])->name('getProposal');
Route::get('getDetilProposal', [ProposalController::class, 'getDetil'])->name('getDetilProposal'); Route::get('getDetilProposal', [ProposalController::class, 'getDetil'])->name('getDetilProposal');
Route::get('cetak-proposal', [ProposalController::class, 'cetak_proposal'])->name('cetak-proposal');
Route::resource('jenis', JenisController::class); Route::resource('jenis', JenisController::class);
Route::get('getJenis', [JenisController::class, 'getData'])->name('getJenis'); Route::get('getJenis', [JenisController::class, 'getData'])->name('getJenis');
......
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