main
ilhamwara 2025-03-19 14:56:22 +07:00
parent 414a2817b7
commit ff118b0a53
14 changed files with 214 additions and 89 deletions

View File

@ -3,6 +3,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Kuesioner;
use App\Models\ProfileSekolah;
use App\Models\Master\FormKriteria;
use App\Models\Penilaian;
class HomeController extends Controller class HomeController extends Controller
{ {
@ -33,6 +37,11 @@ class HomeController extends Controller
$data['title'] = 'Dashboard'; $data['title'] = 'Dashboard';
$data['group'] = session('group_alias'); $data['group'] = session('group_alias');
if(session('group_alias') == 'sekolah'){ if(session('group_alias') == 'sekolah'){
$data['usulan'] = Kuesioner::where('ms_sekolah_id',session('sekolah_id'))->where('tahun',date('Y'))->first();
$data['profile'] = ProfileSekolah::where('ms_sekolah_id',session('sekolah_id'))->first();
$data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->count();
$data['penilaian'] = Penilaian::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->count();
return view($this->template.'.sekolah', $data); return view($this->template.'.sekolah', $data);
}else{ }else{
return view($this->template.'.admin', $data); return view($this->template.'.admin', $data);

View File

@ -9,7 +9,9 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use App\Models\ProfileSekolah as Profile; use App\Models\ProfileSekolah as Profile;
use App\Models\Kuesioner; use App\Models\Kuesioner;
use App\Models\KuesionerLog;
use App\Models\Master\Provinsi; use App\Models\Master\Provinsi;
use App\Models\Master\Sekolah;
class KuesionerController extends Controller class KuesionerController extends Controller
{ {
@ -19,7 +21,18 @@ class KuesionerController extends Controller
public function index() public function index()
{ {
permission('is_read', $this->route, 'module',true); permission('is_read', $this->route, 'module',true);
if(auth()->user()->group->alias == 'sekolah'){
if(session('group_alias') == 'sekolah'){
$data['profile'] = Profile::where('ms_sekolah_id',session('sekolah_id'))->first();
if(!@$data['profile']->data_jumlah && !@$data['profile']->penghematan_air && !@$data['profile']->penghematan_listrik){
return redirect('profile-sekolah/')->with([
'message' => 'Silahkan lengkapi data profile sekolah',
'type' => 'error',
]);
}
return redirect('kuesioner/update/'.encode_id(session('sekolah_id'))); return redirect('kuesioner/update/'.encode_id(session('sekolah_id')));
} }
@ -88,11 +101,13 @@ class KuesionerController extends Controller
$data['kuesioner'] = $kuesioner; $data['kuesioner'] = $kuesioner;
} }
$data['nama_sekolah'] = $kuesioner->sekolah->nama_sekolah; $sekolah = Sekolah::where('MsSekolahId',$keyId)->first();
$data['npsn'] = $kuesioner->sekolah->npsn;
$data['status'] = $kuesioner->sekolah->status; $data['nama_sekolah'] = @$sekolah->nama_sekolah;
$data['alamat_sekolah'] = $kuesioner->profile->alamat_sekolah; $data['npsn'] = @$sekolah->npsn;
$data['tingkat'] = $kuesioner->profile->tingkat->name; $data['status'] = @$sekolah->status;
$data['alamat_sekolah'] = @$sekolah->profile->alamat_sekolah;
$data['tingkat'] = @$sekolah->profile->tingkat->name;
$media = json_decode(@$kuesioner->media); $media = json_decode(@$kuesioner->media);
$data['selectedMediaValues'] = collect($media)->pluck('value')->toArray(); // Ambil value yang dipilih $data['selectedMediaValues'] = collect($media)->pluck('value')->toArray(); // Ambil value yang dipilih
@ -298,6 +313,19 @@ class KuesionerController extends Controller
$insert->tim_adiwiyata_link = @$request->tim_adiwiyata_link; $insert->tim_adiwiyata_link = @$request->tim_adiwiyata_link;
$insert->save(); $insert->save();
//kuesioner log
$log = new KuesionerLog;
$log->kuesioner_id = $insert->KuesionerId;
$log->ms_sekolah_id = session('sekolah_id');
$log->npsn = session('npsn');
$log->ms_group_id = session('group_id');
$log->step = 'create_kuesioner';
$log->status = 0;
$log->created_by = auth()->user()->id;
$log->save();
logActivity($request, __('Create',['val' => strtolower(__('Title',['val' => 'Kuesioner Leveling User ID : '.auth()->user()->id]))])); logActivity($request, __('Create',['val' => strtolower(__('Title',['val' => 'Kuesioner Leveling User ID : '.auth()->user()->id]))]));
return redirect()->back()->with([ return redirect()->back()->with([

View File

@ -47,6 +47,7 @@ class UserSekolahController extends Controller
if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){ if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){
$action .= '<a href="'.url('management/user_sekolah/update/'.encode_id($row->id)).'" data-toggle="tooltip" title="Edit Data" class="btn btn-xs btn-block btn-primary"><i class="fal fa-pencil text-white"></i></a>'; $action .= '<a href="'.url('management/user_sekolah/update/'.encode_id($row->id)).'" data-toggle="tooltip" title="Edit Data" class="btn btn-xs btn-block btn-primary"><i class="fal fa-pencil text-white"></i></a>';
if(session('group_id') == 1){ if(session('group_id') == 1){
$action .= '<a href="#" data-href="'.url('management/user/forcelogin/'.encode_id($row->id)).'" data-toggle="tooltip" title="Force Login" class="forcelogin btn btn-xs btn-block btn-success"><i class="fal fa-user text-white"></i></a>';
$action .= '<a href="#" data-href="'.url('management/user_sekolah/delete/'.encode_id($row->id)).'" data-toggle="tooltip" title="Edit Data" class="remove_data btn btn-xs btn-block btn-danger"><i class="fal fa-trash text-white"></i></a>'; $action .= '<a href="#" data-href="'.url('management/user_sekolah/delete/'.encode_id($row->id)).'" data-toggle="tooltip" title="Edit Data" class="remove_data btn btn-xs btn-block btn-danger"><i class="fal fa-trash text-white"></i></a>';
} }
} }

View File

@ -18,6 +18,13 @@ class KriteriaController extends Controller
{ {
permission('is_read', $this->route, 'module',true); permission('is_read', $this->route, 'module',true);
if(Kuesioner::where('ms_sekolah_id',session('sekolah_id'))->where('tahun',date('Y'))->count() == 0){
return redirect('kuesioner/update/'.encode_id(session('sekolah_id')))->with([
'message' => 'Maaf anda belum melakukan isi kuesioner, silahkan isi terlebih dahulu',
'type' => 'error',
]);
}
$data['title'] = $this->title; $data['title'] = $this->title;
$data['route'] = $this->route; $data['route'] = $this->route;
$data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray(); $data['page'] = FormKriteria::select('page_number')->groupBy('page_number')->orderBy('page_number','ASC')->pluck('page_number')->toArray();

View File

@ -5,7 +5,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Usulan extends Model class KuesionerLog extends Model
{ {
use HasFactory; use HasFactory;
protected $table = 'kuesioner_log';
protected $primaryKey = 'KuesionerLogId';
protected $guarded = [];
} }

View File

@ -24,6 +24,11 @@ class Sekolah extends Model
'long', 'long',
]; ];
public function profile()
{
return $this->belongsTo(\App\Models\ProfileSekolah::class,'MsSekolahId','ms_sekolah_id');
}
public function provinsi() public function provinsi()
{ {
return $this->belongsTo(\App\Models\Master\Provinsi::class,'ms_provinsi_id','MsProvinsiId'); return $this->belongsTo(\App\Models\Master\Provinsi::class,'ms_provinsi_id','MsProvinsiId');

View File

@ -11,16 +11,20 @@ class Penilaian extends Model
protected $table = 'penilaian'; protected $table = 'penilaian';
protected $primaryKey = 'PenilaianId'; protected $primaryKey = 'PenilaianId';
protected $fillable = [
'ms_sekolah_id', protected $guarded = [];
'npsn',
// 'ms_form_kriteria_id', // protected $fillable = [
'key', // 'ms_sekolah_id',
'page_number', // 'npsn',
'value', // // 'ms_form_kriteria_id',
'skor', // 'key',
'status', // 'page_number',
'tahun', // 'value',
'created_by', // 'skor',
]; // 'status',
// 'tahun',
// 'created_by',
// 'level_adiwiyata',
// ];
} }

View File

@ -21,6 +21,7 @@ return new class extends Migration
$table->json('value')->nullable(); $table->json('value')->nullable();
$table->integer('skor')->default(0); $table->integer('skor')->default(0);
$table->integer('status')->nullable(); $table->integer('status')->nullable();
$table->integer('level_adiwiyata')->default(0);
$table->year('tahun')->nullable(); $table->year('tahun')->nullable();
$table->integer('created_by'); $table->integer('created_by');
$table->timestamps(); $table->timestamps();

View File

@ -1,27 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('usulans', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('usulans');
}
};

View File

@ -1,27 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('usulan_approvals', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('usulan_approvals');
}
};

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('kuesioner_log', function (Blueprint $table) {
$table->id('KuesionerLogId');
$table->integer('kuesioner_id');
$table->integer('ms_sekolah_id');
$table->integer('npsn');
$table->integer('ms_group_id');
$table->string('step')->nullable();
$table->text('note')->nullable();
$table->integer('status');
$table->integer('created_by');
$table->timestampsTz();
$table->foreign('kuesioner_id')->references('KuesionerId')->on('kuesioner')->onDelete('cascade');
$table->foreign('ms_sekolah_id')->references('MsSekolahId')->on('ms_sekolah')->onDelete('cascade');
$table->foreign('ms_group_id')->references('MsGroupId')->on('ms_group')->onDelete('cascade');
$table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('kuesioner_log');
}
};

View File

@ -40,25 +40,40 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="card"> <div class="">
<div class="card-body"> <div class="">
<div class="row"> <div class="row">
<div class="col-md-12 p-0"> <div class="col-md-12">
<ul class="listItem"> <ul class="listItem">
<li> <li class="bg-success text-white">
<h6><div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp;Registrasi Akun</h6> <h6 class="m-0">
<!-- <div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp; -->
Registrasi Akun
</h6>
</li> </li>
<li class="profile"> <li class="profile {{@$profile->data_jumlah && @$profile->penghematan_air && @$profile->penghematan_listrik ? 'bg-success text-white' : ''}}">
<h6><div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp;Melengkapi Data Profile</h6> <h6 class="m-0">
<!-- <div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp; -->
Melengkapi Data Profile
</h6>
</li> </li>
<li class="kuesioner"> <li class="kuesioner {{@$kuesioner ? 'bg-success text-white' : ''}}">
<h6><div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp;Mengisi Kuesioner Leveling</h6> <h6 class="m-0">
<!-- <div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp; -->
Mengisi Kuesioner Leveling
</h6>
</li> </li>
<li> <li class="{{@$kuesioner->status == 1 ? 'bg-success text-white' : ''}}">
<h6><div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp;Menunggu Diusulkan CSA</h6> <h6 class="m-0">
<!-- <div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp; -->
Menunggu Diusulkan CSA
</h6>
</li> </li>
<li> <li class="{{@$page == @$penilaian ? 'bg-success text-white' : ''}}">
<h6><div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp;Melengkapi Data CSA</h6> <h6 class="m-0">
<!-- <div class="rounded-circle bg-fusion-50 width-1 height-1 text-center d-inline-block bg-success"><i class="mt-1 fal fa-check text-white"></i></div>&nbsp; -->
Melengkapi Data CSA
</h6>
</li> </li>
</ul> </ul>
</div> </div>
@ -109,9 +124,27 @@
<div class="card-body"> <div class="card-body">
<div class="mb-4"> <div class="mb-4">
<h4><b>Status Usulan</b></h4> <h4><b>Status Usulan</b></h4>
<p>Sekolah diusulan untuk menjadi CSA (Calon Sekolah Adiwiyata) Nasional</p> @if(@$usulan && (@$usulan->status == 1))
<span class="text-danger">Silahkan lengkapi data pada menu Usulan Adiwiyata.</span> <?php
if(@$usulan->level == 0){
$textLevel = 'Kabupaten/Kota';
}elseif(@$usulan->level == 1){
$textLevel = 'Provinsi';
}elseif(@$usulan->level == 2){
$textLevel = 'Nasional';
}elseif(@$usulan->level == 3){
$textLevel = 'Mandiri';
}
?>
<p>Sekolah diusulan untuk menjadi CSA (Calon Sekolah Adiwiyata) {{@$textLevel}}</p>
<span class="text-danger">Silahkan lengkapi data pada menu Usulan Adiwiyata.</span>
@else
<div class="alert alert-danger">
Belum ada data usulan
</div>
@endif
</div> </div>
@if(@$usulan)
<table class="table table-bordered"> <table class="table table-bordered">
<tr class="bg-success text-white"> <tr class="bg-success text-white">
<th colspan="2"><b>Penghargaan Terakhir</b></th> <th colspan="2"><b>Penghargaan Terakhir</b></th>
@ -130,6 +163,7 @@
<td style="vertical-align: middle;">--</td> <td style="vertical-align: middle;">--</td>
</tr> </tr>
</table> </table>
@endif
</div> </div>
</div> </div>
</div> </div>

View File

@ -74,7 +74,10 @@
<td colspan="2"><h4><b>{{@$nama_sekolah}}</b></h4></td> <td colspan="2"><h4><b>{{@$nama_sekolah}}</b></h4></td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><span class="badge badge-primary">{{@$tingkat}}</span> <span class="badge badge-success">{{$status}}</span></td> <td colspan="2">
<span class="badge badge-primary">{{@$tingkat}}</span>
<span class="badge badge-success">{{@$status}}</span>
</td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><p>{{@$alamat_sekolah}}</p></td> <td colspan="2"><p>{{@$alamat_sekolah}}</p></td>

View File

@ -66,6 +66,49 @@
@endsection @endsection
@section('page-js') @section('page-js')
<script type="text/javascript"> <script type="text/javascript">
$("#grid-data").on("click", ".forcelogin", function() {
var base_url = $(this).attr('data-href');
var id = $(this).attr('data-id');
swal({
title: "Force Login!",
text: "Apa anda yakin ingin login sebagai akun ini ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#3F7D58",
confirmButtonText: "Ya Masuk Sekarang",
cancelButtonText: "Tidak",
closeOnConfirm: true,
closeOnCancel: true
},
function(isConfirm) {
if(isConfirm){
request = $.ajax({
url: base_url,
type: "GET",
});
// Callback handler that will be called on success
request.done(function(response, textStatus, jqXHR){
console.log(response);
toastr.success("Berhasil Login", 'Berhasil!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
window.location.href = '{{url("/dashboard")}}';
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};
});
// Callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown){
toastr.error(
"Gagal "+textStatus, errorThrown
);
});
}
});
return false;
});
$("#grid-data").on("click", ".remove_data", function() { $("#grid-data").on("click", ".remove_data", function() {
var base_url = $(this).attr('data-href'); var base_url = $(this).attr('data-href');
var id = $(this).attr('data-id'); var id = $(this).attr('data-id');