AddOrc.aph.bak 135 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290
  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. <!-- Theme CSS -->
  45. <link rel="stylesheet" href="assets/stylesheets/theme.css" />
  46. <!-- Skin CSS -->
  47. <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
  48. <!-- Theme Custom CSS -->
  49. <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
  50. <!-- Head Libs -->
  51. <script src="assets/vendor/modernizr/modernizr.js"></script>
  52. <script src="assets/vendor/style-switcher/style.switcher.localstorage.js"></script>
  53. <style>
  54. .flexContainer {
  55. display: flex;
  56. }
  57. .smsediticon {
  58. flex: 1;
  59. }
  60. .btedit { /* margem e largura da imagem */
  61. margin-left: -45px;
  62. width: 47px;
  63. }
  64. </style>
  65. </head>
  66. <body>
  67. <section class="body">
  68. <!-- start: header -->
  69. <header class="header">
  70. <%=cHeader%>
  71. </header>
  72. <!-- end: header -->
  73. <div class="inner-wrapper">
  74. <!-- start: sidebar -->
  75. <aside id="sidebar-left" class="sidebar-left">
  76. <div class="sidebar-header">
  77. <div class="sidebar-title">
  78. Menu
  79. </div>
  80. <div class="sidebar-toggle hidden-xs" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
  81. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  82. </div>
  83. </div>
  84. <div class="nano">
  85. <div class="nano-content">
  86. <nav id="menu" class="nav-main" role="navigation">
  87. <ul class="nav nav-main">
  88. <%=cMenus%>
  89. </ul>
  90. </nav>
  91. </div>
  92. <script>
  93. // Maintain Scroll Position
  94. if (typeof localStorage !== 'undefined') {
  95. if (localStorage.getItem('sidebar-left-position') !== null) {
  96. var initialPosition = localStorage.getItem('sidebar-left-position'),
  97. sidebarLeft = document.querySelector('#sidebar-left .nano-content');
  98. sidebarLeft.scrollTop = initialPosition;
  99. }
  100. }
  101. </script>
  102. </div>
  103. </aside>
  104. <!-- end: sidebar -->
  105. <section role="main" class="content-body">
  106. <header class="page-header">
  107. <h2><%=cPagina%></h2>
  108. <div class="right-wrapper pull-right">
  109. </div>
  110. </header>
  111. <!-- start: page -->
  112. <section class="panel">
  113. <!-- <header class="panel-heading">
  114. </header> -->
  115. <div class="panel-body">
  116. <div class="row">
  117. <div class="col-lg-12">
  118. <section class="panel form-wizard" id="w9">
  119. <form action = "" method="post" class="form-horizontal" id="formOrc">
  120. <div class="tabs">
  121. <ul class="nav nav-tabs nav-justify">
  122. <li class="active">
  123. <a href="#orc-informar" data-toggle="tab" class="text-center">Orçamento</a>
  124. </li>
  125. <!--
  126. <li class="">
  127. <a href="#orc-anexos" data-toggle="tab" class="text-center">Anexos</a>
  128. </li>
  129. -->
  130. <%
  131. private cTab := ""
  132. if cOpcao == 'edit'
  133. cTab += '<li class="">'
  134. cTab += ' <a href="#orc-parceiros" data-toggle="tab" class="text-center" >Parceiros</a>'
  135. cTab += '</li>'
  136. endif
  137. %>
  138. <%=cTab%>
  139. </ul>
  140. <div class="tab-content">
  141. <div id="orc-informar" class="tab-pane active">
  142. <!--
  143. <%=cVendedor%>
  144. -->
  145. <!-- linha 0: dados do Orçamento -->
  146. <%=cFilOrc%>
  147. <%=cCodOrc%>
  148. <div class="mb-md hidden-lg hidden-xl"></div>
  149. <div class="mb-md hidden-lg hidden-xl"></div>
  150. <!-- linha 1: dados da empresa -->
  151. <div class="row form-group">
  152. <div class="col-lg-6">
  153. <label class="control-label">Cliente
  154. <span class="required">*</span>
  155. </label>
  156. <%=cCliente%>
  157. </div>
  158. <div class="col-lg-5">
  159. <label class="control-label">Oportunidade</label>
  160. <%=cOport%>
  161. </div>
  162. <div class="col-lg-1">
  163. <label class="control-label">Revisão</label>
  164. <%=cRevOpt%>
  165. </div>
  166. </div>
  167. <!-- linha 3: input -->
  168. <div class="row form-group">
  169. <div class="col-lg-3">
  170. <label class="control-label">Tipo de Cliente</label>
  171. <%=cTpCliente%>
  172. </div>
  173. <div class="col-lg-2">
  174. <label class="control-label">Grupo de Tributação</label>
  175. <%=cGrpTrib%>
  176. </div>
  177. <div class="col-lg-5" style="display:none;">
  178. <label class="control-label">Tabela de Preço</label>
  179. <%=cTabela%>
  180. </div>
  181. <div class="col-lg-4">
  182. <label class="control-label">Contato
  183. <span class="required">*</span>
  184. </label>
  185. <%=cContato%>
  186. </div>
  187. <div class="col-lg-1">
  188. <label class="control-label">DDD
  189. <span class="required">*</span>
  190. </label>
  191. <%=cContDDD%>
  192. </div>
  193. <div class="col-lg-2">
  194. <label class="control-label">Telefone
  195. <span class="required">*</span>
  196. </label>
  197. <%=cContTel%>
  198. </div>
  199. </div>
  200. <!-- linha 4 input -->
  201. <div class="row form-group">
  202. <div class="col-lg-6">
  203. <label class="control-label">Cliente de Entrega
  204. <span class="required">*</span>
  205. </label>
  206. <%=cCliEntr%>
  207. </div>
  208. <div class="col-lg-6">
  209. <label class="control-label">Local de Entrega</label>
  210. <%=cLocalEnt%>
  211. </div>
  212. </div>
  213. <!-- linha 5 input -->
  214. <div class="row form-group">
  215. <div class="col-lg-6">
  216. <label class="control-label">Obra
  217. <span class="required">*</span>
  218. </label>
  219. <%=cObra%>
  220. </div>
  221. <div class="col-lg-6">
  222. <label class="control-label">Tipo da Obra
  223. <span class="required">*</span>
  224. </label>
  225. <%=cTpObra%>
  226. </div>
  227. </div>
  228. <!-- linha 6 input -->
  229. <div class="row form-group">
  230. <div class="col-lg-3">
  231. <label class="control-label">Status da Obra
  232. <span class="required">*</span>
  233. </label>
  234. <%=cStatusObra%>
  235. </div>
  236. <div class="col-lg-3">
  237. <label class="control-label">Previsão de Fechamento
  238. <span class="required">*</span>
  239. </label>
  240. <%=cPrevFecha%>
  241. </div>
  242. <div class="col-lg-2">
  243. <label class="control-label">Retorno</label>
  244. <%=cRetorno%>
  245. </div>
  246. <div class="col-lg-3">
  247. <label class="control-label">Condição de Pagamento
  248. <span class="required">*</span>
  249. </label>
  250. <%=cCondPag%>
  251. </div>
  252. </div>
  253. <!-- linha 7 input -->
  254. <div class="row form-group">
  255. <div class="col-lg-6">
  256. <label class="control-label">Intermediador</label>
  257. <%=cIntermed%>
  258. </div>
  259. <div class="col-lg-2">
  260. <label class="control-label">Estudo Luminotécnico
  261. <span class="required">*</span>
  262. </label>
  263. <%=cEstudo%>
  264. </div>
  265. <div class="col-lg-2">
  266. <label class="control-label">Num. Estudo</label>
  267. <%=cNumEst%>
  268. </div>
  269. </div>
  270. <!-- linha 8 input -->
  271. <div class="row form-group">
  272. <div class="col-lg-3">
  273. <label class="control-label">Segmento
  274. <span class="required">*</span>
  275. </label>
  276. <%=cSegmento%>
  277. </div>
  278. <div class="col-lg-2">
  279. <label class="control-label">Prospecção</label>
  280. <%=cProsp%>
  281. </div>
  282. <div class="col-lg-3">
  283. <label class="control-label">Prospectado Por</label>
  284. <%=cProspPor%>
  285. </div>
  286. <div class="col-lg-4">
  287. <label class="control-label">Regional
  288. <span class="required">*</span>
  289. </label>
  290. <%=cRegional%>
  291. </div>
  292. </div>
  293. <!-- linha 9: input -->
  294. <div class="row form-group">
  295. <div class="col-lg-6">
  296. <label class="control-label">Vendedor 2
  297. <span class="required">*</span>
  298. </label>
  299. <%=cVend2%>
  300. </div>
  301. <div class="col-lg-6">
  302. <label class="control-label">Vendedor 3</label>
  303. <%=cVend3%>
  304. </div>
  305. </div>
  306. <!-- linha 10: input -->
  307. <div class="row form-group">
  308. <div class="col-lg-4">
  309. <label class="control-label">Vendedor 4</label>
  310. <%=cVend4%>
  311. </div>
  312. <div class="col-lg-4">
  313. <label class="control-label">Especificado por</label>
  314. <%=cEspecif%>
  315. </div>
  316. <div class="col-lg-4">
  317. <label class="control-label">Negociadora
  318. <span class="required">*</span>
  319. </label>
  320. <%=cNegociad%>
  321. </div>
  322. </div>
  323. <!-- linha 11: input -->
  324. <div class="row form-group">
  325. <div class="col-lg-2">
  326. <label class="control-label">Validade</label>
  327. <%=cValidade%>
  328. </div>
  329. <div class="col-lg-2">
  330. <label class="control-label">Prazo de Embarque</label>
  331. <%=cPrazoEmb%>
  332. </div>
  333. <div class="col-lg-2">
  334. <label class="control-label">Tipo de Frete</label>
  335. <%=cTpFrete%>
  336. </div>
  337. <div class="col-lg-2">
  338. <label class="control-label">% Frete
  339. </label>
  340. <%=cPFrete%>
  341. </div>
  342. <div class="col-lg-2">
  343. <label class="control-label">Valor do Frete</label>
  344. <%=cValFre%>
  345. </div>
  346. <div class="col-lg-2">
  347. <label class="control-label">% RT</label>
  348. <%=cComRT%>
  349. </div>
  350. <!--
  351. <div class="col-lg-4">
  352. <label class="control-label">Transportadora</label>
  353. <%=cTransp%>
  354. </div>
  355. -->
  356. </div>
  357. <!-- linha 12 input -->
  358. <div class="row form-group">
  359. <div class="col-md-5">
  360. <label class="control-label" for="textareaDefault">Observação Comercial</label>
  361. <textarea class="form-control" rows="3" data-plugin-maxlength="" maxlength="240" id="CJ_OBS" name="CJ_OBS" <%=Iif(!lEdit,'disabled','')%>><%=cObsCom%></textarea>
  362. </div>
  363. <%=cMargemCont%>
  364. </div>
  365. <!-- linha 13 input -->
  366. <div class="row form-group">
  367. </div>
  368. <br>
  369. <br>
  370. <!-- tabela com os produtos do orçamento -->
  371. <div class="table-responsive" id="ItensOrc" style="overflow-x:visible">
  372. <section class="panel">
  373. <header class="panel-heading">
  374. <h2 class="panel-title">Itens do Orçamento</h2>
  375. </header>
  376. <table class="table table-bordered table-striped mb-none table-hover table-condensed" id="datatable-editable" aria-describedby="datatable-details_info">
  377. <thead>
  378. <tr>
  379. <%=cOrcCabec%>
  380. </tr>
  381. </thead>
  382. <tbody>
  383. <%=cOrcItens%>
  384. </tbody>
  385. </table>
  386. </section>
  387. </div>
  388. <br>
  389. <!-- botões com ações na tabela dos itens -->
  390. <%=cBtnItens%>
  391. <br>
  392. <br>
  393. <!-- Totais -->
  394. <div class="col-lg-13">
  395. <section class="panel">
  396. <header class="panel-heading">
  397. <h2 class="panel-title">Totais do Orçamento</h2>
  398. </header>
  399. <div class="panel-body">
  400. <div class="form-inline" align="center">
  401. <div class="row">
  402. <%=cTotalReg%>
  403. <br />
  404. <div class="col-sm-12">
  405. <label class="">Itens&nbsp;</label>
  406. <input class="form-control text-right" id="TOTAL_ITENS" name="TOTAL_ITENS" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTVlrUnit,"@E 999,999,999,999.99")%>></input>
  407. &nbsp;&nbsp;&nbsp;&nbsp;
  408. <label class="">Impostos&nbsp;</label>
  409. <input class="form-control text-right" id="TOTAL_IMP" name="TOTAL_IMP" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTImpostos,"@E 999,999,999,999.99")%>></input>
  410. &nbsp;&nbsp;&nbsp;&nbsp;
  411. <label class="">Frete&nbsp;</label>
  412. <input class="form-control text-right" id="TOTAL_FRETE" name="TOTAL_FRETE" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTFrete,"@E 999,999,999,999.99")%>></input>
  413. &nbsp;&nbsp;&nbsp;&nbsp;
  414. <label class="text-weight-extrabold">Total&nbsp;</label>
  415. <input class="form-control text-right text-weight-bold" id="TOTAL_ORC" name="TOTAL_ORC" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTTotal,"@E 999,999,999,999.99")%>></input>
  416. </div>
  417. </div>
  418. <br>
  419. <!--
  420. <div class="row">
  421. <div class="col-sm-12">
  422. <label class="">Desconto&nbsp;</label>
  423. <input class="form-control text-right" id="TOTAL_ACRESC" name="TOTAL_ACRESC" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTAcresc,"@E 999,999,999,999.99")%>></input>
  424. <label class="">Total&nbsp;</label>
  425. <input class="form-control text-right" id="TOTAL_ORC" name="TOTAL_ORC" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTTotal,"@E 999,999,999,999.99")%>></input>
  426. </div>
  427. </div>
  428. <div class="row">
  429. <div class="col-sm-12">
  430. <label class="">Comissão Prevista&nbsp;</label>
  431. <input class="form-control text-right" id="TOTAL_COM" name="TOTAL_COM" placeholder="0,00" disabled="" type="text" value=<%=Transform(nTComiss,"@E 999,999,999,999.99")%>></input>
  432. </div>
  433. </div>
  434. -->
  435. </div>
  436. </div>
  437. </section>
  438. </div>
  439. <br>
  440. <br>
  441. <div class="row form-group" align="center">
  442. <%=cBotoes%>
  443. </div>
  444. </div>
  445. <!-- aba de anexos
  446. <div id="orc-anexos" class="tab-pane">
  447. <div class="form-group">
  448. <label class="col-md-3 control-label">Anexar: </label>
  449. <div class="col-md-9">
  450. <div class="fileupload fileupload-new" data-provides="fileupload">
  451. <div class="input-append">
  452. <div class="uneditable-input">
  453. <i class="fa fa-file fileupload-exists"></i>
  454. <span class="fileupload-preview"></span>
  455. </div>
  456. <span class="btn btn-default btn-file">
  457. <span class="fileupload-exists">Selecionar</span>
  458. <span class="fileupload-new">Arquivo</span>
  459. <input type="file" name="anexo" id="anexo" />
  460. </span>
  461. <a href="#" id="btnOrcUpload" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Gravar</a>
  462. </div>
  463. </div>
  464. </div>
  465. </div>
  466. <div class="row mg-files" data-sort-destination data-sort-id="media-gallery" id="OrcAnexos">
  467. <%=cAnexos%>
  468. </div>
  469. </div>
  470. -->
  471. <div class="tab-pane" id="orc-parceiros">
  472. <div class="panel panel-default">
  473. <div class="panel-heading">
  474. <h3 class="panel-title">Parceiros para Comissão RT</h3>
  475. </div>
  476. <div class="panel-body">
  477. <button type="button" class="btn btn-primary" id="btnIncluir">
  478. <i class="fa fa-plus"></i> Incluir
  479. </button>
  480. <div class="table-responsive" style="margin-top: 15px;">
  481. <table class="table table-bordered table-striped mb-none table-hover dataTable no-footer">
  482. <thead>
  483. <tr>
  484. <th>Parceiro</th>
  485. <th>% RT Pagar</th>
  486. <th>% RT Aumentar</th>
  487. <th>Editar</th>
  488. </tr>
  489. </thead>
  490. <tbody id="tblParceiros">
  491. </tbody>
  492. </table>
  493. </div>
  494. </div>
  495. </div>
  496. </div>
  497. </div>
  498. </div>
  499. </form>
  500. </section>
  501. </div>
  502. </div>
  503. </div>
  504. </section>
  505. <div class="modal fade" id="dialogCusto" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  506. <div class="modal-dialog">
  507. <div class="modal-content">
  508. <div class="modal-header">
  509. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  510. <h4 class="modal-title" id="myModalLabel">Custo e Preço de Venda do Produto</h4>
  511. </div>
  512. <div class="modal-body">
  513. <label class="control-label">Valor de Venda Unitário</label>
  514. <input id="VLRVENDA" name="VLRVENDA" class="form-control money text-right" placeholder="0,00" value="">
  515. <input type="hidden" id="itemAtu"/>
  516. <br>
  517. <label class="control-label">Valor do Custo Unitário</label>
  518. <input id="CUSTO" name="CUSTO" class="form-control money text-right" placeholder="0,00" value="">
  519. </div>
  520. <div class="modal-footer">
  521. <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
  522. <button type="button" class="btn btn-primary" onclick="javascript:gravaCusto( $('#itemAtu').val(),$('#VLRVENDA').val(),$('#CUSTO').val() );">Confirmar</button>
  523. </div>
  524. </div>
  525. </div>
  526. </div>
  527. <div class="modal fade" id="dialogEntrega" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  528. <div class="modal-dialog">
  529. <div class="modal-content">
  530. <div class="modal-header">
  531. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  532. <h4 class="modal-title" id="myModalLabel">Local de Entrega</h4>
  533. </div>
  534. <div class="col-md-12">
  535. <label class="control-label">Estado</label>
  536. <select data-plugin-selectTwo data-live-search="true" id="UF_ENTREGA" name="UF_ENTREGA" class="form-control poulate placeholder mb-md" style="width: 400px;" data-plugin-options='{"placeholder":"Selecione um estado"}' onchange="javascript:getMunEnt($('#UF_ENTREGA').val());">
  537. <%=cOptUF%>
  538. </select>
  539. <br>
  540. <label class="control-label">Município</label>
  541. <select data-plugin-selectTwo data-live-search="true" id="MUN_ENTREGA" name="MUN_ENTREGA" class="form-control poulate placeholder mb-md" style="width: 500px;" data-plugin-options='{"placeholder":"Selecione um município"}' disabled>
  542. <%=cOptMun%>
  543. </select>
  544. </div>
  545. <div class="modal-footer">
  546. <br>
  547. <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
  548. <button type="button" class="btn btn-primary" onclick="javascript:gravaEntrega( $('#UF_ENTREGA').val(),$('#MUN_ENTREGA').val() );">Confirmar</button>
  549. </div>
  550. </div>
  551. </div>
  552. </div>
  553. <!-- Modal Incluir Parceiro -->
  554. <div class="modal fade" id="dialogParceiro" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  555. <div class="modal-dialog">
  556. <div class="modal-content">
  557. <div class="modal-header">
  558. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  559. <h4 class="modal-title" id="tituloIncPar">Incluir Parceiro</h4>
  560. </div>
  561. <div class="modal-body">
  562. <form id="formParceiro" class="form-horizontal">
  563. <input type="hidden" name="operacao" id="operacao" value="create" />
  564. <div class="form-group">
  565. <div class="col-sm-12">
  566. <div class="alert alert-info">
  567. Preencha os dados do parceiro
  568. </div>
  569. </div>
  570. </div>
  571. <div class="form-group">
  572. <label class="col-sm-3 control-label">Parceiro</label>
  573. <div class="col-sm-9">
  574. <%=cLisPar%>
  575. </div>
  576. </div>
  577. <div class="form-group">
  578. <label class="col-sm-3 control-label">% RT Pagar</label>
  579. <div class="col-sm-9">
  580. <%
  581. private cCampoRTP := ""
  582. if cParUs $ HttpSession->CodVend
  583. cCampoRTP := '<input class="form-control" type="number" name="rtpagar" id="cmbRTPagar" value="" />'
  584. else
  585. cCampoRTP := '<select class="form-control" id="cmbRTPagar" name="rtpagar" onchange="atualizaRT(this.value)">'
  586. cCampoRTP += '<option value="">Selecione...</option>'
  587. cCampoRTP += '<option value="3">3%</option>'
  588. cCampoRTP += '<option value="5">5%</option>'
  589. cCampoRTP += '<option value="7">7%</option>'
  590. cCampoRTP += '<option value="10">10%</option>'
  591. cCampoRTP += '</select>'
  592. Endif
  593. %>
  594. <%=cCampoRTP%>
  595. </div>
  596. </div>
  597. <div class="form-group">
  598. <label class="col-sm-3 control-label">% RT Aumentar</label>
  599. <div class="col-sm-9">
  600. <%
  601. private cCampoRTA := ""
  602. if cParUs $ HttpSession->CodVend
  603. cCampoRTA := '<input class="form-control" type="number" name="rtaumentar" id="txtRTAumentar" value="" />'
  604. else
  605. cCampoRTA := '<select class="form-control" id="txtRTAumentar" name="rtaumentar" readonly>'
  606. cCampoRTA += '<option value="">Selecione...</option>'
  607. cCampoRTA += '<option value="5">5%</option>'
  608. cCampoRTA += '<option value="8.5">8,5%</option>'
  609. cCampoRTA += '<option value="12">12%</option>'
  610. cCampoRTA += '<option value="19">19%</option>'
  611. cCampoRTA += '</select>'
  612. Endif
  613. %>
  614. <%=cCampoRTA%>
  615. </div>
  616. </div>
  617. </form>
  618. </div>
  619. <div class="modal-footer">
  620. <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
  621. <button type="button" class="btn btn-primary" id="btnSalvarParceiro">Salvar</button>
  622. </div>
  623. </div>
  624. </div>
  625. </div>
  626. <div style="display:none;">
  627. <form action="U_OrcUpload.apw?PR=<%=cLCodLogin%>" method="post" id="frmOrcUpload" enctype="multipart/form-data">
  628. <input type="hidden" name="dirOrc" value="<%=cDirOrc%>" />
  629. </form>
  630. </div>
  631. <footer class="panel-footer text-right">
  632. Desenvolvido por <img src="images/sms.png" />
  633. </footer>
  634. </div>
  635. </section>
  636. <!-- end: page -->
  637. <div id="dialogRemover" class="modal-block mfp-hide">
  638. <section class="panel">
  639. <header class="panel-heading">
  640. <h2 class="panel-title">Exclusão da linha</h2>
  641. </header>
  642. <div class="panel-body">
  643. <div class="modal-wrapper">
  644. <div class="modal-text">
  645. <p>Confirma a exclusão desta linha?</p>
  646. </div>
  647. </div>
  648. </div>
  649. <footer class="panel-footer">
  650. <div class="row">
  651. <div class="col-md-12 text-right">
  652. <button id="dialogConfirm" class="btn btn-primary">Confirma</button>
  653. <button id="dialogCancel" class="btn btn-default">Cancela</button>
  654. </div>
  655. </div>
  656. </footer>
  657. </section>
  658. </div>
  659. <div id="modalSuccess" class="modal-block modal-block-success mfp-hide">
  660. <section class="panel">
  661. <header class="panel-heading">
  662. <h2 class="panel-title">Success!</h2>
  663. </header>
  664. <div class="panel-body">
  665. <div class="modal-wrapper">
  666. <div class="modal-icon">
  667. <i class="fa fa-check"></i>
  668. </div>
  669. <div class="modal-text">
  670. <h4>Success</h4>
  671. <p>This is a successfull message.</p>
  672. </div>
  673. </div>
  674. </div>
  675. <footer class="panel-footer">
  676. <div class="row">
  677. <div class="col-md-12 text-right">
  678. <button class="btn btn-success modal-dismiss">OK</button>
  679. </div>
  680. </div>
  681. </footer>
  682. </section>
  683. </div>
  684. <!-- Vendor -->
  685. <script src="assets/vendor/jquery/jquery.js"></script>
  686. <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
  687. <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
  688. <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
  689. <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
  690. <script src="assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.min.js"></script>
  691. <script src="assets/vendor/magnific-popup/jquery.magnific-popup.js"></script>
  692. <script src="assets/vendor/jquery-placeholder/jquery-placeholder.js"></script>
  693. <script src="assets/vendor/fuelux/js/spinner.js"></script>
  694. <!-- Custom -->
  695. <script src="custom/js/bootbox.js"></script>
  696. <script src="custom/js/moeda.js"></script>
  697. <!-- Specific Page Vendor -->
  698. <script src="assets/vendor/select2/js/select2.js"></script>
  699. <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
  700. <script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
  701. <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
  702. <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
  703. <script src="assets/vendor/bootstrap-maxlength/bootstrap-maxlength.js"></script>
  704. <script src="assets/vendor/autosize/autosize.js"></script>
  705. <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
  706. <script src="assets/vendor/pnotify/pnotify.custom.js"></script>
  707. <script src="assets/vendor/bootstrap-select/bootstrap-select.min.js"></script>
  708. <!-- Theme Base, Components and Settings -->
  709. <script src="assets/javascripts/theme.js"></script>
  710. <!-- Theme Initialization Files -->
  711. <script src="assets/javascripts/theme.init.js"></script>
  712. <!-- Theme Custom -->
  713. <script src="assets/javascripts/theme.custom.js"></script>
  714. <script src="custom/js/jquery.maskMoney.js"></script>
  715. <script src="custom/js/portalMask.js"></script>
  716. <script type="text/javascript">
  717. var tblDesc = [];
  718. var optProd = '<%=cOptProd%>';
  719. var optCond = '<%=cOptCond%>';
  720. var optCli = '<%=cOptCli%>';
  721. /**
  722. Desabilita o enter na pagina
  723. **/
  724. $(function () {
  725. $('form').bind("keypress", function (e) {
  726. if (e.keyCode == 13) return false;
  727. });
  728. // Evento do botão incluir
  729. $("#btnIncluir").click(function() {
  730. $("#formParceiro")[0].reset();
  731. $("#tituloIncPar")[0].childNodes[0].data = "Incluir Parceiro"
  732. $("#cmbParceiro").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
  733. $("#cmbRTPagar").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
  734. $("#txtRTAumentar").attr('readonly', true).attr("style", "pointer-events: none;");;
  735. $("#dialogParceiro").modal('show');
  736. });
  737. carregarTabelaParceiros()
  738. // Evento do botão salvar
  739. $("#btnSalvarParceiro").click(function() {
  740. var parceiro = $("#cmbParceiro").val();
  741. var rtpagar = $("#cmbRTPagar").val();
  742. var rtaumentar = $("#txtRTAumentar").val();
  743. var numOrc = $("#CJ_NUM").val();
  744. var operacao = $("#operacao").val()
  745. if (!parceiro) {
  746. alert("Selecione um parceiro!");
  747. return;
  748. }
  749. if (!rtpagar) {
  750. alert("Selecione o percentual RT Pagar!");
  751. return;
  752. }
  753. // Verifica se já existe o parceiro na tabela
  754. var existe = false;
  755. $("#datatable-editable tbody tr").each(function() {
  756. var codParceiro = $(this).find("td:first").text().split(" - ")[0];
  757. if (codParceiro === parceiro && operacao != "delete") {
  758. existe = true;
  759. return false;
  760. }
  761. });
  762. if (existe && operacao != 'delete') {
  763. alert("Este parceiro já foi adicionado!");
  764. return;
  765. }
  766. // Adiciona na tabela Z81
  767. if(operacao == 'edit'){
  768. editarParceiro(parceiro, rtpagar, rtaumentar, numOrc);
  769. }else if(operacao == 'delete'){
  770. excluirParceiro(parceiro, numOrc);
  771. }else{
  772. adicionarParceiro(parceiro, rtpagar, rtaumentar, numOrc);
  773. }
  774. $("#dialogParceiro").modal('hide');
  775. });
  776. });
  777. //Remove as opções da tabela e adiciona o scroll
  778. $(document).ready(function () {
  779. $('#datatable-editable').DataTable({
  780. "scrollX": true,
  781. "ordering": false,
  782. "searching": false,
  783. "paging": false,
  784. "autoWidth": true,
  785. "info": false
  786. });
  787. $('.dataTables_length').addClass('.w-auto'); //ajusta o tamanho das colunas automaticamente
  788. });
  789. //Formata campos de moeda
  790. $(function() {
  791. //$('#iCK_PRCVEN01').maskMoney({thousands:'.', decimal:','});
  792. $('.myformato').maskMoney({thousands:'.', decimal:','});
  793. $('.percentual').maskMoney({thousands:'.', decimal:',', suffix:'%',allowNegative:true});
  794. })
  795. function formate() {
  796. $('.myformato').maskMoney({thousands:'.', decimal:','});
  797. $('.percentual').maskMoney({thousands:'.', decimal:',', suffix:'%',allowNegative:true});
  798. }
  799. <%=cTblDesc%>
  800. function sleep(ms) {
  801. return new Promise(resolve => setTimeout(resolve, ms));
  802. }
  803. //Manipulando as colunas
  804. function ocultaColumn (colIndex) {
  805. var table = document.getElementById('datatable-editable');
  806. for (var r = 0; r < table.rows.length; r++)
  807. table.rows[r].cells[colIndex].style.display = 'none';
  808. }
  809. function mostraColumn (colIndex) {
  810. var table = document.getElementById('datatable-editable');
  811. for (var r = 0; r < table.rows.length; r++)
  812. table.rows[r].cells[colIndex].style.display = '';
  813. }
  814. /**
  815. Monta a tela para selecionar o cliente
  816. **/
  817. function getCliente(btPesquisa){
  818. var cCliBusca = $("#CJ_CLIENTE").val().toUpperCase();
  819. // Usando a função buscarProdutos com um callback
  820. buscarClientes(cCliBusca, function (clientesEncontrados) {
  821. if (clientesEncontrados.length >= 1) {
  822. var selectOptions = '<select id="clienteSelecionado" style="width:100%">';
  823. var indiceHifen;
  824. var selOptions = '';
  825. clientesEncontrados.forEach(function (cliente) {
  826. selectOptions += "<option value='" + cliente + "'>" + cliente + "</option>";
  827. });
  828. selectOptions += "</select>";
  829. bootbox.dialog({
  830. title: 'Clientes',
  831. message: "<p>Selecione o cliente desejado:</p>" + selectOptions,
  832. backdrop: false,
  833. size: 'large',
  834. buttons: {
  835. confirm: {
  836. label: 'Confirmar',
  837. className: 'btn-primary',
  838. callback: function () {
  839. var clienteSelecionado = $("#clienteSelecionado").val();
  840. // Atualiza o campo original com o produto escolhido
  841. $("#CJ_CLIENTE").val(clienteSelecionado);
  842. clienteSelecionado = formataCli(clienteSelecionado);
  843. SelCliente(clienteSelecionado);
  844. }
  845. },
  846. cancel: {
  847. label: 'Cancelar',
  848. className: 'btn-default',
  849. callback: function () {
  850. }
  851. }
  852. }
  853. });
  854. }
  855. });
  856. }
  857. /**
  858. Monta a tela para selecionar o local de entrega
  859. **/
  860. function getEntrega(btEntrega){
  861. $("#dialogEntrega").modal('show');
  862. }
  863. /**
  864. Busca as cidades do estado selecionado
  865. **/
  866. function getMunEnt(estado){
  867. if(estado==""){
  868. bootbox.alert("Selecione um estado para continuar!")
  869. } else {
  870. $.ajax({
  871. url: "U_GetMunUF.apw?PR=<%=cLCodLogin%>",
  872. type: "POST",
  873. data: 'uf='+estado,
  874. cache: false,
  875. success: function(retorno){
  876. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  877. $("html").html(retorno);
  878. return;
  879. }
  880. if(retorno==""){
  881. bootbox.alert("Falha ao localizar os municípios, tente novamente!");
  882. return;
  883. }
  884. //Preenche o select das cidades
  885. document.getElementById('MUN_ENTREGA').innerText = null;
  886. $("#MUN_ENTREGA").append(retorno);
  887. $("#MUN_ENTREGA").removeAttr('disabled');
  888. }
  889. });
  890. }
  891. }
  892. /**
  893. Função para gravar o local de entrega no campo em tela
  894. **/
  895. function gravaEntrega(estado,mun){
  896. $('#CJ_UFENT').val(estado+mun);
  897. $("#dialogEntrega").modal('hide');
  898. //busca o percentual de frete
  899. atuVlrFrete();
  900. }
  901. /**
  902. Função para formatar o código do cliente
  903. **/
  904. function formataCli(cli){
  905. var indiceHifen = 0;
  906. if(cli != ""){
  907. // Encontra a posição do primeiro h?fen na string
  908. indiceHifen = cli.indexOf("-");
  909. //Pega apenas o codigo do cliente
  910. if(indiceHifen > 0){
  911. cli = cli.substring(0, indiceHifen);
  912. }
  913. //Remove espaços vazios
  914. cli = cli.replace("/","").trim();
  915. }
  916. return cli
  917. }
  918. /**
  919. Função para formatar o código do produto
  920. **/
  921. function formataProd(prod){
  922. var indiceHifen = 0;
  923. if(prod != ""){
  924. // Encontra a posição do primeiro hífen na string
  925. indiceHifen = prod.indexOf("--");
  926. //Pega apenas o codigo do produto
  927. if(indiceHifen > 0){
  928. prod = prod.substring(0, indiceHifen);
  929. }
  930. //Remove espaços vazios
  931. prod = prod.trim();
  932. }
  933. return prod
  934. }
  935. /**
  936. Funcao excutada ao selecionar o cliente
  937. **/
  938. function SelCliente(cliente){
  939. var lOK = false;
  940. var dialogCli = bootbox.dialog({
  941. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Buscando dados do cliente. Aguarde...</p>',
  942. closeButton: false
  943. });
  944. cliente = cliente.replace('/',"");
  945. //Verifica se cliente tem títulos em atraso
  946. $.ajax({
  947. url: "U_GetSitCli.apw?PR=<%=cLCodLogin%>",
  948. type: "POST",
  949. data: 'cliente='+cliente,
  950. cache: false,
  951. success: function(data){
  952. dialogCli.modal('hide');
  953. if (data.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  954. $("html").html(data);
  955. return;
  956. }
  957. aCli = data.split('|#|');
  958. if (aCli[1] != "" && aCli[1] != "::" && aCli[1].toUpperCase().indexOf("EXPIRES") == -1) {
  959. var dialog = bootbox.dialog({
  960. title: 'Mensagem do Cliente',
  961. message: "<p>"+aCli[1]+"</p>",
  962. backdrop: true,
  963. buttons: {
  964. ok: {
  965. label: "OK"
  966. }
  967. }
  968. });
  969. }
  970. //cliente bloqueado para comprar
  971. if (aCli[0] == "0"){
  972. //Bloqueia os campos para impossibilitar continuar a inclusão
  973. atuModoCpo('B')
  974. } else {
  975. //Desbloqueia os campos
  976. atuModoCpo('D')
  977. $("#select2-CJ_TIPOCLI-container").html($("#CJ_TIPOCLI option[value='"+aCli[2]+"']").html());
  978. $("#CJ_TIPOCLI").val(aCli[2]);
  979. $("#CJ_GRPTRIB").val(aCli[3]);
  980. if (aCli[4] != ""){
  981. $("#CJ_CONDPAG").val(aCli[4]);
  982. $("#select2-CJ_CONDPAG-container").html($("#CJ_CONDPAG option[value='"+aCli[4]+"']").html());
  983. }
  984. $("#CJ_CONDPAG").removeAttr('disabled');
  985. $("#CJ_UFENT").val(aCli[5]);
  986. $("#CJ_VEND").val(aCli[6]);
  987. $("#select2-CJ_VEND-container").html($("#CJ_VEND option[value='"+aCli[6]+"']").html());
  988. //Adiciona as opções do cliente
  989. if($("#CJ_CLIINTE")[0].options.length <= 2){
  990. $("#CJ_CLIINTE").append($.parseHTML(optCli));
  991. }
  992. $('.selectpicker').selectpicker('render');
  993. $('.selectpicker').selectpicker('refresh');
  994. //na alteração já traz o select preenchido
  995. if($("#CJ_CLIENT")[0].options.length <= 1){
  996. $("#CJ_CLIENT").append($.parseHTML(optCli));
  997. }
  998. //$('.selectpicker').selectpicker('render');
  999. //$('.selectpicker').selectpicker('refresh');
  1000. //$('#CJ_CLIENT').selectpicker('val', cliente);
  1001. $('#CJ_CLIENT').val(cliente).select2();
  1002. $("#CJ_NROPOR").focus();
  1003. }
  1004. }
  1005. });
  1006. }
  1007. /**
  1008. Atualiza o modo de edição do campo
  1009. **/
  1010. function atuModoCpo(cTipo){
  1011. var aCampos = ["CJ_CLIENTE","CJ_NROPOR","CJ_XCONTAT","CJ_XCONDDD","CJ_XCONTEL","CJ_CLIENT","CJ_OBRA","CJ_YOBRATP","CJ_VEND6","CJ_TERMOME","CJ_CONDPAG","CJ_CLIINTE","CJ_RETORNO","CJ_LUMINOT","CJ_SEGMENT","CJ_PROPECC","CJ_REGIAO","CJ_VEND","CJ_VEND3","CJ_VEND4","CJ_CODESP","CJ_VEND7","CJ_VALIDA","CJ_PRZEMB","CJ_TPFRETE","CJ_PERCFRT","CJ_FRETE","CJ_OBS","CK_PRODUTO01","btEndEntrega"]; //"CJ_UFENT",
  1012. var nI = 0;
  1013. //Atualiza os campos
  1014. for (nI = 0; nI < (aCampos.length) ; nI++) {
  1015. if(cTipo == 'B'){
  1016. $("#"+aCampos[nI]).attr("disabled","");
  1017. } else {
  1018. $("#"+aCampos[nI]).removeAttr('disabled');
  1019. $("#"+aCampos[nI]).attr("disabled",false);
  1020. }
  1021. }
  1022. }
  1023. /**
  1024. Atualiza o endereço de entrega ao mudar o cliente de entrega
  1025. **/
  1026. function atuLocEnt(){
  1027. var cliEntrega = $("CJ_CLIENT").val();
  1028. var dialogCli = bootbox.dialog({
  1029. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Buscando dados do cliente. Aguarde...</p>',
  1030. closeButton: false
  1031. });
  1032. if(cliEntrega != ""){
  1033. $.ajax({
  1034. url: "U_GetEndCli.apw?PR=<%=cLCodLogin%>",
  1035. type: "POST",
  1036. data: 'cliente='+cliEntrega,
  1037. cache: false,
  1038. success: function(retorno){
  1039. dialogCli.modal('hide');
  1040. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  1041. $("html").html(retorno);
  1042. return;
  1043. }
  1044. $("#CJ_UFENT").val(retorno);
  1045. }
  1046. });
  1047. }
  1048. }
  1049. /**
  1050. Preenche a revisão da oportunidade
  1051. **/
  1052. function atuRevOpt(){
  1053. var cOport = $("#CJ_NROPOR").val();
  1054. var cobjOport = $("#CJ_NROPOR")[0];
  1055. var cRevisa = cobjOport.options[cobjOport.selectedIndex].text.substr(7,2)
  1056. var dialog = bootbox.dialog({
  1057. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Buscando dados da oportunidade... Aguarde...</p>',
  1058. closeButton: false
  1059. });
  1060. if(cOport != ""){
  1061. $("#CJ_REVISA").val(cRevisa);
  1062. $.ajax({
  1063. url: "U_GetDadosOpt.apw?PR=<%=cLCodLogin%>",
  1064. data: 'oportunidade='+cOport+'&revisao='+cRevisa,
  1065. type: "POST",
  1066. async: false,
  1067. success:
  1068. function(dados) {
  1069. if (dados.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  1070. $("html").html(dados);
  1071. return;
  1072. } else {
  1073. if (dados.substr(0, 2) == "OK") {
  1074. aVlr = dados.substr(5).split('|#|');
  1075. //Atualiza a comissão
  1076. $("#CJ_COMISTR").val(aVlr[0]);
  1077. //Atualiza o vendedor
  1078. $("#CJ_VEND3").append($.parseHTML(aVlr[1]));
  1079. $('.selectpicker').selectpicker('render');
  1080. $('.selectpicker').selectpicker('refresh');
  1081. $("#select2-CJ_VEND3-container").html($("#CJ_VEND3 option[value='"+aVlr[2]+"']").html());
  1082. } else {
  1083. bootbox.alert("Falha ao localizar os dados da oportunidade!");
  1084. }
  1085. }
  1086. }
  1087. });
  1088. } else {
  1089. $("#CJ_REVISA").val("");
  1090. }
  1091. dialog.modal('hide');
  1092. }
  1093. /**
  1094. Atualiza o valor do frete
  1095. **/
  1096. function atuVlrFrete(){
  1097. var cUFEnt = $("#CJ_UFENT").val().substr(0,2)
  1098. var cMunEnt = $("#CJ_UFENT").val().substr(2,5)
  1099. if(cUFEnt != ""){
  1100. $.ajax({
  1101. url: "U_GetPerFrt.apw?PR=<%=cLCodLogin%>",
  1102. data: 'uf='+cUFEnt+'&mun='+cMunEnt,
  1103. type: "POST",
  1104. async: false,
  1105. success:
  1106. function(frete) {
  1107. if (frete.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  1108. $("html").html(frete);
  1109. return;
  1110. } else {
  1111. //Atualiza o frete
  1112. $("#CJ_PERCFRT").removeAttr("disabled");
  1113. $("#CJ_PERCFRT").val(frete);
  1114. }
  1115. }
  1116. });
  1117. }
  1118. }
  1119. /**
  1120. Valida o estudo
  1121. **/
  1122. function vldEstudo(){
  1123. var cEstudo = $("#CJ_LUMINOT").val();
  1124. if(cEstudo == "1"){
  1125. $("#CJ_REGLUMI").removeAttr('disabled');
  1126. } else {
  1127. $("#CJ_REGLUMI").val("");
  1128. $("#select2-CJ_REGLUMI-container").html($("#CJ_REGLUMI option[value='']").html());
  1129. $("#CJ_REGLUMI").attr("disabled","");
  1130. }
  1131. }
  1132. /**
  1133. Valida a prospecção
  1134. **/
  1135. function vldProspec(){
  1136. var cProspec = $("#CJ_PROPECC").val();
  1137. if(cProspec == "S"){
  1138. $("#CJ_PROSCOD").removeAttr('disabled');
  1139. } else {
  1140. $("#CJ_PROSCOD").val("");
  1141. $("#select2-CJ_PROSCOD-container").html($("#CJ_PROSCOD option[value='']").html());
  1142. $("#CJ_PROSCOD").attr("disabled","");
  1143. }
  1144. }
  1145. /**
  1146. Valida o campo prospectado por
  1147. **/
  1148. function vldProsPor(){
  1149. var cProspec = $("#CJ_PROPECC").val();
  1150. var cProsPor = $("#CJ_PROSCOD").val();
  1151. if(cProspec == "S" && cProsPor == ""){
  1152. bootbox.alert("Informe o campo Prospectado Por!")
  1153. }
  1154. if (cProspec == "N"){
  1155. $("#CJ_PROSCOD").val("");
  1156. $("#select2-CJ_PROSCOD-container").html($("#CJ_PROSCOD option[value='']").html());
  1157. $("#CJ_PROSCOD").attr("disabled","");
  1158. }
  1159. }
  1160. /**
  1161. Valida a condição de pagamento selecionada
  1162. **/
  1163. function vldCond(){
  1164. var valDesc = 0;
  1165. $.ajax({
  1166. url: "U_VldCondPg.apw?PR=<%=cLCodLogin%>",
  1167. data: 'condPgto='+$("#CJ_CONDPAG").val(),
  1168. type: "POST",
  1169. async: false,
  1170. success:
  1171. function(retorno) {
  1172. valDesc = parseFloat(retorno);
  1173. //Atualiza a variável
  1174. $("#DESCCOND").val(valDesc);
  1175. if (valDesc > 0) {
  1176. bootbox.alert("Condição de pagamento com desconto. Ao salvar o orçamento será aplicado o desconto de "+mascaraValor(valDesc.toFixed(2))+"%.");
  1177. } else {
  1178. $("#DESCCOND").val("0");
  1179. }
  1180. //Atualiza o valor do produto quando altera a condição de pagamento
  1181. if ($('#iCK_PRCVEN01').val()!=$('#CK_PRCVEN01').val() || $("#DESCCOND").val()=="0"){
  1182. AtuValProd();
  1183. }
  1184. }
  1185. });
  1186. }
  1187. /**
  1188. Busca dados do cliente a partir do código ou nome
  1189. **/
  1190. function buscarClientes(cCliBusca,callback){
  1191. if (cCliBusca != ""){
  1192. $.ajax({
  1193. url: "U_GetLikeCli.apw?PR=<%=cLCodLogin%>",
  1194. data: 'digit=' + cCliBusca,
  1195. method: "POST",
  1196. async: false,
  1197. success: function( clientes ) {
  1198. if (clientes.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ||clientes.toUpperCase().indexOf("EXPIRES") != -1) {
  1199. $("html").html(clientes);
  1200. callback([]); // Retorna uma lista vazia em caso de erro
  1201. }
  1202. if (clientes == "") {
  1203. $("#CJ_CLIENTE").empty();
  1204. bootbox.alert('Não foram encontrados clientes para o termo pesquisado!');
  1205. callback([]); // Retorna uma lista vazia em caso de erro
  1206. } else {
  1207. $("#CJ_CLIENTE").empty(); // Limpa o conteúdo existente
  1208. var selectpicker = $("<select>", {
  1209. class: "selectpicker",
  1210. title: "Selecione um cliente"
  1211. });
  1212. selectpicker.append($.parseHTML(clientes));
  1213. // Adiciona os valores dos elementos <option> listaClientes
  1214. var listaClientes = selectpicker.find('option').map(function () {
  1215. return $(this).text();//Pegar o texto completo
  1216. }).get();
  1217. $("#CJ_CLIENTE").append(selectpicker);
  1218. callback(listaClientes); // Retorna a lista de clientes encontrados
  1219. }
  1220. }
  1221. });
  1222. } else {
  1223. bootbox.alert("Informe o cliente para busca!");
  1224. }
  1225. }
  1226. /**
  1227. Monta a tela para selecionar o produto
  1228. **/
  1229. function getProduto(btPesquisa){
  1230. var objProd = btPesquisa.closest("td").find("[autocomplete=off]");
  1231. var cProdBusca = $("#"+objProd.attr("name")).val().toUpperCase();
  1232. //var nItem = btPesquisa[0].id.substr(8,2);
  1233. var nItem = objProd.attr("name").substr(10);
  1234. $("#PROXIMO").val(nItem);
  1235. // Usando a função buscarProdutos com um callback
  1236. buscarProdutos(cProdBusca, nItem, function (produtosEncontrados) {
  1237. if (produtosEncontrados.length >= 1) {
  1238. var selectOptions = '<select id="produtoSelecionado" style="width:100%">';
  1239. //var selectOptions = '<select data-plugin-selectTwo class="form-control populate placeholder" data-plugin-options="{ "placeholder": "Selecione...", "allowClear": false }" id="produtoSelecionado">';
  1240. var indiceHifen;
  1241. var selOptions = '';
  1242. produtosEncontrados.forEach(function (produto) {
  1243. selectOptions += "<option value='" + produto + "'>" + produto + "</option>";
  1244. //selOptions+= "{text: '"+produto+"',value: '"+produto+"'},";
  1245. });
  1246. selectOptions += "</select>";
  1247. bootbox.dialog({
  1248. title: 'Produtos',
  1249. message: "<p>Selecione o produto desejado:</p>" + selectOptions,
  1250. backdrop: false,
  1251. size: 'large',
  1252. buttons: {
  1253. confirm: {
  1254. label: 'Confirmar',
  1255. className: 'btn-primary',
  1256. callback: function () {
  1257. var produtoSelecionado = $("#produtoSelecionado").val();
  1258. // Atualiza o campo original com o produto escolhido
  1259. $("#CK_PRODUTO" + nItem).val(produtoSelecionado);
  1260. produtoSelecionado = formataProd(produtoSelecionado);
  1261. gatProduto(objProd,produtoSelecionado);
  1262. }
  1263. },
  1264. cancel: {
  1265. label: 'Cancelar',
  1266. className: 'btn-default',
  1267. callback: function () {
  1268. }
  1269. }
  1270. }
  1271. });
  1272. }
  1273. });
  1274. }
  1275. /**
  1276. Busca dados do produto a partir do código ou descrição
  1277. **/
  1278. function buscarProdutos(cProdBusca,item,callback){
  1279. var cliente = formataCli($("#CJ_CLIENTE").val());
  1280. var tabpreco = $("#CJ_TABELA").val();
  1281. //var item = $("#PROXIMO").val();
  1282. if (cProdBusca != ""){
  1283. if(cliente == ""){
  1284. bootbox.alert("Selecione o cliente para continuar!");
  1285. return false;
  1286. }
  1287. $.ajax({
  1288. url: "U_GetLikePro.apw?PR=<%=cLCodLogin%>",
  1289. data: 'cliente=' + cliente + '&tabela=' + tabpreco + '&digit=' + cProdBusca,
  1290. method: "POST",
  1291. async: false,
  1292. success: function( produtos ) {
  1293. if (produtos.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ||produtos.toUpperCase().indexOf("EXPIRES") != -1) {
  1294. $("html").html(produtos);
  1295. callback([]); // Retorna uma lista vazia em caso de erro
  1296. }
  1297. if (produtos == "") {
  1298. LimpaLinha(item);
  1299. bootbox.alert('Não foram encontrados produtos para o termo pesquisado!');
  1300. callback([]); // Retorna uma lista vazia em caso de erro
  1301. } else {
  1302. $("#CK_PRODUTO" + item).empty(); // Limpa o conteudo existente
  1303. /*
  1304. // Preenche o select dos produtos
  1305. $("#CK_PRODUTO" + item).empty(); // Limpa o conteudo existente
  1306. $("#CK_PRODUTO"+item).append($.parseHTML(produtos));
  1307. $('.selectpicker').selectpicker('render');
  1308. $('.selectpicker').selectpicker('refresh');
  1309. optProd = produtos;
  1310. */
  1311. var selectpicker = $("<select>", {
  1312. class: "selectpicker",
  1313. title: "Selecione um produto"
  1314. });
  1315. selectpicker.append($.parseHTML(produtos));
  1316. // Adiciona os valores dos elementos <option> listaProdutos
  1317. var listaProdutos = selectpicker.find('option').map(function () {
  1318. //return $(this).val();
  1319. ////Luiz SMS - 04/01/2024
  1320. return $(this).text();//Pegar o texto completo
  1321. }).get();
  1322. $("#CK_PRODUTO" + item).append(selectpicker);
  1323. callback(listaProdutos); // Retorna a lista de produtos encontrados
  1324. }
  1325. }
  1326. });
  1327. } else {
  1328. bootbox.alert("Informe o produto para busca!");
  1329. }
  1330. }
  1331. /**
  1332. Converte o texto para maiusculo
  1333. **/
  1334. function Maiuscula(cItemAtu){
  1335. var cCodBar = $("#"+cItemAtu.attr("id")).val().toUpperCase();
  1336. $(cItemAtu).val(cCodBar);
  1337. }
  1338. /**
  1339. Gatilho acionado ao selecionar o produto para preencher os valores
  1340. **/
  1341. function gatProduto(objInput,produtoSelecionado) {
  1342. var nItens = parseFloat($("#PROXIMO").val());
  1343. var lProdOK = true;
  1344. var nItem = objInput.attr("name").substr(10);
  1345. var dialogProd = bootbox.dialog({
  1346. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Buscando dados do produto... Aguarde...</p>',
  1347. closeButton: false
  1348. });
  1349. //valida a digitação duplicada de itens
  1350. for (i = 1; i<=nItens; i++) {
  1351. cItem = String(i);
  1352. if (parseInt(i) < 10 ){cItem = "0"+String(i)};
  1353. cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
  1354. if(cItmOrc != "x" && nItem != cItem ) {
  1355. if ($('#CK_PRODUTO'+cItem).val() == objInput.val()){
  1356. lProdOK = false;
  1357. $('#CK_PRODUTO'+nItem).val("");
  1358. $("#select2-CK_PRODUTO"+cItem+"-container").html("Selecione...");
  1359. }
  1360. }
  1361. }
  1362. if (!lProdOK ) {
  1363. bootbox.alert("Este item já foi informado no orçamento!");
  1364. dialogProd.modal('hide');
  1365. }
  1366. //Fim da validação de itens duplicados
  1367. if ( ! objInput.is('[readonly]') && $.trim(objInput.val()) != "" && lProdOK ) {
  1368. jQuery.ajax({
  1369. type: "POST",
  1370. url: "U_GATPROD.APW?PR=<%=cLCodLogin%>",
  1371. data: 'produto='+encodeURIComponent(produtoSelecionado)+'&tabela='+$("#CJ_TABELA").val()+'&frete='+$("#CJ_PERCFRT").val()+'&comisRT='+$("#CJ_COMISTR").val(),
  1372. error: function (jqXHR, textStatus, error){
  1373. dialogProd.modal('hide');
  1374. bootbox.alert("Falha ao recuperar informações!");
  1375. console.log(error);
  1376. },
  1377. success: function( data ) {
  1378. var aVlr;
  1379. var cMsgErro;
  1380. var nItem = objInput.attr("name").substr(10);
  1381. var przEmb = parseInt($("#CJ_PRZEMB").val());
  1382. dialogProd.modal('hide');
  1383. if (data.substr(0, 2) == "OK") {
  1384. aVlr = data.substr(3).split('|#|');
  1385. if (aVlr[18] != "" && aVlr[18] != "::") {
  1386. var dialog = bootbox.dialog({
  1387. title: 'Mensagem do Produto',
  1388. message: "<p>"+aVlr[19]+"</p>",
  1389. backdrop: true,
  1390. buttons: {
  1391. ok: {
  1392. label: "OK"
  1393. }
  1394. }
  1395. });
  1396. }
  1397. //Validação do produto chamada no VldPortalSMS
  1398. if(aVlr[17] == "1"){
  1399. //Limpa a quantidade caso tenha alterado o produto
  1400. $.trim($("input[name='CK_QTDVEN"+nItem+"']").val(""));
  1401. //Validação do prazo de embarque
  1402. if (aVlr[19] != ""){
  1403. bootbox.alert("Este item não tem estrutura de produção.<br>O prazo de entrega será acrescido de "+aVlr[19]+" dia(s).");
  1404. przEmb = przEmb+parseInt(aVlr[19]);
  1405. }
  1406. $("input[id='CK_PRZEMB"+nItem+"']").val(String(przEmb));
  1407. $.trim($("input[name='CK_PRCVEN"+nItem+"']").val(aVlr[1]));
  1408. $.trim($("input[name='iCK_PRCVEN"+nItem+"']").val(aVlr[1]));
  1409. //Verifica tipo e grupo do produto
  1410. if(aVlr[20]=="PS" && aVlr[13]=="SERV"){
  1411. bootbox.confirm({
  1412. title: "Custo e Preço de Venda do Serviço",
  1413. message: "Deseja informar o Custo e o Preço de Venda do serviço?",
  1414. buttons: {
  1415. cancel: {
  1416. label: 'Não'
  1417. },
  1418. confirm: {
  1419. label: 'Sim'
  1420. }
  1421. },
  1422. callback: function (result) {
  1423. if (result){
  1424. //Chama tela para informar os dois campos
  1425. informaCusto(nItem);
  1426. }
  1427. }
  1428. });
  1429. }
  1430. nVlrVenda = $('#CK_PRCVEN'+nItem).maskMoney('unmasked')[0];
  1431. nPerFrete = $('#CJ_PERCFRT').maskMoney('unmasked')[0];
  1432. nRT = $('#CJ_COMISTR').maskMoney('unmasked')[0];
  1433. //soma percentual de frete e RT
  1434. if(nVlrVenda > 0 ){
  1435. if(nPerFrete > 0 ){
  1436. nVlrVenda = nVlrVenda + ((nVlrVenda * nPerFrete)/100);
  1437. }
  1438. if(nRT > 0 ){
  1439. nVlrVenda = nVlrVenda + ((nVlrVenda * nRT)/100);
  1440. }
  1441. }
  1442. $("input[name='CK_UM"+nItem+"']").val(aVlr[0]);
  1443. $.trim($("input[name='CK_PRCVEN"+nItem+"']").val(nVlrVenda)); //aVlr[1]
  1444. $.trim($("input[name='iCK_PRCVEN"+nItem+"']").val(nVlrVenda)); //aVlr[1]
  1445. $.trim($("input[name='CK_XVALICM"+nItem+"']").val(aVlr[2]));
  1446. $.trim($("input[name='CK_XVALIPI"+nItem+"']").val(aVlr[3]));
  1447. $.trim($("input[name='CK_XICMST"+nItem+"']").val(aVlr[4]));
  1448. $.trim($("input[name='CK_LOCAL"+nItem+"']").val(aVlr[15]));
  1449. //Input hidden
  1450. $("input[id='ALIQ_IPI"+nItem+"']").val(aVlr[5]);
  1451. $("input[id='ALIQ_ICMS"+nItem+"']").val(aVlr[6]);
  1452. $("input[id='ALIQ_ST"+nItem+"']").val(aVlr[12]);
  1453. $("input[id='BASE_IPI"+nItem+"']").val(aVlr[11]);
  1454. $("input[id='BASE_ICMS"+nItem+"']").val(aVlr[9]);
  1455. $("input[id='BASE_ST"+nItem+"']").val(aVlr[10]);
  1456. $("input[id='VAL_ICMS"+nItem+"']").val(aVlr[2]);
  1457. $("input[id='VAL_ST"+nItem+"']").val(aVlr[4]);
  1458. $("input[id='VAL_IPI"+nItem+"']").val(aVlr[3]);
  1459. $("input[id='QTD_EMB"+nItem+"']").val(aVlr[7]);
  1460. $("input[id='CK_TES"+nItem+"']").val(aVlr[8]);
  1461. $("input[id='GRUPO"+nItem+"']").val(aVlr[13]);
  1462. $("input[id='QTDMIN"+nItem+"']").val(aVlr[14]);
  1463. $("input[id='EST_DISP"+nItem+"']").val(aVlr[16]);
  1464. $("input[id='VENCIMENTO"+nItem+"']").val(aVlr[15]);
  1465. //Salva o valor do imposto pro preço cheio
  1466. if($("#IMP_PRCTAB"+nItem).val() == 0){
  1467. nPrcImp = parseFloat(aVlr[3].replace(",","."))+parseFloat(aVlr[4].replace(",","."));
  1468. $("#IMP_PRCTAB"+nItem).val(nPrcImp);
  1469. }
  1470. //Limpa os inputs, caso tenha trocado o produto
  1471. $("input[name='CK_QTDVEN"+nItem+"']").removeAttr('disabled');
  1472. $("input[name='CK_VALOR"+nItem+"']").val("0,00");
  1473. } else {
  1474. LimpaLinha(nItem);
  1475. }
  1476. } else {
  1477. if (data.substr(0, 4) == "ERRO") {
  1478. cMsgErro = data.substr(5);
  1479. bootbox.alert(cMsgErro);
  1480. LimpaLinha(nItem);
  1481. } else {
  1482. cMsgErro = "Houve falha ao localizar os dados do produto. Tente novamente!";
  1483. bootbox.alert(cMsgErro);
  1484. LimpaLinha(nItem);
  1485. // Quando ocorre erro no protheus
  1486. console.log(data);
  1487. }
  1488. }
  1489. }
  1490. });
  1491. } else if ($.trim(objInput.val()) == "" ) {
  1492. LimpaLinha(nItem);
  1493. }
  1494. return false;
  1495. }
  1496. /**
  1497. Funcao para informar o custo do serviço
  1498. **/
  1499. function informaCusto(cItemAtu) {
  1500. $("#itemAtu").val(cItemAtu);
  1501. $("#dialogCusto").modal('show');
  1502. }
  1503. /**
  1504. Funcao que grava o custo do serviço
  1505. **/
  1506. function gravaCusto(itemAtu,prcVenda,custo){
  1507. var qtd = parseFloat($("#CK_QTDVEN"+itemAtu).val().replace('.',"").replace(",","."));
  1508. var totalCusto = 0;
  1509. custoUnt = $("#CUSTO").maskMoney('unmasked')[0];
  1510. if(qtd == 0){qtd = 1};
  1511. totalCusto = custoUnt * qtd;
  1512. $("#CK_CUSTO"+itemAtu).val(mascaraValor(totalCusto.toFixed(2)));
  1513. $("#CK_PRCVEN"+itemAtu).val(prcVenda);
  1514. $("#iCK_PRCVEN"+itemAtu).val(prcVenda);
  1515. $("#dialogCusto").modal('hide');
  1516. }
  1517. /**
  1518. Funcao de calculo do total do item
  1519. **/
  1520. function TotalItem(cItemAtu) {
  1521. var nQuant;
  1522. var nVlrUnit;
  1523. var nVlrTabela;
  1524. var nVlrCusto;
  1525. var nTotalCusto;
  1526. var nTotalUnit;
  1527. var nICMS;
  1528. var nICMSST;
  1529. var nIPI;
  1530. var nPerDesc = 0;
  1531. var nValFrete;
  1532. var nVlrTotal;
  1533. var nBaseIPI;
  1534. var nBaseICMS;
  1535. var nBaseST;
  1536. var cFaixaDesc;
  1537. var nPerCom = 0;
  1538. var nValCom = 0;
  1539. var nValDesc = 0;
  1540. cCodProd = formataProd($("#CK_PRODUTO"+cItemAtu).val());
  1541. nQuant = parseFloat($("#CK_QTDVEN"+cItemAtu).val().replace('.',"").replace(",","."));
  1542. nVlrTabela = $('#iCK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
  1543. nVlrCusto = $('#CK_CUSTO'+cItemAtu).maskMoney('unmasked')[0];
  1544. //nVlrTabela = $('#CK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
  1545. //nVlrUnit = $('#iCK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
  1546. nValFrete = $("#CJ_FRETE").maskMoney('unmasked')[0];
  1547. if ($('#CK_DESCONT'+cItemAtu).maskMoney('unmasked')[0] != 0){
  1548. nPerDesc = $("#CK_DESCONT"+cItemAtu).maskMoney('unmasked')[0];
  1549. }
  1550. nVlrUnit = nVlrTabela - (nVlrTabela*(nPerDesc/100));
  1551. nVlrTotal = nVlrUnit*nQuant;
  1552. nTotalUnit = nVlrTotal;
  1553. nValDesc = nVlrTabela*(nPerDesc/100);
  1554. nTotalCusto = nVlrCusto*nQuant;
  1555. //Tratamento para os impostos
  1556. nICMS = $('#CK_XVALICM'+cItemAtu).maskMoney('unmasked')[0];
  1557. nICMSST = $('#CK_XICMST'+cItemAtu).maskMoney('unmasked')[0];
  1558. nIPI = $("#CK_XVALIPI"+cItemAtu).maskMoney('unmasked')[0];
  1559. //Aliquotas
  1560. nAliqIPI = parseFloat($("#ALIQ_IPI"+cItemAtu).val());
  1561. nAliqICMS = parseFloat($("#ALIQ_ICMS"+cItemAtu).val());
  1562. nAliqST = parseFloat($("#ALIQ_ST"+cItemAtu).val());
  1563. //Valores Base
  1564. nBaseIPI = parseFloat($("#BASE_IPI"+cItemAtu).val());
  1565. nBaseICMS = parseFloat($("#BASE_ICMS"+cItemAtu).val());
  1566. nBaseST = parseFloat($("#BASE_ST"+cItemAtu).val());
  1567. //Valor do imposto
  1568. nIPI = nBaseIPI * nQuant * (nAliqIPI /100)
  1569. nICMS = nBaseICMS * nQuant * (nAliqICMS /100)
  1570. nICMSST = nQuant * parseFloat($("#VAL_ST"+cItemAtu).val().replace(",","."));
  1571. //nIPI = nVlrTotal*(nAliqIPI /100)
  1572. //nICMS = nVlrTotal*(nAliqICMS /100)
  1573. //nIPI = nQuant * parseFloat($("#VAL_IPI"+cItemAtu).val().replace(",","."));
  1574. //nICMS = nQuant * parseFloat($("#VAL_ICMS"+cItemAtu).val().replace(",","."));
  1575. //nICMSST = nQuant * parseFloat($("#VAL_ST"+cItemAtu).val().replace(",","."));
  1576. nVlrTotal = nVlrTotal+nIPI+nICMSST;
  1577. nTotalUnit = nVlrTotal / nQuant;
  1578. //Atualiza o campo do total
  1579. $.trim($("#CK_XVALICM"+cItemAtu).val(mascaraValor(nICMS.toFixed(2))));
  1580. $.trim($("#CK_XVALIPI"+cItemAtu).val(mascaraValor(nIPI.toFixed(2))));
  1581. $.trim($("#CK_XICMST"+cItemAtu).val(mascaraValor(nICMSST.toFixed(2))));
  1582. $.trim($("#CK_PRCVEN"+cItemAtu).val(mascaraValor(nVlrUnit.toFixed(2))));
  1583. $.trim($("#CK_CUSTO"+cItemAtu).val(mascaraValor(nTotalCusto.toFixed(2))));
  1584. $.trim($("#CK_VALOR"+cItemAtu).val(mascaraValor(nVlrTotal.toFixed(2))));
  1585. $.trim($("#CK_XPRCIMP"+cItemAtu).val(mascaraValor(nTotalUnit.toFixed(2))));
  1586. //Atualiza o total geral
  1587. TotalGeral();
  1588. }
  1589. /**
  1590. Total Geral
  1591. **/
  1592. function TotalGeral() {
  1593. var nItens = parseFloat($("#PROXIMO").val());
  1594. var i;
  1595. var nVlrTabela = 0;
  1596. var nVlrUnit = 0;
  1597. var nVlrUniSD = 0;
  1598. var nICMS = 0;
  1599. var nICMSST = 0;
  1600. var nIPI = 0;
  1601. var nImpostos = 0;
  1602. var nValFrete = 0;
  1603. var nTotal = 0;
  1604. var nAcresc = 0;
  1605. var nDescCond = 0;
  1606. var nQuant = 0;
  1607. var nValCom = 0;
  1608. var cCodProd;
  1609. var cItmOrc;
  1610. var nTotQuant = 0.00;
  1611. var nPerDesc = 0;
  1612. var nValDesc = 0;
  1613. var nVlrSDesc = 0
  1614. for (i = 1; i<=nItens; i++) {
  1615. cItem = String(i);
  1616. if (parseInt(i) < 10 ){cItem = "0"+String(i)};
  1617. cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
  1618. cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
  1619. if(cItmOrc != "x") {
  1620. nQuant = parseFloat($("#CK_QTDVEN"+cItem).val().replace('.',"").replace(",","."));
  1621. nTotQuant += nQuant;
  1622. nVlrUniSD += nQuant * $('#iCK_PRCVEN'+cItem).maskMoney('unmasked')[0];
  1623. nVlrUnit += nQuant * $('#CK_PRCVEN'+cItem).maskMoney('unmasked')[0];
  1624. nICMS += $('#CK_XVALICM'+cItem).maskMoney('unmasked')[0];
  1625. nICMSST += $('#CK_XICMST'+cItem).maskMoney('unmasked')[0];
  1626. nIPI += $("#CK_XVALIPI"+cItem).maskMoney('unmasked')[0];
  1627. nValCom += $("#VAL_COM"+cItem).maskMoney('unmasked')[0];
  1628. nTotal += $('#CK_VALOR'+cItem).maskMoney('unmasked')[0];
  1629. if ($('#CK_DESCONT'+cItem).maskMoney('unmasked')[0] != 0){
  1630. nPerDesc = $("#CK_DESCONT"+cItem).maskMoney('unmasked')[0];
  1631. nValDesc += nVlrUniSD*(nPerDesc/100);
  1632. }
  1633. }
  1634. }
  1635. nImpostos = nICMSST+nIPI; //nICMS
  1636. nValFrete = $("#CJ_FRETE").maskMoney('unmasked')[0];
  1637. /*
  1638. //Verifica acrescimo da condição de pagamento
  1639. $.ajax({
  1640. url: "U_ValAcresc.apw?PR=<%=cLCodLogin%>",
  1641. data: 'condPgto='+$("#CJ_CONDPAG").val()+'&valor='+nTotal,
  1642. type: "POST",
  1643. async: false,
  1644. success:
  1645. function(retorno) {
  1646. //nAcresc = parseFloat(retorno);
  1647. nAcresc = parseFloat(nTotal*(retorno/100))
  1648. }
  1649. });
  1650. */
  1651. //nDescCond = parseFloat((nTotal-nTotalProm)*($("#DESCCOND").val()/100)); //desconto da condição de pagamento
  1652. nDescCond = parseFloat(nTotal*($("#DESCCOND").val()/100)); //desconto da condição de pagamento
  1653. nTotal = (nTotal+nValFrete+nAcresc)-nDescCond;
  1654. nPrcImp = parseFloat($("#IMP_PRCTAB"+cItem).val().replace(",","."));
  1655. nVlrSDesc = nVlrUniSD+nImpostos;
  1656. //nVlrSDesc = nVlrUnit+nPrcImp;
  1657. //nVlrSDesc = nVlrUnit+nImpostos;
  1658. nTotalIt = nVlrUnit;
  1659. //Atualiza os totais
  1660. $("#TOTAL_ITENS_NODESC").val($.trim(mascaraValor(nVlrUniSD.toFixed(2))));
  1661. $("#TOTAL_NODESC_IMP").val($.trim(mascaraValor((nVlrSDesc).toFixed(2))));
  1662. $("#TOTAL_QITENS").val($.trim(mascaraValor(nTotQuant.toFixed(2))));
  1663. $("#TOTAL_ITENS").val($.trim(mascaraValor((nTotalIt).toFixed(2))));
  1664. $("#TOTAL_IMP").val($.trim(mascaraValor(nImpostos.toFixed(2))));
  1665. $("#TOTAL_FRETE").val($("#CJ_FRETE").val());
  1666. $("#TOTAL_ACRESC").val($.trim(mascaraValor(nDescCond.toFixed(2))));
  1667. $("#TOTAL_ORC").val($.trim(mascaraValor(nTotal.toFixed(2))));
  1668. $("#TOTAL_COM").val($.trim(mascaraValor(nValCom.toFixed(2))));
  1669. }
  1670. /**
  1671. Atualiza o valor do produto ao trocar a condição de pagamento
  1672. **/
  1673. function AtuValProd(){
  1674. var nItens = parseFloat($("#PROXIMO").val());
  1675. var i;
  1676. var nvalorcheio = 0;
  1677. for (i = 1; i<=nItens; i++) {
  1678. cItem = String(i);
  1679. if (parseInt(i) < 10 ){cItem = "0"+String(i)};
  1680. cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
  1681. if(cItmOrc != "x") {
  1682. nvalorcheio = $('#CK_PRCVEN'+cItem).val();
  1683. $('#iCK_PRCVEN'+cItem).val(nvalorcheio);
  1684. TotalItem(cItem);
  1685. }
  1686. }
  1687. }
  1688. /**
  1689. Verifica se a quantidade é multiplo da embalagem
  1690. **/
  1691. function VldQtd(cItemAtu) {
  1692. var nQuant;
  1693. var nQtdEmb;
  1694. var nQtdMin;
  1695. var resto;
  1696. var cCodProd = formataProd($("#CK_PRODUTO"+cItemAtu).val());
  1697. var lRet = true;
  1698. //Valida a quantidade por embalagem
  1699. nQtdEmb = parseFloat($("#QTD_EMB"+cItemAtu).val());
  1700. nQtdMin = $("#QTDMIN"+cItemAtu).val();
  1701. nQuant = parseFloat($("#CK_QTDVEN"+cItemAtu).val().replace('.',"").replace(",","."));
  1702. if (nQuant > 0){
  1703. //Valida a quantidade da embalagem
  1704. if (nQtdEmb > 0){
  1705. if (nQuant < (nQtdEmb)){
  1706. bootbox.alert("A quantidade deve ser múltiplo de "+nQtdEmb.toString()+".");
  1707. $("#CK_QTDVEN"+cItemAtu).val("");
  1708. lRet = false;
  1709. return false;
  1710. } else {
  1711. resto = nQuant % nQtdEmb;
  1712. if (resto != 0 ){
  1713. bootbox.alert("A quantidade deve ser múltiplo de "+nQtdEmb.toString()+".");
  1714. $("#CK_QTDVEN"+cItemAtu).val("");
  1715. lRet = false;
  1716. return false;
  1717. }
  1718. }
  1719. }
  1720. /*
  1721. var dialogProd = bootbox.dialog({
  1722. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Buscando dados do produto... Aguarde...</p>',
  1723. closeButton: false
  1724. });
  1725. //Atualiza o preço de acordo com a quantidade
  1726. // Encontra a posição do primeiro h?fen na string
  1727. indiceHifen = cCodProd.indexOf("--");
  1728. //Pega apenas o codigo do produto
  1729. cCodProd = cCodProd.substring(0, indiceHifen);
  1730. //Remove espaços vazios
  1731. cCodProd = cCodProd.trim();
  1732. jQuery.ajax({
  1733. type: "POST",
  1734. url: "U_GATPROD.APW?PR=<%=cLCodLogin%>",
  1735. data: 'produto='+encodeURIComponent(cCodProd)+'&tabela='+$("#CJ_TABELA").val(),
  1736. error: function (jqXHR, textStatus, error){
  1737. dialogProd.modal('hide');
  1738. bootbox.alert("Falha ao recuperar informações!");
  1739. console.log(error);
  1740. },
  1741. success: function( data ) {
  1742. var aVlr;
  1743. var cMsgErro;
  1744. dialogProd.modal('hide');
  1745. if (data.substr(0, 2) == "OK") {
  1746. aVlr = data.substr(3).split('|#|');
  1747. $("input[name='CK_UM"+cItemAtu+"']").val(aVlr[0]);
  1748. $.trim($("input[name='CK_PRCVEN"+cItemAtu+"']").val(aVlr[1]));
  1749. $.trim($("input[name='iCK_PRCVEN"+cItemAtu+"']").val(aVlr[1]));
  1750. $.trim($("input[name='CK_XVALICM"+cItemAtu+"']").val(aVlr[2]));
  1751. $.trim($("input[name='CK_XVALIPI"+cItemAtu+"']").val(aVlr[3]));
  1752. $.trim($("input[name='CK_XICMST"+cItemAtu+"']").val(aVlr[4]));
  1753. $.trim($("input[name='CK_LOCAL"+cItemAtu+"']").val(aVlr[15]));
  1754. //Input hidden
  1755. $("input[id='ALIQ_IPI"+cItemAtu+"']").val(aVlr[5]);
  1756. $("input[id='ALIQ_ICMS"+cItemAtu+"']").val(aVlr[6]);
  1757. $("input[id='ALIQ_ST"+cItemAtu+"']").val(aVlr[12]);
  1758. $("input[id='BASE_IPI"+cItemAtu+"']").val(aVlr[11]);
  1759. $("input[id='BASE_ICMS"+cItemAtu+"']").val(aVlr[9]);
  1760. $("input[id='BASE_ST"+cItemAtu+"']").val(aVlr[10]);
  1761. $("input[id='VAL_ICMS"+cItemAtu+"']").val(aVlr[2]);
  1762. $("input[id='VAL_ST"+cItemAtu+"']").val(aVlr[4]);
  1763. $("input[id='VAL_IPI"+cItemAtu+"']").val(aVlr[3]);
  1764. $("input[id='QTD_EMB"+cItemAtu+"']").val(aVlr[7]);
  1765. $("input[id='CK_TES"+cItemAtu+"']").val(aVlr[8]);
  1766. $("input[id='GRUPO"+cItemAtu+"']").val(aVlr[13]);
  1767. $("input[id='QTDMIN"+cItemAtu+"']").val(aVlr[14]);
  1768. } else {
  1769. if (data.substr(0, 4) == "ERRO") {
  1770. cMsgErro = data.substr(5);
  1771. bootbox.alert(cMsgErro);
  1772. LimpaLinha(cItemAtu);
  1773. } else {
  1774. cMsgErro = "Houve falha ao localizar os dados do produto. Tente novamente!";
  1775. bootbox.alert(cMsgErro);
  1776. LimpaLinha(cItemAtu);
  1777. // Quando ocorre erro no protheus
  1778. console.log(data);
  1779. }
  1780. }
  1781. }
  1782. });
  1783. */
  1784. } else {
  1785. bootbox.alert("Informe a quantidade!");
  1786. lRet = false;
  1787. return false;
  1788. }
  1789. if (lRet == true){
  1790. //Valida o estoque do produto
  1791. //vldEstoque(cItemAtu);
  1792. //Desbloqueia os campos
  1793. $("#CK_OBS"+cItemAtu).removeAttr('disabled');
  1794. $("#CK_PRZEMB"+cItemAtu).removeAttr('disabled');
  1795. $("#CK_DESCONT"+cItemAtu).removeAttr('disabled');
  1796. //cPrzEmb = $("#CJ_PRZEMB").val();
  1797. //$("#CK_PRZEMB"+cItemAtu).val(cPrzEmb);
  1798. }
  1799. //Gatilho para total do item
  1800. TotalItem(cItemAtu);
  1801. }
  1802. /**
  1803. Verifica se existe estoque disponível
  1804. **/
  1805. function vldEstoque(cItem){
  1806. var produto = formataProd($("#CK_PRODUTO"+cItem).val());
  1807. var quantidade = parseFloat($("#CK_QTDVEN"+cItem).val().replace('.',","));
  1808. var qtd = $("#CK_QTDVEN"+cItem).val();
  1809. var lret = true;
  1810. var retVld = true;
  1811. var dialogTab = bootbox.dialog({
  1812. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Verificando estoque disponível... Aguarde...</p>',
  1813. closeButton: false
  1814. });
  1815. $.ajax({
  1816. url: "U_GetEstDisp.apw?PR=<%=cLCodLogin%>",
  1817. data: 'produto='+encodeURIComponent(produto)+'&quantidade='+qtd,
  1818. type: "POST",
  1819. async: false,
  1820. success:
  1821. function(retorno) {
  1822. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  1823. $("html").html(retorno);
  1824. return;
  1825. }
  1826. saldo = parseInt(retorno);
  1827. $("#EST_DISP"+cItem).val(saldo);
  1828. if ( saldo <= 0 || saldo < quantidade) {
  1829. if(retorno < 0){
  1830. retorno = 0
  1831. };
  1832. dialogTab.modal('hide');
  1833. bootbox.alert('Não há saldo disponível em estoque para a quantidade solicitada para o item '+produto+'! <br>O saldo atual é de '+retorno+'.');
  1834. if ($('#CJ_XTPORC').val() == "1"){
  1835. $("#CK_QTDVEN"+cItem).val("");
  1836. lret = false;
  1837. retVld = false;
  1838. }
  1839. }
  1840. }
  1841. });
  1842. if (lret == true){
  1843. //Habilita os campos para edição
  1844. $("#CK_XPEDCLI"+cItem).removeAttr('disabled');
  1845. $("#CK_XITEMCL"+cItem).removeAttr('disabled');
  1846. $("#CK_DESCONT"+cItem).removeAttr('disabled');
  1847. }
  1848. dialogTab.modal('hide');
  1849. return retVld;
  1850. }
  1851. /**
  1852. Limpa os valores da linha
  1853. **/
  1854. function LimpaLinha(cItem) {
  1855. $("#CK_QTDVEN"+cItem).val("");
  1856. $("#CK_PRZEMB"+cItem).val("");
  1857. $("#iCK_PRCVEN"+cItem).val("");
  1858. $("#CK_PRCVEN"+cItem).val("");
  1859. $("#CK_CUSTO"+cItem).val("");
  1860. $("#IMP_PRCTAB"+cItem).val("");
  1861. $("#CK_XPRCIMP"+cItem).val("");
  1862. $("#CK_XVALIPI"+cItem).val("");
  1863. $("#CK_XVALICM"+cItem).val("");
  1864. $("#CK_XICMST"+cItem).val("");
  1865. $("#CK_VALOR"+cItem).val("");
  1866. $("#PER_COM"+cItem).val("");
  1867. $("#VAL_COM"+cItem).val("");
  1868. $("#CK_DESCONT"+cItem).val("");
  1869. TotalGeral();
  1870. }
  1871. /**
  1872. Verifica se o valor digitado é maior que o valor de tabela
  1873. **/
  1874. function VldValor(cItemAtu,cVldDesc) {
  1875. var nVlrTabela = $('#iCK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
  1876. var nVlrUnit = $('#CK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
  1877. var produto = $("#CK_PRODUTO"+cItemAtu).val();
  1878. var cQuant = $("#CK_QTDVEN"+cItemAtu).val();
  1879. var nValMin = 0;
  1880. var nDescont = 0;
  1881. var nDescMax = 0;
  1882. var aDesc;
  1883. var lOK = true;
  1884. var lMostra = false;
  1885. var dialogTab = bootbox.dialog({
  1886. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Verificando valores... Aguarde...</p>',
  1887. closeButton: false
  1888. });
  1889. if ($('#CK_DESCONT'+cItemAtu).maskMoney('unmasked')[0] != 0){
  1890. nDescont = $('#CK_DESCONT'+cItemAtu).maskMoney('unmasked')[0];
  1891. //Verifica desconto negativo
  1892. if (nDescont < 0) {
  1893. dialogTab.modal('hide');
  1894. bootbox.alert('O desconto não deve ser negativo!');
  1895. $('#CK_DESCONT'+cItemAtu).val("");
  1896. return false;
  1897. }
  1898. //Verifica desconto maior que 100
  1899. if (nDescont > 100) {
  1900. dialogTab.modal('hide');
  1901. bootbox.alert('O desconto não deve ser maior que 100!');
  1902. $('#CK_DESCONT'+cItemAtu).val("");
  1903. return false;
  1904. }
  1905. //Verifica validação do desconto
  1906. if (cVldDesc == 'S'){
  1907. produto = formataProd(produto);
  1908. $.ajax({
  1909. url: "U_VldDescto.apw?PR=<%=cLCodLogin%>",
  1910. data: 'produto='+encodeURIComponent(produto)+'&prcvenda='+nVlrUnit+'&quantidade='+cQuant,
  1911. type: "POST",
  1912. async: false,
  1913. error: function (jqXHR, textStatus, error){
  1914. dialogTab.modal('hide');
  1915. bootbox.alert("Falha ao atualizar o valor dos impostos!");
  1916. console.log(error);
  1917. lOK = false;
  1918. },
  1919. success:
  1920. function(cTipoDesc) {
  1921. if(cTipoDesc=='3'){
  1922. bootbox.alert('Produtos do tipo RE, iniciados com RELUMI, do grupo PAN ou acessórios de produtos do grupo PAN não permitem descontos.');
  1923. $('#CK_DESCONT'+cItemAtu).val("");
  1924. return false;
  1925. }
  1926. if(cTipoDesc=='2'){
  1927. msg = '<div class="row form-group">'
  1928. //Usuario
  1929. msg +=' <div class="row form-group">'
  1930. msg +=' <div class="col-lg-1"></div>'
  1931. msg +=' <div class="col-lg-11">'
  1932. msg +=' <label class="control-label">Usuário</label>'
  1933. msg +=' <div class="input-group">'
  1934. msg +=' <input id="userName" class="form-control text-left" value="">'
  1935. msg +=' </div>'
  1936. msg +=' </div>'
  1937. msg +=' </div>'
  1938. //Senha
  1939. msg +=' <div class="row form-group">'
  1940. msg +=' <div class="col-lg-1"></div>'
  1941. msg +=' <div class="col-lg-3">'
  1942. msg +=' <label class="control-label">Senha</label>'
  1943. msg +=' <div class="input-group">'
  1944. msg +=' <input id="userPsw" class="form-control text-left" type="password" value="">'
  1945. msg +=' </div>'
  1946. msg +=' </div>'
  1947. //% de Desconto
  1948. msg +=' <div class="row form-group">'
  1949. msg +=' <div class="col-lg-1"></div>'
  1950. msg +=' <div class="col-lg-3">'
  1951. msg +=' <label class="control-label">% de Desconto</label>'
  1952. msg +=' <div class="input-group">'
  1953. msg +=' <input id="percDesc" class="form-control text-right percentual" type="text" value="" maxlenght="7" placeholder="0,00%">'
  1954. msg +=' </div>'
  1955. msg +=' </div>'
  1956. msg +=' </div>'
  1957. msg +='</div>'
  1958. bootbox.confirm({
  1959. title: 'Senha para Desconto',
  1960. message: "<p>"+msg+"</p>",
  1961. backdrop: true,
  1962. buttons: {
  1963. cancel: {
  1964. label: 'Cancelar'
  1965. },
  1966. confirm: {
  1967. label: 'Confirmar'
  1968. }
  1969. },
  1970. callback: function (result) {
  1971. if (result){
  1972. usrInput = $("#userName").val();
  1973. pswInput = $("#userPsw").val();
  1974. percDesc = $("#percDesc").val();
  1975. //Valida a senha digitada
  1976. $.ajax({
  1977. url: "U_VldSenha.apw?PR=<%=cLCodLogin%>",
  1978. type: "POST",
  1979. data: 'user='+usrInput+'&senha='+pswInput,
  1980. async: false,
  1981. success:
  1982. function(retorno) {
  1983. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ||retorno.toLowerCase().indexOf("Expires") != -1){
  1984. bootbox.alert('Não foi possível realizar a operação pois a sessão foi fechada. Faça login novamente.');
  1985. }
  1986. if(retorno == "NOK"){
  1987. bootbox.alert("Usuário ou senha inválidos!")
  1988. $('#CK_DESCONT'+cItemAtu).val("");
  1989. return false;
  1990. } else {
  1991. $('#CJ_DSDIRET').val(percDesc);
  1992. $('#CK_NOMDIRE'+cItemAtu).val(usrInput);
  1993. }
  1994. }
  1995. });
  1996. } else {
  1997. $('#CK_DESCONT'+cItemAtu).val("");
  1998. return false;
  1999. }
  2000. }
  2001. });
  2002. }
  2003. }
  2004. });
  2005. }
  2006. }
  2007. //Valida o valor máximo --retirado Lucilene 11.08.20
  2008. //if ( lOK && nVlrUnit > nVlrTabela){
  2009. // dialogTab.modal('hide');
  2010. // bootbox.alert("O valor máximo permitido é o valor da tabela!");
  2011. // $("#iCK_PRCVEN"+cItemAtu).val($('#CK_PRCVEN'+cItemAtu).val());
  2012. // $("#iCK_PRCVEN"+cItemAtu).focus();
  2013. // lOK = false;
  2014. //}
  2015. //dialogTab.modal('hide');
  2016. //Atualiza o valor dos impostos
  2017. if (lOK && nDescont != 0){
  2018. var cCodProd = formataProd($("#CK_PRODUTO"+cItemAtu).val());
  2019. var cQuant = $("#CK_QTDVEN"+cItemAtu).val();
  2020. //var dialogImp = bootbox.dialog({
  2021. // message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Atualizando os valores dos impostos... Aguarde...</p>',
  2022. // closeButton: false
  2023. // });
  2024. nVlrUnit = nVlrTabela - (nVlrTabela * (nDescont/100))
  2025. $.ajax({
  2026. url: "U_GetImpostos.apw?PR=<%=cLCodLogin%>",
  2027. data: 'produto='+encodeURIComponent(cCodProd)+'&prcvenda='+nVlrUnit+'&quantidade='+cQuant,
  2028. type: "POST",
  2029. async: false,
  2030. error: function (jqXHR, textStatus, error){
  2031. dialogTab.modal('hide');
  2032. bootbox.alert("Falha ao atualizar o valor dos impostos!");
  2033. console.log(error);
  2034. lOK = false;
  2035. },
  2036. success:
  2037. function(data) {
  2038. dialogTab.modal('hide');
  2039. if (data.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  2040. $("html").html(data);
  2041. return;
  2042. }
  2043. if (data.substr(0, 2) == "OK") {
  2044. aVlr = data.substr(3).split('|#|');
  2045. $.trim($("input[name='CK_XVALICM"+cItemAtu+"']").val(aVlr[2]));
  2046. $.trim($("input[name='CK_XICMST"+cItemAtu+"']").val(aVlr[4]));
  2047. $.trim($("input[name='CK_XVALIPI"+cItemAtu+"']").val(aVlr[3]));
  2048. $.trim($("#CK_PRCVEN"+cItemAtu).val(mascaraValor(nVlrUnit.toFixed(2))));
  2049. //Input hidden
  2050. $("input[id='ALIQ_IPI"+cItemAtu+"']").val(aVlr[5]);
  2051. $("input[id='ALIQ_ICMS"+cItemAtu+"']").val(aVlr[6]);
  2052. $("input[id='ALIQ_ST"+cItemAtu+"']").val(aVlr[12]);
  2053. $("input[id='CK_TES"+cItemAtu+"']").val(aVlr[8]);
  2054. $("input[id='BASE_IPI"+cItemAtu+"']").val(aVlr[11]);
  2055. $("input[id='BASE_ICMS"+cItemAtu+"']").val(aVlr[9]);
  2056. $("input[id='BASE_ST"+cItemAtu+"']").val(aVlr[10]);
  2057. $("input[id='VAL_ICMS"+cItemAtu+"']").val(aVlr[2]);
  2058. $("input[id='VAL_ST"+cItemAtu+"']").val(aVlr[4]);
  2059. $("input[id='VAL_IPI"+cItemAtu+"']").val(aVlr[3]);
  2060. } else {
  2061. cMsgErro = "Houve falha ao atualizar os impostos. Tente novamente!";
  2062. bootbox.alert(cMsgErro);
  2063. LimpaLinha(cItemAtu);
  2064. lOK = false;
  2065. if (data.substr(0, 4) == "ERRO") {
  2066. cMsgErro = data.substr(5);
  2067. } else {
  2068. // Quando ocorre erro no protheus
  2069. console.log(data);
  2070. }
  2071. }
  2072. }
  2073. });
  2074. }
  2075. dialogTab.modal('hide');
  2076. //Gatilho para total do item
  2077. if(lOK){
  2078. TotalItem(cItemAtu);
  2079. }
  2080. }
  2081. /**
  2082. Função para anexar os documentos ao orçamento
  2083. **/
  2084. function OrcGetAnex() {
  2085. $.ajax({
  2086. url: "U_OrcGetAn.apw?PR=<%=cLCodLogin%>",
  2087. type: "POST",
  2088. data: "fornece="+$("#fornece").val()+"&loja="+$("#loja").val(),
  2089. cache: false,
  2090. success: function(html){
  2091. $("#InfAnexos").html(html);
  2092. new PNotify({
  2093. title: 'Anexar arquivo',
  2094. text: 'Anexado com sucesso',
  2095. type: 'success',
  2096. icon: 'fa fa-file-o',
  2097. cornerclass: 'ui-pnotify-sharp'
  2098. });
  2099. $("#arquivo").remove();
  2100. }
  2101. });
  2102. }
  2103. /**
  2104. Funcao de validação do tipo de frete
  2105. **/
  2106. function VldFrete() {
  2107. var cFrete;
  2108. var tabpreco = $("#CJ_TABELA").val();
  2109. cFrete = $("#CJ_TPFRETE").val();
  2110. if (cFrete == 'S'||cFrete == 'T'||cFrete == 'F'){
  2111. $("#CJ_FRETE").removeAttr("required");
  2112. $("#CJ_FRETE").removeAttr("aria-required");
  2113. $("#CJ_FRETE").attr("disabled","");
  2114. $("#CJ_FRETE").val("0,00");
  2115. //$("#CJ_XTRANSP").removeAttr('disabled');
  2116. //$("#CJ_XTRANSP").val("");
  2117. $("#select2-CJ_XTRANSP-container").html("Selecione uma Transportadora");
  2118. } else {
  2119. if (cFrete != ""){
  2120. $("#CJ_FRETE").attr("required","");
  2121. $("#CJ_FRETE").attr("aria-required","true");
  2122. $("#CJ_FRETE").removeAttr('disabled');
  2123. $("#CJ_FRETE").focus();
  2124. //$("#CJ_XTRANSP").removeAttr('disabled');
  2125. //$("#CJ_XTRANSP").val("");
  2126. }
  2127. //Localiza a transportadora
  2128. /*
  2129. $.ajax({
  2130. url: "U_GetTransp.apw?PR=<%=cLCodLogin%>",
  2131. type: "POST",
  2132. data: 'tabela='+tabpreco,
  2133. async: false,
  2134. success:
  2135. function(transp) {
  2136. if (transp.indexOf('<META HTTP-EQUIV') >= 0 ) {
  2137. $("html").html(transp);
  2138. return;
  2139. }
  2140. if ( transp != "" ) {
  2141. //Preenche o campo da transportadora
  2142. document.getElementById('CJ_XTRANSP').innerText = null;
  2143. $("#CJ_XTRANSP").append(transp);
  2144. } else {
  2145. bootbox.alert('Cliente sem transportadora cadastrada!');
  2146. $("#CJ_TPFRETE").val("S")
  2147. $("#select2-CJ_TPFRETE-container").html("Sem Frete")
  2148. $("#CJ_FRETE").removeAttr("required");
  2149. $("#CJ_FRETE").removeAttr("aria-required");
  2150. $("#CJ_FRETE").attr("disabled","");
  2151. $("#CJ_XTRANSP").attr("disabled","");
  2152. $("#CJ_FRETE").val("0,00");
  2153. $("#CJ_XTRANSP").val("");
  2154. $("#select2-CJ_XTRANSP-container").html("Selecione uma Transportadora");
  2155. }
  2156. }
  2157. });
  2158. */
  2159. //$("#select2-CJ_XTRANSP-container").html("Selecione uma Transportadora");
  2160. }
  2161. TotalGeral();
  2162. }
  2163. /**
  2164. // Função para ver detalhes da linha
  2165. **/
  2166. function detalheOrc(cItem){
  2167. var msg = "";
  2168. var produto = $("#CK_PRODUTO"+cItem);
  2169. var retorno = "";
  2170. var estoque = "";
  2171. var dialogTab = "";
  2172. if(produto.val() == ""){
  2173. bootbox.alert("Selecione o produto para ver os detalhes!");
  2174. return false;
  2175. }
  2176. produto = formataProd(produto.val());
  2177. /*
  2178. dialogTab = bootbox.dialog({
  2179. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Carregando detalhes... Aguarde...</p>',
  2180. closeButton: false
  2181. });
  2182. $.ajax({
  2183. url: "U_GetEstGeral.apw?PR=<%=cLCodLogin%>",
  2184. data: 'produto='+encodeURIComponent(produto.val()),
  2185. type: "POST",
  2186. async: false,
  2187. success:
  2188. function(retorno) {
  2189. if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
  2190. $("html").html(retorno);
  2191. return;
  2192. }
  2193. estoque = retorno;
  2194. }
  2195. });
  2196. dialogTab.modal('hide');
  2197. */
  2198. msg = '<div class="row form-group">'
  2199. msg +=' <header class="panel-heading">'
  2200. msg +=' <h2 class="panel-title">Detalhes da linha</h2>'
  2201. msg +=' </header>'
  2202. msg +=' <br>'
  2203. //Descrição do produto
  2204. msg +=' <div class="row form-group">'
  2205. msg +=' <div class="col-lg-1"></div>'
  2206. msg +=' <div class="col-lg-11">'
  2207. msg +=' <label class="control-label">Produto</label>'
  2208. msg +=' <div class="input-group">'
  2209. msg +=' <input class="form-control text-left" style="width: 240%;" value="'+$("#CK_PRODUTO"+cItem).val().split('- ')[1]+'" disabled>'
  2210. //msg +=' <input class="form-control text-left" style="width: 240%;" value="'+$(produto)[0].options[$(produto)[0].selectedIndex].text.split('- ')[1]+'" disabled>'
  2211. msg +=' </div>'
  2212. msg +=' </div>'
  2213. msg +=' </div>'
  2214. /*
  2215. //% ICMS
  2216. msg +=' <div class="row form-group">'
  2217. msg +=' <div class="col-lg-1"></div>'
  2218. msg +=' <div class="col-lg-3">'
  2219. msg +=' <label class="control-label">Aliquota ICMS</label>'
  2220. msg +=' <div class="input-group">'
  2221. msg +=' <input class="form-control text-right" value="'+$("#ALIQ_ICMS"+cItem).val()+'%" disabled>'
  2222. msg +=' </div>'
  2223. msg +=' </div>'
  2224. //% ICMS ST
  2225. msg +=' <div class="col-lg-3">'
  2226. msg +=' <label class="control-label">Aliquota ICMS ST</label>'
  2227. msg +=' <div class="input-group">'
  2228. msg +=' <input class="form-control text-right" value="'+$("#ALIQ_ST"+cItem).val()+'%" disabled>'
  2229. msg +=' </div>'
  2230. msg +=' </div>'
  2231. msg +=' </div>'
  2232. */
  2233. //IPI
  2234. msg +=' <div class="row form-group">'
  2235. msg +=' <div class="col-lg-1"></div>'
  2236. msg +=' <div class="col-lg-3">'
  2237. msg +=' <label class="control-label">IPI</label>'
  2238. msg +=' <div class="input-group">'
  2239. msg +=' <input class="form-control text-right" value="'+$("#VAL_IPI"+cItem).val()+'" disabled>'
  2240. msg +=' </div>'
  2241. msg +=' </div>'
  2242. //ICMS
  2243. msg +=' <div class="col-lg-3">'
  2244. msg +=' <label class="control-label">ICMS</label>'
  2245. msg +=' <div class="input-group">'
  2246. msg +=' <input class="form-control text-right" value="'+$("#VAL_ICMS"+cItem).val()+'" disabled>'
  2247. msg +=' </div>'
  2248. msg +=' </div>'
  2249. //ICMS ST
  2250. msg +=' <div class="col-lg-3">'
  2251. msg +=' <label class="control-label">ICMS ST</label>'
  2252. msg +=' <div class="input-group">'
  2253. msg +=' <input class="form-control text-right" value="'+$("#VAL_ST"+cItem).val()+'" disabled>'
  2254. msg +=' </div>'
  2255. msg +=' </div>'
  2256. msg +=' </div>'
  2257. msg +='</div>'
  2258. if(msg != ""){
  2259. bootbox.dialog({
  2260. title: '',
  2261. message: "<p>"+msg+"</p>",
  2262. backdrop: true,
  2263. buttons: {
  2264. ok: {
  2265. label: "OK"
  2266. }
  2267. }
  2268. });
  2269. }
  2270. }
  2271. //Remover linha
  2272. function removeItem(cItem){
  2273. //e.preventDefault();
  2274. //var btnRem = $(this);
  2275. cItem = parseInt(cItem);
  2276. bootbox.confirm({
  2277. title: "Exclusão da linha",
  2278. message: "Confirma a exclusão desta linha?",
  2279. buttons: {
  2280. cancel: {
  2281. label: 'Cancelar'
  2282. },
  2283. confirm: {
  2284. label: 'Confirmar'
  2285. }
  2286. },
  2287. callback: function (result) {
  2288. if (result){
  2289. if (cItem < 10 ){cItem = "0"+String(cItem)};
  2290. //Desabilita o botão
  2291. //btnRem.attr({ 'disabled': 'disabled' });
  2292. $("#CK_ITEM"+cItem).val("x");
  2293. $("#CK_PRODUTO"+cItem).val("");
  2294. $("#CK_QTDVEN"+cItem).val("1");
  2295. $("#CK_LOCAL"+cItem).val("");
  2296. $("#CK_PRUNIT"+cItem).val("0");
  2297. $("#iCK_PRCVEN"+cItem).val("0,00");
  2298. $("#CK_PRCVEN"+cItem).val("0,00");
  2299. $("#CK_XVALICM"+cItem).val("0,00");
  2300. $("#CK_XVALIPI"+cItem).val("0,00");
  2301. $("#CK_XICMST"+cItem).val("0,00");
  2302. $("#CK_VALOR"+cItem).val("0,00");
  2303. $("#linha"+cItem).hide();
  2304. //Atualiza o total geral
  2305. TotalGeral();
  2306. }
  2307. }
  2308. });
  2309. }
  2310. //Clique no botão pesquisar do Cliente
  2311. $('.btSearchCli').click(function(e) {
  2312. e.preventDefault();
  2313. getCliente($(this));
  2314. });
  2315. //Clique no botão pesquisar do Cliente
  2316. $('.btEndEntrega').click(function(e) {
  2317. e.preventDefault();
  2318. getEntrega($(this));
  2319. });
  2320. $("#datatable-editable").delegate( "button", "click", function( event ) {
  2321. event.preventDefault();
  2322. getProduto($(this));
  2323. });
  2324. /**
  2325. //Anexar
  2326. **/
  2327. $("#btnInfUpload").click(function() {
  2328. var obAnexo = $("#anexo");
  2329. var obArquivo = obAnexo.clone();
  2330. obArquivo.attr("id", "arquivo");
  2331. $("#frmInfUpload").append(obArquivo);
  2332. var data;
  2333. var contentType = "application/x-www-form-urlencoded";
  2334. var processData = true;
  2335. if ($('#frmInfUpload').attr('enctype') == 'multipart/form-data') {
  2336. data = new FormData($('#frmInfUpload').get(0));//seleciona classe form-horizontal adicionada na tag form do html
  2337. contentType = false;
  2338. processData = false;
  2339. } else {
  2340. data = $('#frmInfUpload').serialize();
  2341. }
  2342. $.ajax({
  2343. data: data,
  2344. type: $('#frmInfUpload').attr('method'),
  2345. url: $('#frmInfUpload').attr('action'),
  2346. contentType: contentType,
  2347. processData: processData,
  2348. success: function (response) {
  2349. //seu código apos sucesso
  2350. if( response == "Ok" ) {
  2351. window.location.reload();
  2352. } else {
  2353. bootbox.alert('Erro ao carregar arquivo');
  2354. }
  2355. },
  2356. error: function (exr, sender) {
  2357. bootbox.alert('Erro ao carregar pagina');
  2358. }
  2359. });
  2360. });
  2361. //Adicionar nova linha
  2362. $('#btAddItm').click(function(e) {
  2363. e.preventDefault();
  2364. var newLine = parseFloat($("#PROXIMO").val())+1;
  2365. var nItens = parseFloat($("#PROXIMO").val());
  2366. var linhaAtu = String(newLine);
  2367. var lRet = true;
  2368. var lGridOK = true;
  2369. var btnAdd = $(this);
  2370. var cCodProd;
  2371. var cItmOrc;
  2372. let aExtras = [];
  2373. let aFields = [];
  2374. if (parseInt(linhaAtu) < 10 ){linhaAtu = "0"+String(linhaAtu)};
  2375. //Desabilita o botão
  2376. btnAdd.attr({ 'disabled': 'disabled' });
  2377. //Valida o Grid
  2378. if (nItens == 99){
  2379. lRet = false;
  2380. $("#orc-informar").html();
  2381. new PNotify({
  2382. title: 'Quantidade máxima',
  2383. text: 'O orçamento atingiu a quantidade máxima de itens. Crie um novo orçamento.',
  2384. type: 'error',
  2385. });
  2386. btnAdd.removeAttr('disabled');
  2387. return false;
  2388. }
  2389. if (lRet == true) {
  2390. for (i = 1; i<=nItens; i++) {
  2391. cItem = String(i);
  2392. if (parseInt(i) < 10 ){cItem = "0"+String(i)};
  2393. cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
  2394. if(cItmOrc != "x") {
  2395. cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
  2396. if ($('#CK_PRODUTO'+cItem).val() == "" || $('#CK_QTDVEN'+cItem).val() == ""){
  2397. lGridOK = false;
  2398. }
  2399. }
  2400. }
  2401. if (lGridOK == false){
  2402. lRet = false;
  2403. $("#orc-informar").html();
  2404. new PNotify({
  2405. title: 'Campo obrigatório',
  2406. text: 'Verifique o preenchimento dos campos Produto e Quantidade antes de incluir uma nova linha!',
  2407. type: 'error',
  2408. });
  2409. btnAdd.removeAttr('disabled');
  2410. //Força fechar a janela
  2411. if (lRet == false){
  2412. bootbox.hideAll();
  2413. }
  2414. return false;
  2415. }
  2416. }
  2417. //Cria a linha
  2418. if (lRet == true) {
  2419. if (linhaAtu.length < 2) {
  2420. linhaAtu = "0" + linhaAtu;
  2421. }
  2422. // Carrega os campos do grid
  2423. getFieldsGrid(aFields);
  2424. var tbl = document.getElementById('datatable-editable'), // table reference
  2425. row = tbl.insertRow(tbl.rows.length), // append table row
  2426. i;
  2427. // insert table cells to the new row
  2428. for (i = 0; i < tbl.rows[0].cells.length; i++) {
  2429. newCreateCell(row.insertCell(i), i, linhaAtu, tbl.rows[0].cells.length - 1, aFields[i]);
  2430. }
  2431. // Adiciona um ouvinte de eventos usando a delegação de eventos
  2432. $(document).on('focusout', '[data-row] input', function () {
  2433. // Captura o valor do campo CK_PRODUTO
  2434. var produtoDigitado = this.value;
  2435. // Obtém o numero da linha associado ao campo
  2436. var linhaAtu = $(this).data('row');
  2437. // Chama a função buscarProdutos
  2438. buscarProdutos(produtoDigitado, function (listaProdutos) {
  2439. // Aqui voce pode fazer algo com a lista de produtos, se necessario
  2440. });
  2441. });
  2442. //Adiciona a classe no ultimo td
  2443. $('tr:last').find('td:last').addClass('actions');
  2444. //Adiciona id na linha
  2445. $('tr:last').attr('id','linha'+linhaAtu);
  2446. $('tr:last').attr('class','odd');
  2447. //Atualiza a quantidade de linhas
  2448. $("#PROXIMO").val(linhaAtu);
  2449. //Habilita o botão para adicionar itens
  2450. btnAdd.removeAttr('disabled');
  2451. formate();
  2452. };
  2453. });
  2454. //Obtém os campos da linha
  2455. function getFieldsGrid(aFields) {
  2456. let aExtras = [];
  2457. /// Definicao de campos extras
  2458. aExtras.push({"field": 'btnInfo',
  2459. "element": "i",
  2460. "attrs":[
  2461. {"class": "fa fa-info fa-lg"},
  2462. {"title": "Detalhes da linha"},
  2463. {'onclick': 'detalheOrc($(this).attr("id").substr(-2))'}
  2464. ]
  2465. });
  2466. aExtras.push({"field": 'btnExcl',
  2467. "element": "i",
  2468. "attrs":[
  2469. {"class": "fa fa-times-circle fa-lg"},
  2470. {"title": "Remover linha"},
  2471. {'onclick': 'removeItem($(this).attr("id").substr(-2))'}
  2472. ]
  2473. });
  2474. aExtras.push({"field": 'ALIQ_ICMS',
  2475. "element": "input",
  2476. "attrs":[
  2477. {"type": "hidden"},
  2478. {"value": "0"}
  2479. ]
  2480. });
  2481. aExtras.push({"field": 'ALIQ_IPI',
  2482. "element": "input",
  2483. "attrs":[
  2484. {"type": "hidden"},
  2485. {"value": "0"}
  2486. ]
  2487. });
  2488. aExtras.push({"field": 'ALIQ_ST',
  2489. "element": "input",
  2490. "attrs":[
  2491. {"type": "hidden"},
  2492. {"value": "0"}
  2493. ]
  2494. });
  2495. aExtras.push({"field": 'VAL_ICMS',
  2496. "element": "input",
  2497. "attrs":[
  2498. {"type": "hidden"},
  2499. {"value": "0"}
  2500. ]
  2501. });
  2502. aExtras.push({"field": 'VAL_IPI',
  2503. "element": "input",
  2504. "attrs":[
  2505. {"type": "hidden"},
  2506. {"value": "0"}
  2507. ]
  2508. });
  2509. aExtras.push({"field": 'VAL_ST',
  2510. "element": "input",
  2511. "attrs":[
  2512. {"type": "hidden"},
  2513. {"value": "0"}
  2514. ]
  2515. });
  2516. aExtras.push({"field": 'BASE_ICMS',
  2517. "element": "input",
  2518. "attrs":[
  2519. {"type": "hidden"},
  2520. {"value": "0"}
  2521. ]
  2522. });
  2523. aExtras.push({"field": 'BASE_ST',
  2524. "element": "input",
  2525. "attrs":[
  2526. {"type": "hidden"},
  2527. {"value": "0"}
  2528. ]
  2529. });
  2530. aExtras.push({"field": 'BASE_IPI',
  2531. "element": "input",
  2532. "attrs":[
  2533. {"type": "hidden"},
  2534. {"value": "0"}
  2535. ]
  2536. });
  2537. aExtras.push({"field": 'IMP_PRCTAB',
  2538. "element": "input",
  2539. "attrs":[
  2540. {"type": "hidden"},
  2541. {"value": "0"}
  2542. ]
  2543. });
  2544. aExtras.push({"field": 'QTD_EMB',
  2545. "element": "input",
  2546. "attrs":[
  2547. {"type": "hidden"},
  2548. {"value": "0"}
  2549. ]
  2550. });
  2551. aExtras.push({"field": 'CK_TES',
  2552. "element": "input",
  2553. "attrs":[
  2554. {"type": "hidden"},
  2555. {"value": ""}
  2556. ]
  2557. });
  2558. aExtras.push({"field": 'QTDMIN',
  2559. "element": "input",
  2560. "attrs":[
  2561. {"type": "hidden"},
  2562. {"value": "0"}
  2563. ]
  2564. });
  2565. aExtras.push({"field": 'GRUPO',
  2566. "element": "input",
  2567. "attrs":[
  2568. {"type": "hidden"},
  2569. {"value": ""}
  2570. ]
  2571. });
  2572. aExtras.push({"field": 'VENCIMENTO',
  2573. "element": "input",
  2574. "attrs":[
  2575. {"type": "hidden"},
  2576. {"value": ""}
  2577. ]
  2578. });
  2579. /// Definicao de campos da tabela
  2580. aFields.push({"field": 'CK_ITEM' ,
  2581. "showtd": true,
  2582. "element": "input",
  2583. "attrs": [
  2584. {"type": "text"},
  2585. {"class": "form-control text-left input-block"},
  2586. {"disabled": "disabled"},
  2587. {"value": ""}
  2588. ],
  2589. "aftercreate": function(newLine) {
  2590. $("#CK_ITEM"+newLine).val(newLine);
  2591. }
  2592. });
  2593. aFields.push({"field": 'CK_PRODUTO',
  2594. "showtd": true
  2595. });
  2596. aFields.push({"field": 'CK_QTDVEN' ,
  2597. "showtd": true,
  2598. "element": "input",
  2599. "attrs":[
  2600. {"type": "text"},
  2601. {"class": "form-control text-right only-numbers"},
  2602. {"disabled": "disabled"},
  2603. {"value": ""},
  2604. {"placeholder": "0"},
  2605. {'required': 'required'},
  2606. {'aria-required': 'true'},
  2607. {"onblur": 'javascript:VldQtd($(this).attr("id").substr(-2))'},
  2608. {'onkeyup': 'javascript:TotalItem($(this).attr("id").substr(-2))'}
  2609. ]
  2610. });
  2611. aFields.push({"field": 'CK_OBS' ,
  2612. "showtd": true,
  2613. "element": "input",
  2614. "attrs":[
  2615. {"type": "text"},
  2616. {"class": "form-control text-left"},
  2617. {"disabled": "disabled"},
  2618. {"value": ""},
  2619. {"maxlength": "80"}
  2620. ]
  2621. });
  2622. aFields.push({"field": 'CK_PRZEMB' ,
  2623. "showtd": true,
  2624. "element": "input",
  2625. "attrs":[
  2626. {"type": "text"},
  2627. {"class": "form-control text-right"},
  2628. {"disabled": "disabled"},
  2629. {"value": ""},
  2630. {"maxlength": "3"}
  2631. ]
  2632. });
  2633. aFields.push({"field": 'CK_PRCVEN' ,
  2634. "showtd": true,
  2635. "element": "input",
  2636. "attrs":[
  2637. {"type": "text"},
  2638. {"class": "form-control text-right input-block"},
  2639. {"disabled": "disabled"},
  2640. {"value": ""}
  2641. ]
  2642. });
  2643. aFields.push({"field": 'CK_XPRCIMP',
  2644. "showtd": false,
  2645. "element": "input",
  2646. "attrs":[
  2647. {"type": "text"},
  2648. {"class": "form-control text-right input-block"},
  2649. {"disabled": "disabled"},
  2650. {"value": ""}
  2651. ]
  2652. });
  2653. aFields.push({"field": 'iCK_PRCVEN',
  2654. "showtd": false,
  2655. "element": "input",
  2656. "attrs":[
  2657. {"type": "text"},
  2658. {"class": "form-control text-right myformato"},
  2659. {"disabled": "disabled"},
  2660. {"value": ""},
  2661. {"placeholder": "0"},
  2662. {"onblur": 'javascript:VldValor($(this).attr("id").substr(-2))'},
  2663. {'onkeyup': 'javascript:TotalItem($(this).attr("id").substr(-2))'},
  2664. {'onkeypress': 'FormataValor(this,28,event,2,".",",") || return(moeda(this,'+"'.'"+','+"','"+',event))'}
  2665. ]
  2666. });
  2667. aFields.push({"field": 'CK_CUSTO',
  2668. "showtd": false,
  2669. "element": "input",
  2670. "attrs":[
  2671. {"type": "text"},
  2672. {"class": "form-control text-right"},
  2673. {"disabled": "disabled"}
  2674. ]
  2675. });
  2676. // "aftercreate": "function x"
  2677. aFields.push({"field": 'CK_XVALIPI',
  2678. "showtd": false,
  2679. "element": "input",
  2680. "attrs":[
  2681. {"type": "text"},
  2682. {"class": "form-control text-right input-block"},
  2683. {"disabled": "disabled"},
  2684. {"value": ""}
  2685. ]
  2686. });
  2687. aFields.push({"field": 'CK_XVALICM',
  2688. "showtd": false,
  2689. "element": "input",
  2690. "attrs":[
  2691. {"type": "text"},
  2692. {"class": "form-control text-right input-block"},
  2693. {"disabled": "disabled"},
  2694. {"value": ""}
  2695. ]
  2696. });
  2697. aFields.push({"field": 'CK_XICMST' ,
  2698. "showtd": false,
  2699. "element": "input",
  2700. "attrs":[
  2701. {"type": "text"},
  2702. {"class": "form-control text-right input-block"},
  2703. {"disabled": "disabled"},
  2704. {"value": ""}
  2705. ]
  2706. });
  2707. aFields.push({"field": 'CK_DESCONT',
  2708. "showtd": <%=cShowDesc%>,
  2709. "element": "input",
  2710. "attrs":[
  2711. {"type": "text"},
  2712. {"class": "form-control text-right percentual"},
  2713. {"disabled": "disabled"},
  2714. {"value": ""},
  2715. {"placeholder": "0,00"},
  2716. {'maxlength': '7'},
  2717. {"onblur": 'javascript:VldValor($(this).attr("id").substr(-2))'},
  2718. {'onkeyup': 'javascript:TotalItem($(this).attr("id").substr(-2))'}
  2719. ]
  2720. });
  2721. aFields.push({"field": 'CK_NOMDIRE',
  2722. "showtd": false,
  2723. "element": "input",
  2724. "attrs":[
  2725. {"type": "text"},
  2726. {"class": "form-control text-left"},
  2727. {"disabled": "disabled"},
  2728. {"value": ""},
  2729. {'maxlength': '12'}
  2730. ]
  2731. });
  2732. aFields.push({"field": 'PER_COM' ,
  2733. "showtd": false,
  2734. "element": "input",
  2735. "attrs":[
  2736. {"type": "text"},
  2737. {"class": "form-control text-right input-block"},
  2738. {"disabled": "disabled"},
  2739. {"value": ""}
  2740. ]
  2741. });
  2742. aFields.push({"field": 'VAL_COM' ,
  2743. "showtd": false,
  2744. "element": "input",
  2745. "attrs":[
  2746. {"type": "text"},
  2747. {"class": "form-control text-right input-block"},
  2748. {"disabled": "disabled"},
  2749. {"value": ""}
  2750. ]
  2751. });
  2752. aFields.push({"field": 'CK_VALOR' ,
  2753. "showtd": true,
  2754. "element": "input",
  2755. "attrs":[
  2756. {"type": "text"},
  2757. {"class": "form-control text-right input-block"},
  2758. {"disabled": "disabled"},
  2759. {"value": ""}
  2760. ]
  2761. });
  2762. aFields.push({"field": 'botoes' ,
  2763. "showtd": true,
  2764. "element": "extras",
  2765. "extras": aExtras
  2766. });
  2767. }
  2768. // Criacao da linha da tabela
  2769. function newCreateCell(objCell, ncol, newLine, nTam, objCrea) {
  2770. // Criacao dos elementos
  2771. if ("extras" !== objCrea["element"]) {
  2772. if (objCrea["field"] == "CK_PRODUTO") {
  2773. //icone de pesquisa
  2774. let obji = document.createElement("i");
  2775. obji.setAttribute("class","fa fa-search");
  2776. obji.setAttribute("alt","Pesquisar");
  2777. //botão do icone de pesquisa
  2778. let objb = document.createElement("button");
  2779. objb.setAttribute("class","btSearch");
  2780. objb.setAttribute("id","btSearch"+newLine);
  2781. objb.appendChild(obji); //apenda o icone no botão
  2782. //input do produto
  2783. let objinp = document.createElement("input");
  2784. objinp.setAttribute("type","text");
  2785. objinp.setAttribute("class","form-control smsediticon");
  2786. objinp.setAttribute("placeholder","Digite o código ou descrição...");
  2787. objinp.setAttribute("name","CK_PRODUTO" + newLine);
  2788. objinp.setAttribute("id","CK_PRODUTO" + newLine);
  2789. objinp.setAttribute("aria-required","true");
  2790. objinp.setAttribute("data-live-search","true");
  2791. objinp.setAttribute("autocomplete","off");
  2792. objinp.setAttribute("value","");
  2793. //div flexContainer
  2794. let objDivFlex = document.createElement("div");
  2795. objDivFlex.setAttribute("class","flexContainer");
  2796. objDivFlex.appendChild(objinp);
  2797. objDivFlex.appendChild(objb);
  2798. //div com tamanho da coluna
  2799. let objDivCol = document.createElement("div");
  2800. objDivCol.setAttribute("class","col-md-12");
  2801. objDivCol.appendChild(objDivFlex);
  2802. //div principal
  2803. let objDivForm = document.createElement("div");
  2804. objDivForm.setAttribute("class","form-group");
  2805. objDivForm.appendChild(objDivCol);
  2806. objCell.appendChild(objDivForm);
  2807. } else {
  2808. let objElem = document.createElement(objCrea["element"]);
  2809. objElem.setAttribute('id', objCrea["field"] + newLine);
  2810. if ("input.select.".includes(objCrea["element"]+".")) {
  2811. objElem.setAttribute('name', objCrea["field"] + newLine);
  2812. }
  2813. if (objCrea["attrs"]) {
  2814. for (let attr of objCrea["attrs"]) {
  2815. for (let [key, value] of Object.entries(attr)) {
  2816. objElem.setAttribute(key, value);
  2817. }
  2818. }
  2819. }
  2820. if (objCrea["beforeadd"]) {
  2821. objCrea["beforeadd"](objElem, newLine);
  2822. }
  2823. objCell.appendChild(objElem);
  2824. if (objCrea["aftercreate"]) {
  2825. objCrea["aftercreate"](newLine);
  2826. }
  2827. }
  2828. } else {
  2829. // Inclusao dos campos extras na ultima coluna
  2830. for (let extra of objCrea["extras"]) {
  2831. let objElem = document.createElement(extra["element"]);
  2832. objElem.setAttribute('id', extra["field"] + newLine);
  2833. if (extra["element"] == "input") {
  2834. objElem.setAttribute('name', extra["field"] + newLine);
  2835. }
  2836. if (extra["attrs"]) {
  2837. for (let attr of extra["attrs"]) {
  2838. for (let [key, value] of Object.entries(attr)) {
  2839. objElem.setAttribute(key, value);
  2840. }
  2841. }
  2842. }
  2843. objCell.appendChild(objElem);
  2844. }
  2845. }
  2846. if (!objCrea.showtd) {
  2847. $('tr:last').find('td:last').attr('hidden','');
  2848. }
  2849. }
  2850. // Carrega parceiros ativos do AC4
  2851. function carregarParceiros() {
  2852. $.ajax({
  2853. url: "U_GETPARC.apw?PR=<%=cLCodLogin%>",
  2854. success: function(retorno) {
  2855. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
  2856. $("html").html(retorno);
  2857. return;
  2858. }
  2859. if(retorno == "") {
  2860. bootbox.alert("Falha ao carregar os parceiros, tente novamente!");
  2861. return;
  2862. }
  2863. var combo = $("#cmbParceiro");
  2864. combo.empty();
  2865. combo.append(retorno);
  2866. },
  2867. error: function(xhr, status, error) {
  2868. bootbox.alert("Erro ao carregar parceiros: " + error);
  2869. }
  2870. });
  2871. }
  2872. // Função para carregar a tabela de parceiros
  2873. function carregarTabelaParceiros() {
  2874. var numOrc = $("#CJ_NUM").val();
  2875. if (!numOrc) return;
  2876. $.ajax({
  2877. url: "U_LISTPARC.apw?PR=<%=cLCodLogin%>",
  2878. type: "POST",
  2879. data: { numOrc: numOrc },
  2880. success: function(retorno) {
  2881. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
  2882. $("html").html(retorno);
  2883. return;
  2884. }
  2885. $("#tblParceiros").html(retorno);
  2886. }
  2887. });
  2888. }
  2889. function openModel(parceiro, numOrc, rtpagar, rtaumentar, operacao) {
  2890. $("#formParceiro")[0].reset();
  2891. $("#cmbParceiro").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
  2892. $("#cmbRTPagar").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
  2893. $("#txtRTAumentar").attr('readonly', true).attr("style", "pointer-events: none;");;
  2894. if(operacao == 'edit'){
  2895. $("#tituloIncPar")[0].childNodes[0].data = "Editar Parceiro"
  2896. $("#cmbParceiro").attr('readonly', true).attr("style", "pointer-events: none;");;
  2897. }else if(operacao == 'delete'){
  2898. $("#tituloIncPar")[0].childNodes[0].data = "Excluir Parceiro"
  2899. $("#cmbParceiro").attr('readonly', true).attr("style", "pointer-events: none;");;
  2900. $("#cmbRTPagar").attr('readonly', true).attr("style", "pointer-events: none;");;
  2901. $("#txtRTAumentar").attr('readonly', true).attr("style", "pointer-events: none;");;
  2902. }
  2903. $("#dialogParceiro").modal('show');
  2904. $("#operacao").val(operacao)
  2905. $("#cmbParceiro").val(parceiro);
  2906. $("#cmbRTPagar").val(rtpagar);
  2907. $("#txtRTAumentar").val(rtaumentar);
  2908. }
  2909. function adicionarParceiro(parceiro, rtpagar, rtaumentar, numOrc){
  2910. var dialogSlv = bootbox.dialog({
  2911. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Salvando parceiro... Aguarde...</p>',
  2912. closeButton: false
  2913. });
  2914. $.ajax({
  2915. url: "U_ADDPARC.apw?PR=<%=cLCodLogin%>",
  2916. type: "POST",
  2917. data: {
  2918. parceiro: parceiro,
  2919. rtpagar: rtpagar,
  2920. rtaumentar: rtaumentar,
  2921. numOrc: numOrc
  2922. },
  2923. // success: function(retorno) {
  2924. // if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
  2925. // alert("Erro ao salvar parceiro!");
  2926. // $("html").html(retorno);
  2927. // return;
  2928. // }
  2929. // bootbox.alert("Parceiro salvo com sucesso!");
  2930. // location.reload();
  2931. // }
  2932. }).fail(function(){
  2933. bootbox.alert({
  2934. title: titulo,
  2935. message: "Não foi possível adicionar o parceiro.",
  2936. backdrop: true,
  2937. callback: function (strXml) {
  2938. dialogSlv.modal('hide');
  2939. }
  2940. });
  2941. }).done(function(strXml) {
  2942. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  2943. $("html").html(strXml);
  2944. return;
  2945. }
  2946. if (strXml.toUpperCase().indexOf("NOK") != -1){
  2947. bootbox.alert({
  2948. title: "Cadastro de Parceiro",
  2949. message: "Falha na inclusão de parceiro.",
  2950. backdrop: true,
  2951. callback: function (result) {
  2952. dialogSlv.modal('hide');
  2953. }
  2954. });
  2955. }
  2956. else {
  2957. bootbox.alert({
  2958. title: "Cadastro de Parceiro",
  2959. message: "Parceiro incluído com sucesso!",
  2960. backdrop: true,
  2961. callback: function (result) {
  2962. carregarTabelaParceiros()
  2963. $("#operacao").val('')
  2964. dialogSlv.modal('hide');
  2965. }
  2966. });
  2967. }
  2968. });
  2969. }
  2970. // Função para editar parceiro
  2971. function editarParceiro(parceiro, rtpagar, rtaumentar, numOrc) {
  2972. var dialogSlv = bootbox.dialog({
  2973. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Editando parceiro... Aguarde...</p>',
  2974. closeButton: false
  2975. });
  2976. $.ajax({
  2977. url: "U_EDITPARC.apw?PR=<%=cLCodLogin%>",
  2978. type: "POST",
  2979. data: {
  2980. parceiro: parceiro,
  2981. rtpagar: rtpagar,
  2982. rtaumentar: rtaumentar,
  2983. numOrc: numOrc
  2984. },
  2985. // success: function(response) {
  2986. // if (response.success) {
  2987. // // Atualiza a tabela
  2988. // location.reload();
  2989. // } else {
  2990. // alert(response.message || "Erro ao salvar parceiro!");
  2991. // }
  2992. // }
  2993. }).fail(function(){
  2994. bootbox.alert({
  2995. title: titulo,
  2996. message: "Não foi possível editar o parceiro.",
  2997. backdrop: true,
  2998. callback: function (strXml) {
  2999. dialogSlv.modal('hide');
  3000. }
  3001. });
  3002. }).done(function(strXml) {
  3003. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  3004. $("html").html(strXml);
  3005. return;
  3006. }
  3007. if (strXml.toUpperCase().indexOf("NOK") != -1){
  3008. bootbox.alert({
  3009. title: "Cadastro de Parceiro",
  3010. message: "Falha na edição de parceiro.",
  3011. backdrop: true,
  3012. callback: function (result) {
  3013. dialogSlv.modal('hide');
  3014. }
  3015. });
  3016. }
  3017. else {
  3018. bootbox.alert({
  3019. title: "Cadastro de Parceiro",
  3020. message: "Parceiro editado com sucesso!",
  3021. backdrop: true,
  3022. callback: function (result) {
  3023. carregarTabelaParceiros()
  3024. $("#operacao").val('')
  3025. dialogSlv.modal('hide');
  3026. }
  3027. });
  3028. }
  3029. });
  3030. }
  3031. // Função para excluir parceiro
  3032. function excluirParceiro(parceiro, numOrc) {
  3033. bootbox.confirm({
  3034. message: "Deseja realmente excluir este parceiro?",
  3035. buttons: {
  3036. confirm: {
  3037. label: 'Sim',
  3038. className: 'btn-success'
  3039. },
  3040. cancel: {
  3041. label: 'Não',
  3042. className: 'btn-danger'
  3043. }
  3044. },
  3045. callback: function (result) {
  3046. if (result) {
  3047. var dialogSlv = bootbox.dialog({
  3048. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Excluindo parceiro... Aguarde...</p>',
  3049. closeButton: false
  3050. });
  3051. $.ajax({
  3052. url: "U_DELPARC.apw?PR=<%=cLCodLogin%>",
  3053. type: "POST",
  3054. data: { parceiro: parceiro, numOrc: numOrc},
  3055. // success: function(retorno) {
  3056. // if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
  3057. // $("html").html(retorno);
  3058. // return;
  3059. // }
  3060. // bootbox.alert("Parceiro excluído com sucesso!");
  3061. // }
  3062. }).fail(function(){
  3063. bootbox.alert({
  3064. title: titulo,
  3065. message: "Não foi possível excluir o parceiro.",
  3066. backdrop: true,
  3067. callback: function (strXml) {
  3068. dialogSlv.modal('hide');
  3069. }
  3070. });
  3071. }).done(function(strXml) {
  3072. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  3073. $("html").html(strXml);
  3074. return;
  3075. }
  3076. if (strXml.toUpperCase().indexOf("NOK") != -1){
  3077. bootbox.alert({
  3078. title: "Cadastro de Parceiro",
  3079. message: "Falha na exclusão de parceiro.",
  3080. backdrop: true,
  3081. callback: function (result) {
  3082. dialogSlv.modal('hide');
  3083. }
  3084. });
  3085. }
  3086. else {
  3087. bootbox.alert({
  3088. title: "Cadastro de Parceiro",
  3089. message: "Parceiro excluído com sucesso!",
  3090. backdrop: true,
  3091. callback: function (result) {
  3092. $("#operacao").val('')
  3093. carregarTabelaParceiros()
  3094. dialogSlv.modal('hide');
  3095. }
  3096. });
  3097. }
  3098. });
  3099. }
  3100. }
  3101. });
  3102. }
  3103. function atualizaRT(value){
  3104. var rtaumentar = $("#txtRTAumentar");
  3105. switch (value) {
  3106. case '3':
  3107. rtaumentar.val('5')
  3108. break;
  3109. case '5':
  3110. rtaumentar.val('8.5')
  3111. break;
  3112. case '7':
  3113. rtaumentar.val('12')
  3114. break;
  3115. case '10':
  3116. rtaumentar.val('19')
  3117. break;
  3118. default:
  3119. rtaumentar.val('')
  3120. break;
  3121. }
  3122. }
  3123. //Salvar o orçamento
  3124. $('#btSalvar').click(function() {
  3125. var lRet = true
  3126. var i = 0;
  3127. var nItens = parseFloat($("#PROXIMO").val());
  3128. var lGrid = true;
  3129. var lGrid1 = true;
  3130. var cCodProd;
  3131. var cItmOrc;
  3132. var btnSlv = $(this);
  3133. var cGrupo = "";
  3134. var dialogOrc = bootbox.dialog({
  3135. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Validando orçamento. Aguarde...</p>',
  3136. closeButton: false
  3137. });
  3138. //Desabilita o botao
  3139. btnSlv.attr({ 'disabled': 'disabled' });
  3140. $.ajax({
  3141. url: "U_VerSessao.apw?PR=<%=cLCodLogin%>",
  3142. type: "POST",
  3143. async: false,
  3144. success:
  3145. function(retorno) {
  3146. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  3147. $("html").html(retorno);
  3148. return;
  3149. }
  3150. if (retorno == "nok"||retorno == ''||retorno.toUpperCase().indexOf("EXPIRES") != -1){
  3151. $("#orc-informar").html();
  3152. bootbox.alert('Não foi possível realizar a operação pois a sessão foi fechada. Faça login novamente.');
  3153. lRet = false;
  3154. btnSlv.removeAttr('disabled');
  3155. dialogOrc.modal('hide');
  3156. }
  3157. }
  3158. });
  3159. /**
  3160. Valida os campos obrigatorios
  3161. **/
  3162. //Cliente
  3163. cliente = formataCli($("#CJ_CLIENTE").val());
  3164. if (cliente == "") {
  3165. lRet = false;
  3166. $("#orc-informar").html();
  3167. new PNotify({
  3168. title: 'Campo obrigatório',
  3169. text: 'Preencha o campo Cliente!',
  3170. type: 'error',
  3171. });
  3172. btnSlv.removeAttr('disabled');
  3173. dialogOrc.modal('hide');
  3174. $("#CJ_CLIENTE").focus();
  3175. }
  3176. /**
  3177. Valida os campos obrigatorios
  3178. **/
  3179. //Cliente
  3180. cliente = formataCli($("#CJ_CLIENTE").val());
  3181. if (cliente == "") {
  3182. lRet = false;
  3183. $("#orc-informar").html();
  3184. new PNotify({
  3185. title: 'Campo obrigatório',
  3186. text: 'Preencha o campo Cliente!',
  3187. type: 'error',
  3188. });
  3189. btnSlv.removeAttr('disabled');
  3190. dialogOrc.modal('hide');
  3191. $("#CJ_CLIENTE").focus();
  3192. }
  3193. //Contato do Cliente
  3194. if (lRet == true && $("#CJ_XCONTAT").val() == "") {
  3195. lRet = false;
  3196. $("#orc-informar").html();
  3197. new PNotify({
  3198. title: 'Campo obrigatório',
  3199. text: 'Preencha o campo Contato do Cliente!',
  3200. type: 'error',
  3201. });
  3202. btnSlv.removeAttr('disabled');
  3203. dialogOrc.modal('hide');
  3204. $("#CJ_XCONTAT").focus();
  3205. }
  3206. //Contato do Cliente - DDD
  3207. if (lRet == true && $("#CJ_XCONDDD").val() == "") {
  3208. lRet = false;
  3209. $("#orc-informar").html();
  3210. new PNotify({
  3211. title: 'Campo obrigatório',
  3212. text: 'Preencha o campo DDD do Contato!',
  3213. type: 'error',
  3214. });
  3215. btnSlv.removeAttr('disabled');
  3216. dialogOrc.modal('hide');
  3217. $("#CJ_XCONDDD").focus();
  3218. }
  3219. //Contato do Cliente - Telefone
  3220. if (lRet == true && $("#CJ_XCONTEL").val() == "") {
  3221. lRet = false;
  3222. $("#orc-informar").html();
  3223. new PNotify({
  3224. title: 'Campo obrigatório',
  3225. text: 'Preencha o campo Telefone do Contato!',
  3226. type: 'error',
  3227. });
  3228. btnSlv.removeAttr('disabled');
  3229. dialogOrc.modal('hide');
  3230. $("#CJ_XCONTEL").focus();
  3231. }
  3232. //Cliente de entrega
  3233. if (lRet == true && $("#CJ_CLIENT").val() == "") {
  3234. lRet = false;
  3235. $("#orc-informar").html();
  3236. new PNotify({
  3237. title: 'Campo obrigatório',
  3238. text: 'Preencha o campo Cliente de Entrega!',
  3239. type: 'error',
  3240. });
  3241. btnSlv.removeAttr('disabled');
  3242. dialogOrc.modal('hide');
  3243. $("#CJ_CLIENT").focus();
  3244. }
  3245. //Tabela de preço
  3246. if (lRet == true && $("#CJ_TABELA").val() == "") {
  3247. lRet = false;
  3248. $("#orc-informar").html();
  3249. new PNotify({
  3250. title: 'Campo obrigatório',
  3251. text: 'Falha ao localizar a Tabela de Preço!',
  3252. type: 'error',
  3253. });
  3254. btnSlv.removeAttr('disabled');
  3255. dialogOrc.modal('hide');
  3256. $("#CJ_TABELA").focus();
  3257. }
  3258. //Data de Entrega
  3259. /*
  3260. if (lRet == true && $("#CK_ENTREG").val() == "") {
  3261. lRet = false;
  3262. $("#orc-informar").html();
  3263. new PNotify({
  3264. title: 'Campo obrigatório',
  3265. text: 'Preencha o campo Previsão de Faturamento!',
  3266. type: 'error',
  3267. });
  3268. btnSlv.removeAttr('disabled');
  3269. dialogOrc.modal('hide');
  3270. $("#CK_ENTREGA").focus();
  3271. }
  3272. */
  3273. //Condição de pagamento
  3274. if (lRet == true && $("#CJ_CONDPAG").val() == "") {
  3275. lRet = false;
  3276. $("#orc-informar").html();
  3277. new PNotify({
  3278. title: 'Campo obrigatório',
  3279. text: 'Preencha o campo Condição de Pagamento!',
  3280. type: 'error',
  3281. });
  3282. btnSlv.removeAttr('disabled');
  3283. dialogOrc.modal('hide');
  3284. $("#CJ_CONDPAG").focus();
  3285. }
  3286. //Oportunidade
  3287. if (lRet == true && $("#CJ_NROPOR").val() == "") {
  3288. lRet = false;
  3289. $("#orc-informar").html();
  3290. new PNotify({
  3291. title: 'Campo obrigatório',
  3292. text: 'Preencha o campo Oportunidade!',
  3293. type: 'error',
  3294. });
  3295. btnSlv.removeAttr('disabled');
  3296. dialogOrc.modal('hide');
  3297. $("#CJ_NROPOR").focus();
  3298. }
  3299. //Nome da Obra
  3300. if (lRet == true && $("#CJ_OBRA").val() == "") {
  3301. lRet = false;
  3302. $("#orc-informar").html();
  3303. new PNotify({
  3304. title: 'Campo obrigatório',
  3305. text: 'Preencha o campo Nome da Obra!',
  3306. type: 'error',
  3307. });
  3308. btnSlv.removeAttr('disabled');
  3309. dialogOrc.modal('hide');
  3310. $("#CJ_OBRA").focus();
  3311. }
  3312. //Tipo da Obra
  3313. if (lRet == true && $("#CJ_YOBRATP").val() == "") {
  3314. lRet = false;
  3315. $("#orc-informar").html();
  3316. new PNotify({
  3317. title: 'Campo obrigatório',
  3318. text: 'Preencha o campo Tipo da Obra!',
  3319. type: 'error',
  3320. });
  3321. btnSlv.removeAttr('disabled');
  3322. dialogOrc.modal('hide');
  3323. $("#CJ_YOBRATP").focus();
  3324. }
  3325. //Status da obra
  3326. if (lRet == true && $("#CJ_VEND6").val() == "") {
  3327. lRet = false;
  3328. $("#orc-informar").html();
  3329. new PNotify({
  3330. title: 'Campo obrigatório',
  3331. text: 'Preencha o campo Status da Obra!',
  3332. type: 'error',
  3333. });
  3334. btnSlv.removeAttr('disabled');
  3335. dialogOrc.modal('hide');
  3336. $("#CJ_VEND6").focus();
  3337. }
  3338. //Previsão de fechamento
  3339. if (lRet == true && $("#CJ_TERMOME").val() == "") {
  3340. lRet = false;
  3341. $("#orc-informar").html();
  3342. new PNotify({
  3343. title: 'Campo obrigatório',
  3344. text: 'Preencha o campo Previsão de Fechamento!',
  3345. type: 'error',
  3346. });
  3347. btnSlv.removeAttr('disabled');
  3348. dialogOrc.modal('hide');
  3349. $("#CJ_TERMOME").focus();
  3350. }
  3351. //Estudo luminotécnico
  3352. if (lRet == true && $("#CJ_LUMINOT").val() == "") {
  3353. lRet = false;
  3354. $("#orc-informar").html();
  3355. new PNotify({
  3356. title: 'Campo obrigatório',
  3357. text: 'Preencha o campo Estudo Luminotécnico!',
  3358. type: 'error',
  3359. });
  3360. btnSlv.removeAttr('disabled');
  3361. dialogOrc.modal('hide');
  3362. $("#CJ_LUMINOT").focus();
  3363. } else {
  3364. if($("#CJ_LUMINOT").val() == "1"){
  3365. if($("#CJ_REGLUMI").val() == ""){
  3366. lRet = false;
  3367. $("#orc-informar").html();
  3368. new PNotify({
  3369. title: 'Campo obrigatório',
  3370. text: 'Preencha o campo Número do Estudo Luminotécnico!',
  3371. type: 'error',
  3372. });
  3373. btnSlv.removeAttr('disabled');
  3374. dialogOrc.modal('hide');
  3375. $("#CJ_REGLUMI").focus();
  3376. }
  3377. }
  3378. }
  3379. //Segmento
  3380. if (lRet == true && $("#CJ_SEGMENT").val() == "") {
  3381. lRet = false;
  3382. $("#orc-informar").html();
  3383. new PNotify({
  3384. title: 'Campo obrigatório',
  3385. text: 'Preencha o campo Segmento!',
  3386. type: 'error',
  3387. });
  3388. btnSlv.removeAttr('disabled');
  3389. dialogOrc.modal('hide');
  3390. $("#CJ_SEGMENT").focus();
  3391. }
  3392. //Regional
  3393. if (lRet == true && $("#CJ_REGIAO").val() == "") {
  3394. lRet = false;
  3395. $("#orc-informar").html();
  3396. new PNotify({
  3397. title: 'Campo obrigatório',
  3398. text: 'Preencha o campo Regional!',
  3399. type: 'error',
  3400. });
  3401. btnSlv.removeAttr('disabled');
  3402. dialogOrc.modal('hide');
  3403. $("#CJ_REGIAO").focus();
  3404. }
  3405. //Vendedor 2
  3406. if (lRet == true && $("#CJ_VEND").val() == "") {
  3407. lRet = false;
  3408. $("#orc-informar").html();
  3409. new PNotify({
  3410. title: 'Campo obrigatório',
  3411. text: 'Preencha o campo Vendedor 2!',
  3412. type: 'error',
  3413. });
  3414. btnSlv.removeAttr('disabled');
  3415. dialogOrc.modal('hide');
  3416. $("#CJ_VEND").focus();
  3417. }
  3418. //Negociadora
  3419. if (lRet == true && $("#CJ_VEND7").val() == "") {
  3420. lRet = false;
  3421. $("#orc-informar").html();
  3422. new PNotify({
  3423. title: 'Campo obrigatório',
  3424. text: 'Preencha o campo Negociadora!',
  3425. type: 'error',
  3426. });
  3427. btnSlv.removeAttr('disabled');
  3428. dialogOrc.modal('hide');
  3429. $("#CJ_VEND7").focus();
  3430. }
  3431. //Frete
  3432. if (lRet == true && $("#CJ_FRETE").val() != "") {
  3433. cTpFrete = $("#CJ_TPFRETE").val();
  3434. nTotalOrc = $("#TOTAL_ITENS").maskMoney('unmasked')[0];
  3435. freteMinimo = $("#FRETEMIN").val();
  3436. ufEntrega = $("#CJ_UFENT").val().substr(0,2);
  3437. munEntrega = $("#CJ_UFENT").val().substr(1,5);
  3438. if (freteMinimo != ""){
  3439. if(nTotalOrc <= freteMinimo && (cTpFrete == "C" || cTpFrete == "")){
  3440. $.ajax({
  3441. url: "U_FreteMinimo.apw?PR=<%=cLCodLogin%>",
  3442. data: 'UFEnt='+ufEntrega+'&MunEntrega='+munEntrega,
  3443. type: "POST",
  3444. async: false,
  3445. success:
  3446. function(frete) {
  3447. if (frete.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  3448. $("html").html(frete);
  3449. return;
  3450. } else {
  3451. if (parseInt(frete) > 0) {
  3452. $("#CJ_FRETE").val(frete);
  3453. TotalGeral();
  3454. }
  3455. }
  3456. }
  3457. });
  3458. } else {
  3459. $("#CJ_FRETE").val(0);
  3460. }
  3461. }
  3462. }
  3463. //Grid
  3464. if (lRet == true) {
  3465. var nPrcTab = 0;
  3466. var nPrcVen = 0;
  3467. var lVencido = false;
  3468. var lItmBlq = false;
  3469. var cGrpEsp = 'PE,PEL,PED,PI';
  3470. var cMsLumEspL = '';
  3471. for (i = 1; i<=nItens; i++) {
  3472. cItem = String(i);
  3473. if (parseInt(i) < 10 ){cItem = "0"+String(i)};
  3474. cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
  3475. if(lItmBlq==false){
  3476. lItmBlq = $("#CK_ITEM"+cItem).val() == "xx";
  3477. }
  3478. if(cItmOrc != "x") {
  3479. cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
  3480. qtd = parseFloat($("#CK_QTDVEN"+cItem).val().replace('.',"").replace(",","."));
  3481. nTotalOrc = $("#CK_TOTAL"+cItem).val();
  3482. //nPrcTab += $("#iCK_PRCVEN"+cItem).val().replace('.',"").replace(",",".") * qtd;
  3483. //nPrcVen += $("#CK_PRCVEN"+cItem).val().replace('.',"").replace(",",".") * qtd;
  3484. nPrcTab += $("#iCK_PRCVEN"+cItem).maskMoney('unmasked')[0] * qtd;
  3485. nPrcVen += $("#CK_PRCVEN"+cItem).maskMoney('unmasked')[0] * qtd;
  3486. //Valida o preenchimento dos campos produto e quantidade
  3487. if (cCodProd == "" || $('#CK_QTDVEN'+cItem).val() == "" || nTotalOrc == ""){
  3488. lGrid = false;
  3489. } else {
  3490. cGrupo = $("#GRUPO"+cItem).val();
  3491. vencido = $("#VENCIMENTO"+cItem).val();
  3492. //Valida itens de grupos especiais
  3493. if(cGrpEsp.includes(cGrupo) && vencido == '1' ){
  3494. lVencido = true;
  3495. cMsLumEspL += cItmOrc+';'+cCodProd+';'+$("#CK_QTDVEN"+cItem).val()+'|'
  3496. }
  3497. }
  3498. }
  3499. }
  3500. if (lGrid == false){
  3501. lRet = false;
  3502. $("#orc-informar").html();
  3503. new PNotify({
  3504. title: 'Campo obrigatório',
  3505. text: 'Verifique o preenchimento dos campos Produto, Quantidade e Valor!',
  3506. type: 'error',
  3507. });
  3508. btnSlv.removeAttr('disabled');
  3509. dialogOrc.modal('hide');
  3510. } else {
  3511. $.ajax({
  3512. url: "U_VldDscMax.apw?PR=<%=cLCodLogin%>",
  3513. data: 'vlrTabela='+nPrcTab+'&vlrVenda='+nPrcVen+'&condpag='+$("#CJ_CONDPAG").val()+"&descDir="+$('#CJ_DSDIRET').val(),
  3514. cache: false,
  3515. type: "POST",
  3516. async: false,
  3517. success:
  3518. function(retorno) {
  3519. if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
  3520. $("html").html(retorno);
  3521. return;
  3522. }
  3523. if (retorno.substr(0, 3) == "NOK"){
  3524. aDesc = retorno.split('|#|');
  3525. cMsg = "O orçamento excedeu a Política de Descontos. Entre em contato com a Supervisão ou Diretoria.<br>";
  3526. cMsg += "Desconto concedido: <b>"+aDesc[0].substr(4)+"</b><br>";
  3527. cMsg += "Desconto máximo permitido: <b>"+aDesc[1]+"</b>";
  3528. bootbox.alert(cMsg);
  3529. lRet = false;
  3530. btnSlv.removeAttr('disabled');
  3531. dialogOrc.modal('hide');
  3532. }
  3533. }
  3534. });
  3535. }
  3536. }
  3537. //Verifica os itens especiais vencidos antes de salvar o formulário
  3538. if(lRet == true && lVencido){
  3539. msg = 'Existem códigos especiais com preços desatualizados. <br>';
  3540. msg += 'Deseja enviar e-mail solicitando atualização?';
  3541. bootbox.confirm({
  3542. title: 'Códigos especiais',
  3543. message: "<p>"+msg+"</p>",
  3544. backdrop: true,
  3545. buttons: {
  3546. cancel: {
  3547. label: 'Não'
  3548. },
  3549. confirm: {
  3550. label: 'Sim'
  3551. }
  3552. },
  3553. callback: function (result) {
  3554. if (result){
  3555. filorc = $("#CJ_FILIAL").val();
  3556. numorc = $("#CJ_NUM").val();
  3557. obra = $("#CJ_OBRA").val();
  3558. //Chama a função para envio de email
  3559. $.ajax({
  3560. url: "U_AtuPreco.apw?PR=<%=cLCodLogin%>",
  3561. type: "POST",
  3562. data: 'filial='+filorc+'&orcto='+numorc+'&obra='+obra+'&itens='+cMsLumEspL,
  3563. async: false
  3564. });
  3565. }
  3566. }
  3567. });
  3568. }
  3569. //Salva o orçamento
  3570. if (lRet == true){
  3571. dialogOrc.modal('hide');
  3572. if (lItmBlq == true){
  3573. bootbox.confirm({
  3574. title: "Produto Bloqueado",
  3575. message: "Um ou mais produtos do orçamento estão bloqueados e não serão salvos.",
  3576. buttons: {
  3577. confirm: {
  3578. label: 'OK'
  3579. },
  3580. camcel:{
  3581. label: 'Cancelar'
  3582. }
  3583. },
  3584. callback: function (result) {
  3585. if (result){
  3586. //Submete o formulário
  3587. salvarOrc(btnSlv);
  3588. }
  3589. }
  3590. });
  3591. } else {
  3592. //Submete o formulário
  3593. salvarOrc(btnSlv);
  3594. }
  3595. }
  3596. })
  3597. //Submete formulario
  3598. function salvarOrc(btnSlv){
  3599. var numorc = "";
  3600. //if (lRet == true){
  3601. var dialogSlv = bootbox.dialog({
  3602. message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i>&nbsp;&nbsp;Salvando orçamento... Aguarde...</p>',
  3603. closeButton: false
  3604. });
  3605. //busca os itens cadastrados
  3606. var ITENS = "";
  3607. var i = 0;
  3608. var nItens = parseFloat($("#PROXIMO").val());
  3609. var cCodProd;
  3610. var cItmOrc;
  3611. var cDescAcresc = "0";
  3612. for (i = 1; i<=nItens; i++) {
  3613. cItem = String(i);
  3614. if (parseInt(i) < 10 ){cItem = "0"+String(i)};
  3615. cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
  3616. cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
  3617. if(cItmOrc != "x") {
  3618. cPrcVen = $('#CK_PRCVEN'+cItem).val();
  3619. ITENS+= formataProd($('#CK_PRODUTO'+cItem).val())+';'; //1
  3620. ITENS+= $('#CK_QTDVEN'+cItem).val()+';'; //2
  3621. ITENS+= $('#CK_OBS'+cItem).val()+';'; //3
  3622. ITENS+= $('#CK_PRZEMB'+cItem).val()+';'; //4
  3623. ITENS+= cPrcVen+';'; //5
  3624. ITENS+= $('#CK_XPRCIMP'+cItem).val()+';'; //6
  3625. ITENS+= $('#CK_XVALIPI'+cItem).val()+';'; //7
  3626. ITENS+= $('#CK_XVALICM'+cItem).val()+';'; //8
  3627. ITENS+= $('#CK_XICMST'+cItem).val()+';'; //9
  3628. ITENS+= $('#ALIQ_ICMS'+cItem).val()+';'; //10
  3629. ITENS+= $('#ALIQ_IPI'+cItem).val()+';'; //11
  3630. ITENS+= $('#ALIQ_ST'+cItem).val()+';'; //12
  3631. ITENS+= $('#CK_TES'+cItem).val()+';'; //13
  3632. ITENS+= $('#CK_CUSTO'+cItem).val()+';'; //14
  3633. ITENS+= $('#CK_NOMDIRE'+cItem).val()+';'; //15
  3634. ITENS+= $('#PER_COM'+cItem).val()+';'; //16
  3635. ITENS+= $('#VAL_COM'+cItem).val()+';'; //17
  3636. ITENS+= $('#CK_DESCONT'+cItem).val()+'||' //18
  3637. }
  3638. }
  3639. objDados = {
  3640. CJ_FILIAL: $('#CJ_FILIAL').val(),
  3641. CJ_NUM: $('#CJ_NUM').val(),
  3642. RECCJANT: $('#RECCJANT').val(),
  3643. CJ_CLIENTE: formataCli($('#CJ_CLIENTE').val()),
  3644. CJ_TABELA: $('#CJ_TABELA').val(),
  3645. CJ_NROPOR: $('#CJ_NROPOR').val(),
  3646. CJ_REVISA: $('#CJ_REVISA').val(),
  3647. CJ_XCONTAT: $('#CJ_XCONTAT').val(),
  3648. CJ_XCONDDD: $('#CJ_XCONDDD').val(),
  3649. CJ_XCONTEL: $('#CJ_XCONTEL').val(),
  3650. CJ_CLIENT: $('#CJ_CLIENT').val(),
  3651. CJ_UFENT: $('#CJ_UFENT').val(),
  3652. CJ_OBRA: $('#CJ_OBRA').val(),
  3653. CJ_YOBRATP: $('#CJ_YOBRATP').val(),
  3654. CJ_VEND6: $('#CJ_VEND6').val(),
  3655. CJ_TERMOME: $('#CJ_TERMOME').val(),
  3656. CJ_CONDPAG: $('#CJ_CONDPAG').val(),
  3657. CJ_CLIINTE: $('#CJ_CLIINTE').val(),
  3658. CJ_RETORNO: $('#CJ_RETORNO').val(),
  3659. CJ_LUMINOT: $('#CJ_LUMINOT').val(),
  3660. CJ_REGLUMI: $('#CJ_REGLUMI').val(),
  3661. CJ_SEGMENT: $('#CJ_SEGMENT').val(),
  3662. CJ_PROPECC: $('#CJ_PROPECC').val(),
  3663. CJ_PROSCOD: $('#CJ_PROSCOD').val(),
  3664. CJ_REGIAO: $('#CJ_REGIAO').val(),
  3665. CJ_VEND: $('#CJ_VEND').val(),
  3666. CJ_VEND3: $('#CJ_VEND3').val(),
  3667. CJ_VEND4: $('#CJ_VEND4').val(),
  3668. CJ_CODESP: $('#CJ_CODESP').val(),
  3669. CJ_VEND7: $('#CJ_VEND7').val(),
  3670. CJ_VALIDA: $('#CJ_VALIDA').val(),
  3671. CJ_PRZEMB: $('#CJ_PRZEMB').val(),
  3672. CJ_TPFRETE: $('#CJ_TPFRETE').val(),
  3673. CJ_PERCFRT: $('#CJ_PERCFRT').val(),
  3674. CJ_FRETE: $('#CJ_FRETE').val(),
  3675. CJ_COMISTR: $('#CJ_COMISTR').val(),
  3676. CJ_OBS: $('#CJ_OBS').val(),
  3677. CJ_DSDIRET: $('#CJ_DSDIRET').val(),
  3678. PROXIMO: $('#PROXIMO').val(),
  3679. OPCAO: $('#OPCAO').val(),
  3680. aItens: ITENS
  3681. };
  3682. if($("#OPCAO").val() == "3"){
  3683. msg = "O orçamento foi incluído com sucesso.";
  3684. titulo = "Inclusão de Orçamento";
  3685. operacao = "incluir";
  3686. }
  3687. if($("#OPCAO").val() == "4"){
  3688. msg = "O orçamento foi alterado com sucesso.";
  3689. titulo = "Alteração de Orçamento";
  3690. operacao = "alterar";
  3691. }
  3692. if($("#OPCAO").val() == "5"){
  3693. msg = "O orçamento foi excluído com sucesso.";
  3694. titulo = "Exclusão de Orçamento";
  3695. operacao = "excluir";
  3696. }
  3697. $.ajax({
  3698. type: "POST",
  3699. url: "U_SlvOrc.apw?PR=<%=cLCodLogin%>",
  3700. async: false,
  3701. data: objDados
  3702. }).fail(function(){
  3703. bootbox.alert({
  3704. title: titulo,
  3705. message: "Não foi possível "+operacao+" o orçamento.",
  3706. backdrop: true,
  3707. callback: function (result) {
  3708. btnSlv.removeAttr('disabled');
  3709. dialogSlv.modal('hide');
  3710. }
  3711. });
  3712. }).done(function(strXml) {
  3713. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  3714. $("html").html(strXml);
  3715. return;
  3716. }
  3717. if (strXml == 'erro'||strXml == ''||strXml.toUpperCase().indexOf("EXPIRES") != -1||strXml.toUpperCase().indexOf("INVALID") != -1){
  3718. if (strXml == ''){
  3719. bootbox.alert({
  3720. title: titulo,
  3721. message: "Aguarde o prazo de 3 minutos para "+operacao+" um novo orçamento.",
  3722. backdrop: true,
  3723. callback: function (result) {
  3724. btnSlv.removeAttr('disabled');
  3725. dialogSlv.modal('hide');
  3726. }
  3727. });
  3728. }else{
  3729. bootbox.alert({
  3730. title: titulo,
  3731. message: "Falha ao "+operacao+" o orçamento.",
  3732. backdrop: true,
  3733. callback: function (result) {
  3734. btnSlv.removeAttr('disabled');
  3735. dialogSlv.modal('hide');
  3736. }
  3737. });
  3738. }
  3739. }
  3740. else {
  3741. if($("#OPCAO").val() == "3"){
  3742. numorc = " Foi gerado o orçamento nº "+strXml+"."
  3743. }
  3744. bootbox.alert({
  3745. title: titulo,
  3746. message: msg+numorc,
  3747. backdrop: true,
  3748. callback: function (result) {
  3749. document.location.href = "U_Orcamento.apw?PR=<%=cLCodLogin%>";
  3750. dialogSlv.modal('hide');
  3751. }
  3752. });
  3753. }
  3754. });
  3755. //};
  3756. }
  3757. $('#btExcluir').click(function() {
  3758. var lRet = true
  3759. var i = 0;
  3760. var lGrid = true;
  3761. var cCodProd;
  3762. var btnSlv = $(this);
  3763. //Desabilita o botao
  3764. $('#btExcluir').attr({ 'disabled': 'disabled' });
  3765. objDados = {
  3766. CJ_CLIENTE: formataCli($('#CJ_CLIENTE').val()),
  3767. CJ_NUM: $('#CJ_NUM').val()
  3768. };
  3769. $.ajax({
  3770. type: "POST",
  3771. url: "U_ExcOrc.apw?PR=<%=cLCodLogin%>",
  3772. async: false,
  3773. data: objDados
  3774. }).fail(function(){
  3775. bootbox.alert({
  3776. title: "Exclusão de Orçamento",
  3777. message: "Não foi possível excluir o orçamento.",
  3778. backdrop: true,
  3779. callback: function (result) {
  3780. btnSlv.removeAttr('disabled');
  3781. }
  3782. });
  3783. }).done(function(strXml) {
  3784. if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
  3785. $("html").html(strXml);
  3786. return;
  3787. }
  3788. bootbox.alert({
  3789. title: "Exclusão de Orçamento",
  3790. message: "O orçamento "+$('#CJ_NUM').val()+" foi excluído com sucesso.",
  3791. backdrop: true,
  3792. callback: function (result) {
  3793. document.location.href = "U_Orcamento.apw?PR=<%=cLCodLogin%>";
  3794. }
  3795. });
  3796. });
  3797. })
  3798. </script>
  3799. </body>
  3800. </html>