update assigment lintas region

This commit is contained in:
majid
2024-11-05 08:29:27 +07:00
parent e466e5e7ff
commit 10c9567b4f
19 changed files with 699 additions and 252 deletions

View File

@@ -35,28 +35,41 @@ class ActivityController extends Controller
// Ambil user yang sedang login
$user = auth()->user();
$roles = $user->load('roles');
$regionId = null;
// Cek apakah user memiliki role 'senior officer'
if ($roles->roles->pluck('name')->contains('senior officer')) {
$regionId = TeamsUsers::with('team.regions')
// Inisialisasi regionId dan teamId sebagai null agar bisa dinamis
$regionId = null;
$teamId = null;
if ($roles->roles->pluck('name')->contains('senior-officer')) {
$userTeam = TeamsUsers::with('team')
->where('user_id', $user->id)
->first()?->team->regions_id;
->first();
$regionId = $userTeam?->team->regions_id;
$teamId = $userTeam?->teams_id;
}
$teamsActivity = TeamsUsers::with(['user', 'team', 'team.regions'])
->whereHas('team', function ($q) use ($regionId) {
$teamsActivity = TeamsUsers::with(['user', 'team', 'team.regions', 'user.roles'])
->whereHas('team', function ($q) use ($regionId, $teamId) {
if ($regionId) {
$q->where('regions_id', $regionId);
}
if ($teamId) {
$q->where('id', $teamId); // Hanya tim yang sama
}
})
->where('user_id', '!=', $user->id)
->whereHas('user.roles', function ($query) {
// Filter hanya peran 'surveyor' atau 'surveyor-penilai'
$query->whereIn('name', ['surveyor', 'surveyor-penilai']);
})
->get();
return view('lpj::activity.progres_activity.index', compact('teamsActivity'));
}
public function senior()
{
return view('lpj::activity.senior_officer.index');
@@ -194,14 +207,24 @@ class ActivityController extends Controller
public function dataTablesForActivity(Request $request, $id)
{
if (is_null($this->user) || !$this->user->can('debitur.view')) {
// abort(403, 'Sorry! You are not allowed to view users.');
}
// Query Penilaian dengan relasi yang diperlukan
$query = Penilaian::with(['permohonan', 'permohonan.debiture', 'permohonan.tujuanPenilaian', 'permohonan.debiture.documents.jenisJaminan'])
->where(function($q) use ($id) {
$q->where('surveyor_id', $id)
->orWhere('penilaian_id', $id)
->orWhere('penilai_surveyor_id', $id);
$query = Penilaian::with([
'permohonan',
'permohonan.debiture',
'permohonan.tujuanPenilaian',
'permohonan.debiture.documents.jenisJaminan',
'userPenilai'
])
->whereHas('userPenilai', function ($q) use ($id) {
$q->where('user_id', $id);
});
// Filter pencarian
if ($request->has('search') && !empty($request->get('search'))) {
$search = $request->get('search');

View File

@@ -5,14 +5,18 @@ namespace Modules\Lpj\Http\Controllers;
use App\Http\Controllers\Controller;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Modules\Lpj\Http\Requests\PenilaianRequest;
use Modules\Lpj\Models\JenisPenilaian;
use Modules\Lpj\Models\Penilaian;
use Modules\Lpj\Models\PenilaianTeam;
use Modules\Lpj\Models\Permohonan;
use Modules\Lpj\Models\StatusPermohonan;
use Modules\Lpj\Models\Teams;
use Modules\Lpj\Models\Regions;
use Modules\Lpj\Models\TeamsUsers;
use Modules\Usermanagement\Models\User;
use Illuminate\Support\Facades\Auth;
class PenilaianController extends Controller
{
@@ -37,17 +41,84 @@ class PenilaianController extends Controller
if ($validatedData) {
try {
$penilaian = Penilaian::create($validatedData);
DB::beginTransaction();
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi);
$penilaian = Penilaian::create($validatedData);
$validatedData['penilaian_id'] = $penilaian->id;
$teams_ids = [];
$user_ids = [];
$roles = [];
if ($validatedData['surveyor_id'] === 'pilih_dari_region') {
$surveyor_region_id = $validatedData['surveyor_region_id'];
// Hapus team_id sebelumnya di Permohonan jika ada
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi)->first();
if ($permohonan) {
$permohonan->update([
'status' => 'assign',
'region_id' => $surveyor_region_id,
]);
}
$teams_ids[] = $surveyor_region_id;
$user_ids[] = null;
$roles[] = 'surveyor';
} else {
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi)->first();
$teams_ids[] = $validatedData['teams_id'];
$user_ids[] = $validatedData['surveyor_id'];
$roles[] = 'surveyor';
}
if ($validatedData['penilai_id'] === 'pilih_dari_region') {
$penilaian_region_id = $validatedData['penilai_region_id'];
// Hapus team_id sebelumnya di Permohonan jika ada
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi)->first();
if ($permohonan) {
$permohonan->update([
'region_id' => $penilaian_region_id,
]);
}
$teams_ids[] = $penilaian_region_id;
$user_ids[] = null;
$roles[] = 'penilai';
} else {
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi)->first();
$teams_ids[] = $validatedData['teams_id'];
$user_ids[] = $validatedData['penilai_id'];
$roles[] = 'penilai';
}
foreach ($teams_ids as $key => $teams_id) {
PenilaianTeam::create([
'penilaian_id' => $validatedData['penilaian_id'],
'team_id' => $teams_id,
'user_id' => $user_ids[$key],
'role' => $roles[$key],
]);
}
if ($validatedData['surveyor_id'] === 'pilih_dari_region' || $validatedData['penilai_id'] === 'pilih_dari_region') {
$status = 'registered';
} else {
$status = 'assign';
}
$permohonan->update([
'status' => $status,
]);
DB::commit();
return redirect()->route('penilaian.index')->with('success', 'Penilaian berhasil disimpan');
} catch (Exception $e) {
return redirect()->route('penilaian.index')->with('error', $e->getMessage());
DB::rollBack();
return response()->json(array('error' => $e->getMessage()));
}
}
}
@@ -63,22 +134,43 @@ class PenilaianController extends Controller
/**
* Update the specified resource in storage.
*/
public function update(PenilaianRequest $request, $id)
public function update(Request $request, $id)
{
$validate = $request->validated();
if ($validate) {
try {
$penilaian = Penilaian::where('nomor_registrasi', $request->nomor_registrasi)->firstOrFail();
$penilaian->update($validate);
DB::beginTransaction();
$penilaian = Penilaian::where('nomor_registrasi', $request->nomor_registrasi)->first();
$penilaianId = $penilaian->id;
$penilainTeam = PenilaianTeam::where('penilaian_id', $penilaianId)->get();
foreach ($penilainTeam as $item) {
if ($item->role === 'surveyor' && $item->user_id === null) {
$item->update([
'user_id' => $request->surveyor_id,
'role' => 'surveyor',
]);
}
if ($item->role === 'penilai' && $item->user_id === null) {
$item->update([
'user_id' => $request->penilai_id,
'role' => 'penilai',
]);
}
}
$permohonan = Permohonan::where('nomor_registrasi', $request->nomor_registrasi);
$permohonan->update([
'status' => 'assign',
]);
return redirect()->route('penilaian.index', $id)->with('success', 'Penilaian berhasil diubah');
DB::commit();
return redirect()->route('penilaian.index')->with('success', 'Penilaian berhasil disimpan');
} catch (Exception $e) {
return redirect()->route('penilaian.index', $id)->with('error', $e->getMessage());
}
DB::rollBack();
return response()->json(array('error' => $e->getMessage()));
}
}
@@ -87,8 +179,7 @@ class PenilaianController extends Controller
*/
public function assignment($id)
{
$permohonan = Permohonan::with(
[
$permohonan = Permohonan::with([
'user',
'debiture.province',
'debiture.city',
@@ -96,20 +187,28 @@ class PenilaianController extends Controller
'debiture.village',
'branch',
'tujuanPenilaian',
],
)->findOrFail($id);
])->findOrFail($id);
$idPenilaian = $permohonan->jenis_penilaian_id;
$idRegion = $permohonan->region_id;
$jenisPenilaian = JenisPenilaian::find($idPenilaian);
$teamPenilai = Teams::with(['regions', 'teamsUsers', 'teamsUsers.user'])
$userTeam = Teams::with(['regions', 'teamsUsers.user'])
->whereHas('regions', function ($q) use ($idRegion) {
$q->where('id', $idRegion);
})->get();
})
->get();
$teamPenilai = $userTeam->flatMap(function ($team) {
return $team->teamsUsers->filter(function ($teamUser) {
return $teamUser->user->roles->contains(function ($role) {
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai';
});
})->map(function ($teamUser) {
return $teamUser->user;
});
})->unique('id');
$existingTeamIds = $teamPenilai->pluck('id')->toArray();
@@ -117,19 +216,29 @@ class PenilaianController extends Controller
->whereNotIn('id', $existingTeamIds)
->get();
$regionName = null;
foreach ($teamPenilai as $item) {
foreach ($userTeam as $item) {
$regionName = $item->regions;
}
// $regionName = $userTeam->first()?->regions->name;
// dd($teamPenilai);
$penilaian = Penilaian::where('nomor_registrasi', $permohonan->nomor_registrasi)->first();
return view('lpj::penilaian.form', compact('permohonan', 'teamPenilai', 'jenisPenilaian', 'penilaian', 'regionName', 'updateTeamPenilai'));
$penilaianTeam = collect();
if ($penilaian && $penilaian->id) {
$penilaianTeam = PenilaianTeam::where('penilaian_id', $penilaian->id)->get();
}
// return response()->json([
// 'penilaianTeam' => $penilaianTeam
// ]);
return view('lpj::penilaian.form', compact('permohonan', 'teamPenilai', 'jenisPenilaian', 'penilaian', 'regionName', 'updateTeamPenilai', 'penilaianTeam'));
}
/**
* Remove the specified resource from storage.
*/
@@ -167,8 +276,9 @@ class PenilaianController extends Controller
public function dataForDatatables(Request $request)
{
if (is_null($this->user) || !$this->user->can('debitur.view')) {
// abort(403, 'Sorry! You are not allowed to view users.');
}
$query = Permohonan::query();
@@ -187,6 +297,9 @@ class PenilaianController extends Controller
}
$query->whereRaw('LOWER(status) = ?', ['registered']);
$query->whereHas('region.teams.teamsUsers.user', function ($q) {
$q->where('id', Auth::user()->id);
});
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
$order = $request->get('sortOrder');
@@ -209,7 +322,7 @@ class PenilaianController extends Controller
}
$filteredRecords = $query->count();
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'region.teams.teamsUsers.user'])->get();
$pageCount = ceil($totalRecords / $size);
@@ -312,7 +425,7 @@ class PenilaianController extends Controller
if (!empty($otorisator)) {
if ($status == 'proses') {
$query->whereIn('status_bayar', ['sudah_bayar', 'belum_bayar']);
}else{
} else {
$query->whereRaw('LOWER(status) = ?', [strtolower($status)]);
}
}

