assign('nomeRelatorio', $nomeRelatorio);
$smarty->assign('idRel', $idRel);
$smarty->assign('listaDisp', GetColunasRelatorio($dbcon, $idRel));
$smarty->assign('listaInc', GetColunasRelatorioInc($dbcon, $idRel));
$smarty->assign('msg', $msg);
GetTemplate($smarty, 'relOrdena.tpl');
function GetColunasRelatorio($dbcon, $idRel) {
$query = "select ord_id, ord_rel_id, ord_nome_coluna, ord_display_coluna
from pbx_relatorio_ordena a
where ord_rel_id = '$idRel'
and not exists(select '' from pbx_relatorio_ordena_set where ord_id = a.ord_id)
order by ord_display_coluna
";
$result = pg_query($dbcon, $query);
$opt = '';
while ($row = pg_fetch_array($result)) {
$id = sprintf('%s|%s|%s', $row['ord_id'], $row['ord_rel_id'], $row['ord_nome_coluna']);
$disp = $row['ord_display_coluna'];
$opt .= sprintf('', $id, $disp);
}
return $opt;
}
function GetColunasRelatorioInc($dbcon, $idRel) {
$query = "select a.ord_id, a.ord_rel_id, a.ord_nome_coluna, a.ord_display_coluna
from pbx_relatorio_ordena a, pbx_relatorio_ordena_set b
where b.ord_id = a.ord_id
and a.ord_rel_id = '$idRel'
order by ords_seq";
$result = pg_query($dbcon, $query);
$opt = '';
while ($row = pg_fetch_array($result)) {
$id = $row['ord_id'];
$disp = $row['ord_display_coluna'];
$opt .= sprintf('', $id, $disp);
}
return $opt;
}
function GetMaxOrdena($dbcon, $idRel) {
$query = "select max(ords_seq) as ords_seq
from pbx_relatorio_ordena_set a
where a.ord_rel_id = '$idRel'";
$result = pg_query($dbcon, $query);
$row = pg_fetch_row($result);
return !$row[0] ? 0 : $row[0];
}
?>