$value) { $d .= ''.sekolah($value)->nama_sekolah.'
'; } array_push($res, $d); $res = implode("", $res); return $res; } } if (!function_exists('getPenghargaanTerakhir')) { /** * @param $val * * @return string */ function getPenghargaanTerakhir($sekolah_id) { $usulan = Kuesioner::where('ms_sekolah_id',$sekolah_id)->where('tahun',date('Y'))->first(); if($usulan->level == 0){ $usulanAwal = 'Belum Pernah'; }elseif($usulan->level == 1){ $usulanAwal = 'Adiwiyata Kab/Kota'; }elseif($usulan->level == 2){ $usulanAwal = 'Adiwiyata Provinsi'; }elseif($usulan->level == 3){ $usulanAwal = 'Adiwiyata Nasional'; }elseif($usulan->level == 4){ $usulanAwal = 'Adiwiyata Mandiri'; } return $usulanAwal; } } if (!function_exists('getUsulan')) { /** * @param $val * * @return string */ function getUsulan($sekolah_id) { $usulan = Kuesioner::where('ms_sekolah_id',$sekolah_id)->where('tahun',date('Y'))->first(); if(($usulan->level+1) == 1){ $jenis_usulan = 'Adiwiyata Kab/Kota'; }elseif(($usulan->level+1) == 2){ $jenis_usulan = 'Adiwiyata Provinsi'; }elseif(($usulan->level+1) == 3){ $jenis_usulan = 'Adiwiyata Nasional'; }elseif(($usulan->level+1) == 4){ $jenis_usulan = 'Adiwiyata Mandiri'; } return $jenis_usulan; } } if (!function_exists('getNilaiAll')) { /** * @param $val * * @return string */ function getNilaiAll($type,$sekolah_id) { // $countSoal = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->count(); if($type == 'sekolah'){ // 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'){ $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 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'){ $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 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; } } if (!function_exists('getNilai')) { /** * @param $val * * @return string */ function getNilai($type,$page_number,$sekolah_id) { if($type == 'sekolah'){ $nilai = Penilaian::where('ms_sekolah_id',$sekolah_id) ->where('page_number',$page_number) ->where('skor','!=',0) ->where('tahun',date('Y')) ->where('status',0) //inputan sekolah ->first(); }elseif($type == 'kota'){ $nilai = Penilaian::where('ms_sekolah_id',$sekolah_id) ->where('page_number',$page_number) ->where('skor','!=',0) ->where('tahun',date('Y')) ->where('status',1) //inputan sekolah ->first(); }elseif($type == 'provinsi'){ $nilai = Penilaian::where('ms_sekolah_id',$sekolah_id) ->where('page_number',$page_number) ->where('skor','!=',0) ->where('tahun',date('Y')) ->where('status',2) //inputan sekolah ->first(); } return @$nilai ? @$nilai->skor : 0; } } if (!function_exists('kuesionerLogStatus')) { /** * @param $val * * @return string */ function kuesionerLogStatus($KuesionerId,$plain = null) { $log = KuesionerLog::where('kuesioner_id',$KuesionerId)->orderBy('KuesionerLogId','DESC')->first(); if($plain == 'plain'){ $progress = str_replace('_',' ',\Str::title($log->step)); }else{ $progress = ''.str_replace('_',' ',\Str::title($log->step)).''; } return $progress; } } if (!function_exists('status_kuesioner')) { /** * @param $val * * @return string */ function status_kuesioner() { //0 = Belum di Verifikasi Dinas //1 = Sudah Diusulkan Oleh Dinas atau Sudin //2 = Approve Dokumen //3 = Kirim Ke Penilai Kota ( Proses Penilaian ) //4 = Selesai Penilaian Kota //5 = Dikembalikan Penilaian Kota ke Sekolah //6 = Selesai Penilaian Provinsi //7 = Dikembalikan Penilaian Provinsi ke Kota //8 = Selesai Penilaian Nasional //9 = Selesai Penilaian Mandiri //10 = Selesai Final //11 = Terbit SK } } if (!function_exists('group')) { /** * @param $val * * @return string */ function group($id) { $user = User::find($id); $group = MasterGroup::where('MsGroupId',$user->ms_group_id)->first(); return @$group; } } if (!function_exists('user')) { /** * @param $val * * @return string */ function user($id) { $user = User::find($id); return @$user; } } if (!function_exists('checkPenilaian')) { /** * @param $val * * @return string */ function checkPenilaian($page_number,$sekolah_id = null) { if(@$sekolah_id){ $idSekolah = @$sekolah_id; }else{ $idSekolah = session('sekolah_id'); } if(session('group_alias') == 'sekolah'){ $penilaian = Penilaian::where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',0)->first(); }elseif(session('group_alias') == 'penilai_kota'){ $penilaian = Penilaian::where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',1)->first(); }elseif(session('group_alias') == 'penilai_provinsi'){ $penilaian = Penilaian::where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',2)->first(); }else{ $penilaian = Penilaian::where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); } // $penilaian = Penilaian::where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); return @$penilaian ? true : false; } } if (!function_exists('hitungSkor')) { /** * @param $val * * @return string */ function hitungSkor($key,$val,$lainnya = []) { $skor = 0; $countLainnya = 0; if(@$lainnya){ $countLainnya = count(array_filter($lainnya, function ($value) { return !is_null($value); })); } if($key == 'rencana_gerakan_pblhs'){ if($val == "Sesuai dengan Laporan EDS dan hasil IPMLH."){ $skor = 3; }elseif($val == "Sesuai dengan Laporan EDS atau hasil IPMLH."){ $skor = 2; }elseif($val == "Tidak sesuai dengan Laporan EDS dan hasil IPMLH."){ $skor = 1; }else{ $skor = 0; } }elseif($key == 'pihak_terlibat_pblhs'){ $array3 = ["Kepala Sekolah", "Dewan pendidik", "Komite sekolah", "Peserta Didik", "Masyarakat"]; $array2 = ["Kepala Sekolah", "Dewan pendidik", "Komite sekolah", "Peserta Didik"]; $array1 = ["Kepala Sekolah", "Dewan pendidik", "Komite sekolah"]; if (!array_diff($array3, $val) && !array_diff($val, $array3)) { $skor = 3; } elseif (!array_diff($array2, $val) && !array_diff($val, $array2)) { $skor = 2; } elseif (!array_diff($array1, $val) && !array_diff($val, $array1)) { $skor = 1; } else { $skor = 0; } }elseif($key == 'dokumen_ktsp'){ $array3 = ["Visi", "Misi", "Tujuan", "Program pengembangan diri"]; $array2 = ["Visi", "Misi", "Tujuan"]; $array22 = ["Visi", "Misi", "Program pengembangan diri"]; $array1 = ["Visi", "Misi","Tujuan", "Program pengembangan diri tidak memuat"]; if (!array_diff($array3, $val) && !array_diff($val, $array3)) { $skor = 3; } elseif ((!array_diff($array2, $val) && !array_diff($val, $array2)) || (!array_diff($array22, $val) && !array_diff($val, $array22))) { $skor = 2; } elseif (!array_diff($array1, $val) && !array_diff($val, $array1)) { $skor = 1; } else { $skor = 0; } }elseif($key == 'aspek_prlh'){ if(count($val) >= 5){ $skor = 5; }elseif(count($val) == 4){ $skor = 4; }elseif(count($val) == 3){ $skor = 3; }elseif(count($val) == 2){ $skor = 2; }elseif(count($val) == 1){ $skor = 1; }else{ $skor = 0; } }elseif($key == 'jumlah_rpp'){ if($val > 80){ $skor = 5; }elseif(($val > 60) && ($val < 80)){ $skor = 4; }elseif(($val > 40) && ($val < 60)){ $skor = 3; }elseif(($val > 20) && ($val < 40)){ $skor = 2; }elseif($val <= 20){ $skor = 1; }else{ $skor = 0; } }elseif($key == 'unsur_warga_partisipasi'){ if(count($val) <= 4){ $skor = 1; }elseif((count($val) >= 4) && ($countLainnya == 1)){ $skor = 2; }elseif((count($val) >= 4) && ($countLainnya == 2)){ $skor = 3; }elseif((count($val) >= 4) && ($countLainnya == 3)){ $skor = 4; }elseif((count($val) >= 4) && ($countLainnya >= 4)){ $skor = 5; }else{ $skor = 0; } }elseif($key == 'upaya_pemeliharaan'){ if(count($val) >= 7){ $skor = 5; }elseif(count($val) == 6){ $skor = 4; }elseif(count($val) == 5){ $skor = 3; }elseif(count($val) == 4){ $skor = 2; }elseif(count($val) <= 3){ $skor = 1; } }elseif($key == 'pelihara_kebersihan'){ $array3 = ["Sekolah bersih", "Sanitasi berfungsi", "Drainase berfungsi"]; $array2 = ["Sekolah bersih", "Sanitasi berfungsi"]; $array22 = ["Sekolah bersih", "Drainase berfungsi"]; if(!empty($val) && !is_array($val)){ $val = array($val); } if (!array_diff($array3, $val) && !array_diff($val, $array3)) { $skor = 3; } elseif ((!array_diff($array2, $val) && !array_diff($val, $array2)) || (!array_diff($array22, $val) && !array_diff($val, $array22))) { $skor = 2; } else { $skor = 1; } }elseif($key == 'upaya_pengurangan_timbulan'){ if(count($val) >= 7){ $skor = 5; }elseif(count($val) == 6){ $skor = 4; }elseif(count($val) == 5){ $skor = 3; }elseif(count($val) == 4){ $skor = 2; }elseif(count($val) <= 3){ $skor = 1; } }elseif($key == 'upaya_daur_ulang_sampah'){ if(count($val) >= 3){ $skor = 3; }elseif(count($val) == 2){ $skor = 2; }elseif(count($val) == 1){ $skor = 1; } }elseif($key == 'pihak_terlibat_pemindahan_sampah'){ $array3 = ["Peserta didik", "Kader Adiwiyata", "Petugas kebersihan"]; $array2 = ["Peserta didik", "Kader Adiwiyata"]; $array1 = ["Petugas kebersihan"]; if(!empty($val) && !is_array($val)){ $val = array($val); } if (!array_diff($array3, $val) && !array_diff($val, $array3)) { $skor = 3; } elseif ((!array_diff($array2, $val) && !array_diff($val, $array2))) { $skor = 2; }elseif ((!array_diff($array1, $val) && !array_diff($val, $array1))) { $skor = 1; } }elseif($key == 'kegiatan_penghijauan'){ $array3 = ["Penanaman", "Pemeliharaan", "Pembibitan"]; $array2 = ["Penanaman", "Pemeliharaan"]; $array1 = ["Penanaman"]; if(!empty($val) && !is_array($val)){ $val = array($val); } if (!array_diff($array3, $val) && !array_diff($val, $array3)) { $skor = 3; } elseif ((!array_diff($array2, $val) && !array_diff($val, $array2))) { $skor = 2; }elseif ((!array_diff($array1, $val) && !array_diff($val, $array1))) { $skor = 1; } }elseif($key == 'warga_sekolah'){ if(count($val) >= 5){ $skor = 5; }elseif(count($val) == 4){ $skor = 4; }elseif(count($val) == 3){ $skor = 3; }elseif(count($val) == 2){ $skor = 2; }elseif(count($val) <= 1){ $skor = 1; } }elseif($key == 'upaya_konservasi_air'){ if(count($val) >= 7){ $skor = 5; }elseif(count($val) == 6){ $skor = 4; }elseif(count($val) == 5){ $skor = 3; }elseif(count($val) == 4){ $skor = 2; }elseif(count($val) <= 3){ $skor = 1; } }elseif($key == 'upaya_konservasi_energi'){ if(count($val) >= 7){ $skor = 5; }elseif(count($val) == 6){ $skor = 4; }elseif(count($val) == 5){ $skor = 3; }elseif(count($val) == 4){ $skor = 2; }elseif(count($val) <= 3){ $skor = 1; } }elseif($key == 'jumlah_karya_inovatif'){ if($val >= 5){ $skor = 3; }elseif(($val >= 3) || ($val <= 4)){ $skor = 2; }elseif(($val >= 1) || ($val <= 2)){ $skor = 1; } }elseif($key == 'aksi_penerapan_prlh'){ if(count($val) >= 4){ $skor = 5; }elseif(count($val) == 3){ $skor = 4; }elseif(count($val) == 2){ $skor = 3; }elseif(count($val) == 1){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'pemilahan_sampah'){ if($val == 'Sampah terpilah dan terkelola dengan baik'){ $skor = 3; }elseif($val == 'Sampah terpilah namun tidak terkelola dengan baik'){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'jejaring_kerja'){ if(count($val) >= 5){ $skor = 5; }elseif(count($val) == 4){ $skor = 4; }elseif(count($val) == 3){ $skor = 3; }elseif(count($val) == 2){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'kegiatan_kampanye'){ if(count($val) >= 5){ $skor = 5; }elseif(count($val) == 4){ $skor = 4; }elseif(count($val) == 3){ $skor = 3; }elseif(count($val) == 2){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'media'){ if($val >= 5){ $skor = 3; }elseif(($val >= 3) || ($val <= 4)){ $skor = 2; }elseif(($val >= 1) || ($val <= 2)){ $skor = 1; } }elseif($key == 'jumlah_kader'){ if($val > 20){ $skor = 5; }elseif(($val > 15) || ($val <= 20)){ $skor = 4; }elseif(($val > 10) || ($val <= 15)){ $skor = 3; }elseif(($val > 5) || ($val <= 10)){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'kegiatan_kader_adiwiyata'){ if(count($val) >= 5){ $skor = 5; }elseif(count($val) == 4){ $skor = 4; }elseif(count($val) == 3){ $skor = 3; }elseif(count($val) == 2){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'frekuensi_pelaksanaan'){ if($val == '3 kali dalam 1 tahun'){ $skor = 3; }elseif($val == '2 kali dalam 1 tahun'){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'rencana_kegiatan_pblhs'){ if($val > 80){ $skor = 5; }elseif(($val > 60) || ($val <= 80)){ $skor = 4; }elseif(($val > 40) || ($val <= 60)){ $skor = 3; }elseif(($val > 20) || ($val <= 40)){ $skor = 2; }else{ $skor = 1; } }elseif($key == 'unsur_pemantauan_evaluasi'){ $array3 = ["Kepala sekolah", "Dewan Pendidik", "Komite sekolah","Peserta Didik","Masyarakat"]; $array2 = ["Kepala sekolah", "Dewan Pendidik", "Komite sekolah","Peserta Didik"]; $array1 = ["Kepala sekolah", "Dewan Pendidik", "Komite sekolah"]; if(!empty($val) && !is_array($val)){ $val = array($val); } if (!array_diff($array3, $val) && !array_diff($val, $array3)) { $skor = 3; } elseif ((!array_diff($array2, $val) && !array_diff($val, $array2))) { $skor = 2; }elseif ((!array_diff($array1, $val) && !array_diff($val, $array1))) { $skor = 1; } } // return $skor; } } if (!function_exists('formKriteria')) { /** * @param $val * * @return string */ function formKriteria($page_number,$sekolah_id = null) { $kriteria = FormKriteria::where('page_number',$page_number)->get(); $html = ''; if(@$sekolah_id){ $idSekolah = @$sekolah_id; }else{ $idSekolah = session('sekolah_id'); } $kuesioner = Kuesioner::where('ms_sekolah_id',$idSekolah)->where('tahun',date('Y'))->first(); foreach($kriteria as $keyKriteria => $data){ if(session('group_alias') == 'sekolah'){ $penilaian = Penilaian::where('key',$data->key)->where('ms_sekolah_id',$idSekolah)->where('status',0)->first(); }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(); } // dd(); $html .= '
'; $html .= '
'; $html .= '
'.$data->judul.'
'; // $html .= ''; //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 .= '
'; }elseif($data->type == 'freetext'){ $value = json_decode(@$penilaian->value); $valueOld = json_decode(@$penilaianOld->value); if(@$value){ $nilai = @$value; }else{ $nilai = @$valueOld; } $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 .= '
'; } }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 .= '
'; } }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 .= '
'; $html .= '
'; if($data->active_lainnya == 1){ if(session('group_alias') == 'sekolah'){ $lainnya = Penilaian::where('key','lainnya')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',0)->first(); }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(); } if(@$lainnya){ $valueLainnya = json_decode(@$lainnya->value); }else{ $valueLainnya = json_decode(@$lainnyaOld->value); } // dd($valueLainnya); $html .= '
'; $html .= '
'; $html .= '
'.$data->judul_lainnya.'
'; for($i = 1; $i <= $data->number_answer_lainnya; $i++){ $html .= '
'; $html .= ''; $html .= '
'; } $html .= '
'; $html .= '
'; } } $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(); $valueCatatan = json_decode(@$catatan->value); if(session('group_alias') == 'sekolah'){ $html .= '
'; $html .= ''; $html .= '
'; $html .= '
Upload File Bukti
'; $html .= '
'; $html .= '
Drop PDF files here or click to upload
    '; 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 .= '
