sementara
This commit is contained in:
32
app/Http/Controllers/# Run on VM.sh
Normal file
32
app/Http/Controllers/# Run on VM.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
# Run on VM
|
||||
rclone hashsum MD5 "gdrive:01_Data Mentah/itdel/bawang_putih/BPM1" --drive-shared-with-me --output-file itdel_bawang_putih_gdrive.txt
|
||||
rclone hashsum MD5 "gcs:transit_bucket_ysds/itdel/BPM1" --output-file itdel_bawang_putih_gcs.txt
|
||||
rclone check --checksum "gcs:transit_bucket_ysds/itdel/BPM1" "gdrive:01_Data Mentah/itdel/bawang_putih/BPM1" --drive-shared-with-me --combined="itdel_bawang_putih_cheksum_bucket_drive.txt" --log-file="itdel_bawang_putih_count_checksum_bucket_drive.txt"
|
||||
# Run on Local Machine
|
||||
rclone hashsum MD5 "/data/storageserver/0.RAW/WGS/revio call/Raw/itdel/bawang_putih/BPM1" --output-file itdel_bawang_putih_local.txt
|
||||
rclone check --checksum "/data/storageserver/0.RAW/WGS/revio call/Raw/itdel/bawang_putih/BPM1" "gdrive:01_Data Mentah/itdel/bawang_putih/BPM1" --drive-shared-with-me --combined="itdel_bawang_putih_checksum_local_gdrive.txt" --log-file="itdel_bawang_putih_count_checksum_local_gdrive.txt"
|
||||
|
||||
# Run on VM
|
||||
rclone hashsum MD5 "gdrive:01_Data Mentah/itdel/kemenyan" --drive-shared-with-me --output-file itdel_kemenyan_gdrive.txt
|
||||
rclone hashsum MD5 "gcs:transit_bucket_ysds/itdel/kemenyan" --output-file itdel_kemenyan_gcs.txt
|
||||
rclone check --checksum "gcs:transit_bucket_ysds/itdel/kemenyan" "gdrive:01_Data Mentah/itdel/kemenyan" --drive-shared-with-me --combined="itdel_kemenyan_checksum_bucket_drive.txt" --log-file="itdel_kemenyan_count_checksum_bucket_drive.txt"
|
||||
# Run on Local Machine
|
||||
rclone hashsum MD5 "/data/storageserver/0.RAW/WGS/revio call/Raw/itdel/kemenyan" --output-file itdel_kemenyan_local.txt
|
||||
rclone check --checksum "/data/storageserver/0.RAW/WGS/revio call/Raw/itdel/kemenyan" "gdrive:01_Data Mentah/itdel/kemenyan" --drive-shared-with-me --combined="itdel_kemenyan_checksum_local_gdrive.txt" --log-file="itdel_kemenyan_count_checksum_local_gdrive.txt"
|
||||
|
||||
# Run on VM
|
||||
rclone hashsum MD5 "gdrive:01_Data Mentah/ugm/prima/bawang_putih" --drive-shared-with-me --output-file ugm_prima_bawang_putih_gdrive.txt
|
||||
rclone hashsum MD5 "gcs:transit_bucket_ysds/bawang_putih_prima_UGM" --output-file ugm_prima_bawang_putih_gcs.txt
|
||||
rclone check --checksum "gcs:transit_bucket_ysds/bawang_putih_prima_UGM" "gdrive:01_Data Mentah/ugm/prima/bawang_putih" --drive-shared-with-me --combined="ugm_prima_bawang_putih_checksum_bucket_drive.txt" --log-file="ugm_prima_bawang_putih_count_checksum_bucket_drive.txt"
|
||||
# Run on Local Machine
|
||||
rclone hashsum MD5 "/data/storageserver/0.RAW/WGS/revio call/Raw/bawang_putih" --output-file ugm_prima_bawang_putih_local.txt
|
||||
rclone check --checksum "/data/storageserver/0.RAW/WGS/revio call/Raw/bawang_putih" "gdrive:01_Data Mentah/ugm/prima/bawang_putih" --drive-shared-with-me --combined="ugm_prima_bawang_putih_checksum_local_gdrive.txt" --log-file="ugm_prima_bawang_putih_count_checksum_local_gdrive.txt"
|
||||
|
||||
|
||||
# Run on VM
|
||||
rclone hashsum MD5 "gdrive:01_Data Mentah/polije/netty/bawang_merah" --drive-shared-with-me --output-file polije_netty_bawang_merah_gdrive.txt
|
||||
rclone hashsum MD5 "gcs:transit_bucket_ysds/bawang_merah_netty_polije" --output-file polije_netty_bawang_merah_gcs.txt
|
||||
rclone check --checksum "gcs:transit_bucket_ysds/bawang_merah_netty_polije" "gdrive:01_Data Mentah/polije/netty/bawang_merah" --drive-shared-with-me --combined="polije_netty_bawang_merah_checksum_bucket_drive.txt" --log-file="polije_netty_bawang_merah_count_checksum_bucket_drive.txt"
|
||||
# Run on Local Machine
|
||||
rclone hashsum MD5 "/data/storageserver/0.RAW/WGS/revio call/Raw/bawang_merah" --output-file polije_netty_bawang_merah_local.txt
|
||||
rclone check --checksum "/data/storageserver/0.RAW/WGS/revio call/Raw/bawang_merah" "gdrive:01_Data Mentah/polije/netty/bawang_merah" --drive-shared-with-me --combined="polije_netty_bawang_merah_checksum_local_gdrive.txt" --log-file="polije_netty_bawang_merah_count_checksum_local_gdrive.txt"
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Log;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Lpj\Http\Requests\BankDataRequest;
|
||||
use Modules\Lpj\Models\BankData;
|
||||
@@ -88,7 +88,8 @@
|
||||
}
|
||||
} else {
|
||||
// Invalid coordinates
|
||||
Log::warning("Invalid coordinates: Lat: $_lat, Lng: $_lng");// Do something to handle this situation, such as logging an error or skipping the record
|
||||
Log::warning("Invalid coordinates: Lat: $_lat, Lng: $_lng");
|
||||
// Do something to handle this situation, such as logging an error or skipping the record
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +139,8 @@
|
||||
}
|
||||
} else {
|
||||
// Invalid coordinates
|
||||
Log::warning("Invalid coordinates: Lat: $lat, Lng: $lng");// Do something to handle this situation, such as logging an error or skipping the record
|
||||
Log::warning("Invalid coordinates: Lat: $lat, Lng: $lng");
|
||||
// Do something to handle this situation, such as logging an error or skipping the record
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,6 +199,24 @@
|
||||
// Retrieve data from the database
|
||||
$query = BankData::query();
|
||||
|
||||
// Check if show_all parameter is set
|
||||
$showAll = $request->has('show_all') && $request->get('show_all') === 'true';
|
||||
|
||||
// If show_all is true, we'll get all data without pagination
|
||||
if ($showAll) {
|
||||
// Get all records without pagination
|
||||
$data = $query->get();
|
||||
|
||||
return response()->json([
|
||||
'data' => $data,
|
||||
'recordsTotal' => $data->count(),
|
||||
'recordsFiltered' => $data->count(),
|
||||
'page' => 1,
|
||||
'pageSize' => $data->count(),
|
||||
'total' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
@@ -252,8 +272,10 @@
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
// Apply pagination only if explicitly requested or not first load
|
||||
$shouldPaginate = $request->has('page') && $request->has('size') && !$request->has('show_all');
|
||||
|
||||
if ($shouldPaginate) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
@@ -287,11 +309,11 @@
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
// Calculate the page count (1 if showing all data)
|
||||
$pageCount = $shouldPaginate ? ceil($totalRecords / $request->get('size')) : 1;
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page', 1);
|
||||
$currentPage = $shouldPaginate ? $request->get('page', 1) : 1;
|
||||
|
||||
// Ensure current page doesn't exceed page count
|
||||
$currentPage = min($currentPage, $pageCount);
|
||||
|
||||
441
app/Http/Controllers/ReferensiLinkController.php
Normal file
441
app/Http/Controllers/ReferensiLinkController.php
Normal file
@@ -0,0 +1,441 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\ReferensiLink;
|
||||
use Modules\Lpj\Http\Requests\ReferensiLinkRequest;
|
||||
use Modules\Lpj\Exports\ReferensiLinkExport;
|
||||
use Modules\Lpj\Imports\ReferensiLinkImport;
|
||||
|
||||
class ReferensiLinkController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = auth()->user();
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//$this->authorize('referensi-link.view', $this->user);
|
||||
|
||||
$data = [
|
||||
'title' => 'Referensi Link',
|
||||
'subtitle' => 'Daftar Referensi Link',
|
||||
'breadcrumb' => [
|
||||
['url' => route('dashboard'), 'text' => 'Dashboard'],
|
||||
['text' => 'Referensi Link']
|
||||
],
|
||||
'kategoriOptions' => $this->getKategoriOptions(),
|
||||
];
|
||||
|
||||
return view('lpj::referensi_link.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//$this->authorize('referensi-link.create', $this->user);
|
||||
|
||||
$data = [
|
||||
'title' => 'Tambah Referensi Link',
|
||||
'subtitle' => 'Form Tambah Referensi Link Baru',
|
||||
'breadcrumb' => [
|
||||
['url' => route('dashboard'), 'text' => 'Dashboard'],
|
||||
['url' => route('basicdata.referensi-link.index'), 'text' => 'Referensi Link'],
|
||||
['text' => 'Tambah']
|
||||
],
|
||||
'kategoriOptions' => $this->getKategoriOptions(),
|
||||
];
|
||||
|
||||
return view('lpj::referensi_link.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(ReferensiLinkRequest $request)
|
||||
{
|
||||
//$this->authorize('referensi-link.create', $this->user);
|
||||
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
|
||||
// Set urutan otomatis jika belum diisi
|
||||
if (empty($validated['urutan'])) {
|
||||
$validated['urutan'] = ReferensiLink::max('urutan') + 1;
|
||||
}
|
||||
|
||||
$referensiLink = ReferensiLink::create($validated);
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.referensi-link.index')
|
||||
->with('success', 'Referensi Link berhasil ditambahkan');
|
||||
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('error', 'Gagal menambahkan Referensi Link: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//$this->authorize('referensi-link.update', $this->user);
|
||||
|
||||
$referensiLink = ReferensiLink::findOrFail($id);
|
||||
|
||||
$data = [
|
||||
'title' => 'Edit Referensi Link',
|
||||
'subtitle' => 'Form Edit Referensi Link',
|
||||
'breadcrumb' => [
|
||||
['url' => route('dashboard'), 'text' => 'Dashboard'],
|
||||
['url' => route('basicdata.referensi-link.index'), 'text' => 'Referensi Link'],
|
||||
['text' => 'Edit']
|
||||
],
|
||||
'referensiLink' => $referensiLink,
|
||||
'kategoriOptions' => $this->getKategoriOptions(),
|
||||
];
|
||||
|
||||
return view('lpj::referensi_link.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(ReferensiLinkRequest $request, $id)
|
||||
{
|
||||
//$this->authorize('referensi-link.update', $this->user);
|
||||
|
||||
try {
|
||||
$referensiLink = ReferensiLink::findOrFail($id);
|
||||
$validated = $request->validated();
|
||||
|
||||
$referensiLink->update($validated);
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.referensi-link.index')
|
||||
->with('success', 'Referensi Link berhasil diperbarui');
|
||||
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('error', 'Gagal memperbarui Referensi Link: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//$this->authorize('referensi-link.delete', $this->user);
|
||||
|
||||
try {
|
||||
$referensiLink = ReferensiLink::findOrFail($id);
|
||||
$referensiLink->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Referensi Link berhasil dihapus'
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal menghapus Referensi Link: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Datatable API for KTDataTable
|
||||
*/
|
||||
public function dataTable(Request $request)
|
||||
{
|
||||
//$this->authorize('referensi-link.view', $this->user);
|
||||
|
||||
$query = ReferensiLink::with(['createdBy', 'updatedBy'])
|
||||
->select('referensi_link.*');
|
||||
|
||||
// Search
|
||||
$search = $request->input('search');
|
||||
if (!empty($search)) {
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('name', 'LIKE', "%{$search}%")
|
||||
->orWhere('link', 'LIKE', "%{$search}%")
|
||||
->orWhere('kategori', 'LIKE', "%{$search}%");
|
||||
});
|
||||
}
|
||||
|
||||
// Optional filters (support multiple request shapes)
|
||||
$filters = $request->input('filters', []);
|
||||
$kategori = $request->input('kategori', $filters['kategori'] ?? null);
|
||||
if (!empty($kategori)) {
|
||||
if (is_array($kategori)) {
|
||||
$query->whereIn('kategori', $kategori);
|
||||
} else {
|
||||
$values = preg_split('/[,|]/', (string) $kategori, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (count($values) > 1) {
|
||||
$query->whereIn('kategori', $values);
|
||||
} else {
|
||||
$query->where('kategori', $kategori);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$statusRaw = $request->input('status', $filters['status'] ?? $request->input('is_active'));
|
||||
$statusParsed = $this->parseActiveFilter($statusRaw);
|
||||
if ($statusParsed !== null) {
|
||||
$query->where('is_active', $statusParsed);
|
||||
}
|
||||
|
||||
// Sorting
|
||||
$allowedSortFields = ['id', 'name', 'link', 'kategori', 'urutan', 'is_active', 'created_at', 'updated_at'];
|
||||
$sortField = in_array($request->input('sortField', 'urutan'), $allowedSortFields, true)
|
||||
? $request->input('sortField', 'urutan')
|
||||
: 'urutan';
|
||||
$sortOrder = strtolower($request->input('sortOrder', 'asc'));
|
||||
if (in_array($sortOrder, ['asc', 'desc'], true)) {
|
||||
$query->orderBy($sortField, $sortOrder);
|
||||
}
|
||||
|
||||
// Pagination
|
||||
$page = max((int) $request->input('page', 1), 1);
|
||||
$size = max((int) $request->input('size', 10), 1);
|
||||
$totalRecords = (clone $query)->count();
|
||||
$offset = ($page - 1) * $size;
|
||||
$items = $query->skip($offset)->take($size)->get();
|
||||
|
||||
// Map data rows
|
||||
$data = $items->map(function ($row) {
|
||||
return [
|
||||
'id' => $row->id,
|
||||
'name' => $row->name,
|
||||
'link' => '<a href="' . $row->link . '" target="_blank" class="text-primary">' . Str::limit($row->link, 50) . ' <i class="fas fa-external-link-alt"></i></a>',
|
||||
'kategori' => $row->kategori,
|
||||
'status_badge' => $row->status_badge,
|
||||
'urutan' => $row->urutan,
|
||||
'actions' => (
|
||||
(auth()->user()->can('referensi-link.update') ? '<a class="dropdown-item" href="' . route('basicdata.referensi-link.edit', $row->id) . '"><i class="fas fa-edit"></i> Edit</a>' : '') .
|
||||
(auth()->user()->can('referensi-link.delete') ? '<a class="dropdown-item text-danger" href="javascript:void(0)" onclick="deleteData(' . $row->id . ')"><i class="fas fa-trash"></i> Hapus</a>' : '')
|
||||
),
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'draw' => (int) $request->input('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $totalRecords,
|
||||
'pageCount' => (int) ceil($totalRecords / $size),
|
||||
'page' => $page,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export data to Excel
|
||||
*/
|
||||
public function export(Request $request)
|
||||
{
|
||||
//$this->authorize('referensi-link.export', $this->user);
|
||||
|
||||
try {
|
||||
$filename = 'referensi_link_' . date('YmdHis') . '.xlsx';
|
||||
|
||||
return Excel::download(new ReferensiLinkExport($request->all()), $filename);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', 'Gagal export data: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show import form
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
//$this->authorize('referensi-link.import', $this->user);
|
||||
|
||||
$data = [
|
||||
'title' => 'Import Referensi Link',
|
||||
'subtitle' => 'Import data Referensi Link dari Excel',
|
||||
'breadcrumb' => [
|
||||
['url' => route('dashboard'), 'text' => 'Dashboard'],
|
||||
['url' => route('basicdata.referensi-link.index'), 'text' => 'Referensi Link'],
|
||||
['text' => 'Import']
|
||||
],
|
||||
];
|
||||
|
||||
return view('lpj::referensi_link.import', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process import
|
||||
*/
|
||||
public function importProcess(Request $request)
|
||||
{
|
||||
//$this->authorize('referensi-link.import', $this->user);
|
||||
|
||||
$request->validate([
|
||||
'file' => 'required|mimes:xlsx,xls|max:10240', // max 10MB
|
||||
]);
|
||||
|
||||
try {
|
||||
$import = new ReferensiLinkImport();
|
||||
Excel::import($import, $request->file('file'));
|
||||
|
||||
$stats = $import->getImportStats();
|
||||
|
||||
$message = "Import berhasil! {$stats['success']} data berhasil diimport";
|
||||
if ($stats['failed'] > 0) {
|
||||
$message .= ", {$stats['failed']} data gagal diimport";
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('basicdata.referensi-link.index')
|
||||
->with('success', $message);
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error('ReferensiLink import error: ' . $e->getMessage());
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', 'Gagal import data: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle status (active/inactive)
|
||||
*/
|
||||
public function toggleStatus($id)
|
||||
{
|
||||
//$this->authorize('referensi-link.update', $this->user);
|
||||
|
||||
try {
|
||||
$referensiLink = ReferensiLink::findOrFail($id);
|
||||
$referensiLink->is_active = !$referensiLink->is_active;
|
||||
$referensiLink->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Status berhasil diubah',
|
||||
'status' => $referensiLink->is_active
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengubah status: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get kategori options for dropdown
|
||||
*/
|
||||
private function getKategoriOptions()
|
||||
{
|
||||
return [
|
||||
'regulasi' => 'Regulasi',
|
||||
'panduan' => 'Panduan',
|
||||
'prosedur' => 'Prosedur',
|
||||
'formulir' => 'Formulir',
|
||||
'laporan' => 'Laporan',
|
||||
'lainnya' => 'Lainnya'
|
||||
];
|
||||
}
|
||||
|
||||
private function parseActiveFilter($value): ?bool
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$val = strtolower(trim((string) $value));
|
||||
|
||||
if (in_array($val, ['1', 'true', 'aktif', 'active', 'yes', 'y'], true)) {
|
||||
return true;
|
||||
}
|
||||
if (in_array($val, ['0', 'false', 'tidak', 'inactive', 'nonaktif', 'no', 'n'], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download import template
|
||||
*/
|
||||
public function downloadTemplate()
|
||||
{
|
||||
//$this->authorize('referensi-link.import', $this->user);
|
||||
|
||||
try {
|
||||
$headers = [
|
||||
'Nama',
|
||||
'Link',
|
||||
'Kategori',
|
||||
'Deskripsi',
|
||||
'Status Aktif',
|
||||
'Urutan'
|
||||
];
|
||||
|
||||
$filename = 'template_referensi_link_' . date('YmdHis') . '.xlsx';
|
||||
|
||||
return Excel::download(new class($headers) implements \Maatwebsite\Excel\Concerns\FromArray, \Maatwebsite\Excel\Concerns\WithHeadings {
|
||||
private $headers;
|
||||
|
||||
public function __construct($headers)
|
||||
{
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return [
|
||||
['Contoh Referensi', 'https://example.com', 'panduan', 'Deskripsi contoh referensi link', 'aktif', 1],
|
||||
['Contoh Regulasi', 'https://regulasi.example.com', 'regulasi', 'Deskripsi regulasi', 'aktif', 2],
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
}, $filename);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', 'Gagal download template: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -883,11 +883,10 @@ class SurveyorController extends Controller
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
|
||||
$permohonan = Permohonan::where('nomor_registrasi', $penilaian->nomor_registrasi)->first();
|
||||
;
|
||||
if (Carbon::parse($validate['waktu_penilaian']) <= Carbon::parse($penilaian->tanggal_kunjungan)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Waktu penilaian harus lebih besar dari tanggal assign.'
|
||||
'message' => 'Waktu penilaian harus lebih besar dari tanggal assign.'.$penilaian->tanggal_kunjungan.' '.$validate['waktu_penilaian']
|
||||
], 422);
|
||||
}
|
||||
|
||||
@@ -2924,29 +2923,29 @@ class SurveyorController extends Controller
|
||||
|
||||
// Jika ada data tanpa dokument_id, cek apakah ada data dengan dokument_id yang sama
|
||||
if ($dataWithoutDokument->isNotEmpty() && $dataWithDokument->isNotEmpty()) {
|
||||
|
||||
|
||||
// Group data dengan dokument_id by created_by
|
||||
$groupedDataWithDokument = $dataWithDokument->groupBy('created_by');
|
||||
|
||||
|
||||
// Group data tanpa dokument_id by created_by
|
||||
$groupedDataWithoutDokument = $dataWithoutDokument->groupBy('created_by');
|
||||
|
||||
// Proses cleanup untuk setiap user
|
||||
foreach ($groupedDataWithDokument as $userId => $userDataWithDokument) {
|
||||
|
||||
|
||||
// Cek apakah user ini juga memiliki data tanpa dokument_id
|
||||
if (isset($groupedDataWithoutDokument[$userId])) {
|
||||
|
||||
|
||||
// Ambil salah satu data dengan dokument_id sebagai referensi untuk logging
|
||||
$referenceData = $userDataWithDokument->first();
|
||||
|
||||
|
||||
Log::info('SurveyorController: Menemukan data lengkap untuk user, akan menghapus data tidak lengkap', [
|
||||
'user_id' => $userId,
|
||||
'permohonan_id' => $permohonanId,
|
||||
'reference_dokument_id' => $referenceData->dokument_id,
|
||||
'data_count_to_delete' => $groupedDataWithoutDokument[$userId]->count()
|
||||
]);
|
||||
|
||||
|
||||
// Ambil semua data tanpa dokument_id untuk user ini
|
||||
$userDataWithoutDokument = $groupedDataWithoutDokument[$userId];
|
||||
|
||||
@@ -2956,7 +2955,7 @@ class SurveyorController extends Controller
|
||||
try {
|
||||
// Soft delete data
|
||||
$dataToDelete->delete();
|
||||
|
||||
|
||||
Log::info('SurveyorController: Data inspeksi berhasil di-soft delete', [
|
||||
'id' => $dataToDelete->id,
|
||||
'permohonan_id' => $dataToDelete->permohonan_id,
|
||||
|
||||
Reference in New Issue
Block a user