diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index c4fa1a4..673ad7c 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -11,6 +11,7 @@ use App\Models\DokumenAdministrasi;
use App\Models\Penilaian;
use App\Models\SK;
use App\Models\Usulan;
+use App\Models\SampahTerkelola;
class HomeController extends Controller
{
@@ -59,6 +60,40 @@ class HomeController extends Controller
$data['sk'] = SK::where('tahun',date('Y'))->where('sekolah','like','%'.session('sekolah_id').'%')->first();
$data['log'] = KuesionerLog::where('kuesioner_id',@$data['kuesioner']->KuesionerId)->orderBy('created_at','DESC')->first();
+ $series = SampahTerkelola::where('ms_sekolah_id',session('sekolah_id'))->where('tahun',date('Y'))->orderBy('bulan','ASC')->get();
+ $organik = array_fill(1, 12, 0);
+ $anorganik = array_fill(1, 12, 0);
+ $b3 = array_fill(1, 12, 0);
+ $minyak = array_fill(1, 12, 0);
+
+ foreach ($series as $row) {
+ $bulan = (int) $row->bulan;
+
+ $organik[$bulan] = (int) $row->organik;
+ $anorganik[$bulan] = (int) $row->sampah_anorganik;
+ $b3[$bulan] = (int) $row->b3;
+ $minyak[$bulan] = (int) $row->minyak_jelantah;
+ }
+
+ $data['series'] = [
+ [
+ 'name' => 'Organik',
+ 'data' => array_values($organik),
+ ],
+ [
+ 'name' => 'Anorganik',
+ 'data' => array_values($anorganik),
+ ],
+ [
+ 'name' => 'B3',
+ 'data' => array_values($b3),
+ ],
+ [
+ 'name' => 'Minyak Jelantah',
+ 'data' => array_values($minyak),
+ ],
+ ];
+
return view($this->template.'.sekolah', $data);
}else{
if(session('kabupaten_id') != ''){
@@ -101,8 +136,14 @@ class HomeController extends Controller
$data['total_sekolah_prov'] = Kuesioner::where('tahun',date('Y'))->where('level',1)->where('status',11)->count();
$data['total_sekolah_nasional'] = Kuesioner::where('tahun',date('Y'))->where('level',2)->where('status',11)->count();
$data['total_sekolah_mandiri'] = Kuesioner::where('tahun',date('Y'))->where('level',3)->where('status',11)->count();
- }
+ $data['summary'] = SampahTerkelola::where('tahun', date('Y'))
+ ->selectRaw('SUM(organik::integer) as organik,
+ SUM(sampah_anorganik::integer) as anorganik,
+ SUM(b3::integer) as b3,
+ SUM(minyak_jelantah::integer) as minyak
+ ')->first();
+ }
$data['route'] = 'modules';
return view($this->template.'.admin', $data);
diff --git a/app/Http/Controllers/SampahController.php b/app/Http/Controllers/SampahController.php
index 67282fd..f038043 100644
--- a/app/Http/Controllers/SampahController.php
+++ b/app/Http/Controllers/SampahController.php
@@ -31,20 +31,50 @@ class SampahController extends Controller
public function grid(Request $request)
{
+ if(session('group_alias') == 'sekolah'){
+ $data = SampahTerkelola::where('ms_sekolah_id',session('sekolah_id'))
+ ->orderBy('tahun','DESC')
+ ->orderBy('bulan','ASC');
+ }else{
+ if(session('kabupaten_id') != ''){
+ $data = SampahTerkelola::whereHas('sekolah',function($query){
+ $query->where('ms_kabupaten_id',session('kabupaten_id'));
+ })->orderBy('tahun','DESC')
+ ->orderBy('bulan','ASC');
+
+ }else{
+ $data = SampahTerkelola::with(['sekolah'])->orderBy('tahun','DESC')
+ ->orderBy('bulan','ASC');
+ }
+ }
- $data = SampahTerkelola::where('ms_sekolah_id',session('sekolah_id'))
- ->orderBy('tahun','DESC')
- ->orderBy('bulan','ASC')
- ->get();
+ if(@request()->tahun){
+ $tahun = request()->tahun;
+ }else{
+ $tahun = date('Y');
+ }
+
+ $data->where('tahun',$tahun);
+
+
$_data = [];
+
- foreach ($data as $key => $row) {
+ foreach ($data->get() as $key => $row) {
+
+ $sekolah = '';
+ $sekolah .= @$row->sekolah->nama_sekolah.'
';
+ $sekolah .= ''.@$row->sekolah->profile->tingkat->name.' ';
+ $sekolah .= ''.@$row->sekolah->profile->status_sekolah.' ';
+ $sekolah .= 'Level '.levelAdiwiyata($row->sekolah->npsn).'';
+ $sekolah .= ''.@$row->sekolah->profile->alamat_sekolah.' ';
$_data[] = [
'no' => $key+1,
'id' => encode_id($row->SampahTekelolaId),
'tahun' => $row->tahun,
+ 'sekolah' => $sekolah,
'bulan' => monthtString($row->bulan),
'organik' => $row->organik,
'sampah_anorganik' => $row->sampah_anorganik,
diff --git a/app/Models/SampahTerkelola.php b/app/Models/SampahTerkelola.php
index d2975a2..2f2580c 100644
--- a/app/Models/SampahTerkelola.php
+++ b/app/Models/SampahTerkelola.php
@@ -12,4 +12,9 @@ class SampahTerkelola extends Model
protected $table = 'sampah_terkelola';
protected $guarded = [];
protected $primaryKey = 'SampahTerkelolaId';
+
+ public function sekolah()
+ {
+ return $this->belongsTo(\App\Models\Master\Sekolah::class,'ms_sekolah_id','MsSekolahId');
+ }
}
diff --git a/public/assets/logo.png b/public/assets/logo.png
new file mode 100644
index 0000000..4783cd9
Binary files /dev/null and b/public/assets/logo.png differ
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
index e04a45a..f3c3657 100644
--- a/resources/views/auth/login.blade.php
+++ b/resources/views/auth/login.blade.php
@@ -43,7 +43,8 @@
+| # | --}}No | - {{--Sekolah | --}} + @if(session('group_alias') != 'sekolah') +Sekolah | + @endifTahun | Bulan | -Organik | -An Organik | -B3 | +Organik (Kg) | +An Organik (Kg) | +B3 (Kg) | Minyak Jelantah |
|---|