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.
|
|
#!/bin/bash |
|
|
HOST_DB="172.16.51.15" |
|
|
BASE_DB="PBX" |
|
|
USUARIO="contacte" |
|
|
SENHA="ctepgSQL" |
|
|
TBL_AGENTES="pbx_supervisor_agentes" |
|
|
|
|
|
|
|
|
case "$1" in |
|
|
|
|
|
inserir_agente) |
|
|
|
|
|
echo parametro 1 = $1 |
|
|
#inserir agente |
|
|
if [ -z "$2" -o -z "$3" ] |
|
|
then |
|
|
exit |
|
|
fi |
|
|
|
|
|
export PGPASSWORD=$SENHA |
|
|
psql -c "insert into $TBL_AGENTES (status,matricula,tempo_login,logado) values ('$2','$3',now(),now())" -h $HOST_DB -d $BASE_DB -U $USUARIO |
|
|
|
|
|
exit 0 |
|
|
|
|
|
;; |
|
|
|
|
|
deletar_agente) |
|
|
|
|
|
echo parametro 1 = $1 |
|
|
#deletar agente |
|
|
if [ -z "$2" ] |
|
|
then |
|
|
exit |
|
|
fi |
|
|
|
|
|
export PGPASSWORD=$SENHA |
|
|
psql -c "delete from $TBL_AGENTES where matricula = '$2'" -h $HOST_DB -d $BASE_DB -U $USUARIO |
|
|
|
|
|
exit 0 |
|
|
|
|
|
;; |
|
|
|
|
|
atualizar_transferencia) |
|
|
|
|
|
echo parametro 1 = $1 |
|
|
#atualizar transferencia |
|
|
if [ -z "$2" -o -z "$3" ] |
|
|
then |
|
|
exit |
|
|
fi |
|
|
|
|
|
export PGPASSWORD=$SENHA |
|
|
PAUSA=$(psql -c "select count(*) from $TBL_AGENTES where status = 'PAUSA' and matricula = '$3'" -h $HOST_DB -d $BASE_DB -U $USUARIO|head -n3|tail -n1) |
|
|
|
|
|
echo 'Pausa = '$PAUSA |
|
|
if [ $PAUSA = 1 ] |
|
|
then |
|
|
exit |
|
|
fi |
|
|
|
|
|
psql -c "UPDATE $TBL_AGENTES SET status = '$2',duracao = now(),origem_destino = '',canal = '' WHERE CANAL = '$3'" -h $HOST_DB -d $BASE_DB -U $USUARIO |
|
|
|
|
|
exit 0 |
|
|
|
|
|
;; |
|
|
|
|
|
atualizar_canal) |
|
|
|
|
|
echo parametro 1 = $1 |
|
|
#atualizar canal |
|
|
if [ -z "$2" -o -z "$3" -o -z "$4" ] |
|
|
then |
|
|
exit |
|
|
fi |
|
|
|
|
|
export PGPASSWORD=$SENHA |
|
|
psql -c "UPDATE $TBL_AGENTES SET status = 'ORIGINANDO' ,canal = '$2',duracao = now(),origem_destino = '$4' WHERE matricula = '$3'" -h $HOST_DB -d $BASE_DB -U $USUARIO |
|
|
|
|
|
exit 0 |
|
|
|
|
|
;; |
|
|
|
|
|
atualizar_agente) |
|
|
|
|
|
echo parametro 1 = $1 |
|
|
#atualizar agente |
|
|
if [ -z "$2" -o -z "$3" ] |
|
|
then |
|
|
exit |
|
|
fi |
|
|
|
|
|
export PGPASSWORD=$SENHA |
|
|
PAUSA=$(psql -c "select count(*) from $TBL_AGENTES where status = 'PAUSA' and matricula = '$3'" -h $HOST_DB -d $BASE_DB -U $USUARIO|head -n3|tail -n1) |
|
|
|
|
|
echo 'Pausa = '$PAUSA |
|
|
if [ $PAUSA = 1 ] |
|
|
then |
|
|
psql -c "UPDATE $TBL_AGENTES SET origem_destino = '',canal = '' WHERE matricula = '$3'" -h $HOST_DB -d $BASE_DB -U $USUARIO |
|
|
exit |
|
|
fi |
|
|
|
|
|
psql -c "UPDATE $TBL_AGENTES SET status = '$2',duracao = now(),origem_destino = '',canal = '' WHERE matricula = '$3'" -h $HOST_DB -d $BASE_DB -U $USUARIO |
|
|
|
|
|
exit 0 |
|
|
|
|
|
;; |
|
|
|
|
|
*) |
|
|
date +%F-%T >> /var/log/scripts/callcenter.log |
|
|
echo Op<EFBFBD><EFBFBD>o inv<EFBFBD>lida: $1 >> /var/log/scripts/callcenter.log |
|
|
echo " " >> /var/log/scripts/callcenter.log |
|
|
exit 1 |
|
|
;; |
|
|
|
|
|
esac
|
|
|
|