<?php
declare(strict_types=1);

use App\Core\Registries\MenuRegistry;
use App\Core\Registries\PermissionRegistry;

// ────────────────────────────────────────────────────────────
// Inventory — Permissions
// ────────────────────────────────────────────────────────────

PermissionRegistry::register('inventory', [
    'inventory.view'            => ['ar' => 'عرض الأصناف والتصنيفات',        'en' => 'View Items & Categories'],
    'inventory.manage'          => ['ar' => 'إدارة الأصناف والتصنيفات',       'en' => 'Manage Items & Categories'],
    'warehouse.view'            => ['ar' => 'عرض المخازن',                    'en' => 'View Warehouses'],
    'warehouse.manage'          => ['ar' => 'إدارة المخازن',                   'en' => 'Manage Warehouses'],
    'stock.view'                => ['ar' => 'عرض حركات المخزون',              'en' => 'View Stock Movements'],
    'stock.move'                => ['ar' => 'إجراء حركات مخزون',              'en' => 'Create Stock Movements'],
    'stock.approve_transfer'    => ['ar' => 'اعتماد نقل بين المخازن',         'en' => 'Approve Stock Transfers'],
    'stock.audit'               => ['ar' => 'إجراء جرد المخزون',              'en' => 'Conduct Stock Audits'],
    'stock.approve_adjustment'  => ['ar' => 'اعتماد تسويات الجرد',            'en' => 'Approve Audit Adjustments'],
    'purchase.view'             => ['ar' => 'عرض أوامر الشراء',               'en' => 'View Purchase Orders'],
    'purchase.create'           => ['ar' => 'إنشاء أوامر شراء',               'en' => 'Create Purchase Orders'],
    'purchase.approve'          => ['ar' => 'اعتماد أوامر الشراء',             'en' => 'Approve Purchase Orders'],
    'supplier.view'             => ['ar' => 'عرض الموردين',                   'en' => 'View Suppliers'],
    'supplier.manage'           => ['ar' => 'إدارة الموردين',                  'en' => 'Manage Suppliers'],
    'asset.view'                => ['ar' => 'عرض الأصول',                     'en' => 'View Assets'],
    'asset.manage'              => ['ar' => 'إدارة الأصول والإهلاك',           'en' => 'Manage Assets & Depreciation'],
    'report.inventory'          => ['ar' => 'تقارير المخزون',                  'en' => 'Inventory Reports'],
    'inventory.bom.view'        => ['ar' => 'عرض قوائم المواد',                'en' => 'View Bill of Materials'],
    'inventory.bom.manage'      => ['ar' => 'إدارة قوائم المواد',               'en' => 'Manage Bill of Materials'],
    'inventory.opening.manage'  => ['ar' => 'أرصدة افتتاحية',                  'en' => 'Opening Balances'],
]);

// ────────────────────────────────────────────────────────────
// Inventory — Sidebar menu
// ────────────────────────────────────────────────────────────

MenuRegistry::register('inventory', [
    'label_ar'   => 'إدارة المخازن',
    'label_en'   => 'Inventory Management',
    'icon'       => 'warehouse',
    'route'      => '/inventory/items',
    'permission' => 'inventory.view',
    'parent'     => null,
    'order'      => 400,
    'children'   => [
        ['label_ar' => 'الأصناف',            'label_en' => 'Items',              'route' => '/inventory/items',               'permission' => 'inventory.view',    'order' => 1],
        ['label_ar' => 'التصنيفات',          'label_en' => 'Categories',         'route' => '/inventory/categories',          'permission' => 'inventory.view',    'order' => 2],
        ['label_ar' => 'المخازن',            'label_en' => 'Warehouses',         'route' => '/inventory/warehouses',          'permission' => 'warehouse.view',    'order' => 3],
        ['label_ar' => 'حركات المخزون',      'label_en' => 'Stock Movements',    'route' => '/inventory/movements',           'permission' => 'stock.view',        'order' => 4],
        ['label_ar' => 'النقل بين المخازن',  'label_en' => 'Stock Transfers',    'route' => '/inventory/transfers',           'permission' => 'stock.view',        'order' => 5],
        ['label_ar' => 'الجرد',              'label_en' => 'Stock Audits',       'route' => '/inventory/audits',              'permission' => 'stock.audit',       'order' => 6],
        ['label_ar' => 'الموردين',           'label_en' => 'Suppliers',          'route' => '/inventory/suppliers',           'permission' => 'supplier.view',     'order' => 7],
        ['label_ar' => 'أوامر الشراء',       'label_en' => 'Purchase Orders',    'route' => '/inventory/purchase-orders',     'permission' => 'purchase.view',     'order' => 8],
        ['label_ar' => 'الأصول والإهلاك',    'label_en' => 'Assets',             'route' => '/inventory/assets',              'permission' => 'asset.view',        'order' => 9],
        ['label_ar' => 'عهدة الأصول',       'label_en' => 'Asset Custody',      'route' => '/inventory/assets/custody',      'permission' => 'asset.view',        'order' => 10],
        ['label_ar' => 'قوائم المواد (BOM)', 'label_en' => 'Bill of Materials',  'route' => '/inventory/bom',                 'permission' => 'inventory.bom.view','order' => 11],
        ['label_ar' => 'أرصدة افتتاحية',    'label_en' => 'Opening Balances',   'route' => '/inventory/opening-balances',    'permission' => 'inventory.opening.manage', 'order' => 12],
        ['label_ar' => 'تقارير المخزون',     'label_en' => 'Inventory Reports',  'route' => '/inventory/reports/stock-balance','permission' => 'report.inventory', 'order' => 13],
    ],
]);
