12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766 |
- <%
- /**** 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-margem" data-toggle="tab" class="text-center">Margem de Contribuição</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>'
- cTab += '<li class="">'
- cTab += ' <a href="#orc-etapas" data-toggle="tab" class="text-center" >Etapas</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
- <span class="required">*</span>
- </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>
- -->
- <!-- aba margem -->
- <div class="tab-pane" id="orc-margem">
- <div class="panel panel-default">
-
- <div class="panel-body">
- <div class="form-inline" align="center">
- <div class="row">
- <div class="col-sm-12">
-
- <div class="row form-group">
-
- <div class="col-md-3">
- <label class="">% Margem de Contribuição do Orçamento </label>
- <input class="form-control text-right" id="MARGEM_ORC" name="MARGEM_ORC" placeholder="0,00" disabled="" type="text" value=<%=Transform(nMargem,"@E 999,999,999,999.99")%>></input>
- </div>
-
- <div class="col-md-3">
- <label class="">% Margem de Contribuição - Luminarias </label>
- <input class="form-control text-right" id="MARGEM_LUMI" name="MARGEM_LUMI" placeholder="0,00" disabled="" type="text" value=<%=Transform(nMLuminaria,"@E 999,999,999,999.99")%>></input>
- </div>
- <div class="col-md-3">
- <label class="">% Margem de Contribuição - Equipamentos </label>
- <input class="form-control text-right" id="MARGEM_EQUIP" name="MARGEM_EQUIP" placeholder="0,00" disabled="" type="text" value=<%=Transform(nMEquipa,"@E 999,999,999,999.99")%>></input>
- </div>
- <div class="col-md-3">
- <label class="">% Margem de Contribuição - Painel LED </label>
- <input class="form-control text-right" id="MARGEM_PAINEL" name="MARGEM_PAINEL" placeholder="0,00" disabled="" type="text" value=<%=Transform(nMPainel,"@E 999,999,999,999.99")%>></input>
- </div>
- </div>
- </div>
- </div>
- </div>
- <br>
- <br>
- <section class="panel">
- <header class="panel-heading">
- <h2 class="panel-title">Itens do Orçamento</h2>
- </header>
- <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 width="150px">Item</th>
- <th>Produto</th>
- <th width="150px">Tipo</th>
- <th width="150px">% Mark-Up</th>
- <th width="250px">% Margem Contribuição</th>
- </tr>
- </thead>
- <tbody id="tblItemMargem">
- <%=cMgItens%>
- </tbody>
- </table>
- </div>
- </section>
- </div>
- </div>
- </div>
- <!-- aba parceiros -->
-
- <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 class="tab-pane" id="orc-etapas">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Etapas da Nogiação</h3>
- </div>
- <div class="panel-body">
- <button type="button" class="btn btn-primary" id="btnIncluirNeg">
- <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>Data</th>
- <th>Hora</th>
- <th>Usuário</th>
- <th>Histórico</th>
- </tr>
- </thead>
- <tbody id="tblNegociacao">
- </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>
-
- <!-- Modal Incluir Etapa -->
- <div class="modal fade" id="dialogEtapas" 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="tituloIncEtap">Incluir Etapa</h4>
- </div>
- <div class="modal-body">
- <form id="formEtapa" 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 da Etapa
- </div>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">Data</label>
- <div class="col-sm-9">
- <input type="text" class="form-control" name="dataEtapa" id="dataEtapa" value="" disabled/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">Hora</label>
- <div class="col-sm-9">
- <input type="text" class="form-control" name="horaEtapa" id="horaEtapa" value="" disabled/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">Usuário</label>
- <div class="col-sm-9">
- <input type="text" class="form-control" name="usuEtapa" id="usuEtapa" value="<%=cCodLogin%>" disabled/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label">Histórico</label>
- <div class="col-sm-9">
- <textarea maxlenght="100" class="form-control" name="descriEtapa" id="descriEtapa" value=""></textarea>
- </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="btnSalvarEtapa">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%>';
- var optInter = '<%=cOptInter%>';
- /**
- 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');
- });
- // Evento do botão incluir
- $("#btnIncluirNeg").click(function() {
- $("#dataEtapa").val(new Date().toLocaleDateString('pt-BR'));
- $("#horaEtapa").val(new Date().toLocaleTimeString('pt-BR'));
- $("#descriEtapa").val("");
-
- $("#dialogEtapas").modal('show');
- });
- carregarTabelaParceiros()
- carregarTabelaNegociacao()
- // 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');
- });
- $("#btnSalvarEtapa").click(function() {
- var descricao = $("#descriEtapa").val();
- var numOrc = $("#CJ_NUM").val();
- if (descricao == "") {
- alert("Informe uma descrição");
- return;
- }
- adicionarEtapa(descricao, numOrc);
- $("#dialogEtapas").modal('hide');
- });
- // 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 intermediador
- if($("#CJ_CLIINTE")[0].options.length <= 2){
- $("#CJ_CLIINTE").append($.parseHTML(optInter));
- }
- $('.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 endereço de entrega. 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());
- var nComis = 0;
- 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[18]+"</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]));
- //Comissão
- $.trim($("input[name='B1_COMIS"+nItem+"']").val(aVlr[21]));
- atuComis(nItem);
-
- //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;
- }
- /**
- Atualiza a comissão do item
- **/
- function atuComis(cItem){
- var nComisRT = parseFloat($('#CJ_COMISTR').val().replace(",","."));
- var nComisB1 = parseFloat($('#B1_COMIS'+cItem).val().replace(",","."));
- var cVend3 = $("#CJ_VEND3").val();
- var nComis = 0;
- if(cVend3 != ""){
- nComis = nComisB1/2;
- } else {
- nComis = nComisB1;
- }
-
- if(nComisRT > 0){
- nComis = (nComis / ((100 + nComisRT)/100))
- }
-
- $.trim($("input[name='CK_COMIS1"+cItem+"']").val(nComis));
- $.trim($("input[name='CK_COMIS3"+cItem+"']").val(nComis));
-
- }
- /**
- 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();
- //Atualiza a margem de contribuição
- atuComis(cItemAtu);
- atuMargem();
- }
-
- /**
- 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 a margem de contribuição
- **/
- function atuMargem() {
- var nItens = parseFloat($("#PROXIMO").val());
- var i;
- var nMC_T = 0;
- var nMCTotIt = 0;
- var nMC_L = 0;
- var nMCTotIt_L = 0;
- var nMC_E = 0;
- var nMCTotIt_E = 0;
- var nMC_P = 0;
- var nMCTotIt_P = 0;
- var nMLuminaria = 0;
- var nMEquipa = 0;
- var nMPainel = 0;
- var cTR = "";
- var dialogProd = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Calculando margem... Aguarde...</p>',
- closeButton: false
- });
- cCliente = $("#CJ_CLIENT").val();
- cCodVend = $("#CJ_VEND").val();
- cTpFrete = $("#CJ_TPFRETE").val();
- nPerFrete = parseFloat($("#CJ_PERCFRT").val().replace(",","."));
- nComisRT = parseFloat($('#CJ_COMISTR').val().replace(",","."));
-
- 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();
- if(cItmOrc.substr(0,1) != "x") {
- nCusto = $('#CK_CUSTO'+cItem).maskMoney('unmasked')[0];
- nValor = $('#CK_VALOR'+cItem).maskMoney('unmasked')[0];
- nQtd = $('#CK_QTDVEN'+cItem).val();
- cTes = $("#CK_TES"+cItem).val();
- nComis2 = parseFloat($('#CK_COMIS1'+cItem).val().replace(",","."));
-
- if( $("#CJ_VEND3").val() != ""){
- nComis3 = parseFloat($('#CK_COMIS3'+cItem).val().replace(",","."));
- //nComis3 = nComis2
- }
-
- total = $("#TOTAL_ITENS").maskMoney('unmasked')[0];
- //Chama função para calculo dos impostos
- jQuery.ajax({
- type: "POST",
- url: "U_MARGEMPT.APW?PR=<%=cLCodLogin%>",
- data: 'item='+cItmOrc+'+&produto='+encodeURIComponent(cCodProd)+'&tes='+cTes+'&cliente='+cCliente+'&custo='+nCusto+'&qtd='+nQtd+'&valor='+nValor+'&vendedor='+cCodVend+'&comis2='+nComis2+'&comis3='+nComis3+'&RT='+nComisRT+'&tpfrete='+cTpFrete+'&perfrete='+nPerFrete+'&total='+total+'&mct='+nMC_T+'&mcit='+nMCTotIt,
- error: function (jqXHR, textStatus, error){
- dialogProd.modal('hide');
- bootbox.alert("Falha ao recuperar informações!");
- console.log(error);
- },
- success: function( data ) {
- if (data.substr(0, 2) == "OK") {
- aMargem = data.substr(3).split('|#|');
- cTR+= aMargem[0];
- nMC_T+= parseFloat(aMargem[1].replace(".","").replace(",","."));
- nMCTotIt+= parseFloat(aMargem[2].replace(".","").replace(",","."));
- nMC_L+= parseFloat(aMargem[3].replace(".","").replace(",","."));
- nMCTotIt_L+= parseFloat(aMargem[4].replace(".","").replace(",","."));
- nMC_E+= parseFloat(aMargem[5].replace(".","").replace(",","."));
- nMCTotIt_E+= parseFloat(aMargem[6].replace(".","").replace(",","."));
- nMC_P+= parseFloat(aMargem[7].replace(".","").replace(",","."));
- nMCTotIt_P+= parseFloat(aMargem[8].replace(".","").replace(",","."));
- if(i>=nItens){
- //atualiza a tela
- if(nMCTotIt_L>0){
- nMLuminaria = (nMC_L / nMCTotIt_L)*100;
- }
- if(nMCTotIt_E>0){
- nMEquipa = (nMC_E / nMCTotIt_E)*100;
- }
- if(nMCTotIt_P>0){
- nMPainel = (nMC_P / nMCTotIt_P)*100;
- }
- $("#MARGEM_ORC").val(mascaraValor(nMC_T.toFixed(2)));
- $("#MARGEM_LUMI").val(mascaraValor(nMLuminaria.toFixed(2)));
- $("#MARGEM_EQUIP").val(mascaraValor(nMEquipa.toFixed(2)));
- $("#MARGEM_PAINEL").val(mascaraValor(nMPainel.toFixed(2)));
- //recarrega a tabela
- $("#tblItemMargem").html(cTR);
- dialogProd.modal('hide');
- }
- }
- }
- });
- }
- }
- }
- /**
- 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");
- if(cFrete == 'F'){
- bootbox.alert("Informar a equipe do ativo sobre as regras de expedição para frete FOB.")
- }
- } 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
- $('#datatable-editable tr:last').find('td:last').addClass('actions');
-
- //Adiciona id na linha
- $('#datatable-editable tr:last').attr('id','linha'+linhaAtu);
- $('#datatable-editable 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": ""}
- ]
- });
- aExtras.push({"field": 'B1_COMIS',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'CK_COMIS1',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- aExtras.push({"field": 'CK_COMIS3',
- "element": "input",
- "attrs":[
- {"type": "hidden"},
- {"value": "0"}
- ]
- });
- /// 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) {
- $('#datatable-editable tr:last').find('td:last').attr('hidden','');
- //$('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);
- }
- });
- }
- // Função para carregar a tabela de parceiros
- function carregarTabelaNegociacao() {
- var numOrc = $("#CJ_NUM").val();
- if (!numOrc) return;
- $.ajax({
- url: "U_LISTNEG.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: { numOrc: numOrc },
- success: function(retorno) {
- if (retorno.toUpperCase().indexOf('META HTTP-EQUIV') >= 0) {
- $("html").html(retorno);
- return;
- }
- $("#tblNegociacao").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;
- }
- }
- function adicionarEtapa(descricao, numOrc){
- var dialogSlv = bootbox.dialog({
- message: '<p class="text-center"><i class="fa fa-spin fa-spinner"></i> Salvando Etapa... Aguarde...</p>',
- closeButton: false
- });
- $.ajax({
- url: "U_ADDETAPA.apw?PR=<%=cLCodLogin%>",
- type: "POST",
- data: {
- cdescricao: descricao,
- corcamento: 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 a etapa.",
- 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 Etapa",
- message: "Falha na inclusão da etapa.",
- backdrop: true,
- callback: function (result) {
- dialogSlv.modal('hide');
- }
- });
- }
- else {
- bootbox.alert({
- title: "Cadastro de Etapa",
- message: "Etapa incluído com sucesso!",
- backdrop: true,
- callback: function (result) {
- carregarTabelaNegociacao()
- dialogSlv.modal('hide');
- }
- });
-
- }
- });
- }
-
- //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();
- }
- //Local de entrega
- if (lRet == true && $("#CJ_UFENT").val() == "") {
- lRet = false;
-
- $("#orc-informar").html();
- new PNotify({
- title: 'Campo obrigatório',
- text: 'Preencha o campo Local de Entrega!',
- type: 'error',
- });
- btnSlv.removeAttr('disabled');
- dialogOrc.modal('hide');
- $("#CJ_UFENT").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'
- },
- cancel:{
- 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>
|