#--------------------------------#
FUNCTION log02700_create_process()
#--------------------------------#
DEFINE la_html ARRAY[1] OF RECORD
name CHAR(50),
code TEXT
END RECORD
DEFINE la_events ARRAY[1] OF RECORD
name CHAR(50),
code TEXT
END RECORD
DEFINE la_states ARRAY[3] OF RECORD
name CHAR(050),
description CHAR(100),
instruction CHAR(200),
deadline INTEGER,
attribution INTEGER,
codattribution CHAR(100)
END RECORD
DEFINE l_form_id INTEGER
DEFINE l_return CHAR(100)
# Nome e conteúdo do formulário HTML que será criado para o processo.
LET la_html[1].name = 'log002700.html'
LET la_html[1].code = log02700_get_wf_html()
# Define os eventos do formulário.
LET la_events[1].name = 'validateForm'
LET la_events[1].code = log02700_get_wf_form_event(la_events[1].name)
# Cria o formulário HTML no ECM.
LET l_form_id = _ADVPL_WfCard('LOG02700','Manutenção de Usuários','Usuários',la_html,la_events)
IF l_form_id < 1 THEN
CALL LOG_message(_ADVPL_WfGetError(1),'ERROR',_ADVPL_WfGetError(2),NULL,0)
RETURN FALSE
END IF
# Define as atividades do processo.
LET la_states[1].name = 'inicio'
LET la_states[1].description = 'Início'
LET la_states[1].instruction = 'Informar os dados do usuário'
LET la_states[1].deadline = 0
LET la_states[1].attribution = 0
LET la_states[1].codattribution = ''
LET la_states[2].name = 'revisao'
LET la_states[2].description = 'Revisão'
LET la_states[2].instruction = 'Revisar os dados do usuário'
LET la_states[2].deadline = 0
LET la_states[2].attribution = 2
LET la_states[2].codattribution = 'admlog' # Somente o Administrador poderá revisar e efetivar o cadastro.
LET la_states[3].name = 'efetivacao'
LET la_states[3].description = 'Efetivação'
LET la_states[3].instruction = 'Efetiva criação do usuário no ERP Logix'
LET la_states[3].deadline = 0
LET la_states[3].attribution = 0
LET la_states[3].codattribution = ''
# Define os eventos do processo.
LET la_events[1].name = 'afterProcessFinish'
LET la_events[1].code = log02700_get_wf_process_event(la_events[1].name)
# Cria o processo no ECM.
LET l_return = _ADVPL_WfProcess('LOG02700','Processo de manutenção de Usuários','Usuários',l_form_id,la_states,la_events)
IF l_return THEN
CALL LOG_message('Processo criado com sucesso!','INFO',NULL,NULL,0)
ELSE
CALL LOG_message(_ADVPL_WfGetError(1),'ERROR',_ADVPL_WfGetError(2),NULL,0)
END IF
RETURN l_return
END FUNCTION
#-----------------------------#
FUNCTION log02700_get_wf_html()
#-----------------------------#
DEFINE l_wf_html TEXT
LET l_wf_html = l_wf_html CLIPPED,'<div id="ALL" class="fw-box" style="height: 99%; width: 100%">'
LET l_wf_html = l_wf_html CLIPPED,' <div id="USUARIOS" class="fw-fields">'
LET l_wf_html = l_wf_html CLIPPED,' <fieldset>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Usuário:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="cod_usuario" class="fw-input-char" maxlength="8" size="8">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Nome:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="nom_funcionario" class="fw-input-char" maxlength="30" size="30" data="{picture:\'@!\'}">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </fieldset>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-folder" id="USUARIOS_FOLDER">'
LET l_wf_html = l_wf_html CLIPPED,' <ul>'
LET l_wf_html = l_wf_html CLIPPED,' <li><a href="#USUARIOS_1">Dados principais</a></li>'
LET l_wf_html = l_wf_html CLIPPED,' <li><a href="#USUARIOS_2">Dados complementares</a></li>'
LET l_wf_html = l_wf_html CLIPPED,' </ul>'
LET l_wf_html = l_wf_html CLIPPED,' <div id="USUARIOS_1" class="fw-sheet">'
LET l_wf_html = l_wf_html CLIPPED,' <div class="ui-widget-content ui-corner-all">'
LET l_wf_html = l_wf_html CLIPPED,' <fieldset>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Telefone:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="num_telefone" class="fw-input-char" maxlength="20" size="20" data="{picture:\'(99) 9999-9999\'}">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Ramal:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="num_ramal" class="fw-input-char" maxlength="5" size="5" data="{picture:\'99999\'}">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">E-mail:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="e_mail" class="fw-input-char" maxlength="35" size="35">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Empresa padrão:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="cod_empresa_padrao" class="fw-input-char" maxlength="02" size="02" data="{picture:\'@!\',zoom:{name:\'zoom_empresa\',selection:[[\'cod_empresa_padrao\',\'cod_empresa\']]}}">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Dispositivo padrão:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="cod_impress_padrao" class="fw-input-char" maxlength="10" size="10" data="{picture:\'@!\'}">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Idioma:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <select name="idioma" class="fw-input-select" value="1">'
LET l_wf_html = l_wf_html CLIPPED,' <option value="1">Português</option>'
LET l_wf_html = l_wf_html CLIPPED,' <option value="2">Inglês</option>'
LET l_wf_html = l_wf_html CLIPPED,' <option value="3">Espanhol</option>'
LET l_wf_html = l_wf_html CLIPPED,' </select>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">É administrador?</label>'
LET l_wf_html = l_wf_html CLIPPED,' <select name="ind_admlog" class="fw-input-select" value="N">'
LET l_wf_html = l_wf_html CLIPPED,' <option value="S">Sim</option>'
LET l_wf_html = l_wf_html CLIPPED,' <option value="N">Não</option>'
LET l_wf_html = l_wf_html CLIPPED,' </select>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Cria pesquisa relacional?</label>'
LET l_wf_html = l_wf_html CLIPPED,' <select name="mantem_pesq_relac" class="fw-input-select" value="N">'
LET l_wf_html = l_wf_html CLIPPED,' <option value="S">Sim</option>'
LET l_wf_html = l_wf_html CLIPPED,' <option value="N">Não</option>'
LET l_wf_html = l_wf_html CLIPPED,' </select>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </fieldset>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div id="USUARIOS_2" class="fw-sheet">'
LET l_wf_html = l_wf_html CLIPPED,' <div class="ui-widget-content ui-corner-all">'
LET l_wf_html = l_wf_html CLIPPED,' <fieldset>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Senha:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="password" name="senha" class="fw-input-char" maxlength="24" size="24">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Confirmação de senha:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="password" name="confirma_senha" class="fw-input-char" maxlength="24" size="24">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' <div class="fw-input">'
LET l_wf_html = l_wf_html CLIPPED,' <label class="fw-descr-top">Dica de senha:</label>'
LET l_wf_html = l_wf_html CLIPPED,' <input type="text" name="dica_senha" class="fw-input-char" maxlength="16" size="24">'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </fieldset>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,' </div>'
LET l_wf_html = l_wf_html CLIPPED,'</div>'
RETURN l_wf_html
END FUNCTION
#-----------------------------------------------#
FUNCTION log02700_get_wf_form_event(l_event_name)
#-----------------------------------------------#
DEFINE l_event_name CHAR(50)
DEFINE l_event_code TEXT
CASE l_event_name
WHEN "validateForm"
LET l_event_code = l_event_code CLIPPED,'function validateForm(form) {'
LET l_event_code = l_event_code CLIPPED,' var senha = form.getValue("senha"),'
LET l_event_code = l_event_code CLIPPED,' confirma_senha = form.getValue("confirma_senha");'
LET l_event_code = l_event_code CLIPPED,' if (senha != confirma_senha) {'
LET l_event_code = l_event_code CLIPPED,' throw "Senhas informadas não conferem.";'
LET l_event_code = l_event_code CLIPPED,' }'
LET l_event_code = l_event_code CLIPPED,'}'
END CASE
RETURN l_event_code
END FUNCTION
#--------------------------------------------------#
FUNCTION log02700_get_wf_process_event(l_event_name)
#--------------------------------------------------#
DEFINE l_event_name CHAR(50)
DEFINE l_event_code TEXT
CASE l_event_name
WHEN "afterProcessFinish"
LET l_event_code = l_event_code CLIPPED,'function afterProcessFinish(processId) {
LET l_event_code = l_event_code CLIPPED,' var values,result;'
LET l_event_code = l_event_code CLIPPED,' values = {'
LET l_event_code = l_event_code CLIPPED,' "usuarios" : {'
LET l_event_code = l_event_code CLIPPED,' "cod_usuario" : hAPI.getCardValue("cod_usuario"),'
LET l_event_code = l_event_code CLIPPED,' "nom_funcionario" : hAPI.getCardValue("nom_funcionario"),'
LET l_event_code = l_event_code CLIPPED,' "num_telefone" : hAPI.getCardValue("num_telefone"),'
LET l_event_code = l_event_code CLIPPED,' "num_ramal" : hAPI.getCardValue("num_ramal"),'
LET l_event_code = l_event_code CLIPPED,' "e_mail" : hAPI.getCardValue("e_mail"),'
LET l_event_code = l_event_code CLIPPED,' "cod_empresa_padrao" : hAPI.getCardValue("cod_empresa_padrao"),'
LET l_event_code = l_event_code CLIPPED,' "cod_impress_padrao" : hAPI.getCardValue("cod_impress_padrao"),'
LET l_event_code = l_event_code CLIPPED,' "ind_admlog" : hAPI.getCardValue("ind_admlog")'
LET l_event_code = l_event_code CLIPPED,' },'
LET l_event_code = l_event_code CLIPPED,' "log_usuarios_compl" : {'
LET l_event_code = l_event_code CLIPPED,' "idioma" : hAPI.getCardValue("idioma"),'
LET l_event_code = l_event_code CLIPPED,' "mantem_pesq_relac" : hAPI.getCardValue("mantem_pesq_relac")'
LET l_event_code = l_event_code CLIPPED,' },'
LET l_event_code = l_event_code CLIPPED,' "usuario_senha" : {'
LET l_event_code = l_event_code CLIPPED,' "senha" : hAPI.getCardValue("senha")'
LET l_event_code = l_event_code CLIPPED,' },'
LET l_event_code = l_event_code CLIPPED,' "log_usu_troca_sen" : {'
LET l_event_code = l_event_code CLIPPED,' "dica_senha" : hAPI.getCardValue("dica_senha")'
LET l_event_code = l_event_code CLIPPED,' }'
LET l_event_code = l_event_code CLIPPED,' };'
LET l_event_code = l_event_code CLIPPED,' result = callLogixFunction("log02700_create_usuario", values);'
LET l_event_code = l_event_code CLIPPED,' if (result) {'
LET l_event_code = l_event_code CLIPPED,' if (result.status) {'
LET l_event_code = l_event_code CLIPPED,' log.info("[LOGIX] " + result.msg);'
LET l_event_code = l_event_code CLIPPED,' } else {'
LET l_event_code = l_event_code CLIPPED,' log.error("[LOGIX] Nao foi possivel concluir a criacao do usuario ["+ result.msg + "]");'
LET l_event_code = l_event_code CLIPPED,' }'
LET l_event_code = l_event_code CLIPPED,' }'
LET l_event_code = l_event_code CLIPPED,'}'
END CASE
RETURN l_event_code
END FUNCTION |