View File

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Response;
use Modules\Lpj\Models\Permohonan;
use Modules\Lpj\Models\Branch;
@@ -47,6 +48,7 @@ use Modules\Lpj\Http\Requests\FormSurveyorRequest;
class SurveyorController extends Controller
{
public $user;
/**
* Display a listing of the resource.
*/
@@ -118,6 +120,8 @@ class SurveyorController extends Controller
->where('permohonan_id', $id)
->get();
return view('lpj::surveyor.detail', compact(
'buttonDisable',
'fotojaminan',
@@ -513,6 +517,11 @@ class SurveyorController extends Controller
$query->whereRaw('LOWER(status) = ?', ['assign']);
$query->whereHas('region.teams.teamsUsers.user', function ($q) {
$q->where('id', Auth::user()->id);
});
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
$order = $request->get('sortOrder');
$column = $request->get('sortField');
@@ -614,7 +623,6 @@ class SurveyorController extends Controller
'golMasySekitar',
'tingkatKeramaian',
'laluLintasLokasi'
));
}
@@ -693,7 +701,7 @@ class SurveyorController extends Controller
$spekKategoriBagunan = SpekKategoritBangunan::all();
$header = $this->getHeader($type);
return view('lpj::surveyor.data.form', compact('header','spekKategoriBagunan'));
return view('lpj::surveyor.data.form', compact('header', 'spekKategoriBagunan'));
}
@@ -713,7 +721,7 @@ class SurveyorController extends Controller
->with('error', 'Invalid type specified.');
}
if($type == 'spek-bangunan') {
if ($type == 'spek-bangunan') {
$validate['spek_kategori_bagunan_id'] = $request->spek_kategori_bagunan_id;
}
@@ -764,7 +772,7 @@ class SurveyorController extends Controller
}
return view('lpj::surveyor.data.form', compact('header', 'model','spekKategoriBagunan'));
return view('lpj::surveyor.data.form', compact('header', 'model', 'spekKategoriBagunan'));
}
@@ -774,7 +782,7 @@ class SurveyorController extends Controller
if ($validate) {
$modelClass = $this->getModelClass($type);
if($type == 'spek-bangunan') {
if ($type == 'spek-bangunan') {
$validate['spek_kategori_bagunan_id'] = $request->spek_kategori_bagunan_id;
}
@@ -931,6 +939,8 @@ class SurveyorController extends Controller
public function submitSurveyor(Request $request, $id)
{
$permohonan = Permohonan::find($id);
$permohonan->update([
'status' => 'done',
@@ -942,6 +952,11 @@ class SurveyorController extends Controller
}
public function validateSubmit(){
}
private function getModelClass(string $type): ?string
{
return $this->modelClasses[$type] ?? null;

View File

@@ -43,7 +43,7 @@ class TeamsController extends Controller
$user = $usersWithRole->filter(function ($user) {
return $user->roles->contains(function ($role) {
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai';
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai' || $role->name === 'senior-officer';
});
});
@@ -112,7 +112,7 @@ class TeamsController extends Controller
$user = $usersWithRole->filter(function ($user) {
return $user->roles->contains(function ($role) {
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai';
return $role->name === 'surveyor' || $role->name === 'surveyor-penilai' || $role->name === 'senior-officer';
});
});

View File

@@ -33,9 +33,12 @@ class PenilaianRequest extends FormRequest
'tanggal_kunjungan' => 'required|max:255',
'status' => 'required|string',
'nomor_registrasi' => 'required|string',
'surveyor_id' => 'nullable|required_without:penilai_surveyor_id',
'penilaian_id' => 'nullable|required_without:penilai_surveyor_id',
'penilai_surveyor_id' => 'nullable|required_without_all:surveyor_id,penilaian_id',
'surveyor_id' => 'nullable| required_without:penilai_surveyor_id',
'penilai_id' => 'nullable|required_without:penilai_surveyor_id',
'penilai_surveyor_id' => 'nullable|required_without_all:surveyor_id,penilai_id',
'surveyor_region_id' => 'nullable|required_without:surveyor_id',
'penilai_region_id' => 'nullable|required_without:penilai_id',
'keterangan' => 'nullable',
];
}

View File

@@ -17,7 +17,7 @@ class Penilaian extends Model
*/
protected $table = 'penilaian';
protected $fillable = [
'jenis_penilaian_id', 'teams_id', 'tanggal_kunjungan', 'keterangan','nomor_registrasi','penilaian_id','surveyor_id','penilai_surveyor_id',
'jenis_penilaian_id', 'tanggal_kunjungan', 'keterangan','nomor_registrasi',
'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_at',
'created_by', 'updated_at', 'updated_by', 'deleted_at', 'deleted_by'
];
@@ -39,18 +39,9 @@ class Penilaian extends Model
public function userPenilai()
{
return $this->belongsTo(User::class, 'penilaian_id', 'id');
return $this->hasMany(PenilaianTeam::class, 'penilaian_id', 'id');
}
public function userSurveyor()
{
return $this->belongsTo(User::class, 'surveyor_id', 'id');
}
public function userPenilaiSurveyor()
{
return $this->belongsTo(User::class, 'penilai_surveyor_id', 'id');
}
public function permohonan()
{

View File

@@ -0,0 +1,39 @@
<?php
namespace Modules\Lpj\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Lpj\Database\Factories\PenilaianTeamFactory;
class PenilaianTeam extends Model
{
use HasFactory;
protected $table = 'penilaian_team';
/**
* The attributes that are mass assignable.
*/
protected $fillable = ['penilaian_id', 'team_id', 'user_id','role'];
public function userPenilaiTeam()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
public function team(){
return $this->belongsTo(Team::class, 'team_id', 'id');
}
public function penilaian(){
return $this->belongsTo(Penilaian::class, 'penilaian_id', 'id');
}
protected static function newFactory(): PenilaianTeamFactory
{
//return PenilaianTeamFactory::new();
}
}

View File

@@ -83,4 +83,9 @@ class Permohonan extends Base
{
return $this->belongsTo(Penilaian::class, 'nomor_registrasi', 'nomor_registrasi');
}
public function region()
{
return $this->belongsTo(Regions::class, 'region_id');
}
}

View File

@@ -30,8 +30,8 @@ class Teams extends Model
return $this->hasMany(TeamsUsers::class, 'teams_id', 'id');
}
public function penilaian(){
return $this->hasMany(Penilaian::class, 'teams_id', 'id');
public function penilaianTeam(){
return $this->hasMany(penilaianTeam::class, 'team_id', 'id');
}

View File

@@ -0,0 +1,37 @@
<?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('kategori_jenis_aset', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code');
$table->boolean('status')->default(true);
$table->char('authorized_status', 1)->nullable();
$table->timestamps();
$table->timestamp('authorized_at')->nullable();
$table->unsignedBigInteger('authorized_by')->nullable();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('kategori_jenis_aset');
}
};

View File

@@ -0,0 +1,38 @@
<?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::table('penilaian', function (Blueprint $table) {
$table->dropColumn('teams_id');
$table->dropColumn('surveyor_id');
$table->dropColumn('penilaian_id');
$table->dropColumn('penilai_surveyor_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penilaian', function (Blueprint $table) {
$table->foreignIdFor(Teams::class);
$table->foreignIdFor(User::class);
});
}
};

View File

@@ -0,0 +1,38 @@
<?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('penilaian_team', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('penilaian_id');
$table->unsignedBigInteger('team_id');
$table->unsignedBigInteger('user_id');
$table->string('role');
$table->boolean('status')->default(true);
$table->char('authorized_status', 1)->nullable();
$table->timestamps();
$table->timestamp('authorized_at')->nullable();
$table->unsignedBigInteger('authorized_by')->nullable();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('penilai_team');
}
};

View File

@@ -0,0 +1,38 @@
<?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('kategori_form_analisa_inspeksi', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code');
$table->foreign('kategori_jenis_aset_id')->references('id')->on('kategori_jenis_aset');
$table->boolean('status')->default(true);
$table->char('authorized_status', 1)->nullable();
$table->timestamps();
$table->timestamp('authorized_at')->nullable();
$table->unsignedBigInteger('authorized_by')->nullable();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('kategori_form_analisa_inspeksi');
}
};

