<?php

declare(strict_types=1);

namespace App\Modules\Inventory\Presentation\Controllers;

use App\Core\Auth;
use App\Core\Request;
use App\Core\Response;
use App\Modules\Inventory\Application\Services\ItemBalanceService;

final class ItemBalanceController
{
    public function __construct(private ?ItemBalanceService $service = null)
    {
        $this->service ??= new ItemBalanceService(db());
    }

    public function index(): void
    {
        Auth::requireLogin();

        $data = $this->service->data(
            (int) Request::get('warehouse_id', 0),
            (int) Request::get('item_id', 0)
        );

        Response::view('pages/stock/item_balance', $data + [
            'page_title' => 'استعلام رصيد صنف',
            'breadcrumbs' => [
                ['label' => 'لوحة التحكم', 'url' => '/admin/dashboard'],
                ['label' => 'استعلام رصيد صنف'],
            ],
        ]);
    }
}
