assign("listaRamaisDisp", $listaRamaisDisp); $smarty->assign("listaNumerosInc", $listaNumerosInc); $smarty->assign("cc_id", $cc_id); $smarty->assign("cc_descricao", $cc_descricao); GetTemplate($smarty, $nomeTpl); function GetRamaisCCDisp($ccId = 0) { global $dbcon; $org_id = GetOrganizacao(); if (!$ccId) { $query = "select nome, dispositivo from pbx_ramais a where not exists(select '' from pbx_pbx_centro_custo_ramais where trim(ramal) = trim(a.nome)) and a.org_id = {$org_id} order by nome"; } else { $query = "select nome, dispositivo from pbx_ramais a where exists(select '' from pbx_pbx_centro_custo_ramais where trim(ramal) = trim(a.nome) and cc_id = '$ccId') and a.org_id = {$org_id} order by nome"; } $result = pg_query($dbcon, $query); $opt = ''; while ($dados = pg_fetch_array($result)) { $nome = $dados['nome']; $opt .= "\n"; } return $opt; }