From cb2b578a8075891f979dc47c86c066c46f55659b Mon Sep 17 00:00:00 2001 From: ilhamwara Date: Mon, 2 Jun 2025 16:06:05 +0700 Subject: [PATCH] update --- app/Helpers/custom.php | 58 +++- app/Http/Controllers/KuesionerController.php | 85 +++++- .../Modules/Usulan/AdministrasiController.php | 36 ++- .../Modules/Usulan/KriteriaController.php | 15 +- .../views/modules/kuesioner/form.blade.php | 31 +- .../views/modules/profile/sekolah.blade.php | 278 ++++++++++-------- .../usulan/administrasi/index.blade.php | 10 +- .../views/modules/usulan/csak/form.blade.php | 13 +- .../modules/usulan/kriteria/form.blade.php | 16 +- 9 files changed, 374 insertions(+), 168 deletions(-) diff --git a/app/Helpers/custom.php b/app/Helpers/custom.php index 077d44a..e499793 100644 --- a/app/Helpers/custom.php +++ b/app/Helpers/custom.php @@ -674,10 +674,12 @@ if (!function_exists('formKriteria')) { }elseif(session('group_alias') == 'penilai_kota'){ $penilaian = Penilaian::where('key',$data->key)->where('ms_sekolah_id',$idSekolah)->where('status',1)->first(); + $penilaianOld = Penilaian::where('key',$data->key)->where('ms_sekolah_id',$idSekolah)->where('status',0)->first(); }elseif(session('group_alias') == 'penilai_provinsi'){ $penilaian = Penilaian::where('key',$data->key)->where('ms_sekolah_id',$idSekolah)->where('status',2)->first(); + $penilaianOld = Penilaian::where('key',$data->key)->where('ms_sekolah_id',$idSekolah)->where('status',1)->first(); }else{ $penilaian = Penilaian::where('key',$data->key)->where('ms_sekolah_id',$idSekolah)->first(); @@ -694,27 +696,53 @@ if (!function_exists('formKriteria')) { //QUESTION if($data->type == 'textarea'){ $value = json_decode(@$penilaian->value); + $valueOld = json_decode(@$penilaianOld->value); + + if(@$value){ + $nilai = @$value; + }else{ + $nilai = @$valueOld; + } $html .= '
'; - $html .= ''; + $html .= ''; $html .= '
'; }elseif($data->type == 'freetext'){ $value = json_decode(@$penilaian->value); + $valueOld = json_decode(@$penilaianOld->value); + + if(@$value){ + $nilai = @$value; + }else{ + $nilai = @$valueOld; + } $html .= '
'; - $html .= ''; + $html .= ''; $html .= '
'; }elseif($data->type == 'checkbox'){ $option = json_decode($data->option); $value = json_decode(@$penilaian->value); + $valueOld = json_decode(@$penilaianOld->value); + foreach($option as $keyOption => $dataOption){ + if(@$value){ + if(in_array($dataOption, (is_array(@$value) ? @$value : array(@$value)))){ + $checked = 'checked'; + } + }else{ + if(in_array($dataOption, (is_array(@$valueOld) ? @$valueOld : array(@$valueOld)))){ + $checked = 'checked'; + } + } + $key = 'number_'.$keyKriteria.'_'.$keyOption; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; } @@ -722,12 +750,14 @@ if (!function_exists('formKriteria')) { }elseif($data->type == 'radio_button'){ $option = json_decode($data->option); $value = json_decode(@$penilaian->value); + $valueOld = json_decode(@$penilaianOld->value); + foreach($option as $keyOption => $dataOption){ $key = 'number_'.$keyKriteria.'_'.$keyOption; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; } @@ -735,8 +765,16 @@ if (!function_exists('formKriteria')) { }elseif($data->type == 'number'){ $value = json_decode(@$penilaian->value); + $valueOld = json_decode(@$penilaianOld->value); + + if(@$value){ + $nilai = @$value; + }else{ + $nilai = @$valueOld; + } + $html .= '
'; - $html .= ''; + $html .= ''; $html .= '
'; } @@ -749,14 +787,20 @@ if (!function_exists('formKriteria')) { }elseif(session('group_alias') == 'penilai_kota'){ $lainnya = Penilaian::where('key','lainnya')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',1)->first(); + $lainnyaOld = Penilaian::where('key','lainnya')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',0)->first(); }elseif(session('group_alias') == 'penilai_provinsi'){ $lainnya = Penilaian::where('key','lainnya')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',2)->first(); + $lainnyaOld = Penilaian::where('key','lainnya')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',1)->first(); }else{ $lainnya = Penilaian::where('key','lainnya')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); } - $valueLainnya = json_decode(@$lainnya->value); + if(@$lainnya){ + $valueLainnya = json_decode(@$lainnya->value); + }else{ + $valueLainnya = json_decode(@$lainnyaOld->value); + } // dd($valueLainnya); $html .= '
'; @@ -788,8 +832,6 @@ if (!function_exists('formKriteria')) { $html .= '
Drop PDF files here or click to upload -
- Max File 1MB
diff --git a/app/Http/Controllers/KuesionerController.php b/app/Http/Controllers/KuesionerController.php index ab53ce2..9725f3f 100644 --- a/app/Http/Controllers/KuesionerController.php +++ b/app/Http/Controllers/KuesionerController.php @@ -7,11 +7,14 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\File; +use Carbon\Carbon; use App\Models\ProfileSekolah as Profile; use App\Models\Kuesioner; use App\Models\KuesionerLog; use App\Models\Master\Provinsi; use App\Models\Master\Sekolah; +use App\Models\DokumenAdministrasi; class KuesionerController extends Controller { @@ -127,7 +130,8 @@ class KuesionerController extends Controller } $sekolah = Sekolah::where('MsSekolahId',$keyId)->first(); - + + $data['dok'] = DokumenAdministrasi::where('ms_sekolah_id',$keyId)->where('tahun',date('Y'))->first(); $data['nama_sekolah'] = @$sekolah->nama_sekolah; $data['npsn'] = @$sekolah->npsn; $data['status'] = @$sekolah->status; @@ -351,6 +355,31 @@ class KuesionerController extends Controller $level = 6; } + if (@$request->hasFile('tim_adiwiyata_link')) { + $file = $request->file('tim_adiwiyata_link'); + $destinationPath = public_path('uploads/tim_adiwiyata'); + $current = Carbon::now()->format('Y/m/d'); + $path = $destinationPath . '/' . $current; + $fileName = $file->getClientOriginalName(); + $fileMime = $file->getClientMimeType(); + $fileExtension = $file->getClientOriginalExtension(); + $fileSize = $file->getSize(); + if($fileExtension != 'pdf'){ + return redirect()->back()->with([ + 'message' => 'Maaf File Harus Berupa PDF!', + 'type' => "error" + ]); + } + $newFilename = session('id').'_'.uniqid('file_') . '.' . $fileExtension; + + if (!File::exists($path)) { + File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); + } + + $filePathTim = 'tim_adiwiyata/' . $current . '/' . $newFilename; + $uploaded = $file->move($path, $newFilename); + } + $insert = new Kuesioner; $insert->ms_sekolah_id = session('sekolah_id'); $insert->created_by = auth()->user()->id; @@ -367,9 +396,51 @@ class KuesionerController extends Controller $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->tim_adiwiyata_link = @$filePathTim; + $insert->status = 1; $insert->save(); + if (@$request->hasFile('file_usulan')) { + $file = $request->file('file_usulan'); + $destinationPath = public_path('uploads/file_usulan'); + $current = Carbon::now()->format('Y/m/d'); + $path = $destinationPath . '/' . $current; + $fileName = $file->getClientOriginalName(); + $fileMime = $file->getClientMimeType(); + $fileExtension = $file->getClientOriginalExtension(); + $fileSize = $file->getSize(); + if($fileExtension != 'pdf'){ + return redirect()->back()->with([ + 'message' => 'Maaf File Harus Berupa PDF!', + 'type' => "error" + ]); + } + $newFilename = session('id').'_'.uniqid('file_') . '.' . $fileExtension; + + if (!File::exists($path)) { + File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); + } + + $filePathUsulan = 'file_usulan/' . $current . '/' . $newFilename; + $uploaded = $file->move($path, $newFilename); + + $dok = DokumenAdministrasi::updateOrCreate([ + 'kuesioner_id' => $insert->KuesionerId, + 'ms_sekolah_id' => session('sekolah_id'), + 'npsn' => session('npsn'), + 'created_by' => auth()->user()->id, + 'tahun' => date('Y'), + ],[ + 'kuesioner_id' => $insert->KuesionerId, + 'ms_sekolah_id' => session('sekolah_id'), + 'npsn' => session('npsn'), + 'created_by' => auth()->user()->id, + 'tahun' => date('Y'), + 'file_usulan' => @$filePathUsulan, + 'status' => 0, + ]); + } + //kuesioner log $log = new KuesionerLog; @@ -382,6 +453,16 @@ class KuesionerController extends Controller $log->created_by = auth()->user()->id; $log->save(); + $log = new KuesionerLog; + $log->kuesioner_id = $insert->KuesionerId; + $log->ms_sekolah_id = session('sekolah_id'); + $log->npsn = session('npsn'); + $log->ms_group_id = session('group_id'); + $log->step = 'proses_usulan'; + $log->status = 1; + $log->created_by = auth()->user()->id; + $log->save(); + logActivity($request, __('Create',['val' => strtolower(__('Title',['val' => 'Kuesioner Leveling User ID : '.auth()->user()->id]))])); diff --git a/app/Http/Controllers/Modules/Usulan/AdministrasiController.php b/app/Http/Controllers/Modules/Usulan/AdministrasiController.php index f060470..4dbd40f 100644 --- a/app/Http/Controllers/Modules/Usulan/AdministrasiController.php +++ b/app/Http/Controllers/Modules/Usulan/AdministrasiController.php @@ -59,7 +59,7 @@ class AdministrasiController extends Controller if(session('group_alias') == 'sekolah'){ if((@$dok->status == 0) || (@$dok->status == 2)){ - if($row->status != 0){ + if($dok->status != 0){ $action .= ''; } } @@ -74,11 +74,19 @@ class AdministrasiController extends Controller } } - if(@$usulan){ - $fileUsulan = '  Surat Usulan'; - }else{ - $fileUsulan = ''; - } + $fileUsulan = ''; + $fileUsulan .= '
+ + +
'; + if($row->level == 0){ $penghargaan = ' Belum Pernah'; @@ -115,9 +123,9 @@ class AdministrasiController extends Controller $labelDok = 'Belum Upload Dokumen'; } - if($row->status == 0){ - $labelDok .= '
Menunggu Usulan Dari Dinas/Sudin'; - } + // if($row->status == 0){ + // $labelDok .= '
Menunggu Usulan Dari Dinas/Sudin'; + // } $sekolah = ''; $sekolah .= @$row->sekolah->nama_sekolah.'
'; @@ -205,7 +213,7 @@ class AdministrasiController extends Controller if (@$request->hasFile('sk_tim_adiwiyata')) { $file = $request->file('sk_tim_adiwiyata'); - $destinationPath = public_path('uploads/file_sk_tim'); + $destinationPath = public_path('uploads/tim_adiwiyata'); $current = Carbon::now()->format('Y/m/d'); $path = $destinationPath . '/' . $current; $fileName = $file->getClientOriginalName(); @@ -224,8 +232,12 @@ class AdministrasiController extends Controller File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); } - $filePathTim = 'file_sk_tim/' . $current . '/' . $newFilename; + $filePathTim = 'tim_adiwiyata/' . $current . '/' . $newFilename; $uploaded = $file->move($path, $newFilename); + + $kuesioner = Kuesioner::find($keyId); + $kuesioner->tim_adiwiyata_link = $filePathTim; + $kuesioner->save(); } if (@$request->hasFile('surat_usulan')) { @@ -254,6 +266,8 @@ class AdministrasiController extends Controller } // dd($filePathUsulan); + + $dok = DokumenAdministrasi::updateOrCreate([ 'kuesioner_id' => $keyId, 'ms_sekolah_id' => session('sekolah_id'), diff --git a/app/Http/Controllers/Modules/Usulan/KriteriaController.php b/app/Http/Controllers/Modules/Usulan/KriteriaController.php index 68828cd..8d8ef07 100644 --- a/app/Http/Controllers/Modules/Usulan/KriteriaController.php +++ b/app/Http/Controllers/Modules/Usulan/KriteriaController.php @@ -30,17 +30,24 @@ class KriteriaController extends Controller } $kuesioner = Kuesioner::where('ms_sekolah_id',session('sekolah_id'))->where('tahun',date('Y'))->first(); - + $dok = DokumenAdministrasi::where('kuesioner_id',$kuesioner->KuesionerId)->first(); if($kuesioner->status == 0){ - return redirect('kuesioner/update/'.encode_id(session('sekolah_id')))->with([ - 'message' => 'Menunggu Usulan dari Dinas/Sudin', + if(@$dok->status == 0){ + return redirect('kuesioner/update/'.encode_id(session('sekolah_id')))->with([ + 'message' => 'Maaf menunggu verifikasi dokumen oleh Dinas/Sudin', 'type' => 'error', ]); + }elseif(@$dok->status == 2){ + return redirect('kuesioner/update/'.encode_id(session('sekolah_id')))->with([ + 'message' => 'Dokumen ditolak oleh Dinas/Sudin, silahkan upload ulang', + 'type' => 'error', + ]); + } } if(@$kuesioner){ if(@$kuesioner->status == 1){ - $dok = DokumenAdministrasi::where('kuesioner_id',$kuesioner->KuesionerId)->first(); + // $dok = DokumenAdministrasi::where('kuesioner_id',$kuesioner->KuesionerId)->first(); if(@$dok->status == 0){ return redirect('kuesioner/update/'.encode_id(session('sekolah_id')))->with([ 'message' => 'Maaf menunggu verifikasi dokumen oleh Dinas/Sudin', diff --git a/resources/views/modules/kuesioner/form.blade.php b/resources/views/modules/kuesioner/form.blade.php index 88cce5f..09f1752 100644 --- a/resources/views/modules/kuesioner/form.blade.php +++ b/resources/views/modules/kuesioner/form.blade.php @@ -46,8 +46,8 @@
@endif -
- {{csrf_field()}} + + {{csrf_field()}}
@@ -122,8 +122,11 @@
- +
+ @if(@$kuesioner->tim_adiwiyata_link) +  File SK Tim Adiwiyata + @endif
@@ -417,9 +420,29 @@
+ +
+ @if(@$dok->file_usulan) +
+
+
+ +
+ +
+
+ @else +
+ + +
+ @endif +
@if(!@$kuesioner)
- +
@endif diff --git a/resources/views/modules/profile/sekolah.blade.php b/resources/views/modules/profile/sekolah.blade.php index c382b21..3be2a7f 100644 --- a/resources/views/modules/profile/sekolah.blade.php +++ b/resources/views/modules/profile/sekolah.blade.php @@ -51,135 +51,107 @@
+
+
+
Data Jumlah
+
Penghematan Air
+
Penghematan Listrik
+
+
{{csrf_field()}} -
-
-
- -
- -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-
-
-
-
-

