partial update create kpi and progress bar
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateKpiTargetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('kpi_targets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->integer('target_value');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Unique constraint untuk mencegah duplikasi target aktif per user (satu target aktif per user)
|
||||
$table->unique(['user_id', 'is_active'], 'kpi_targets_user_active_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('kpi_targets');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateKpiAchievementsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('kpi_achievements', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('kpi_target_id')->constrained()->onDelete('cascade');
|
||||
$table->integer('target_value'); // Menyimpan target value secara langsung untuk historical tracking
|
||||
$table->integer('actual_value')->default(0);
|
||||
$table->decimal('achievement_percentage', 5, 2)->default(0);
|
||||
$table->integer('year');
|
||||
$table->integer('month');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Unique constraint untuk mencegah duplikasi achievement per user per bulan
|
||||
// Note: Tidak menggunakan kpi_target_id karena target sekarang permanen per user
|
||||
$table->unique(['user_id', 'year', 'month']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('kpi_achievements');
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,10 @@ class MenuSeeder extends Seeder
|
||||
[
|
||||
'name' => 'Histori Stock',
|
||||
'link' => 'stock-audit.index'
|
||||
],
|
||||
[
|
||||
'name' => 'Target',
|
||||
'link' => 'kpi.targets.index'
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user