PortalSMS.apl 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #include "PROTHEUS.CH"
  2. #include "RWMAKE.CH"
  3. #include "APWEBEX.CH"
  4. #include "TOPCONN.CH"
  5. #include "TBICONN.CH"
  6. /*
  7. +----------------------------------------------------------------------------+
  8. ! FICHA TECNICA DO PROGRAMA !
  9. +----------------------------------------------------------------------------+
  10. ! DADOS DO PROGRAMA !
  11. +------------------+---------------------------------------------------------+
  12. !Tipo ! Portal SMS !
  13. +------------------+-------qtv--------------------------------------------------+
  14. !Modulo ! PortalSMS !
  15. +------------------+---------------------------------------------------------+
  16. !Nome ! PortalSMS !
  17. +------------------+---------------------------------------------------------+
  18. !Descricao ! Portal SMS !
  19. +------------------+---------------------------------------------------------+
  20. !Autor ! Anderson José Zelenski !
  21. +------------------+---------------------------------------------------------+
  22. !Data de Criacao ! 19/09/2013 !
  23. +----------------------------------------------------------------------------+
  24. */
  25. User Function PortalSMS()
  26. Local cHtml
  27. Local aMenu
  28. Private cJS
  29. Web Extended Init cHtml Start U_inSite()
  30. if Empty(AllTrim(HttpSession->Nome))
  31. cHtml := U_PortalLogin()
  32. else
  33. aMenu := {'clientes','fornecedores','funcionarios','compras','vendas','estoque','financeiro','rh'}
  34. // Localiza os modulos disponível para adicionar os arquivos JavaScript
  35. cQuery := "SELECT ZM0_NOME, ZM0_MENU "
  36. cQuery += " FROM ZM0990 ZM0 " //"+RetSqlName("ZM0")+"
  37. cQuery += " INNER JOIN ZM2990 ZM2 ON " //"+RetSqlName("ZM2")+"
  38. If !Empty(AllTrim(xFilial("ZM2"))) .And. !Empty(AllTrim(xFilial("ZM0")))
  39. cQuery += " ZM2_FILIAL = ZM0_FILIAL "
  40. Else
  41. cQuery += " ZM2_FILIAL = '"+xFilial("ZM2")+"' "
  42. EndIf
  43. cQuery += " AND ZM0_CODIGO = ZM2_MODULO AND ZM2.D_E_L_E_T_ = ' ' "
  44. cQuery += " WHERE ZM0_FILIAL = '"+xFilial("ZM0")+"'"
  45. cQuery += " AND ZM2.ZM2_USER = '"+HttpSession->UserId+"'"
  46. cQuery += " AND ZM0.D_E_L_E_T_ = ' '"
  47. cQuery += "ORDER BY ZM0_MENU"
  48. APWExOpenQuery(ChangeQuery(cQuery),'QRY',.T.)
  49. cJS := ""
  50. While !QRY->(EOF())
  51. cJS += '<script type="text/javascript" src="'+AllTrim(aMenu[val(QRY->ZM0_MENU)])+'/'+AllTrim(QRY->ZM0_NOME)+'/js/'+AllTrim(QRY->ZM0_NOME)+'.js"></script>'
  52. DbSkip()
  53. EndDo
  54. APWExCloseQuery('QRY')
  55. cHtml := H_PortalSMS()
  56. EndIf
  57. Web Extended end
  58. return (cHTML)
  59. /*
  60. +----------------------------------------------------------------------------+
  61. ! FICHA TECNICA DO PROGRAMA !
  62. +----------------------------------------------------------------------------+
  63. ! DADOS DO PROGRAMA !
  64. +------------------+---------------------------------------------------------+
  65. !Tipo ! Portal SMS !
  66. +------------------+---------------------------------------------------------+
  67. !Modulo ! PortalSMS !
  68. +------------------+---------------------------------------------------------+
  69. !Nome ! PSLogado !
  70. +------------------+---------------------------------------------------------+
  71. !Descricao ! Retorna o ID do usuario logado !
  72. +------------------+---------------------------------------------------------+
  73. !Autor ! Anderson José Zelenski !
  74. +------------------+---------------------------------------------------------+
  75. !Data de Criacao ! 29/09/2013 !
  76. +----------------------------------------------------------------------------+
  77. */
  78. User Function PSLogado()
  79. Local cHtml
  80. Private cReturn
  81. Web Extended Init cHtml Start U_inSite()
  82. cReturn := AllTrim(HttpSession->UserId)
  83. cHtml := H_PSReturn()
  84. Web Extended end
  85. return (cHTML)
  86. /*
  87. +----------------------------------------------------------------------------+
  88. ! FICHA TECNICA DO PROGRAMA !
  89. +----------------------------------------------------------------------------+
  90. ! DADOS DO PROGRAMA !
  91. +------------------+---------------------------------------------------------+
  92. !Tipo ! Portal SMS !
  93. +------------------+---------------------------------------------------------+
  94. !Modulo ! PortalSMS !
  95. +------------------+---------------------------------------------------------+
  96. !Nome ! PSSCRKey !
  97. +------------------+---------------------------------------------------------+
  98. !Descricao ! Retorna a chave da aprovação !
  99. +------------------+---------------------------------------------------------+
  100. !Autor ! Anderson José Zelenski !
  101. +------------------+---------------------------------------------------------+
  102. !Data de Criacao ! 02/10/2013 !
  103. +----------------------------------------------------------------------------+
  104. */
  105. User Function PSSCRKey()
  106. Local cHtml
  107. Private cReturn
  108. Web Extended Init cHtml
  109. if ValType(HttpSession->SCRKey) <> "U"
  110. cReturn := AllTrim(HttpSession->SCRKey)
  111. Else
  112. cReturn := ""
  113. End
  114. cHtml := H_PSReturn()
  115. Web Extended end
  116. return (cHTML)
  117. /*
  118. +----------------------------------------------------------------------------+
  119. ! FICHA TECNICA DO PROGRAMA !
  120. +----------------------------------------------------------------------------+
  121. ! DADOS DO PROGRAMA !
  122. +------------------+---------------------------------------------------------+
  123. !Tipo ! Portal SMS !
  124. +------------------+---------------------------------------------------------+
  125. !Modulo ! PortalSMS !
  126. +------------------+---------------------------------------------------------+
  127. !Nome ! PSSCRTip !
  128. +------------------+---------------------------------------------------------+
  129. !Descricao ! Verifica se existe a chave e retorna o tipo !
  130. +------------------+---------------------------------------------------------+
  131. !Autor ! Anderson José Zelenski !
  132. +------------------+---------------------------------------------------------+
  133. !Data de Criacao ! 02/10/2013 !
  134. +----------------------------------------------------------------------------+
  135. */
  136. User Function PSSCRTip()
  137. Local cHtml
  138. Private cReturn
  139. Web Extended Init cHtml
  140. if ValType(HttpSession->SCRKey) <> "U"
  141. Do Case
  142. Case HttpSession->SCRTipo == 'PC'
  143. DbSelectArea("SCR")
  144. DbGoTo(Val(HttpSession->SCRKey))
  145. if SCR->(Recno()) == Val(HttpSession->SCRKey) .And. SCR->CR_STATUS <> "01"
  146. cReturn := AllTrim(HttpSession->SCRTipo)
  147. Else
  148. cReturn := ""
  149. End
  150. Case HttpSession->SCRTipo == 'SO'
  151. DbSelectArea("SCR")
  152. DbGoTo(Val(HttpSession->SCRKey))
  153. if SCR->(Recno()) == Val(HttpSession->SCRKey) .And. SCR->CR_STATUS <> "01"
  154. cReturn := AllTrim(HttpSession->SCRTipo)
  155. Else
  156. cReturn := ""
  157. End
  158. Case HttpSession->SCRTipo == 'AE'
  159. DbSelectArea("SCR")
  160. DbGoTo(Val(HttpSession->SCRKey))
  161. if SCR->(Recno()) == Val(HttpSession->SCRKey) .And. SCR->CR_STATUS <> "01"
  162. cReturn := AllTrim(HttpSession->SCRTipo)
  163. Else
  164. cReturn := ""
  165. End
  166. Case HttpSession->SCRTipo == 'CT'
  167. DbSelectArea("SCR")
  168. DbGoTo(Val(HttpSession->SCRKey))
  169. if SCR->(Recno()) == Val(HttpSession->SCRKey) .And. SCR->CR_STATUS <> "01"
  170. cReturn := AllTrim(HttpSession->SCRTipo)
  171. Else
  172. cReturn := ""
  173. End
  174. EndCase
  175. Else
  176. cReturn := ""
  177. End
  178. cHtml := H_PSReturn()
  179. Web Extended end
  180. return (cHTML)