update
parent
a01e890d03
commit
122d735ed8
|
|
@ -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')) {
|
if (!function_exists('listSekolah')) {
|
||||||
function listSekolah($sekolah){
|
function listSekolah($sekolah){
|
||||||
|
|
||||||
|
|
@ -820,7 +852,7 @@ if (!function_exists('formKriteria')) {
|
||||||
$key = 'number_'.$keyKriteria.'_'.$keyOption;
|
$key = 'number_'.$keyKriteria.'_'.$keyOption;
|
||||||
|
|
||||||
$html .= '<div class="custom-control custom-checkbox m-2">';
|
$html .= '<div class="custom-control custom-checkbox m-2">';
|
||||||
$html .= '<input type="checkbox" '.@$checked.' class="custom-control-input is-required" id="'.$key.'" value="'.$dataOption.'" name="input_'.$data->key.'[]">';
|
$html .= '<input type="checkbox" '.@$checked.' class="custom-control-input is-required checklistInput" id="'.$key.'" data-value="'.preg_replace('/[^a-z0-9]+/', '_', strtolower($dataOption)).'" value="'.$dataOption.'" name="input_'.$data->key.'[]">';
|
||||||
$html .= '<label class="custom-control-label" for="'.$key.'">'.$dataOption.'</label>';
|
$html .= '<label class="custom-control-label" for="'.$key.'">'.$dataOption.'</label>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
@ -835,7 +867,7 @@ if (!function_exists('formKriteria')) {
|
||||||
$key = 'number_'.$keyKriteria.'_'.$keyOption;
|
$key = 'number_'.$keyKriteria.'_'.$keyOption;
|
||||||
|
|
||||||
$html .= '<div class="custom-control custom-radio m-2">';
|
$html .= '<div class="custom-control custom-radio m-2">';
|
||||||
$html .= '<input '.(@$value == $dataOption ? 'checked' : (@$valueOld == $dataOption ? 'checked' : '') ).' type="radio" class="custom-control-input is-required" id="'.$key.'" value="'.$dataOption.'" name="input_'.$data->key.'">';
|
$html .= '<input '.(@$value == $dataOption ? 'checked' : (@$valueOld == $dataOption ? 'checked' : '') ).' type="radio" class="custom-control-input is-required checklistInput" data-value="'.preg_replace('/[^a-z0-9]+/', '_', strtolower($dataOption)).'" id="'.$key.'" value="'.$dataOption.'" name="input_'.$data->key.'">';
|
||||||
$html .= '<label class="custom-control-label" for="'.$key.'">'.$dataOption.'</label>';
|
$html .= '<label class="custom-control-label" for="'.$key.'">'.$dataOption.'</label>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
@ -901,12 +933,28 @@ if (!function_exists('formKriteria')) {
|
||||||
$catatan = Penilaian::where('key','catatan')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first();
|
$catatan = Penilaian::where('key','catatan')->where('page_number',$page_number)->where('ms_sekolah_id',$idSekolah)->first();
|
||||||
$valueCatatan = json_decode(@$catatan->value);
|
$valueCatatan = json_decode(@$catatan->value);
|
||||||
|
|
||||||
|
$kriteriaFirst = FormKriteria::where('page_number',$page_number)->first();
|
||||||
|
|
||||||
if(session('group_alias') == 'sekolah'){
|
if(session('group_alias') == 'sekolah'){
|
||||||
$html .= '<div class="card mb-2 removeFormKriteria">';
|
$html .= '<div class="card mb-2 removeFormKriteria">';
|
||||||
$html .= '<input type="hidden" name="key" value="'.encode_id($page_number).'">';
|
$html .= '<input type="hidden" name="key" value="'.encode_id($page_number).'">';
|
||||||
$html .= '<div class="card-body">';
|
$html .= '<div class="card-body">';
|
||||||
|
$html .= '<div class="d-flex justify-content-between align-items-center mb-3">';
|
||||||
$html .= '<h6><b>Upload File Bukti</b></h6>';
|
$html .= '<h6><b>Upload File Bukti</b></h6>';
|
||||||
|
// $html .= '<a class="btn btn-primary text-white"><i class="fal fa-plus"></i> Tambah File</a>';
|
||||||
|
|
||||||
|
$html .= '</div>';
|
||||||
$html .= '<div class="form-group">';
|
$html .= '<div class="form-group">';
|
||||||
|
$html .= '<div id="dynamic-file-container"></div>';
|
||||||
|
|
||||||
|
if(($kriteriaFirst->type == 'textarea') || ($kriteriaFirst->type == 'number')){
|
||||||
|
// $html .= '<div class="mb-3 file-item">';
|
||||||
|
// $html .= '<input type="hidden" name="input_upload_files_label[]" value="">';
|
||||||
|
// $html .= '<input type="file" name="input_upload_files[]" class="removeFormKriteria uploadedFiles is-required form-control">';
|
||||||
|
// $html .= '<span><i>Ukuran Maksimal File : 10MB, Ekstension File : .pdf,.png,.jpeg,.jpg</i></span>';
|
||||||
|
// $html .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
$html .= '<div style="border: 2px dashed #0087F7; padding: 20px;" class="dropzone" id="my-dropzone">
|
$html .= '<div style="border: 2px dashed #0087F7; padding: 20px;" class="dropzone" id="my-dropzone">
|
||||||
<div class="dz-message">
|
<div class="dz-message">
|
||||||
Drop PDF files here or click to upload
|
Drop PDF files here or click to upload
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ class KriteriaController extends Controller
|
||||||
$idSekolah = session('sekolah_id');
|
$idSekolah = session('sekolah_id');
|
||||||
$sekolah = Sekolah::find($idSekolah);
|
$sekolah = Sekolah::find($idSekolah);
|
||||||
}
|
}
|
||||||
|
// dd(request()->all());
|
||||||
if($key == 'input_upload_files'){
|
if($key == 'input_upload_files'){
|
||||||
|
|
||||||
$filePaths = [];
|
$filePaths = [];
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\SampahTerkelola;
|
||||||
|
|
||||||
class SampahController extends Controller
|
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.
|
* Store a newly created resource in storage.
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
class SampahTerkelola extends Model
|
class SampahTerkelola extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'sampah_terkelola';
|
||||||
|
protected $guarded = [];
|
||||||
|
protected $primaryKey = 'SampahTerkelolaId';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,13 @@
|
||||||
id="grid-data">
|
id="grid-data">
|
||||||
<thead class="bg-primary-light text-primary">
|
<thead class="bg-primary-light text-primary">
|
||||||
<tr>
|
<tr>
|
||||||
<th data-field="action">#</th>
|
{{-- <th data-field="action">#</th> --}}
|
||||||
<th data-field="no">No</th>
|
<th data-field="no">No</th>
|
||||||
<th data-field="sekolah">Sekolah</th>
|
{{-- <th data-field="sekolah">Sekolah</th> --}}
|
||||||
<th data-field="bulan">Tahun</th>
|
<th data-field="tahun">Tahun</th>
|
||||||
<th data-field="bulan">Bulan</th>
|
<th data-field="bulan">Bulan</th>
|
||||||
<th data-field="organik">Organik</th>
|
<th data-field="organik">Organik</th>
|
||||||
<th data-field="anorganik">An Organik</th>
|
<th data-field="sampah_anorganik">An Organik</th>
|
||||||
<th data-field="b3">B3</th>
|
<th data-field="b3">B3</th>
|
||||||
<th data-field="minyak_jelantah">Minyak Jelantah</th>
|
<th data-field="minyak_jelantah">Minyak Jelantah</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -62,10 +62,43 @@
|
||||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
|
||||||
<form action="{{ route($route.'.store') }}" method="POST">
|
<form action="{{ route($route.'.store') }}" method="POST">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
|
<div class="modal-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xl-12 form-label">Tahun</label>
|
||||||
|
<div class="col-12 pr-1">
|
||||||
|
<input type="text" class="form-control" name="tahun" value="{{ date('Y') }}" disabled>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xl-12 form-label">Bulan</label>
|
||||||
|
<div class="col-12 pr-1">
|
||||||
|
<select name="bulan" class="form-control is-required @error('bulan') is-invalid @enderror" id="">
|
||||||
|
<option value="">-- Pilih Bulan --</option>
|
||||||
|
<option value="1">Januari</option>
|
||||||
|
<option value="2">Februari</option>
|
||||||
|
<option value="3">Maret</option>
|
||||||
|
<option value="4">April</option>
|
||||||
|
<option value="5">Mei</option>
|
||||||
|
<option value="6">Juni</option>
|
||||||
|
<option value="7">Juli</option>
|
||||||
|
<option value="8">Agustus</option>
|
||||||
|
<option value="9">September</option>
|
||||||
|
<option value="10">Oktober</option>
|
||||||
|
<option value="11">November</option>
|
||||||
|
<option value="12">Desember</option>
|
||||||
|
</select>
|
||||||
|
@error('bulan')
|
||||||
|
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col-md-6 mb-2">
|
<div class="col-md-6 mb-2">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-xl-12 form-label">Sampah Organik</label>
|
<label class="col-xl-12 form-label">Sampah Organik</label>
|
||||||
|
|
@ -132,12 +165,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
<button type="button" class="btn btn-primary">Simpan</button>
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<link rel="stylesheet" href="{{asset('assets/css/formplugins/dropzone/dropzone.css')}}">
|
<link rel="stylesheet" href="{{asset('assets/css/formplugins/dropzone/dropzone.css')}}">
|
||||||
@endsection
|
@endsection
|
||||||
@section('content')
|
@section('content')
|
||||||
<form method="POST" id="form">
|
<form method="POST" id="form" enctype="multipart/form-data">
|
||||||
{{csrf_field()}}
|
{{csrf_field()}}
|
||||||
<input type="hidden" name="secure_id" value="{{encode_id($kuesioner->KuesionerId)}}">
|
<input type="hidden" name="secure_id" value="{{encode_id($kuesioner->KuesionerId)}}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -168,6 +168,47 @@
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
$(document).on('change', '.checklistInput1[type="radio"]', function () {
|
||||||
|
const value = $(this).data('value');
|
||||||
|
const label = $(this).val();
|
||||||
|
const container = $('#dynamic-file-container');
|
||||||
|
|
||||||
|
// Radio hanya 1 → hapus semua dulu
|
||||||
|
container.empty();
|
||||||
|
|
||||||
|
container.append(`
|
||||||
|
<div class="mb-3 file-item" id="file_${value}">
|
||||||
|
<label class="fw-500">Upload Dokumen ${label}</label>
|
||||||
|
<input type="hidden" name="input_upload_files_label[]" value="${value}">
|
||||||
|
<input type="file" name="input_upload_files[]" class="removeFormKriteria is-required form-control">
|
||||||
|
<span><i>Ukuran Maksimal File : 10MB, Ekstension File : .pdf,.png,.jpeg,.jpg</i></span>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('change', '.checklistInput1', function () {
|
||||||
|
const value = $(this).data('value');
|
||||||
|
const label = $(this).val();
|
||||||
|
const container = $('#dynamic-file-container');
|
||||||
|
|
||||||
|
if ($(this).is(':checked')) {
|
||||||
|
|
||||||
|
// Cegah double insert
|
||||||
|
if ($('#file_' + value).length === 0) {
|
||||||
|
container.append(`
|
||||||
|
<div class="mb-3 file-item" id="file_${value}">
|
||||||
|
<label class="fw-500">Upload Dokumen ${label}</label>
|
||||||
|
<input type="hidden" name="input_upload_files_label[]" value="${value}">
|
||||||
|
<input type="file" name="input_upload_files[]" class="removeFormKriteria is-required form-control">
|
||||||
|
<span><i>Ukuran Maksimal File : 10MB, Ekstension File : .pdf,.png,.jpeg,.jpg</i></span>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#file_' + value).remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
$('.page').on('click',function(e){
|
$('.page').on('click',function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let number = $(this).data('number');
|
let number = $(this).data('number');
|
||||||
|
|
@ -302,16 +343,16 @@
|
||||||
let value = $(this).val()?.trim(); // Pastikan nilai di-trim untuk menghindari spasi kosong
|
let value = $(this).val()?.trim(); // Pastikan nilai di-trim untuk menghindari spasi kosong
|
||||||
|
|
||||||
let uploadedFilesValue = $('.uploadedFiles').val();
|
let uploadedFilesValue = $('.uploadedFiles').val();
|
||||||
if(file == 'false'){
|
// if(file == 'false'){
|
||||||
if (!uploadedFilesValue || uploadedFilesValue === '') {
|
// if (!uploadedFilesValue || uploadedFilesValue === '') {
|
||||||
isValid = false;
|
// isValid = false;
|
||||||
$('.uploadedFiles').addClass("is-invalid");
|
// $('.uploadedFiles').addClass("is-invalid");
|
||||||
toastr.error("Harap upload minimal 1 file", 'Error!', {positionClass: 'toast-bottom-right'});
|
// toastr.error("Harap upload minimal 1 file", 'Error!', {positionClass: 'toast-bottom-right'});
|
||||||
return;
|
// return;
|
||||||
} else {
|
// } else {
|
||||||
$('.uploadedFiles').removeClass("is-invalid");
|
// $('.uploadedFiles').removeClass("is-invalid");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (type === 'radio') {
|
if (type === 'radio') {
|
||||||
// Validasi radio: setidaknya satu opsi harus dipilih
|
// Validasi radio: setidaknya satu opsi harus dipilih
|
||||||
|
|
@ -349,11 +390,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isMultiple) {
|
// if (!isMultiple) {
|
||||||
toastr.error("Harap isi minimal lebih dari 1 isian", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
// toastr.error("Harap isi minimal lebih dari 1 isian", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
||||||
// alert(".");
|
// // alert(".");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{route($route.'.store')}}", // Ganti dengan URL API-mu
|
url: "{{route($route.'.store')}}", // Ganti dengan URL API-mu
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue