fix relation, fix migration, fix all route use token, fix service sync simbg, fix detail pbg
This commit is contained in:
@@ -28,7 +28,7 @@ class DashboardController extends Controller
|
||||
->first();
|
||||
});
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskCount = $query->total_data ?? 0;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
|
||||
return $this->resSuccess([
|
||||
@@ -54,7 +54,7 @@ class DashboardController extends Controller
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
});
|
||||
$taskCount = $query->total_data;
|
||||
$taskCount = $query->total_data ?? 0;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
return $this->resSuccess([
|
||||
"count" => $taskCount,
|
||||
@@ -71,8 +71,8 @@ class DashboardController extends Controller
|
||||
)
|
||||
->first();
|
||||
});
|
||||
$taskCount = $query->task_count;
|
||||
$taskTotal = $query->total_retribution;
|
||||
$taskCount = $query->task_count ?? 0;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
return $this->resSuccess([
|
||||
"count" => $taskCount,
|
||||
"total" => $taskTotal
|
||||
@@ -90,8 +90,8 @@ class DashboardController extends Controller
|
||||
->first();
|
||||
});
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution;
|
||||
$taskCount = $query->total_data ?? 0;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
|
||||
return $this->resSuccess([
|
||||
"count"=> $taskCount,
|
||||
@@ -113,7 +113,7 @@ class DashboardController extends Controller
|
||||
->first();
|
||||
});
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskCount = $query->total_data ?? 0;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
|
||||
return $this->resSuccess([
|
||||
|
||||
@@ -70,7 +70,7 @@ class PbgTaskController extends Controller
|
||||
public function show(string $id)
|
||||
{
|
||||
try{
|
||||
$pbg_task = PbgTask::with(['pbg_task_retributions','pbg_task_index_integrations'])->findOrFail($id);
|
||||
$pbg_task = PbgTask::with(['pbg_task_retributions','pbg_task_index_integrations','pbg_task_retributions.pbg_task_prasarana'])->findOrFail($id);
|
||||
return response()->json([
|
||||
"success"=> true,
|
||||
"message"=> "Data ditemukan",
|
||||
|
||||
@@ -37,7 +37,7 @@ class PbgTaskController extends Controller
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
$data = PbgTask::with(['pbg_task_retributions','pbg_task_index_integrations'])->findOrFail($id);
|
||||
$data = PbgTask::with(['pbg_task_retributions','pbg_task_index_integrations', 'pbg_task_retributions.pbg_task_prasarana'])->findOrFail($id);
|
||||
return view("pbg_task.show", compact("data"));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,5 +20,10 @@ class PbgTaskPrasarana extends Model
|
||||
'quantity',
|
||||
'unit',
|
||||
'index_prasarana',
|
||||
'pbg_task_retribution_id'
|
||||
];
|
||||
|
||||
public function pbg_task_retributions(){
|
||||
return $this->hasMany(PbgTaskRetributions::class, 'pbg_task_retribution_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,8 @@ class PbgTaskRetributions extends Model
|
||||
public function pbg_task(){
|
||||
return $this->belongsTo(PbgTask::class, 'pbg_task_uid', 'uuid');
|
||||
}
|
||||
|
||||
public function pbg_task_prasarana(){
|
||||
return $this->hasMany(PbgTaskPrasarana::class, 'pbg_task_retribution_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +227,6 @@ class ServiceSIMBG
|
||||
|
||||
$res = $this->service_client->get($url, $headers);
|
||||
|
||||
Log::info("response task detail submit", ['res' => $res]);
|
||||
|
||||
if (empty($res->original['success']) || !$res->original['success']) {
|
||||
// Log error
|
||||
Log::error("API response indicates failure", ['url' => $url, 'uuid' => $uuid]);
|
||||
@@ -249,7 +247,7 @@ class ServiceSIMBG
|
||||
? Carbon::parse($data['updated_at'])->format('Y-m-d H:i:s')
|
||||
: null;
|
||||
|
||||
PbgTaskRetributions::updateOrCreate(
|
||||
$pbg_task_retributions = PbgTaskRetributions::updateOrCreate(
|
||||
['detail_id' => $data['id']],
|
||||
[
|
||||
'detail_uid' => $data['uid'] ?? null,
|
||||
@@ -273,10 +271,13 @@ class ServiceSIMBG
|
||||
]
|
||||
);
|
||||
|
||||
$pbg_task_retribution_id = $pbg_task_retributions->id;
|
||||
|
||||
$prasaranaData = $data['prasarana'] ?? [];
|
||||
if (!empty($prasaranaData)) {
|
||||
$insertData = array_map(fn($item) => [
|
||||
'pbg_task_uid' => $uuid,
|
||||
'pbg_task_retribution_id' => $pbg_task_retribution_id,
|
||||
'prasarana_id' => $item['id'] ?? null,
|
||||
'prasarana_type' => $item['prasarana_type'] ?? null,
|
||||
'building_type' => $item['building_type'] ?? null,
|
||||
|
||||
@@ -12,6 +12,17 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('pbg_task', function (Blueprint $table) {
|
||||
$constraintExists = DB::select("
|
||||
SELECT COUNT(*) as count
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'pbg_task'
|
||||
AND index_name = 'pbg_task_uuid_unique'
|
||||
");
|
||||
|
||||
if ($constraintExists[0]->count > 0) {
|
||||
$table->dropUnique('pbg_task_uuid_unique');
|
||||
}
|
||||
$table->string('uuid')->nullable()->unique()->change();
|
||||
});
|
||||
}
|
||||
@@ -22,6 +33,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pbg_task', function (Blueprint $table) {
|
||||
$table->dropUnique('pbg_task_uuid_unique');
|
||||
$table->string('uuid')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,6 +12,17 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('pbg_task_index_integrations', function (Blueprint $table) {
|
||||
$constraintExists = DB::select("
|
||||
SELECT COUNT(*) as count
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'pbg_task_index_integrations'
|
||||
AND index_name = 'pbg_task_index_integrations_pbg_task_uid_unique'
|
||||
");
|
||||
|
||||
if ($constraintExists[0]->count > 0) {
|
||||
$table->dropUnique('pbg_task_index_integrations_pbg_task_uid_unique');
|
||||
}
|
||||
$table->string('pbg_task_uid')->unique()->change();
|
||||
});
|
||||
}
|
||||
@@ -22,6 +33,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pbg_task_index_integrations', function (Blueprint $table) {
|
||||
$table->dropUnique('pbg_task_index_integrations_pbg_task_uid_unique');
|
||||
$table->string('pbg_task_uid')->unique()->change();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,6 +12,17 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('pbg_task_retributions', function (Blueprint $table) {
|
||||
$constraintExists = DB::select("
|
||||
SELECT COUNT(*) as count
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'pbg_task_retributions'
|
||||
AND index_name = 'pbg_task_retributions_detail_id_unique'
|
||||
");
|
||||
|
||||
if ($constraintExists[0]->count > 0) {
|
||||
$table->dropUnique('pbg_task_retributions_detail_id_unique');
|
||||
}
|
||||
$table->string('detail_id')->unique()->change();
|
||||
});
|
||||
}
|
||||
@@ -22,6 +33,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pbg_task_retributions', function (Blueprint $table) {
|
||||
$table->dropUnique('pbg_task_retributions_detail_id_unique');
|
||||
$table->string('detail_id')->unique()->change();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,6 +12,17 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('pbg_task_prasarana', function (Blueprint $table) {
|
||||
$constraintExists = DB::select("
|
||||
SELECT COUNT(*) as count
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'pbg_task_prasarana'
|
||||
AND index_name = 'pbg_task_prasarana_prasarana_id_unique'
|
||||
");
|
||||
|
||||
if ($constraintExists[0]->count > 0) {
|
||||
$table->dropUnique('pbg_task_prasarana_prasarana_id_unique');
|
||||
}
|
||||
$table->integer('prasarana_id')->nullable()->unique()->change();
|
||||
});
|
||||
}
|
||||
@@ -22,6 +33,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pbg_task_prasarana', function (Blueprint $table) {
|
||||
$table->dropUnique('pbg_task_prasarana_prasarana_id_unique');
|
||||
$table->integer('prasarana_id')->nullable()->unique()->change();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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('pbg_task_prasarana', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('pbg_task_retribution_id')->nullable(); // nullable in case some records do not match
|
||||
|
||||
// Step 2: Define the foreign key relation from `table3` to `table2`
|
||||
$table->foreign('pbg_task_retribution_id')->references('id')->on('pbg_task_retributions')->onDelete('cascade');
|
||||
});
|
||||
|
||||
\DB::table('pbg_task_prasarana')
|
||||
->join('pbg_task', 'pbg_task.uuid', '=', 'pbg_task_prasarana.pbg_task_uid') // Relating pbg_task_prasarana to pbg_task
|
||||
->join('pbg_task_retributions', 'pbg_task_retributions.pbg_task_uid', '=', 'pbg_task.uuid') // Relating pbg_task_retributions to pbg_task
|
||||
->whereNotNull('pbg_task_retributions.id') // Ensure the `pbg_task_retributions` id exists
|
||||
->update(['pbg_task_prasarana.pbg_task_retribution_id' => \DB::raw('pbg_task_retributions.id')]); // Set the foreign key
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pbg_task_prasarana', function (Blueprint $table) {
|
||||
$table->dropForeign(['pbg_task_retribution_id']);
|
||||
$table->dropColumn('pbg_task_retribution_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -16,7 +16,12 @@ class DataSettingSeeder extends Seeder
|
||||
$data_settings = [
|
||||
[
|
||||
"key" => "TARGET_PAD",
|
||||
"value" => "33.200.000.000",
|
||||
"value" => "50000000000",
|
||||
"type" => "integer"
|
||||
],
|
||||
[
|
||||
"key" => "TATA_RUANG",
|
||||
"value" => "10000000000",
|
||||
"type" => "integer"
|
||||
]
|
||||
];
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
"_global-config-Dl5-jBxt.js": {
|
||||
"file": "assets/global-config-Dl5-jBxt.js",
|
||||
"_global-config-9uDKFQ8j.js": {
|
||||
"file": "assets/global-config-9uDKFQ8j.js",
|
||||
"name": "global-config"
|
||||
},
|
||||
"_gridjs.umd-BiCNXlqL.js": {
|
||||
@@ -94,33 +94,33 @@
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/js/dashboards/bigdata.js": {
|
||||
"file": "assets/bigdata-BFcpLrsm.js",
|
||||
"file": "assets/bigdata-C1y9KS-u.js",
|
||||
"name": "bigdata",
|
||||
"src": "resources/js/dashboards/bigdata.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_global-config-Dl5-jBxt.js"
|
||||
"_global-config-9uDKFQ8j.js"
|
||||
]
|
||||
},
|
||||
"resources/js/data-settings/index.js": {
|
||||
"file": "assets/index-CjwDTyfA.js",
|
||||
"file": "assets/index-CzuDcG6g.js",
|
||||
"name": "index",
|
||||
"src": "resources/js/data-settings/index.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_gridjs.umd-BiCNXlqL.js",
|
||||
"_global-config-Dl5-jBxt.js",
|
||||
"_global-config-9uDKFQ8j.js",
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
"resources/js/master/users/users.js": {
|
||||
"file": "assets/users-o8xrenvF.js",
|
||||
"file": "assets/users-BoDXPe3W.js",
|
||||
"name": "users",
|
||||
"src": "resources/js/master/users/users.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_gridjs.umd-BiCNXlqL.js",
|
||||
"_global-config-Dl5-jBxt.js",
|
||||
"_global-config-9uDKFQ8j.js",
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
@@ -223,35 +223,46 @@
|
||||
]
|
||||
},
|
||||
"resources/js/pbg-task/index.js": {
|
||||
"file": "assets/index-BIwgvpVl.js",
|
||||
"file": "assets/index-BW29TEbh.js",
|
||||
"name": "index",
|
||||
"src": "resources/js/pbg-task/index.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_gridjs.umd-BiCNXlqL.js",
|
||||
"_global-config-Dl5-jBxt.js",
|
||||
"_global-config-9uDKFQ8j.js",
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
"resources/js/settings/general/general-settings.js": {
|
||||
"file": "assets/general-settings-BNtJQCVY.js",
|
||||
"file": "assets/general-settings-BoJeYQk1.js",
|
||||
"name": "general-settings",
|
||||
"src": "resources/js/settings/general/general-settings.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_gridjs.umd-BiCNXlqL.js",
|
||||
"_global-config-Dl5-jBxt.js",
|
||||
"_global-config-9uDKFQ8j.js",
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
"resources/js/settings/syncronize/syncronize.js": {
|
||||
"file": "assets/syncronize-D6sYFuSv.js",
|
||||
"file": "assets/syncronize-DjtcngRb.js",
|
||||
"name": "syncronize",
|
||||
"src": "resources/js/settings/syncronize/syncronize.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_gridjs.umd-BiCNXlqL.js",
|
||||
"_global-config-Dl5-jBxt.js",
|
||||
"_global-config-9uDKFQ8j.js",
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
"resources/js/tables/common-table.js": {
|
||||
"file": "assets/common-table-KF_NVAIE.js",
|
||||
"name": "common-table",
|
||||
"src": "resources/js/tables/common-table.js",
|
||||
"isEntry": true,
|
||||
"imports": [
|
||||
"_gridjs.umd-BiCNXlqL.js",
|
||||
"_global-config-9uDKFQ8j.js",
|
||||
"__commonjsHelpers-C4iS2aBk.js"
|
||||
]
|
||||
},
|
||||
@@ -266,7 +277,7 @@
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/scss/style.scss": {
|
||||
"file": "assets/style-Dazdq775.css",
|
||||
"file": "assets/style-B2v4WMju.css",
|
||||
"src": "resources/scss/style.scss",
|
||||
"isEntry": true
|
||||
}
|
||||
|
||||
@@ -39,10 +39,11 @@ class BigData {
|
||||
|
||||
// kekurangan potensi
|
||||
this.totalKekuranganPotensi = new Big(
|
||||
this.totalTargetPAD - this.bigTotalPotensi
|
||||
this.bigTargetPAD - this.bigTotalPotensi
|
||||
);
|
||||
|
||||
this.percentageKekuranganPotensi =
|
||||
this.totalKekuranganPotensi <= 0 || this.totalTargetPAD <= 0
|
||||
this.totalKekuranganPotensi <= 0 || this.bigTargetPAD <= 0
|
||||
? 0
|
||||
: this.totalKekuranganPotensi
|
||||
.div(this.bigTargetPAD)
|
||||
@@ -88,7 +89,7 @@ class BigData {
|
||||
.times(100)
|
||||
.toFixed(2);
|
||||
|
||||
if (!this.totalTargetPAD) {
|
||||
if (!this.bigTargetPAD) {
|
||||
console.error("Failed to load chart data");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
@include('layouts.partials/page-title', ['title' => 'Detail', 'subtitle' => 'PBG'])
|
||||
@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'PBG'])
|
||||
|
||||
<div class="row">
|
||||
<div class="card">
|
||||
@@ -203,8 +203,47 @@
|
||||
@endif
|
||||
</div>
|
||||
<div class="tab-pane" id="pbgTaskPrasarana">
|
||||
<div class="row d-flex flex-warp gap-3 justify-content-center">
|
||||
@if ($data->pbg_task_retributions && $data->pbg_task_retributions->pbg_task_prasarana)
|
||||
@foreach ($data->pbg_task_retributions->pbg_task_prasarana as $prasarana)
|
||||
<div class="border p-3 rounded shadow-sm col-md-4">
|
||||
<div class="mb-3">
|
||||
<dt>Prasarana Type</dt>
|
||||
<dd>{{$prasarana->prasarana_type}}</dd>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<dt>Building Type</dt>
|
||||
<dd>{{$prasarana->building_type}}</dd>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<dt>Total</dt>
|
||||
<dd>{{$prasarana->total}}</dd>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<dt>Quantity</dt>
|
||||
<dd>{{$prasarana->quantity}}</dd>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<dt>Unit</dt>
|
||||
<dd>{{$prasarana->unit}}</dd>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<dt>Index Prasarana</dt>
|
||||
<dd>{{$prasarana->index_prasarana}}</dd>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<dt>Created At</dt>
|
||||
<dd>{{$prasarana->created_at}}</dd>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="row">
|
||||
aslkdjkasjd
|
||||
<div class="col-md-12">
|
||||
Data Not Available
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,12 +52,11 @@ Route::group(['middleware' => 'auth:sanctum'], function (){
|
||||
|
||||
// sync pbg google sheet
|
||||
Route::get('/sync-pbg-task-google-sheet', [PbgTaskController::class, 'syncPbgFromGoogleSheet'])->name('pbg-task.sync-google-sheet');
|
||||
Route::apiResource('/api-google-sheet', GoogleSheetController::class);
|
||||
Route::get('/sync-task', [SyncronizeController::class, 'syncPbgTask'])->name('api.task');
|
||||
Route::get('/get-user-token', [SyncronizeController::class, 'getUserToken'])->name('api.task.token');
|
||||
Route::get('/get-index-integration-retribution/{uuid}', [SyncronizeController::class, 'syncIndexIntegration'])->name('api.task.inntegration');
|
||||
Route::get('/sync-task-submit/{uuid}', [SyncronizeController::class, 'syncTaskDetailSubmit'])->name('api.task.submit');
|
||||
});
|
||||
|
||||
Route::apiResource('/api-google-sheet', GoogleSheetController::class);
|
||||
|
||||
|
||||
Route::get('/sync-task', [SyncronizeController::class, 'syncPbgTask'])->name('api.task');
|
||||
Route::get('/get-user-token', [SyncronizeController::class, 'getUserToken'])->name('api.task.token');
|
||||
Route::get('/get-index-integration-retribution/{uuid}', [SyncronizeController::class, 'syncIndexIntegration'])->name('api.task.inntegration');
|
||||
Route::get('/sync-task-submit/{uuid}', [SyncronizeController::class, 'syncTaskDetailSubmit'])->name('api.task.submit');
|
||||
Reference in New Issue
Block a user