diff --git a/app/Http/Controllers/KuesionerController.php b/app/Http/Controllers/KuesionerController.php index dbea891..6a032a4 100644 --- a/app/Http/Controllers/KuesionerController.php +++ b/app/Http/Controllers/KuesionerController.php @@ -365,6 +365,7 @@ class KuesionerController extends Controller $insert->pihak_kegiatan_lingkungan = json_encode(@$pihakKegiatanFormatted); $insert->tahun = date('Y'); $insert->link_sk_adiwiyata = @$request->link_sk_adiwiyata; + $insert->tahun_penghargaan = @$request->tahun_penghargaan; $insert->tim_adiwiyata_nomor_sk = @$request->tim_adiwiyata_nomor_sk; $insert->tim_adiwiyata_link = @$request->tim_adiwiyata_link; $insert->save(); diff --git a/app/Http/Controllers/Modules/Usulan/CSAPController.php b/app/Http/Controllers/Modules/Usulan/CSAPController.php index 179c27b..063543a 100644 --- a/app/Http/Controllers/Modules/Usulan/CSAPController.php +++ b/app/Http/Controllers/Modules/Usulan/CSAPController.php @@ -6,6 +6,11 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\Master\Provinsi; use App\Models\Kuesioner; +use App\Models\KuesionerLog; +use App\Models\Master\Sekolah; +use App\Models\Master\FormKriteria; +use App\Models\DokumenAdministrasi; +use App\Models\Penilaian; class CSAPController extends Controller { @@ -25,6 +30,52 @@ class CSAPController extends Controller return view($this->template.'.index',$data); } + public function update($id) + { + $keyId = decode_id($id); + $data['kuesioner'] = Kuesioner::where('ms_sekolah_id',$keyId)->where('tahun',date('Y'))->first(); + $data['sekolah'] = Sekolah::find($keyId); + $data['route'] = $this->route; + $data['title'] = $this->title; + $data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray(); + + $jumlah = json_decode($data['sekolah']->profile->data_jumlah); + $data['jumlah_peserta_didik'] = @$jumlah->jumlah_peserta_didik; + $data['jumlah_tenaga_pendidik'] = @$jumlah->jumlah_tenaga_pendidik; + $data['jumlah_tenaga_kependidikan'] = @$jumlah->jumlah_tenaga_kependidikan; + $data['jumlah_warga_sekolah_lainnya'] = @$jumlah->jumlah_warga_sekolah_lainnya; + $data['jumlah_biopori'] = @$jumlah->jumlah_biopori; + $data['jumlah_sumur_resapan'] = @$jumlah->jumlah_sumur_resapan; + $data['jumlah_pohon'] = @$jumlah->jumlah_pohon; + + $air = json_decode($data['sekolah']->profile->penghematan_air); + $data['air_sebelum_pblhs'] = @$air->air_sebelum_pblhs; + $data['air_setelah_pblhs'] = @$air->air_setelah_pblhs; + + $listrik = json_decode($data['sekolah']->profile->penghematan_listrik); + $data['listrik_sebelum_pblhs'] = @$listrik->listrik_sebelum_pblhs; + $data['listrik_setelah_pblhs'] = @$listrik->listrik_setelah_pblhs; + $data['luas_ruangan_ac'] = @$listrik->luas_ruangan_ac; + $data['luas_ruangan_non_ac'] = @$listrik->luas_ruangan_non_ac; + $data['jumlah_kader'] = @$listrik->jumlah_kader; + + $data['dokumen'] = DokumenAdministrasi::where('ms_sekolah_id',$keyId)->where('tahun',date('Y'))->first(); + + return view($this->template.'.form',$data); + } + public function resume($id) + { + // permission('is_read', $this->route, 'module',true); + + $data['title'] = $this->title; + $data['route'] = $this->route; + $keyId = decode_id($id); + $data['sekolah'] = Sekolah::find($keyId); + $data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray(); + + return view($this->template.'.resume',$data); + } + public function grid(Request $request) { $kuesioner = Kuesioner::where('level',1)->orderBy('created_at','DESC')->get(); @@ -33,7 +84,7 @@ class CSAPController extends Controller $action = ''; if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){ - $action .= ''; + $action .= ''; } if($row->level == 0){ @@ -48,6 +99,11 @@ class CSAPController extends Controller $penghargaan = ' Adiwiyata Mandiri'; } + $penilaian = ''; + $penilaian .= ' Sekolah : '.getNilaiAll('sekolah',$row->ms_sekolah_id).'
'; + $penilaian .= ' Kota : '.getNilaiAll('kota',$row->ms_sekolah_id).'
'; + $penilaian .= ' Provinsi : '.getNilaiAll('provinsi',$row->ms_sekolah_id).'
'; + $sekolah = ''; $sekolah .= @$row->sekolah->nama_sekolah.'
'; $sekolah .= ''.@$row->profile->tingkat->name.' '; @@ -59,7 +115,8 @@ class CSAPController extends Controller 'npsn' => $row->sekolah->npsn, 'nama' => $sekolah, 'wilayah' => $row->sekolah->kabupaten->name, - 'penghargaan' => $penghargaan, + 'penilaian' => $penilaian, + 'progress' => kuesionerLogStatus($row->KuesionerId), 'action' => $action, ]; @@ -81,7 +138,91 @@ class CSAPController extends Controller */ public function store(Request $request) { - // + $sekolahId = decode_id($request->sekolah); + if(session('group_alias') == 'penilai_kota'){ + $status = 1; + }else{ + $status = 2; + } + + $soal = Penilaian::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray(); + $penilaian = Penilaian::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->where('status',$status)->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray(); + + if(count($soal) != count($penilaian)){ + return response()->json(['validasi' => false,'message' => 'Maaf Penilaian Belum Lengkap!']); + } + + if($request['validasi'] == 1){ + + if(session('group_alias') == 'penilai_kota'){ + $kuesioner = Kuesioner::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->first(); + $kuesioner->catatan_usulan = $request['catatan_validasi']; + $kuesioner->status = 4; + $kuesioner->save(); + + //kuesioner log + $log = new KuesionerLog; + $log->kuesioner_id = $kuesioner->KuesionerId; + $log->ms_sekolah_id = $kuesioner->ms_sekolah_id; + $log->npsn = $kuesioner->npsn; + $log->ms_group_id = session('group_id'); + $log->step = 'selesai_penilaian_kota'; + $log->status = 4; + $log->created_by = auth()->user()->id; + $log->save(); + }elseif(session('group_alias') == 'penilai_provinsi'){ + $kuesioner = Kuesioner::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->first(); + $kuesioner->catatan_usulan = $request['catatan_validasi']; + $kuesioner->status = 10; + $kuesioner->save(); + + //kuesioner log + $log = new KuesionerLog; + $log->kuesioner_id = $kuesioner->KuesionerId; + $log->ms_sekolah_id = $kuesioner->ms_sekolah_id; + $log->npsn = $kuesioner->npsn; + $log->ms_group_id = session('group_id'); + $log->step = 'selesai_penilaian_provinsi'; + $log->status = 6; + $log->created_by = auth()->user()->id; + $log->save(); + + //kuesioner log final + $log = new KuesionerLog; + $log->kuesioner_id = $kuesioner->KuesionerId; + $log->ms_sekolah_id = $kuesioner->ms_sekolah_id; + $log->npsn = $kuesioner->npsn; + $log->ms_group_id = session('group_id'); + $log->step = 'selesai_final'; + $log->status = 10; + $log->created_by = auth()->user()->id; + $log->save(); + } + + + }elseif($request['validasi'] == 2){ + + $kuesioner = Kuesioner::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->first(); + $kuesioner->catatan_usulan = $request['catatan_validasi']; + $kuesioner->status = 5; + $kuesioner->save(); + + //kuesioner log + $log = new KuesionerLog; + $log->kuesioner_id = $kuesioner->KuesionerId; + $log->ms_sekolah_id = $kuesioner->ms_sekolah_id; + $log->npsn = $kuesioner->npsn; + $log->ms_group_id = session('group_id'); + $log->step = 'dikembalikan_penilaian_kota'; + $log->status = 5; + $log->created_by = auth()->user()->id; + $log->save(); + + }else{ + return response()->json(['validasi' => false,'message' => 'Maaf Terjadi Kesalahan Dalam Input Data!']); + } + + return response()->json(['status' => true,'message' => 'Berhasil update data!']); } /** @@ -100,14 +241,6 @@ class CSAPController extends Controller // } - /** - * Update the specified resource in storage. - */ - public function update(Request $request, string $id) - { - // - } - /** * Remove the specified resource from storage. */ diff --git a/resources/views/modules/kuesioner/form.blade.php b/resources/views/modules/kuesioner/form.blade.php index 0695ec3..1af1ca2 100644 --- a/resources/views/modules/kuesioner/form.blade.php +++ b/resources/views/modules/kuesioner/form.blade.php @@ -475,16 +475,16 @@
- @for($i = (date('Y')-5); $i <= (date('Y')); $i++) - + @endfor
- +
@@ -534,40 +534,57 @@ let tim_adiwiyata = $('input[name="tim_adiwiyata"]:checked').val(); if(level >= 0){ + if(level == 0){ + if((tim_adiwiyata >= 1)){ - if((tim_adiwiyata >= 1)){ - - if(tim_adiwiyata == 2){ - if(($('input[name="tim_adiwiyata[nomor_sk]]"').val() == '') || ($('input[name="tim_adiwiyata[link]"]').val() == '')){ - toastr.error("Nomor SK dan Link GDrive Tim Adiwiyata Belum Diisi ", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); + if(tim_adiwiyata == 2){ + if(($('input[name="tim_adiwiyata[nomor_sk]]"').val() == '') || ($('input[name="tim_adiwiyata[link]"]').val() == '')){ + toastr.error("Nomor SK dan Link GDrive Tim Adiwiyata Belum Diisi ", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); + } } + + if ( + $('input[name="info_pblhs"]:checked').length > 0 && // Radio button + // $('input[name="media[]"]:checked').length > 0 && // Checkbox + // $('input[name="materi[]"]:checked').length > 0 && + $('input[name="komitmen"]:checked').length > 0 && + $('input[name="kegiatan_lingkungan[]"]:checked').length > 0 && + $('input[name="pihak_kegiatan_lingkungan[]"]:checked').length > 0 + ) { + toastr.success("Data Sudah Lengkap", 'Sukses!', { + positionClass: 'toast-bottom-right', + containerId: 'toast-bottom-right' + }); + + $('#form').submit(); + } else { + toastr.error("Data Belum Lengkap", 'Error!', { + positionClass: 'toast-bottom-right', + containerId: 'toast-bottom-right' + }); + } + + + }else{ + toastr.error("Data Belum Lengkap ", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); } - - if ( - $('input[name="info_pblhs"]:checked').length > 0 && // Radio button - // $('input[name="media[]"]:checked').length > 0 && // Checkbox - // $('input[name="materi[]"]:checked').length > 0 && - $('input[name="komitmen"]:checked').length > 0 && - $('input[name="kegiatan_lingkungan[]"]:checked').length > 0 && - $('input[name="pihak_kegiatan_lingkungan[]"]:checked').length > 0 - ) { - toastr.success("Data Sudah Lengkap", 'Sukses!', { - positionClass: 'toast-bottom-right', - containerId: 'toast-bottom-right' - }); - - $('#form').submit(); - } else { - toastr.error("Data Belum Lengkap", 'Error!', { - positionClass: 'toast-bottom-right', - containerId: 'toast-bottom-right' - }); - } - - + }else{ + let tahun = $('.tahun_penghargaan').find(':selected').val(); + let link_sk_adiwiyata = $('.link_sk_adiwiyata').val(); + if((tahun == '') || (link_sk_adiwiyata == '')){ + toastr.error("Data Belum Lengkap", 'Error!', { + positionClass: 'toast-bottom-right', + containerId: 'toast-bottom-right' + }); }else{ - toastr.error("Data Belum Lengkap ", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); + toastr.success("Data Sudah Lengkap", 'Sukses!', { + positionClass: 'toast-bottom-right', + containerId: 'toast-bottom-right' + }); + + $('#form').submit(); } + } }else{ toastr.error("Penghargaan adiwiyata Belum Diisi ", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); diff --git a/resources/views/modules/usulan/csak/form.blade.php b/resources/views/modules/usulan/csak/form.blade.php index 41372d7..033dc3e 100644 --- a/resources/views/modules/usulan/csak/form.blade.php +++ b/resources/views/modules/usulan/csak/form.blade.php @@ -103,7 +103,7 @@ {{@$sekolah->npsn}} - Nama Sekolag + Nama Sekolah {{@$sekolah->nama_sekolah}} @@ -553,7 +553,7 @@ let name = $(this).attr('name'); let value = $(this).val()?.trim(); // Pastikan nilai di-trim untuk menghindari spasi kosong - if (type === 'radio' || type === 'checkbox') { + if (type === 'radio') { // Validasi radio: setidaknya satu opsi harus dipilih if ($(`input[name="${name}"]:checked`).length === 0) { isValid = false; @@ -561,6 +561,16 @@ } else { $(`input[name="${name}"]`).closest('.custom-control-input').removeClass("is-invalid"); } + }else if(type === 'checkbox'){ + if ($(`input[name="${name}"]:checked`).length === 0) { + isValid = false; + $(`input[name="${name}"]`).closest('.custom-control-input').addClass("is-invalid"); + }else if ($(`input[name="${name}"]:checked`).length === 1) { + isMultiple = false; + $(`input[name="${name}"]`).closest('.custom-control-input').addClass("is-invalid"); + } else { + $(`input[name="${name}"]`).closest('.custom-control-input').removeClass("is-invalid"); + } } else { // Validasi input teks atau lainnya if (!value) { diff --git a/resources/views/modules/usulan/csap/form.blade.php b/resources/views/modules/usulan/csap/form.blade.php index 52e83ae..cec129b 100644 --- a/resources/views/modules/usulan/csap/form.blade.php +++ b/resources/views/modules/usulan/csap/form.blade.php @@ -86,7 +86,7 @@
@@ -320,7 +320,7 @@
- @if(@$kuesioner->status < 4) + @if(@$kuesioner->status <= 4)
@@ -336,39 +336,27 @@ Jenis Usulan CSA {{getUsulan($sekolah->MsSekolahId)}} - + Berdasarkan data usulan yang dilengkapi, dinyatakan bahwa {{@$sekolah->nama_sekolah}} : - - Nilai Dokumen Administrasi - 0 - - - Nilai Pemenuhan Kriteria - 0 - Validasi @@ -378,7 +366,7 @@ - @if(@$kuesioner->status < 4) + @if(@$kuesioner->status <= 4) @@ -576,7 +564,7 @@ let name = $(this).attr('name'); let value = $(this).val()?.trim(); // Pastikan nilai di-trim untuk menghindari spasi kosong - if (type === 'radio' || type === 'checkbox') { + if (type === 'radio') { // Validasi radio: setidaknya satu opsi harus dipilih if ($(`input[name="${name}"]:checked`).length === 0) { isValid = false; @@ -584,6 +572,16 @@ } else { $(`input[name="${name}"]`).closest('.custom-control-input').removeClass("is-invalid"); } + }else if(type === 'checkbox'){ + if ($(`input[name="${name}"]:checked`).length === 0) { + isValid = false; + $(`input[name="${name}"]`).closest('.custom-control-input').addClass("is-invalid"); + }else if ($(`input[name="${name}"]:checked`).length === 1) { + isMultiple = false; + $(`input[name="${name}"]`).closest('.custom-control-input').addClass("is-invalid"); + } else { + $(`input[name="${name}"]`).closest('.custom-control-input').removeClass("is-invalid"); + } } else { // Validasi input teks atau lainnya if (!value) { @@ -617,6 +615,8 @@ success: function (response) { // console.log('Response:', response); toastr.success("Berhasil menyimpan data", 'Success!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); + $('.nilai_kota').html(response.nilai_kota); + $('.nilai_provinsi').html(response.nilai_prov); $('.page').closest('.activePage').addClass('bg-success'); diff --git a/resources/views/modules/usulan/kriteria/form.blade.php b/resources/views/modules/usulan/kriteria/form.blade.php index 8aa7c38..e0b1184 100644 --- a/resources/views/modules/usulan/kriteria/form.blade.php +++ b/resources/views/modules/usulan/kriteria/form.blade.php @@ -178,7 +178,7 @@ hiddenInput.name = 'input_upload_files[]'; hiddenInput.value = fileInfo.filename; hiddenInput.class = 'removeFormKriteria'; - var elem = ''; + var elem = ''; $('.changeForm').append(elem); }); }); @@ -251,7 +251,7 @@ hiddenInput.name = 'input_upload_files[]'; hiddenInput.class = 'removeFormKriteria'; hiddenInput.value = fileInfo.filename; - var elem = ''; + var elem = ''; $('.changeForm').append(elem); }); }); @@ -316,6 +316,16 @@ let name = $(this).attr('name'); let value = $(this).val()?.trim(); // Pastikan nilai di-trim untuk menghindari spasi kosong + let uploadedFilesValue = $('.uploadedFiles').val(); + if (!uploadedFilesValue || uploadedFilesValue === '') { + isValid = false; + $('.uploadedFiles').addClass("is-invalid"); + toastr.error("Harap upload minimal 1 file", 'Error!', {positionClass: 'toast-bottom-right'}); + return; + } else { + $('.uploadedFiles').removeClass("is-invalid"); + } + if (type === 'radio') { // Validasi radio: setidaknya satu opsi harus dipilih if ($(`input[name="${name}"]:checked`).length === 0) {