<?php
namespace App\Controllers\PSI;

use App\Controllers\Controller;
use App\Models\PSI\StockMove;
use App\Models\PSI\Material;
use App\Models\PSI\Product;

/** 库存流水台账（所有出入库变动记录） */
class StockController extends Controller
{


    public function index()
    {
        $moves = (new StockMove())->all();
        $moves = array_reverse($moves);
        $nameMap = [];
        foreach ((new Material())->all() as $m) { $nameMap['material:' . $m['id']] = $m['name']; }
        foreach ((new Product())->all() as $p) { $nameMap['product:' . $p['id']] = $p['name']; }
        return $this->renderSubsys('psi', 'psi/stock', ['moves' => $moves, 'nameMap' => $nameMap], \psi_nav(), 'stock');
    }
}
