12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563 |
- var DBG = DBG || 0;
- var DBG1 = true;
- var CURRENT_DATE = CURRENT_DATE || '';
- if (!STORE_NAME) throw "Store name not defined";
- if (!global[STORE_NAME]) throw "Store not defined";
- if (!URL_TABLE_POWIAZANIA) throw "Brak URL_TABLE_POWIAZANIA";
- if (!BASE_URLS) throw "Brak BASE_URLS"
- var RECORD_MORE_FUNCTIONS_OPENED_NODE = null;
- if (!FIELD_LIST_PRACOWNICY) throw "Brak FIELD_LIST_PRACOWNICY"
- if (!FIELD_LIST_KONTRAHENCI) throw "Brak FIELD_LIST_KONTRAHENCI"
- var EXPORT_FIELDS_OD = EXPORT_FIELDS_OD || null;
- var EXPORT_FIELDS_DO = EXPORT_FIELDS_DO || null;
- var createReactClass = global.p5VendorJs.createReactClass;
- var h = global.p5VendorJs.React.createElement;
- var ReactDOM = global.p5VendorJs.ReactDOM;
- var swal = window.swal;
- var globalRaportStore = global[STORE_NAME];
- if (!p5UI__clickedOutsideElement) throw "Brak p5UI__clickedOutsideElement"
- if (!global.p5VendorJs.Unstated) throw "Brak Unstated"
- var Unstated = global.p5VendorJs.Unstated;
- var P5UI__Anton1Header = createReactClass({
- getStateFromStore: function () {
- var storeState = this.props.store.getState();
- return {
- totalOdPracownicy: storeState.totalOdPracownicy,
- totalOdPozostale: storeState.totalOdPozostale,
- totalDoKontrahenci: storeState.totalDoKontrahenci,
- totalDoPozostale: storeState.totalDoPozostale,
- depth: storeState.depth,
- onlyTargets: storeState.onlyTargets,
- title: storeState.title,
- };
- },
- getInitialState: function() {
- return this.getStateFromStore();
- },
- componentDidMount: function () {
- this.unsubscribe = this.props.store.subscribe(this.storeUpdated)
- },
- componentWillUnmount: function () {
- this.unsubscribe()
- },
- storeUpdated: function () {
- DBG && console.log('DBG::P5UI__Anton1Header::storeUpdated ', this.getStateFromStore());
- this.setState(this.getStateFromStore())
- },
- addOdPozostale: function (event) {
- // window['createPracownikAjax'](event)
- window['addPozostaleOdDo'](event)
- },
- addDoPozostale: function (event) {
- // window['createKontrahentAjax'](event)
- window['addPozostaleOdDo'](event)
- },
- clearPozostaleOd: function (event) {
- this.props.store.dispatch({ type: 'CLEAR_POZOSTALE_OD' })
- },
- clearPozostaleDo: function (event) {
- this.props.store.dispatch({ type: 'CLEAR_POZOSTALE_DO' })
- },
- handleChangeDepth: function (event) {
- var store = this.props.store;
- var depth = event.target.value;
- store.dispatch({ type: 'SET_DEPTH', depth: depth })
- },
- handleChangeSetOnlyTargetsYes: function () {
- this.props.store.dispatch({ type: 'SET_ONLY_TARGETS', onlyTargets: true })
- },
- handleChangeSetOnlyTargetsNo: function () {
- this.props.store.dispatch({ type: 'SET_ONLY_TARGETS', onlyTargets: false })
- },
- handleChangeTitle: function (event) {
- this.props.store.dispatch({ type: 'SET_TITLE', title: event.target.value })
- },
- handleRaportSubmitForm: function (event) {
- event.preventDefault();
- var self_store = this.props.store;
- var idsPracownicy = getListFromLocalStorage('Anton1.biAuditForm.pracownicyIds');
- var idsKontrahenci = getListFromLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- var pozostaleOd = getListFromLocalStorage(getSelectedListLocalStorageKey('OD'));
- var pozostaleDo = getListFromLocalStorage(getSelectedListLocalStorageKey('DO'));
- var allOdLength = idsPracownicy.length + pozostaleOd.length;
- var allDoLength = idsKontrahenci.length + pozostaleDo.length;
- var depthValue = getItemLocalStorage('Anton1.biAuditForm.depth');
- var smadReaportTitle = getItemLocalStorage('Anton1.biAuditForm.smadReaportTitle');
- var analizaOnlyTargets = getItemLocalStorage('Anton1.biAuditForm.analizaOnlyTargets');
- if ( !smadReaportTitle ) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie podano tytułu raportu' });
- return;
- }
- if ( !depthValue ) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie podano wartości dla głębokości powiązań' });
- return;
- }
- if ( !analizaOnlyTargets ) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie podano wartości czy zwracać wyniki tylko z obiektami docelowymi' });
- return;
- }
- if ( !allOdLength ) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie wybrano pozycji OD do analizy (pracownicy lub pozostałe bazy)' });
- return;
- }
- if ( !allOdLength && !allDoLength ) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie wybrano pozycji do analizy' });
- return;
- }
- // TODO: analizaOnlyTargets = ( 'y' | 'n' ) - allDoLength should depend of analizaOnlyTargets?
- // if not choise 'pracownicy' or 'kontrahenci'
- if ( !allOdLength || !allDoLength ) {
- var messageConfirm = '';
- if ( !allDoLength ) {
- messageConfirm = 'Nie wybrano podmiotów/kontrahentów! Czas przygotowania raportu może wydłużyć się ze względu na sprawdzenie powiązania ze wszystkimi podmiotami/kontrahentami w systemie. Czy jesteś pewny? ';
- }
- // show confirm window with message
- if (!confirm(messageConfirm)) return;
- }
- window.fetch(URL_GENERATE_BI_AUDIT_RAPORT_AJAX, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- pracownicyIds: idsPracownicy,
- kontrahenciIds: idsKontrahenci,
- pozostaleOd: pozostaleOd,
- pozostaleDo: pozostaleDo,
- depthValue: depthValue,
- smadReaportTitle: smadReaportTitle,
- analizaOnlyTargets: analizaOnlyTargets
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- self_store.dispatch({ type: 'CLEAR_ALL' })
- updateTopCounters();
- $('#smad-table-PRACOWNICY form').find(':checkbox').prop('checked', false);
- $('#smad-table-KONTRAHENCI form').find(':checkbox').prop('checked', false);
- $('#count-selected-item-kontrahenci').text('0');
- $('#count-selected-item-pracownicy').text('0');
- $('.bottom--message-warning-critical-search').text('');
- swal({
- title: result.msg,
- html: '<a href="' + URL_TABLE_POWIAZANIA + '" title="przejdź do raportów" >Przejdź do raportów</a>',
- allowOutsideClick: false, // TODO: btn Anuluj na dole?
- showCloseButton: true,
- confirmButtonText: 'OK',
- });
- window.setTimeout(function () {
- console.warn("URL_TABLE_POWIAZANIA:", URL_TABLE_POWIAZANIA);
- }, 100);
- window.setTimeout(function () {
- window.location.href = URL_TABLE_POWIAZANIA;
- }, 6000);
- resolve(result.msg);
- } else {
- if (result.type && result.msg) p5UI__notifyAjaxCallback(result);
- reject(result.msg);
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- });
- },
- handleAddByLastReportClick: function (event) {
- swal({
- title: "dodaj do analizy wg raportu",
- input: 'radio',
- inputOptions: {
- 'pracownicy' : "Pracownicy",
- 'kontrahenci' : "Kontrahenci",
- // 'pracownicy_pozostale' : "Pracownicy (pozostałe)",
- // 'kontrahenci_pozostale' : "Kontrahenci (pozostałe)",
- },
- inputValidator: function (value) {
- return !value && 'Proszę wybrać typ danych';
- }
- }).then(function (data) {
- handleAddToReportByPreviousReport(data.value);
- })
- // TODO: like addToReportByPreviousReport but after select report, show counters for pracow., kontr., pozostale od and do with checkbox
- // swal({
- // title: "TODO: dodaj do analizy wg raportu",
- // })
- // TODO: https://github.com/sweetalert2/sweetalert2-react-content
- // - just pass React element to 'html' ?
- },
- renderClearPozostaleOdBtn: function () {
- return h('i', {
- title: "Wyczyść pozostałe",
- className: "glyphicon glyphicon-remove",
- style: { 'font-size': '14px', 'line-height': '21px', 'margin-left': '3px', 'vertical-align': 'middle', color: "#f00", opacity: "0.5", cursor: "pointer" },
- onClick: this.clearPozostaleOd, 'line-height': '20px'
- });
- },
- renderClearPozostaleDoBtn: function () {
- return h('i', {
- title: "Wyczyść pozostałe",
- className: "glyphicon glyphicon-remove",
- style: { 'font-size': '14px', 'line-height': '21px', 'margin-left': '3px', 'vertical-align': 'middle', color: "#f00", opacity: "0.5", cursor: "pointer" },
- onClick: this.clearPozostaleDo, 'line-height': '20px'
- });
- },
- renderSummaryList: function () {
- var totalOd = this.state.totalOdPracownicy + this.state.totalOdPozostale;
- var totalDo = this.state.totalDoKontrahenci + this.state.totalDoPozostale;
- return h('ul', {}, [
- h('li', { style: { marginTop: "6px" } }, [
- h('span', {
- style: totalOd > 0 ? { color: "#d7142d" } : {}
- }, [
- " OD ",
- h('span', { className: "badge", style: totalOd > 0 ? { 'background-color': "#d7142d" } : {} }, totalOd),
- " : ",
- ]),
- h('a', { className: "btn btn-primary btn-xs", href: "#PRACOWNICY" }, [ // .bi-btn-primary
- " pracownicy ",
- h('span', { className: "badge" }, this.state.totalOdPracownicy),
- ]),
- h('i', { className: "glyphicon glyphicon-plus", style: { 'font-size': "14px", margin: "0 12px" } }),
- h('button', { className: "btn btn-primary btn-xs", onClick: this.addOdPozostale }, [ // .bi-btn-primary
- " pozostałe ",
- h('span', { className: "badge" }, this.state.totalOdPozostale),
- ]),
- (this.state.totalOdPozostale > 0) ? this.renderClearPozostaleOdBtn() : null,
- ]),
- h('li', { style: { marginTop: "6px" } }, [
- h('span', {
- style: totalDo > 0 ? { color: "#d7142d" } : {}
- }, [
- " DO ",
- h('span', { className: "badge", style: totalDo > 0 ? { 'background-color': "#d7142d" } : {} }, totalDo),
- " : ",
- ]),
- h('a', { className: "btn btn-primary btn-xs", href: "#KONTRAHENCI" }, [ // .bi-btn-primary
- " kontrahenci ",
- h('span', { className: "badge" }, this.state.totalDoKontrahenci),
- ]),
- h('i', { className: "glyphicon glyphicon-plus", style: { 'font-size': "14px", margin: "0 12px" } }),
- h('button', { className: "btn btn-primary btn-xs", onClick: this.addOdPozostale }, [ // .bi-btn-primary
- " pozostałe ",
- h('span', { className: "badge" }, this.state.totalDoPozostale),
- ]),
- (this.state.totalDoPozostale > 0) ? this.renderClearPozostaleDoBtn() : null,
- ]),
- ]);
- },
- renderRaportParamsForm: function () {
- var depth = parseInt(this.state.depth);
- var isDepthValid = ( !isNaN(depth) && depth >= 1 && depth <= 16 );
- var onlyTargets = this.state.onlyTargets;
- return h('div', {}, [
- h('div', { className: "row" + ( isDepthValid ? "" : " has-error" ), style: { 'margin-bottom': "12px" } }, [
- h('div', { className: "form-item col-md-7 col-lg-9 smad-heder-title", style: { 'font-size': "14px", 'text-align': "right", 'padding-top': "5px", 'padding-bottom': "0" } }, [
- "głębokość powiązań: ",
- ]),
- h('div', { className: "form-item col-md-5 col-lg-3" }, [
- h('input', { type: "number", className: "form-control", placeholder: "1-16", value: this.state.depth, onChange: this.handleChangeDepth, min: 1, max: 16 }),
- ]),
- ]),
- h('div', { className: "row", style: { 'margin-bottom': "12px" } }, [
- h('div', { className: "form-item col-md-7 col-lg-9 smad-heder-title", style: { 'font-size': "14px", 'text-align': "right", 'padding-top': "5px", 'padding-bottom': "0" } }, [
- "Czy zwracać wyniki tylko ze znalezionymi obiektami docelowymi (DO)? ",
- ]),
- h('div', { className: "form-item col-md-5 col-lg-3" }, [
- h('div', { className: "btn-group" }, [
- h('div', { className: "btn btn-default" + ( onlyTargets ? " active" : "" ), style: { padding: "6px 12px" }, onClick: this.handleChangeSetOnlyTargetsYes }, "TAK"),
- h('div', { className: "btn btn-default" + ( onlyTargets ? "" : " active" ), style: { padding: "6px 12px" }, onClick: this.handleChangeSetOnlyTargetsNo }, "NIE"),
- ]),
- ]),
- ]),
- h('div', { className: "row", style: { 'margin-bottom': "12px" } }, [
- h('div', { className: "form-item col-md-3 col-lg-3", style: { 'font-size': "14px", 'text-align': "right", 'padding-top': "5px", 'padding-bottom': "0" } }, [
- "Tytuł:",
- ]),
- h('div', { className: "form-item col-md-9 col-lg-9" }, [
- h('input', { type: "text", className: "form-control", placeholder: 'Raport bez tytułu z dnia ' + CURRENT_DATE, value: this.state.title, onChange: this.handleChangeTitle }),
- ]),
- ]),
- ]);
- },
- renderRaportFormSubmitBtn: function () {
- var totalOd = this.state.totalOdPracownicy + this.state.totalOdPozostale;
- var totalDo = this.state.totalDoKontrahenci + this.state.totalDoPozostale;
- var isFormValid = (totalOd || totalDo);
- return h('div', { className: "row", style: { padding: "0", 'margin-bottom': "0", 'text-align': "right" } }, [
- h('div', { className: "form-item col-md-12 col-lg-12" }, [
- h('button', {
- type: "button",
- className: "btn btn-default" + ( isFormValid ? "" : " disabled" ),
- onClick: this.handleRaportSubmitForm,
- style: { padding: "18px 42px", 'font-size': "18px", 'font-weight': "900" }
- }, "GENERUJ RAPORT POWIĄZAŃ"),
- ]),
- ]);
- },
- renderAddMoreBtns: function () {
- return h('div', {
- style: { 'padding-top': 6, 'padding-bottom': 20 }
- }, [
- h('button', { className: "btn btn-success btn-xs", onClick: this.handleAddByLastReportClick }, "dodaj do analizy wg raportu"),
- ]);
- },
- render: function () {
- DBG && console.log('DBG::P5UI__Anton1Header::render ', { state: this.state });
- var totalOd = this.state.totalOdPracownicy + this.state.totalOdPozostale;
- var totalDo = this.state.totalDoKontrahenci + this.state.totalDoPozostale;
- var depth = this.state.depth;
- var errorMsg = (depth > 16) ? "Maksymalna głębokość powiązań to 16!" : "";
- var warningMsg = ( ( !totalOd || !totalDo ) && depth > 6 ) ? "Krytyczne wielkości danych do przeszukania. Optymalna głębokość szukania powiaząń to: 6" : "";
- return h('div', { className: "container-fluid", style: { backgroundColor: "#efefef" } }, [
- h('div', { style: { fontSize: '16px', fontWeight: "normal", color: "#777" } }, [
- h('div', { className: "row" }, [
- h('div', { className: "col-md-6" }, [
- h('h3', { style: { color: "#000" } }, [
- h('span', { style: { fontSize: "120%", color: "#d7142d" } }, "|"),
- " Tworzenie nowego raportu ",
- h('br'),
- h('small', {}, [
- "(Wybierz elementy do porównania: ",
- h('span', { style: { color: "#d7142d" } }, " OD "),
- h('i', { className: "glyphicon glyphicon-random", style: { padding: '0 3px', 'font-size': "80%", color: "#000" } }),
- h('span', { style: { color: "#d7142d" } }, " DO"),
- ")",
- ])
- ]),
- "Wybrano:",
- this.renderSummaryList(),
- this.renderAddMoreBtns(),
- ]),
- h('div', { className: "col-md-6", style: { 'padding-top': "20px", 'padding-bottom': "20px" } }, [
- this.renderRaportParamsForm(),
- this.renderRaportFormSubmitBtn(),
- ]),
- ]),
- h('div', { className: "row" }, [
- h('div', { className: "col-md-8 col-md-offset-2 col-xs-12" }, [
- errorMsg ? h('div', { className: "alert alert-danger" }, errorMsg) : null,
- warningMsg ? h('div', { className: "alert alert-warning" }, warningMsg) : null,
- ]),
- ]),
- ])
- ])
- }
- })
- function getSelectedListLocalStorageKey(from) { // from: ( OD | DO )
- switch (from) {
- case 'OD': return 'Anton1.biAuditForm.odFeatureKeys';
- case 'DO': return 'Anton1.biAuditForm.doFeatureKeys';
- default: throw "Not implemented from selected list '" + from + "' - expected 'OD' or 'DO'";
- }
- }
- function getListFromLocalStorage(key) {
- return JSON.parse( localStorage.getItem(key) || '[]' );
- }
- function getSignedIntFromLocalStorage(key, defaultValue) {
- return JSON.parse( localStorage.getItem(key) || defaultValue );
- }
- function getStringFromLocalStorage(key, defaultValue) {
- var value = localStorage.getItem(key);
- value = (value) ? JSON.parse(value) : '';
- return (value) ? value : defaultValue;
- }
- // function saveToSelectedListInLocalStorage(from, featureKey) {
- // DBG && console.log("DBG::saveToSelectedListInLocalStorage(from, featureKey)", {from, featureKey}, {added: getSelectedListFromLocalStorage(from).concat(featureKey)});
- // localStorage.setItem(getSelectedListLocalStorageKey(from), JSON.stringify(
- // getSelectedListFromLocalStorage(from).concat(featureKey)
- // ))
- // }
- // function removeFromSelectedListInLocalStorage(from, featureKey) {
- // DBG && console.log("DBG::removeFromSelectedListInLocalStorage(from, featureKey)", {from, featureKey});
- // localStorage.setItem(getSelectedListLocalStorageKey(from), JSON.stringify(
- // getSelectedListFromLocalStorage(from).filter(function (item) {
- // return ( item !== featureKey );
- // })
- // ))
- // }
- /* DATA FOR READ REAPORT */
- function urlFetchKontrahenciPowiazania() {
- // Documentation: https://github.com/github/fetch
- fetch(URL_FETCH_KONTRAHENCI_POWIAZANIA, {
- credentials: 'same-origin'
- })
- .then(function parseJSON(response) {
- return response.json()
- })
- .then(function(data) {
- var reaportItemsKontrahenciPowiazani = null;
- data.body.items.forEach (function(row) {
- reaportItemsKontrahenciPowiazani += '<tr><td><input type="checkbox" name="kontrID[]" value="'+row['ID']+'" /></td>'+
- '<td align="right">'+row["ID"]+'</td>';
- });
- $( "#body-reaport-kontrahenci-powiazani-tree" ).html(reaportItemsKontrahenciPowiazani);
- }).catch(function(error) {
- if(DBG) console.log('request failed', error)
- });
- }
- /* FORM DATA FOR GENERATAE REAPORT */
- /**
- * Załadowanie wybranej pozycji w select czy zwracać wyniki tylko z obiektami docelowymi onlyTarget
- */
- function loadCurrentOnlyTargetsSelect() {
- var analizaOnlyTargets = getItemLocalStorage('Anton1.biAuditForm.analizaOnlyTargets');
- $('#smad-select-target').val(analizaOnlyTargets).attr("selected", "selected");
- $('#smad-select-target-kontrahenci').val(analizaOnlyTargets).attr("selected", "selected");
- }
- /**
- * Załadowanie do storage informacji czy zwracać wyniki tylko z obiektami docelowymi
- */
- function updateLocalStorageBiAuditOnlyTargets(idSelect) {
- $(idSelect).change(function() {
- var newValue = $(idSelect).val();
- var responseValue = newValue;
- setItemLocalStorage('Anton1.biAuditForm.analizaOnlyTargets', responseValue);
- $('#smad-select-target').val(newValue).attr("selected", "selected");
- $('#smad-select-target-kontrahenci').val(newValue).attr("selected", "selected");
- // load in select selected option
- loadCurrentOnlyTargetsSelect();
- });
- }
- /**
- * Funkcja pozwala na wyświetlenie okienka importu
- */
- function showViewUploadFile( event, headerTitle, enumType, showCheckbox, csvFileExample ) {
- event.preventDefault();
- var enumType = enumType;
- if( csvFileExample !== undefined) { // przykład + instrukcja do pobrania
- csvFileExample = '<div><a href="'+csvFileExample+'" title="Pobierz przykład" download target="_balnk">Pobierz przykład</a></div>';
- }
- swal({
- title: 'Importuj plik csv',
- input: 'file',
- html: csvFileExample,
- inputAttributes: {
- 'accept': 'text/csv',
- 'aria-label': 'Upload csv file'
- },
- confirmButtonText: 'Importuj',
- preConfirm: function (file) {
- return new Promise(function (resolve, reject) {
- if (!file) {
- reject("Proszę wybrać plik csv");
- return
- }
- var input = document.querySelector('input[type="file"]');
- var data = new FormData()
- data.append('file', input.files[0])
- data.append('showCheckbox', showCheckbox);
- var responseParseFile = parseCsvFile( data, enumType );
- resolve('file imported')
- })
- },
- }).then(function (result) {
- if(DBG) console.log('result', result);
- }).catch(function (e) {
- if(DBG) console.log('catch: ', e);
- });
- }
- /**
- * Funkcja przekazuje dane z pliku csv do przeparsowania
- */
- function parseCsvFile( fileData, enumType ) {
- event.preventDefault();
- if(DBG) console.log( 'parseCsvFile fileData', fileData);
- fetch(URL_FORM_DATA_CSV_FILE_AJAX, {
- method: 'POST',
- credentials: 'same-origin',
- body: fileData
- })
- .then(function(response) {
- return response.json()
- }).then(function(json) {
- swal({
- title: 'Dane załadowane z pliku CSV',
- html: json.body.view,
- width: Math.round(window.innerWidth * 0.9),
- allowOutsideClick: false, // TODO: btn Anuluj na dole?
- showCloseButton: true,
- confirmButtonText: 'Zapisz',
- preConfirm: function (dataForm) {
- return new Promise(function (resolve, reject) {
- if (!dataForm) {
- reject("Formularz nie zawiera danych do zapisania");
- return
- }
- // zapisanie danych
- var responseSaveData = saveFormCsvFileAjaxAction(enumType);
- resolve('data save from form')
- })
- },
- }).then(function (result) {
- if(DBG) console.log('result', result)
- }).catch(function (e) {
- if(DBG) console.log('catch: ', e)
- });
- }).catch(function(ex) {
- if(DBG) console.log('parsing failed', ex);
- });
- }
- /**
- * Funkcja zapisuje dane z formularza do wgrania pliku csv
- */
- function saveFormCsvFileAjaxAction(enumType) {
- event.preventDefault();
- var formDataFrom = $("#formDataFromCsv").serialize();
- formDataFrom = formDataFrom.replace(/%5B/g,"[");
- formDataFrom = formDataFrom.replace(/%5D/g,"]");
- fetch(URL_SAVE_FORM_CSV_FILE_AJAX, {
- method: 'POST',
- credentials: 'same-origin',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- formData: formDataFrom,
- enumType: enumType
- })
- })
- .then(function(response) {
- return response.json()
- }).then(function(json) {
- if(DBG) console.log('parsed json', json);
- if (response.type == 'success') {
- p5UI__notifyAjaxCallback(response.msg);
- }
- // return json;
- }).catch(function(ex) {
- if(DBG) console.log('parsing failed', ex);
- });
- }
- /**
- * Dodaj nowego pracownika
- */
- function createPracownikAjax(event) {
- event.preventDefault();
- swal({
- title: 'Dodaj osobę',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- html:
- '<div class="form-group">'+
- '<input class="form-control required" id="personName" placeholder="Imię" >' +
- '<input class="form-control required" id="personSurname" placeholder="Nazwisko">'+
- '<input class="form-control required" id="personNip" placeholder="NIP">'+
- '<input class="form-control required" id="personPesel" placeholder="PESEL">'+
- '<input class="form-control required" id="personRegon" placeholder="REGON">'+
- '</div>',
- preConfirm: () => {
- return new Promise(function (resolve, reject) {
- // data from form
- var personName = $('#personName').val();
- var personSurname = $('#personSurname').val();
- var personNip = $('#personNip').val();
- var personPesel = $('#personPesel').val();
- var personRegon = $('#personRegon').val();
- //validate data from input
- if (!personName){
- reject('Proszę podać imię')
- return;
- }
- if (!personSurname){
- reject('Proszę podać nazwisko')
- return;
- }
- window.fetch(URL_CREATE_PRACOWNICY, {
- method: 'POST',
- header: {
- 'contentType': 'applications/json'
- },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'personName': personName,
- 'personSurname': personSurname,
- 'personNip': personNip,
- 'personPesel': personPesel,
- 'personRegon': personRegon
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.body);
- urlFetchPracownicy(1);
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- })
- })
- },
- allowOutsideClick: false
- }).then(function (createPerson) {
- if(DBG) console.log('dodanie osoby: ', createPerson);
- });
- }
- /**
- * Dodaj nowego kontrahenta
- */
- function createKontrahentAjax(event) {
- event.preventDefault();
- swal({
- title: 'Dodaj podmiot/kontrahenta',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- html:
- '<div class="form-group">'+
- '<input class="form-control required" id="companyFullName" placeholder="Pelna nazwa" >' +
- '<input class="form-control required" id="companyShortName" placeholder="Skrócona nazwa\">'+
- '<input class="form-control required" id="companyNameGroup" placeholder="Nazwa grupy kapitałowej">'+
- '<input class="form-control required" id="companyKrs" placeholder="KRS">'+
- '<input class="form-control required" id="companyNip" placeholder="NIP">'+
- '<input class="form-control required" id="companyPesel" placeholder="PESEL">'+
- '<input class="form-control required" id="companyFax" placeholder="FAX">'+
- '<input class="form-control required" id="companyTelefon" placeholder="Telefon">'+
- '<input class="form-control required" id="companyMail" placeholder="Mail">'+
- '<input class="form-control required" id="companyStreet" placeholder="Ulica">'+
- '<input class="form-control required" id="companyNumberBuilding" placeholder="Numer budynku">'+
- '<input class="form-control required" id="companyNumberLocal" placeholder="Numer mieszkania /lokalu">'+
- '<input class="form-control required" id="companyPostCode" placeholder="Kod pocztowy">'+
- '<input class="form-control required" id="companyPlace" placeholder="Miejscowosc">'+
- '<input class="form-control required" id="companyCountry" placeholder="Kraj">'+
- '<input class="form-control required" id="companyTypeCompany" placeholder="Typ kontrahenta">'+
- '<input class="form-control required" id="companyTitleDocument" placeholder="Tytul dokumentu">'+
- '<input class="form-control required" id="companyDesc" placeholder="uwagi">'+
- '</div>',
- preConfirm: () => {
- return new Promise(function (resolve, reject) {
- // data from form
- var companyFullName = $('#companyFullName').val();
- var companyShortName = $('#companyShortName').val();
- var companyNameGroup = $('#companyNameGroup').val();
- var companyKrs = $('#companyKrs').val();
- var companyNip = $('#companyNip').val();
- var companyPesel = $('#companyPesel').val();
- var companyFax = $('#companyFax').val();
- var companyTelefon = $('#companyTelefon').val();
- var companyMail = $('#companyMail').val();
- var companyStreet = $('#companyStreet').val();
- var companyNumberBuilding = $('#companyNumberBuilding').val();
- var companyNumberLocal = $('#companyNumberLocal').val();
- var companyPostCode = $('#companyPostCode').val();
- var companyPlace = $('#companyPlace').val();
- var companyCountry = $('#companyCountry').val();
- var companyTypeCompany = $('#companyTypeCompany').val();
- var companyTitleDocument = $('#companyTitleDocument').val();
- var companyDesc = $('#companyDesc').val();
- //validate data from input
- if (!companyFullName){
- reject('Proszę podać pełną nazwę');
- return;
- }
- window.fetch(URL_CREATE_KONTRAHENCI, {
- method: 'POST',
- header: {
- 'contentType': 'applications/json'
- },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'companyFullName': companyFullName,
- 'companyShortName': companyShortName,
- 'companyNameGroup': companyNameGroup,
- 'companyKrs': companyKrs,
- 'companyNip': companyNip,
- 'companyPesel': companyPesel,
- 'companyFax': companyFax,
- 'companyTelefon': companyTelefon,
- 'companyMail': companyMail,
- 'companyStreet': companyStreet,
- 'companyNumberBuilding': companyNumberBuilding,
- 'companyNumberLocal': companyNumberLocal,
- 'companyPostCode': companyPostCode,
- 'companyPlace': companyPlace,
- 'companyCountry': companyCountry,
- 'companyTypeCompany': companyTypeCompany,
- 'companyTitleDocument': companyTitleDocument,
- 'companyDesc': companyDesc
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.body);
- urlFetchKontrahenci(1);
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- })
- })
- },
- allowOutsideClick: false
- }).then(function (createPerson) {
- if(DBG) console.log('dodanie podmiotu: ', createPerson);
- });
- }
- /**
- * Popup z opcja przeniesienia pracowników do innej grupy
- */
- function addPracownikToGroup(event) {
- event.preventDefault();
- var pracownicyIdsArray = getItemLocalStorage('Anton1.biAuditForm.pracownicyIds');
- if (pracownicyIdsArray === null || !pracownicyIdsArray || !pracownicyIdsArray.length) {
- showTextListIdPracownikow = 'nie wybrano osób';
- } else {
- showTextListIdPracownikow = '' + pracownicyIdsArray.length + ' osób';
- }
- var arrayGroupOptions = [];
- var listGroupStorage = getItemLocalStorage('Anton1.biAuditForm.pracownicy.groups');
- // utworzenie tablicy Optionsów grupy
- listGroupStorage.map(function(item) {
- if (item.ID !== undefined) {
- arrayGroupOptions[item.ID] = item.NAZWA;
- }
- });
- swal({
- title: 'Dodaj do grupy',
- input: 'select',
- text: showTextListIdPracownikow,
- inputOptions: arrayGroupOptions,
- inputPlaceholder: 'Wybierz grupę',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- preConfirm: function (idGroup) {
- if (!idGroup) {
- swal.showValidationError('Proszę wybrać nazwę grupy');
- return;
- }
- if (!pracownicyIdsArray || !pracownicyIdsArray.length) {
- swal.showValidationError('Proszę wybrać pracowników');
- return;
- }
- return new Promise(function (resolve, reject) {
- window.fetch(URL_ADD_PRACOWNICY_TO_GROUP, {
- method: 'POST',
- header: { 'contentType': 'applications/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'idGroup': idGroup,
- 'pracownicyIds': getItemLocalStorage('Anton1.biAuditForm.pracownicyIds'),
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.msg);
- } else {
- reject(result.msg);
- }
- })
- .catch(function(error) {
- if(DBG) console.warn('request failed', error);
- });
- })
- },
- allowOutsideClick: false
- }).then(function (value) {
- { // remove from selected
- setItemLocalStorage('Anton1.biAuditForm.pracownicyIds', []);
- updateCountItemCheckedByType('pracownicy');
- $('form').find(':checkbox').prop('checked', false);
- }
- }).catch(function (e) {
- DBG && console.log('DBG: e', e)
- });
- }
- function addPracownikAllToGroup(event) {
- event.preventDefault();
- var showTextListIdPracownikow = 'wszystkich pracowników pasujących do kryteriów wyszukiwania';
- var arrayGroupOptions = [];
- var listGroupStorage = getItemLocalStorage('Anton1.biAuditForm.pracownicy.groups');
- // utworzenie tablicy Optionsów grupy
- listGroupStorage.map(function(item) {
- if (item.ID !== undefined) {
- arrayGroupOptions[item.ID] = item.NAZWA;
- }
- });
- swal({
- title: 'Dodaj do grupy',
- input: 'select',
- text: showTextListIdPracownikow,
- inputOptions: arrayGroupOptions,
- inputPlaceholder: 'Wybierz grupę',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- preConfirm: function (idGroup) {
- return new Promise(function (resolve, reject) {
- if (!idGroup) {
- reject('Proszę wybrać nazwę grupy');
- return;
- }
- var filterFields = {}
- var frm = document.getElementById('filtersFieldRemoveBtn-PRACOWNICY').form
- var fieldNameList = FIELD_LIST_PRACOWNICY
- fieldNameList.filter(function (fieldName) {
- if (!frm[fieldName] && DBG) console.log('Err missing field: "'+fieldName+'"');
- return (frm[fieldName]) ? true : false
- }).map(function (fieldName) {
- return [ fieldName, frm[fieldName].value ]
- }).filter(function (filter) {
- return ( filter[1].length > 0 )
- }).map(function (filter) {
- filterFields[ filter[0] ] = filter[1]
- })
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup');
- if (filterIdGroup) filterFields[ 'filterIdGroup' ] = filterIdGroup
- window.fetch(URL_ADD_PRACOWNICY_TO_GROUP, {
- method: 'POST',
- header: {
- 'contentType': 'applications/json'
- },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'idGroup': idGroup,
- 'type': 'filter',
- 'filter': filterFields,
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.msg);
- } else {
- reject(result.msg);
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- });
- })
- },
- allowOutsideClick: false
- }).then(function (groupPracownicyData) {
- //TODO: pIOTRKU CZY TU POWINIENEM COŚ JESZCZE OBSŁUŻYĆ
- });
- }
- /**
- * Popup z opcja przeniesienia kontrahentów do innej grupy
- */
- function addKontrahenciToGroup(event) {
- event.preventDefault();
- var kontrahenciIdsArray = getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- if (kontrahenciIdsArray === null || !kontrahenciIdsArray || !kontrahenciIdsArray.length) {
- showTextListIdKontrahentow = 'nie wybrano kontrahentów';
- } else {
- showTextListIdKontrahentow = '' + kontrahenciIdsArray.length + ' podmiotów/kontrahentów';
- }
- var arrayGroupOptions = [];
- var listGroupStorage = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.groups');
- // utworzenie tablicy Optionsów grupy
- listGroupStorage.map(function(item) {
- if (item.ID !== undefined) {
- arrayGroupOptions[item.ID] = item.NAZWA;
- }
- });
- swal({
- title: 'Dodaj do grupy',
- input: 'select',
- text: showTextListIdKontrahentow,
- inputOptions: arrayGroupOptions,
- inputPlaceholder: 'Wybierz grupę',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- preConfirm: function (idGroup) {
- if (!idGroup) {
- swal.showValidationError('Proszę wybrać nazwę grupy');
- return;
- }
- if (!kontrahenciIdsArray || !kontrahenciIdsArray.length) {
- swal.showValidationError('Proszę wybrać kontrahentów');
- return;
- }
- return new Promise(function (resolve, reject) {
- window.fetch(URL_ADD_KONTRAHENCI_TO_GROUP, {
- method: 'POST',
- header: { 'contentType': 'applications/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'idGroup': idGroup,
- 'kontrahenciIds': getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds'),
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.msg);
- } else {
- reject(result.msg);
- }
- })
- .catch(function(error) {
- if(DBG) console.warn('request failed', error);
- });
- })
- },
- allowOutsideClick: false
- }).then(function (value) {
- { // remove from selected
- setItemLocalStorage('Anton1.biAuditForm.kontrahenciIds', []);
- updateCountItemCheckedByType('kontrahenci');
- $('form').find(':checkbox').prop('checked', false);
- }
- }).catch(function (e) {
- DBG && console.log('DBG: e', e)
- });
- }
- function addKontrahenciAllToGroup(event) {
- event.preventDefault();
- var kontrahenciIdsArray = getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- var showTextListIdKontrahentow = 'wszystkich podmotów/kontrahentów pasujących do kryteriów wyszukiwania';
- var arrayGroupOptions = [];
- var listGroupStorage = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.groups');
- // utworzenie tablicy Optionsów grupy
- listGroupStorage.map(function(item) {
- if (item.ID !== undefined) {
- arrayGroupOptions[item.ID] = item.NAZWA;
- }
- });
- swal({
- title: 'Dodaj do grupy',
- input: 'select',
- text: showTextListIdKontrahentow,
- inputOptions: arrayGroupOptions,
- inputPlaceholder: 'Wybierz grupę',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- preConfirm: function (idGroup) {
- return new Promise(function (resolve, reject) {
- if (!idGroup) {
- reject('Proszę wybrać nazwę grupy');
- return;
- }
- var filterFields = {}
- var frm = document.getElementById('filtersFieldRemoveBtn-KONTRAHENCI').form
- var fieldNameList = FIELD_LIST_KONTRAHENCI
- fieldNameList.filter(function (fieldName) {
- if (!frm[fieldName] && DBG) console.log('Err missing field: "'+fieldName+'"')
- return (frm[fieldName]) ? true : false
- }).map(function (fieldName) {
- return [ fieldName, frm[fieldName].value ]
- }).filter(function (filter) {
- return ( filter[1].length > 0 )
- }).map(function (filter) {
- filterFields[ filter[0] ] = filter[1]
- })
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup');
- if (filterIdGroup) filterFields[ 'filterIdGroup' ] = filterIdGroup
- window.fetch(URL_ADD_KONTRAHENCI_TO_GROUP, {
- method: 'POST',
- header: {
- 'contentType': 'applications/json'
- },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'idGroup': idGroup,
- 'type': 'filter',
- 'filter': filterFields,
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- $('#smad-table-PRACOWNICY form').find(':checkbox').prop('checked', false);
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.msg);
- } else {
- reject(result.msg);
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- });
- })
- },
- allowOutsideClick: false
- });
- }
- function removeKontrahenciFromGroup(event) {
- event.preventDefault;
- var kontrahenciIdsArray = getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- if (kontrahenciIdsArray === null || !kontrahenciIdsArray || !kontrahenciIdsArray.length) {
- showTextListIdKontrahentow = 'nie wybrano kontrahentów';
- } else {
- showTextListIdKontrahentow = '' + kontrahenciIdsArray.length + ' podmiotów/kontrahentów';
- }
- var groupId = getItemLocalStorage("Anton1.biAuditForm.kontrahenci.filterIdGroup");
- var removeTitle = "Czy chcesz usunąć z "
- if (groupId === "0") {
- removeTitle += "systemu";
- } else {
- var arrayGroupOptions = [];
- var listGroupStorage = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.groups');
- // utworzenie tablicy Optionsów grupy
- listGroupStorage.map(function(item) {
- if (item.ID !== undefined) {
- arrayGroupOptions[item.ID] = item.NAZWA;
- }
- });
- removeTitle += "grupy ";
- removeTitle += arrayGroupOptions[groupId];
- }
- swal({
- title: removeTitle,
- text: showTextListIdKontrahentow,
- showConfirmButton: true,
- showCancelButton: true,
- confirmButtonText: 'Usuń',
- cancelButtonText: 'Anuluj',
- showLoaderOnConfirm: true,
- preConfirm: function () {
- return new Promise(function (resolve, reject) {
- if (!kontrahenciIdsArray || !kontrahenciIdsArray.length) {
- reject('Wybierz kontrahentów');
- return;
- }
- window.fetch(URL_REMOVE_KONTRAHENCI_FROM_GROUP, {
- method: 'POST',
- header: { 'contentType': 'applications/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'idGroup': getItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup'),
- 'kontrahenciIds': getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds'),
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- result
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- updateTopCounters();
- $('#smad-table-KONTRAHENCI form').find(':checkbox').prop('checked', false);
- resolve(result.msg);
- } else {
- reject(result.msg);
- }
- })
- })
- },
- allowOutsideClick: false
- }).then((result) => {
- if (!result) return;
- if (result.dismiss) return;
- if (!result.value) return;
- { // remove from selected
- setItemLocalStorage('Anton1.biAuditForm.kontrahenciIds', []);
- updateCountItemCheckedByType('kontrahenci');
- $('#smad-table-KONTRAHENCI form').find(':checkbox').prop('checked', false);
- }
- urlFetchKontrahenci(1);
- });
- }
- function removePracownikFromGroup(event){
- event.preventDefault;
- var pracownicyIdsArray = getItemLocalStorage('Anton1.biAuditForm.pracownicyIds');
- if (pracownicyIdsArray === null || !pracownicyIdsArray || !pracownicyIdsArray.length) {
- showTextListIdPracownikow = 'nie wybrano osób';
- } else {
- showTextListIdPracownikow = '' + pracownicyIdsArray.length + ' osób';
- }
- var groupId = getItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup');
- var removeTitle = "Czy chcesz usunąć z "
- if (!groupId) {
- removeTitle += "systemu";
- } else {
- var arrayGroupOptions = [];
- var listGroupStorage = getItemLocalStorage('Anton1.biAuditForm.pracownicy.groups');
- // utworzenie tablicy Optionsów grupy
- listGroupStorage.map(function(item) {
- if (item.ID !== undefined) {
- arrayGroupOptions[item.ID] = item.NAZWA;
- }
- });
- removeTitle += "grupy ";
- removeTitle += arrayGroupOptions[groupId];
- }
- swal({
- title: removeTitle,
- text: showTextListIdPracownikow,
- showConfirmButton: true,
- showCancelButton: true,
- confirmButtonText: 'Usuń',
- cancelButtonText: 'Anuluj',
- showLoaderOnConfirm: true,
- preConfirm: function () {
- return new Promise(function (resolve, reject) {
- if (!pracownicyIdsArray || !pracownicyIdsArray.length) {
- reject('Wybierz osoby');
- return;
- }
- window.fetch(URL_REMOVE_PRACOWNICY_FROM_GROUP, {
- method: 'POST',
- header: { 'contentType': 'applications/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'idGroup': getItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup'),
- 'pracownicyIds': getItemLocalStorage('Anton1.biAuditForm.pracownicyIds'),
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- updateTopCounters();
- $('#smad-table-PRACOWNICY form').find(':checkbox').prop('checked', false);
- resolve(result.msg);
- } else {
- reject(result.msg);
- }
- })
- })
- },
- allowOutsideClick: false
- }).then((result) => {
- if (!result) return;
- if (result.dismiss) return;
- if (!result.value) return;
- { // remove from selected
- setItemLocalStorage('Anton1.biAuditForm.pracownicyIds', []);
- updateCountItemCheckedByType('pracownicy');
- $('#smad-table-PRACOWNICY form').find(':checkbox').prop('checked', false);
- }
- urlFetchPracownicy(1);
- });
- }
- function createGroupKontrahenci(event) {
- event.preventDefault();
- swal({
- title: 'Utwórz grupę',
- input: 'text',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- preConfirm: function (NAZWA) {
- return new Promise(function (resolve, reject) {
- if (!NAZWA) {
- reject('Proszę podać nazwę grupy');
- return;
- }
- window.fetch(URL_CREATE_PRACOWNICY_GROUP, {
- method: 'POST',
- header: { 'contentType': 'applications/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'NAZWA': NAZWA
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.body);
- } else {
- reject("Proszę podać inną nazwę grupy");
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- })
- })
- },
- allowOutsideClick: false
- }).then(function (result) {
- if (!result) return;
- if (result.dismiss) return;
- if (!result.value) return;
- // NOTE: swal has input, so resolver object from preConfirm is in { value: resolvedObject }
- var addedGroup = result.value;
- if (addedGroup.id && addedGroup.nazwa) {
- $('#group-kontrahenci').append('<button class="btn btn-default" title="'+addedGroup['nazwa']+'" data-group-filter="'+addedGroup['id']+'">'+addedGroup['nazwa']+'</button>');
- { // add group to local storage
- setItemLocalStorage(
- 'Anton1.biAuditForm.kontrahenci.groups',
- [].concat(
- getItemLocalStorage('Anton1.biAuditForm.kontrahenci.groups') || [],
- [ { 'ID': addedGroup.id, 'NAZWA': addedGroup.nazwa } ]
- )
- );
- }
- }
- //TODO: aktualizacja fitrów na widoku -> SPrawdzić co dostaniemy w odpowiedzi po dodaniu filtra grupy
- });
- }
- function createGroupPracownicy(event) {
- event.preventDefault();
- swal({
- title: 'Utwórz grupę',
- input: 'text',
- showCancelButton: true,
- confirmButtonText: 'Zapisz',
- showLoaderOnConfirm: true,
- preConfirm: function (NAZWA) {
- return new Promise(function (resolve, reject) {
- if (!NAZWA) {
- reject('Proszę podać nazwę grupy');
- return;
- }
- window.fetch(URL_CREATE_PRACOWNICY_GROUP, {
- method: 'POST',
- header: { 'contentType': 'applications/json' },
- credentials: 'same-origin',
- body: JSON.stringify({
- 'NAZWA': NAZWA
- })
- })
- .then(function(response) {
- return response.text();
- })
- .then(function(responseText) {
- try {
- return JSON.parse(responseText);
- } catch (e) {
- throw responseText;
- }
- })
- .then(function(result) {
- console.warn('DBG group added? result', result)
- if (result.type == 'success') {
- p5UI__notifyAjaxCallback(result);
- resolve(result.body);
- } else {
- reject("Proszę podać inną nazwę grupy");
- }
- })
- .catch(function(error) {
- if(DBG) console.log('request failed', error);
- })
- })
- },
- allowOutsideClick: false
- }).then(function (result) {
- if (!result) return;
- if (result.dismiss) return;
- if (!result.value) return;
- // NOTE: swal has input, so resolver object from preConfirm is in { value: resolvedObject }
- var addedGroup = result.value;
- if (addedGroup.id && addedGroup.nazwa) {
- $('#group-pracownicy').append('<button class="btn btn-default" title="'+addedGroup['nazwa']+'" data-group-filter="'+addedGroup['id']+'">'+addedGroup['nazwa']+'</button>');
- { // add group to local storage
- setItemLocalStorage(
- 'Anton1.biAuditForm.pracownicy.groups',
- [].concat(
- getItemLocalStorage('Anton1.biAuditForm.pracownicy.groups') || [],
- [ { 'ID': addedGroup.id, 'NAZWA': addedGroup.nazwa } ]
- )
- );
- }
- }
- //TODO: aktualizacja fitrów na widoku -> SPrawdzić co dostaniemy w odpowiedzi po dodaniu filtra grupy
- });
- }
- /**
- * Function for load view Form pracownicy/kontrahenci
- */
- function rootChangeForm() {
- //todo: do przeniesienia
- urlFetchKontrahenciPowiazania();
- var valueUrl = global.location.hash;
- switch (valueUrl) {
- case '#KONTRAHENCI':
- $( ".container-bi_audit_form_kontrahenci_raport" ).html( VIEW_KONTRAHENCI );
- urlFetchKontrahenci(1);
- fetchGroupKontrahenci();
- $( ".container-bi_audit_form_pracownicy_raport" ).hide();
- $( ".container-bi_audit_form_kontrahenci_raport" ).show();
- $(".container-bi-audit_form_operacyjna_baza_zgloszen").hide();
- //parseGraph();
- break;
- case '#PRACOWNICY':
- $( ".container-bi_audit_form_pracownicy_raport" ).html( VIEW_PRACOWNICY );
- urlFetchPracownicy(1);
- fetchGroupPracownicy();
- $( ".container-bi_audit_form_kontrahenci_raport" ).hide();
- $( ".container-bi_audit_form_pracownicy_raport" ).show();
- $(".container-bi-audit_form_operacyjna_baza_zgloszen").hide();
- break;
- case '#OPERACYJNA_BAZA_ZGLOSZEN':
- $( ".container-bi_audit_form_operacyjna_baza_zgloszen" ).html( OPERACYJNA_BAZA_ZGLOSZEN );
- // urlFetchPracownicy(1);
- // fetchGroupPracownicy();
- $( ".container-bi_audit_form_kontrahenci_raport" ).hide();
- $( ".container-bi_audit_form_pracownicy_raport" ).hide();
- $(".container-bi-audit_form_operacyjna_baza_zgloszen").show();
- break;
- // case '#REAPORT':
- // $( ".container-bi_audit_form_raport_data" ).html( VIEW_TREE_REAPORT );
- // urlFetchKontrahenciPowiazania();
- // $( ".container-bi_audit_form_kontrahenci_raport" ).hide();
- // $( ".container-bi_audit_form_pracownicy_raport" ).hide();
- // $( ".container-bi_audit_form_raport_data" ).show();
- // break;
- default:
- $( ".container-bi_audit_form_pracownicy_raport" ).html( VIEW_PRACOWNICY );
- urlFetchPracownicy(1);
- fetchGroupPracownicy();
- $( ".container-bi_audit_form_kontrahenci_raport" ).hide();
- $( ".container-training" ).hide();
- $( ".container-about" ).hide();
- $( ".container-bi_audit_form_pracownicy_raport" ).show();
- break;
- }
- // aktualizacja select option czy zwracać wyniki tylko z obiektami docelowymi
- updateLocalStorageBiAuditOnlyTargets('#smad-select-target');
- updateLocalStorageBiAuditOnlyTargets('#smad-select-target-kontrahenci');
- // load in select selected option BI_analiza_onlyTargets
- loadCurrentOnlyTargetsSelect();
- }
- function getAddressData(objectValue) {
- var objectValue = objectValue || [];
- var listData = '';
- if (!objectValue) {
- return true;
- }
- objectValue.forEach (function(item) {
- if (item['kodPocztowy']) { listData += '<div>kod pocztowy: ' + item['kodPocztowy'] + '<div>'; }
- if (item['miejscowosc']) { listData += '<div>miejscowość: ' + item['miejscowosc'] + '<div>'; }
- if (item['nrBudynku']) { listData += '<div>nr budynku: ' + item['nrBudynku'] + '<div>'; }
- if (item['nrLokalu']) { listData += '<div>nr lokalu: ' + item['nrLokalu'] + '<div>'; }
- if (item['typAdresu']) { listData += '<div>typ adresu: ' + item['typAdresu'] + '<div>'; }
- if (item['ulica']) { listData += '<div>ulica: ' + item['ulica'] + '<div>'; }
- listData += '<div>------<div>';
- });
- return listData;
- }
- /**
- * Get name name group
- */
- function getNameGroupById(store, filterIdGroup) {
- var NAZWA = '';
- if (!store || filterIdGroup === 0 ) {
- NAZWA = 'Wszyscy';
- } else {
- $(store).each(function() {
- if ( parseInt(filterIdGroup) === parseInt(this.ID) ) {
- NAZWA = this.NAZWA;
- }
- });
- }
- return NAZWA;
- }
- function getSearchParamsKontrahenci(page) {
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup');
- var frm = document.getElementById('filtersFieldRemoveBtn-KONTRAHENCI').form
- var fieldNameList = FIELD_LIST_KONTRAHENCI
- var filterFields = fieldNameList.filter(function (fieldName) {
- if (!frm[fieldName] && DBG) console.log('Err missing field: "' + fieldName + '"')
- return (frm[fieldName]) ? true : false
- }).map(function (fieldName) {
- return [fieldName, frm[fieldName].value]
- }).filter(function (filter) {
- return (filter[1].length > 0)
- }).map(function (filter) {
- return '' + filter[0] + '=' + filter[1]
- }).join('&')
- return {
- page: page,
- filterIdGroup: filterIdGroup,
- filterFields: (filterFields.length > 0) ? filterFields : null,
- };
- }
- function getUrlFetchKontrahenci(page) {
- // return URL_FETCH_PRACOWNICY + '&page=' + page + '&filterIdGroup=' + filterIdGroup + filterFields;
- var searchParams = getSearchParamsKontrahenci(page);
- return [
- URL_FETCH_KONTRAHENCI,
- 'page=' + searchParams.page,
- 'filterIdGroup=' + searchParams.filterIdGroup,
- searchParams.filterFields,
- ].filter(Boolean).join('&');
- }
- function urlFetchKontrahenci(page) {
- hideMoreRecordFunctionsPopover()
- var page = page || getItemLocalStorage('Anton1.biAuditForm.kontrahenci.pagination.page');
- selectPage('KONTRAHENCI', page);
- if ( page === 1) {
- setItemLocalStorage('Anton1.biAuditForm.kontrahenci.pagination.page', 1);
- }
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup');
- var frm = document.getElementById('filtersFieldRemoveBtn-KONTRAHENCI').form
- var fieldNameList = FIELD_LIST_KONTRAHENCI
- var filterFields = fieldNameList.map(function (fieldName) {
- return [ fieldName, frm[fieldName].value ]
- }).filter(function (filter) {
- return ( filter[1].length > 0 )
- }).map(function (filter) {
- return '' + filter[0] + '=' + filter[1]
- }).join('&')
- filterFields = (filterFields.length > 0) ? '&' + filterFields : ''
- fetch(URL_FETCH_KONTRAHENCI + '&page=' + page + '&filterIdGroup=' + filterIdGroup + filterFields, {
- credentials: 'same-origin'
- })
- .then(function parseJSON(response) {
- return response.json()
- var filterIdGroup = filterIdGroup || getItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup');
- })
- .then(function(data) {
- var listItemsKontrahenci = null;
- data.body.items.forEach (function(row) {
- listItemsKontrahenci += '<tr><td style="white-space:nowrap">' +
- '<input style="vertical-align:top" type="checkbox" name="kontrID[]" value="'+row['ID']+'" />' +
- '<i onClick="kontrahenciLoadMoreRecordFunctions(event, this, '+row['ID']+')" style="margin-left:6px; cursor:pointer; color:#333" class="glyphicon glyphicon-menu-hamburger" title="Więcej funkcji dla rekordu nr ' + row['ID'] + '"></i>' +
- '</td>' +
- '<td align="right">'+row["ID"]+'</td>'+
- '<td align="right">' + ( row["Nazwa_grupy_kapitalowej"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Pelna_nazwa_kontrahenta"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Numer_kontrahenta"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Skrocona_Nazwa_Kontrahenta"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Typ_kontrahenta"] || '' ) + '</td>' +
- '<td align="right">' + ( row["NIP"] || '' ) + '</td>' +
- '<td align="right">' + ( row["KRS"] || '' ) + '</td>' +
- '<td align="right">' + ( row["REGON"] || '' ) + '</td>' +
- '<td align="right">' + ( row["PESEL"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Forma_prawna_dzialalnosci"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Ulica"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Numer_budynku"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Numer_mieszkania_lokalu"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Miejscowosc"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Kod_pocztowy"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Kraj"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Telefon"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Fax"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Mail"] || '' ) + '</td>' +
- '<td align="right">' + ( row["A_ADM_COMPANY"] || '' ) + '</td>' +
- '<td align="right">' + ( row["A_CLASSIFIED"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Dodano"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Podmiot_dominujacy"] || '' ) + '</td>' +
- '<td align="right">' + ( row["Tytul_dokumentu"] || '' ) + '</td>' +
- '<td align="right">' + ( row["ownCompany"] || '' ) + '</td>' +
- '<td align="right">' + ( row["uwagi"] || '' ) + '</td></tr>';
- });
- if (data.body.pagination !== undefined) {
- Pagination.Init(document.getElementById('pagination-kontrahenci'), {
- url: BASE_URLS+'index.php?_route=UrlAction_Anton1#KONTRAHENCI',
- id_pagination: 'pagination-kontrahenci',
- type: 'KONTRAHENCI',
- limit: data.body.pagination.limit,
- total_items: data.body.pagination.total_items, // pages size
- size: data.body.pagination.size, // pages size
- page: page, // selected page
- step: 1 // pages before and after current
- });
- var paginationShowNextCount = 1;
- if ( parseInt(data.body.pagination.current) !== 1) {
- paginationShowNextCount = parseInt(data.body.pagination.limit) * (parseInt(data.body.pagination.current) - 1 ) + 1;
- }
- $('#paginationShowNextCount-KONTRAHENCI').text(paginationShowNextCount);
- $('#smad-filter-desc-kontrahenci').text(data.body.pagination.total_items);
- if (data.body.pagination.total_items > 0) {
- var btnAddAll = $('<button class="btn btn-primary" style="padding:1px 5px; margin-left:12px">DODAJ WSZYSTKIE DO ANALIZY</button>');
- btnAddAll.on('click', { type: 'kontrahenci', pagination: data.body.pagination }, addAllMatchesToReport);
- $('#smad-filter-desc-kontrahenci').append(btnAddAll);
- // var btnAddByReport = $('<button class="btn btn-primary" style="padding:1px 5px; margin-left:12px">DODAJ DO ANALIZY WG RAPORTU</button>');
- // btnAddByReport.on('click', { type: 'kontrahenci', pagination: data.body.pagination }, addToReportByPreviousReport);
- // $('#smad-filter-desc-kontrahenci').append(btnAddByReport);
- var btnAddAllToGroup = $('<button class="btn btn-info" style="padding:1px 5px; margin-left:12px">DODAJ WSZYSTKIE DO GRUPY</button>');
- btnAddAllToGroup.on('click', addKontrahenciAllToGroup);
- $('#smad-filter-desc-kontrahenci').append(btnAddAllToGroup);
- }
- }
- var groupSelectData = getNameGroupById(getItemLocalStorage('Anton1.biAuditForm.kontrahenci.groups'), filterIdGroup);
- $('#smad-filter-head-title-kontrahenci').text(groupSelectData);
- if(DBG) console.log('kontrahenci groupSelectData: ', groupSelectData);
- $( "#body-kontrahenci" ).html(listItemsKontrahenci);
- checkAll('KONTRAHENCI');
- catchEventCheckbox('KONTRAHENCI');
- checkedChoiseItems('KONTRAHENCI', getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds') );
- // $( ".container-bi_audit_raport" ).append( data.body.view );
- if(DBG) console.log('request succeeded with JSON responseKontrahenci', data)
- updateTopCounters();
- }).catch(function(error) {
- if(DBG) console.log('request failed', error);
- })
- }
- function getSearchParamsPracownicy(page) {
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup');
- var frm = document.getElementById('filtersFieldRemoveBtn-PRACOWNICY').form
- var fieldNameList = FIELD_LIST_PRACOWNICY
- var filterFields = fieldNameList.filter(function (fieldName) {
- if (!frm[fieldName] && DBG) console.log('Err missing field: "' + fieldName + '"')
- return (frm[fieldName]) ? true : false
- }).map(function (fieldName) {
- return [fieldName, frm[fieldName].value]
- }).filter(function (filter) {
- return (filter[1].length > 0)
- }).map(function (filter) {
- return '' + filter[0] + '=' + filter[1]
- }).join('&')
- return {
- page: page,
- filterIdGroup: filterIdGroup,
- filterFields: (filterFields.length > 0) ? filterFields : null,
- };
- }
- function getUrlFetchPracownicy(page) {
- // return URL_FETCH_PRACOWNICY + '&page=' + page + '&filterIdGroup=' + filterIdGroup + filterFields;
- var searchParams = getSearchParamsPracownicy(page);
- return [
- URL_FETCH_PRACOWNICY,
- 'page=' + searchParams.page,
- 'filterIdGroup=' + searchParams.filterIdGroup,
- searchParams.filterFields,
- ].filter(Boolean).join('&');
- }
- function urlFetchPracownicy(page) {
- hideMoreRecordFunctionsPopover()
- var page = page || getItemLocalStorage('Anton1.biAuditForm.pracownicy.pagination.page');
- if ( page === 1) {
- setItemLocalStorage('Anton1.biAuditForm.pracownicy.pagination.page', 1);
- }
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup');
- selectPage('PRACOWNICY', page);
- // var paginationLimit = 20;
- /*p5WFS_GetFeature('default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
- Object.assign({
- sortBy: 'ID+D',
- maxFeatures: paginationLimit,
- startIndex: (page - 1) * paginationLimit,
- // TODO: backRefNS, backRefPK, backRefField - TODO: from groups
- // resolve: 'all',
- // resolveDepth: 2
- 'ogc:Filter': '<wfs:Query>' + '\n' + [
- '*',
- 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*',
- [
- 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
- 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
- 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
- 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI'
- ].join('/')
- ].map(function (fieldName) {
- return '<wfs:PropertyName>' + fieldName + '</wfs:PropertyName>';
- }).join('\n') + '\n' + '</wfs:Query>'
- }, (filterIdGroup > 0)
- ? {
- backRefNS: 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
- backRefPK: filterIdGroup,
- backRefField: 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
- }
- : {}
- )
- ).then(function (items) {
- if(DBG)console.log('p5WFS_GetFeature: items: ', items);
- }).catch(function (err) {
- if(DBG)console.log('p5WFS_GetFeature: err: ', err);
- })*/
- var fetchUrl = getUrlFetchPracownicy(page);
- DBG && console.log('DBG: fetch ', { fetchUrl });
- fetch(fetchUrl, {
- credentials: 'same-origin'
- })
- .then(function parseJSON(response) {
- return response.json()
- })
- .then(function(data) {
- var addresPerson = '';
- var listItemsPracownik = null;
- if(DBG) console.log('urlFetchPracownicy', data.body.items);
- data.body.items.forEach (function(row) {
- if (row["default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy"]) {
- addresPerson = getAddressData(row["default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy"]);
- }
- listItemsPracownik += '<tr><td style="white-space:nowrap">' +
- '<input style="vertical-align:top" type="checkbox" name="prID[]" value="'+row['ID']+'" />' +
- '<i onClick="pracownicyLoadMoreRecordFunctions(event, this, '+row['ID']+')" style="margin-left:6px; cursor:pointer; color:#333" class="glyphicon glyphicon-menu-hamburger" title="Więcej funkcji dla rekordu nr ' + row['ID'] + '"></i>' +
- '</td>' +
- '<td align="right">'+row["ID"]+'</td>' +
- '<td align="right">' + ( row["imiona"] || '' ) + '</td>' +
- '<td align="right">' + ( row["nazwisko"] || '' ) + '</td>' +
- '<td align="right">' + ( row["nip"] || '' ) + '</td>' +
- '<td align="right">' + ( row["pesel"] || '' ) + '</td>' +
- '<td align="right">' + ( row["regon"] || '' ) + '</td>' +
- '<td align="right">' + ( row["source"] || '' ) + '</td>' +
- '<td align="right">' + ( row["jednostka_organizacyjna"] || '' ) + '</td>' +
- '<td align="right">' + ( row["A_STATUS"] || '' ) + '</td>' +
- '<td align="right">' + ( row["A_STATUS_INFO"] || '' ) + '</td>' +
- '<td align="right">' + ( row["L_APPOITMENT_USER"] || '' ) + '</td>' +
- '<td align="right">'+ addresPerson +'</td></tr>';
- });
- if (data.body.pagination.size) {
- Pagination.Init(document.getElementById('pagination-pracownicy'), {
- url: BASE_URLS+'index.php?_route=UrlAction_Anton1#PRACOWNICY',
- id_pagination: 'pagination-pracownicy',
- type: 'PRACOWNICY',
- limit: data.body.pagination.limit,
- total_items: data.body.pagination.total_items, // pages size
- size: data.body.pagination.size, // pages size
- page: data.body.pagination.current, // selected page
- step: 1 // pages before and after current
- });
- var paginationShowNextCount = 1;
- if ( parseInt(data.body.pagination.current) !== 1) {
- paginationShowNextCount = parseInt(data.body.pagination.limit) * (parseInt(data.body.pagination.current) - 1 ) + 1;
- }
- $('#paginationShowNextCount-PRACOWNICY').text(paginationShowNextCount);
- $('#smad-filter-desc-pracownicy').text(data.body.pagination.total_items);
- if (data.body.pagination.total_items > 0) {
- var btnAddAll = $('<button class="btn btn-primary" style="padding:1px 5px; margin-left:12px">DODAJ WSZYSTKIE DO ANALIZY</button>')
- btnAddAll.on('click', { type: 'pracownicy', pagination: data.body.pagination }, addAllMatchesToReport);
- $('#smad-filter-desc-pracownicy').append(btnAddAll);
- // var btnAddByReport = $('<button class="btn btn-primary" style="padding:1px 5px; margin-left:12px">DODAJ DO ANALIZY WG RAPORTU</button>');
- // btnAddByReport.on('click', { type: 'pracownicy', pagination: data.body.pagination }, addToReportByPreviousReport);
- // $('#smad-filter-desc-pracownicy').append(btnAddByReport);
- var btnAddAllToGroup = $('<button class="btn btn-info" style="padding:1px 5px; margin-left:12px">DODAJ WSZYSTKIE DO GRUPY</button>');
- btnAddAllToGroup.on('click', addPracownikAllToGroup);
- $('#smad-filter-desc-kontrahenci').append(btnAddAllToGroup);
- }
- }
- // wyświetlenie wybranej grupy w naglówku nad tabela
- var groupSelectData = getNameGroupById(getItemLocalStorage('Anton1.biAuditForm.pracownicy.groups'), filterIdGroup);
- $('#smad-filter-head-title-pracownicy').text(groupSelectData);
- // zaladaowanie listy pracowników
- $( "#body-pracownicy" ).html( listItemsPracownik);
- checkAll('PRACOWNICY');
- catchEventCheckbox('PRACOWNICY');
- checkedChoiseItems('PRACOWNICY', getItemLocalStorage('Anton1.biAuditForm.pracownicyIds') );
- updateTopCounters();
- }).catch(function(error) {
- if(DBG) console.log('request failed', error)
- })
- }
- function selectPage(type, nrPage) {
- var type = type.toLowerCase();
- $('#pagination-' + type + ' ul li a').each(function(index, value){
- if (this.text === nrPage) {
- $(this).addClass('active');
- } else {
- $(this).removeClass('active');
- }
- });
- }
- function checkAll(type) {
- $('#checkAll-' + type).change(function() {
- var valueCheckbox = null;
- var checkboxes = $('form').find(':checkbox');
- if($(this).prop('checked')) {
- checkboxes.prop('checked', true);
- //valueCheckbox = checkboxes.prop("checked");
- var allValsChecked = [];
- var checkedValues = $('#smad-table-' + type + ' input:checkbox:checked').map(function() {
- if (this.value !== 'on') {
- allValsChecked.push(parseInt(this.value));
- }
- }).get();
- updateListIdBiAuditReaport(type, allValsChecked);
- } else {
- checkboxes.prop('checked', false);
- var allValsUnChecked = [];
- var checkedValues = $('#smad-table-' + type + ' input:checkbox:not(:checked)').map(function() {
- if (this.value !== 'on') {
- allValsUnChecked.push(parseInt(this.value));
- }
- }).get();
- deleteListIdBiAuditReaport(type, allValsUnChecked);
- }
- // update count selected IDs
- updateCountItemCheckedByType(type.toLowerCase());
- });
- }
- /**
- * Select again checkbox before selected item chekbox from storage (pracownicy/kontrahenci)
- */
- function checkedChoiseItems(type, store) {
- updateCountItemCheckedByType(type.toLowerCase());
- var idElement = 'smad-table-' + type;
- // if id element exist
- if (document.getElementById(idElement)) {
- // if not checked
- if (!store) {
- return false;
- }
- // checked again if user selected Item (pracownicy/kontrahent)
- for (i = 0; i < store.length; i++) {
- $('#body-'+type.toLowerCase() +' input[type=checkbox] ').map(function(k, v) {
- if ( store[i] === parseInt(this.value) ){
- $(this).prop('checked', true);
- }
- }).get();
- }
- }
- $('#smad-table-' + type + ' input[type=checkbox]').on( 'load', function() {
- var itemsCHecked = getItemLocalStorage('Anton1.biAuditForm.pracownicyIds');
- getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- if (itemsCHecked.lenght === 0 ) {
- return;
- }
- var valueCheckbox = null;
- var checkboxes = $('form').find(':checkbox');
- if($(this).prop('checked')) {
- checkboxes.prop('checked', true);
- var allValsChecked = [];
- var checkedValues = $('#smad-table-' + type + ' input:checkbox:checked').map(function() {
- if (this.value !== 'on') {
- allValsChecked.push(parseInt(this.value));
- }
- }).get();
- updateListIdBiAuditReaport(type, allValsChecked);
- } else {
- checkboxes.prop('checked', false);
- var allValsUnChecked = [];
- var checkedValues = $('#smad-table-' + type + ' input:checkbox:not(:checked)').map(function() {
- if (this.value !== 'on') {
- allValsUnChecked.push(parseInt(this.value));
- }
- }).get();
- deleteListIdBiAuditReaport(type, allValsUnChecked);
- }
- });
- }
- function catchEventCheckbox(type) {
- $('#smad-table-' + type + ' input[type="checkbox"]').on('change', function() {
- if($(this).is(":checked")) {
- var allValsChecked = [];
- if (this.value !== 'on') {
- allValsChecked.push(parseInt(this.value));
- }
- updateListIdBiAuditReaport(type, allValsChecked);
- } else {
- var allValsUnChecke = [];
- if (this.value !== 'on') {
- allValsUnChecke.push(parseInt(this.value));
- }
- deleteListIdBiAuditReaport(type, allValsUnChecke);
- }
- // update count selected IDs
- updateCountItemCheckedByType(type.toLowerCase());
- });
- }
- function clearSelectedCheckbox() {
- $('#checkAll-PRACOWNICY').prop('checked', false)
- $('#checkAll-KONTRAHENCI').prop('checked', false)
- }
- function updateListIdBiAuditReaport(type, valueArray) {
- var currentStoragePracownicyIds = [];
- var updateListPracownicyIds = null;
- var currentStorageKontrahenciIds = [];
- var updateListKontrahenciIds = null;
- if ( type == 'PRACOWNICY') {
- currentStoragePracownicyIds = getItemLocalStorage('Anton1.biAuditForm.pracownicyIds');
- if(currentStoragePracownicyIds !== null) {
- updateListPracownicyIds = [...new Set([...currentStoragePracownicyIds ,...valueArray])];
- }
- else {
- updateListPracownicyIds = valueArray;
- }
- setItemLocalStorage('Anton1.biAuditForm.pracownicyIds', updateListPracownicyIds);
- }
- if ( type == 'KONTRAHENCI') {
- currentStorageKontrahenciIds = getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- if(currentStorageKontrahenciIds !== null) {
- updateListKontrahenciIds = [...new Set([...currentStorageKontrahenciIds ,...valueArray])];
- }
- else {
- updateListKontrahenciIds = valueArray;
- }
- setItemLocalStorage('Anton1.biAuditForm.kontrahenciIds', updateListKontrahenciIds);
- }
- }
- function deleteListIdBiAuditReaport(type, valueArray) {
- if ( type == 'PRACOWNICY') {
- deleteItemLocalStorage('Anton1.biAuditForm.pracownicyIds', valueArray);
- }
- if ( type == 'KONTRAHENCI') {
- deleteItemLocalStorage('Anton1.biAuditForm.kontrahenciIds', valueArray);
- }
- }
- function fetchGroupPracownicy() {
- fetch(URL_FETCH_GROUP_PRACOWNICY, {
- credentials: 'same-origin'
- })
- .then(function parseJSON(response) {
- return response.json()
- })
- .then(function(data) {
- setItemLocalStorage('Anton1.biAuditForm.pracownicy.groups', data.body.itmesGroupPracownicy);
- if (data.body.itmesGroupPracownicy === null) {
- return;
- }
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup');
- var currentDepthValue = getItemLocalStorage('Anton1.biAuditForm.depth');
- setItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup', filterIdGroup);
- setItemLocalStorage('Anton1.biAuditForm.depth', currentDepthValue);
- var groupsPracownicy = '';
- var activeButton = '';
- data.body.itmesGroupPracownicy.forEach (function(row) {
- activeButton = '';
- if ( filterIdGroup === parseInt(row['ID']) ) {
- activeButton = 'active';
- $('#group-pracownicy button.active').removeClass('active');
- }
- groupsPracownicy += '<button class="btn btn-default '+activeButton+'" title="' + row['NAZWA'] + '" data-group-filter="' + row['ID'] + '">' + row['NAZWA'] + '</button>';
- });
- $("#group-pracownicy").append(groupsPracownicy);
- updateCountItemCheckedByType('pracownicy');
- detectChoiseFilter();
- }).catch(function(error) {
- if(DBG) console.log('request failed', error)
- });
- }
- function fetchGroupKontrahenci() {
- fetch(URL_FETCH_GROUP_KONTRAHENCI, {
- credentials: 'same-origin'
- })
- .then(function parseJSON(response) {
- return response.json()
- })
- .then(function(data) {
- setItemLocalStorage('Anton1.biAuditForm.kontrahenci.groups', data.body.itemsGroupKontrahenci);
- if (data.body.itemsGroupKontrahenci === null) {
- return;
- }
- var filterIdGroup = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup');
- var currentDepthValue = getItemLocalStorage('Anton1.biAuditForm.depth');
- setItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup', filterIdGroup);
- setItemLocalStorage('Anton1.biAuditForm.depth', currentDepthValue);
- var groupsKontrahenci = '';
- var activeButton = '';
- data.body.itemsGroupKontrahenci.forEach (function(row) {
- activeButton = '';
- if ( filterIdGroup === parseInt(row['ID']) ) {
- activeButton = 'active';
- $('#group-kontrahenci button.active').removeClass('active');
- }
- groupsKontrahenci += '<button class="btn btn-default '+activeButton+'" title="'+row['NAZWA']+'" data-group-filter="'+row['ID']+'">'+row['NAZWA']+'</button>';
- });
- $("#group-kontrahenci").append(groupsKontrahenci);
- updateCountItemCheckedByType('kontrahenci');
- detectChoiseFilter();
- }).catch(function(error) {
- if(DBG) console.log('request failed', error)
- });
- }
- function detectChoiseFilter() {
- $('#group-kontrahenci').on('click', 'button', function(evt) {
- $('#group-kontrahenci button.active').removeClass('active');
- $(this).addClass('active');
- // pobranie id grupy kliknietego buttonu
- var filterIdGroup = $(this).attr("data-group-filter");
- // aktaulna wartość zagłebienia
- var currentDepthValue = getItemLocalStorage('Anton1.biAuditForm.depth');
- // czy zwracać wyniki tylko z obiektami docelowymi
- var analizaOnlyTargets = getItemLocalStorage('Anton1.biAuditForm.analizaOnlyTargets');
- // ustawienie ostaniej wartości zagłebienia przed resete
- setItemLocalStorage('Anton1.biAuditForm.depth', currentDepthValue);
- // czy zwracać wyniki tylko z obiektami docelowymi
- setItemLocalStorage('Anton1.biAuditForm.analizaOnlyTargets', analizaOnlyTargets);
- // ustawić id grupy do sesyjnej
- setItemLocalStorage('Anton1.biAuditForm.kontrahenci.filterIdGroup', parseInt(filterIdGroup));
- // wywylac funckje pobrania danych
- urlFetchKontrahenci(1);
- });
- $('#group-pracownicy').on('click', 'button', function(e) {
- e.preventDefault();
- $('#group-pracownicy button.active').removeClass('active');
- $(this).addClass('active');
- // pobranie id grupy kliknietego buttonu
- var filterIdGroup = $(this).attr("data-group-filter");
- // aktaulna wartość zagłebienia
- var currentDepthValue = getItemLocalStorage('Anton1.biAuditForm.depth');
- // ustawienie ostaniej wartości zagłebienia przed resete
- setItemLocalStorage('Anton1.biAuditForm.depth', currentDepthValue);
- // ustawić id grupy do sesyjnej
- setItemLocalStorage('Anton1.biAuditForm.pracownicy.filterIdGroup', parseInt(filterIdGroup));
- // wywylac funckje pobrania danych
- urlFetchPracownicy(1);
- });
- }
- // Local storage
- function setItemLocalStorage(key, array) {
- localStorage.setItem(key, JSON.stringify(array));
- }
- function getItemLocalStorage(key) {
- var retrievedData = localStorage.getItem(key);
- var response = JSON.parse(retrievedData);
- return response;
- }
- function deleteItemLocalStorage(key, itemsArray) {
- var currentStorageArray = getItemLocalStorage(key);
- var newStorageArray = removeItemArrayInArray(currentStorageArray, itemsArray);
- setItemLocalStorage(key, newStorageArray);
- }
- /**
- * arr - array
- * item - search item
- */
- function removeItemInArray(arr, item) {
- for(var i = arr.length; i--;) {
- if(arr[i] === item) {
- arr.splice(i, 1);
- }
- }
- return arr;
- }
- /**
- * arr - array
- * item - array list items
- */
- function removeItemArrayInArray(arr, itemsArray) {
- for(var i = arr.length; i--;) {
- for(var j = itemsArray.length; j--;) {
- if(arr[i] === itemsArray[j]) {
- arr.splice(i, 1);
- }
- }
- }
- return arr;
- }
- /**
- * Cleart list local storage by type
- * typeNameLocalStorage - name (praconwicy/kontrahenci)
- */
- function clearListLocalStorageByType(typeNameLocalStorage) {
- if (typeNameLocalStorage === 'pracownicy') {
- setItemLocalStorage('Anton1.biAuditForm.pracownicyIds', []);
- }
- if (typeNameLocalStorage === 'kontrahenci') {
- setItemLocalStorage('Anton1.biAuditForm.kontrahenciIds', []);
- }
- // update count selected item
- updateCountItemCheckedByType(typeNameLocalStorage);
- // unchecked checkbox
- $('#smad-table-'+typeNameLocalStorage.toUpperCase()+' form').find(':checkbox').prop('checked', false);
- }
- /**
- * Update count selected pracowniyc/kontrahenci
- */
- function updateCountItemCheckedByType(typeNameLocalStorage) {
- var countId = 0;
- updateTopCounters();
- if (typeNameLocalStorage === 'pracownicy') {
- var countPracownicy = getItemLocalStorage('Anton1.biAuditForm.pracownicyIds');
- if (countPracownicy === null || countPracownicy === undefined) {
- return countId;
- }
- countId = Object.keys(countPracownicy).length;
- $('#count-selected-item-pracownicy').text(countId);
- }
- if (typeNameLocalStorage === 'kontrahenci') {
- var countKontrahenci = getItemLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- if (countKontrahenci === null || countKontrahenci === undefined) {
- return countId;
- }
- countId = Object.keys(countKontrahenci).length;
- $('#count-selected-item-kontrahenci').text(countId);
- }
- return countId;
- }
- function updateTopCounters() {
- var idsPracownicy = getListFromLocalStorage('Anton1.biAuditForm.pracownicyIds');
- var idsKontrahenci = getListFromLocalStorage('Anton1.biAuditForm.kontrahenciIds');
- var pozostaleOd = getListFromLocalStorage(getSelectedListLocalStorageKey('OD'));
- var pozostaleDo = getListFromLocalStorage(getSelectedListLocalStorageKey('DO'));
- var allOdLength = idsPracownicy.length + pozostaleOd.length;
- var allDoLength = idsKontrahenci.length + pozostaleDo.length;
- var depthValue = getItemLocalStorage('Anton1.biAuditForm.depth');
- if (globalRaportStore) globalRaportStore.dispatch({
- type: 'UPDATE',
- totalOdPracownicy: idsPracownicy.length,
- totalDoKontrahenci: idsKontrahenci.length,
- })
- }
- var P5UI__Anton1__ExportFieldSelectOverlay = createReactClass({
- handleChange: function (fieldName) {
- DBG && console.log('DBG:P5UI__Anton1__ExportFieldSelectOverlay:handleChange', { fieldName })
- this.props.handleToggle(fieldName);
- },
- setRef: function (reactComponent) {
- this._rootNode = reactComponent;
- },
- componentWillMount: function () { // TODO: mv to div at the end of body, then position div by event.target.offsetTop / offsetLeft
- this._closeDropdownIfClickedOutside = function (event) {
- if (DBG) console.log("P5UI__Anton1__ExportFieldSelectOverlay::_closeDropdownIfClickedOutside idHtmlPopover:", { 'this__rootNode': this._rootNode })
- if (!this._rootNode) return;
- var isClickedOutside = p5UI__clickedOutsideElement(this._rootNode, event)
- if (isClickedOutside) {
- this._unbindCloseDropdownIfClickedOutside();
- this.props.handleClose();
- }
- }.bind(this);
- this._bindCloseDropdownIfClickedOutside = function () {
- if (DBG) console.log("P5UI__Anton1__ExportFieldSelectOverlay::_bindCloseDropdownIfClickedOutside", this._closeDropdownIfClickedOutside)
- if (!document.addEventListener && document.attachEvent) {
- document.attachEvent('onclick', this._closeDropdownIfClickedOutside);
- } else {
- document.addEventListener('click', this._closeDropdownIfClickedOutside);
- }
- }.bind(this);
- this._unbindCloseDropdownIfClickedOutside = function () {
- if (DBG) console.log("P5UI__Anton1__ExportFieldSelectOverlay::_unbindCloseDropdownIfClickedOutside", this._closeDropdownIfClickedOutside)
- if (!document.removeEventListener && document.detachEvent) {
- document.detachEvent('onclick', this._closeDropdownIfClickedOutside);
- } else {
- document.removeEventListener('click', this._closeDropdownIfClickedOutside);
- }
- }.bind(this);
- },
- componentDidMount: function () {
- this._bindCloseDropdownIfClickedOutside();
- },
- renderExportField: function (field) {
- // <li><input checked="" type="checkbox" title="ID" value="ID"> Nr</li>
- var self = this;
- var fieldName = field.name;
- var label = field.label;
- var isChecked = this.props.exportFieldsStore.state.selected.has(fieldName);
- return h('li', {}, [
- h('label', { style: { 'font-size': "small", 'font-weight': "normal", 'margin-bottom': "0" } }, [
- h('input', {
- checked: isChecked,
- type: "checkbox",
- title: fieldName,
- value: fieldName,
- onChange: function () {
- self.handleChange(fieldName);
- }
- }),
- " ",
- label.replace(/_/g, ' ')
- ])
- ]);
- },
- handleExportToHTML: function (event) {
- event.preventDefault();
- this.openExportWindow('html');
- },
- handleExportToCSV: function (event) {
- event.preventDefault();
- this.openExportWindow('csv');
- },
- handleExportToLatin2CSV: function (event) {
- event.preventDefault();
- this.openExportWindow('csv_cp1250');
- },
- handleExportToXLS: function (event) {
- event.preventDefault();
- this.openExportWindow('xls');
- },
- handleExportToXLSX: function (event) {
- event.preventDefault();
- this.openExportWindow('xlsx');
- },
- openExportWindow: function (format) {
- var selected = this.props.exportFieldsStore.state.selected;
- DBG && console.log('DBG:P5UI__Anton1__ExportFieldSelectOverlay:openExportWindow', { format: format, selected: selected })
- var exportUrl = [ 'index.php?_route=ExportTableAjax&namespace=' + this.props.namespace,
- 'format=' + format,
- 'flds=' + Array.from(selected).join(','),
- 'sortCol=' + (this.props.sortCol || ''),
- 'sortDir=' + (this.props.sortDir ? "desc" : "asc"),
- this.props.queryFilter
- ].join('&');
- var win = window.open(exportUrl, '_blank');
- win.focus();
- },
- // if (!exportFields.length) {
- // alert('Nie wybrano żadnych pól do eksportu.');
- // e.preventDefault();
- // return false;
- // }
- // var limit = 10000;
- // if (!_data.total || _data.total <= 0) {
- // alert('Brak rekordów do eksportu.');
- // e.preventDefault();
- // return false;
- // }
- // if (_data.total > limit) {
- // if (!confirm('Za dużo rekordów. Wyeksportowane zostaną tylko pierwsze ' + limit + ' z ' + _data.total + ' rekordów.')) {
- // e.preventDefault();
- // return false;
- // }
- // }
- renderExportToHTML: function () {
- return h('li', {}, [
- h('a', { href: "#", onClick: this.handleExportToHTML, style: { 'font-size': "small", 'font-weight': "normal", 'margin-bottom': "0" } }, [
- h('i', { className: "glyphicon glyphicon-share" }),
- " Export do HTML"
- ])
- ]);
- },
- renderExportToCSV: function () {
- return h('li', {}, [
- h('a', { href: "#", onClick: this.handleExportToCSV, style: { 'font-size': "small", 'font-weight': "normal", 'margin-bottom': "0" } }, [
- h('i', { className: "glyphicon glyphicon-share" }),
- " Export do CSV"
- ])
- ]);
- },
- renderExportToLatin2CSV: function () {
- return h('li', {}, [
- h('a', {
- href: "#", onClick: this.handleExportToLatin2CSV,
- style: { 'font-size': "small", 'font-weight': "normal", 'margin-bottom': "0" },
- title: "Export do pliku CSV w kodowaniu Windows-1250",
- }, [
- h('i', { className: "glyphicon glyphicon-share" }),
- " Export do CSV (Windows-1250)"
- ])
- ]);
- },
- renderExportToXLS: function () {
- return h('li', {}, [
- h('a', { href: "#", onClick: this.handleExportToXLS, style: { 'font-size': "small", 'font-weight': "normal", 'margin-bottom': "0" } }, [
- h('i', { className: "glyphicon glyphicon-share" }),
- " Export do XLS"
- ])
- ]);
- },
- renderExportToXLSX: function () {
- return h('li', {}, [
- h('a', { href: "#", onClick: this.handleExportToXLSX, style: { 'font-size': "small", 'font-weight': "normal", 'margin-bottom': "0" } }, [
- h('i', { className: "glyphicon glyphicon-share" }),
- " Export do XLSX"
- ])
- ]);
- },
- render: function () {
- if (!this.props.exportFields) console.warn('DBG: missing this.props.exportFields', { 'this.props': this.props });
- if (!this.props.exportFields) return null;
- return h('ul', {
- ref: this.setRef,
- className: "dropdown-menu",
- style: {
- height: "250px",
- 'min-width': "300px",
- 'padding': "5px 20px 5px 8px",
- overflow: "auto",
- display: "block",
- position: "absolute",
- left: this.props.offsetLeft,
- top: this.props.offsetTop - 250,
- margin: 0,
- // height: 250px;
- // this.props.btnBBox
- },
- }, this.props.exportFields.map(this.renderExportField).concat([
- this.renderExportToHTML(),
- this.renderExportToCSV(),
- this.renderExportToLatin2CSV(),
- this.renderExportToXLS(),
- this.renderExportToXLSX(),
- ]));
- }
- });
- var _Containers__ExportFields = {}; // namespace => Unstated Container
- var _Containers__get = function (namespace, initialSelected) {
- if (_Containers__ExportFields[namespace]) return _Containers__ExportFields[namespace];
- var selected = new Set();
- if (initialSelected) initialSelected.forEach(function (field) {
- selected.add(field.name);
- })
- _Containers__ExportFields[namespace] = global.p5VendorJs.createUnstatedContainer({
- state: {
- namespace: namespace,
- selected: selected,
- },
- toggleField(fieldName) {
- var selected = this.state.selected;
- selected.has(fieldName) ? selected.delete(fieldName) : selected.add(fieldName)
- this.setState({ selected: selected });
- },
- selectField(fieldName) {
- var selected = this.state.selected;
- selected.add(fieldName)
- this.setState({ selected: selected });
- },
- unselectField(fieldName) {
- var selected = this.state.selected;
- selected.delete(fieldName)
- this.setState({ selected: selected });
- },
- });
- // namespace = 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY';
- // namespace = 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI';
- return _Containers__ExportFields[namespace];
- }
- var P5UI__Anton1__ExportTable = createReactClass({ // @props: { namespace, exportFields }
- _node: null,
- getInitialState: function () {
- return {
- isOpen: false,
- };
- },
- handleToggleDropdown: function (event) {
- var offsetLeft = 0;
- var offsetTop = 0;
- this.removePopup();
- if (!this.state.isOpen) {
- var btnBBox = ("BUTTON" !== event.target.nodeName) ? event.target.parentNode.getBoundingClientRect() : event.target.getBoundingClientRect();
- offsetLeft = btnBBox.left;
- offsetTop = window.pageYOffset + btnBBox.y;
- this._node = document.createElement('div');
- this._node.setAttribute('data-p5class', "P5UI__Anton1__ExportTable");
- this._node.position = "absolute";
- this._node.left = "0";
- this._node.top = "0";
- this._node.height = "100%";
- this._node.backgroundColor = "#00000050";
- this._node.width = "100%";
- var handleClose = this.handleClose.bind(this);
- var exportFields = this.props.exportFields;
- var exportFieldsContainer = _Containers__get(this.props.namespace, this.props.exportFields);
- document.body.appendChild(this._node);
- var self__props = this.props;
- ReactDOM.render(
- h(Unstated.Provider, {}, [
- h(Unstated.Subscribe, { to: [ exportFieldsContainer ] },
- function (exportFieldsCont) {
- DBG && console.log('DBG:exportFieldsCont', { exportFieldsCont })
- return h(P5UI__Anton1__ExportFieldSelectOverlay, Object.assign({}, self__props, {
- exportFields: exportFields,
- btnBBox: btnBBox,
- exportFieldsStore: exportFieldsCont,
- handleToggle: exportFieldsCont.toggleField.bind(exportFieldsCont),
- handleClose: handleClose,
- offsetLeft: offsetLeft,
- offsetTop: offsetTop,
- }));
- }
- )
- ]),
- this._node
- );
- }
- this.setState({ isOpen: !this.state.isOpen });
- },
- removePopup: function () {
- if (this._node && 1 === this._node.nodeType) {
- document.body.removeChild(this._node);
- }
- this._node = null;
- },
- handleClose: function () {
- this.removePopup();
- this.setState({ isOpen: false });
- },
- render: function () {
- // Pagination.code += '<div class="btn-group dropup pagesize" style="margin-left:40px">' +
- // <button class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" href="#">Export <span class="caret"></span></button>
- // <ul class="dropdown-menu" style="max-height:250px;padding:5px 20px 5px 8px;overflow:auto;">
- // <li><input checked="" type="checkbox" title="ID" value="ID"> Nr</li>
- // <li><input checked="" type="checkbox" title="A_STATUS" value="A_STATUS"> Status</li>
- // ...
- // <li><input checked="" type="checkbox" title="TV_DVBC_EPG_CHANNEL_NUMBER" value="TV_DVBC_EPG_CHANNEL_NUMBER"> TV: Nr kanału w EPG</li>
- // <li><a href="index.php" target="_blank" class=""><i class="glyphicon glyphicon-share"></i>Export do HTML</a></li>
- // <li><a href="index.php" target="_blank" class=""><i class="glyphicon glyphicon-share"></i>Export do CSV</a></li>
- // <li><a href="index.php" target="_blank" class=""><i class="glyphicon glyphicon-share" title="Export do pliku CSV w kodowaniu Windows-1250"></i>Export do CSV (Windows-1250)</a></li>
- // </ul></div>';
- return h('div', {
- className: "btn-group", // className: "btn-group dropup pagesize" + " open",
- }, [
- h('button', {
- className: "btn btn-sm btn-default", // className: "btn btn-sm btn-default dropdown-toggle", // 'data-toggle': "dropdown",
- onClick: this.handleToggleDropdown
- }, [
- "Export ",
- h('span', { className: "caret" }),
- ]),
- // h('ul', {
- // className: "dropdown-menu",
- // style: {
- // 'max-height': "250px",
- // 'min-width': "300px",
- // 'padding': "5px 20px 5px 8px",
- // overflow: "auto",
- // }
- // }, this.props.exportFields.map(this.renderExportField))
- ]);
- // @from TableAjax:
- // if (priv.options.exportFields && priv.options.exportFields.length) {
- // node = $('<div class="btn-group dropup pagesize ' + nodeClass + '"></div>');
- // var btn = $('<button class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" href="#">Export </button>').appendTo(node);
- // var span = $('<span class="caret"></span>').appendTo(btn);
- // var ul = $('<ul class="dropdown-menu" style="max-height:250px;padding:5px 20px 5px 8px;overflow:auto;">').appendTo(node);
- // $.each(_data.cols, function (col, props) {
- // if (-1 !== priv.options.exportFields.indexOf(col)) {
- // var li = $('<li></li>').appendTo(ul);
- // $(p5Utils__format('<input {0} type="checkbox" title="{1}" value="{1}" > {2}</input>', [(_exportFieldsSelect[col]) ? 'checked' : '', col, props.friendly || col])).appendTo(li);
- // li.on('click', 'input', priv.exportFieldChanged);
- // }
- // });
- // var li = $('<li></li>').appendTo(ul);
- // $('<a href="index.php" target="_blank" class=""><i class="glyphicon glyphicon-share"></i>Export do HTML</a>').appendTo(li);
- // li.on('click', 'a', priv.exportToHTML);
- // var li = $('<li></li>').appendTo(ul);
- // $('<a href="index.php" target="_blank" class=""><i class="glyphicon glyphicon-share"></i>Export do CSV</a>').appendTo(li);
- // li.on('click', 'a', priv.exportToCSV);
- // var li = $('<li></li>').appendTo(ul);
- // $('<a href="index.php" target="_blank" class=""><i class="glyphicon glyphicon-share" title="Export do pliku CSV w kodowaniu Windows-1250"></i>Export do CSV (Windows-1250)</a>').appendTo(li);
- // li.on('click', 'a', priv.exportToCSVWinCP1250);
- // } else {
- // node = $('<span class="' + nodeClass + '"></span>');
- // }
- }
- });
- // Pagination
- var Pagination = {
- code: '', // end show html paginations
- clickPage: 1, // set default 1 page
- // --------------------
- // Utility
- // --------------------
- // initialize default data
- Extend: function(data) {
- data = data || {};
- Pagination.url = data.url;
- Pagination.id_pagination = data.id_pagination;
- Pagination.type = data.type;
- Pagination.limit = data.limit;
- Pagination.total_items = data.total_items;
- Pagination.size = data.size || 2;
- Pagination.page = data.page || 1;
- Pagination.step = data.step || 3;
- },
- // add pages by number (from [s] to [f])
- Add: function(s, f) {
- for (var i = s; i < f; i++) {
- Pagination.code += '<li><a href="' + Pagination.url + '" class="btn btn-default">' + i + '</a></li>';
- }
- },
- // add last page with separator
- Last: function() {
- Pagination.code += '<li><a href="' + Pagination.url + '" class="btn btn-default">>></a></li>';
- },
- // add first page with separator
- First: function() {
- Pagination.code += '<li><a href="' + Pagination.url + '" class="btn btn-default"><<</a></li>';
- },
- // add last page with separator
- Next: function() {
- Pagination.code += '<li><a href="' + Pagination.url + '" class="btn btn-default">></a></li>';
- },
- // add first page with separator
- Prev: function() {
- Pagination.code += '<li><a href="' + Pagination.url + '" class="btn btn-default"><</a></li>';
- },
- // --------------------
- // Handlers
- // --------------------
- // change page
- Click: function() {
- clearSelectedCheckbox();
- var selectPage = $("#pagination-"+Pagination.type.toLowerCase()+' .tblAjax__footer__toolbar__pagination').find('a.active').text();
- Pagination.clickPage = +this.innerHTML || '';
- if ( selectPage === NaN || selectPage > Pagination.size) { selectPage = 1; }
- switch (this.innerHTML) {
- case '>>': // last
- Pagination.clickPage = Pagination.size;
- break;
- case '<<': // first
- Pagination.clickPage = 1;
- break;
- case '<': // prev
- Pagination.clickPage = parseInt(selectPage) - 1;
- if (Pagination.clickPage < 1) {
- Pagination.clickPage = 1;
- }
- break;
- case '>': // next
- Pagination.clickPage = parseInt(selectPage) + 1;
- if (Pagination.clickPage > Pagination.size) {
- Pagination.clickPage = Pagination.size;
- }
- break;
- }
- if ( Pagination.type === 'KONTRAHENCI' ) {
- setItemLocalStorage('Anton1.biAuditForm.kontrahenci.pagination.page', Pagination.clickPage);
- Pagination.page = urlFetchKontrahenci(Pagination.clickPage);
- }
- else if ( Pagination.type === 'PRACOWNICY' ){
- setItemLocalStorage('Anton1.biAuditForm.pracownicy.pagination.page', Pagination.clickPage);
- Pagination.page = urlFetchPracownicy(Pagination.clickPage);
- }
- Pagination.Start();
- },
- // --------------------
- // Script structure pagination
- // --------------------
- // binding pages
- Bind: function() {
- var a = Pagination.e.getElementsByTagName('a');
- // var currentPage = Pagination.clickPage || 1;
- for (var i = 0; i < a.length; i++) {
- if (+a[i].innerHTML === Pagination.page) a[i].className = 'btn btn-default active';
- a[i].addEventListener('click', Pagination.Click, false);
- }
- },
- ExportWidget: function() {
- var exportWidgetId = 'p5__exportWidget__' + Pagination.type;
- Pagination.code += '<div id="' + exportWidgetId + '" class="btn-group dropup pagesize" style="margin-left:40px"></div>';
- },
- getSearchQueryFilter: function () { // @return url query filter by namespace
- switch (Pagination.type) {
- case 'PRACOWNICY': {
- var searchParams = getSearchParamsPracownicy();
- return [
- searchParams.filterFields,
- (searchParams.filterIdGroup) ? 'filterIdGroup=' + searchParams.filterIdGroup : null, // TODO: backRef search
- ].filter(Boolean).join('&')
- }
- case 'KONTRAHENCI': {
- var searchParams = getSearchParamsKontrahenci();
- return [
- searchParams.filterFields,
- (searchParams.filterIdGroup) ? 'filterIdGroup=' + searchParams.filterIdGroup : null, // TODO: backRef search
- ].filter(Boolean).join('&')
- }
- default: return '';
- }
- },
- CreateExportWidget: function() {
- var exportFields = null;
- var namespace = '';
- if (Pagination.type === 'PRACOWNICY') {
- exportFields = EXPORT_FIELDS_OD;
- namespace = 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY';
- } else if (Pagination.type === 'KONTRAHENCI') {
- exportFields = EXPORT_FIELDS_DO;
- namespace = 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI';
- }
- DBG && console.log('DBG:EXPORT_FIELDS...', { EXPORT_FIELDS_OD, EXPORT_FIELDS_DO, exportFields });
- if (!exportFields || (exportFields && !exportFields.length)) return;
- var exportWidgetId = 'p5__exportWidget__' + Pagination.type;
- var node = document.getElementById(exportWidgetId);
- DBG && console.log('node: ', { node });
- if (!node) return;
- var sortCol = 'ID';
- var sortDir = 'desc';
- var queryFilter = Pagination.getSearchQueryFilter();
- ReactDOM.render(
- h(P5UI__Anton1__ExportTable, {
- namespace: namespace,
- exportFields: exportFields,
- sortCol: sortCol,
- sortDir: sortDir,
- queryFilter: queryFilter,
- }),
- node
- );
- },
- Finish: function() {
- Pagination.e.innerHTML = Pagination.code;
- Pagination.Bind();
- Pagination.CreateExportWidget();
- },
- // find pagination type
- Start: function() {
- Pagination.code = '';
- if ( Pagination.type === 'KONTRAHENCI' ) {
- Pagination.code += '<div class="foot-info tblAjax__footer__toolbar__info footer_pagination_menu_items"><p>Wiersze od <span id="paginationShowNextCount-KONTRAHENCI"></span> do ' + Pagination.total_items + ' z ' + Pagination.total_items + '</p></div>';
- } else if ( Pagination.type === 'PRACOWNICY' ) {
- Pagination.code += '<div class="foot-info tblAjax__footer__toolbar__info footer_pagination_menu_items"><p>Wiersze od <span id="paginationShowNextCount-PRACOWNICY"></span> do ' + Pagination.total_items + ' z ' + Pagination.total_items + '</p></div>';
- }
- Pagination.code += '<nav aria-label="Page navigation" class="footer_pagination_menu_items"><ul class="btn-group tblAjax__footer__toolbar__pagination smad-pagination" style="margin-bottom:0">';
- Pagination.First();
- Pagination.Prev();
- if ( Pagination.type === 'KONTRAHENCI' ) {
- Pagination.page = getItemLocalStorage('Anton1.biAuditForm.kontrahenci.pagination.page') || 1;
- }
- else if ( Pagination.type === 'PRACOWNICY' ) {
- Pagination.page = getItemLocalStorage('Anton1.biAuditForm.pracownicy.pagination.page') || 1;
- }
- if ( Pagination.page > Pagination.size ) {
- Pagination.page = 1;
- }
- if (Pagination.size < Pagination.step * 2 + 6) {
- Pagination.Add(1, Pagination.size + 1);
- }
- else if (Pagination.page < Pagination.step * 2 + 1) {
- Pagination.Add(1, Pagination.step * 2 + 4);
- }
- else if (Pagination.page > Pagination.size - Pagination.step * 2) {
- Pagination.Add(Pagination.size - Pagination.step * 2 - 2, Pagination.size + 1);
- }
- else {
- Pagination.Add(Pagination.page - Pagination.step, Pagination.page + Pagination.step + 1);
- }
- Pagination.Next();
- Pagination.Last();
- Pagination.code += '</ul></nav>';
- Pagination.ExportWidget();
- Pagination.Finish();
- },
- // --------------------
- // Initialization
- // --------------------
- // binding buttons
- Buttons: function(e) {
- var nav = e.getElementsByTagName('a');
- },
- // create skeleton
- Create: function(element) {
- var html = [
- '<div></div>' // pagination container
- ];
- element.innerHTML = html.join('');
- Pagination.e = element.getElementsByTagName('div')[0];
- Pagination.Buttons(element);
- },
- // init
- Init: function(element, options) {
- Pagination.Extend(options);
- Pagination.Create(element);
- Pagination.Start();
- }
- };
- function todo__fetchRaport(id) {
- /* p5WFS_GetFeature('default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', {
- primaryKey: id,
- resolve: 'all',
- resolveDepth: 3,
- }).then(function (features) {
- if(DBG) console.log('features', features)
- }).catch(function (e) {
- if(DBG) console.warn(e)
- p5UI__notifyAjaxCallback({ type: 'error', msg: e })
- })*/
- }
- function removeFiltersPracownicy(event, btnNode) {
- event.preventDefault()
- var fieldNameList = FIELD_LIST_PRACOWNICY
- fieldNameList.forEach(function (fieldName) {
- btnNode.form[fieldName].value = ''
- })
- urlFetchPracownicy(1)
- }
- function removeFiltersKontrahenci(event, btnNode) {
- event.preventDefault()
- var fieldNameList = FIELD_LIST_KONTRAHENCI
- fieldNameList.forEach(function (fieldName) {
- btnNode.form[fieldName].value = ''
- })
- urlFetchKontrahenci(1)
- }
- function onChangeFiltersPracownicy(event, inputNode) {
- urlFetchPracownicy(1)
- }
- function onKeypressFiltersPracownicy(event, inputNode) {
- if ("Enter" === event.key) {
- event.stopPropagation()
- event.preventDefault()
- urlFetchPracownicy(1)
- return false
- }
- }
- function onChangeFiltersKontrahenci(event, inputNode) {
- urlFetchKontrahenci(1)
- }
- function onKeypressFiltersKontrahenci(event, inputNode) {
- if ("Enter" === event.key) {
- event.stopPropagation()
- event.preventDefault()
- urlFetchKontrahenci(1)
- return false
- }
- }
- function loadMoreRecordFunctions(event, node, rowPK, namespace) {
- var _node = node
- var _rowPK = rowPK
- var toShow = true
- if (RECORD_MORE_FUNCTIONS_OPENED_NODE) {
- if (RECORD_MORE_FUNCTIONS_OPENED_NODE === node) toShow = false
- if (RECORD_MORE_FUNCTIONS_OPENED_NODE !== node) {
- jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('destroy')
- }
- }
- RECORD_MORE_FUNCTIONS_OPENED_NODE = node
- // jQuery(node).popover({
- // container: 'body',
- // placement: 'right',
- // trigger: 'click',
- // template: '<div class="popover" role="tooltip" style="max-width:600px;width:440px;">' +
- // '<div class="arrow"></div>' +
- // '<div style="display:block;position:relative;">' +
- // '<div class="popover-title">' +
- // '</div>' +
- // '<button type="button" class="close" onclick="return hideMoreRecordFunctionsPopover();" style="position:absolute;right:8px;top:6px;">×</button>' +
- // '</div>' +
- // '<div class="popover-content"></div>' +
- // '</div>' +
- // '',
- // html: true,
- // })
- // jQuery(node).popover('show')
- global.fetch(BASE_URLS + 'index.php?_route=ViewTableAjax&namespace=' + namespace + '&_task=moreFunctionsCellAjax&ID=' + rowPK, {
- credentials: 'same-origin'
- }).then(function (response) {
- return response.json()
- }).then(function (json) {
- var funcListWrap = $('<div></div>')
- if (_node === RECORD_MORE_FUNCTIONS_OPENED_NODE) {
- if (json && 'success' === json.type && json.rowFunctions && json.rowFunctions.length > 0) {
- var popoverContent = generateViewMoreRecordFunctions(json.rowFunctions, namespace, _rowPK);
- popoverContent.appendTo(funcListWrap);
- }
- }
- // jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('destroy')
- jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover({
- container: 'body',
- placement: 'right',
- trigger: 'click',
- template: '<div class="popover" role="tooltip" style="max-width:600px;width:440px;">' +
- '<div class="arrow"></div>' +
- '<div style="display:block;position:relative;">' +
- '<div class="popover-title">' +
- '</div>' +
- '<button type="button" class="close" onclick="return hideMoreRecordFunctionsPopover();" style="position:absolute;right:8px;top:6px;">×</button>' +
- '</div>' +
- '<div class="popover-content"></div>' +
- '</div>' +
- '',
- html: true,
- content: funcListWrap.html(),
- })
- jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('show')
- }).catch(function (err) {
- if(DBG) console.log('err', err);
- })
- }
- function generateViewMoreRecordFunctions(rowFunctions, namespace, rowPK) {
- var popoverContent;
- var funcNodesToUpdate = [];
- if (!rowFunctions.length) {
- popoverContent = $('<p class="text-muted">Brak dodatkowych funkcji</p>');
- } else if (3 === namespace.split('/').length) { // if namesapce is AntAcl [ and has ref fields or back ref ]
- popoverContent = $('<ul class="list-unstyled"></ul>');
- var rowFunctionsByType = rowFunctions.reduce(function (ret, funObj) {
- if (
- 'Powiązania od ' === funObj.label.substr(0, 'Powiązania od '.length)
- || 'Powiązania do ' === funObj.label.substr(0, 'Powiązania do '.length)
- ) {
- if (funObj.total > 0) {
- ret.refConnections.push(funObj);
- } else {
- ret.refEmptyConnections.push(funObj);
- }
- } else {
- ret.others.push(funObj);
- }
- return ret;
- // href: "https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_KRS/BI_audit_KRS&childRefNS=default_db/BI_audit_KRS/BI_audit_KRS&childRefPK=2068689"
- // ico: "glyphicon glyphicon-random"
- // label: "Powiązania od 'KRS' <span class="badge">0</span>"
- // title: "Powiązania od 'Audyt / KRS' (0)"
- }, { refConnections: [], refEmptyConnections: [], others: [] });
- rowFunctionsByType.others.forEach(function (funObj) {
- var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, { ico: true, label: true });
- if (funObj.id) {
- funcNodesToUpdate.push({ id: funObj.id, node: funcNode });
- } else {
- var funcItemNode = $('<li></li>').appendTo(popoverContent);
- funcItemNode.append(funcNode);
- }
- });
- if (!rowFunctionsByType.refConnections.length) {
- $('<li>Brak powiązań</li>').appendTo(popoverContent);
- } else {
- var refConnItemNode = $('<li style="margin-top:10px"><i class="glyphicon glyphicon-random"></i> <b>Powiązania</b></li>').appendTo(popoverContent);
- {
- var funObj = {
- // ico: 'glyphicon glyphicon-random',
- label: 'przeglądaj',
- title: "Przeglądaj powiązania",
- href: 'index.php?_route=RefGraph&namespace=' + namespace + '&primaryKey=' + rowPK,
- // onclick: function (e) { // TODO: open in
- // console.log('TODO: przeglądaj powiązania')
- // }
- }
- var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, { ico: true, label: true })
- refConnItemNode.append(" - ");
- refConnItemNode.append(funcNode);
- }
- var refConnFuncList = $('<ul class="list-unstyled" style="margin-left:20px"></ul>').appendTo(refConnItemNode);
- rowFunctionsByType.refConnections.forEach(function (funObj) {
- var refFunObj = Object.assign({}, funObj, {
- // ico: null,
- label: funObj.label.substr('Powiązania '.length),
- });
- var funcNode = p5UI_TableAjax_generateFunctionNode(refFunObj, rowPK, { ico: true, label: true });
- var funcItemNode = $('<li></li>').appendTo(refConnFuncList);
- funcItemNode.append(funcNode);
- })
- }
- if (rowFunctionsByType.refEmptyConnections.length) {
- var refConnItemNode = $('<li style="margin-top:10px; opacity:0.7"></li>').appendTo(popoverContent);
- var emptyRefsDetailsNode = $('<details></details>').appendTo(refConnItemNode);
- // $('<summary><i class="glyphicon glyphicon-random"></i> Pozostałe powiązania</summary>').appendTo(emptyRefsDetailsNode);
- $('<summary style="cursor:pointer">Pozostałe powiązania ...</summary>').appendTo(emptyRefsDetailsNode);
- var refConnFuncList = $('<ul class="list-unstyled" style="margin-left:20px"></ul>').appendTo(emptyRefsDetailsNode);
- rowFunctionsByType.refEmptyConnections.forEach(function (funObj) {
- var refFunObj = Object.assign({}, funObj, {
- // ico: null,
- label: funObj.label.substr('Powiązania '.length),
- });
- var funcNode = p5UI_TableAjax_generateFunctionNode(refFunObj, rowPK, { ico: true, label: true });
- var funcItemNode = $('<li></li>').appendTo(refConnFuncList);
- funcItemNode.append(funcNode);
- })
- }
- } else {
- popoverContent = $('<ul class="list-unstyled"></ul>');
- rowFunctions.forEach(function (funObj) {
- var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, { ico: true, label: true });
- if (funObj.id) {
- funcNodesToUpdate.push({ id: funObj.id, node: funcNode });
- } else {
- var funcItemNode = $('<li></li>').appendTo(popoverContent);
- funcItemNode.append(funcNode);
- }
- });
- }
- return popoverContent;
- }
- function p5UI_TableAjax_generateFunctionNode(funObj, rowPK, props) {
- if (!rowPK) throw "Missing primaryKey in p5UI_TableAjax_generateFunctionNode";
- var defaultsProps = {
- ico: true,
- label: false
- };
- var props = jQuery.extend({}, defaultsProps, props);
- var funcNode = $('<a href="#" style="margin:0 2px;"></a>');
- if ('href' in funObj) funcNode.attr('href', p5Utils__format(funObj.href, [rowPK]));
- if (props.ico) {
- if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
- }
- if ('onclick' in funObj) funcNode.attr('onclick', p5Utils__format(funObj.onclick, [rowPK]));
- if ('title' in funObj) funcNode.attr('title', funObj.title);
- if ('target' in funObj) funcNode.attr('target', funObj.target);
- if (props.label) {
- if ('label' in funObj) {
- funcNode.append(' ' + funObj.label);
- } else if ('title' in funObj) {
- funcNode.append(' ' + funObj.title);
- }
- }
- return funcNode;
- };
- global.p5UI_TableAjax_generateFunctionNode = p5UI_TableAjax_generateFunctionNode
- function addAllMatchesToReport(event) {
- switch (event.data.type) {
- case 'kontrahenci': break; // OK
- case 'pracownicy': break; // OK
- default: throw "Wrong type";
- }
- var postData = {}
- if ('filter_idGroup' in event.data.pagination && event.data.pagination['filter_idGroup']) postData['filter_idGroup'] = event.data.pagination['filter_idGroup']
- Object.keys(event.data.pagination).filter(function (key) {
- return ('f_' === key.substr(0, 2))
- }).forEach(function (filterKey) {
- var value = event.data.pagination[filterKey]
- postData[filterKey] = value
- })
- var thisButton = $(this)
- thisButton.attr('disabled', true)
- thisButton.text( thisButton.text() + '...' )
- if ('pracownicy' === event.data.type) {
- p5UI__notifyAjaxCallback({ type: 'info', msg: "Pobieranie pracowników..." })
- var frm = document.getElementById('filtersFieldRemoveBtn-PRACOWNICY').form
- var fieldNameList = FIELD_LIST_PRACOWNICY
- fieldNameList.filter(function (fieldName) {
- if (!frm[fieldName] && DBG) console.log('Err missing field: "'+fieldName+'"')
- return (frm[fieldName]) ? true : false
- }).map(function (fieldName) {
- return [ fieldName, frm[fieldName].value ]
- }).filter(function (filter) {
- return ( filter[1].length > 0 )
- }).forEach(function (filter) {
- postData[ filter[0] ] = filter[1];
- })
- global.fetch(URL_FETCH_PRACOWNICY_IDS_AJAX, {
- credentials: 'same-origin',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(postData)
- })
- .then(function __parseJSON(response) {
- return response.json()
- })
- .then(function (json) {
- if ('success' === json.type && json.body && json.body.ids) {
- updateListIdBiAuditReaport('PRACOWNICY', json.body.ids.map(function (id) {
- return parseInt(id)
- }))
- // jQuery('#body-pracownicy').find('input[name="prID[]"]').attr('checked', true)
- jQuery('#body-pracownicy').find('input[name="prID[]"]').each(function (idx, inputNode) {
- inputNode.checked = true;
- })
- thisButton.attr('disabled', false)
- var txt = thisButton.text()
- thisButton.text( '...' === txt.substr(-3) ? txt.substr(0, txt.length - 3) : txt )
- updateCountItemCheckedByType('pracownicy');
- p5UI__notifyAjaxCallback({ type: 'success', msg: "Dodano "+json.body.ids.length+" pracowników" })
- }
- })
- .catch(function (e) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: '' + e })
- thisButton.attr('disabled', false)
- var txt = thisButton.text()
- thisButton.text( '...' === txt.substr(-3) ? txt.substr(0, txt.length - 3) : txt )
- })
- }
- if ('kontrahenci' === event.data.type) {
- p5UI__notifyAjaxCallback({ type: 'info', msg: "Pobieranie podmiotów/kontrahentów..." })
- var frm = document.getElementById('filtersFieldRemoveBtn-KONTRAHENCI').form
- var fieldNameList = FIELD_LIST_KONTRAHENCI
- fieldNameList.filter(function (fieldName) {
- if (!frm[fieldName] && DBG) console.log('Err missing field: "'+fieldName+'"')
- return (frm[fieldName]) ? true : false
- }).map(function (fieldName) {
- return [ fieldName, frm[fieldName].value ]
- }).filter(function (filter) {
- return ( filter[1].length > 0 )
- }).forEach(function (filter) {
- postData[ filter[0] ] = filter[1];
- })
- global.fetch(URL_FETCH_KONTRAHENCI_IDS_AJAX, {
- credentials: 'same-origin',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(postData)
- })
- .then(function __parseJSON(response) {
- return response.json()
- })
- .then(function (json) {
- if ('success' === json.type && json.body && json.body.ids) {
- updateListIdBiAuditReaport('KONTRAHENCI', json.body.ids.map(function (id) {
- return parseInt(id)
- }))
- // jQuery('#body-kontrahenci').find('input[name="kontrID[]"]').attr('checked', true); // Not working
- jQuery('#body-kontrahenci').find('input[name="kontrID[]"]').each(function (idx, inputNode) {
- inputNode.checked = true;
- })
- thisButton.attr('disabled', false);
- var txt = thisButton.text()
- thisButton.text( '...' === txt.substr(-3) ? txt.substr(0, txt.length - 3) : txt )
- updateCountItemCheckedByType('kontrahenci');
- p5UI__notifyAjaxCallback({ type: 'success', msg: "Dodano "+json.body.ids.length+" kontrahentów" })
- }
- })
- .catch(function (e) {
- p5UI__notifyAjaxCallback({ type: 'error', msg: '' + e })
- thisButton.attr('disabled', false)
- var txt = thisButton.text()
- thisButton.text( '...' === txt.substr(-3) ? txt.substr(0, txt.length - 3) : txt )
- });
- }
- }
- function mock_error__fetchLastReports(id) {
- return new Promise(function (resolve) {
- throw "Wystąpił błąd, spróbuj ponownie później"
- })
- }
- function mock__fetchLastReports(id) {
- return new Promise(function (resolve) {
- var fakeResponse = '{"type":"success","msg":"ostatnie raporty","body":{"items":[{"id":"103","adnotacje":"raport pani x","totalPracownicy":"1","totalKontrahenci":"2"},{"id":"102","adnotacje":"test","totalPracownicy":"1","totalKontrahenci":"1"},{"id":"101","adnotacje":"Zuranski test all 7","totalPracownicy":"1","totalKontrahenci":"9307"},{"id":"100","adnotacje":"kike all 4","totalPracownicy":"5","totalKontrahenci":"9305"},{"id":"99","adnotacje":"test pracownik z KRS bez celu 3","totalPracownicy":"1","totalKontrahenci":"9305"}]}}';
- var json = JSON.parse(fakeResponse);
- var items = json.body.items;
- console.log('items', items)
- setTimeout(function () {
- console.log('resolve items', items)
- resolve(items);
- }, 500);
- });
- }
- function fetchLastReports(id) {
- return global.fetch(URL_FETCH_LAST_REPORTS_AJAX, {
- credentials: 'same-origin',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ id: id })
- })
- .then(function __parseJSON(response) {
- return response.json()
- })
- .then(function (json) {
- if ('success' === json.type && json.body && json.body.items) {
- if (!json.body.items.length) throw "Brak danych"
- return json.body.items;
- }
- throw "Wystąpił błąd, spróbuj ponownie później.";
- })
- }
- function fetchPracownicyIdsByReport(id) {
- return global.fetch(URL_FETCH_PRACOWNICY_IDS_BY_REPORT_AJAX, {
- credentials: 'same-origin',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ id: id })
- })
- .then(function __parseJSON(response) {
- return response.json()
- })
- .then(function (json) {
- if ('success' === json.type && json.body && json.body.ids) {
- if (!json.body.ids.length) throw "Brak danych"
- return json.body.ids;
- }
- throw "Wystąpił błąd, spróbuj ponownie później.";
- })
- }
- function fetchKontrahenciIdsByReport(id) {
- return global.fetch(URL_FETCH_KONTRAHENCI_IDS_BY_REPORT_AJAX, {
- credentials: 'same-origin',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ id: id })
- })
- .then(function __parseJSON(response) {
- return response.json()
- })
- .then(function (json) {
- if ('success' === json.type && json.body && json.body.ids) {
- if (!json.body.ids.length) throw "Brak danych"
- return json.body.ids;
- }
- throw "Wystąpił błąd, spróbuj ponownie później.";
- })
- }
- function addToReportByPreviousReport(event) {
- var pageType = (event.data.type) ? event.data.type : '';
- handleAddToReportByPreviousReport(pageType);
- }
- function handleAddToReportByPreviousReport(pageType) {
- switch (pageType) {
- case 'pracownicy': break; // OK
- case 'kontrahenci': break; // OK
- default: throw "Wrong type";
- }
- var thisButton = $(this)
- thisButton.attr('disabled', true)
- thisButton.text( thisButton.text() + '...' )
- function this__enableButton() {
- thisButton.attr('disabled', false)
- var txt = thisButton.text()
- thisButton.text( '...' === txt.substr(-3) ? txt.substr(0, txt.length - 3) : txt )
- }
- var lastReportOptions = new Promise(function (resolve) {
- fetchLastReports() // TODO: TEST remote `mock__`
- .then(function (items) {
- var options = {};
- items.forEach(function (item) {
- var label = "Nr " + item.id + ": " + item.adnotacje + " ";
- var total = 0;
- switch (pageType) {
- case 'pracownicy': total = parseInt(item.totalPracownicy); break;
- case 'kontrahenci': total = parseInt(item.totalKontrahenci); break;
- }
- label += ( total > 0 ? "(" + total + ")" : "brak");
- options['raport-'+item.id] = label;
- });
- resolve(options);
- })
- .catch(function (e) {
- swal.showValidationError(''+e)
- swal.hideLoading();
- resolve();
- })
- });
- swal({
- title: "Dodaj " + ('pracownicy' === pageType ? "praconików" : "kontrahentów") + " do analizy",
- showCancelButton: true,
- cancelButtonText: "Anuluj",
- showConfirmButton: true,
- confirmButtonText: "Wybierz",
- focusCancel: true,
- width: 600,
- input: 'select',
- inputOptions: lastReportOptions,
- inputClass: "form-control input-lg",
- preConfirm: function (selected) {
- var id = parseInt(selected.substr('raport-'.length));
- swal.showLoading();
- if ('pracownicy' === pageType) {
- return new Promise(function (resolve) {
- fetchPracownicyIdsByReport(id)
- .then(function (ids) {
- updateListIdBiAuditReaport('PRACOWNICY', ids.map(function (id) {
- return parseInt(id)
- }))
- ids.forEach(function (id) {
- jQuery('#body-pracownicy').find('input[name="prID[]"][value="'+id+'"]').each(function (idx, inputNode) {
- inputNode.checked = true;
- })
- })
- updateCountItemCheckedByType('pracownicy');
- p5UI__notifyAjaxCallback({ type: 'success', msg: "Dodano "+ids.length+" pracowników" })
- resolve();
- })
- .catch(function (e) {
- swal.showValidationError(''+e)
- swal.hideLoading();
- resolve();
- });
- });
- } else if ('kontrahenci' === pageType) {
- return new Promise(function (resolve) {
- fetchKontrahenciIdsByReport(id)
- .then(function (ids) {
- updateListIdBiAuditReaport('KONTRAHENCI', ids.map(function (id) {
- return parseInt(id)
- }))
- ids.forEach(function (id) {
- jQuery('#body-kontrahenci').find('input[name="kontrID[]"][value="'+id+'"]').each(function (idx, inputNode) {
- inputNode.checked = true;
- })
- })
- updateCountItemCheckedByType('kontrahenci');
- p5UI__notifyAjaxCallback({ type: 'success', msg: "Dodano "+ids.length+" kontrahentów" })
- resolve();
- })
- .catch(function (e) {
- swal.showValidationError(''+e)
- swal.hideLoading();
- resolve();
- });
- });
- } else return true;
- },
- // inputValidator: (value) => {
- // return !value && 'Proszę wybrać raport'
- // }
- // html: '<p>Ostatnie raporty:</p>' + '<ul id="' + uniqHtmlId + '"></ul></p>',
- }).then(function (selected) {
- this__enableButton();
- }).catch(function (e) {
- this__enableButton();
- })
- }
- $(document).ready(function(){
- DBG && console.warn('DBG:: SET window[STORE_NAME]', { store: window[STORE_NAME], STORE_NAME: STORE_NAME, globalRaportStore })
- ReactDOM.render(
- h(P5UI__Anton1Header, {
- store: globalRaportStore
- }),
- document.getElementById('bi_audit_header')
- );
- rootChangeForm();
- updateTopCounters();
- var unsubscribe = globalRaportStore.subscribe(function () {
- // TODO: fetch data from globalRaportStore.getState()
- // var defaultState = global[STORE_NAME + '__defaults']();
- })
- $(window).on('hashchange', function() {
- DBG && console.warn("$(window).on('hashchange', ...")
- rootChangeForm();
- updateTopCounters();
- hideMoreRecordFunctionsPopover()
- });
- });
- global.hideMoreRecordFunctionsPopover = function() {
- if (RECORD_MORE_FUNCTIONS_OPENED_NODE) jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('destroy')
- }
- global.pracownicyLoadMoreRecordFunctions = function(event, node, rowPK) {
- return loadMoreRecordFunctions(event, node, rowPK, "default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY")
- }
- global.kontrahenciLoadMoreRecordFunctions = function(event, node, rowPK) {
- return loadMoreRecordFunctions(event, node, rowPK, "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI")
- }
- global.removeFiltersPracownicy = removeFiltersPracownicy;
- global.removeFiltersKontrahenci = removeFiltersKontrahenci;
- global.onChangeFiltersPracownicy = onChangeFiltersPracownicy;
- global.onKeypressFiltersPracownicy = onKeypressFiltersPracownicy;
- global.onChangeFiltersKontrahenci = onChangeFiltersKontrahenci;
- global.onKeypressFiltersKontrahenci = onKeypressFiltersKontrahenci;
- global.checkAll = checkAll;
- global.checkedChoiseItems = checkedChoiseItems;
- global.catchEventCheckbox = catchEventCheckbox;
- global.clearSelectedCheckbox = clearSelectedCheckbox;
- global.getNameGroupById = getNameGroupById;
- global.createGroupPracownicy = createGroupPracownicy;
- global.createGroupKontrahenci = createGroupKontrahenci;
- global.selectPage = selectPage;
- global.detectChoiseFilter = detectChoiseFilter;
- global.updateListIdBiAuditReaport = updateListIdBiAuditReaport;
- global.deleteListIdBiAuditReaport = deleteListIdBiAuditReaport;
- global.urlFetchPracownicy = urlFetchPracownicy;
- global.urlFetchKontrahenci = urlFetchKontrahenci;
- global.getAddressData = getAddressData;
- global.Pagination = Pagination;
- global.todo__fetchRaport = todo__fetchRaport;
- global.setItemLocalStorage = setItemLocalStorage;
- global.getItemLocalStorage = getItemLocalStorage;
- global.deleteItemLocalStorage = deleteItemLocalStorage;
- global.removeItemInArray = removeItemInArray;
- global.removeItemArrayInArray = removeItemArrayInArray;
- global.addPracownikToGroup = addPracownikToGroup;
- global.addPracownikAllToGroup = addPracownikAllToGroup;
- global.addKontrahenciToGroup = addKontrahenciToGroup;
- global.addKontrahenciAllToGroup = addKontrahenciAllToGroup;
- global.createPracownikAjax = createPracownikAjax;
- global.createKontrahentAjax = createKontrahentAjax;
- global.removePracownikFromGroup = removePracownikFromGroup;
- global.removeKontrahenciFromGroup = removeKontrahenciFromGroup;
- global.showViewUploadFile = showViewUploadFile;
- global.parseCsvFile = parseCsvFile;
- global.clearListLocalStorageByType = clearListLocalStorageByType;
- // message
- global.messageCriticalSearchData = 'Krytyczne wielkości danych do przeszukania. Optymalna wartość głębokość szukania powiaząń to: 6';
|