SMSGrid.aph.bak 44 KB

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