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 458KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706
  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_conversionrate" value=""/><input type="hidden" id="hf_currencyid" 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 conversionRate = item.ConversionRate;
  5517. $("#hf_conversionrate").val(conversionRate);
  5518. var currencyId = item.CurrencyId;
  5519. $("#hf_currencyid").val(currencyId);
  5520. var date = $(".date_journaldate").val().toString();
  5521. var NumOfDays = 0;
  5522. if (paymentid == 0) {
  5523. NumOfDays = datediff(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(item.JournalAlloc.JournalDate, null), date);
  5524. }
  5525. else {
  5526. var PaymentDate = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_paymentdate").Value;
  5527. NumOfDays = datediff(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(item.JournalAlloc.JournalDate, null), date);
  5528. }
  5529. instance.bindDuesHtml(item, dBalance, NumOfDays, trnId, tBalance);
  5530. }
  5531. }
  5532. if (duesTotalBal > 0)
  5533. element.find('.txtDuesTotalAmt').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(duesTotalBal, 2));
  5534. else
  5535. element.find('.txtDuesTotalAmt').text("0.00");
  5536. if (duesTotalBal > 0) {
  5537. $(".anchor_totalDue").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(duesTotalBal, 2));
  5538. }
  5539. else {
  5540. $(".anchor_totalDue").text("0.00");
  5541. }
  5542. }).then(function () {
  5543. $(".txtTotalDueAdjusted").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(adjustedTotal, 2));
  5544. $(".secDues").removeClass("hidden");
  5545. element.find('.secDues_' + trnId + '').addClass('hidden');
  5546. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5547. instance.isDueLoading = false;
  5548. var isWalletLoading = Bizgaze.Apps.Transact.Controls.Wallet.Instance().isWalletLoading;
  5549. if (instance.isDueLoading == false && isWalletLoading == false) {
  5550. instance.navigationHelper.hideLoading();
  5551. }
  5552. });
  5553. }
  5554. }
  5555. toggleDues(trnId) {
  5556. var instance = this;
  5557. var element = $('.transactonList_item_' + trnId + '');
  5558. element.find('.secDues_' + trnId + '').toggleClass('hidden');
  5559. }
  5560. AutoAdjustDues(trnId) {
  5561. var instance = this;
  5562. var element = $('.transactonList_item_' + trnId + '');
  5563. var btnColor = $(element).find('#btnAutoAdjustDues').attr('class');
  5564. if ($(element).find('#btnAutoAdjustDues').attr("name") == "enabled") {
  5565. }
  5566. else {
  5567. $(element).find('#btnAutoAdjustDues').attr("name", "enabled");
  5568. }
  5569. instance.updatePayment(trnId);
  5570. var totAdj = 0;
  5571. $(element).find('.divDue_Item').each(function () {
  5572. var xyz = Number($(this).find('.txtCurrentAmount').val());
  5573. if (!isNaN(xyz))
  5574. totAdj += xyz;
  5575. });
  5576. $('.txtTotalDueAdjusted').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAdj, 2));
  5577. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5578. }
  5579. clearDues() {
  5580. var instance = this;
  5581. var trnId = "TRN" + instance.transactionId;
  5582. var totalDueAdjAmt = Number($(".totAdjusted").first().text());
  5583. var totalCreditAmt = Number($(".totAmount").first().text());
  5584. if ((totalDueAdjAmt < totalCreditAmt) || (totalDueAdjAmt > totalCreditAmt)) {
  5585. $(".txtTotalDueAdjusted").val(0);
  5586. $(".totAdjusted").text(0.00);
  5587. var elementforPayment = $('.transactonList_item_' + trnId + '');
  5588. $(elementforPayment).find('.divDue_Item').each(function () {
  5589. $(this).find('.txtCurrentAmount').val(0);
  5590. var walletAmt = $(this).find('.hfDueAmount').val();
  5591. $(this).find('.lblDueBalance').val(walletAmt);
  5592. });
  5593. }
  5594. }
  5595. updatePayment(trnId) {
  5596. var instance = this;
  5597. var element = $('.transactonList_item_' + trnId + '');
  5598. var advanceAmt = 0;
  5599. var total = 0;
  5600. var ttWalAdj = Number($('.txtTotalWalletAdjusted').val());
  5601. var totWalAdj = (isNaN(ttWalAdj)) ? 0 : Number($('.txtTotalWalletAdjusted').val());
  5602. var prevamount = Number($("#txt_TotalCreditAmount").val()) + totWalAdj;
  5603. $(".paymentmodelistitem").each(function () {
  5604. if (!($(this).hasClass("hidden"))) {
  5605. var amount = Number($(this).find('.paymentamount').val());
  5606. $(this).find('.amount').text(amount);
  5607. total = Number(prevamount) + Number(amount);
  5608. prevamount = total;
  5609. }
  5610. });
  5611. var paymentTotal = Number(total) == 0 ? prevamount : Number(total);
  5612. $("#hf_TotalCreditAmount").val(paymentTotal);
  5613. $(element).find('.divDue_Item').each(function (index) {
  5614. var amount = Number($("#txt_TotalCreditAmount").val());
  5615. var txtDiscountAmount = Number($(this).find('.txtDiscountAmount').val());
  5616. var txtTdsAmount = Number($(this).find('.txtTdsAmount').val());
  5617. var currentAmount = Number($(this).find('.txtCurrentAmount').val());
  5618. var discamount = Number($(this).find('.hfDiscountAmount').val());
  5619. var tdsamount = Number($(this).find('.hfTdsAmount').val());
  5620. var dueAmount = 0;
  5621. if ((discamount == 0) && (tdsamount == 0)) {
  5622. $('.lblDueBalance').val();
  5623. dueAmount = Number($(this).find('.hfDueAmount').val()) - txtDiscountAmount - txtTdsAmount;
  5624. }
  5625. if ((discamount != 0) && (tdsamount != 0)) {
  5626. dueAmount = (Number($(this).find('.hfDueAmount').val()) + tdsamount + discamount) - txtDiscountAmount - txtTdsAmount;
  5627. }
  5628. if ((discamount != 0) && (tdsamount == 0)) {
  5629. dueAmount = (Number($(this).find('.hfDueAmount').val()) + discamount) - txtDiscountAmount - txtTdsAmount;
  5630. }
  5631. if ((discamount == 0) && (tdsamount != 0)) {
  5632. dueAmount = (Number($(this).find('.hfDueAmount').val()) + tdsamount) - txtDiscountAmount - txtTdsAmount;
  5633. }
  5634. var txtCurrentAmt = 0;
  5635. if (paymentTotal >= dueAmount) {
  5636. if (dueAmount != 0) {
  5637. paymentTotal -= dueAmount;
  5638. txtCurrentAmt = dueAmount;
  5639. dueAmount = 0;
  5640. advanceAmt = paymentTotal;
  5641. }
  5642. }
  5643. else {
  5644. dueAmount -= paymentTotal;
  5645. txtCurrentAmt = paymentTotal;
  5646. paymentTotal = 0;
  5647. }
  5648. if (Number(paymentTotal) < 0.01) {
  5649. paymentTotal = 0;
  5650. }
  5651. $(this).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(txtCurrentAmt, 2));
  5652. $(this).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(dueAmount, 2));
  5653. });
  5654. }
  5655. bindDuesHtml(item, dBalance, NumOfDays, formPropId, tBalance) {
  5656. var instance = this;
  5657. var discAmount = item.DiscountAmount;
  5658. if (item.PaymentTermMode == 2) {
  5659. discAmount = discAmount * -1;
  5660. }
  5661. var tdsAttr = "";
  5662. if (item.TCSAmount > 0) {
  5663. tdsAttr = "disabled";
  5664. }
  5665. var journalAlloc = item.JournalAlloc;
  5666. var Amount = item.Amount;
  5667. var html = '<div class="list-group-item divDue_Item" id="divDue_List_item_' + journalAlloc.JournalId + '"><div class="row">' +
  5668. '<input type="hidden" class="hf_JournalAllocId" value="' + journalAlloc.JournalAllocId + '" />' +
  5669. '<input type="hidden" class="hf_RefAllocId" value="' + journalAlloc.RefAllocId + '" />' +
  5670. '<input type="hidden" class="hf_conversionrate" value="' + item.ConversionRate + '" />' +
  5671. '<input type="hidden" class="hf_currencyid" value="' + item.CurrencyId + '" />' +
  5672. '<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>' +
  5673. '<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>' +
  5674. '<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>' +
  5675. '<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>' +
  5676. '<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>' +
  5677. '</div></div>';
  5678. var element = $('.transactonList_item_TRN' + formPropId + '');
  5679. element.find('.divDue_List_item').before(html);
  5680. }
  5681. bindDueEvents() {
  5682. }
  5683. tdsValidation(evt, id, jId, trnId) {
  5684. var instance = this;
  5685. instance.flag = 0;
  5686. var val = document.getElementById(id);
  5687. var curDueAmount = Number(val.value);
  5688. var elementforPayment = $('.transactonList_item_' + trnId);
  5689. var element = elementforPayment.find('#divDue_List_item_' + jId);
  5690. var tdsAccountId = Number($("#hf_TDSAccountId").val());
  5691. var totDueAmount = Number($(element).find('.hfDueAmount').val());
  5692. instance.AdjustDueAmount(evt, jId, trnId);
  5693. if (totDueAmount < curDueAmount) {
  5694. $(element).find('.txtTdsAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5695. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("TDSAmount cannot be greater than Due Amount");
  5696. return false;
  5697. }
  5698. var adjustedAmt = $(element).find('.txtCurrentAmount').val();
  5699. if (adjustedAmt != 0) {
  5700. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5701. }
  5702. return true;
  5703. }
  5704. discountValidation(evt, id, jId, trnId) {
  5705. var instance = this;
  5706. instance.flag = 0;
  5707. var val = document.getElementById(id);
  5708. var isNegativeValue = (val.value.match(/-/g) || []).length;
  5709. var curDueAmount = Number(val.value);
  5710. var elementforPayment = $('.transactonList_item_' + trnId);
  5711. var element = elementforPayment.find('#divDue_List_item_' + jId);
  5712. var discountAccountId = Number($("#hf_DiscountAccountId").val());
  5713. var penalityAccountId = Number($("#hf_PenalityAccountId").val());
  5714. var totDueAmount = Number($(element).find('.hfDueAmount').val());
  5715. var isDiscAmount = Math.sign(curDueAmount);
  5716. if (isNaN(isDiscAmount)) {
  5717. $(element).find('.txtDiscountAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5718. return false;
  5719. }
  5720. instance.AdjustDueAmount(evt, jId, trnId);
  5721. if (totDueAmount < curDueAmount) {
  5722. $(element).find('.txtDiscountAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5723. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Discount cannot be greater than Due Amount");
  5724. return false;
  5725. }
  5726. var adjustedAmt = $(element).find('.txtCurrentAmount').val();
  5727. if (adjustedAmt != 0) {
  5728. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5729. }
  5730. return true;
  5731. }
  5732. AdjustDueAmount(event, jId, trnId) {
  5733. var instance = this;
  5734. instance.flag = 0;
  5735. const maxAmt = Number($(event.target).parents('.divDue_Item').find('.hfOrgDueAmount').val());
  5736. const currVal = Number($(event.target).val());
  5737. if (currVal > maxAmt) {
  5738. $(event.target).val(maxAmt);
  5739. }
  5740. var formId = $(".transactonList_div_" + trnId).parents("form").attr("id").split('_')[1];
  5741. var elementforPayment = $('.transactonList_item_' + trnId + '');
  5742. var totDue = 0;
  5743. var totDueAmt = Number(elementforPayment.find('.txtDuesTotalAmt').text());
  5744. $(elementforPayment).find('.divDue_Item').each(function () {
  5745. var xyz = Number($(this).find('.txtCurrentAmount').val());
  5746. if (!isNaN(xyz))
  5747. totDue += xyz;
  5748. });
  5749. var element = elementforPayment.find('#divDue_List_item_' + jId + '');
  5750. var previousValue = $(element).find('.txtCurrentAmount').data("previousvalue");
  5751. var crAmt = totDueAmt;
  5752. var totalAmt = Number($(".totAmount").first().text());
  5753. var OrgdueAmount = Number($(element).find('.hfOrgDueAmount').val());
  5754. var DueAmount = Number($(element).find('.hfDueAmount').val());
  5755. var txtCurrentAmt = $(element).find('.txtCurrentAmount').val();
  5756. var txtDiscountAmt = Number($(element).find('.txtDiscountAmount').val());
  5757. var txtTDSAmt = Number($(element).find('.txtTdsAmount').val());
  5758. var hf_DiscountAmount = Number($(element).find(".hfDiscountAmount").val());
  5759. var hf_TDSAmount = Number($(element).find(".hfTdsAmount").val());
  5760. var lblDueBalance = Number($(element).find(".lblDueBalance").val());
  5761. var totalAmount = OrgdueAmount + hf_DiscountAmount + hf_TDSAmount;
  5762. var txtDueBal = 0;
  5763. if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt != 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5764. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5765. }
  5766. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt != 0 && txtTDSAmt == 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5767. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5768. }
  5769. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5770. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5771. }
  5772. else if ((txtCurrentAmt != 0) && txtDiscountAmt == 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5773. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5774. }
  5775. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt == 0 && txtTDSAmt == 0 && hf_DiscountAmount != 0) {
  5776. txtDueBal = OrgdueAmount + hf_DiscountAmount;
  5777. }
  5778. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt == 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5779. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5780. }
  5781. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && txtTDSAmt != 0 && lblDueBalance != 0) {
  5782. txtDueBal = totalAmount - txtDiscountAmt - txtTDSAmt;
  5783. }
  5784. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && hf_TDSAmount != 0 && lblDueBalance == 0 && totalAmount != txtCurrentAmt && hf_DiscountAmount == 0) {
  5785. txtDueBal = Number(txtCurrentAmt) - txtDiscountAmt;
  5786. }
  5787. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && hf_TDSAmount != 0 && lblDueBalance == 0 && totalAmount != txtCurrentAmt && hf_DiscountAmount != 0 && txtTDSAmt != 0) {
  5788. txtDueBal = totalAmount - txtDiscountAmt - txtTDSAmt;
  5789. }
  5790. else if ((txtCurrentAmt != 0) && txtDiscountAmt != 0 && txtTDSAmt != 0 && lblDueBalance == 0) {
  5791. txtDueBal = OrgdueAmount - txtTDSAmt;
  5792. }
  5793. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt == 0 && txtTDSAmt != 0) {
  5794. txtDueBal = OrgdueAmount + hf_DiscountAmount;
  5795. }
  5796. else if ((txtCurrentAmt == 0 || txtCurrentAmt == "") && txtDiscountAmt != 0 && txtTDSAmt == 0 && hf_DiscountAmount != 0) {
  5797. txtDueBal = (OrgdueAmount + hf_TDSAmount + hf_DiscountAmount) - txtDiscountAmt;
  5798. }
  5799. else if ((txtCurrentAmt != 0) && txtDiscountAmt == 0 && txtTDSAmt == 0 && lblDueBalance == 0 && hf_DiscountAmount != 0) {
  5800. txtDueBal = OrgdueAmount + hf_DiscountAmount;
  5801. }
  5802. else if ((txtDiscountAmt == 0 && hf_DiscountAmount != 0) && (txtTDSAmt == 0 && hf_TDSAmount != 0) && txtCurrentAmt == 0) {
  5803. txtDueBal = totalAmount;
  5804. }
  5805. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt == 0 && lblDueBalance != 0) {
  5806. txtDueBal = totalAmount - txtDiscountAmt - txtTDSAmt;
  5807. }
  5808. else if (txtCurrentAmt != 0 && txtDiscountAmt == 0 && txtTDSAmt == 0 && lblDueBalance != 0) {
  5809. txtDueBal = totalAmount - txtTDSAmt;
  5810. }
  5811. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt == 0 && lblDueBalance == 0 && txtCurrentAmt == totalAmount) {
  5812. txtDueBal = totalAmount - txtDiscountAmt;
  5813. }
  5814. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt == 0 && lblDueBalance == 0) {
  5815. txtDueBal = OrgdueAmount + hf_DiscountAmount - txtDiscountAmt;
  5816. }
  5817. else if (txtCurrentAmt == lblDueBalance && txtCurrentAmt != "" && txtCurrentAmt != 0) {
  5818. txtDueBal = OrgdueAmount + hf_DiscountAmount + hf_TDSAmount;
  5819. }
  5820. else if (txtCurrentAmt != 0 && txtDiscountAmt != 0 && txtTDSAmt != 0 && hf_DiscountAmount == 0 && hf_TDSAmount == 0) {
  5821. txtDueBal = OrgdueAmount - txtDiscountAmt - txtTDSAmt;
  5822. }
  5823. else if (txtCurrentAmt == 0 && DueAmount != 0 && OrgdueAmount != 0 && hf_DiscountAmount != 0 && hf_TDSAmount != 0 && txtDiscountAmt != 0 && txtTDSAmt != 0) {
  5824. txtDueBal = OrgdueAmount;
  5825. }
  5826. else if (txtCurrentAmt == 0 && txtDiscountAmt != 0 && hf_TDSAmount != 0 && hf_DiscountAmount == 0 && hf_TDSAmount != 0) {
  5827. txtDueBal = OrgdueAmount - txtDiscountAmt;
  5828. }
  5829. else if (totalAmount == txtCurrentAmt) {
  5830. txtDueBal = totalAmount;
  5831. }
  5832. else {
  5833. txtDueBal = OrgdueAmount;
  5834. }
  5835. if (txtDueBal < 0) {
  5836. txtDueBal = 0;
  5837. }
  5838. $(' #lblDueBalance_' + jId + '').val(txtDueBal);
  5839. if (totDue <= crAmt) {
  5840. if (totDue <= totalAmt) {
  5841. if (totDue <= totDueAmt) {
  5842. if (txtCurrentAmt == 0 || txtCurrentAmt == undefined) {
  5843. $(element).find('.txtCurrentAmount').val(0.00);
  5844. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(txtDueBal, 2));
  5845. var ttWallet = 0;
  5846. $(elementforPayment).find('.divDue_Item').each(function () {
  5847. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5848. if (!isNaN(pqr))
  5849. ttWallet += pqr;
  5850. });
  5851. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5852. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5853. var currentValue = Number($(element).find('.txtCurrentAmount').val());
  5854. $(element).find('.txtCurrentAmount').data("previousvalue", currentValue);
  5855. return false;
  5856. }
  5857. if (Number(txtCurrentAmt) + txtDiscountAmt + txtTDSAmt > OrgdueAmount) {
  5858. var walletAmount_ = 0;
  5859. if ((hf_DiscountAmount != 0 && txtDiscountAmt == 0)) {
  5860. walletAmount_ = Number(hf_DiscountAmount);
  5861. }
  5862. else if ((hf_TDSAmount != 0 && txtTDSAmt == 0)) {
  5863. walletAmount_ = walletAmount_ + Number(hf_TDSAmount);
  5864. }
  5865. if (txtDiscountAmt == 0) {
  5866. $(element).find('.txtDiscountAmount').val(0.00);
  5867. }
  5868. if (txtTDSAmt == 0) {
  5869. $(element).find('.txtTdsAmount').val(0.00);
  5870. }
  5871. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(txtDueBal, 2));
  5872. if (txtCurrentAmt == totalAmount) {
  5873. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5874. }
  5875. else {
  5876. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletAmount_, 2));
  5877. }
  5878. }
  5879. else {
  5880. var walletAmount = txtDueBal - Number(txtCurrentAmt);
  5881. if (walletAmount < 0) {
  5882. walletAmount = 0;
  5883. }
  5884. if (hf_TDSAmount != 0 && txtTDSAmt == 0 && txtDiscountAmt == 0 && hf_DiscountAmount != 0) {
  5885. walletAmount = hf_DiscountAmount + hf_TDSAmount + walletAmount;
  5886. }
  5887. $(element).find('.txtCurrentAmount').val(txtCurrentAmt);
  5888. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(walletAmount, 2));
  5889. }
  5890. var ttWallet = 0;
  5891. $(elementforPayment).find('.divDue_Item').each(function () {
  5892. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5893. if (!isNaN(pqr))
  5894. ttWallet += pqr;
  5895. });
  5896. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5897. }
  5898. else {
  5899. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(OrgdueAmount - txtDiscountAmt - txtTDSAmt, 2));
  5900. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(0, 2));
  5901. var ttWallet = 0;
  5902. $(elementforPayment).find('.divDue_List_item').each(function () {
  5903. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5904. if (!isNaN(pqr))
  5905. ttWallet += pqr;
  5906. });
  5907. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5908. }
  5909. }
  5910. else {
  5911. MessageHelper.Instance().showError("You cannot adjust without enough credits", 'div_ErrorMessage_' + formId);
  5912. $(element).find('.txtCurrentAmount').val(previousValue);
  5913. }
  5914. }
  5915. else {
  5916. var ttWallet = 0;
  5917. $(elementforPayment).find('.divDue_Item').each(function () {
  5918. var pqr = Number($(this).find('.txtCurrentAmount').val());
  5919. if (!isNaN(pqr))
  5920. ttWallet += pqr;
  5921. });
  5922. var newAmt = Number(crAmt) - (Number(ttWallet) - Number(txtCurrentAmt));
  5923. var OldCurAdjAmt = Number($(element).find('.txtCurrentAmount').val());
  5924. if (newAmt >= 0) {
  5925. if (newAmt >= Number($(element).find('.hfDueAmount').val())) {
  5926. var curAdjAmt = ttWallet - OldCurAdjAmt;
  5927. var newAdjAmt = txtDueBal;
  5928. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(newAdjAmt, 2));
  5929. $(element).find('.lblDueBalance').val(0.00);
  5930. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(curAdjAmt + newAdjAmt, 2));
  5931. }
  5932. else {
  5933. var curAdjAmt = ttWallet - OldCurAdjAmt;
  5934. var newAdjAmt = OrgdueAmount - newAmt;
  5935. $(element).find('.txtCurrentAmount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(newAmt, 2));
  5936. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(newAdjAmt, 2));
  5937. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(curAdjAmt + newAdjAmt, 2));
  5938. }
  5939. }
  5940. else {
  5941. $(element).find('.txtCurrentAmount').val(0);
  5942. $(element).find('.lblDueBalance').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(element).find('.hfWalletAmount').val()), 2));
  5943. $(elementforPayment).find('.txtTotalDueAdjusted_' + trnId + '').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(ttWallet, 2));
  5944. }
  5945. }
  5946. Bizgaze.Apps.Transact.Controls.PaymentSummary.Instance().updatePaymentSummaryTotal();
  5947. var currentValue = Number($(element).find('.txtCurrentAmount').val());
  5948. $(element).find('.txtCurrentAmount').data("previousvalue", currentValue);
  5949. }
  5950. isDecimalplusNoLongPress(evt, id) {
  5951. let value = $('#' + id).val();
  5952. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5953. if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode == 46) {
  5954. return false;
  5955. }
  5956. if (value) {
  5957. if (value.split('.').length >= 2) {
  5958. if (value.split('.')[1]) {
  5959. if (value.split('.')[1].length >= 2) {
  5960. let valNew = parseFloat(`${value}`).toFixed(2);
  5961. $('#' + id).val(valNew);
  5962. }
  5963. }
  5964. }
  5965. }
  5966. return true;
  5967. }
  5968. isSignDecimalplusNoLongPress(evt, id) {
  5969. var instance = this;
  5970. instance.flag++;
  5971. var charCode = (evt.which) ? evt.which : evt.keyCode;
  5972. if (instance.flag <= 4) {
  5973. if (charCode == 46) {
  5974. var val = document.getElementById(id);
  5975. var txt = val.value;
  5976. if (!(txt.indexOf(".") > -1)) {
  5977. return true;
  5978. }
  5979. }
  5980. if (charCode == 45) {
  5981. return true;
  5982. }
  5983. if (charCode > 31 && (charCode < 48 || charCode > 57))
  5984. return false;
  5985. }
  5986. else {
  5987. return false;
  5988. }
  5989. return true;
  5990. }
  5991. initFlag() {
  5992. var instance = this;
  5993. instance.flag = 0;
  5994. }
  5995. loadControlSettings(controlsettingjson, formpropertyid) {
  5996. return ``;
  5997. }
  5998. loadPropertySettings(propertysettings, formpropertyid) {
  5999. if (propertysettings != null) {
  6000. for (var i = 0; i < propertysettings.length; i++) {
  6001. var data = propertysettings[i];
  6002. if (data.ControlPropertyName == "ControlType" && data.ControlPropertyValue != "") {
  6003. $("#hdn_" + formpropertyid).attr("ControlType", data.ControlPropertyValue);
  6004. $("#hdn_" + formpropertyid).val(data.ControlPropertyValue);
  6005. }
  6006. }
  6007. }
  6008. }
  6009. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  6010. return ``;
  6011. }
  6012. dueControlObj(trnId) {
  6013. var walletamount = Number($('.txtTotalWalletAdjusted').val());
  6014. var dueamount = Number($('.txtTotalDueAdjusted ').val());
  6015. if (walletamount > 0 && dueamount == 0) {
  6016. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Error! Wallet amount is not adjusted against Dues. Remove the excess amount from wallets & save!");
  6017. return false;
  6018. }
  6019. var instance = this;
  6020. var element = $('.transactonList_item_' + trnId + '');
  6021. var data = new Array();
  6022. element.find('.divDue_Item').each(function (index) {
  6023. var balanceAmount = Number($(this).find('.lblDueBalance').val());
  6024. var isDueObj = false;
  6025. if ($(this).find('.txtCurrentAmount').val() != 0 && $(this).find('.txtCurrentAmount').val() != '' && $(this).find('.txtCurrentAmount').val() != undefined) {
  6026. isDueObj = true;
  6027. }
  6028. else if (!isNaN(balanceAmount) && balanceAmount == 0) {
  6029. isDueObj = true;
  6030. }
  6031. if (isDueObj) {
  6032. var jAId = Number($(this).find('.hf_JournalAllocId').val());
  6033. var conversionRate = Number($(this).find('.hf_conversionrate').val());
  6034. var currencyId = Number($(this).find('.hf_currencyid').val());
  6035. var journalTypeId = 2;
  6036. var discountAmount = Number($(this).find('.txtDiscountAmount').val());
  6037. var tdsAmount = Number($(this).find('.txtTdsAmount').val());
  6038. if (instance.journalTypeId == 1) {
  6039. data.push({
  6040. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  6041. Credit: Number($(this).find('.txtCurrentAmount').val()),
  6042. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  6043. AllocType: 2,
  6044. AllocTypeId: 2,
  6045. Discount: discountAmount,
  6046. TDSAmount: tdsAmount,
  6047. ConversionRate: conversionRate,
  6048. CurrencyId: currencyId,
  6049. });
  6050. }
  6051. else if (journalTypeId == 2) {
  6052. data.push({
  6053. JournalAllocId: isNaN(jAId) ? 0 : jAId,
  6054. Debit: Number($(this).find('.txtCurrentAmount').val()),
  6055. RefAllocId: Number($(this).find('.hf_RefAllocId').val()),
  6056. AllocType: 2,
  6057. AllocTypeId: 2,
  6058. Discount: discountAmount,
  6059. TDSAmount: tdsAmount,
  6060. });
  6061. }
  6062. }
  6063. });
  6064. return data;
  6065. }
  6066. checkConversionnRateByOrganization(curContactId) {
  6067. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().CheckConversionRateByOrganization(curContactId).then(function (response) {
  6068. if (response.result != null) {
  6069. $(".divCustomProperties_conversionrate").removeClass("hidden");
  6070. $(".number_conversionrate").addClass("required");
  6071. $("#div_ForeignExchange").removeClass("hidden");
  6072. $("#txtAutoComplete_ForeignExchangeAccount").addClass("required");
  6073. }
  6074. else {
  6075. $(".divCustomProperties_conversionrate").addClass("hidden");
  6076. $(".number_conversionrate").removeClass("required");
  6077. $("#div_ForeignExchange").addClass("hidden");
  6078. $("#txtAutoComplete_ForeignExchangeAccount").removeClass("required");
  6079. }
  6080. });
  6081. }
  6082. static Instance() {
  6083. if (this.instance === undefined) {
  6084. this.instance = new Dues();
  6085. }
  6086. return this.instance;
  6087. }
  6088. }
  6089. Controls.Dues = Dues;
  6090. })(Controls = Transact.Controls || (Transact.Controls = {}));
  6091. })(Transact = Apps.Transact || (Apps.Transact = {}));
  6092. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  6093. })(Bizgaze || (Bizgaze = {}));
  6094. var Bizgaze;
  6095. (function (Bizgaze) {
  6096. let Apps;
  6097. (function (Apps) {
  6098. let Transact;
  6099. (function (Transact) {
  6100. let Controls;
  6101. (function (Controls) {
  6102. class PaymentSummary extends Unibase.Platform.Core.BaseComponent {
  6103. init(formpropertyid, prop, callback) {
  6104. var instance = this;
  6105. }
  6106. loadControl(containerid, prop) {
  6107. var instance = this;
  6108. var containerhtml = `<div id="paymentSummaryContainer"></div>`;
  6109. $("#" + containerid).html(containerhtml);
  6110. instance.loadPaymentSummaryControl("paymentSummaryContainer");
  6111. }
  6112. loadPaymentSummaryControl(containerid) {
  6113. var instance = this;
  6114. var html = '<div class="row clearfix">' +
  6115. '<div class="col-md-4 ">' +
  6116. '<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>' +
  6117. '<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>' +
  6118. '<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>' +
  6119. '</div>' +
  6120. '<div class="col-md-3">' +
  6121. '<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">' +
  6122. '<label for="lbl" id="lbl_Discount">Discount Account<span class="text-danger" id="spnlbl_Discount"> *</span></label>' +
  6123. '<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>' +
  6124. '</div>' +
  6125. '<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">' +
  6126. '<label for="lbl" id="lbl_Penality">Penality Account<span class="text-danger" id="spnlbl_Penality"> *</span></label>' +
  6127. '<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>' +
  6128. '</div>' +
  6129. '<div id="div_ForeignExchange" class="col-sm-12 form-group floating-label-form-group floating-label-form-group-with-value border-0 pb-10">' +
  6130. '<label for="lbl" id="lbl_ForeignExchange">Foreign Exchange Account<span class="text-danger" id="spnlbl_ForeignExchange"> *</span></label>' +
  6131. '<div class="input-group"><select id="txtAutoComplete_ForeignExchangeAccount" class="txtAutoComplete_ForeignExchangeAccount form-control text-control select2-hidden-accessible" style="width:100%;" placeholder="Select Foreign Exchange Account"></select><input type="hidden" id="hfAutoComplete_ForeignExchangeAccount" value="" class="hfAutoComplete_ForeignExchangeAccount form-control"/></div>' +
  6132. '</div>' +
  6133. '<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">' +
  6134. '<label for="lbl" id="lbl_TDS">TDS Account<span class="text-danger" id="spnlbl_TDS"> *</span></label>' +
  6135. '<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>' +
  6136. '</div>' +
  6137. '</div>' +
  6138. '<div class="col-md-5 no-padder text-right d-none d-md-block" id="divTotalAmount">' +
  6139. '<input type="hidden" class="totBalance" id="totBalance"></input>' +
  6140. '<div class="row col-sm-12 form-group">' +
  6141. '<div class="col-sm-6 text-right">' +
  6142. '<span>Total Amount</span>' +
  6143. '</div>' +
  6144. '<div class="col-md-6 text-right">' +
  6145. '<strong>' +
  6146. '<span class="totAmount" id="totAmount">0.00</span>' +
  6147. ' </strong>' +
  6148. '</div>' +
  6149. '</div>' +
  6150. '<div class="row col-sm-12 form-group summary" id="divDiscountAmount">' +
  6151. '<div class="col-md-6 text-right">' +
  6152. '<span>Discount</span>' +
  6153. '</div>' +
  6154. '<div class="col-md-6 text-right ">' +
  6155. '<strong>' +
  6156. '<span class="totDiscount" id="totDiscount">0.00</span>' +
  6157. '</strong>' +
  6158. ' </div>' +
  6159. '</div>' +
  6160. '<div class="row col-sm-12 form-group summary" id="divPenalityAmount">' +
  6161. '<div class="col-md-6 text-right">' +
  6162. '<span>Penality</span>' +
  6163. '</div>' +
  6164. '<div class="col-md-6 text-right ">' +
  6165. '<strong>' +
  6166. '<span class="totPenality" id="totPenality">0.00</span>' +
  6167. '</strong>' +
  6168. ' </div>' +
  6169. '</div>' +
  6170. '<div class="row col-sm-12 form-group summary" id="divAdjustedAmount">' +
  6171. '<div class="col-sm-6 text-right">' +
  6172. '<span>Adjusted</span>' +
  6173. '</div>' +
  6174. '<div class="col-sm-6 text-right">' +
  6175. '<strong>' +
  6176. '<span class="totAdjusted" id="totAdjusted">0.00</span>' +
  6177. '</strong>' +
  6178. '</div>' +
  6179. '</div>' +
  6180. '<div class="row col-sm-12 form-group summary" id="divAdvanceAmount">' +
  6181. '<div class="col-sm-6 text-right">' +
  6182. '<span>Advance</span>' +
  6183. '</div>' +
  6184. '<div class="col-sm-6 text-right">' +
  6185. '<strong>' +
  6186. '<span class="totAdvance" id="totAdvance">0.00</span>' +
  6187. '</strong>' +
  6188. '</div>' +
  6189. '</div>' +
  6190. '<div class="row col-sm-12" id="divTdsAmount">' +
  6191. '<div class="col-md-6 text-right">' +
  6192. '<span>TDS</span>' +
  6193. '</div>' +
  6194. '<div class="col-md-6 text-right">' +
  6195. '<strong>' +
  6196. '<span class="totTds" id="totTds">0.00</span>' +
  6197. '</strong>' +
  6198. '</div>' +
  6199. '</div>' +
  6200. '</div>' +
  6201. '<div class="col-sm-12 no-padder d-md-none border-top border-dark " id="divTotalAmount">' +
  6202. '<input type="hidden" class="totBalance" id="totBalance"></input>' +
  6203. '<div class="row col-sm-12 form-group pt-10">' +
  6204. '<div class="col-6 text-left">' +
  6205. '<span>Total Amount</span>' +
  6206. '</div>' +
  6207. '<div class="col-6 text-left">' +
  6208. '<strong>' +
  6209. '<span class="totAmount" id="totAmount">0.00</span>' +
  6210. ' </strong>' +
  6211. '</div>' +
  6212. '</div>' +
  6213. '<div class="row col-sm-12 form-group summary" id="divDiscountAmount">' +
  6214. '<div class="col-6 ">' +
  6215. '<span>Discount</span>' +
  6216. '</div>' +
  6217. '<div class="col-6 ">' +
  6218. '<strong>' +
  6219. '<span class="totDiscount" id="totDiscount">0.00</span>' +
  6220. '</strong>' +
  6221. ' </div>' +
  6222. '</div>' +
  6223. '<div class="row col-sm-12 form-group summary" id="divPenalityAmount">' +
  6224. '<div class="col-6 ">' +
  6225. '<span>Penality</span>' +
  6226. '</div>' +
  6227. '<div class="col-6 ">' +
  6228. '<strong>' +
  6229. '<span class="totPenality" id="totPenality">0.00</span>' +
  6230. '</strong>' +
  6231. ' </div>' +
  6232. '</div>' +
  6233. '<div class="row col-sm-12 form-group summary" id="divAdjustedAmount">' +
  6234. '<div class="col-6 ">' +
  6235. '<span>Adjusted.</span>' +
  6236. '</div>' +
  6237. '<div class="col-6 ">' +
  6238. '<strong>' +
  6239. '<span class="totAdjusted" id="totAdjusted">0.00</span>' +
  6240. '</strong>' +
  6241. '</div>' +
  6242. '</div>' +
  6243. '<div class="row col-sm-12 form-group summary" id="divAdvanceAmount">' +
  6244. '<div class="col-6">' +
  6245. '<span>Advance</span>' +
  6246. '</div>' +
  6247. '<div class="col-6">' +
  6248. '<strong>' +
  6249. '<span class="totAdvance" id="totAdvance">0.00</span>' +
  6250. '</strong>' +
  6251. '</div>' +
  6252. '</div>' +
  6253. '<div class="row col-sm-12" id="divTdsAmount">' +
  6254. '<div class="col-6">' +
  6255. '<span>TDS</span>' +
  6256. '</div>' +
  6257. '<div class="col-6">' +
  6258. '<strong>' +
  6259. '<span class="totTds" id="totTds">0.00</span>' +
  6260. '</strong>' +
  6261. '</div>' +
  6262. '</div>' +
  6263. '</div>' +
  6264. '</div>';
  6265. $("#" + containerid).html(html);
  6266. instance.loadAccounts();
  6267. }
  6268. loadPaymentSummary() {
  6269. var instance = this;
  6270. var dueFormPropertyId = $("#dueControlList").parents(".divCustomProperties").data("formpropertyid");
  6271. var totAdjAmount = 0;
  6272. var totTds = 0;
  6273. var totDiscount = 0;
  6274. var totPenality = 0;
  6275. var elementforDue = $('.transactonList_item_TRN' + dueFormPropertyId + '');
  6276. $(elementforDue).find('.divDue_Item').each(function () {
  6277. var curAdjAmt = Number($(this).find('.txtCurrentAmount').val());
  6278. if (!isNaN(curAdjAmt) && curAdjAmt != 0) {
  6279. totAdjAmount += curAdjAmt;
  6280. var curDiscAmt = Number($(this).find(".txtDiscountAmount").val());
  6281. if (!isNaN(curDiscAmt) && curDiscAmt != 0) {
  6282. if (curDiscAmt > 0) {
  6283. totDiscount += curDiscAmt;
  6284. }
  6285. else {
  6286. totPenality += curDiscAmt;
  6287. }
  6288. }
  6289. var curTds = Number($(this).find(".txtTdsAmount").val());
  6290. if (!isNaN(curTds) && curTds != 0) {
  6291. totTds += curTds;
  6292. }
  6293. }
  6294. });
  6295. $('.txtTotalDueAdjusted').val(totAdjAmount);
  6296. var ttCreditAmt = 0;
  6297. if ($("#paymentslist li").length > 1) {
  6298. var amt = 0;
  6299. $("#paymentslist li").each(function (e) {
  6300. var curAmt = Number($(this).find(".spn_payment_amount").text());
  6301. if (!isNaN(curAmt)) {
  6302. amt += curAmt;
  6303. }
  6304. });
  6305. ttCreditAmt = amt;
  6306. }
  6307. else {
  6308. var amt = Number($("#txt_TotalCreditAmount").val());
  6309. if (!isNaN(amt)) {
  6310. ttCreditAmt = amt;
  6311. }
  6312. }
  6313. var walletFormPropertyId = $("#walletControlList").parents(".divCustomProperties").data("formpropertyid");
  6314. var elementforPayment = $('.transactonList_item_TRN' + walletFormPropertyId);
  6315. var totWalletAdjusted = Number($(elementforPayment).find('.txtTotalWalletAdjusted_TRN' + walletFormPropertyId).val());
  6316. if (!isNaN(totWalletAdjusted)) {
  6317. ttCreditAmt += totWalletAdjusted;
  6318. }
  6319. $("#hf_TotalCreditAmount").val(ttCreditAmt);
  6320. var advanceAmt = Number($("#hf_TotalCreditAmount").val()) - Number($('.txtTotalDueAdjusted').val());
  6321. var advAmt = (advanceAmt > 0) ? advanceAmt : 0;
  6322. $('.totAdvance').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(advAmt, 2));
  6323. var totAdjusted = Number($('.txtTotalDueAdjusted').val());
  6324. $('.totAdjusted').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAdjusted, 2));
  6325. var totAmountCredited = Number($("#hf_TotalCreditAmount").val());
  6326. $('.totAmount').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAmountCredited, 2));
  6327. $('.totDiscount').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totDiscount, 2));
  6328. $('.totPenality').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totPenality, 2));
  6329. $('.totTds').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totTds, 2));
  6330. instance.showOrHideAccounts(totDiscount, totPenality, totTds);
  6331. }
  6332. updatePaymentSummary() {
  6333. var instance = this;
  6334. var cashAmt = 0;
  6335. var chequeAmt = 0;
  6336. var onlineAmt = 0;
  6337. var neftAmt = 0;
  6338. var rtgs = 0;
  6339. var fundTransfer = 0;
  6340. var adjustment = 0;
  6341. var upiAmt = 0;
  6342. var cardAmt = 0;
  6343. var totalAmount = 0;
  6344. var hasAdjustment = false;
  6345. $("#paymentslist li").each(function () {
  6346. var curPaymentMode = Number($(this).find("#hf_PaymentModeId").val());
  6347. var curAmt = Number($(this).find(".spn_payment_amount").text());
  6348. var flag = 1;
  6349. if (!isNaN(curPaymentMode) && !isNaN(curAmt)) {
  6350. flag = 1;
  6351. }
  6352. else {
  6353. flag = 0;
  6354. var ddlPaymentModeId = $("#txtAutoComplete_paymentmodeid").val();
  6355. if (ddlPaymentModeId != null && ddlPaymentModeId != 0 && ddlPaymentModeId != undefined && ddlPaymentModeId != "0") {
  6356. flag = 1;
  6357. curPaymentMode = Number($("#txtAutoComplete_paymentmodeid").val());
  6358. curAmt = Number($("#txt_TotalCreditAmount").val());
  6359. }
  6360. }
  6361. if (flag == 1) {
  6362. totalAmount += curAmt;
  6363. if (curPaymentMode == 1) {
  6364. cashAmt += curAmt;
  6365. }
  6366. else if (curPaymentMode == 2) {
  6367. chequeAmt += curAmt;
  6368. }
  6369. else if (curPaymentMode == 3) {
  6370. onlineAmt += curAmt;
  6371. }
  6372. else if (curPaymentMode == 4) {
  6373. neftAmt += curAmt;
  6374. }
  6375. else if (curPaymentMode == 5) {
  6376. rtgs += curAmt;
  6377. }
  6378. else if (curPaymentMode == 6) {
  6379. fundTransfer += curAmt;
  6380. }
  6381. else if (curPaymentMode == 7) {
  6382. hasAdjustment = true;
  6383. adjustment += curAmt;
  6384. }
  6385. else if (curPaymentMode == 8) {
  6386. upiAmt += curAmt;
  6387. }
  6388. else if (curPaymentMode == 9) {
  6389. cardAmt += curAmt;
  6390. }
  6391. }
  6392. });
  6393. $('.paymentmodes').remove();
  6394. if (cashAmt > 0) {
  6395. $("#paymentmodesummary").append("<span class='row paymentmodes'>Cash</span>");
  6396. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(cashAmt, 2) + "</span>");
  6397. }
  6398. if (chequeAmt > 0) {
  6399. $("#paymentmodesummary").append("<span class='row paymentmodes'>Cheque</span>");
  6400. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(chequeAmt, 2) + "</span>");
  6401. }
  6402. if (onlineAmt > 0) {
  6403. $("#paymentmodesummary").append("<span class='row paymentmodes'>Online</span>");
  6404. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(onlineAmt, 2) + "</span>");
  6405. }
  6406. if (neftAmt > 0) {
  6407. $("#paymentmodesummary").append("<span class='row paymentmodes'>NEFT</span>");
  6408. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(neftAmt, 2) + "</span>");
  6409. }
  6410. if (rtgs > 0) {
  6411. $("#paymentmodesummary").append("<span class='row paymentmodes'>RTGS</span>");
  6412. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rtgs, 2) + "</span>");
  6413. }
  6414. if (fundTransfer > 0) {
  6415. $("#paymentmodesummary").append("<span class='row paymentmodes'>FundTransfer</span>");
  6416. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(fundTransfer, 2) + "</span>");
  6417. }
  6418. if (adjustment > 0 || hasAdjustment) {
  6419. $("#paymentmodesummary").append("<span class='row paymentmodes'>Adjustment</span>");
  6420. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(adjustment, 2) + "</span>");
  6421. }
  6422. if (upiAmt > 0) {
  6423. $("#paymentmodesummary").append("<span class='row paymentmodes'>UPI</span>");
  6424. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(upiAmt, 2) + "</span>");
  6425. }
  6426. if (cardAmt > 0) {
  6427. $("#paymentmodesummary").append("<span class='row paymentmodes'>Card</span>");
  6428. $("#paymentmodeamountsummary").append("<span class='row paymentmodes'>" + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(cardAmt, 2) + "</span>");
  6429. }
  6430. instance.updatePaymentSummaryTotal();
  6431. }
  6432. updatePaymentSummaryTotal() {
  6433. var instance = this;
  6434. var amt = 0;
  6435. var totalCreditAmt = Number($("#txt_TotalCreditAmount").val());
  6436. if (!isNaN(totalCreditAmt)) {
  6437. amt = totalCreditAmt;
  6438. }
  6439. $("#paymentslist li").each(function (e) {
  6440. var curAmt = Number($(this).find(".spn_payment_amount").text());
  6441. if (!isNaN(curAmt)) {
  6442. amt += curAmt;
  6443. }
  6444. });
  6445. var discAmt = 0;
  6446. var tdsAmt = 0;
  6447. var penalityAmt = 0;
  6448. $("#dueControl_transactonListDiv .divDue_Item").each(function (e) {
  6449. var curAdjAmt = Number($(this).find(".txtCurrentAmount").val());
  6450. if (!isNaN(curAdjAmt) && curAdjAmt != 0) {
  6451. var curDiscAmt = Number($(this).find(".txtDiscountAmount").val());
  6452. if (!isNaN(curDiscAmt)) {
  6453. if (curDiscAmt > 0) {
  6454. discAmt += curDiscAmt;
  6455. }
  6456. else {
  6457. penalityAmt += curDiscAmt;
  6458. }
  6459. }
  6460. }
  6461. });
  6462. $("#dueControl_transactonListDiv .divDue_Item").each(function (e) {
  6463. var curAdjAmt = Number($(this).find(".txtCurrentAmount").val());
  6464. if (!isNaN(curAdjAmt) && curAdjAmt != 0) {
  6465. var curTdsAmt = Number($(this).find(".txtTdsAmount").val());
  6466. if (!isNaN(curTdsAmt)) {
  6467. tdsAmt += curTdsAmt;
  6468. }
  6469. }
  6470. });
  6471. var walletAmt = Number($(".txtTotalWalletAdjusted").val());
  6472. if (!isNaN(walletAmt)) {
  6473. amt += walletAmt;
  6474. }
  6475. var totAdj = Number($(".txtTotalDueAdjusted").val());
  6476. if (totAdj != null && totAdj != undefined && !isNaN(totAdj)) {
  6477. $(".totAdjusted").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totAdj, 2));
  6478. }
  6479. else {
  6480. totAdj = 0;
  6481. }
  6482. if (amt != null && amt != undefined && !isNaN(amt)) {
  6483. $("#hf_TotalCreditAmount").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(amt, 2));
  6484. $(".totAmount").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(amt, 2));
  6485. }
  6486. else {
  6487. amt = 0;
  6488. }
  6489. var advanceAmt = amt - totAdj;
  6490. var advAmt = (advanceAmt > 0) ? advanceAmt : 0;
  6491. $('.totAdvance').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(advAmt, 2));
  6492. var totDiscountAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discAmt, 2);
  6493. $('.totDiscount').text(totDiscountAmount);
  6494. var totPenalityAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(penalityAmt, 2);
  6495. $('.totPenality').text(totPenalityAmount);
  6496. var totTDSAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(tdsAmt, 2);
  6497. $('.totTds').text(totTDSAmount);
  6498. instance.showOrHideAccounts(discAmt, penalityAmt, tdsAmt);
  6499. }
  6500. loadAccounts() {
  6501. var instance = this;
  6502. var discount = 'Discount Account';
  6503. var foreignExchnage = 'Foreign Exchange';
  6504. var paymentTypeId = Number($(".hdn_paymenttypeid").val());
  6505. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
  6506. var url1 = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/receiptledgerautocomplete/discount/' + discount + '/paymenttypeid/' + paymentTypeId;
  6507. var url2 = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/receiptledgerautocomplete/discount/' + foreignExchnage + '/paymenttypeid/' + paymentTypeId;
  6508. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_DiscountAccount", "#hfAutoComplete_DiscountAccount", url1, function (response) {
  6509. });
  6510. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_ForeignExchangeAccount", "#hfAutoComplete_ForeignExchangeAccount", url2, function (response) {
  6511. });
  6512. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_PenalityAccount", "#hfAutoComplete_PenalityAccount", url, null);
  6513. AutoCompleteHelper.getHelper().Create("#txtAutoComplete_TDSAccount", "#hfAutoComplete_TDSAccount", url, null);
  6514. $("#txtAutoComplete_DiscountAccount").on('select2:select', function (e) {
  6515. instance.accountsOnChange(Transact.Enums.PaymentDiscountType.Discount);
  6516. });
  6517. $("#txtAutoComplete_PenalityAccount").on('select2:select', function (e) {
  6518. instance.accountsOnChange(Transact.Enums.PaymentDiscountType.Penalty);
  6519. });
  6520. $("#txtAutoComplete_TDSAccount").on('select2:select', function (e) {
  6521. instance.accountsOnChange(Transact.Enums.PaymentDiscountType.TDS);
  6522. });
  6523. }
  6524. accountsOnChange(accountType) {
  6525. var instance = this;
  6526. var accountId = 0;
  6527. var accountName = "";
  6528. var controlId = "";
  6529. var hiddenFieldControlId = "";
  6530. if (accountType == Transact.Enums.PaymentDiscountType.Discount) {
  6531. accountId = Number($("#txtAutoComplete_DiscountAccount").val());
  6532. accountName = $("#txtAutoComplete_DiscountAccount").text();
  6533. controlId = "#txtAutoComplete_DiscountAccount";
  6534. hiddenFieldControlId = "#hfAutoComplete_DiscountAccount";
  6535. }
  6536. else if (accountType == Transact.Enums.PaymentDiscountType.Penalty) {
  6537. accountId = Number($("#txtAutoComplete_PenalityAccount").val());
  6538. accountName = $("#txtAutoComplete_PenalityAccount").text();
  6539. controlId = "#txtAutoComplete_PenalityAccount";
  6540. hiddenFieldControlId = "#hfAutoComplete_PenalityAccount";
  6541. }
  6542. else if (accountType == Transact.Enums.PaymentDiscountType.TDS) {
  6543. accountId = Number($("#txtAutoComplete_TDSAccount").val());
  6544. accountName = $("#txtAutoComplete_TDSAccount").text();
  6545. controlId = "#txtAutoComplete_TDSAccount";
  6546. hiddenFieldControlId = "#hfAutoComplete_TDSAccount";
  6547. }
  6548. if (accountId == 0)
  6549. accountName = "Select Account";
  6550. if (accountId == 1 || accountId == -1)
  6551. accountName = "Create New";
  6552. if (accountName == "Create New") {
  6553. $("#txtAutoComplete_DiscountAccount").val(null).trigger("change");
  6554. $("#txtAutoComplete_PenalityAccount").val(null).trigger("change");
  6555. $("#txtAutoComplete_TDSAccount").val(null).trigger("change");
  6556. var FormUniqueId = "Bizgaze_Extension_Transact_Ledgers_App_Ledgers_CreateForm";
  6557. var AppConfigurationUnique = "Bizgaze_Extension_Transact_Ledgers_AppConfiguration_CreateLedgers";
  6558. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(FormUniqueId).then(function (response) {
  6559. var obj = {
  6560. controlid: controlId,
  6561. hiddenid: hiddenFieldControlId
  6562. };
  6563. var successobj = {
  6564. CallBack: function (id, obj) {
  6565. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLedgerById(id).then(function (response) {
  6566. var createdLedger = new Option(response.result.LedgerName, response.result.LedgerId, true);
  6567. $(obj.controlid + " option").remove();
  6568. $(obj.controlid).append(createdLedger).trigger('change');
  6569. $(obj.hiddenid).val(response.result.LedgerId);
  6570. $(obj.controlid).parents(".transactonList_item").find('.hf_AccountId').val(response.result.LedgerId);
  6571. });
  6572. },
  6573. Parameters: obj,
  6574. };
  6575. var formviewerObj = {
  6576. FormId: response.result.FormId,
  6577. AppConfigurationId: 0,
  6578. Pk_Value: 0,
  6579. PortletWidgetId: 0,
  6580. OnSuccess: successobj,
  6581. OnFail: null,
  6582. OnLoad: null,
  6583. };
  6584. instance.fileCacheHelper.loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  6585. Unibase.Platform.Forms.Components.FormViewer.instance.init(formviewerObj);
  6586. });
  6587. });
  6588. }
  6589. }
  6590. bindAccounts(accountsObj) {
  6591. if (accountsObj.DiscountAccountName != null && accountsObj.DiscountAccountName != "" && accountsObj.DiscountAccountName != undefined) {
  6592. var selectedDiscountAcc = new Option(accountsObj.DiscountAccountName, accountsObj.DiscountAccountId, true);
  6593. $("#txtAutoComplete_DiscountAccount").append(selectedDiscountAcc);
  6594. }
  6595. if (accountsObj.PenalityAccountName != null && accountsObj.PenalityAccountName != "" && accountsObj.PenalityAccountName != undefined) {
  6596. var selectedPenalityAcc = new Option(accountsObj.PenalityAccountName, accountsObj.PenalityAccountId, true);
  6597. $("#txtAutoComplete_PenalityAccount").append(selectedPenalityAcc);
  6598. }
  6599. if (accountsObj.TDSAccountName != null && accountsObj.TDSAccountName != "" && accountsObj.TDSAccountName != undefined) {
  6600. var selectedTDSAcc = new Option(accountsObj.TDSAccountName, accountsObj.TDSAccountId, true);
  6601. $("#txtAutoComplete_TDSAccount").append(selectedTDSAcc);
  6602. }
  6603. if (accountsObj.ForeignExchangeAccountName != null && accountsObj.ForeignExchangeAccountName != "" && accountsObj.ForeignExchangeAccountName != undefined) {
  6604. var selectedForeignExchangeAcc = new Option(accountsObj.ForeignExchangeAccountName, accountsObj.ForeignExchangeAccountId, true);
  6605. $("#txtAutoComplete_ForeignExchangeAccount").append(selectedForeignExchangeAcc);
  6606. }
  6607. }
  6608. showOrHideAccounts(discount, penality, tds) {
  6609. if (discount == 0) {
  6610. $("#div_Discount").addClass("hidden");
  6611. $("#txtAutoComplete_DiscountAccount").removeClass("required");
  6612. }
  6613. else {
  6614. $("#div_Discount").removeClass("hidden");
  6615. $("#txtAutoComplete_DiscountAccount").addClass("required");
  6616. }
  6617. if (penality == 0) {
  6618. $("#div_Penality").addClass("hidden");
  6619. $("#txtAutoComplete_PenalityAccount").removeClass("required");
  6620. }
  6621. else {
  6622. $("#div_Penality").removeClass("hidden");
  6623. $("#txtAutoComplete_PenalityAccount").addClass("required");
  6624. }
  6625. if (tds == 0) {
  6626. $("#div_TDS").addClass("hidden");
  6627. $("#txtAutoComplete_TDSAccount").removeClass("required");
  6628. }
  6629. else {
  6630. $("#div_TDS").removeClass("hidden");
  6631. $("#txtAutoComplete_TDSAccount").addClass("required");
  6632. }
  6633. }
  6634. getPaymentByRemoteId(remoteId, netTotal) {
  6635. var sum = 0;
  6636. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/payments/paymentmanager.js", function () {
  6637. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getPaymentByRemoteId(remoteId).then(function (response) {
  6638. var response = response.result;
  6639. if (response != null) {
  6640. for (var i = 0; i < response.length; i++) {
  6641. var data = response[i];
  6642. var totalAmount = data.paymentamount;
  6643. sum = sum + totalAmount;
  6644. }
  6645. var orderAmount = netTotal - sum;
  6646. if (orderAmount > 0) {
  6647. $("#txt_TotalCreditAmount").parent().addClass("floating-label-form-group-with-value");
  6648. $("#txt_TotalCreditAmount").val(orderAmount);
  6649. }
  6650. else {
  6651. $("#txt_TotalCreditAmount").parent().addClass("floating-label-form-group-with-value");
  6652. $("#txt_TotalCreditAmount").val(0);
  6653. }
  6654. }
  6655. else {
  6656. $("#txt_TotalCreditAmount").val(netTotal);
  6657. }
  6658. });
  6659. });
  6660. }
  6661. loadControlSettings(controlsettingjson, formpropertyid) {
  6662. return ``;
  6663. }
  6664. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) {
  6665. return ``;
  6666. }
  6667. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  6668. return ``;
  6669. }
  6670. static Instance() {
  6671. if (this.instance === undefined) {
  6672. this.instance = new PaymentSummary();
  6673. }
  6674. return this.instance;
  6675. }
  6676. }
  6677. Controls.PaymentSummary = PaymentSummary;
  6678. })(Controls = Transact.Controls || (Transact.Controls = {}));
  6679. })(Transact = Apps.Transact || (Apps.Transact = {}));
  6680. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  6681. })(Bizgaze || (Bizgaze = {}));