ViewPed.apl 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #include "PROTHEUS.CH"
  2. #include "RWMAKE.CH"
  3. #include "APWEBEX.CH"
  4. #include "TOPCONN.CH"
  5. #include "TBICONN.CH"
  6. #DEFINE SMSDEBUG
  7. /*__________________________________________________________________________
  8. ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  9. ¦¦+-----------------------------------------------------------------------+¦¦
  10. ¦¦¦Funçäo ¦ ViewPed ¦ Autor ¦ Lucilene Mendes ¦ Data ¦02.05.24 ¦¦¦
  11. ¦¦+----------+------------------------------------------------------------¦¦¦
  12. ¦¦¦Descriçäo ¦ Visualização dos pedidos. ¦¦¦
  13. ¦¦+-----------------------------------------------------------------------+¦¦
  14. ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  15. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/
  16. User Function ViewPed()
  17. Local cHtml
  18. Local cItem := ""
  19. Local nLin := 0
  20. Local nPosFrete:= 0
  21. Local lMoeda := .F.
  22. Local lNumber := .F.
  23. Local aTpFrete := {}
  24. Private cDirPortal := ""
  25. Private cEndServ := "" // Endereço do servidor da pagina de Portal
  26. Private cPVCabec := ""
  27. Private cPVItens := ""
  28. Private cNFSerie := ""
  29. Private cBotoes := ""
  30. Private cTpFrete := ""
  31. Private cValFre := ""
  32. Private cTransp := ""
  33. Private cCliente := ""
  34. Private cEntrega := ""
  35. Private cBtnItens := ""
  36. Private cObsNota := ""
  37. Private cChaveNF := ""
  38. Private cEmissao := ""
  39. Private nTVlrUnit := 0
  40. Private nTTotal := 0
  41. Private nTImpostos := 0
  42. Private nTFrete := 0
  43. Private nItens := 0
  44. Private cSite := "u_PortalLogin.apw"
  45. Private cPagina := "Pedido"
  46. Private cMenus := ""
  47. Private cFooter := ""
  48. Private cTitle := ""
  49. Private cAnexos := ""
  50. Private aItens := {}
  51. Private cCodLogin := ""
  52. Private cLoginGet := ""
  53. Web Extended Init cHtml Start U_inSite(empty(cLoginGet))
  54. cVendLogin := u_GetUsrPR()
  55. cCodLogin := U_SetParPR(cVendLogin)
  56. If Empty(HttpSession->CodVend)
  57. cHtml:= '<META HTTP-EQUIV="Refresh" CONTENT="0 ; URL='+cSite+'">'
  58. Return cHtml
  59. Else
  60. If !Empty(HttpSession->Superv) .and. HttpSession->Superv <> HttpSession->CodVend
  61. HttpSession->CodVend:= HttpSession->Superv
  62. Endif
  63. Endif
  64. // Pega do parâmetro com o Titulo do Portal
  65. cTitle := SuperGetMV("PS_TITLE", .T., "Portal SMS")
  66. // Define a funcao a ser chama no link
  67. cSite := "u_SMSPortal.apw?PR="+cCodLogin
  68. // Monta o cabeçalho para a pagina
  69. cHeader := U_PSHeader(cTitle, cSite)
  70. //Função que atualiza os menus
  71. cMenus := U_GetMenus(AllTrim(Upper(Procname())), cLoginGet)
  72. //Função que retorna o rodapé da página
  73. // cFooter:= U_GetFooter()
  74. //Atualiza as variáveis
  75. cEndServ := GetMv('MV_WFBRWSR')
  76. cItem := StrZero(1,TamSX3("C6_ITEM")[1])
  77. nRecSC5 := val(HttpGet->rec)
  78. //Posiciona no Pedido
  79. If !Empty(nRecSC5)
  80. dbSelectArea("SC5")
  81. SC5->(dbGoTo(nRecSC5))
  82. //Troca de filial
  83. u_PTChgFil(SC5->C5_FILIAL)
  84. dbSelectArea("SC5")
  85. SC5->(dbGoTo(nRecSC5))
  86. dbSelectArea("SC6")
  87. SC6->(dbSeek(xFilial("SC6")+SC5->C5_NUM))
  88. Endif
  89. cPVSerie:= SC5->C5_NUM
  90. //cChaveNF:= SC5->C5_CHVNFE
  91. cEmissao:= dtoc(SC5->C5_EMISSAO)
  92. //Observações do orçamento
  93. cObsNota:= SC5->C5_MENNOTA
  94. /*
  95. aItens - array que define o cabeçalho da tabela de produtos
  96. [1] - Nome da coluna
  97. [2] - Nome do campo
  98. [3] - Tamanho
  99. [4] - Alinhamento
  100. [5] - Tipo
  101. [6] - Editável
  102. [7] - Obrigatório
  103. [8] - Moeda
  104. [9] - Placeholder
  105. */
  106. aItens := { {"Produto","C6_PRODUTO","500px","left","C",.F.,.T.,.F.,"Selecione..."},;
  107. {"UM","C6_UM","*","right","C",.F.,.F.,.F.,""},;
  108. {"Quantidade","C6_QTDVEN","*","right","N",.F.,.T.,.F.,"0"},;
  109. {"Previsão Entrega","C6_ENTREG","*","left","C",.F.,.F.,.F.,""},;
  110. {"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"},;
  111. {"Total","C6_VALOR","*","right","N",.F.,.F.,.T.,"0,00"}}
  112. // Cria o cabeçalho dos Itens
  113. For nLin := 1 to Len(aItens)
  114. cPVCabec += '<th'+Iif(aItens[nLin,2] == "C6_PRODUTO",' width="'+aItens[nLin,3]+'"','')+'>'+aItens[nLin][1]+'</th>'
  115. Next
  116. //Tipo de frete
  117. aTpFrete:= {{"S","Sem Frete"},{"C","CIF"},{"F","FOB"}}
  118. cTpFrete:='<select class="form-control mb-md" name="C5_TPFRETE" id="C5_TPFRETE" value="'+SC5->C5_TPFRETE+'" disabled>'
  119. nPosFrete:= aScan(aTpFrete,{|x|x[1]==SC5->C5_TPFRETE})
  120. If nPosFrete = 0
  121. nPosFrete:= 1
  122. Endif
  123. cTpFrete+=' <option value="'+SC5->C5_TPFRETE+'">'+aTpFrete[nPosFrete,2]+'</option>'
  124. cTpFrete+='</select>'
  125. cValFre:= Transform(SC5->C5_FRETE,"@E 999,999,999.99")
  126. //Transportadora
  127. cTransp:= SC5->C5_TRANSP+' - '+Alltrim(Posicione("SA4",1,xFilial("SA4")+SC5->C5_TRANSP,"A4_NREDUZ"))
  128. //Condição de Pagamento
  129. cCondPag:='<select class="form-control mb-md" name="C5_COND" id="C5_COND" required="" aria-required="true" disabled>'
  130. cCondPag+=' <option value="'+SC5->C5_CONDPAG+'">'+SC5->C5_CONDPAG+" - "+Posicione("SE4",1,xFilial("SE4")+SC5->C5_CONDPAG,"E4_DESCRI")+'</option>'
  131. cCondPag+='</select>'
  132. //Cliente
  133. cCliente:='<select data-plugin-selectTwo class="form-control populate placeholder" data-plugin-options='+"'"
  134. cCliente+='{ "placeholder": "Selecione um Cliente", "allowClear": false }'+"'"+' name="C5_CLIENTE" id="C5_CLIENTE" '
  135. cCliente+=' disabled >'
  136. 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>'
  137. cCliente+='</select>'
  138. //Data Prevista de Entrega
  139. /*
  140. nDiasEnt:= GetNewPar("AE_DTENT",10)
  141. cEntrega:='<input type="text" id="CK_ENTREG" name="CK_ENTREG" data-plugin-datepicker data-plugin-options='+"'"+'{ "startDate": "+'+nDiasEnt+'d", "language": "pt-BR",'
  142. cEntrega+='"daysOfWeekDisabled": "[0]","daysOfWeekHighlighted":"[0]"}'+"'"+' class="form-control only-numbers" placeholder="__/__/____"'
  143. cEntrega+='value='+DTOC(SCK->CK_ENTREG)
  144. cEntrega+=Iif(!lEdit,' disabled','')+'>'
  145. */
  146. //Preenchimento dos itens
  147. nTFrete:= SC5->C5_FRETE
  148. nTTotal:= SC5->C5_FRETE
  149. dbSelectArea("SC6")
  150. SC6->(dbSetOrder(1))
  151. SC6->(dbSeek(xFilial("SC6")+SC5->C5_NUM))
  152. While SC6->(!Eof()) .and. SC6->C6_NUM = SC5->C5_NUM .AND. SC6->C6_SERIE = SC5->C5_SERIE
  153. nItens++
  154. Posicione("SB1",1,xFilial("SB1")+SC6->C6_PRODUTO,"B1_DESC")
  155. cPVItens += '<tr class="odd" id="linha'+StrZero(nItens,2)+'">'
  156. //nTImpostos += SC6->(C6_ICMSRET+C6_VALIPI) //C6_VALICM+
  157. nTVlrUnit += SC6->C6_QTDVEN * SC6->C6_PRCVEN
  158. nTTotal+= SC6->C6_VALOR
  159. For nLin := 1 to Len(aItens)
  160. cPVItens += '<td'+Iif(!Empty(aItens[nLin][4]),' align="'+aItens[nLin][4]+'"',"")+'>'
  161. lMoeda:= aItens[nLin,8] //Indica se é Moeda
  162. lNumber:= aItens[nLin,5] = "N" //Indica que é numérico
  163. xValue:= ""
  164. Do Case
  165. Case aItens[nLin][5] == 'C'
  166. If aItens[nLin,2] == "C6_PRODUTO"
  167. xValue := AllTrim(SC6->&(aItens[nLin][2]))+" - "+Alltrim(SB1->B1_DESC)
  168. Elseif aItens[nLin,2] == "C6_ENTREG"
  169. xValue := dtoc(SC6->&(aItens[nLin][2]))
  170. Else
  171. xValue := AllTrim(SC6->&(aItens[nLin][2]))
  172. Endif
  173. Case aItens[nLin][5] == 'N'
  174. If aItens[nLin,2] == "C6_QTDVEN"
  175. xValue := Alltrim(PadR(TransForm(SC6->&(aItens[nLin][2]),"@E 999,999,999"),14))
  176. Else
  177. xValue := Alltrim(PadR(TransForm(SC6->&(aItens[nLin][2]),"@E 999,999,999.99"),14))
  178. Endif
  179. EndCase
  180. 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="" '
  181. cPVItens += 'value="'+Alltrim(xValue)+'" title="'+Alltrim(xValue)+'">'
  182. cPVItens += '</td>'
  183. Next
  184. cPVItens += '</tr>'
  185. SC6->(dbSkip())
  186. End
  187. //Adiciona os botões da página
  188. 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)
  189. //Retorna o HTML para construção da página
  190. cHtml := H_ViewPed()
  191. Web Extended End
  192. Return (cHTML)