Function getUnitFromCode : add filter by type of unit

This commit is contained in:
atm-lena
2022-09-15 11:55:08 +02:00
parent 9881e7753d
commit 1c14c61064
2 changed files with 8 additions and 4 deletions

View File

@@ -8498,7 +8498,7 @@ function dol_osencode($str)
* @return int <0 if KO, Id of code if OK
* @see $langs->getLabelFromKey
*/
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0)
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '')
{
global $cache_codes;
@@ -8520,6 +8520,9 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
if (!empty($entityfilter)) {
$sql .= " AND entity IN (".getEntity($tablename).")";
}
if ($filters) {
$sql .= $filters;
}
$resql = $db->query($sql);
if ($resql) {