'; if($kuesioner->status == 5){ $catatan = Penilaian::where('key','catatan')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->where('status',1)->first(); $html .= '
'; // $html .= ''; $html .= '
'; $html .= '
Catatan
'; $html .= '

'.json_decode($catatan->value).'

'; $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 .= '
'; $html .= '
Catatan
'; $html .= '
'; $html .= ''; $html .= '
'; $html .= '
'; $html .= '
'; } return $html; } } if (!function_exists('levelAdiwiyata')) { /** * @param $val * * @return string */ function levelAdiwiyata($npsn) { $kuesioner = Kuesioner::where('npsn',$npsn)->where('tahun',date('Y'))->first(); $sekolah = Sekolah::where('npsn',$npsn)->first(); $sk = SK::where('tahun',date('Y'))->where('sekolah','like','%'.$sekolah->MsSekolahId.'%')->first(); $data = null; if(@$kuesioner){ $data = $kuesioner; }else{ $kuesioner = Kuesioner::where('npsn',$npsn)->where('tahun',(date('Y')-1))->first(); $data = $kuesioner; } $level = ''; if(@$data->level == 0){ if((@$data->level == 0) && (@$data->tim_adiwiyata == 2) && (@$data->info_pblhs == 2) ){ if(@$sk->jenis_usulan == 1){ $level = '3'; }else{ $level = '2'; } }elseif((@$data->level == 0) && (@$data->tim_adiwiyata == 2)){ if(@$sk->jenis_usulan == 1){ $level = '3'; }else{ $level = '1'; } }else{ if(@$sk->jenis_usulan == 1){ $level = '3'; }else{ $level = '0'; } } }elseif(@$data->level == 1){ if(@$sk->jenis_usulan == 2){ $level = '4'; }else{ $level = '3'; } }elseif(@$data->level == 2){ if(@$sk->jenis_usulan == 3){ $level = '5'; }else{ $level = '4'; } }else{ if(@$sk->jenis_usulan == 1){ $level = '3'; }else{ $level = '0'; } } return $level; } } if (!function_exists('taskLabel')) { /** * @param $val * * @return string */ function taskLabel($val) { if ($val == 'store') { $task = 'save'; } elseif ($val == 'save_permission') { $task = 'save group access'; } elseif ($val == 'destroy') { $task = 'delete'; } elseif ($val == 'batch') { $task = 'delete'; } else { $task = $val; } return $task; } } if (!function_exists('logActivity')) { /** * @param $request * @param $note */ function logActivity($request, $note) { $repository = app(\App\Models\Log::class); $data = [ 'module' => $request->route()->getAction('prefix'), 'task' => taskLabel($request->route()->getActionMethod()), 'user_id' => session('uid'), 'ipaddress' => $request->getClientIp(), 'useragent' => $request->header('User-Agent'), 'note' => $note, 'created_at' => \Carbon\Carbon::now() ]; if (session('superuser') == false) $repository->create($data); } } if (!function_exists('trimId')) { /** * @param $val * @return array */ function trimId($val) { $string = explode('+', $val); return $string; } } if (!function_exists('dateTime')) { /** * make secure id * * @param string|null $val * * @return string */ function dateTime($date) { return date('d-m-Y H:i:s',strtotime(@$date)); } } if (!function_exists('encode_id')) { /** * make secure id * * @param string|null $val * * @return string */ function encode_id(?string $val = ''): string { $params = ['val' => $val]; return rtrim(base64_encode(serialize($params)), "="); } } if (!function_exists('decode_id')) { /** * @param string|null $val * ${STATIC} * * @return mixed|null * @author alex.gz * @created 02/12/2023 4:28 * */ function decode_id(?string $val = ''): mixed { $secure = unserialize(base64_decode($val)); return $secure ? $secure['val'] : null; } } if (!function_exists('permission')) { /** * @param $access * @param $key * @param string $method * @param bool $view * * @return mixed */ function permission($access, $key, string $method = 'menu', bool $view = false): mixed { if (@session('group_id') != 1) { if ($method == 'module') { if (is_array($access)) { $model = MasterAccessMenu::where('module', 'LIKE', "{$key}%")->where('ms_group_id', session('group_id'))->first(); $query = count(array_intersect((array)$access, (array)$model->access)); } else { $query = MasterAccessMenu::where($access, true)->where('module', 'LIKE', $key.'%')->where('ms_group_id', session('group_id'))->count(); if ($query > 0) { return true; } else { return abort('401'); } } } else { $query = MasterAccessMenu::where($access, true)->where('ms_menu_id', $key)->where('ms_group_id', session('group_id'))->count(); } if ($query > 0) { return true; } else { return false; } } else { return true; } } } if (!function_exists('access')) { /** * @param $access * @param $key * * @return bool */ function access($access, $key) { if (session('group_alias') != 'administrator') { $query = MasterAccessMenu::where($access, 1)->where('module', $key)->where('ms_group_id', session('group_id'))->count(); if ($query > 0) { return true; } else if (session('group_alias') == 'administrator') { return true; } else { return false; } } else { return true; } } } if (!function_exists('activeMenuClass')) { /** * Helper to grab the application version. * * @return mixed */ function activeMenuClass($route){ // dd(request()->route()->getName()); // if(request()->route()->getName() == $route){ // return true; // }else{ // return false; // } if (\Str::is($route, request()->route()->getName())) { return true; } else { return false; } } } if (!function_exists('renderMenu')) { /** * Loops through a folder and requires all PHP files * Searches sub-directories as well. * * @param $folder */ function renderMenu() { $parent = MasterMenu::where('status',true)->where('menu_type','sidebar')->where('parent_id',0)->orderBy('ordering','ASC')->get(); $html = ''; foreach ($parent as $p1) { // echo $p1->MsMenuId.'
'; $child2 = MasterMenu::where('status',true)->where('menu_type','sidebar')->where('parent_id',$p1->MsMenuId)->get(); $access1 = permission('is_read', $p1->MsMenuId, 'menu', true); $ch1 = count($child2) > 0 ? '' : ''; $link1 = count($child2) > 0 ? '' : 'menu-link'; $active = activeMenuClass($p1->module) ? 'active' : ''; // dd($p1->route); if ($access1) { $active1 = activeMenuClass($p1->module) ? 'active' : ''; $html .= '
  • ' . @$p1->title.''; if (count($child2) > 0) { $html .= ''; $html .= ''; } else { $html .= ''; } $html .= '
  • '; } } return $html; } } if (!function_exists('include_route_files')) { /** * Loops through a folder and requires all PHP files * Searches sub-directories as well. * * @param $folder */ function include_route_files($folder) { include_files_in_folder($folder); } } if (!function_exists('include_files_in_folder')) { /** * Loops through a folder and requires all PHP files * Searches sub-directories as well. * * @param $folder */ function include_files_in_folder($folder) { try { $rdi = new RecursiveDirectoryIterator($folder); $it = new RecursiveIteratorIterator($rdi); while ($it->valid()) { if (!$it->isDot() && $it->isFile() && $it->isReadable() && $it->current()->getExtension() === 'php') { require $it->key(); } $it->next(); } } catch (Exception $e) { echo $e->getMessage(); } } }