SMSGrid_old.aph 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <%
  2. /**** Pagina de login do site ****/
  3. // Local cLSite := "./" // Site
  4. Local cLTitle := "" // Titulo da pagina
  5. Local cLPagina := "" // Nome da página
  6. // Local cLHeader := ""
  7. Local cLTopo := ""
  8. Local cLMenus := ""
  9. Local cLWidgets := ""
  10. Local cLColunas := ""
  11. Local cLItens := ""
  12. Local cLJavaScr := ""
  13. Local aLStatGrid := {}
  14. local lLSidebar := .t.
  15. Local cLCodLogin := ""
  16. Local nInd
  17. if type("cSite") <> "U"
  18. cLSite := cSite
  19. else
  20. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cSite")
  21. Endif
  22. if type("cTitle") <> "U"
  23. cLTitle := cTitle
  24. else
  25. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cTitle")
  26. Endif
  27. if type("cPagina") <> "U"
  28. cLPagina := cPagina
  29. else
  30. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cPagina")
  31. Endif
  32. if type("cMenus") <> "U"
  33. cLMenus := cMenus
  34. else
  35. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cMenus")
  36. Endif
  37. if type("cWidgets") <> "U"
  38. cLWidgets := cWidgets
  39. else
  40. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cWidgets")
  41. Endif
  42. if type("cTopo") <> "U"
  43. cLTopo := cTopo
  44. else
  45. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cTopo")
  46. Endif
  47. if type("cColunas") <> "U"
  48. cLColunas := cColunas
  49. else
  50. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cColunas")
  51. Endif
  52. if type("cItens") <> "U"
  53. cLItens := cItens
  54. else
  55. conout(dtoc(date())+" " + time() + " Portal "+procname(1)+"("+cValToChar(procline(1))+") Faltou cItens")
  56. Endif
  57. if type("lSidebar") = "L"
  58. lLSidebar := lSidebar
  59. endif
  60. if type("aStatGrid") = "A"
  61. aLStatGrid := aclone(aStatGrid)
  62. Endif
  63. if type ("cCodLogin") <> "U"
  64. cLCodLogin := cCodLogin
  65. Endif
  66. if type("cJavaScr") <> "U"
  67. cLJavaScr := cJavaScr
  68. endif
  69. %>
  70. <!DOCTYPE html>
  71. <html class="fixed">
  72. <head>
  73. <!-- Basic -->
  74. <meta charset="iso-8859-1">
  75. <link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" />
  76. <title><%=cLTitle%></title>
  77. <meta name="keywords" content="<%=cLTitle%>" />
  78. <meta name="description" content="Portal <%=cLTitle%>">
  79. <meta name="author" content="SMSTI">
  80. <!-- Mobile Metas -->
  81. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  82. <!-- Web Fonts -->
  83. <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
  84. <!-- Vendor CSS -->
  85. <!-- <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" /> -->
  86. <!-- 20210106 -->
  87. <link rel="stylesheet" href="ndtb/Bootstrap-3.3.7/css/bootstrap.css" />
  88. <link rel="stylesheet" href="ndtb/datatables.css" />
  89. <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
  90. <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
  91. <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css" />
  92. <!-- Specific Page Vendor CSS -->
  93. <link rel="stylesheet" href="assets/vendor/select2/css/select2.css" />
  94. <link rel="stylesheet" href="assets/vendor/select2-bootstrap-theme/select2-bootstrap.min.css" />
  95. <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
  96. <link rel="stylesheet" href="assets/vendor/dropzone/basic.css" />
  97. <link rel="stylesheet" href="assets/vendor/dropzone/dropzone.css" />
  98. <!-- 20210106 -->
  99. <link rel="stylesheet" href="ndtb/DataTables-1.10.23/css/dataTables.bootstrap.min.css" />
  100. <link rel="stylesheet" href="ndtb/Buttons-1.6.5/css/buttons.dataTables.min.css" />
  101. <!-- Theme CSS -->
  102. <link rel="stylesheet" href="assets/stylesheets/theme.css" />
  103. <!-- Skin CSS -->
  104. <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
  105. <!-- Theme Custom CSS -->
  106. <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
  107. <!-- Head Libs -->
  108. <script src="assets/vendor/modernizr/modernizr.js"></script>
  109. </head>
  110. <section class="body">
  111. <!-- start: header -->
  112. <header class="header">
  113. <div class="logo-container">
  114. <a href="<%= cLSite %>" class="logo pull-left">
  115. <img src="images/<%='logo'+cEmpAnt%>.png" alt="<%= cLTitle %>" height="45"/>
  116. </a>
  117. <%if lLSidebar%>
  118. <div class="visible-xs toggle-sidebar-left" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
  119. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  120. </div>
  121. <%endif%>
  122. </div>
  123. <div class="header-right">
  124. <span class="separator"></span>
  125. <div id="userbox" class="userbox">
  126. <a href="#" data-toggle="dropdown">
  127. <div class="profile-info" data-lock-name="<%= HttpSession->Nome %>">
  128. <span class="name"><%= HttpSession->NomeFull %></span>
  129. <span class="role"><%= HttpSession->Perfil %></span>
  130. <span class="role"><%= HttpSession->NomeEmpresa %></span>
  131. </div>
  132. <i class="fa custom-caret"></i>
  133. </a>
  134. <div class="dropdown-menu">
  135. <ul class="list-unstyled">
  136. <li>
  137. <a role="menuitem" tabindex="-1" href="U_PortalLogin.apw"><i class="fa fa-power-off"></i>Sair</a>
  138. </li>
  139. </ul>
  140. </div>
  141. </div>
  142. </div>
  143. </header>
  144. <!-- end: header -->
  145. <div class="inner-wrapper">
  146. <!-- start: sidebar -->
  147. <aside id="sidebar-left" class="sidebar-left">
  148. <div class="sidebar-header">
  149. <div class="sidebar-title">
  150. Menu
  151. </div>
  152. <div class="sidebar-toggle hidden-xs" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
  153. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  154. </div>
  155. </div>
  156. <div class="nano">
  157. <div class="nano-content">
  158. <nav id="menu" class="nav-main" role="navigation">
  159. <ul class="nav nav-main">
  160. <%=cLMenus%>
  161. </ul>
  162. </nav>
  163. </div>
  164. <script>
  165. // Maintain Scroll Position
  166. if (typeof localStorage !== 'undefined') {
  167. if (localStorage.getItem('sidebar-left-position') !== null) {
  168. var initialPosition = localStorage.getItem('sidebar-left-position'),
  169. sidebarLeft = document.querySelector('#sidebar-left .nano-content');
  170. sidebarLeft.scrollTop = initialPosition;
  171. }
  172. }
  173. </script>
  174. </div>
  175. </aside>
  176. <!-- end: sidebar -->
  177. <section role="main" class="content-body">
  178. <header class="page-header">
  179. <h2><%=cLPagina%></h2>
  180. <div class="right-wrapper pull-right">
  181. </div>
  182. </header>
  183. <!-- start: page -->
  184. <section class="panel">
  185. <!--
  186. <header class="panel-heading">
  187. <div class="panel-actions">
  188. <a href="#" class="panel-action panel-action-toggle" data-panel-toggle></a>
  189. <a href="#" class="panel-action panel-action-dismiss" data-panel-dismiss></a>
  190. </div>
  191. <h2 class="panel-title">Basic with Table Tools</h2>
  192. </header>
  193. -->
  194. <div class="panel-body">
  195. <%=cLTopo%>
  196. <br>
  197. <br>
  198. <%if lTableTools%>
  199. <table class="table table-bordered table-striped mb-none table-hover" id="datatable-tabletools" style="width: 100%;">
  200. <%else%>
  201. <table class="table table-bordered mb-none" style="width: 100%;">
  202. <%endif%>
  203. <thead>
  204. <tr>
  205. <%=cLColunas%>
  206. </tr>
  207. </thead>
  208. <tbody>
  209. <%=cLItens%>
  210. </tbody>
  211. </table>
  212. </div>
  213. <%if len(aLStatGrid) > 0 %>
  214. <div class="panel-footer">
  215. <table class="table">
  216. <tr>
  217. <% for nInd := 1 to len(aLStatGrid)
  218. if (nInd % 2) = 1 %>
  219. <th align="right"><span class="smcircle sm<%= aLStatGrid[nInd, 1] %>"></span></th><th><%= aLStatGrid[nInd, 2] %></th>
  220. <% else %>
  221. <th><span class="smcircle sm<%= aLStatGrid[nInd, 1] %>"></span></th><th><%= aLStatGrid[nInd, 2] %></th>
  222. <% endif
  223. next %>
  224. </tr>
  225. </table>
  226. </div>
  227. <% endif %>
  228. <div class="modal fade" id="dialogMsgFin" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  229. <div class="modal-dialog">
  230. <div class="modal-content">
  231. <div class="modal-header">
  232. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  233. <h4 class="modal-title" id="myModalLabel">Mensagem para o Financeiro</h4>
  234. </div>
  235. <div class="modal-body">
  236. <label class="control-label">Mensagem</label>
  237. <textarea class="form-control" rows="3" id="textoMensagem"></textarea>
  238. <input type="hidden" id="recCliente"/>
  239. <br>
  240. <label class="control-label">Anexos</label>
  241. <form action="/u_uploadfile.apw?PR=<%=cLCodLogin%>" method="POST" enctype="multipart/form-data" id="dropzone-form" class="dropzone dz-square dz-clickable">
  242. <div class="dz-default dz-message">
  243. <span>Clique ou arraste e solte os arquivos aqui</span>
  244. </div>
  245. </form>
  246. </div>
  247. <div class="modal-footer">
  248. <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
  249. <button type="button" class="btn btn-primary" onclick="javascript:emailFin( $('#recCliente').val() );">Enviar</button>
  250. </div>
  251. </div>
  252. </div>
  253. </div>
  254. </section>
  255. <!-- end: page -->
  256. </section>
  257. <footer class="panel-footer text-right">
  258. Desenvolvido por <img src="images/sms.png" />
  259. </footer>
  260. </div>
  261. </section>
  262. <!-- Vendor -->
  263. <script src="assets/vendor/jquery/jquery.js"></script>
  264. <!-- 20210106 -->
  265. <script src="ndtb/jQuery-3.5.1/jquery-3.5.1.js"></script>
  266. <script src="ndtb/datatables.js"></script>
  267. <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
  268. <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
  269. <!-- 20210106 -->
  270. <script src="ndtb/Bootstrap-3.3.7/js/bootstrap.js"></script>
  271. <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
  272. <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
  273. <script src="assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.min.js"></script>
  274. <script src="assets/vendor/magnific-popup/jquery.magnific-popup.js"></script>
  275. <script src="assets/vendor/jquery-placeholder/jquery-placeholder.js"></script>
  276. <!-- Custom -->
  277. <script src="custom/js/bootbox.js"></script>
  278. <script src="custom/js/moeda.js"></script>
  279. <!-- Specific Page Vendor -->
  280. <script src="assets/vendor/select2/js/select2.js"></script>
  281. <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
  282. <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
  283. <!-- 20210106 -->
  284. <script src="ndtb/DataTables-1.10.23/js/jquery.dataTables.js"></script>
  285. <script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
  286. <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
  287. <!-- 20210106 -->
  288. <script src="ndtb/DataTables-1.10.23/js/dataTables.bootstrap.js"></script>
  289. <script src="ndtb/Buttons-1.6.5/js/dataTables.buttons.min.js"></script>
  290. <script src="ndtb/JSZip-3.1.3/jszip.min.js"></script>
  291. <script src="ndtb/pdfmake-0.1.53/pdfmake.min.js"></script>
  292. <script src="ndtb/pdfmake-0.1.53/vfs_fonts.js"></script>
  293. <script src="ndtb/Buttons-1.6.5/js/buttons.html5.js"></script>
  294. <script src="ndtb/Buttons-1.6.5/js/buttons.print.min.js"></script>
  295. <script src="assets/vendor/dropzone/dropzone.js"></script>
  296. <script src="custom/js/dropzone.js"></script>
  297. <!-- Theme Base, Components and Settings -->
  298. <script src="assets/javascripts/theme.js"></script>
  299. <!-- Theme Initialization Files -->
  300. <script src="assets/javascripts/theme.init.js"></script>
  301. <!--
  302. <script src="assets/javascripts/tables/examples.datatables.default.js"></script>
  303. <script src="assets/javascripts/tables/examples.datatables.row.with.details.js"></script>
  304. <script src="js/examples/examples.advanced.form.js"></script>
  305. <%if lTableTools%>
  306. <script src="assets/javascripts/tables/examples.datatables.tabletools.js"></script>
  307. <%else%>
  308. <script src="assets/javascripts/tables/examples.datatables.tabletools.nd.js"></script>
  309. <%endif%>
  310. -->
  311. <!-- Theme Custom -->
  312. <script src="assets/javascripts/theme.custom.js"></script>
  313. <script src="custom/js/datebr.js"></script>
  314. <script>
  315. $(document).ready( function() {
  316. $("#datatable-tabletools").attr("role","button");
  317. // Antigamente
  318. // var oTable = $('#datatable-tabletools').dataTable();
  319. // Criacao da datatable
  320. var oTable = $('#datatable-tabletools').dataTable( {
  321. dom: 'lBfrtip',
  322. buttons: [
  323. 'excel', 'pdf', 'print'
  324. ]
  325. <%if ! lTableTools%>
  326. , "ordering": false
  327. , "searching": false
  328. <%endif%>
  329. , "scrollX": true
  330. });
  331. var url_atual = window.location.href;
  332. //Ordenação da tabela
  333. oTable.fnSort( [ ] );
  334. if( url_atual.match('orcamento.apw') || url_atual.match('Orcamento.apw'))
  335. {
  336. oTable.fnSort( [1, 'desc' ] );
  337. }
  338. //Valida os percentuais no botão filtrar para curva ABC
  339. $('#btFiltroP').click(function() {
  340. var nPercA = parseFloat($("#PERC_A").val());
  341. var nPercB = parseFloat($("#PERC_B").val());
  342. var nPercC = parseFloat($("#PERC_C").val());
  343. if (nPercA+nPercB+nPercC != 100){
  344. bootbox.alert("A soma dos percentuais de A, B e C deve ser 100!");
  345. $(this).removeAttr('disabled');
  346. return false;
  347. }
  348. });
  349. $(window).on('sidebar-left-toggle', function() {
  350. $($.fn.dataTable.tables(true)).DataTable().columns.adjust();
  351. })
  352. /*
  353. Modal Dismiss
  354. */
  355. // $(document).on('click', '.modal-dismiss', function (e) {
  356. // $('.modal-dismiss').on('click touch touchstart', function (e) {
  357. // e.preventDefault();
  358. // $.magnificPopup.close();
  359. // });
  360. /*
  361. Modal Confirm
  362. */
  363. // $(document).on('click', '.modal-confirm', function (e) {
  364. // e.preventDefault();
  365. // $.magnificPopup.close();
  366. // var cemail = $("input[name='email']").val();
  367. // var cdoc = $("input[name='nrdoc']").val();
  368. // var cform = $("input[name='formDest']").val();
  369. //
  370. // var dialogMail = bootbox.dialog({
  371. // message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Enviando e-mail... Aguarde...</p>',
  372. // closeButton: false
  373. // });
  374. //
  375. // //Envio de e-mail
  376. // $.ajax({
  377. // url: "U_"+cform+"?PR=<%=cLCodLogin%>",
  378. // data: 'email='+cemail+'&pagina='+cform+'&doc='+cdoc,
  379. // type: "POST",
  380. // async: false,
  381. // success:
  382. // function(retorno) {
  383. // dialogMail.modal('hide');
  384. // if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  385. // $("html").html(retorno);
  386. // return;
  387. // }
  388. // bootbox.alert(retorno);
  389. // }
  390. // });
  391. //});
  392. /*
  393. Form
  394. */
  395. $('.modal-email').magnificPopup({
  396. type: 'inline',
  397. preloader: false,
  398. focus: '#email',
  399. modal: true,
  400. // When elemened is focused, some mobile browsers in some cases zoom in
  401. // It looks not nice, so we disable it:
  402. callbacks: {
  403. beforeOpen: function() {
  404. if($(window).width() < 700) {
  405. this.st.focus = false;
  406. } else {
  407. this.st.focus = '#email';
  408. }
  409. },
  410. elementParse: function(item) {
  411. // Function will fire for each target element
  412. // "item.el" is a target DOM element (if present)
  413. // "item.src" is a source that you may modify
  414. console.log('Parsing content. Item object that is being parsed:', item);
  415. if (item.el && item.el.attr("id")) {
  416. $("input[name='nrdoc']").val(item.el.attr("id").substr(2));
  417. }
  418. }
  419. }
  420. });
  421. });
  422. function abreEmail(cParm,cEmail) {
  423. $("input[name='nrdoc']").val(cParm);
  424. $("input[name='email']").val(cEmail);
  425. $('.modal-email').magnificPopup({
  426. items: {
  427. src: '#modalEmail'
  428. },
  429. type: 'inline',
  430. preloader: false,
  431. focus: '#email',
  432. modal: true
  433. }).magnificPopup('open');
  434. }
  435. function fecharEmail() {
  436. $.magnificPopup.close();
  437. return false;
  438. };
  439. function enviarEmail() {
  440. $.magnificPopup.close();
  441. var cemail = $("input[name='email']").val();
  442. var cdoc = $("input[name='nrdoc']").val();
  443. var cform = $("input[name='formDest']").val();
  444. var dialogMail = bootbox.dialog({
  445. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Enviando e-mail... Aguarde...</p>',
  446. closeButton: false
  447. });
  448. //Envio de e-mail
  449. $.ajax({
  450. url: "U_"+cform+"?PR=<%=cLCodLogin%>",
  451. data: 'email='+cemail+'&pagina='+cform+'&doc='+cdoc,
  452. type: "POST",
  453. async: false,
  454. success:
  455. function(retorno) {
  456. dialogMail.modal('hide');
  457. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  458. $("html").html(retorno);
  459. return;
  460. }
  461. bootbox.alert(retorno);
  462. }
  463. });
  464. return false;
  465. }
  466. //ViewDanfe
  467. function ViewDanfe(notaFiscal,tipo){
  468. $.ajax({
  469. url: "U_MailNF.apw?PR=<%=cLCodLogin%>",
  470. type: "POST",
  471. data: 'email=&doc='+notaFiscal+'&tipo='+tipo,
  472. cache: false,
  473. success:
  474. function(docDanfe) {
  475. if (docDanfe.indexOf('HTTP-EQUIV') >= 0 ) {
  476. $("html").html(docDanfe);
  477. return;
  478. }
  479. if (docDanfe == "" || docDanfe.indexOf('Falha') >= 0 ) {
  480. bootbox.alert('Falha ao gerar o arquivo. Tente novamente mais tarde.');
  481. }
  482. if (docDanfe.substr(0,5) == "DANFE") {
  483. window.open('/anexos/danfe/'+docDanfe,"_blank")
  484. }
  485. }
  486. });
  487. }
  488. //Impressão do Orçamento
  489. function PrtOrc(orcto){
  490. $.ajax({
  491. url: "U_MailOrc.apw?PR=<%=cLCodLogin%>&opc=print",
  492. type: "POST",
  493. data: 'opc=print&doc='+orcto,
  494. cache: false,
  495. success:
  496. function(docOrcto) {
  497. if (docOrcto.indexOf('HTTP-EQUIV') >= 0 ) {
  498. $("html").html(docOrcto);
  499. return;
  500. }
  501. if (docOrcto == "" ) {
  502. bootbox.alert('Falha ao gerar o arquivo. Tente novamente mais tarde.');
  503. }
  504. if (docOrcto.substr(0,9) == "orcamento") {
  505. window.open('/anexos/orcamentos/'+docOrcto,"_blank")
  506. }
  507. }
  508. });
  509. }
  510. function Filtro(){
  511. if( window.location.href.match('estoque.apw') || window.location.href.match('Estoque.apw')){
  512. tabSel = $("#TABELA");
  513. filtab = $(tabSel)[0].options[$(tabSel)[0].selectedIndex].text.split('/')[0];
  514. $("#FILTAB").val(filtab);
  515. }
  516. //Submete formulario
  517. $("#formGrid").submit();
  518. }
  519. function GerarBoletos(){
  520. var noCheckedBox = true;
  521. var oBtnBol = $("#btBoleto");
  522. if (document.querySelectorAll("input[type=checkbox]").length>1){
  523. oBtnBol.attr("disabled","");
  524. document.querySelectorAll("input[type=checkbox]").forEach(e=> {
  525. if (e.checked) {
  526. noCheckedBox = false;
  527. }
  528. })
  529. if (noCheckedBox){
  530. bootbox.alert("Selecione pelo menos 1 título!");
  531. oBtnBol.removeAttr("disabled");
  532. } else {
  533. document.querySelectorAll("input[type=checkbox]").forEach(e=> {
  534. if (e.checked) {
  535. ViewBoleto(e.value);
  536. e.checked=false;
  537. }
  538. })
  539. bootbox.alert("Aguarde... Os boletos serão gerados em breve!");
  540. oBtnBol.removeAttr("disabled");
  541. }
  542. } else {
  543. bootbox.alert("Sem títulos para geração de boleto!");
  544. oBtnBol.removeAttr("disabled");
  545. }
  546. }
  547. /*
  548. function Filtro(obBtn){
  549. // this.value= '+"'"+'Aguarde...'+"'"+';this.disabled= '+"'"+'disabled'+"'"+';
  550. obBtn.disabled = true;
  551. //Submete formulario
  552. $("#formGrid").submit();
  553. } */
  554. function Filtrar(obBtn){
  555. // this.value= '+"'"+'Aguarde...'+"'"+';this.disabled= '+"'"+'disabled'+"'"+';
  556. obBtn.disabled = true;
  557. //Submete formulario
  558. $("#formGrid").submit();
  559. }
  560. /**
  561. // Função para ver detalhes do limite
  562. **/
  563. function detLimite(cCliente){
  564. var msg = "";
  565. var total = "";
  566. var pedlib = "";
  567. var pedidos = "";
  568. var titulos = "";
  569. var saldo = "";
  570. var vencto = "";
  571. var risco = "";
  572. var orcprev = "";
  573. var orcfirme = "";
  574. var atraso = "";
  575. var utilizado = "";
  576. $.ajax({
  577. url: "U_ConsLmt.apw?PR=<%=cLCodLogin%>",
  578. data: 'cliente='+cCliente,
  579. type: "POST",
  580. async: false,
  581. success:
  582. function(retorno) {
  583. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  584. $("html").html(retorno);
  585. return;
  586. }
  587. aRet = retorno.split('|');
  588. total = aRet[0];
  589. pedlib = aRet[1];
  590. titulos = aRet[2];
  591. saldo = aRet[3];
  592. vencto = aRet[4];
  593. risco = aRet[5];
  594. pedidos = aRet[6];
  595. orcprev = aRet[7];
  596. orcfirme = aRet[8];
  597. atraso = aRet[9];
  598. utilizado = aRet[10];
  599. }
  600. });
  601. msg = '<div class="row form-group">'
  602. msg +=' <br>'
  603. //Limite Total
  604. msg +=' <div class="row form-group">'
  605. msg +=' <div class="col-lg-1"></div>'
  606. msg +=' <div class="col-lg-5">'
  607. msg +=' <label class="control-label">Limite Total</label>'
  608. msg +=' <div class="input-group">'
  609. msg +=' <input class="form-control text-right" value="'+total+'" disabled>'
  610. msg +=' </div>'
  611. msg +=' </div>'
  612. msg +=' <div class="col-lg-5">'
  613. msg +=' <label class="control-label">Limite Disponível</label>'
  614. msg +=' <div class="input-group">'
  615. msg +=' <input class="form-control text-right" value="'+saldo+'" disabled>'
  616. msg +=' </div>'
  617. msg +=' </div>'
  618. msg +=' </div>'
  619. //CREDITO
  620. msg +=' <div class="row form-group">'
  621. msg +=' <div class="col-lg-1"></div>'
  622. msg +=' <div class="col-lg-5">'
  623. msg +=' <label class="control-label">Limite Utilizado</label>'
  624. msg +=' <div class="input-group">'
  625. msg +=' <input class="form-control text-right" value="'+utilizado+'" disabled>'
  626. msg +=' </div>'
  627. msg +=' </div>'
  628. msg +=' <div class="col-lg-5">'
  629. msg +=' <label class="control-label">Saldo em títulos</label>'
  630. msg +=' <div class="input-group">'
  631. msg +=' <input class="form-control text-right" value="'+titulos+'" disabled>'
  632. msg +=' </div>'
  633. msg +=' </div>'
  634. msg +=' </div>'
  635. msg +=' <div class="row form-group">'
  636. msg +=' <div class="col-lg-1"></div>'
  637. msg +=' <div class="col-lg-5">'
  638. msg +=' <label class="control-label">Valor em atraso</label>'
  639. msg +=' <div class="input-group">'
  640. msg +=' <input class="form-control text-right" value="'+atraso+'" disabled>'
  641. msg +=' </div>'
  642. msg +=' </div>'
  643. msg +=' </div>'
  644. // msg +=' <div class="col-lg-3">'
  645. // msg +=' <label class="control-label">Vencimento Limite</label>'
  646. // msg +=' <div class="input-group">'
  647. // msg +=' <input class="form-control text-right" value="'+vencto+'" disabled>'
  648. // msg +=' </div>'
  649. // msg +=' </div>'
  650. // msg +=' <div class="col-lg-2">'
  651. // msg +=' <label class="control-label">Risco</label>'
  652. // msg +=' <div class="input-group">'
  653. // msg +=' <input class="form-control text-right" value="'+risco+'" disabled>'
  654. // msg +=' </div>'
  655. // msg +=' </div>'
  656. // msg +=' </div>'
  657. //Pedidos
  658. // msg +=' <div class="row form-group">'
  659. // msg +=' <div class="col-lg-1"></div>'
  660. // msg +=' <div class="col-lg-5">'
  661. // msg +=' <label class="control-label">Pedidos em Aberto</label>'
  662. // msg +=' <div class="input-group">'
  663. // msg +=' <input class="form-control text-right" value="'+pedidos+'" disabled>'
  664. // msg +=' </div>'
  665. // msg +=' </div>'
  666. // msg +=' <div class="col-lg-5">'
  667. // msg +=' <label class="control-label">Pedidos Liberados</label>'
  668. // msg +=' <div class="input-group">'
  669. // msg +=' <input class="form-control text-right" value="'+pedlib+'" disabled>'
  670. // msg +=' </div>'
  671. // msg +=' </div>'
  672. // msg +=' </div>'
  673. //Orçamentos
  674. // msg +=' <div class="row form-group">'
  675. // msg +=' <div class="col-lg-1"></div>'
  676. // msg +=' <div class="col-lg-5">'
  677. // msg +=' <label class="control-label">Orçamentos Previstos</label>'
  678. // msg +=' <div class="input-group">'
  679. // msg +=' <input class="form-control text-right" value="'+orcprev+'" disabled>'
  680. // msg +=' </div>'
  681. // msg +=' </div>'
  682. // msg +=' <div class="col-lg-5">'
  683. // msg +=' <label class="control-label">Orçamentos Firmes</label>'
  684. // msg +=' <div class="input-group">'
  685. // msg +=' <input class="form-control text-right" value="'+orcfirme+'" disabled>'
  686. // msg +=' </div>'
  687. // msg +=' </div>'
  688. // msg +=' </div>'
  689. // msg +='</div>'
  690. if(msg != ""){
  691. bootbox.dialog({
  692. title: 'Limite de Crédito',
  693. message: "<p>"+msg+"</p>",
  694. backdrop: true,
  695. buttons: {
  696. ok: {
  697. label: "OK"
  698. }
  699. }
  700. });
  701. }
  702. }
  703. /**
  704. // Função para enviar msg ao financeiro
  705. **/
  706. function mensagemFin(cRecCli){
  707. $("#recCliente").val(cRecCli);
  708. $("#dialogMsgFin").modal('show');
  709. }
  710. /**
  711. // Função para envio de e-mail ao financeiro
  712. **/
  713. function emailFin(cRecCli){
  714. //aguardar
  715. var x = [];
  716. var cAnexos = "";
  717. var cMensagem = $("#textoMensagem").val();
  718. var dialogTab = bootbox.dialog({
  719. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Enviando e-mail... Aguarde...</p>',
  720. closeButton: false
  721. });
  722. $('#dialogMsgFin').modal('hide');
  723. $(".dz-filename").each(function() { x.push($(this).text())});
  724. for (i = 0; i < x.length; i++) {
  725. cAnexos += x[i]+"|";
  726. }
  727. oObjDados = {'cliente': cRecCli, 'mensagem': cMensagem, 'anexos':cAnexos};
  728. $.ajax({
  729. url: "U_EnvMsgFin.apw?PR=<%=cLCodLogin%>",
  730. //data: 'cliente='+cRecCli+'&mensagem='+cMensagem+'&anexos='+cAnexos,
  731. data: oObjDados,
  732. type: "POST",
  733. async: false,
  734. success:
  735. function(retorno) {
  736. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  737. $("html").html(retorno);
  738. return;
  739. } else {
  740. //remove aguarde
  741. dialogTab.modal('hide');
  742. $('.bootbox.modal').modal('hide');
  743. bootbox.alert("Mensagem enviada com sucesso!");
  744. //document.location.href = "U_LimiteCredito.apw?PR=<%=cLCodLogin%>" ;
  745. }
  746. }
  747. });
  748. }
  749. /**
  750. // Função para buscar as filiais que o vendedor tem acesso
  751. **/
  752. function getFilVend(){
  753. var msg = "";
  754. var cFilVend = "";
  755. var lRet = false;
  756. $.ajax({
  757. url: "U_FilVend.apw?PR=<%=cLCodLogin%>",
  758. type: "POST",
  759. async: false,
  760. success:
  761. function(retorno) {
  762. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  763. $("html").html(retorno);
  764. return;
  765. }
  766. if(retorno != "" && retorno.indexOf("Expires") == -1) {
  767. msg = '<div class="row form-group">'
  768. msg +=' <br>'
  769. msg +=' <div class="row form-group">'
  770. msg +=' <div class="col-lg-1"></div>'
  771. msg +=' <div class="col-lg-9">'
  772. msg +=' <label class="control-label">Selecione a filial para geração do orçamento</label>'
  773. msg +=' <div class="input-group">'
  774. msg +=' <select data-plugin-selectTwo class="form-control populate placeholder mb-md" data-plugin-options='+"'"
  775. msg +=' { "placeholder": "Selecione...", "allowClear": false }'+"'"+' name="FILVEND" id="FILVEND" '
  776. msg +=' required="" aria-required="true">'
  777. msg += retorno
  778. msg +=' </select>'
  779. msg +=' </div>'
  780. msg +=' </div>'
  781. msg +=' </div>'
  782. msg +='</div>'
  783. if(msg != ""){
  784. bootbox.dialog({
  785. title: 'Filial Para Orçamento',
  786. message: "<p>"+msg+"</p>",
  787. backdrop: true,
  788. closeButton: false,
  789. onEscape: false,
  790. buttons: {
  791. sucess: {
  792. label: "OK",
  793. callback: function () {
  794. cFilVend = $("#FILVEND").val();
  795. $('.bootbox.modal').modal('hide');
  796. //Chama função para trocar de filial
  797. $.ajax({
  798. url: "U_TrocaFil.apw?PR=<%=cLCodLogin%>",
  799. data: 'filial='+cFilVend,
  800. type: "POST",
  801. async: false,
  802. success:
  803. function(retfil) {
  804. if (retfil.indexOf('HTTP-EQUIV') >= 0 ) {
  805. $("html").html(retfil);
  806. return;
  807. }
  808. if(retfil != "" && retfil.indexOf("Expires") == -1) {
  809. url_atual = window.location.href;
  810. if( url_atual.match('orcamento.apw') || url_atual.match('Orcamento.apw')){
  811. //if(location.pathname.indexOf('U_orcamento')>0){
  812. location.href='u_AddOrc.apw?PR=<%=cLCodLogin%>'
  813. } else {
  814. location.href='u_AddCF.apw?PR=<%=cLCodLogin%>'
  815. }
  816. } else {
  817. bootbox.alert("Falha ao logar na filial "+cFilVend+".");
  818. }
  819. }
  820. });
  821. }
  822. }
  823. },
  824. });
  825. }
  826. } else {
  827. $('.bootbox.modal').modal('hide');
  828. bootbox.alert("Falha ao localizar as filiais que o vendedor tem acesso.");
  829. }
  830. }
  831. });
  832. }
  833. /**
  834. // Função para buscar a filial para inclusão da venda agregada
  835. **/
  836. function getFilial(){
  837. var msg = "";
  838. var cFilVend = "";
  839. var lRet = false;
  840. $.ajax({
  841. url: "U_FilVend.apw?PR=<%=cLCodLogin%>",
  842. type: "POST",
  843. async: false,
  844. success:
  845. function(retorno) {
  846. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  847. $("html").html(retorno);
  848. return;
  849. }
  850. if(retorno != "" && retorno.indexOf("Expires") == -1) {
  851. msg = '<div class="row form-group">'
  852. msg +=' <br>'
  853. msg +=' <div class="row form-group">'
  854. msg +=' <div class="col-lg-1"></div>'
  855. msg +=' <div class="col-lg-9">'
  856. msg +=' <label class="control-label">Selecione a filial para inclusão da venda</label>'
  857. msg +=' <div class="input-group">'
  858. msg +=' <select data-plugin-selectTwo class="form-control populate placeholder mb-md" data-plugin-options='+"'"
  859. msg +=' { "placeholder": "Selecione...", "allowClear": false }'+"'"+' name="FILVEND" id="FILVEND" '
  860. msg +=' required="" aria-required="true">'
  861. msg += retorno
  862. msg +=' </select>'
  863. msg +=' </div>'
  864. msg +=' </div>'
  865. msg +=' </div>'
  866. msg +='</div>'
  867. if(msg != ""){
  868. bootbox.dialog({
  869. title: 'Filial Venda Agregada',
  870. message: "<p>"+msg+"</p>",
  871. backdrop: true,
  872. closeButton: false,
  873. onEscape: false,
  874. buttons: {
  875. sucess: {
  876. label: "OK",
  877. callback: function () {
  878. cFilVend = $("#FILVEND").val();
  879. $('.bootbox.modal').modal('hide');
  880. //Chama função para trocar de filial
  881. $.ajax({
  882. url: "U_TrocaFil.apw?PR=<%=cLCodLogin%>",
  883. data: 'filial='+cFilVend,
  884. type: "POST",
  885. async: false,
  886. success:
  887. function(retfil) {
  888. if (retfil.indexOf('HTTP-EQUIV') >= 0 ) {
  889. $("html").html(retfil);
  890. return;
  891. }
  892. if(retfil != "" && retfil.indexOf("Expires") == -1) {
  893. location.href='u_AgregarVenda.apw?PR=<%=cLCodLogin%>'
  894. } else {
  895. bootbox.alert("Falha ao logar na filial "+cFilVend+".");
  896. }
  897. }
  898. });
  899. }
  900. }
  901. },
  902. });
  903. }
  904. } else {
  905. $('.bootbox.modal').modal('hide');
  906. bootbox.alert("Falha ao localizar as filiais que o vendedor tem acesso.");
  907. }
  908. }
  909. });
  910. }
  911. <%=cLJavaScr%>
  912. </script>
  913. </body>
  914. </html>