Operação realizada com sucesso!"; } else { @pg_query($dbcon, 'rollback'); $erroDb = pg_last_error($dbcon); $msg = "A operação não pode realizada!" . ($erroDb ? (" Erro: " . $erroDb) : "") . ""; } } else if (isset($_POST["btRmDac"])) { $dacs = $_POST["dacsInc"]; @pg_query($dbcon, 'begin'); foreach ($dacs as $idDac) { $query = "delete from pbx_classifica_dacs where id_dac = '$idDac' and clas_id = '$clasId' "; $result = pg_query($dbcon, $query); if (!$result) break; } if ($result) { @pg_query($dbcon, 'commit'); $msg = "Operação realizada com sucesso!"; } else { @pg_query($dbcon, 'rollback'); $erroDb = pg_last_error($dbcon); $msg = "A operação não pode realizada!" . ($erroDb ? (" Erro: " . $erroDb) : "") . ""; } } $dacs = GetDacClas($dbcon, $clasId); $dacsIncs = GetDacClasInc($dbcon, $clasId); GetDac($dbcon, $codDac); $smarty->assign("clas_id", $clasId); $smarty->assign("clas_descricao", $clasDesc); $smarty->assign("dacs", $dacs); $smarty->assign("dacsIncs", $dacsIncs); $smarty->assign("erro", $msg); GetTemplate($smarty, 'cadastros/classificaAtendimento/classificacaoDacs.htm'); function GetDacClas($dbcon, $clasId) { /* * Carrega lista de dacs disponivel * para ser inserdo entre as tags */ $isAdm = (IsAdmin() && !$matricula); $idUser = !$matricula ? GetIdUser() : GetIdUserFromMatricula($dbcon, $matricula); $matricula = GetMatricula(); $query = "select distinct id, nome as nome, 'Receptivo' as tipo from pbx_dacs d where status = 'A' and id not in(select id_dac from pbx_classifica_dacs where clas_id = $clasId) order by 2"; /* if($isAdm) { } else { $query = "select distinct d.id, d.nome, 'Receptivo' as tipo, 'false' as padrao from pbx_usuarios a, pbx_grupo_usuario b, pbx_fila_grupos c, pbx_dacs d where b.user_id = a.id and c.gp_id = b.gp_id and d.id = c.id and lower(a.matricula) = lower('$matricula') and d.id in (select id_dac from pbx_classifica_dacs where clas_id = $clasId) and d.status = 'A' order by 1, 2 "; } */ // echo $query; $result = pg_query($dbcon, $query); $dacs = ""; return $dacs; } function GetDacClasInc($dbcon, $clasId) { /* * Carrega lista de dacs disponivel * para ser inserdo entre as tags */ $isAdm = (IsAdmin() && !$matricula); $matricula = GetMatricula(); $query = "select distinct id, nome as nome, 'Receptivo' as tipo from pbx_dacs d where status = 'A' and id in(select id_dac from pbx_classifica_dacs where clas_id = $clasId) order by 2"; /* if($isAdm) { } else { $query = "select distinct d.id, d.nome, 'Receptivo' as tipo, 'false' as padrao from pbx_usuarios a, pbx_grupo_usuario b, pbx_fila_grupos c, pbx_dacs d where b.user_id = a.id and c.gp_id = b.gp_id and d.id = c.id and lower(a.matricula) = lower('$matricula') and d.id not in (select id_dac from pbx_classifica_dacs where clas_id = $clasId) and d.status = 'A' order by 1, 2 "; } */ //echo $query; $result = pg_query($dbcon, $query); $dacs = ""; return $dacs; } ?>