Penghematan air sebelum dan setelah melaksanakan gerakan PBLHS

-
-
- - -
-
- - -
-
-
-
-

Penghematan listrik sebelum dan setelah melaksanakan gerakan PBLHS

-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
-
- +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +
+
+

Penghematan air sebelum dan setelah melaksanakan gerakan PBLHS

+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

Penghematan listrik sebelum dan setelah melaksanakan gerakan PBLHS

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
@@ -190,5 +162,65 @@
@endsection @section('page-js') + @endsection \ No newline at end of file diff --git a/resources/views/modules/usulan/administrasi/index.blade.php b/resources/views/modules/usulan/administrasi/index.blade.php index c602465..105383a 100644 --- a/resources/views/modules/usulan/administrasi/index.blade.php +++ b/resources/views/modules/usulan/administrasi/index.blade.php @@ -134,8 +134,8 @@ NPSN Nama Sekolah Wilayah - File Usulan - Status Dokumen + File + Status @@ -312,7 +312,7 @@ div += '
SK Tim Adiwiyata
'; div += ''; div += ''; - div += ''; + div += ''; if(filetim != ''){ div += '
File SK Tim Adiwiyata
'; } @@ -324,7 +324,7 @@ div += '
Surat Usulan
'; div += ''; div += ''; - div += ''; + div += ''; if(fileusulan != ''){ div += '
File Usulan
'; } @@ -337,7 +337,7 @@ div += '
'+$(this).attr('data-jenisusulan')+'
'; div += ''; div += ''; - div += ''; + div += ''; div += 'Format : .pdf, Maksimal File : 2MB'; div += ''; div += ''; diff --git a/resources/views/modules/usulan/csak/form.blade.php b/resources/views/modules/usulan/csak/form.blade.php index ba553c4..ae5bdba 100644 --- a/resources/views/modules/usulan/csak/form.blade.php +++ b/resources/views/modules/usulan/csak/form.blade.php @@ -319,8 +319,8 @@ let number = $(this).data('number'); let base_url = "{{url('/')}}"; // Tambahkan kelas active dan hapus dari yang lain - $('.page').removeClass('activePage'); - $(this).addClass('activePage'); + $('.page').removeClass('bg-primary-light border-primary text-primary'); + $(this).addClass('bg-primary-light border-primary text-primary'); $.ajax({ url: base_url+'/getForm', // Ganti dengan URL API-mu @@ -541,10 +541,13 @@ $('.nilai_kota').html(response.nilai_kota); $('.nilai_provinsi').html(response.nilai_prov); - $('.page').closest('.activePage').addClass('bg-success'); - $('.page').closest('.activePage').addClass('text-white'); - $('.page').removeClass('activePage'); + // $('.page').closest('.activePage').addClass('bg-success'); + // $('.page').closest('.activePage').addClass('text-white'); + // $('.page').removeClass('activePage'); // (checkPenilaian($hal) == true ? 'bg-success text-white' : '' ) + + $('.page').closest('.bg-primary-light').addClass('bg-success-light border-success text-success'); + $('.page').closest('.bg-primary-light').removeClass('bg-primary-light border-primary border-secondary text-primary'); }, error: function (xhr, status, error) { // console.error('AJAX Error:', status, error); diff --git a/resources/views/modules/usulan/kriteria/form.blade.php b/resources/views/modules/usulan/kriteria/form.blade.php index 0ea8264..358948f 100644 --- a/resources/views/modules/usulan/kriteria/form.blade.php +++ b/resources/views/modules/usulan/kriteria/form.blade.php @@ -130,7 +130,7 @@ uploadMultiple: true, init: function() { this.on("successmultiple", function(files, response) { - console.log('Upload success multiple:', response); + // console.log('Upload success multiple:', response); const fileList = document.getElementById('file-list'); @@ -184,7 +184,7 @@ $('.removeFormKriteria').remove(); }, success: function (response) { - console.log('Response:', response); + // console.log('Response:', response); $('.changeForm').append(response.data); $('.changeTitle').html(response.title); @@ -258,7 +258,7 @@ $('#btnSave').on('click',function(e){ e.preventDefault(); let currentForm = $("#form").serializeArray(); - console.log(currentForm); + // console.log(currentForm); let formData = {}; let allData = {}; @@ -351,9 +351,13 @@ toastr.success("Berhasil menyimpan data", 'Success!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); - $('.page').closest('.active').addClass('bg-success'); - $('.page').closest('.active').addClass('text-white'); - $('.page').removeClass('active'); + // $('.page').closest('.active').addClass('bg-success'); + // $('.page').closest('.active').addClass('text-white'); + + $('.page').closest('.bg-primary-light').addClass('bg-success-light border-success text-success'); + $('.page').closest('.bg-primary-light').removeClass('bg-primary-light border-primary border-secondary text-primary'); + + // $('.page').removeClass('active'); // (checkPenilaian($hal) == true ? 'bg-success text-white' : '' ) }, error: function (xhr, status, error) {