<?php

namespace Modules\Stock\Trait\Repo;

trait LigneRepoTrait
{
    /**
     * @param string $no
     * @param string $key
     * @param string $codeTab
     * @param string $enteKey
     * @return int
     */
    public function getNouveauNoLigne(string $no, string $key, string $codeTab, string $enteKey): int
    {
        $requete = "SELECT MAX(".$key.") AS MAX_LIG FROM ".$codeTab." WITH (nolock) WHERE ".$enteKey."=:no GROUP BY ".$enteKey;

        return (int) $this->fetchAssocOne($requete, [':no' => $no])['MAX_LIG'] + 1;
    }
}
