AddOpt.aph 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. <%
  2. /**** Pagina de login do site ****/
  3. Local cLCodLogin := ""
  4. if type ("cCodLogin") <> "U"
  5. cLCodLogin := cCodLogin
  6. Endif
  7. %>
  8. <!DOCTYPE html>
  9. <html class="fixed sidebar-left-collapsed">
  10. <head>
  11. <!-- Basic -->
  12. <meta charset="iso-8859-1">
  13. <link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" />
  14. <title><%=cTitle%></title>
  15. <meta name="keywords" content="<%=cTitle%>" />
  16. <meta name="description" content="<%=cTitle%>">
  17. <meta name="author" content="SMSTI">
  18. <meta http-equiv="Chache-Control" content="no-cache" />
  19. <meta http-equiv="Expires" content="0" />
  20. <meta http-equiv="Pragma" content="no-cache" />
  21. <!-- Mobile Metas -->
  22. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  23. <!-- Web Fonts -->
  24. <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
  25. <!-- Vendor CSS -->
  26. <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
  27. <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
  28. <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
  29. <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css" />
  30. <link rel="stylesheet" href="assets/vendor/bootstrap-select/css/bootstrap-select.min.css" />
  31. <style>
  32. body .btn {
  33. white-space: nowrap !important;
  34. display: inline;
  35. overflow-y: hidden;
  36. }
  37. </style>
  38. <!-- Specific Page Vendor CSS -->
  39. <link rel="stylesheet" href="assets/vendor/select2/css/select2.css" />
  40. <link rel="stylesheet" href="assets/vendor/select2-bootstrap-theme/select2-bootstrap.min.css" />
  41. <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
  42. <link rel="stylesheet" href="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />
  43. <link rel="stylesheet" href="assets/vendor/pnotify/pnotify.custom.css" />
  44. <link rel="stylesheet" href="assets/vendor/dropzone/basic.css" />
  45. <link rel="stylesheet" href="assets/vendor/dropzone/dropzone.css" />
  46. <!-- Theme CSS -->
  47. <link rel="stylesheet" href="assets/stylesheets/theme.css" />
  48. <!-- Skin CSS -->
  49. <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
  50. <!-- Theme Custom CSS -->
  51. <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
  52. <!-- Head Libs -->
  53. <script src="assets/vendor/modernizr/modernizr.js"></script>
  54. <script src="assets/vendor/style-switcher/style.switcher.localstorage.js"></script>
  55. </head>
  56. <body>
  57. <section class="body">
  58. <!-- start: header -->
  59. <header class="header">
  60. <%=cHeader%>
  61. </header>
  62. <!-- end: header -->
  63. <div class="inner-wrapper">
  64. <!-- start: sidebar -->
  65. <aside id="sidebar-left" class="sidebar-left">
  66. <div class="sidebar-header">
  67. <div class="sidebar-title">
  68. Menu
  69. </div>
  70. <div class="sidebar-toggle hidden-xs"data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
  71. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  72. </div>
  73. </div>
  74. <div class="nano">
  75. <div class="nano-content">
  76. <nav id="menu" class="nav-main" role="navigation">
  77. <ul class="nav nav-main">
  78. <%=cMenus%>
  79. </ul>
  80. </nav>
  81. </div>
  82. <script>
  83. // Maintain Scroll Position
  84. if (typeof localStorage !== 'undefined') {
  85. if (localStorage.getItem('sidebar-left-position') !== null) {
  86. var initialPosition = localStorage.getItem('sidebar-left-position'),
  87. sidebarLeft = document.querySelector('#sidebar-left .nano-content');
  88. sidebarLeft.scrollTop = initialPosition;
  89. }
  90. }
  91. </script>
  92. </div>
  93. </aside>
  94. <!-- end: sidebar -->
  95. <section role="main" class="content-body">
  96. <header class="page-header">
  97. <h2><%=cPagina%></h2>
  98. <div class="right-wrapper pull-right">
  99. </div>
  100. </header>
  101. <!-- start: page -->
  102. <section class="panel">
  103. <!-- <header class="panel-heading">
  104. </header> -->
  105. <div class="panel-body">
  106. <div class="row">
  107. <div class="col-lg-12">
  108. <section class="panel form-wizard" id="w9">
  109. <form action = "" method="post" class="form-horizontal" id="formOrc">
  110. <div class="tabs">
  111. <ul class="nav nav-tabs nav-justify">
  112. <li class="active">
  113. <a href="#orc-informar" data-toggle="tab" class="text-center">homologação</a>
  114. </li>
  115. <li class="">
  116. <a href="#orc-anexos" data-toggle="tab" class="text-center">Anexos</a>
  117. </li>
  118. </ul>
  119. <div class="tab-content">
  120. <div id="orc-informar" class="tab-pane active">
  121. <!--
  122. <%=cVendedor%>
  123. -->
  124. <!-- linha 0: dados da Oportunidade -->
  125. <%=cCodOpt%>
  126. <div class="mb-md hidden-lg hidden-xl"></div>
  127. <div class="mb-md hidden-lg hidden-xl"></div>
  128. <!-- linha 1: dados da empresa -->
  129. <div class="row form-group">
  130. <div class="col-lg-5">
  131. <span class="required">*</span>
  132. <label class="control-label">Descrição</label>
  133. <%=cDescri%>
  134. </div>
  135. <div class="col-lg-2">
  136. <span class="required">*</span>
  137. <label class="control-label">Início</label>
  138. <div class="input-group">
  139. <span class="input-group-addon">
  140. <i class="fa fa-calendar"></i>
  141. </span>
  142. <%=cInicio%>
  143. </div>
  144. </div>
  145. <div class="col-lg-2">
  146. <span class="required">*</span>
  147. <label class="control-label">Término</label>
  148. <div class="input-group">
  149. <span class="input-group-addon">
  150. <i class="fa fa-calendar"></i>
  151. </span>
  152. <%=cFim%>
  153. </div>
  154. </div>
  155. <!--
  156. <div class="col-lg-7">
  157. <label class="control-label">Complemento</label>
  158. <%=cComplem%>
  159. </div>
  160. -->
  161. </div>
  162. <!-- linha 2: input -->
  163. <div class="row form-group">
  164. <div class="col-lg-4">
  165. <span class="required">*</span>
  166. <label class="control-label">Regional</label>
  167. <%=cRegional%>
  168. </div>
  169. <div class="col-lg-5">
  170. <span class="required">*</span>
  171. <label class="control-label">Vendedor</label>
  172. <%=cVendedor%>
  173. </div>
  174. <div class="col-lg-2">
  175. <label class="control-label">% RT</label>
  176. <%=cRT%>
  177. </div>
  178. </div>
  179. <!-- linha 3 input -->
  180. <div class="row form-group">
  181. <div class="col-lg-5">
  182. <span class="required">*</span>
  183. <label class="control-label">Cliente</label>
  184. <%=cCliente%>
  185. </div>
  186. <div class="col-lg-7">
  187. <span class="required">*</span>
  188. <label class="control-label">Contato</label>
  189. <%=cContato%>
  190. </div>
  191. </div>
  192. <!--linha 4 input
  193. <div class="row form-group">
  194. <div class="col-lg-6">
  195. <label class="control-label">Email</label>
  196. <%=cEmail%>
  197. </div>
  198. <div class="col-lg-6">
  199. <label class="control-label">Parceiro</label>
  200. <%=cParceiro%>
  201. </div>
  202. </div>
  203. -->
  204. <!-- linha 5 input -->
  205. <div class="row form-group">
  206. <div class="col-lg-2">
  207. <span class="required">*</span>
  208. <label class="control-label">UF</label>
  209. <%=cUF%>
  210. </div>
  211. <div class="col-lg-4">
  212. <span class="required">*</span>
  213. <label class="control-label">Cidade</label>
  214. <%=cCidade%>
  215. </div>
  216. <div class="col-lg-6">
  217. <label class="control-label">Endereço</label>
  218. <%=cEndereco%>
  219. </div>
  220. </div>
  221. <!-- linha 6 input -->
  222. <div class="row form-group">
  223. <div class="col-lg-6">
  224. <label class="control-label">Especificadora</label>
  225. <%=cEspecif%>
  226. </div>
  227. <div class="col-lg-6">
  228. <label class="control-label">Contato</label>
  229. <%=cContEsp%>
  230. </div>
  231. </div>
  232. <!-- linha 7: input -->
  233. <div class="row form-group">
  234. <div class="col-lg-3">
  235. <span class="required">*</span>
  236. <label class="control-label">Status homologação</label>
  237. <%=cStatusHom%>
  238. </div>
  239. <div class="col-lg-3">
  240. <span class="required">*</span>
  241. <label class="control-label">Segmento</label>
  242. <%=cSegmento%>
  243. </div>
  244. <div class="col-lg-3">
  245. <span class="required">*</span>
  246. <label class="control-label">Nível</label>
  247. <%=cNivel%>
  248. </div>
  249. </div>
  250. <!-- linha 7 input
  251. <div class="row form-group">
  252. <div class="col-md-5">
  253. <label class="control-label" for="textareaDefault">Notas</label>
  254. <textarea class="form-control" rows="3" data-plugin-maxlength="" maxlength="240" id="AD1_MEMO" name="AD1_MEMO" <%=Iif(!lEdit,'disabled','')%>><%=cNotas%></textarea>
  255. </div>
  256. </div>
  257. -->
  258. <!-- linha 7 input -->
  259. <div class="row form-group">
  260. <div class="col-lg-3">
  261. <label class="control-label">Status</label>
  262. <%=cStatus%>
  263. </div>
  264. <div class="col-lg-3">
  265. <label class="control-label">Encerramento</label>
  266. <%=cEncer%>
  267. </div>
  268. <div class="col-md-5">
  269. <label class="control-label" for="textareaDefault">Motivo</label>
  270. <%=cMotivo%>
  271. </div>
  272. </div>
  273. <br>
  274. <br>
  275. <div class="row form-group" align="center">
  276. <%=cBotoes%>
  277. </div>
  278. </div>
  279. <!-- aba de anexos -->
  280. <div id="orc-anexos" class="tab-pane">
  281. <div class="row form-group" align="center">
  282. <%=cBtAddAnex%>
  283. </div>
  284. <div class="row mg-files" data-sort-destination data-sort-id="media-gallery" style="margin: 20px" id="OrcAnexos">
  285. <%=cAnexos%>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. </div>
  291. </form>
  292. <div class="modal fade" id="dialogAnex" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  293. <div class="modal-dialog">
  294. <div class="modal-content">
  295. <div class="modal-header">
  296. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  297. <h4 class="modal-title" id="myModalLabel">Anexos</h4>
  298. </div>
  299. <div class="modal-body">
  300. <label class="control-label">Anexar Documentos</label>
  301. <form action="u_uploadfile.apw?PR=<%=cLCodLogin%>" method="POST" enctype="multipart/form-data" id="dropzone-form" class="dropzone dz-square dz-clickable">
  302. <div class="dz-default dz-message">
  303. <span>Clique ou arraste e solte os arquivos aqui</span>
  304. </div>
  305. </form>
  306. </div>
  307. <div class="modal-footer">
  308. <button type="button" class="btn btn-default" data-dismiss="modal" onclick="javascript:cancDoctos();">Cancelar</button>
  309. <button type="button" class="btn btn-primary" data-dismiss="modal">Confirmar</button>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </section>
  315. </div>
  316. </div>
  317. </div>
  318. </section>
  319. <footer class="panel-footer text-right">
  320. Desenvolvido por <img src="images/sms.png" />
  321. </footer>
  322. </div>
  323. </section>
  324. <!-- end: page -->
  325. <!-- Vendor -->
  326. <script src="assets/vendor/jquery/jquery.js"></script>
  327. <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
  328. <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
  329. <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
  330. <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
  331. <script src="assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.min.js"></script>
  332. <script src="assets/vendor/magnific-popup/jquery.magnific-popup.js"></script>
  333. <script src="assets/vendor/jquery-placeholder/jquery-placeholder.js"></script>
  334. <script src="assets/vendor/fuelux/js/spinner.js"></script>
  335. <!-- Custom -->
  336. <script src="custom/js/bootbox.js"></script>
  337. <script src="custom/js/moeda.js"></script>
  338. <!-- Specific Page Vendor -->
  339. <script src="assets/vendor/select2/js/select2.js"></script>
  340. <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
  341. <script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
  342. <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
  343. <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
  344. <script src="assets/vendor/bootstrap-maxlength/bootstrap-maxlength.js"></script>
  345. <script src="assets/vendor/autosize/autosize.js"></script>
  346. <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
  347. <script src="assets/vendor/pnotify/pnotify.custom.js"></script>
  348. <script src="assets/vendor/bootstrap-select/bootstrap-select.min.js"></script>
  349. <script src="assets/vendor/dropzone/dropzone.js"></script>
  350. <script src="custom/js/dropzone.js"></script>
  351. <!-- Theme Base, Components and Settings -->
  352. <script src="assets/javascripts/theme.js"></script>
  353. <!-- Theme Initialization Files -->
  354. <script src="assets/javascripts/theme.init.js"></script>
  355. <!-- Theme Custom -->
  356. <script src="assets/javascripts/theme.custom.js"></script>
  357. <script src="custom/js/jquery.maskMoney.js"></script>
  358. <script src="custom/js/portalMask.js"></script>
  359. <script type="text/javascript">
  360. var optModal = '<%=cOptMun%>';
  361. // Inicialize o Dropzone e adicione a funcionalidade de remoção
  362. Dropzone.autoDiscover = false; // Evitar que o Dropzone seja automaticamente inicializado.
  363. var myDropzone = new Dropzone("#dropzone-form", {
  364. url: "u_uploadfile.apw?PR=<%=cLCodLogin%>", // URL para o envio do arquivo
  365. addRemoveLinks: true, // Habilita o link de remoção
  366. dictRemoveFile: "Remover", // Texto do link de remoção
  367. init: function() {
  368. this.on("addedfile", function(file) {
  369. console.log("Arquivo adicionado: " + file.name);
  370. });
  371. // Aqui você pode adicionar algum comportamento adicional caso necessário, como
  372. // controlar o que acontece após o upload de um arquivo, se precisar.
  373. this.on("removedfile", function(file) {
  374. console.log("Arquivo removido: " + file.name);
  375. });
  376. }
  377. });
  378. /**
  379. Desabilita o enter na página
  380. **/
  381. $(function () {
  382. $('form').bind("keypress", function (e) {
  383. if (e.keyCode == 13) return false;
  384. });
  385. });
  386. //Remove as opções da tabela e adiciona o scroll
  387. $(document).ready(function () {
  388. $('#datatable-editable').DataTable({
  389. "scrollX": true,
  390. "ordering": false,
  391. "searching": false,
  392. "paging": false,
  393. "autoWidth": true,
  394. "info": false
  395. });
  396. $('.dataTables_length').addClass('.w-auto'); //ajusta o tamanho das colunas automaticamente
  397. });
  398. //Formata campos de moeda
  399. $(function() {
  400. //$('#iCK_PRCVEN01').maskMoney({thousands:'.', decimal:','});
  401. $('.myformato').maskMoney({thousands:'.', decimal:','});
  402. $('.percentual').maskMoney({thousands:'.', decimal:',', suffix:'%',allowNegative:true});
  403. })
  404. function formate() {
  405. $('.myformato').maskMoney({thousands:'.', decimal:','});
  406. $('.percentual').maskMoney({thousands:'.', decimal:',', suffix:'%',allowNegative:true});
  407. }
  408. function sleep(ms) {
  409. return new Promise(resolve => setTimeout(resolve, ms));
  410. }
  411. /**
  412. Valida a data de Término da oportunidade
  413. **/
  414. function vldDtFim(){
  415. var dDtIni = $("#AD1_DTINI").val();
  416. var dRDtIni = dDtIni.split("/").reverse();
  417. var dDtFim = $("#AD1_DTFIM").val();
  418. var dRDtFim = dDtFim.split("/").reverse();
  419. var dNDtIni = new Date(dRDtIni);
  420. var dNDtFim = new Date(dRDtFim);
  421. if(dNDtFim < dNDtIni){
  422. bootbox.alert('A data final deve ser maior ou igual a data inicial!');
  423. $("#AD1_DTFIM").focus();
  424. }
  425. }
  426. /**
  427. Atualiza o select da cidade de acordo com o estado
  428. **/
  429. function SetCidade(){
  430. var estado = $("#AD1_UF").val();
  431. var dialogTab = bootbox.dialog({
  432. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Localizando os municípios... Aguarde...</p>',
  433. closeButton: false
  434. });
  435. $.ajax({
  436. url: "U_fSetCidade.apw?PR=<%=cLCodLogin%>",
  437. data: 'estado='+estado,
  438. type: "POST",
  439. async: false,
  440. success:
  441. function(retorno) {
  442. if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
  443. $("html").html(retorno);
  444. return;
  445. }
  446. if ( retorno == "" && retorno.indexOf("Expires") == -1 ) {
  447. bootbox.alert('Falha ao localizar os municípios do estado '+estado+'.');
  448. }
  449. else {
  450. //Preenche o select das cidades
  451. document.getElementById('AD1_CIDADE').innerText = null;
  452. $("#AD1_CIDADE").append(retorno);
  453. optMun = retorno;
  454. $("#AD1_CIDADE").removeAttr('disabled');
  455. }
  456. }
  457. });
  458. dialogTab.modal('hide');
  459. }
  460. /**
  461. Valida a data de Término da oportunidade
  462. **/
  463. function vldStatus(){
  464. var cStatus = $("#AD1_STATUS").val();
  465. //Status perdido ou suspenso
  466. if(cStatus == '2' || cStatus == '3'){
  467. $("#AD1_ENCERR").removeAttr('disabled');
  468. $("#AD1_MTVENC").removeAttr('disabled');
  469. $("#AD1_ENCERR").focus();
  470. }else {
  471. $("#AD1_ENCERR").attr("disabled","");
  472. $("#AD1_MTVENC").attr("disabled","");
  473. $("#AD1_ENCERR").val("");
  474. $("#AD1_MTVENC").val("");
  475. }
  476. }
  477. //Salvar o orçamento
  478. $('#btSalvar').click(function() {
  479. var lRet = true
  480. var i = 0;
  481. var btnSlv = $(this);
  482. var dialogOrc = bootbox.dialog({
  483. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Validando homologação. Aguarde...</p>',
  484. closeButton: false
  485. });
  486. //Desabilita o botão
  487. btnSlv.attr({ 'disabled': 'disabled' });
  488. $.ajax({
  489. url: "U_VerSessao.apw?PR=<%=cLCodLogin%>",
  490. type: "POST",
  491. async: false,
  492. success:
  493. function(retorno) {
  494. if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
  495. $("html").html(retorno);
  496. return;
  497. }
  498. if (retorno == "nok"||retorno == ''||retorno.indexOf("Expires") != -1){
  499. $("#orc-informar").html();
  500. bootbox.alert('Não foi possível realizar a operação pois a sessão foi fechada. Faça login novamente.');
  501. lRet = false;
  502. btnSlv.removeAttr('disabled');
  503. dialogOrc.modal('hide');
  504. }
  505. }
  506. });
  507. /**
  508. Valida os campos obrigatorios
  509. **/
  510. //Cliente
  511. if ($("#AD1_CODCLI").val() == "") {
  512. lRet = false;
  513. $("#orc-informar").html();
  514. new PNotify({
  515. title: 'Campo obrigatório',
  516. text: 'Preencha o campo Cliente!',
  517. type: 'error',
  518. });
  519. btnSlv.removeAttr('disabled');
  520. dialogOrc.modal('hide');
  521. $("#AD1_CODCLI").focus();
  522. }
  523. //Descrição
  524. if (lRet == true && $("#AD1_DESCRI").val() == "") {
  525. lRet = false;
  526. $("#orc-informar").html();
  527. new PNotify({
  528. title: 'Campo obrigatório',
  529. text: 'Preencha o campo Descrição!',
  530. type: 'error',
  531. });
  532. btnSlv.removeAttr('disabled');
  533. dialogOrc.modal('hide');
  534. $("#AD1_DESCRI").focus();
  535. }
  536. //Data de Término
  537. if (lRet == true && $("#AD1_DTFIM").val() == "") {
  538. lRet = false;
  539. $("#orc-informar").html();
  540. new PNotify({
  541. title: 'Campo obrigatório',
  542. text: 'Preencha o campo Data Término!',
  543. type: 'error',
  544. });
  545. btnSlv.removeAttr('disabled');
  546. dialogOrc.modal('hide');
  547. $("#AD1_DTFIM").focus();
  548. }
  549. //Vendedor
  550. if (lRet == true && $("#AD1_VEND").val() == "") {
  551. lRet = false;
  552. $("#orc-informar").html();
  553. new PNotify({
  554. title: 'Campo obrigatório',
  555. text: 'Preencha o campo Vendedor!',
  556. type: 'error',
  557. });
  558. btnSlv.removeAttr('disabled');
  559. dialogOrc.modal('hide');
  560. $("#AD1_VEND").focus();
  561. }
  562. //Regional
  563. if (lRet == true && $("#AD1_REGION").val() == "") {
  564. lRet = false;
  565. $("#orc-informar").html();
  566. new PNotify({
  567. title: 'Campo obrigatório',
  568. text: 'Preencha o campo Regional!',
  569. type: 'error',
  570. });
  571. btnSlv.removeAttr('disabled');
  572. dialogOrc.modal('hide');
  573. $("#AD1_REGIONAL").focus();
  574. }
  575. //Estado
  576. if (lRet == true & $("#AD1_UF").val() == "") {
  577. lRet = false;
  578. $("#orc-informar").html();
  579. new PNotify({
  580. title: 'Campo obrigatório',
  581. text: 'Preencha o campo Estado!',
  582. type: 'error',
  583. });
  584. btnSlv.removeAttr('disabled');
  585. dialogOrc.modal('hide');
  586. $("#AD1_UF").focus();
  587. }
  588. //Cidade
  589. if (lRet == true & $("#AD1_CIDADE").val() == "") {
  590. lRet = false;
  591. $("#orc-informar").html();
  592. new PNotify({
  593. title: 'Campo obrigatório',
  594. text: 'Preencha o campo Cidade!',
  595. type: 'error',
  596. });
  597. btnSlv.removeAttr('disabled');
  598. dialogOrc.modal('hide');
  599. $("#AD1_CIDADE").focus();
  600. }
  601. if (lRet == true && $("#AD1_CONTCL").val() == "") {
  602. lRet = false;
  603. $("#orc-informar").html();
  604. new PNotify({
  605. title: 'Campo obrigatório',
  606. text: 'Preencha o campo Contato!',
  607. type: 'error',
  608. });
  609. btnSlv.removeAttr('disabled');
  610. dialogOrc.modal('hide');
  611. $("#AD1_CONTCL").focus();
  612. }
  613. if (lRet == true && $("#AD1_STATUS").val() == "") {
  614. lRet = false;
  615. $("#orc-informar").html();
  616. new PNotify({
  617. title: 'Campo obrigatório',
  618. text: 'Preencha o campo Status!',
  619. type: 'error',
  620. });
  621. btnSlv.removeAttr('disabled');
  622. dialogOrc.modal('hide');
  623. $("#AD1_STATUS").focus();
  624. }
  625. if (lRet == true && $("#AD1_STATUS").val()!= "") {
  626. //Suspensa/perdida
  627. if($("#AD1_STATUS").val() == "2" || $("#AD1_STATUS").val() == "3"){
  628. if ($("#AD1_ENCERR").val().trim()==""){
  629. lRet = false;
  630. $("#orc-informar").html();
  631. new PNotify({
  632. title: 'Campo obrigatório',
  633. text: 'Preencha o campo Encerramento!',
  634. type: 'error',
  635. });
  636. btnSlv.removeAttr('disabled');
  637. dialogOrc.modal('hide');
  638. $("#AD1_ENCERR").focus();
  639. } else {
  640. if ($("#AD1_MTVENC").val().trim()==""){
  641. lRet = false;
  642. $("#orc-informar").html();
  643. new PNotify({
  644. title: 'Campo obrigatório',
  645. text: 'Preencha o campo Motivo do Encerramento!',
  646. type: 'error',
  647. });
  648. btnSlv.removeAttr('disabled');
  649. dialogOrc.modal('hide');
  650. $("#AD1_MTVENC").focus();
  651. }
  652. }
  653. }
  654. }
  655. if (lRet == true && $("#AD1_HOMOLO").val() == "") {
  656. lRet = false;
  657. $("#orc-informar").html();
  658. new PNotify({
  659. title: 'Campo obrigatório',
  660. text: 'Preencha o campo Status da homologação!',
  661. type: 'error',
  662. });
  663. btnSlv.removeAttr('disabled');
  664. dialogOrc.modal('hide');
  665. $("#AD1_HOMOLO").focus();
  666. }
  667. if (lRet == true && $("#AD1_SEGMEN").val() == "") {
  668. lRet = false;
  669. $("#orc-informar").html();
  670. new PNotify({
  671. title: 'Campo obrigatório',
  672. text: 'Preencha o campo Segmento!',
  673. type: 'error',
  674. });
  675. btnSlv.removeAttr('disabled');
  676. dialogOrc.modal('hide');
  677. $("#AD1_SEGMEN").focus();
  678. }
  679. if (lRet == true && $("#AD1_NIVOPO").val() == "") {
  680. lRet = false;
  681. $("#orc-informar").html();
  682. new PNotify({
  683. title: 'Campo obrigatório',
  684. text: 'Preencha o campo Nível!',
  685. type: 'error',
  686. });
  687. btnSlv.removeAttr('disabled');
  688. dialogOrc.modal('hide');
  689. $("#AD1_NIVOPO").focus();
  690. }
  691. //Valida a condição de pagamento
  692. if (lRet == true){
  693. dialogOrc.modal('hide');
  694. //Submete o formulário
  695. salvarOport(btnSlv);
  696. }
  697. })
  698. $('#btExcluir').click(function() {
  699. var lRet = true;
  700. var btnExc = $(this);
  701. //Desabilita o botão
  702. $('#btExcluir').attr({ 'disabled': 'disabled' });
  703. objDados = {
  704. AD1_FILIAL: $('#AD1_FILIAL').val(),
  705. AD1_NROPOR: $('#AD1_NROPOR').val()
  706. };
  707. $.ajax({
  708. type: "POST",
  709. url: "U_ExcOpt.apw?PR=<%=cLCodLogin%>",
  710. async: false,
  711. data: objDados
  712. }).fail(function(){
  713. bootbox.alert({
  714. title: "Exclusão da homologação",
  715. message: "Não foi possível excluir a homologação.",
  716. backdrop: true,
  717. callback: function (result) {
  718. btnSlv.removeAttr('disabled');
  719. }
  720. });
  721. }).done(function(strXml) {
  722. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  723. $("html").html(strXml);
  724. return;
  725. }
  726. bootbox.alert({
  727. title: "Exclusão da homologação",
  728. message: "A homologação "+$('#AD1_NROPOR').val()+" foi excluída com sucesso.",
  729. backdrop: true,
  730. callback: function (result) {
  731. document.location.href = "U_Oportunidade.apw?PR=<%=cLCodLogin%>";
  732. }
  733. });
  734. });
  735. })
  736. /**
  737. // Função para salvar os arquivos anexados
  738. **/
  739. function cancDoctos(){
  740. //aguardar
  741. var x = [];
  742. var cAnexos = "";
  743. $('#dialogAnex').modal('hide');
  744. $(".dz-filename").each(function() { x.push($(this).text())});
  745. for (i = 0; i < x.length; i++) {
  746. cAnexos += x[i]+"|";
  747. }
  748. oObjDados = {'anexos':cAnexos};
  749. $.ajax({
  750. url: "U_DelDoctos.apw?PR=<%=cLCodLogin%>",
  751. data: oObjDados,
  752. type: "POST",
  753. async: false,
  754. success:
  755. function(retorno) {
  756. if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
  757. $("html").html(retorno);
  758. return;
  759. }
  760. }
  761. });
  762. }
  763. //Submete formulario
  764. function salvarOport(btnSlv){
  765. var numoport = "";
  766. var titulo = "Manutenção da homologação";
  767. var dialogSlv = bootbox.dialog({
  768. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Salvando a homologação... Aguarde...</p>',
  769. closeButton: false
  770. });
  771. objDados = {
  772. AD1_FILIAL: $('#AD1_FILIAL').val(),
  773. AD1_NROPOR: $('#AD1_NROPOR').val(),
  774. AD1_DESCRI: $('#AD1_DESCRI').val(),
  775. AD1_DESCOP: $('#AD1_DESCOP').val(),
  776. AD1_CODCLI: $('#AD1_CODCLI').val(),
  777. AD1_LOJCLI: $('#AD1_LOJCLI').val(),
  778. AD1_CONTCL: $('#AD1_CONTCL').val(),
  779. AD1_EMAIL1: $('#AD1_EMAIL1').val(),
  780. AD1_PARC1: $('#AD1_PARC1').val(),
  781. AD1_UF: $("#AD1_UF").val(),
  782. AD1_CIDADE: $('#AD1_CIDADE').val(),
  783. AD1_ENDER: $('#AD1_ENDER').val(),
  784. AD1_DTINI: $('#AD1_DTINI').val(),
  785. AD1_DTFIM: $('#AD1_DTFIM').val(),
  786. AD1_REGION: $('#AD1_REGION').val(),
  787. AD1_VEND: $('#AD1_VEND').val(),
  788. AD1_PERCEI: $('#AD1_PERCEI').val(),
  789. AD1_CONTAT: $('#AD1_CONTAT').val(),
  790. AD1_HOMOLO: $('#AD1_HOMOLO').val(),
  791. AD1_COMIRT: $('#AD1_COMIRT').val(),
  792. AD1_SEGMEN: $('#AD1_SEGMEN').val(),
  793. AD1_NIVOPO: $('#AD1_NIVOPO').val(),
  794. AD1_MEMO: $('#AD1_MEMO').val(),
  795. AD1_STATUS: $('#AD1_STATUS').val(),
  796. AD1_ENCERR: $('#AD1_ENCERR').val(),
  797. AD1_MTVENC: $('#AD1_MTVENC').val(),
  798. OPCAO: $('#OPCAO').val()
  799. };
  800. if($("#OPCAO").val() == "3"){
  801. msg = "A homologação foi incluída com sucesso.";
  802. titulo = "Inclusão de homologação";
  803. operacao = "incluir";
  804. }
  805. if($("#OPCAO").val() == "4"){
  806. msg = "A homologação foi alterada com sucesso.";
  807. titulo = "Alteração de homologação";
  808. operacao = "alterar";
  809. }
  810. if($("#OPCAO").val() == "5"){
  811. msg = "A homologação foi excluída com sucesso.";
  812. titulo = "Exclusão de homologação";
  813. operacao = "excluir";
  814. }
  815. $.ajax({
  816. type: "POST",
  817. url: "U_SlvOpt.apw?PR=<%=cLCodLogin%>",
  818. async: false,
  819. data: objDados
  820. }).fail(function(){
  821. bootbox.alert({
  822. title: titulo,
  823. message: "Não foi possível "+operacao+" a homologação.",
  824. backdrop: true,
  825. callback: function (result) {
  826. btnSlv.removeAttr('disabled');
  827. dialogSlv.modal('hide');
  828. }
  829. });
  830. }).done(function(strXml) {
  831. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  832. $("html").html(strXml);
  833. return;
  834. }
  835. if (strXml == 'erro'||strXml == ''||strXml.indexOf("Expires") != -1||strXml.indexOf("invalid") != -1){
  836. if (strXml == ''){
  837. bootbox.alert({
  838. title: titulo,
  839. message: "Aguarde o prazo de 3 minutos para "+operacao+" uma nova homologação.",
  840. backdrop: true,
  841. callback: function (result) {
  842. btnSlv.removeAttr('disabled');
  843. dialogSlv.modal('hide');
  844. }
  845. });
  846. }else{
  847. bootbox.alert({
  848. title: titulo,
  849. message: "Falha ao "+operacao+" a homologação.",
  850. backdrop: true,
  851. callback: function (result) {
  852. btnSlv.removeAttr('disabled');
  853. dialogSlv.modal('hide');
  854. }
  855. });
  856. }
  857. }
  858. else {
  859. if($("#OPCAO").val() == "3"){
  860. numoport = " Foi gerada a homologação nº "+strXml+"."
  861. }
  862. bootbox.alert({
  863. title: titulo,
  864. message: msg+numoport,
  865. backdrop: true,
  866. callback: function (result) {
  867. document.location.href = "U_Oportunidade.apw?PR=<%=cLCodLogin%>";
  868. dialogSlv.modal('hide');
  869. }
  870. });
  871. }
  872. });
  873. }
  874. /**
  875. Função para anexar arquivos
  876. **/
  877. function Anexar(cCodAD1){
  878. $("#codAD1").val(cCodAD1);
  879. $("#dialogAnex").modal('show');
  880. }
  881. </script>
  882. </body>
  883. </html>