123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290 |
- <%
- /**** Pagina de login do site ****/
- Local cLCodLogin := ""
- if type ("cCodLogin") <> "U"
- cLCodLogin := cCodLogin
- Endif
- %>
- <!DOCTYPE html>
- <html class="fixed sidebar-left-collapsed">
- <head>
- <!-- Basic -->
- <meta charset="iso-8859-1">
- <link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" />
-
- <title><%=cTitle%></title>
-
- <meta name="keywords" content="<%=cTitle%>" />
- <meta name="description" content="<%=cTitle%>">
- <meta name="author" content="SMSTI">
- <meta http-equiv="Chache-Control" content="no-cache" />
- <meta http-equiv="Expires" content="0" />
- <meta http-equiv="Pragma" content="no-cache" />
-
- <!-- Mobile Metas -->
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
-
- <!-- Web Fonts -->
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
-
- <!-- Vendor CSS -->
- <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
- <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
- <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
- <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css" />
- <link rel="stylesheet" href="assets/vendor/bootstrap-select/css/bootstrap-select.min.css" />
- <style>
- body .btn {
- white-space: nowrap !important;
- display: inline;
- overflow-y: hidden;
- }
-
- </style>
- <!-- Specific Page Vendor CSS -->
- <link rel="stylesheet" href="assets/vendor/select2/css/select2.css" />
- <link rel="stylesheet" href="assets/vendor/select2-bootstrap-theme/select2-bootstrap.min.css" />
- <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
- <link rel="stylesheet" href="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />
- <link rel="stylesheet" href="assets/vendor/pnotify/pnotify.custom.css" />
-
- <!-- Theme CSS -->
- <link rel="stylesheet" href="assets/stylesheets/theme.css" />
-
- <!-- Skin CSS -->
- <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />
-
- <!-- Theme Custom CSS -->
- <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
-
- <!-- Head Libs -->
- <script src="assets/vendor/modernizr/modernizr.js"></script>
- <script src="assets/vendor/style-switcher/style.switcher.localstorage.js"></script>
-
- <style>
- .flexContainer {
- display: flex;
- }
-
- .smsediticon {
- flex: 1;
- }
-
- .btedit { /* margem e largura da imagem */
- margin-left: -45px;
- width: 47px;
- }
- </style>
- </head>
- <body>
- <section class="body">
-
- <!-- start: header -->
- <header class="header">
- <%=cHeader%>
- </header>
- <!-- end: header -->
-
- <div class="inner-wrapper">
- <!-- start: sidebar -->
- <aside id="sidebar-left" class="sidebar-left">
-
- <div class="sidebar-header">
- <div class="sidebar-title">
- Menu
- </div>
- <div class="sidebar-toggle hidden-xs" data-toggle-class="sidebar-left-collapsed" data-target="html" data-fire-event="sidebar-left-toggle">
- <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
- </div>
- </div>
-
- <div class="nano">
- <div class="nano-content">
- <nav id="menu" class="nav-main" role="navigation">
-
- <ul class="nav nav-main">
- <%=cMenus%>
- </ul>
- </nav>
- </div>
-
- <script>
- // Maintain Scroll Position
- if (typeof localStorage !== 'undefined') {
- if (localStorage.getItem('sidebar-left-position') !== null) {
- var initialPosition = localStorage.getItem('sidebar-left-position'),
- sidebarLeft = document.querySelector('#sidebar-left .nano-content');
-
- sidebarLeft.scrollTop = initialPosition;
- }
- }
- </script>
- </div>
-
- </aside>
- <!-- end: sidebar -->
-
- <section role="main" class="content-body">
- <header class="page-header">
- <h2><%=cPagina%></h2>
-
- <div class="right-wrapper pull-right">
- </div>
- </header>
-
- <!-- start: page -->
- <section class="panel">
- <!-- <header class="panel-heading">
- </header> -->
- <div class="panel-body">
- <div class="row">
- <div class="col-lg-12">
- <section class="panel form-wizard" id="w9">
- <form action = "" method="post" class="form-horizontal" id="formOrc">
- <div class="tabs">
- <ul class="nav nav-tabs nav-justify">
- <li class="active">
- <a href="#orc-informar" data-toggle="tab" class="text-center">Orçamento</a>
- </li>
- <!--
- <li class="">
- <a href="#orc-anexos" data-toggle="tab" class="text-center">Anexos</a>
- </li>
- -->
- <%
- private cTab := ""
- if cOpcao == 'edit'
- cTab += '<li class="">'
- cTab += ' <a href="#orc-parceiros" data-toggle="tab" class="text-center" >Parceiros</a>'
- cTab += '</li>'
- endif
- %>
- <%=cTab%>
- </ul>
-
- <div class="tab-content">
- <div id="orc-informar" class="tab-pane active">
- <!--
- <%=cVendedor%>
- -->
-
- <!-- linha 0: dados do Orçamento -->
- <%=cFilOrc%>
- <%=cCodOrc%>
- <div class="mb-md hidden-lg hidden-xl"></div>
- <div class="mb-md hidden-lg hidden-xl"></div>
- <!-- linha 1: dados da empresa -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">Cliente
- <span class="required">*</span>
- </label>
- <%=cCliente%>
- </div>
-
- <div class="col-lg-5">
- <label class="control-label">Oportunidade</label>
- <%=cOport%>
- </div>
- <div class="col-lg-1">
- <label class="control-label">Revisão</label>
- <%=cRevOpt%>
- </div>
-
- </div>
-
-
- <!-- linha 3: input -->
- <div class="row form-group">
- <div class="col-lg-3">
- <label class="control-label">Tipo de Cliente</label>
- <%=cTpCliente%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Grupo de Tributação</label>
- <%=cGrpTrib%>
- </div>
- <div class="col-lg-5" style="display:none;">
- <label class="control-label">Tabela de Preço</label>
- <%=cTabela%>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Contato
- <span class="required">*</span>
- </label>
- <%=cContato%>
- </div>
- <div class="col-lg-1">
- <label class="control-label">DDD
- <span class="required">*</span>
- </label>
- <%=cContDDD%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Telefone
- <span class="required">*</span>
- </label>
- <%=cContTel%>
- </div>
- </div>
-
- <!-- linha 4 input -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">Cliente de Entrega
- <span class="required">*</span>
- </label>
- <%=cCliEntr%>
- </div>
- <div class="col-lg-6">
- <label class="control-label">Local de Entrega</label>
- <%=cLocalEnt%>
- </div>
- </div>
- <!-- linha 5 input -->
- <div class="row form-group">
-
- <div class="col-lg-6">
- <label class="control-label">Obra
- <span class="required">*</span>
- </label>
- <%=cObra%>
- </div>
-
- <div class="col-lg-6">
- <label class="control-label">Tipo da Obra
- <span class="required">*</span>
- </label>
- <%=cTpObra%>
- </div>
- </div>
- <!-- linha 6 input -->
- <div class="row form-group">
- <div class="col-lg-3">
- <label class="control-label">Status da Obra
- <span class="required">*</span>
- </label>
- <%=cStatusObra%>
- </div>
- <div class="col-lg-3">
- <label class="control-label">Previsão de Fechamento
- <span class="required">*</span>
- </label>
- <%=cPrevFecha%>
- </div>
-
- <div class="col-lg-2">
- <label class="control-label">Retorno</label>
- <%=cRetorno%>
- </div>
- <div class="col-lg-3">
- <label class="control-label">Condição de Pagamento
- <span class="required">*</span>
- </label>
- <%=cCondPag%>
- </div>
- </div>
- <!-- linha 7 input -->
- <div class="row form-group">
-
- <div class="col-lg-6">
- <label class="control-label">Intermediador</label>
- <%=cIntermed%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Estudo Luminotécnico
- <span class="required">*</span>
- </label>
- <%=cEstudo%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Num. Estudo</label>
- <%=cNumEst%>
- </div>
- </div>
-
- <!-- linha 8 input -->
- <div class="row form-group">
- <div class="col-lg-3">
- <label class="control-label">Segmento
- <span class="required">*</span>
- </label>
- <%=cSegmento%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Prospecção</label>
- <%=cProsp%>
- </div>
- <div class="col-lg-3">
- <label class="control-label">Prospectado Por</label>
- <%=cProspPor%>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Regional
- <span class="required">*</span>
- </label>
- <%=cRegional%>
- </div>
- </div>
-
- <!-- linha 9: input -->
- <div class="row form-group">
- <div class="col-lg-6">
- <label class="control-label">Vendedor 2
- <span class="required">*</span>
- </label>
- <%=cVend2%>
- </div>
- <div class="col-lg-6">
- <label class="control-label">Vendedor 3</label>
- <%=cVend3%>
- </div>
- </div>
- <!-- linha 10: input -->
- <div class="row form-group">
- <div class="col-lg-4">
- <label class="control-label">Vendedor 4</label>
- <%=cVend4%>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Especificado por</label>
- <%=cEspecif%>
- </div>
- <div class="col-lg-4">
- <label class="control-label">Negociadora
- <span class="required">*</span>
- </label>
- <%=cNegociad%>
- </div>
- </div>
- <!-- linha 11: input -->
- <div class="row form-group">
- <div class="col-lg-2">
- <label class="control-label">Validade</label>
- <%=cValidade%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Prazo de Embarque</label>
- <%=cPrazoEmb%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Tipo de Frete</label>
- <%=cTpFrete%>
- </div>
-
- <div class="col-lg-2">
- <label class="control-label">% Frete
- </label>
- <%=cPFrete%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">Valor do Frete</label>
- <%=cValFre%>
- </div>
- <div class="col-lg-2">
- <label class="control-label">% RT</label>
- <%=cComRT%>
- </div>
- <!--
- <div class="col-lg-4">
- <label class="control-label">Transportadora</label>
- <%=cTransp%>
- </div>
- -->
- </div>
-
-
-
- <!-- linha 12 input -->
- <div class="row form-group">
-
- <div class="col-md-5">
- <label class="control-label" for="textareaDefault">Observação Comercial</label>
- <textarea class="form-control" rows="3" data-plugin-maxlength="" maxlength="240" id="CJ_OBS" name="CJ_OBS" <%=Iif(!lEdit,'disabled','')%>><%=cObsCom%></textarea>
- </div>
-
- <%=cMargemCont%>
- </div>
-
- <!-- linha 13 input -->
- <div class="row form-group">
-
-
- </div>
-
-
-
- <br>
- <br>
-
- <!-- tabela com os produtos do orçamento -->
- <div class="table-responsive" id="ItensOrc" style="overflow-x:visible">
- <section class="panel">
- <header class="panel-heading">
- <h2 class="panel-title">Itens do Orçamento</h2>
- </header>
- <table class="table table-bordered table-striped mb-none table-hover table-condensed" id="datatable-editable" aria-describedby="datatable-details_info">
- <thead>
- <tr>
- <%=cOrcCabec%>
- </tr>
- </thead>
- <tbody>
- <%=cOrcItens%>
- </tbody>
- </table>
- </section>
- </div>
- <br>
-
- <!-- botões com ações na tabela dos itens -->
- <%=cBtnItens%>
- <br>
- <br>
-
- <!-- Totais -->
- <div class="col-lg-13">
- <section class="panel">
- <header class="panel-heading">
- <h2 class="panel-title">Totais do Orçamento</h2>
- </header>
- <div class="panel-body">
-
- <div class="form-inline" align="center">
- <div class="row">
- <%=cTotalReg%>
- <br />
- <div class="col-sm-12">
- <label class="">Itens </label>
- <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>
-
-
- <label class="">Impostos </label>
- <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>
-
-
-
- <label class="">Frete </label>
- <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>
-
-
-
- <label class="text-weight-extrabold">Total </label>
- <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>
- </div>
- </div>
- <br>
- <!--
- <div class="row">
- <div class="col-sm-12">
- <label class="">Desconto </label>
- <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>
-
- <label class="">Total </label>
- <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>
- </div>
- </div>
-
- <div class="row">
- <div class="col-sm-12">
- <label class="">Comissão Prevista </label>
- <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>
- </div>
- </div>
- -->
- </div>
- </div>
- </section>
- </div>
-
- <br>
- <br>
-
- <div class="row form-group" align="center">
- <%=cBotoes%>
- </div>
- </div>
-
- <!-- aba de anexos
- <div id="orc-anexos" class="tab-pane">
- <div class="form-group">
- <label class="col-md-3 control-label">Anexar: </label>
- <div class="col-md-9">
- <div class="fileupload fileupload-new" data-provides="fileupload">
- <div class="input-append">
- <div class="uneditable-input">
- <i class="fa fa-file fileupload-exists"></i>
- <span class="fileupload-preview"></span>
- </div>
- <span class="btn btn-default btn-file">
- <span class="fileupload-exists">Selecionar</span>
- <span class="fileupload-new">Arquivo</span>
- <input type="file" name="anexo" id="anexo" />
- </span>
- <a href="#" id="btnOrcUpload" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Gravar</a>
- </div>
- </div>
- </div>
- </div>
-
- <div class="row mg-files" data-sort-destination data-sort-id="media-gallery" id="OrcAnexos">
- <%=cAnexos%>
- </div>
- </div>
- -->
- <div class="tab-pane" id="orc-parceiros">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Parceiros para Comissão RT</h3>
- </div>
- <div class="panel-body">
- <button type="button" class="btn btn-primary" id="btnIncluir">
- <i class="fa fa-plus"></i> Incluir
- </button>
-
- <div class="table-responsive" style="margin-top: 15px;">
- <table class="table table-bordered table-striped mb-none table-hover dataTable no-footer">
- <thead>
- <tr>
- <th>Parceiro</th>
- <th>% RT Pagar</th>
- <th>% RT Aumentar</th>
- <th>Editar</th>
- </tr>
- </thead>
- <tbody id="tblParceiros">
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </form>
- </section>
- </div>
- </div>
- </div>
- </section>
-
- <div class="modal fade" id="dialogCusto" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title" id="myModalLabel">Custo e Preço de Venda do Produto</h4>
- </div>
- <div class="modal-body">
- <label class="control-label">Valor de Venda Unitário</label>
- <input id="VLRVENDA" name="VLRVENDA" class="form-control money text-right" placeholder="0,00" value="">
- <input type="hidden" id="itemAtu"/>
- <br>
- <label class="control-label">Valor do Custo Unitário</label>
- <input id="CUSTO" name="CUSTO" class="form-control money text-right" placeholder="0,00" value="">
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
- <button type="button" class="btn btn-primary" onclick="javascript:gravaCusto( $('#itemAtu').val(),$('#VLRVENDA').val(),$('#CUSTO').val() );">Confirmar</button>
- </div>
- </div>
- </div>
- </div>
-
- <div class="modal fade" id="dialogEntrega" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title" id="myModalLabel">Local de Entrega</h4>
- </div>
- <div class="col-md-12">
- <label class="control-label">Estado</label>
- <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());">
- <%=cOptUF%>
- </select>
- <br>
- <label class="control-label">Município</label>
- <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>
- <%=cOptMun%>
- </select>
- </div>
- <div class="modal-footer">
- <br>
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
- <button type="button" class="btn btn-primary" onclick="javascript:gravaEntrega( $('#UF_ENTREGA').val(),$('#MUN_ENTREGA').val() );">Confirmar</button>
- </div>
- </div>
- </div>
- </div>
- <!-- Modal Incluir Parceiro -->
- <div class="modal fade" id="dialogParceiro" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title" id="tituloIncPar">Incluir Parceiro</h4>
- </div>
- <div class="modal-body">
- <form id="formParceiro" class="form-horizontal">
- <input type="hidden" name="operacao" id="operacao" value="create" />
- <div class="form-group">
- <div class="col-sm-12">
- <div class="alert alert-info">
- Preencha os dados do parceiro
- </div>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">Parceiro</label>
- <div class="col-sm-9">
- <%=cLisPar%>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">% RT Pagar</label>
- <div class="col-sm-9">
- <%
- private cCampoRTP := ""
- if cParUs $ HttpSession->CodVend
- cCampoRTP := '<input class="form-control" type="number" name="rtpagar" id="cmbRTPagar" value="" />'
- else
- cCampoRTP := '<select class="form-control" id="cmbRTPagar" name="rtpagar" onchange="atualizaRT(this.value)">'
- cCampoRTP += '<option value="">Selecione...</option>'
- cCampoRTP += '<option value="3">3%</option>'
- cCampoRTP += '<option value="5">5%</option>'
- cCampoRTP += '<option value="7">7%</option>'
- cCampoRTP += '<option value="10">10%</option>'
- cCampoRTP += '</select>'
- Endif
- %>
- <%=cCampoRTP%>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">% RT Aumentar</label>
- <div class="col-sm-9">
- <%
- private cCampoRTA := ""
- if cParUs $ HttpSession->CodVend
- cCampoRTA := '<input class="form-control" type="number" name="rtaumentar" id="txtRTAumentar" value="" />'
- else
- cCampoRTA := '<select class="form-control" id="txtRTAumentar" name="rtaumentar" readonly>'
- cCampoRTA += '<option value="">Selecione...</option>'
- cCampoRTA += '<option value="5">5%</option>'
- cCampoRTA += '<option value="8.5">8,5%</option>'
- cCampoRTA += '<option value="12">12%</option>'
- cCampoRTA += '<option value="19">19%</option>'
- cCampoRTA += '</select>'
- Endif
- %>
- <%=cCampoRTA%>
- </div>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
- <button type="button" class="btn btn-primary" id="btnSalvarParceiro">Salvar</button>
- </div>
- </div>
- </div>
- </div>
- <div style="display:none;">
- <form action="U_OrcUpload.apw?PR=<%=cLCodLogin%>" method="post" id="frmOrcUpload" enctype="multipart/form-data">
- <input type="hidden" name="dirOrc" value="<%=cDirOrc%>" />
- </form>
- </div>
- <footer class="panel-footer text-right">
- Desenvolvido por <img src="images/sms.png" />
- </footer>
- </div>
- </section>
- <!-- end: page -->
-
- <div id="dialogRemover" class="modal-block mfp-hide">
- <section class="panel">
- <header class="panel-heading">
- <h2 class="panel-title">Exclusão da linha</h2>
- </header>
- <div class="panel-body">
- <div class="modal-wrapper">
- <div class="modal-text">
- <p>Confirma a exclusão desta linha?</p>
- </div>
- </div>
- </div>
- <footer class="panel-footer">
- <div class="row">
- <div class="col-md-12 text-right">
- <button id="dialogConfirm" class="btn btn-primary">Confirma</button>
- <button id="dialogCancel" class="btn btn-default">Cancela</button>
- </div>
- </div>
- </footer>
- </section>
- </div>
-
- <div id="modalSuccess" class="modal-block modal-block-success mfp-hide">
- <section class="panel">
- <header class="panel-heading">
- <h2 class="panel-title">Success!</h2>
- </header>
- <div class="panel-body">
- <div class="modal-wrapper">
- <div class="modal-icon">
- <i class="fa fa-check"></i>
- </div>
- <div class="modal-text">
- <h4>Success</h4>
- <p>This is a successfull message.</p>
- </div>
- </div>
- </div>
- <footer class="panel-footer">
- <div class="row">
- <div class="col-md-12 text-right">
- <button class="btn btn-success modal-dismiss">OK</button>
- </div>
- </div>
- </footer>
- </section>
- </div>
- <!-- Vendor -->
- <script src="assets/vendor/jquery/jquery.js"></script>
- <script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
- <script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
- <script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
- <script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
- <script src="assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.min.js"></script>
- <script src="assets/vendor/magnific-popup/jquery.magnific-popup.js"></script>
- <script src="assets/vendor/jquery-placeholder/jquery-placeholder.js"></script>
- <script src="assets/vendor/fuelux/js/spinner.js"></script>
- <!-- Custom -->
- <script src="custom/js/bootbox.js"></script>
- <script src="custom/js/moeda.js"></script>
-
- <!-- Specific Page Vendor -->
- <script src="assets/vendor/select2/js/select2.js"></script>
- <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
- <script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
- <script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>
- <script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
- <script src="assets/vendor/bootstrap-maxlength/bootstrap-maxlength.js"></script>
- <script src="assets/vendor/autosize/autosize.js"></script>
- <script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
- <script src="assets/vendor/pnotify/pnotify.custom.js"></script>
- <script src="assets/vendor/bootstrap-select/bootstrap-select.min.js"></script>
-
- <!-- Theme Base, Components and Settings -->
- <script src="assets/javascripts/theme.js"></script>
-
- <!-- Theme Initialization Files -->
- <script src="assets/javascripts/theme.init.js"></script>
-
- <!-- Theme Custom -->
- <script src="assets/javascripts/theme.custom.js"></script>
-
- <script src="custom/js/jquery.maskMoney.js"></script>
- <script src="custom/js/portalMask.js"></script>
- <script type="text/javascript">
- var tblDesc = [];
- var optProd = '<%=cOptProd%>';
- var optCond = '<%=cOptCond%>';
- var optCli = '<%=cOptCli%>';
- /**
- Desabilita o enter na pagina
- **/
- $(function () {
- $('form').bind("keypress", function (e) {
- if (e.keyCode == 13) return false;
- });
- // Evento do botão incluir
- $("#btnIncluir").click(function() {
- $("#formParceiro")[0].reset();
- $("#tituloIncPar")[0].childNodes[0].data = "Incluir Parceiro"
- $("#cmbParceiro").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
- $("#cmbRTPagar").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
- $("#txtRTAumentar").attr('readonly', true).attr("style", "pointer-events: none;");;
- $("#dialogParceiro").modal('show');
- });
- carregarTabelaParceiros()
- // Evento do botão salvar
- $("#btnSalvarParceiro").click(function() {
- var parceiro = $("#cmbParceiro").val();
- var rtpagar = $("#cmbRTPagar").val();
- var rtaumentar = $("#txtRTAumentar").val();
- var numOrc = $("#CJ_NUM").val();
- var operacao = $("#operacao").val()
- if (!parceiro) {
- alert("Selecione um parceiro!");
- return;
- }
- if (!rtpagar) {
- alert("Selecione o percentual RT Pagar!");
- return;
- }
- // Verifica se já existe o parceiro na tabela
- var existe = false;
- $("#datatable-editable tbody tr").each(function() {
- var codParceiro = $(this).find("td:first").text().split(" - ")[0];
- if (codParceiro === parceiro && operacao != "delete") {
- existe = true;
- return false;
- }
- });
- if (existe && operacao != 'delete') {
- alert("Este parceiro já foi adicionado!");
- return;
- }
- // Adiciona na tabela Z81
- if(operacao == 'edit'){
- editarParceiro(parceiro, rtpagar, rtaumentar, numOrc);
- }else if(operacao == 'delete'){
- excluirParceiro(parceiro, numOrc);
- }else{
- adicionarParceiro(parceiro, rtpagar, rtaumentar, numOrc);
- }
- $("#dialogParceiro").modal('hide');
- });
- });
- //Remove as opções da tabela e adiciona o scroll
- $(document).ready(function () {
- $('#datatable-editable').DataTable({
- "scrollX": true,
- "ordering": false,
- "searching": false,
- "paging": false,
- "autoWidth": true,
- "info": false
- });
- $('.dataTables_length').addClass('.w-auto'); //ajusta o tamanho das colunas automaticamente
- });
- //Formata campos de moeda
- $(function() {
- //$('#iCK_PRCVEN01').maskMoney({thousands:'.', decimal:','});
- $('.myformato').maskMoney({thousands:'.', decimal:','});
- $('.percentual').maskMoney({thousands:'.', decimal:',', suffix:'%',allowNegative:true});
- })
-
- function formate() {
- $('.myformato').maskMoney({thousands:'.', decimal:','});
- $('.percentual').maskMoney({thousands:'.', decimal:',', suffix:'%',allowNegative:true});
- }
- <%=cTblDesc%>
-
-
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
-
- //Manipulando as colunas
- function ocultaColumn (colIndex) {
- var table = document.getElementById('datatable-editable');
- for (var r = 0; r < table.rows.length; r++)
- table.rows[r].cells[colIndex].style.display = 'none';
- }
- function mostraColumn (colIndex) {
- var table = document.getElementById('datatable-editable');
- for (var r = 0; r < table.rows.length; r++)
- table.rows[r].cells[colIndex].style.display = '';
- }
-
- /**
- Monta a tela para selecionar o cliente
- **/
- function getCliente(btPesquisa){
- var cCliBusca = $("#CJ_CLIENTE").val().toUpperCase();
-
- // Usando a função buscarProdutos com um callback
- buscarClientes(cCliBusca, function (clientesEncontrados) {
- if (clientesEncontrados.length >= 1) {
- var selectOptions = '<select id="clienteSelecionado" style="width:100%">';
- var indiceHifen;
- var selOptions = '';
- clientesEncontrados.forEach(function (cliente) {
- selectOptions += "<option value='" + cliente + "'>" + cliente + "</option>";
- });
- selectOptions += "</select>";
- bootbox.dialog({
- title: 'Clientes',
- message: "<p>Selecione o cliente desejado:</p>" + selectOptions,
- backdrop: false,
- size: 'large',
- buttons: {
- confirm: {
- label: 'Confirmar',
- className: 'btn-primary',
- callback: function () {
- var clienteSelecionado = $("#clienteSelecionado").val();
- // Atualiza o campo original com o produto escolhido
- $("#CJ_CLIENTE").val(clienteSelecionado);
- clienteSelecionado = formataCli(clienteSelecionado);
- SelCliente(clienteSelecionado);
- }
- },
- cancel: {
- label: 'Cancelar',
- className: 'btn-default',
- callback: function () {
- }
- }
- }
- });
-
- }
- });
- }
- /**
- Monta a tela para selecionar o local de entrega
- **/
- function getEntrega(btEntrega){
- $("#dialogEntrega").modal('show');
- }
- /**
- Busca as cidades do estado selecionado
- **/
- function getMunEnt(estado){
- if(estado==""){
- bootbox.alert("Selecione um estado para continuar!")
- } else {
- $.ajax({
- url: "U_GetMunUF.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: 'uf='+estado,
- cache: false,
- success: function(retorno){
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
- if(retorno==""){
- bootbox.alert("Falha ao localizar os municípios, tente novamente!");
- return;
- }
-
- //Preenche o select das cidades
- document.getElementById('MUN_ENTREGA').innerText = null;
- $("#MUN_ENTREGA").append(retorno);
- $("#MUN_ENTREGA").removeAttr('disabled');
- }
- });
- }
- }
- /**
- Função para gravar o local de entrega no campo em tela
- **/
- function gravaEntrega(estado,mun){
- $('#CJ_UFENT').val(estado+mun);
- $("#dialogEntrega").modal('hide');
- //busca o percentual de frete
- atuVlrFrete();
- }
- /**
- Função para formatar o código do cliente
- **/
- function formataCli(cli){
- var indiceHifen = 0;
- if(cli != ""){
- // Encontra a posição do primeiro h?fen na string
- indiceHifen = cli.indexOf("-");
- //Pega apenas o codigo do cliente
- if(indiceHifen > 0){
- cli = cli.substring(0, indiceHifen);
- }
- //Remove espaços vazios
- cli = cli.replace("/","").trim();
- }
- return cli
- }
-
- /**
- Função para formatar o código do produto
- **/
- function formataProd(prod){
- var indiceHifen = 0;
- if(prod != ""){
- // Encontra a posição do primeiro hífen na string
- indiceHifen = prod.indexOf("--");
- //Pega apenas o codigo do produto
- if(indiceHifen > 0){
- prod = prod.substring(0, indiceHifen);
- }
- //Remove espaços vazios
- prod = prod.trim();
- }
- return prod
- }
- /**
- Funcao excutada ao selecionar o cliente
- **/
- function SelCliente(cliente){
- var lOK = false;
- var dialogCli = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Buscando dados do cliente. Aguarde...</p>',
- closeButton: false
- });
- cliente = cliente.replace('/',"");
-
- //Verifica se cliente tem títulos em atraso
- $.ajax({
- url: "U_GetSitCli.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: 'cliente='+cliente,
- cache: false,
- success: function(data){
- dialogCli.modal('hide');
- if (data.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(data);
- return;
- }
- aCli = data.split('|#|');
- if (aCli[1] != "" && aCli[1] != "::" && aCli[1].toUpperCase().indexOf("EXPIRES") == -1) {
- var dialog = bootbox.dialog({
- title: 'Mensagem do Cliente',
- message: "<p>"+aCli[1]+"</p>",
- backdrop: true,
- buttons: {
- ok: {
- label: "OK"
- }
- }
- });
- }
- //cliente bloqueado para comprar
- if (aCli[0] == "0"){
-
- //Bloqueia os campos para impossibilitar continuar a inclusão
- atuModoCpo('B')
- } else {
- //Desbloqueia os campos
- atuModoCpo('D')
- $("#select2-CJ_TIPOCLI-container").html($("#CJ_TIPOCLI option[value='"+aCli[2]+"']").html());
- $("#CJ_TIPOCLI").val(aCli[2]);
- $("#CJ_GRPTRIB").val(aCli[3]);
- if (aCli[4] != ""){
- $("#CJ_CONDPAG").val(aCli[4]);
- $("#select2-CJ_CONDPAG-container").html($("#CJ_CONDPAG option[value='"+aCli[4]+"']").html());
- }
- $("#CJ_CONDPAG").removeAttr('disabled');
-
- $("#CJ_UFENT").val(aCli[5]);
- $("#CJ_VEND").val(aCli[6]);
- $("#select2-CJ_VEND-container").html($("#CJ_VEND option[value='"+aCli[6]+"']").html());
- //Adiciona as opções do cliente
- if($("#CJ_CLIINTE")[0].options.length <= 2){
- $("#CJ_CLIINTE").append($.parseHTML(optCli));
- }
- $('.selectpicker').selectpicker('render');
- $('.selectpicker').selectpicker('refresh');
-
- //na alteração já traz o select preenchido
- if($("#CJ_CLIENT")[0].options.length <= 1){
- $("#CJ_CLIENT").append($.parseHTML(optCli));
- }
- //$('.selectpicker').selectpicker('render');
- //$('.selectpicker').selectpicker('refresh');
- //$('#CJ_CLIENT').selectpicker('val', cliente);
- $('#CJ_CLIENT').val(cliente).select2();
- $("#CJ_NROPOR").focus();
- }
- }
- });
- }
-
- /**
- Atualiza o modo de edição do campo
- **/
- function atuModoCpo(cTipo){
- 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",
- var nI = 0;
- //Atualiza os campos
- for (nI = 0; nI < (aCampos.length) ; nI++) {
- if(cTipo == 'B'){
- $("#"+aCampos[nI]).attr("disabled","");
- } else {
- $("#"+aCampos[nI]).removeAttr('disabled');
- $("#"+aCampos[nI]).attr("disabled",false);
- }
- }
- }
- /**
- Atualiza o endereço de entrega ao mudar o cliente de entrega
- **/
- function atuLocEnt(){
- var cliEntrega = $("CJ_CLIENT").val();
- var dialogCli = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Buscando dados do cliente. Aguarde...</p>',
- closeButton: false
- });
- if(cliEntrega != ""){
-
- $.ajax({
- url: "U_GetEndCli.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: 'cliente='+cliEntrega,
- cache: false,
- success: function(retorno){
- dialogCli.modal('hide');
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
-
- $("#CJ_UFENT").val(retorno);
- }
- });
-
- }
- }
- /**
- Preenche a revisão da oportunidade
- **/
- function atuRevOpt(){
- var cOport = $("#CJ_NROPOR").val();
- var cobjOport = $("#CJ_NROPOR")[0];
- var cRevisa = cobjOport.options[cobjOport.selectedIndex].text.substr(7,2)
- var dialog = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Buscando dados da oportunidade... Aguarde...</p>',
- closeButton: false
- });
- if(cOport != ""){
- $("#CJ_REVISA").val(cRevisa);
-
- $.ajax({
- url: "U_GetDadosOpt.apw?PR=<%=cLCodLogin%>",
- data: 'oportunidade='+cOport+'&revisao='+cRevisa,
- type: "POST",
- async: false,
- success:
- function(dados) {
- if (dados.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(dados);
- return;
- } else {
- if (dados.substr(0, 2) == "OK") {
- aVlr = dados.substr(5).split('|#|');
-
- //Atualiza a comissão
- $("#CJ_COMISTR").val(aVlr[0]);
- //Atualiza o vendedor
- $("#CJ_VEND3").append($.parseHTML(aVlr[1]));
- $('.selectpicker').selectpicker('render');
- $('.selectpicker').selectpicker('refresh');
- $("#select2-CJ_VEND3-container").html($("#CJ_VEND3 option[value='"+aVlr[2]+"']").html());
-
- } else {
- bootbox.alert("Falha ao localizar os dados da oportunidade!");
- }
- }
- }
- });
- } else {
- $("#CJ_REVISA").val("");
- }
- dialog.modal('hide');
- }
- /**
- Atualiza o valor do frete
- **/
- function atuVlrFrete(){
- var cUFEnt = $("#CJ_UFENT").val().substr(0,2)
- var cMunEnt = $("#CJ_UFENT").val().substr(2,5)
-
- if(cUFEnt != ""){
-
- $.ajax({
- url: "U_GetPerFrt.apw?PR=<%=cLCodLogin%>",
- data: 'uf='+cUFEnt+'&mun='+cMunEnt,
- type: "POST",
- async: false,
- success:
- function(frete) {
- if (frete.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(frete);
- return;
- } else {
- //Atualiza o frete
- $("#CJ_PERCFRT").removeAttr("disabled");
- $("#CJ_PERCFRT").val(frete);
- }
- }
- });
- }
- }
- /**
- Valida o estudo
- **/
- function vldEstudo(){
- var cEstudo = $("#CJ_LUMINOT").val();
- if(cEstudo == "1"){
- $("#CJ_REGLUMI").removeAttr('disabled');
- } else {
- $("#CJ_REGLUMI").val("");
- $("#select2-CJ_REGLUMI-container").html($("#CJ_REGLUMI option[value='']").html());
- $("#CJ_REGLUMI").attr("disabled","");
- }
- }
- /**
- Valida a prospecção
- **/
- function vldProspec(){
- var cProspec = $("#CJ_PROPECC").val();
- if(cProspec == "S"){
- $("#CJ_PROSCOD").removeAttr('disabled');
- } else {
- $("#CJ_PROSCOD").val("");
- $("#select2-CJ_PROSCOD-container").html($("#CJ_PROSCOD option[value='']").html());
- $("#CJ_PROSCOD").attr("disabled","");
- }
- }
- /**
- Valida o campo prospectado por
- **/
- function vldProsPor(){
- var cProspec = $("#CJ_PROPECC").val();
- var cProsPor = $("#CJ_PROSCOD").val();
- if(cProspec == "S" && cProsPor == ""){
- bootbox.alert("Informe o campo Prospectado Por!")
- }
- if (cProspec == "N"){
- $("#CJ_PROSCOD").val("");
- $("#select2-CJ_PROSCOD-container").html($("#CJ_PROSCOD option[value='']").html());
- $("#CJ_PROSCOD").attr("disabled","");
- }
- }
-
-
-
- /**
- Valida a condição de pagamento selecionada
- **/
- function vldCond(){
- var valDesc = 0;
-
- $.ajax({
- url: "U_VldCondPg.apw?PR=<%=cLCodLogin%>",
- data: 'condPgto='+$("#CJ_CONDPAG").val(),
- type: "POST",
- async: false,
- success:
- function(retorno) {
- valDesc = parseFloat(retorno);
-
- //Atualiza a variável
- $("#DESCCOND").val(valDesc);
-
- if (valDesc > 0) {
- bootbox.alert("Condição de pagamento com desconto. Ao salvar o orçamento será aplicado o desconto de "+mascaraValor(valDesc.toFixed(2))+"%.");
- } else {
- $("#DESCCOND").val("0");
- }
- //Atualiza o valor do produto quando altera a condição de pagamento
- if ($('#iCK_PRCVEN01').val()!=$('#CK_PRCVEN01').val() || $("#DESCCOND").val()=="0"){
- AtuValProd();
- }
- }
- });
- }
-
- /**
- Busca dados do cliente a partir do código ou nome
- **/
- function buscarClientes(cCliBusca,callback){
-
- if (cCliBusca != ""){
- $.ajax({
- url: "U_GetLikeCli.apw?PR=<%=cLCodLogin%>",
- data: 'digit=' + cCliBusca,
- method: "POST",
- async: false,
- success: function( clientes ) {
- if (clientes.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ||clientes.toUpperCase().indexOf("EXPIRES") != -1) {
- $("html").html(clientes);
- callback([]); // Retorna uma lista vazia em caso de erro
- }
-
- if (clientes == "") {
- $("#CJ_CLIENTE").empty();
- bootbox.alert('Não foram encontrados clientes para o termo pesquisado!');
- callback([]); // Retorna uma lista vazia em caso de erro
- } else {
- $("#CJ_CLIENTE").empty(); // Limpa o conteúdo existente
- var selectpicker = $("<select>", {
- class: "selectpicker",
- title: "Selecione um cliente"
- });
- selectpicker.append($.parseHTML(clientes));
- // Adiciona os valores dos elementos <option> listaClientes
- var listaClientes = selectpicker.find('option').map(function () {
- return $(this).text();//Pegar o texto completo
- }).get();
- $("#CJ_CLIENTE").append(selectpicker);
- callback(listaClientes); // Retorna a lista de clientes encontrados
- }
- }
- });
- } else {
- bootbox.alert("Informe o cliente para busca!");
- }
- }
- /**
- Monta a tela para selecionar o produto
- **/
- function getProduto(btPesquisa){
- var objProd = btPesquisa.closest("td").find("[autocomplete=off]");
- var cProdBusca = $("#"+objProd.attr("name")).val().toUpperCase();
- //var nItem = btPesquisa[0].id.substr(8,2);
- var nItem = objProd.attr("name").substr(10);
- $("#PROXIMO").val(nItem);
- // Usando a função buscarProdutos com um callback
- buscarProdutos(cProdBusca, nItem, function (produtosEncontrados) {
- if (produtosEncontrados.length >= 1) {
- var selectOptions = '<select id="produtoSelecionado" style="width:100%">';
- //var selectOptions = '<select data-plugin-selectTwo class="form-control populate placeholder" data-plugin-options="{ "placeholder": "Selecione...", "allowClear": false }" id="produtoSelecionado">';
- var indiceHifen;
- var selOptions = '';
- produtosEncontrados.forEach(function (produto) {
- selectOptions += "<option value='" + produto + "'>" + produto + "</option>";
- //selOptions+= "{text: '"+produto+"',value: '"+produto+"'},";
- });
- selectOptions += "</select>";
- bootbox.dialog({
- title: 'Produtos',
- message: "<p>Selecione o produto desejado:</p>" + selectOptions,
- backdrop: false,
- size: 'large',
- buttons: {
- confirm: {
- label: 'Confirmar',
- className: 'btn-primary',
- callback: function () {
- var produtoSelecionado = $("#produtoSelecionado").val();
- // Atualiza o campo original com o produto escolhido
- $("#CK_PRODUTO" + nItem).val(produtoSelecionado);
- produtoSelecionado = formataProd(produtoSelecionado);
- gatProduto(objProd,produtoSelecionado);
- }
- },
- cancel: {
- label: 'Cancelar',
- className: 'btn-default',
- callback: function () {
- }
- }
- }
- });
- }
- });
- }
-
- /**
- Busca dados do produto a partir do código ou descrição
- **/
- function buscarProdutos(cProdBusca,item,callback){
- var cliente = formataCli($("#CJ_CLIENTE").val());
- var tabpreco = $("#CJ_TABELA").val();
- //var item = $("#PROXIMO").val();
- if (cProdBusca != ""){
- if(cliente == ""){
- bootbox.alert("Selecione o cliente para continuar!");
- return false;
- }
- $.ajax({
- url: "U_GetLikePro.apw?PR=<%=cLCodLogin%>",
- data: 'cliente=' + cliente + '&tabela=' + tabpreco + '&digit=' + cProdBusca,
- method: "POST",
- async: false,
- success: function( produtos ) {
- if (produtos.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ||produtos.toUpperCase().indexOf("EXPIRES") != -1) {
- $("html").html(produtos);
- callback([]); // Retorna uma lista vazia em caso de erro
- }
-
- if (produtos == "") {
- LimpaLinha(item);
- bootbox.alert('Não foram encontrados produtos para o termo pesquisado!');
- callback([]); // Retorna uma lista vazia em caso de erro
- } else {
- $("#CK_PRODUTO" + item).empty(); // Limpa o conteudo existente
- /*
- // Preenche o select dos produtos
- $("#CK_PRODUTO" + item).empty(); // Limpa o conteudo existente
- $("#CK_PRODUTO"+item).append($.parseHTML(produtos));
- $('.selectpicker').selectpicker('render');
- $('.selectpicker').selectpicker('refresh');
- optProd = produtos;
- */
- var selectpicker = $("<select>", {
- class: "selectpicker",
- title: "Selecione um produto"
- });
- selectpicker.append($.parseHTML(produtos));
- // Adiciona os valores dos elementos <option> listaProdutos
- var listaProdutos = selectpicker.find('option').map(function () {
- //return $(this).val();
- ////Luiz SMS - 04/01/2024
- return $(this).text();//Pegar o texto completo
- }).get();
- $("#CK_PRODUTO" + item).append(selectpicker);
- callback(listaProdutos); // Retorna a lista de produtos encontrados
- }
- }
- });
- } else {
- bootbox.alert("Informe o produto para busca!");
- }
- }
- /**
- Converte o texto para maiusculo
- **/
- function Maiuscula(cItemAtu){
- var cCodBar = $("#"+cItemAtu.attr("id")).val().toUpperCase();
- $(cItemAtu).val(cCodBar);
- }
-
- /**
- Gatilho acionado ao selecionar o produto para preencher os valores
- **/
- function gatProduto(objInput,produtoSelecionado) {
- var nItens = parseFloat($("#PROXIMO").val());
- var lProdOK = true;
- var nItem = objInput.attr("name").substr(10);
- var dialogProd = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Buscando dados do produto... Aguarde...</p>',
- closeButton: false
- });
-
-
- //valida a digitação duplicada de itens
- for (i = 1; i<=nItens; i++) {
- cItem = String(i);
- if (parseInt(i) < 10 ){cItem = "0"+String(i)};
-
- cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
-
- if(cItmOrc != "x" && nItem != cItem ) {
- if ($('#CK_PRODUTO'+cItem).val() == objInput.val()){
- lProdOK = false;
- $('#CK_PRODUTO'+nItem).val("");
- $("#select2-CK_PRODUTO"+cItem+"-container").html("Selecione...");
- }
- }
- }
-
- if (!lProdOK ) {
- bootbox.alert("Este item já foi informado no orçamento!");
- dialogProd.modal('hide');
- }
- //Fim da validação de itens duplicados
-
- if ( ! objInput.is('[readonly]') && $.trim(objInput.val()) != "" && lProdOK ) {
-
- jQuery.ajax({
- type: "POST",
- url: "U_GATPROD.APW?PR=<%=cLCodLogin%>",
- data: 'produto='+encodeURIComponent(produtoSelecionado)+'&tabela='+$("#CJ_TABELA").val()+'&frete='+$("#CJ_PERCFRT").val()+'&comisRT='+$("#CJ_COMISTR").val(),
- error: function (jqXHR, textStatus, error){
- dialogProd.modal('hide');
- bootbox.alert("Falha ao recuperar informações!");
- console.log(error);
- },
- success: function( data ) {
- var aVlr;
- var cMsgErro;
- var nItem = objInput.attr("name").substr(10);
- var przEmb = parseInt($("#CJ_PRZEMB").val());
- dialogProd.modal('hide');
-
- if (data.substr(0, 2) == "OK") {
- aVlr = data.substr(3).split('|#|');
- if (aVlr[18] != "" && aVlr[18] != "::") {
- var dialog = bootbox.dialog({
- title: 'Mensagem do Produto',
- message: "<p>"+aVlr[19]+"</p>",
- backdrop: true,
- buttons: {
- ok: {
- label: "OK"
- }
- }
- });
- }
- //Validação do produto chamada no VldPortalSMS
- if(aVlr[17] == "1"){
- //Limpa a quantidade caso tenha alterado o produto
- $.trim($("input[name='CK_QTDVEN"+nItem+"']").val(""));
-
- //Validação do prazo de embarque
- if (aVlr[19] != ""){
- bootbox.alert("Este item não tem estrutura de produção.<br>O prazo de entrega será acrescido de "+aVlr[19]+" dia(s).");
- przEmb = przEmb+parseInt(aVlr[19]);
- }
- $("input[id='CK_PRZEMB"+nItem+"']").val(String(przEmb));
- $.trim($("input[name='CK_PRCVEN"+nItem+"']").val(aVlr[1]));
- $.trim($("input[name='iCK_PRCVEN"+nItem+"']").val(aVlr[1]));
- //Verifica tipo e grupo do produto
- if(aVlr[20]=="PS" && aVlr[13]=="SERV"){
- bootbox.confirm({
- title: "Custo e Preço de Venda do Serviço",
- message: "Deseja informar o Custo e o Preço de Venda do serviço?",
- buttons: {
- cancel: {
- label: 'Não'
- },
- confirm: {
- label: 'Sim'
- }
- },
- callback: function (result) {
- if (result){
- //Chama tela para informar os dois campos
- informaCusto(nItem);
- }
- }
- });
- }
- nVlrVenda = $('#CK_PRCVEN'+nItem).maskMoney('unmasked')[0];
- nPerFrete = $('#CJ_PERCFRT').maskMoney('unmasked')[0];
- nRT = $('#CJ_COMISTR').maskMoney('unmasked')[0];
- //soma percentual de frete e RT
- if(nVlrVenda > 0 ){
- if(nPerFrete > 0 ){
- nVlrVenda = nVlrVenda + ((nVlrVenda * nPerFrete)/100);
- }
- if(nRT > 0 ){
- nVlrVenda = nVlrVenda + ((nVlrVenda * nRT)/100);
- }
- }
- $("input[name='CK_UM"+nItem+"']").val(aVlr[0]);
- $.trim($("input[name='CK_PRCVEN"+nItem+"']").val(nVlrVenda)); //aVlr[1]
- $.trim($("input[name='iCK_PRCVEN"+nItem+"']").val(nVlrVenda)); //aVlr[1]
- $.trim($("input[name='CK_XVALICM"+nItem+"']").val(aVlr[2]));
- $.trim($("input[name='CK_XVALIPI"+nItem+"']").val(aVlr[3]));
- $.trim($("input[name='CK_XICMST"+nItem+"']").val(aVlr[4]));
- $.trim($("input[name='CK_LOCAL"+nItem+"']").val(aVlr[15]));
-
- //Input hidden
- $("input[id='ALIQ_IPI"+nItem+"']").val(aVlr[5]);
- $("input[id='ALIQ_ICMS"+nItem+"']").val(aVlr[6]);
- $("input[id='ALIQ_ST"+nItem+"']").val(aVlr[12]);
- $("input[id='BASE_IPI"+nItem+"']").val(aVlr[11]);
- $("input[id='BASE_ICMS"+nItem+"']").val(aVlr[9]);
- $("input[id='BASE_ST"+nItem+"']").val(aVlr[10]);
- $("input[id='VAL_ICMS"+nItem+"']").val(aVlr[2]);
- $("input[id='VAL_ST"+nItem+"']").val(aVlr[4]);
- $("input[id='VAL_IPI"+nItem+"']").val(aVlr[3]);
-
- $("input[id='QTD_EMB"+nItem+"']").val(aVlr[7]);
- $("input[id='CK_TES"+nItem+"']").val(aVlr[8]);
- $("input[id='GRUPO"+nItem+"']").val(aVlr[13]);
- $("input[id='QTDMIN"+nItem+"']").val(aVlr[14]);
- $("input[id='EST_DISP"+nItem+"']").val(aVlr[16]);
- $("input[id='VENCIMENTO"+nItem+"']").val(aVlr[15]);
-
- //Salva o valor do imposto pro preço cheio
- if($("#IMP_PRCTAB"+nItem).val() == 0){
- nPrcImp = parseFloat(aVlr[3].replace(",","."))+parseFloat(aVlr[4].replace(",","."));
- $("#IMP_PRCTAB"+nItem).val(nPrcImp);
- }
-
- //Limpa os inputs, caso tenha trocado o produto
- $("input[name='CK_QTDVEN"+nItem+"']").removeAttr('disabled');
- $("input[name='CK_VALOR"+nItem+"']").val("0,00");
- } else {
- LimpaLinha(nItem);
- }
- } else {
-
- if (data.substr(0, 4) == "ERRO") {
- cMsgErro = data.substr(5);
- bootbox.alert(cMsgErro);
- LimpaLinha(nItem);
- } else {
- cMsgErro = "Houve falha ao localizar os dados do produto. Tente novamente!";
- bootbox.alert(cMsgErro);
- LimpaLinha(nItem);
- // Quando ocorre erro no protheus
- console.log(data);
- }
- }
- }
- });
-
- } else if ($.trim(objInput.val()) == "" ) {
- LimpaLinha(nItem);
- }
-
- return false;
- }
- /**
- Funcao para informar o custo do serviço
- **/
- function informaCusto(cItemAtu) {
- $("#itemAtu").val(cItemAtu);
- $("#dialogCusto").modal('show');
- }
-
- /**
- Funcao que grava o custo do serviço
- **/
- function gravaCusto(itemAtu,prcVenda,custo){
- var qtd = parseFloat($("#CK_QTDVEN"+itemAtu).val().replace('.',"").replace(",","."));
- var totalCusto = 0;
- custoUnt = $("#CUSTO").maskMoney('unmasked')[0];
- if(qtd == 0){qtd = 1};
- totalCusto = custoUnt * qtd;
- $("#CK_CUSTO"+itemAtu).val(mascaraValor(totalCusto.toFixed(2)));
- $("#CK_PRCVEN"+itemAtu).val(prcVenda);
- $("#iCK_PRCVEN"+itemAtu).val(prcVenda);
- $("#dialogCusto").modal('hide');
- }
- /**
- Funcao de calculo do total do item
- **/
- function TotalItem(cItemAtu) {
- var nQuant;
- var nVlrUnit;
- var nVlrTabela;
- var nVlrCusto;
- var nTotalCusto;
- var nTotalUnit;
- var nICMS;
- var nICMSST;
- var nIPI;
- var nPerDesc = 0;
- var nValFrete;
- var nVlrTotal;
- var nBaseIPI;
- var nBaseICMS;
- var nBaseST;
- var cFaixaDesc;
- var nPerCom = 0;
- var nValCom = 0;
- var nValDesc = 0;
-
- cCodProd = formataProd($("#CK_PRODUTO"+cItemAtu).val());
- nQuant = parseFloat($("#CK_QTDVEN"+cItemAtu).val().replace('.',"").replace(",","."));
- nVlrTabela = $('#iCK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
- nVlrCusto = $('#CK_CUSTO'+cItemAtu).maskMoney('unmasked')[0];
- //nVlrTabela = $('#CK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
- //nVlrUnit = $('#iCK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
- nValFrete = $("#CJ_FRETE").maskMoney('unmasked')[0];
- if ($('#CK_DESCONT'+cItemAtu).maskMoney('unmasked')[0] != 0){
- nPerDesc = $("#CK_DESCONT"+cItemAtu).maskMoney('unmasked')[0];
- }
-
- nVlrUnit = nVlrTabela - (nVlrTabela*(nPerDesc/100));
- nVlrTotal = nVlrUnit*nQuant;
- nTotalUnit = nVlrTotal;
- nValDesc = nVlrTabela*(nPerDesc/100);
- nTotalCusto = nVlrCusto*nQuant;
-
- //Tratamento para os impostos
- nICMS = $('#CK_XVALICM'+cItemAtu).maskMoney('unmasked')[0];
- nICMSST = $('#CK_XICMST'+cItemAtu).maskMoney('unmasked')[0];
- nIPI = $("#CK_XVALIPI"+cItemAtu).maskMoney('unmasked')[0];
-
- //Aliquotas
- nAliqIPI = parseFloat($("#ALIQ_IPI"+cItemAtu).val());
- nAliqICMS = parseFloat($("#ALIQ_ICMS"+cItemAtu).val());
- nAliqST = parseFloat($("#ALIQ_ST"+cItemAtu).val());
-
- //Valores Base
- nBaseIPI = parseFloat($("#BASE_IPI"+cItemAtu).val());
- nBaseICMS = parseFloat($("#BASE_ICMS"+cItemAtu).val());
- nBaseST = parseFloat($("#BASE_ST"+cItemAtu).val());
-
- //Valor do imposto
- nIPI = nBaseIPI * nQuant * (nAliqIPI /100)
- nICMS = nBaseICMS * nQuant * (nAliqICMS /100)
- nICMSST = nQuant * parseFloat($("#VAL_ST"+cItemAtu).val().replace(",","."));
-
- //nIPI = nVlrTotal*(nAliqIPI /100)
- //nICMS = nVlrTotal*(nAliqICMS /100)
- //nIPI = nQuant * parseFloat($("#VAL_IPI"+cItemAtu).val().replace(",","."));
- //nICMS = nQuant * parseFloat($("#VAL_ICMS"+cItemAtu).val().replace(",","."));
- //nICMSST = nQuant * parseFloat($("#VAL_ST"+cItemAtu).val().replace(",","."));
-
- nVlrTotal = nVlrTotal+nIPI+nICMSST;
- nTotalUnit = nVlrTotal / nQuant;
-
- //Atualiza o campo do total
- $.trim($("#CK_XVALICM"+cItemAtu).val(mascaraValor(nICMS.toFixed(2))));
- $.trim($("#CK_XVALIPI"+cItemAtu).val(mascaraValor(nIPI.toFixed(2))));
- $.trim($("#CK_XICMST"+cItemAtu).val(mascaraValor(nICMSST.toFixed(2))));
- $.trim($("#CK_PRCVEN"+cItemAtu).val(mascaraValor(nVlrUnit.toFixed(2))));
- $.trim($("#CK_CUSTO"+cItemAtu).val(mascaraValor(nTotalCusto.toFixed(2))));
- $.trim($("#CK_VALOR"+cItemAtu).val(mascaraValor(nVlrTotal.toFixed(2))));
- $.trim($("#CK_XPRCIMP"+cItemAtu).val(mascaraValor(nTotalUnit.toFixed(2))));
- //Atualiza o total geral
- TotalGeral();
- }
-
- /**
- Total Geral
- **/
- function TotalGeral() {
- var nItens = parseFloat($("#PROXIMO").val());
- var i;
- var nVlrTabela = 0;
- var nVlrUnit = 0;
- var nVlrUniSD = 0;
- var nICMS = 0;
- var nICMSST = 0;
- var nIPI = 0;
- var nImpostos = 0;
- var nValFrete = 0;
- var nTotal = 0;
- var nAcresc = 0;
- var nDescCond = 0;
- var nQuant = 0;
- var nValCom = 0;
- var cCodProd;
- var cItmOrc;
- var nTotQuant = 0.00;
- var nPerDesc = 0;
- var nValDesc = 0;
- var nVlrSDesc = 0
-
- for (i = 1; i<=nItens; i++) {
- cItem = String(i);
- if (parseInt(i) < 10 ){cItem = "0"+String(i)};
-
- cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
- cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
- if(cItmOrc != "x") {
- nQuant = parseFloat($("#CK_QTDVEN"+cItem).val().replace('.',"").replace(",","."));
- nTotQuant += nQuant;
- nVlrUniSD += nQuant * $('#iCK_PRCVEN'+cItem).maskMoney('unmasked')[0];
- nVlrUnit += nQuant * $('#CK_PRCVEN'+cItem).maskMoney('unmasked')[0];
- nICMS += $('#CK_XVALICM'+cItem).maskMoney('unmasked')[0];
- nICMSST += $('#CK_XICMST'+cItem).maskMoney('unmasked')[0];
- nIPI += $("#CK_XVALIPI"+cItem).maskMoney('unmasked')[0];
- nValCom += $("#VAL_COM"+cItem).maskMoney('unmasked')[0];
- nTotal += $('#CK_VALOR'+cItem).maskMoney('unmasked')[0];
- if ($('#CK_DESCONT'+cItem).maskMoney('unmasked')[0] != 0){
- nPerDesc = $("#CK_DESCONT"+cItem).maskMoney('unmasked')[0];
- nValDesc += nVlrUniSD*(nPerDesc/100);
- }
- }
- }
-
- nImpostos = nICMSST+nIPI; //nICMS
- nValFrete = $("#CJ_FRETE").maskMoney('unmasked')[0];
-
- /*
- //Verifica acrescimo da condição de pagamento
- $.ajax({
- url: "U_ValAcresc.apw?PR=<%=cLCodLogin%>",
- data: 'condPgto='+$("#CJ_CONDPAG").val()+'&valor='+nTotal,
- type: "POST",
- async: false,
- success:
- function(retorno) {
- //nAcresc = parseFloat(retorno);
- nAcresc = parseFloat(nTotal*(retorno/100))
- }
- });
- */
- //nDescCond = parseFloat((nTotal-nTotalProm)*($("#DESCCOND").val()/100)); //desconto da condição de pagamento
- nDescCond = parseFloat(nTotal*($("#DESCCOND").val()/100)); //desconto da condição de pagamento
- nTotal = (nTotal+nValFrete+nAcresc)-nDescCond;
- nPrcImp = parseFloat($("#IMP_PRCTAB"+cItem).val().replace(",","."));
- nVlrSDesc = nVlrUniSD+nImpostos;
- //nVlrSDesc = nVlrUnit+nPrcImp;
- //nVlrSDesc = nVlrUnit+nImpostos;
- nTotalIt = nVlrUnit;
- //Atualiza os totais
- $("#TOTAL_ITENS_NODESC").val($.trim(mascaraValor(nVlrUniSD.toFixed(2))));
- $("#TOTAL_NODESC_IMP").val($.trim(mascaraValor((nVlrSDesc).toFixed(2))));
-
- $("#TOTAL_QITENS").val($.trim(mascaraValor(nTotQuant.toFixed(2))));
- $("#TOTAL_ITENS").val($.trim(mascaraValor((nTotalIt).toFixed(2))));
- $("#TOTAL_IMP").val($.trim(mascaraValor(nImpostos.toFixed(2))));
- $("#TOTAL_FRETE").val($("#CJ_FRETE").val());
- $("#TOTAL_ACRESC").val($.trim(mascaraValor(nDescCond.toFixed(2))));
- $("#TOTAL_ORC").val($.trim(mascaraValor(nTotal.toFixed(2))));
- $("#TOTAL_COM").val($.trim(mascaraValor(nValCom.toFixed(2))));
- }
-
- /**
- Atualiza o valor do produto ao trocar a condição de pagamento
- **/
- function AtuValProd(){
- var nItens = parseFloat($("#PROXIMO").val());
- var i;
- var nvalorcheio = 0;
- for (i = 1; i<=nItens; i++) {
- cItem = String(i);
- if (parseInt(i) < 10 ){cItem = "0"+String(i)};
- cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
- if(cItmOrc != "x") {
- nvalorcheio = $('#CK_PRCVEN'+cItem).val();
- $('#iCK_PRCVEN'+cItem).val(nvalorcheio);
- TotalItem(cItem);
- }
- }
- }
- /**
- Verifica se a quantidade é multiplo da embalagem
- **/
- function VldQtd(cItemAtu) {
- var nQuant;
- var nQtdEmb;
- var nQtdMin;
- var resto;
- var cCodProd = formataProd($("#CK_PRODUTO"+cItemAtu).val());
- var lRet = true;
-
- //Valida a quantidade por embalagem
- nQtdEmb = parseFloat($("#QTD_EMB"+cItemAtu).val());
- nQtdMin = $("#QTDMIN"+cItemAtu).val();
- nQuant = parseFloat($("#CK_QTDVEN"+cItemAtu).val().replace('.',"").replace(",","."));
- if (nQuant > 0){
-
- //Valida a quantidade da embalagem
- if (nQtdEmb > 0){
- if (nQuant < (nQtdEmb)){
- bootbox.alert("A quantidade deve ser múltiplo de "+nQtdEmb.toString()+".");
- $("#CK_QTDVEN"+cItemAtu).val("");
- lRet = false;
- return false;
- } else {
- resto = nQuant % nQtdEmb;
- if (resto != 0 ){
- bootbox.alert("A quantidade deve ser múltiplo de "+nQtdEmb.toString()+".");
- $("#CK_QTDVEN"+cItemAtu).val("");
- lRet = false;
- return false;
- }
- }
- }
- /*
- var dialogProd = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Buscando dados do produto... Aguarde...</p>',
- closeButton: false
- });
- //Atualiza o preço de acordo com a quantidade
- // Encontra a posição do primeiro h?fen na string
- indiceHifen = cCodProd.indexOf("--");
- //Pega apenas o codigo do produto
- cCodProd = cCodProd.substring(0, indiceHifen);
- //Remove espaços vazios
- cCodProd = cCodProd.trim();
-
- jQuery.ajax({
- type: "POST",
- url: "U_GATPROD.APW?PR=<%=cLCodLogin%>",
- data: 'produto='+encodeURIComponent(cCodProd)+'&tabela='+$("#CJ_TABELA").val(),
- error: function (jqXHR, textStatus, error){
- dialogProd.modal('hide');
- bootbox.alert("Falha ao recuperar informações!");
- console.log(error);
- },
- success: function( data ) {
- var aVlr;
- var cMsgErro;
-
- dialogProd.modal('hide');
-
- if (data.substr(0, 2) == "OK") {
- aVlr = data.substr(3).split('|#|');
- $("input[name='CK_UM"+cItemAtu+"']").val(aVlr[0]);
- $.trim($("input[name='CK_PRCVEN"+cItemAtu+"']").val(aVlr[1]));
- $.trim($("input[name='iCK_PRCVEN"+cItemAtu+"']").val(aVlr[1]));
- $.trim($("input[name='CK_XVALICM"+cItemAtu+"']").val(aVlr[2]));
- $.trim($("input[name='CK_XVALIPI"+cItemAtu+"']").val(aVlr[3]));
- $.trim($("input[name='CK_XICMST"+cItemAtu+"']").val(aVlr[4]));
- $.trim($("input[name='CK_LOCAL"+cItemAtu+"']").val(aVlr[15]));
-
- //Input hidden
- $("input[id='ALIQ_IPI"+cItemAtu+"']").val(aVlr[5]);
- $("input[id='ALIQ_ICMS"+cItemAtu+"']").val(aVlr[6]);
- $("input[id='ALIQ_ST"+cItemAtu+"']").val(aVlr[12]);
- $("input[id='BASE_IPI"+cItemAtu+"']").val(aVlr[11]);
- $("input[id='BASE_ICMS"+cItemAtu+"']").val(aVlr[9]);
- $("input[id='BASE_ST"+cItemAtu+"']").val(aVlr[10]);
- $("input[id='VAL_ICMS"+cItemAtu+"']").val(aVlr[2]);
- $("input[id='VAL_ST"+cItemAtu+"']").val(aVlr[4]);
- $("input[id='VAL_IPI"+cItemAtu+"']").val(aVlr[3]);
-
- $("input[id='QTD_EMB"+cItemAtu+"']").val(aVlr[7]);
- $("input[id='CK_TES"+cItemAtu+"']").val(aVlr[8]);
- $("input[id='GRUPO"+cItemAtu+"']").val(aVlr[13]);
- $("input[id='QTDMIN"+cItemAtu+"']").val(aVlr[14]);
-
- } else {
-
- if (data.substr(0, 4) == "ERRO") {
- cMsgErro = data.substr(5);
- bootbox.alert(cMsgErro);
- LimpaLinha(cItemAtu);
- } else {
- cMsgErro = "Houve falha ao localizar os dados do produto. Tente novamente!";
- bootbox.alert(cMsgErro);
- LimpaLinha(cItemAtu);
- // Quando ocorre erro no protheus
- console.log(data);
- }
- }
- }
- });
- */
- } else {
- bootbox.alert("Informe a quantidade!");
- lRet = false;
- return false;
- }
-
- if (lRet == true){
- //Valida o estoque do produto
- //vldEstoque(cItemAtu);
- //Desbloqueia os campos
- $("#CK_OBS"+cItemAtu).removeAttr('disabled');
- $("#CK_PRZEMB"+cItemAtu).removeAttr('disabled');
- $("#CK_DESCONT"+cItemAtu).removeAttr('disabled');
- //cPrzEmb = $("#CJ_PRZEMB").val();
- //$("#CK_PRZEMB"+cItemAtu).val(cPrzEmb);
- }
-
- //Gatilho para total do item
- TotalItem(cItemAtu);
- }
-
-
-
-
- /**
- Verifica se existe estoque disponível
- **/
- function vldEstoque(cItem){
- var produto = formataProd($("#CK_PRODUTO"+cItem).val());
- var quantidade = parseFloat($("#CK_QTDVEN"+cItem).val().replace('.',","));
- var qtd = $("#CK_QTDVEN"+cItem).val();
- var lret = true;
- var retVld = true;
-
- var dialogTab = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Verificando estoque disponível... Aguarde...</p>',
- closeButton: false
- });
-
- $.ajax({
- url: "U_GetEstDisp.apw?PR=<%=cLCodLogin%>",
- data: 'produto='+encodeURIComponent(produto)+'&quantidade='+qtd,
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
- saldo = parseInt(retorno);
- $("#EST_DISP"+cItem).val(saldo);
- if ( saldo <= 0 || saldo < quantidade) {
- if(retorno < 0){
- retorno = 0
- };
- dialogTab.modal('hide');
- bootbox.alert('Não há saldo disponível em estoque para a quantidade solicitada para o item '+produto+'! <br>O saldo atual é de '+retorno+'.');
-
- if ($('#CJ_XTPORC').val() == "1"){
- $("#CK_QTDVEN"+cItem).val("");
- lret = false;
- retVld = false;
- }
- }
- }
- });
-
- if (lret == true){
- //Habilita os campos para edição
- $("#CK_XPEDCLI"+cItem).removeAttr('disabled');
- $("#CK_XITEMCL"+cItem).removeAttr('disabled');
- $("#CK_DESCONT"+cItem).removeAttr('disabled');
- }
- dialogTab.modal('hide');
-
- return retVld;
- }
-
- /**
- Limpa os valores da linha
- **/
- function LimpaLinha(cItem) {
- $("#CK_QTDVEN"+cItem).val("");
- $("#CK_PRZEMB"+cItem).val("");
- $("#iCK_PRCVEN"+cItem).val("");
- $("#CK_PRCVEN"+cItem).val("");
- $("#CK_CUSTO"+cItem).val("");
- $("#IMP_PRCTAB"+cItem).val("");
- $("#CK_XPRCIMP"+cItem).val("");
- $("#CK_XVALIPI"+cItem).val("");
- $("#CK_XVALICM"+cItem).val("");
- $("#CK_XICMST"+cItem).val("");
- $("#CK_VALOR"+cItem).val("");
- $("#PER_COM"+cItem).val("");
- $("#VAL_COM"+cItem).val("");
- $("#CK_DESCONT"+cItem).val("");
-
- TotalGeral();
- }
-
- /**
- Verifica se o valor digitado é maior que o valor de tabela
- **/
- function VldValor(cItemAtu,cVldDesc) {
- var nVlrTabela = $('#iCK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
- var nVlrUnit = $('#CK_PRCVEN'+cItemAtu).maskMoney('unmasked')[0];
- var produto = $("#CK_PRODUTO"+cItemAtu).val();
- var cQuant = $("#CK_QTDVEN"+cItemAtu).val();
- var nValMin = 0;
- var nDescont = 0;
- var nDescMax = 0;
- var aDesc;
- var lOK = true;
- var lMostra = false;
- var dialogTab = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Verificando valores... Aguarde...</p>',
- closeButton: false
- });
-
- if ($('#CK_DESCONT'+cItemAtu).maskMoney('unmasked')[0] != 0){
- nDescont = $('#CK_DESCONT'+cItemAtu).maskMoney('unmasked')[0];
- //Verifica desconto negativo
- if (nDescont < 0) {
- dialogTab.modal('hide');
- bootbox.alert('O desconto não deve ser negativo!');
- $('#CK_DESCONT'+cItemAtu).val("");
- return false;
- }
- //Verifica desconto maior que 100
- if (nDescont > 100) {
- dialogTab.modal('hide');
- bootbox.alert('O desconto não deve ser maior que 100!');
- $('#CK_DESCONT'+cItemAtu).val("");
- return false;
- }
-
- //Verifica validação do desconto
- if (cVldDesc == 'S'){
- produto = formataProd(produto);
- $.ajax({
- url: "U_VldDescto.apw?PR=<%=cLCodLogin%>",
- data: 'produto='+encodeURIComponent(produto)+'&prcvenda='+nVlrUnit+'&quantidade='+cQuant,
- type: "POST",
- async: false,
- error: function (jqXHR, textStatus, error){
- dialogTab.modal('hide');
- bootbox.alert("Falha ao atualizar o valor dos impostos!");
- console.log(error);
- lOK = false;
- },
- success:
- function(cTipoDesc) {
- if(cTipoDesc=='3'){
- bootbox.alert('Produtos do tipo RE, iniciados com RELUMI, do grupo PAN ou acessórios de produtos do grupo PAN não permitem descontos.');
- $('#CK_DESCONT'+cItemAtu).val("");
- return false;
- }
- if(cTipoDesc=='2'){
-
- msg = '<div class="row form-group">'
- //Usuario
- msg +=' <div class="row form-group">'
- msg +=' <div class="col-lg-1"></div>'
- msg +=' <div class="col-lg-11">'
- msg +=' <label class="control-label">Usuário</label>'
- msg +=' <div class="input-group">'
- msg +=' <input id="userName" class="form-control text-left" value="">'
- msg +=' </div>'
- msg +=' </div>'
- msg +=' </div>'
-
- //Senha
- msg +=' <div class="row form-group">'
- msg +=' <div class="col-lg-1"></div>'
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">Senha</label>'
- msg +=' <div class="input-group">'
- msg +=' <input id="userPsw" class="form-control text-left" type="password" value="">'
- msg +=' </div>'
- msg +=' </div>'
- //% de Desconto
- msg +=' <div class="row form-group">'
- msg +=' <div class="col-lg-1"></div>'
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">% de Desconto</label>'
- msg +=' <div class="input-group">'
- msg +=' <input id="percDesc" class="form-control text-right percentual" type="text" value="" maxlenght="7" placeholder="0,00%">'
- msg +=' </div>'
- msg +=' </div>'
- msg +=' </div>'
- msg +='</div>'
-
- bootbox.confirm({
- title: 'Senha para Desconto',
- message: "<p>"+msg+"</p>",
- backdrop: true,
- buttons: {
- cancel: {
- label: 'Cancelar'
- },
- confirm: {
- label: 'Confirmar'
- }
- },
- callback: function (result) {
- if (result){
- usrInput = $("#userName").val();
- pswInput = $("#userPsw").val();
- percDesc = $("#percDesc").val();
- //Valida a senha digitada
- $.ajax({
- url: "U_VldSenha.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: 'user='+usrInput+'&senha='+pswInput,
- async: false,
- success:
- function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ||retorno.toLowerCase().indexOf("Expires") != -1){
- bootbox.alert('Não foi possível realizar a operação pois a sessão foi fechada. Faça login novamente.');
- }
- if(retorno == "NOK"){
- bootbox.alert("Usuário ou senha inválidos!")
- $('#CK_DESCONT'+cItemAtu).val("");
- return false;
- } else {
- $('#CJ_DSDIRET').val(percDesc);
- $('#CK_NOMDIRE'+cItemAtu).val(usrInput);
- }
- }
- });
- } else {
- $('#CK_DESCONT'+cItemAtu).val("");
- return false;
- }
- }
- });
- }
- }
-
- });
- }
- }
-
-
- //Valida o valor máximo --retirado Lucilene 11.08.20
- //if ( lOK && nVlrUnit > nVlrTabela){
- // dialogTab.modal('hide');
- // bootbox.alert("O valor máximo permitido é o valor da tabela!");
- // $("#iCK_PRCVEN"+cItemAtu).val($('#CK_PRCVEN'+cItemAtu).val());
- // $("#iCK_PRCVEN"+cItemAtu).focus();
- // lOK = false;
- //}
-
- //dialogTab.modal('hide');
-
- //Atualiza o valor dos impostos
- if (lOK && nDescont != 0){
- var cCodProd = formataProd($("#CK_PRODUTO"+cItemAtu).val());
- var cQuant = $("#CK_QTDVEN"+cItemAtu).val();
- //var dialogImp = bootbox.dialog({
- // message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Atualizando os valores dos impostos... Aguarde...</p>',
- // closeButton: false
- // });
- nVlrUnit = nVlrTabela - (nVlrTabela * (nDescont/100))
- $.ajax({
- url: "U_GetImpostos.apw?PR=<%=cLCodLogin%>",
- data: 'produto='+encodeURIComponent(cCodProd)+'&prcvenda='+nVlrUnit+'&quantidade='+cQuant,
- type: "POST",
- async: false,
- error: function (jqXHR, textStatus, error){
- dialogTab.modal('hide');
- bootbox.alert("Falha ao atualizar o valor dos impostos!");
- console.log(error);
- lOK = false;
- },
- success:
- function(data) {
-
- dialogTab.modal('hide');
- if (data.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(data);
- return;
- }
-
- if (data.substr(0, 2) == "OK") {
- aVlr = data.substr(3).split('|#|');
- $.trim($("input[name='CK_XVALICM"+cItemAtu+"']").val(aVlr[2]));
- $.trim($("input[name='CK_XICMST"+cItemAtu+"']").val(aVlr[4]));
- $.trim($("input[name='CK_XVALIPI"+cItemAtu+"']").val(aVlr[3]));
- $.trim($("#CK_PRCVEN"+cItemAtu).val(mascaraValor(nVlrUnit.toFixed(2))));
- //Input hidden
- $("input[id='ALIQ_IPI"+cItemAtu+"']").val(aVlr[5]);
- $("input[id='ALIQ_ICMS"+cItemAtu+"']").val(aVlr[6]);
- $("input[id='ALIQ_ST"+cItemAtu+"']").val(aVlr[12]);
- $("input[id='CK_TES"+cItemAtu+"']").val(aVlr[8]);
- $("input[id='BASE_IPI"+cItemAtu+"']").val(aVlr[11]);
- $("input[id='BASE_ICMS"+cItemAtu+"']").val(aVlr[9]);
- $("input[id='BASE_ST"+cItemAtu+"']").val(aVlr[10]);
- $("input[id='VAL_ICMS"+cItemAtu+"']").val(aVlr[2]);
- $("input[id='VAL_ST"+cItemAtu+"']").val(aVlr[4]);
- $("input[id='VAL_IPI"+cItemAtu+"']").val(aVlr[3]);
- } else {
- cMsgErro = "Houve falha ao atualizar os impostos. Tente novamente!";
- bootbox.alert(cMsgErro);
- LimpaLinha(cItemAtu);
- lOK = false;
- if (data.substr(0, 4) == "ERRO") {
- cMsgErro = data.substr(5);
- } else {
- // Quando ocorre erro no protheus
- console.log(data);
- }
- }
- }
- });
- }
- dialogTab.modal('hide');
- //Gatilho para total do item
- if(lOK){
- TotalItem(cItemAtu);
- }
- }
-
-
-
- /**
- Função para anexar os documentos ao orçamento
- **/
- function OrcGetAnex() {
- $.ajax({
- url: "U_OrcGetAn.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: "fornece="+$("#fornece").val()+"&loja="+$("#loja").val(),
- cache: false,
- success: function(html){
- $("#InfAnexos").html(html);
- new PNotify({
- title: 'Anexar arquivo',
- text: 'Anexado com sucesso',
- type: 'success',
- icon: 'fa fa-file-o',
- cornerclass: 'ui-pnotify-sharp'
- });
- $("#arquivo").remove();
- }
- });
- }
-
-
- /**
- Funcao de validação do tipo de frete
- **/
- function VldFrete() {
- var cFrete;
- var tabpreco = $("#CJ_TABELA").val();
- cFrete = $("#CJ_TPFRETE").val();
- if (cFrete == 'S'||cFrete == 'T'||cFrete == 'F'){
- $("#CJ_FRETE").removeAttr("required");
- $("#CJ_FRETE").removeAttr("aria-required");
- $("#CJ_FRETE").attr("disabled","");
- $("#CJ_FRETE").val("0,00");
- //$("#CJ_XTRANSP").removeAttr('disabled');
- //$("#CJ_XTRANSP").val("");
- $("#select2-CJ_XTRANSP-container").html("Selecione uma Transportadora");
- } else {
- if (cFrete != ""){
- $("#CJ_FRETE").attr("required","");
- $("#CJ_FRETE").attr("aria-required","true");
- $("#CJ_FRETE").removeAttr('disabled');
- $("#CJ_FRETE").focus();
- //$("#CJ_XTRANSP").removeAttr('disabled');
- //$("#CJ_XTRANSP").val("");
- }
- //Localiza a transportadora
- /*
- $.ajax({
- url: "U_GetTransp.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: 'tabela='+tabpreco,
- async: false,
- success:
- function(transp) {
- if (transp.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(transp);
- return;
- }
- if ( transp != "" ) {
- //Preenche o campo da transportadora
- document.getElementById('CJ_XTRANSP').innerText = null;
- $("#CJ_XTRANSP").append(transp);
- } else {
- bootbox.alert('Cliente sem transportadora cadastrada!');
- $("#CJ_TPFRETE").val("S")
- $("#select2-CJ_TPFRETE-container").html("Sem Frete")
- $("#CJ_FRETE").removeAttr("required");
- $("#CJ_FRETE").removeAttr("aria-required");
- $("#CJ_FRETE").attr("disabled","");
- $("#CJ_XTRANSP").attr("disabled","");
- $("#CJ_FRETE").val("0,00");
- $("#CJ_XTRANSP").val("");
- $("#select2-CJ_XTRANSP-container").html("Selecione uma Transportadora");
-
- }
- }
- });
- */
-
- //$("#select2-CJ_XTRANSP-container").html("Selecione uma Transportadora");
- }
-
-
- TotalGeral();
- }
-
-
- /**
- // Função para ver detalhes da linha
- **/
- function detalheOrc(cItem){
- var msg = "";
- var produto = $("#CK_PRODUTO"+cItem);
- var retorno = "";
- var estoque = "";
- var dialogTab = "";
- if(produto.val() == ""){
- bootbox.alert("Selecione o produto para ver os detalhes!");
- return false;
- }
-
- produto = formataProd(produto.val());
- /*
- dialogTab = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Carregando detalhes... Aguarde...</p>',
- closeButton: false
- });
-
- $.ajax({
- url: "U_GetEstGeral.apw?PR=<%=cLCodLogin%>",
- data: 'produto='+encodeURIComponent(produto.val()),
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
- estoque = retorno;
- }
- });
- dialogTab.modal('hide');
- */
- msg = '<div class="row form-group">'
- msg +=' <header class="panel-heading">'
- msg +=' <h2 class="panel-title">Detalhes da linha</h2>'
- msg +=' </header>'
- msg +=' <br>'
- //Descrição do produto
- msg +=' <div class="row form-group">'
- msg +=' <div class="col-lg-1"></div>'
- msg +=' <div class="col-lg-11">'
- msg +=' <label class="control-label">Produto</label>'
- msg +=' <div class="input-group">'
- msg +=' <input class="form-control text-left" style="width: 240%;" value="'+$("#CK_PRODUTO"+cItem).val().split('- ')[1]+'" disabled>'
- //msg +=' <input class="form-control text-left" style="width: 240%;" value="'+$(produto)[0].options[$(produto)[0].selectedIndex].text.split('- ')[1]+'" disabled>'
- msg +=' </div>'
- msg +=' </div>'
- msg +=' </div>'
- /*
- //% ICMS
- msg +=' <div class="row form-group">'
- msg +=' <div class="col-lg-1"></div>'
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">Aliquota ICMS</label>'
- msg +=' <div class="input-group">'
- msg +=' <input class="form-control text-right" value="'+$("#ALIQ_ICMS"+cItem).val()+'%" disabled>'
- msg +=' </div>'
- msg +=' </div>'
- //% ICMS ST
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">Aliquota ICMS ST</label>'
- msg +=' <div class="input-group">'
- msg +=' <input class="form-control text-right" value="'+$("#ALIQ_ST"+cItem).val()+'%" disabled>'
- msg +=' </div>'
- msg +=' </div>'
- msg +=' </div>'
- */
- //IPI
- msg +=' <div class="row form-group">'
- msg +=' <div class="col-lg-1"></div>'
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">IPI</label>'
- msg +=' <div class="input-group">'
- msg +=' <input class="form-control text-right" value="'+$("#VAL_IPI"+cItem).val()+'" disabled>'
- msg +=' </div>'
- msg +=' </div>'
- //ICMS
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">ICMS</label>'
- msg +=' <div class="input-group">'
- msg +=' <input class="form-control text-right" value="'+$("#VAL_ICMS"+cItem).val()+'" disabled>'
- msg +=' </div>'
- msg +=' </div>'
- //ICMS ST
- msg +=' <div class="col-lg-3">'
- msg +=' <label class="control-label">ICMS ST</label>'
- msg +=' <div class="input-group">'
- msg +=' <input class="form-control text-right" value="'+$("#VAL_ST"+cItem).val()+'" disabled>'
- msg +=' </div>'
- msg +=' </div>'
- msg +=' </div>'
- msg +='</div>'
-
- if(msg != ""){
- bootbox.dialog({
- title: '',
- message: "<p>"+msg+"</p>",
- backdrop: true,
- buttons: {
- ok: {
- label: "OK"
- }
- }
- });
- }
- }
-
- //Remover linha
- function removeItem(cItem){
- //e.preventDefault();
- //var btnRem = $(this);
- cItem = parseInt(cItem);
-
- bootbox.confirm({
- title: "Exclusão da linha",
- message: "Confirma a exclusão desta linha?",
- buttons: {
- cancel: {
- label: 'Cancelar'
- },
- confirm: {
- label: 'Confirmar'
- }
- },
- callback: function (result) {
- if (result){
- if (cItem < 10 ){cItem = "0"+String(cItem)};
-
- //Desabilita o botão
- //btnRem.attr({ 'disabled': 'disabled' });
-
- $("#CK_ITEM"+cItem).val("x");
- $("#CK_PRODUTO"+cItem).val("");
- $("#CK_QTDVEN"+cItem).val("1");
- $("#CK_LOCAL"+cItem).val("");
- $("#CK_PRUNIT"+cItem).val("0");
- $("#iCK_PRCVEN"+cItem).val("0,00");
- $("#CK_PRCVEN"+cItem).val("0,00");
- $("#CK_XVALICM"+cItem).val("0,00");
- $("#CK_XVALIPI"+cItem).val("0,00");
- $("#CK_XICMST"+cItem).val("0,00");
- $("#CK_VALOR"+cItem).val("0,00");
- $("#linha"+cItem).hide();
-
- //Atualiza o total geral
- TotalGeral();
- }
- }
- });
- }
-
-
- //Clique no botão pesquisar do Cliente
- $('.btSearchCli').click(function(e) {
- e.preventDefault();
- getCliente($(this));
- });
- //Clique no botão pesquisar do Cliente
- $('.btEndEntrega').click(function(e) {
- e.preventDefault();
- getEntrega($(this));
- });
- $("#datatable-editable").delegate( "button", "click", function( event ) {
- event.preventDefault();
- getProduto($(this));
- });
- /**
- //Anexar
- **/
- $("#btnInfUpload").click(function() {
- var obAnexo = $("#anexo");
- var obArquivo = obAnexo.clone();
-
- obArquivo.attr("id", "arquivo");
-
- $("#frmInfUpload").append(obArquivo);
- var data;
- var contentType = "application/x-www-form-urlencoded";
- var processData = true;
- if ($('#frmInfUpload').attr('enctype') == 'multipart/form-data') {
- data = new FormData($('#frmInfUpload').get(0));//seleciona classe form-horizontal adicionada na tag form do html
- contentType = false;
- processData = false;
- } else {
- data = $('#frmInfUpload').serialize();
- }
- $.ajax({
- data: data,
- type: $('#frmInfUpload').attr('method'),
- url: $('#frmInfUpload').attr('action'),
- contentType: contentType,
- processData: processData,
- success: function (response) {
- //seu código apos sucesso
- if( response == "Ok" ) {
- window.location.reload();
- } else {
- bootbox.alert('Erro ao carregar arquivo');
- }
- },
- error: function (exr, sender) {
- bootbox.alert('Erro ao carregar pagina');
- }
- });
- });
-
- //Adicionar nova linha
- $('#btAddItm').click(function(e) {
- e.preventDefault();
- var newLine = parseFloat($("#PROXIMO").val())+1;
- var nItens = parseFloat($("#PROXIMO").val());
- var linhaAtu = String(newLine);
- var lRet = true;
- var lGridOK = true;
- var btnAdd = $(this);
- var cCodProd;
- var cItmOrc;
- let aExtras = [];
- let aFields = [];
-
- if (parseInt(linhaAtu) < 10 ){linhaAtu = "0"+String(linhaAtu)};
-
- //Desabilita o botão
- btnAdd.attr({ 'disabled': 'disabled' });
-
- //Valida o Grid
- if (nItens == 99){
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Quantidade máxima',
- text: 'O orçamento atingiu a quantidade máxima de itens. Crie um novo orçamento.',
- type: 'error',
- });
- btnAdd.removeAttr('disabled');
- return false;
- }
-
- if (lRet == true) {
- for (i = 1; i<=nItens; i++) {
- cItem = String(i);
- if (parseInt(i) < 10 ){cItem = "0"+String(i)};
-
- cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
- if(cItmOrc != "x") {
- cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
-
- if ($('#CK_PRODUTO'+cItem).val() == "" || $('#CK_QTDVEN'+cItem).val() == ""){
- lGridOK = false;
- }
- }
- }
-
- if (lGridOK == false){
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Verifique o preenchimento dos campos Produto e Quantidade antes de incluir uma nova linha!',
- type: 'error',
- });
- btnAdd.removeAttr('disabled');
-
- //Força fechar a janela
- if (lRet == false){
- bootbox.hideAll();
- }
- return false;
- }
- }
-
- //Cria a linha
- if (lRet == true) {
- if (linhaAtu.length < 2) {
- linhaAtu = "0" + linhaAtu;
- }
- // Carrega os campos do grid
- getFieldsGrid(aFields);
- var tbl = document.getElementById('datatable-editable'), // table reference
-
- row = tbl.insertRow(tbl.rows.length), // append table row
- i;
-
- // insert table cells to the new row
- for (i = 0; i < tbl.rows[0].cells.length; i++) {
- newCreateCell(row.insertCell(i), i, linhaAtu, tbl.rows[0].cells.length - 1, aFields[i]);
- }
- // Adiciona um ouvinte de eventos usando a delegação de eventos
- $(document).on('focusout', '[data-row] input', function () {
- // Captura o valor do campo CK_PRODUTO
- var produtoDigitado = this.value;
- // Obtém o numero da linha associado ao campo
- var linhaAtu = $(this).data('row');
- // Chama a função buscarProdutos
- buscarProdutos(produtoDigitado, function (listaProdutos) {
- // Aqui voce pode fazer algo com a lista de produtos, se necessario
- });
- });
- //Adiciona a classe no ultimo td
- $('tr:last').find('td:last').addClass('actions');
-
- //Adiciona id na linha
- $('tr:last').attr('id','linha'+linhaAtu);
- $('tr:last').attr('class','odd');
-
- //Atualiza a quantidade de linhas
- $("#PROXIMO").val(linhaAtu);
-
- //Habilita o botão para adicionar itens
- btnAdd.removeAttr('disabled');
- formate();
- };
- });
-
- //Obtém os campos da linha
- function getFieldsGrid(aFields) {
- let aExtras = [];
- /// Definicao de campos extras
- aExtras.push({"field": 'btnInfo',
- "element": "i",
- "attrs":[
- {"class": "fa fa-info fa-lg"},
- {"title": "Detalhes da linha"},
- {'onclick': 'detalheOrc($(this).attr("id").substr(-2))'}
- ]
- });
- aExtras.push({"field": 'btnExcl',
- "element": "i",
- "attrs":[
- {"class": "fa fa-times-circle fa-lg"},
- {"title": "Remover linha"},
- {'onclick': 'removeItem($(this).attr("id").substr(-2))'}
- ]
- });
- aExtras.push({"field": 'ALIQ_ICMS',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'ALIQ_IPI',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'ALIQ_ST',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'VAL_ICMS',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'VAL_IPI',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'VAL_ST',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'BASE_ICMS',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'BASE_ST',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'BASE_IPI',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'IMP_PRCTAB',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'QTD_EMB',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'CK_TES',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": ""}
- ]
- });
- aExtras.push({"field": 'QTDMIN',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'GRUPO',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": ""}
- ]
- });
- aExtras.push({"field": 'VENCIMENTO',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": ""}
- ]
- });
- /// Definicao de campos da tabela
- aFields.push({"field": 'CK_ITEM' ,
- "showtd": true,
- "element": "input",
- "attrs": [
- {"type": "text"},
- {"class": "form-control text-left input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ],
- "aftercreate": function(newLine) {
- $("#CK_ITEM"+newLine).val(newLine);
- }
- });
-
- aFields.push({"field": 'CK_PRODUTO',
- "showtd": true
- });
- aFields.push({"field": 'CK_QTDVEN' ,
- "showtd": true,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right only-numbers"},
- {"disabled": "disabled"},
- {"value": ""},
- {"placeholder": "0"},
- {'required': 'required'},
- {'aria-required': 'true'},
- {"onblur": 'javascript:VldQtd($(this).attr("id").substr(-2))'},
- {'onkeyup': 'javascript:TotalItem($(this).attr("id").substr(-2))'}
- ]
- });
- aFields.push({"field": 'CK_OBS' ,
- "showtd": true,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-left"},
- {"disabled": "disabled"},
- {"value": ""},
- {"maxlength": "80"}
- ]
- });
- aFields.push({"field": 'CK_PRZEMB' ,
- "showtd": true,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right"},
- {"disabled": "disabled"},
- {"value": ""},
- {"maxlength": "3"}
- ]
- });
- aFields.push({"field": 'CK_PRCVEN' ,
- "showtd": true,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'CK_XPRCIMP',
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'iCK_PRCVEN',
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right myformato"},
- {"disabled": "disabled"},
- {"value": ""},
- {"placeholder": "0"},
- {"onblur": 'javascript:VldValor($(this).attr("id").substr(-2))'},
- {'onkeyup': 'javascript:TotalItem($(this).attr("id").substr(-2))'},
- {'onkeypress': 'FormataValor(this,28,event,2,".",",") || return(moeda(this,'+"'.'"+','+"','"+',event))'}
- ]
- });
- aFields.push({"field": 'CK_CUSTO',
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right"},
- {"disabled": "disabled"}
- ]
- });
- // "aftercreate": "function x"
- aFields.push({"field": 'CK_XVALIPI',
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'CK_XVALICM',
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'CK_XICMST' ,
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
-
- aFields.push({"field": 'CK_DESCONT',
- "showtd": <%=cShowDesc%>,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right percentual"},
- {"disabled": "disabled"},
- {"value": ""},
- {"placeholder": "0,00"},
- {'maxlength': '7'},
- {"onblur": 'javascript:VldValor($(this).attr("id").substr(-2))'},
- {'onkeyup': 'javascript:TotalItem($(this).attr("id").substr(-2))'}
- ]
- });
- aFields.push({"field": 'CK_NOMDIRE',
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-left"},
- {"disabled": "disabled"},
- {"value": ""},
- {'maxlength': '12'}
- ]
- });
- aFields.push({"field": 'PER_COM' ,
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'VAL_COM' ,
- "showtd": false,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'CK_VALOR' ,
- "showtd": true,
- "element": "input",
- "attrs":[
- {"type": "text"},
- {"class": "form-control text-right input-block"},
- {"disabled": "disabled"},
- {"value": ""}
- ]
- });
- aFields.push({"field": 'botoes' ,
- "showtd": true,
- "element": "extras",
- "extras": aExtras
- });
- }
- // Criacao da linha da tabela
- function newCreateCell(objCell, ncol, newLine, nTam, objCrea) {
- // Criacao dos elementos
- if ("extras" !== objCrea["element"]) {
- if (objCrea["field"] == "CK_PRODUTO") {
- //icone de pesquisa
- let obji = document.createElement("i");
- obji.setAttribute("class","fa fa-search");
- obji.setAttribute("alt","Pesquisar");
- //botão do icone de pesquisa
- let objb = document.createElement("button");
- objb.setAttribute("class","btSearch");
- objb.setAttribute("id","btSearch"+newLine);
- objb.appendChild(obji); //apenda o icone no botão
- //input do produto
- let objinp = document.createElement("input");
- objinp.setAttribute("type","text");
- objinp.setAttribute("class","form-control smsediticon");
- objinp.setAttribute("placeholder","Digite o código ou descrição...");
- objinp.setAttribute("name","CK_PRODUTO" + newLine);
- objinp.setAttribute("id","CK_PRODUTO" + newLine);
- objinp.setAttribute("aria-required","true");
- objinp.setAttribute("data-live-search","true");
- objinp.setAttribute("autocomplete","off");
- objinp.setAttribute("value","");
- //div flexContainer
- let objDivFlex = document.createElement("div");
- objDivFlex.setAttribute("class","flexContainer");
- objDivFlex.appendChild(objinp);
- objDivFlex.appendChild(objb);
- //div com tamanho da coluna
- let objDivCol = document.createElement("div");
- objDivCol.setAttribute("class","col-md-12");
- objDivCol.appendChild(objDivFlex);
- //div principal
- let objDivForm = document.createElement("div");
- objDivForm.setAttribute("class","form-group");
- objDivForm.appendChild(objDivCol);
-
- objCell.appendChild(objDivForm);
- } else {
- let objElem = document.createElement(objCrea["element"]);
- objElem.setAttribute('id', objCrea["field"] + newLine);
- if ("input.select.".includes(objCrea["element"]+".")) {
- objElem.setAttribute('name', objCrea["field"] + newLine);
- }
- if (objCrea["attrs"]) {
- for (let attr of objCrea["attrs"]) {
- for (let [key, value] of Object.entries(attr)) {
- objElem.setAttribute(key, value);
- }
- }
- }
- if (objCrea["beforeadd"]) {
- objCrea["beforeadd"](objElem, newLine);
- }
- objCell.appendChild(objElem);
- if (objCrea["aftercreate"]) {
- objCrea["aftercreate"](newLine);
- }
- }
-
- } else {
- // Inclusao dos campos extras na ultima coluna
- for (let extra of objCrea["extras"]) {
- let objElem = document.createElement(extra["element"]);
- objElem.setAttribute('id', extra["field"] + newLine);
- if (extra["element"] == "input") {
- objElem.setAttribute('name', extra["field"] + newLine);
- }
- if (extra["attrs"]) {
- for (let attr of extra["attrs"]) {
- for (let [key, value] of Object.entries(attr)) {
- objElem.setAttribute(key, value);
- }
- }
- }
- objCell.appendChild(objElem);
- }
- }
- if (!objCrea.showtd) {
- $('tr:last').find('td:last').attr('hidden','');
- }
- }
- // Carrega parceiros ativos do AC4
- function carregarParceiros() {
- $.ajax({
- url: "U_GETPARC.apw?PR=<%=cLCodLogin%>",
- success: function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
- $("html").html(retorno);
- return;
- }
- if(retorno == "") {
- bootbox.alert("Falha ao carregar os parceiros, tente novamente!");
- return;
- }
-
- var combo = $("#cmbParceiro");
- combo.empty();
- combo.append(retorno);
- },
- error: function(xhr, status, error) {
- bootbox.alert("Erro ao carregar parceiros: " + error);
- }
- });
- }
- // Função para carregar a tabela de parceiros
- function carregarTabelaParceiros() {
- var numOrc = $("#CJ_NUM").val();
- if (!numOrc) return;
- $.ajax({
- url: "U_LISTPARC.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: { numOrc: numOrc },
- success: function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
- $("html").html(retorno);
- return;
- }
- $("#tblParceiros").html(retorno);
- }
- });
- }
- function openModel(parceiro, numOrc, rtpagar, rtaumentar, operacao) {
- $("#formParceiro")[0].reset();
- $("#cmbParceiro").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
- $("#cmbRTPagar").attr('readonly', false).removeAttr("style", "pointer-events: none;");;
- $("#txtRTAumentar").attr('readonly', true).attr("style", "pointer-events: none;");;
- if(operacao == 'edit'){
- $("#tituloIncPar")[0].childNodes[0].data = "Editar Parceiro"
- $("#cmbParceiro").attr('readonly', true).attr("style", "pointer-events: none;");;
- }else if(operacao == 'delete'){
- $("#tituloIncPar")[0].childNodes[0].data = "Excluir Parceiro"
- $("#cmbParceiro").attr('readonly', true).attr("style", "pointer-events: none;");;
- $("#cmbRTPagar").attr('readonly', true).attr("style", "pointer-events: none;");;
- $("#txtRTAumentar").attr('readonly', true).attr("style", "pointer-events: none;");;
- }
- $("#dialogParceiro").modal('show');
- $("#operacao").val(operacao)
- $("#cmbParceiro").val(parceiro);
- $("#cmbRTPagar").val(rtpagar);
- $("#txtRTAumentar").val(rtaumentar);
- }
- function adicionarParceiro(parceiro, rtpagar, rtaumentar, numOrc){
- var dialogSlv = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Salvando parceiro... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_ADDPARC.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: {
- parceiro: parceiro,
- rtpagar: rtpagar,
- rtaumentar: rtaumentar,
- numOrc: numOrc
- },
- // success: function(retorno) {
- // if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
- // alert("Erro ao salvar parceiro!");
- // $("html").html(retorno);
- // return;
- // }
- // bootbox.alert("Parceiro salvo com sucesso!");
- // location.reload();
- // }
- }).fail(function(){
- bootbox.alert({
- title: titulo,
- message: "Não foi possível adicionar o parceiro.",
- backdrop: true,
- callback: function (strXml) {
- dialogSlv.modal('hide');
- }
- });
- }).done(function(strXml) {
- if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(strXml);
- return;
- }
- if (strXml.toUpperCase().indexOf("NOK") != -1){
- bootbox.alert({
- title: "Cadastro de Parceiro",
- message: "Falha na inclusão de parceiro.",
- backdrop: true,
- callback: function (result) {
- dialogSlv.modal('hide');
- }
- });
- }
- else {
- bootbox.alert({
- title: "Cadastro de Parceiro",
- message: "Parceiro incluído com sucesso!",
- backdrop: true,
- callback: function (result) {
- carregarTabelaParceiros()
- $("#operacao").val('')
- dialogSlv.modal('hide');
- }
- });
-
- }
- });
- }
- // Função para editar parceiro
- function editarParceiro(parceiro, rtpagar, rtaumentar, numOrc) {
- var dialogSlv = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Editando parceiro... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_EDITPARC.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: {
- parceiro: parceiro,
- rtpagar: rtpagar,
- rtaumentar: rtaumentar,
- numOrc: numOrc
- },
- // success: function(response) {
- // if (response.success) {
- // // Atualiza a tabela
- // location.reload();
- // } else {
- // alert(response.message || "Erro ao salvar parceiro!");
- // }
- // }
- }).fail(function(){
- bootbox.alert({
- title: titulo,
- message: "Não foi possível editar o parceiro.",
- backdrop: true,
- callback: function (strXml) {
- dialogSlv.modal('hide');
- }
- });
- }).done(function(strXml) {
- if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(strXml);
- return;
- }
- if (strXml.toUpperCase().indexOf("NOK") != -1){
- bootbox.alert({
- title: "Cadastro de Parceiro",
- message: "Falha na edição de parceiro.",
- backdrop: true,
- callback: function (result) {
- dialogSlv.modal('hide');
- }
- });
- }
- else {
- bootbox.alert({
- title: "Cadastro de Parceiro",
- message: "Parceiro editado com sucesso!",
- backdrop: true,
- callback: function (result) {
- carregarTabelaParceiros()
- $("#operacao").val('')
- dialogSlv.modal('hide');
- }
- });
-
- }
- });
- }
- // Função para excluir parceiro
- function excluirParceiro(parceiro, numOrc) {
- bootbox.confirm({
- message: "Deseja realmente excluir este parceiro?",
- buttons: {
- confirm: {
- label: 'Sim',
- className: 'btn-success'
- },
- cancel: {
- label: 'Não',
- className: 'btn-danger'
- }
- },
- callback: function (result) {
- if (result) {
- var dialogSlv = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Excluindo parceiro... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_DELPARC.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: { parceiro: parceiro, numOrc: numOrc},
- // success: function(retorno) {
- // if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
- // $("html").html(retorno);
- // return;
- // }
- // bootbox.alert("Parceiro excluído com sucesso!");
- // }
- }).fail(function(){
- bootbox.alert({
- title: titulo,
- message: "Não foi possível excluir o parceiro.",
- backdrop: true,
- callback: function (strXml) {
- dialogSlv.modal('hide');
- }
- });
- }).done(function(strXml) {
- if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(strXml);
- return;
- }
- if (strXml.toUpperCase().indexOf("NOK") != -1){
- bootbox.alert({
- title: "Cadastro de Parceiro",
- message: "Falha na exclusão de parceiro.",
- backdrop: true,
- callback: function (result) {
- dialogSlv.modal('hide');
- }
- });
- }
- else {
- bootbox.alert({
- title: "Cadastro de Parceiro",
- message: "Parceiro excluído com sucesso!",
- backdrop: true,
- callback: function (result) {
- $("#operacao").val('')
- carregarTabelaParceiros()
- dialogSlv.modal('hide');
- }
- });
-
- }
- });
- }
- }
- });
- }
- function atualizaRT(value){
- var rtaumentar = $("#txtRTAumentar");
- switch (value) {
- case '3':
- rtaumentar.val('5')
- break;
- case '5':
- rtaumentar.val('8.5')
- break;
- case '7':
- rtaumentar.val('12')
- break;
- case '10':
- rtaumentar.val('19')
- break;
-
- default:
- rtaumentar.val('')
- break;
- }
- }
-
- //Salvar o orçamento
- $('#btSalvar').click(function() {
- var lRet = true
- var i = 0;
- var nItens = parseFloat($("#PROXIMO").val());
- var lGrid = true;
- var lGrid1 = true;
- var cCodProd;
- var cItmOrc;
- var btnSlv = $(this);
- var cGrupo = "";
- var dialogOrc = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Validando orçamento. Aguarde...</p>',
- closeButton: false
- });
- //Desabilita o botao
- btnSlv.attr({ 'disabled': 'disabled' });
-
- $.ajax({
- url: "U_VerSessao.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
- if (retorno == "nok"||retorno == ''||retorno.toUpperCase().indexOf("EXPIRES") != -1){
- $("#orc-informar").html();
- bootbox.alert('Não foi possível realizar a operação pois a sessão foi fechada. Faça login novamente.');
- lRet = false;
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- }
- }
- });
-
- /**
- Valida os campos obrigatorios
- **/
- //Cliente
- cliente = formataCli($("#CJ_CLIENTE").val());
- if (cliente == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Cliente!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_CLIENTE").focus();
- }
-
- /**
- Valida os campos obrigatorios
- **/
- //Cliente
- cliente = formataCli($("#CJ_CLIENTE").val());
- if (cliente == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Cliente!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_CLIENTE").focus();
- }
- //Contato do Cliente
- if (lRet == true && $("#CJ_XCONTAT").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Contato do Cliente!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_XCONTAT").focus();
- }
- //Contato do Cliente - DDD
- if (lRet == true && $("#CJ_XCONDDD").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo DDD do Contato!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_XCONDDD").focus();
- }
- //Contato do Cliente - Telefone
- if (lRet == true && $("#CJ_XCONTEL").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Telefone do Contato!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_XCONTEL").focus();
- }
- //Cliente de entrega
- if (lRet == true && $("#CJ_CLIENT").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Cliente de Entrega!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_CLIENT").focus();
- }
- //Tabela de preço
- if (lRet == true && $("#CJ_TABELA").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Falha ao localizar a Tabela de Preço!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_TABELA").focus();
- }
-
- //Data de Entrega
- /*
- if (lRet == true && $("#CK_ENTREG").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Previsão de Faturamento!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CK_ENTREGA").focus();
- }
- */
-
- //Condição de pagamento
- if (lRet == true && $("#CJ_CONDPAG").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Condição de Pagamento!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_CONDPAG").focus();
- }
- //Oportunidade
- if (lRet == true && $("#CJ_NROPOR").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Oportunidade!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_NROPOR").focus();
- }
-
- //Nome da Obra
- if (lRet == true && $("#CJ_OBRA").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Nome da Obra!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_OBRA").focus();
- }
- //Tipo da Obra
- if (lRet == true && $("#CJ_YOBRATP").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Tipo da Obra!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_YOBRATP").focus();
- }
- //Status da obra
- if (lRet == true && $("#CJ_VEND6").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Status da Obra!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_VEND6").focus();
- }
- //Previsão de fechamento
- if (lRet == true && $("#CJ_TERMOME").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Previsão de Fechamento!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_TERMOME").focus();
- }
- //Estudo luminotécnico
- if (lRet == true && $("#CJ_LUMINOT").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Estudo Luminotécnico!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_LUMINOT").focus();
- } else {
- if($("#CJ_LUMINOT").val() == "1"){
- if($("#CJ_REGLUMI").val() == ""){
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Número do Estudo Luminotécnico!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_REGLUMI").focus();
- }
- }
- }
-
- //Segmento
- if (lRet == true && $("#CJ_SEGMENT").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Segmento!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_SEGMENT").focus();
- }
- //Regional
- if (lRet == true && $("#CJ_REGIAO").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Regional!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_REGIAO").focus();
- }
- //Vendedor 2
- if (lRet == true && $("#CJ_VEND").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Vendedor 2!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_VEND").focus();
- }
- //Negociadora
- if (lRet == true && $("#CJ_VEND7").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Negociadora!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_VEND7").focus();
- }
- //Frete
- if (lRet == true && $("#CJ_FRETE").val() != "") {
-
- cTpFrete = $("#CJ_TPFRETE").val();
- nTotalOrc = $("#TOTAL_ITENS").maskMoney('unmasked')[0];
- freteMinimo = $("#FRETEMIN").val();
- ufEntrega = $("#CJ_UFENT").val().substr(0,2);
- munEntrega = $("#CJ_UFENT").val().substr(1,5);
- if (freteMinimo != ""){
-
- if(nTotalOrc <= freteMinimo && (cTpFrete == "C" || cTpFrete == "")){
- $.ajax({
- url: "U_FreteMinimo.apw?PR=<%=cLCodLogin%>",
- data: 'UFEnt='+ufEntrega+'&MunEntrega='+munEntrega,
- type: "POST",
- async: false,
- success:
- function(frete) {
- if (frete.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(frete);
- return;
- } else {
- if (parseInt(frete) > 0) {
- $("#CJ_FRETE").val(frete);
- TotalGeral();
- }
- }
- }
- });
- } else {
- $("#CJ_FRETE").val(0);
- }
- }
- }
-
- //Grid
- if (lRet == true) {
- var nPrcTab = 0;
- var nPrcVen = 0;
- var lVencido = false;
- var lItmBlq = false;
- var cGrpEsp = 'PE,PEL,PED,PI';
- var cMsLumEspL = '';
- for (i = 1; i<=nItens; i++) {
- cItem = String(i);
- if (parseInt(i) < 10 ){cItem = "0"+String(i)};
-
- cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
- if(lItmBlq==false){
- lItmBlq = $("#CK_ITEM"+cItem).val() == "xx";
- }
- if(cItmOrc != "x") {
- cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
- qtd = parseFloat($("#CK_QTDVEN"+cItem).val().replace('.',"").replace(",","."));
- nTotalOrc = $("#CK_TOTAL"+cItem).val();
- //nPrcTab += $("#iCK_PRCVEN"+cItem).val().replace('.',"").replace(",",".") * qtd;
- //nPrcVen += $("#CK_PRCVEN"+cItem).val().replace('.',"").replace(",",".") * qtd;
-
- nPrcTab += $("#iCK_PRCVEN"+cItem).maskMoney('unmasked')[0] * qtd;
- nPrcVen += $("#CK_PRCVEN"+cItem).maskMoney('unmasked')[0] * qtd;
-
- //Valida o preenchimento dos campos produto e quantidade
- if (cCodProd == "" || $('#CK_QTDVEN'+cItem).val() == "" || nTotalOrc == ""){
- lGrid = false;
- } else {
- cGrupo = $("#GRUPO"+cItem).val();
- vencido = $("#VENCIMENTO"+cItem).val();
-
- //Valida itens de grupos especiais
- if(cGrpEsp.includes(cGrupo) && vencido == '1' ){
- lVencido = true;
- cMsLumEspL += cItmOrc+';'+cCodProd+';'+$("#CK_QTDVEN"+cItem).val()+'|'
- }
-
- }
- }
- }
- if (lGrid == false){
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Verifique o preenchimento dos campos Produto, Quantidade e Valor!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- } else {
- $.ajax({
- url: "U_VldDscMax.apw?PR=<%=cLCodLogin%>",
- data: 'vlrTabela='+nPrcTab+'&vlrVenda='+nPrcVen+'&condpag='+$("#CJ_CONDPAG").val()+"&descDir="+$('#CJ_DSDIRET').val(),
- cache: false,
- type: "POST",
- async: false,
- success:
- function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0 ) {
- $("html").html(retorno);
- return;
- }
- if (retorno.substr(0, 3) == "NOK"){
- aDesc = retorno.split('|#|');
- cMsg = "O orçamento excedeu a Política de Descontos. Entre em contato com a Supervisão ou Diretoria.<br>";
- cMsg += "Desconto concedido: <b>"+aDesc[0].substr(4)+"</b><br>";
- cMsg += "Desconto máximo permitido: <b>"+aDesc[1]+"</b>";
- bootbox.alert(cMsg);
- lRet = false;
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- }
- }
- });
- }
- }
-
- //Verifica os itens especiais vencidos antes de salvar o formulário
- if(lRet == true && lVencido){
- msg = 'Existem códigos especiais com preços desatualizados. <br>';
- msg += 'Deseja enviar e-mail solicitando atualização?';
-
- bootbox.confirm({
- title: 'Códigos especiais',
- message: "<p>"+msg+"</p>",
- backdrop: true,
- buttons: {
- cancel: {
- label: 'Não'
- },
- confirm: {
- label: 'Sim'
- }
- },
- callback: function (result) {
- if (result){
- filorc = $("#CJ_FILIAL").val();
- numorc = $("#CJ_NUM").val();
- obra = $("#CJ_OBRA").val();
- //Chama a função para envio de email
- $.ajax({
- url: "U_AtuPreco.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: 'filial='+filorc+'&orcto='+numorc+'&obra='+obra+'&itens='+cMsLumEspL,
- async: false
- });
- }
- }
- });
- }
-
- //Salva o orçamento
- if (lRet == true){
- dialogOrc.modal('hide');
- if (lItmBlq == true){
- bootbox.confirm({
- title: "Produto Bloqueado",
- message: "Um ou mais produtos do orçamento estão bloqueados e não serão salvos.",
- buttons: {
- confirm: {
- label: 'OK'
- },
- camcel:{
- label: 'Cancelar'
- }
- },
- callback: function (result) {
- if (result){
- //Submete o formulário
- salvarOrc(btnSlv);
- }
- }
- });
- } else {
- //Submete o formulário
- salvarOrc(btnSlv);
- }
- }
- })
-
-
- //Submete formulario
- function salvarOrc(btnSlv){
- var numorc = "";
-
- //if (lRet == true){
-
- var dialogSlv = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Salvando orçamento... Aguarde...</p>',
- closeButton: false
- });
-
- //busca os itens cadastrados
- var ITENS = "";
- var i = 0;
- var nItens = parseFloat($("#PROXIMO").val());
- var cCodProd;
- var cItmOrc;
- var cDescAcresc = "0";
-
- for (i = 1; i<=nItens; i++) {
- cItem = String(i);
- if (parseInt(i) < 10 ){cItem = "0"+String(i)};
-
- cCodProd = formataProd($("#CK_PRODUTO"+cItem).val());
- cItmOrc = $("#CK_ITEM"+cItem).val().substr(0,1);
- if(cItmOrc != "x") {
- cPrcVen = $('#CK_PRCVEN'+cItem).val();
-
- ITENS+= formataProd($('#CK_PRODUTO'+cItem).val())+';'; //1
- ITENS+= $('#CK_QTDVEN'+cItem).val()+';'; //2
- ITENS+= $('#CK_OBS'+cItem).val()+';'; //3
- ITENS+= $('#CK_PRZEMB'+cItem).val()+';'; //4
- ITENS+= cPrcVen+';'; //5
- ITENS+= $('#CK_XPRCIMP'+cItem).val()+';'; //6
- ITENS+= $('#CK_XVALIPI'+cItem).val()+';'; //7
- ITENS+= $('#CK_XVALICM'+cItem).val()+';'; //8
- ITENS+= $('#CK_XICMST'+cItem).val()+';'; //9
- ITENS+= $('#ALIQ_ICMS'+cItem).val()+';'; //10
- ITENS+= $('#ALIQ_IPI'+cItem).val()+';'; //11
- ITENS+= $('#ALIQ_ST'+cItem).val()+';'; //12
- ITENS+= $('#CK_TES'+cItem).val()+';'; //13
- ITENS+= $('#CK_CUSTO'+cItem).val()+';'; //14
- ITENS+= $('#CK_NOMDIRE'+cItem).val()+';'; //15
- ITENS+= $('#PER_COM'+cItem).val()+';'; //16
- ITENS+= $('#VAL_COM'+cItem).val()+';'; //17
- ITENS+= $('#CK_DESCONT'+cItem).val()+'||' //18
-
- }
- }
-
- objDados = {
- CJ_FILIAL: $('#CJ_FILIAL').val(),
- CJ_NUM: $('#CJ_NUM').val(),
- RECCJANT: $('#RECCJANT').val(),
- CJ_CLIENTE: formataCli($('#CJ_CLIENTE').val()),
- CJ_TABELA: $('#CJ_TABELA').val(),
- CJ_NROPOR: $('#CJ_NROPOR').val(),
- CJ_REVISA: $('#CJ_REVISA').val(),
- CJ_XCONTAT: $('#CJ_XCONTAT').val(),
- CJ_XCONDDD: $('#CJ_XCONDDD').val(),
- CJ_XCONTEL: $('#CJ_XCONTEL').val(),
- CJ_CLIENT: $('#CJ_CLIENT').val(),
- CJ_UFENT: $('#CJ_UFENT').val(),
- CJ_OBRA: $('#CJ_OBRA').val(),
- CJ_YOBRATP: $('#CJ_YOBRATP').val(),
- CJ_VEND6: $('#CJ_VEND6').val(),
- CJ_TERMOME: $('#CJ_TERMOME').val(),
- CJ_CONDPAG: $('#CJ_CONDPAG').val(),
- CJ_CLIINTE: $('#CJ_CLIINTE').val(),
- CJ_RETORNO: $('#CJ_RETORNO').val(),
- CJ_LUMINOT: $('#CJ_LUMINOT').val(),
- CJ_REGLUMI: $('#CJ_REGLUMI').val(),
- CJ_SEGMENT: $('#CJ_SEGMENT').val(),
- CJ_PROPECC: $('#CJ_PROPECC').val(),
- CJ_PROSCOD: $('#CJ_PROSCOD').val(),
- CJ_REGIAO: $('#CJ_REGIAO').val(),
- CJ_VEND: $('#CJ_VEND').val(),
- CJ_VEND3: $('#CJ_VEND3').val(),
- CJ_VEND4: $('#CJ_VEND4').val(),
- CJ_CODESP: $('#CJ_CODESP').val(),
- CJ_VEND7: $('#CJ_VEND7').val(),
- CJ_VALIDA: $('#CJ_VALIDA').val(),
- CJ_PRZEMB: $('#CJ_PRZEMB').val(),
- CJ_TPFRETE: $('#CJ_TPFRETE').val(),
- CJ_PERCFRT: $('#CJ_PERCFRT').val(),
- CJ_FRETE: $('#CJ_FRETE').val(),
- CJ_COMISTR: $('#CJ_COMISTR').val(),
- CJ_OBS: $('#CJ_OBS').val(),
- CJ_DSDIRET: $('#CJ_DSDIRET').val(),
- PROXIMO: $('#PROXIMO').val(),
- OPCAO: $('#OPCAO').val(),
- aItens: ITENS
- };
-
-
- if($("#OPCAO").val() == "3"){
- msg = "O orçamento foi incluído com sucesso.";
- titulo = "Inclusão de Orçamento";
- operacao = "incluir";
- }
- if($("#OPCAO").val() == "4"){
- msg = "O orçamento foi alterado com sucesso.";
- titulo = "Alteração de Orçamento";
- operacao = "alterar";
- }
- if($("#OPCAO").val() == "5"){
- msg = "O orçamento foi excluído com sucesso.";
- titulo = "Exclusão de Orçamento";
- operacao = "excluir";
- }
-
-
- $.ajax({
- type: "POST",
- url: "U_SlvOrc.apw?PR=<%=cLCodLogin%>",
- async: false,
- data: objDados
-
- }).fail(function(){
- bootbox.alert({
- title: titulo,
- message: "Não foi possível "+operacao+" o orçamento.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- dialogSlv.modal('hide');
- }
- });
- }).done(function(strXml) {
- if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(strXml);
- return;
- }
- if (strXml == 'erro'||strXml == ''||strXml.toUpperCase().indexOf("EXPIRES") != -1||strXml.toUpperCase().indexOf("INVALID") != -1){
- if (strXml == ''){
- bootbox.alert({
- title: titulo,
- message: "Aguarde o prazo de 3 minutos para "+operacao+" um novo orçamento.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- dialogSlv.modal('hide');
- }
- });
- }else{
- bootbox.alert({
- title: titulo,
- message: "Falha ao "+operacao+" o orçamento.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- dialogSlv.modal('hide');
- }
- });
- }
- }
- else {
- if($("#OPCAO").val() == "3"){
- numorc = " Foi gerado o orçamento nº "+strXml+"."
- }
- bootbox.alert({
- title: titulo,
- message: msg+numorc,
- backdrop: true,
- callback: function (result) {
- document.location.href = "U_Orcamento.apw?PR=<%=cLCodLogin%>";
- dialogSlv.modal('hide');
- }
- });
-
- }
- });
-
- //};
-
- }
-
- $('#btExcluir').click(function() {
- var lRet = true
- var i = 0;
- var lGrid = true;
- var cCodProd;
- var btnSlv = $(this);
-
- //Desabilita o botao
- $('#btExcluir').attr({ 'disabled': 'disabled' });
-
- objDados = {
- CJ_CLIENTE: formataCli($('#CJ_CLIENTE').val()),
- CJ_NUM: $('#CJ_NUM').val()
- };
-
- $.ajax({
- type: "POST",
- url: "U_ExcOrc.apw?PR=<%=cLCodLogin%>",
- async: false,
- data: objDados
-
- }).fail(function(){
- bootbox.alert({
- title: "Exclusão de Orçamento",
- message: "Não foi possível excluir o orçamento.",
- backdrop: true,
- callback: function (result) {
- btnSlv.removeAttr('disabled');
- }
- });
- }).done(function(strXml) {
- if (strXml.indexOf('<META HTTP-EQUIV') >= 0 ) {
- $("html").html(strXml);
- return;
- }
- bootbox.alert({
- title: "Exclusão de Orçamento",
- message: "O orçamento "+$('#CJ_NUM').val()+" foi excluído com sucesso.",
- backdrop: true,
- callback: function (result) {
- document.location.href = "U_Orcamento.apw?PR=<%=cLCodLogin%>";
- }
- });
- });
- })
- </script>
- </body>
- </html>
|