#INCLUDE "protheus.ch"
#INCLUDE "FWMVCDEF.CH"
User Function AT870NWMNU()
Local aMenu := {}
Local nC := 0
Local aRetMenu := {}
Local nTam := 0
//Tratamento do parâmetro de entrada
If ValType(PARAMIXB) == "A"
nTam := Len(PARAMIXB)
For nC := 1 to nTam
aAdd(aRetMenu, aClone(PARAMIXB[nC]))
Next nC
//Pode adicionar novos menus, substituindo o Ponto de Entrada AT870MNU,
//neste caso somente adiciona uma posição no array com valor 2 que se refere ao parameto nRealOpc do método AddButton do compomente FWFormBrowse
aAdd( aRetMenu, {"Ajusta Agenda", { || FwMsgRun(Nil,{|| ABBIDCFAL()}, Nil, "Ajustando..")} , 2} )
EndIf
Return aRetMenu
//------------------------------------------------------------------------------
/*/{Protheus.doc} ABBIDCFAL
Ajuste na Tabela ABB caso o contrato tenha espaços em branco
@Return Sem Retorno
@since 18/05/2021
@author Augusto Albuquerque
@version P12
/*/
//------------------------------------------------------------------------------
Static Function ABBIDCFAL()
Local aItem := {}
Local cNewValor := ""
Local cAliasABB := GetNextAlias()
Local nTamABB := TamSX3("ABB_IDCFAL")[1]
Local nTotal := 0
Local nAlter := 0
Local nMeter
Local oDlg
Local oMeter
Local oSayMtr
Local cLen := ""
If TcGetDb() $ "ORACLE,POSTGRES,DB2,INFORMIX,MSSQL"
cLen := IIF(Trim(Upper(TcGetDb())) $ "ORACLE,POSTGRES,DB2,INFORMIX","LENGTH","LEN") + "(ABB_IDCFAL) != " + Str(nTamABB)
cLen := "%"+cLen+"%"
If TamSX3("ABQ_ITEM")[1] > 2 .AND. TamSX3("ABB_IDCFAL")[1] > 20
Begin Transaction
BeginSql alias cAliasABB
SELECT ABB.R_E_C_N_O_ RECNO, ABB.ABB_IDCFAL FROM %table:ABB% ABB
WHERE ABB.ABB_IDCFAL IN (
SELECT RTRIM(LTRIM(ABQ.ABQ_CONTRT + ABQ.ABQ_ITEM + ABQ.ABQ_ORIGEM)) FROM %table:ABQ% ABQ
WHERE ABQ.ABQ_CONTRT LIKE ' %' AND ABQ.%NotDel%)
AND ABB.%NotDel%
EndSql
nTamABB := 0
(cAliasABB)->(dbEval({||nTotal++}))
(cAliasABB)->(DbGoTop())
If !(cAliasABB)->(Eof())
If IsBlind()
ABBProces( cAliasABB )
Else
DEFINE MSDIALOG oDlg FROM 0,0 TO 5,60 TITLE "Configurando o Gestão de Serviços" // "Configurando o Gestão de Serviços"
nMeter := 0
oSayMtr := tSay():New(10,10,{||"Essa operação pode demorar varios minutos..."},oDlg,,,,,,.T.,,,220,20) // "Essa operação pode demorar varios minutos..."
oMeter := tMeter():New(20,10,{|u|if(Pcount()>0,nMeter:=u,nMeter)},nTotal,oDlg,220,10,,.T.) // cria a régua
ACTIVATE MSDIALOG oDlg CENTERED ON INIT ( nAlter := ABBProces( cAliasABB, oDlg, oMeter, oSayMtr, nTotal ) )
EndIf
EndIf
End Transaction
EndIf
EndIf
Return
//------------------------------------------------------------------------------
/*/{Protheus.doc} ABBProces
Quebra para exibir quantidade na tela.
@Return nAlter - numero de registros alterados.
@since 28/11/2019
@author Augusto Albuquerque
@version P12
/*/
//------------------------------------------------------------------------------
Static Function ABBProces( cAliasABB, oDlg, oMeter, oSayMtr, nTotal )
Local cAliasABQ := ""
Local cIdcFal := ""
Local cIdcFalAnt:= ""
Local nReg := 0
Local nAlter := 0
Local nTamABB := 0
Default oDlg := Nil
Default oMeter := Nil
Default oSayMtr := Nil
Default nTotal := 0
While !(cAliasABB)->(Eof())
If cIdcFalAnt <> (cAliasABB)->ABB_IDCFAL
cIdcFalAnt := (cAliasABB)->ABB_IDCFAL
cAliasABQ := GetNextAlias()
BeginSql alias cAliasABQ
SELECT ABQ.ABQ_ITEM, ABQ.ABQ_CONTRT, ABQ.ABQ_ORIGEM
FROM %table:ABQ% ABQ
WHERE ABQ.%NotDel%
AND RTRIM(LTRIM(ABQ.ABQ_CONTRT + ABQ.ABQ_ITEM + ABQ.ABQ_ORIGEM)) = %exp:(cAliasABB)->ABB_IDCFAL%
ORDER BY ABQ.ABQ_CONTRT, ABQ.ABQ_ITEM, ABQ.ABQ_ORIGEM
EndSql
If !(cAliasABQ)->(Eof())
cIdcFal := (cAliasABQ)->ABQ_CONTRT + (cAliasABQ)->ABQ_ITEM + (cAliasABQ)->ABQ_ORIGEM
EndIf
(cAliasABQ)->(dbCloseArea())
EndIf
If !Empty(cIdcFal) .AND. cIdcFalAnt <> cIdcFal
DBSelectArea("ABB")
ABB->(DBGoTo((cAliasABB)->RECNO))
RecLock("ABB", .F.)
ABB->ABB_IDCFAL := cIdcFal
ABB->(MsUnLock())
nAlter++
EndIf
If !IsBlind()
oMeter:Set(++nReg)
oSayMtr:SetText("Processando: " + cValToChar(nReg) + " de " + cValToChar(nTotal)) // "Processando: " ## " de "
oMeter:Refresh()
oSayMtr:CtrlRefresh()
SysRefresh()
EndIf
(cAliasABB)->(dBSkip())
EndDo
If !IsBlind()
oDlg:End()
EndIf
(cAliasABB)->(dbCloseArea())
Return nAlter