' . "Błąd: brak lub niepoprawny parametr id_zasob" . ''; return; } $db = DB::getDB(); $zasob = $db->get_by_id('CRM_LISTA_ZASOBOW', $zasobId); if (!$zasob) { echo '
cnf (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cnf);echo''; } if (!empty($cnf)) { $external_ids = array(); foreach ($cnf as $k_table_name => $v_cnf) { $vTblId = ProcesHelper::getZasobTableID($k_table_name); $cur_cnf = new stdClass(); $cur_cnf->id_col = V::get('id_col', 'ID', $v_cnf); $cur_cnf->search_col = V::get('search_col', 'CRM_LISTA_ZASOBOW_ID', $v_cnf); $cur_cnf->search_col_regex = V::get('search_col_regex', '', $v_cnf); $sql_id_col = $cur_cnf->id_col; $sql_where = ""; if ($cur_cnf->search_col_regex) { $sql_where = "`{$cur_cnf->search_col}` like '".str_replace('$ID', $zasob->ID, $cur_cnf->search_col_regex)."'"; } else { $sql_where = "`{$cur_cnf->search_col}`='{$zasob->ID}'"; } $sql = "select t.`ID`, {$sql_id_col} as id_col from `{$k_table_name}` as t where {$sql_where} "; if($DBG > 2){ echo'
sql (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo''; } $res = $db->query($sql); while ($r = $db->fetch($res)) { $r->tblId = $vTblId; $extRows[] = $r; if ('ID' != $sql_id_col) { $external_ids []= $r->ID . "(" . $r->id_col . ")"; } else { $external_ids []= "" . $r->id_col; } } } } if($DBG){echo'
extRows (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($extRows);echo'';}
if (!empty($extRows)) {
foreach ($extRows as $vExtRow) {
$tblLabels[$vExtRow->tblId] = false;
}
$sqlTblsIds = array_keys($tblLabels);
if (!empty($sqlTblsIds)) {
$sqlTblsIds = implode(", ", $sqlTblsIds);
$sql = "select z.`ID`, z.`DESC`, z.`DESC_PL`, z.`OPIS`
from `CRM_LISTA_ZASOBOW` as z
where
z.`ID` in({$sqlTblsIds})
";
$res = $db->query($sql);
while ($r = $db->fetch($res)) {
$vLabel = $r->DESC_PL;
$vTitle = htmlspecialchars($r->OPIS);
if (empty($vLabel) && !empty($r->OPIS)) {
$posLimit = 20;
$vLabel = $r->OPIS;
if (mb_strlen($r->OPIS) > $posLimit) {
$pos = strpos($r->OPIS, ' - ');
if ($pos > $posLimit || $pos < 5) {
$pos = $posLimit;
$vLabel = mb_substr($r->OPIS, 0, $posLimit, 'utf-8') . '...';
} else {
$vLabel = mb_substr($r->OPIS, 0, $pos, 'utf-8');
}
}
}
if (empty($vLabel)) {
$vLabel = $r->DESC;
}
$vLabel = 'ID}] {$vTitle}" . '">' . $vLabel. '';
$tblLabels[$r->ID] = $vLabel;
}
}
}
SE_Layout::menu();
?>