View File

@@ -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('label_name_inspeksi', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('label_name_inspeksi');
}
};

View File

@@ -46,14 +46,14 @@
@php
$sortedTeamsActivity = $teamsActivity->sortBy(function ($item) {
return $item->team->penilaian
->filter(function ($penilaian) use ($item) {
return $penilaian->penilaian_id == $item->user->id ||
$penilaian->surveyor_id == $item->user->id ||
$penilaian->penilai_surveyor_id == $item->user->id;
return $item->team->penilaianTeam
->filter(function ($penilaianTeam) use ($item) {
return $penilaianTeam->user_id == $item->user->id;
})
->count();
});
@endphp
@foreach ($sortedTeamsActivity as $index => $item)
@@ -70,11 +70,9 @@
<th class="min-w-[150px]">
<span class="text-base text-gray-900 font-normal">
@php
$totalTasks = $item->team->penilaian
->filter(function ($penilaian) use ($item) {
return $penilaian->penilaian_id == $item->user->id ||
$penilaian->surveyor_id == $item->user->id ||
$penilaian->penilai_surveyor_id == $item->user->id;
$totalTasks = $item->team->penilaianTeam
->filter(function ($penilaianTeam) use ($item) {
return $penilaianTeam->user_id == $item->user->id;
})
->count();
@endphp
@@ -156,8 +154,6 @@
const apiUrl = accordion.querySelector('.card-grid').getAttribute(
'data-api-url');
console.log("This is the API URL: " + apiUrl);
const dataTableOptions = {
apiEndpoint: apiUrl,
pageSize: 5,

View File

@@ -308,8 +308,12 @@
</div>
</div>
{{-- @php
var_dump($penilaianTeam);
@endphp --}}
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<div
class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 {{ $penilaianTeam->isEmpty() ? '' : 'hidden' }}">
<label class="form-label max-w-56">
Pilih Surveyor dan Penilai
</label>
@@ -328,6 +332,7 @@
@enderror
</div>
</div>
<div id="same_surveyor_penilai" class="hidden">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
@@ -338,8 +343,8 @@
<select id="penilai_surveyor_id" name="penilai_surveyor_id"
class="input tomselect @error('penilai_surveyor_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Surveyor dan Penilai</option>
@foreach ($teamPenilai->first()->teamsUsers as $item)
<option value="{{ $item->user->id }}">{{ $item->user->name }}</option>
@foreach ($teamPenilai as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
</select>
</div>
@@ -351,8 +356,13 @@
</div>
<div id="different_surveyor_penilai" class="hidden">
<div id="different_surveyor_penilai" class="{{ $penilaianTeam->isNotEmpty() ? '' : 'hidden' }}">
<div class="grid gap-2.5">
@if (
$penilaianTeam->isNotEmpty() &&
$penilaianTeam->contains(fn($item) => $item->role == 'surveyor' && is_null($item->user_id))
)
<div id="surveyorId" class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Surveyor yang di tunjuk
@@ -362,11 +372,14 @@
<select id="surveyor_id" name="surveyor_id"
class="tomselect input @error('surveyor_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Surveyor</option>
@foreach ($teamPenilai->first()->teamsUsers as $item)
<option value="{{ $item->user->id }}">{{ $item->user->name }}</option>
@foreach ($teamPenilai as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
<option value="pilih_dari_region">pilih dari region berdeda</option>
@if ($penilaianTeam->isEmpty())
<option value="pilih_dari_region">pilih dari region berdeda
</option>
@endif
</select>
</div>
@error('surveyor_id')
@@ -374,6 +387,32 @@
@enderror
</div>
</div>
@elseif($penilaianTeam->isEmpty())
<div id="surveyorId" class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Surveyor yang di tunjuk
</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="input-group w-full">
<select id="surveyor_id" name="surveyor_id"
class="tomselect input @error('surveyor_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Surveyor</option>
@foreach ($teamPenilai as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
@if ($penilaianTeam->isEmpty())
<option value="pilih_dari_region">pilih dari region berdeda
</option>
@endif
</select>
</div>
@error('surveyor_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
@endif
<div id="surveyorRegion" class="hidden items-baseline flex-wrap lg:flex-nowrap gap-2.5">
@@ -382,63 +421,97 @@
</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="input-group w-full">
<select id="surveyor_id" name="surveyor_id"
class="tomselect input @error('surveyor_id') border-danger bg-danger-light @enderror w-full">
<select id="surveyor_region_id" name="surveyor_region_id"
class="tomselect input @error('surveyor_region_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Region</option>
@if (isset($updateTeamPenilai))
@foreach ($updateTeamPenilai as $item)
<option value="{{ $item->regions->id }}">{{ $item->regions->name }}</option>
<option value="{{ $item->regions->id }}">
{{ $item->regions->name }}</option>
@endforeach
@endif
</select>
</div>
@error('surveyor_id')
@error('surveyor_region_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
@if (
$penilaianTeam->isNotEmpty() &&
$penilaianTeam->contains(fn($item) => $item->role == 'penilai' && is_null($item->user_id))
)
<div id="penilaiId" class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Penilai yang di tunjuk
</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="input-group w-full">
<select id="penilaian_id" name="penilaian_id"
class="input tomselect @error('penilaian_id') border-danger bg-danger-light @enderror w-full">
<select id="penilai_id" name="penilai_id"
class="input tomselect @error('penilai_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Penilai</option>
@foreach ($teamPenilai->first()->teamsUsers as $item)
<option value="{{ $item->user->id }}">{{ $item->user->name }}</option>
@foreach ($teamPenilai as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
<option value="pilih_dari_region">pilih dari region berdeda</option>
@if ($penilaianTeam->isEmpty())
<option value="pilih_dari_region">pilih dari region berdeda
</option>
@endif
</select>
</div>
@error('penilaian_id')
@error('penilai_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
@elseif($penilaianTeam->isEmpty())
<div id="penilaiId" class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Penilai yang di tunjuk
</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="input-group w-full">
<select id="penilai_id" name="penilai_id"
class="input tomselect @error('penilai_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Penilai</option>
@foreach ($teamPenilai as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
@if ($penilaianTeam->isEmpty())
<option value="pilih_dari_region">pilih dari region berdeda
</option>
@endif
</select>
</div>
@error('penilai_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
</div>
@endif
<div id="penilaiRegion" class="hidden items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
Pilih Region
</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="input-group w-full">
<select id="surveyor_id" name="surveyor_id"
class="tomselect input @error('surveyor_id') border-danger bg-danger-light @enderror w-full">
<select id="penilai_region_id" name="penilai_region_id"
class="tomselect input @error('penilai_region_id') border-danger bg-danger-light @enderror w-full">
<option value="">Pilih Region</option>
@if (isset($updateTeamPenilai))
@foreach ($updateTeamPenilai as $item)
<option value="{{ $item->regions->id }}">{{ $item->regions->name }}</option>
<option value="{{ $item->regions->id }}">
{{ $item->regions->name }}</option>
@endforeach
@endif
</select>
</div>
@error('surveyor_id')
@error('penilai_region_id')
<em class="alert text-danger text-sm">{{ $message }}</em>
@enderror
</div>
@@ -572,7 +645,7 @@
if (selectedValue === 'pilih_dari_region') {
surveyorRegion.classList.remove('hidden');
surveyorRegion.classList.add('flex');
}else{
} else {
surveyorRegion.classList.add('hidden');
}
});
@@ -584,7 +657,7 @@
if (selectedValue === 'pilih_dari_region') {
penilaiRegion.classList.remove('hidden');
penilaiRegion.classList.add('flex');
}else{
} else {
penilaiRegion.classList.add('hidden');
}
});

View File

@@ -668,8 +668,10 @@
</label>
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute[]" value="rute">
<input id="inputRute" type="file" name="foto_rute" class="file-input file-input-bordered w-full" accept="image/*">
<button id="mod" type="button" class="btn btn-light" onclick="openModal('gistaru')">
<input id="inputRute" type="file" name="foto_rute"
class="file-input file-input-bordered w-full" accept="image/*">
<button id="gistaru" type="button" class="btn btn-light"
onclick="openModal('gistaru')">
<i class="ki-outline ki-abstract-33"></i> Gistaru
</button>
</div>
@@ -679,9 +681,11 @@
<span class="form-label">Bumi</span>
</label>
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute[]" value="rute">
<input id="inputRute" type="file" name="foto_rute" class="file-input file-input-bordered w-full" accept="image/*" capture="camera">
<button id="mod" type="button" class="btn btn-light" onclick="openModal('bumi')">
<input class="name_rute" type="hidden" name="name_rute" value="rute">
<input id="inputRute" type="file" name="foto_rute"
class="file-input file-input-bordered w-full" accept="image/*" capture="camera">
<button id="bumi" type="button" class="btn btn-light"
onclick="openModal('bumi')">
<i class="ki-outline ki-abstract-33"></i> Bumi
</button>
</div>
@@ -759,7 +763,7 @@
</button>
</div>
<div class="modal-body" id="screenshotContainer" style="height: 500px">
<iframe id="mapFrameGis" frameborder="0" style="width: 100%; height: 100%;"></iframe>
<iframe id="mapFrameGis" style="width: 100%; height: 100%;"></iframe>
</div>
<div class="modal-footer flex justify-end">
<button id="takeScreenshot" class="btn btn-success">Take Screenshot</button>
@@ -770,7 +774,7 @@
@endsection
@push('scripts')
<script>
<script>
function getMap(params) {
const iframe = document.getElementById('mapFrameGis');
const maps = [
@@ -782,11 +786,17 @@
}
function openModal(type) {
const modal = document.getElementById('mod');
modal.setAttribute('data-modal-toggle', '#modal');
const modalGistaru = document.getElementById('gistaru');
const modalBumi = document.getElementById('bumi');
if (type === 'bumi') {
modalBumi.setAttribute('data-modal-toggle', '#modal');
}else if (type === 'gistaru') {
modalGistaru.setAttribute('data-modal-toggle', '#modal');
}
getMap(type === 'gistaru' ? 0 : 1);
}
}
document.getElementById('takeScreenshot').addEventListener('click', () => {
const screenshotContainer = document.getElementById('screenshotContainer');
@@ -808,9 +818,9 @@
// Isi input dengan data URL gambar
inputRute.value = dataURL;
});
</script>
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<script>
// Fungsi untuk mengambil lokasi pengguna
function getUserLocation() {

View File

@@ -196,7 +196,7 @@
@if (request()->has('form') && request('form') !== 'data-pembanding')
<div class="card-footer">
<form action="{{ route('surveyor.submitSurveyor', $surveyor) }}" method="POST">
<form action="{{ route('surveyor.submitSurveyor', $surveyor ) }}" method="POST">
@csrf
@method('PUT')
<button type="submit" class="btn btn-primary " {{ $buttonDisable ? 'disabled' : '' }}>

View File

@@ -202,10 +202,10 @@
},
tanggal_permohonan: {
title: 'Tanggal Assigned',
render: (item, data) => {
const createdAt = convertDate(data.penilaian.created_at);
return createdAt;
},
// render: (item, data) => {
// const createdAt = convertDate(data.penilaian.created_at);
// return createdAt;
// },
},
user_id: {
@@ -250,10 +250,10 @@
dataTable.search(searchValue, true);
});
statusFilter.addEventListener('change', function() {
const selectedStatus = this.value;
dataTable.search(selectedStatus);
});
// statusFilter.addEventListener('change', function() {
// const selectedStatus = this.value;
// dataTable.search(selectedStatus);
// });
function convertDate(date) {
const createdAt = new Date(date);