forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
4.9 KiB
155 lines
4.9 KiB
<?php |
|
|
|
$tpLayout = 1; |
|
$clasId = $_REQUEST["clas_id"]; |
|
$clasDesc = $_REQUEST["clas_descricao"]; |
|
|
|
|
|
if (isset($_POST["btIncDac"])) { |
|
$dacs = $_POST["dacs"]; |
|
pg_query($dbcon, 'begin'); |
|
foreach ($dacs as $idDac) { |
|
$query = "insert into pbx_classifica_dacs(clas_id, id_dac ) |
|
select '$clasId', '$idDac' |
|
where not exists(select '' 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 = "<span style=\"color: #0000FF\">Operação realizada com sucesso!</span>"; |
|
} else { |
|
pg_query($dbcon, 'rollback'); |
|
$erroDb = pg_last_error($dbcon); |
|
$msg = "<span style=\"color: #FF0000\">A operação não pode realizada!" . ($erroDb ? (" Erro: " . $erroDb) : "") . "</span>"; |
|
} |
|
} 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 = "<span style=\"color: #0000FF\">Operação realizada com sucesso!</span>"; |
|
} else { |
|
pg_query($dbcon, 'rollback'); |
|
$erroDb = pg_last_error($dbcon); |
|
$msg = "<span style=\"color: #FF0000\">A operação não pode realizada!" . ($erroDb ? (" Erro: " . $erroDb) : "") . "</span>"; |
|
} |
|
} |
|
|
|
|
|
$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 <select></select> |
|
*/ |
|
|
|
$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 = "<select name=\"dacs[]\" id=\"dacs\" size=\"6\" multiple=\"multiple\" style=\"width:250px;\" >"; |
|
|
|
while ($dados = pg_fetch_row($result)) { |
|
$dacs .= "<option value=\"$dados[0]\" $sel>$dados[1]</option>"; |
|
$cont++; |
|
} |
|
$dacs .= "</select>"; |
|
return $dacs; |
|
} |
|
|
|
function GetDacClasInc($dbcon, $clasId) { |
|
/* |
|
* Carrega lista de dacs disponivel |
|
* para ser inserdo entre as tags <select></select> |
|
*/ |
|
|
|
$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 = "<select name=\"dacsInc[]\" id=\"dacsInc\" size=\"6\" multiple=\"multiple\" style=\"width:250px;\" >"; |
|
|
|
while ($dados = pg_fetch_row($result)) { |
|
$dacs .= "<option value=\"$dados[0]\" $sel>$dados[1]</option>"; |
|
$cont++; |
|
} |
|
$dacs .= "</select>"; |
|
return $dacs; |
|
} |
|
|
|
?>
|
|
|