Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.form.viewer.js 454KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class SubForm {
  8. constructor() {
  9. this.Index = 0;
  10. }
  11. init(formpropertyid, prop, callback) {
  12. var instance = SubForm.Instance();
  13. }
  14. loadControl(containerid, prop) {
  15. var ControlJsonText = JSON.parse(prop.ControlJsonText);
  16. var html = '';
  17. var parentPkid = Unibase.Platform.Forms.Components.FormViewer.instance.Pk_Value;
  18. html = '<div class="divSubForm" class="SubformInstalledAppId" data-subforminstalledappid="' + ControlJsonText.InstalledAppId + '"><input type="hidden" id="SubformInstalledAppId_' + prop.FormPropertyId + '" value="' + ControlJsonText.InstalledAppId + '" ><div class="divNextSubForm_' + prop.UniqueId + ' hidden"></div><div class="divNextSubFormList_' + prop.UniqueId + ' divCheckRequired"><div class="subformControlData"></div><div class="subformBtnContainer text-center"></div><div class="subformTableDataList"></div></div></div>';
  19. if (ControlJsonText.EnableSubFormSettings == true) {
  20. html += '<div class="col-sm-3 div_SubFormdetails" id="div_subformsettings">' +
  21. '<a href="javascript:;" class="btn btn-success text-white btnAddSubForm btnSubform_' + prop.UniqueId + '" id="btnAddSubForm_' + prop.UniqueId + '" data-subformcount="0" data-islistsubform="false" /><span>' + ControlJsonText.ButtonName + '</span></a>' +
  22. '</div>';
  23. }
  24. $("#" + containerid).html(html);
  25. if (ControlJsonText.EnableSubFormSettings == true) {
  26. $("#btnAddSubForm_" + prop.UniqueId).click(function () {
  27. var childformdata = ControlJsonText.FormInfo;
  28. Unibase.Forms.Controls.SubForm.Instance().addButtonClick(childformdata, prop.UniqueId, ControlJsonText.SubFormName, ControlJsonText.ChildFormId, 0);
  29. });
  30. var html = '<div class="divSubFormUl loadfirstsubformdata hidden divNextSubForm_' + prop.UniqueId + ' divNextSubForm_' + prop.FormPropertyId + ' divNextSubForm_' + prop.UniqueId + '_0"><div class="card-header"><span class="pull-left">' + ControlJsonText.SubFormName + '-0' + '</span><a class="ml-auto btn-xs pull-right btn btn-icon btn-icon-circle btn-pink btn-icon-style-3 remove-icon_' + prop.FormPropertyId + '" href="javascript:;" title="Remove row" onclick="Unibase.Forms.Controls.SubForm.Instance().SubFormRemove(' + prop.FormPropertyId + ",0,\'" + ControlJsonText.SubFormName + '\');"><span class="btn-icon-wrap"><i class="fa fa-times remove-icon_ ' + prop.FormPropertyId + '"></i><span></span></span></a></div><div class="card-body divSubForm_' + prop.UniqueId + '" id="divSubForm_' + prop.UniqueId + '"></div></div>';
  31. $(".divNextSubForm_" + prop.UniqueId).after(html);
  32. var childformdata = ControlJsonText.FormInfo;
  33. if (childformdata == undefined) {
  34. Unibase.Platform.Forms.Managers.FormManager.Instance().getForm(ControlJsonText.ChildFormId).then(function (response) {
  35. var forminfo = response.result;
  36. var formviewerObj = {
  37. FormId: 0,
  38. AppConfigurationId: 0,
  39. Pk_Value: 0,
  40. PortletWidgetId: 0,
  41. OnSuccess: null,
  42. OnFail: null,
  43. OnLoad: null,
  44. FormContainer: null,
  45. };
  46. var subformhtml = Unibase.Platform.Forms.Components.FormViewer.instance.loadFormHtml(forminfo, true, "container-subform-0", formviewerObj, null);
  47. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(subformhtml.JsFiles, function () {
  48. $("#divSubForm_" + prop.UniqueId).html(subformhtml.TotalFormHtml);
  49. });
  50. });
  51. }
  52. else {
  53. if (parentPkid != 0) {
  54. var forminfos = childformdata;
  55. for (var i = 0; i < forminfos.length; i++) {
  56. var forminfo = forminfos[i];
  57. var childPkid = forminfos[i].Pk_Value;
  58. Unibase.Forms.Controls.SubForm.Instance().addButtonClick(forminfo, prop.UniqueId, ControlJsonText.SubFormName, ControlJsonText.ChildFormId, childPkid);
  59. }
  60. }
  61. }
  62. $("#btnAddSubForm_" + prop.UniqueId).attr("data-subformcount", 1);
  63. }
  64. if (ControlJsonText.EnableListFormSettings == true) {
  65. var childformdata = ControlJsonText.FormInfo;
  66. if (childformdata == undefined) {
  67. Unibase.Platform.Forms.Managers.FormManager.Instance().getForm(ControlJsonText.ChildFormId).then(function (response) {
  68. var forminfo = response.result;
  69. var formviewerObj = {
  70. FormId: 0,
  71. AppConfigurationId: 0,
  72. Pk_Value: 0,
  73. PortletWidgetId: 0,
  74. OnSuccess: null,
  75. OnFail: null,
  76. OnLoad: null,
  77. FormContainer: null,
  78. };
  79. var subformhtml = Unibase.Platform.Forms.Components.FormViewer.instance.loadFormHtml(forminfo, true, "container-subformlist-1", formviewerObj, null);
  80. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(subformhtml.JsFiles, function () {
  81. var listhtml = '<div class="divSubFormList_' + prop.UniqueId + '">' + subformhtml.TotalFormHtml + '</div>';
  82. listhtml += '<div class="col-sm-3 div_SubFormList" id="div_subformlist">' +
  83. '<a href="javascript:;" class="btn btn-success text-white btnSubform_' + prop.UniqueId + '" id="btnAddSubFormList_' + prop.UniqueId + '" data-subformcount="1" data-islistsubform="true"/><span class="fa fa-plus"></span></a>' +
  84. '</div><div id="divSubFormListData_' + prop.UniqueId + '" class="hidden"></div></div>';
  85. $(".divNextSubForm_" + prop.UniqueId).after(listhtml);
  86. $("#btnAddSubFormList_" + prop.UniqueId).click(function () {
  87. Unibase.Forms.Controls.SubForm.Instance().addButtonClickForList(prop.UniqueId, 0, forminfos, ControlJsonText, prop);
  88. });
  89. });
  90. });
  91. }
  92. else {
  93. var forminfos = childformdata;
  94. Unibase.Forms.Controls.SubForm.instance.loadSubformData(forminfos, ControlJsonText, prop);
  95. }
  96. }
  97. }
  98. loadSubformData(forminfos, ControlJsonText, prop) {
  99. var instance = this;
  100. for (var i = 0; i < forminfos.length; i++) {
  101. var forminfo = forminfos[i];
  102. var childPkid = forminfos[i].Pk_Value;
  103. var formviewerObj = {
  104. FormId: 0,
  105. AppConfigurationId: 0,
  106. Pk_Value: 0,
  107. PortletWidgetId: 0,
  108. OnSuccess: null,
  109. OnFail: null,
  110. OnLoad: null,
  111. FormContainer: null,
  112. };
  113. var subformhtml = Unibase.Platform.Forms.Components.FormViewer.instance.loadFormHtml(forminfo, true, "container-subformlist-1", formviewerObj, null);
  114. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(subformhtml.JsFiles, function () {
  115. var listhtml = '<form id="subformformValidate_' + prop.UniqueId + '" data-validate="parsley"><div class="divSubFormList_' + prop.UniqueId + ' divSubFormList" >' + subformhtml.TotalFormHtml + '</div>';
  116. listhtml += '<div class="div_SubFormList text-center" id="div_subformlist"></div></form>';
  117. $(".divNextSubFormList_" + prop.UniqueId + ' .subformControlData').html(listhtml);
  118. let issubFormListDivLoaded = $('.subformTableDataList').find("#divSubFormListData_" + prop.UniqueId);
  119. if (issubFormListDivLoaded.length == 0) {
  120. let addBtnHtml = '<a href="javascript:;" class="btn btn-success text-white btnSubform_' + prop.UniqueId + '" id="btnAddSubFormList_' + prop.UniqueId + '" data-subformcount="1" data-islistsubform="true"/>Add</a>';
  121. $(".divNextSubFormList_" + prop.UniqueId + ' .subformBtnContainer').html(addBtnHtml);
  122. let subformListHtml = '<div class="table-responsive"><table class="table sub-form-table hidden"><tbody id="divSubFormListData_' + prop.UniqueId + '"></tbody></table></div><div class="hidden subFormListFooter" id="subFormTableFooter_' + prop.UniqueId + '"><div class="d-flex flex-wrap justify-content-between align-items-center"><div class="checkListTotal"><span class="font-weight-500 text-dark">Total: </span><span class="visibleRowsCount"></span> of <span class="totalRowsCount"></span></div><div class="checkListMoreBtn hidden"><a href="javascript:;" onclick="Unibase.Forms.Controls.SubForm.Instance().loadMoreSubFormlist(' + prop.UniqueId + ');" class="btn btn-success btn-sm text-white loadMoreBtn">More</a></div></div></div>';
  123. $(".divNextSubFormList_" + prop.UniqueId + ' .subformTableDataList').html(subformListHtml);
  124. }
  125. $("#btnAddSubFormList_" + prop.UniqueId).off().click(function () {
  126. let formDivId = "subformformValidate_" + prop.UniqueId;
  127. var viewererobj = new Unibase.Platform.Forms.Components.FormViewer();
  128. let result = viewererobj.requiredFieldValidation(formDivId);
  129. if (result == false) {
  130. let requiredFieldsLength = $("#" + formDivId + " .form-group-required").length;
  131. if (requiredFieldsLength == 1) {
  132. let subFormPropertyName = $('.form-group-required').parents('.control-group').data('validatename');
  133. MessageHelper.Instance().showError(subFormPropertyName + " is required", 'div_ErrorMessage_' + ControlJsonText.ParentFormId);
  134. }
  135. else {
  136. MessageHelper.Instance().showError("Mandatory fields are missing", 'div_ErrorMessage_' + ControlJsonText.ParentFormId);
  137. }
  138. return false;
  139. }
  140. else {
  141. Unibase.Forms.Controls.SubForm.Instance().addButtonClickForList(prop.UniqueId, childPkid, forminfos, ControlJsonText, prop);
  142. }
  143. });
  144. });
  145. }
  146. }
  147. addButtonClick(ChildFormData, FormPropertyId, SubFormName, ChildFormId, Pk_Value) {
  148. $(".loadfirstsubformdata").addClass('hidden');
  149. var Index = Number($("#btnAddSubForm_" + FormPropertyId).attr("data-subformcount"));
  150. var namelength = Number($(".divNextSubForm_" + FormPropertyId + ".subformcls").length) + 1;
  151. var subformname = SubFormName + '-' + namelength;
  152. var CurrentContainer = $(".divNextSubForm_" + FormPropertyId);
  153. var html = '<div class="subformcls divNextSubForm_' + FormPropertyId + ' card subform_' + Index + '" data-index="' + Index + '"><div class="card-header"><span class="pull-left subformname subforname_' + FormPropertyId + '">' + subformname + '</span><a class="ml-auto btn-xs pull-right btn btn-icon btn-icon-circle btn-pink btn-icon-style-3 remove-icon_' + FormPropertyId + '_' + Index + '" href="javascript:;" title="Remove row" onclick="Unibase.Forms.Controls.SubForm.Instance().SubFormRemove(' + FormPropertyId + "," + Index + ",\'" + SubFormName + '\');"><span class="btn-icon-wrap"><i class="fa fa-times remove-icon_ ' + FormPropertyId + '_' + Index + '"></i><span></span></span></a></div><div class="card-body divSubForm_' + FormPropertyId + '" id="divSubForm_' + FormPropertyId + '_' + Index + '"></div></div>';
  154. $(CurrentContainer).last().after(html);
  155. if (ChildFormData == undefined) {
  156. Unibase.Platform.Forms.Managers.FormManager.Instance().getForm(ChildFormId).then(function (response) {
  157. var forminfo = response.result;
  158. var formviewerObj = {
  159. FormId: 0,
  160. AppConfigurationId: 0,
  161. Pk_Value: 0,
  162. PortletWidgetId: 0,
  163. OnSuccess: null,
  164. OnFail: null,
  165. OnLoad: null,
  166. FormContainer: null,
  167. };
  168. var subformhtml = Unibase.Platform.Forms.Components.FormViewer.instance.loadFormHtml(forminfo, true, "container-subform-" + Index, formviewerObj, null);
  169. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(subformhtml.JsFiles, function () {
  170. $("#divSubForm_" + FormPropertyId + '_' + Index).html(subformhtml.TotalFormHtml);
  171. $("#btnAddSubForm_" + FormPropertyId).attr("data-subformcount", Index + 1);
  172. });
  173. });
  174. }
  175. else {
  176. var forminfos = ChildFormData;
  177. for (var i = 0; i < forminfos.length; i++) {
  178. var forminfo = forminfos[i];
  179. var childPkid = forminfos[i].Pk_Value;
  180. var formviewerObj = {
  181. FormId: 0,
  182. AppConfigurationId: 0,
  183. Pk_Value: childPkid,
  184. PortletWidgetId: 0,
  185. OnSuccess: null,
  186. OnFail: null,
  187. OnLoad: null,
  188. FormContainer: null,
  189. };
  190. var subformhtml = Unibase.Platform.Forms.Components.FormViewer.instance.loadFormHtml(forminfo, true, "container-subform-" + Index, formviewerObj, null);
  191. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(subformhtml.JsFiles, function () {
  192. $("#divSubForm_" + FormPropertyId + '_' + Index).html(subformhtml.TotalFormHtml);
  193. $("#btnAddSubForm_" + FormPropertyId).attr("data-subformcount", Index + 1);
  194. });
  195. }
  196. }
  197. }
  198. addButtonClickForList(FormPropertyId, pk_value, forminfos, ControlJsonText, prop) {
  199. var temp = $("#btnAddSubFormList_" + FormPropertyId).attr("data-subformcount");
  200. var Index = temp;
  201. var html = '';
  202. var ItemRowLen = $('.CheckList-row-' + Index).length;
  203. var isFormValid = true;
  204. $(".divSubFormList_" + FormPropertyId).find(".value-control").each(function () {
  205. let value = $(this).val();
  206. value = $.trim(value);
  207. if ((value == "" || value == null || value == "0" || value == undefined)) {
  208. isFormValid = false;
  209. }
  210. else {
  211. isFormValid = true;
  212. return false;
  213. }
  214. });
  215. if (isFormValid) {
  216. if ($("#divSubFormListData_" + FormPropertyId + ' tr').length == 0) {
  217. $("#divSubFormListData_" + FormPropertyId).closest('table').removeClass('hidden').addClass('mt-20');
  218. html += `<tr class="bg-light">`;
  219. $(".divSubFormList_" + FormPropertyId).find(".value-control").each(function () {
  220. var formpropertyname = $(this).parents(".container-subformlist-1").attr("data-formpropertyname");
  221. var controlname = $(this).parents(".container-subformlist-1").attr("data-controlname");
  222. var placeholdernameAuto = $(this).parents(".container-subformlist-1").attr("data-validatename");
  223. var placeholdername = $(this).parents(".container-subformlist-1").find(".value-control").attr("data-placeholder");
  224. var hiddenitem = controlname == "HiddenField" ? "hidden" : "";
  225. html += '<th ' + hiddenitem + '><div class="container-subform-list-' + Index + '" class="divsubformlist_placeholder" data-formpropertyname="' + formpropertyname + '"><input type="hidden" class="' + placeholdernameAuto + '" value="' + placeholdernameAuto + '"/><span class="CheckListItemName_placeholder" ' + hiddenitem + ' id="CheckListItemName_Placeholder' + Index + '" ><strong>' + placeholdernameAuto + '</strong></span>' +
  226. '<input type="hidden" value=' + Index + ' class="CheckListId_placeholder">' +
  227. '<input type="hidden" value=' + Index + ' class="hf_CheckListIndex_placeholder"></div></th>';
  228. });
  229. html += '<th class="font-weight-bold text-right">Delete</th></tr>';
  230. }
  231. let isHidden = "";
  232. $("#subFormTableFooter_" + FormPropertyId).removeClass('hidden');
  233. if ($("#divSubFormListData_" + FormPropertyId + ' tr').length >= 6) {
  234. isHidden = "hidden";
  235. $("#subFormTableFooter_" + FormPropertyId + " .checkListMoreBtn").removeClass('hidden');
  236. }
  237. html += '<tr class="' + isHidden + ' CheckList-item-row divSubForm_' + FormPropertyId + ' CheckList-row-' + Index + '" id="li_CheklistItem_' + Index + '" >' +
  238. '<input type="hidden" class="hf_CheckListId" value="' + Index + '">';
  239. var check = -1;
  240. $(".divSubFormList_" + FormPropertyId).find(".value-control").each(function () {
  241. if (($(this).val() == "") && ($(this).parents('.control-group').data('controlname') == 'NumberBox')) {
  242. $(this).val('0');
  243. }
  244. $(this).parent('.floating-label-form-group').removeClass('floating-label-form-group-with-value');
  245. var value = $(this).val();
  246. if ((value == "" || value == null || value == "0" || value == undefined) && (check != 1)) {
  247. check = 1;
  248. }
  249. else {
  250. check = 0;
  251. }
  252. var formpropertyname = $(this).parents(".container-subformlist-1").attr("data-formpropertyname");
  253. var controlname = $(this).parents(".container-subformlist-1").attr("data-controlname");
  254. var hiddenitem = controlname == "HiddenField" ? "hidden" : "";
  255. var text = "";
  256. if (controlname == "AutoComplete") {
  257. text = $("#" + $(this).attr("data-autotextid") + " option:selected").text();
  258. }
  259. else if (controlname == "DatePicker") {
  260. text = $(this).siblings('.datepicker-input').val();
  261. }
  262. else if (controlname == "DropDown") {
  263. text = $(this).find(":selected").text();
  264. }
  265. else if (controlname == "CascadingAutocomplete") {
  266. text = $("#" + $(this).attr("data-autotextid") + " option:selected").text();
  267. }
  268. else if (controlname == "Select2") {
  269. text = $(this).attr("data-text");
  270. }
  271. else {
  272. text = $(this).val();
  273. }
  274. var Id = $(this).attr("id");
  275. if (controlname == "HiddenField") {
  276. $("#" + Id).val("0");
  277. }
  278. if (controlname == "AutoComplete") {
  279. var autocompleteId = $(this).parent().find('select').attr("id");
  280. $("#" + autocompleteId).empty();
  281. }
  282. html += '<td ' + hiddenitem + '><div class="container-subform-list-' + Index + '" class="divsubformlist" data-formpropertyname="' + formpropertyname + '"><input type="hidden" class="value-control" value="' + value + '"/><span class="CheckListItemName" ' + hiddenitem + ' id="CheckListItemName_' + Index + '" >' + text + '</span>' +
  283. '<input type="hidden" value=' + Index + ' class="CheckListId" >' +
  284. '<input type="hidden" value=' + Index + ' class="hf_CheckListIndex"></div></td>';
  285. });
  286. html += '<td class="text-right">' +
  287. '<a class="btn-icon" href="javascript:;" onclick="Unibase.Forms.Controls.SubForm.Instance().removeChekList(' + Index + ',' + FormPropertyId + ');" >' +
  288. '<i class="fa fa-trash-o text-danger" ></i></a>' +
  289. '</td>' +
  290. '</tr>';
  291. $(".hf_CheckListId").val(Index);
  292. $("#divSubFormListData_" + FormPropertyId).append(html);
  293. $("#btnAddSubFormList_" + FormPropertyId).attr("data-subformcount", Number(Index) + 1);
  294. let totalRowsCount = $("#divSubFormListData_" + FormPropertyId + ' tr').length - 1;
  295. let visibleRowsCount = totalRowsCount - $("#divSubFormListData_" + FormPropertyId + ' tr.hidden').length;
  296. $("#subFormTableFooter_" + FormPropertyId).find('span.totalRowsCount').text(totalRowsCount);
  297. $("#subFormTableFooter_" + FormPropertyId).find('span.visibleRowsCount').text(visibleRowsCount);
  298. Unibase.Forms.Controls.SubForm.instance.loadSubformData(forminfos, ControlJsonText, prop);
  299. }
  300. }
  301. loadMoreSubFormlist(FormPropertyId) {
  302. $("#divSubFormListData_" + FormPropertyId + " tr.hidden").each(function (index, item) {
  303. if (index < 5) {
  304. $(item).removeClass('hidden');
  305. let totalRowsCount = $("#divSubFormListData_" + FormPropertyId + ' tr').length - 1;
  306. let visibleRowsCount = totalRowsCount - $("#divSubFormListData_" + FormPropertyId + ' tr.hidden').length;
  307. $("#subFormTableFooter_" + FormPropertyId).find('span.visibleRowsCount').text(visibleRowsCount);
  308. if (visibleRowsCount == totalRowsCount) {
  309. $("#subFormTableFooter_" + FormPropertyId + " .checkListMoreBtn").addClass('hidden');
  310. }
  311. }
  312. });
  313. }
  314. loadControl_delete(containerid, prop) {
  315. var Index = 0;
  316. SubForm.instance.Subprops = [];
  317. SubForm.instance.Subprops.push(prop);
  318. let html = '';
  319. var id = JSON.parse(prop.ControlJsonText);
  320. SubForm.Instance().EnableListFormSettings = id.EnableListFormSettings;
  321. SubForm.Instance().EnableSubFormSettings = id.EnableSubFormSettings;
  322. Unibase.Forms.Controls.SubForm.instance.loadingjsfiles(id);
  323. if ($('#EnableSubForm').length != 0 && $("#isclcikevent").val() == "true") {
  324. var FormPropertyId = prop.FormPropertyId + Number($("#SubFormIndex").val());
  325. html += '<div id="divSub_' + FormPropertyId + '" class="div_' + FormPropertyId + '"><input type="hidden" id="hdn_Containerid" value="' + containerid + '">';
  326. html += '</div>';
  327. }
  328. else {
  329. html += '<div id="div_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '" class="div_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '">';
  330. html += '</div>';
  331. }
  332. if ($('#EnableSubForm').length == 0) {
  333. html += '<input type="hidden" id="SubFormIndex" value="0">';
  334. }
  335. else if ($('#EnableSubForm').length != 0 && $("#isclcikevent").val() == "true") {
  336. html += '<input type="hidden" id="IsSubFormExist" value="true">';
  337. }
  338. SubForm.instance.Index = moment().valueOf();
  339. $("#" + containerid).html(html);
  340. if ($('#EnableSubForm').length == 0) {
  341. var html1 = '<div class="lastdiv"></div><div id="Subform_id"><input type="hidden" id="isclcikevent" value="false"><input type="hidden" id="SubformInstalledAppId" value="' + id.InstalledAppId + '"><input type="hidden" id="subform_FormPropertyId" value="' + prop.FormPropertyId + '"><input type="hidden" id="checkedevent" value="false"><input type="hidden" id="SubFormButtonText" value="' + id.ButtonName + '"><div class="row" id="EnableSubForm"></div>' +
  342. '<input type="hidden" id="Subform_ChildFormId" value="' + id.ChildFormId + '"><input type="hidden" id="MultipleSubFormIndex" value="0"><input type="hidden" id="Subform_DocPropertyName" value="' + prop.DocPropertyName + '"><input type="hidden" id="Subform_SectionName" value=""><input type="hidden" id="Subform_SubFormName" value="' + id.SubFormName + '"><input type="hidden" id="Subform_SectionId" value="' + prop.SectionId + '">';
  343. if (id.EnableSubFormSettings == true) {
  344. html1 += '<div class="col-sm-3 div_SubFormdetails" id="div_subformsettings">' +
  345. '<a href="javascript:;" class="btn btn-success text-white" onclick="Unibase.Forms.Controls.SubForm.Instance().subFormSettings(' + id.ChildFormId + ',Unibase.Forms.Controls.SubForm.Instance().Subprops[' + Index + '])"><span>' + id.ButtonName + '</span></a>' +
  346. '</div>';
  347. }
  348. html1 += '</div>';
  349. $("#" + containerid).append(html1);
  350. var value = Number($('#MultipleSubFormIndex').val());
  351. $('#MultipleSubFormIndex').val(value + 1);
  352. }
  353. }
  354. LoadCheckListForm(Index) {
  355. var len = $('.CheckList-row').length;
  356. if (len == 0) {
  357. len = 1;
  358. }
  359. let html = '<div class="card div_CheckListform col-sm-12"><div class="card-header"><span>Add Check Lists</span></div><div class="card-body CheckListform"><div class="CheckListform-row col-sm-2" id="CheckListform-row"></div><div class="CheckList-row added-row value-row card" id="div_Checklist_' + len + '">' +
  360. '<ul id="ul_chekList_items">' +
  361. '<li class="list-group-item" >' +
  362. '<div class="row">' +
  363. '<div class="col-11 ml-10" >' +
  364. '<div class="floating-label-form-group" ><input type="text" maxlength="500" class="form-control floating-label-control CheckListItem" id="txt_CheckListItem_' + len + '" data-isdynamic="false" placeholder="Checklist Item *" data-placeholder="Checklist Item *" data-label="Checklist Item *">' +
  365. '<input type="hidden" id="hf_CheckListId_' + len + '" ></div> ' +
  366. '</div>' +
  367. '<div class="row"><div class="col-6"><a id="btnAddItemPayout" href="javascript:;" onclick=" Unibase.Forms.Controls.SubForm.Instance().addNewCheckListItem(' + len + ')" class="btn-icon "><i class="fa fa-plus ml-25 mt-20"></i></a></div>' +
  368. '</div ></div >' +
  369. '</li>' +
  370. '<li class="CheckList-row-' + len + '" id="hfli_ChecklistItem_' + len + '"></li>' +
  371. '</ul></div>' +
  372. '</div>';
  373. $('#div_' + $("#Subform_DocPropertyName").val() + '_' + $("#subform_FormPropertyId").val() + '').after(html);
  374. }
  375. addNewCheckListItem(len) {
  376. var currentindex = 0;
  377. var formpropertyid = 0;
  378. var Index = Number(currentindex);
  379. var d = $(".hf_CheckListId").val();
  380. var i = Number(d);
  381. if (d == undefined) {
  382. Index = Index + 1;
  383. }
  384. else {
  385. Index = i + 1;
  386. }
  387. $("#SubFormIndex").val(Index);
  388. var BasicaddNewCheckListItem_Template = Unibase.Forms.Controls.SubForm.Instance().GetCheckListItem(Index, formpropertyid);
  389. var container_div = '<div class="container-subform-' + Index + '">' + BasicaddNewCheckListItem_Template + '</div>';
  390. $('#div_' + $("#Subform_DocPropertyName").val() + '_' + $("#subform_FormPropertyId").val() + '').after(BasicaddNewCheckListItem_Template);
  391. }
  392. GetCheckListItem(len, formpropertyid) {
  393. var temp = len;
  394. var Index = temp;
  395. var html = '';
  396. var emptyformpropertyname = "";
  397. var ItemRowLen = $('.CheckList-row-' + Index).length;
  398. let formpropertid;
  399. html += '<li class="list-group-item CheckList-item-row CheckList-row-' + Index + '" id="li_CheklistItem_' + Index + '">' +
  400. '<input type="hidden" class="hf_CheckListId" value="' + Index + '">' +
  401. '<div class="row" > ' +
  402. '<div class="col-11 row">';
  403. $(".container-subform-list-0").find(".value-control").each(function () {
  404. var id = $(this).attr('id');
  405. var FrmPropertyName = $(this).parents('.container-subform-list-0').data('formpropertyname');
  406. var FrmPrtyid = $(this).parents('.container-subform-list-0').data('formpropertyid');
  407. let formpropertyname = $("#" + id).val();
  408. formpropertid = $("#" + id).val();
  409. var cntrlclass = $(this).attr('class');
  410. var cls = cntrlclass.split(' ');
  411. var arraycontainsbycontrollername = (cls.indexOf("txtSeriesAutoComplete_" + FrmPropertyName) > -1);
  412. if (arraycontainsbycontrollername == true) {
  413. formpropertid = $("#" + id + " option:selected").val();
  414. formpropertyname = $("#" + id + " option:selected").text();
  415. var seriesautocompelete = $("#" + id + " option:selected").val();
  416. if (seriesautocompelete == undefined || seriesautocompelete == "0") {
  417. formpropertyname = "";
  418. }
  419. }
  420. var Autocompletecontrollername = (cls.indexOf("txtAutoComplete_" + FrmPropertyName) > -1);
  421. if (Autocompletecontrollername == true) {
  422. formpropertid = $("#" + id + " option:selected").val();
  423. formpropertyname = $("#" + id + " option:selected").text();
  424. var autocompelete = $("#" + id + " option:selected").val();
  425. if (autocompelete == undefined || seriesautocompelete == "0") {
  426. formpropertyname = "";
  427. }
  428. }
  429. var DropDowncontrollername = "ddl_" + FrmPropertyName + "_" + FrmPrtyid;
  430. if (DropDowncontrollername == id) {
  431. formpropertid = $("#" + id + " option:selected").val();
  432. formpropertyname = $("#" + id + " option:selected").text();
  433. var DropDown = $("#" + id + " option:selected").val();
  434. if (DropDown == undefined || seriesautocompelete == "0") {
  435. formpropertyname = "";
  436. }
  437. }
  438. if (formpropertyname != "" && formpropertyname != null) {
  439. if (formpropertid == "0") {
  440. formpropertyname = "";
  441. }
  442. html += '<div class="container-subform-' + Index + '" data-formpropertyname="' + FrmPropertyName + '"><input type="hidden" class="value-control" value="' + formpropertid + '"/><span class="CheckListItemName pl-25 col-sm-3" id="CheckListItemName_' + Index + '" >' + formpropertyname + '</span>' +
  443. '<input type="hidden" value=' + Index + ' class="CheckListId" >' +
  444. '<input type="hidden" value=' + Index + ' class="hf_CheckListIndex"></div>';
  445. $("#" + id).val(0);
  446. $("#" + id + " option:selected").val(0);
  447. $("#" + id + " option:selected").text('-- Select --');
  448. }
  449. emptyformpropertyname += formpropertyname;
  450. });
  451. html += '</div><div class="col-1 ml-md-2 pl-md-60">' +
  452. '<a class="btn-icon" href="javascript:;" onclick="Unibase.Forms.Controls.SubForm.Instance().removeChekList(' + Index + ',' + formpropertyid + ');" >' +
  453. '<i class="fa fa-trash-o text-danger" ></i></a>' +
  454. '</div></div>' +
  455. '</li>';
  456. $(".hf_CheckListId").val(Index);
  457. if (emptyformpropertyname == "" || emptyformpropertyname == "0") {
  458. html = "";
  459. }
  460. return html;
  461. }
  462. removeChekList(CheckListIndex, formProperyId) {
  463. let checkListItem = $('#divSubFormListData_' + formProperyId + ' #li_CheklistItem_' + CheckListIndex);
  464. let tableDiv = $(checkListItem).closest('table');
  465. let tableBody = $(checkListItem).parent('tbody');
  466. let tableFooter = $(tableDiv).parent('.table-responsive').next('.subFormListFooter');
  467. if ($(tableDiv).find('tr').length == 2) {
  468. $(tableDiv).addClass('hidden').removeClass('mt-20');
  469. $(tableFooter).addClass('hidden');
  470. $(checkListItem).parent().html('');
  471. }
  472. $(checkListItem).remove();
  473. let totalRowsCount = tableBody.find('tr').length - 1;
  474. let visibleRowsCount = totalRowsCount - tableBody.find('tr.hidden').length;
  475. if (visibleRowsCount <= 5) {
  476. if ($(tableBody).find('tr.hidden').length > 0) {
  477. $(tableBody).find('tr.hidden').first().removeClass('hidden');
  478. visibleRowsCount += 1;
  479. }
  480. }
  481. $(tableFooter).find('span.totalRowsCount').text(totalRowsCount);
  482. $(tableFooter).find('span.visibleRowsCount').text(visibleRowsCount);
  483. if (visibleRowsCount == totalRowsCount) {
  484. tableFooter.find('.checkListMoreBtn').addClass('hidden');
  485. }
  486. }
  487. loadControlSettings(controlsettingjson, formpropertyid) {
  488. return ``;
  489. }
  490. loadPropertySettings(propertysettings, formpropertyid) {
  491. return ``;
  492. }
  493. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  494. $("#txt_" + formpropertyid).val(propval);
  495. }
  496. subFormSettings(formid, prop) {
  497. var setting = JSON.parse(prop.ControlJsonText);
  498. var subformlistSetting = setting.EnableListFormSettings;
  499. var containerClass = "container-subform-" + $("#SubFormIndex").val();
  500. if (subformlistSetting == true) {
  501. containerClass = "container-subform-list-" + $("#SubFormIndex").val();
  502. }
  503. var rowid = moment().valueOf();
  504. $("#isclcikevent").val("true");
  505. $("#Subform_id").addClass('hidden');
  506. $(".div_SubFormdetails").addClass('hidden');
  507. var sectionnanme = $("#section_" + prop.SectionId).text();
  508. var value = Number($("#SubFormIndex").val()) + 1;
  509. $("#SubFormIndex").val(value);
  510. $("#Subform_SectionName").val(sectionnanme);
  511. $("#Subform_SectionId").val(prop.SectionId);
  512. SubForm.instance.Index = rowid;
  513. var successCallBack = {
  514. CallBack: function (id) {
  515. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLedgerById(id).then(function (response) {
  516. var rowid = Bizgaze.Forms.Controls.Tax.Instance().length;
  517. Bizgaze.Forms.Controls.Tax.Instance().bindLedgers(rowid, response.result.LedgerId, response.result.LedgerName);
  518. });
  519. },
  520. Parameters: null,
  521. };
  522. var formviewerObj = {
  523. FormId: Number($("#Subform_ChildFormId").val()),
  524. AppConfigurationId: 0,
  525. Pk_Value: 0,
  526. PortletWidgetId: 0,
  527. OnSuccess: successCallBack,
  528. OnFail: null,
  529. OnLoad: null,
  530. FormContainer: null,
  531. };
  532. var viewererobj = new Unibase.Platform.Forms.Components.FormViewer();
  533. viewererobj.init(formviewerObj);
  534. }
  535. SubFormRemove(formpropertyid, Index, subformname) {
  536. var totalcount = Number($("#btnAddSubForm_" + formpropertyid).data("subformcount"));
  537. $("#btnAddSubForm_" + formpropertyid).data("subformcount", totalcount - 1);
  538. $('.divNextSubForm_' + formpropertyid + '.subform_' + Index).remove();
  539. SubForm.instance.refreshList(formpropertyid, subformname);
  540. }
  541. refreshList(formpropertyid, subformname) {
  542. var index = 0;
  543. $('.divNextSubForm_' + formpropertyid + '.subformcls').each(function () {
  544. index++;
  545. $(this).find(".subforname_" + formpropertyid).text(subformname + "-" + index);
  546. });
  547. }
  548. loadhtml(Index, prop, RoleClass, SubformIndex) {
  549. var html = "";
  550. let subformlistSetting;
  551. var setting = JSON.parse(prop.ControlJsonText);
  552. if (setting != null) {
  553. subformlistSetting = setting.EnableListFormSettings;
  554. }
  555. else {
  556. subformlistSetting = false;
  557. }
  558. var containerClass = "container-subform-" + SubformIndex;
  559. if (subformlistSetting == true) {
  560. containerClass = "container-subform-list-" + SubformIndex;
  561. }
  562. if ($("#isclcikevent").val() == "true") {
  563. html += '<div id="control-container-' + prop.UniqueId + '" class="control-group ' + containerClass + ' divCustomProperties_' + prop.DocPropertyName + ' controldata_' + prop.DocPropertyId + ' col-sm-' + prop.PropertyWidth + RoleClass + '" data-size="' + prop.PropertyWidth + '" data-propertyname="' + prop.DocPropertyName + '" data-propertyid="' + prop.DocPropertyId + '" data-doctypeid="' + prop.DocTypeId + '" data-level="' + prop.Level + '" data-doctypetable="' + prop.DocTypeTableName + '" data-doctypename="' + prop.DocTypeName + '" data-isdefault="' + prop.IsDefault + '" data-RowIndex="' + prop.RowIndex + '" data-formpropertyid="' + prop.FormPropertyId + '" data-controlname="' + prop.ControlName + '" data-formpropertyname="' + prop.FormPropertyName + '" data-validatename="' + prop.LabelName + '"></div>';
  564. }
  565. else if (prop.ControlName == "SubForm") {
  566. html += '<div id="control-container-' + prop.FormPropertyId + '" class="control-group divCustomProperties divCustomProperties_' + prop.DocPropertyName + ' controldata_' + prop.DocPropertyId + ' col-sm-12' + RoleClass + '" data-size="' + prop.PropertyWidth + '" data-propertyname="' + prop.DocPropertyName + '" data-propertyid="' + prop.DocPropertyId + '" data-doctypeid="' + prop.DocTypeId + '" data-level="' + prop.Level + '" data-doctypetable="' + prop.DocTypeTableName + '" data-doctypename="' + prop.DocTypeName + '" data-isdefault="' + prop.IsDefault + '" data-RowIndex="' + prop.RowIndex + '" data-formpropertyid="' + prop.FormPropertyId + '" data-controlname="' + prop.ControlName + '" data-formpropertyname="' + prop.FormPropertyName + '" data-validatename="' + prop.LabelName + '"></div>';
  567. }
  568. return html;
  569. }
  570. finalhtml(html, totalform, prop, script, formcontainerclass) {
  571. var Subtotalform = '<script type="text/javascript">' +
  572. '$(document).ready(function () {' +
  573. 'var _fileCacheHelper = Unibase.Platform.Helpers.FileCacheHelper.Instance();' +
  574. '_fileCacheHelper.loadJsFile("' + prop.JsUrl + '", function () {' + script +
  575. prop.FormJsVariableName + '.Instance();';
  576. if (prop.JsText != "" && prop.JsText != null) {
  577. var RegExp_Prop = new RegExp("{{container}}", "gi");
  578. var jstext = prop.JsText.replace(RegExp_Prop, formcontainerclass);
  579. Subtotalform += jstext;
  580. }
  581. Subtotalform += '});});</script>';
  582. if ($("#IsSubFormExist").val() == "true") {
  583. $("#subform_FormPropertyId").val();
  584. var Id = Number($("#subform_FormPropertyId").val()) + Number($("#SubFormIndex").val());
  585. ;
  586. var Containerid1 = $("#hdn_Containerid").val();
  587. var sub1 = html;
  588. sub1 += Subtotalform;
  589. $("#" + Containerid1).removeClass();
  590. $("#" + Containerid1).addClass('control-group divCustomProperties controldata_ col-sm-12');
  591. $("#" + Containerid1).find('#divSub_' + Id).append(sub1);
  592. $("#IsSubFormExist").val("false");
  593. }
  594. else if ($("#isclcikevent").val() == "true") {
  595. $(".div_SubFormdetai").empty();
  596. $(".div_SubFormdetai").removeAttr("style");
  597. var rowid1 = moment().valueOf();
  598. var SectionName = $("#Subform_SectionName").val();
  599. var SectionId = $("#Subform_SectionId").val();
  600. var ChildFormId = Number($("#Subform_ChildFormId").val());
  601. var index = SubForm.instance.Index;
  602. var FormPropertyid = $("#subform_FormPropertyId").val();
  603. var sub = '<div class="section_' + SectionName + ' card">';
  604. sub += '<div class="card-header" id="section_' + SectionId + '">' + SectionName + '</div>';
  605. sub = '<div class="dummy ' + formcontainerclass + '">' + html + '</div>';
  606. sub += Subtotalform;
  607. sub += '</div>';
  608. sub += '<div class="lastdiv"></div><div class="col-sm-3 div_SubFormdetai" style="padding-bottom:20px" id="div_subformsettings' + index + '">' +
  609. '<a href="javascript:;" class="btn btn-success text-white" title="Delete Item" onclick="Unibase.Forms.Controls.SubForm.Instance().subFormSettings(' + ChildFormId + ',Unibase.Forms.Controls.SubForm.Instance().Subprops[0])"><span>' + $("#SubFormButtonText").val() + '</span></a>' +
  610. '</div>';
  611. $(".lastdiv:last").after(sub);
  612. $("#IsSubFormExist").val("false");
  613. }
  614. else {
  615. $('#div_' + $("#Subform_DocPropertyName").val() + '_' + $("#subform_FormPropertyId").val() + '').append(totalform);
  616. }
  617. }
  618. loadingjsfiles(props) {
  619. Unibase.Platform.Forms.Managers.FormManager.Instance().getForm(props.ChildFormId).then(function (response) {
  620. var data = response.result;
  621. var json = JSON.parse(data.FormJson);
  622. for (var k = 0; k < json.Sections.length; k++) {
  623. var section = json.Sections[k];
  624. for (var j = 0; j < section.FormProperties.length; j++) {
  625. var prop = section.FormProperties[j];
  626. if (prop != undefined) {
  627. if (prop.PropertyType != "Section") {
  628. var controljsurl = prop.ControlJsUrl;
  629. controljsurl = controljsurl;
  630. var _fileCacheHelper = Unibase.Platform.Helpers.FileCacheHelper.Instance();
  631. _fileCacheHelper.loadJsFile(controljsurl, function () { });
  632. }
  633. }
  634. }
  635. }
  636. var subformlistSetting = props.EnableListFormSettings;
  637. var containerClass = "container-subform-" + $("#SubFormIndex").val();
  638. if (subformlistSetting == true) {
  639. containerClass = "container-subform-list-" + $("#SubFormIndex").val();
  640. }
  641. var successCallBack = {
  642. CallBack: function (id) {
  643. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLedgerById(id).then(function (response) {
  644. var rowid = Bizgaze.Forms.Controls.Tax.Instance().length;
  645. Bizgaze.Forms.Controls.Tax.Instance().bindLedgers(rowid, response.result.LedgerId, response.result.LedgerName);
  646. });
  647. },
  648. Parameters: null,
  649. };
  650. var formviewerObj = {
  651. FormId: props.ChildFormId,
  652. AppConfigurationId: 0,
  653. Pk_Value: 0,
  654. PortletWidgetId: 0,
  655. OnSuccess: successCallBack,
  656. OnFail: null,
  657. OnLoad: null,
  658. FormContainer: null,
  659. };
  660. var viewererobj = new Unibase.Platform.Forms.Components.FormViewer();
  661. viewererobj.init(formviewerObj);
  662. });
  663. }
  664. removeRequiredclass(container) {
  665. $("." + container).find('.type-control').each(function () {
  666. var id = $(this).attr('id');
  667. var viewererobj = new Unibase.Platform.Forms.Components.FormViewer();
  668. viewererobj.removeRequiredClass("#" + id);
  669. });
  670. }
  671. static Instance() {
  672. if (this.instance === undefined) {
  673. this.instance = new SubForm();
  674. }
  675. return this.instance;
  676. }
  677. }
  678. Controls.SubForm = SubForm;
  679. class SubFormSetting {
  680. }
  681. Controls.SubFormSetting = SubFormSetting;
  682. })(Controls = Forms.Controls || (Forms.Controls = {}));
  683. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  684. })(Unibase || (Unibase = {}));
  685. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  686. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  687. return new (P || (P = Promise))(function (resolve, reject) {
  688. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  689. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  690. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  691. step((generator = generator.apply(thisArg, _arguments || [])).next());
  692. });
  693. };
  694. var Unibase;
  695. (function (Unibase) {
  696. let Platform;
  697. (function (Platform) {
  698. let Files;
  699. (function (Files) {
  700. let Managers;
  701. (function (Managers) {
  702. class FileManager extends Platform.Core.BaseManager {
  703. validateDocument(Id, InstalledAppId) {
  704. return __awaiter(this, void 0, void 0, function* () {
  705. const url = 'apis/v4/unibase/platform/files/validatedocument/pkid/' + Id + '/installedappid/' + InstalledAppId;
  706. return yield this.dataHelper().postAsync(url, null).then(function (response) {
  707. if (response.result !== null)
  708. response.result = JSON.parse(response.result);
  709. return response;
  710. });
  711. });
  712. }
  713. validateDocumentByGroup(Id, InstalledAppId) {
  714. return __awaiter(this, void 0, void 0, function* () {
  715. const url = 'apis/v4/unibase/platform/files/validatedocumentbygroup/pkid/' + Id + '/installedappid/' + InstalledAppId;
  716. return yield this.dataHelper().postAsync(url, null).then(function (response) {
  717. if (response.result !== null)
  718. response.result = JSON.parse(response.result);
  719. return response;
  720. });
  721. });
  722. }
  723. getDocumentTypes() {
  724. return __awaiter(this, void 0, void 0, function* () {
  725. const url = 'apis/v4/unibase/platform/files/documenttypes';
  726. return yield this.dataHelper().getAsync(url).then(function (response) {
  727. if (response.result !== null)
  728. response.result = JSON.parse(response.result);
  729. return response;
  730. });
  731. });
  732. }
  733. getDocumentFile(Id) {
  734. return __awaiter(this, void 0, void 0, function* () {
  735. const url = 'apis/v4/unibase/platform/files/getdocumentfile/fileid/' + Id;
  736. return yield this.dataHelper().getAsync(url).then(function (response) {
  737. if (response.result !== null)
  738. response.result = JSON.parse(response.result);
  739. return response;
  740. });
  741. });
  742. }
  743. getDocumentBase64File(Id) {
  744. return __awaiter(this, void 0, void 0, function* () {
  745. const url = 'apis/v4/unibase/platform/files/getebase64documentfile/id/' + Id;
  746. return yield this.dataHelper().getAsync(url).then(function (response) {
  747. if (response.result !== null)
  748. response.result = JSON.parse(response.result);
  749. return response;
  750. });
  751. });
  752. }
  753. getDocumentByRefId(refid, formpropertyid) {
  754. return __awaiter(this, void 0, void 0, function* () {
  755. const url = 'apis/v4/unibase/platform/files/getdocumentbyrefid/refid/' + refid + '/formpropertyid/' + formpropertyid;
  756. return yield this.dataHelper().getAsync(url).then(function (response) {
  757. if (response.result !== null && response.result !== "")
  758. response.result = JSON.parse(response.result);
  759. return response;
  760. });
  761. });
  762. }
  763. deleteDocumentFile(DocumentFileId) {
  764. return __awaiter(this, void 0, void 0, function* () {
  765. const url = 'apis/v4/unibase/platform/files/deletedocumentfile/documentfileid/' + DocumentFileId;
  766. return yield this.dataHelper().postAsync(url, null).then(function (response) {
  767. return response;
  768. });
  769. });
  770. }
  771. updateFileProvider(fileproviderid) {
  772. return __awaiter(this, void 0, void 0, function* () {
  773. const url = 'apis/v4/unibase/platform/files/updatefileprovider/fileproviderid/' + fileproviderid;
  774. return yield this.dataHelper().postAsync(url, null).then(function (response) {
  775. return response;
  776. });
  777. });
  778. }
  779. getfileprovider() {
  780. return __awaiter(this, void 0, void 0, function* () {
  781. const url = 'apis/v4/unibase/platform/files/gettenant';
  782. return yield this.dataHelper().getAsync(url).then(function (response) {
  783. if (response.result !== null)
  784. response.result = JSON.parse(response.result);
  785. return response;
  786. });
  787. });
  788. }
  789. _tempFileSave(postData) {
  790. return __awaiter(this, void 0, void 0, function* () {
  791. const url = 'apis/v4/unibase/platform/forms/uploadfile';
  792. return yield this.dataHelper().postAsync(url, postData).then(function (response) {
  793. return response;
  794. });
  795. });
  796. }
  797. getDocumentByRefIdApi(RefId) {
  798. return __awaiter(this, void 0, void 0, function* () {
  799. const url = 'apis/v4/unibase/platform/files/getdocumentbyrefidapi/refid/' + RefId;
  800. return yield this.dataHelper().getAsync(url).then(function (response) {
  801. if (response.result !== null && response.result !== "")
  802. response.result = JSON.parse(response.result);
  803. return response;
  804. });
  805. });
  806. }
  807. static Instance() {
  808. if (this.instance === undefined) {
  809. this.instance = new FileManager();
  810. }
  811. return this.instance;
  812. }
  813. }
  814. Managers.FileManager = FileManager;
  815. })(Managers = Files.Managers || (Files.Managers = {}));
  816. })(Files = Platform.Files || (Platform.Files = {}));
  817. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  818. })(Unibase || (Unibase = {}));
  819. var Unibase;
  820. (function (Unibase) {
  821. let Forms;
  822. (function (Forms) {
  823. let Controls;
  824. (function (Controls) {
  825. class hiddenfield {
  826. init(formpropertyid, prop, callback) {
  827. var instance = new hiddenfield();
  828. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  829. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  830. if (callback != null)
  831. callback();
  832. }
  833. loadControl(containerid, prop) {
  834. var regExpr = "";
  835. var ErrMsg = "";
  836. var validationlist = prop.Validations;
  837. if (validationlist != null) {
  838. for (var i = 0; i < validationlist.length; i++) {
  839. regExpr += validationlist[i].RegularExp + '||';
  840. ErrMsg += validationlist[i].ErrorMessage + '||';
  841. }
  842. }
  843. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  844. var required = prop.IsRequired != true ? '' : 'required';
  845. var reqMark = prop.IsRequired != true ? '' : '*';
  846. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  847. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  848. var StagesForRequired = prop.StagesForRequired.split('|');
  849. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  850. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  851. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  852. }
  853. var defaultvalue = "0";
  854. if (prop.PropertySettings != null) {
  855. for (var i = 0; i < prop.PropertySettings.length; i++) {
  856. var data = prop.PropertySettings[i];
  857. if (prop.DataTypeId == 9) {
  858. if (data.ControlPropertyName == "DefaultValue" && data.ControlPropertyValue != "") {
  859. defaultvalue = data.ControlPropertyValue;
  860. }
  861. }
  862. }
  863. }
  864. let html = '<div class="hidden">' +
  865. '<label for="lbl" id="lbl_' + prop.ControlId + '"><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyId + '"> *</span></label>' +
  866. '<input type="hidden" id="hdn_' + prop.FormPropertyId + '" class="hdn_' + prop.DocPropertyName + ' form-control type-control value-control floating-label-control" placeholder="' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + reqMark + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" value="' + defaultvalue + '">' +
  867. '</div>';
  868. $("#" + containerid).html(html);
  869. if (Unibase.Platform.Forms.Components.FormViewer.Instance().DesignerMode == false) {
  870. $("#" + containerid).addClass("hidden");
  871. }
  872. else {
  873. $("#" + containerid).removeClass("hidden");
  874. }
  875. $(".divCustomFormProperties[data-sectionname='Hidden']").css("height", "25");
  876. }
  877. loadControlSettings(controlsettingjson, formpropertyid) {
  878. return null;
  879. }
  880. loadPropertySettings(propertysettings, formpropertyid) {
  881. if (propertysettings != null) {
  882. for (var i = 0; i < propertysettings.length; i++) {
  883. var data = propertysettings[i];
  884. if (data.ControlPropertyName == "DefaultValue" && data.ControlPropertyValue != "") {
  885. $("#hdn_" + formpropertyid).attr("DefaultValue", data.ControlPropertyValue);
  886. $("#hdn_" + formpropertyid).val(data.ControlPropertyValue);
  887. }
  888. }
  889. }
  890. }
  891. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  892. $("#hdn_" + formpropertyid).val(propval);
  893. }
  894. static Instance() {
  895. if (this.instance === undefined) {
  896. this.instance = new hiddenfield();
  897. }
  898. return this.instance;
  899. }
  900. }
  901. Controls.hiddenfield = hiddenfield;
  902. })(Controls = Forms.Controls || (Forms.Controls = {}));
  903. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  904. })(Unibase || (Unibase = {}));
  905. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  906. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  907. return new (P || (P = Promise))(function (resolve, reject) {
  908. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  909. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  910. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  911. step((generator = generator.apply(thisArg, _arguments || [])).next());
  912. });
  913. };
  914. var Unibase;
  915. (function (Unibase) {
  916. let Forms;
  917. (function (Forms) {
  918. let Controls;
  919. (function (Controls) {
  920. class AutoComplete extends Unibase.Platform.Core.BaseComponent {
  921. constructor() {
  922. super(...arguments);
  923. this.FormAutoUniqueId = null;
  924. this.loadCascading = true;
  925. this.container = null;
  926. this.DocPropertyId = 0;
  927. this.FormPropertyId = 0;
  928. this.FormPropertyName = "";
  929. this.FormId = 0;
  930. this.totalreportdatafilter = [];
  931. this.totalreportid = 0;
  932. this.mappingtextcolumn = null;
  933. this.mappingidcolumn = null;
  934. }
  935. init(formpropertyid, prop, callback) {
  936. var instance = AutoComplete.Instance();
  937. var container = $("#txtAutoComplete_" + prop.UniqueId);
  938. instance.LoadAutoComplete(container, null).then(function () {
  939. if (callback != null)
  940. callback();
  941. });
  942. var autoSettingData = JSON.parse(prop.ControlJsonText);
  943. if (autoSettingData.AppConfigId != 0) {
  944. $(container).change(function () {
  945. if ($("#txtAutoComplete_" + prop.UniqueId + " option:selected").text() == "Create New") {
  946. var autoContainer = "autocomplete_" + prop.FormPropertyId;
  947. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormByAppConfiguration(autoSettingData.AppConfigId).then(function (response) {
  948. var formid = response.result.FormId;
  949. $("#txtAutoComplete_" + prop.UniqueId).text('');
  950. $("#hfAutoCompleteId_" + prop.UniqueId).val('');
  951. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormPropertyName = prop.FormPropertyName;
  952. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).container = "#txtAutoComplete_" + prop.UniqueId;
  953. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).DocPropertyId = prop.DocPropertyId;
  954. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormPropertyId = prop.FormPropertyId;
  955. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormId = formid;
  956. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormAutoUniqueId = "autocomplete_" + prop.UniqueId + "_" + response.result.FormId;
  957. var successCallBack = {
  958. CallBack: function (id) {
  959. let AppConfigType = Unibase.Platform.Forms.Components.FormViewer.instance.AppConfigType;
  960. Unibase.Platform.Forms.Components.FormViewer.instance.AppConfigType = 0;
  961. Unibase.Platform.Forms.Managers.FormManager.Instance().getAutocompleteSelectedData(Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).DocPropertyId, id, Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).FormPropertyId, 0).then(function (response) {
  962. var selectedOptions = new Option(response.result[0].DisplayText, response.result[0].Value, true);
  963. $(Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).container).append(selectedOptions).trigger('change');
  964. Unibase.Platform.Forms.Components.FormViewer.instance.AppConfigType = AppConfigType;
  965. });
  966. },
  967. Parameters: null,
  968. };
  969. var formviewerObj = {
  970. FormId: formid,
  971. AppConfigurationId: autoSettingData.AppConfigId,
  972. Pk_Value: 0,
  973. PortletWidgetId: 0,
  974. OnSuccess: successCallBack,
  975. OnFail: null,
  976. OnLoad: null,
  977. FormContainer: null,
  978. };
  979. Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
  980. });
  981. }
  982. else {
  983. var IdFormPropertyid = $("#hfAutoCompleteId_" + prop.UniqueId).data("textformpropertyid");
  984. $("#hdn_" + IdFormPropertyid).val($("#txtAutoComplete_" + prop.UniqueId + " option:selected").text());
  985. }
  986. });
  987. }
  988. }
  989. loadControl(containerid, prop) {
  990. var instance = this;
  991. var jsfiles = ["platform/controls/cascadingautocomplete/cascadingautocomplete.component.js", "platform/controls/cascadingautocomplete/cascadingautocomplete.settings.js"];
  992. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  993. var required = prop.IsRequired != true ? '' : 'required';
  994. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  995. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  996. var StagesForRequired = prop.StagesForRequired.split('|');
  997. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  998. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  999. }
  1000. var IsTagSelect = false;
  1001. var text;
  1002. if (prop.ControlJsonText != "" && prop.ControlJsonText != null && prop.ControlJsonText != undefined) {
  1003. var text = JSON.parse(prop.ControlJsonText);
  1004. if (text["IsTagSelect"] == true) {
  1005. IsTagSelect = true;
  1006. }
  1007. }
  1008. var divclass = text.ShowTotalReportData == true ? 'col-sm-11 col-11' : 'col-sm-12';
  1009. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  1010. var html = `<div id="div_${prop.DocPropertyName}" style=""><label for="lbl" id="lbl_${prop.DocPropertyName}">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger hide ${Isrequired}" id="spnIsRequired_${prop.FormPropertyId}"> *</span></label><div class="input-group ">` +
  1011. '<div class="' + divclass + '" style="margin:0px;padding:0px;"><select id="txtAutoComplete_' + prop.UniqueId + '" class="txtAutoComplete_' + prop.DocPropertyName + ' form-control type-control text-control select_address ' + required + ' " data-isdefault="' + prop.IsDefault + '" style="width:100%;" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-istagselect="' + IsTagSelect + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" data-formid="' + text.FormId + '" value="0" data-textformpropertyid="' + text.TextFormPropertyId + '" data-showtotalreportdata="' + text.ShowTotalReportData + '" ></select>' +
  1012. '<input type="hidden" id="hfAutoCompleteId_' + prop.UniqueId + '" value="0" class="hfAutoCompleteId_' + prop.DocPropertyName + ' form-control value-control" data-autotextid="txtAutoComplete_' + prop.UniqueId + '" data-required="' + prop.IsRequired + '" data- data-regularexp="" data-validatemsg="" />' + helpTextHtml + '</div>';
  1013. if (text.ShowTotalReportData == true) {
  1014. html += '<div class=" col-sm-1 col-1 input-group-append" style=";margin:0px;padding:0px;">' +
  1015. '<a class="CheckOutButton align-items-center btn btn-primary btn-xs d-flex h-100 justify-content-center" href="javascript:;" id="hf_totalreportdata_' + prop.UniqueId + '" onclick="javascript:return Unibase.Forms.Controls.AutoComplete.Instance().loadTotalReportData(' + text.TotalDataReportId + ',' + "'" + text.MappingTextColumn + "'" + ',' + "'" + text.MappingIdColumn + "','" + "txtAutoComplete_" + prop.UniqueId + "'" + ',' + prop.FormPropertyId + ')" > <i class="la la-retweet font-18 line-height-12"></i></a></div>';
  1016. }
  1017. html += '</div><input type="hidden" id="hfId_' + prop.DocPropertyName + '" value=""><label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label></div>';
  1018. $("#" + containerid).html(html);
  1019. $("#" + containerid).find("#txtAutoComplete_" + prop.UniqueId).on('change', function () {
  1020. instance.fileCacheHelper.loadJsFiles(jsfiles, function () {
  1021. var controlJson = prop.ControlJsonText;
  1022. if (instance.loadCascading) {
  1023. Unibase.Forms.Controls.CascadingAutocomplete.Instance().ChildCascadingData(false, prop.FormPropertyId, Number($("#txtAutoComplete_" + prop.UniqueId).val()), 0, '');
  1024. }
  1025. instance.loadCascading = true;
  1026. });
  1027. });
  1028. }
  1029. loadTotalReportData(ReportId, TextColumn, IdColumn, Element, FormPropertyId) {
  1030. Unibase.Platform.Analytics.Viewers.TableViewer.Instance().IsSelectable = true;
  1031. Unibase.Platform.Analytics.Viewers.TableViewer.Instance().TextColumn = TextColumn;
  1032. Unibase.Platform.Analytics.Viewers.TableViewer.Instance().IdColumn = IdColumn;
  1033. Unibase.Platform.Analytics.Viewers.TableViewer.Instance().AutoCompleteElement = Element;
  1034. var localinstance = Unibase.Platform.Analytics.Components.ReportViewer.Instance();
  1035. let reportViewerInstance = Unibase.Platform.Helpers.NavigationHelper.reportViewerInstance;
  1036. var isInstance = false;
  1037. const containerid = "reportviewer_" + ReportId;
  1038. if (reportViewerInstance.length > 0)
  1039. isInstance = reportViewerInstance.find(rv => rv.childcontainerid == "reportviewer_" + ReportId) ? true : false;
  1040. if (!isInstance) {
  1041. reportViewerInstance.push({
  1042. instance: localinstance,
  1043. childcontainerid: containerid,
  1044. parentcontainerid: null
  1045. });
  1046. }
  1047. else {
  1048. var tempinstance = reportViewerInstance.find(rv => rv.childcontainerid == "reportviewer_" + ReportId);
  1049. localinstance = tempinstance.instance;
  1050. }
  1051. var autoContainer = "autocomplete_" + FormPropertyId;
  1052. localinstance.dynamicFilters = Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).totalreportdatafilter;
  1053. if (ReportId != undefined)
  1054. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(ReportId, containerid, localinstance, function () {
  1055. $(`#ViewerFooter_${containerid}`).removeClass('d-none').find(`#div_pagination_${containerid}`).addClass('d-none');
  1056. $(`#ReportClose_${containerid}`).removeClass('hidden pull-right');
  1057. $(`#reportCloseBtn_${containerid}`).removeClass('d-none');
  1058. }, Unibase.Platform.Helpers.Size.DockLeft);
  1059. }
  1060. reportOnClick(TextColumn, IdColumn, element) {
  1061. var selectedOptions = new Option(TextColumn, IdColumn, true);
  1062. $("#" + element).append(selectedOptions);
  1063. jQuery("#" + element).val(IdColumn).trigger('change');
  1064. Unibase.Platform.Helpers.NavigationHelper.Instance().closePopUp();
  1065. Unibase.Platform.Analytics.Viewers.TableViewer.Instance().IsSelectable = false;
  1066. }
  1067. loadControlSettings() {
  1068. return ``;
  1069. }
  1070. LoadAutoComplete(Container, Parameters) {
  1071. return __awaiter(this, void 0, void 0, function* () {
  1072. var DocPropertyId = Container.data('propertyid');
  1073. var DocPropertyName = Container.data('propertyname');
  1074. var FormPropertyId = Container.data('formpropertyid');
  1075. var FormId = Container.data('formid');
  1076. var ColumnName = "0";
  1077. var Value = "0";
  1078. var reportfilter = [];
  1079. if (Parameters != null && Parameters != "") {
  1080. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  1081. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  1082. }
  1083. var uniqueid = $(Container).attr('id').split('_')[1];
  1084. var textCol = Container;
  1085. var idCol = $("#hfAutoCompleteId_" + uniqueid);
  1086. var istagselect = false;
  1087. if ($("#txtAutoComplete_" + uniqueid).data("istagselect") == true) {
  1088. istagselect = true;
  1089. }
  1090. var showtotalreportdata = $(Container).data("showtotalreportdata");
  1091. if (showtotalreportdata) {
  1092. if (Parameters != null && Parameters != "") {
  1093. Parameters.map(function (item) {
  1094. var reportfilterobj = { ParameterName: item.ColumnName, ParameterValue: item.Value.toString(), ExpOp: Unibase.Platform.Core.Enums.ExpressionOperator.Equals };
  1095. reportfilter.push(reportfilterobj);
  1096. });
  1097. }
  1098. var autoContainer = "autocomplete_" + FormPropertyId;
  1099. Unibase.Forms.Controls.AutoComplete.localInstance(autoContainer).totalreportdatafilter = reportfilter;
  1100. }
  1101. var bindedData = undefined;
  1102. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/autocomplete/docpropertyid/' + DocPropertyId + '/columnname/' + ColumnName + '/value/' + Value + '/formpropertyid/' + FormPropertyId + '/formid/' + FormId + '/bindeddata/' + bindedData;
  1103. AutoCompleteHelper.getHelper().Create(textCol, idCol, url, function (response) {
  1104. var data = response;
  1105. }, istagselect);
  1106. $(textCol).on('select2:open', function () {
  1107. var id = $(textCol).attr("id");
  1108. let searchField = $('#select2-' + id + '-results').parents('.select2-container').find('.select2-search__field');
  1109. if (istagselect == true && searchField.val() == "") {
  1110. searchField.val($("#" + id + " option:selected").text());
  1111. }
  1112. });
  1113. $(textCol).on('select2:select', function () {
  1114. if (istagselect == true) {
  1115. var id = $(textCol).attr("id");
  1116. var isFreeText = $("#" + id + " option:selected").attr('data-select2-tag');
  1117. if (isFreeText == "true") {
  1118. $(textCol).attr('data-addldata', "");
  1119. }
  1120. }
  1121. });
  1122. var autocompleteid1 = $(".txtAutoComplete_" + DocPropertyName).attr('id');
  1123. });
  1124. }
  1125. loadPropertySettings(propertysettings, formpropertyid) {
  1126. return ``;
  1127. }
  1128. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  1129. if (propval != "null") {
  1130. var instance = this;
  1131. var autojson = JSON.parse(propval);
  1132. var IdValue = autojson.AutoCompleteIdColumn;
  1133. var TextValue = autojson.AutoCompleteTextColumn;
  1134. var selectedOptions = new Option(TextValue, IdValue, true);
  1135. if (IdValue != "0") {
  1136. $("#txtAutoComplete_" + formpropertyid).append(selectedOptions);
  1137. instance.loadCascading = false;
  1138. jQuery("#txtAutoComplete_" + formpropertyid).val(IdValue).trigger("change");
  1139. }
  1140. }
  1141. }
  1142. GetOrAddCurrentAutoCompleteInstance(ContainerId) {
  1143. if (ContainerId != undefined && ContainerId != null && ContainerId != "") {
  1144. let isInstance = false;
  1145. let formControlInstance = Unibase.Platform.Forms.Components.FormViewer.formControlInstances;
  1146. if (formControlInstance.length > 0)
  1147. isInstance = formControlInstance.find(fv => fv.containerid == ContainerId) ? true : false;
  1148. var viewerInstance = new Unibase.Forms.Controls.AutoComplete();
  1149. var currentinstance = {
  1150. instance: viewerInstance,
  1151. containerid: ContainerId,
  1152. };
  1153. if (isInstance == true) {
  1154. viewerInstance = formControlInstance.find(fv => fv.containerid == ContainerId).instance;
  1155. }
  1156. if (!isInstance)
  1157. formControlInstance.push(currentinstance);
  1158. return viewerInstance;
  1159. }
  1160. }
  1161. static localInstance(ContainerId) {
  1162. var formobj = new Unibase.Forms.Controls.AutoComplete();
  1163. this.instance = formobj.GetOrAddCurrentAutoCompleteInstance(ContainerId);
  1164. return this.instance;
  1165. }
  1166. static Instance() {
  1167. if (this.instance === undefined) {
  1168. this.instance = new AutoComplete();
  1169. }
  1170. return this.instance;
  1171. }
  1172. }
  1173. Controls.AutoComplete = AutoComplete;
  1174. })(Controls = Forms.Controls || (Forms.Controls = {}));
  1175. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  1176. })(Unibase || (Unibase = {}));
  1177. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1178. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1179. return new (P || (P = Promise))(function (resolve, reject) {
  1180. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1181. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1182. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1183. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1184. });
  1185. };
  1186. var Unibase;
  1187. (function (Unibase) {
  1188. let Forms;
  1189. (function (Forms) {
  1190. let Controls;
  1191. (function (Controls) {
  1192. class Series {
  1193. init(formpropertyid, prop, callback) {
  1194. var instance = Series.Instance();
  1195. var container = "control-container-" + prop.UniqueId;
  1196. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/series/managers/seriesmanager.js', function () {
  1197. instance.sereisAutoComplete(container, prop).then(function () {
  1198. if (callback != null)
  1199. callback();
  1200. });
  1201. });
  1202. }
  1203. loadControl(containerid, prop) {
  1204. var requiredClass = 'required';
  1205. let ControlId = 'txt_' + prop.FormPropertyId;
  1206. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  1207. var required = prop.IsRequired != true ? '' : 'required';
  1208. let html = '<div id="divAutoComplete_' + prop.FormPropertyId + '" class="div_' + prop.DocPropertyName + '" style="border-bottom:0;">' +
  1209. '<label for= "lbl" id = "lbl_' + prop.DocPropertyName + '" >' + prop.LabelName + '<span class="text-danger hide ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyName + '"> *</span></label>' +
  1210. '<div class="input-group"><select id="txtSeriesAutoComplete_' + prop.FormPropertyId + '" class="txt_series_autocomplete txtSeriesAutoComplete_' + prop.FormPropertyId + ' value-control txtSeriesAutoComplete_' + prop.DocPropertyName + ' form-control text-control ' + required + '" data-isdefault="' + prop.IsDefault + '" style="width:100%;" placeholder = "' + prop.Placeholder + '" data-required="' + prop.IsRequired + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" ><option value="">-- Select --</option></select>';
  1211. html += '</div></div>';
  1212. if (prop.ControlJsonText != "" && prop.ControlJsonText != null) {
  1213. var Response = prop;
  1214. var data = JSON.parse(prop.ControlJsonText);
  1215. if (data != null && data != "") {
  1216. html += '<div id="divTxtBox_' + data.FormPropertyId + '" class="hidden"><div class="floating-label-form-group divTxtBox_' + data.FormPropertyId + '" >' +
  1217. '<label for="lbl" id="lbl_' + prop.ControlId + '">Code<span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + data.FormPropertyId + '"> *</span></label>' +
  1218. '<div class="manualseriesvalue"data-id="' + data.FormPropertyId + '">' +
  1219. '<input type="text" onchange ="Unibase.Forms.Controls.Series.Instance().TextSeriesChange(' + data.FormPropertyId + ',' + prop.FormPropertyId + ');" id="TextSeries_' + data.FormPropertyId + '"" class="TextManualSeries form-control floating-label-control" placeholder="Enter Manual Series" data-placeholder="Enter Manual Series" data-label=Code data-regularexp="" data-validatemsg="">' +
  1220. '<input type="hidden" class="manualseriesvalue" id="hfManualseries_' + data.FormPropertyId + '" value="" /><span id="clearManualSeries" onclick="Unibase.Forms.Controls.Series.Instance().clearManualSeries(`' + containerid + '`,' + data.FormPropertyId + ',' + prop.FormPropertyId + ')" class="fa fa-close font-15 mr-10 field-icon"></span>' +
  1221. '</div>' +
  1222. '</div></div>';
  1223. }
  1224. }
  1225. $("#" + containerid).html(html);
  1226. if (prop.Value == "0")
  1227. Unibase.Forms.Controls.Series.Instance().EditSeries(prop);
  1228. if (prop.Value != "0")
  1229. $('.divisManualSeries_' + prop.FormPropertyId).addClass("hidden");
  1230. $("#txtSeriesAutoComplete_" + prop.FormPropertyId).change(function () {
  1231. var seriesTypeData = $("#txtSeriesAutoComplete_" + prop.FormPropertyId).select2('data')[0];
  1232. var isManual = seriesTypeData.AddlData;
  1233. if (isManual) {
  1234. $('#divAutoComplete_' + prop.FormPropertyId).addClass("hidden");
  1235. $('#divTxtBox_' + data.FormPropertyId).removeClass("hidden");
  1236. $("#TextSeries_" + data.FormPropertyId).addClass('required');
  1237. var code = $('#hdn_' + data.FormPropertyId).val();
  1238. if (code != null && code != undefined && code != "" && code != "0" && prop.Value != "0") {
  1239. $('#TextSeries_' + data.FormPropertyId).val(code);
  1240. $('#clearManualSeries').addClass("hidden");
  1241. $('#divTxtBox_' + data.FormPropertyId).addClass("floating-label-form-group-with-value");
  1242. }
  1243. }
  1244. else {
  1245. $('#divAutoComplete_' + prop.FormPropertyId).removeClass("hidden");
  1246. $('#divTxtBox_' + data.FormPropertyId).addClass("hidden");
  1247. $('#TextSeries_' + data.FormPropertyId).val("");
  1248. $("#TextSeries_" + data.FormPropertyId).removeClass('required');
  1249. }
  1250. });
  1251. }
  1252. TextSeriesChange(FormPropertyId, SeriesId) {
  1253. if ($('#TextSeries_' + FormPropertyId).val() != "") {
  1254. $('#TextSeries_' + FormPropertyId).removeClass('required');
  1255. var hiddenpropid = $("#control-container-" + FormPropertyId).attr('data-formpropertyid');
  1256. if (hiddenpropid == FormPropertyId) {
  1257. $('#hdn_' + FormPropertyId).val($('#TextSeries_' + FormPropertyId).val());
  1258. $('.txtSeriesAutoComplete_' + SeriesId).removeClass('required');
  1259. }
  1260. }
  1261. }
  1262. clearManualSeries(containerId, codeFormPropertyId, seriesFormPropertyId) {
  1263. $(".txtSeriesAutoComplete_" + seriesFormPropertyId + " option:selected").text('');
  1264. var html = '<option value=""></option>';
  1265. $('.txt_series_autocomplete').append(html);
  1266. $(".txt_series_autocomplete").val("");
  1267. $('#TextSeries_' + codeFormPropertyId).val("");
  1268. $('#divAutoComplete_' + seriesFormPropertyId).removeClass("hidden");
  1269. $('#divTxtBox_' + codeFormPropertyId).addClass("hidden");
  1270. $('#TextSeries_' + codeFormPropertyId).val("");
  1271. $("#TextSeries_" + codeFormPropertyId).removeClass('required');
  1272. }
  1273. EditSeries(prop) {
  1274. if (prop.Value == "0") {
  1275. var data = JSON.parse(prop.ControlJsonText);
  1276. $('#divTxtBox_' + data.FormPropertyId).removeClass("hidden");
  1277. $('#divAutoComplete_' + prop.FormPropertyId).addClass("hidden");
  1278. var Code = $('#hdn_' + data.FormPropertyId).val();
  1279. $('#TextSeries_' + data.FormPropertyId).val(Code);
  1280. $('#divTxtBox_' + data.FormPropertyId).addClass('floating-label-form-group-with-value');
  1281. var html = '<option value="0"></option>';
  1282. $('.txt_series_autocomplete').append(html);
  1283. $(".txt_series_autocomplete").val(0).trigger('change');
  1284. $(".TextManualSeries").prop('disabled', true);
  1285. }
  1286. }
  1287. loadControlSettings(controlsettingjson, formpropertyid) {
  1288. return null;
  1289. }
  1290. loadPropertySettings(propertysettings, formpropertyid) {
  1291. return null;
  1292. }
  1293. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  1294. $("#txtSeriesAutoComplete_" + formpropertyid).val(propval).trigger('change');
  1295. }
  1296. LoadSeriesAutoComplete(docPropertyName, DocPropertyId, containerid) {
  1297. var FormPropertyId = $('#' + containerid).find(".txtSeriesAutoComplete_" + docPropertyName).parents(".divCustomProperties").data("formpropertyid");
  1298. var installedappid = $("#" + containerid).parents(".formValidate").find("#hf_FormInstalledAppId").val();
  1299. var appkeyid = $("#" + containerid).parents(".formValidate").find("#hf_FormAppKeyId").val();
  1300. var TextId = $('#' + containerid).find("#txtSeriesAutoComplete_" + FormPropertyId);
  1301. var hiddenId = $('#' + containerid).find("#hfSeriesAutoCompleteId_" + FormPropertyId + '_' + docPropertyName);
  1302. }
  1303. sereisAutoComplete(containerid, prop) {
  1304. return __awaiter(this, void 0, void 0, function* () {
  1305. var installedappid = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId;
  1306. var Forminstalledappid = Unibase.Platform.Forms.Components.FormViewer.instance.FormInstalledAppId;
  1307. var issubform = $("#" + containerid).attr('data-issubform');
  1308. if (issubform == "true") {
  1309. var subforminstalledappid = $("#" + containerid).parents(".control-group").attr("data-installedappid");
  1310. installedappid = Number(subforminstalledappid);
  1311. }
  1312. else if (installedappid == undefined) {
  1313. var installedappid = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId;
  1314. }
  1315. else {
  1316. var installedappid = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId;
  1317. }
  1318. var Id = Forminstalledappid;
  1319. if (installedappid == Forminstalledappid || Forminstalledappid == 0) {
  1320. Id = installedappid;
  1321. }
  1322. else {
  1323. Id = Forminstalledappid;
  1324. }
  1325. yield Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Id).then(function (response) {
  1326. var controlData = [];
  1327. var count = response.result.length;
  1328. for (let i = 0; i < response.result.length; i++) {
  1329. var controls = response.result[i];
  1330. if (count == 1) {
  1331. controlData.push({ id: controls.SeriesId, text: controls.SeriesName, AddlData: controls.ManualNumbering, selected: true });
  1332. }
  1333. else {
  1334. controlData.push({ id: controls.SeriesId, text: controls.SeriesName, AddlData: controls.ManualNumbering });
  1335. }
  1336. }
  1337. $('.txtSeriesAutoComplete_' + prop.FormPropertyId).select2({
  1338. placeholder: 'Select Control',
  1339. data: controlData,
  1340. theme: "default select2ErrorClass",
  1341. });
  1342. if (prop.Value == null && prop.Value !== "0") {
  1343. $('.divisManualSeries_' + prop.DocPropertyId).removeClass("hidden");
  1344. $('#txtSeriesAutoComplete_' + prop.FormPropertyId).prop('disabled', false);
  1345. }
  1346. else {
  1347. $('.divisManualSeries_' + prop.DocPropertyId).addClass("hidden");
  1348. $('#txtSeriesAutoComplete_' + prop.FormPropertyId).prop('disabled', true);
  1349. }
  1350. });
  1351. });
  1352. }
  1353. static Instance() {
  1354. if (this.instance === undefined)
  1355. this.instance = new Series();
  1356. return this.instance;
  1357. }
  1358. }
  1359. Controls.Series = Series;
  1360. })(Controls = Forms.Controls || (Forms.Controls = {}));
  1361. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  1362. })(Unibase || (Unibase = {}));
  1363. var Unibase;
  1364. (function (Unibase) {
  1365. let Forms;
  1366. (function (Forms) {
  1367. let Controls;
  1368. (function (Controls) {
  1369. class CheckBox {
  1370. init(formpropertyid, prop, callback) {
  1371. var instance = CheckBox.Instance();
  1372. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  1373. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  1374. if (callback != null)
  1375. callback();
  1376. }
  1377. loadControl(containerid, prop) {
  1378. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  1379. var required = prop.IsRequired != true ? '' : 'required';
  1380. var reqMark = prop.IsRequired != true ? '' : '*';
  1381. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  1382. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  1383. var StagesForRequired = prop.StagesForRequired.split('|');
  1384. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  1385. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  1386. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  1387. }
  1388. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  1389. var html = `<div id="div_${prop.DocPropertyName}" class="div_${prop.DocPropertyId} form-group floating-label mt-sm-10 mb-0"><br><label for= "lbl" id="lbl_${prop.DocPropertyName}" style="align:center;">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger ${Isrequired}" id="spnIsRequired_${prop.DocPropertyName}">*</span></label>` +
  1390. '<input type="hidden" id="hdnchk_' + prop.DocPropertyName + '" class="form-control value-control ' + required + '" data-isdefault="' + prop.IsDefault + '" data-required="' + prop.IsRequired + '" data-regularexp="" data-validatemsg="" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-ismultiple="' + prop.IsMultiple + '" value="false" />' +
  1391. '<span id="spnChk_' + prop.FormPropertyId + '" data-isswitch="' + prop.IsSwitch + '"></span><input type="hidden" id="hfId" value="false"><label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label><input type="hidden" id="hfFormPropertyId" value="" />' + helpTextHtml + '</div>';
  1392. $("#" + containerid).html(html);
  1393. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/controls/subform/subform.component.js", function () {
  1394. Unibase.Forms.Controls.CheckBox.instance.GetDocPropertiesByPropId(containerid, prop.DocPropertyName, prop);
  1395. });
  1396. }
  1397. GetDocPropertiesByPropId(containerid, DocPropertyName, prop) {
  1398. var html = "";
  1399. var data1 = JSON.parse(prop.ControlJsonText);
  1400. var instance = Unibase.Forms.Controls.CheckBox.Instance();
  1401. for (var i = 0; i < data1.length; i++) {
  1402. var res = data1[i];
  1403. if (Unibase.Forms.Controls.SubForm.Instance().Index != undefined && Unibase.Forms.Controls.SubForm.Instance().Index != 0) {
  1404. var id = DocPropertyName + '_' + res.ColumnText + Number($("#SubFormIndex").val());
  1405. }
  1406. else {
  1407. var id = DocPropertyName;
  1408. if (res.ColumnText != null && res.ColumnText != "") {
  1409. id = DocPropertyName + '_' + res.ColumnText;
  1410. }
  1411. }
  1412. if (res.IsSwitch == true) {
  1413. if (res.ColumnText == undefined)
  1414. res.ColumnText = "";
  1415. if (res.IsMultiple == false)
  1416. html += '<label id="lblCheckBox_' + DocPropertyName + '" class="lblCheckBox_' + DocPropertyName + ' ' + ' switch m-t pull-right"><input type="checkbox" id="chk_' + DocPropertyName + '" class="type-control chk_' + id + '" name="' + DocPropertyName + '" onclick="Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(' + res.DocPropertyId + ',' + "'" + DocPropertyName + "'" + ')" placeholder = "' + prop.Placeholder + '"/><span></span></label>';
  1417. else
  1418. html += '<div class="switch m-t"><input type="checkbox" id="chk_' + DocPropertyName + '" class="type-control chk_' + id + '" name="' + DocPropertyName + '" onclick="Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(' + res.DocPropertyId + ',' + "'" + DocPropertyName + "'" + ')" placeholder = "' + prop.Placeholder + '"/><label class="col-sm-6" for="chk_' + id + '">' + res.ColumnText + '</label><span></span>&nbsp</div>';
  1419. }
  1420. else {
  1421. var checkclass = "";
  1422. if (res.ColumnText == null || res.ColumnText == "") {
  1423. res.ColumnText = "";
  1424. checkclass += "pull-right";
  1425. }
  1426. var onclick = "Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClick('" + DocPropertyName + "'," + res.CheckBoxColumnId + ")";
  1427. if (res.IsMultiple == false) {
  1428. onclick = "Unibase.Forms.Controls.CheckBox.Instance().CheckBoxClickSingle(" + prop.DocPropertyId + ",'" + DocPropertyName + "')";
  1429. }
  1430. var _subform = $(".btnAddSubForm");
  1431. if (_subform.length > 0) {
  1432. const Index = Number($(".btnAddSubForm").attr("data-subformcount")) - 1;
  1433. html += '<div class="custom-control custom-checkbox divEnablePieces checkbox-primary ' + checkclass + '"><input type="checkbox" class="type-control custom-control-input" id = chk_' + id + '_' + Index + ' name="' + DocPropertyName + '" onclick="' + onclick + '" placeholder = "' + prop.Placeholder + '"><label class="custom-control-label" for = chk_' + id + '_' + Index + '>' + res.ColumnText + '</label><span></span>&nbsp</div>';
  1434. }
  1435. else {
  1436. html += '<div class="custom-control custom-checkbox divEnablePieces checkbox-primary ' + checkclass + '"><input type="checkbox" class="type-control custom-control-input" id = chk_' + id + ' name="' + DocPropertyName + '" onclick="' + onclick + '" placeholder = "' + prop.Placeholder + '"><label class="custom-control-label" for = chk_' + id + '>' + res.ColumnText + '</label><span></span>&nbsp</div>';
  1437. }
  1438. }
  1439. }
  1440. $("#" + containerid).find('.div_' + prop.DocPropertyId).find("#spnChk_" + prop.FormPropertyId).html(html);
  1441. }
  1442. loadControlSettings(controlsettingjson, formpropertyid) {
  1443. return null;
  1444. }
  1445. loadPropertySettings(propertysettings, formpropertyid) {
  1446. return null;
  1447. }
  1448. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  1449. if (propval == "True") {
  1450. $("#chk_" + DocPropertyName).prop("checked", true);
  1451. $("#hdnchk_" + DocPropertyName).val("true");
  1452. }
  1453. }
  1454. CheckBoxClick(DocPropertyName, CheckBoxColumnId) {
  1455. var ids = $("#hdnchk_" + DocPropertyName).val();
  1456. if ($("#chk_" + CheckBoxColumnId).is(':checked')) {
  1457. if (ids != "") {
  1458. ids += CheckBoxColumnId + "|";
  1459. }
  1460. else {
  1461. ids = CheckBoxColumnId + "|";
  1462. }
  1463. }
  1464. else {
  1465. var tg = ids.split('|');
  1466. ids = "";
  1467. for (var i = 0; i < tg.length; i++) {
  1468. var a = tg[i];
  1469. if (a != CheckBoxColumnId && tg[i] != '') {
  1470. ids += tg[i] + "|";
  1471. }
  1472. }
  1473. }
  1474. $("#hdnchk_" + DocPropertyName).val(ids);
  1475. }
  1476. CheckBoxClickSingle(DocPropertyId, DocPropertyName) {
  1477. if ($("#chk_" + DocPropertyName).is(':checked')) {
  1478. $("#hdnchk_" + DocPropertyName).val("true");
  1479. }
  1480. else {
  1481. $("#hdnchk_" + DocPropertyName).val("false");
  1482. }
  1483. }
  1484. static Instance() {
  1485. if (this.instance === undefined) {
  1486. this.instance = new CheckBox();
  1487. }
  1488. return this.instance;
  1489. }
  1490. }
  1491. Controls.CheckBox = CheckBox;
  1492. })(Controls = Forms.Controls || (Forms.Controls = {}));
  1493. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  1494. })(Unibase || (Unibase = {}));
  1495. var Unibase;
  1496. (function (Unibase) {
  1497. let Forms;
  1498. (function (Forms) {
  1499. let Controls;
  1500. (function (Controls) {
  1501. class DatePicker {
  1502. constructor() {
  1503. this._bizgaze_dateFormat = 'DD/MM/YYYY';
  1504. this.IsTimePicker = false;
  1505. this._time = false;
  1506. this.propval = "";
  1507. this.dtime = false;
  1508. this.disableFutureDate = false;
  1509. }
  1510. init(formpropertyid, prop, callback) {
  1511. var instance = DatePicker.Instance();
  1512. let TimePicker = prop.PropertySettings.filter(t => t.ControlPropertyName == "IsTime" && t.ControlPropertyValue == "true");
  1513. if (TimePicker.length > 0) {
  1514. instance.IsTimePicker = true;
  1515. }
  1516. else {
  1517. instance.IsTimePicker = false;
  1518. }
  1519. if (callback != null && callback != 1)
  1520. callback();
  1521. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  1522. var container = "control-container-" + formpropertyid;
  1523. $("#" + container).find('#date_' + prop.FormPropertyId + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  1524. $("#" + container).find('#date_' + prop.FormPropertyId).val(picker.startDate.format('YYYY/MM/DD'));
  1525. });
  1526. var currentYear = (new Date()).getFullYear();
  1527. if (this._time == true) {
  1528. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1529. autoUpdateInput: false,
  1530. timePicker: true,
  1531. timePicker24Hour: true,
  1532. locale: {
  1533. format: 'DD/MM/YYYY HH:mm',
  1534. firstDay: 1,
  1535. },
  1536. singleDatePicker: true,
  1537. showDropdowns: true,
  1538. minYear: 1901,
  1539. });
  1540. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  1541. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  1542. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  1543. });
  1544. this._time = false;
  1545. }
  1546. else {
  1547. $("#" + container).find('#date_' + prop.FormPropertyId).daterangepicker({
  1548. locale: {
  1549. format: 'DD/MM/YYYY',
  1550. firstDay: 1,
  1551. },
  1552. singleDatePicker: true,
  1553. showDropdowns: true,
  1554. minYear: 1901,
  1555. maxDate: new Date(2050, 11, 31)
  1556. }, function (start, end, label) {
  1557. $("#" + container).find('#hfdate_' + prop.FormPropertyId).val(end.format('YYYY-MM-DD'));
  1558. });
  1559. }
  1560. if (instance.propval == "") {
  1561. $("#" + container).find('#date_' + prop.FormPropertyId).val('');
  1562. }
  1563. $(".date_" + prop.DocPropertyName).keypress(function (e) {
  1564. $(".date_" + prop.DocPropertyName).attr("maxlength", "10");
  1565. if (e.which != 8 && e.which != 0 && (e.which < 47 || e.which > 57)) {
  1566. return false;
  1567. }
  1568. else {
  1569. var value = $(".date_" + prop.DocPropertyName).val().toString().replace(/^(\d\d)(\d)$/g, '$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/[^\d\/]/g, '');
  1570. $(".date_" + prop.DocPropertyName).val(value);
  1571. }
  1572. });
  1573. $(".date_" + prop.DocPropertyName).focusout(function (e) {
  1574. if ($(".date_" + prop.DocPropertyName).val() == "") {
  1575. $('#hfdate_' + prop.FormPropertyId).val("");
  1576. }
  1577. });
  1578. instance.loadPropertySettings(prop.PropertySettings, formpropertyid, prop.DocPropertyName);
  1579. }
  1580. loadControl(containerid, prop) {
  1581. var regExpr = "";
  1582. var ErrMsg = "";
  1583. var validationlist = prop.Validations;
  1584. if (validationlist != null) {
  1585. for (var i = 0; i < validationlist.length; i++) {
  1586. regExpr += validationlist[i].RegularExp + '||';
  1587. ErrMsg += validationlist[i].ErrorMessage + '||';
  1588. }
  1589. }
  1590. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  1591. var requiredClass = prop.IsRequired != true ? '' : 'required';
  1592. var reqMark = prop.IsRequired != true ? '' : '*';
  1593. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  1594. if (prop.IncludedStages != null && prop.IncludedStages != "") {
  1595. var StagesForRequired = prop.IncludedStages.split('|');
  1596. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  1597. requiredClass = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  1598. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  1599. }
  1600. if (prop.ExcludedStages != null && prop.ExcludedStages != "") {
  1601. var ExcludedStages = prop.ExcludedStages.split('|');
  1602. Isrequired = ExcludedStages.find(x => x == CurrentStageId) ? 'hidden' : '';
  1603. requiredClass = ExcludedStages.find(x => x == CurrentStageId) ? '' : 'required';
  1604. reqMark = ExcludedStages.find(x => x == CurrentStageId) ? '' : '*';
  1605. }
  1606. let ControlId = 'txt_' + prop.DocPropertyId;
  1607. if (prop.IsRequired)
  1608. requiredClass = 'required';
  1609. let isReadOnly = '';
  1610. if (!Unibase.Themes.Compact.Components.Index.Instance().desktopMode) {
  1611. isReadOnly = 'readonly';
  1612. }
  1613. const { helpTooltipHtml, helpTextHtml, helpClass } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  1614. let html = `<div class="floating-label-form-group CancelBtnFloating_${prop.UniqueId} ${helpClass}" id ="div_${prop.UniqueId}">` +
  1615. '<label for="lbl" id="lbl_' + prop.ControlId + '">' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyId + '"> *</span></label>' +
  1616. '<div class="input-group">' +
  1617. '<input type="hidden" id="hfdate_' + prop.UniqueId + '" class="value-control hfdate_' + prop.DocPropertyName + '" value=""/>' +
  1618. '<input type="text" id="date_' + prop.UniqueId + '" class="form-control type-control datepicker-input hasDatepicker ' + requiredClass + ' floating-label-control txt_' + prop.UniqueId + ' date_' + prop.DocPropertyName + '" placeholder="' + prop.LabelName + " " + reqMark + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + " " + reqMark + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '"' + isReadOnly + '>' +
  1619. '<span class="input-group-addon mt-10 cursor-pointer"><i class="fa fa-calendar calender_' + prop.DocPropertyName + '"></i></span>' +
  1620. '<input type="hidden" id="hf_' + prop.ControlId + '" /></div>' + helpTextHtml + '</div>';
  1621. $("#" + containerid).append(html);
  1622. Unibase.Forms.Controls.DatePicker.Instance().loadDate(prop.UniqueId, prop);
  1623. }
  1624. loadControlSettings(controlsettingjson, formpropertyid) {
  1625. return null;
  1626. }
  1627. loadDate(formpropertyid, prop) {
  1628. var container = "control-container-" + formpropertyid;
  1629. if (this._time == true) {
  1630. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1631. autoUpdateInput: false,
  1632. timePicker: true,
  1633. timePicker24Hour: true,
  1634. locale: {
  1635. format: 'DD/MM/YYYY HH:mm',
  1636. firstDay: 1,
  1637. },
  1638. singleDatePicker: true,
  1639. showDropdowns: true,
  1640. minYear: 1901,
  1641. });
  1642. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  1643. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  1644. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  1645. });
  1646. this._time = false;
  1647. }
  1648. else {
  1649. $("#" + container).find('#date_' + prop.FormPropertyId).daterangepicker({
  1650. locale: {
  1651. format: 'DD/MM/YYYY',
  1652. firstDay: 1,
  1653. },
  1654. singleDatePicker: true,
  1655. showDropdowns: true,
  1656. minYear: 1901,
  1657. }, function (start, end, label) {
  1658. $("#" + container).find('#hfdate_' + prop.FormPropertyId).val(end.format('YYYY-MM-DD'));
  1659. });
  1660. }
  1661. $(`.calender_${prop.DocPropertyName}`).click(function () {
  1662. $(this).parents('.input-group').find('.datepicker-input').trigger('click');
  1663. });
  1664. }
  1665. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  1666. var instance = this;
  1667. var istime = false;
  1668. var dateNow = new Date();
  1669. var container = "control-container-" + formpropertyid;
  1670. if (propertysettings != null) {
  1671. for (var i = 0; i < propertysettings.length; i++) {
  1672. var data = propertysettings[i];
  1673. if (data.ControlPropertyName == "IsTodayDate") {
  1674. if (data.ControlPropertyValue == "true") {
  1675. var DateTime_Value = $("#" + container).find('#date_' + formpropertyid).val();
  1676. if (DateTime_Value == "") {
  1677. var maxDate;
  1678. if (instance.disableFutureDate)
  1679. maxDate = new Date();
  1680. else
  1681. maxDate = new Date(2050, 11, 31);
  1682. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1683. singleDatePicker: true,
  1684. showDropdowns: true,
  1685. minYear: 1901,
  1686. locale: {
  1687. format: 'DD/MM/YYYY',
  1688. firstDay: 1,
  1689. },
  1690. maxDate: maxDate
  1691. });
  1692. var todayDate = $("#" + container).find('#date_' + formpropertyid).val();
  1693. var hfformat = "YYYY/MM/DD";
  1694. var tdate = moment(todayDate, "DD/MM/YYYY").format("YYYY/MM/DD");
  1695. $("#" + container).find('#hfdate_' + formpropertyid).val(tdate);
  1696. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  1697. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY'));
  1698. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD'));
  1699. $("#" + container).find('#div_' + formpropertyid).addClass('floating-label-form-group-with-value');
  1700. });
  1701. }
  1702. $("#" + container).find('#div_' + formpropertyid).addClass('floating-label-form-group-with-value');
  1703. $("#" + container).find('#date_' + formpropertyid).keypress(function (e) {
  1704. $(this).attr("maxlength", "10");
  1705. if (e.which != 8 && e.which != 0 && (e.which < 47 || e.which > 57)) {
  1706. return false;
  1707. }
  1708. else {
  1709. var value = $(this).val().toString().replace(/^(\d\d)(\d)$/g, '$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/[^\d\/]/g, '');
  1710. $(this).val(value);
  1711. }
  1712. });
  1713. if (instance.dtime == false) {
  1714. if (istime == true) {
  1715. var DateTime_Value = $("#" + container).find('#date_' + formpropertyid).val();
  1716. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1717. autoUpdateInput: false,
  1718. timePicker: true,
  1719. timePicker24Hour: true,
  1720. singleDatePicker: true,
  1721. showDropdowns: true,
  1722. minYear: 1901,
  1723. locale: {
  1724. format: 'DD/MM/YYYY HH:mm',
  1725. firstDay: 1,
  1726. },
  1727. });
  1728. var cdate = new Date();
  1729. var currentdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalTime(cdate, "DD/MM/YYYY HH:mm");
  1730. $("#" + container).find('#date_' + formpropertyid).val(currentdate);
  1731. var hfcdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDateTime(cdate, "YYYY/MM/DD HH:mm");
  1732. $("#" + container).find('#hfdate_' + formpropertyid).val(hfcdate);
  1733. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  1734. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  1735. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  1736. });
  1737. let curren = new Date();
  1738. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('show.daterangepicker', function (ev, picker) {
  1739. var dateTime_New = $("#" + container).find('#date_' + formpropertyid).val();
  1740. var hours = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") - 2, dateTime_New.toString().indexOf(":"));
  1741. if (hours.substring(0, 1) == "0") {
  1742. hours = hours.substring(1);
  1743. }
  1744. var minutes = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") + 1, dateTime_New.toString().indexOf(":") + 3);
  1745. if (minutes.substring(0, 1) == "0") {
  1746. minutes = minutes.substring(1);
  1747. }
  1748. $('.show-calendar').find('.hourselect option:selected').removeAttr('selected');
  1749. $('.show-calendar').find('.minuteselect option:selected').removeAttr('selected');
  1750. $('.hourselect option[value="' + hours + '"]').attr("selected", "selected");
  1751. $('.minuteselect option[value="' + minutes + '"]').attr("selected", "selected");
  1752. });
  1753. }
  1754. }
  1755. }
  1756. }
  1757. if (data.ControlPropertyName == "IsTime") {
  1758. if (instance.dtime == false) {
  1759. if (data.ControlPropertyValue == "true") {
  1760. istime = true;
  1761. var DateTime_Value = $("#" + container).find('#date_' + formpropertyid).val();
  1762. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1763. autoUpdateInput: false,
  1764. timePicker: true,
  1765. timePicker24Hour: true,
  1766. singleDatePicker: true,
  1767. showDropdowns: true,
  1768. minYear: 1901,
  1769. locale: {
  1770. format: 'DD/MM/YYYY HH:mm',
  1771. firstDay: 1,
  1772. },
  1773. });
  1774. var cdate = new Date();
  1775. var currentdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalTime(cdate, "DD/MM/YYYY HH:mm");
  1776. $("#" + container).find('#date_' + formpropertyid).val(currentdate);
  1777. var hfcdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDateTime(cdate, "YYYY/MM/DD HH:mm");
  1778. $("#" + container).find('#hfdate_' + formpropertyid).val(hfcdate);
  1779. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  1780. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  1781. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  1782. });
  1783. let curren = new Date();
  1784. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('show.daterangepicker', function (ev, picker) {
  1785. var dateTime_New = $("#" + container).find('#date_' + formpropertyid).val();
  1786. var hours = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") - 2, dateTime_New.toString().indexOf(":"));
  1787. if (hours.substring(0, 1) == "0") {
  1788. hours = hours.substring(1);
  1789. }
  1790. var minutes = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") + 1, dateTime_New.toString().indexOf(":") + 3);
  1791. if (minutes.substring(0, 1) == "0") {
  1792. minutes = minutes.substring(1);
  1793. }
  1794. $('.show-calendar').find('.hourselect option:selected').removeAttr('selected');
  1795. $('.show-calendar').find('.minuteselect option:selected').removeAttr('selected');
  1796. $('.hourselect option[value="' + hours + '"]').attr("selected", "selected");
  1797. $('.minuteselect option[value="' + minutes + '"]').attr("selected", "selected");
  1798. });
  1799. $(".hasDatepicker").keypress(function (e) {
  1800. $(this).attr("maxlength", "19");
  1801. var value = $(this).val().toString().replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/^(\d\d\/\d\d\/\d\d\d\d)(\d)/g, '$1 ').replace(/^(\d\d\/\d\d\/\d\d\d\d\s\d\d)(\d)/g, '$1:$2$2:');
  1802. $(this).val(value);
  1803. });
  1804. }
  1805. }
  1806. }
  1807. if (data.ControlPropertyName == "DisableFutureDate") {
  1808. if (data.ControlPropertyValue == "true") {
  1809. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1810. singleDatePicker: true,
  1811. showDropdowns: true,
  1812. autoUpdateInput: false,
  1813. minYear: 1901,
  1814. maxDate: new Date(),
  1815. locale: {
  1816. format: 'DD/MM/YYYY',
  1817. firstDay: 1,
  1818. },
  1819. }, function (start, end, label) {
  1820. $("#" + container).find('#hfdate_' + formpropertyid).val(end.format('YYYY-MM-DD'));
  1821. });
  1822. $('#date_' + formpropertyid + '.datepicker-input').keyup(function (e) {
  1823. let dateString = $(this).val();
  1824. let errorMsgDiv = $(this).parents('.formValidate').find('.form-error-message').attr('id');
  1825. let myDate = moment(dateString, ['DD/MM/YYYY', 'D/M/YYYY', 'DD/M/YYYY', 'D/MM/YYYY'], true);
  1826. MessageHelper.Instance().hideMessage();
  1827. $(this).attr('data-isValid', 'false');
  1828. if (dateString.length >= 8 && dateString != "") {
  1829. if (myDate.isValid() == false) {
  1830. MessageHelper.Instance().showError('Enter Correct Date Format!.', errorMsgDiv);
  1831. }
  1832. else if (moment(dateString, 'DD/MM/YYYY').isSameOrBefore(moment().format()) == false) {
  1833. MessageHelper.Instance().showError('You cannot enter a date in the future.', errorMsgDiv);
  1834. }
  1835. else if (moment(dateString, 'DD/MM/YYYY').isSameOrAfter('01/01/1901', 'year') == false) {
  1836. MessageHelper.Instance().showError('You cannot enter a date before 1901.', errorMsgDiv);
  1837. }
  1838. else {
  1839. MessageHelper.Instance().hideMessage();
  1840. $('#hfdate_' + formpropertyid).val(moment(dateString, 'DD/MM/YYYY').format('YYYY-MM-DD'));
  1841. $(this).attr('data-isValid', 'true');
  1842. }
  1843. }
  1844. });
  1845. instance.disableFutureDate = true;
  1846. $('#date_' + formpropertyid + '.datepicker-input').focusout(function (e) {
  1847. let isDateValid = $(this).attr('data-isValid');
  1848. if (isDateValid == 'false') {
  1849. $(this).val("");
  1850. $('#hfdate_' + formpropertyid).val("");
  1851. $(this).attr('data-isValid', 'true');
  1852. }
  1853. });
  1854. }
  1855. }
  1856. }
  1857. }
  1858. instance.propval = "";
  1859. instance.dtime = false;
  1860. }
  1861. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  1862. var instance = this;
  1863. var format = "DD/MM/YYYY";
  1864. var hfformat = "YYYY/MM/DD";
  1865. var hfdate = "";
  1866. if (instance.IsTimePicker) {
  1867. instance.propval = moment(propval).format("DD/MM/YYYY HH:mm");
  1868. hfdate = moment(propval).format("YYYY/MM/DD HH:mm");
  1869. instance._time = true;
  1870. $('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  1871. autoUpdateInput: false,
  1872. timePicker: true,
  1873. timePicker24Hour: true,
  1874. singleDatePicker: true,
  1875. showDropdowns: true,
  1876. minYear: 1901,
  1877. locale: {
  1878. format: 'DD/MM/YYYY HH:mm',
  1879. firstDay: 1,
  1880. },
  1881. });
  1882. instance.dtime = true;
  1883. }
  1884. else {
  1885. instance.propval = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(propval, format);
  1886. hfdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDate(propval, hfformat);
  1887. }
  1888. var formattedPropVal = Unibase.Platform.Helpers.DateTimeHelper.Instance().serverDateformat(instance.propval);
  1889. if (instance.propval == "Invalid date" || formattedPropVal == "01/01/1901" || formattedPropVal == "01/01/1900" || formattedPropVal == "01/01/2001" || formattedPropVal == "01/01/0001") {
  1890. instance.propval = "";
  1891. }
  1892. $("#hfdate_" + formpropertyid).val(hfdate);
  1893. $("#date_" + formpropertyid).val(instance.propval);
  1894. if ($("#date_" + formpropertyid).val() != "") {
  1895. $("#div_" + formpropertyid).addClass("floating-label-form-group-with-value");
  1896. }
  1897. }
  1898. static Instance() {
  1899. if (this.instance === undefined)
  1900. this.instance = new DatePicker();
  1901. return this.instance;
  1902. }
  1903. }
  1904. Controls.DatePicker = DatePicker;
  1905. })(Controls = Forms.Controls || (Forms.Controls = {}));
  1906. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  1907. })(Unibase || (Unibase = {}));
  1908. var Unibase;
  1909. (function (Unibase) {
  1910. let Forms;
  1911. (function (Forms) {
  1912. let Controls;
  1913. (function (Controls) {
  1914. class TextBox {
  1915. init(formpropertyid, prop, callback) {
  1916. var instance = TextBox.Instance();
  1917. instance.loadControlSettings(prop.ControlJsonText, prop.UniqueId);
  1918. instance.loadPropertySettings(prop.PropertySettings, prop.UniqueId);
  1919. if (callback != null)
  1920. callback();
  1921. }
  1922. loadControl(containerid, prop) {
  1923. var regExpr = "";
  1924. var ErrMsg = "";
  1925. var validationlist = prop.Validations;
  1926. if (validationlist != null) {
  1927. for (var i = 0; i < validationlist.length; i++) {
  1928. regExpr += validationlist[i].RegularExp + '||';
  1929. ErrMsg += validationlist[i].ErrorMessage + '||';
  1930. }
  1931. }
  1932. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  1933. var requiredClass = prop.IsRequired != true ? '' : 'required';
  1934. var reqMark = prop.IsRequired != true ? '' : '*';
  1935. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  1936. if (prop.IncludedStages != null && prop.IncludedStages != "") {
  1937. var StagesForRequired = prop.IncludedStages.split('|');
  1938. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  1939. requiredClass = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  1940. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  1941. }
  1942. if (prop.ExcludedStages != null && prop.ExcludedStages != "") {
  1943. var ExcludedStages = prop.ExcludedStages.split('|');
  1944. Isrequired = ExcludedStages.find(x => x == CurrentStageId) ? 'hidden' : '';
  1945. requiredClass = ExcludedStages.find(x => x == CurrentStageId) ? '' : 'required';
  1946. reqMark = ExcludedStages.find(x => x == CurrentStageId) ? '' : '*';
  1947. }
  1948. let ControlId = 'txt_' + prop.UniqueId;
  1949. if (prop.IsRequired)
  1950. requiredClass = 'required';
  1951. const { helpTooltipHtml, helpTextHtml, helpClass } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  1952. let html = `<div class="floating-label-form-group div_txt div_${prop.DocPropertyName} ${helpClass}" id="TxtDiv_${prop.FormPropertyId}">
  1953. <label for="lbl" id="lbl_${ControlId}" class="lbl_txt">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger ${Isrequired}" id="spnIsRequired_${prop.FormPropertyId}"> *</span></label>
  1954. <input type="text" id="${ControlId}" class="type-control form-control type-control value-control ${requiredClass} floating-label-control txt_${prop.DocPropertyName}" placeholder="${prop.LabelName} ${reqMark}" data-placeholder="${prop.Placeholder}" data-label="${prop.LabelName} ${reqMark}" data-regularexp="${regExpr}" data-validatemsg="${ErrMsg}">
  1955. <input type="hidden" id="hf_${prop.ControlId}" />
  1956. ${helpTextHtml}
  1957. </div>`;
  1958. $("#" + containerid).append(html);
  1959. }
  1960. loadControlSettings(controlsettingjson, formpropertyid) {
  1961. return null;
  1962. }
  1963. loadPropertySettings(propertysettings, formpropertyid) {
  1964. if (propertysettings != null) {
  1965. for (var i = 0; i < propertysettings.length; i++) {
  1966. var data = propertysettings[i];
  1967. if (data.ControlPropertyName == "MaxLength" && data.ControlPropertyValue != "") {
  1968. $("#txt_" + formpropertyid).attr("MaxLength", data.ControlPropertyValue);
  1969. }
  1970. }
  1971. }
  1972. }
  1973. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  1974. if (propval == 'null')
  1975. propval = '';
  1976. var decodeText = unescape(propval);
  1977. $("#txt_" + formpropertyid).val(decodeText);
  1978. if (decodeText != "") {
  1979. $("#TxtDiv_" + formpropertyid).addClass("floating-label-form-group-with-value");
  1980. }
  1981. }
  1982. static Instance() {
  1983. if (this.instance === undefined) {
  1984. this.instance = new TextBox();
  1985. }
  1986. return this.instance;
  1987. }
  1988. }
  1989. Controls.TextBox = TextBox;
  1990. })(Controls = Forms.Controls || (Forms.Controls = {}));
  1991. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  1992. })(Unibase || (Unibase = {}));
  1993. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1994. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1995. return new (P || (P = Promise))(function (resolve, reject) {
  1996. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1997. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1998. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1999. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2000. });
  2001. };
  2002. var Unibase;
  2003. (function (Unibase) {
  2004. let Forms;
  2005. (function (Forms) {
  2006. let Controls;
  2007. (function (Controls) {
  2008. class Dropdown extends Unibase.Platform.Core.BaseComponent {
  2009. constructor() {
  2010. super(...arguments);
  2011. this.loadCascading = true;
  2012. }
  2013. init(formpropertyid, prop, callback) {
  2014. var instance = new Dropdown();
  2015. instance.loadControlSettings(prop, prop.UniqueId).then(function () {
  2016. if (callback != null)
  2017. callback();
  2018. });
  2019. $('#ddl_' + prop.DocPropertyName + '').focusin(function () {
  2020. $('#ddl_' + prop.DocPropertyName + '').attr('style', 'border:solid 2px rgb(0, 165, 230);border-radius:5px;border-shadow: 3px 3px 3px 3px;');
  2021. });
  2022. $('#ddl_' + prop.DocPropertyName + '').focusout(function () {
  2023. $('#ddl_' + prop.DocPropertyName + '').attr('style', 'none');
  2024. });
  2025. }
  2026. loadControl(containerid, prop) {
  2027. var instance = this;
  2028. var jsfiles = ["platform/controls/cascadingautocomplete/cascadingautocomplete.component.js", "platform/controls/cascadingautocomplete/cascadingautocomplete.settings.js"];
  2029. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  2030. var required = prop.IsRequired != true ? '' : 'required';
  2031. var CurrentStageId = '';
  2032. if (prop.IncludedStages != null && prop.IncludedStages != "") {
  2033. var StagesForRequired = prop.IncludedStages.split('|');
  2034. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  2035. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  2036. }
  2037. var dropdownJson = JSON.parse(prop.ControlJsonText);
  2038. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  2039. var html = '<div id="div_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '" class="div_' + prop.FormPropertyId + ' floating-label-form-group-with-value">' +
  2040. '<label for="lbl" id="lbl_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '">' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '"> *</span></label>' +
  2041. '<select id="ddl_' + prop.UniqueId + '" class="form-control type-control ' + required + ' value-control dropdown_' + prop.DocPropertyName + '" data-propertyname="" data-isdefault="' + prop.IsDefault + '" data-propdoctypename="' + prop.DocPropertyName + '" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-isparent="false">';
  2042. if (dropdownJson[0].EnableSelectOption == true) {
  2043. if (prop.IsRequired) {
  2044. html += '<option value="">--Select--</option>';
  2045. }
  2046. else {
  2047. html += '<option value="0">--Select--</option>';
  2048. }
  2049. }
  2050. html += '</select>' + helpTextHtml +
  2051. '</div>';
  2052. $("#" + containerid).html(html);
  2053. $("#" + containerid).find("#ddl_" + prop.UniqueId).on('change', function () {
  2054. instance.fileCacheHelper.loadJsFiles(jsfiles, function () {
  2055. if (instance.loadCascading) {
  2056. Unibase.Forms.Controls.CascadingAutocomplete.Instance().ChildCascadingData(false, prop.FormPropertyId, 0, 0, '');
  2057. }
  2058. instance.loadCascading = true;
  2059. });
  2060. });
  2061. }
  2062. loadControlSettings(controlsettingjson, formpropertyid) {
  2063. return __awaiter(this, void 0, void 0, function* () {
  2064. if (controlsettingjson != "" && controlsettingjson != null && controlsettingjson != undefined) {
  2065. var container = "control-container-" + formpropertyid;
  2066. var response = JSON.parse(controlsettingjson.ControlJsonText);
  2067. if (response != null) {
  2068. if ((response.length == 1) && (response[0].ReportId != 0)) {
  2069. yield Unibase.Platform.Forms.Managers.FormManager.Instance().dynamicDropDown(response[0].DropDownColumnId).then(function (res) {
  2070. var drpDwnData = [];
  2071. let result = res.result;
  2072. for (let i = 0; i < result.length; i++) {
  2073. var drpDwn = result[i];
  2074. drpDwnData.push({ id: drpDwn.ColumnText, text: drpDwn.ColumnValue });
  2075. }
  2076. $('#' + container).find("#ddl_" + formpropertyid).select2({
  2077. placeholder: 'Select',
  2078. theme: "default select2ErrorClass",
  2079. data: drpDwnData,
  2080. width: '100%',
  2081. });
  2082. });
  2083. }
  2084. else {
  2085. $('#' + container).find("#ddl_" + controlsettingjson.DocPropertyName).find('option').remove();
  2086. var data = '';
  2087. for (var i = 0; i < response.length; i++) {
  2088. var columnvalue = controlsettingjson.datatypeid == 3 ? response[i].ColumnNumber : response[i].ColumnValue;
  2089. if (response[i].IsParent == true) {
  2090. $('#' + container).find("#ddl_" + controlsettingjson.DocPropertyName).data("isparent", response[i].IsParent);
  2091. }
  2092. data += '<option value="' + columnvalue + '" columnvalue="' + response[i].DropDownColumnId + '">' + response[i].ColumnText + '</option>';
  2093. }
  2094. $('#' + container).find("#ddl_" + formpropertyid).append(data);
  2095. }
  2096. }
  2097. }
  2098. });
  2099. }
  2100. loadPropertySettings(propertysettings, formpropertyid) {
  2101. return null;
  2102. }
  2103. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  2104. var instance = this;
  2105. instance.loadCascading = false;
  2106. $("#ddl_" + formpropertyid).val(propval).trigger('change');
  2107. }
  2108. static Instance() {
  2109. if (this._instance === undefined)
  2110. this._instance = new Dropdown();
  2111. return this._instance;
  2112. }
  2113. }
  2114. Controls.Dropdown = Dropdown;
  2115. })(Controls = Forms.Controls || (Forms.Controls = {}));
  2116. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  2117. })(Unibase || (Unibase = {}));
  2118. var Unibase;
  2119. (function (Unibase) {
  2120. let Forms;
  2121. (function (Forms) {
  2122. let Controls;
  2123. (function (Controls) {
  2124. class TextEditor extends Unibase.Platform.Core.BaseComponent {
  2125. init(formpropertyid, prop, callback) {
  2126. var instance = new TextEditor();
  2127. var container = "control-container-" + formpropertyid;
  2128. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  2129. var summernoteid = $("#" + container).find(".txtSummernote_" + prop.DocPropertyName).attr('id');
  2130. var data = null;
  2131. if (prop.ControlJsonText != "") {
  2132. data = JSON.parse(prop.ControlJsonText);
  2133. }
  2134. if (data != null) {
  2135. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getHeaderColumns(data.TokenReportId).then(function (response) {
  2136. var Data = new Array();
  2137. for (let i = 0; i < response.length; i++) {
  2138. var result = response[i].title;
  2139. Data.push(result);
  2140. }
  2141. var placeholder = $("#summernote_" + prop.FormPropertyId).data('placeholder');
  2142. var _fileCacheHelper = instance.fileCacheHelper;
  2143. _fileCacheHelper.loadJsFile("libs/summernote/summernote.min.js", function () {
  2144. _fileCacheHelper.loadCssFile("libs/summernote/summernote.css", function () {
  2145. instance.loadSummernote(prop.FormPropertyId, placeholder, Data);
  2146. });
  2147. });
  2148. });
  2149. }
  2150. else {
  2151. var placeholder = $("#summernote_" + prop.FormPropertyId).data('placeholder');
  2152. var _fileCacheHelper = instance.fileCacheHelper;
  2153. _fileCacheHelper.loadJsFile("libs/summernote/summernote.min.js", function () {
  2154. _fileCacheHelper.loadCssFile("libs/summernote/summernote.css", function () {
  2155. instance.loadSummernote(prop.FormPropertyId, placeholder, Unibase.Data);
  2156. });
  2157. });
  2158. }
  2159. $(".divCustomProperties_" + prop.DocPropertyName).find('.note-editor').find('.note-eventButton').addClass('hidden');
  2160. $(".divCustomProperties_" + prop.DocPropertyName).find(".note-editable").attr("id", "note-editable" + prop.DocPropertyName);
  2161. if (prop.ControlJsonText != "") {
  2162. data = JSON.parse(prop.ControlJsonText);
  2163. }
  2164. if (data != "" && data != null) {
  2165. if (data.tokenreportid != 0) {
  2166. $(".divCustomProperties_" + prop.DocPropertyName).find('.note-editor').find('.note-eventButton').removeClass('hidden');
  2167. $("#SummerNoteToken_" + prop.DocPropertyName).change(function () {
  2168. var tokentext = $("#SummerNoteToken_" + prop.DocPropertyName + " option:selected").text();
  2169. var tokenlisttext = "{{" + tokentext + "}}";
  2170. $(".summernote_" + prop.DocPropertyName).summernote('editor.restoreRange');
  2171. $(".summernote_" + prop.DocPropertyName).summernote('editor.focus');
  2172. $(".summernote_" + prop.DocPropertyName).summernote('editor.insertText', tokenlisttext);
  2173. $("#SummerNoteToken_" + prop.DocPropertyName).text("Tokens");
  2174. });
  2175. $("#SummerNoteToken_" + prop.DocPropertyName).css("height", "35").css("width", "102").css("padding-right", "0").css("padding-top", "1");
  2176. $("#SummerNoteToken_" + prop.DocPropertyName).parent().css("height", "40").css("width", "200").css("padding-left", "-10px").css("padding-top", "-10px").css("margin-top", "-2px");
  2177. $("#SummerNoteToken_" + prop.DocPropertyName).parent().parent().css("height", "35").css("padding", "0").css("background-color", "transparent");
  2178. $('.select2-container--default').css('width', '100%');
  2179. }
  2180. else {
  2181. $(".divCustomProperties_" + prop.DocPropertyName).find('.note-editor').find('.note-eventButton').addClass('hidden');
  2182. }
  2183. }
  2184. else {
  2185. $(".divCustomProperties_" + prop.DocPropertyName).find('.note-editor').find('.note-eventButton').addClass('hidden');
  2186. }
  2187. if (callback != null)
  2188. callback();
  2189. }
  2190. loadSummernote(FormPropertyId, Placeholder, Data) {
  2191. $(".summernote_" + FormPropertyId).summernote({
  2192. height: 100,
  2193. minHeight: null,
  2194. maxHeight: null,
  2195. placeholder: Placeholder,
  2196. disableDragAndDrop: true,
  2197. codemirror: {
  2198. mode: 'text/html',
  2199. lineNumbers: true
  2200. },
  2201. toolbar: [
  2202. ['font', ['bold', 'italic', 'underline']],
  2203. ['color', ['color']],
  2204. ['view', ['fullscreen', 'codeview', 'help']],
  2205. ['table', ['table']],
  2206. ],
  2207. hint: {
  2208. match: /\B[@!](\w*)$/,
  2209. search: function (keyword, callback) {
  2210. callback($.grep(Data, function (i) {
  2211. var user = i;
  2212. return user.indexOf(keyword) === 0;
  2213. }));
  2214. },
  2215. content: function (i) {
  2216. var user = i;
  2217. return $('<span>@' + user + '</span>')[0];
  2218. }
  2219. }
  2220. });
  2221. $(".note-editor").css("z-index", "0");
  2222. }
  2223. loadControl(containerid, prop) {
  2224. var regExpr = "";
  2225. var ErrMsg = "";
  2226. var validationlist = prop.Validations;
  2227. if (validationlist != null) {
  2228. for (var i = 0; i < validationlist.length; i++) {
  2229. regExpr += validationlist[i].RegularExp + '||';
  2230. ErrMsg += validationlist[i].ErrorMessage + '||';
  2231. }
  2232. }
  2233. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  2234. var required = prop.IsRequired != true ? '' : 'required';
  2235. var reqMark = prop.IsRequired != true ? '' : '*';
  2236. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  2237. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  2238. var StagesForRequired = prop.StagesForRequired.split('|');
  2239. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  2240. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  2241. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  2242. }
  2243. var isCodeView = "false";
  2244. var propSettings = prop.PropertySettings.find(x => x.ControlPropertyName == "IsCodeView");
  2245. if (propSettings != null || propSettings != undefined) {
  2246. if (propSettings.ControlPropertyValue == "true") {
  2247. isCodeView = "true";
  2248. }
  2249. }
  2250. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  2251. var html = '<div id="div" class="TextEditor"><input type="hidden" id="txthdn_' + prop.FormPropertyId + '" data-event="Unibase.Forms.Controls.TextEditor.Instance().getobj(' + prop.FormPropertyId + ',\'' + isCodeView + '\');" class="TextEditor value-control" data-iscodeview="' + isCodeView + '">' +
  2252. '<span class="text-danger ' + Isrequired + '" id = "spnIsRequired_' + prop.DocPropertyName + '" ></span >' +
  2253. '<div class="type-control summernote_' + prop.DocPropertyName + ' summernote_' + prop.FormPropertyId + ' ' + required + '" style="display: block;" id="summernote_' + prop.FormPropertyId + '" data-propdoctypename="' + prop.DocPropertyName + '" data-required="' + prop.IsRequired + '" data-regularexp="" data-validatemsg="" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-iscodeview="' + isCodeView + '"></div>' +
  2254. '<label for="Validation" id="lblValidation"></label></div>' + helpTooltipHtml + helpTextHtml;
  2255. if (isCodeView == "false") {
  2256. html = '<div class=""><input type="hidden" id="txthdn_' + prop.FormPropertyId + '" class="TextEditor" data-iscodeview="' + isCodeView + '">' +
  2257. '<div class="input-group">' +
  2258. '<textarea id="textarea_' + prop.FormPropertyId + '" class="type-control value-control floating-label-control" rows="5" style="width:100%;" placeholder="' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.Placeholder + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" data-event="Unibase.Forms.Controls.TextEditor.Instance().getobj(' + prop.FormPropertyId + ',\'' + isCodeView + '\');" ></textarea>' +
  2259. '</div></div>' + helpTooltipHtml + helpTextHtml;
  2260. }
  2261. $("#" + containerid).html(html);
  2262. $("#summernote_" + prop.FormPropertyId).on("summernote.change", function (e) {
  2263. var val = $("#control-container-" + prop.FormPropertyId).find('.note-editable').text();
  2264. });
  2265. }
  2266. loadControlSettings(controlsettingjson, formpropertyid) {
  2267. return null;
  2268. }
  2269. loadPropertySettings(propertysettings, formpropertyid) {
  2270. return null;
  2271. }
  2272. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  2273. var iscodeview = $("#txthdn_" + formpropertyid).data("iscodeview");
  2274. if (iscodeview == false) {
  2275. $("#textarea_" + formpropertyid).val(unescape(propval));
  2276. }
  2277. else {
  2278. var decodedData = unescape(propval);
  2279. var decode = HtmlHelper.getHelper().decode(decodedData);
  2280. $("#summernote_" + formpropertyid).summernote('code', decode);
  2281. }
  2282. }
  2283. getobj(formPropertyId, isCodeView) {
  2284. var finalval = "";
  2285. if (isCodeView == "false") {
  2286. finalval = $("#textarea_" + formPropertyId).val().toString();
  2287. finalval = finalval.trim();
  2288. }
  2289. else {
  2290. var code = $("#summernote_" + formPropertyId).summernote('code');
  2291. finalval = HtmlHelper.getHelper().encode(code);
  2292. finalval = finalval.trim();
  2293. }
  2294. return finalval;
  2295. }
  2296. static Instance() {
  2297. if (this.instance === undefined) {
  2298. this.instance = new TextEditor();
  2299. }
  2300. return this.instance;
  2301. }
  2302. }
  2303. Controls.TextEditor = TextEditor;
  2304. })(Controls = Forms.Controls || (Forms.Controls = {}));
  2305. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  2306. })(Unibase || (Unibase = {}));
  2307. var Unibase;
  2308. (function (Unibase) {
  2309. let Forms;
  2310. (function (Forms) {
  2311. let Controls;
  2312. (function (Controls) {
  2313. class hiddenfield {
  2314. init(formpropertyid, prop, callback) {
  2315. var instance = new hiddenfield();
  2316. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  2317. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  2318. if (callback != null)
  2319. callback();
  2320. }
  2321. loadControl(containerid, prop) {
  2322. var regExpr = "";
  2323. var ErrMsg = "";
  2324. var validationlist = prop.Validations;
  2325. if (validationlist != null) {
  2326. for (var i = 0; i < validationlist.length; i++) {
  2327. regExpr += validationlist[i].RegularExp + '||';
  2328. ErrMsg += validationlist[i].ErrorMessage + '||';
  2329. }
  2330. }
  2331. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  2332. var required = prop.IsRequired != true ? '' : 'required';
  2333. var reqMark = prop.IsRequired != true ? '' : '*';
  2334. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  2335. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  2336. var StagesForRequired = prop.StagesForRequired.split('|');
  2337. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  2338. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  2339. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  2340. }
  2341. var defaultvalue = "0";
  2342. if (prop.PropertySettings != null) {
  2343. for (var i = 0; i < prop.PropertySettings.length; i++) {
  2344. var data = prop.PropertySettings[i];
  2345. if (prop.DataTypeId == 9) {
  2346. if (data.ControlPropertyName == "DefaultValue" && data.ControlPropertyValue != "") {
  2347. defaultvalue = data.ControlPropertyValue;
  2348. }
  2349. }
  2350. }
  2351. }
  2352. let html = '<div class="hidden">' +
  2353. '<label for="lbl" id="lbl_' + prop.ControlId + '"><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyId + '"> *</span></label>' +
  2354. '<input type="hidden" id="hdn_' + prop.FormPropertyId + '" class="hdn_' + prop.DocPropertyName + ' form-control type-control value-control floating-label-control" placeholder="' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + reqMark + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" value="' + defaultvalue + '">' +
  2355. '</div>';
  2356. $("#" + containerid).html(html);
  2357. if (Unibase.Platform.Forms.Components.FormViewer.Instance().DesignerMode == false) {
  2358. $("#" + containerid).addClass("hidden");
  2359. }
  2360. else {
  2361. $("#" + containerid).removeClass("hidden");
  2362. }
  2363. $(".divCustomFormProperties[data-sectionname='Hidden']").css("height", "25");
  2364. }
  2365. loadControlSettings(controlsettingjson, formpropertyid) {
  2366. return null;
  2367. }
  2368. loadPropertySettings(propertysettings, formpropertyid) {
  2369. if (propertysettings != null) {
  2370. for (var i = 0; i < propertysettings.length; i++) {
  2371. var data = propertysettings[i];
  2372. if (data.ControlPropertyName == "DefaultValue" && data.ControlPropertyValue != "") {
  2373. $("#hdn_" + formpropertyid).attr("DefaultValue", data.ControlPropertyValue);
  2374. $("#hdn_" + formpropertyid).val(data.ControlPropertyValue);
  2375. }
  2376. }
  2377. }
  2378. }
  2379. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  2380. $("#hdn_" + formpropertyid).val(propval);
  2381. }
  2382. static Instance() {
  2383. if (this.instance === undefined) {
  2384. this.instance = new hiddenfield();
  2385. }
  2386. return this.instance;
  2387. }
  2388. }
  2389. Controls.hiddenfield = hiddenfield;
  2390. })(Controls = Forms.Controls || (Forms.Controls = {}));
  2391. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  2392. })(Unibase || (Unibase = {}));
  2393. var Unibase;
  2394. (function (Unibase) {
  2395. let Forms;
  2396. (function (Forms) {
  2397. let Controls;
  2398. (function (Controls) {
  2399. class CascadingAutocomplete {
  2400. constructor() {
  2401. this.cascadingArray = [];
  2402. this.loadCascading = true;
  2403. }
  2404. init(formpropertyid, prop, callback) {
  2405. var instance = CascadingAutocomplete.Instance();
  2406. var container = "control-container-" + formpropertyid;
  2407. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  2408. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  2409. if (callback != null)
  2410. callback();
  2411. }
  2412. loadControl(containerid, prop) {
  2413. var instance = this;
  2414. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  2415. var required = prop.IsRequired != true ? '' : 'required';
  2416. var reqMark = prop.IsRequired != true ? '' : '*';
  2417. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  2418. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  2419. var StagesForRequired = prop.StagesForRequired.split('|');
  2420. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  2421. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  2422. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  2423. }
  2424. var data = JSON.parse(prop.ControlJsonText);
  2425. var cascArray = CascadingAutocomplete.instance.cascadingArray;
  2426. var isexist = Unibase.Forms.Controls.CascadingAutocomplete.Instance().cascadingArray.find(x => x.UniqueId == prop.UniqueId) ? true : false;
  2427. data["UniqueId"] = prop.UniqueId;
  2428. if (isexist == false)
  2429. CascadingAutocomplete.instance.cascadingArray.push(data);
  2430. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  2431. var html = `<div id="div_${prop.UniqueId}">
  2432. <label for="ddl_cascading_${prop.UniqueId}" id="lbl_cascading_${prop.UniqueId}" class="font-bold" style="color:grey">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger ${Isrequired}" id="spnCascading_${prop.UniqueId}"> *</span></label>` +
  2433. '<div class="input-group">' +
  2434. '<select id="ddl_cascading_' + prop.UniqueId + '" class="ddl_cascading_' + prop.DocPropertyName + ' form-control type-control text-control ' + required + ' " data-isdefault="' + prop.IsDefault + '" style="width:100%;" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" value="0" ></select>' +
  2435. '<input type="hidden" id="hfddl_cascading_' + prop.UniqueId + '" value="0" data-autotextid="ddl_cascading_' + prop.UniqueId + '" class="hfAutoCompleteId_' + prop.DocPropertyName + ' form-control value-control" />' + helpTextHtml + '</div></div>';
  2436. $("#" + containerid).html(html);
  2437. $("#ddl_cascading_" + prop.UniqueId).select2({
  2438. placeholder: prop.Placeholder,
  2439. width: '100%',
  2440. });
  2441. $("#" + containerid).find("#ddl_cascading_" + prop.UniqueId).on('change', function () {
  2442. if (instance.loadCascading) {
  2443. Unibase.Forms.Controls.CascadingAutocomplete.Instance().ChildCascadingData(false, prop.FormPropertyId, Number($("#ddl_cascading_" + prop.UniqueId).val()), 0, '');
  2444. }
  2445. instance.loadCascading = true;
  2446. });
  2447. }
  2448. loadControlSettings(controlsettingjson, formpropertyid) {
  2449. return null;
  2450. }
  2451. loadPropertySettings(propertysettings, formpropertyid) {
  2452. return null;
  2453. }
  2454. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  2455. var instance = this;
  2456. if (propval != "") {
  2457. var cascInfo = JSON.parse(propval);
  2458. instance.ChildCascadingData(true, cascInfo.ParentFormPropertyId, cascInfo.ReportColumnText, cascInfo.ReportColumnValueId, cascInfo.ReportColumnValue);
  2459. if (cascInfo.ReportColumnValueId != 0) {
  2460. var cascOption = new Option(cascInfo.ReportColumnValue, cascInfo.ReportColumnValueId, true);
  2461. $("#ddl_cascading_" + formpropertyid).append(cascOption);
  2462. instance.loadCascading = false;
  2463. jQuery("#ddl_cascading_" + formpropertyid).val(cascInfo.ReportColumnValueId).trigger('change');
  2464. }
  2465. }
  2466. }
  2467. ChildCascadingData(isEditForm, ParentFormPropertyId, ParentTextColumnValue, Id, Value) {
  2468. var instance = this;
  2469. var hdn_cascading_array = CascadingAutocomplete.instance.cascadingArray;
  2470. if (hdn_cascading_array != undefined) {
  2471. var list = hdn_cascading_array.filter(x => x.ParentFormPropertyId == ParentFormPropertyId);
  2472. for (var i = 0; i < list.length; i++) {
  2473. var listitem = list[i];
  2474. var casFormPropId = listitem.UniqueId;
  2475. var response = listitem;
  2476. var reportId = response.ReportId;
  2477. var formPropertyId = response.FormPropertyId;
  2478. var parentFormPropertyId = response.ParentFormPropertyId;
  2479. var applyFor = response.ApplyFor;
  2480. var formId = Number($(".formValidate:visible").find("#hf_FormId").val());
  2481. if (!isEditForm) {
  2482. $("#ddl_cascading_" + casFormPropId).val(null).trigger("change");
  2483. }
  2484. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/getcascadingautocompletedata/formpropertyid/' + formPropertyId + '/parentidcolumn/' + applyFor + '/parentcolumnvalue/' + ParentTextColumnValue + '/parentformpropertyid/' + parentFormPropertyId;
  2485. AutoCompleteHelper.getHelper().Create("#ddl_cascading_" + casFormPropId, "#hfddl_cascading_" + casFormPropId, url, function (response) {
  2486. });
  2487. }
  2488. }
  2489. }
  2490. static Instance() {
  2491. if (this.instance === undefined) {
  2492. this.instance = new CascadingAutocomplete();
  2493. }
  2494. return this.instance;
  2495. }
  2496. }
  2497. Controls.CascadingAutocomplete = CascadingAutocomplete;
  2498. })(Controls = Forms.Controls || (Forms.Controls = {}));
  2499. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  2500. })(Unibase || (Unibase = {}));
  2501. var Unibase;
  2502. (function (Unibase) {
  2503. let Forms;
  2504. (function (Forms) {
  2505. let Controls;
  2506. (function (Controls) {
  2507. class CascadingAutocomplete_Settings {
  2508. loadControlPropertiesHtml(controlpropList, container) {
  2509. return ``;
  2510. }
  2511. bindPropertySettings(prop) {
  2512. var propertySettings = prop.PropertySettings;
  2513. return "";
  2514. }
  2515. savePropertySettings(prop) {
  2516. var propertySettings = prop.PropertySettings;
  2517. return "";
  2518. }
  2519. loadSettingHtml(container) {
  2520. let html = `<section class="card"><div class="card-header"><h6><b>Cascading Settings</b></h6></div><div class="card-body"><div class="row"><div class="col-sm-6 mt-10" id ="CasCadingdddDocProp"><label for="lblDocPropertyName" id="lblDocPropertyName" class="font-bold" style="color:grey">Parent Property<span class="text-danger" id="spnIsRequired_ParentProperty"> *</span></label><select id="ddlParentProperty" class="form-control value-control required" data-controlpropertyname="Width"></select><input type="hidden" id="hfddlParentProperty"/></div></div><div class="row"><div class="col-sm-6"><label class="font-bold" style="color:grey">Report<span class="text-danger" id="spnIsRequired_Report"> *</span></label><select id="ddl_cascAutocompleteReport" class="form-control value-control required" data-placeholder="Select" placeholder="Select"></select><input type="hidden" id="hfddl_cascAutocompleteReport" class="hfddl_cascAutocompleteReport form-control value-control" data-isdynamic="true"/></div></div><div class="row"><div class="col-sm-4"><label class="font-bold" style="color:grey">Id Column<span class="text-danger" id="spnIsRequired_IdColumn"> *</span></label><select id="ddl_cascAutocompleteIdColumn" class="form-control value-control required" data-placeholder="Select" placeholder="Select"></select><input type="hidden" id="hfddl_cascAutocompleteIdColumn" class="hfddl_cascAutocompleteIdColumn form-control value-control" data-isdynamic="true"/></div><div class="col-sm-4"><label class="font-bold" style="color:grey">Text Column<span class="text-danger" id="spnIsRequired_TextColumn"> *</span></label><select id="ddl_cascAutocompleteTextColumn" class="form-control value-control required" data-placeholder="Select" placeholder="Select"></select><input type="hidden" id="hfddl_cascAutocompleteTextColumn" class="hfddl_cascAutocompleteTextColumn form-control value-control" data-isdynamic="true"/></div><div class="col-sm-4"><label class="font-bold" style="color:grey">Apply For<span class="text-danger" id="spnIsRequired_ApplyFor"> *</span></label><select id="ddl_cascAutocompleteApplyFor" class="form-control value-control required" data-placeholder="Select" placeholder="Select"></select><input type="hidden" id="hfddl_cascAutocompleteApplyFor" class="hfddl_cascAutocompleteApplyFor form-control value-control" data-isdynamic="true"/></div></div></div></section>`;
  2521. $(container).append(html);
  2522. this.GetDocPropertyDetails();
  2523. $("#ddl_cascAutocompleteReport").on("change", function () {
  2524. $("#ddl_cascAutocompleteIdColumn").val(null).trigger("change");
  2525. $("#ddl_cascAutocompleteTextColumn").val(null).trigger("change");
  2526. });
  2527. }
  2528. bindControlData(controldatajson) {
  2529. if (controldatajson != undefined && controldatajson != "") {
  2530. var result = controldatajson;
  2531. var parentName = Unibase.Platform.Forms.Components.FormBuilder.Instance().FormPropertiesJson.find(x => x.FormPropertyId == result.ParentFormPropertyId).FormPropertyName;
  2532. var parent = new Option(parentName, result.ParentFormPropertyId, true);
  2533. $("#ddlParentProperty").append(parent);
  2534. jQuery("#ddlParentProperty").val(result.ParentFormPropertyId).trigger('change');
  2535. var report = new Option(result.ReportName, result.ReportId, true);
  2536. $("#ddl_cascAutocompleteReport").append(report);
  2537. jQuery("#ddl_cascAutocompleteReport").val(result.ReportId).trigger('change');
  2538. var reportColumnText = new Option(result.ReportColumnText, result.ReportColumnTextId, true);
  2539. $("#ddl_cascAutocompleteTextColumn").append(reportColumnText);
  2540. jQuery("#ddl_cascAutocompleteTextColumn").val(result.ReportColumnTextId).trigger('change');
  2541. var reportColumnValue = new Option(result.ReportColumnValue, result.ReportColumnValueId, true);
  2542. $("#ddl_cascAutocompleteIdColumn").append(reportColumnValue);
  2543. jQuery("#ddl_cascAutocompleteIdColumn").val(result.ReportColumnValueId).trigger('change');
  2544. var reportColumnApplyFor = new Option(result.ApplyFor, result.ApplyForId, true);
  2545. $("#ddl_cascAutocompleteApplyFor").append(reportColumnApplyFor);
  2546. jQuery("#ddl_cascAutocompleteApplyFor").val(result.ApplyForId).trigger('change');
  2547. }
  2548. }
  2549. GetDocPropertyDetails() {
  2550. let FormId = Unibase.Platform.Forms.Components.FormBuilder.Instance().FormId;
  2551. let CurDocPropertyId = Unibase.Platform.Forms.Components.PropertyEditor.Instance().DocPropertyId;
  2552. var parentProperties = Unibase.Platform.Forms.Components.FormBuilder.Instance().FormPropertiesJson.filter(x => x.ControlName == "DropDown" || x.ControlName == "CascadingAutocomplete" || x.ControlName == "AutoComplete");
  2553. var parentProps = [];
  2554. for (let i = 0; i < parentProperties.length; i++) {
  2555. parentProps.push({ id: parentProperties[i].UniqueId, text: parentProperties[i].FormPropertyName });
  2556. }
  2557. $("#ddlParentProperty").select2({
  2558. placeholder: 'Select',
  2559. data: parentProps,
  2560. width: '100%',
  2561. });
  2562. var reportsurl = _appsettings.server_url() + '/apis/v4/unibase/platform/analytics/reports';
  2563. AutoCompleteHelper.getHelper().Create($("#ddl_cascAutocompleteReport"), $("#hfddl_cascAutocompleteReport"), reportsurl, function (response) {
  2564. var data = response;
  2565. });
  2566. $("#ddl_cascAutocompleteReport").change(function () {
  2567. var reportId = $("#ddl_cascAutocompleteReport").val();
  2568. var reportcolumnsurl = _appsettings.server_url() + '/apis/v4/unibase/platform/analytics/reportcolumnsautocomplete/reportid/' + Number(reportId);
  2569. AutoCompleteHelper.getHelper().Create($("#ddl_cascAutocompleteTextColumn"), $("#hfddl_cascAutocompleteTextColumn"), reportcolumnsurl, function (response) {
  2570. var data = response;
  2571. });
  2572. AutoCompleteHelper.getHelper().Create($("#ddl_cascAutocompleteIdColumn"), $("#hfddl_cascAutocompleteIdColumn"), reportcolumnsurl, function (response) {
  2573. var data = response;
  2574. });
  2575. AutoCompleteHelper.getHelper().Create($("#ddl_cascAutocompleteApplyFor"), $("#hfddl_cascAutocompleteApplyFor"), reportcolumnsurl, function (response) {
  2576. var data = response;
  2577. });
  2578. });
  2579. }
  2580. SaveControlData(controldatajson) {
  2581. var instance = this;
  2582. var parentFormProp = Number($("#ddlParentProperty option:selected").val());
  2583. var parentProp = Unibase.Platform.Forms.Components.FormBuilder.Instance().FormPropertiesJson.find(x => x.UniqueId == parentFormProp);
  2584. var data = {
  2585. CascadingId: 0,
  2586. ControlId: Number(Unibase.Platform.Forms.Components.ControlEditor.Instance().ControlId),
  2587. ReportId: Number($("#ddl_cascAutocompleteReport option:selected").val()),
  2588. ReportName: $("#ddl_cascAutocompleteReport option:selected").text(),
  2589. ReportColumnTextId: Number($("#ddl_cascAutocompleteTextColumn option:selected").val()),
  2590. ReportColumnText: $("#ddl_cascAutocompleteTextColumn option:selected").text(),
  2591. ReportColumnValueId: Number($("#ddl_cascAutocompleteIdColumn option:selected").val()),
  2592. ReportColumnValue: $("#ddl_cascAutocompleteIdColumn option:selected").text(),
  2593. ApplyForId: Number($("#ddl_cascAutocompleteApplyFor option:selected").val()),
  2594. ApplyFor: $("#ddl_cascAutocompleteApplyFor option:selected").text(),
  2595. ParentFormPropertyId: parentFormProp,
  2596. ParentDocPropertyId: parentProp.DocPropertyId,
  2597. };
  2598. var ControlJsonText = JSON.stringify(data);
  2599. return ControlJsonText;
  2600. }
  2601. static Instance() {
  2602. if (this._instance === undefined)
  2603. this._instance = new CascadingAutocomplete_Settings();
  2604. return this._instance;
  2605. }
  2606. }
  2607. Controls.CascadingAutocomplete_Settings = CascadingAutocomplete_Settings;
  2608. })(Controls = Forms.Controls || (Forms.Controls = {}));
  2609. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  2610. })(Unibase || (Unibase = {}));
  2611. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2612. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2613. return new (P || (P = Promise))(function (resolve, reject) {
  2614. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2615. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2616. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2617. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2618. });
  2619. };
  2620. var Unibase;
  2621. (function (Unibase) {
  2622. let Forms;
  2623. (function (Forms) {
  2624. let Controls;
  2625. (function (Controls) {
  2626. class select2 {
  2627. constructor() {
  2628. this.Ids = [];
  2629. this.data = [];
  2630. }
  2631. init(formpropertyid, prop, callback) {
  2632. var container = $(".select2_" + prop.FormPropertyId);
  2633. Unibase.Forms.Controls.select2.Instance().loadControlSettings(container, null).then(function () {
  2634. if (callback != null)
  2635. callback();
  2636. });
  2637. $(".select2_" + prop.FormPropertyId).on('select2:select', function (e) {
  2638. var ids = $(".select2_" + prop.FormPropertyId).val().toString().replace(/,/g, '|');
  2639. $("#hdnselect2_" + prop.FormPropertyId).val(ids);
  2640. });
  2641. $(".select2_" + prop.FormPropertyId).on('select2:unselect', function (e) {
  2642. $("#hdnselect2_" + prop.FormPropertyId).val(0);
  2643. var ids = $(".select2_" + prop.FormPropertyId).val().toString().replace(/,/g, '|');
  2644. $("#hdnselect2_" + prop.FormPropertyId).val(ids);
  2645. });
  2646. }
  2647. loadControl(containerid, prop) {
  2648. Unibase.Forms.Controls.select2.Instance().data = [];
  2649. Unibase.Forms.Controls.select2.Instance().Ids = [];
  2650. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  2651. var required = prop.IsRequired != true ? '' : 'required';
  2652. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  2653. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  2654. var StagesForRequired = prop.StagesForRequired.split('|');
  2655. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  2656. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  2657. }
  2658. var IsTagSelect = false;
  2659. if (prop.ControlJsonText != "" && prop.ControlJsonText != null && prop.ControlJsonText != undefined) {
  2660. var text = JSON.parse(prop.ControlJsonText);
  2661. if (text["IsTagSelect"] == true) {
  2662. IsTagSelect = true;
  2663. }
  2664. }
  2665. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  2666. var html = '<div id="div_' + prop.DocPropertyName + '" class="floating-label-form-group-with-value floating-validate" style="border-bottom:0;"><label for= "lbl" id = "lbl_' + prop.DocPropertyName + '" >' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger hide ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyName + '"> *</span></label >' +
  2667. '<input type="hidden" id="hdnselect2_' + prop.FormPropertyId + '" class="value-control" value="0" data-text="">' +
  2668. '<select id="select2_' + prop.FormPropertyId + '" class=" select2_' + prop.FormPropertyId + ' type-control select2_' + prop.DocPropertyName + ' form-control text-control ' + required + '" multiple="multiple" data-isdynamic="' + prop.IsDefault + '" data-istagselect="' + IsTagSelect + '" style="width:100%;" data-propdoctypename="' + prop.DocTypeName + '" data-propertyid="' + prop.DocPropertyId + '" data-propertyname="' + prop.DocPropertyName + '" data-formpropertyid="' + prop.FormPropertyId + '" data-regularexp="" data-validatemsg="" data-textformpropertyid="' + text.TextFormPropertyId + '"><option>Select</option></select>' + helpTextHtml +
  2669. '</div>';
  2670. $("#" + containerid).html(html);
  2671. }
  2672. loadControlSettings(Container, Parameters) {
  2673. return __awaiter(this, void 0, void 0, function* () {
  2674. var ColumnName = "0";
  2675. var Value = "0";
  2676. var DocPropertyId = Container.data('propertyid');
  2677. var DocPropertyName = Container.data('propertyname');
  2678. var FormPropertyId = Container.data('formpropertyid');
  2679. if (Parameters != null && Parameters != "") {
  2680. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  2681. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  2682. }
  2683. var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  2684. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/select2post';
  2685. var data = select2.instance.data.find(x => x.formpropertyid == FormPropertyId);
  2686. $(".select2_" + FormPropertyId).select2({
  2687. multiple: true,
  2688. allowClear: false,
  2689. data: select2.instance.data,
  2690. placeholder: 'Select',
  2691. ajax: {
  2692. url: function (request) {
  2693. var reqUrl = url;
  2694. return reqUrl;
  2695. },
  2696. contentType: 'application/json',
  2697. type: "POST",
  2698. delay: 250,
  2699. data: function (params) {
  2700. var query = {
  2701. term: params.term,
  2702. DocPropertyId: DocPropertyId,
  2703. ColumnName: ColumnName,
  2704. FormPropertyId: FormPropertyId,
  2705. Value: Value,
  2706. bindedData: "",
  2707. authToken: userinfo.sessionId,
  2708. SelectedIds: $(".select2_" + FormPropertyId).val().toString().replace(/,/g, '|'),
  2709. };
  2710. return JSON.stringify(query);
  2711. },
  2712. beforeSend: function (xhr) {
  2713. if (userinfo !== undefined && userinfo !== null) {
  2714. xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
  2715. xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
  2716. }
  2717. },
  2718. processResults: function (data, params) {
  2719. return {
  2720. results: jQuery.map(JSON.parse(data.result), function (item) {
  2721. return {
  2722. id: item.Value,
  2723. text: item.DisplayText
  2724. };
  2725. })
  2726. };
  2727. }
  2728. },
  2729. templateResult: function (item) { return item.text; },
  2730. templateSelection: function (item) { return item.text; },
  2731. }).on('select2:select', function () {
  2732. Unibase.Forms.Controls.select2.Instance().assigningDataText(FormPropertyId, this);
  2733. }).on('select2:unselect', function () {
  2734. Unibase.Forms.Controls.select2.Instance().assigningDataText(FormPropertyId, this);
  2735. });
  2736. $(".select2_" + FormPropertyId).val(select2.instance.Ids).trigger('change');
  2737. var autocompleteid1 = $(".select2_" + DocPropertyName).attr('id');
  2738. if (autocompleteid1 != undefined) {
  2739. var eventList = $.data($("#" + autocompleteid1)[0], "events");
  2740. if (eventList != undefined) {
  2741. eventList.change.unshift(eventList.change.pop());
  2742. }
  2743. }
  2744. });
  2745. }
  2746. assigningDataText(FormPropertyId, instance) {
  2747. let selectedValues = '';
  2748. let length = $(instance).select2('data').length;
  2749. $(instance).select2('data').forEach(function (obj, i) {
  2750. if (i == length - 1) {
  2751. selectedValues = selectedValues + obj.text;
  2752. }
  2753. else {
  2754. selectedValues = selectedValues + obj.text + '|';
  2755. }
  2756. });
  2757. $(`#hdnselect2_${FormPropertyId}`).attr('data-text', selectedValues);
  2758. }
  2759. loadControlSettings_delete(Container, Parameters) {
  2760. return __awaiter(this, void 0, void 0, function* () {
  2761. var ColumnName = "0";
  2762. var Value = "0";
  2763. var DocPropertyId = Container.data('propertyid');
  2764. var DocPropertyName = Container.data('propertyname');
  2765. var FormPropertyId = Container.data('formpropertyid');
  2766. if (Parameters != null && Parameters != "") {
  2767. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  2768. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  2769. }
  2770. var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  2771. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/autocomplete/docpropertyid/' + DocPropertyId + '/columnname/' + ColumnName + '/value/' + Value + '/formpropertyid/' + FormPropertyId + '/formid/0';
  2772. url = url + "/term/";
  2773. url = url.replace('#', '');
  2774. var data = select2.instance.data.find(x => x.formpropertyid == FormPropertyId);
  2775. $(".select2_" + FormPropertyId).select2({
  2776. multiple: true,
  2777. allowClear: false,
  2778. data: select2.instance.data,
  2779. placeholder: 'Select',
  2780. ajax: {
  2781. url: function (request) {
  2782. var reqUrl = url;
  2783. var term = request.term;
  2784. if (term == undefined || term == "")
  2785. reqUrl = reqUrl + term + "/authtoken/" + userinfo.sessionId;
  2786. else
  2787. reqUrl = reqUrl + term + "/authtoken/" + userinfo.sessionId;
  2788. return reqUrl;
  2789. },
  2790. beforeSend: function (xhr) {
  2791. if (userinfo !== undefined && userinfo !== null) {
  2792. xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
  2793. xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
  2794. }
  2795. },
  2796. delay: 250,
  2797. dataType: 'json',
  2798. processResults: function (data) {
  2799. var selectData = [];
  2800. var Data = JSON.parse(data.result);
  2801. for (var i = 0; i < Data.length; i++) {
  2802. selectData.push({
  2803. id: Data[i].Value,
  2804. text: Data[i].DisplayText
  2805. });
  2806. }
  2807. ;
  2808. return { results: selectData };
  2809. }
  2810. },
  2811. templateResult: function (item) { return item.text; },
  2812. templateSelection: function (item) { return item.text; },
  2813. });
  2814. $(".select2_" + FormPropertyId).val(select2.instance.Ids).trigger('change');
  2815. var autocompleteid1 = $(".select2_" + DocPropertyName).attr('id');
  2816. if (autocompleteid1 != undefined) {
  2817. var eventList = $.data($("#" + autocompleteid1)[0], "events");
  2818. if (eventList != undefined) {
  2819. eventList.change.unshift(eventList.change.pop());
  2820. }
  2821. }
  2822. });
  2823. }
  2824. loadPropertySettings(propertysettings, formpropertyid) {
  2825. throw new Error("Method not implemented.");
  2826. }
  2827. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  2828. return __awaiter(this, void 0, void 0, function* () {
  2829. if (propval != null || propval != "" || propval != undefined) {
  2830. var selectedvalues = JSON.parse(propval);
  2831. if (selectedvalues != 0) {
  2832. $("#hdnselect2_" + formpropertyid).val(selectedvalues[selectedvalues.length - 1]);
  2833. for (var i = 0; i < selectedvalues.length; i++) {
  2834. var data = selectedvalues[i];
  2835. if ((data.id != undefined && data.text != undefined) && (data.id != "" && data.text != "")) {
  2836. select2.instance.Ids.push(data.id);
  2837. var newOption = new Option(data.text, data.id, true, true);
  2838. $(".select2_" + formpropertyid).append(newOption).trigger('change');
  2839. }
  2840. }
  2841. }
  2842. }
  2843. });
  2844. }
  2845. static Instance() {
  2846. if (this.instance === undefined) {
  2847. this.instance = new select2();
  2848. }
  2849. return this.instance;
  2850. }
  2851. }
  2852. Controls.select2 = select2;
  2853. })(Controls = Forms.Controls || (Forms.Controls = {}));
  2854. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  2855. })(Unibase || (Unibase = {}));
  2856. var Unibase;
  2857. (function (Unibase) {
  2858. let Forms;
  2859. (function (Forms) {
  2860. let Controls;
  2861. (function (Controls) {
  2862. class DatePicker {
  2863. constructor() {
  2864. this._bizgaze_dateFormat = 'DD/MM/YYYY';
  2865. this.IsTimePicker = false;
  2866. this._time = false;
  2867. this.propval = "";
  2868. this.dtime = false;
  2869. this.disableFutureDate = false;
  2870. }
  2871. init(formpropertyid, prop, callback) {
  2872. var instance = DatePicker.Instance();
  2873. let TimePicker = prop.PropertySettings.filter(t => t.ControlPropertyName == "IsTime" && t.ControlPropertyValue == "true");
  2874. if (TimePicker.length > 0) {
  2875. instance.IsTimePicker = true;
  2876. }
  2877. else {
  2878. instance.IsTimePicker = false;
  2879. }
  2880. if (callback != null && callback != 1)
  2881. callback();
  2882. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  2883. var container = "control-container-" + formpropertyid;
  2884. $("#" + container).find('#date_' + prop.FormPropertyId + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  2885. $("#" + container).find('#date_' + prop.FormPropertyId).val(picker.startDate.format('YYYY/MM/DD'));
  2886. });
  2887. var currentYear = (new Date()).getFullYear();
  2888. if (this._time == true) {
  2889. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  2890. autoUpdateInput: false,
  2891. timePicker: true,
  2892. timePicker24Hour: true,
  2893. locale: {
  2894. format: 'DD/MM/YYYY HH:mm',
  2895. firstDay: 1,
  2896. },
  2897. singleDatePicker: true,
  2898. showDropdowns: true,
  2899. minYear: 1901,
  2900. });
  2901. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  2902. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  2903. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  2904. });
  2905. this._time = false;
  2906. }
  2907. else {
  2908. $("#" + container).find('#date_' + prop.FormPropertyId).daterangepicker({
  2909. locale: {
  2910. format: 'DD/MM/YYYY',
  2911. firstDay: 1,
  2912. },
  2913. singleDatePicker: true,
  2914. showDropdowns: true,
  2915. minYear: 1901,
  2916. maxDate: new Date(2050, 11, 31)
  2917. }, function (start, end, label) {
  2918. $("#" + container).find('#hfdate_' + prop.FormPropertyId).val(end.format('YYYY-MM-DD'));
  2919. });
  2920. }
  2921. if (instance.propval == "") {
  2922. $("#" + container).find('#date_' + prop.FormPropertyId).val('');
  2923. }
  2924. $(".date_" + prop.DocPropertyName).keypress(function (e) {
  2925. $(".date_" + prop.DocPropertyName).attr("maxlength", "10");
  2926. if (e.which != 8 && e.which != 0 && (e.which < 47 || e.which > 57)) {
  2927. return false;
  2928. }
  2929. else {
  2930. var value = $(".date_" + prop.DocPropertyName).val().toString().replace(/^(\d\d)(\d)$/g, '$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/[^\d\/]/g, '');
  2931. $(".date_" + prop.DocPropertyName).val(value);
  2932. }
  2933. });
  2934. $(".date_" + prop.DocPropertyName).focusout(function (e) {
  2935. if ($(".date_" + prop.DocPropertyName).val() == "") {
  2936. $('#hfdate_' + prop.FormPropertyId).val("");
  2937. }
  2938. });
  2939. instance.loadPropertySettings(prop.PropertySettings, formpropertyid, prop.DocPropertyName);
  2940. }
  2941. loadControl(containerid, prop) {
  2942. var regExpr = "";
  2943. var ErrMsg = "";
  2944. var validationlist = prop.Validations;
  2945. if (validationlist != null) {
  2946. for (var i = 0; i < validationlist.length; i++) {
  2947. regExpr += validationlist[i].RegularExp + '||';
  2948. ErrMsg += validationlist[i].ErrorMessage + '||';
  2949. }
  2950. }
  2951. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  2952. var requiredClass = prop.IsRequired != true ? '' : 'required';
  2953. var reqMark = prop.IsRequired != true ? '' : '*';
  2954. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  2955. if (prop.IncludedStages != null && prop.IncludedStages != "") {
  2956. var StagesForRequired = prop.IncludedStages.split('|');
  2957. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  2958. requiredClass = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  2959. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  2960. }
  2961. if (prop.ExcludedStages != null && prop.ExcludedStages != "") {
  2962. var ExcludedStages = prop.ExcludedStages.split('|');
  2963. Isrequired = ExcludedStages.find(x => x == CurrentStageId) ? 'hidden' : '';
  2964. requiredClass = ExcludedStages.find(x => x == CurrentStageId) ? '' : 'required';
  2965. reqMark = ExcludedStages.find(x => x == CurrentStageId) ? '' : '*';
  2966. }
  2967. let ControlId = 'txt_' + prop.DocPropertyId;
  2968. if (prop.IsRequired)
  2969. requiredClass = 'required';
  2970. let isReadOnly = '';
  2971. if (!Unibase.Themes.Compact.Components.Index.Instance().desktopMode) {
  2972. isReadOnly = 'readonly';
  2973. }
  2974. const { helpTooltipHtml, helpTextHtml, helpClass } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  2975. let html = `<div class="floating-label-form-group CancelBtnFloating_${prop.UniqueId} ${helpClass}" id ="div_${prop.UniqueId}">` +
  2976. '<label for="lbl" id="lbl_' + prop.ControlId + '">' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyId + '"> *</span></label>' +
  2977. '<div class="input-group">' +
  2978. '<input type="hidden" id="hfdate_' + prop.UniqueId + '" class="value-control hfdate_' + prop.DocPropertyName + '" value=""/>' +
  2979. '<input type="text" id="date_' + prop.UniqueId + '" class="form-control type-control datepicker-input hasDatepicker ' + requiredClass + ' floating-label-control txt_' + prop.UniqueId + ' date_' + prop.DocPropertyName + '" placeholder="' + prop.LabelName + " " + reqMark + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + " " + reqMark + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '"' + isReadOnly + '>' +
  2980. '<span class="input-group-addon mt-10 cursor-pointer"><i class="fa fa-calendar calender_' + prop.DocPropertyName + '"></i></span>' +
  2981. '<input type="hidden" id="hf_' + prop.ControlId + '" /></div>' + helpTextHtml + '</div>';
  2982. $("#" + containerid).append(html);
  2983. Unibase.Forms.Controls.DatePicker.Instance().loadDate(prop.UniqueId, prop);
  2984. }
  2985. loadControlSettings(controlsettingjson, formpropertyid) {
  2986. return null;
  2987. }
  2988. loadDate(formpropertyid, prop) {
  2989. var container = "control-container-" + formpropertyid;
  2990. if (this._time == true) {
  2991. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  2992. autoUpdateInput: false,
  2993. timePicker: true,
  2994. timePicker24Hour: true,
  2995. locale: {
  2996. format: 'DD/MM/YYYY HH:mm',
  2997. firstDay: 1,
  2998. },
  2999. singleDatePicker: true,
  3000. showDropdowns: true,
  3001. minYear: 1901,
  3002. });
  3003. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  3004. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  3005. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  3006. });
  3007. this._time = false;
  3008. }
  3009. else {
  3010. $("#" + container).find('#date_' + prop.FormPropertyId).daterangepicker({
  3011. locale: {
  3012. format: 'DD/MM/YYYY',
  3013. firstDay: 1,
  3014. },
  3015. singleDatePicker: true,
  3016. showDropdowns: true,
  3017. minYear: 1901,
  3018. }, function (start, end, label) {
  3019. $("#" + container).find('#hfdate_' + prop.FormPropertyId).val(end.format('YYYY-MM-DD'));
  3020. });
  3021. }
  3022. $(`.calender_${prop.DocPropertyName}`).click(function () {
  3023. $(this).parents('.input-group').find('.datepicker-input').trigger('click');
  3024. });
  3025. }
  3026. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  3027. var instance = this;
  3028. var istime = false;
  3029. var dateNow = new Date();
  3030. var container = "control-container-" + formpropertyid;
  3031. if (propertysettings != null) {
  3032. for (var i = 0; i < propertysettings.length; i++) {
  3033. var data = propertysettings[i];
  3034. if (data.ControlPropertyName == "IsTodayDate") {
  3035. if (data.ControlPropertyValue == "true") {
  3036. var DateTime_Value = $("#" + container).find('#date_' + formpropertyid).val();
  3037. if (DateTime_Value == "") {
  3038. var maxDate;
  3039. if (instance.disableFutureDate)
  3040. maxDate = new Date();
  3041. else
  3042. maxDate = new Date(2050, 11, 31);
  3043. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  3044. singleDatePicker: true,
  3045. showDropdowns: true,
  3046. minYear: 1901,
  3047. locale: {
  3048. format: 'DD/MM/YYYY',
  3049. firstDay: 1,
  3050. },
  3051. maxDate: maxDate
  3052. });
  3053. var todayDate = $("#" + container).find('#date_' + formpropertyid).val();
  3054. var hfformat = "YYYY/MM/DD";
  3055. var tdate = moment(todayDate, "DD/MM/YYYY").format("YYYY/MM/DD");
  3056. $("#" + container).find('#hfdate_' + formpropertyid).val(tdate);
  3057. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  3058. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY'));
  3059. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD'));
  3060. $("#" + container).find('#div_' + formpropertyid).addClass('floating-label-form-group-with-value');
  3061. });
  3062. }
  3063. $("#" + container).find('#div_' + formpropertyid).addClass('floating-label-form-group-with-value');
  3064. $("#" + container).find('#date_' + formpropertyid).keypress(function (e) {
  3065. $(this).attr("maxlength", "10");
  3066. if (e.which != 8 && e.which != 0 && (e.which < 47 || e.which > 57)) {
  3067. return false;
  3068. }
  3069. else {
  3070. var value = $(this).val().toString().replace(/^(\d\d)(\d)$/g, '$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/[^\d\/]/g, '');
  3071. $(this).val(value);
  3072. }
  3073. });
  3074. if (instance.dtime == false) {
  3075. if (istime == true) {
  3076. var DateTime_Value = $("#" + container).find('#date_' + formpropertyid).val();
  3077. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  3078. autoUpdateInput: false,
  3079. timePicker: true,
  3080. timePicker24Hour: true,
  3081. singleDatePicker: true,
  3082. showDropdowns: true,
  3083. minYear: 1901,
  3084. locale: {
  3085. format: 'DD/MM/YYYY HH:mm',
  3086. firstDay: 1,
  3087. },
  3088. });
  3089. var cdate = new Date();
  3090. var currentdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalTime(cdate, "DD/MM/YYYY HH:mm");
  3091. $("#" + container).find('#date_' + formpropertyid).val(currentdate);
  3092. var hfcdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDateTime(cdate, "YYYY/MM/DD HH:mm");
  3093. $("#" + container).find('#hfdate_' + formpropertyid).val(hfcdate);
  3094. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  3095. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  3096. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  3097. });
  3098. let curren = new Date();
  3099. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('show.daterangepicker', function (ev, picker) {
  3100. var dateTime_New = $("#" + container).find('#date_' + formpropertyid).val();
  3101. var hours = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") - 2, dateTime_New.toString().indexOf(":"));
  3102. if (hours.substring(0, 1) == "0") {
  3103. hours = hours.substring(1);
  3104. }
  3105. var minutes = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") + 1, dateTime_New.toString().indexOf(":") + 3);
  3106. if (minutes.substring(0, 1) == "0") {
  3107. minutes = minutes.substring(1);
  3108. }
  3109. $('.show-calendar').find('.hourselect option:selected').removeAttr('selected');
  3110. $('.show-calendar').find('.minuteselect option:selected').removeAttr('selected');
  3111. $('.hourselect option[value="' + hours + '"]').attr("selected", "selected");
  3112. $('.minuteselect option[value="' + minutes + '"]').attr("selected", "selected");
  3113. });
  3114. }
  3115. }
  3116. }
  3117. }
  3118. if (data.ControlPropertyName == "IsTime") {
  3119. if (instance.dtime == false) {
  3120. if (data.ControlPropertyValue == "true") {
  3121. istime = true;
  3122. var DateTime_Value = $("#" + container).find('#date_' + formpropertyid).val();
  3123. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  3124. autoUpdateInput: false,
  3125. timePicker: true,
  3126. timePicker24Hour: true,
  3127. singleDatePicker: true,
  3128. showDropdowns: true,
  3129. minYear: 1901,
  3130. locale: {
  3131. format: 'DD/MM/YYYY HH:mm',
  3132. firstDay: 1,
  3133. },
  3134. });
  3135. var cdate = new Date();
  3136. var currentdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalTime(cdate, "DD/MM/YYYY HH:mm");
  3137. $("#" + container).find('#date_' + formpropertyid).val(currentdate);
  3138. var hfcdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDateTime(cdate, "YYYY/MM/DD HH:mm");
  3139. $("#" + container).find('#hfdate_' + formpropertyid).val(hfcdate);
  3140. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('apply.daterangepicker', function (ev, picker) {
  3141. $("#" + container).find('#date_' + formpropertyid).val(picker.startDate.format('DD/MM/YYYY HH:mm'));
  3142. $("#" + container).find('#hfdate_' + formpropertyid).val(picker.startDate.format('YYYY/MM/DD HH:mm'));
  3143. });
  3144. let curren = new Date();
  3145. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').on('show.daterangepicker', function (ev, picker) {
  3146. var dateTime_New = $("#" + container).find('#date_' + formpropertyid).val();
  3147. var hours = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") - 2, dateTime_New.toString().indexOf(":"));
  3148. if (hours.substring(0, 1) == "0") {
  3149. hours = hours.substring(1);
  3150. }
  3151. var minutes = dateTime_New.toString().substring(dateTime_New.toString().indexOf(":") + 1, dateTime_New.toString().indexOf(":") + 3);
  3152. if (minutes.substring(0, 1) == "0") {
  3153. minutes = minutes.substring(1);
  3154. }
  3155. $('.show-calendar').find('.hourselect option:selected').removeAttr('selected');
  3156. $('.show-calendar').find('.minuteselect option:selected').removeAttr('selected');
  3157. $('.hourselect option[value="' + hours + '"]').attr("selected", "selected");
  3158. $('.minuteselect option[value="' + minutes + '"]').attr("selected", "selected");
  3159. });
  3160. $(".hasDatepicker").keypress(function (e) {
  3161. $(this).attr("maxlength", "19");
  3162. var value = $(this).val().toString().replace(/^(\d\d\/\d\d)(\d+)$/g, '$1/$2').replace(/^(\d\d\/\d\d\/\d\d\d\d)(\d)/g, '$1 ').replace(/^(\d\d\/\d\d\/\d\d\d\d\s\d\d)(\d)/g, '$1:$2$2:');
  3163. $(this).val(value);
  3164. });
  3165. }
  3166. }
  3167. }
  3168. if (data.ControlPropertyName == "DisableFutureDate") {
  3169. if (data.ControlPropertyValue == "true") {
  3170. $("#" + container).find('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  3171. singleDatePicker: true,
  3172. showDropdowns: true,
  3173. autoUpdateInput: false,
  3174. minYear: 1901,
  3175. maxDate: new Date(),
  3176. locale: {
  3177. format: 'DD/MM/YYYY',
  3178. firstDay: 1,
  3179. },
  3180. }, function (start, end, label) {
  3181. $("#" + container).find('#hfdate_' + formpropertyid).val(end.format('YYYY-MM-DD'));
  3182. });
  3183. $('#date_' + formpropertyid + '.datepicker-input').keyup(function (e) {
  3184. let dateString = $(this).val();
  3185. let errorMsgDiv = $(this).parents('.formValidate').find('.form-error-message').attr('id');
  3186. let myDate = moment(dateString, ['DD/MM/YYYY', 'D/M/YYYY', 'DD/M/YYYY', 'D/MM/YYYY'], true);
  3187. MessageHelper.Instance().hideMessage();
  3188. $(this).attr('data-isValid', 'false');
  3189. if (dateString.length >= 8 && dateString != "") {
  3190. if (myDate.isValid() == false) {
  3191. MessageHelper.Instance().showError('Enter Correct Date Format!.', errorMsgDiv);
  3192. }
  3193. else if (moment(dateString, 'DD/MM/YYYY').isSameOrBefore(moment().format()) == false) {
  3194. MessageHelper.Instance().showError('You cannot enter a date in the future.', errorMsgDiv);
  3195. }
  3196. else if (moment(dateString, 'DD/MM/YYYY').isSameOrAfter('01/01/1901', 'year') == false) {
  3197. MessageHelper.Instance().showError('You cannot enter a date before 1901.', errorMsgDiv);
  3198. }
  3199. else {
  3200. MessageHelper.Instance().hideMessage();
  3201. $('#hfdate_' + formpropertyid).val(moment(dateString, 'DD/MM/YYYY').format('YYYY-MM-DD'));
  3202. $(this).attr('data-isValid', 'true');
  3203. }
  3204. }
  3205. });
  3206. instance.disableFutureDate = true;
  3207. $('#date_' + formpropertyid + '.datepicker-input').focusout(function (e) {
  3208. let isDateValid = $(this).attr('data-isValid');
  3209. if (isDateValid == 'false') {
  3210. $(this).val("");
  3211. $('#hfdate_' + formpropertyid).val("");
  3212. $(this).attr('data-isValid', 'true');
  3213. }
  3214. });
  3215. }
  3216. }
  3217. }
  3218. }
  3219. instance.propval = "";
  3220. instance.dtime = false;
  3221. }
  3222. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  3223. var instance = this;
  3224. var format = "DD/MM/YYYY";
  3225. var hfformat = "YYYY/MM/DD";
  3226. var hfdate = "";
  3227. if (instance.IsTimePicker) {
  3228. instance.propval = moment(propval).format("DD/MM/YYYY HH:mm");
  3229. hfdate = moment(propval).format("YYYY/MM/DD HH:mm");
  3230. instance._time = true;
  3231. $('#date_' + formpropertyid + '.datepicker-input').daterangepicker({
  3232. autoUpdateInput: false,
  3233. timePicker: true,
  3234. timePicker24Hour: true,
  3235. singleDatePicker: true,
  3236. showDropdowns: true,
  3237. minYear: 1901,
  3238. locale: {
  3239. format: 'DD/MM/YYYY HH:mm',
  3240. firstDay: 1,
  3241. },
  3242. });
  3243. instance.dtime = true;
  3244. }
  3245. else {
  3246. instance.propval = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(propval, format);
  3247. hfdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerLocalDate(propval, hfformat);
  3248. }
  3249. var formattedPropVal = Unibase.Platform.Helpers.DateTimeHelper.Instance().serverDateformat(instance.propval);
  3250. if (instance.propval == "Invalid date" || formattedPropVal == "01/01/1901" || formattedPropVal == "01/01/1900" || formattedPropVal == "01/01/2001" || formattedPropVal == "01/01/0001") {
  3251. instance.propval = "";
  3252. }
  3253. $("#hfdate_" + formpropertyid).val(hfdate);
  3254. $("#date_" + formpropertyid).val(instance.propval);
  3255. if ($("#date_" + formpropertyid).val() != "") {
  3256. $("#div_" + formpropertyid).addClass("floating-label-form-group-with-value");
  3257. }
  3258. }
  3259. static Instance() {
  3260. if (this.instance === undefined)
  3261. this.instance = new DatePicker();
  3262. return this.instance;
  3263. }
  3264. }
  3265. Controls.DatePicker = DatePicker;
  3266. })(Controls = Forms.Controls || (Forms.Controls = {}));
  3267. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  3268. })(Unibase || (Unibase = {}));
  3269. var Unibase;
  3270. (function (Unibase) {
  3271. let Forms;
  3272. (function (Forms) {
  3273. let Controls;
  3274. (function (Controls) {
  3275. class RadioBox {
  3276. init(formpropertyid, prop, callback) {
  3277. var instance = RadioBox.Instance();
  3278. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  3279. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  3280. if (callback != null)
  3281. callback();
  3282. }
  3283. loadControl(containerid, prop) {
  3284. var regExpr = "";
  3285. var ErrMsg = "";
  3286. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  3287. var required = prop.IsRequired != true ? '' : 'required';
  3288. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  3289. if (prop.StagesForRequired != null && prop.StagesForRequired != "") {
  3290. var StagesForRequired = prop.StagesForRequired.split('|');
  3291. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  3292. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  3293. }
  3294. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  3295. var html = '<div id="div_' + prop.DocPropertyName + '" class="div_' + prop.DocPropertyName + '_' + prop.FormPropertyId + '"><label for= "lbl" id = "lbl_' + prop.DocPropertyName + '" >' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyName + '"> *</span></label ><br />' +
  3296. '<input type="hidden" id="hdnRdb_' + prop.DocPropertyName + '" value="0" class="value-control" data-isdefault="' + prop.IsDefault + '" data-propdoctypename="' + prop.DocTypeName + '" data-required="' + prop.IsRequired + '" data-regularexp="' + regExpr + '" data-validatemsg="' + ErrMsg + '" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + '" />' +
  3297. '<span id="spnRdb_' + prop.DocPropertyName + '" class="spnRdb_' + prop.DocPropertyName + ' text-control" ></span>' +
  3298. '<input type = "hidden" id = "hfId_' + prop.DocPropertyName + '" value = "0" ><label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label><input type = "hidden" id = "hfFormPropertyId" value = "' + prop.FormPropertyId + '" />' + helpTextHtml + '</div>';
  3299. $("#" + containerid).html(html);
  3300. Unibase.Forms.Controls.RadioBox.Instance().getControlOptions(containerid, prop.DocPropertyName, prop);
  3301. }
  3302. getControlOptions(containerid, DocPropertyName, prop) {
  3303. var hiddenids = $('#hdnRdb_' + DocPropertyName).val();
  3304. var html = '';
  3305. var data = JSON.parse(prop.ControlJsonText);
  3306. if (prop.PropertySettings[0].ControlPropertyValue == "true") {
  3307. html = '<span class="row">';
  3308. }
  3309. for (var i = 0; i < data.length; i++) {
  3310. var assignValue = "";
  3311. if (hiddenids != '') {
  3312. if (hiddenids == data[i].ColumnValue) {
  3313. assignValue = "checked";
  3314. }
  3315. }
  3316. var textcolumn;
  3317. if (data[i].ColumnValue.includes(" ") || data[i].ColumnValue.includes("/") || data[i].ColumnValue.includes("&")) {
  3318. textcolumn = data[i].ColumnValue.replaceAll(" ", "").replaceAll("/", "").replaceAll("&", "");
  3319. }
  3320. else {
  3321. textcolumn = data[i].ColumnValue;
  3322. }
  3323. if (Unibase.Forms.Controls.SubForm.Instance().Index != undefined && Unibase.Forms.Controls.SubForm.Instance().Index != 0) {
  3324. var id = DocPropertyName + '_' + textcolumn + Number($("#SubFormIndex").val());
  3325. }
  3326. else {
  3327. var id = DocPropertyName + '_' + textcolumn;
  3328. }
  3329. var columnvalue = prop.datatypeid == 3 ? data[i].ColumnNumber : data[i].ColumnValue;
  3330. let val = columnvalue;
  3331. if (prop.PropertySettings[0].ControlPropertyValue == "true") {
  3332. html += '<div class="custom-control custom-radio col-sm-6 col-md-4 col-xl-3 p-0"><label id="lbl_' + id + '" class="btn btn-xs btn-rounded btn btn-light lblid_' + id + ' setting_radio' + DocPropertyName + ' mx-10 d-block" onclick="Unibase.Forms.Controls.RadioBox.Instance().radioButtonClick(' + "'" + DocPropertyName + "' ," + "'" + columnvalue + "'" + " ," + "'" + id + "'" + ')" style="height:30px" for="rdb_' + id + '">' + data[i].ColumnText + '</label><input type="radio" id="rdb_' + id + '" name="roleid" class="radio-tabview type-control custom-control-input rdb_' + DocPropertyName + '"/></div>';
  3333. if (i == data.length - 1) {
  3334. html += '</span>';
  3335. }
  3336. }
  3337. else {
  3338. html += '<div class="custom-control custom-radio">' +
  3339. '<input type = "radio" id="rdb_' + id + '" name="' + DocPropertyName + '" class="type-control custom-control-input rdb_' + DocPropertyName + '_' + columnvalue + '" onclick="Unibase.Forms.Controls.RadioBox.Instance().radioButtonClick(' + "'" + DocPropertyName + "' ," + "'" + columnvalue + "'" + " ," + "'" + id + "'" + ')" ' + assignValue + '>' +
  3340. '<label class="custom-control-label" for="rdb_' + id + '">' + data[i].ColumnText + '</label></div >';
  3341. }
  3342. }
  3343. $("#" + containerid).find('.div_' + DocPropertyName + '_' + prop.FormPropertyId).find(".spnRdb_" + DocPropertyName).html(html);
  3344. }
  3345. loadControlSettings(controlsettingjson, formpropertyid) {
  3346. return null;
  3347. }
  3348. loadPropertySettings(propertysettings, formpropertyid) {
  3349. if (propertysettings != null) {
  3350. for (var i = 0; i < propertysettings.length; i++) {
  3351. var data = propertysettings[i];
  3352. if (data.ControlPropertyName == "IsTabView") {
  3353. $("#txt_" + formpropertyid).attr("MaxLength", data.ControlPropertyValue);
  3354. }
  3355. }
  3356. }
  3357. }
  3358. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  3359. let value = propval;
  3360. propval = propval.replaceAll(" ", "").replaceAll("/", "").replaceAll("&", "");
  3361. if ($(".rdb_" + DocPropertyName).hasClass("radio-tabview")) {
  3362. var _id = $(".lblid_" + DocPropertyName + "_" + propval);
  3363. if (_id.length > 0) {
  3364. var id = _id.attr("id").replace("lbl_", "");
  3365. Unibase.Forms.Controls.RadioBox.Instance().radioButtonClick(DocPropertyName, value, id);
  3366. }
  3367. }
  3368. else {
  3369. $(".rdb_" + DocPropertyName + "_" + propval).prop("checked", true);
  3370. $("#hdnRdb_" + DocPropertyName).val(value);
  3371. }
  3372. }
  3373. radioButtonClick(DocPropertyName, ColumnValue, id) {
  3374. if ($(".rdb_" + DocPropertyName).hasClass("radio-tabview")) {
  3375. $(".setting_radio" + DocPropertyName).removeClass("btn-primary");
  3376. $(".setting_radio" + DocPropertyName).addClass("btn-light");
  3377. $("#lbl_" + id).removeClass("btn-light");
  3378. $("#lbl_" + id).addClass("btn-primary");
  3379. $("#hdnRdb_" + DocPropertyName).val(ColumnValue);
  3380. }
  3381. else {
  3382. $("#hdnRdb_" + DocPropertyName).val(ColumnValue);
  3383. }
  3384. }
  3385. static Instance() {
  3386. if (this.instance === undefined) {
  3387. this.instance = new RadioBox();
  3388. }
  3389. return this.instance;
  3390. }
  3391. }
  3392. Controls.RadioBox = RadioBox;
  3393. })(Controls = Forms.Controls || (Forms.Controls = {}));
  3394. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  3395. })(Unibase || (Unibase = {}));
  3396. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3397. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3398. return new (P || (P = Promise))(function (resolve, reject) {
  3399. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3400. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3401. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3402. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3403. });
  3404. };
  3405. var Bizgaze;
  3406. (function (Bizgaze) {
  3407. let Apps;
  3408. (function (Apps) {
  3409. let Transact;
  3410. (function (Transact) {
  3411. let Managers;
  3412. (function (Managers) {
  3413. class PriceListManager extends Unibase.Platform.Core.BaseManager {
  3414. saveMrp(obj) {
  3415. return __awaiter(this, void 0, void 0, function* () {
  3416. const url = 'apis/v4/bizgaze/transact/pricelists/savemrp';
  3417. return yield this.dataHelper().postAsync(url, obj).then(function (response) {
  3418. return response;
  3419. });
  3420. });
  3421. }
  3422. getItem(itemid) {
  3423. return __awaiter(this, void 0, void 0, function* () {
  3424. const url = 'apis/v4/unibase/transact/items/getitem/itemid/' + itemid;
  3425. return yield this.dataHelper().getAsync(url).then(function (response) {
  3426. if (response.result !== null)
  3427. response.result = JSON.parse(response.result);
  3428. return response;
  3429. });
  3430. });
  3431. }
  3432. editMrp(MrpId) {
  3433. return __awaiter(this, void 0, void 0, function* () {
  3434. const url = 'apis/v4/bizgaze/transact/pricelists/getmrp/mrpid/' + MrpId;
  3435. return yield this.dataHelper().getAsync(url).then(function (response) {
  3436. if (response.result !== null)
  3437. response.result = JSON.parse(response.result);
  3438. return response;
  3439. });
  3440. });
  3441. }
  3442. exportList(PriceListId) {
  3443. return __awaiter(this, void 0, void 0, function* () {
  3444. const url = 'apis/v4/bizgaze/transact/pricelist/export/pricelistid/' + PriceListId;
  3445. return yield this.dataHelper().getAsync(url).then(function (response) {
  3446. if (response.result !== null)
  3447. response.result = JSON.parse(response.result);
  3448. return response;
  3449. });
  3450. });
  3451. }
  3452. saveBatch(obj) {
  3453. return __awaiter(this, void 0, void 0, function* () {
  3454. const url = 'apis/v4/bizgaze/transact/pricelists/savebatch';
  3455. return yield this.dataHelper().postAsync(url, obj).then(function (response) {
  3456. return response;
  3457. });
  3458. });
  3459. }
  3460. getbatch(batchid) {
  3461. return __awaiter(this, void 0, void 0, function* () {
  3462. const url = 'apis/v4/bizgaze/transact/pricelist/getbatch/batchid/' + batchid;
  3463. return yield this.dataHelper().getAsync(url).then(function (response) {
  3464. if (response.result !== null && response.result !== '')
  3465. response.result = JSON.parse(response.result);
  3466. return response;
  3467. });
  3468. });
  3469. }
  3470. getpricecodes(lobid) {
  3471. return __awaiter(this, void 0, void 0, function* () {
  3472. const url = 'apis/v4/bizgaze/transact/pricelists/pricecode/' + lobid;
  3473. return yield this.dataHelper().getAsync(url).then(function (response) {
  3474. return response;
  3475. });
  3476. });
  3477. }
  3478. getPriceCodeByContact(ContactId, LobId) {
  3479. return __awaiter(this, void 0, void 0, function* () {
  3480. const url = 'apis/v4/bizgaze/transact/pricelist/getpricecodebycontact/contactid/' + ContactId + '/lobid/' + LobId;
  3481. return yield this.dataHelper().getAsync(url).then(function (response) {
  3482. if (response.result !== null && response.result != "")
  3483. response.result = JSON.parse(response.result);
  3484. return response;
  3485. });
  3486. });
  3487. }
  3488. getpricelists(pricelistid) {
  3489. return __awaiter(this, void 0, void 0, function* () {
  3490. const url = 'apis/v4/bizgaze/transact/pricelists/pricelist/' + pricelistid;
  3491. return yield this.dataHelper().getAsync(url).then(function (response) {
  3492. return response;
  3493. });
  3494. });
  3495. }
  3496. postdatafilter(request) {
  3497. return __awaiter(this, void 0, void 0, function* () {
  3498. const url = 'apis/v4/bizgaze/transact/pricelists/savepricelist';
  3499. return yield this.dataHelper().postAsync(url, request).then(function (response) {
  3500. return response;
  3501. });
  3502. });
  3503. }
  3504. pricelistvalues(request) {
  3505. return __awaiter(this, void 0, void 0, function* () {
  3506. const url = 'apis/v4/bizgaze/transact/pricelists/savepricevalues';
  3507. return yield this.dataHelper().postAsync(url, request).then(function (response) {
  3508. Unibase.Apps.Transact.Controls.CreatePriceList.Instance().editPriceList(Number($("#gridPager2").find('.pagination').find(".active").text()) - 1, 2, "");
  3509. return response;
  3510. });
  3511. });
  3512. }
  3513. CreatePriceListItems(voucherid, contactid, page, searchtext) {
  3514. return __awaiter(this, void 0, void 0, function* () {
  3515. const url = 'apis/v4/bizgaze/transact/pricelists/getpricelistitems/id/' + voucherid + '/page/' + page + '/rows/10/query/' + searchtext;
  3516. return yield this.dataHelper().getAsync(url).then(function (response) {
  3517. if (response.result !== null && response.result != "")
  3518. response.result = JSON.parse(response.result);
  3519. return response;
  3520. });
  3521. });
  3522. }
  3523. EditPriceListItems(voucherid, contactid, page, searchtext) {
  3524. return __awaiter(this, void 0, void 0, function* () {
  3525. const url = 'apis/v4/bizgaze/transact/pricelists/pricelistitems/id/' + voucherid + '/page/' + page + '/rows/10/query/' + searchtext;
  3526. return yield this.dataHelper().getAsync(url).then(function (response) {
  3527. return response;
  3528. });
  3529. });
  3530. }
  3531. getlobs(ContactId) {
  3532. return __awaiter(this, void 0, void 0, function* () {
  3533. const url = 'apis/v4/bizgaze/transact/automationrules/getruleautotaggroups/' + ContactId;
  3534. return yield this.dataHelper().getAsync(url).then(function (response) {
  3535. return JSON.parse(response.result);
  3536. });
  3537. });
  3538. }
  3539. saveContactDefault(obj) {
  3540. return __awaiter(this, void 0, void 0, function* () {
  3541. const url = 'apis/v4/bizgaze/transact/pricelists/contactdefault';
  3542. return yield this.dataHelper().postAsync(url, obj).then(function (response) {
  3543. return response;
  3544. });
  3545. });
  3546. }
  3547. getPriceValue(itemid) {
  3548. return __awaiter(this, void 0, void 0, function* () {
  3549. const url = 'apis/v4/bizgaze/transact/pricelist/getlatestpricevalue/itemid/' + itemid + '/mrpid/0/lobid/0';
  3550. return yield this.dataHelper().getAsync(url).then(function (response) {
  3551. if (response.result !== null && response.result !== '')
  3552. response.result = JSON.parse(response.result);
  3553. return response;
  3554. });
  3555. });
  3556. }
  3557. static Instance() {
  3558. if (this._instance === undefined)
  3559. this._instance = new Bizgaze.Apps.Transact.Managers.PriceListManager();
  3560. return this._instance;
  3561. }
  3562. }
  3563. Managers.PriceListManager = PriceListManager;
  3564. })(Managers = Transact.Managers || (Transact.Managers = {}));
  3565. })(Transact = Apps.Transact || (Apps.Transact = {}));
  3566. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  3567. })(Bizgaze || (Bizgaze = {}));
  3568. var Bizgaze;
  3569. (function (Bizgaze) {
  3570. let Apps;
  3571. (function (Apps) {
  3572. let Transact;
  3573. (function (Transact) {
  3574. let Enums;
  3575. (function (Enums) {
  3576. let DcType;
  3577. (function (DcType) {
  3578. DcType[DcType["Inward"] = 1] = "Inward";
  3579. DcType[DcType["Outward"] = 2] = "Outward";
  3580. DcType[DcType["ClaimInward"] = 3] = "ClaimInward";
  3581. DcType[DcType["ClaimOutward"] = 4] = "ClaimOutward";
  3582. })(DcType = Enums.DcType || (Enums.DcType = {}));
  3583. let StockStatus;
  3584. (function (StockStatus) {
  3585. StockStatus[StockStatus["Active"] = 1] = "Active";
  3586. StockStatus[StockStatus["Delivered"] = 2] = "Delivered";
  3587. StockStatus[StockStatus["Damaged"] = 3] = "Damaged";
  3588. StockStatus[StockStatus["Missing"] = 4] = "Missing";
  3589. StockStatus[StockStatus["Allocated"] = 5] = "Allocated";
  3590. StockStatus[StockStatus["Expired"] = 6] = "Expired";
  3591. StockStatus[StockStatus["InActive"] = 7] = "InActive";
  3592. StockStatus[StockStatus["Void"] = 8] = "Void";
  3593. StockStatus[StockStatus["Transfer"] = 9] = "Transfer";
  3594. })(StockStatus = Enums.StockStatus || (Enums.StockStatus = {}));
  3595. let StockType;
  3596. (function (StockType) {
  3597. StockType[StockType["Item"] = 1] = "Item";
  3598. StockType[StockType["Package"] = 2] = "Package";
  3599. StockType[StockType["Asset"] = 3] = "Asset";
  3600. })(StockType = Enums.StockType || (Enums.StockType = {}));
  3601. let OrderType;
  3602. (function (OrderType) {
  3603. OrderType[OrderType["Sales"] = 1] = "Sales";
  3604. OrderType[OrderType["Purchase"] = 2] = "Purchase";
  3605. OrderType[OrderType["SalesOpportunity"] = 3] = "SalesOpportunity";
  3606. OrderType[OrderType["PurchaseOpportunity"] = 4] = "PurchaseOpportunity";
  3607. OrderType[OrderType["SalesClaim"] = 5] = "SalesClaim";
  3608. OrderType[OrderType["PurchaseClaim"] = 6] = "PurchaseClaim";
  3609. OrderType[OrderType["SalesEstimate"] = 7] = "SalesEstimate";
  3610. OrderType[OrderType["PurchaseEstimate"] = 8] = "PurchaseEstimate";
  3611. OrderType[OrderType["OrderTransfer"] = 9] = "OrderTransfer";
  3612. OrderType[OrderType["InwardOrder"] = 10] = "InwardOrder";
  3613. OrderType[OrderType["OutwardOrder"] = 11] = "OutwardOrder";
  3614. OrderType[OrderType["SalesContract"] = 12] = "SalesContract";
  3615. OrderType[OrderType["PurchaseContract"] = 13] = "PurchaseContract";
  3616. OrderType[OrderType["PurchasePlanning"] = 14] = "PurchasePlanning";
  3617. OrderType[OrderType["WorkOrder"] = 15] = "WorkOrder";
  3618. OrderType[OrderType["ProductionPlanning"] = 16] = "ProductionPlanning";
  3619. })(OrderType = Enums.OrderType || (Enums.OrderType = {}));
  3620. let PriceType;
  3621. (function (PriceType) {
  3622. PriceType[PriceType["None"] = 1] = "None";
  3623. PriceType[PriceType["CompositePrice"] = 2] = "CompositePrice";
  3624. PriceType[PriceType["PiecePrice"] = 3] = "PiecePrice";
  3625. PriceType[PriceType["Both"] = 4] = "Both";
  3626. })(PriceType = Enums.PriceType || (Enums.PriceType = {}));
  3627. let InventoryApplyType;
  3628. (function (InventoryApplyType) {
  3629. InventoryApplyType[InventoryApplyType["Packs"] = 1] = "Packs";
  3630. InventoryApplyType[InventoryApplyType["Quantity"] = 2] = "Quantity";
  3631. InventoryApplyType[InventoryApplyType["Numbers"] = 3] = "Numbers";
  3632. InventoryApplyType[InventoryApplyType["Pieces"] = 4] = "Pieces";
  3633. InventoryApplyType[InventoryApplyType["PacksAndPieces"] = 5] = "PacksAndPieces";
  3634. })(InventoryApplyType = Enums.InventoryApplyType || (Enums.InventoryApplyType = {}));
  3635. let OrderStatus;
  3636. (function (OrderStatus) {
  3637. OrderStatus[OrderStatus["Draft"] = 1] = "Draft";
  3638. OrderStatus[OrderStatus["Approval"] = 2] = "Approval";
  3639. OrderStatus[OrderStatus["Active"] = 3] = "Active";
  3640. OrderStatus[OrderStatus["Rejected"] = 4] = "Rejected";
  3641. OrderStatus[OrderStatus["Partial"] = 5] = "Partial";
  3642. OrderStatus[OrderStatus["Completed"] = 6] = "Completed";
  3643. OrderStatus[OrderStatus["Void"] = 7] = "Void";
  3644. })(OrderStatus = Enums.OrderStatus || (Enums.OrderStatus = {}));
  3645. let PaymentDiscountType;
  3646. (function (PaymentDiscountType) {
  3647. PaymentDiscountType[PaymentDiscountType["Discount"] = 1] = "Discount";
  3648. PaymentDiscountType[PaymentDiscountType["Penalty"] = 2] = "Penalty";
  3649. PaymentDiscountType[PaymentDiscountType["TDS"] = 3] = "TDS";
  3650. })(PaymentDiscountType = Enums.PaymentDiscountType || (Enums.PaymentDiscountType = {}));
  3651. let PaymentType;
  3652. (function (PaymentType) {
  3653. PaymentType[PaymentType["Receipt"] = 1] = "Receipt";
  3654. PaymentType[PaymentType["Payment"] = 2] = "Payment";
  3655. })(PaymentType = Enums.PaymentType || (Enums.PaymentType = {}));
  3656. let PaymentMode;
  3657. (function (PaymentMode) {
  3658. PaymentMode[PaymentMode["None"] = 0] = "None";
  3659. PaymentMode[PaymentMode["Cash"] = 1] = "Cash";
  3660. PaymentMode[PaymentMode["Cheque"] = 2] = "Cheque";
  3661. PaymentMode[PaymentMode["Online"] = 3] = "Online";
  3662. PaymentMode[PaymentMode["Neft"] = 4] = "Neft";
  3663. PaymentMode[PaymentMode["Rtgs"] = 5] = "Rtgs";
  3664. PaymentMode[PaymentMode["FundTransfer"] = 6] = "FundTransfer";
  3665. PaymentMode[PaymentMode["Adjustment"] = 7] = "Adjustment";
  3666. PaymentMode[PaymentMode["Upi"] = 8] = "Upi";
  3667. PaymentMode[PaymentMode["Cards"] = 9] = "Cards";
  3668. PaymentMode[PaymentMode["MultiplePayments"] = 10] = "MultiplePayments";
  3669. })(PaymentMode = Enums.PaymentMode || (Enums.PaymentMode = {}));
  3670. let PaymentSettingType;
  3671. (function (PaymentSettingType) {
  3672. PaymentSettingType[PaymentSettingType["Discount"] = 1] = "Discount";
  3673. PaymentSettingType[PaymentSettingType["Penalty"] = 2] = "Penalty";
  3674. PaymentSettingType[PaymentSettingType["TDS"] = 3] = "TDS";
  3675. PaymentSettingType[PaymentSettingType["MultiplePaymentMode"] = 4] = "MultiplePaymentMode";
  3676. PaymentSettingType[PaymentSettingType["CompanyWisePayments"] = 5] = "CompanyWisePayments";
  3677. })(PaymentSettingType = Enums.PaymentSettingType || (Enums.PaymentSettingType = {}));
  3678. let InventoryType;
  3679. (function (InventoryType) {
  3680. InventoryType[InventoryType["Item"] = 1] = "Item";
  3681. InventoryType[InventoryType["Service"] = 2] = "Service";
  3682. InventoryType[InventoryType["Package"] = 3] = "Package";
  3683. InventoryType[InventoryType["Assembly"] = 4] = "Assembly";
  3684. InventoryType[InventoryType["Coupons"] = 5] = "Coupons";
  3685. InventoryType[InventoryType["Discount"] = 6] = "Discount";
  3686. InventoryType[InventoryType["Expense"] = 7] = "Expense";
  3687. InventoryType[InventoryType["Subscription"] = 8] = "Subscription";
  3688. })(InventoryType = Enums.InventoryType || (Enums.InventoryType = {}));
  3689. let InvoiceStatus;
  3690. (function (InvoiceStatus) {
  3691. InvoiceStatus[InvoiceStatus["Draft"] = 1] = "Draft";
  3692. InvoiceStatus[InvoiceStatus["Active"] = 2] = "Active";
  3693. InvoiceStatus[InvoiceStatus["Confirmed"] = 3] = "Confirmed";
  3694. InvoiceStatus[InvoiceStatus["PartialPaid"] = 4] = "PartialPaid";
  3695. InvoiceStatus[InvoiceStatus["Paid"] = 5] = "Paid";
  3696. InvoiceStatus[InvoiceStatus["Void"] = 6] = "Void";
  3697. })(InvoiceStatus = Enums.InvoiceStatus || (Enums.InvoiceStatus = {}));
  3698. let InvoiceType;
  3699. (function (InvoiceType) {
  3700. InvoiceType[InvoiceType["Sales"] = 1] = "Sales";
  3701. InvoiceType[InvoiceType["Purchase"] = 2] = "Purchase";
  3702. InvoiceType[InvoiceType["SalesReturn"] = 3] = "SalesReturn";
  3703. InvoiceType[InvoiceType["PurchaseReturn"] = 4] = "PurchaseReturn";
  3704. InvoiceType[InvoiceType["Transfer"] = 5] = "Transfer";
  3705. InvoiceType[InvoiceType["DebitNote"] = 6] = "DebitNote";
  3706. InvoiceType[InvoiceType["CreditNote"] = 7] = "CreditNote";
  3707. InvoiceType[InvoiceType["Income"] = 8] = "Income";
  3708. InvoiceType[InvoiceType["Expense"] = 9] = "Expense";
  3709. InvoiceType[InvoiceType["InwardTransfer"] = 10] = "InwardTransfer";
  3710. InvoiceType[InvoiceType["OutwardTransfer"] = 11] = "OutwardTransfer";
  3711. })(InvoiceType = Enums.InvoiceType || (Enums.InvoiceType = {}));
  3712. })(Enums = Transact.Enums || (Transact.Enums = {}));
  3713. })(Transact = Apps.Transact || (Apps.Transact = {}));
  3714. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  3715. })(Bizgaze || (Bizgaze = {}));
  3716. var Unibase;
  3717. (function (Unibase) {
  3718. let Core;
  3719. (function (Core) {
  3720. let Helpers;
  3721. (function (Helpers) {
  3722. class NumberHelper {
  3723. roundNumber1(number, Int64s) {
  3724. let dnum = Math.pow(10, Int64s);
  3725. var n = parseFloat(((number * dnum) / dnum).toString());
  3726. return n.toFixed(Int64s);
  3727. }
  3728. roundNumber(number, Int64s) {
  3729. let Int64Value = 0;
  3730. Int64s = Int64s || 0;
  3731. number *= parseFloat((Math.pow(10, (Int64s + 1))).toString());
  3732. Int64Value = parseInt((Math.floor(number)).toString()) - (Math.floor(number / 10) * 10);
  3733. number = Math.floor(number / 10);
  3734. if (Int64Value >= 5) {
  3735. number += 1;
  3736. }
  3737. number /= parseFloat((Math.pow(10, (Int64s))).toString());
  3738. return number.toFixed(Int64s);
  3739. }
  3740. DelimiterNumber(number) {
  3741. var parts = number.toString().split(".");
  3742. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  3743. return parts.join(".");
  3744. }
  3745. format(num, digits, InMillions) {
  3746. var si = [];
  3747. if (InMillions) {
  3748. si = [
  3749. { value: 1, symbol: "" },
  3750. { value: 1E3, symbol: "k" },
  3751. { value: 1E6, symbol: "M" },
  3752. { value: 1E9, symbol: "G" },
  3753. { value: 1E12, symbol: "T" },
  3754. { value: 1E15, symbol: "P" },
  3755. { value: 1E18, symbol: "E" }
  3756. ];
  3757. }
  3758. else {
  3759. si = [
  3760. { value: 1, symbol: "" },
  3761. { value: 1E3, symbol: "k" },
  3762. { value: 1E5, symbol: "L" },
  3763. { value: 1E7, symbol: "Cr" },
  3764. { value: 1E9, symbol: "KCr" },
  3765. { value: 1E11, symbol: "LCr" }
  3766. ];
  3767. }
  3768. var rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
  3769. var i;
  3770. for (i = si.length - 1; i > 0; i--) {
  3771. if (num >= si[i].value) {
  3772. break;
  3773. }
  3774. }
  3775. return (num / si[i].value).toFixed(digits).replace(rx, "$1") + si[i].symbol;
  3776. }
  3777. static Instance() {
  3778. if (this.instance === null || this.instance === undefined)
  3779. this.instance = new NumberHelper();
  3780. return this.instance;
  3781. }
  3782. }
  3783. Helpers.NumberHelper = NumberHelper;
  3784. })(Helpers = Core.Helpers || (Core.Helpers = {}));
  3785. })(Core = Unibase.Core || (Unibase.Core = {}));
  3786. })(Unibase || (Unibase = {}));
  3787. var Unibase;
  3788. (function (Unibase) {
  3789. let Forms;
  3790. (function (Forms) {
  3791. let Controls;
  3792. (function (Controls) {
  3793. class NumberBox {
  3794. init(formpropertyid, prop, callback) {
  3795. var instance = NumberBox.Instance();
  3796. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  3797. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  3798. var formid = $("#number_" + prop.UniqueId).parents('.formValidate').attr('id');
  3799. var errormsg = $("#" + formid).find('.bizgaze_FormErrorMessages').attr('id');
  3800. $("#number_" + prop.UniqueId).keyup(function (e) {
  3801. if (e.which == 8 || e.which == 46) {
  3802. let numVal = $("#number_" + prop.UniqueId).val().toString();
  3803. if (numVal.startsWith('.') == false) {
  3804. return true;
  3805. }
  3806. }
  3807. if (e.which === 9) {
  3808. return true;
  3809. }
  3810. if (prop.DataTypeId == Number(Unibase.Platform.Analytics.Reports.Enums.DataType.decimal)) {
  3811. var regex = /^[0-9]+\.?[0-9]*$/;
  3812. var result = regex.test($("#number_" + prop.UniqueId).val().toString());
  3813. if (result == false) {
  3814. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Allow only Decimal Values");
  3815. $("#number_" + prop.UniqueId).val('');
  3816. return false;
  3817. }
  3818. }
  3819. else if (prop.DataTypeId == Number(Unibase.Platform.Analytics.Reports.Enums.DataType.int64) || prop.DataTypeId == Number(Unibase.Platform.Analytics.Reports.Enums.DataType.int32)) {
  3820. var regex = /^[0-9]*$/;
  3821. var result = regex.test($("#number_" + prop.UniqueId).val().toString());
  3822. if (result == false) {
  3823. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Numbers only Allowed");
  3824. $("#number_" + prop.UniqueId).val('');
  3825. return false;
  3826. }
  3827. }
  3828. });
  3829. if (callback != null)
  3830. callback();
  3831. }
  3832. loadControl(containerid, prop) {
  3833. var regExpr = "";
  3834. var ErrMsg = "";
  3835. var validationlist = prop.Validations;
  3836. if (validationlist != null) {
  3837. for (var i = 0; i < validationlist.length; i++) {
  3838. regExpr += validationlist[i].RegularExp + '||';
  3839. ErrMsg += validationlist[i].ErrorMessage + '||';
  3840. }
  3841. }
  3842. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  3843. var required = prop.IsRequired != true ? '' : 'required';
  3844. var reqMark = prop.IsRequired != true ? '' : '*';
  3845. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  3846. if (prop.StagesForRequired != null) {
  3847. var StagesForRequired = prop.StagesForRequired.split('|');
  3848. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  3849. required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  3850. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  3851. }
  3852. const { helpTooltipHtml, helpTextHtml, helpClass } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  3853. var html = `<div id="div_${prop.DocPropertyName}" class="floating-label-form-group ${helpClass}"><label for= "lbl" id="lbl_${prop.FormPropertyId}">${helpTooltipHtml}<span class="label-name">${prop.LabelName}</span><span class="text-danger ${Isrequired}" id="spnIsRequired_${prop.FormPropertyId}"> *</span></label>
  3854. <input type="text" id="number_${prop.UniqueId}" class="type-control creditnumber form-control value-control ${required} floating-label-control number_${prop.DocPropertyName}" data-isdefault="${prop.IsDefault}" data-propdoctypename="${prop.DocTypeName}" data-required="${prop.IsRequired}" data-regularexp="${regExpr}" data-validatemsg="${ErrMsg}" placeholder = "${prop.LabelName} ${reqMark}" data-placeholder="${prop.Placeholder}" data-label="${prop.LabelName} ${reqMark}" value="" />
  3855. <input type="hidden" id="hfId" value=""><label for="Validation" id="lblValidation_${prop.DocPropertyName}"></label><input type="hidden" id="hfFormPropertyId" value="" />${helpTextHtml}</div>`;
  3856. $("#" + containerid).html(html);
  3857. eval('_floatingLabelHelper.init()');
  3858. }
  3859. numberBoxValue(uniqueId, isRequired) {
  3860. var currentValue = $("#number_" + uniqueId).val();
  3861. if (isRequired) {
  3862. if (currentValue == "0") {
  3863. return "";
  3864. }
  3865. else {
  3866. return currentValue;
  3867. }
  3868. }
  3869. else {
  3870. if (currentValue == "" || currentValue == undefined) {
  3871. return "0";
  3872. }
  3873. else {
  3874. return currentValue;
  3875. }
  3876. }
  3877. }
  3878. loadControlSettings(controlsettingjson, formpropertyid) {
  3879. return null;
  3880. }
  3881. loadPropertySettings(propertysettings, formpropertyid) {
  3882. if (propertysettings != null) {
  3883. for (var i = 0; i < propertysettings.length; i++) {
  3884. var data = propertysettings[i];
  3885. if (data.ControlPropertyName == "DefaultValue" && data.ControlPropertyValue != "") {
  3886. $("#number_" + formpropertyid).val(data.ControlPropertyValue);
  3887. $("#number_" + formpropertyid).addClass("floating-label-form-group-with-value");
  3888. }
  3889. }
  3890. }
  3891. }
  3892. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  3893. $("#number_" + formpropertyid).val(propval);
  3894. }
  3895. static Instance() {
  3896. if (this.instance === undefined) {
  3897. this.instance = new NumberBox();
  3898. }
  3899. return this.instance;
  3900. }
  3901. }
  3902. Controls.NumberBox = NumberBox;
  3903. })(Controls = Forms.Controls || (Forms.Controls = {}));
  3904. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  3905. })(Unibase || (Unibase = {}));
  3906. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3907. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3908. return new (P || (P = Promise))(function (resolve, reject) {
  3909. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3910. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3911. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3912. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3913. });
  3914. };
  3915. var Unibase;
  3916. (function (Unibase) {
  3917. let Forms;
  3918. (function (Forms) {
  3919. let Controls;
  3920. (function (Controls) {
  3921. class ImagePicker {
  3922. constructor() {
  3923. this.fileData = [];
  3924. }
  3925. jsFiles() {
  3926. return ["apps/communications/ai/components/resumeparsingmanager.js"];
  3927. }
  3928. init(formpropertyid, prop, callback) {
  3929. var instance = this;
  3930. var errormsg = $(".bizgaze_FormErrorMessages:visible").attr("id");
  3931. if ($("#img_" + prop.FormPropertyId).val() == "") {
  3932. instance.fileData[formpropertyid] = [];
  3933. }
  3934. $('#browse_' + prop.FormPropertyId).click(function () {
  3935. $("#img_" + prop.FormPropertyId).click();
  3936. });
  3937. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  3938. $("#img_" + formpropertyid).change(function (e) {
  3939. $("#editFileName_" + formpropertyid).addClass("hidden");
  3940. if (!$("#editFileName_" + formpropertyid).hasClass("hidden") && instance.fileData[formpropertyid] != []) {
  3941. var fileReq = {
  3942. FileId: 1,
  3943. FilePath: instance.fileData[formpropertyid].FilePath,
  3944. };
  3945. instance.fileData[formpropertyid] = fileReq;
  3946. }
  3947. $("#img_" + formpropertyid).removeAttr("style");
  3948. var file = $("#img_" + formpropertyid).get(0);
  3949. var files = file.files;
  3950. if (!files[0].type.match('image.*')) {
  3951. $("#img_" + formpropertyid).val('');
  3952. MessageHelper.Instance().showError("Please Select Image File.", errormsg);
  3953. }
  3954. else {
  3955. instance.selectImageFile(files[0], prop.DocPropertyName, formpropertyid, null);
  3956. var item = { Files: files[0] };
  3957. instance.getBase64(item).then(function (response) {
  3958. var filePath = null;
  3959. if (instance.fileData[formpropertyid].FilePath != null) {
  3960. filePath = instance.fileData[formpropertyid].FilePath;
  3961. }
  3962. instance.fileData[formpropertyid] = response;
  3963. instance.fileData[formpropertyid].FilePath = filePath;
  3964. });
  3965. }
  3966. });
  3967. if (callback != null) {
  3968. callback();
  3969. }
  3970. }
  3971. selectImageFile(file, DocPropertyName, formpropertyid, imgurl) {
  3972. var instance = this;
  3973. $("#fileCount").addClass('hidden');
  3974. var html = "";
  3975. var imgShow = "";
  3976. var filename = "";
  3977. if (file != null) {
  3978. var tmppath = URL.createObjectURL(file);
  3979. imgShow = tmppath;
  3980. filename = file.name;
  3981. $("#requiredImgInput_" + formpropertyid).val(filename);
  3982. instance.fileHtml(filename, formpropertyid, DocPropertyName, imgShow);
  3983. }
  3984. else {
  3985. filename = DocPropertyName;
  3986. $("#requiredImgInput_" + formpropertyid).val(filename);
  3987. DocPropertyName = "";
  3988. var src = "";
  3989. var path = 'apis/v4/Documents/GetFile?path=' + imgurl;
  3990. Unibase.Platform.Analytics.Managers.ReportManager.Instance().dataHelper().getAsync(path).then(function (response) {
  3991. src = 'data:image/png;base64,' + response.file;
  3992. }).then(function () {
  3993. instance.fileHtml(filename, formpropertyid, DocPropertyName, src);
  3994. });
  3995. }
  3996. }
  3997. fileHtml(filename, formpropertyid, DocPropertyName, imgShow) {
  3998. if (filename.length > 15) {
  3999. var File_Extension = filename.substr(filename.lastIndexOf("."));
  4000. filename = filename.substr(0, 15) + '...' + File_Extension;
  4001. }
  4002. var html = '<li class="list-group-item b-a clear p-0 mb-15" id="list-file_' + formpropertyid + '" style="border: none">' +
  4003. '<span class="block fileuploads filename hidden">' +
  4004. '<span class="pull-left">' +
  4005. '<span class="fa fa-trash-o fa-lg text-danger mr-15" style="cursor:pointer" href="javascript:;" onclick="javascript:Unibase.Forms.Controls.ImagePicker.Instance().removeFile(' + formpropertyid + ',\'' + filename + '\'' + ',\'' + DocPropertyName + '\'' + '); " title="Click to Delete"></span>' +
  4006. '<img id="img_upload " class="mr-20" style="height:35px;width:35px;vertical-align:middle;" alt="" src="' + imgShow + '">' +
  4007. '<span class="h6 fileName" title="' + filename + '">' + filename + '</span>' +
  4008. '</span></span></li>';
  4009. $('.fileuploads_' + formpropertyid).find('.thumb_output_').html(html);
  4010. $('#list-file_' + formpropertyid).find('.fileuploads').removeClass("hidden");
  4011. }
  4012. removeFile(formpropertyid, filename, docpropertyname) {
  4013. $('#img_' + formpropertyid).val(null);
  4014. $("#list-file_" + formpropertyid).remove();
  4015. $("#requiredImgInput_" + formpropertyid).val("");
  4016. $("#editFileName_" + formpropertyid).addClass("hidden");
  4017. }
  4018. loadControl(containerid, prop) {
  4019. var isrequired = 'hidden';
  4020. var required = '';
  4021. if (prop.IsRequired != null) {
  4022. isrequired = (prop.IsRequired) ? '' : 'hidden';
  4023. required = (prop.IsRequired) ? 'required' : '';
  4024. }
  4025. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  4026. var html = '<div id="ImageUpload" class="form-group floating-label focus m-0 pt-10 pb-10">' +
  4027. '<label for="lbl" id="lbl_' + prop.UniqueId + '" >' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + isrequired + '" id="spnIsRequired_' + prop.UniqueId + '"> *</span></label >' +
  4028. '<input id="requiredImgInput_' + prop.UniqueId + '" class="hidden d-none value-control form-control requiredImgInput ' + required + '" type="text" val="">' +
  4029. '<input id="img_' + prop.UniqueId + '" type="file" class="hidden fileUpload_ d-none" data-propertyname="' + prop.DocPropertyName + '" data-isdefault="' + prop.IsDefault + '" data-propdoctypename="' + prop.DocTypeName + '" data-required="' + prop.IsRequired + '" onclick="this.value=null;" />' +
  4030. '<input type="button" value="Choose Image" style="color:black;margin-left:20px;height: 30px;width: 130px;" id="browse_' + prop.UniqueId + '" /><label class="hidden" id="editFileName_' + prop.UniqueId + '"></label>' +
  4031. '<label for="file_' + prop.DocPropertyName + '"><span id="fileCount"></span></label><input type="hidden" id="hfId" value="">' +
  4032. '<label for="Validation" id="lblValidation_' + prop.DocPropertyName + '"></label>' +
  4033. '<input type="hidden" id="hfFormPropertyId" value="" />' + helpTextHtml + '</div>' +
  4034. '<div class="row ml-15 fileuploads_' + prop.FormPropertyId + ' filename"><div class="row col-md-12 pl-2"><div class="row">' +
  4035. '<ul class="list-group mb-n mt-n-15 no-border thumb_output_">' +
  4036. '<li class="hidden no-border"></li>' +
  4037. '</ul></div></div></div>';
  4038. $("#" + containerid).html(html);
  4039. }
  4040. loadControlSettings(controlsettingjson, formpropertyid) {
  4041. return null;
  4042. }
  4043. loadPropertySettings(propertysettings, formpropertyid) {
  4044. return null;
  4045. }
  4046. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  4047. var instance = this;
  4048. if (propval != "") {
  4049. var splitArray = propval.split("/");
  4050. var fileName = splitArray[splitArray.length - 1];
  4051. propval = propval.replaceAll("/", "\\");
  4052. var fileReq = {
  4053. FileId: 0,
  4054. FilePath: propval,
  4055. };
  4056. instance.fileData[formpropertyid] = fileReq;
  4057. $("#editFileName_" + formpropertyid).removeClass("hidden");
  4058. instance.selectImageFile(null, fileName, formpropertyid, propval);
  4059. }
  4060. }
  4061. fileObj(formpropertyid) {
  4062. var instance = this;
  4063. var file = $("#img_" + formpropertyid).get(0);
  4064. var files = file.files;
  4065. if (files.length == 0 && $("#editFileName_" + formpropertyid).hasClass("hidden")) {
  4066. var filepath = instance.fileData[formpropertyid].FilePath;
  4067. if (instance.fileData[formpropertyid].FilePath != undefined) {
  4068. filepath = null;
  4069. }
  4070. var fileReq = {
  4071. FileId: 1,
  4072. FilePath: filepath,
  4073. };
  4074. instance.fileData[formpropertyid] = fileReq;
  4075. }
  4076. return instance.fileData[formpropertyid];
  4077. }
  4078. getBase64(item) {
  4079. return __awaiter(this, void 0, void 0, function* () {
  4080. var filename = "";
  4081. filename = item.Files.DocumentFileName;
  4082. if (filename == undefined)
  4083. filename = item.Files.name;
  4084. let file = item.Files;
  4085. let fileInfo = item.Files.name.split('.');
  4086. return new Promise((resolve, reject) => {
  4087. let instance;
  4088. let content = '';
  4089. const reader = new FileReader();
  4090. reader.readAsDataURL(item.Files);
  4091. reader.onloadend = function () {
  4092. return __awaiter(this, void 0, void 0, function* () {
  4093. var base64String = reader.result.toString().replace(/^data:.+;base64,/, '');
  4094. var fileReq = {
  4095. FileData: base64String,
  4096. FileName: fileInfo[0],
  4097. FileType: fileInfo[1],
  4098. ByteData: null
  4099. };
  4100. resolve(fileReq);
  4101. });
  4102. };
  4103. reader.onerror = function (e) {
  4104. reject(e);
  4105. };
  4106. });
  4107. });
  4108. }
  4109. static Instance() {
  4110. if (this._instance === undefined)
  4111. this._instance = new ImagePicker();
  4112. return this._instance;
  4113. }
  4114. }
  4115. Controls.ImagePicker = ImagePicker;
  4116. })(Controls = Forms.Controls || (Forms.Controls = {}));
  4117. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  4118. })(Unibase || (Unibase = {}));
  4119. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  4120. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4121. return new (P || (P = Promise))(function (resolve, reject) {
  4122. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4123. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4124. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4125. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4126. });
  4127. };
  4128. var Unibase;
  4129. (function (Unibase) {
  4130. let Forms;
  4131. (function (Forms) {
  4132. let Controls;
  4133. (function (Controls) {
  4134. class Tag extends Unibase.Platform.Core.BaseComponent {
  4135. constructor() {
  4136. super(...arguments);
  4137. this.editData = [];
  4138. this.isFormEdit = [];
  4139. }
  4140. init(formpropertyid, prop, callback) {
  4141. var instance = Unibase.Forms.Controls.Tag.Instance();
  4142. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  4143. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  4144. var controlJsonText = JSON.parse(prop.ControlJsonText);
  4145. var containerId = "control-container-" + formpropertyid;
  4146. $("#" + containerId).find("#hdn_tagtype").val(controlJsonText.TagTypeId);
  4147. $("#" + containerId).find("#hdn_tagcategoryid_controljson").val(controlJsonText.TagCategoryId);
  4148. if (controlJsonText.TagTypeId == 1)
  4149. instance.isGroupWiseTag = false;
  4150. else
  4151. instance.isGroupWiseTag = true;
  4152. var initBindData = {
  4153. isBindData: true,
  4154. propVal: "",
  4155. isEdit: false,
  4156. };
  4157. instance.editData[formpropertyid] = initBindData;
  4158. var isApplyFilter = controlJsonText.IsApplyFilter;
  4159. if (isApplyFilter) {
  4160. if (callback != null) {
  4161. var bindData = {
  4162. isBindData: false,
  4163. propVal: "",
  4164. isEdit: true,
  4165. };
  4166. instance.editData[formpropertyid] = bindData;
  4167. callback();
  4168. }
  4169. }
  4170. else {
  4171. instance.getTagsByTagTypeId(containerId, prop.UniqueId, controlJsonText.TagTypeId, controlJsonText.TagCategoryId, isApplyFilter).then(function () {
  4172. if (callback != null) {
  4173. callback();
  4174. }
  4175. });
  4176. }
  4177. }
  4178. loadControl(containerid, prop) {
  4179. var instance = this;
  4180. $("#" + containerid).append('<div id="tagControlParentDiv"><div id="hiddenFieldsDiv"><input type="hidden" id="hdn_tagtype" val="0"/><input type="hidden" id="hdn_taggroups" val="0"/><input type="hidden" id="hdn_tagcategories" val="0"/><input type="hidden" id="hdn_tagcategoryid_controljson" val="0"/><input type="hidden" id="hdn_tagcontrol_' + prop.UniqueId + '" class="hdn_tagcontrol type-control value-control" value="Unibase.Forms.Controls.Tag.Instance().tagItemObj();"><div id="tagControlEmpty" class="row"><small class="ml-10 text-danger">No tags found...</small></div></div><div id="tagControl"></div></div>');
  4181. }
  4182. loadControlSettings(controlsettingjson, formpropertyid) {
  4183. }
  4184. loadPropertySettings(propertysettings, formpropertyid) {
  4185. }
  4186. bindEditFormDetails(formPropertyId, propval, DocPropertyName) {
  4187. var instance = this;
  4188. var editData = instance.editData[formPropertyId];
  4189. if (editData.isBindData) {
  4190. var groupWiseTagsList = JSON.parse(propval.replace(/'/g, '"'));
  4191. var containerid = "control-container-" + formPropertyId;
  4192. var items = [];
  4193. if (groupWiseTagsList.length > 0) {
  4194. for (let k = 0; k < groupWiseTagsList.length; k++) {
  4195. $("#chkGroupWiseTag_" + groupWiseTagsList[k].TagGroupId + "").prop('checked', true);
  4196. }
  4197. var tagItemsList = groupWiseTagsList[0].TagItems;
  4198. for (let i = 0; i < tagItemsList.length; i++) {
  4199. let tagId = tagItemsList[i].TagId;
  4200. let parentTagId = tagItemsList[i].ParentRootId;
  4201. let uniqueId = formPropertyId + "_" + parentTagId;
  4202. if ($("#hfTagShowType_" + uniqueId).val() == Unibase.Platform.Forms.Enums.TagShowType.Select2) {
  4203. var selectedTag = new Option(tagItemsList[i].TagName, tagId.toString(), true);
  4204. $("#ddlMultiChildTags_single_" + uniqueId).append(selectedTag);
  4205. items.push(tagId.toString());
  4206. $("#ddlMultiChildTags_single_" + uniqueId).val(items).trigger("change");
  4207. var selectedTags = $("#ddlMultiChildTags_single_" + uniqueId).val();
  4208. $("#" + containerid).find("#hfSelectedGroupId_" + uniqueId).val(selectedTags);
  4209. }
  4210. else {
  4211. if ($("#hfIsMultiple_" + uniqueId).val() == "true") {
  4212. $("#chkIsChecked_" + formPropertyId + "_" + tagId).prop('checked', true);
  4213. var chktagids = $("#bindtags_" + uniqueId).find(".chkselectedTags:checked").map(function () {
  4214. return jQuery(this).data('tagid');
  4215. });
  4216. chktagids = Array.from(chktagids);
  4217. $("#" + containerid).find("#hfSelectedGroupId_" + uniqueId).val(chktagids);
  4218. }
  4219. else {
  4220. $("#rdBtntag_" + formPropertyId + "_" + tagId).prop('checked', true);
  4221. var rbdtagids = $("#bindtags_" + uniqueId).find(".rdBtntag:checked").map(function () {
  4222. return jQuery(this).data('tagid');
  4223. });
  4224. rbdtagids = Array.from(rbdtagids);
  4225. $("#" + containerid).find("#hfSelectedGroupId_" + uniqueId).val(rbdtagids);
  4226. }
  4227. }
  4228. }
  4229. }
  4230. }
  4231. else {
  4232. var bindData = {
  4233. isBindData: true,
  4234. propVal: propval,
  4235. isEdit: true
  4236. };
  4237. instance.editData[formPropertyId] = bindData;
  4238. }
  4239. }
  4240. bindFilterHiddenFields(tagGroupIds, tagCategoryIds) {
  4241. var instance = this;
  4242. var containerId = $("#tagControl:visible").parents(".divCustomProperties").attr("id");
  4243. var uniquePropId = $("#" + containerId).find("#tagControl").parents(".divCustomProperties").data("uniqueid");
  4244. var tagTypeId = Number($("#" + containerId).find("#tagControlParentDiv").find("#hdn_tagtype").val());
  4245. var tagCategoryId = Number($("#" + containerId).find("#hdn_tagcategoryid_controljson").val());
  4246. $("#" + containerId).find("#hdn_taggroups").val(tagGroupIds);
  4247. $("#" + containerId).find("#hdn_tagcategories").val(tagCategoryIds);
  4248. instance.refreshControl(containerId, uniquePropId, tagTypeId, tagCategoryId);
  4249. }
  4250. refreshControl(containerId, uniquePropId, tagTypeId, tagCategoryId) {
  4251. var instance = this;
  4252. $("#" + containerId).find("#tagControl").empty();
  4253. instance.getTagsByTagTypeId(containerId, uniquePropId, tagTypeId, tagCategoryId, true);
  4254. }
  4255. getTagsByTagTypeId(containerId, uniquePropId, tagTypeId, tagCategoryId, isApplyFilter) {
  4256. return __awaiter(this, void 0, void 0, function* () {
  4257. var instance = this;
  4258. var tagCategoryIds = $("#" + containerId).find("#hdn_tagcategories").val();
  4259. if (tagCategoryIds == undefined && tagCategoryIds == null && tagCategoryIds != "") {
  4260. tagCategoryIds = "0";
  4261. }
  4262. var tagGroupIds = $("#" + containerId).find("#hdn_taggroups").val();
  4263. if (tagGroupIds == undefined && tagGroupIds == null && tagGroupIds == "") {
  4264. tagGroupIds = "0";
  4265. }
  4266. var reqObj = {
  4267. TagSettingTypeId: tagTypeId,
  4268. TagCategoryId: tagCategoryId,
  4269. TagGroupIds: tagGroupIds,
  4270. TagCategoryIds: tagCategoryIds,
  4271. };
  4272. yield Unibase.Platform.Forms.Managers.TagManager.Instance().getTagsByTagTypeId(reqObj).then(function (response) {
  4273. return __awaiter(this, void 0, void 0, function* () {
  4274. var result = response.result;
  4275. $("#" + containerId).find("#tagControlEmpty").addClass("hidden");
  4276. if (response.status == Unibase.Data.Status.Success) {
  4277. if (response.result.length > 0) {
  4278. if (tagTypeId == 1) {
  4279. var parentTags = result[0].TagList;
  4280. yield instance.bindTagHTML(containerId, uniquePropId, parentTags, 0);
  4281. }
  4282. else if (tagTypeId == 2) {
  4283. yield instance.bindTagGroupHTML(containerId, uniquePropId, result);
  4284. }
  4285. }
  4286. if (isApplyFilter) {
  4287. var isEdit = instance.editData[uniquePropId].isEdit;
  4288. if (isEdit) {
  4289. var propVal = instance.editData[uniquePropId].propVal;
  4290. instance.bindEditFormDetails(uniquePropId, propVal, "");
  4291. var initBindData = {
  4292. isBindData: true,
  4293. propVal: "",
  4294. isEdit: false,
  4295. };
  4296. instance.editData[uniquePropId] = initBindData;
  4297. }
  4298. }
  4299. }
  4300. });
  4301. });
  4302. });
  4303. }
  4304. bindTagGroupHTML(containerId, uniquePropId, result) {
  4305. return __awaiter(this, void 0, void 0, function* () {
  4306. var instance = this;
  4307. for (var i = 0; i < result.length; i++) {
  4308. var data = result[i];
  4309. var tagGroupHtml = '<li class="list-group-item col-sm-12 GroupWiseTags" id="liGroupWiseTags_' + data.TagGroupId + '"><a class="clear" onclick="Unibase.Forms.Controls.Tag.Instance().onClickEventsforGroups(' + data.TagGroupId + ')" href="javascript:" style="text-decoration:underline;color:deepskyblue">' + data.GroupName + '</a><input type="checkbox" id="chkGroupWiseTag_' + data.TagGroupId + '" class="pull-right chkGroupWiseTag" data-taggroupid="' + data.TagGroupId + '"><div class="hidden" draggable="true" id="divTags_' + data.TagGroupId + '"><span id="spnMessage" class=""></span><div class="divCustomFormProperties hidden" id="divCustomForm' + data.TagGroupId + '"></div></div></li>';
  4310. $("#" + containerId).append(tagGroupHtml);
  4311. $("#chkGroupWiseTag_" + data.TagGroupId + "").change(function (res) {
  4312. if ($(this).prop('checked') == false) {
  4313. for (let j = 0; j < $(this).parent().find('select').length; j++) {
  4314. $('#' + $(this).parent().find('select')[j].id).val(null).trigger("change");
  4315. $(this).parent().find('.hfSelectedGroupId').val("");
  4316. }
  4317. for (let k = 0; k < $(this).parent().find("input[type='radio'],input[type='checkbox']").length; k++) {
  4318. $('#' + $(this).parent().find("input[type='radio'],input[type='checkbox']")[k].id).prop('checked', false);
  4319. $(this).parent().find('.hfSelectedGroupId').val("");
  4320. }
  4321. }
  4322. });
  4323. yield instance.bindTagHTML(containerId, uniquePropId, data.TagList, data.TagGroupId);
  4324. }
  4325. });
  4326. }
  4327. bindTagHTML(containerId, uniquePropId, parentTags, TagGId) {
  4328. return __awaiter(this, void 0, void 0, function* () {
  4329. var instance = this;
  4330. var taghtml = '';
  4331. var parentTagsLen = 0;
  4332. if (parentTags != null && parentTags != "" && parentTags != undefined) {
  4333. parentTagsLen = parentTags.length;
  4334. }
  4335. if (parentTagsLen != 0) {
  4336. for (var i = 0; i < parentTagsLen; i++) {
  4337. $("#" + containerId).find("#tagControlEmpty").addClass("hidden");
  4338. var requiredCls = "";
  4339. var spanForReq = "";
  4340. var uniqueId = uniquePropId + '_' + parentTags[i].TagId;
  4341. if (parentTags[i].IsRequired == true) {
  4342. spanForReq = '<span class="text-danger " id="spnIsRequired_' + uniqueId + '"> *</span>';
  4343. requiredCls = 'requiredtagsDiv required';
  4344. }
  4345. var hiddenclass = "hidden";
  4346. if (TagGId == 0)
  4347. hiddenclass = "";
  4348. var html = '<div id="div_' + uniqueId + '" class="GroupWiseTagsDiv form-group floating-label focus divtaggroup_' + parentTags[i].TagGroupId + ' divtagid_' + parentTags[i].TagId + ' divtags divtag_' + TagGId + ' ' + hiddenclass + '"><label id="lblTagParentName_' + uniqueId + '">' + parentTags[i].TagName + '</label> ' + spanForReq + '' +
  4349. '<input type="hidden" data-taggroupid="' + parentTags[i].TagGroupId + '" class="hfSelectedGroupId" id="hfSelectedGroupId_' + uniqueId + '" value="" />' +
  4350. '<input type="hidden" id="hfRootTagId_' + uniqueId + '" value="' + parentTags[i].TagId + '" />' +
  4351. '<input type="hidden" id="hfTagShowType_' + uniqueId + '" value="' + parentTags[i].TagShowTypeId + '" />' +
  4352. '<input type="hidden" id="hfIsMultiple_' + uniqueId + '" value="' + parentTags[i].IsMultiple + '" />' +
  4353. '<div id="bindtags_' + uniqueId + '" class="row floating-label-form-group-with-value bindtags_' + uniqueId + ' ' + requiredCls + '"></div></div>';
  4354. if (TagGId == 0)
  4355. $("#" + containerId).find("#tagControl").append(html);
  4356. else
  4357. $("#" + containerId).find("#liGroupWiseTags_" + TagGId).append(html);
  4358. var tagCategoryId = parentTags[i].TagCategoryId;
  4359. var tagShowType = parentTags[i].TagShowTypeId;
  4360. var tagId = parentTags[i].TagId;
  4361. var tagGroupId = parentTags[i].TagGroupId;
  4362. var isMultiple = parentTags[i].IsMultiple;
  4363. var tagsInfo;
  4364. if (tagShowType == Unibase.Platform.Forms.Enums.TagShowType.Select2) {
  4365. taghtml = '';
  4366. var MaxSize = 0;
  4367. var multiple = "";
  4368. if (isMultiple) {
  4369. MaxSize = 50;
  4370. multiple = "multiple";
  4371. }
  4372. else {
  4373. MaxSize = 1;
  4374. }
  4375. taghtml += '<div class="col-12 col-xl-6 d-flex justify-content-between align-items-center tags-select2-container"><div style="flex-grow:2"><select id="ddlMultiChildTags_single_' + uniqueId + '" class="ddlMultiChildTags_single" ' + multiple + ' style="width:100%" data-maxsize="' + MaxSize + '"></select></div>' +
  4376. '<div class="bg-light border border-left-0 d-flex h-100 justify-content-center align-items-center px-10 rounded-bottom-left-0 rounded-top-left-0" style="border-radius:10px;"><a href="javascript:;" onclick="javascript:return Unibase.Forms.Controls.Tag.Instance().tagSelectionPopup(' + tagId + ',' + isMultiple + ',' + uniquePropId + ',' + tagGroupId + ',\'' + containerId + '\')" ><i class="fa fa-pencil"></i></a></div></div>';
  4377. if (TagGId == 0)
  4378. $("#" + containerId).find("#bindtags_" + uniqueId).html(taghtml);
  4379. else
  4380. $("#" + containerId).find("#liGroupWiseTags_" + TagGId).find("#bindtags_" + uniqueId).html(taghtml);
  4381. instance.loadSelect2ForTags(tagId, uniquePropId, tagCategoryId, tagGroupId, "", "", containerId);
  4382. instance.select2ChangeEvent(uniqueId, TagGId, containerId);
  4383. }
  4384. else if (tagShowType == Unibase.Platform.Forms.Enums.TagShowType.Checkbox) {
  4385. var tagresult = parentTags[i]._children;
  4386. if (tagresult.length > 0) {
  4387. var uniquekey = uniquePropId + '_' + tagresult[0].ParentRootId;
  4388. if (isMultiple) {
  4389. taghtml = '';
  4390. for (var j = 0; j < tagresult.length; j++) {
  4391. if (tagresult[j].ParentId != 0) {
  4392. var selected = '';
  4393. if (tagsInfo != undefined && tagsInfo.length > 0) {
  4394. var id = tagsInfo.find(x => x == tagresult[j].TagId) ? true : false;
  4395. if (id == true) {
  4396. selected = "checked";
  4397. }
  4398. }
  4399. taghtml += '<span class="col-sm-6"><div class="col-sm-12">' +
  4400. '<span class="m-l-xs"><input type="checkbox" data-tagid="' + tagresult[j].TagId + '" class="mr-5 chkselectedTags chkselectedTags_' + tagresult[j].TagId + '" onclick="javascript:return Unibase.Forms.Controls.Tag.Instance().checkEvent(' + tagresult[j].TagId + ',' + "'" + containerId + "'" + ',' + uniquePropId + ',' + tagresult[0].ParentRootId + ',' + TagGId + ')" id="chkIsChecked_' + uniquePropId + '_' + tagresult[j].TagId + '" ' + selected + '>' + tagresult[j].TagName + '</span>' +
  4401. '</div></span>';
  4402. }
  4403. if (j == tagresult.length - 1) {
  4404. if (TagGId == 0)
  4405. $("#" + containerId).find("#bindtags_" + uniquekey).html(taghtml);
  4406. else
  4407. $("#" + containerId).find("#liGroupWiseTags_" + TagGId).find("#bindtags_" + uniquekey).html(taghtml);
  4408. }
  4409. }
  4410. }
  4411. else {
  4412. taghtml = '';
  4413. for (var k = 0; k < tagresult.length; k++) {
  4414. if (tagresult[k].ParentId != 0) {
  4415. var radioSelected = '';
  4416. if (tagsInfo != undefined && tagsInfo.length > 0) {
  4417. var id = tagsInfo.find(x => x == tagresult[k].TagId) ? true : false;
  4418. if (id == true) {
  4419. radioSelected = "checked";
  4420. }
  4421. }
  4422. taghtml += '<div class="col-sm-12">' +
  4423. '<span class="col-sm-6"><input data-tagid="' + tagresult[k].TagId + '" name="parenttag_' + tagresult[k].ParentRootId + '" class="rdBtntag" onclick="javascript:return Unibase.Forms.Controls.Tag.Instance().checkRadioEvent(' + tagresult[k].TagId + ',' + "'" + containerId + "'" + ',' + uniquePropId + ',' + tagresult[0].ParentRootId + ',' + TagGId + ')" id="rdBtntag_' + uniquePropId + '_' + tagresult[k].TagId + '" value="' + tagresult[k].TagId + '" type="radio" name="rdBtnTags" mutiple="false" ' + radioSelected + ' > ' + tagresult[k].TagName + '</span></div>';
  4424. }
  4425. if (k == tagresult.length - 1) {
  4426. if (TagGId == 0)
  4427. $("#" + containerId).find("#bindtags_" + uniquekey).html(taghtml);
  4428. else
  4429. $("#" + containerId).find("#liGroupWiseTags_" + TagGId).find("#bindtags_" + uniquekey).html(taghtml);
  4430. }
  4431. }
  4432. }
  4433. }
  4434. else {
  4435. }
  4436. }
  4437. else {
  4438. }
  4439. }
  4440. }
  4441. else {
  4442. var hiddenclass = "hidden";
  4443. if (TagGId == 0)
  4444. hiddenclass = "";
  4445. var html = '<div id="div_' + uniqueId + '" class="list-group-item GroupWiseTagsDiv form-group floating-label focus divtags divtag_' + TagGId + ' ' + hiddenclass + '"><input type="hidden" data-taggroupid="' + TagGId + '" class="hfSelectedGroupId" id="hfSelectedGroupId_' + uniqueId + '" value="" /><div class="row"><small class="ml-10 text-danger">No tags found...</small></div></div>';
  4446. if (TagGId == 0)
  4447. $("#" + containerId).find("#tagControl").append(html);
  4448. else
  4449. $("#" + containerId).find("#liGroupWiseTags_" + TagGId).append(html);
  4450. }
  4451. });
  4452. }
  4453. loadSelect2ForTags(TagId, UniquePropId, TagCategoryId, TagGroupId, SelectedIds, Parameters, containerid) {
  4454. var instance = this;
  4455. var uniqueId = UniquePropId + '_' + TagId;
  4456. var Select2SelectedValues = [];
  4457. if (SelectedIds != "" && SelectedIds != null) {
  4458. var ColumnName = "0";
  4459. var Value = "0";
  4460. if (Parameters != null && Parameters != "") {
  4461. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  4462. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  4463. }
  4464. if (SelectedIds == "-1") {
  4465. Select2SelectedValues.push({ id: "-1", text: "All" });
  4466. }
  4467. else {
  4468. var postData = {
  4469. ColumnName: ColumnName,
  4470. FormPropertyId: 0,
  4471. Value: Value,
  4472. bindedData: 0,
  4473. authToken: 0,
  4474. term: 0,
  4475. SelectedIds: SelectedIds,
  4476. };
  4477. Unibase.Platform.Forms.Managers.TagManager.Instance().getSelectedTags(SelectedIds).then(function (response) {
  4478. var result = response.result;
  4479. if (result.length != 0) {
  4480. for (var i = 0; i < result.length; i++) {
  4481. Select2SelectedValues.push({ id: result[i].TagId, text: result[i].TagName });
  4482. }
  4483. }
  4484. });
  4485. }
  4486. }
  4487. if (Select2SelectedValues.length > 0) {
  4488. var Ids = [];
  4489. for (var i = 0; i < Select2SelectedValues.length; i++) {
  4490. if (Select2SelectedValues[i].id != 0) {
  4491. Ids.push(Select2SelectedValues[i].id);
  4492. }
  4493. Ids.push(Select2SelectedValues[i].id);
  4494. }
  4495. }
  4496. var ColumnName = "0";
  4497. var Value = "0";
  4498. if (Parameters != null && Parameters != "") {
  4499. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  4500. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  4501. }
  4502. postData = null;
  4503. $("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).empty();
  4504. instance.bindSelect2Tags(containerid, Select2SelectedValues, Ids, uniqueId, TagGroupId, TagCategoryId, TagId, ColumnName, Value);
  4505. }
  4506. bindSelect2Tags(containerid, Select2SelectedValues, Ids, uniqueId, TagGroupId, TagCategoryId, TagId, ColumnName, Value) {
  4507. var istagselect = false;
  4508. if ($("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).data("istagselect") == "true") {
  4509. istagselect = true;
  4510. }
  4511. var postData = null;
  4512. var userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  4513. var sessionid = userinfo.sessionId;
  4514. $("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).select2({
  4515. placeholder: "Select",
  4516. tags: istagselect,
  4517. allowClear: true,
  4518. theme: "default select2ErrorClass",
  4519. data: Select2SelectedValues,
  4520. ajax: {
  4521. url: function (request) {
  4522. var reqUrl = _appsettings.server_url() + "/apis/v4/unibase/platform/forms/autotagsforassignment";
  4523. return reqUrl;
  4524. },
  4525. type: "POST",
  4526. contentType: 'application/json',
  4527. dataType: 'json',
  4528. data: function (params) {
  4529. var ParticipantsCount = 0;
  4530. var p = $("#" + containerid).find("#ddlMultiChildTags_single_" + uniqueId).val();
  4531. var Participant = (p == null) ? "" : p.toString();
  4532. ParticipantsCount = Participant.replace(/,/g, "|");
  4533. if (ParticipantsCount == "") {
  4534. ParticipantsCount = "0";
  4535. }
  4536. var Term = params.term;
  4537. sessionid = sessionid.replace('#', '');
  4538. postData = {
  4539. TagGroupId: TagGroupId,
  4540. TagCatagoryId: TagCategoryId,
  4541. TagId: TagId,
  4542. ColumnName: ColumnName,
  4543. FormPropertyId: 0,
  4544. Value: Value,
  4545. bindedData: ParticipantsCount,
  4546. authToken: sessionid,
  4547. term: Term,
  4548. };
  4549. return JSON.stringify(postData);
  4550. },
  4551. beforeSend: function (xhr) {
  4552. if (userinfo !== undefined && userinfo !== null) {
  4553. xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
  4554. xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
  4555. }
  4556. },
  4557. processResults: function (data) {
  4558. return {
  4559. results: jQuery.map(JSON.parse(data.result), function (item) {
  4560. return {
  4561. id: item.Value,
  4562. text: item.SelectText,
  4563. addlInfo: item.addlData
  4564. };
  4565. })
  4566. };
  4567. },
  4568. },
  4569. escapeMarkup: function (m) {
  4570. return m;
  4571. },
  4572. templateResult: formatRepo,
  4573. templateSelection: formatRepoSelection,
  4574. });
  4575. var newText = [];
  4576. function formatRepo(repo) {
  4577. if (repo.loading) {
  4578. return repo.text;
  4579. }
  4580. var markup = "";
  4581. if (repo.text.includes('|')) {
  4582. newText = repo.text.split('|');
  4583. markup =
  4584. "<div class='select2-result-repository__meta'>" +
  4585. "<div class='select2-result-repository__title'><strong>" + newText[0] + "</strong></div>";
  4586. markup += "<div class='select2-result-repository__statistics'>" +
  4587. "<div class='select2-result-repository__forks'><i class='fa fa-envelope'></i> " + newText[1] + "</div>" +
  4588. "</div>" +
  4589. "</div></div>";
  4590. }
  4591. else {
  4592. markup =
  4593. "<div class='select2-result-repository__meta'>" +
  4594. "<div class='select2-result-repository__title'>" + repo.text + "</div>";
  4595. }
  4596. return markup;
  4597. }
  4598. function formatRepoSelection(repo) {
  4599. if (repo.id != 0) {
  4600. newText = repo.text.split('|');
  4601. return newText[0];
  4602. }
  4603. if (repo.id === '') {
  4604. return 'Select';
  4605. }
  4606. }
  4607. $("#ddlMultiChildTags_single_" + uniqueId).css("border-color", "rgb(255, 255, 255)");
  4608. jQuery("#ddlMultiChildTags_single_" + uniqueId).val(Ids).trigger('change');
  4609. $('.select2-search__field').css('width', '100%');
  4610. }
  4611. tagSelectionPopup(tagId, IsMultiple, UniquePropId, tagGroupId, containerId) {
  4612. var instance = this;
  4613. instance.fileCacheHelper.loadJsFile('platform/tag/component/tagselection.js', function () {
  4614. Unibase.Platform.Forms.Components.TagSelection.Instance().loadTagSelectionForm(tagId, IsMultiple, UniquePropId, tagGroupId, containerId);
  4615. });
  4616. }
  4617. select2ChangeEvent(uniqueId, taggroupid, containerid) {
  4618. var instance = this;
  4619. $("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).on('select2:select', function (e) {
  4620. var selectedValues = $("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).val();
  4621. if (selectedValues != null) {
  4622. selectedValues = selectedValues.toString();
  4623. }
  4624. $("#" + containerid).find("#hfSelectedGroupId_" + uniqueId).val(selectedValues);
  4625. if (instance.isGroupWiseTag) {
  4626. instance.refreshChkGroupWiseTags(taggroupid, true);
  4627. }
  4628. });
  4629. $("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).on('select2:unselect', function (e) {
  4630. var selectedValues = $("#" + containerid).find('#ddlMultiChildTags_single_' + uniqueId).val();
  4631. if (selectedValues != null) {
  4632. selectedValues = selectedValues.toString();
  4633. }
  4634. $("#" + containerid).find("#hfSelectedGroupId_" + uniqueId).val(selectedValues);
  4635. if (instance.isGroupWiseTag) {
  4636. instance.refreshChkGroupWiseTags(taggroupid, false);
  4637. }
  4638. });
  4639. }
  4640. checkEvent(tagId, containerId, UniquePropId, rootTagId, tagGroupId) {
  4641. var instance = this;
  4642. var uniqueKey = UniquePropId + '_' + rootTagId;
  4643. var selectedValues = $("#" + containerId).find("#hfSelectedGroupId_" + uniqueKey).val();
  4644. if ($("#" + containerId).find("#chkIsChecked_" + UniquePropId + '_' + tagId).is(':checked')) {
  4645. if (selectedValues == undefined || selectedValues == "")
  4646. selectedValues = tagId.toString();
  4647. else
  4648. selectedValues += "," + tagId;
  4649. if (instance.isGroupWiseTag) {
  4650. if (selectedValues == undefined || selectedValues == "")
  4651. $("#chkGroupWiseTag_" + tagGroupId).prop("checked", false);
  4652. else
  4653. $("#chkGroupWiseTag_" + tagGroupId).prop("checked", true);
  4654. }
  4655. }
  4656. else {
  4657. var array = selectedValues.toString().split(",");
  4658. var index = array.findIndex(x => x == tagId);
  4659. array.splice(index, 1);
  4660. selectedValues = array.toString();
  4661. if (instance.isGroupWiseTag) {
  4662. if (!selectedValues && !$(`#liGroupWiseTags_${tagGroupId} .chkselectedTags:checked`).length)
  4663. $("#chkGroupWiseTag_" + tagGroupId).prop("checked", false);
  4664. else
  4665. $("#chkGroupWiseTag_" + tagGroupId).prop("checked", true);
  4666. }
  4667. }
  4668. $("#" + containerId).find("#hfSelectedGroupId_" + uniqueKey).val(selectedValues);
  4669. }
  4670. checkRadioEvent(tagId, containerId, UniquePropId, rootTagId, tagGroupId) {
  4671. var instance = this;
  4672. var uniqueKey = UniquePropId + '_' + rootTagId;
  4673. if ($("#" + containerId).find("#rdBtntag_" + UniquePropId + '_' + tagId).is(':checked')) {
  4674. $("#" + containerId).find("#hfSelectedGroupId_" + uniqueKey).val(tagId.toString());
  4675. if (instance.isGroupWiseTag) {
  4676. instance.refreshChkGroupWiseTags(tagGroupId, true);
  4677. }
  4678. }
  4679. else {
  4680. $("#" + containerId).find("#hfSelectedGroupId_" + uniqueKey).val("");
  4681. if (instance.isGroupWiseTag) {
  4682. instance.refreshChkGroupWiseTags(tagGroupId, false);
  4683. }
  4684. }
  4685. }
  4686. onClickEventsforGroups(tagGroupId) {
  4687. var HiddenStatus = $('.divtag_' + tagGroupId).hasClass("hidden");
  4688. if (HiddenStatus) {
  4689. $('.divtag_' + tagGroupId).removeClass("hidden");
  4690. }
  4691. else {
  4692. $('.divtag_' + tagGroupId).addClass("hidden");
  4693. }
  4694. }
  4695. refreshChkGroupWiseTags(TagGroupId, IsInclude) {
  4696. var instance = this;
  4697. var IsValue = instance.findValue(TagGroupId);
  4698. if (TagGroupId != undefined && TagGroupId != "") {
  4699. if (IsInclude == true && IsValue == true) {
  4700. $("#chkGroupWiseTag_" + TagGroupId).prop("checked", true);
  4701. }
  4702. else if (IsInclude == true && IsValue == false) {
  4703. $("#chkGroupWiseTag_" + TagGroupId).prop("checked", false);
  4704. }
  4705. else if (IsInclude == false && IsValue == true) {
  4706. $("#chkGroupWiseTag_" + TagGroupId).prop("checked", true);
  4707. }
  4708. else if (IsInclude == false && IsValue == false) {
  4709. $("#chkGroupWiseTag_" + TagGroupId).prop("checked", false);
  4710. }
  4711. }
  4712. }
  4713. findValue(TagGroupId) {
  4714. var IsValue = false;
  4715. $("#liGroupWiseTags_" + TagGroupId).find(".hfSelectedGroupId").each(function () {
  4716. var tagIds = $(this).val().toString().split(',');
  4717. if (tagIds.length > 1) {
  4718. IsValue = true;
  4719. return false;
  4720. }
  4721. if (tagIds[0] != "") {
  4722. IsValue = true;
  4723. return false;
  4724. }
  4725. });
  4726. return IsValue;
  4727. }
  4728. tagItemObj() {
  4729. var instance = this;
  4730. var tagItemArray = new Array();
  4731. var groupWiseTagArray = new Array();
  4732. if (instance.isGroupWiseTag) {
  4733. $(".GroupWiseTags").each(function () {
  4734. var tagItemArray = new Array();
  4735. var isTagGroup = $(this).find('.chkGroupWiseTag').prop('checked');
  4736. if (isTagGroup) {
  4737. $(".GroupWiseTagsDiv").each(function () {
  4738. var selectedGroupIds = $(this).find(".hfSelectedGroupId").val();
  4739. if (selectedGroupIds != undefined && selectedGroupIds != "") {
  4740. var tagIds = selectedGroupIds.toString().split(',');
  4741. for (var i = 0; i < tagIds.length; i++) {
  4742. if (Number(tagIds[i]) != 0) {
  4743. tagItemArray.push({
  4744. TagItemId: 0,
  4745. TagId: Number(tagIds[i]),
  4746. });
  4747. }
  4748. }
  4749. }
  4750. });
  4751. groupWiseTagArray.push({
  4752. TagItemId: 0,
  4753. TagGroupId: Number($(this).find('.chkGroupWiseTag').data("taggroupid")),
  4754. TagItems: tagItemArray,
  4755. });
  4756. }
  4757. });
  4758. }
  4759. else {
  4760. $(".GroupWiseTagsDiv").each(function () {
  4761. var tagItemArray = new Array();
  4762. var selectedGroupIds = $(this).find(".hfSelectedGroupId").val();
  4763. if (selectedGroupIds != undefined && selectedGroupIds != "") {
  4764. var tagIds = selectedGroupIds.toString().split(',');
  4765. if (tagIds[0] != "" && tagIds.length > 0) {
  4766. for (var i = 0; i < tagIds.length; i++) {
  4767. if (Number(tagIds[i]) != 0) {
  4768. tagItemArray.push({
  4769. TagItemId: 0,
  4770. TagId: Number(tagIds[i]),
  4771. });
  4772. }
  4773. }
  4774. }
  4775. if (tagItemArray.length > 0) {
  4776. groupWiseTagArray.push({
  4777. TagItemId: 0,
  4778. TagGroupId: Number($(this).find(".hfSelectedGroupId").data("taggroupid")),
  4779. TagItems: tagItemArray,
  4780. });
  4781. }
  4782. }
  4783. });
  4784. }
  4785. var checkrequired = true;
  4786. if (instance.isGroupWiseTag) {
  4787. $(".GroupWiseTagsDiv").addClass("hidden");
  4788. $(".requiredtagsDiv").closest(".GroupWiseTagsDiv").each(function (e) {
  4789. var isGroupChecked = $(this).closest(".GroupWiseTags").find(".chkGroupWiseTag").prop("checked");
  4790. var value = $(this).find(".hfSelectedGroupId").val();
  4791. if (value == "" && isGroupChecked) {
  4792. $(this).find('.select2-selection').addClass("form-group-required");
  4793. checkrequired = false;
  4794. if (instance.isGroupWiseTag) {
  4795. $(this).removeClass("hidden");
  4796. }
  4797. }
  4798. });
  4799. }
  4800. else {
  4801. $(".requiredtagsDiv").closest(".GroupWiseTagsDiv").each(function (e) {
  4802. var value = $(this).find(".hfSelectedGroupId").val();
  4803. if (value == "") {
  4804. $(this).find('.select2-selection').addClass("form-group-required");
  4805. checkrequired = false;
  4806. if (instance.isGroupWiseTag) {
  4807. $(this).removeClass("hidden");
  4808. }
  4809. }
  4810. });
  4811. }
  4812. if (checkrequired == false) {
  4813. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Mandatory fields are missing");
  4814. return false;
  4815. }
  4816. else {
  4817. return groupWiseTagArray;
  4818. }
  4819. }
  4820. static Instance() {
  4821. if (this.instance === undefined) {
  4822. this.instance = new Tag();
  4823. }
  4824. return this.instance;
  4825. }
  4826. }
  4827. Controls.Tag = Tag;
  4828. })(Controls = Forms.Controls || (Forms.Controls = {}));
  4829. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  4830. })(Unibase || (Unibase = {}));
  4831. var Unibase;
  4832. (function (Unibase) {
  4833. let Forms;
  4834. (function (Forms) {
  4835. let Controls;
  4836. (function (Controls) {
  4837. class TimePicker {
  4838. init(formpropertyid, prop, callback) {
  4839. var instance = TimePicker.Instance();
  4840. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  4841. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  4842. var formid = $("#time_" + prop.DocPropertyName).parents('.formValidate').attr('id');
  4843. var errormsg = $("#" + formid).find('.bizgaze_FormErrorMessages').attr('id');
  4844. if (callback != null)
  4845. callback();
  4846. }
  4847. loadControl(containerid, prop) {
  4848. var regExpr = "";
  4849. var ErrMsg = "";
  4850. var validationlist = prop.Validations;
  4851. if (validationlist != null) {
  4852. for (var i = 0; i < validationlist.length; i++) {
  4853. regExpr += validationlist[i].RegularExp + '||';
  4854. ErrMsg += validationlist[i].ErrorMessage + '||';
  4855. }
  4856. }
  4857. var Isrequired = prop.IsRequired != true ? 'hidden' : '';
  4858. var requiredClass = prop.IsRequired != true ? '' : 'required';
  4859. var reqMark = prop.IsRequired != true ? '' : '*';
  4860. var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val();
  4861. if (prop.IncludedStages != null && prop.IncludedStages != "") {
  4862. var StagesForRequired = prop.IncludedStages.split('|');
  4863. Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden';
  4864. requiredClass = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : '';
  4865. reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : '';
  4866. }
  4867. if (prop.ExcludedStages != null && prop.ExcludedStages != "") {
  4868. var ExcludedStages = prop.ExcludedStages.split('|');
  4869. Isrequired = ExcludedStages.find(x => x == CurrentStageId) ? 'hidden' : '';
  4870. requiredClass = ExcludedStages.find(x => x == CurrentStageId) ? '' : 'required';
  4871. reqMark = ExcludedStages.find(x => x == CurrentStageId) ? '' : '*';
  4872. }
  4873. let ControlId = 'txt_' + prop.DocPropertyId;
  4874. if (prop.IsRequired)
  4875. requiredClass = 'required';
  4876. const { helpTooltipHtml, helpTextHtml } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop);
  4877. let html = '<div class="floating-label-form-group floating-label-form-group-with-value">' +
  4878. '<label for="lbl" id="lbl_' + prop.ControlId + '">' + helpTooltipHtml + '<span class="label-name">' + prop.LabelName + '</span><span class="text-danger ' + Isrequired + '" id="spnIsRequired_' + prop.DocPropertyId + '"> *</span></label>' +
  4879. '<div class="input-group">' +
  4880. '<input type="time" id = "time_' + prop.DocPropertyName + '" class="type-control form-control value-control ' + requiredClass + '" data - propdoctypename="${prop.DocTypeName}" data-regularexp="' + regExpr + '" data - validatemsg="' + ErrMsg + '" placeholder = "' + prop.Placeholder + '" data-placeholder="' + prop.Placeholder + '" data-label="' + prop.LabelName + reqMark + '" /> ' +
  4881. '<input type="hidden" id="hfId" value=""><label for="Validation" id="lblValidation_"' + prop.DocPropertyName + '"></label><input type="hidden" id="hfFormPropertyId" value="" /></div>' + helpTextHtml + '</div>';
  4882. $("#" + containerid).append(html);
  4883. }
  4884. loadControlSettings(controlsettingjson, formpropertyid) {
  4885. return null;
  4886. }
  4887. loadPropertySettings(propertysettings, formpropertyid) {
  4888. return null;
  4889. }
  4890. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  4891. var time = propval.split(" ");
  4892. let timeVal = time[1];
  4893. let meridiem = time[2];
  4894. if (typeof meridiem != "undefined") {
  4895. let [hours, minutes] = timeVal.split(':');
  4896. let formattedTime = "";
  4897. if (meridiem == 'PM') {
  4898. if (hours === '12') {
  4899. hours = '00';
  4900. }
  4901. hours = parseInt(hours, 10) + 12;
  4902. formattedTime = `${hours}:${minutes}`;
  4903. time[1] = formattedTime;
  4904. }
  4905. else if (hours.length == 1) {
  4906. hours = "0" + hours;
  4907. formattedTime = `${hours}:${minutes}`;
  4908. time[1] = formattedTime;
  4909. }
  4910. }
  4911. $("#time_" + DocPropertyName).val(time[1]);
  4912. }
  4913. static Instance() {
  4914. if (this.instance === undefined) {
  4915. this.instance = new TimePicker();
  4916. }
  4917. return this.instance;
  4918. }
  4919. }
  4920. Controls.TimePicker = TimePicker;
  4921. })(Controls = Forms.Controls || (Forms.Controls = {}));
  4922. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  4923. })(Unibase || (Unibase = {}));
  4924. var Bizgaze;
  4925. (function (Bizgaze) {
  4926. let Apps;
  4927. (function (Apps) {
  4928. let Transact;
  4929. (function (Transact) {
  4930. let Controls;
  4931. (function (Controls) {
  4932. class Wallet extends Unibase.Platform.Core.BaseComponent {
  4933. init(formpropertyid, prop, callback) {
  4934. var instance = this;
  4935. instance.flag = 0;
  4936. instance.isWalletLoading = false;
  4937. var jsfiles = ['apps/transact/managers/payments/paymentmanager.js', 'platform/core/helpers/numberhelper/numberhelper.js', 'apps/transact/controls/payments/paymentsummary.components.js'];
  4938. instance.fileCacheHelper.loadJsFiles(jsfiles, function () {
  4939. });
  4940. }
  4941. loadControl(containerid, prop) {
  4942. var instance = this;
  4943. instance.transactionId = prop.FormPropertyId;
  4944. var html = '<div class="col-sm-12 transactonList_div transactonList_div_TRN' + prop.FormPropertyId + ' p-0"><div class="transactonList_item transactonList_item_TRN' + prop.FormPropertyId + '" name="' + prop.FormPropertyId + '"><div id="walletControl_transactonListDiv" class="col-sm-12 transactonList_div transactonList_div_TRN2 p-0"><div class="row rowWallets" id="walletControlList"><div class="col-sm-3 mt-20 text-ul"><u><a href="javascript:;" class="h6" onclick="Bizgaze.Apps.Transact.Controls.Wallet.Instance().toggleWallets(\'TRN' + prop.FormPropertyId + '\');" >Wallet : <span class="txtWalletsTotalAmt">0.00</span></a></u></div>' +
  4945. '<div class="col-sm-3"></div><div class="d-none d-sm-block col-sm-2 text-right m-r-n"><div class="mt-30"><label class="h6">Adjusted : </label></div></div><div class="block d-sm-none col-sm-2 m-r-n"><div class="mt-30"><label class="h6">Adjusted : </label></div></div><div class="col-sm-4"><div class="floating-label-form-group mt-15"><input data-trnid="TRN' + prop.FormPropertyId + '" id="txtIdTotalWalletAdjusted_TRN' + prop.FormPropertyId + '" class="form-control txtTotalWalletAdjusted txtTotalWalletAdjusted_TRN' + prop.FormPropertyId + ' floating-label-control m-b-n" type="text" onkeypress="return Bizgaze.Apps.Transact.Controls.Wallet.Instance().isDecimalplusNoLongPress(event,this.id);" onkeyup="Bizgaze.Apps.Transact.Controls.Wallet.Instance().totalWalletAdjustment(event,this);"/></div></div></div>' +
  4946. '<input type="hidden" id="hdn_walletcontrol" class="value-control" value="Bizgaze.Apps.Transact.Controls.Wallet.Instance().walletControlObj(\'TRN' + prop.FormPropertyId + '\');"/>' +
  4947. '<section class="mt-5 secWallets secWallets_TRN' + prop.FormPropertyId + ' hidden"><div class="list-group divWallet_List"></div></section></div><input type="hidden" class="hf_AdvanceJournalAllocId" id="hf_AdvanceJournalAllocId_TRN' + instance.transactionId + '" value="">';
  4948. $("#" + containerid).html(html);
  4949. if (prop.PropertySettings != null) {
  4950. for (var i = 0; i < prop.PropertySettings.length; i++) {
  4951. var data = prop.PropertySettings[i];
  4952. if (data.ControlPropertyName == "ControlType" && data.ControlPropertyValue != "") {
  4953. this.controlType = data.ControlPropertyValue;
  4954. }
  4955. }
  4956. }
  4957. if (this.controlType == "1") {
  4958. instance.journalTypeId = 2;
  4959. }
  4960. else if (this.controlType == "2") {
  4961. instance.journalTypeId = 1;
  4962. }
  4963. else if (this.controlType == "3") {
  4964. instance.journalTypeId = 3;
  4965. }
  4966. }
  4967. loadInvoiceWallets(response) {
  4968. var instance = this;
  4969. var trnId = instance.transactionId;
  4970. var result = response;
  4971. var element = $('.transactonList_item_TRN' + trnId + '');
  4972. var divWallets = element.find('.divWallet_List');
  4973. $(divWallets).empty();
  4974. $(divWallets).html('<div class="list-group-item m-b-n divWallet_List_item hidden"></div>');
  4975. var walletsTotalBal = 0;
  4976. var adjustdTotalAmount = 0;
  4977. if (result.length != 0) {
  4978. for (var i = 0; i < result.length; i++) {
  4979. var item = result[i];
  4980. walletsTotalBal += Number(item.TotalAmount - item.CurrentAmount);
  4981. adjustdTotalAmount += Number(item.CurrentAmount);
  4982. function datediff(date2, today) {
  4983. today = new Date(today.split('/')[2], today.split('/')[1] - 1, today.split('/')[0]);
  4984. date2 = new Date(date2.split('/')[2], date2.split('/')[1] - 1, date2.split('/')[0]);
  4985. var timeDiff = Math.abs(today.getTime() - date2.getTime());
  4986. var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
  4987. return diffDays;
  4988. }
  4989. var today = new Date();
  4990. var dd = today.getDate();
  4991. var mm = today.getMonth() + 1;
  4992. var yyyy = today.getFullYear();
  4993. if (dd < 10) {
  4994. dd = '0' + dd;
  4995. }
  4996. if (mm < 10) {
  4997. mm = '0' + mm;
  4998. }
  4999. today = dd + '/' + mm + '/' + yyyy;
  5000. var wBalance = Number(item.TotalAmount);
  5001. var NumOfDays = datediff(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(item.JournalDate, null), today);
  5002. instance.bindWalletsHtml(item, wBalance, NumOfDays, item.CurrentAmount, trnId);
  5003. }
  5004. }
  5005. if (walletsTotalBal > 0)
  5006. element.find('.txtWalletsTotalAmt').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletsTotalBal, 2));
  5007. else
  5008. element.find('.txtWalletsTotalAmt').text("0.00");
  5009. if (adjustdTotalAmount > 0)
  5010. element.find('.txtTotalWalletAdjusted').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(adjustdTotalAmount, 2));
  5011. else
  5012. element.find('.txtTotalWalletAdjusted').val("0.00");
  5013. }
  5014. loadPaymentWallets(contactId) {
  5015. var instance = this;
  5016. if (contactId != null && contactId != 0 && contactId != undefined) {
  5017. var instance = this;
  5018. var trnId = instance.transactionId;
  5019. var paymentid = 0;
  5020. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length != 0) {
  5021. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  5022. var hiddenFieldPaymentId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_paymentid");
  5023. if (hiddenFieldPaymentId != null || hiddenFieldPaymentId != undefined) {
  5024. paymentid = Number(hiddenFieldPaymentId.Value);
  5025. }
  5026. }
  5027. var lobid = Number($(".txtAutoComplete_lobid").val());
  5028. if (isNaN(lobid)) {
  5029. lobid = 0;
  5030. }
  5031. var date = "";
  5032. var userDate = $(".date_journaldate").val();
  5033. if (userDate != undefined && userDate != null && userDate != "") {
  5034. var formattedUserDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(userDate);
  5035. date = moment(formattedUserDate).format("YYYY-MM-DD");
  5036. }
  5037. else {
  5038. var curDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  5039. date = moment(curDate).format("YYYY-MM-DD");
  5040. }
  5041. var adjustedTotal = 0;
  5042. instance.isWalletLoading = true;
  5043. instance.navigationHelper.showLoading();
  5044. var element = $('.transactonList_item_TRN' + trnId + '');
  5045. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getPendings(Number(contactId), paymentid, null, instance.journalTypeId, lobid, date, "Wallets").then(function (response) {
  5046. var result = response.result;
  5047. var divWallets = element.find('.divWallet_List');
  5048. $(divWallets).empty();
  5049. $(divWallets).html('<div class="list-group-item m-b-n divWallet_List_item hidden"></div>');
  5050. var walletsTotalBal = 0;
  5051. if (result.length != 0) {
  5052. for (var i = 0; i < result.length; i++) {
  5053. var item = result[i];
  5054. adjustedTotal += item.Amount;
  5055. walletsTotalBal += Number(item.JournalAlloc.TotalAmount - item.JournalAlloc.AdjustedAmount);
  5056. function datediff(date2, today) {
  5057. today = new Date(today.split('/')[2], today.split('/')[1] - 1, today.split('/')[0]);
  5058. date2 = new Date(date2.split('/')[2], date2.split('/')[1] - 1, date2.split('/')[0]);
  5059. var timeDiff = Math.abs(today.getTime() - date2.getTime());
  5060. var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
  5061. return diffDays;
  5062. }
  5063. var today = new Date();
  5064. var dd = today.getDate();
  5065. var mm = today.getMonth() + 1;
  5066. var yyyy = today.getFullYear();
  5067. if (dd < 10) {
  5068. dd = '0' + dd;
  5069. }
  5070. if (mm < 10) {
  5071. mm = '0' + mm;
  5072. }
  5073. today = dd + '/' + mm + '/' + yyyy;
  5074. var wBalance = Number(item.JournalAlloc.TotalAmount - item.JournalAlloc.AdjustedAmount);
  5075. var NumOfDays = datediff(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(item.JournalAlloc.JournalDate, null), today);
  5076. instance.bindWalletsHtml(item.JournalAlloc, wBalance, NumOfDays, item.Amount, trnId);
  5077. }
  5078. }
  5079. if (walletsTotalBal > 0)
  5080. element.find('.txtWalletsTotalAmt').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletsTotalBal, 2));
  5081. else
  5082. element.find('.txtWalletsTotalAmt').text("0.00");
  5083. }).then(function () {
  5084. $(".txtTotalWalletAdjusted").val(adjustedTotal);
  5085. element.find('.secWallets_' + trnId + '').addClass('hidden');
  5086. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5087. instance.isWalletLoading = false;
  5088. var isDueLoading = Bizgaze.Apps.Transact.Controls.Dues.Instance().isDueLoading;
  5089. if (instance.isWalletLoading == false && isDueLoading == false) {
  5090. instance.navigationHelper.hideLoading();
  5091. }
  5092. });
  5093. }
  5094. }
  5095. toggleWallets(trnId) {
  5096. var instance = this;
  5097. var element = $('.transactonList_item_' + trnId + '');
  5098. element.find('.secWallets_' + trnId + '').toggleClass('hidden');
  5099. }
  5100. isDecimal(evt, id) {
  5101. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5102. if (charCode == 46) {
  5103. var val = document.getElementById(id);
  5104. var txt = val.value;
  5105. if (!(txt.indexOf(".") > -1)) {
  5106. return true;
  5107. }
  5108. }
  5109. if (charCode > 31 && (charCode < 48 || charCode > 57))
  5110. return false;
  5111. return true;
  5112. }
  5113. isDecimalplusNoLongPress(evt, id) {
  5114. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5115. if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
  5116. return false;
  5117. else {
  5118. var val = document.getElementById(id);
  5119. var len = val.value.length;
  5120. var index = val.value.indexOf('.');
  5121. if (index > 0 && charCode == 46) {
  5122. return false;
  5123. }
  5124. if (index > 0) {
  5125. var CharAfterdot = (len + 1) - index;
  5126. if (CharAfterdot > 3) {
  5127. return false;
  5128. }
  5129. }
  5130. }
  5131. return true;
  5132. }
  5133. initFlag() {
  5134. var instance = this;
  5135. instance.flag = 0;
  5136. }
  5137. bindWalletsHtml(journalAlloc, wBalance, NumOfDays, Amount, formPropId) {
  5138. var instance = this;
  5139. var html = '<div class="list-group-item divWallet_Item" id="divWallet_List_item_' + journalAlloc.JournalId + '"><div class="row">' +
  5140. '<input type="hidden" class="hf_JournalAllocId" value="' + journalAlloc.JournalAllocId + '" />' +
  5141. '<input type="hidden" class="hf_RefAllocId" value="' + journalAlloc.RefAllocId + '" />' +
  5142. '<input type="hidden" class="hf_JournalId" value="' + journalAlloc.JournalId + '" />' +
  5143. '<input type="hidden" class="hf_AdjustedAmount" value="' + journalAlloc.AdjustedAmount + '" />' +
  5144. '<div class="col-sm-4"><div class="floating-label-form-group m-b floating-label-form-group-with-value py-1 m-0 p-0 border-0 shadow-none" style="border:0px"><div class="h6 h-100 card-header align-items-center d-flex p-0 border-0">' + journalAlloc.JournalNo + ' (' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(wBalance, 2) + ')</div><input class="form-control value-control text-dark" disabled type="text" value="' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(journalAlloc.JournalDate, null) + ' (' + NumOfDays + ' days)"></div></div>' +
  5145. '<div class="col-sm-4"><div class="floating-label-form-group m-b floating-label-form-group-with-value py-1 m-0 p-0 border-0 shadow-none" style="border:0px"><div class="h6 h-100 card-header align-items-center d-flex p-0 border-0">Remaining Amt</div><input class="hfWalletAmount" type="hidden" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(wBalance, 2) + '" /><input id="lblWalletRemaing_' + journalAlloc.JournalId + '" class="form-control value-control lblWalletRemaing text-dark" disabled type="text" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(wBalance - Amount, 2) + '"></div></div>' +
  5146. '<div class="col-sm-4"><div class="floating-label-form-group m-b py-1 m-0 p-0 border-0 shadow-none"><div class="h6 card-header align-items-center d-flex p-0 h-100 border-0">Adjusted Amt</div><input id="txtWalletCurrentAmount_' + journalAlloc.JournalId + '" type="text" value="' + Amount + '" class="form-control txtWalletCurrentAmount floating-label-control value-control" placeholder="Amount" data-label="Amount" onkeypress="return Bizgaze.Apps.Transact.Controls.Wallet.Instance().isDecimalplusNoLongPress(event,this.id)" onkeyup="Bizgaze.Apps.Transact.Controls.Wallet.Instance().AdjustWalletAmount(\'' + journalAlloc.JournalId + '\',\'' + "TRN" + formPropId + '\',event);" /></div></div>' +
  5147. '</div></div>';
  5148. var element = $('.transactonList_item_TRN' + formPropId + '');
  5149. element.find('.divWallet_List_item').before(html);
  5150. }
  5151. bindWalletEvents() {
  5152. }
  5153. totalWalletAdjustment(evt, curElement) {
  5154. var instance = this;
  5155. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5156. if (charCode == 190 || charCode == 110 || charCode == 46) {
  5157. return true;
  5158. }
  5159. var errormsg = $(".bizgaze_FormErrorMessages:visible").attr("id");
  5160. instance.initFlag();
  5161. if (instance.controlType != "3") {
  5162. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().loadPaymentSummary();
  5163. }
  5164. var trnId = curElement.dataset.trnid;
  5165. var element = $('.transactonList_item_' + trnId + '');
  5166. var curAdjAmt = Number(element.find('.txtTotalWalletAdjusted').val());
  5167. var totWalletAmt = Number(element.find('.txtWalletsTotalAmt').text());
  5168. if (curAdjAmt > totWalletAmt) {
  5169. var totWalletAmt = Number(element.find('.txtWalletsTotalAmt').text());
  5170. element.find('.txtTotalWalletAdjusted_' + trnId).val(totWalletAmt);
  5171. MessageHelper.Instance().showError("Cannot adjust more than your wallets", errormsg);
  5172. }
  5173. instance.updatePayment(trnId);
  5174. }
  5175. walletsTotal(trnId) {
  5176. var instance = this;
  5177. var element = $('.transactonList_item_' + trnId + '');
  5178. var amount = 0;
  5179. var wTotals = element.find('.txtTotalWalletAdjusted').val();
  5180. wTotals = Number(wTotals);
  5181. if (wTotals > 0)
  5182. amount += wTotals;
  5183. return amount;
  5184. }
  5185. updatePayment(trnId) {
  5186. var instance = this;
  5187. var element = $('.transactonList_item_' + trnId + '');
  5188. var walletsTotal = instance.walletsTotal(trnId);
  5189. if (Number(walletsTotal) != 0) {
  5190. element.find('.txtTotalWalletAdjusted').val(walletsTotal);
  5191. $(element).find('.divWallet_Item').each(function (index) {
  5192. var wAmount = Number($(this).find('.hfWalletAmount').val());
  5193. var wCurrentAmt = 0;
  5194. if (walletsTotal >= wAmount) {
  5195. if (wAmount != 0) {
  5196. walletsTotal -= wAmount;
  5197. wCurrentAmt = wAmount;
  5198. wAmount = 0;
  5199. }
  5200. }
  5201. else {
  5202. wAmount -= walletsTotal;
  5203. wCurrentAmt = walletsTotal;
  5204. walletsTotal = 0;
  5205. }
  5206. $(this).find('.txtWalletCurrentAmount').val(wCurrentAmt);
  5207. $(this).find('.lblWalletRemaing').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(wAmount, 2));
  5208. });
  5209. }
  5210. else if (Number(walletsTotal) == 0) {
  5211. element.find('.txtTotalWalletAdjusted').val(walletsTotal);
  5212. element.find('.txtWalletCurrentAmount').val(walletsTotal);
  5213. $('.divWallet_Item').each(function () {
  5214. $(this).find(".lblWalletRemaing").val($(this).find(".hfWalletAmount").val());
  5215. });
  5216. }
  5217. }
  5218. AdjustWalletAmount(jId, trnId, evt) {
  5219. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5220. if (charCode == 190 || charCode == 110 || charCode == 46) {
  5221. return true;
  5222. }
  5223. var instance = this;
  5224. instance.flag = 0;
  5225. var formId = $(".transactonList_div_" + trnId).parents("form").attr("id").split('_')[1];
  5226. var x = document.getElementById("divWallet_List_item_" + jId).parentElement.parentElement.getAttribute("class");
  5227. var elementforPayment = $('.transactonList_item_' + trnId + '');
  5228. var totAdjustment = $(elementforPayment).find('.txtTotalWalletAdjusted_' + trnId + '').val();
  5229. var totWallet = 0;
  5230. var totWalletAmt = Number(elementforPayment.find('.txtWalletsTotalAmt').text());
  5231. $(elementforPayment).find('.divWallet_Item').each(function () {
  5232. var xyz = Number($(this).find('.txtWalletCurrentAmount').val());
  5233. if (!isNaN(xyz))
  5234. totWallet += xyz;
  5235. });
  5236. var element = elementforPayment.find('#divWallet_List_item_' + jId + '');
  5237. var Amt = $("#hf_TotalCreditAmount").val();
  5238. if (instance.controlType == "3")
  5239. Amt = totWallet;
  5240. if (totWallet <= totWalletAmt) {
  5241. var OrgwalletAmount = Number($(element).find('.hfWalletAmount').val());
  5242. var txtWalletCurrentAmount = 0;
  5243. txtWalletCurrentAmount = Number($(element).find('.txtWalletCurrentAmount').val());
  5244. if (txtWalletCurrentAmount == 0 || txtWalletCurrentAmount == undefined) {
  5245. $(element).find('.txtWalletCurrentAmount').val(0.00);
  5246. $(element).find('.lblWalletRemaing').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(OrgwalletAmount, 2));
  5247. var ttWallet = 0;
  5248. $(elementforPayment).find('.divWallet_Item').each(function () {
  5249. var pqr = Number($(this).find('.txtWalletCurrentAmount').val());
  5250. if (!isNaN(pqr))
  5251. ttWallet += pqr;
  5252. });
  5253. $(elementforPayment).find('.txtTotalWalletAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5254. return false;
  5255. }
  5256. if (txtWalletCurrentAmount > OrgwalletAmount) {
  5257. $(element).find('.txtWalletCurrentAmount').val(OrgwalletAmount);
  5258. $(element).find('.lblWalletRemaing').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5259. }
  5260. else {
  5261. var walletAmount = OrgwalletAmount - txtWalletCurrentAmount;
  5262. $(element).find('.txtWalletCurrentAmount').val(txtWalletCurrentAmount);
  5263. $(element).find('.lblWalletRemaing').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletAmount, 2));
  5264. }
  5265. var ttWallet = 0;
  5266. $(elementforPayment).find('.divWallet_Item').each(function () {
  5267. var pqr = Number($(this).find('.txtWalletCurrentAmount').val());
  5268. if (!isNaN(pqr))
  5269. ttWallet += pqr;
  5270. });
  5271. $(elementforPayment).find('.txtTotalWalletAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5272. }
  5273. else {
  5274. MessageHelper.Instance().showError("You don't have enough amount in that wallets", 'div_ErrorMessage_' + formId);
  5275. $(element).find('.txtWalletCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(element).find('.hfWalletAmount').val()), 2));
  5276. $(element).find('.lblWalletRemaing').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5277. var ttWallet = 0;
  5278. $(elementforPayment).find('.divWallet_Item').each(function () {
  5279. var pqr = Number($(this).find('.txtWalletCurrentAmount').val());
  5280. if (!isNaN(pqr))
  5281. ttWallet += pqr;
  5282. });
  5283. $(elementforPayment).find('.txtTotalWalletAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5284. }
  5285. if (instance.controlType != "3") {
  5286. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5287. Bizgaze.Apps.Transact.Controls.Dues.Instance().clearDues();
  5288. }
  5289. }
  5290. walletControlObj(trnId) {
  5291. var instance = this;
  5292. var element = $('.transactonList_item_' + trnId + '');
  5293. var data = new Array();
  5294. element.find('.divWallet_Item').each(function (index) {
  5295. if ($(this).find('.txtWalletCurrentAmount').val() != 0 && $(this).find('.txtWalletCurrentAmount').val() != '' && $(this).find('.txtWalletCurrentAmount').val() != undefined) {
  5296. var jAId = Number($(this).find('.hf_JournalAllocId').val());
  5297. if (instance.journalTypeId == 1) {
  5298. data.push({
  5299. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  5300. Debit: Number($(this).find('.txtWalletCurrentAmount').val()),
  5301. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  5302. AllocType: 2,
  5303. AllocTypeId: 2
  5304. });
  5305. }
  5306. else if (instance.journalTypeId == 2) {
  5307. data.push({
  5308. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  5309. Credit: Number($(this).find('.txtWalletCurrentAmount').val()),
  5310. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  5311. AllocType: 2,
  5312. AllocTypeId: 2
  5313. });
  5314. }
  5315. else if (instance.controlType == "3") {
  5316. let Notes = "";
  5317. let Debit = 0;
  5318. let Credit = 0;
  5319. if ($(".hdn_invoicetypeid").val() == "1") {
  5320. Notes = "Adjustment SalesReturn against " + $(".hdn_tempjournalno").val();
  5321. Debit = Number($(this).find('.txtWalletCurrentAmount').val());
  5322. }
  5323. else {
  5324. Notes = " Adjustment PurchaseReturn against " + $(".hdn_tempjournalno").val();
  5325. Credit = Number($(this).find('.txtWalletCurrentAmount').val());
  5326. }
  5327. data.push({
  5328. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  5329. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  5330. JournalId: Number($(this).find(".hf_JournalId").val()),
  5331. AdjustedAmount: Number($(this).find('.hf_AdjustedAmount').val()),
  5332. TotalAmount: Number($(this).find(".txtWalletsTotalAmt").text()),
  5333. IsWallet: true,
  5334. CurrentAmount: Number($(this).find('.txtWalletCurrentAmount').val()),
  5335. AllocType: 2,
  5336. Discount: 0,
  5337. RefNo: "",
  5338. Credit: Credit,
  5339. Debit: Debit
  5340. });
  5341. }
  5342. }
  5343. });
  5344. if (Number($(".totAdvance").first().text()) > 0) {
  5345. var jAId = Number($(this).find('.hf_AdvanceJournalAllocId').val());
  5346. if (instance.journalTypeId == 1) {
  5347. data.push({
  5348. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  5349. LedgerId: Number($(".txtAutoComplete_contactid option:selected").val()),
  5350. Credit: Number($(".totAdvance").first().text()),
  5351. RefAllocId: 0,
  5352. AllocType: 3,
  5353. AllocTypeId: 3,
  5354. });
  5355. }
  5356. else if (instance.journalTypeId == 2) {
  5357. data.push({
  5358. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  5359. LedgerId: Number($(".txtAutoComplete_contactid option:selected").val()),
  5360. Debit: Number($(".totAdvance").first().text()),
  5361. RefAllocId: 0,
  5362. AllocType: 3,
  5363. AllocTypeId: 3,
  5364. });
  5365. }
  5366. }
  5367. return data;
  5368. }
  5369. loadControlSettings(controlsettingjson, formpropertyid) {
  5370. return ``;
  5371. }
  5372. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  5373. return ``;
  5374. }
  5375. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  5376. return ``;
  5377. }
  5378. static Instance() {
  5379. if (this.instance === undefined) {
  5380. this.instance = new Wallet();
  5381. }
  5382. return this.instance;
  5383. }
  5384. }
  5385. Controls.Wallet = Wallet;
  5386. })(Controls = Transact.Controls || (Transact.Controls = {}));
  5387. })(Transact = Apps.Transact || (Apps.Transact = {}));
  5388. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  5389. })(Bizgaze || (Bizgaze = {}));
  5390. var Bizgaze;
  5391. (function (Bizgaze) {
  5392. let Apps;
  5393. (function (Apps) {
  5394. let Transact;
  5395. (function (Transact) {
  5396. let Controls;
  5397. (function (Controls) {
  5398. class Dues extends Unibase.Platform.Core.BaseComponent {
  5399. init(formpropertyid, prop, callback) {
  5400. var instance = this;
  5401. instance.flag = 0;
  5402. instance.isDueLoading = false;
  5403. var jsfiles = ['apps/transact/managers/payments/paymentmanager.js', 'platform/core/helpers/numberhelper/numberhelper.js'];
  5404. instance.fileCacheHelper.loadJsFiles(jsfiles, function () {
  5405. });
  5406. }
  5407. loadControl(containerid, prop) {
  5408. var instance = this;
  5409. instance.transactionId = prop.FormPropertyId;
  5410. var html = '<div class="col-sm-12 transactonList_div transactonList_div_TRN' + instance.transactionId + ' p-0"><div class="transactonList_item transactonList_item_TRN' + instance.transactionId + '" name="' + instance.transactionId + '"><div id="dueControl_transactonListDiv" class="col-sm-12 transactonList_div transactonList_div_TRN2 p-0"><div class="row rowDues" id="dueControlList"><input type="hidden" id="hf_TotalDiscountAmount" value=""/><input type="hidden" id="hf_DiscountAccountId" value="0"/><input type="hidden" id="hf_PenalityAccountId" value="0"/><input type="hidden" id="hf_TDSAccountId" value="0"/><input type="hidden" id="hf_DiscountAccountName" value=""/><input type="hidden" id="hf_PenalityAccountName" value=""/><input type="hidden" id="hf_TDSAccountName" value=""/><div class="col-sm-3 mt-20 text-ul"><u><a href="javascript:;" class="h6" onclick="Bizgaze.Apps.Transact.Controls.Dues.Instance().toggleDues(\'TRN' + instance.transactionId + '\');" style="color:#5ba8fb;">Dues : <span class="txtDuesTotalAmt">0.00</span></a></u></div>' +
  5411. '<div class="col-sm-3"></div><div class="d-none d-sm-block col-sm-3 text-right m-r-n"><div class="mt-10"><a href="javascript:;" name="disabled" class="btn btn-sm btn-success" onclick="Bizgaze.Apps.Transact.Controls.Dues.Instance().AutoAdjustDues(\'TRN' + instance.transactionId + '\');" id="btnAutoAdjustDues">Auto Adjust</a></div></div><div class="block d-sm-none col-sm-2 m-r-n"><div class="mt-10"><a href="javascript:;" name="disabled" class="btn btn-sm btn-success" onclick="Bizgaze.Apps.Transact.Controls.Dues.Instance().AutoAdjustDues(\'TRN' + instance.transactionId + '\');" id="btnAutoAdjustDues">Auto Adjust</a></div></div><div class="col-sm-3"><div class="floating-label-form-group m-t-md"><input data-trnid="TRN' + instance.transactionId + '" class="form-control txtTotalDueAdjusted txtTotalDueAdjusted_TRN' + instance.transactionId + ' floating-label-control m-b-n" type="text" style="cursor: not-allowed;" disabled="disabled"/></div></div></div>' +
  5412. '<input type="hidden" id="hdn_duecontrol" class="value-control" value="Bizgaze.Apps.Transact.Controls.Dues.Instance().dueControlObj(\'TRN' + instance.transactionId + '\');"/>' +
  5413. '<section class="mt-5 secDues secDues_TRN' + instance.transactionId + ' hidden"><div class="list-group divDue_List"></div></section>';
  5414. $("#" + containerid).html(html);
  5415. var controlType = "0";
  5416. if (prop.PropertySettings != null) {
  5417. for (var i = 0; i < prop.PropertySettings.length; i++) {
  5418. var data = prop.PropertySettings[i];
  5419. if (data.ControlPropertyName == "ControlType" && data.ControlPropertyValue != "") {
  5420. controlType = data.ControlPropertyValue;
  5421. }
  5422. }
  5423. }
  5424. if (controlType == "1") {
  5425. instance.journalTypeId = 2;
  5426. }
  5427. else if (controlType == "2") {
  5428. instance.journalTypeId = 1;
  5429. }
  5430. else if (controlType == "3") {
  5431. }
  5432. }
  5433. loadPaymentDues(contactId) {
  5434. var instance = this;
  5435. if (contactId != null && contactId != 0 && contactId != undefined) {
  5436. var instance = this;
  5437. var trnId = instance.transactionId;
  5438. var paymentid = 0;
  5439. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length != 0) {
  5440. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  5441. var hiddenFieldPaymentId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_paymentid");
  5442. if (hiddenFieldPaymentId != null || hiddenFieldPaymentId != undefined) {
  5443. paymentid = Number(hiddenFieldPaymentId.Value);
  5444. }
  5445. }
  5446. var lobid = Number($(".txtAutoComplete_lobid").val());
  5447. if (isNaN(lobid)) {
  5448. lobid = 0;
  5449. }
  5450. var date = "";
  5451. var userDate = $(".date_journaldate").val();
  5452. if (userDate != undefined && userDate != null && userDate != "") {
  5453. var formattedUserDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate(userDate);
  5454. date = moment(formattedUserDate).format("YYYY-MM-DD");
  5455. }
  5456. else {
  5457. var curDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  5458. date = moment(curDate).format("YYYY-MM-DD");
  5459. }
  5460. var duesTotalBal = 0;
  5461. var adjustedTotal = 0;
  5462. instance.isDueLoading = true;
  5463. instance.navigationHelper.showLoading();
  5464. var element = $('.transactonList_item_TRN' + trnId + '');
  5465. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getPendings(Number(contactId), paymentid, null, instance.journalTypeId, lobid, date, "Dues").then(function (response) {
  5466. var totalDue = 0;
  5467. var result = response.result;
  5468. var divDues = element.find('.divDue_List');
  5469. $(divDues).empty();
  5470. $(divDues).html('<div class="list-group-item m-b-n divDue_List_item hidden"></div>');
  5471. if (result.length != 0) {
  5472. for (var i = 0; i < result.length; i++) {
  5473. var item = result[i];
  5474. if (i == 0) {
  5475. $("#hf_DiscountAccountId").val(item.DiscountAccountId);
  5476. $("#hf_PenalityAccountId").val(item.PenalityAccountId);
  5477. $("#hf_TDSAccountId").val(item.TDSAccountId);
  5478. $("#hf_DiscountAccountName").val(item.DiscountAccountName);
  5479. $("#hf_PenalityAccountName").val(item.PenalityAccountName);
  5480. $("#hf_TDSAccountName").val(item.TDSAccountName);
  5481. var accountsObj = {
  5482. DiscountAccountId: item.DiscountAccountId,
  5483. PenalityAccountId: item.PenalityAccountId,
  5484. TDSAccountId: item.TDSAccountId,
  5485. DiscountAccountName: item.DiscountAccountName,
  5486. PenalityAccountName: item.PenalityAccountName,
  5487. TDSAccountName: item.TDSAccountName,
  5488. };
  5489. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().bindAccounts(accountsObj);
  5490. }
  5491. adjustedTotal += item.Amount;
  5492. duesTotalBal += Number(item.JournalAlloc.TotalAmount - item.JournalAlloc.AdjustedAmount);
  5493. function datediff(date2, today) {
  5494. today = new Date(today.split('/')[2], today.split('/')[1] - 1, today.split('/')[0]);
  5495. date2 = new Date(date2.split('/')[2], date2.split('/')[1] - 1, date2.split('/')[0]);
  5496. var timeDiff = Math.abs(today.getTime() - date2.getTime());
  5497. var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
  5498. return diffDays;
  5499. }
  5500. var today = new Date();
  5501. var dd = today.getDate();
  5502. var mm = today.getMonth() + 1;
  5503. var yyyy = today.getFullYear();
  5504. if (dd < 10) {
  5505. dd = '0' + dd;
  5506. }
  5507. if (mm < 10) {
  5508. mm = '0' + mm;
  5509. }
  5510. today = dd + '/' + mm + '/' + yyyy;
  5511. var dBalance = 0;
  5512. var tBalance = 0;
  5513. dBalance = Number(item.JournalAlloc.TotalAmount - item.JournalAlloc.AdjustedAmount);
  5514. instance.damount = dBalance;
  5515. tBalance = Number(item.JournalAlloc.TotalAmount);
  5516. var date = $(".date_journaldate").val().toString();
  5517. var NumOfDays = 0;
  5518. if (paymentid == 0) {
  5519. NumOfDays = datediff(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(item.JournalAlloc.JournalDate, null), date);
  5520. }
  5521. else {
  5522. var PaymentDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_paymentdate").Value;
  5523. NumOfDays = datediff(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(item.JournalAlloc.JournalDate, null), date);
  5524. }
  5525. instance.bindDuesHtml(item, dBalance, NumOfDays, trnId, tBalance);
  5526. }
  5527. }
  5528. if (duesTotalBal > 0)
  5529. element.find('.txtDuesTotalAmt').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(duesTotalBal, 2));
  5530. else
  5531. element.find('.txtDuesTotalAmt').text("0.00");
  5532. if (duesTotalBal > 0) {
  5533. $(".anchor_totalDue").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(duesTotalBal, 2));
  5534. }
  5535. else {
  5536. $(".anchor_totalDue").text("0.00");
  5537. }
  5538. }).then(function () {
  5539. $(".txtTotalDueAdjusted").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(adjustedTotal, 2));
  5540. $(".secDues").removeClass("hidden");
  5541. element.find('.secDues_' + trnId + '').addClass('hidden');
  5542. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5543. instance.isDueLoading = false;
  5544. var isWalletLoading = Bizgaze.Apps.Transact.Controls.Wallet.Instance().isWalletLoading;
  5545. if (instance.isDueLoading == false && isWalletLoading == false) {
  5546. instance.navigationHelper.hideLoading();
  5547. }
  5548. });
  5549. }
  5550. }
  5551. toggleDues(trnId) {
  5552. var instance = this;
  5553. var element = $('.transactonList_item_' + trnId + '');
  5554. element.find('.secDues_' + trnId + '').toggleClass('hidden');
  5555. }
  5556. AutoAdjustDues(trnId) {
  5557. var instance = this;
  5558. var element = $('.transactonList_item_' + trnId + '');
  5559. var btnColor = $(element).find('#btnAutoAdjustDues').attr('class');
  5560. if ($(element).find('#btnAutoAdjustDues').attr("name") == "enabled") {
  5561. }
  5562. else {
  5563. $(element).find('#btnAutoAdjustDues').attr("name", "enabled");
  5564. }
  5565. instance.updatePayment(trnId);
  5566. var totAdj = 0;
  5567. $(element).find('.divDue_Item').each(function () {
  5568. var xyz = Number($(this).find('.txtCurrentAmount').val());
  5569. if (!isNaN(xyz))
  5570. totAdj += xyz;
  5571. });
  5572. $('.txtTotalDueAdjusted').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAdj, 2));
  5573. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5574. }
  5575. clearDues() {
  5576. var instance = this;
  5577. var trnId = "TRN" + instance.transactionId;
  5578. var totalDueAdjAmt = Number($(".totAdjusted").first().text());
  5579. var totalCreditAmt = Number($(".totAmount").first().text());
  5580. if ((totalDueAdjAmt < totalCreditAmt) || (totalDueAdjAmt > totalCreditAmt)) {
  5581. $(".txtTotalDueAdjusted").val(0);
  5582. $(".totAdjusted").text(0.00);
  5583. var elementforPayment = $('.transactonList_item_' + trnId + '');
  5584. $(elementforPayment).find('.divDue_Item').each(function () {
  5585. $(this).find('.txtCurrentAmount').val(0);
  5586. var walletAmt = $(this).find('.hfDueAmount').val();
  5587. $(this).find('.lblDueBalance').val(walletAmt);
  5588. });
  5589. }
  5590. }
  5591. updatePayment(trnId) {
  5592. var instance = this;
  5593. var element = $('.transactonList_item_' + trnId + '');
  5594. var advanceAmt = 0;
  5595. var total = 0;
  5596. var ttWalAdj = Number($('.txtTotalWalletAdjusted').val());
  5597. var totWalAdj = (isNaN(ttWalAdj)) ? 0 : Number($('.txtTotalWalletAdjusted').val());
  5598. var prevamount = Number($("#txt_TotalCreditAmount").val()) + totWalAdj;
  5599. $(".paymentmodelistitem").each(function () {
  5600. if (!($(this).hasClass("hidden"))) {
  5601. var amount = Number($(this).find('.paymentamount').val());
  5602. $(this).find('.amount').text(amount);
  5603. total = Number(prevamount) + Number(amount);
  5604. prevamount = total;
  5605. }
  5606. });
  5607. var paymentTotal = Number(total) == 0 ? prevamount : Number(total);
  5608. $("#hf_TotalCreditAmount").val(paymentTotal);
  5609. $(element).find('.divDue_Item').each(function (index) {
  5610. var amount = Number($("#txt_TotalCreditAmount").val());
  5611. var txtDiscountAmount = Number($(this).find('.txtDiscountAmount').val());
  5612. var txtTdsAmount = Number($(this).find('.txtTdsAmount').val());
  5613. var currentAmount = Number($(this).find('.txtCurrentAmount').val());
  5614. var discamount = Number($(this).find('.hfDiscountAmount').val());
  5615. var tdsamount = Number($(this).find('.hfTdsAmount').val());
  5616. var dueAmount = 0;
  5617. if ((discamount == 0) && (tdsamount == 0)) {
  5618. $('.lblDueBalance').val();
  5619. dueAmount = Number($(this).find('.hfDueAmount').val()) - txtDiscountAmount - txtTdsAmount;
  5620. }
  5621. if ((discamount != 0) && (tdsamount != 0)) {
  5622. dueAmount = (Number($(this).find('.hfDueAmount').val()) + tdsamount + discamount) - txtDiscountAmount - txtTdsAmount;
  5623. }
  5624. if ((discamount != 0) && (tdsamount == 0)) {
  5625. dueAmount = (Number($(this).find('.hfDueAmount').val()) + discamount) - txtDiscountAmount - txtTdsAmount;
  5626. }
  5627. if ((discamount == 0) && (tdsamount != 0)) {
  5628. dueAmount = (Number($(this).find('.hfDueAmount').val()) + tdsamount) - txtDiscountAmount - txtTdsAmount;
  5629. }
  5630. var txtCurrentAmt = 0;
  5631. if (paymentTotal >= dueAmount) {
  5632. if (dueAmount != 0) {
  5633. paymentTotal -= dueAmount;
  5634. txtCurrentAmt = dueAmount;
  5635. dueAmount = 0;
  5636. advanceAmt = paymentTotal;
  5637. }
  5638. }
  5639. else {
  5640. dueAmount -= paymentTotal;
  5641. txtCurrentAmt = paymentTotal;
  5642. paymentTotal = 0;
  5643. }
  5644. if (Number(paymentTotal) < 0.01) {
  5645. paymentTotal = 0;
  5646. }
  5647. $(this).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(txtCurrentAmt, 2));
  5648. $(this).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(dueAmount, 2));
  5649. });
  5650. }
  5651. bindDuesHtml(item, dBalance, NumOfDays, formPropId, tBalance) {
  5652. var instance = this;
  5653. var discAmount = item.DiscountAmount;
  5654. if (item.PaymentTermMode == 2) {
  5655. discAmount = discAmount * -1;
  5656. }
  5657. var tdsAttr = "";
  5658. if (item.TCSAmount > 0) {
  5659. tdsAttr = "disabled";
  5660. }
  5661. var journalAlloc = item.JournalAlloc;
  5662. var Amount = item.Amount;
  5663. var html = '<div class="list-group-item divDue_Item" id="divDue_List_item_' + journalAlloc.JournalId + '"><div class="row">' +
  5664. '<input type="hidden" class="hf_JournalAllocId" value="' + journalAlloc.JournalAllocId + '" />' +
  5665. '<input type="hidden" class="hf_RefAllocId" value="' + journalAlloc.RefAllocId + '" />' +
  5666. '<div class="col-sm-3"><div class="floating-label-form-group m-b floating-label-form-group-with-value" style="border:0px"><span class="h6">' + journalAlloc.JournalNo + ' (' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(tBalance, 2) + ')</span><br/><input class="form-control value-control text-dark" disabled type="text" value="' + Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(journalAlloc.JournalDate, null) + ' (' + NumOfDays + ' days)"></div></div>' +
  5667. '<div class="col-sm-2"><div class="floating-label-form-group m-b floating-label-form-group-with-value" style="border:0px"><span class="h6">Balance</span><input class="hfOrgDueAmount" type="hidden" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(dBalance - discAmount - item.TDSAmount, 2) + '"><input class="hfDueAmount" type="hidden" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(dBalance - discAmount - item.TDSAmount, 2) + '"><input id="lblDueBalance_' + journalAlloc.JournalId + '" class="form-control value-control lblDueBalance text-dark" disabled type="text" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(dBalance - discAmount - Amount - item.TDSAmount, 2) + '" placeholder="Balance" data-label="Balance"></div></div>' +
  5668. '<div class="col-sm-2"><div class="floating-label-form-group m-b floating-label-form-group-with-value"><span class="h6">Discount</span><br /><input class="hfDiscountAmount" type="hidden" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discAmount, 2) + '" /><input class="form-control value-control floating-label-control txtDiscountAmount" type="text" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discAmount, 2) + '" id="txtDiscountAmount_' + journalAlloc.JournalId + '" class="form-control value-control floating-label-control txtCurrentAmount" placeholder="Discount Amount" data-label="Discount Amount" onclick="this.select()" onkeypress="return Bizgaze.Apps.Transact.Controls.Dues.Instance().isSignDecimalplusNoLongPress(event,this.id)" onkeyup="Bizgaze.Apps.Transact.Controls.Dues.Instance().discountValidation(event,this.id,\'' + journalAlloc.JournalId + '\',\'' + "TRN" + formPropId + '\')" /></div></div>' +
  5669. '<div class="col-sm-2"><div class="floating-label-form-group m-b floating-label-form-group-with-value"><span class="h6">TDS</span><br /><input class="hfTdsAmount" type="hidden" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(item.TDSAmount, 2) + '" /><input class="form-control value-control floating-label-control txtTdsAmount" ' + tdsAttr + ' type="text" value="' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(item.TDSAmount, 2) + '" id="txtTdsAmount_' + journalAlloc.JournalId + '" class="form-control value-control floating-label-control" placeholder="TDS Amount" data-label="TDS Amount" onclick="this.select()" oninput="return Bizgaze.Apps.Transact.Controls.Dues.Instance().isDecimalplusNoLongPress(event,this.id)" onkeyup="Bizgaze.Apps.Transact.Controls.Dues.Instance().tdsValidation(event,this.id,\'' + journalAlloc.JournalId + '\',\'' + "TRN" + formPropId + '\')" /></div></div>' +
  5670. '<div class="col-sm-3"><div class="floating-label-form-group m-b"><span class="h6">Adjusted Amount</span><br><input id="txtCurrentAmount_' + journalAlloc.JournalId + '" type="text" data-previousvalue="0" value="' + Amount + '" class="form-control value-control floating-label-control txtCurrentAmount" placeholder="Amount" data-label="Amount" onclick="this.select()" oninput="return Bizgaze.Apps.Transact.Controls.Dues.Instance().isDecimalplusNoLongPress(event,this.id)" onkeyup="Bizgaze.Apps.Transact.Controls.Dues.Instance().AdjustDueAmount(event,\'' + journalAlloc.JournalId + '\',\'' + "TRN" + formPropId + '\');"/></div></div>' +
  5671. '</div></div>';
  5672. var element = $('.transactonList_item_TRN' + formPropId + '');
  5673. element.find('.divDue_List_item').before(html);
  5674. }
  5675. bindDueEvents() {
  5676. }
  5677. tdsValidation(evt, id, jId, trnId) {
  5678. var instance = this;
  5679. instance.flag = 0;
  5680. var val = document.getElementById(id);
  5681. var curDueAmount = Number(val.value);
  5682. var elementforPayment = $('.transactonList_item_' + trnId);
  5683. var element = elementforPayment.find('#divDue_List_item_' + jId);
  5684. var tdsAccountId = Number($("#hf_TDSAccountId").val());
  5685. var totDueAmount = Number($(element).find('.hfDueAmount').val());
  5686. instance.AdjustDueAmount(evt, jId, trnId);
  5687. if (totDueAmount < curDueAmount) {
  5688. $(element).find('.txtTdsAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5689. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("TDSAmount cannot be greater than Due Amount");
  5690. return false;
  5691. }
  5692. var adjustedAmt = $(element).find('.txtCurrentAmount').val();
  5693. if (adjustedAmt != 0) {
  5694. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5695. }
  5696. return true;
  5697. }
  5698. discountValidation(evt, id, jId, trnId) {
  5699. var instance = this;
  5700. instance.flag = 0;
  5701. var val = document.getElementById(id);
  5702. var isNegativeValue = (val.value.match(/-/g) || []).length;
  5703. var curDueAmount = Number(val.value);
  5704. var elementforPayment = $('.transactonList_item_' + trnId);
  5705. var element = elementforPayment.find('#divDue_List_item_' + jId);
  5706. var discountAccountId = Number($("#hf_DiscountAccountId").val());
  5707. var penalityAccountId = Number($("#hf_PenalityAccountId").val());
  5708. var totDueAmount = Number($(element).find('.hfDueAmount').val());
  5709. var isDiscAmount = Math.sign(curDueAmount);
  5710. if (isNaN(isDiscAmount)) {
  5711. $(element).find('.txtDiscountAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5712. return false;
  5713. }
  5714. instance.AdjustDueAmount(evt, jId, trnId);
  5715. if (totDueAmount < curDueAmount) {
  5716. $(element).find('.txtDiscountAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5717. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Discount cannot be greater than Due Amount");
  5718. return false;
  5719. }
  5720. var adjustedAmt = $(element).find('.txtCurrentAmount').val();
  5721. if (adjustedAmt != 0) {
  5722. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5723. }
  5724. return true;
  5725. }
  5726. AdjustDueAmount(event, jId, trnId) {
  5727. var instance = this;
  5728. instance.flag = 0;
  5729. const maxAmt = Number($(event.target).parents('.divDue_Item').find('.hfOrgDueAmount').val());
  5730. const currVal = Number($(event.target).val());
  5731. if (currVal > maxAmt) {
  5732. $(event.target).val(maxAmt);
  5733. }
  5734. var formId = $(".transactonList_div_" + trnId).parents("form").attr("id").split('_')[1];
  5735. var elementforPayment = $('.transactonList_item_' + trnId + '');
  5736. var totDue = 0;
  5737. var totDueAmt = Number(elementforPayment.find('.txtDuesTotalAmt').text());
  5738. $(elementforPayment).find('.divDue_Item').each(function () {
  5739. var xyz = Number($(this).find('.txtCurrentAmount').val());
  5740. if (!isNaN(xyz))
  5741. totDue += xyz;
  5742. });
  5743. var element = elementforPayment.find('#divDue_List_item_' + jId + '');
  5744. var previousValue = $(element).find('.txtCurrentAmount').data("previousvalue");
  5745. var crAmt = totDueAmt;
  5746. var totalAmt = Number($(".totAmount").first().text());
  5747. var OrgdueAmount = Number($(element).find('.hfOrgDueAmount').val());
  5748. var DueAmount = Number($(element).find('.hfDueAmount').val());
  5749. var txtCurrentAmt = $(element).find('.txtCurrentAmount').val();
  5750. var txtDiscountAmt = Number($(element).find('.txtDiscountAmount').val());
  5751. var txtTDSAmt = Number($(element).find('.txtTdsAmount').val());
  5752. var hf_DiscountAmount = Number($(element).find(".hfDiscountAmount").val());
  5753. var hf_TDSAmount = Number($(element).find(".hfTdsAmount").val());
  5754. var lblDueBalance = Number($(element).find(".lblDueBalance").val());
  5755. var totalAmount = OrgdueAmount + hf_DiscountAmount + hf_TDSAmount;
  5756. var txtDueBal = 0;
  5757. if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt != 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5758. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5759. }
  5760. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt != 0 && txtTDSAmt == 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5761. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5762. }
  5763. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5764. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5765. }
  5766. else if ((txtCurrentAmt != 0) && txtDiscountAmt == 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5767. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5768. }
  5769. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt == 0 && txtTDSAmt == 0 && hf_DiscountAmount != 0) {
  5770. txtDueBal = OrgdueAmount + hf_DiscountAmount;
  5771. }
  5772. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt == 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5773. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5774. }
  5775. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && txtTDSAmt != 0 && lblDueBalance != 0) {
  5776. txtDueBal = totalAmount - txtDiscountAmt - txtTDSAmt;
  5777. }
  5778. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && hf_TDSAmount != 0 && lblDueBalance == 0 && totalAmount != txtCurrentAmt && hf_DiscountAmount == 0) {
  5779. txtDueBal = Number(txtCurrentAmt) - txtDiscountAmt;
  5780. }
  5781. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && hf_TDSAmount != 0 && lblDueBalance == 0 && totalAmount != txtCurrentAmt && hf_DiscountAmount != 0 && txtTDSAmt != 0) {
  5782. txtDueBal = totalAmount - txtDiscountAmt - txtTDSAmt;
  5783. }
  5784. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && txtTDSAmt != 0 && lblDueBalance == 0) {
  5785. txtDueBal = OrgdueAmount - txtTDSAmt;
  5786. }
  5787. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt == 0 && txtTDSAmt != 0) {
  5788. txtDueBal = OrgdueAmount + hf_DiscountAmount;
  5789. }
  5790. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt != 0 && txtTDSAmt == 0 && hf_DiscountAmount != 0) {
  5791. txtDueBal = (OrgdueAmount + hf_TDSAmount + hf_DiscountAmount) - txtDiscountAmt;
  5792. }
  5793. else if ((txtCurrentAmt != 0) && txtDiscountAmt == 0 && txtTDSAmt == 0 && lblDueBalance == 0 && hf_DiscountAmount != 0) {
  5794. txtDueBal = OrgdueAmount + hf_DiscountAmount;
  5795. }
  5796. else if ((txtDiscountAmt == 0 && hf_DiscountAmount != 0) && (txtTDSAmt == 0 && hf_TDSAmount != 0) && txtCurrentAmt == 0) {
  5797. txtDueBal = totalAmount;
  5798. }
  5799. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt == 0 && lblDueBalance != 0) {
  5800. txtDueBal = totalAmount - txtDiscountAmt - txtTDSAmt;
  5801. }
  5802. else if (txtCurrentAmt != 0 && txtDiscountAmt == 0 && txtTDSAmt == 0 && lblDueBalance != 0) {
  5803. txtDueBal = totalAmount - txtTDSAmt;
  5804. }
  5805. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt == 0 && lblDueBalance == 0 && txtCurrentAmt == totalAmount) {
  5806. txtDueBal = totalAmount - txtDiscountAmt;
  5807. }
  5808. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt == 0 && lblDueBalance == 0) {
  5809. txtDueBal = OrgdueAmount + hf_DiscountAmount - txtDiscountAmt;
  5810. }
  5811. else if (txtCurrentAmt == lblDueBalance && txtCurrentAmt != "" && txtCurrentAmt != 0) {
  5812. txtDueBal = OrgdueAmount + hf_DiscountAmount + hf_TDSAmount;
  5813. }
  5814. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5815. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5816. }
  5817. else if (txtCurrentAmt == 0 && DueAmount != 0 && OrgdueAmount != 0 && hf_DiscountAmount != 0 && hf_TDSAmount != 0 && txtDiscountAmt != 0 && txtTDSAmt != 0) {
  5818. txtDueBal = OrgdueAmount;
  5819. }
  5820. else if (txtCurrentAmt == 0 && txtDiscountAmt != 0 && hf_TDSAmount != 0 && hf_DiscountAmount == 0 && hf_TDSAmount != 0) {
  5821. txtDueBal = OrgdueAmount - txtDiscountAmt;
  5822. }
  5823. else if (totalAmount == txtCurrentAmt) {
  5824. txtDueBal = totalAmount;
  5825. }
  5826. else {
  5827. txtDueBal = OrgdueAmount;
  5828. }
  5829. if (txtDueBal < 0) {
  5830. txtDueBal = 0;
  5831. }
  5832. $(' #lblDueBalance_' + jId + '').val(txtDueBal);
  5833. if (totDue <= crAmt) {
  5834. if (totDue <= totalAmt) {
  5835. if (totDue <= totDueAmt) {
  5836. if (txtCurrentAmt == 0 || txtCurrentAmt == undefined) {
  5837. $(element).find('.txtCurrentAmount').val(0.00);
  5838. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(txtDueBal, 2));
  5839. var ttWallet = 0;
  5840. $(elementforPayment).find('.divDue_Item').each(function () {
  5841. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5842. if (!isNaN(pqr))
  5843. ttWallet += pqr;
  5844. });
  5845. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5846. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5847. var currentValue = Number($(element).find('.txtCurrentAmount').val());
  5848. $(element).find('.txtCurrentAmount').data("previousvalue", currentValue);
  5849. return false;
  5850. }
  5851. if (Number(txtCurrentAmt) + txtDiscountAmt + txtTDSAmt > OrgdueAmount) {
  5852. var walletAmount_ = 0;
  5853. if ((hf_DiscountAmount != 0 && txtDiscountAmt == 0)) {
  5854. walletAmount_ = Number(hf_DiscountAmount);
  5855. }
  5856. else if ((hf_TDSAmount != 0 && txtTDSAmt == 0)) {
  5857. walletAmount_ = walletAmount_ + Number(hf_TDSAmount);
  5858. }
  5859. if (txtDiscountAmt == 0) {
  5860. $(element).find('.txtDiscountAmount').val(0.00);
  5861. }
  5862. if (txtTDSAmt == 0) {
  5863. $(element).find('.txtTdsAmount').val(0.00);
  5864. }
  5865. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(txtDueBal, 2));
  5866. if (txtCurrentAmt == totalAmount) {
  5867. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5868. }
  5869. else {
  5870. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletAmount_, 2));
  5871. }
  5872. }
  5873. else {
  5874. var walletAmount = txtDueBal - Number(txtCurrentAmt);
  5875. if (walletAmount < 0) {
  5876. walletAmount = 0;
  5877. }
  5878. if (hf_TDSAmount != 0 && txtTDSAmt == 0 && txtDiscountAmt == 0 && hf_DiscountAmount != 0) {
  5879. walletAmount = hf_DiscountAmount + hf_TDSAmount + walletAmount;
  5880. }
  5881. $(element).find('.txtCurrentAmount').val(txtCurrentAmt);
  5882. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletAmount, 2));
  5883. }
  5884. var ttWallet = 0;
  5885. $(elementforPayment).find('.divDue_Item').each(function () {
  5886. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5887. if (!isNaN(pqr))
  5888. ttWallet += pqr;
  5889. });
  5890. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5891. }
  5892. else {
  5893. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(OrgdueAmount - txtDiscountAmt - txtTDSAmt, 2));
  5894. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5895. var ttWallet = 0;
  5896. $(elementforPayment).find('.divDue_List_item').each(function () {
  5897. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5898. if (!isNaN(pqr))
  5899. ttWallet += pqr;
  5900. });
  5901. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5902. }
  5903. }
  5904. else {
  5905. MessageHelper.Instance().showError("You cannot adjust without enough credits", 'div_ErrorMessage_' + formId);
  5906. $(element).find('.txtCurrentAmount').val(previousValue);
  5907. }
  5908. }
  5909. else {
  5910. var ttWallet = 0;
  5911. $(elementforPayment).find('.divDue_Item').each(function () {
  5912. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5913. if (!isNaN(pqr))
  5914. ttWallet += pqr;
  5915. });
  5916. var newAmt = Number(crAmt) - (Number(ttWallet) - Number(txtCurrentAmt));
  5917. var OldCurAdjAmt = Number($(element).find('.txtCurrentAmount').val());
  5918. if (newAmt >= 0) {
  5919. if (newAmt >= Number($(element).find('.hfDueAmount').val())) {
  5920. var curAdjAmt = ttWallet - OldCurAdjAmt;
  5921. var newAdjAmt = txtDueBal;
  5922. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(newAdjAmt, 2));
  5923. $(element).find('.lblDueBalance').val(0.00);
  5924. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(curAdjAmt + newAdjAmt, 2));
  5925. }
  5926. else {
  5927. var curAdjAmt = ttWallet - OldCurAdjAmt;
  5928. var newAdjAmt = OrgdueAmount - newAmt;
  5929. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(newAmt, 2));
  5930. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(newAdjAmt, 2));
  5931. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(curAdjAmt + newAdjAmt, 2));
  5932. }
  5933. }
  5934. else {
  5935. $(element).find('.txtCurrentAmount').val(0);
  5936. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(element).find('.hfWalletAmount').val()), 2));
  5937. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5938. }
  5939. }
  5940. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5941. var currentValue = Number($(element).find('.txtCurrentAmount').val());
  5942. $(element).find('.txtCurrentAmount').data("previousvalue", currentValue);
  5943. }
  5944. isDecimalplusNoLongPress(evt, id) {
  5945. let value = $('#' + id).val();
  5946. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5947. if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode == 46) {
  5948. return false;
  5949. }
  5950. if (value) {
  5951. if (value.split('.').length >= 2) {
  5952. if (value.split('.')[1]) {
  5953. if (value.split('.')[1].length >= 2) {
  5954. let valNew = parseFloat(`${value}`).toFixed(2);
  5955. $('#' + id).val(valNew);
  5956. }
  5957. }
  5958. }
  5959. }
  5960. return true;
  5961. }
  5962. isSignDecimalplusNoLongPress(evt, id) {
  5963. var instance = this;
  5964. instance.flag++;
  5965. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5966. if (instance.flag <= 4) {
  5967. if (charCode == 46) {
  5968. var val = document.getElementById(id);
  5969. var txt = val.value;
  5970. if (!(txt.indexOf(".") > -1)) {
  5971. return true;
  5972. }
  5973. }
  5974. if (charCode == 45) {
  5975. return true;
  5976. }
  5977. if (charCode > 31 && (charCode < 48 || charCode > 57))
  5978. return false;
  5979. }
  5980. else {
  5981. return false;
  5982. }
  5983. return true;
  5984. }
  5985. initFlag() {
  5986. var instance = this;
  5987. instance.flag = 0;
  5988. }
  5989. loadControlSettings(controlsettingjson, formpropertyid) {
  5990. return ``;
  5991. }
  5992. loadPropertySettings(propertysettings, formpropertyid) {
  5993. if (propertysettings != null) {
  5994. for (var i = 0; i < propertysettings.length; i++) {
  5995. var data = propertysettings[i];
  5996. if (data.ControlPropertyName == "ControlType" && data.ControlPropertyValue != "") {
  5997. $("#hdn_" + formpropertyid).attr("ControlType", data.ControlPropertyValue);
  5998. $("#hdn_" + formpropertyid).val(data.ControlPropertyValue);
  5999. }
  6000. }
  6001. }
  6002. }
  6003. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  6004. return ``;
  6005. }
  6006. dueControlObj(trnId) {
  6007. var walletamount = Number($('.txtTotalWalletAdjusted').val());
  6008. var dueamount = Number($('.txtTotalDueAdjusted ').val());
  6009. if (walletamount > 0 && dueamount == 0) {
  6010. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Error! Wallet amount is not adjusted against Dues. Remove the excess amount from wallets & save!");
  6011. return false;
  6012. }
  6013. var instance = this;
  6014. var element = $('.transactonList_item_' + trnId + '');
  6015. var data = new Array();
  6016. element.find('.divDue_Item').each(function (index) {
  6017. var balanceAmount = Number($(this).find('.lblDueBalance').val());
  6018. var isDueObj = false;
  6019. if ($(this).find('.txtCurrentAmount').val() != 0 && $(this).find('.txtCurrentAmount').val() != '' && $(this).find('.txtCurrentAmount').val() != undefined) {
  6020. isDueObj = true;
  6021. }
  6022. else if (!isNaN(balanceAmount) && balanceAmount == 0) {
  6023. isDueObj = true;
  6024. }
  6025. if (isDueObj) {
  6026. var jAId = Number($(this).find('.hf_JournalAllocId').val());
  6027. var journalTypeId = 2;
  6028. var discountAmount = Number($(this).find('.txtDiscountAmount').val());
  6029. var tdsAmount = Number($(this).find('.txtTdsAmount').val());
  6030. if (instance.journalTypeId == 1) {
  6031. data.push({
  6032. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  6033. Credit: Number($(this).find('.txtCurrentAmount').val()),
  6034. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  6035. AllocType: 2,
  6036. AllocTypeId: 2,
  6037. Discount: discountAmount,
  6038. TDSAmount: tdsAmount,
  6039. });
  6040. }
  6041. else if (journalTypeId == 2) {
  6042. data.push({
  6043. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  6044. Debit: Number($(this).find('.txtCurrentAmount').val()),
  6045. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  6046. AllocType: 2,
  6047. AllocTypeId: 2,
  6048. Discount: discountAmount,
  6049. TDSAmount: tdsAmount,
  6050. });
  6051. }
  6052. }
  6053. });
  6054. return data;
  6055. }
  6056. static Instance() {
  6057. if (this.instance === undefined) {
  6058. this.instance = new Dues();
  6059. }
  6060. return this.instance;
  6061. }
  6062. }
  6063. Controls.Dues = Dues;
  6064. })(Controls = Transact.Controls || (Transact.Controls = {}));
  6065. })(Transact = Apps.Transact || (Apps.Transact = {}));
  6066. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  6067. })(Bizgaze || (Bizgaze = {}));
  6068. var Bizgaze;
  6069. (function (Bizgaze) {
  6070. let Apps;
  6071. (function (Apps) {
  6072. let Transact;
  6073. (function (Transact) {
  6074. let Controls;
  6075. (function (Controls) {
  6076. class PaymentSummary extends Unibase.Platform.Core.BaseComponent {
  6077. init(formpropertyid, prop, callback) {
  6078. var instance = this;
  6079. }
  6080. loadControl(containerid, prop) {
  6081. var instance = this;
  6082. var containerhtml = `<div id="paymentSummaryContainer"></div>`;
  6083. $("#" + containerid).html(containerhtml);
  6084. instance.loadPaymentSummaryControl("paymentSummaryContainer");
  6085. }
  6086. loadPaymentSummaryControl(containerid) {
  6087. var instance = this;
  6088. var html = '<div class="row clearfix">' +
  6089. '<div class="col-md-4 ">' +
  6090. '<div class="header row form-group col-sm-12"><div id="paymentmodesummary" class="col-6"><strong class="row">Mode</strong></div><div id="paymentmodeamountsummary" class="col-6"><strong class="row">Amount</strong></div></div>' +
  6091. '<div class="row col-sm-12 form-group paymentsummaryItem hidden" id="div_wallet_summary"><div class="col-sm-6 col-6"><span>Wallets</span></div><div class="col-sm-6 col-6"><strong><span id="spn_wallet_amount"></span></strong></div></div>' +
  6092. '<div class="row col-sm-12 form-group paymentsummaryItem hidden" id="div_coupon_summary"><div class="col-sm-6 col-6"><span>Coupons</span></div><div class="col-sm-6 col-6"><strong><span id="spn_coupon_amount"></span></strong></div></div>' +
  6093. '</div>' +
  6094. '<div class="col-md-3">' +
  6095. '<div id="div_Discount" class="hidden col-sm-12 form-group floating-label-form-group floating-label-form-group-with-value border-0 pb-10">' +
  6096. '<label for="lbl" id="lbl_Discount">Discount Account<span class="text-danger" id="spnlbl_Discount"> *</span></label>' +
  6097. '<div class="input-group"><select id="txtAutoComplete_DiscountAccount" class="txtAutoComplete_DiscountAccount hidden form-control text-control select2-hidden-accessible" style="width:100%;" placeholder="Select Discount Account"></select><input type="hidden" id="hfAutoComplete_DiscountAccount" value="" class="hfAutoComplete_DiscountAccount form-control"/></div>' +
  6098. '</div>' +
  6099. '<div id="div_Penality" class="hidden col-sm-12 form-group floating-label-form-group floating-label-form-group-with-value border-0 pb-10">' +
  6100. '<label for="lbl" id="lbl_Penality">Penality Account<span class="text-danger" id="spnlbl_Penality"> *</span></label>' +
  6101. '<div class="input-group"><select id="txtAutoComplete_PenalityAccount" class="txtAutoComplete_PenalityAccount hidden form-control text-control select2-hidden-accessible" style="width:100%;" placeholder="Select Penality Account"></select><input type="hidden" id="hfAutoComplete_PenalityAccount" value="" class="hfAutoComplete_PenalityAccount form-control"/></div>' +
  6102. '</div>' +
  6103. '<div id="div_TDS" class="hidden col-sm-12 form-group floating-label-form-group floating-label-form-group-with-value border-0 pb-10">' +
  6104. '<label for="lbl" id="lbl_TDS">TDS Account<span class="text-danger" id="spnlbl_TDS"> *</span></label>' +
  6105. '<div class="input-group"><select id="txtAutoComplete_TDSAccount" class="txtAutoComplete_TDSAccount hidden form-control text-control select2-hidden-accessible" style="width:100%;" placeholder="Select TDS Account"></select><input type="hidden" id="hfAutoComplete_TDSAccount" value="" class="hfAutoComplete_TDSAccount form-control"/></div>' +
  6106. '</div>' +
  6107. '</div>' +
  6108. '<div class="col-md-5 no-padder text-right d-none d-md-block" id="divTotalAmount">' +
  6109. '<input type="hidden" class="totBalance" id="totBalance"></input>' +
  6110. '<div class="row col-sm-12 form-group">' +
  6111. '<div class="col-sm-6 text-right">' +
  6112. '<span>Total Amount</span>' +
  6113. '</div>' +
  6114. '<div class="col-md-6 text-right">' +
  6115. '<strong>' +
  6116. '<span class="totAmount" id="totAmount">0.00</span>' +
  6117. ' </strong>' +
  6118. '</div>' +
  6119. '</div>' +
  6120. '<div class="row col-sm-12 form-group summary" id="divDiscountAmount">' +
  6121. '<div class="col-md-6 text-right">' +
  6122. '<span>Discount</span>' +
  6123. '</div>' +
  6124. '<div class="col-md-6 text-right ">' +
  6125. '<strong>' +
  6126. '<span class="totDiscount" id="totDiscount">0.00</span>' +
  6127. '</strong>' +
  6128. ' </div>' +
  6129. '</div>' +
  6130. '<div class="row col-sm-12 form-group summary" id="divPenalityAmount">' +
  6131. '<div class="col-md-6 text-right">' +
  6132. '<span>Penality</span>' +
  6133. '</div>' +
  6134. '<div class="col-md-6 text-right ">' +
  6135. '<strong>' +
  6136. '<span class="totPenality" id="totPenality">0.00</span>' +
  6137. '</strong>' +
  6138. ' </div>' +
  6139. '</div>' +
  6140. '<div class="row col-sm-12 form-group summary" id="divAdjustedAmount">' +
  6141. '<div class="col-sm-6 text-right">' +
  6142. '<span>Adjusted</span>' +
  6143. '</div>' +
  6144. '<div class="col-sm-6 text-right">' +
  6145. '<strong>' +
  6146. '<span class="totAdjusted" id="totAdjusted">0.00</span>' +
  6147. '</strong>' +
  6148. '</div>' +
  6149. '</div>' +
  6150. '<div class="row col-sm-12 form-group summary" id="divAdvanceAmount">' +
  6151. '<div class="col-sm-6 text-right">' +
  6152. '<span>Advance</span>' +
  6153. '</div>' +
  6154. '<div class="col-sm-6 text-right">' +
  6155. '<strong>' +
  6156. '<span class="totAdvance" id="totAdvance">0.00</span>' +
  6157. '</strong>' +
  6158. '</div>' +
  6159. '</div>' +
  6160. '<div class="row col-sm-12" id="divTdsAmount">' +
  6161. '<div class="col-md-6 text-right">' +
  6162. '<span>TDS</span>' +
  6163. '</div>' +
  6164. '<div class="col-md-6 text-right">' +
  6165. '<strong>' +
  6166. '<span class="totTds" id="totTds">0.00</span>' +
  6167. '</strong>' +
  6168. '</div>' +
  6169. '</div>' +
  6170. '</div>' +
  6171. '<div class="col-sm-12 no-padder d-md-none border-top border-dark " id="divTotalAmount">' +
  6172. '<input type="hidden" class="totBalance" id="totBalance"></input>' +
  6173. '<div class="row col-sm-12 form-group pt-10">' +
  6174. '<div class="col-6 text-left">' +
  6175. '<span>Total Amount</span>' +
  6176. '</div>' +
  6177. '<div class="col-6 text-left">' +
  6178. '<strong>' +
  6179. '<span class="totAmount" id="totAmount">0.00</span>' +
  6180. ' </strong>' +
  6181. '</div>' +
  6182. '</div>' +
  6183. '<div class="row col-sm-12 form-group summary" id="divDiscountAmount">' +
  6184. '<div class="col-6 ">' +
  6185. '<span>Discount</span>' +
  6186. '</div>' +
  6187. '<div class="col-6 ">' +
  6188. '<strong>' +
  6189. '<span class="totDiscount" id="totDiscount">0.00</span>' +
  6190. '</strong>' +
  6191. ' </div>' +
  6192. '</div>' +
  6193. '<div class="row col-sm-12 form-group summary" id="divPenalityAmount">' +
  6194. '<div class="col-6 ">' +
  6195. '<span>Penality</span>' +
  6196. '</div>' +
  6197. '<div class="col-6 ">' +
  6198. '<strong>' +
  6199. '<span class="totPenality" id="totPenality">0.00</span>' +
  6200. '</strong>' +
  6201. ' </div>' +
  6202. '</div>' +
  6203. '<div class="row col-sm-12 form-group summary" id="divAdjustedAmount">' +
  6204. '<div class="col-6 ">' +
  6205. '<span>Adjusted.</span>' +
  6206. '</div>' +
  6207. '<div class="col-6 ">' +
  6208. '<strong>' +
  6209. '<span class="totAdjusted" id="totAdjusted">0.00</span>' +
  6210. '</strong>' +
  6211. '</div>' +
  6212. '</div>' +
  6213. '<div class="row col-sm-12 form-group summary" id="divAdvanceAmount">' +
  6214. '<div class="col-6">' +
  6215. '<span>Advance</span>' +
  6216. '</div>' +
  6217. '<div class="col-6">' +
  6218. '<strong>' +
  6219. '<span class="totAdvance" id="totAdvance">0.00</span>' +
  6220. '</strong>' +
  6221. '</div>' +
  6222. '</div>' +
  6223. '<div class="row col-sm-12" id="divTdsAmount">' +
  6224. '<div class="col-6">' +
  6225. '<span>TDS</span>' +
  6226. '</div>' +
  6227. '<div class="col-6">' +
  6228. '<strong>' +
  6229. '<span class="totTds" id="totTds">0.00</span>' +
  6230. '</strong>' +
  6231. '</div>' +
  6232. '</div>' +
  6233. '</div>' +
  6234. '</div>';
  6235. $("#" + containerid).html(html);
  6236. instance.loadAccounts();
  6237. }
  6238. loadPaymentSummary() {
  6239. var instance = this;
  6240. var dueFormPropertyId = $("#dueControlList").parents(".divCustomProperties").data("formpropertyid");
  6241. var totAdjAmount = 0;
  6242. var totTds = 0;
  6243. var totDiscount = 0;
  6244. var totPenality = 0;
  6245. var elementforDue = $('.transactonList_item_TRN' + dueFormPropertyId + '');
  6246. $(elementforDue).find('.divDue_Item').each(function () {
  6247. var curAdjAmt = Number($(this).find('.txtCurrentAmount').val());
  6248. if (!isNaN(curAdjAmt) && curAdjAmt != 0) {
  6249. totAdjAmount += curAdjAmt;
  6250. var curDiscAmt = Number($(this).find(".txtDiscountAmount").val());
  6251. if (!isNaN(curDiscAmt) && curDiscAmt != 0) {
  6252. if (curDiscAmt > 0) {
  6253. totDiscount += curDiscAmt;
  6254. }
  6255. else {
  6256. totPenality += curDiscAmt;
  6257. }
  6258. }
  6259. var curTds = Number($(this).find(".txtTdsAmount").val());
  6260. if (!isNaN(curTds) && curTds != 0) {
  6261. totTds += curTds;
  6262. }
  6263. }
  6264. });
  6265. $('.txtTotalDueAdjusted').val(totAdjAmount);
  6266. var ttCreditAmt = 0;
  6267. if ($("#paymentslist li").length > 1) {
  6268. var amt = 0;
  6269. $("#paymentslist li").each(function (e) {
  6270. var curAmt = Number($(this).find(".spn_payment_amount").text());
  6271. if (!isNaN(curAmt)) {
  6272. amt += curAmt;
  6273. }
  6274. });
  6275. ttCreditAmt = amt;
  6276. }
  6277. else {
  6278. var amt = Number($("#txt_TotalCreditAmount").val());
  6279. if (!isNaN(amt)) {
  6280. ttCreditAmt = amt;
  6281. }
  6282. }
  6283. var walletFormPropertyId = $("#walletControlList").parents(".divCustomProperties").data("formpropertyid");
  6284. var elementforPayment = $('.transactonList_item_TRN' + walletFormPropertyId);
  6285. var totWalletAdjusted = Number($(elementforPayment).find('.txtTotalWalletAdjusted_TRN' + walletFormPropertyId).val());
  6286. if (!isNaN(totWalletAdjusted)) {
  6287. ttCreditAmt += totWalletAdjusted;
  6288. }
  6289. $("#hf_TotalCreditAmount").val(ttCreditAmt);
  6290. var advanceAmt = Number($("#hf_TotalCreditAmount").val()) - Number($('.txtTotalDueAdjusted').val());
  6291. var advAmt = (advanceAmt > 0) ? advanceAmt : 0;
  6292. $('.totAdvance').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(advAmt, 2));
  6293. var totAdjusted = Number($('.txtTotalDueAdjusted').val());
  6294. $('.totAdjusted').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAdjusted, 2));
  6295. var totAmountCredited = Number($("#hf_TotalCreditAmount").val());
  6296. $('.totAmount').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAmountCredited, 2));
  6297. $('.totDiscount').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totDiscount, 2));
  6298. $('.totPenality').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totPenality, 2));
  6299. $('.totTds').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totTds, 2));
  6300. instance.showOrHideAccounts(totDiscount, totPenality, totTds);
  6301. }
  6302. updatePaymentSummary() {
  6303. var instance = this;
  6304. var cashAmt = 0;
  6305. var chequeAmt = 0;
  6306. var onlineAmt = 0;
  6307. var neftAmt = 0;
  6308. var rtgs = 0;
  6309. var fundTransfer = 0;
  6310. var adjustment = 0;
  6311. var upiAmt = 0;
  6312. var cardAmt = 0;
  6313. var totalAmount = 0;
  6314. var hasAdjustment = false;
  6315. $("#paymentslist li").each(function () {
  6316. var curPaymentMode = Number($(this).find("#hf_PaymentModeId").val());
  6317. var curAmt = Number($(this).find(".spn_payment_amount").text());
  6318. var flag = 1;
  6319. if (!isNaN(curPaymentMode) && !isNaN(curAmt)) {
  6320. flag = 1;
  6321. }
  6322. else {
  6323. flag = 0;
  6324. var ddlPaymentModeId = $("#txtAutoComplete_paymentmodeid").val();
  6325. if (ddlPaymentModeId != null && ddlPaymentModeId != 0 && ddlPaymentModeId != undefined && ddlPaymentModeId != "0") {
  6326. flag = 1;
  6327. curPaymentMode = Number($("#txtAutoComplete_paymentmodeid").val());
  6328. curAmt = Number($("#txt_TotalCreditAmount").val());
  6329. }
  6330. }
  6331. if (flag == 1) {
  6332. totalAmount += curAmt;
  6333. if (curPaymentMode == 1) {
  6334. cashAmt += curAmt;
  6335. }
  6336. else if (curPaymentMode == 2) {
  6337. chequeAmt += curAmt;
  6338. }
  6339. else if (curPaymentMode == 3) {
  6340. onlineAmt += curAmt;
  6341. }
  6342. else if (curPaymentMode == 4) {
  6343. neftAmt += curAmt;
  6344. }
  6345. else if (curPaymentMode == 5) {
  6346. rtgs += curAmt;
  6347. }
  6348. else if (curPaymentMode == 6) {
  6349. fundTransfer += curAmt;
  6350. }
  6351. else if (curPaymentMode == 7) {
  6352. hasAdjustment = true;
  6353. adjustment += curAmt;
  6354. }
  6355. else if (curPaymentMode == 8) {
  6356. upiAmt += curAmt;
  6357. }
  6358. else if (curPaymentMode == 9) {
  6359. cardAmt += curAmt;
  6360. }
  6361. }
  6362. });
  6363. $('.paymentmodes').remove();
  6364. if (cashAmt > 0) {
  6365. $("#paymentmodesummary").append("<span class='row paymentmodes'>Cash</span>");
  6366. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(cashAmt, 2) + "</span>");
  6367. }
  6368. if (chequeAmt > 0) {
  6369. $("#paymentmodesummary").append("<span class='row paymentmodes'>Cheque</span>");
  6370. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(chequeAmt, 2) + "</span>");
  6371. }
  6372. if (onlineAmt > 0) {
  6373. $("#paymentmodesummary").append("<span class='row paymentmodes'>Online</span>");
  6374. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(onlineAmt, 2) + "</span>");
  6375. }
  6376. if (neftAmt > 0) {
  6377. $("#paymentmodesummary").append("<span class='row paymentmodes'>NEFT</span>");
  6378. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(neftAmt, 2) + "</span>");
  6379. }
  6380. if (rtgs > 0) {
  6381. $("#paymentmodesummary").append("<span class='row paymentmodes'>RTGS</span>");
  6382. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rtgs, 2) + "</span>");
  6383. }
  6384. if (fundTransfer > 0) {
  6385. $("#paymentmodesummary").append("<span class='row paymentmodes'>FundTransfer</span>");
  6386. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(fundTransfer, 2) + "</span>");
  6387. }
  6388. if (adjustment > 0 || hasAdjustment) {
  6389. $("#paymentmodesummary").append("<span class='row paymentmodes'>Adjustment</span>");
  6390. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(adjustment, 2) + "</span>");
  6391. }
  6392. if (upiAmt > 0) {
  6393. $("#paymentmodesummary").append("<span class='row paymentmodes'>UPI</span>");
  6394. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(upiAmt, 2) + "</span>");
  6395. }
  6396. if (cardAmt > 0) {
  6397. $("#paymentmodesummary").append("<span class='row paymentmodes'>Card</span>");
  6398. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(cardAmt, 2) + "</span>");
  6399. }
  6400. instance.updatePaymentSummaryTotal();
  6401. }
  6402. updatePaymentSummaryTotal() {
  6403. var instance = this;
  6404. var amt = 0;
  6405. var totalCreditAmt = Number($("#txt_TotalCreditAmount").val());
  6406. if (!isNaN(totalCreditAmt)) {
  6407. amt = totalCreditAmt;
  6408. }
  6409. $("#paymentslist li").each(function (e) {
  6410. var curAmt = Number($(this).find(".spn_payment_amount").text());
  6411. if (!isNaN(curAmt)) {
  6412. amt += curAmt;
  6413. }
  6414. });
  6415. var discAmt = 0;
  6416. var tdsAmt = 0;
  6417. var penalityAmt = 0;
  6418. $("#dueControl_transactonListDiv .divDue_Item").each(function (e) {
  6419. var curAdjAmt = Number($(this).find(".txtCurrentAmount").val());
  6420. if (!isNaN(curAdjAmt) && curAdjAmt != 0) {
  6421. var curDiscAmt = Number($(this).find(".txtDiscountAmount").val());
  6422. if (!isNaN(curDiscAmt)) {
  6423. if (curDiscAmt > 0) {
  6424. discAmt += curDiscAmt;
  6425. }
  6426. else {
  6427. penalityAmt += curDiscAmt;
  6428. }
  6429. }
  6430. }
  6431. });
  6432. $("#dueControl_transactonListDiv .divDue_Item").each(function (e) {
  6433. var curAdjAmt = Number($(this).find(".txtCurrentAmount").val());
  6434. if (!isNaN(curAdjAmt) && curAdjAmt != 0) {
  6435. var curTdsAmt = Number($(this).find(".txtTdsAmount").val());
  6436. if (!isNaN(curTdsAmt)) {
  6437. tdsAmt += curTdsAmt;
  6438. }
  6439. }
  6440. });
  6441. var walletAmt = Number($(".txtTotalWalletAdjusted").val());
  6442. if (!isNaN(walletAmt)) {
  6443. amt += walletAmt;
  6444. }
  6445. var totAdj = Number($(".txtTotalDueAdjusted").val());
  6446. if (totAdj != null && totAdj != undefined && !isNaN(totAdj)) {
  6447. $(".totAdjusted").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAdj, 2));
  6448. }
  6449. else {
  6450. totAdj = 0;
  6451. }
  6452. if (amt != null && amt != undefined && !isNaN(amt)) {
  6453. $("#hf_TotalCreditAmount").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(amt, 2));
  6454. $(".totAmount").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(amt, 2));
  6455. }
  6456. else {
  6457. amt = 0;
  6458. }
  6459. var advanceAmt = amt - totAdj;
  6460. var advAmt = (advanceAmt > 0) ? advanceAmt : 0;
  6461. $('.totAdvance').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(advAmt, 2));
  6462. var totDiscountAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discAmt, 2);
  6463. $('.totDiscount').text(totDiscountAmount);
  6464. var totPenalityAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(penalityAmt, 2);
  6465. $('.totPenality').text(totPenalityAmount);
  6466. var totTDSAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(tdsAmt, 2);
  6467. $('.totTds').text(totTDSAmount);
  6468. instance.showOrHideAccounts(discAmt, penalityAmt, tdsAmt);
  6469. }
  6470. loadAccounts() {
  6471. var instance = this;
  6472. var discount = 'Discount Account';
  6473. var paymentTypeId = Number($(".hdn_paymenttypeid").val());
  6474. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
  6475. var url1 = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/receiptledgerautocomplete/discount/' + discount + '/paymenttypeid/' + paymentTypeId;
  6476. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_DiscountAccount", "#hfAutoComplete_DiscountAccount", url1, function (response) {
  6477. });
  6478. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_PenalityAccount", "#hfAutoComplete_PenalityAccount", url, null);
  6479. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_TDSAccount", "#hfAutoComplete_TDSAccount", url, null);
  6480. $("#txtAutoComplete_DiscountAccount").on('select2:select', function (e) {
  6481. instance.accountsOnChange(Transact.Enums.PaymentDiscountType.Discount);
  6482. });
  6483. $("#txtAutoComplete_PenalityAccount").on('select2:select', function (e) {
  6484. instance.accountsOnChange(Transact.Enums.PaymentDiscountType.Penalty);
  6485. });
  6486. $("#txtAutoComplete_TDSAccount").on('select2:select', function (e) {
  6487. instance.accountsOnChange(Transact.Enums.PaymentDiscountType.TDS);
  6488. });
  6489. }
  6490. accountsOnChange(accountType) {
  6491. var instance = this;
  6492. var accountId = 0;
  6493. var accountName = "";
  6494. var controlId = "";
  6495. var hiddenFieldControlId = "";
  6496. if (accountType == Transact.Enums.PaymentDiscountType.Discount) {
  6497. accountId = Number($("#txtAutoComplete_DiscountAccount").val());
  6498. accountName = $("#txtAutoComplete_DiscountAccount").text();
  6499. controlId = "#txtAutoComplete_DiscountAccount";
  6500. hiddenFieldControlId = "#hfAutoComplete_DiscountAccount";
  6501. }
  6502. else if (accountType == Transact.Enums.PaymentDiscountType.Penalty) {
  6503. accountId = Number($("#txtAutoComplete_PenalityAccount").val());
  6504. accountName = $("#txtAutoComplete_PenalityAccount").text();
  6505. controlId = "#txtAutoComplete_PenalityAccount";
  6506. hiddenFieldControlId = "#hfAutoComplete_PenalityAccount";
  6507. }
  6508. else if (accountType == Transact.Enums.PaymentDiscountType.TDS) {
  6509. accountId = Number($("#txtAutoComplete_TDSAccount").val());
  6510. accountName = $("#txtAutoComplete_TDSAccount").text();
  6511. controlId = "#txtAutoComplete_TDSAccount";
  6512. hiddenFieldControlId = "#hfAutoComplete_TDSAccount";
  6513. }
  6514. if (accountId == 0)
  6515. accountName = "Select Account";
  6516. if (accountId == 1 || accountId == -1)
  6517. accountName = "Create New";
  6518. if (accountName == "Create New") {
  6519. $("#txtAutoComplete_DiscountAccount").val(null).trigger("change");
  6520. $("#txtAutoComplete_PenalityAccount").val(null).trigger("change");
  6521. $("#txtAutoComplete_TDSAccount").val(null).trigger("change");
  6522. var FormUniqueId = "Bizgaze_Extension_Transact_Ledgers_App_Ledgers_CreateForm";
  6523. var AppConfigurationUnique = "Bizgaze_Extension_Transact_Ledgers_AppConfiguration_CreateLedgers";
  6524. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
  6525. var obj = {
  6526. controlid: controlId,
  6527. hiddenid: hiddenFieldControlId
  6528. };
  6529. var successobj = {
  6530. CallBack: function (id, obj) {
  6531. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLedgerById(id).then(function (response) {
  6532. var createdLedger = new Option(response.result.LedgerName, response.result.LedgerId, true);
  6533. $(obj.controlid + " option").remove();
  6534. $(obj.controlid).append(createdLedger).trigger('change');
  6535. $(obj.hiddenid).val(response.result.LedgerId);
  6536. $(obj.controlid).parents(".transactonList_item").find('.hf_AccountId').val(response.result.LedgerId);
  6537. });
  6538. },
  6539. Parameters: obj,
  6540. };
  6541. var formviewerObj = {
  6542. FormId: response.result.FormId,
  6543. AppConfigurationId: 0,
  6544. Pk_Value: 0,
  6545. PortletWidgetId: 0,
  6546. OnSuccess: successobj,
  6547. OnFail: null,
  6548. OnLoad: null,
  6549. };
  6550. instance.fileCacheHelper.loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  6551. Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
  6552. });
  6553. });
  6554. }
  6555. }
  6556. bindAccounts(accountsObj) {
  6557. if (accountsObj.DiscountAccountName != null && accountsObj.DiscountAccountName != "" && accountsObj.DiscountAccountName != undefined) {
  6558. var selectedDiscountAcc = new Option(accountsObj.DiscountAccountName, accountsObj.DiscountAccountId, true);
  6559. $("#txtAutoComplete_DiscountAccount").append(selectedDiscountAcc);
  6560. }
  6561. if (accountsObj.PenalityAccountName != null && accountsObj.PenalityAccountName != "" && accountsObj.PenalityAccountName != undefined) {
  6562. var selectedPenalityAcc = new Option(accountsObj.PenalityAccountName, accountsObj.PenalityAccountId, true);
  6563. $("#txtAutoComplete_PenalityAccount").append(selectedPenalityAcc);
  6564. }
  6565. if (accountsObj.TDSAccountName != null && accountsObj.TDSAccountName != "" && accountsObj.TDSAccountName != undefined) {
  6566. var selectedTDSAcc = new Option(accountsObj.TDSAccountName, accountsObj.TDSAccountId, true);
  6567. $("#txtAutoComplete_TDSAccount").append(selectedTDSAcc);
  6568. }
  6569. }
  6570. showOrHideAccounts(discount, penality, tds) {
  6571. if (discount == 0) {
  6572. $("#div_Discount").addClass("hidden");
  6573. $("#txtAutoComplete_DiscountAccount").removeClass("required");
  6574. }
  6575. else {
  6576. $("#div_Discount").removeClass("hidden");
  6577. $("#txtAutoComplete_DiscountAccount").addClass("required");
  6578. }
  6579. if (penality == 0) {
  6580. $("#div_Penality").addClass("hidden");
  6581. $("#txtAutoComplete_PenalityAccount").removeClass("required");
  6582. }
  6583. else {
  6584. $("#div_Penality").removeClass("hidden");
  6585. $("#txtAutoComplete_PenalityAccount").addClass("required");
  6586. }
  6587. if (tds == 0) {
  6588. $("#div_TDS").addClass("hidden");
  6589. $("#txtAutoComplete_TDSAccount").removeClass("required");
  6590. }
  6591. else {
  6592. $("#div_TDS").removeClass("hidden");
  6593. $("#txtAutoComplete_TDSAccount").addClass("required");
  6594. }
  6595. }
  6596. getPaymentByRemoteId(remoteId, netTotal) {
  6597. var sum = 0;
  6598. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/payments/paymentmanager.js", function () {
  6599. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getPaymentByRemoteId(remoteId).then(function (response) {
  6600. var response = response.result;
  6601. if (response != null) {
  6602. for (var i = 0; i < response.length; i++) {
  6603. var data = response[i];
  6604. var totalAmount = data.paymentamount;
  6605. sum = sum + totalAmount;
  6606. }
  6607. var orderAmount = netTotal - sum;
  6608. if (orderAmount > 0) {
  6609. $("#txt_TotalCreditAmount").parent().addClass("floating-label-form-group-with-value");
  6610. $("#txt_TotalCreditAmount").val(orderAmount);
  6611. }
  6612. else {
  6613. $("#txt_TotalCreditAmount").parent().addClass("floating-label-form-group-with-value");
  6614. $("#txt_TotalCreditAmount").val(0);
  6615. }
  6616. }
  6617. else {
  6618. $("#txt_TotalCreditAmount").val(netTotal);
  6619. }
  6620. });
  6621. });
  6622. }
  6623. loadControlSettings(controlsettingjson, formpropertyid) {
  6624. return ``;
  6625. }
  6626. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  6627. return ``;
  6628. }
  6629. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  6630. return ``;
  6631. }
  6632. static Instance() {
  6633. if (this.instance === undefined) {
  6634. this.instance = new PaymentSummary();
  6635. }
  6636. return this.instance;
  6637. }
  6638. }
  6639. Controls.PaymentSummary = PaymentSummary;
  6640. })(Controls = Transact.Controls || (Transact.Controls = {}));
  6641. })(Transact = Apps.Transact || (Apps.Transact = {}));
  6642. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  6643. })(Bizgaze || (Bizgaze = {}));