#include "PROTHEUS.CH" #include "RWMAKE.CH" #include "APWEBEX.CH" #include "TOPCONN.CH" #include "TBICONN.CH" /*__________________________________________________________________________ ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ ¦¦+-----------------------------------------------------------------------+¦¦ ¦¦¦Funçäo ¦ Estoque ¦ Autor ¦ Lucilene Mendes ¦ Data ¦17.07.19 ¦¦¦ ¦¦+----------+------------------------------------------------------------¦¦¦ ¦¦¦Descriçäo ¦ Grid com o estoque de itens por tabela de preço. ¦¦¦ ¦¦+-----------------------------------------------------------------------+¦¦ ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/ User Function Estoque() Local cHtml Local cArmazem := "" //Local cVend := HttpSession->CodVend Local cTabela := "" Local cGrupoP := "" Local cTpCli := "" Local i := 0 Local cCliSel := "" Local cOport := "" Local cUfEntr := "" Local cUFFat := "" Local cMunEnt := "" Local cTipoProd := "" Local cGrupoProd:= "" Local nPrcVen := 0 Private oObjLog := nil Private aMunic := {} Private cColunas:= "" Private cItens := "" Private cTopo := "" Private cSite := "u_PortalLogin.apw" Private cPagina := "Consulta de Preço" Private cTitle := "" Private lTableTools:= .T. Private lSidebar:= .F. Private cCodLogin := "" Private cVendLogin:= "" Web Extended Init cHtml Start U_inSite() oObjLog:= LogSMS():new() oObjLog:setFileName("\temp\"+Procname()+"_"+dtos(date())+".txt") cVendLogin := u_GetUsrPR() cCodLogin := U_SetParPR(cVendLogin) If Empty(HttpSession->CodVend) cHtml:= '' Return cHtml Else If !Empty(HttpSession->Superv) .and. HttpSession->Superv <> HttpSession->CodVend HttpSession->CodVend:= HttpSession->Superv Endif Endif // Pega do parâmetro com o Titulo do Portal cTitle := SuperGetMV("PS_TITLE", .T., "Portal SMS") // Define a funcao a ser chama no link cSite := "u_SMSPortal.apw?PR="+cCodLogin // Monta o cabeçalho para a pagina cHeader := U_PSHeader(cTitle, cSite) //Função que atualiza os menus cMenus := U_GetMenus(AllTrim(Upper(Procname())), cVendLogin) //Armazéns considerados para busca do estoque //@Todo - Ainda precisa? cArmazem:= GetNewPar("PR_ARMZPR","'01'") //deve estar no formato '01','02' //Tipos de produto que devem ser exibidos na consulta cTipoProd:= GetNewPar("PR_TPPROD","PA|RE") //Grupos de produto que devem ser exibidos na consulta cGrupoProd:= GetNewPar("PR_GRPPROD","PE|PEL") If type("HttpPost->FILTROP") <> "U" if !empty(HttpPost->FILTROP) cTabela := Alltrim(HttpPost->FILTROP)//@Todo - Valor fixado em 001 //cGrupoP := HttpPost->GRUPOP cOport := Alltrim(HttpPost->OPORTUN) cUFEntr := Alltrim(HttpPost->EST_ENTRE) cUFFat := Alltrim(HttpPost->EST_FAT) cMunEnt := Alltrim(HttpPost->MUN_ENTRE) cTpCli := Alltrim(HttpPost->TPCLI) if !empty(Alltrim(HttpPost->CLIENTE)) cCliSel := Alltrim(HttpPost->CLIENTE) else cCliSel := RetCli(cUFFat,cTpCli)//Usuario não preencheu o campo do cliente endif endif endif cQuery := " Select A1_COD, A1_LOJA, A1_NOME,A1_TIPO,A1_EST,A1_MUN,A1_GRPTRIB" cQuery += " From "+RetSqlName("SA1")+" SA1 " cQuery += " Where A1_FILIAL = '"+xFilial("SA1")+"' " cQuery += " And A1_MSBLQL <> '1'" cQuery += " AND A1_VEND = '"+cVendLogin+"' " if !empty(cCliSel)//Ao entrar na rotina, não estava vindo nenhum cliente para seleção if !empty(Alltrim(HttpPost->CLIENTE)) cQuery += " AND A1_COD = '"+SubStr(cCliSel,1,len(cCliSel)-2)+"' " endif endif cQuery += " And SA1.D_E_L_E_T_ = ' ' " cQuery += " Order by A1_COD " If Select("QRY") > 0 QRY->(dbCloseArea()) Endif APWExOpenQuery(ChangeQuery(cQuery),"QRY",.T.) //Query das oportunidades cQuery := " Select AD1_NROPOR,AD1_REVISA, AD1_DESCRI, AD1_DESCCI, AD1_NOMPAR" cQuery += " From "+RetSqlName("AD1")+" AD1 " cQuery += " Where AD1_FILIAL = '"+xFilial("AD1")+"' " cQuery += " And AD1_HOMOLO = '3' " //Status homologação = homologado cQuery += " And AD1.D_E_L_E_T_ = ' ' " cQuery += " Order by AD1_NROPOR " If Select("QRYAD1") > 0 QRYAD1->(dbCloseArea()) Endif APWExOpenQuery(ChangeQuery(cQuery),"QRYAD1",.T.) //Query dos grupos de produtos /*cQuery := " Select BM_GRUPO,BM_DESC" cQuery += " From "+RetSqlName("SBM")+" SBM " cQuery += " Where BM_FILIAL = '"+xFilial("SBM")+"' " cQuery += " And BM_GRUPO NOT IN ('PE') AND BM_MSBLQL <> '1' AND SBM.D_E_L_E_T_ = ' ' " cQuery += " Order by BM_GRUPO " If Select("QRYSBM") > 0 QRYSBM->(dbCloseArea()) Endif APWExOpenQuery(ChangeQuery(cQuery),"QRYSBM",.T.) */ aTpCli := {{"F","Cons. Final"},{"L","Prod. Rural"},{"R","Revendedor"},{"S","Solidario"},{"X","Exportacao"}} aEstados := {"AC","AL","AM","AP","BA","CE","DF","ES","EX","GO","MA","MG","MS","MT","PA","PB","PI","PR","RJ","RN","RO","RR","RS","SC","SE","SP","TO"} aMunicipio := {} cTopo := '