get(); $html = ''; foreach($kriteria as $keyKriteria => $data){ $nameOption = 'option_number_'.$keyKriteria; $html .= '
'; $html .= '
'; $html .= '
'.$data->judul.'
'; //QUESTION if($data->type == 'textarea'){ $html .= '
'; $html .= ''; $html .= '
'; }elseif($data->type == 'freetext'){ $html .= '
'; $html .= ''; $html .= '
'; }elseif($data->type == 'checkbox'){ $option = json_decode($data->option); foreach($option as $keyOption => $dataOption){ $key = 'number_'.$keyKriteria.'_'.$keyOption; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; } }elseif($data->type == 'radio_button'){ $option = json_decode($data->option); foreach($option as $keyOption => $dataOption){ $key = 'number_'.$keyKriteria.'_'.$keyOption; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; } }elseif($data->type == 'number'){ $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(); 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) ){ $level = '2'; }elseif(($data->level == 0) && ($data->tim_adiwiyata == 2)){ $level = '1'; }else{ $level = '0'; } }elseif($data->level == 1){ $level = '3'; }elseif($data->level == 2){ $level = '4'; }else{ $level = '4'; } 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(); } } 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('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 = $active ? ' active ' . null : null; $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(); } } }