214 lines
8.8 KiB
PHP
214 lines
8.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Modules\Usulan;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Master\Provinsi;
|
|
use App\Models\Kuesioner;
|
|
use App\Models\KuesionerLog;
|
|
use App\Models\Master\Sekolah;
|
|
use App\Models\Master\FormKriteria;
|
|
use App\Models\DokumenAdministrasi;
|
|
use App\Models\Penilaian;
|
|
|
|
class CSAKController extends Controller
|
|
{
|
|
private $template = 'modules.usulan.csak';
|
|
private $route = 'modules.usulan.csak';
|
|
private $title = 'Usulan CSAK';
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$data['route'] = $this->route;
|
|
$data['title'] = $this->title;
|
|
$data['provinsi'] = Provinsi::where('kode_wilayah','010000')->get();
|
|
|
|
return view($this->template.'.index',$data);
|
|
}
|
|
public function update($id)
|
|
{
|
|
$keyId = decode_id($id);
|
|
$data['kuesioner'] = Kuesioner::where('ms_sekolah_id',$keyId)->where('tahun',date('Y'))->first();
|
|
$data['sekolah'] = Sekolah::find($keyId);
|
|
$data['route'] = $this->route;
|
|
$data['title'] = $this->title;
|
|
$data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray();
|
|
|
|
$jumlah = json_decode($data['sekolah']->profile->data_jumlah);
|
|
$data['jumlah_peserta_didik'] = @$jumlah->jumlah_peserta_didik;
|
|
$data['jumlah_tenaga_pendidik'] = @$jumlah->jumlah_tenaga_pendidik;
|
|
$data['jumlah_tenaga_kependidikan'] = @$jumlah->jumlah_tenaga_kependidikan;
|
|
$data['jumlah_warga_sekolah_lainnya'] = @$jumlah->jumlah_warga_sekolah_lainnya;
|
|
$data['jumlah_biopori'] = @$jumlah->jumlah_biopori;
|
|
$data['jumlah_sumur_resapan'] = @$jumlah->jumlah_sumur_resapan;
|
|
$data['jumlah_pohon'] = @$jumlah->jumlah_pohon;
|
|
|
|
$air = json_decode($data['sekolah']->profile->penghematan_air);
|
|
$data['air_sebelum_pblhs'] = @$air->air_sebelum_pblhs;
|
|
$data['air_setelah_pblhs'] = @$air->air_setelah_pblhs;
|
|
|
|
$listrik = json_decode($data['sekolah']->profile->penghematan_listrik);
|
|
$data['listrik_sebelum_pblhs'] = @$listrik->listrik_sebelum_pblhs;
|
|
$data['listrik_setelah_pblhs'] = @$listrik->listrik_setelah_pblhs;
|
|
$data['luas_ruangan_ac'] = @$listrik->luas_ruangan_ac;
|
|
$data['luas_ruangan_non_ac'] = @$listrik->luas_ruangan_non_ac;
|
|
$data['jumlah_kader'] = @$listrik->jumlah_kader;
|
|
|
|
$data['dokumen'] = DokumenAdministrasi::where('ms_sekolah_id',$keyId)->where('tahun',date('Y'))->first();
|
|
|
|
return view($this->template.'.form',$data);
|
|
}
|
|
public function resume($id)
|
|
{
|
|
// permission('is_read', $this->route, 'module',true);
|
|
|
|
$data['title'] = $this->title;
|
|
$data['route'] = $this->route;
|
|
$keyId = decode_id($id);
|
|
$data['sekolah'] = Sekolah::find($keyId);
|
|
$data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray();
|
|
|
|
return view($this->template.'.resume',$data);
|
|
}
|
|
|
|
public function grid(Request $request)
|
|
{
|
|
$kuesioner = Kuesioner::where('level',0)->orderBy('created_at','DESC')->get();
|
|
foreach ($kuesioner as $key => $row) {
|
|
|
|
$action = '';
|
|
|
|
if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){
|
|
if($row->status == 3){
|
|
$action .= '<a href="'.url('usulan/csak/update/'.encode_id($row->ms_sekolah_id)).'" data-toggle="tooltip" title="View Data" class="btn btn-xs btn-block btn-primary"><i class="fal fa-edit text-white"></i></a>';
|
|
}
|
|
}
|
|
|
|
if($row->level == 0){
|
|
$penghargaan = '<i class="fal fa-trophy"></i> Belum Pernah';
|
|
}elseif($row->level == 1){
|
|
$penghargaan = '<i class="fal fa-trophy"></i> Adiwiyata Kab/Kota';
|
|
}elseif($row->level == 2){
|
|
$penghargaan = '<i class="fal fa-trophy"></i> Adiwiyata Provinsi';
|
|
}elseif($row->level == 3){
|
|
$penghargaan = '<i class="fal fa-trophy"></i> Adiwiyata Nasional';
|
|
}elseif($row->level == 4){
|
|
$penghargaan = '<i class="fal fa-trophy"></i> Adiwiyata Mandiri';
|
|
}
|
|
|
|
$penilaian = '';
|
|
$penilaian .= '<span style="width:100%;" class="text-left badge badge-secondary"> Sekolah : '.getNilaiAll('sekolah',$row->ms_sekolah_id).'</span></br>';
|
|
$penilaian .= '<span style="width:100%;" class="text-left badge badge-primary"> Kota : '.getNilaiAll('kota',$row->ms_sekolah_id).'</span></br>';
|
|
// $penilaian .= '<span style="width:100%;" class="text-left badge badge-success"> Provinsi : '.getNilaiAll('provinsi',$row->ms_sekolah_id).'</span></br>';
|
|
|
|
$log = KuesionerLog::where('kuesioner_id',$row->KuesionerId)->orderBy('created_at','DESC')->first();
|
|
$progress = '<span class="badge badge-warning">'.str_replace('_',' ',\Str::title($log->step)).'</span>';
|
|
|
|
$sekolah = '';
|
|
$sekolah .= @$row->sekolah->nama_sekolah.'<br>';
|
|
$sekolah .= '<span class="badge badge-success">'.@$row->profile->tingkat->name.'</span> ';
|
|
$sekolah .= '<span class="badge badge-primary">'.@$row->profile->status_sekolah.'</span> ';
|
|
|
|
$_data[] = [
|
|
'no' => $key+1,
|
|
'id' => encode_id($row->id),
|
|
'npsn' => $row->sekolah->npsn,
|
|
'nama' => $sekolah,
|
|
'status_level' => '<span style="width:100%" class="badge badge-secondary">Level '.levelAdiwiyata($row->npsn).'</span>',
|
|
'wilayah' => $row->sekolah->kabupaten->name,
|
|
'penghargaan' => $penghargaan,
|
|
'penilaian' => $penilaian,
|
|
'progress' => $progress,
|
|
'action' => $action,
|
|
];
|
|
|
|
}
|
|
|
|
return response()->json($_data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$sekolahId = decode_id($request->sekolah);
|
|
$dokumen = DokumenAdministrasi::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->first();
|
|
|
|
if((@$dokumen->nama_dalam_sk == 0) || (@$dokumen->sk_ttd == 0) || (@$dokumen->waktu_penetapan == 0)){
|
|
return response()->json(['status' => false,'message' => 'Data Dokumen Administrasi Belum Diisi!']);
|
|
}
|
|
|
|
if($request['validasi'] == 1){
|
|
$step = 'validasi_usulan_diteruskan';
|
|
$status = 4;
|
|
}elseif($request['validasi'] == 2){
|
|
$step = 'validasi_usulan_dikembalikan';
|
|
$status = 5;
|
|
}else{
|
|
return response()->json(['validasi' => false,'message' => 'Maaf Terjadi Kesalahan Dalam Input Data!']);
|
|
}
|
|
|
|
$soal = Penilaian::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray();
|
|
$penilaian = Penilaian::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->where('status',1)->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray();
|
|
|
|
if(count($soal) != count($penilaian)){
|
|
return response()->json(['validasi' => false,'message' => 'Maaf Penilaian Belum Lengkap!']);
|
|
}
|
|
|
|
$kuesioner = Kuesioner::where('ms_sekolah_id',$sekolahId)->where('tahun',date('Y'))->first();
|
|
$kuesioner->catatan_usulan = $request['catatan_validasi'];
|
|
$kuesioner->status = $status;
|
|
$kuesioner->save();
|
|
|
|
//kuesioner log
|
|
$log = new KuesionerLog;
|
|
$log->kuesioner_id = $kuesioner->KuesionerId;
|
|
$log->ms_sekolah_id = $kuesioner->ms_sekolah_id;
|
|
$log->npsn = $kuesioner->npsn;
|
|
$log->ms_group_id = session('group_id');
|
|
$log->step = @$step;
|
|
$log->status = $status;
|
|
$log->created_by = auth()->user()->id;
|
|
$log->save();
|
|
|
|
return response()->json(['status' => true,'message' => 'Berhasil update data!']);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(string $id)
|
|
{
|
|
//
|
|
}
|
|
}
|