2024-04-17 11:40:27 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2024-05-04 11:49:35 +07:00
|
|
|
use App\Models\PengajuanPemutihan;
|
2024-04-17 11:40:27 +07:00
|
|
|
use App\Models\User;
|
2024-05-21 09:47:32 +07:00
|
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
|
|
use Carbon\Carbon;
|
2024-04-17 11:40:27 +07:00
|
|
|
use Illuminate\Http\Request;
|
2024-05-21 09:47:32 +07:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
2024-04-17 11:40:27 +07:00
|
|
|
|
2024-05-04 11:49:35 +07:00
|
|
|
class LayananPemutihanController extends Controller
|
2024-04-17 11:40:27 +07:00
|
|
|
{
|
|
|
|
|
2024-05-04 11:49:35 +07:00
|
|
|
public function index(){
|
2024-05-21 09:47:32 +07:00
|
|
|
$data = PengajuanPemutihan::
|
|
|
|
select(
|
|
|
|
'pengajuan_pemutihans.*',
|
|
|
|
'users.nama_gelar as dosen_pengampu',
|
|
|
|
)
|
2024-07-08 20:26:55 +07:00
|
|
|
->join('users','dosen_id','=','users.id')
|
|
|
|
->get();
|
2024-05-04 11:49:35 +07:00
|
|
|
return view('layanan-pemutihan.index',['title' => 'Pengajuan Pemutihan | Admin Dashboard','data' => $data]);
|
|
|
|
}
|
|
|
|
|
2024-04-17 11:40:27 +07:00
|
|
|
public function tambah(){
|
|
|
|
$dosen = User::role('Dosen')->get();
|
2024-05-04 11:49:35 +07:00
|
|
|
return view('layanan-pemutihan.tambah',['title' => 'Pengajuan Pemutihan','dosen' => $dosen]);
|
2024-04-17 11:40:27 +07:00
|
|
|
}
|
|
|
|
|
2024-05-04 11:49:35 +07:00
|
|
|
public function store(Request $request){
|
|
|
|
$request->validate([
|
|
|
|
'mata_kuliah'=>'required',
|
|
|
|
'ruang_kelas'=>'required',
|
|
|
|
'jurnal_kuliah'=>'required',
|
|
|
|
'dosen_pengampu'=>'required|numeric',
|
|
|
|
'program_studi'=>'required',
|
|
|
|
'tanggal_kelas'=>'required|date',
|
|
|
|
'jam_kelas'=>'required|date_format:H:i',
|
|
|
|
'alasan'=>'required',
|
|
|
|
'bukti_pemutihan'=>'required|mimes:pdf,jpg|max:4096',
|
|
|
|
|
|
|
|
],[
|
|
|
|
'dosen.numeric' => 'Dosen tidak valid, cek kembali Dosen yang dipilih',
|
|
|
|
'tanggal_kelas.date' => 'Tanggal Tidak Valid, Cek kembali tanggal perkuliahan yang anda masukkan',
|
|
|
|
'jam_kelas.date_format' => 'Jam tidak valid, cek kembali jam perkuliahan yang anda masukkan',
|
|
|
|
'bukti_pemutihan.mimes' => 'Format File tidak berupa file JPG / PDF, cek kembali file anda',
|
|
|
|
'bukti_pemutihan.max' => 'Ukuran File Anda lebih dari 4Mb, Cek Ulang File anda',
|
|
|
|
]);
|
2024-05-21 09:47:32 +07:00
|
|
|
//get lastid + 1
|
|
|
|
$countcaseid = PengajuanPemutihan::latest()->first()->id;
|
|
|
|
$caseid = "P".date_format(date_create(),"Y").$countcaseid+1;
|
2024-05-04 11:49:35 +07:00
|
|
|
|
2024-05-21 09:47:32 +07:00
|
|
|
$data_pemutihan['caseid'] = $caseid;
|
|
|
|
$data_pemutihan['mata_kuliah'] = $request->mata_kuliah;
|
|
|
|
$data_pemutihan['dosen_id'] = $request->dosen_pengampu;
|
|
|
|
$data_pemutihan['program_studi'] = $request->program_studi;
|
|
|
|
$data_pemutihan['ruang_kelas'] = $request->ruang_kelas;
|
|
|
|
$data_pemutihan['tanggal_kelas'] = $request->tanggal_kelas;
|
|
|
|
$data_pemutihan['jam_kelas'] = $request->jam_kelas;
|
|
|
|
$data_pemutihan['jurnal_kuliah'] = $request->jurnal_kuliah;
|
|
|
|
$data_pemutihan['alasan'] = $request->alasan;
|
|
|
|
$data_pemutihan['keterangan'] = $request->keterangan;
|
|
|
|
|
|
|
|
$bukti_pemutihan = $request->file('bukti_pemutihan');
|
2024-07-08 20:26:55 +07:00
|
|
|
$bukti_pemutihan_name = $caseid.'_'.str_replace(' ', '_',$bukti_pemutihan->getClientOriginalName());
|
|
|
|
$path = 'pemutihan/'.$bukti_pemutihan_name;
|
|
|
|
|
2024-05-21 09:47:32 +07:00
|
|
|
//jika berhasil save file dan save data mhs maka pengajuan akan diisi
|
|
|
|
if(Storage::disk('public')->put($path, file_get_contents($bukti_pemutihan))){
|
|
|
|
$data_pemutihan['bukti_izin_dosen'] = $bukti_pemutihan_name;
|
|
|
|
PengajuanPemutihan::create($data_pemutihan);
|
|
|
|
return redirect()->route('layanan-pemutihan.tambah')->with('success','Sukses Tambah Data, Silahkan Monitoring Pengajuan Anda melalui menu monitoring');
|
|
|
|
}
|
|
|
|
return redirect()->route('layanan-pemutihan.tambah')->with('error','Gagal Tambah data, Cek kembali data yang anda masukkan');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function cetak($caseid){
|
|
|
|
$data = PengajuanPemutihan::
|
|
|
|
select(
|
|
|
|
'pengajuan_pemutihans.*',
|
|
|
|
'users.nama_gelar as dosen_pengampu',
|
|
|
|
'users.nip as dosen_pengampu_nip',
|
|
|
|
)
|
|
|
|
->join('users','dosen_id','=','users.id')
|
|
|
|
->where('caseid',$caseid)
|
|
|
|
->first();
|
|
|
|
|
|
|
|
//jika data kosong maka render ini
|
|
|
|
if(is_null($data)){
|
|
|
|
return redirect()->route('monitoring.caseid',['caseid'=>$caseid])->with('error','Data Dengan CASEID Tersebut Tidak ada');
|
|
|
|
}
|
|
|
|
$tanggal_kelas = strtotime($data->tanggal_kelas);
|
|
|
|
$data_pdf = [
|
|
|
|
'title' => 'Form Berita Acara Perkuliahan dalam Kondisi Gangguan Sistem',
|
|
|
|
// 'date' => Carbon::now()->format('d-m-Y'),
|
|
|
|
'date' => $data->created_at->format('d-m-Y'),
|
|
|
|
'mata_kuliah' => $data->mata_kuliah,
|
|
|
|
'program_studi' => $data->program_studi,
|
|
|
|
'ruang_kelas' => $data->ruang_kelas,
|
|
|
|
'tanggal_kelas' => date('d-m-Y',$tanggal_kelas),
|
|
|
|
'jam_kelas' => $data->jam_kelas,
|
|
|
|
'jurnal_kuliah' => $data->jurnal_kuliah,
|
|
|
|
'alasan' => $data->alasan,
|
|
|
|
'keterangan' => $data->keterangan,
|
|
|
|
'dosen_pengampu' => $data->dosen_pengampu,
|
|
|
|
'dosen_pengampu_nip' => $data->dosen_pengampu_nip,
|
|
|
|
'dosen_pengampu_qrcode' => base64_encode(QrCode::size(100)->generate($data->dosen_pengampu.'_TTD_'.$data->created_at)),
|
|
|
|
];
|
|
|
|
$pdf = Pdf::loadView('layanan-pemutihan.cetak', $data_pdf);
|
|
|
|
return $pdf->setPaper('a4', 'potrait')->stream($caseid.'-Form Berita Acara Perkuliahan dalam Kondisi Gangguan Sistem.pdf');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function selesai($caseid, Request $request){
|
|
|
|
$data = PengajuanPemutihan::where('caseid', $caseid)->first();
|
|
|
|
if($data==null){
|
|
|
|
return redirect()->route('layanan-pemutihan.index')->with('error','Gagal Memproses, Data tidak ditemukan');
|
|
|
|
}
|
|
|
|
$data->status_operator = Carbon::now();
|
|
|
|
$data->save();
|
|
|
|
return redirect()->route('layanan-pemutihan.index')->with('success','Data Berhasil Disimpan, status akan diupdate menjadi selesai');
|
2024-07-08 20:26:55 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
function tolak($caseid, Request $request){
|
2024-05-04 11:49:35 +07:00
|
|
|
dd($request->all());
|
2024-07-08 20:26:55 +07:00
|
|
|
$data = PengajuanPemutihan::where('caseid', $caseid)->first();
|
|
|
|
if($data==null){
|
|
|
|
return redirect()->route('layanan-pemutihan.index')->with('error','Gagal Memproses, Data tidak ditemukan');
|
|
|
|
}
|
|
|
|
$data->status_operator = 0;
|
|
|
|
$data->save();
|
|
|
|
return redirect()->route('layanan-pemutihan.index')->with('success','Data Berhasil Disimpan, status akan diupdate menjadi selesai');
|
2024-05-04 11:49:35 +07:00
|
|
|
}
|
2024-04-17 11:40:27 +07:00
|
|
|
}
|