<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class MasterDataSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Seed Range DOI dengan data default
        DB::table('m_range_dois')->insert([
            [
                'name' => 'Critical',
                'min_days' => 0,
                'max_days' => 3,
                'color_code' => '#dc3545',
                'description' => 'Stok kritis yang memerlukan perhatian segera',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Normal',
                'min_days' => 3.1,
                'max_days' => 7,
                'color_code' => '#28a745',
                'description' => 'Stok dalam kondisi normal',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Overstock',
                'min_days' => 7.1,
                'max_days' => 999999,
                'color_code' => '#6f42c1',
                'description' => 'Stok berlebih yang perlu dikurangi',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);

        // Seed Reason Adjustments dengan data predefined
        DB::table('m_reason_adjustments')->insert([
            [
                'code' => 'ADJ001',
                'name' => 'Big Order',
                'description' => 'Penyesuaian karena ada pesanan besar dari customer',
                'category' => 'Positive',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'code' => 'ADJ002',
                'name' => 'GM Day',
                'description' => 'Penyesuaian untuk event GM Day khusus',
                'category' => 'Neutral',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'code' => 'ADJ003',
                'name' => 'Forecast Issue',
                'description' => 'Penyesuaian karena masalah perhitungan forecast',
                'category' => 'Negative',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);

        // Seed contoh Menu
        DB::table('m_menus')->insert([
            [
                'code' => 'MN000001',
                'name' => 'Bakmi Ayam',
                'menu_group' => 'Noodles',
                'plu_code' => 'PLU001',
                'category' => 'Main Course',
                'price' => 25000,
                'description' => 'Bakmi ayam dengan topping lengkap',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'code' => 'MN000002',
                'name' => 'Bakmi Babi',
                'menu_group' => 'Noodles',
                'plu_code' => 'PLU002',
                'category' => 'Main Course',
                'price' => 28000,
                'description' => 'Bakmi babi dengan char siu',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'code' => 'MN000003',
                'name' => 'Nasi Goreng Spesial',
                'menu_group' => 'Rice',
                'plu_code' => 'PLU003',
                'category' => 'Main Course',
                'price' => 30000,
                'description' => 'Nasi goreng dengan topping spesial',
                'is_active' => true,
                'delete_flag' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);

        echo "Master data seeded successfully!\n";
    }
}