123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- #include "PROTHEUS.CH"
- #include "RWMAKE.CH"
- #include "APWEBEX.CH"
- #include "TOPCONN.CH"
- #include "TBICONN.CH"
- #DEFINE SMSDEBUG
- /*__________________________________________________________________________
- ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
- ¦¦+-----------------------------------------------------------------------+¦¦
- ¦¦¦Funçäo ¦ ViewPed ¦ Autor ¦ Lucilene Mendes ¦ Data ¦02.05.24 ¦¦¦
- ¦¦+----------+------------------------------------------------------------¦¦¦
- ¦¦¦Descriçäo ¦ Visualização dos pedidos. ¦¦¦
- ¦¦+-----------------------------------------------------------------------+¦¦
- ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
- ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/
- User Function ViewPed()
- Local cHtml
- Local cItem := ""
- Local nLin := 0
- Local nPosFrete:= 0
- Local lMoeda := .F.
- Local lNumber := .F.
- Local aTpFrete := {}
- Private cDirPortal := ""
- Private cEndServ := "" // Endereço do servidor da pagina de Portal
- Private cPVCabec := ""
- Private cPVItens := ""
- Private cNFSerie := ""
- Private cBotoes := ""
- Private cTpFrete := ""
- Private cValFre := ""
- Private cTransp := ""
- Private cCliente := ""
- Private cEntrega := ""
- Private cBtnItens := ""
- Private cObsNota := ""
- Private cChaveNF := ""
- Private cEmissao := ""
- Private nTVlrUnit := 0
- Private nTTotal := 0
- Private nTImpostos := 0
- Private nTFrete := 0
- Private nItens := 0
-
- Private cSite := "u_PortalLogin.apw"
- Private cPagina := "Pedido"
- Private cMenus := ""
- Private cFooter := ""
- Private cTitle := ""
- Private cAnexos := ""
- Private aItens := {}
- Private cCodLogin := ""
- Private cLoginGet := ""
-
- Web Extended Init cHtml Start U_inSite(empty(cLoginGet))
-
- cVendLogin := u_GetUsrPR()
- cCodLogin := U_SetParPR(cVendLogin)
- If Empty(HttpSession->CodVend)
- cHtml:= '<META HTTP-EQUIV="Refresh" CONTENT="0 ; URL='+cSite+'">'
- 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())), cLoginGet)
-
- //Função que retorna o rodapé da página
- // cFooter:= U_GetFooter()
-
- //Atualiza as variáveis
- cEndServ := GetMv('MV_WFBRWSR')
- cItem := StrZero(1,TamSX3("C6_ITEM")[1])
- nRecSC5 := val(HttpGet->rec)
-
-
- //Posiciona no Pedido
- If !Empty(nRecSC5)
- dbSelectArea("SC5")
- SC5->(dbGoTo(nRecSC5))
-
- //Troca de filial
- u_PTChgFil(SC5->C5_FILIAL)
-
- dbSelectArea("SC5")
- SC5->(dbGoTo(nRecSC5))
-
- dbSelectArea("SC6")
- SC6->(dbSeek(xFilial("SC6")+SC5->C5_NUM))
- Endif
-
- cPVSerie:= SC5->C5_NUM
- //cChaveNF:= SC5->C5_CHVNFE
- cEmissao:= dtoc(SC5->C5_EMISSAO)
-
- //Observações do orçamento
- cObsNota:= SC5->C5_MENNOTA
-
- /*
- aItens - array que define o cabeçalho da tabela de produtos
- [1] - Nome da coluna
- [2] - Nome do campo
- [3] - Tamanho
- [4] - Alinhamento
- [5] - Tipo
- [6] - Editável
- [7] - Obrigatório
- [8] - Moeda
- [9] - Placeholder
- */
- aItens := { {"Produto","C6_PRODUTO","500px","left","C",.F.,.T.,.F.,"Selecione..."},;
- {"UM","C6_UM","*","right","C",.F.,.F.,.F.,""},;
- {"Quantidade","C6_QTDVEN","*","right","N",.F.,.T.,.F.,"0"},;
- {"Previsão Entrega","C6_ENTREG","*","left","C",.F.,.F.,.F.,""},;
- {"V.Unitário","C6_PRCVEN","*","","N",.F.,.F.,.T.,"0,00000"},; // {"IPI","C6_VALIPI","*","right","N",.F.,.F.,.T.,"0,00"},; // {"ICMS","C6_VALICM","*","right","N",.F.,.F.,.T.,"0,00"},; // {"ICMS ST","C6_ICMSRET","*","right","N",.F.,.F.,.T.,"0,00"},;
- {"Total","C6_VALOR","*","right","N",.F.,.F.,.T.,"0,00"}}
-
-
- // Cria o cabeçalho dos Itens
- For nLin := 1 to Len(aItens)
- cPVCabec += '<th'+Iif(aItens[nLin,2] == "C6_PRODUTO",' width="'+aItens[nLin,3]+'"','')+'>'+aItens[nLin][1]+'</th>'
- Next
-
- //Tipo de frete
- aTpFrete:= {{"S","Sem Frete"},{"C","CIF"},{"F","FOB"}}
- cTpFrete:='<select class="form-control mb-md" name="C5_TPFRETE" id="C5_TPFRETE" value="'+SC5->C5_TPFRETE+'" disabled>'
- nPosFrete:= aScan(aTpFrete,{|x|x[1]==SC5->C5_TPFRETE})
- If nPosFrete = 0
- nPosFrete:= 1
- Endif
- cTpFrete+=' <option value="'+SC5->C5_TPFRETE+'">'+aTpFrete[nPosFrete,2]+'</option>'
-
- cTpFrete+='</select>'
-
- cValFre:= Transform(SC5->C5_FRETE,"@E 999,999,999.99")
-
-
- //Transportadora
- cTransp:= SC5->C5_TRANSP+' - '+Alltrim(Posicione("SA4",1,xFilial("SA4")+SC5->C5_TRANSP,"A4_NREDUZ"))
-
- //Condição de Pagamento
- cCondPag:='<select class="form-control mb-md" name="C5_COND" id="C5_COND" required="" aria-required="true" disabled>'
- cCondPag+=' <option value="'+SC5->C5_CONDPAG+'">'+SC5->C5_CONDPAG+" - "+Posicione("SE4",1,xFilial("SE4")+SC5->C5_CONDPAG,"E4_DESCRI")+'</option>'
- cCondPag+='</select>'
-
- //Cliente
- cCliente:='<select data-plugin-selectTwo class="form-control populate placeholder" data-plugin-options='+"'"
- cCliente+='{ "placeholder": "Selecione um Cliente", "allowClear": false }'+"'"+' name="C5_CLIENTE" id="C5_CLIENTE" '
- cCliente+=' disabled >'
- cCliente+=' <option value='+SC5->C5_CLIENTE+SC5->C5_LOJACLI+'>'+SC5->C5_CLIENTE+'/'+SC5->C5_LOJACLI+' - '+Alltrim(Posicione("SA1",1,xFilial("SA1")+SC5->C5_CLIENTE+SC5->C5_LOJACLI,"A1_NOME"))+'</option>'
- cCliente+='</select>'
-
- //Data Prevista de Entrega
- /*
- nDiasEnt:= GetNewPar("AE_DTENT",10)
- cEntrega:='<input type="text" id="CK_ENTREG" name="CK_ENTREG" data-plugin-datepicker data-plugin-options='+"'"+'{ "startDate": "+'+nDiasEnt+'d", "language": "pt-BR",'
- cEntrega+='"daysOfWeekDisabled": "[0]","daysOfWeekHighlighted":"[0]"}'+"'"+' class="form-control only-numbers" placeholder="__/__/____"'
- cEntrega+='value='+DTOC(SCK->CK_ENTREG)
- cEntrega+=Iif(!lEdit,' disabled','')+'>'
- */
- //Preenchimento dos itens
- nTFrete:= SC5->C5_FRETE
- nTTotal:= SC5->C5_FRETE
- dbSelectArea("SC6")
- SC6->(dbSetOrder(1))
- SC6->(dbSeek(xFilial("SC6")+SC5->C5_NUM))
- While SC6->(!Eof()) .and. SC6->C6_NUM = SC5->C5_NUM .AND. SC6->C6_SERIE = SC5->C5_SERIE
- nItens++
- Posicione("SB1",1,xFilial("SB1")+SC6->C6_PRODUTO,"B1_DESC")
- cPVItens += '<tr class="odd" id="linha'+StrZero(nItens,2)+'">'
-
- //nTImpostos += SC6->(C6_ICMSRET+C6_VALIPI) //C6_VALICM+
- nTVlrUnit += SC6->C6_QTDVEN * SC6->C6_PRCVEN
- nTTotal+= SC6->C6_VALOR
- For nLin := 1 to Len(aItens)
-
- cPVItens += '<td'+Iif(!Empty(aItens[nLin][4]),' align="'+aItens[nLin][4]+'"',"")+'>'
-
- lMoeda:= aItens[nLin,8] //Indica se é Moeda
- lNumber:= aItens[nLin,5] = "N" //Indica que é numérico
- xValue:= ""
- Do Case
- Case aItens[nLin][5] == 'C'
- If aItens[nLin,2] == "C6_PRODUTO"
- xValue := AllTrim(SC6->&(aItens[nLin][2]))+" - "+Alltrim(SB1->B1_DESC)
- Elseif aItens[nLin,2] == "C6_ENTREG"
- xValue := dtoc(SC6->&(aItens[nLin][2]))
- Else
- xValue := AllTrim(SC6->&(aItens[nLin][2]))
- Endif
- Case aItens[nLin][5] == 'N'
- If aItens[nLin,2] == "C6_QTDVEN"
- xValue := Alltrim(PadR(TransForm(SC6->&(aItens[nLin][2]),"@E 999,999,999"),14))
- Else
- xValue := Alltrim(PadR(TransForm(SC6->&(aItens[nLin][2]),"@E 999,999,999.99"),14))
- Endif
- EndCase
-
- cPVItens += '<input id="'+aItens[nLin][2]+cItem+'" data-prop="'+aItens[nLin][2]+'" name="'+aItens[nLin][2]+cItem+'" class="form-control input-block" type="text" disabled width="" '
- cPVItens += 'value="'+Alltrim(xValue)+'" title="'+Alltrim(xValue)+'">'
- cPVItens += '</td>'
- Next
-
- cPVItens += '</tr>'
- SC6->(dbSkip())
- End
-
- //Adiciona os botões da página
- cBotoes+='<input class="btn btn-primary" type="button" id="btVoltar" name="btVoltar" value="Voltar" onclick="javascript: location.href='+"'"+'u_pedidos.apw?PR='+cCodLogin+"';"+'"/>'+chr(13)+chr(10)
-
- //Retorna o HTML para construção da página
- cHtml := H_ViewPed()
-
- Web Extended End
- Return (cHTML)
|