diff --git a/app/Helpers/custom.php b/app/Helpers/custom.php index f6e1361..dd16c8a 100644 --- a/app/Helpers/custom.php +++ b/app/Helpers/custom.php @@ -98,25 +98,81 @@ if (!function_exists('getNilaiAll')) { */ function getNilaiAll($type,$sekolah_id) { - $countSoal = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->count(); + // $countSoal = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->count(); if($type == 'sekolah'){ - $nilai = Penilaian::where('ms_sekolah_id',$sekolah_id) + // III = ((SUM(D246:D252)/11)*20) + // II = ((SUM(D35:D243)/89)*60) + // I = ((SUM(D9:D30)/19)*20) + + $kriteria1 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','I.Perencanaan Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai1 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria1) ->where('skor','!=',0) ->where('tahun',date('Y')) ->where('status',0) //inputan sekolah ->sum('skor'); + + $kriteria2 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','II.Pelaksanaan Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai2 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria2) + ->where('skor','!=',0) + ->where('tahun',date('Y')) + ->where('status',0) //inputan sekolah + ->sum('skor'); + + $kriteria3 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','III.Pemantauan dan Evaluasi Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai3 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria3) + ->where('skor','!=',0) + ->where('tahun',date('Y')) + ->where('status',0) //inputan sekolah + ->sum('skor'); + + $nilai = (($nilai3/11)*20)+(($nilai2/89)*60)+(($nilai1/19)*20); + }elseif($type == 'kota'){ - $nilai = Penilaian::where('ms_sekolah_id',$sekolah_id) + $kriteria1 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','I.Perencanaan Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai1 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria1) ->where('skor','!=',0) ->where('tahun',date('Y')) - ->where('status',1) //inputan sekolah + ->where('status',1) //inputan Kota ->sum('skor'); + + $kriteria2 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','II.Pelaksanaan Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai2 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria2) + ->where('skor','!=',0) + ->where('tahun',date('Y')) + ->where('status',1) //inputan Kota + ->sum('skor'); + + $kriteria3 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','III.Pemantauan dan Evaluasi Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai3 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria3) + ->where('skor','!=',0) + ->where('tahun',date('Y')) + ->where('status',1) //inputan Kota + ->sum('skor'); + + $nilai = (($nilai3/11)*20)+(($nilai2/89)*60)+(($nilai1/19)*20); }elseif($type == 'provinsi'){ - $nilai = Penilaian::where('ms_sekolah_id',$sekolah_id) + $kriteria1 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','I.Perencanaan Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai1 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria1) ->where('skor','!=',0) ->where('tahun',date('Y')) - ->where('status',2) //inputan sekolah + ->where('status',2) //inputan provinsi ->sum('skor'); + + $kriteria2 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','II.Pelaksanaan Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai2 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria2) + ->where('skor','!=',0) + ->where('tahun',date('Y')) + ->where('status',2) //inputan provinsi + ->sum('skor'); + + $kriteria3 = FormKriteria::select('page_number')->groupBy('page_number')->where('kategori','III.Pemantauan dan Evaluasi Gerakan PBLHS')->pluck('page_number')->toArray(); + $nilai3 = Penilaian::where('ms_sekolah_id',$sekolah_id)->whereIn('page_number',$kriteria3) + ->where('skor','!=',0) + ->where('tahun',date('Y')) + ->where('status',2) //inputan provinsi + ->sum('skor'); + + $nilai = (($nilai3/11)*20)+(($nilai2/89)*60)+(($nilai1/19)*20); } return @$nilai ? round(@$nilai) : 0; @@ -614,6 +670,7 @@ if (!function_exists('formKriteria')) { $html .= '
'; $html .= '
'; $html .= '
'.$data->judul.'
'; + // $html .= ''; //QUESTION if($data->type == 'textarea'){ @@ -697,7 +754,7 @@ if (!function_exists('formKriteria')) { } } - $link = Penilaian::where('key','link_grdive')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); + $link = Penilaian::where('key','upload_files')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); $valueLink = json_decode(@$link->value); $catatan = Penilaian::where('key','catatan')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); @@ -707,14 +764,61 @@ if (!function_exists('formKriteria')) { $html .= '
'; $html .= ''; $html .= '
'; - $html .= '
Link Google Drive (folder/File penyimpanan bukti)
'; + $html .= '
Upload File Bukti
'; $html .= '
'; - $html .= ''; - $html .= 'Contoh link : https://example.com'; + $html .= '
+
+ Drop PDF files here or click to upload +
+ Max File 1MB +
+
+
+
    '; + if(@$valueLink){ + if(is_array(@$valueLink)){ + foreach(@$valueLink as $kuy => $file){ + $html .= '
  • + File '.($kuy+1).' +
  • '; + } + }else{ + $html .= '
  • File 1
  • '; + } + } + $html .= '
+
+ '; + // $html .= ''; + // $html .= 'Contoh link : https://example.com'; $html .= '
'; $html .= '
'; $html .= '
'; }else{ + + $html .= '
'; + $html .= '
'; + $html .= '
Bukti File
'; + $html .= '
'; + $html .= '
+
    '; + if(@$valueLink){ + if(is_array(@$valueLink)){ + foreach(@$valueLink as $kuy => $file){ + $html .= '
  • + File '.($kuy+1).' +
  • '; + } + }else{ + $html .= '
  • File 1
  • '; + } + } + $html .= '
+
'; + $html .= '
'; + $html .= '
'; + $html .= '
'; + $html .= '
'; $html .= ''; $html .= '
'; diff --git a/app/Http/Controllers/AjaxController.php b/app/Http/Controllers/AjaxController.php index 35d838d..51bbc5c 100644 --- a/app/Http/Controllers/AjaxController.php +++ b/app/Http/Controllers/AjaxController.php @@ -13,6 +13,36 @@ use App\Models\Kuesioner; class AjaxController extends Controller { + public function uploadTemp(Request $request) + { + $request->validate([ + 'file.*' => 'required|file|mimes:pdf|max:5120', + ]); + + $uploadedFiles = []; + + if ($request->hasFile('file')) { + foreach ($request->file('file') as $file) { + $filename = uniqid() . '-' . time() . '.' . $file->getClientOriginalExtension(); + $path = $file->storeAs('tmp_uploads', $filename); + + $uploadedFiles[] = [ + 'filename' => $filename, + 'url' => asset('storage/tmp_uploads/' . $filename), + ]; + } + + return response()->json([ + 'success' => true, + 'files' => $uploadedFiles, // Kembalikan semua file + ]); + } + + return response()->json([ + 'success' => false, + 'message' => 'Upload failed.', + ]); + } public function sekolahNpsn(Request $request) { if ($request->ajax()) { diff --git a/app/Http/Controllers/Modules/Usulan/CSAKController.php b/app/Http/Controllers/Modules/Usulan/CSAKController.php index bef3e5f..b99f00e 100644 --- a/app/Http/Controllers/Modules/Usulan/CSAKController.php +++ b/app/Http/Controllers/Modules/Usulan/CSAKController.php @@ -103,7 +103,7 @@ class CSAKController extends Controller $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).'
'; + // $penilaian .= ' Provinsi : '.getNilaiAll('provinsi',$row->ms_sekolah_id).'
'; $log = KuesionerLog::where('kuesioner_id',$row->KuesionerId)->orderBy('created_at','DESC')->first(); $progress = ''.str_replace('_',' ',\Str::title($log->step)).''; diff --git a/app/Http/Controllers/Modules/Usulan/KriteriaController.php b/app/Http/Controllers/Modules/Usulan/KriteriaController.php index 79cc6d8..68828cd 100644 --- a/app/Http/Controllers/Modules/Usulan/KriteriaController.php +++ b/app/Http/Controllers/Modules/Usulan/KriteriaController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Modules\Usulan; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Support\Facades\File; use App\Models\Kuesioner; use App\Models\Master\FormKriteria; use App\Models\Master\Sekolah; @@ -90,7 +91,7 @@ class KriteriaController extends Controller } public function store(Request $request) { - // dd($request['sekolah']); + // dd($request); $data = $request['data']; $_value = []; @@ -164,6 +165,44 @@ class KriteriaController extends Controller $sekolah = Sekolah::find($idSekolah); } + if($key == 'input_upload_files'){ + + $filePaths = []; + if(is_array($value)){ + foreach ($value as $file) { + $tempPath = storage_path('app/tmp_uploads/' . $file); + + if (file_exists($tempPath)) { + $path = public_path('uploads/kriteria/' . date('Y').'/'.$idSekolah . '/' .decode_id($data['key']) ); + if (!File::exists($path)) { + File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); + } + + $newPath = 'uploads/kriteria/'.date('Y').'/'.$idSekolah.'/'.decode_id($data['key']).'/'.$file; + copy($tempPath, public_path($newPath)); + $filePaths[] = $newPath; + } + } + }else{ + $tempPath = storage_path('app/tmp_uploads/' . $value); + + if (file_exists($tempPath)) { + $path = public_path('uploads/kriteria/' . date('Y').'/'.$idSekolah . '/' .decode_id($data['key']) ); + if (!File::exists($path)) { + File::isDirectory($path) or File::makeDirectory($path, 0777, true, true); + } + + $newPath = 'uploads/kriteria/'.date('Y').'/'.$idSekolah.'/'.decode_id($data['key']).'/'.$value; + copy($tempPath, public_path($newPath)); + $filePaths[] = $newPath; + } + } + + $value = $filePaths; + } + + + $nilai_kota = Penilaian::where('ms_sekolah_id',$idSekolah) ->where('page_number',decode_id($data['key'])) ->where('skor','!=',0) @@ -180,6 +219,8 @@ class KriteriaController extends Controller $kuesioner = decode_id($data['secure_id']); + + $penilaian[$key] = Penilaian::updateOrCreate([ 'kuesioner_id' => $kuesioner, 'tahun' => date('Y'), diff --git a/app/Models/Penilaian.php b/app/Models/Penilaian.php index 9d83f51..2c9f369 100644 --- a/app/Models/Penilaian.php +++ b/app/Models/Penilaian.php @@ -27,4 +27,9 @@ class Penilaian extends Model // 'created_by', // 'level_adiwiyata', // ]; + + public function page() + { + return $this->belongsTo(\App\Models\Master\FormKriteria::class,'page_number','page_number'); + } } diff --git a/public/68103ee854726-1745895144.pdf b/public/68103ee854726-1745895144.pdf new file mode 100644 index 0000000..9715d86 Binary files /dev/null and b/public/68103ee854726-1745895144.pdf differ diff --git a/public/68103ee8582b2-1745895144.pdf b/public/68103ee8582b2-1745895144.pdf new file mode 100644 index 0000000..f80496f Binary files /dev/null and b/public/68103ee8582b2-1745895144.pdf differ diff --git a/resources/views/modules/usulan/csak/form.blade.php b/resources/views/modules/usulan/csak/form.blade.php index 1484c0d..16d51b1 100644 --- a/resources/views/modules/usulan/csak/form.blade.php +++ b/resources/views/modules/usulan/csak/form.blade.php @@ -86,7 +86,7 @@ +
@endsection @section('page-js') + +