random commit - detail question answer1
parent
aa04a09deb
commit
e0a9da7ceb
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Admins;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Master\ManagementMasters;
|
||||
use App\Models\QuestionAnswers;
|
||||
use App\Models\QuestionDetails;
|
||||
use App\Models\QuestionSurveys;
|
||||
|
@ -64,8 +65,8 @@ class SurveyController extends Controller
|
|||
{
|
||||
// find data
|
||||
$survey = Surveys::where('status', '!=', 'Deleted')
|
||||
->with(['questionSurveys' => fn($query) => $query->where('status', '!=', 'Deleted')])
|
||||
->findOrFail($id);
|
||||
->with(['questionSurveys' => fn ($query) => $query->where('status', '!=', 'Deleted')])
|
||||
->findOrFail($id);
|
||||
// return ($survey);
|
||||
|
||||
// return view
|
||||
|
@ -78,11 +79,14 @@ class SurveyController extends Controller
|
|||
public function show(string $id)
|
||||
{
|
||||
// find data
|
||||
$survey = Surveys::where('status', '!=', 'Deleted')->findOrFail($id);
|
||||
$questionSurveys = QuestionSurveys::where('survey_id', $id)->paginate();
|
||||
$survey = Surveys::where('status', '!=', 'Deleted')->with('questionSurveys')->findOrFail($id);
|
||||
// return $survey->questionSurveys;
|
||||
$questionAnswers = QuestionAnswers::where('survey_id', $id)->with('questionSurveys')->get();
|
||||
// return $questionSurveys = QuestionSurveys::where('survey_id', $id)->with('questionAnswers')->get();
|
||||
// return [$survey->questionSurveys->first()->questionAnswers->first()->users->name];
|
||||
|
||||
// return view
|
||||
return view('pages.admins.surveys.detail', compact('survey', 'questionSurveys'));
|
||||
return view('pages.admins.surveys.detail', compact('survey', 'questionAnswers'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,9 +96,10 @@ class SurveyController extends Controller
|
|||
{
|
||||
// find data
|
||||
$survey = Surveys::where('status', '!=', 'Deleted')->findOrFail($id);
|
||||
$management_master = ManagementMasters::get();
|
||||
|
||||
// return view
|
||||
return view('pages.admins.surveys.edit', compact('survey'));
|
||||
return view('pages.admins.surveys.edit', compact('survey', 'management_master'));
|
||||
}
|
||||
|
||||
// SaveSurvey (Autosaved)
|
||||
|
@ -142,6 +147,20 @@ class SurveyController extends Controller
|
|||
'question_label' => '["' . $value['labelfrom'] . '","' . $value['labelto'] . '"]',
|
||||
'question_value' => '["' . $value['valuefrom'] . '","' . $value['valueto'] . '"]',
|
||||
]);
|
||||
} else if ($value['type'] == 'Jawaban Angka') {
|
||||
QuestionDetails::updateOrCreate([
|
||||
'question_id' => $questionSurveys->id,
|
||||
], [
|
||||
'question_label' => '["Jawaban Angka"]',
|
||||
'question_value' => '["Angka"]',
|
||||
]);
|
||||
} else if ($value['type'] == 'Jawaban Singkat') {
|
||||
QuestionDetails::updateOrCreate([
|
||||
'question_id' => $questionSurveys->id,
|
||||
], [
|
||||
'question_label' => '["Jawaban Singkat"]',
|
||||
'question_value' => '["Teks Jawaban Singkat"]',
|
||||
]);
|
||||
} else if ($value['type'] == 'Esai') {
|
||||
QuestionDetails::updateOrCreate([
|
||||
'question_id' => $questionSurveys->id,
|
||||
|
@ -149,6 +168,13 @@ class SurveyController extends Controller
|
|||
'question_label' => '["Esai"]',
|
||||
'question_value' => '["Teks"]',
|
||||
]);
|
||||
} else if ($value['type'] == 'Master') {
|
||||
QuestionDetails::updateOrCreate([
|
||||
'question_id' => $questionSurveys->id,
|
||||
], [
|
||||
'question_label' => '["Master"]',
|
||||
'question_value' => '["' . $value['master'] . '"]',
|
||||
]);
|
||||
} else {
|
||||
QuestionDetails::updateOrCreate([
|
||||
'question_id' => $questionSurveys->id,
|
||||
|
@ -190,8 +216,8 @@ class SurveyController extends Controller
|
|||
{
|
||||
// create unique answer_id
|
||||
$unique_answer_id = QuestionAnswers::select('answer_id')->groupby('answer_id')->latest()->first();
|
||||
$unique_answer_id = empty($unique_answer_id) ? 1 : $unique_answer_id['answer_id'] + 1;
|
||||
|
||||
$unique_answer_id = empty($unique_answer_id) ? 1 : $unique_answer_id['answer_id'] + 1;
|
||||
|
||||
// validation
|
||||
$request->validate([
|
||||
'question.*.answer' => 'required',
|
||||
|
@ -200,10 +226,12 @@ class SurveyController extends Controller
|
|||
|
||||
// return $request;
|
||||
foreach ($request->question as $key => $value) {
|
||||
$answer_type = QuestionSurveys::select('type')->find($key);
|
||||
QuestionAnswers::create([
|
||||
'user_id' => Auth::user()->id,
|
||||
'question_id' => $key,
|
||||
'answer_id' => $unique_answer_id,
|
||||
'answer_type' => $answer_type ? $answer_type['type'] : null,
|
||||
'answer' => $value['answer'],
|
||||
'survey_id' => $request->survey_id,
|
||||
]);
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Master\ManagementMasters;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ManagementMasterController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$management_master = ManagementMasters::paginate(10);
|
||||
|
||||
return view('pages.masters.management_masters.index', compact('management_master'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// call view pages.masters.management_masters.create
|
||||
return view('pages.masters.management_masters.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// validation
|
||||
$rules = array(
|
||||
'master_code' => 'required',
|
||||
'master_value' => 'required',
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// check validation
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('master/management-master/create')
|
||||
->withErrors($validator)
|
||||
->withInput($request->all());
|
||||
} else {
|
||||
// create new master data
|
||||
$management_master = ManagementMasters::create([
|
||||
'master_code' => $request->master_code,
|
||||
'master_value' => $request->master_value,
|
||||
]);
|
||||
|
||||
// Create Session message
|
||||
Session::flash('management_masters-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil menambahkan data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('master/management-master');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
// get data from management_master
|
||||
$management_master = ManagementMasters::findOrFail($id);
|
||||
|
||||
// call view pages
|
||||
return view('pages.masters.management_masters.edit', compact('management_master'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// validation
|
||||
$rules = array(
|
||||
'master_code' => 'required',
|
||||
'master_value' => 'required',
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// process the login
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('master/management-master/edit/' . $id)
|
||||
->withErrors($validator)
|
||||
->withInput($request->all());
|
||||
} else {
|
||||
// create new account
|
||||
$management_master = ManagementMasters::findOrFail($id);
|
||||
if (!$management_master) {
|
||||
// Create Session message
|
||||
Session::flash('management_masters-message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Data tidak ditemukan!'
|
||||
]);
|
||||
|
||||
return Redirect::to('master/management-master');
|
||||
}
|
||||
$management_master->update([
|
||||
'master_code' => $request->master_code,
|
||||
'master_value' => $request->master_value,
|
||||
]);
|
||||
|
||||
// Create Session message
|
||||
Session::flash('management_masters-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil mengubah data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('master/management-master');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Master\Agamas;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MasterAgamaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$agama = Agamas::paginate(10);
|
||||
|
||||
return view('pages.masters.agamas.index', compact('agama'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Master;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Agamas extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'mst_agamas';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Master;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ManagementMasters extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'management_masters';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
|
@ -16,13 +16,14 @@ class QuestionAnswers extends Model
|
|||
'user_id',
|
||||
'survey_id',
|
||||
'answer_id',
|
||||
'answer_type',
|
||||
'answer',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function questionSurveys(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(QuestionSurveys::class, 'id', 'question_id');
|
||||
return $this->belongsTo(QuestionSurveys::class, 'question_id', 'id');
|
||||
}
|
||||
|
||||
public function users(): HasOne
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?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
|
||||
{
|
||||
// Add answer_type to make unique answer per question
|
||||
Schema::table('question_answers', function (Blueprint $table) {
|
||||
$table->string('answer_type')->after('question_id')->nullable(); // answer_type
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// remove answer_type
|
||||
Schema::table('question_answers', function (Blueprint $table) {
|
||||
$table->dropColumn('answer_type'); // answer_type
|
||||
});
|
||||
}
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
<?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('mst_agamas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string("keterangan");
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mst_agamas');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?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('management_masters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('master_code'); // code for question master
|
||||
$table->string('master_value'); // Value get model master
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('management_masters');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AgamaSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
$agama = [
|
||||
[
|
||||
'id' => 1,
|
||||
'keterangan' => 'Islam',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'keterangan' => 'Kristen',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'keterangan' => 'Katolik',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'keterangan' => 'Hindu',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'keterangan' => 'Budha',
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'keterangan' => 'Khonghucu',
|
||||
],
|
||||
[
|
||||
'id' => 100,
|
||||
'keterangan' => 'Lainnya',
|
||||
],
|
||||
];
|
||||
|
||||
DB::table("mst_agamas")->insert($agama);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr" data-bs-theme="light" data-color-theme="Blue_Theme">
|
||||
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Favicon icon-->
|
||||
<link rel="shortcut icon" type="image/png" href="{{ asset('assets/images/logos/favicon.png') }}" />
|
||||
|
||||
<!-- Core Css -->
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/styles-new.css') }}" />
|
||||
|
||||
<title>403 Access Denied</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Preloader -->
|
||||
<!-- <div class="preloader">
|
||||
<img src="../assets/images/logos/favicon.png" alt="loader" class="lds-ripple img-fluid" />
|
||||
</div> -->
|
||||
<div id="main-wrapper">
|
||||
<div class="position-relative overflow-hidden min-vh-100 w-100 d-flex align-items-center justify-content-center">
|
||||
<div class="d-flex align-items-center justify-content-center w-100">
|
||||
<div class="row justify-content-center w-100">
|
||||
<div class="col-lg-4">
|
||||
<div class="text-center">
|
||||
<img src="{{ asset('assets/images/backgrounds/403error.svg') }}" alt="" class="img-fluid" width="300">
|
||||
<h1 class="fw-semibold mb-7 fs-9">Opsss!!!</h1>
|
||||
<h4 class="fw-semibold mb-7">Maaf akses ditolak, silahkan login terlebih dahulu.</h4>
|
||||
<a class="btn btn-primary" href="{{ url('/auth/login') }}" role="button"><i class="ti ti-arrow-left"></i> Kembali</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr" data-bs-theme="light" data-color-theme="Blue_Theme">
|
||||
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Favicon icon-->
|
||||
<link rel="shortcut icon" type="image/png" href="{{ asset('assets/images/logos/favicon.png') }}" />
|
||||
|
||||
<!-- Core Css -->
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/styles-new.css') }}" />
|
||||
|
||||
<title>404 Not Found</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Preloader -->
|
||||
<!-- <div class="preloader">
|
||||
<img src="../assets/images/logos/favicon.png" alt="loader" class="lds-ripple img-fluid" />
|
||||
</div> -->
|
||||
<div id="main-wrapper">
|
||||
<div class="position-relative overflow-hidden min-vh-100 w-100 d-flex align-items-center justify-content-center">
|
||||
<div class="d-flex align-items-center justify-content-center w-100">
|
||||
<div class="row justify-content-center w-100">
|
||||
<div class="col-lg-4">
|
||||
<div class="text-center">
|
||||
<img src="{{ asset('assets/images/backgrounds/404error.svg') }}" alt="" class="img-fluid" width="300">
|
||||
<h1 class="fw-semibold mb-7 fs-9">Opsss!!!</h1>
|
||||
<h4 class="fw-semibold mb-7">Maaf, halaman yang anda cari tidak ditemukan.</h4>
|
||||
<a class="btn btn-primary" href="{{ url('/admin/dashboard') }}" role="button"><i class="ti ti-arrow-left"></i> Kembali</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -49,9 +49,42 @@
|
|||
</a>
|
||||
</li>
|
||||
@role(['Admin'])
|
||||
{{-- Management Master --}}
|
||||
<li class="nav-small-cap">
|
||||
<i class="ti ti-dots nav-small-cap-icon fs-4"></i>
|
||||
<span class="hide-menu">User Management</span>
|
||||
<span class="hide-menu">Data Master</span>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<a class="sidebar-link" href="{{ URL::to('master/management-master') }}" aria-expanded="false">
|
||||
<span>
|
||||
<i class="ti ti-database"></i>
|
||||
</span>
|
||||
<span class="hide-menu">Manajemen Master</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<a class="sidebar-link has-arrow" href="javascript:void(0)" aria-expanded="false">
|
||||
<span class="d-flex">
|
||||
<i class="ti ti-layout-sidebar"></i>
|
||||
</span>
|
||||
<span class="hide-menu">Master</span>
|
||||
</a>
|
||||
<ul aria-expanded="false" class="collapse first-level">
|
||||
<li class="sidebar-item">
|
||||
<a href="{{ URL::to('master/master-agama') }}" class="sidebar-link">
|
||||
<div class="round-16 d-flex align-items-center justify-content-center">
|
||||
<i class="ti ti-circle"></i>
|
||||
</div>
|
||||
<span class="hide-menu">Master Agama</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
{{-- Management User --}}
|
||||
<li class="nav-small-cap">
|
||||
<i class="ti ti-dots nav-small-cap-icon fs-4"></i>
|
||||
<span class="hide-menu">Manajemen Pengguna</span>
|
||||
</li>
|
||||
<li class="sidebar-item">
|
||||
<a class="sidebar-link" href="{{ URL::to('admin/users') }}" aria-expanded="false">
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
@extends('layouts.app')
|
||||
@section('title', 'Detail Survei')
|
||||
@section('content')
|
||||
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h3 class="form-label mt-2 text-white border-bottom pb-3">{{ $survey->name }}</h3>
|
||||
<pre for="description" class="mt-3">{{ $survey->description }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table table-responsive table-bordered text-nowrap mb-0 align-middle">
|
||||
<thead class="text-dark fs-4">
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="45px">
|
||||
<h6 class="fw-semibold mb-0 text-center">No.</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0">
|
||||
<h6 class="fw-semibold mb-0">Pertanyaan</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Tipe</h6>
|
||||
</th>
|
||||
@forelse ($questionSurveys->first()->questionAnswers as $answer)
|
||||
<th class="border-bottom-0" width="300px">
|
||||
<h6 class="fw-semibold mb-0 text-wrap text-break text-center">{{ $answer->users->name }}</h6>
|
||||
</th>
|
||||
@empty
|
||||
<th class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Jawaban</h6>
|
||||
</th>
|
||||
@endforelse
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($questionSurveys as $question)
|
||||
<tr>
|
||||
<td class="border-bottom-0" width="45px">
|
||||
<h6 class="fw-normal mb-0 text-center">{{ ($questionSurveys->currentPage()-1) * $questionSurveys->perPage() + $loop->index + 1 }}</h6>
|
||||
</td>
|
||||
<td class="border-bottom-0" width="400px">
|
||||
<h6 class="fw-normal mb-0 text-wrap">{{ $question->name }}</h6>
|
||||
</td>
|
||||
<td class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-normal mb-0">
|
||||
{{ $question->type }}
|
||||
@if ($question->questionDetails && $question->type == 'Skala')
|
||||
<hr>
|
||||
{{ json_decode($question->questionDetails->question_value)[0] }} = {{ json_decode($question->questionDetails->question_label)[0] }}
|
||||
<br>
|
||||
{{ json_decode($question->questionDetails->question_value)[1] }} = {{ json_decode($question->questionDetails->question_label)[1] }}
|
||||
@endif
|
||||
</h6>
|
||||
</td>
|
||||
@forelse ($question->questionAnswers as $row)
|
||||
<td class="border-bottom-0" width="300px">
|
||||
<h6 class="fw-normal mb-0 text-wrap text-break text-center">{{ $row->answer }}</h6>
|
||||
</td>
|
||||
@empty
|
||||
<td class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-normal mb-0 text-center">Jawaban Kosong</h6>
|
||||
</td>
|
||||
@endforelse
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="100px" colspan="3">
|
||||
<h6 class="fw-normal mb-0 text-center">Survey Kosong</h6>
|
||||
</th>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
|
@ -2,53 +2,83 @@
|
|||
@section('title', 'Detail Survei')
|
||||
@section('content')
|
||||
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h3 class="form-label mt-2 text-white border-bottom pb-3">{{ $survey->name }}</h3>
|
||||
<pre for="description" class="mt-3">{{ $survey->description }}</pre>
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h3 class="form-label mt-2 text-white border-bottom pb-3">{{ $survey->name }}</h3>
|
||||
<pre for="description" class="mt-3 text-wrap">{{ $survey->description }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table table-responsive table-bordered text-nowrap mb-0 align-middle">
|
||||
<thead class="text-dark fs-4">
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="45px">
|
||||
<h6 class="fw-semibold mb-0 text-center">No.</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0">
|
||||
<h6 class="fw-semibold mb-0">Pertanyaan</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Tipe</h6>
|
||||
</th>
|
||||
@forelse ($questionSurveys->first()->questionAnswers as $answer)
|
||||
<th class="border-bottom-0" width="300px">
|
||||
<h6 class="fw-semibold mb-0 text-wrap text-break text-center">{{ $answer->users->name }}</h6>
|
||||
</th>
|
||||
@empty
|
||||
<th class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Jawaban</h6>
|
||||
</th>
|
||||
@endforelse
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($questionSurveys as $question)
|
||||
<tr>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body table-responsive">
|
||||
<table class="table table-responsive table-bordered text-nowrap mb-0 align-middle">
|
||||
<thead class="text-dark fs-4">
|
||||
<tr>
|
||||
<th class="border-bottom-0 align-middle" width="45px">
|
||||
<h6 class="fw-semibold mb-0 text-center">No.</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0 align-middle" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Tahun</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0 align-middle">
|
||||
<h6 class="fw-semibold mb-0">NIK</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0 align-middle" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Nama</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0 align-middle" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Jenis Kelamin</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0 align-middle" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Tempat Lahir</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0 align-middle" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Usia</h6>
|
||||
</th>
|
||||
@foreach ($survey->questionSurveys as $_question)
|
||||
<th class="border-bottom-0 align-middle" width="300px">
|
||||
<h6 class="fw-semibold mb-0 text-wrap text-center">
|
||||
{{ $_question->name }}
|
||||
</h6>
|
||||
</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$no = 1;
|
||||
$answer_user = '';
|
||||
@endphp
|
||||
|
||||
@foreach ($questionAnswers as $_answers)
|
||||
<tr>
|
||||
<td>{{ $no++ }}</td>
|
||||
<td>{{ $survey->years }}</td>
|
||||
{{-- @php $user_detail = $question->questionAnswers->first(); @endphp --}}
|
||||
<td>{{ $_answers->users->nik }}</td>
|
||||
<td>{{ $_answers->users->name }}</td>
|
||||
<td>{{ $_answers->users->gender }}</td>
|
||||
<td>{{ $_answers->users->place_of_birth }}</td>
|
||||
<td>{{ $_answers->users->date_of_birth }}</td>
|
||||
@foreach ($survey->questionSurveys as $_question)
|
||||
<td>{{ $_question->id == $_answers->question_id ? $_answers->answer : 'Kosong' }}
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- <tr>
|
||||
<td class="border-bottom-0" width="45px">
|
||||
<h6 class="fw-normal mb-0 text-center">{{ ($questionSurveys->currentPage()-1) * $questionSurveys->perPage() + $loop->index + 1 }}</h6>
|
||||
</td>
|
||||
|
@ -75,19 +105,19 @@
|
|||
<h6 class="fw-normal mb-0 text-center">Jawaban Kosong</h6>
|
||||
</td>
|
||||
@endforelse
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="100px" colspan="3">
|
||||
<h6 class="fw-normal mb-0 text-center">Survey Kosong</h6>
|
||||
</th>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</tr> --}}
|
||||
{{-- @empty
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="100px" colspan="3">
|
||||
<h6 class="fw-normal mb-0 text-center">Survey Kosong</h6>
|
||||
</th>
|
||||
</tr>
|
||||
@endforelse --}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
||||
@stop
|
||||
|
|
|
@ -2,26 +2,27 @@
|
|||
@section('title', 'Surveys')
|
||||
@section('content')
|
||||
|
||||
<!-- script js -->
|
||||
<script>
|
||||
function choose_type(type_name, type_value, questionDetails = null) {
|
||||
console.log(`#detail-${type_name}`);
|
||||
var nameType = type_name.split('[type]')[0];
|
||||
let result = '';
|
||||
console.log(questionDetails);
|
||||
<!-- script js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
// Setting default question detail
|
||||
if (questionDetails == null) {
|
||||
questionDetails = {
|
||||
labelfrom: 'Sangat Tidak Setuju',
|
||||
labelto: 'Sangat Setuju',
|
||||
valuefrom: 0,
|
||||
valueto: 5
|
||||
<script>
|
||||
function choose_type(type_name, type_value, questionDetails = null) {
|
||||
console.log(`#detail-${type_name}`);
|
||||
var nameType = type_name.split('[type]')[0];
|
||||
let result = '';
|
||||
|
||||
// Setting default question detail
|
||||
if (questionDetails == null) {
|
||||
questionDetails = {
|
||||
labelfrom: 'Sangat Tidak Setuju',
|
||||
labelto: 'Sangat Setuju',
|
||||
valuefrom: 0,
|
||||
valueto: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type_value == 'Skala') {
|
||||
result = `<div class="mt-3 col-lg-6">
|
||||
if (type_value == 'Skala') {
|
||||
result = `<div class="mt-3 col-lg-6">
|
||||
<div class="d-flex mb-2">
|
||||
<select name="${nameType}[valuefrom]" id="${nameType}[valuefrom]" class="form-select border-bottom" style="border: none; width: 85px;">
|
||||
<option value="0" ${(questionDetails['valuefrom'] == 0) ? 'selected' : ''}>0</option>
|
||||
|
@ -32,17 +33,33 @@
|
|||
<p class="mx-3 my-auto"> sampai </p>
|
||||
|
||||
<select name="${nameType}[valueto]" id="${nameType}[valueto]" class="form-select border-bottom" style="border: none; width: 85px;">
|
||||
@for($i=2; $i<=10; $i++) <option value="{{ $i }}" ${(questionDetails['valueto'] == '{{ $i }}') ? 'selected' : ''}>{{ $i }}</option>@endfor
|
||||
@for ($i = 2; $i <= 10; $i++) <option value="{{ $i }}" ${(questionDetails['valueto'] == '{{ $i }}') ? 'selected' : ''}>{{ $i }}</option>@endfor
|
||||
</select>
|
||||
<input type="text" class="form-control ms-2" name="${nameType}[labelto]" style="width: 150px;" placeholder="Setuju" value="${questionDetails['labelto']}" required>
|
||||
</div>
|
||||
</div>`;
|
||||
} else if (type_value == 'Esai') {
|
||||
result = `<div class="mt-3 col-lg-12">
|
||||
<textarea class="form-control" id="${nameType}[esai]" rows="3" placeholder="Pertanyaan berupa teks atau esai" disabled></textarea>
|
||||
} else if (type_value == 'Jawaban Angka') {
|
||||
result = `<div class="mt-3 col-lg-12">
|
||||
<input type="number" class="form-control" id="${nameType}[angka]" rows="3" placeholder="Pertanyaan berupa angka" disabled>
|
||||
</div>`;
|
||||
} else {
|
||||
result = `<div class="mt-3 col-lg-6">
|
||||
} else if (type_value == 'Jawaban Singkat') {
|
||||
result = `<div class="mt-3 col-lg-12">
|
||||
<input type="text" class="form-control" id="${nameType}[teks]" rows="3" placeholder="Pertanyaan berupa teks singkat" disabled>
|
||||
</div>`;
|
||||
} else if (type_value == 'Esai') {
|
||||
result = `<div class="mt-3 col-lg-12">
|
||||
<textarea class="form-control" id="${nameType}[esai]" rows="3" placeholder="Pertanyaan berupa teks panjang atau esai" disabled></textarea>
|
||||
</div>`;
|
||||
} else if (type_value == 'Master') {
|
||||
result = `<div class="mt-3 col-lg-12">
|
||||
<select class="form-select" id="${nameType}[master]" name="${nameType}[master]">
|
||||
@foreach ($management_master as $master)
|
||||
<option value="{{ $master->master_value }}" ${(questionDetails == '{{ $master->master_value }}' ? 'selected' : null)}>{{ $master->master_code }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>`;
|
||||
} else {
|
||||
result = `<div class="mt-3 col-lg-6">
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="radio" id="value${nameType}" value="1">
|
||||
<label class="form-check-label" for="value${nameType}" id="label${nameType}" >
|
||||
|
@ -56,27 +73,27 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
document.getElementById(`detail-${type_name}`).innerHTML = result;
|
||||
}
|
||||
|
||||
document.getElementById(`detail-${type_name}`).innerHTML = result;
|
||||
}
|
||||
let id = '{{ isset($survey->questionSurveys->last()->id) ? $survey->questionSurveys->last()->id + 1 : 1 }}';
|
||||
|
||||
let id = '{{ isset($survey->questionSurveys->last()->id) ? ($survey->questionSurveys->last()->id + 1) : 1 }}';
|
||||
|
||||
function add_question() {
|
||||
$('#labelAddQuestion').html('Loading...')
|
||||
var form_data = new FormData($('#add-question')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/add-question', $survey->id) }}",
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$('#labelAddQuestion').html('Tambah Pertanyaan')
|
||||
console.log(data);
|
||||
$('#question_all').append(`<div class="col-lg-12 mx-auto" id="question-${data.id}">
|
||||
function add_question() {
|
||||
$('#labelAddQuestion').html('Loading...')
|
||||
var form_data = new FormData($('#add-question')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/add-question', $survey->id) }}",
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$('#labelAddQuestion').html('Tambah Pertanyaan')
|
||||
console.log(data);
|
||||
$('#question_all').append(`<div class="col-lg-12 mx-auto" id="question-${data.id}">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" id="delete-question-${data.id}">
|
||||
|
@ -106,8 +123,11 @@
|
|||
<select class="form-select" id="questionSurvey[${data.id}][type]" name="questionSurvey[${data.id}][type]" onchange="choose_type(this.name, this.value)" required>
|
||||
<option value="">Pilih Tipe Pertanyaan</option>
|
||||
<option value="Iya atau Tidak" selected>Iya atau Tidak</option>
|
||||
<option value="Jawaban Angka">Jawaban Angka</option>
|
||||
<option value="Jawaban Singkat">Jawaban Singkat</option>
|
||||
<option value="Skala">Skala</option>
|
||||
<option value="Esai">Esai</option>
|
||||
<option value="Master">Master</option>
|
||||
</select>
|
||||
<!-- error message -->
|
||||
@error('questionSurvey[${data.id}][type]')
|
||||
|
@ -125,211 +145,264 @@
|
|||
</div>
|
||||
</div>`);
|
||||
|
||||
console.log(id);
|
||||
id++; // add id
|
||||
},
|
||||
error: function() {
|
||||
$('#labelAddQuestion').html('Tambah Pertanyaan')
|
||||
console.log('Add question error');
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log(id);
|
||||
id++; // add id
|
||||
},
|
||||
error: function() {
|
||||
$('#labelAddQuestion').html('Tambah Pertanyaan')
|
||||
console.log('Add question error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_question(id) {
|
||||
$('#label-delete-' + id).html('Loading...')
|
||||
var form_data = new FormData($('#delete-' + id)[0]);
|
||||
let question_id = id.split('-')[1];
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/delete-question') }}" + '/' + question_id,
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById(id).remove();
|
||||
},
|
||||
error: function() {
|
||||
$('#label-delete-' + id).html('<i class="ti ti-trash"></i>')
|
||||
console.log('Delete question error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<form method="post" id="form-survey" onsubmit="save_survey()">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom d-flex">
|
||||
<h3>Form Survey</h3>
|
||||
<i class="ms-auto my-auto text-primary" id="labelAutoSaved">Auto Saved</i>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-6">
|
||||
<label for="name" class="form-label">Judul Survey</label>
|
||||
<input type="text" class="form-control" id="name" name="name" value="{{ $survey->name }}" onkeyup="save_survey()" required>
|
||||
<!-- error message -->
|
||||
@error('name')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-12">
|
||||
<label for="description" class="form-label">Deskripsi</label>
|
||||
<textarea class="form-control @error('description') is-invalid @enderror" id="description" name="description" rows="3" placeholder="Isikan penjelasan tentang tujuan survey anda" onkeyup="save_survey()" required>{{ $survey->description }}</textarea>
|
||||
<!-- error message -->
|
||||
@error('description')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Questions -->
|
||||
<div class="row d-flex align-items-strech" id="question_all">
|
||||
@foreach ($survey->questionSurveys as $questionSurveys)
|
||||
<div class="col-lg-12 mx-auto row" id="question-{{ $questionSurveys->id }}">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" id="delete-question-{{ $questionSurveys->id }}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<div class="d-flex">
|
||||
<a href="javascript:void(0)" onclick="delete_question('question-{{ $questionSurveys->id }}')" class="badge text-bg-danger text-light ms-auto" id="label-delete-question-{{ $questionSurveys->id }}">
|
||||
<i class="ti ti-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" id="form-question-{{ $questionSurveys->id }}" onkeyup="save_question(this.id)" onchange="save_question(this.id)">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<label class="form-label">Pertanyaan</label>
|
||||
</div>
|
||||
<div class="mb-3 col-lg-8">
|
||||
<input type="text" class="form-control" id="questionSurvey[{{ $questionSurveys->id }}][question]" name="questionSurvey[{{ $questionSurveys->id }}][question]" value="{{ $questionSurveys->name }}" placeholder="Tuliskan pertayaan anda?" required>
|
||||
<!-- error message -->
|
||||
@error('questionSurvey[{{ $questionSurveys->id }}][question]')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-lg-4">
|
||||
<select class="form-select" id="questionSurvey[{{ $questionSurveys->id }}][type]" name="questionSurvey[{{ $questionSurveys->id }}][type]" onchange="choose_type(this.name, this.value)" required>
|
||||
<option value="">Pilih Tipe Pertanyaan</option>
|
||||
<option value="Iya atau Tidak" @if ($questionSurveys->type == 'Iya atau Tidak') selected @endif>Iya atau Tidak</option>
|
||||
<option value="Skala" @if ($questionSurveys->type == 'Skala') selected @endif>Skala</option>
|
||||
<option value="Esai" @if ($questionSurveys->type == 'Esai') selected @endif>Esai</option>
|
||||
</select>
|
||||
<!-- error message -->
|
||||
@error('questionSurvey[{{ $questionSurveys->id }}][type]')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-0" id="detail-questionSurvey[{{ $questionSurveys->id }}][type]">
|
||||
<!-- Result detail type -->
|
||||
</div>
|
||||
<script>
|
||||
var questionDetail = null;
|
||||
if ('{{ isset($questionSurveys->questionDetails) ? 1 : 0 }}' && '{{ $questionSurveys->type }}' == 'Skala') {
|
||||
questionDetail = {
|
||||
labelfrom: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == "Skala" ? json_decode($questionSurveys->questionDetails->question_label)[0] : null }}',
|
||||
labelto: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == "Skala" ? json_decode($questionSurveys->questionDetails->question_label)[1] : null }}',
|
||||
valuefrom: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == "Skala" ? json_decode($questionSurveys->questionDetails->question_value)[0] : null }}',
|
||||
valueto: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == "Skala" ? json_decode($questionSurveys->questionDetails->question_value)[1] : null }}'
|
||||
}
|
||||
function delete_question(id) {
|
||||
$('#label-delete-' + id).html('Loading...')
|
||||
var form_data = new FormData($('#delete-' + id)[0]);
|
||||
let question_id = id.split('-')[1];
|
||||
Swal.fire({
|
||||
title: 'Kamu yakin?',
|
||||
text: "Ingin menghapus pertanyaan ini!",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Iya, saya yakin!',
|
||||
cancelButtonText: 'Tidak'
|
||||
}).then((result) => {
|
||||
console.log(result);
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/delete-question') }}" + '/' + question_id,
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById(id).remove();
|
||||
},
|
||||
error: function() {
|
||||
$('#label-delete-' + id).html('<i class="ti ti-trash"></i>')
|
||||
console.log('Delete question error');
|
||||
}
|
||||
choose_type("questionSurvey[{{ $questionSurveys->id }}][type]", '{{ $questionSurveys->type }}', questionDetail);
|
||||
</script>
|
||||
</form>
|
||||
});
|
||||
} else if (result.isDismissed) {
|
||||
$('#label-delete-' + id).html('<i class="ti ti-trash"></i>')
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<form method="post" id="form-survey" onsubmit="save_survey()">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom d-flex">
|
||||
<h3>Form Survey</h3>
|
||||
<i class="ms-auto my-auto text-primary" id="labelAutoSaved">Auto Saved</i>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-6">
|
||||
<label for="name" class="form-label">Judul Survey</label>
|
||||
<input type="text" class="form-control" id="name" name="name"
|
||||
value="{{ $survey->name }}" onkeyup="save_survey()" required>
|
||||
<!-- error message -->
|
||||
@error('name')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-lg-2"></div>
|
||||
<div class="mb-3 col-lg-4">
|
||||
<label for="years" class="form-label">Tahun</label>
|
||||
<input type="number" class="form-control" id="years" name="years"
|
||||
value="{{ $survey->years }}" onkeyup="save_survey()" required>
|
||||
<!-- error message -->
|
||||
@error('years')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3 col-lg-12">
|
||||
<label for="description" class="form-label">Deskripsi</label>
|
||||
<textarea class="form-control @error('description') is-invalid @enderror" id="description" name="description"
|
||||
rows="3" placeholder="Isikan penjelasan tentang tujuan survey anda" onkeyup="save_survey()" required>{{ $survey->description }}</textarea>
|
||||
<!-- error message -->
|
||||
@error('description')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<!-- Add Question -->
|
||||
<div class="col-lg-12 text-end">
|
||||
<form method="POST" id="add-question">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<a href="javascript:void(0)" onclick="add_question()" class="btn btn-sm bg-info-subtle text-info " data-bs-toggle="tooltip" title="Tambah Pertanyaan">
|
||||
<i class="ti ti-plus"></i> <span id="labelAddQuestion">Tambah Pertanyaan</span>
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Questions -->
|
||||
<div class="row d-flex align-items-strech" id="question_all">
|
||||
@foreach ($survey->questionSurveys as $questionSurveys)
|
||||
<div class="col-lg-12 mx-auto row" id="question-{{ $questionSurveys->id }}">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" id="delete-question-{{ $questionSurveys->id }}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<div class="d-flex">
|
||||
<a href="javascript:void(0)"
|
||||
onclick="delete_question('question-{{ $questionSurveys->id }}')"
|
||||
class="badge text-bg-danger text-light ms-auto"
|
||||
id="label-delete-question-{{ $questionSurveys->id }}">
|
||||
<i class="ti ti-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" id="form-question-{{ $questionSurveys->id }}" onkeyup="save_question(this.id)"
|
||||
onchange="save_question(this.id)">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<label class="form-label">Pertanyaan</label>
|
||||
</div>
|
||||
<div class="mb-3 col-lg-8">
|
||||
<input type="text" class="form-control"
|
||||
id="questionSurvey[{{ $questionSurveys->id }}][question]"
|
||||
name="questionSurvey[{{ $questionSurveys->id }}][question]"
|
||||
value="{{ $questionSurveys->name }}" placeholder="Tuliskan pertayaan anda?"
|
||||
required>
|
||||
<!-- error message -->
|
||||
@error('questionSurvey[{{ $questionSurveys->id }}][question]')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-lg-4">
|
||||
<select class="form-select" id="questionSurvey[{{ $questionSurveys->id }}][type]"
|
||||
name="questionSurvey[{{ $questionSurveys->id }}][type]"
|
||||
onchange="choose_type(this.name, this.value)" required>
|
||||
<option value="">Pilih Tipe Pertanyaan</option>
|
||||
<option value="Iya atau Tidak" @if ($questionSurveys->type == 'Iya atau Tidak') selected @endif>Iya
|
||||
atau Tidak</option>
|
||||
<option value="Skala" @if ($questionSurveys->type == 'Skala') selected @endif>Skala
|
||||
</option>
|
||||
<option value="Jawaban Angka" @if ($questionSurveys->type == 'Jawaban Angka') selected @endif>
|
||||
Jawaban Angka</option>
|
||||
<option value="Jawaban Singkat" @if ($questionSurveys->type == 'Jawaban Singkat') selected @endif>
|
||||
Jawaban Singkat</option>
|
||||
<option value="Esai" @if ($questionSurveys->type == 'Esai') selected @endif>Esai
|
||||
</option>
|
||||
<option value="Master" @if ($questionSurveys->type == 'Master') selected @endif>Master
|
||||
</option>
|
||||
</select>
|
||||
<!-- error message -->
|
||||
@error('questionSurvey[{{ $questionSurveys->id }}][type]')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-0" id="detail-questionSurvey[{{ $questionSurveys->id }}][type]">
|
||||
<!-- Result detail type -->
|
||||
</div>
|
||||
<script>
|
||||
var questionDetail = null;
|
||||
if ('{{ isset($questionSurveys->questionDetails) ? 1 : 0 }}' && '{{ $questionSurveys->type }}' == 'Skala') {
|
||||
questionDetail = {
|
||||
labelfrom: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == 'Skala' ? json_decode($questionSurveys->questionDetails->question_label)[0] : null }}',
|
||||
labelto: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == 'Skala' ? json_decode($questionSurveys->questionDetails->question_label)[1] : null }}',
|
||||
valuefrom: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == 'Skala' ? json_decode($questionSurveys->questionDetails->question_value)[0] : null }}',
|
||||
valueto: '{{ isset($questionSurveys->questionDetails) && $questionSurveys->type == 'Skala' ? json_decode($questionSurveys->questionDetails->question_value)[1] : null }}'
|
||||
}
|
||||
} else if ('{{ $questionSurveys->type }}' == 'Master') {
|
||||
questionDetail =
|
||||
'{{ isset($questionSurveys->questionDetails) ? json_decode($questionSurveys->questionDetails->question_value)[0] : '' }}';
|
||||
}
|
||||
choose_type("questionSurvey[{{ $questionSurveys->id }}][type]", '{{ $questionSurveys->type }}', questionDetail);
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<!-- Save Survey -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="btn btn-primary mt-3">Simpan</a>
|
||||
<!-- Add Question -->
|
||||
<div class="col-lg-12 text-end">
|
||||
<form method="POST" id="add-question">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<a href="javascript:void(0)" onclick="add_question()" class="btn btn-sm bg-info-subtle text-info "
|
||||
data-bs-toggle="tooltip" title="Tambah Pertanyaan">
|
||||
<i class="ti ti-plus"></i> <span id="labelAddQuestion">Tambah Pertanyaan</span>
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function save_survey() {
|
||||
$('#labelAutoSaved').html('Loading...')
|
||||
var form_data = new FormData($('#form-survey')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/save-survey', $survey->id) }}",
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log(data);
|
||||
},
|
||||
error: function() {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log('Saving data error');
|
||||
}
|
||||
});
|
||||
}
|
||||
<!-- Save Survey -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="btn btn-primary mt-3">Simpan</a>
|
||||
|
||||
function save_question(html_id) {
|
||||
$('#labelAutoSaved').html('Loading...')
|
||||
var form_data = new FormData($('#' + html_id)[0]);
|
||||
var question_id = html_id.split('-')[2];
|
||||
console.log('#' + html_id);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/save-question') }}/" + question_id,
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log(data);
|
||||
},
|
||||
error: function() {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log('Saving data error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@stop
|
||||
<script>
|
||||
function save_survey() {
|
||||
$('#labelAutoSaved').html('Loading...')
|
||||
var form_data = new FormData($('#form-survey')[0]);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/save-survey', $survey->id) }}",
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log(data);
|
||||
},
|
||||
error: function() {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log('Saving data error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function save_question(html_id) {
|
||||
$('#labelAutoSaved').html('Loading...')
|
||||
var form_data = new FormData($('#' + html_id)[0]);
|
||||
var question_id = html_id.split('-')[2];
|
||||
console.log('#' + html_id);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "{{ URL::to('admin/surveys/save-question') }}/" + question_id,
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log(data);
|
||||
},
|
||||
error: function() {
|
||||
$('#labelAutoSaved').html('Auto Saved')
|
||||
console.log('Saving data error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@stop
|
||||
|
|
|
@ -2,76 +2,110 @@
|
|||
@section('title', 'Surveys')
|
||||
@section('content')
|
||||
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
<!-- button back -->
|
||||
<a href="{{ URL::to('admin/surveys') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h3 class="form-label mt-2 text-white border-bottom pb-3">{{ $survey->name }}</h3>
|
||||
<pre for="description" class="mt-3">{{ $survey->description }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Questions -->
|
||||
<form method="post" action="{{ URL::to('admin/surveys/question-answers') }}">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="row d-flex align-items-strech" id="question_all">
|
||||
<input type="hidden" name="survey_id" value="{{ $survey->id }}">
|
||||
@foreach ($survey->questionSurveys as $questionSurveys)
|
||||
<div class="col-lg-12 mx-auto row" id="question-{{ $questionSurveys->id }}">
|
||||
<!-- Surveys -->
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-12 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-10">
|
||||
<label class="form-label">{{ $questionSurveys->name }}</label>
|
||||
</div>
|
||||
@if ($questionSurveys->type == 'Iya atau Tidak')
|
||||
<div class="col-lg-2 row px-4">
|
||||
<div class="form-check col-lg-6 mb-2">
|
||||
<input class="form-check-input" type="radio" name="question[{{ $questionSurveys->id }}][answer]" value="1" required>
|
||||
<label class="form-check-label" for="answer">
|
||||
Iya
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check col-lg-6">
|
||||
<input class="form-check-input" type="radio" name="question[{{ $questionSurveys->id }}][answer]" value="0" required>
|
||||
<label class="form-check-label" for="answer">
|
||||
Tidak
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Skala')
|
||||
<div class="col-lg-12 p-2">
|
||||
<div class="mx-auto text-center">
|
||||
<label class="form-check-label" for="answer">{{ json_decode($questionSurveys->questionDetails->question_label)[0] }}</label>
|
||||
@for ($i=(json_decode($questionSurveys->questionDetails->question_value)[0]); $i<=(json_decode($questionSurveys->questionDetails->question_value)[1]); $i++)
|
||||
<input class="form-check-input mx-2" type="radio" name="question[{{ $questionSurveys->id }}][answer]" value="{{ $i }}" required>
|
||||
@endfor
|
||||
<label class="form-check-label" for="answer">{{ json_decode($questionSurveys->questionDetails->question_label)[1] }}</label>
|
||||
</div>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Esai')
|
||||
<div class="mt-3 col-lg-12">
|
||||
<textarea class="form-control" name="question[{{ $questionSurveys->id }}][answer]" rows="3" placeholder="Jawaban berupa teks atau esai" required></textarea>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h3 class="form-label mt-2 text-white border-bottom pb-3">{{ $survey->name }}</h3>
|
||||
<pre for="description" class="mt-3 text-wrap">{{ $survey->description }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div class="col-lg-12">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@stop
|
||||
|
||||
<!-- Questions -->
|
||||
<form method="post" action="{{ URL::to('admin/surveys/question-answers') }}">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="row d-flex align-items-strech" id="question_all">
|
||||
<input type="hidden" name="survey_id" value="{{ $survey->id }}">
|
||||
@foreach ($survey->questionSurveys as $questionSurveys)
|
||||
<div class="col-lg-12 mx-auto row" id="question-{{ $questionSurveys->id }}">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-10">
|
||||
<label class="form-label">{{ $questionSurveys->name }}</label>
|
||||
</div>
|
||||
@if ($questionSurveys->type == 'Iya atau Tidak')
|
||||
<div class="col-lg-2 row px-4">
|
||||
<div class="form-check col-lg-6 mb-2">
|
||||
<input class="form-check-input" type="radio"
|
||||
name="question[{{ $questionSurveys->id }}][answer]" value="1" required>
|
||||
<label class="form-check-label" for="answer">
|
||||
Iya
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check col-lg-6">
|
||||
<input class="form-check-input" type="radio"
|
||||
name="question[{{ $questionSurveys->id }}][answer]" value="0" required>
|
||||
<label class="form-check-label" for="answer">
|
||||
Tidak
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Skala')
|
||||
<div class="col-lg-12 p-2">
|
||||
<div class="mx-auto text-center">
|
||||
<label class="form-check-label"
|
||||
for="answer">{{ json_decode($questionSurveys->questionDetails->question_label)[0] }}</label>
|
||||
@for ($i = json_decode($questionSurveys->questionDetails->question_value)[0]; $i <= json_decode($questionSurveys->questionDetails->question_value)[1]; $i++)
|
||||
<input class="form-check-input mx-2" type="radio"
|
||||
name="question[{{ $questionSurveys->id }}][answer]"
|
||||
value="{{ $i }}" required>
|
||||
@endfor
|
||||
<label class="form-check-label"
|
||||
for="answer">{{ json_decode($questionSurveys->questionDetails->question_label)[1] }}</label>
|
||||
</div>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Jawaban Angka')
|
||||
<div class="mt-3 col-lg-12">
|
||||
<input type="number" class="form-control"
|
||||
name="question[{{ $questionSurveys->id }}][answer]"
|
||||
placeholder="Jawaban berupa angka" required>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Jawaban Singkat')
|
||||
<div class="mt-3 col-lg-12">
|
||||
<input type="text" class="form-control"
|
||||
name="question[{{ $questionSurveys->id }}][answer]"
|
||||
placeholder="Jawaban berupa teks singkat" required>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Esai')
|
||||
<div class="mt-3 col-lg-12">
|
||||
<textarea class="form-control" name="question[{{ $questionSurveys->id }}][answer]" rows="3"
|
||||
placeholder="Jawaban berupa teks atau esai" required></textarea>
|
||||
</div>
|
||||
@elseif ($questionSurveys->type == 'Master')
|
||||
<div class="mt-3 col-lg-12">
|
||||
<select class="form-select" name="question[{{ $questionSurveys->id }}][answer]"
|
||||
required>
|
||||
@php
|
||||
$master =
|
||||
'App\Models\Master\\' .
|
||||
json_decode($questionSurveys->questionDetails->question_value)[0];
|
||||
@endphp
|
||||
@foreach ($master::get() as $_master)
|
||||
<option value="{{ $_master->keterangan }}">{{ $_master->keterangan }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div class="col-lg-12">
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@stop
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
@method('POST')
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="Contoh: Ardito Pratama" value="{{ old('name') }} " required>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="Contoh: Ardito Pratama" value="{{ old('name') }}" required>
|
||||
<div id="emailHelp" class="form-text">Silahkan masukkan nama lengkap anda.</div>
|
||||
<!-- error message-->
|
||||
@error('name')
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
@extends('layouts.app')
|
||||
@section('title', 'Master Agama')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 d-flex align-items-stretch">
|
||||
<div class="card w-100">
|
||||
<div class="card-body p-4">
|
||||
<div class="d-flex align-items-stretch">
|
||||
<h5 class="card-title fw-semibold mb-4">Master Agama</h5>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-responsive table-bordered text-nowrap mb-0 align-middle">
|
||||
<thead class="text-dark fs-4">
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="65px">
|
||||
<h6 class="fw-semibold mb-0 text-center">#</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0" style="max-width: 100px;">
|
||||
<h6 class="fw-semibold mb-0">Kode Master</h6>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($agama as $_agama)
|
||||
<tr>
|
||||
<td class="border-bottom-0 text-center">
|
||||
<span class="fw-normal mb-0">{{ ($agama->currentPage()-1) * $agama->perPage() + $loop->index + 1 }}</span>
|
||||
</td>
|
||||
<td class="border-bottom-0" style="max-width: 100px;">
|
||||
<span class="fw-normal mb-1 badge text-bg-light">{{ $_agama->keterangan }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<div class="alert alert-danger">
|
||||
Data master belum Tersedia.
|
||||
</div>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
@if (Session::has('agamas-message'))
|
||||
<script>
|
||||
Swal.fire({
|
||||
text: "{{ Session::get('agamas-message')['msg'] }}",
|
||||
icon: "{{ Session::get('agamas-message')['type'] }}",
|
||||
timer: 2500
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
@stop
|
|
@ -0,0 +1,46 @@
|
|||
@extends('layouts.app')
|
||||
@section('title', 'Buat Data Pengguna')
|
||||
@section('content')
|
||||
<!-- Button Back -->
|
||||
<a href="{{ URL::to('master/management-master') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-6 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Tambah Manajemen Master</h3>
|
||||
</div>
|
||||
<div class="card-body border-top">
|
||||
<form method="post" action="{{ route('master.management-master.index') }}">
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="mb-3">
|
||||
<label for="master_code" class="form-label">Kode Model</label>
|
||||
<input type="text" class="form-control" id="master_code" name="master_code" placeholder="Contoh: Master Agama" value="{{ old('master_code') }}" required>
|
||||
<!-- error message-->
|
||||
@error('master_code')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="master_value" class="form-label">Master Model</label>
|
||||
<input type="text" class="form-control" id="master_value" name="master_value" value="{{ old('master_value') }}" placeholder="Contoh: Agama diambil dari model master" required>
|
||||
{{-- <div id="master_value_help" class="form-text">Isikan nama model yang diambil dari App/Models/Master .</div> --}}
|
||||
<!-- error message -->
|
||||
@error('master_value')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
|
@ -0,0 +1,46 @@
|
|||
@extends('layouts.app')
|
||||
@section('title', 'Ubah Data Manajemen Master')
|
||||
@section('content')
|
||||
<!-- Button Back -->
|
||||
<a href="{{ URL::to('master/management-master') }}" class="mb-3 badge text-bg-light text-primary">
|
||||
<i class="ti ti-arrow-left"> </i> Kembali
|
||||
</a>
|
||||
|
||||
<div class="row d-flex align-items-strech">
|
||||
<div class="col-lg-6 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Edit Manajemen Master</h3>
|
||||
</div>
|
||||
<div class="card-body border-top">
|
||||
<form method="post" action="{{ route('master.management-master.update', $management_master->id) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="mb-3">
|
||||
<label for="master_code" class="form-label">Kode Model</label>
|
||||
<input type="text" class="form-control" id="master_code" name="master_code" placeholder="Contoh: Master Agama" value="{{ isset($management_master->master_code) ? $management_master->master_code : '' }}" required>
|
||||
<!-- error message-->
|
||||
@error('master_code')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="master_value" class="form-label">Master Model</label>
|
||||
<input type="text" class="form-control" id="master_value" name="master_value" value="{{ isset($management_master->master_value) ? $management_master->master_value : '' }}" placeholder="Contoh: Agama diambil dari model master" required>
|
||||
{{-- <div id="master_value_help" class="form-text">Isikan nama model yang diambil dari App/Models/Master .</div> --}}
|
||||
<!-- error message -->
|
||||
@error('master_value')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
|
@ -0,0 +1,80 @@
|
|||
@extends('layouts.app')
|
||||
@section('title', 'Manajemen Master')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 d-flex align-items-stretch">
|
||||
<div class="card w-100">
|
||||
<div class="card-body p-4">
|
||||
<div class="d-flex align-items-stretch">
|
||||
<h5 class="card-title fw-semibold mb-4">Manajemen Master</h5>
|
||||
@role(['Admin'])
|
||||
<div class="d-inline ms-auto">
|
||||
@method('GET')
|
||||
<a href="{{ URL::to('master/management-master/create') }}" class="btn btn-sm btn-success">
|
||||
<i class="ti ti-circle-plus"></i> Tambah
|
||||
</a>
|
||||
</div>
|
||||
@endrole
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-responsive table-bordered text-nowrap mb-0 align-middle">
|
||||
<thead class="text-dark fs-4">
|
||||
<tr>
|
||||
<th class="border-bottom-0" width="45px">
|
||||
<h6 class="fw-semibold mb-0 text-center">No.</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0">
|
||||
<h6 class="fw-semibold mb-0">Kode Master</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0">
|
||||
<h6 class="fw-semibold mb-0">Keterangan</h6>
|
||||
</th>
|
||||
<th class="border-bottom-0" width="100px">
|
||||
<h6 class="fw-semibold mb-0 text-center">Aksi</h6>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($management_master as $_mana)
|
||||
<tr>
|
||||
<td class="border-bottom-0 text-center">
|
||||
<span class="fw-normal mb-0">{{ ($management_master->currentPage()-1) * $management_master->perPage() + $loop->index + 1 }}</span>
|
||||
</td>
|
||||
<td class="border-bottom-0 text-truncate" style="max-width: 100px;">
|
||||
<span class="fw-normal mb-1">{{ $_mana->master_code }}</span>
|
||||
</td>
|
||||
<td class="border-bottom-0">
|
||||
<span class="fw-normal mb-1 badge text-bg-light">{{ $_mana->master_value }}</span>
|
||||
</td>
|
||||
<td class="border-bottom-0">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
@role(['Admin'])
|
||||
<a href="{{ URL::to('master/management-master/edit/' . $_mana->id) }}" class="btn btn-sm bg-warning-subtle text-warning mx-auto" data-bs-toggle="tooltip" title="Edit data"><i class="ti ti-edit"></i></a>
|
||||
@endrole
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<div class="alert alert-danger">
|
||||
Data master belum Tersedia.
|
||||
</div>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
@if (Session::has('management_masters-message'))
|
||||
<script>
|
||||
Swal.fire({
|
||||
text: "{{ Session::get('management_masters-message')['msg'] }}",
|
||||
icon: "{{ Session::get('management_masters-message')['type'] }}",
|
||||
timer: 2500
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
@stop
|
|
@ -5,6 +5,8 @@ use App\Http\Controllers\Admins\ProfileController;
|
|||
use App\Http\Controllers\Auths\AuthController;
|
||||
use App\Http\Controllers\Admins\SurveyController;
|
||||
use App\Http\Controllers\Admins\Users\UserController;
|
||||
use App\Http\Controllers\Master\ManagementMasterController;
|
||||
use App\Http\Controllers\Master\MasterAgamaController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
|
@ -40,7 +42,7 @@ Route::group(['prefix' => 'auth'], function () {
|
|||
|
||||
|
||||
// Auth with Admin
|
||||
Route::group(['prefix' => 'admin', 'middleware' => ['role:Admin']], function () {
|
||||
Route::group(['prefix' => 'admin', 'middleware' => ['role:Admin|Staff']], function () {
|
||||
// Dashboard
|
||||
Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard.index');
|
||||
|
||||
|
@ -56,17 +58,6 @@ Route::group(['prefix' => 'admin', 'middleware' => ['role:Admin']], function ()
|
|||
Route::put('users/update/{id}', [UserController::class, 'update'])->name('users.update');
|
||||
Route::delete('users/delete/{id}', [UserController::class, 'destroy'])->name('users.delete');
|
||||
|
||||
// // Roles
|
||||
// Route::group(['prefix' => 'roles'], function () {
|
||||
// Route::get('/', [RoleController::class, 'index'])->name('roles.index')->comment('Halaman Roles');
|
||||
// Route::get('/create', [RoleController::class, 'create'])->name('roles.create')->comment('Halaman Tambah Roles');
|
||||
// Route::post('/', [RoleController::class, 'store'])->name('roles.store')->comment('Tambah Roles');
|
||||
// Route::get('/edit/{id}', [RoleController::class, 'edit'])->name('roles.edit')->comment('Halaman Edit Roles');
|
||||
// Route::put('/update/{id}', [RoleController::class, 'update'])->name('roles.update')->comment('Perbarui Roles');
|
||||
// Route::delete('/delete/{id}', [RoleController::class, 'destroy'])->name('roles.delete')->comment('Menghapus Roles');
|
||||
// Route::get('/refresh-routes', [RoleController::class, 'refreshRoutes'])->name('roles.refresh-routes')->comment('Refresh Permission Routes');
|
||||
// });
|
||||
|
||||
// Survey
|
||||
Route::get('surveys/preview/{id}', [SurveyController::class, 'preview'])->name('admin.surveys.preview');
|
||||
Route::post('surveys/save-survey/{id}', [SurveyController::class, 'saveSurvey'])->name('admin.surveys.save-survey');
|
||||
|
@ -79,4 +70,16 @@ Route::group(['prefix' => 'admin', 'middleware' => ['role:Admin']], function ()
|
|||
|
||||
// Dashboard
|
||||
Route::get('dashboard/total', [DashboardController::class, 'total'])->name('admin.dashboard.total');
|
||||
});
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'master', 'middleware' => ['role:Admin']], function () {
|
||||
// Management Master
|
||||
Route::get('management-master', [ManagementMasterController::class, 'index'])->name('master.management-master.index');
|
||||
Route::get('management-master/create', [ManagementMasterController::class, 'create'])->name('master.management-master.create');
|
||||
Route::post('management-master', [ManagementMasterController::class, 'store'])->name('master.management-master.store');
|
||||
Route::get('management-master/edit/{id}', [ManagementMasterController::class, 'edit'])->name('master.management-master.edit');
|
||||
Route::put('management-master/update/{id}', [ManagementMasterController::class, 'update'])->name('master.management-master.update');
|
||||
|
||||
// Master Agama
|
||||
Route::get('master-agama', [MasterAgamaController::class, 'index'])->name('master');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue