diff --git a/app/Helpers/custom.php b/app/Helpers/custom.php index f50caf3..ce9577a 100644 --- a/app/Helpers/custom.php +++ b/app/Helpers/custom.php @@ -19,6 +19,38 @@ if (!function_exists('sekolah')) { } } +if (!function_exists('monthtString')) { + + /** + * Date format based on active locale + * + * @param $date + * @return string + */ + function monthtString($val) + { + $result = $val; + if (!empty($val)) { + $month = [ + "Januari", + "Februari", + "Maret", + "April", + "Mei", + "Juni", + "Juli", + "Agustus", + "September", + "Oktober", + "November", + "Desember", + ]; + $result = $month[(int)$val - 1]; + } + return ($result); + } +} + if (!function_exists('listSekolah')) { function listSekolah($sekolah){ @@ -820,7 +852,7 @@ if (!function_exists('formKriteria')) { $key = 'number_'.$keyKriteria.'_'.$keyOption; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; } @@ -835,7 +867,7 @@ if (!function_exists('formKriteria')) { $key = 'number_'.$keyKriteria.'_'.$keyOption; $html .= '
'; - $html .= ''; + $html .= ''; $html .= ''; $html .= '
'; } @@ -901,12 +933,28 @@ if (!function_exists('formKriteria')) { $catatan = Penilaian::where('key','catatan')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first(); $valueCatatan = json_decode(@$catatan->value); + $kriteriaFirst = FormKriteria::where('page_number',$page_number)->first(); + if(session('group_alias') == 'sekolah'){ $html .= '
'; $html .= ''; $html .= '
'; - $html .= '
Upload File Bukti
'; + $html .= '
'; + $html .= '
Upload File Bukti
'; + // $html .= ' Tambah File'; + + $html .= '
'; $html .= '
'; + $html .= '
'; + + if(($kriteriaFirst->type == 'textarea') || ($kriteriaFirst->type == 'number')){ + // $html .= '
'; + // $html .= ''; + // $html .= ''; + // $html .= 'Ukuran Maksimal File : 10MB, Ekstension File : .pdf,.png,.jpeg,.jpg'; + // $html .= '
'; + } + $html .= '
Drop PDF files here or click to upload diff --git a/app/Http/Controllers/Modules/Usulan/KriteriaController.php b/app/Http/Controllers/Modules/Usulan/KriteriaController.php index 07e36a9..01d4e8b 100644 --- a/app/Http/Controllers/Modules/Usulan/KriteriaController.php +++ b/app/Http/Controllers/Modules/Usulan/KriteriaController.php @@ -245,7 +245,7 @@ class KriteriaController extends Controller $idSekolah = session('sekolah_id'); $sekolah = Sekolah::find($idSekolah); } - + // dd(request()->all()); if($key == 'input_upload_files'){ $filePaths = []; diff --git a/app/Http/Controllers/SampahController.php b/app/Http/Controllers/SampahController.php index 7178697..67282fd 100644 --- a/app/Http/Controllers/SampahController.php +++ b/app/Http/Controllers/SampahController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Models\SampahTerkelola; class SampahController extends Controller { @@ -28,12 +29,68 @@ class SampahController extends Controller // } + public function grid(Request $request) + { + + $data = SampahTerkelola::where('ms_sekolah_id',session('sekolah_id')) + ->orderBy('tahun','DESC') + ->orderBy('bulan','ASC') + ->get(); + $_data = []; + + + foreach ($data as $key => $row) { + + $_data[] = [ + 'no' => $key+1, + 'id' => encode_id($row->SampahTekelolaId), + 'tahun' => $row->tahun, + 'bulan' => monthtString($row->bulan), + 'organik' => $row->organik, + 'sampah_anorganik' => $row->sampah_anorganik, + 'b3' => $row->b3, + 'minyak_jelantah' => $row->minyak_jelantah, + ]; + + } + + // return response()->json($_data); // Return the data as a JSON response + return response()->json($_data); + + } + /** * Store a newly created resource in storage. */ public function store(Request $request) { - // + try { + $data = SampahTerkelola::updateOrCreate([ + 'tahun' => date('Y'), + 'bulan' => $request->bulan, + 'ms_sekolah_id' => session('sekolah_id'), + ],[ + 'tahun' => date('Y'), + 'ms_sekolah_id' => session('sekolah_id'), + 'bulan' => $request->bulan, + 'organik' => $request->organik, + 'sampah_anorganik' => $request->anorganik, + 'b3' => $request->b3, + 'minyak_jelantah' => $request->minyak_jelantah, + ]); + + return redirect()->back()->with([ + 'message' => 'Berhasil update data', + 'type' => 'success', + ]); + } catch (\Throwable $th) { + //throw $th; + + dd($th); + } + + + } /** diff --git a/app/Models/SampahTerkelola.php b/app/Models/SampahTerkelola.php index 09a6eee..d2975a2 100644 --- a/app/Models/SampahTerkelola.php +++ b/app/Models/SampahTerkelola.php @@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model; class SampahTerkelola extends Model { use HasFactory; + + protected $table = 'sampah_terkelola'; + protected $guarded = []; + protected $primaryKey = 'SampahTerkelolaId'; } diff --git a/resources/views/modules/sampah/index.blade.php b/resources/views/modules/sampah/index.blade.php index 59e6591..91df594 100644 --- a/resources/views/modules/sampah/index.blade.php +++ b/resources/views/modules/sampah/index.blade.php @@ -33,13 +33,13 @@ id="grid-data"> - # + {{-- # --}} No - Sekolah - Tahun + {{-- Sekolah --}} + Tahun Bulan Organik - An Organik + An Organik B3 Minyak Jelantah @@ -62,82 +62,116 @@
-