ringkasan dan summary petani
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -125,7 +125,6 @@ class KolomBasisDataController extends Controller
|
||||
]);
|
||||
|
||||
$kolom->update([...$validated,
|
||||
'created_by' => auth()->id(),
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Ekosistem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Models\Ekosistem\RingkasanBasisData;
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
|
||||
use App\Rules\ValidSql;
|
||||
|
||||
class RingkasanBasisDataController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function store(Request $request, string $tabelId): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$table = TabelBasisData::find($tabelId);
|
||||
if (!$table) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data tabel tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'heading' => ['required', 'string'],
|
||||
'subheading' => ['required', 'string'],
|
||||
'query_ringkasan' => ['required', 'string', new ValidSql()],
|
||||
]);
|
||||
|
||||
RingkasanBasisData::create([
|
||||
'tabel_id' => $tabelId,
|
||||
'heading' => $validated['heading'],
|
||||
'subheading' => $validated['subheading'],
|
||||
'query_ringkasan' => $validated['query_ringkasan'],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ringkasan basis data berhasil ditambahkan.'
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function show(string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$ringkasan = RingkasanBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$ringkasan) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data ringkasan tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json(['data' => $ringkasan, 'status' => 'success']);
|
||||
}
|
||||
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$ringkasan = RingkasanBasisData::find($id);
|
||||
if (!$ringkasan) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data ringkasan tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'heading' => ['required', 'string'],
|
||||
'subheading' => ['required', 'string'],
|
||||
'query_ringkasan' => ['required', 'string', new ValidSql()],
|
||||
]);
|
||||
|
||||
$ringkasan->update([...$validated,
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ringkasan basis data berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function destroy(string $id)
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$ringkasan = RingkasanBasisData::find($id);
|
||||
if (!$ringkasan) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data ringkasan tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$ringkasan->update([
|
||||
'deleted_by' => auth()->id(),
|
||||
]);
|
||||
$ringkasan->delete();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ringkasan basis data berhasil dihapus.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function moveUp(Request $request, string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$current = RingkasanBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$current) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data ringkasan tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$prev = RingkasanBasisData::where('tabel_id', $current->tabel_id)
|
||||
->where('urutan', '<', $current->urutan)
|
||||
->orderBy('urutan', 'desc')
|
||||
->first();
|
||||
|
||||
if ($prev) {
|
||||
// swap
|
||||
[$current->urutan, $prev->urutan] = [$prev->urutan, $current->urutan];
|
||||
$current->save();
|
||||
$prev->save();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ringkasan basis data berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function moveDown(Request $request, string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$current = RingkasanBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$current) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data ringkasan tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$next = RingkasanBasisData::where('tabel_id', $current->tabel_id)
|
||||
->where('urutan', '>', $current->urutan)
|
||||
->orderBy('urutan', 'asc')
|
||||
->first();
|
||||
|
||||
if ($next) {
|
||||
// swap
|
||||
[$current->urutan, $next->urutan] = [$next->urutan, $current->urutan];
|
||||
$current->save();
|
||||
$next->save();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Ringkasan basis data berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
use App\Models\Ekosistem\KolomBasisData;
|
||||
use App\Models\Ekosistem\ValueBasisData;
|
||||
use App\Models\Ekosistem\RingkasanBasisData;
|
||||
use App\Models\Core\Program;
|
||||
|
||||
class ValueBasisDataController extends Controller
|
||||
@@ -53,6 +54,21 @@ class ValueBasisDataController extends Controller
|
||||
|
||||
$selects = [];
|
||||
foreach ($kolom as $k) {
|
||||
if ($k->tipe == 'boolean') {
|
||||
$selects[] = "
|
||||
MAX(
|
||||
CASE
|
||||
WHEN kolom_id = {$k->id}
|
||||
THEN CASE
|
||||
WHEN value_boolean = true THEN 'Ya'
|
||||
WHEN value_boolean = false THEN 'Tidak'
|
||||
ELSE NULL
|
||||
END
|
||||
ELSE NULL
|
||||
END
|
||||
) AS \"{$k->kolom}\"
|
||||
";
|
||||
} else {
|
||||
$selects[] = "
|
||||
MAX(
|
||||
CASE
|
||||
@@ -63,19 +79,22 @@ class ValueBasisDataController extends Controller
|
||||
) AS \"{$k->kolom}\"
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
$base = ValueBasisData::query()
|
||||
->join('core_program', 'core_program.id', '=', 'ekosistem_basis_data_value.program_id')
|
||||
->where('tabel_id', $tabelId)
|
||||
->when($program, function ($query) use ($program) {
|
||||
$query->where('program_id', $program->id);
|
||||
})
|
||||
->selectRaw("
|
||||
program_id,
|
||||
core_program.id AS program_id,
|
||||
core_program.nama AS program_nama,
|
||||
tabel_id,
|
||||
value_id,
|
||||
" . implode(",\n", $selects) . "
|
||||
")
|
||||
->groupBy('program_id', 'tabel_id', 'value_id')
|
||||
->groupBy('core_program.id', 'core_program.nama', 'tabel_id', 'value_id')
|
||||
->orderBy('value_id', 'asc');
|
||||
|
||||
$values = DB::query()->fromSub($base, 'pivot')
|
||||
@@ -90,7 +109,23 @@ class ValueBasisDataController extends Controller
|
||||
})
|
||||
->paginate($perPage);
|
||||
|
||||
return view('ekosistem.value-basis-data.index', compact('programList', 'program', 'tabel', 'kolom', 'values'));
|
||||
$ringkasan = RingkasanBasisData::where('tabel_id', $tabelId)->get();
|
||||
$baseSql = $base->toSql();
|
||||
if ($ringkasan->isNotEmpty()) {
|
||||
foreach ($ringkasan as $r) {
|
||||
$q = str_replace($tabel->tabel, "(" . $baseSql . ") as " . $tabel->tabel, $r->query_ringkasan);
|
||||
$result_q = DB::select($q, $base->getBindings());
|
||||
if (!empty($result_q)) {
|
||||
$row = (array) $result_q[0]; // object → array
|
||||
$r->nilai = array_values($row)[0] ?? 0; // ambil value pertama
|
||||
} else {
|
||||
$r->nilai = 0;
|
||||
}
|
||||
$r->hasil_ringkasan = $result_q;
|
||||
}
|
||||
}
|
||||
|
||||
return view('ekosistem.value-basis-data.index', compact('programList', 'program', 'tabel', 'kolom', 'values', 'ringkasan'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,13 +152,11 @@ class ValueBasisDataController extends Controller
|
||||
if ($request->has('program_id') && $request->query('program_id')) {
|
||||
$programId = $request->query('program_id');
|
||||
$program = Program::find($programId);
|
||||
}
|
||||
}
|
||||
if (!$program) {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
} else {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
}
|
||||
|
||||
return view('ekosistem.value-basis-data.add', compact('tabel', 'kolom', 'program'));
|
||||
}
|
||||
@@ -188,7 +221,7 @@ class ValueBasisDataController extends Controller
|
||||
}
|
||||
});
|
||||
|
||||
return redirect()->route('tabel.data.index', [$tabelId, 'program' => $program->id])->with('success', 'Data berhasil ditambahkan.');
|
||||
return redirect()->route('tabel.data.index', [$tabelId, 'program_id' => $program->id])->with('success', 'Data berhasil ditambahkan.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,16 +329,40 @@ class ValueBasisDataController extends Controller
|
||||
$validated = $request->validate($validationRules);
|
||||
|
||||
DB::transaction(function () use ($program, $tabelId, $validated, $kolom, $id, $values) {
|
||||
foreach ($values as $v) {
|
||||
$k = $kolom->where('id', $v->kolom_id)->first();
|
||||
foreach ($validated as $kol => $val) {
|
||||
$k = $kolom->where('kolom', $kol)->first();
|
||||
if (!$k) {
|
||||
continue;
|
||||
}
|
||||
$v = $values->where('kolom_id', $k->id)->first();
|
||||
if (!$v) {
|
||||
$vals = [
|
||||
'program_id' => $program->id,
|
||||
'tabel_id' => (int)$tabelId,
|
||||
'kolom_id' => $k->id,
|
||||
'value_id' => $id,
|
||||
'created_by' => auth()->id(),
|
||||
'updated_by' => auth()->id(),
|
||||
];
|
||||
$vals['value_' . $k->tipe] = $validated[$k->kolom] ?? null;
|
||||
ValueBasisData::create($vals);
|
||||
} else {
|
||||
$v->update([
|
||||
'value_' . $k->tipe => $validated[$k->kolom] ?? null,
|
||||
'value_' . $k->tipe => $val,
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
// foreach ($values as $v) {
|
||||
// $k = $kolom->where('id', $v->kolom_id)->first();
|
||||
// $v->update([
|
||||
// 'value_' . $k->tipe => $validated[$k->kolom] ?? null,
|
||||
// 'updated_by' => auth()->id(),
|
||||
// ]);
|
||||
// }
|
||||
});
|
||||
|
||||
return redirect()->route('tabel.data.index', [$tabelId, 'program' => $program->id])->with('success', 'Data berhasil diperbarui.');
|
||||
return redirect()->route('tabel.data.index', [$tabelId, 'program_id' => $program->id])->with('success', 'Data berhasil diperbarui.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,6 +411,6 @@ class ValueBasisDataController extends Controller
|
||||
->where('program_id', $program->id)
|
||||
->delete();
|
||||
|
||||
return redirect()->route('tabel.data.index', [$tabelId, 'program' => $program->id])->with('success', 'Data berhasil dihapus.');
|
||||
return redirect()->route('tabel.data.index', [$tabelId, 'program_id' => $program->id])->with('success', 'Data berhasil dihapus.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class SummaryDashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
// if (!Gate::allows('super_admin') && !Gate::allows('admin')) {
|
||||
// abort(403);
|
||||
// }
|
||||
$title = 'Summary Dashboard';
|
||||
return view('dashboard.summary', compact('title'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Ekosistem;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
use App\Models\Core\Program;
|
||||
|
||||
class RingkasanBasisData extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'ekosistem_basis_data_ringkasan';
|
||||
|
||||
protected $fillable = [
|
||||
'tabel_id',
|
||||
'heading',
|
||||
'subheading',
|
||||
'query_ringkasan',
|
||||
'urutan',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$max = self::where('tabel_id', $model->tabel_id)->max('urutan');
|
||||
$model->urutan = ($max ?? 0) + 1;
|
||||
});
|
||||
static::addGlobalScope('order', function (Builder $builder) {
|
||||
$builder->orderBy('urutan');
|
||||
});
|
||||
}
|
||||
|
||||
public function tabel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TabelBasisData::class, 'tabel_id');
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use App\Models\Ekosistem\KolomBasisData;
|
||||
use App\Models\Ekosistem\GroupBasisData;
|
||||
use App\Models\Ekosistem\RingkasanBasisData;
|
||||
|
||||
class TabelBasisData extends Model
|
||||
{
|
||||
@@ -46,4 +48,9 @@ class TabelBasisData extends Model
|
||||
{
|
||||
return $this->belongsTo(GroupBasisData::class, 'group_id');
|
||||
}
|
||||
|
||||
public function ringkasan(): HasMany
|
||||
{
|
||||
return $this->hasMany(RingkasanBasisData::class, 'tabel_id')->orderBy('urutan');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ class ValueBasisData extends Model
|
||||
'value_date',
|
||||
'value_datetime',
|
||||
'value_text',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function tabel(): BelongsTo
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ValidSql implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
$sql = trim($value);
|
||||
|
||||
if (empty($sql)) {
|
||||
$fail('Query tidak boleh kosong.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!str_starts_with(strtolower($sql), 'select')) {
|
||||
$fail('Query harus diawali dengan SELECT.');
|
||||
return;
|
||||
}
|
||||
|
||||
$forbiddenCommands = ['insert', 'update', 'delete', 'drop', 'alter', 'create', 'truncate', 'replace', 'grant', 'revoke'];
|
||||
foreach ($forbiddenCommands as $command) {
|
||||
if (stripos($sql, $command) !== false) {
|
||||
$fail("Query tidak boleh mengandung perintah '$command'.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($sql, ';') !== false) {
|
||||
$fail('Query tidak boleh mengandung multiple statements.');
|
||||
return;
|
||||
}
|
||||
|
||||
$pattern = '/^select\s+.+\s+from\s+\w+/i';
|
||||
if (!preg_match($pattern, $sql)) {
|
||||
$fail('Query tidak memiliki format SQL yang valid.');
|
||||
return;
|
||||
}
|
||||
|
||||
// try {
|
||||
// DB::beginTransaction();
|
||||
|
||||
// $wrapped = "SELECT * FROM ({$sql}) as x LIMIT 1";
|
||||
|
||||
// DB::select($wrapped);
|
||||
|
||||
// DB::rollBack();
|
||||
// } catch (\Throwable $e) {
|
||||
// DB::rollBack();
|
||||
// $fail("Query tidak valid: " . $e->getMessage());
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -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('ekosistem_basis_data_ringkasan', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('tabel_id')->constrained('ekosistem_basis_data_tabel')->restrictOnDelete();
|
||||
|
||||
$table->string('heading');
|
||||
$table->string('subheading');
|
||||
$table->text('query_ringkasan');
|
||||
$table->integer('urutan')->default(0);
|
||||
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
|
||||
$table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null');
|
||||
$table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ekosistem_basis_data_ringkasan');
|
||||
}
|
||||
};
|
||||
@@ -2,8 +2,75 @@
|
||||
|
||||
@section('content')
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div class="row g-6 mb-6">
|
||||
<div class="col-3">
|
||||
<div class="card">
|
||||
<div class="card-body border-bottom">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start justify-content-between">
|
||||
<div class="content-left">
|
||||
<span class="text-heading">Jumlah</span>
|
||||
<div class="d-flex align-items-center my-1">
|
||||
<h4 class="mb-0 me-2" id="jumlah_petani">12</h4>
|
||||
</div>
|
||||
<small class="mb-0" id="jenis_kelamin_petani">2 Laki-laki | 5 Perempuan</small>
|
||||
</div>
|
||||
<div class="avatar">
|
||||
<span class="avatar-initial rounded bg-label-primary">
|
||||
<i class="icon-base ti tabler-friends icon-26px"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start justify-content-between">
|
||||
<div class="content-left">
|
||||
<span class="text-heading">Usia</span>
|
||||
<div class="d-flex align-items-center my-1">
|
||||
<h4 class="mb-0 me-2" id="usia_rata_rata">30.5 (rata-rata)</h4>
|
||||
</div>
|
||||
<small class="mb-0" id="usia_mayoritas">20-45 (mayoritas)</small>
|
||||
</div>
|
||||
<div class="avatar">
|
||||
<span class="avatar-initial rounded bg-label-warning">
|
||||
<i class="icon-base ti tabler-calendar icon-26px"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start justify-content-between">
|
||||
<div class="content-left">
|
||||
<span class="text-heading">Pendidikan Terakhir</span>
|
||||
<div class="d-flex align-items-center my-1">
|
||||
<h4 class="mb-0 me-2" id="pendidikan_mayoritas">SD (mayoritas)</h4>
|
||||
</div>
|
||||
<small class="mb-0" id="pendidikan_tertinggi">SMA (tertinggi)</small>
|
||||
</div>
|
||||
<div class="avatar">
|
||||
<span class="avatar-initial rounded bg-label-info">
|
||||
<i class="icon-base ti tabler-books icon-26px"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom">
|
||||
<h5 class="card-title mb-0">Data Petani (CPCL)</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body border-bottom pt-4">
|
||||
<form method="GET" action="{{ route('tabel.index') }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
|
||||
<div class="col-md-auto">
|
||||
<div class="d-flex align-items-center">
|
||||
@@ -108,6 +175,33 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('petani-cpm.summary', 'jenis_kelamin') }}",
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('#jumlah_petani').text(data.total);
|
||||
$('#jenis_kelamin_petani').text(`${data.laki_laki} Laki-laki | ${data.perempuan} Perempuan`);
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('petani-cpm.summary', 'usia') }}",
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('#usia_rata_rata').text(`${data.usia_rata_rata} (rata-rata)`);
|
||||
$('#usia_mayoritas').text(`${data.usia_mayoritas} (mayoritas)`);
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('petani-cpm.summary', 'pendidikan') }}",
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('#pendidikan_mayoritas').text(`${data.pendidikan_mayoritas} (mayoritas)`);
|
||||
$('#pendidikan_tertinggi').text(`${data.pendidikan_tertinggi} (tertinggi)`);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -0,0 +1,87 @@
|
||||
<div
|
||||
class="offcanvas offcanvas-end"
|
||||
tabindex="-1"
|
||||
id="offcanvasAddRingkasan"
|
||||
aria-labelledby="offcanvasAddRingkasanLabel">
|
||||
<div class="offcanvas-header border-bottom">
|
||||
<h5 id="offcanvasAddRingkasanLabel" class="offcanvas-title">Tambah Ringkasan</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close text-reset"
|
||||
data-bs-dismiss="offcanvas"
|
||||
aria-label="Tutup"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body mx-0 flex-grow-0 p-6 h-100">
|
||||
<form class="add-new-ringkasan pt-0" id="addNewRingkasanForm" action="{{ route('tabel.ringkasan.store', $tabel->id) }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="add-ringkasan-heading">Heading<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="add-ringkasan-heading" name="heading" placeholder="Cth: Nama Petani" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="add-ringkasan-subheading">Subheading<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="add-ringkasan-subheading" name="subheading" placeholder="Cth: Informasi Petani" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="add-ringkasan-query">Query Ringkasan<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="add-ringkasan-query" name="query_ringkasan" placeholder="Cth: SELECT * FROM petani"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success me-3 data-submit">Simpan</button>
|
||||
<button type="reset" class="btn btn-label-danger" data-bs-dismiss="offcanvas">Batal</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$.validator.addMethod("snakecase", function(value, element) {
|
||||
return this.optional(element) || /^[a-z0-9]+(_[a-z0-9]+)*$/.test(value);
|
||||
}, "Gunakan format snake_case (huruf kecil dan underscore)");
|
||||
|
||||
const offcanvasAddRingkasan = new bootstrap.Offcanvas(document.getElementById('offcanvasAddRingkasan'));
|
||||
$('#addNewRingkasanForm').validate({
|
||||
rules: {
|
||||
heading: { required: true },
|
||||
subheading: { required: true },
|
||||
query_ringkasan: { required: true }
|
||||
},
|
||||
messages: {
|
||||
heading: { required: "Heading wajib diisi" },
|
||||
subheading: { required: "Subheading wajib diisi" },
|
||||
query_ringkasan: { required: "Query wajib diisi" }
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
$.ajax({
|
||||
url: $(form).attr('action'),
|
||||
type: 'POST',
|
||||
data: $(form).serialize(),
|
||||
success: function () {
|
||||
offcanvasAddRingkasan.hide();
|
||||
form.reset();
|
||||
Swal.fire({ icon: 'success', title: 'Berhasil!', showConfirmButton: false, timer: 1500 })
|
||||
.then(() => window.location.reload());
|
||||
},
|
||||
error: function (xhr) {
|
||||
Swal.fire({ icon: 'error', title: 'Gagal!', text: xhr.responseJSON?.message || 'Error' });
|
||||
}
|
||||
});
|
||||
},
|
||||
errorElement: 'div',
|
||||
errorPlacement: function (error, element) {
|
||||
error.addClass('invalid-feedback');
|
||||
element.closest('.mb-6, .form-control-validation').append(error);
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).removeClass('is-invalid');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -0,0 +1,108 @@
|
||||
<div
|
||||
class="offcanvas offcanvas-end"
|
||||
tabindex="-1"
|
||||
id="offcanvasUpdateRingkasan"
|
||||
aria-labelledby="offcanvasUpdateRingkasanLabel">
|
||||
<div class="offcanvas-header border-bottom">
|
||||
<h5 id="offcanvasUpdateRingkasanLabel" class="offcanvas-title">Edit Ringkasan</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close text-reset"
|
||||
data-bs-dismiss="offcanvas"
|
||||
aria-label="Tutup"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body mx-0 flex-grow-0 p-6 h-100">
|
||||
<form class="update-ringkasan pt-0" id="updateRingkasanForm" action="{{ route('tabel.ringkasan.update', [$tabel->id, ':id']) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="update-ringkasan-heading">Heading<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="update-ringkasan-heading" name="heading" placeholder="Cth: Nama Petani" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="update-ringkasan-subheading">Subheading<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="update-ringkasan-subheading" name="subheading" placeholder="Cth: Informasi Petani" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="update-ringkasan-query">Query Ringkasan<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="update-ringkasan-query" name="query_ringkasan" placeholder="Cth: SELECT * FROM petani"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success me-3 data-submit">Simpan</button>
|
||||
<button type="reset" class="btn btn-label-danger" data-bs-dismiss="offcanvas">Batal</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$.validator.addMethod("snakecase", function(value, element) {
|
||||
return this.optional(element) || /^[a-z0-9]+(_[a-z0-9]+)*$/.test(value);
|
||||
}, "Gunakan format snake_case (huruf kecil dan underscore)");
|
||||
|
||||
const offcanvasUpdateRingkasan = new bootstrap.Offcanvas(document.getElementById('offcanvasUpdateRingkasan'));
|
||||
$(".edit-ringkasan").click(function () {
|
||||
const id = $(this).data('id');
|
||||
console.log("Edit record with ID:", id);
|
||||
|
||||
const editForm = $('#updateRingkasanForm');
|
||||
editForm.validate().resetForm();
|
||||
editForm.find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.get("{{ route('tabel.ringkasan.show', [$tabel->id, ':id']) }}".replace(':id', id), function (res) {
|
||||
if (res.status === 'success') {
|
||||
console.log("Data ringkasan:", res.data);
|
||||
$('#update-ringkasan-id').val(res.data.id);
|
||||
$('#update-ringkasan-heading').val(res.data.heading);
|
||||
$('#update-ringkasan-subheading').val(res.data.subheading);
|
||||
$('#update-ringkasan-query').val(res.data.query_ringkasan);
|
||||
offcanvasUpdateRingkasan.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#updateRingkasanForm').validate({
|
||||
rules: {
|
||||
heading: { required: true },
|
||||
subheading: { required: true },
|
||||
query_ringkasan: { required: true }
|
||||
},
|
||||
messages: {
|
||||
heading: { required: "Heading wajib diisi" },
|
||||
subheading: { required: "Subheading wajib diisi" },
|
||||
query_ringkasan: { required: "Query wajib diisi" }
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
$.ajax({
|
||||
url: $(form).attr('action').replace(':id', $('#update-ringkasan-id').val()),
|
||||
type: 'PUT',
|
||||
data: $(form).serialize(),
|
||||
success: function () {
|
||||
offcanvasUpdateRingkasan.hide();
|
||||
form.reset();
|
||||
Swal.fire({ icon: 'success', title: 'Berhasil!', showConfirmButton: false, timer: 1500 })
|
||||
.then(() => window.location.reload());
|
||||
},
|
||||
error: function (xhr) {
|
||||
Swal.fire({ icon: 'error', title: 'Gagal!', text: xhr.responseJSON?.message || 'Error' });
|
||||
}
|
||||
});
|
||||
},
|
||||
errorElement: 'div',
|
||||
errorPlacement: function (error, element) {
|
||||
error.addClass('invalid-feedback');
|
||||
element.closest('.mb-6, .form-control-validation').append(error);
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).removeClass('is-invalid');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -95,6 +95,70 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h6 class="mb-3">Informasi Ringkasan Tabel</h6>
|
||||
|
||||
<hr class="my-4 mx-n4" />
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-auto d-flex gap-2">
|
||||
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="offcanvas" data-bs-target="#offcanvasAddRingkasan" >
|
||||
<i class="ti tabler-plus me-1"></i> Tambah
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-12 mb-4 form-control-validation">
|
||||
|
||||
<div class="table-responsive text-nowrap mb-4">
|
||||
<table class="table table-hover">
|
||||
<thead class="border-top">
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Heading / Subheading</th>
|
||||
<th>Query</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($tabel->ringkasan as $index => $ringkasan)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>
|
||||
<span class="text-muted">{{ $ringkasan->heading }}</span><br>
|
||||
<small class="text-muted">{{ $ringkasan->subheading }}</small>
|
||||
</td>
|
||||
<td><span class="text-muted">{{ $ringkasan->query_ringkasan }}</span></td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
@if (!$loop->first)
|
||||
<button type="button"
|
||||
class="btn btn-icon btn-text-secondary move-up-ringkasan"
|
||||
data-id="{{ $ringkasan->id }}">
|
||||
<i class="ti tabler-arrow-up"></i>
|
||||
</button>
|
||||
@endif
|
||||
@if (!$loop->last)
|
||||
<button type="button"
|
||||
class="btn btn-icon btn-text-secondary move-down-ringkasan"
|
||||
data-id="{{ $ringkasan->id }}">
|
||||
<i class="ti tabler-arrow-down"></i>
|
||||
</button>
|
||||
@endif
|
||||
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill edit-ringkasan" data-id="{{ $ringkasan->id }}"><i class="ti tabler-edit ti-md"></i></a>
|
||||
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-ringkasan" data-id="{{ $ringkasan->id }}" data-nama="{{ $ringkasan->heading }}"><i class="ti tabler-trash ti-md"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="text-center py-4">Tidak ada ringkasan ditemukan.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<a href="{{ route('tabel.index') }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||
</div>
|
||||
@@ -103,6 +167,8 @@
|
||||
</div>
|
||||
@include('ekosistem.kolom-basis-data.add')
|
||||
@include('ekosistem.kolom-basis-data.edit')
|
||||
@include('ekosistem.ringkasan-basis-data.add')
|
||||
@include('ekosistem.ringkasan-basis-data.edit')
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -168,6 +234,63 @@
|
||||
});
|
||||
});
|
||||
|
||||
$(".move-up-ringkasan").click(function (e) {
|
||||
e.preventDefault();
|
||||
let id = $(this).data('id');
|
||||
|
||||
$.post("{{ route('tabel.ringkasan.move-up', [$tabel->id, ':id']) }}".replace(':id', id), {
|
||||
_token: '{{ csrf_token() }}',
|
||||
_method: 'PUT'
|
||||
}, function (res) {
|
||||
if (res.status === 'success') {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".move-down-ringkasan").click(function (e) {
|
||||
e.preventDefault();
|
||||
let id = $(this).data('id');
|
||||
|
||||
$.post("{{ route('tabel.ringkasan.move-down', [$tabel->id, ':id']) }}".replace(':id', id), {
|
||||
_token: '{{ csrf_token() }}',
|
||||
_method: 'PUT'
|
||||
}, function (res) {
|
||||
if (res.status === 'success') {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".delete-ringkasan").click(function (e) {
|
||||
e.preventDefault();
|
||||
const id = $(this).data('id');
|
||||
const name = $(this).data('nama');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Hapus?',
|
||||
text: `Ringkasan ${name} akan dihapus!`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Ya, Hapus!',
|
||||
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
||||
buttonsStyling: false
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: "{{ route('tabel.ringkasan.destroy', [$tabel->id, ':id']) }}".replace(':id', id),
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function () {
|
||||
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
|
||||
.then(() => window.location.reload());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -35,7 +35,7 @@
|
||||
<input type="datetime" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}"
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) }}" />
|
||||
@elseif($k->tipe == 'boolean')
|
||||
<select class="form-select @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
|
||||
<select class="form-select tipe-boolean @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
|
||||
<option value="1" {{ old($k->kolom) == 1 ? 'selected' : '' }}>Ya</option>
|
||||
<option value="0" {{ old($k->kolom) == 0 ? 'selected' : '' }}>Tidak</option>
|
||||
</select>
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<a href="{{ route('tabel.data.index', [$tabel->id, 'program' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||
<a href="{{ route('tabel.data.index', [$tabel->id, 'program_id' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||
<button type="submit" class="btn btn-success data-submit">Simpan Data</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -63,6 +63,7 @@
|
||||
<script>
|
||||
'use strict';
|
||||
$(document).ready(function () {
|
||||
$('#add-data-program,.tipe-boolean').select2();
|
||||
|
||||
$('#addNewDataForm').validate({
|
||||
rules: {
|
||||
|
||||
@@ -13,6 +13,19 @@
|
||||
@method('PUT')
|
||||
|
||||
<h6 class="mb-3">Informasi {{ $tabel->label }}</h6>
|
||||
@if (!$program)
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<label class="form-label" for="add-data-program">Program<span class="text-danger">*</span></label>
|
||||
<select name="program_id" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
|
||||
<option value="">Pilih Program</option>
|
||||
@foreach($programList as $prog)
|
||||
<option value="{{ $prog->id }}" {{ request('program_id') == $prog->id ? 'selected' : '' }}>{{ $prog->nama }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
@foreach($kolom as $k)
|
||||
<?php
|
||||
@@ -40,8 +53,8 @@
|
||||
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
|
||||
@elseif($k->tipe == 'boolean')
|
||||
<select class="form-select @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
|
||||
<option value="1" {{ old($k->kolom) ?? $value['value_'.$k->tipe] == 1 ? 'selected' : '' }}>Ya</option>
|
||||
<option value="0" {{ old($k->kolom) ?? $value['value_'.$k->tipe] == 0 ? 'selected' : '' }}>Tidak</option>
|
||||
<option value="1" {{ (old($k->kolom) ?? ($value['value_'.$k->tipe] ?? null)) == 1 ? 'selected' : '' }}>Ya</option>
|
||||
<option value="0" {{ (old($k->kolom) ?? ($value['value_'.$k->tipe] ?? null)) == 0 ? 'selected' : '' }}>Tidak</option>
|
||||
</select>
|
||||
@else
|
||||
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}"
|
||||
@@ -54,7 +67,7 @@
|
||||
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<a href="{{ route('tabel.data.index', [$tabel->id, 'program' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||
<a href="{{ route('tabel.data.index', [$tabel->id, 'program_id' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
|
||||
<button type="submit" class="btn btn-success data-submit">Simpan Data</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -2,6 +2,32 @@
|
||||
|
||||
@section('content')
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
@if($ringkasan->isNotEmpty())
|
||||
<div class="row g-6 mb-6">
|
||||
@foreach($ringkasan as $r)
|
||||
<div class="col-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start justify-content-between">
|
||||
<div class="content-left">
|
||||
<span class="text-heading">{{ $r->heading }}</span>
|
||||
<div class="d-flex align-items-center my-1">
|
||||
<h4 class="mb-0 me-2">{{ $r->nilai }}</h4>
|
||||
</div>
|
||||
<small class="mb-0">{{ $r->subheading }}</small>
|
||||
</div>
|
||||
<div class="avatar">
|
||||
<span class="avatar-initial rounded bg-label-primary">
|
||||
<i class="icon-base ti tabler-gauge icon-26px"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom">
|
||||
<h5 class="card-title mb-0">Data {{ $tabel->label }}</h5>
|
||||
@@ -40,7 +66,8 @@
|
||||
<input type="text" name="search" class="form-control" placeholder="Cari Nama Tabel..." value="{{ request('search') }}">
|
||||
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
|
||||
</div>
|
||||
<a href="{{ route('tabel.data.create', [$tabel->id, 'program_id' => request('program')]) }}" class="btn btn-sm btn-primary add-new">
|
||||
<a href="{{ route('tabel.data.create', [$tabel->id, 'program_id' => request('program_id')]) }}" class="btn btn-sm btn-primary add-new"
|
||||
style="display: {{ request('program_id') ? 'flex' : 'none' }};">
|
||||
<i class="ti tabler-plus me-1"></i> Tambah
|
||||
</a>
|
||||
</div>
|
||||
@@ -52,6 +79,7 @@
|
||||
<thead class="border-top">
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Nama Program</th>
|
||||
@foreach($kolom as $k)
|
||||
<th>{{ $k->label }}</th>
|
||||
@endforeach
|
||||
@@ -62,14 +90,15 @@
|
||||
@forelse($values as $v)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $v->program_nama ?? 'N/A' }}</td>
|
||||
@foreach($kolom as $k)
|
||||
<td>{{ $v->{$k->kolom} }}</td>
|
||||
@endforeach
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<a href="{{ route('tabel.data.edit', [$tabel->id, $v->value_id, 'program_id' => $k->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
|
||||
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $v->value_id }}" data-program-id="{{ $k->program_id }}"><i class="ti tabler-trash ti-md"></i></a>
|
||||
<a href="{{ route('tabel.data.show', [$tabel->id, $v->value_id, 'program_id' => $k->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
|
||||
<a href="{{ route('tabel.data.edit', [$tabel->id, $v->value_id, 'program_id' => $v->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
|
||||
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $v->value_id }}" data-program-id="{{ $v->program_id }}"><i class="ti tabler-trash ti-md"></i></a>
|
||||
<a href="{{ route('tabel.data.show', [$tabel->id, $v->value_id, 'program_id' => $v->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -99,6 +128,7 @@
|
||||
const id = $(this).data('id');
|
||||
const programId = $(this).data('program-id');
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: 'Hapus?',
|
||||
text: `Data tersebut akan dihapus!`,
|
||||
@@ -108,9 +138,19 @@
|
||||
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
||||
buttonsStyling: false
|
||||
}).then(function (result) {
|
||||
console.log(id);
|
||||
console.log(programId);
|
||||
var baseUrl = "{{ route('tabel.data.destroy', [$tabel->id, ':id']) }}"
|
||||
.replace(':id', id)
|
||||
var params = new URLSearchParams({
|
||||
program_id: programId
|
||||
});
|
||||
|
||||
var url = baseUrl + '?' + params.toString();
|
||||
console.log(url);
|
||||
if (result.value) {
|
||||
$.ajax({
|
||||
url: "{{ route('tabel.data.destroy', [$tabel->id, ':id', 'program_id' => ':programId']) }}".replace(':id', id).replace(':programId', programId),
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}',
|
||||
|
||||
@@ -115,7 +115,12 @@ Route::middleware('auth')
|
||||
Route::put('tabel/{tabelId}/kolom/{id}/move-down', [App\Http\Controllers\Web\Ekosistem\KolomBasisDataController::class, 'moveDown'])->name('tabel.kolom.move-down');
|
||||
Route::resource('tabel.kolom', App\Http\Controllers\Web\Ekosistem\KolomBasisDataController::class)->only(['show', 'store', 'update', 'destroy']);
|
||||
Route::resource('tabel.data', App\Http\Controllers\Web\Ekosistem\ValueBasisDataController::class);
|
||||
Route::resource('tabel.ringkasan', App\Http\Controllers\Web\Ekosistem\RingkasanBasisDataController::class);
|
||||
Route::put('tabel/{tabelId}/ringkasan/{id}/move-up', [App\Http\Controllers\Web\Ekosistem\RingkasanBasisDataController::class, 'moveUp'])->name('tabel.ringkasan.move-up');
|
||||
Route::put('tabel/{tabelId}/ringkasan/{id}/move-down', [App\Http\Controllers\Web\Ekosistem\RingkasanBasisDataController::class, 'moveDown'])->name('tabel.ringkasan.move-down');
|
||||
|
||||
Route::resource('petani-cpm', App\Http\Controllers\Web\Ekosistem\PetaniCPMController::class);
|
||||
Route::get('petani-cpm/summary/{tipe}', [App\Http\Controllers\Web\Ekosistem\PetaniCPMController::class, 'summary'])->name('petani-cpm.summary');
|
||||
|
||||
// Monev
|
||||
Route::resource('framework', App\Http\Controllers\Web\Program\FrameworkController::class);
|
||||
|
||||
Reference in New Issue
Block a user