<?php
declare(strict_types=1);

use App\Core\Database;

return function (Database $db): void {
    $ts = date('Y-m-d H:i:s');

    $warehouses = [
        ['code' => 'WH-MAIN', 'name_ar' => 'المخزن الرئيسي',             'warehouse_type' => 'general'],
        ['code' => 'WH-SHOP', 'name_ar' => 'المحل الرياضي',              'warehouse_type' => 'sports_shop'],
        ['code' => 'WH-CAFE', 'name_ar' => 'مخزن الكافيتريا',            'warehouse_type' => 'cafeteria'],
        ['code' => 'WH-GYM',  'name_ar' => 'مخزن الجيم',                 'warehouse_type' => 'gym'],
        ['code' => 'WH-MED',  'name_ar' => 'مخزن المستلزمات الطبية',     'warehouse_type' => 'medical'],
    ];

    foreach ($warehouses as $wh) {
        $existing = $db->selectOne("SELECT id FROM warehouses WHERE code = ?", [$wh['code']]);
        if ($existing) {
            continue;
        }
        $db->insert('warehouses', [
            'code'           => $wh['code'],
            'name_ar'        => $wh['name_ar'],
            'warehouse_type' => $wh['warehouse_type'],
            'is_active'      => 1,
            'created_at'     => $ts,
            'updated_at'     => $ts,
        ]);
    }
};
