SMSGrid.aph 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  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. if type("cPerda") == "U"
  70. cPerda:= ""
  71. endif
  72. if type("cConcorrente") == "U"
  73. cConcorrente:= ""
  74. endif
  75. %>
  76. <!DOCTYPE html>
  77. <%if lLSidebar%>
  78. <html class="fixed">
  79. <%else%>
  80. <html class="fixed sidebar-left-collapsed">
  81. <%endif%>
  82. <head>
  83. <!-- Basic -->
  84. <meta charset="iso-8859-1">
  85. <link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" />
  86. <title><%=cLTitle%></title>
  87. <meta name="keywords" content="<%=cLTitle%>" />
  88. <meta name="description" content="Portal <%=cLTitle%>">
  89. <meta name="author" content="SMSTI">
  90. <!-- Mobile Metas -->
  91. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  92. <!-- Web Fonts -->
  93. <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
  94. <!-- Vendor CSS -->
  95. <!-- <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" /> -->
  96. <!-- 20210106 -->
  97. <link rel="stylesheet" href="ndtb/Bootstrap-3.3.7/css/bootstrap.css" />
  98. <link rel="stylesheet" href="ndtb/datatables.css" />
  99. <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
  100. <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
  101. <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css" />
  102. <!-- Specific Page Vendor CSS -->
  103. <link rel="stylesheet" href="assets/vendor/select2/css/select2.css" />
  104. <link rel="stylesheet" href="assets/vendor/select2-bootstrap-theme/select2-bootstrap.min.css" />
  105. <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
  106. <link rel="stylesheet" href="assets/vendor/dropzone/basic.css" />
  107. <link rel="stylesheet" href="assets/vendor/dropzone/dropzone.css" />
  108. <!-- 20210106 -->
  109. <link rel="stylesheet" href="ndtb/DataTables-1.10.23/css/dataTables.bootstrap.min.css" />
  110. <link rel="stylesheet" href="ndtb/Buttons-1.6.5/css/buttons.dataTables.min.css" />
  111. <!-- Theme CSS -->
  112. <link rel="stylesheet" href="assets/stylesheets/theme.css" />
  113. <!-- Skin CSS -->
  114. <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
  115. <!-- Theme Custom CSS -->
  116. <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
  117. <!-- Head Libs -->
  118. <script src="assets/vendor/modernizr/modernizr.js"></script>
  119. </head>
  120. <section class="body">
  121. <!-- start: header -->
  122. <header class="header">
  123. <div class="logo-container">
  124. <a href="<%= cLSite %>" class="logo pull-left">
  125. <img src="images/<%='logo'+cEmpAnt%>.png" alt="<%= cLTitle %>" height="45"/>
  126. </a>
  127. </div>
  128. <div class="header-right">
  129. <span class="separator"></span>
  130. <div id="userbox" class="userbox">
  131. <a href="#" data-toggle="dropdown">
  132. <div class="profile-info" data-lock-name="<%= HttpSession->Nome %>">
  133. <span class="name"><%= HttpSession->NomeFull %></span>
  134. <span class="role"><%= HttpSession->Perfil %></span>
  135. <span class="role"><%= HttpSession->NomeEmpresa %></span>
  136. </div>
  137. <i class="fa custom-caret"></i>
  138. </a>
  139. <div class="dropdown-menu">
  140. <ul class="list-unstyled">
  141. <li>
  142. <a role="menuitem" tabindex="-1" href="U_PortalLogin.apw"><i class="fa fa-power-off"></i>Sair</a>
  143. </li>
  144. </ul>
  145. </div>
  146. </div>
  147. </div>
  148. </header>
  149. <!-- end: header -->
  150. <div class="inner-wrapper">
  151. <!-- start: sidebar -->
  152. <aside id="sidebar-left" class="sidebar-left">
  153. <div class="sidebar-header">
  154. <div class="sidebar-title">
  155. Menu
  156. </div>
  157. <%if lLSidebar%>
  158. <div class="sidebar-toggle" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
  159. <%else%>
  160. <div class="sidebar-toggle hidden-xs"data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
  161. <%endif%>
  162. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  163. </div>
  164. </div>
  165. <div class="nano">
  166. <div class="nano-content">
  167. <nav id="menu" class="nav-main" role="navigation">
  168. <ul class="nav nav-main">
  169. <%=cLMenus%>
  170. </ul>
  171. </nav>
  172. </div>
  173. <script>
  174. // Maintain Scroll Position
  175. if (typeof localStorage !== 'undefined') {
  176. if (localStorage.getItem('sidebar-left-position') !== null) {
  177. var initialPosition = localStorage.getItem('sidebar-left-position'),
  178. sidebarLeft = document.querySelector('#sidebar-left .nano-content');
  179. sidebarLeft.scrollTop = initialPosition;
  180. }
  181. }
  182. </script>
  183. </div>
  184. </aside>
  185. <!-- end: sidebar -->
  186. <section role="main" class="content-body">
  187. <header class="page-header">
  188. <h2><%=cLPagina%></h2>
  189. <div class="right-wrapper pull-right">
  190. </div>
  191. </header>
  192. <!-- start: page -->
  193. <section class="panel">
  194. <!--
  195. <header class="panel-heading">
  196. <div class="panel-actions">
  197. <a href="#" class="panel-action panel-action-toggle" data-panel-toggle></a>
  198. <a href="#" class="panel-action panel-action-dismiss" data-panel-dismiss></a>
  199. </div>
  200. <h2 class="panel-title">Basic with Table Tools</h2>
  201. </header>
  202. -->
  203. <div class="panel-body">
  204. <%=cLTopo%>
  205. <br>
  206. <br>
  207. <%if lTableTools%>
  208. <table class="table table-bordered table-striped mb-none table-hover" id="datatable-tabletools" style="width: 100%;">
  209. <%else%>
  210. <table class="table table-bordered mb-none" style="width: 100%;">
  211. <%endif%>
  212. <thead>
  213. <tr>
  214. <%=cLColunas%>
  215. </tr>
  216. </thead>
  217. <tbody>
  218. <%=cLItens%>
  219. </tbody>
  220. </table>
  221. </div>
  222. <%if len(aLStatGrid) > 0 %>
  223. <div class="panel-footer">
  224. <table class="table">
  225. <tr>
  226. <% for nInd := 1 to len(aLStatGrid)
  227. if (nInd % 2) = 1 %>
  228. <th align="right"><span class="smcircle sm<%= aLStatGrid[nInd, 1] %>"></span></th><th><%= aLStatGrid[nInd, 2] %></th>
  229. <% else %>
  230. <th><span class="smcircle sm<%= aLStatGrid[nInd, 1] %>"></span></th><th><%= aLStatGrid[nInd, 2] %></th>
  231. <% endif
  232. next %>
  233. </tr>
  234. </table>
  235. </div>
  236. <% endif %>
  237. </section>
  238. <!-- end: page -->
  239. </section>
  240. <footer class="panel-footer text-right">
  241. Desenvolvido por <img src="images/sms.png" />
  242. </footer>
  243. </div>
  244. </section>
  245. <!-- Vendor -->
  246. <script src="assets/vendor/jquery/jquery.js"></script>
  247. <!-- 20210106 -->
  248. <script src="ndtb/jQuery-3.5.1/jquery-3.5.1.js"></script>
  249. <script src="ndtb/datatables.js"></script>
  250. <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
  251. <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
  252. <!-- 20210106 -->
  253. <script src="ndtb/Bootstrap-3.3.7/js/bootstrap.js"></script>
  254. <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
  255. <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
  256. <script src="assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.min.js"></script>
  257. <script src="assets/vendor/magnific-popup/jquery.magnific-popup.js"></script>
  258. <script src="assets/vendor/jquery-placeholder/jquery-placeholder.js"></script>
  259. <!-- Custom -->
  260. <script src="custom/js/bootbox.js"></script>
  261. <script src="custom/js/moeda.js"></script>
  262. <!-- Specific Page Vendor -->
  263. <script src="assets/vendor/select2/js/select2.js"></script>
  264. <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
  265. <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
  266. <!-- 20210106 -->
  267. <script src="ndtb/DataTables-1.10.23/js/jquery.dataTables.js"></script>
  268. <script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
  269. <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
  270. <!-- 20210106 -->
  271. <script src="ndtb/DataTables-1.10.23/js/dataTables.bootstrap.js"></script>
  272. <script src="ndtb/Buttons-1.6.5/js/dataTables.buttons.min.js"></script>
  273. <script src="ndtb/JSZip-3.1.3/jszip.min.js"></script>
  274. <script src="ndtb/pdfmake-0.1.53/pdfmake.min.js"></script>
  275. <script src="ndtb/pdfmake-0.1.53/vfs_fonts.js"></script>
  276. <script src="ndtb/Buttons-1.6.5/js/buttons.html5.js"></script>
  277. <script src="ndtb/Buttons-1.6.5/js/buttons.print.min.js"></script>
  278. <script src="assets/vendor/dropzone/dropzone.js"></script>
  279. <script src="custom/js/dropzone.js"></script>
  280. <!-- Theme Base, Components and Settings -->
  281. <script src="assets/javascripts/theme.js"></script>
  282. <!-- Theme Initialization Files -->
  283. <script src="assets/javascripts/theme.init.js"></script>
  284. <!--
  285. <script src="assets/javascripts/tables/examples.datatables.default.js"></script>
  286. <script src="assets/javascripts/tables/examples.datatables.row.with.details.js"></script>
  287. <script src="js/examples/examples.advanced.form.js"></script>
  288. <%if lTableTools%>
  289. <script src="assets/javascripts/tables/examples.datatables.tabletools.js"></script>
  290. <%else%>
  291. <script src="assets/javascripts/tables/examples.datatables.tabletools.nd.js"></script>
  292. <%endif%>
  293. -->
  294. <!-- Theme Custom -->
  295. <script src="assets/javascripts/theme.custom.js"></script>
  296. <script src="custom/js/datebr.js"></script>
  297. <script>
  298. $(document).ready( function() {
  299. $("#datatable-tabletools").attr("role","button");
  300. // Antigamente
  301. // var oTable = $('#datatable-tabletools').dataTable();
  302. // Criacao da datatable
  303. var oTable = $('#datatable-tabletools').dataTable( {
  304. dom: 'lBfrtip',
  305. buttons: [
  306. 'excel', 'pdf', 'print'
  307. ]
  308. <%if ! lTableTools%>
  309. , "ordering": false
  310. , "searching": false
  311. <%endif%>
  312. , "scrollX": true
  313. });
  314. var url_atual = window.location.href;
  315. //Ordenacao da tabela
  316. oTable.fnSort( [ ] );
  317. if( url_atual.match('orcamento.apw') || url_atual.match('Orcamento.apw'))
  318. {
  319. oTable.fnSort( [1, 'desc' ] );
  320. }else if( url_atual.match('pedidos.apw') || url_atual.match('Pedidos.apw') ){
  321. oTable.fnSort( [1, 'desc' ] );
  322. }
  323. //Valida os percentuais no bot�o filtrar para curva ABC
  324. $('#btFiltroP').click(function() {
  325. var nPercA = parseFloat($("#PERC_A").val());
  326. var nPercB = parseFloat($("#PERC_B").val());
  327. var nPercC = parseFloat($("#PERC_C").val());
  328. if (nPercA+nPercB+nPercC != 100){
  329. bootbox.alert("A soma dos percentuais de A, B e C deve ser 100!");
  330. $(this).removeAttr('disabled');
  331. return false;
  332. }
  333. });
  334. $(window).on('sidebar-left-toggle', function() {
  335. $($.fn.dataTable.tables(true)).DataTable().columns.adjust();
  336. })
  337. /*
  338. Modal Dismiss
  339. */
  340. // $(document).on('click', '.modal-dismiss', function (e) {
  341. // $('.modal-dismiss').on('click touch touchstart', function (e) {
  342. // e.preventDefault();
  343. // $.magnificPopup.close();
  344. // });
  345. /*
  346. Modal Confirm
  347. */
  348. // $(document).on('click', '.modal-confirm', function (e) {
  349. // e.preventDefault();
  350. // $.magnificPopup.close();
  351. // var cemail = $("input[name='email']").val();
  352. // var cdoc = $("input[name='nrdoc']").val();
  353. // var cform = $("input[name='formDest']").val();
  354. //
  355. // var dialogMail = bootbox.dialog({
  356. // message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Enviando e-mail... Aguarde...</p>',
  357. // closeButton: false
  358. // });
  359. //
  360. // //Envio de e-mail
  361. // $.ajax({
  362. // url: "U_"+cform+"?PR=<%=cLCodLogin%>",
  363. // data: 'email='+cemail+'&pagina='+cform+'&doc='+cdoc,
  364. // type: "POST",
  365. // async: false,
  366. // success:
  367. // function(retorno) {
  368. // dialogMail.modal('hide');
  369. // if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  370. // $("html").html(retorno);
  371. // return;
  372. // }
  373. // bootbox.alert(retorno);
  374. // }
  375. // });
  376. //});
  377. /*
  378. Form
  379. */
  380. $('.modal-email').magnificPopup({
  381. type: 'inline',
  382. preloader: false,
  383. focus: '#email',
  384. modal: true,
  385. // When elemened is focused, some mobile browsers in some cases zoom in
  386. // It looks not nice, so we disable it:
  387. callbacks: {
  388. beforeOpen: function() {
  389. if($(window).width() < 700) {
  390. this.st.focus = false;
  391. } else {
  392. this.st.focus = '#email';
  393. }
  394. },
  395. elementParse: function(item) {
  396. // Function will fire for each target element
  397. // "item.el" is a target DOM element (if present)
  398. // "item.src" is a source that you may modify
  399. console.log('Parsing content. Item object that is being parsed:', item);
  400. if (item.el && item.el.attr("id")) {
  401. $("input[name='nrdoc']").val(item.el.attr("id").substr(2));
  402. }
  403. }
  404. }
  405. });
  406. });
  407. function abreEmail(cParm,cEmail) {
  408. $("input[name='nrdoc']").val(cParm);
  409. $("input[name='email']").val(cEmail);
  410. $('.modal-email').magnificPopup({
  411. items: {
  412. src: '#modalEmail'
  413. },
  414. type: 'inline',
  415. preloader: false,
  416. focus: '#email',
  417. modal: true
  418. }).magnificPopup('open');
  419. }
  420. function fecharEmail() {
  421. $.magnificPopup.close();
  422. return false;
  423. };
  424. function enviarEmail() {
  425. $.magnificPopup.close();
  426. var cemail = $("input[name='email']").val();
  427. var cdoc = $("input[name='nrdoc']").val();
  428. var cform = $("input[name='formDest']").val();
  429. var dialogMail = bootbox.dialog({
  430. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Enviando e-mail... Aguarde...</p>',
  431. closeButton: false
  432. });
  433. //Envio de e-mail
  434. $.ajax({
  435. url: "U_"+cform+"?PR=<%=cLCodLogin%>",
  436. data: 'email='+cemail+'&pagina='+cform+'&doc='+cdoc,
  437. type: "POST",
  438. async: false,
  439. success:
  440. function(retorno) {
  441. dialogMail.modal('hide');
  442. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  443. $("html").html(retorno);
  444. return;
  445. }
  446. bootbox.alert(retorno);
  447. }
  448. });
  449. return false;
  450. }
  451. /*
  452. Efetivação do orçamento
  453. */
  454. function efetivaOrc(cNumOrc,cRecOrc) {
  455. bootbox.dialog({
  456. title: "Efetivar Orçamento",
  457. message: "Confirma a efetivação do orçamento "+cNumOrc+"?",
  458. buttons: {
  459. cancel: {
  460. label: 'Não'
  461. },
  462. sucess: {
  463. label: 'Sim',
  464. callback: function () {
  465. $('.bootbox.modal').modal('hide');
  466. var dialogEftv = bootbox.dialog({
  467. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Efetivando orçamento. Aguarde...</p>',
  468. closeButton: false
  469. });
  470. //Efetiva o orçamento
  471. $.ajax({
  472. url: "U_GeraEfetiva.apw?PR=<%=cLCodLogin%>",
  473. type: "POST",
  474. data: 'recorc='+cRecOrc,
  475. cache: false,
  476. success:
  477. function(retorno) {
  478. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  479. dialogEftv.modal('hide');
  480. $("html").html(retorno);
  481. return;
  482. }
  483. if (retorno == "") {
  484. dialogEftv.modal('hide');
  485. bootbox.alert('Falha ao efetivar o orçamento. Tente novamente mais tarde.');
  486. }else{
  487. dialogEftv.modal('hide');
  488. bootbox.confirm({
  489. title: "Efetivação do Orçamento",
  490. message: retorno,
  491. buttons: {
  492. cancel: {
  493. label: 'Cancelar'
  494. },
  495. confirm: {
  496. label: 'OK'
  497. }
  498. },
  499. callback: function (result) {
  500. if (result){
  501. location.href='u_Orcamento.apw?PR=<%=cLCodLogin%>'
  502. }
  503. }
  504. });
  505. }
  506. }
  507. });
  508. }
  509. }
  510. }
  511. });
  512. }
  513. /*
  514. Cancelamento do orçamento
  515. */
  516. function cancelaOrc(cNumOrc,cRecOrc){
  517. $("#numOrc").val(cNumOrc);
  518. $("#recOrc").val(cRecOrc);
  519. montaModal(cNumOrc,cRecOrc);
  520. }
  521. /*
  522. Monta a modal do cancelamento
  523. */
  524. function montaModal(numOcto,recOcto){
  525. msg = '<div class="row form-group">'
  526. msg +=' <header class="panel-heading">'
  527. msg +=' <h2 class="panel-title">Cancelar Orçamento '+numOcto+'</h2>'
  528. msg +=' </header>'
  529. msg +=' <br>'
  530. //Código perda
  531. msg +=' <div class="row form-group">'
  532. msg +=' <div class="col-lg-1"></div>'
  533. msg +=' <div class="col-lg-9">'
  534. msg +=' <label class="control-label">Motivo da perda</label>'
  535. msg +=' <div class="input-group">'
  536. msg +=' <select data-plugin-selectTwo class="form-control populate placeholder mb-md" data-plugin-options='+"'"
  537. msg +=' { "placeholder": "Selecione...", "allowClear": false }'+"'"+' name="CJ_CODPERD'+numOcto+'" id="CJ_CODPERD'+numOcto+'"'
  538. msg +=' required="" aria-required="true">'
  539. msg +=' <%=cPerda%>'
  540. msg +=' </select>'
  541. msg +=' </div>'
  542. msg +=' </div>'
  543. msg +=' </div>'
  544. msg +=' <div class="row form-group">'
  545. msg +=' <div class="col-lg-1"></div>'
  546. msg +=' <div class="col-lg-9">'
  547. msg +=' <label class="control-label">Concorrente</label>'
  548. msg +=' <div class="input-group">'
  549. msg +=' <select data-plugin-selectTwo class="form-control populate placeholder mb-md" data-plugin-options='+"'"
  550. msg +=' { "placeholder": "Selecione...", "allowClear": false }'+"'"+' name="CJ_CDCONCO'+numOcto+'" id="CJ_CDCONCO'+numOcto+'"'
  551. msg +=' required="" aria-required="true">'
  552. msg +=' <%=cConcorrente%>'
  553. msg +=' </select>'
  554. msg +=' </div>'
  555. msg +=' </div>'
  556. msg +=' </div>'
  557. msg +='</div>'
  558. if(msg != ""){
  559. bootbox.dialog({
  560. title: '',
  561. message: "<p>"+msg+"</p>",
  562. backdrop: true,
  563. buttons: {
  564. cancel: {
  565. label: "Cancelar"
  566. },
  567. sucess:{
  568. label: "Confirmar",
  569. callback: function () {
  570. var codPerda = $("#CJ_CODPERD"+numOcto).val();
  571. var codConc = $("#CJ_CDCONCO"+numOcto).val();
  572. if(codPerda==""){
  573. bootbox.alert("Informe o motivo da perda!")
  574. $("#CJ_CODPERD"+numOcto).focus();
  575. return false;
  576. }
  577. if(codPerda.substr(0,1)=="S" && codConc =="" ){
  578. bootbox.alert("Para esse motivo de cancelamento é obrigatório informar o concorrente!")
  579. $("#CJ_CDCONCO"+numOcto).focus();
  580. return false;
  581. }
  582. $('.bootbox.modal').modal('hide');
  583. var dialogCanc = bootbox.dialog({
  584. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Cancelando o orçamento. Aguarde...</p>',
  585. closeButton: false
  586. });
  587. //Cancela o orçamento
  588. $.ajax({
  589. url: "U_GeraCancela.apw?PR=<%=cLCodLogin%>",
  590. type: "POST",
  591. data: 'recorc='+recOcto+'&codperda='+codPerda+'&concorrente='+codConc,
  592. cache: false,
  593. success:
  594. function(retorno) {
  595. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  596. $("html").html(retorno);
  597. $('.bootbox.modal').modal('hide');
  598. return;
  599. }
  600. if (retorno == "") {
  601. bootbox.alert('Falha ao cancelar o orçamento. Tente novamente mais tarde.');
  602. }else{
  603. $('.bootbox.modal').modal('hide');
  604. //bootbox.alert("Orçamento cancelado com sucesso!");
  605. bootbox.dialog({
  606. title: '',
  607. message: "Orçamento cancelado com sucesso!",
  608. backdrop: true,
  609. buttons: {
  610. sucess:{
  611. label: "OK",
  612. callback: function () {
  613. location.href='u_Orcamento.apw?PR=<%=cLCodLogin%>'
  614. }
  615. }
  616. }
  617. });
  618. }
  619. }
  620. });
  621. }
  622. }
  623. }
  624. });
  625. }
  626. }
  627. //ViewDanfe
  628. function ViewDanfe(notaFiscal,tipo){
  629. $.ajax({
  630. url: "U_MailNF.apw?PR=<%=cLCodLogin%>",
  631. type: "POST",
  632. data: 'email=&doc='+notaFiscal+'&tipo='+tipo,
  633. cache: false,
  634. success:
  635. function(docDanfe) {
  636. if (docDanfe.indexOf('HTTP-EQUIV') >= 0 ) {
  637. $("html").html(docDanfe);
  638. return;
  639. }
  640. if (docDanfe == "" || docDanfe.indexOf('Falha') >= 0 ) {
  641. bootbox.alert('Falha ao gerar o arquivo. Tente novamente mais tarde.');
  642. }
  643. if (docDanfe.substr(0,5) == "DANFE") {
  644. window.open('/anexos/danfe/'+docDanfe,"_blank")
  645. }
  646. }
  647. });
  648. }
  649. //Impressão do Orçamento
  650. function PrtOrc(orcto){
  651. $.ajax({
  652. url: "U_MailOrc.apw?PR=<%=cLCodLogin%>&opc=print",
  653. type: "POST",
  654. data: 'opc=print&doc='+orcto,
  655. cache: false,
  656. success:
  657. function(docOrcto) {
  658. if (docOrcto.indexOf('HTTP-EQUIV') >= 0 ) {
  659. $("html").html(docOrcto);
  660. return;
  661. }
  662. if (docOrcto == "" ) {
  663. bootbox.alert('Falha ao gerar o arquivo. Tente novamente mais tarde.');
  664. }
  665. if (docOrcto.substr(0,9) == "orcamento") {
  666. window.open('/anexos/orcamentos/'+docOrcto,"_blank")
  667. }
  668. }
  669. });
  670. }
  671. function Filtro(){
  672. if( window.location.href.match('estoque.apw') || window.location.href.match('Estoque.apw')){
  673. var cliSel = $("#CLIENTE").val();//Cliente
  674. var tpCli = $("#TPCLI").val();//Tipo Cliente
  675. var estFat = $("#EST_FAT").val();//Estado faturamento
  676. var estEntre = $("#EST_ENTRE").val();//Estado entrega
  677. var munEntre = $("#MUN_ENTRE").val()//Municipio entrega
  678. //var grupoSel = $("#GRUP_PROD").val();//Grupo produto
  679. var _oportun = $("#OPORTUN").val();//Oportunidade
  680. var btFiltro = document.getElementById("btFiltro");
  681. var lRetFil = true;
  682. if(cliSel == '' && (estFat == "" || tpCli == "")) {
  683. bootbox.alert("Campos Tipo/Estado de faturamento vazios.");
  684. lRetFil = false;
  685. btFiltro.value="Consultar";
  686. $("#CLIENTE").focus();
  687. return;
  688. }
  689. if (tpCli == ""){
  690. bootbox.alert("Campo Tipo Vazio.");
  691. lRetFil = false;
  692. btFiltro.value="Consultar";
  693. return;
  694. }
  695. if (estFat == ""){
  696. bootbox.alert("Campo Estado Faturamento Vazio.");
  697. $("#EST_FAT").focus();
  698. btFiltro.value="Consultar";
  699. lRetFil = false;
  700. return;
  701. }
  702. if (estEntre == ""){
  703. bootbox.alert("Campo Estado Entrega Vazio.");
  704. $("#EST_ENTRE").focus();
  705. btFiltro.value="Consultar";
  706. lRetFil = false;
  707. return;
  708. }
  709. if (munEntre == ""){
  710. bootbox.alert("Campo Municipio Entrega Vazio.");
  711. $("#MUN_ENTRE").focus();
  712. btFiltro.value="Consultar";
  713. lRetFil = false;
  714. return;
  715. }
  716. //if (grupoSel == ""){
  717. // bootbox.alert("Campo Grupo V�zio.");
  718. // lRetFil = false;
  719. // return;
  720. // }
  721. if (_oportun == ""){
  722. bootbox.alert("Campo Oportunidade Vazio.");
  723. $("#OPORTUN").focus();
  724. btFiltro.value="Consultar";
  725. lRetFil = false;
  726. return;
  727. }
  728. if (lRetFil){
  729. //$("#GRUPOP").val(grupoSel);
  730. $("#FILTROP").val('001');
  731. $("#formGrid").submit();
  732. }
  733. } else {
  734. //Submete formulario
  735. $("#formGrid").submit();
  736. }
  737. }
  738. function GerarBoletos(){
  739. var noCheckedBox = true;
  740. var oBtnBol = $("#btBoleto");
  741. if (document.querySelectorAll("input[type=checkbox]").length>1){
  742. oBtnBol.attr("disabled","");
  743. document.querySelectorAll("input[type=checkbox]").forEach(e=> {
  744. if (e.checked) {
  745. noCheckedBox = false;
  746. }
  747. })
  748. if (noCheckedBox){
  749. bootbox.alert("Selecione pelo menos 1 título!");
  750. oBtnBol.removeAttr("disabled");
  751. } else {
  752. document.querySelectorAll("input[type=checkbox]").forEach(e=> {
  753. if (e.checked) {
  754. ViewBoleto(e.value);
  755. e.checked=false;
  756. }
  757. })
  758. bootbox.alert("Aguarde... Os boletos serão gerados em breve!");
  759. oBtnBol.removeAttr("disabled");
  760. }
  761. } else {
  762. bootbox.alert("Sem títulos para geração de boleto!");
  763. oBtnBol.removeAttr("disabled");
  764. }
  765. }
  766. /*
  767. function Filtro(obBtn){
  768. // this.value= '+"'"+'Aguarde...'+"'"+';this.disabled= '+"'"+'disabled'+"'"+';
  769. obBtn.disabled = true;
  770. //Submete formulario
  771. $("#formGrid").submit();
  772. } */
  773. function Filtrar(obBtn){
  774. // this.value= '+"'"+'Aguarde...'+"'"+';this.disabled= '+"'"+'disabled'+"'"+';
  775. obBtn.disabled = true;
  776. //Submete formulario
  777. $("#formGrid").submit();
  778. console.log("Formulário enviado!");
  779. }
  780. /**
  781. // Função para ver detalhes do limite
  782. **/
  783. function detLimite(cCliente){
  784. var msg = "";
  785. var total = "";
  786. var pedlib = "";
  787. var pedidos = "";
  788. var titulos = "";
  789. var saldo = "";
  790. var vencto = "";
  791. var risco = "";
  792. var orcprev = "";
  793. var orcfirme = "";
  794. var atraso = "";
  795. var utilizado = "";
  796. $.ajax({
  797. url: "U_ConsLmt.apw?PR=<%=cLCodLogin%>",
  798. data: 'cliente='+cCliente,
  799. type: "POST",
  800. async: false,
  801. success:
  802. function(retorno) {
  803. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  804. $("html").html(retorno);
  805. return;
  806. }
  807. aRet = retorno.split('|');
  808. total = aRet[0];
  809. pedlib = aRet[1];
  810. titulos = aRet[2];
  811. saldo = aRet[3];
  812. vencto = aRet[4];
  813. risco = aRet[5];
  814. pedidos = aRet[6];
  815. orcprev = aRet[7];
  816. orcfirme = aRet[8];
  817. atraso = aRet[9];
  818. utilizado = aRet[10];
  819. }
  820. });
  821. msg = '<div class="row form-group">'
  822. msg +=' <br>'
  823. //Limite Total
  824. msg +=' <div class="row form-group">'
  825. msg +=' <div class="col-lg-1"></div>'
  826. msg +=' <div class="col-lg-5">'
  827. msg +=' <label class="control-label">Limite Total</label>'
  828. msg +=' <div class="input-group">'
  829. msg +=' <input class="form-control text-right" value="'+total+'" disabled>'
  830. msg +=' </div>'
  831. msg +=' </div>'
  832. msg +=' <div class="col-lg-5">'
  833. msg +=' <label class="control-label">Limite Disponível</label>'
  834. msg +=' <div class="input-group">'
  835. msg +=' <input class="form-control text-right" value="'+saldo+'" disabled>'
  836. msg +=' </div>'
  837. msg +=' </div>'
  838. msg +=' </div>'
  839. //CREDITO
  840. msg +=' <div class="row form-group">'
  841. msg +=' <div class="col-lg-1"></div>'
  842. msg +=' <div class="col-lg-5">'
  843. msg +=' <label class="control-label">Limite Utilizado</label>'
  844. msg +=' <div class="input-group">'
  845. msg +=' <input class="form-control text-right" value="'+utilizado+'" disabled>'
  846. msg +=' </div>'
  847. msg +=' </div>'
  848. msg +=' <div class="col-lg-5">'
  849. msg +=' <label class="control-label">Saldo em títulos</label>'
  850. msg +=' <div class="input-group">'
  851. msg +=' <input class="form-control text-right" value="'+titulos+'" disabled>'
  852. msg +=' </div>'
  853. msg +=' </div>'
  854. msg +=' </div>'
  855. msg +=' <div class="row form-group">'
  856. msg +=' <div class="col-lg-1"></div>'
  857. msg +=' <div class="col-lg-5">'
  858. msg +=' <label class="control-label">Valor em atraso</label>'
  859. msg +=' <div class="input-group">'
  860. msg +=' <input class="form-control text-right" value="'+atraso+'" disabled>'
  861. msg +=' </div>'
  862. msg +=' </div>'
  863. msg +=' </div>'
  864. // msg +=' <div class="col-lg-3">'
  865. // msg +=' <label class="control-label">Vencimento Limite</label>'
  866. // msg +=' <div class="input-group">'
  867. // msg +=' <input class="form-control text-right" value="'+vencto+'" disabled>'
  868. // msg +=' </div>'
  869. // msg +=' </div>'
  870. // msg +=' <div class="col-lg-2">'
  871. // msg +=' <label class="control-label">Risco</label>'
  872. // msg +=' <div class="input-group">'
  873. // msg +=' <input class="form-control text-right" value="'+risco+'" disabled>'
  874. // msg +=' </div>'
  875. // msg +=' </div>'
  876. // msg +=' </div>'
  877. //Pedidos
  878. // msg +=' <div class="row form-group">'
  879. // msg +=' <div class="col-lg-1"></div>'
  880. // msg +=' <div class="col-lg-5">'
  881. // msg +=' <label class="control-label">Pedidos em Aberto</label>'
  882. // msg +=' <div class="input-group">'
  883. // msg +=' <input class="form-control text-right" value="'+pedidos+'" disabled>'
  884. // msg +=' </div>'
  885. // msg +=' </div>'
  886. // msg +=' <div class="col-lg-5">'
  887. // msg +=' <label class="control-label">Pedidos Liberados</label>'
  888. // msg +=' <div class="input-group">'
  889. // msg +=' <input class="form-control text-right" value="'+pedlib+'" disabled>'
  890. // msg +=' </div>'
  891. // msg +=' </div>'
  892. // msg +=' </div>'
  893. //Orçamentos
  894. // msg +=' <div class="row form-group">'
  895. // msg +=' <div class="col-lg-1"></div>'
  896. // msg +=' <div class="col-lg-5">'
  897. // msg +=' <label class="control-label">Orçamentos Previstos</label>'
  898. // msg +=' <div class="input-group">'
  899. // msg +=' <input class="form-control text-right" value="'+orcprev+'" disabled>'
  900. // msg +=' </div>'
  901. // msg +=' </div>'
  902. // msg +=' <div class="col-lg-5">'
  903. // msg +=' <label class="control-label">Orçamentos Firmes</label>'
  904. // msg +=' <div class="input-group">'
  905. // msg +=' <input class="form-control text-right" value="'+orcfirme+'" disabled>'
  906. // msg +=' </div>'
  907. // msg +=' </div>'
  908. // msg +=' </div>'
  909. // msg +='</div>'
  910. if(msg != ""){
  911. bootbox.dialog({
  912. title: 'Limite de Crédito',
  913. message: "<p>"+msg+"</p>",
  914. backdrop: true,
  915. buttons: {
  916. ok: {
  917. label: "OK"
  918. }
  919. }
  920. });
  921. }
  922. }
  923. /**
  924. // Função para enviar msg ao financeiro
  925. **/
  926. function mensagemFin(cRecCli){
  927. $("#recCliente").val(cRecCli);
  928. $("#dialogMsgFin").modal('show');
  929. }
  930. /**
  931. // Função para envio de e-mail ao financeiro
  932. **/
  933. function emailFin(cRecCli){
  934. //aguardar
  935. var x = [];
  936. var cAnexos = "";
  937. var cMensagem = $("#textoMensagem").val();
  938. var dialogTab = bootbox.dialog({
  939. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Enviando e-mail... Aguarde...</p>',
  940. closeButton: false
  941. });
  942. $('#dialogMsgFin').modal('hide');
  943. $(".dz-filename").each(function() { x.push($(this).text())});
  944. for (i = 0; i < x.length; i++) {
  945. cAnexos += x[i]+"|";
  946. }
  947. oObjDados = {'cliente': cRecCli, 'mensagem': cMensagem, 'anexos':cAnexos};
  948. $.ajax({
  949. url: "U_EnvMsgFin.apw?PR=<%=cLCodLogin%>",
  950. //data: 'cliente='+cRecCli+'&mensagem='+cMensagem+'&anexos='+cAnexos,
  951. data: oObjDados,
  952. type: "POST",
  953. async: false,
  954. success:
  955. function(retorno) {
  956. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  957. $("html").html(retorno);
  958. return;
  959. } else {
  960. //remove aguarde
  961. dialogTab.modal('hide');
  962. $('.bootbox.modal').modal('hide');
  963. bootbox.alert("Mensagem enviada com sucesso!");
  964. //document.location.href = "U_LimiteCredito.apw?PR=<%=cLCodLogin%>" ;
  965. }
  966. }
  967. });
  968. }
  969. /**
  970. // Função para buscar as filiais que o vendedor tem acesso
  971. **/
  972. function getFilVend(){
  973. var msg = "";
  974. var cFilVend = "";
  975. var lRet = false;
  976. var tipoTit = "Orçamento"
  977. $.ajax({
  978. url: "U_FilVend.apw?PR=<%=cLCodLogin%>",
  979. type: "POST",
  980. async: false,
  981. success:
  982. function(retorno) {
  983. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  984. $("html").html(retorno);
  985. return;
  986. }
  987. if(retorno != "" && retorno.indexOf("Expires") == -1) {
  988. url_atual = window.location.href;
  989. if (url_atual.match('pedidos.apw') || url_atual.match('Pedidos.apw')) {
  990. tipoTit = "Pedido"
  991. }
  992. msg = '<div class="row form-group">'
  993. msg +=' <br>'
  994. msg +=' <div class="row form-group">'
  995. msg +=' <div class="col-lg-1"></div>'
  996. msg +=' <div class="col-lg-9">'
  997. msg +=' <label class="control-label">Selecione a filial para geração do '+tipoTit+'</label>'
  998. msg +=' <div class="input-group">'
  999. msg +=' <select data-plugin-selectTwo class="form-control populate placeholder mb-md" data-plugin-options='+"'"
  1000. msg +=' { "placeholder": "Selecione...", "allowClear": false }'+"'"+' name="FILVEND" id="FILVEND" '
  1001. msg +=' required="" aria-required="true">'
  1002. msg += retorno
  1003. msg +=' </select>'
  1004. msg +=' </div>'
  1005. msg +=' </div>'
  1006. msg +=' </div>'
  1007. msg +='</div>'
  1008. if(msg != ""){
  1009. bootbox.dialog({
  1010. title: 'Filial Para '+tipoTit,
  1011. message: "<p>"+msg+"</p>",
  1012. backdrop: true,
  1013. closeButton: false,
  1014. onEscape: false,
  1015. buttons: {
  1016. cancel: {
  1017. label: "Cancelar"
  1018. },
  1019. sucess: {
  1020. label: "OK",
  1021. callback: function () {
  1022. cFilVend = $("#FILVEND").val();
  1023. $('.bootbox.modal').modal('hide');
  1024. //Chama função para trocar de filial
  1025. $.ajax({
  1026. url: "U_TrocaFil.apw?PR=<%=cLCodLogin%>",
  1027. data: 'filial='+cFilVend,
  1028. type: "POST",
  1029. async: false,
  1030. success:
  1031. function(retfil) {
  1032. if (retfil.indexOf('HTTP-EQUIV') >= 0 ) {
  1033. $("html").html(retfil);
  1034. return;
  1035. }
  1036. if(retfil != "" && retfil.indexOf("Expires") == -1) {
  1037. url_atual = window.location.href;
  1038. if( url_atual.match('orcamento.apw') || url_atual.match('Orcamento.apw')){
  1039. //if(location.pathname.indexOf('U_orcamento')>0){
  1040. location.href='u_AddOrc.apw?PR=<%=cLCodLogin%>'
  1041. } else if (url_atual.match('pedidos.apw') || url_atual.match('Pedidos.apw')) {
  1042. location.href='u_AddPed.apw?PR=<%=cLCodLogin%>'
  1043. } else {
  1044. location.href='u_AddCF.apw?PR=<%=cLCodLogin%>'
  1045. }
  1046. } else {
  1047. bootbox.alert("Falha ao logar na filial "+cFilVend+".");
  1048. }
  1049. }
  1050. });
  1051. }
  1052. }
  1053. },
  1054. });
  1055. }
  1056. } else {
  1057. $('.bootbox.modal').modal('hide');
  1058. bootbox.alert("Falha ao localizar as filiais que o vendedor tem acesso.");
  1059. }
  1060. }
  1061. });
  1062. }
  1063. /**
  1064. // Função para buscar a filial para inclusão da venda agregada
  1065. **/
  1066. function getFilial(){
  1067. var msg = "";
  1068. var cFilVend = "";
  1069. var lRet = false;
  1070. $.ajax({
  1071. url: "U_FilVend.apw?PR=<%=cLCodLogin%>",
  1072. type: "POST",
  1073. async: false,
  1074. success:
  1075. function(retorno) {
  1076. if (retorno.indexOf('HTTP-EQUIV') >= 0 ) {
  1077. $("html").html(retorno);
  1078. return;
  1079. }
  1080. if(retorno != "" && retorno.indexOf("Expires") == -1) {
  1081. msg = '<div class="row form-group">'
  1082. msg +=' <br>'
  1083. msg +=' <div class="row form-group">'
  1084. msg +=' <div class="col-lg-1"></div>'
  1085. msg +=' <div class="col-lg-9">'
  1086. msg +=' <label class="control-label">Selecione a filial para inclusão da venda</label>'
  1087. msg +=' <div class="input-group">'
  1088. msg +=' <select data-plugin-selectTwo class="form-control populate placeholder mb-md" data-plugin-options='+"'"
  1089. msg +=' { "placeholder": "Selecione...", "allowClear": false }'+"'"+' name="FILVEND" id="FILVEND" '
  1090. msg +=' required="" aria-required="true">'
  1091. msg += retorno
  1092. msg +=' </select>'
  1093. msg +=' </div>'
  1094. msg +=' </div>'
  1095. msg +=' </div>'
  1096. msg +='</div>'
  1097. if(msg != ""){
  1098. bootbox.dialog({
  1099. title: 'Filial Venda Agregada',
  1100. message: "<p>"+msg+"</p>",
  1101. backdrop: true,
  1102. closeButton: false,
  1103. onEscape: false,
  1104. buttons: {
  1105. sucess: {
  1106. label: "OK",
  1107. callback: function () {
  1108. cFilVend = $("#FILVEND").val();
  1109. $('.bootbox.modal').modal('hide');
  1110. //Chama função para trocar de filial
  1111. $.ajax({
  1112. url: "U_TrocaFil.apw?PR=<%=cLCodLogin%>",
  1113. data: 'filial='+cFilVend,
  1114. type: "POST",
  1115. async: false,
  1116. success:
  1117. function(retfil) {
  1118. if (retfil.indexOf('HTTP-EQUIV') >= 0 ) {
  1119. $("html").html(retfil);
  1120. return;
  1121. }
  1122. if(retfil != "" && retfil.indexOf("Expires") == -1) {
  1123. location.href='u_AgregarVenda.apw?PR=<%=cLCodLogin%>'
  1124. } else {
  1125. bootbox.alert("Falha ao logar na filial "+cFilVend+".");
  1126. }
  1127. }
  1128. });
  1129. }
  1130. }
  1131. },
  1132. });
  1133. }
  1134. } else {
  1135. $('.bootbox.modal').modal('hide');
  1136. bootbox.alert("Falha ao localizar as filiais que o vendedor tem acesso.");
  1137. }
  1138. }
  1139. });
  1140. }
  1141. function SelectCli() {
  1142. var clienteSelect = document.getElementById("CLIENTE");
  1143. var tipoCliSel = document.getElementById("TPCLI");
  1144. var estCliSel = document.getElementById("EST_FAT");
  1145. var estEntSel = document.getElementById("EST_ENTRE");
  1146. var munCliSel = document.getElementById("MUN_ENTRE");
  1147. //var grupoCliSel = document.getElementById("GRUP");
  1148. var selectedOption = clienteSelect.options[clienteSelect.selectedIndex];
  1149. var tipoCliVal = selectedOption.getAttribute("TIPO");
  1150. var estadoCliVal = selectedOption.getAttribute("EST");
  1151. var entregaCliVal = selectedOption.getAttribute("ESTE");
  1152. var munCliVal = selectedOption.getAttribute("MUN");
  1153. //var grupoCliVal = selectedOption.getAttribute("GRUPO");
  1154. tipoCliSel.value = tipoCliVal;
  1155. estCliSel.value = estadoCliVal;
  1156. estEntSel.value = entregaCliVal;
  1157. munCliSel.value = munCliVal;
  1158. //grupoCliSel.value = grupoCliVal;
  1159. $("select[name=TPCLI]").change();
  1160. $("select[name=EST_FAT]").change();
  1161. $("select[name=EST_ENTRE]").change();
  1162. $("select[name=MUN_ENTRE]").change();
  1163. }
  1164. function retMunicipios(cMunE) {
  1165. var cEst = document.getElementById('EST_ENTRE').value;//element.value;
  1166. var cCli = document.getElementById('CLIENTE').value;
  1167. var cMun = cMunE//document.getElementById('MUN_ENTRE').value;
  1168. $.ajax({
  1169. url: "U_RetMun.apw?PR=<%=cLCodLogin%>",
  1170. data: 'cEst='+cEst + '&cCli='+cCli,
  1171. type: "POST",
  1172. async: false,
  1173. success:
  1174. function(municipios) {
  1175. if (municipios.indexOf('<META HTTP-EQUIV') >= 0 ) {
  1176. $("html").html(municipios);
  1177. return;
  1178. }
  1179. if ( municipios == "" ) {
  1180. bootbox.alert('Nenhum Mucicipio Listado!');
  1181. $("#EST_FAT").focus();
  1182. }else{
  1183. $('#MUN_ENTRE').empty();
  1184. $("#MUN_ENTRE").append(municipios);
  1185. $("select[name=MUN_ENTRE]").change();
  1186. }
  1187. }
  1188. });
  1189. }
  1190. <%=cLJavaScr%>
  1191. </script>
  1192. </body>
  1193. </html>