config.js 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969
  1. //JS버전
  2. var today = new Date();
  3. const js_version = itp_fn_date_format(today);
  4. requirejs.config({
  5. baseUrl: ITP_CONTEXTPATH,
  6. paths: {
  7. 'jquery': 'js/jquery.min',
  8. 'jquery-ui': 'js/jquery-ui.min',
  9. 'jquery.number': 'js/jquery.number',
  10. 'jquery.sortable': 'js/jquery.ui.sortable',
  11. 'jquery.grid.addons': 'plugins/grid.addons',
  12. 'jquery.bootstrap': 'bootstrap/dist/js/bootstrap.min',
  13. 'jquery.bootstrap.treeview': 'bootstrap/dist/js/bootstrap-treeview',
  14. 'jquery.bootstrap.fileUpload': 'bootstrap-fileUpload/dist/bootstrap-FileUpload.js?version='+js_version,
  15. 'jquery.bootstrap.datepicker': 'bootstrap-datepicker/js/bootstrap-datepicker',
  16. 'jquery.bootstrap.datepicker.locale': 'bootstrap-datepicker/locales/bootstrap-datepicker.' + ITP_LANGUAGE + '.min',
  17. 'jquery.rwdImageMaps': 'js/jquery.rwdImageMaps',
  18. 'jquery.maphilight': 'js/jquery.maphilight.min',
  19. 'jquery.jqGrid': 'js/jquery.jqGrid',
  20. 'jquery.jqGrid.grouping': 'js/grid.grouping',
  21. 'jquery.jqGrid.inlinedit': 'js/grid.inlinedit',
  22. 'jquery.jqGrid.formedit': 'js/grid.formedit',
  23. 'jquery.jqGrid.celledit': 'js/grid.celledit',
  24. 'jquery.jqGrid.treegrid': 'js/grid.treegrid',
  25. 'jquery.jqGrid.fmatter': 'js/jquery.fmatter',
  26. 'jquery.jqGrid.locale': 'js/i18n/grid.locale-' + ITP_LANGUAGE,
  27. 'smarteditor2': 'se2/js/service/HuskyEZCreator',
  28. 'message.locale': 'js/app/locales/locale-' + ITP_LANGUAGE + '.js?version='+js_version,
  29. 'kakao.postcode': 'https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2',
  30. 'kakao.maps': 'https://dapi.kakao.com/v2/maps/sdk.js?appkey=a2ce7c66185a5413095b6485ac9ad3cd&libraries=services,clusterer&autoload=false',
  31. 'file.saver': 'js/FileSaver.min', // 엑셀 다운로드 (JSON 데이터를 파일로 전환)
  32. 'xlsx': 'js/xlsx.full.min', // 엑셀 다운로드 (JSON 데이터를 파일로 전환)
  33. 'html2canvas': 'js/html2canvas.min', // PDF 다운로드 (html 객체를 canvas로 변환)
  34. 'jspdf': 'js/jspdf.min', // PDF 다운로드 (html, 이미지, canvas 객체를 pdf로 변환)
  35. // 'jspdf.autotable': 'js/jspdf.plugin.autotable.min', // PDF 다운로드 (html, 이미지, canvas 객체를 pdf로 변환)
  36. 'crypto': 'js/crypto', //Crypto 암호화 js
  37. 'check': 'js/check.js?version='+js_version //
  38. },
  39. shim: {
  40. 'jquery.bootstrap': {
  41. deps: [
  42. 'jquery',
  43. 'jquery-ui'
  44. ]
  45. },
  46. 'jquery.bootstrap.treeview': {
  47. deps: ['jquery.bootstrap']
  48. },
  49. 'jquery.bootstrap.fileUpload': {
  50. deps: ['jquery.bootstrap']
  51. },
  52. 'jquery.bootstrap.datepicker.locale': {
  53. deps: [
  54. 'jquery.bootstrap',
  55. 'jquery.bootstrap.datepicker'
  56. ]
  57. },
  58. 'jquery.jqGrid.locale': {
  59. deps: [
  60. 'jquery.jqGrid',
  61. 'jquery.jqGrid.grouping',
  62. 'jquery.jqGrid.inlinedit',
  63. 'jquery.jqGrid.formedit',
  64. 'jquery.jqGrid.celledit',
  65. 'jquery.jqGrid.treegrid',
  66. 'jquery.jqGrid.fmatter'
  67. ]
  68. },
  69. 'xlsx': {
  70. deps: ['file.saver']
  71. },
  72. 'jspdf': {
  73. deps: [
  74. // 'jspdf.autotable',
  75. 'html2canvas'
  76. ]
  77. }
  78. }
  79. });
  80. require([
  81. 'jquery',
  82. 'jquery.bootstrap',
  83. 'jquery.bootstrap.datepicker.locale',
  84. 'jquery.jqGrid.locale',
  85. 'message.locale'
  86. ], function($) {
  87. $.jgrid.styleUI.Bootstrap.base.rowTable = 'table table-bordered table-striped';
  88. $.jgrid.defaults.styleUI = 'Bootstrap';
  89. $.jgrid.defaults.datatype = 'json';
  90. $.jgrid.defaults.mtype = 'POST';
  91. $.jgrid.defaults.width = 782;
  92. $.jgrid.defaults.height = '100%';
  93. $.jgrid.defaults.autowidth = true;
  94. $.jgrid.defaults.shrinkToFit = true;
  95. $.jgrid.defaults.viewrecords = true;
  96. $.jgrid.defaults.altRows = true;
  97. $.jgrid.defaults.loadonce = false;
  98. $.jgrid.defaults.resizable = true;
  99. $.jgrid.defaults.multiSort = false;
  100. $.jgrid.defaults.cellEdit = false;
  101. $.jgrid.defaults.multiselect = true;
  102. $.jgrid.defaults.multiboxonly = true;
  103. $.jgrid.defaults.outoencode = true;
  104. $.jgrid.defaults.cellsubmit = 'clientArray';
  105. $.jgrid.defaults.page = 1;
  106. $.jgrid.defaults.rowNum = 20;
  107. $.jgrid.defaults.rownumWidth = 50;
  108. //$.jgrid.defaults.multiselectWidth = 30;
  109. $.jgrid.defaults.jsonReader = {
  110. root: 'gridRows',
  111. page: 'gridPage',
  112. total: 'gridTotal',
  113. records: 'gridRecords',
  114. repeatitems: false,
  115. cell: 'cell'
  116. };
  117. $.jgrid.defaults.ajaxGridOptions = {
  118. contentType: 'application/json'
  119. };
  120. $.jgrid.defaults.treeGridModel = 'adjacency';
  121. $.jgrid.defaults.ExpandColClick = true;
  122. $.jgrid.defaults.tree_root_level = 0;
  123. $.jgrid.defaults.treeReader = {
  124. level_field: 'level',
  125. leaf_field: 'leaf'
  126. };
  127. history.pushState(null, null, location.href);
  128. window.onpopstate = function () {
  129. itp_fn_modal_alert(ITP_MSG_LOCALE.message.page.noBack);
  130. history.go(1);
  131. };
  132. $('[data-toggle="tooltip"]').tooltip();
  133. $('.modal.itp_modal .modal-content').draggable();
  134. itp_fn_set_timeout.init();
  135. $('#ITP_BTN_HOME').on('click', function() {
  136. location.replace(ITP_CONTEXTPATH + '/main.html');
  137. });
  138. $('#ITP_BTN_USER').on('click', function() {
  139. itp_fn_call_popup(ITP_CONTEXTPATH + '/COMMONPOP_USER', '#ITP_ASIDE', 'COMMONPOP_USER', null, undefined, null, null);
  140. });
  141. $('#ITP_BTN_MENU').on('click', function() {
  142. //$('#ITP_OVERLAY').toggle();
  143. $('#ITP_SIDEBAR').toggleClass('itp_open_nav');
  144. $('#ITP_CONTAINER').toggleClass('itp_open_conts');
  145. itp_fn_fire_window_resize();
  146. /*
  147. $('#ITP_OVERLAY').off('click');
  148. $('#ITP_OVERLAY').on('click', function() {
  149. $('#ITP_OVERLAY').hide();
  150. $('#ITP_SIDEBAR').removeClass('itp_open_nav');
  151. });
  152. */
  153. });
  154. $('#ITP_SIDEBAR .accordion-toggle').off('click');
  155. $('#ITP_SIDEBAR .accordion-toggle').on('click', function() {
  156. $(this).find('i.indicator').toggleClass('glyphicon-chevron-down glyphicon-chevron-up');
  157. });
  158. $('#ITP_HEADER .itp_tab_list').on('click', '.itp_tab_open', function() {
  159. // console.log('[ITP_TAB_OPEN] CALL');
  160. //로그인체크
  161. itp_fn_logined_check();
  162. itp_fn_fire_window_resize();
  163. });
  164. $('#ITP_HEADER .itp_tab_list').on('click', '.itp_tab_close', function() {
  165. var tab_id = $(this).attr('data-itp-tab-id');
  166. var li = $(this).closest('li');
  167. var tabSize = $('#ITP_HEADER .itp_tab_list li').size() - 1;
  168. var curIdx = li.index();
  169. $('#ITP_TAB_' + tab_id).remove();
  170. $(this).closest('li').remove();
  171. if(curIdx === tabSize) {
  172. $('#ITP_HEADER .itp_tab_list li').removeClass('active');
  173. $('#ITP_CONTAINER .itp_contents .itp_sec').removeClass('active');
  174. // $('#ITP_HEADER .itp_tab_list li:first-child').addClass('active');
  175. // $('#ITP_CONTAINER .itp_contents .itp_sec:first-child').addClass('active');
  176. $('#ITP_HEADER .itp_tab_list li').eq(curIdx - 1).addClass('active');
  177. $('#ITP_CONTAINER .itp_contents .itp_sec').eq(curIdx - 1).addClass('active');
  178. itp_fn_fire_window_resize();
  179. }
  180. return false;
  181. });
  182. $('#ITP_CONTAINER').on('click', '.itp_srh_wrap_toggle .itp_srh_close', function() {
  183. var wrap = $(this).closest('.itp_srh_wrap_toggle');
  184. wrap.addClass('itp_srh_list_close');
  185. wrap.find('.itp_srh_toggle').addClass('itp_hide_away');
  186. wrap.find('.itp_srh_head').addClass('itp_height_full');
  187. wrap.find('.itp_srh_tab_toggle').hide();
  188. $(this).removeClass('show');
  189. $(this).addClass('hidden');
  190. $(this).next().removeClass('hidden');
  191. $(this).next().addClass('show');
  192. itp_fn_fire_window_resize();
  193. });
  194. $('#ITP_CONTAINER').on('click', '.itp_srh_wrap_toggle .itp_srh_open', function() {
  195. var wrap = $(this).closest('.itp_srh_wrap_toggle');
  196. wrap.removeClass('itp_srh_list_close');
  197. wrap.find('.itp_srh_toggle').removeClass('itp_hide_away');
  198. wrap.find('.itp_srh_head').removeClass('itp_height_full');
  199. wrap.find('.itp_srh_tab_toggle').show();
  200. $(this).removeClass('show');
  201. $(this).addClass('hidden');
  202. $(this).prev().removeClass('hidden');
  203. $(this).prev().addClass('show');
  204. itp_fn_fire_window_resize();
  205. });
  206. $('#ITP_HEADER #ITP_LOGIN_USER').on('click', function() {
  207. const key = {viewCd: 'R', userId: USER_ID};
  208. var param = $.param(key);
  209. var popFn = function(result) {
  210. };
  211. fn_call_popup('comm', 'USER_INFO_MODIFY_POPUP', '#ITP_ASIDE', popFn, param, 'S');
  212. $('#ITP_USER_INFO_MODIFY_POPUP > div.modal-dialog').width('500px');
  213. });
  214. $('#ITP_CONTAINER').on('keyup', 'input, textarea', function() {
  215. var $th = $(this);
  216. $th.val($th.val().replace(/(<([^>]+)>)/ig, function() {return '';}));
  217. });
  218. $.fn.clearForm = function() {
  219. return this.each(function() {
  220. var type = this.type, tag = this.tagName.toLowerCase();
  221. if (tag == 'form')
  222. return $(':input',this).clearForm();
  223. if (type == 'text' || type == 'password' || tag == 'textarea'|| type == 'hidden')
  224. this.value = '';
  225. else if (type == 'checkbox' || type == 'radio')
  226. this.checked = false;
  227. else if (tag == 'select')
  228. this.selectedIndex = -1;
  229. });
  230. };
  231. $.fn.serializeObject = function() {
  232. var result = {};
  233. var extend = function(i, element) {
  234. var node = result[element.name];
  235. if ('undefined' !== typeof node && node !== null) {
  236. if ($.isArray(node)) {
  237. node.push($.trim(element.value));
  238. } else {
  239. result[element.name] = [node, $.trim(element.value)];
  240. }
  241. } else {
  242. result[element.name] = $.trim(element.value);
  243. }
  244. }
  245. $.each(this.serializeArray(), extend);
  246. return result;
  247. };
  248. $.fn.extend({
  249. treed: function(o) {
  250. var openedClass = 'glyphicon-minus text-primary';
  251. var closedClass = 'glyphicon-plus text-primary';
  252. if (typeof o != 'undefined') {
  253. if (typeof o.openedClass != 'undefined') {
  254. openedClass = o.openedClass;
  255. }
  256. if (typeof o.closedClass != 'undefined') {
  257. closedClass = o.closedClass;
  258. }
  259. };
  260. var tree = $(this);
  261. tree.addClass('tree');
  262. tree.find('li').has('ul').each(function() {
  263. var branch = $(this);
  264. branch.find('.list-group-item').first().prepend('<i class="indicator glyphicon ' + closedClass + '"></i>');
  265. branch.addClass('branch');
  266. branch.on('click', function(e) {
  267. if (this == e.target) {
  268. var icon = $(this).find('.list-group-item').first().children('i:first');
  269. icon.toggleClass(openedClass + ' ' + closedClass);
  270. $(this).children('ul').children().toggle();
  271. }
  272. });
  273. branch.children('ul').children().toggle();
  274. //branch.children('ul').children().show();
  275. });
  276. tree.find('.branch .indicator').each(function() {
  277. $(this).on('click', function() {
  278. $(this).closest('li').click();
  279. return false;
  280. });
  281. });
  282. }
  283. });
  284. const newPostParam = {
  285. openYn: $('#ITP_CONTAINER').data('openYn'),
  286. navId: $('#ITP_CONTAINER').data('navId'),
  287. titId: $('#ITP_CONTAINER').data('titId')
  288. };
  289. if (newPostParam.openYn == 'Y') {itp_fn_open_tab(newPostParam);}
  290. // 로그아웃 버튼
  291. $('.ITP_BTN_LOGOUT').click(function() {
  292. fnLogout();
  293. });
  294. // 로그인 여부 체크
  295. var pathname = $(location).attr('pathname');
  296. if(pathname.indexOf('login.html') < 0) {
  297. itp_fn_logined_check(true, function() {
  298. if (VIEW_PAGE != 'LOGIN') { //main.html 이 load 되면 기본 정보 데이터를 불러온다.
  299. var data = JSON.parse(sessionStorage.getItem('itp_login_info'));
  300. CONN_KEY = data.connKey; //로그인 했을때 넣었던 키를 가져옴
  301. var callbackFn = function(result) {
  302. console.log(result);
  303. CODE_LIST = result.codeList;
  304. AUTH_MENU_LIST = result.authMenuList;
  305. ACT_LIST = result.actList;
  306. POP_LIST = result.popList;
  307. USER_ID = result.userId;
  308. USER_NM = result.userNm;
  309. USER_TYPE_CD = result.userTypeCd;
  310. AUTH_TYPE_CD = result.authTpCd;
  311. AUTH_TYPE_NM = result.authTpNm;
  312. AFFL_SHOP_LIST = result.afflList;
  313. AFFL_BRAND_LIST = result.brandList;
  314. /*
  315. if(FRCOMP_LIST.length > 0) {
  316. let itp_manage_cmpy_cd = '';
  317. let data = JSON.parse(sessionStorage.getItem('itp_manage_cmpy_cd'));
  318. if(data != null && data != undefined ) {
  319. itp_manage_cmpy_cd = data.cmpyCd;
  320. }
  321. let check = false;
  322. $.each(FRCOMP_LIST, function(idx, value) {
  323. if(value.cmpyCd == itp_manage_cmpy_cd) {
  324. check = true;
  325. }
  326. });
  327. if(!check) {
  328. sessionStorage.setItem('itp_manage_cmpy_cd', JSON.stringify(FRCOMP_LIST[0])); // 가맹점정보
  329. }
  330. } else {
  331. // sessionStorage.removeItem('itp_manage_cmpy_cd');
  332. */
  333. sessionStorage.setItem('itp_manage_cmpy_cd', '{}');
  334. //}
  335. // 사용자명
  336. $('#ITP_LOGIN_USER').text(USER_NM);
  337. // 가맹점 만들기
  338. fn_make_affl_brand.init();
  339. // 왼쪽 메뉴 만들기
  340. fn_make_side_menu();
  341. // 메뉴 요약
  342. fn_make_menu_summary();
  343. // 메인 팝업 띄우기
  344. fn_proc_popup_view('M');
  345. };
  346. fn_ajax_call('/api/session/data', null, callbackFn, 'GET');
  347. }
  348. });
  349. }
  350. });
  351. function fn_make_menu_summary() {
  352. $('#ITP_AJAX_SUMMARY_DETAIL_CONTAINER #ITP_SUMMARY_jqGrid_list tbody tr').css('display','none');
  353. $('#ITP_AJAX_SUMMARY_DETAIL_CONTAINER #ITP_SUMMARY_jqGrid_list tbody .USER_TYPE_'+USER_TYPE_CD).show();
  354. }
  355. var fn_make_affl_brand = {
  356. init : function() {
  357. this.make();
  358. this.action();
  359. },
  360. make: function () {
  361. sessionStorage.setItem('itp_manage_cmpy_cd', (AFFL_BRAND_LIST.length < 1) ? '' : JSON.stringify(AFFL_BRAND_LIST[0]));
  362. let authTypeNm = (AUTH_TYPE_NM === undefined) ? '오더퀸' : AUTH_TYPE_NM;
  363. $('#ITP_TXT_MAIN_SHR_AFFL').text(authTypeNm);
  364. },
  365. action: function () {
  366. $('#ITP_BTN_MAIN_SHR_AFFL').on('click', function() {
  367. // 팝업
  368. var popFn = function(rowDataPop) {
  369. console.log(rowDataPop);
  370. // sessionStorage.setItem('itp_manage_cmpy_cd', JSON.stringify(AFFL_BRAND_LIST[0]));
  371. // $('#ITP_TXT_MAIN_SHR_CMPY').text(AFFL_BRAND_LIST[0].brandNm);
  372. $.each(rowDataPop, function(key, value) {
  373. itp_fn_close_other_tab(''); // 다른탭 닫기
  374. $('#ITP_TXT_MAIN_SHR_BRAND').text('(' + value.brandNm + ')');
  375. sessionStorage.setItem('itp_manage_brand_cd', JSON.stringify(value));
  376. });
  377. };
  378. fn_call_popup('biz', 'BIZPOP_AFFL_BRAND', '#ITP_ASIDE', popFn, null, 'S');
  379. });
  380. }
  381. };
  382. function fn_make_side_menu() {
  383. $('#ITP_SIDEBAR .panel-group').empty();
  384. $.each(AUTH_MENU_LIST, function(key, value) {
  385. // console.log(JSON.stringify(value));
  386. if(value.level == 2) { // LEVEL2
  387. $('#ITP_SIDEBAR .panel-group').append($('#ITP_AJAX_MAIN_SIDE_LEVEL2_ROWCOPY').val());
  388. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.fnMenuNm').text(value.menuNm);
  389. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.accordion-toggle').attr('href', '#ITP_NAV_'+value.menuNo);
  390. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.panel-collapse').attr('id', 'ITP_NAV_'+value.menuNo);
  391. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.fnLevelBottomList').empty();
  392. } else if(value.level == 3) { // LEVEL3
  393. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.fnLevelBottomList').append($('#ITP_AJAX_MAIN_SIDE_LEVEL3_ROWCOPY').val());
  394. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.fnMenuNm').text(value.menuNm);
  395. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-itp-nav-id', value.menuId);
  396. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-conn-url', value.connUrl);
  397. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-open-cd', value.openCd);
  398. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('id', value.menuId + '_PAGE_NO');
  399. } else if(value.level == 4) { // LEVEL4
  400. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.fnLevelBottomList').append($('#ITP_AJAX_MAIN_SIDE_LEVEL4_ROWCOPY').val());
  401. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.fnMenuNm').text(value.menuNm);
  402. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-itp-nav-id', value.menuId);
  403. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-conn-url', value.connUrl);
  404. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-open-cd', value.openCd);
  405. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('id', value.menuId + '_PAGE_NO');
  406. } else if(value.level == 5) { // LEVEL5
  407. $('#ITP_SIDEBAR .panel-group > .panel-default:last').find('.fnLevelBottomList').append($('#ITP_AJAX_MAIN_SIDE_LEVEL5_ROWCOPY').val());
  408. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.fnMenuNm').text(value.menuNm);
  409. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-itp-nav-id', value.menuId);
  410. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-conn-url', value.connUrl);
  411. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('data-open-cd', value.openCd);
  412. $('#ITP_SIDEBAR .panel-group > .panel-default:last .fnLevelBottomList .itp_svg_in:last').find('.itp_nav_link').attr('id', value.menuId + '_PAGE_NO');
  413. }
  414. });
  415. $('#ITP_SIDEBAR .itp_nav_link').off('click');
  416. $('#ITP_SIDEBAR .itp_nav_link').on('click', function() {
  417. const id = $(this).attr('data-itp-nav-id');
  418. const connUrl = $(this).attr('data-conn-url');
  419. const openCd = $(this).attr('data-open-cd');
  420. // const path = '/app/'+id.substring(0, id.length - 5).toLowerCase();
  421. const tabSize = $('#ITP_HEADER .itp_tab_list li').size();
  422. console.log('[ITP_NAV_LINK] data-itp-nav-id = ' + id + ', data-conn-url = ' + connUrl + ', tabSize = ' + tabSize);
  423. // if(String(id).indexOf('OPER') === -1 && String(id).indexOf('SYSTEM') === -1 && !sessionStorage.getItem('itp_manage_brand_cd')) {
  424. // itp_fn_modal_alert(ITP_MSG_LOCALE.message.page.noChoiceBrand);
  425. // return false;
  426. // }
  427. if (tabSize > 10) {
  428. itp_fn_modal_alert(ITP_MSG_LOCALE.message.page.noMoreTab);
  429. return false;
  430. }
  431. let isDup = false;
  432. $('#ITP_HEADER .itp_tab_list li').each(function() {
  433. const tab_id = $(this).find('.itp_tab_close').attr('data-itp-tab-id');
  434. if (tab_id == id) {
  435. isDup = true;
  436. $('#ITP_HEADER .itp_tab_list li').removeClass('active');
  437. $('#ITP_CONTAINER .itp_contents .itp_sec').removeClass('active');
  438. $(this).addClass('active');
  439. $('#ITP_TAB_' + id).addClass('active');
  440. return false;
  441. }
  442. });
  443. if (!isDup && openCd == 'C') {
  444. const href = ITP_CONTEXTPATH + connUrl; // $(this).attr('href');
  445. const text = $(this).children('.itp_tt').text();
  446. const tab = '<li class="active"><a href="#ITP_TAB_' + id + '" role="tab" data-toggle="tab" class="itp_tab_open">' + text + ' <i class="glyphicon glyphicon-remove itp_tab_close" data-itp-tab-id="' + id + '"></i></a></li>';
  447. itp_fn_load_page(href, tab, '', id);
  448. } else {
  449. itp_fn_fire_window_resize();
  450. }
  451. return false;
  452. });
  453. }
  454. function fn_proc_btn_auth(menu_id) {
  455. $.each(ACT_LIST, function(key, value) {
  456. if(menu_id == value.menuId) {
  457. if(value.viewYn == 'Y') {
  458. $('#ITP_TAB_' + menu_id).find('.'+value.actTpCd).addClass('SHOW');
  459. } else {
  460. $('#ITP_TAB_' + menu_id).find('.'+value.actTpCd).removeClass('SHOW');
  461. }
  462. }
  463. });
  464. $('#ITP_TAB_' + menu_id + ' button').each(function(index, item) {
  465. // console.log('id = ' + item.id);
  466. if(item.id && item.id != '') {
  467. $('#'+item.id).hide();
  468. if($('#'+item.id).hasClass('SHOW')) {
  469. $('#'+item.id).show();
  470. }
  471. }
  472. });
  473. // 가맹점검색 버튼 처리
  474. if(USER_TYPE_CD == 'N' || USER_TYPE_CD == 'P') { // 내부사용자&영업
  475. $('#ITP_TXT_'+menu_id+'_SHR_CMPY').show();
  476. $('#ITP_BTN_'+menu_id+'_SHR_CMPY').show();
  477. } else {
  478. $('#ITP_TXT_'+menu_id+'_SHR_CMPY').hide();
  479. $('#ITP_BTN_'+menu_id+'_SHR_CMPY').hide();
  480. }
  481. fn_proc_popup_view('S', menu_id); // 팝업처리
  482. }
  483. function fn_proc_popup_view(view_target_cd, menu_id) {
  484. var sIdx=0;
  485. var mIdx=0;
  486. var lIdx=0;
  487. $.each(POP_LIST, function(key, value) {
  488. if('S' == view_target_cd && 'S' == value.viewTargetCd && value.menuId == menu_id) {
  489. // 팝업처리
  490. console.log('[POPUP_VIEW:S]' + value.popNo);
  491. if(itp_fn_get_cookie(value.popNo) != 'Y') {
  492. fn_popup_window_center('popup.html?popNo='+value.popNo, value.popNo, value.popWidth, value.popHeight, sIdx);
  493. }
  494. sIdx++;
  495. } else if('M' == view_target_cd && 'M' == value.viewTargetCd) {
  496. // 팝업처리
  497. console.log('[POPUP_VIEW:M]' + value.popNo + ', mIdx : ' + mIdx);
  498. if(itp_fn_get_cookie(value.popNo) != 'Y') {
  499. fn_popup_window_center('popup.html?popNo='+value.popNo, value.popNo, value.popWidth, value.popHeight, mIdx);
  500. }
  501. mIdx++;
  502. } else if('L' == view_target_cd && 'L' == value.viewTargetCd) {
  503. // 팝업처리
  504. console.log('[POPUP_VIEW:L]' + value.popNo + ', lIdx : ' + lIdx);
  505. if(itp_fn_get_cookie(value.popNo) != 'Y') {
  506. fn_popup_window_center('popup.html?popNo='+value.popNo, value.popNo, value.popWidth, value.popHeight, lIdx);
  507. }
  508. lIdx++;
  509. }
  510. });
  511. }
  512. function fn_show_btn_auth(btn_id) {
  513. if($(btn_id).hasClass('SHOW')) {
  514. $(btn_id).show();
  515. } else {
  516. $(btn_id).hide();
  517. }
  518. }
  519. function fn_make_select(options, code, select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  520. $select_id = $('#' + select_id);
  521. $select_id.empty();
  522. $.each(options, function(key, value) {
  523. if (value.codeCd == code) {
  524. if(all_show_yn == undefined || all_show_yn == true) {
  525. if(all_name == undefined || all_name == '') {
  526. $('<option/>', {'value': '', 'text': value.codeNm}).prependTo($select_id);
  527. } else {
  528. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  529. }
  530. }
  531. $.each(value.codeDtlList, function(k, val) {
  532. $('<option/>', {
  533. 'value': val.codeDtlCd,
  534. 'text': val.codeDtlNm
  535. }).appendTo($select_id);
  536. });
  537. return false;
  538. }
  539. });
  540. };
  541. function fn_make_select_upper_menu(options, select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  542. $select_id = $('#' + select_id);
  543. $select_id.empty();
  544. if(all_show_yn == true) {
  545. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  546. }
  547. $.each(options, function(key, value) {
  548. if (value.level == 3) {
  549. $('<option/>', {
  550. 'value': value.menuNo,
  551. 'text': value.menuNm
  552. }).appendTo($select_id);
  553. }
  554. });
  555. };
  556. function fn_make_select_brand(options, select_id, all_show_yn, all_name) { //브랜드 셀렉트 박스 만들기
  557. $select_id = $('#' + select_id);
  558. $select_id.empty();
  559. if(all_show_yn == true) {
  560. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  561. }
  562. $.each(options, function(key, value) {
  563. $('<option/>', {
  564. 'value': value.brandId, // 브랜드코드
  565. 'text': value.brandNm // 브랜드명
  566. }).appendTo($select_id);
  567. });
  568. };
  569. function fn_make_select_store(options, select_id, all_show_yn, all_name, all_value) { //매장 셀렉트 박스 만들기
  570. $select_id = $('#' + select_id);
  571. $select_id.empty();
  572. if(all_show_yn == true) {
  573. $('<option/>', {'value': !all_value || all_value == undefined ? '' : all_value, 'text': all_name}).prependTo($select_id);
  574. }
  575. $.each(options, function(key, value) {
  576. $('<option/>', {
  577. 'value': value.storeNo, // 매장번호
  578. 'data-sale-store-no': value.saleStoreNo, // 판매매장번호
  579. 'text': value.storeNm // 매장명
  580. }).appendTo($select_id);
  581. });
  582. };
  583. function fn_make_select_pos(options, select_id, all_show_yn, all_name) { //포스 셀렉트 박스 만들기
  584. $select_id = $('#' + select_id);
  585. $select_id.empty();
  586. if(all_show_yn == true) {
  587. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  588. }
  589. $.each(options, function(key, value) {
  590. $('<option/>', {
  591. 'value': value.posNo, // 포스번호
  592. 'text': value.posNo // 포스명
  593. }).appendTo($select_id);
  594. });
  595. };
  596. function fn_make_select_van(options, select_id, all_show_yn, all_name) { //매장 셀렉트 박스 만들기
  597. $select_id = $('#' + select_id);
  598. $select_id.empty();
  599. if(all_show_yn == true) {
  600. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  601. }
  602. $.each(options, function(key, value) {
  603. $('<option/>', {
  604. 'value': value.vanCd, // VAN코드
  605. 'text': value.vanNm // VAN명
  606. }).appendTo($select_id);
  607. });
  608. };
  609. function fn_make_select_class(options, select_id, all_show_yn, all_name) { //카테고리 셀렉트 박스 만들기
  610. $select_id = $('#' + select_id);
  611. $select_id.empty();
  612. if(all_show_yn == true) {
  613. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  614. }
  615. if(options == null) {
  616. return;
  617. }
  618. $.each(options, function(key, value) {
  619. $('<option/>', {
  620. 'value': value.classCd,
  621. 'text': value.classNm
  622. }).appendTo($select_id);
  623. });
  624. };
  625. function fn_make_select_corner(options, select_id, all_show_yn, all_name) { //코너 셀렉트 박스 만들기
  626. $select_id = $('#' + select_id);
  627. $select_id.empty();
  628. if(all_show_yn == true) {
  629. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  630. }
  631. $.each(options, function(key, value) {
  632. $('<option/>', {
  633. 'value': value.cornerCd,
  634. 'text': value.cornerNm
  635. }).appendTo($select_id);
  636. });
  637. };
  638. function fn_make_select_workplace(options, select_id, all_show_yn, all_name) { //사업장 셀렉트 박스 만들기
  639. $select_id = $('#' + select_id);
  640. $select_id.empty();
  641. if(all_show_yn == true) {
  642. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  643. }
  644. $.each(options, function(key, value) {
  645. $('<option/>', {
  646. 'value': value.wkpeNo, // 사업장번호
  647. 'text': value.wkpeNm // 사업장명
  648. }).appendTo($select_id);
  649. });
  650. };
  651. function fn_make_select_location(options, select_id, all_show_yn, all_name) { //위치 셀렉트 박스 만들기
  652. $select_id = $('#' + select_id);
  653. $select_id.empty();
  654. if(all_show_yn == true) {
  655. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  656. }
  657. $.each(options, function(key, value) {
  658. $('<option/>', {
  659. 'value': value.lctnNo, // 위치번호
  660. 'text': value.lctnNm // 위치명
  661. }).appendTo($select_id);
  662. });
  663. };
  664. function fn_make_select_category(options, select_id, all_show_yn, all_name) { //카테고리 셀렉트 박스 만들기
  665. $select_id = $('#' + select_id);
  666. $select_id.empty();
  667. if(all_show_yn == true) {
  668. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  669. }
  670. $.each(options, function(key, value) {
  671. $('<option/>', {
  672. 'value': value.cateNo, // 카테고리번호
  673. 'text': value.cateNm // 카테고리명
  674. }).appendTo($select_id);
  675. });
  676. };
  677. function fn_make_year_select(select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  678. $select_id = $('#' + select_id);
  679. $select_id.empty();
  680. if(all_show_yn == true) {
  681. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  682. }
  683. var toDate = new Date();
  684. var current_year = toDate.getFullYear();
  685. var start_year = current_year;
  686. for(var i = start_year ; i <= current_year ; i++) {
  687. $('<option/>', {'value': i, 'text': i + '년'}).appendTo($select_id);
  688. }
  689. $select_id.val(current_year);
  690. };
  691. function fn_make_month_select(select_id, all_show_yn, all_name, start_mon, current_yn, char_yn) { //셀렉트 박스 만들기
  692. $select_id = $('#' + select_id);
  693. $select_id.empty();
  694. if(all_show_yn == true) {
  695. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  696. }
  697. if (!start_mon || start_mon == undefined)
  698. start_mon = 0;
  699. var value;
  700. for(var i = start_mon ; i < 13 ; i++) {
  701. if(i < 10) value = '0' + i;
  702. else value = i;
  703. if(char_yn == true) {
  704. $('<option/>', {'value': value, 'text': value + '월'}).appendTo($select_id);
  705. } else {
  706. $('<option/>', {'value': value, 'text': value}).appendTo($select_id);
  707. }
  708. }
  709. if (current_yn && current_yn == true) {
  710. var toDate = new Date();
  711. var mm = toDate.getMonth() + 1;
  712. mm = (mm < 10) ? '0' + mm : mm;
  713. $select_id.val(mm);
  714. }
  715. };
  716. function fn_make_day_select(select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  717. $select_id = $('#' + select_id);
  718. $select_id.empty();
  719. if(all_show_yn == true) {
  720. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  721. }
  722. var value;
  723. for(var i = 0 ; i < 32 ; i++) {
  724. if(i < 10) value = '0' + i;
  725. else value = i;
  726. $('<option/>', {'value': value, 'text': value}).appendTo($select_id);
  727. }
  728. };
  729. function fn_make_hh_select(select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  730. $select_id = $('#' + select_id);
  731. $select_id.empty();
  732. if(all_show_yn == true) {
  733. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  734. }
  735. var value;
  736. for(var i = 0 ; i < 24 ; i++) {
  737. if(i < 10) value = '0' + i;
  738. else value = i;
  739. $('<option/>', {'value': value, 'text': value}).appendTo($select_id);
  740. }
  741. };
  742. function fn_make_mi_select(select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  743. $select_id = $('#' + select_id);
  744. $select_id.empty();
  745. if(all_show_yn == true) {
  746. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  747. }
  748. var value;
  749. for(var i = 0 ; i < 60 ; i++) {
  750. if(i < 10) value = '0' + i;
  751. else value = i;
  752. $('<option/>', {'value': value, 'text': value}).appendTo($select_id);
  753. }
  754. };
  755. function fn_make_ss_select(select_id, all_show_yn, all_name) { //셀렉트 박스 만들기
  756. $select_id = $('#' + select_id);
  757. $select_id.empty();
  758. if(all_show_yn == true) {
  759. $('<option/>', {'value': '', 'text': all_name}).prependTo($select_id);
  760. }
  761. var value;
  762. for(var i = 0 ; i < 60 ; i++) {
  763. if(i < 10) value = '0' + i;
  764. else value = i;
  765. $('<option/>', {'value': value, 'text': value}).appendTo($select_id);
  766. }
  767. };
  768. function fn_make_input_common_cd(options, code, input_id, all_show_yn) { //HIDDEN 공통코드 리스트 만들기
  769. $input_id = $('#' + input_id);
  770. $input_id.val('');
  771. $.each(options, function(key, value) {
  772. if (value.codeCd == code) {
  773. //예제) :;BN:읽기버튼;BNW:쓰기버튼;LK:링크;MU:메뉴
  774. let code_list = '';
  775. if(all_show_yn == true) {
  776. code_list = code_list + ':';
  777. }
  778. $.each(value.codeDtlList, function(k, val) {
  779. if(k > 0) {
  780. code_list = code_list + ';';
  781. } else if(k == 0 && all_show_yn == true) {
  782. code_list = code_list + ';';
  783. }
  784. code_list = code_list + val.codeDtlCd;
  785. code_list = code_list + ':';
  786. code_list = code_list + val.codeDtlNm;
  787. });
  788. $input_id.val(code_list);
  789. return false;
  790. }
  791. });
  792. };
  793. function fn_make_common_cd_list(options, code, all_show_yn) { // 공통코드 리스트 만들기
  794. // $input_id = $('#' + input_id);
  795. // $input_id.val('');
  796. var return_val;
  797. $.each(options, function(key, value) {
  798. if (value.codeCd == code) {
  799. //예제) :;BN:읽기버튼;BNW:쓰기버튼;LK:링크;MU:메뉴
  800. let code_list = '';
  801. if(all_show_yn == true) {
  802. code_list = code_list + ':';
  803. }
  804. $.each(value.codeDtlList, function(k, val) {
  805. if(k > 0) {
  806. code_list = code_list + ';';
  807. } else if(k == 0 && all_show_yn == true) {
  808. code_list = code_list + ';';
  809. }
  810. code_list = code_list + val.codeDtlCd;
  811. code_list = code_list + ':';
  812. code_list = code_list + val.codeDtlNm;
  813. });
  814. // $input_id.val(code_list);
  815. // return code_list;
  816. return_val = code_list;
  817. }
  818. });
  819. return return_val;
  820. };
  821. function fn_make_input_store_print(options, input_id, all_show_yn) { //HIDDEN 매장프린터 리스트 만들기
  822. $input_id = $('#' + input_id);
  823. $input_id.val('');
  824. let list = '';
  825. if(all_show_yn == true) {
  826. list = list + ':';
  827. }
  828. $.each(options, function(key, value) {
  829. if(key > 0) {
  830. list = list + ';';
  831. } else if(key == 0 && all_show_yn == true) {
  832. list = list + ';';
  833. }
  834. list = list + value.printNo;
  835. list = list + ':';
  836. list = list + value.printNo;
  837. });
  838. $input_id.val(list);
  839. };
  840. function fn_make_input_store_kds(options, input_id, all_show_yn) { //HIDDEN 매장KDS 리스트 만들기
  841. $input_id = $('#' + input_id);
  842. $input_id.val('');
  843. let list = '';
  844. if(all_show_yn == true) {
  845. list = list + ':';
  846. }
  847. $.each(options, function(key, value) {
  848. if(key > 0) {
  849. list = list + ';';
  850. } else if(key == 0 && all_show_yn == true) {
  851. list = list + ';';
  852. }
  853. list = list + value.kdsNo;
  854. list = list + ':';
  855. list = list + value.kdsNo;
  856. });
  857. $input_id.val(list);
  858. };
  859. function fnHashed(code) { //유니코드로 들어오는 해쉬키를 스트링으로 변환
  860. return decodeURIComponent(JSON.parse('"' + code.replace(/\"/g, '\\"') + '"'));
  861. };
  862. function fnLogout() { //로그아웃
  863. var callbackFn = function(result) {
  864. sessionStorage.removeItem('itp_login_info'); //Jwt 키 제거
  865. $(location).attr('href', ITP_CONTEXTPATH + '/login.html');
  866. };
  867. fn_ajax_call('/api/member/sign-out', null, callbackFn, 'PATCH');
  868. };
  869. function fnSessionOut() { //1시간 동안 아무것도 안할때 또는 강제 만료시킬때 사용
  870. var callbackFn = function(result) {
  871. sessionStorage.removeItem('itp_login_info'); //Jwt 키 제거
  872. $(location).attr('href', ITP_CONTEXTPATH + '/login.html');
  873. };
  874. fn_ajax_call('/api/session/expire', null, callbackFn, 'PATCH');
  875. };
  876. //AJAX 양식 (이렇게 사용하시면 됩니다.)
  877. function fn_ajax_call(href, param, fn, type) {
  878. $.ajax({
  879. contentType: 'application/json',
  880. url: DOMAIN + href,
  881. data: param,
  882. type: type,
  883. async: false,
  884. timeout: 10000,
  885. xhrFields: {
  886. withCredentials: true //Cross Domain 처리
  887. },
  888. beforeSend: function(xhr) {
  889. $('#ITP_OVERLAY').show();
  890. xhr.setRequestHeader('X-AUTH-TOKEN', CONN_KEY); //Jwt 토큰을 헤더에 담아서 보낸다.
  891. },
  892. complete: function() {
  893. $('#ITP_OVERLAY').hide();
  894. },
  895. success: function(result) {
  896. if (result.code !== undefined) { //성공시에도 메세지가 있으면 얼럿 예)저장되었습니다.
  897. itp_fn_modal_alert_ajax(result.message);
  898. }
  899. if (fn !== undefined || typeof fn !== 'undefined') fn(result);
  900. },
  901. error: function(xhr, status, error) {
  902. if (xhr.responseJSON !== undefined) { //실패시 서버에서 내려주는 메세지 얼럿
  903. itp_fn_modal_alert_ajax(xhr.responseJSON.message);
  904. if (xhr.status == 401) { //401에러가 떨어지면 로그인페이지로 이동
  905. sessionStorage.removeItem('itp_login_info'); //Jwt 키 제거
  906. $(location).attr('href', ITP_CONTEXTPATH + '/login.html');
  907. }
  908. } else {
  909. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  910. }
  911. },
  912. fail: function() {
  913. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  914. }
  915. });
  916. };
  917. function itp_fn_logined_check(user_nm_update, fn) {
  918. //console.log('[ITP_FN_LOGINED_CHECK] CALL, user_nm_update = ' + user_nm_update);
  919. var now, expiration, data = false;
  920. data = sessionStorage.getItem('itp_login_info');
  921. if(data) {
  922. data = JSON.parse(data);
  923. now = new Date();
  924. expiration = new Date(data.timestamp);
  925. expiration.setMinutes(expiration.getMinutes() + 60);
  926. if (now.getTime() > expiration.getTime()) {
  927. data = false;
  928. fnSessionOut();
  929. } else {
  930. sessionStorage.setItem('itp_login_info', JSON.stringify({
  931. timestamp: new Date(),
  932. connKey: data.connKey //Jwt키를 가져와서 세션 스토리지에 저장
  933. }));
  934. if(user_nm_update && user_nm_update == true) {
  935. if (fn !== undefined || typeof fn !== 'undefined') {
  936. fn();
  937. }
  938. }
  939. }
  940. } else {
  941. // 로그인 페이지로 이동
  942. $(location).attr('href', ITP_CONTEXTPATH + '/login.html');
  943. }
  944. }
  945. function itp_fn_get_code_detail_list(code_cd) {
  946. let map = new Map(JSON.parse(sessionStorage.itp_common_code));
  947. if(map.has(code_cd)) {
  948. return JSON.parse(map.get(code_cd));
  949. } else {
  950. return null;
  951. }
  952. }
  953. const ITP_GRID_NAV_DEFAULTS = {
  954. navGrid: {edit: false, add: false, del: false, refresh: true, view: false, search: false},
  955. inlineNav: {edit: false, add: false, cancel: false, save: false}
  956. };
  957. const ITP_GRID_NUM_WIDTH = {
  958. numWidth: 50,
  959. orderWidth: 70
  960. };
  961. const ITP_GRID_COL_STYLE = {
  962. link: {'color': '#000', 'text-decoration': 'underline', 'font-weight': 'bold', 'cursor': 'pointer'},
  963. selected: {'color': '#337ab7', 'text-decoration': 'underline', 'cursor': 'pointer'},
  964. popup: {'color': '#000', 'text-decoration': 'underline'},
  965. register: {'color': '#337ab7', 'text-decoration': 'underline'},
  966. delete: {'color': '#ac2925', 'text-decoration': 'underline'},
  967. important: {'color': '#ac2925'},
  968. cancel: {'color': '#ac2925', 'background': '#fff3f3'},
  969. blue: {'background': '#f3f8ff'},
  970. pay: {'color': '#337ab7', 'background': '#f3f8ff'},
  971. settle: {'background': '#f1f1f1'}
  972. };
  973. let ITP_UPLOAD_DEFAULTS = {
  974. fileTypes: {
  975. archives: ['zip', '7z', 'gz', 'gzip', 'rar', 'tar']
  976. ,audio: ['mp3', 'wav', 'wma', 'wpl', 'aac', 'flac', 'm4a', 'm4b', 'm4p', 'midi', 'ogg']
  977. ,files: ['doc', 'docx', 'dotx', 'docm', 'ods', 'odt', 'ott', 'ods', 'pdf', 'ppt', 'pptm', 'pptx', 'pub', 'rtf', 'csv', 'log', 'txt', 'xls', 'xlsm', 'xlsx', 'hwp', 'avi', 'mp4']
  978. ,images: ['bmp', 'tif', 'tiff', 'gif', 'jpeg', 'jpg', 'png', 'svg', 'ico', 'raw']
  979. }
  980. };
  981. const ITP_DATE_LANGUAGE = (function() {
  982. let lang = ITP_LANGUAGE;
  983. if (lang == 'en') {lang = ITP_LANGUAGE + '-GB';}
  984. var agrs = {language: lang};
  985. return agrs;
  986. }());
  987. function itp_fn_get_date_lang_format(yyyy, mm, dd, split){
  988. var retVal = '';
  989. if (ITP_LANGUAGE == 'en') {
  990. retVal = mm + split + dd + split + yyyy;
  991. } else {
  992. retVal = yyyy + split + mm + split + dd;
  993. }
  994. return retVal;
  995. };
  996. function itp_fn_get_add_date(sDate, v, split) {
  997. if (split == null || split == undefined) split = '.';
  998. sDate = itp_fn_delete_date_format(sDate);
  999. var yy = parseInt(sDate.substring(0, 4), 10);
  1000. var mm = parseInt(sDate.substring(4, 6), 10);
  1001. var dd = parseInt(sDate.substring(6), 10);
  1002. var d = new Date(yy, mm - 1, dd + v);
  1003. yy = d.getFullYear();
  1004. mm = d.getMonth() + 1; mm = (mm < 10) ? '0' + mm : mm;
  1005. dd = d.getDate(); dd = (dd < 10) ? '0' + dd : dd;
  1006. return itp_fn_get_date_lang_format(yy, mm, dd, split);
  1007. };
  1008. function itp_fn_get_add_date_ko(sDate, v, split) {
  1009. if (split == null || split == undefined) split = '.';
  1010. sDate = itp_fn_delete_date_format(sDate);
  1011. var yy = parseInt(sDate.substring(0, 4), 10);
  1012. var mm = parseInt(sDate.substring(4, 6), 10);
  1013. var dd = parseInt(sDate.substring(6), 10);
  1014. var d = new Date(yy, mm - 1, dd + v);
  1015. yy = d.getFullYear();
  1016. mm = d.getMonth() + 1; mm = (mm < 10) ? '0' + mm : mm;
  1017. dd = d.getDate(); dd = (dd < 10) ? '0' + dd : dd;
  1018. return yy + split + mm + split + dd;
  1019. };
  1020. function itp_fn_get_today(split) {
  1021. var retVal = '';
  1022. if (split == null || split == undefined) split = '.';
  1023. var toDate = new Date();
  1024. var yyyy = toDate.getFullYear();
  1025. var mm = toDate.getMonth()+1;
  1026. var dd = toDate.getDate();
  1027. mm = (mm < 10) ? '0' + mm : mm;
  1028. dd = (dd < 10) ? '0' + dd : dd;
  1029. return itp_fn_get_date_lang_format(yyyy, mm, dd, split);
  1030. };
  1031. function itp_fn_get_bom_today(split) {
  1032. var retVal = '';
  1033. if (split == null || split == undefined) split = '.';
  1034. //var toDate = new Date();
  1035. var yyyy = "2099";
  1036. var mm = "12";
  1037. var dd = "31";
  1038. mm = (mm < 10) ? '0' + mm : mm;
  1039. dd = (dd < 10) ? '0' + dd : dd;
  1040. return itp_fn_get_date_lang_format(yyyy, mm, dd, split);
  1041. };
  1042. function itp_fn_get_today_ko(split) {
  1043. var retVal = '';
  1044. if (split == null || split == undefined) split = '.';
  1045. var toDate = new Date();
  1046. var yyyy = toDate.getFullYear();
  1047. var mm = toDate.getMonth()+1;
  1048. var dd = toDate.getDate();
  1049. mm = (mm < 10) ? '0' + mm : mm;
  1050. dd = (dd < 10) ? '0' + dd : dd;
  1051. return yyyy + split + mm + split + dd;
  1052. };
  1053. function itp_fn_get_before_month(dateStr, addMonth, split) {
  1054. if (split == null || split == undefined) split = '.';
  1055. dateStr = itp_fn_delete_date_format(dateStr);
  1056. var yyyy = dateStr.substring(0,4),
  1057. mm = parseInt(dateStr.substring(4,6), 10),
  1058. dd = parseInt(dateStr.substring(6), 10),
  1059. date = new Date(yyyy, mm-1, dd);
  1060. date.setMonth(date.getMonth() - addMonth);
  1061. yyyy = date.getFullYear();
  1062. mm = date.getMonth()+1;
  1063. dd = date.getDate();
  1064. if (parseInt(mm) < 10) mm = '0' + mm;
  1065. if (parseInt(dd) < 10) dd = '0' + dd;
  1066. return itp_fn_get_date_lang_format(yyyy, mm, dd, split);
  1067. };
  1068. function itp_fn_get_after_month(dateStr, addMonth, split) {
  1069. if (split == null || split == undefined) split = '.';
  1070. dateStr = itp_fn_delete_date_format(dateStr);
  1071. var yyyy = dateStr.substring(0,4),
  1072. mm = parseInt(dateStr.substring(4,6), 10),
  1073. dd = parseInt(dateStr.substring(6), 10),
  1074. date = new Date(yyyy, mm-1, dd);
  1075. date.setMonth(date.getMonth() + addMonth);
  1076. yyyy = date.getFullYear();
  1077. mm = date.getMonth()+1;
  1078. dd = date.getDate();
  1079. if (parseInt(mm) < 10) mm = '0' + mm;
  1080. if (parseInt(dd) < 10) dd = '0' + dd;
  1081. return itp_fn_get_date_lang_format(yyyy, mm, dd, split);
  1082. };
  1083. function itp_fn_get_last_day(dateStr, month, split) {
  1084. if (split == null || split == undefined) split = '.';
  1085. var _tmp = '';
  1086. if (dateStr == null || dateStr == undefined) _tmp = itp_fn_get_today_ko('');
  1087. else _tmp = itp_fn_delete_date_format(dateStr);
  1088. var yyyy = _tmp.substring(0,4),
  1089. mm = _tmp.substring(4,6);
  1090. if (month != null && month != undefined) mm = month;
  1091. var dd = (new Date(yyyy,mm,0)).getDate();
  1092. return itp_fn_get_date_lang_format(yyyy, mm, dd, split);
  1093. };
  1094. function itp_fn_get_first_day(dateStr, split) {
  1095. if (split == null || split == undefined) split = '.';
  1096. var _tmp = '';
  1097. if (dateStr == null || dateStr == undefined) _tmp = itp_fn_get_today_ko('');
  1098. else _tmp = itp_fn_delete_date_format(dateStr);
  1099. var yyyy = _tmp.substring(0,4)
  1100. ,mm = _tmp.substring(4,6)
  1101. ,dd = '01';
  1102. return itp_fn_get_date_lang_format(yyyy, mm, dd, split);
  1103. };
  1104. function itp_fn_delete_date_format(str) {
  1105. var temp = '';
  1106. for (var i = 0; i < str.length; i++) {
  1107. if (str.charAt(i) == '-' || str.charAt(i) == '.' || str.charAt(i) == '/' || str.charAt(i) == ':') {
  1108. continue;
  1109. } else {
  1110. temp += str.charAt(i);
  1111. }
  1112. }
  1113. return temp;
  1114. };
  1115. function itp_fn_get_url_param(name) {
  1116. var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
  1117. if (results == null) {
  1118. return null;
  1119. } else {
  1120. return results[1] || 0;
  1121. }
  1122. };
  1123. var itp_fn_get_param_value = function(params, key){
  1124. var results = new RegExp('[\?&]' + key + '=([^&#]*)').exec(params);
  1125. if (results==null){
  1126. return null;
  1127. }
  1128. else{
  1129. return results[1] || 0;
  1130. }
  1131. }
  1132. function itp_fn_close_other_tab(tabId) {
  1133. $('#ITP_HEADER .itp_tab_list li').each(function() {
  1134. var tmpId = $(this).find('.itp_tab_close').attr('data-itp-tab-id');
  1135. if(tmpId) {
  1136. // console.log('### MEMU : ' + tmpId + ', ACTIVE : ' + $(this).hasClass('active'));
  1137. if($(this).hasClass('active') == false && tmpId != tabId) {
  1138. $(this).find('.itp_tab_close').trigger('click');
  1139. }
  1140. }
  1141. });
  1142. $('#ITP_HEADER .itp_tab_list a[href="#ITP_TAB_'+tabId+'"]').trigger('click');
  1143. }
  1144. function itp_fn_open_tab(param) {
  1145. const id = param.navId;
  1146. const tabSize = $('#ITP_HEADER .itp_tab_list li').size();
  1147. if (tabSize > 10) {
  1148. itp_fn_modal_alert(ITP_MSG_LOCALE.message.page.noMoreTab);
  1149. return false;
  1150. }
  1151. let isDup = false;
  1152. $('#ITP_HEADER .itp_tab_list li').each(function() {
  1153. const tab_id = $(this).find('.itp_tab_close').attr('data-itp-tab-id');
  1154. if (tab_id == id) {
  1155. isDup = true;
  1156. $('#ITP_HEADER .itp_tab_list li').removeClass('active');
  1157. $('#ITP_CONTAINER .itp_contents .itp_sec').removeClass('active');
  1158. $(this).addClass('active');
  1159. $('#ITP_TAB_' + id).addClass('active');
  1160. return false;
  1161. }
  1162. });
  1163. if (!isDup) {
  1164. const href = '/' + id;
  1165. let text = $('#' + id + '_PAGE_NO').children('.itp_tt').text();
  1166. if (param.titId !== null && param.titId !== undefined && param.titId != '') {
  1167. text = $('#' + param.titId + '_PAGE_NO').children('.itp_tt').text();
  1168. }
  1169. const tab = '<li class="active"><a href="#ITP_TAB_' + id + '" role="tab" data-toggle="tab" class="itp_tab_open">' + text + ' <i class="glyphicon glyphicon-remove itp_tab_close" data-itp-tab-id="' + id + '"></i></a></li>';
  1170. itp_fn_load_page(href, tab);
  1171. } else {
  1172. itp_fn_fire_window_resize();
  1173. }
  1174. return false;
  1175. };
  1176. function itp_fn_open_tab_self(param, fn) {
  1177. const id = param.navId;
  1178. const tabSize = $('#ITP_HEADER .itp_tab_list li').size();
  1179. if (tabSize > 10) {
  1180. itp_fn_modal_alert(ITP_MSG_LOCALE.message.page.noMoreTab);
  1181. return false;
  1182. }
  1183. let isDup = false;
  1184. $('#ITP_HEADER .itp_tab_list li').each(function() {
  1185. const tab_id = $(this).find('.itp_tab_close').attr('data-itp-tab-id');
  1186. if (tab_id == id) {
  1187. isDup = true;
  1188. $('#ITP_HEADER .itp_tab_list li').removeClass('active');
  1189. $('#ITP_CONTAINER .itp_contents .itp_sec').removeClass('active');
  1190. $(this).addClass('active');
  1191. $('#ITP_TAB_' + id).addClass('active');
  1192. fn(param);
  1193. return false;
  1194. }
  1195. });
  1196. if (!isDup) {
  1197. const href = '/' + id;
  1198. const tab = '<li class="active"><a href="#ITP_TAB_' + id + '" role="tab" data-toggle="tab" class="itp_tab_open">' + param.menuTit + ' <i class="glyphicon glyphicon-remove itp_tab_close" data-itp-tab-id="' + id + '"></i></a></li>';
  1199. const key = $.param(param);
  1200. itp_fn_load_page(href, tab, key);
  1201. } else {
  1202. itp_fn_fire_window_resize();
  1203. }
  1204. return false;
  1205. };
  1206. function itp_fn_set_file_upload(wrap, folder, multi, thumb, screen, arg) {
  1207. if (thumb) {
  1208. multi = false;
  1209. ITP_UPLOAD_DEFAULTS = {
  1210. fileTypes: {
  1211. images: ['bmp', 'tif', 'tiff', 'gif', 'jpeg', 'jpg', 'png', 'svg', 'ico', 'raw']
  1212. }
  1213. };
  1214. }
  1215. $('#' + wrap).bootstrapFileUpload({
  1216. url: DOMAIN + '/api/file/upload',
  1217. inputName: 'uploadFile',
  1218. folderName: folder,
  1219. fileNumber: arg.fileNo,
  1220. fileInput: arg.fileId,
  1221. fileTypes: ITP_UPLOAD_DEFAULTS.fileTypes,
  1222. viewCode: arg.viewCd,
  1223. formMethod: 'post',
  1224. multiFile: multi,
  1225. multiUpload: false,
  1226. maxSize: 100,
  1227. maxFiles: 5,
  1228. showThumb: thumb,
  1229. thumbWidth: 80,
  1230. thumbHeight: 80,
  1231. debug: true,
  1232. screen_id: screen,
  1233. showYn: arg.showYn,
  1234. onFileAdded: function() {
  1235. $.bootstrapFileUpload('uploadStart', wrap);
  1236. },
  1237. onInit: function() {
  1238. $('#' + wrap).on('click', 'table.fileupload-download .filedownload-remove', function() {
  1239. var trRow = $(this).closest('tr.fileupload-downloadrow');
  1240. var tdData = trRow.children('td.itp_file_info');
  1241. var pFileNo = tdData.attr('data-file-no');
  1242. var pFileSeq = tdData.attr('data-file-seq');
  1243. const param = {'fileNo': pFileNo, 'fileSeq': pFileSeq};
  1244. $.ajax({
  1245. contentType: 'application/json',
  1246. url: DOMAIN + '/api/file/delete',
  1247. data: JSON.stringify(param),
  1248. type: 'DELETE',
  1249. async: false,
  1250. timeout: 10000,
  1251. xhrFields: {
  1252. withCredentials: true //Cross Domain 처리
  1253. },
  1254. beforeSend: function(xhr) {
  1255. xhr.setRequestHeader('X-AUTH-TOKEN', CONN_KEY); //Jwt 토큰을 헤더에 담아서 보낸다.
  1256. },
  1257. success: function(result) {
  1258. trRow.hide();
  1259. trRow.remove();
  1260. },
  1261. error: function(xhr, status, error) {
  1262. if (xhr.responseJSON !== undefined) { //실패시 서버에서 내려주는 메세지 얼럿
  1263. itp_fn_modal_alert_ajax(xhr.responseJSON.message);
  1264. if (xhr.status == 401) { //401에러가 떨어지면 로그인페이지로 이동
  1265. sessionStorage.removeItem('itp_login_info'); //Jwt 키 제거
  1266. $(location).attr('href', ITP_CONTEXTPATH + '/login.html');
  1267. }
  1268. } else {
  1269. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1270. }
  1271. },
  1272. fail: function() {
  1273. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1274. }
  1275. });
  1276. });
  1277. }
  1278. });
  1279. };
  1280. function itp_fn_check_file_uploading(fileId) {
  1281. let isUploading = false;
  1282. const fileCount = $(fileId).find('table.fileupload-preview tbody.files tr.row').length;
  1283. if (fileCount > 0) {isUploading = true;}
  1284. return isUploading;
  1285. };
  1286. function itp_fn_check_file_validate(fileId) {
  1287. let isValidate = false;
  1288. const downCount = $(fileId).find('table.fileupload-download tbody tr.row').length;
  1289. const fileCount = $(fileId).find('table.fileupload-preview tbody.files tr.row').length;
  1290. if (downCount < 1) {
  1291. if (fileCount < 1) {isValidate = true;}
  1292. }
  1293. return isValidate;
  1294. };
  1295. function itp_fn_upload_thumb(input, img, cont, fileNo, folder) {
  1296. if ($(input).val() != '') {
  1297. if ($(img).attr('data-thumb-yn') == 'Y') {
  1298. itp_fn_modal_alert(ITP_MSG_LOCALE.message.upload.deleteFile);
  1299. return;
  1300. }
  1301. const ext = $(input).val().split('.').pop().toLowerCase();
  1302. if ($.inArray(ext, ['gif', 'jpg', 'jpeg', 'png']) == -1) {
  1303. itp_fn_modal_alert(ITP_MSG_LOCALE.message.upload.fileType);
  1304. $(input).val('');
  1305. return;
  1306. }
  1307. let fileSize = input.files[0].size;
  1308. fileSize = (fileSize / 1024) / 1024;
  1309. const maxSize = 10;
  1310. if (fileSize > maxSize) {
  1311. itp_fn_modal_alert(maxSize + 'MB' + ITP_MSG_LOCALE.message.upload.fileSize);
  1312. $(input).val('');
  1313. return;
  1314. }
  1315. const hh = $(img).height();
  1316. if (input.files && input.files[0]) {
  1317. var reader = new FileReader();
  1318. reader.onload = function(e) {
  1319. $(img).attr('src', e.target.result);
  1320. };
  1321. reader.readAsDataURL(input.files[0]);
  1322. $(img).css('height', hh);
  1323. }
  1324. var formData = new FormData();
  1325. formData.append('uploadFolder', folder);
  1326. formData.append('fileNo', fileNo);
  1327. formData.append('uploadFile', input.files[0], input.files[0].name);
  1328. $.ajax({
  1329. url: ITP_CONTEXTPATH + '/uploadFile',
  1330. type: 'post',
  1331. data: formData,
  1332. enctype: 'multipart/form-data',
  1333. cache: false,
  1334. contentType: false,
  1335. processData: false,
  1336. success: function(result) {
  1337. if (result.resultCd == 'E') {
  1338. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1339. $(img).attr('src', ITP_CONTEXTPATH + '/images/noImg.png');
  1340. $(img).attr('data-thumb-yn', 'N');
  1341. } else {
  1342. $(img).attr('data-file-nm', result.resultData.FILE[0].fileNm);
  1343. $(img).attr('data-thumb-yn', 'Y');
  1344. }
  1345. },
  1346. error: function(xhr, status, error) {
  1347. if(xhr.status == 401) location.reload();
  1348. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1349. },
  1350. fail: function() {
  1351. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1352. }
  1353. });
  1354. }
  1355. };
  1356. function itp_fn_delete_thumb(img, input, fileNo) {
  1357. var fileNm = $(img).attr('data-file-nm');
  1358. const param = {'fileNo': fileNo, 'fileNm': fileNm};
  1359. if ($(img).attr('data-thumb-yn') == 'N') {
  1360. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.upload.fileNeed);
  1361. return;
  1362. }
  1363. $.ajax({
  1364. contentType: 'application/json',
  1365. url: ITP_CONTEXTPATH + '/deleteFileByNm',
  1366. data: JSON.stringify(param),
  1367. type: 'POST',
  1368. dataType: 'json',
  1369. async: false,
  1370. timeout: 10000,
  1371. success: function(result) {
  1372. if (result.resultCd == 'E') {
  1373. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1374. } else {
  1375. $(img).attr('src', ITP_CONTEXTPATH + '/images/noImg.png');
  1376. $(img).attr('data-thumb-yn', 'N');
  1377. $(input).val('');
  1378. }
  1379. },
  1380. error: function(xhr, status, error) {
  1381. if(xhr.status == 401) location.reload();
  1382. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1383. },
  1384. fail: function() {
  1385. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  1386. }
  1387. });
  1388. };
  1389. function itp_fn_thumb_validate(img, inline) {
  1390. var error = function(msg) {
  1391. $ele = $(img).closest('.itp_thumb_area');
  1392. $ele.closest('.form-group').addClass('has-error');
  1393. var error_msg = $('<span class="help-block">' + msg + '</span>');
  1394. if (inline == 'inline') {
  1395. $ele.append(error_msg);
  1396. } else {
  1397. error_msg.insertAfter($ele);
  1398. }
  1399. };
  1400. if ($(img).attr('data-thumb-yn') == 'N') {
  1401. error(ITP_MSG_LOCALE.message.upload.fileNeed);
  1402. return;
  1403. }
  1404. return true;
  1405. };
  1406. function itp_fn_get_image_thumbnail(id, w, h) {
  1407. let fileInfo = document.getElementById(id).files[0];
  1408. let reader = new FileReader();
  1409. reader.onload = function() {
  1410. document.getElementById(id + '_IMG').src = reader.result;
  1411. };
  1412. if (fileInfo) {
  1413. if(!/\.(jpg|jpeg)$/i.test(fileInfo.name)) {
  1414. itp_fn_modal_alert(ITP_MSG_LOCALE.message.form.onlyImage);
  1415. return;
  1416. }
  1417. var _URL = window.URL || window.webkitURL;
  1418. var img = new Image();
  1419. img.src = _URL.createObjectURL(fileInfo);
  1420. img.onload = function() {
  1421. //console.log(img.width + ' ' + img.height);
  1422. if (img.width != w || img.height != h) {
  1423. //itp_fn_modal_alert(ITP_MSG_LOCALE.message.form.noImageSize);
  1424. //return;
  1425. }
  1426. reader.readAsDataURL(fileInfo);
  1427. }
  1428. }
  1429. };
  1430. function itp_fn_get_category_thumbnail(id, w, h) {
  1431. let fileInfo = document.getElementById(id).files[0];
  1432. let reader = new FileReader();
  1433. reader.onload = function() {
  1434. document.getElementById(id + '_IMG').src = reader.result;
  1435. };
  1436. if (fileInfo) {
  1437. if(!/\.(jpg|jpeg|png)$/i.test(fileInfo.name)) {
  1438. itp_fn_modal_alert(ITP_MSG_LOCALE.message.form.onlyImage2);
  1439. return;
  1440. }
  1441. var _URL = window.URL || window.webkitURL;
  1442. var img = new Image();
  1443. img.src = _URL.createObjectURL(fileInfo);
  1444. img.onload = function() {
  1445. //console.log(img.width + ' ' + img.height);
  1446. if (img.width != w || img.height != h) {
  1447. //itp_fn_modal_alert(ITP_MSG_LOCALE.message.form.noImageSize);
  1448. //return;
  1449. }
  1450. reader.readAsDataURL(fileInfo);
  1451. }
  1452. }
  1453. };
  1454. function itp_fn_get_image_intro(obj, w, h) {
  1455. let isLoad = true;
  1456. let fileInfo = obj.files[0];
  1457. let reader = new FileReader();
  1458. reader.onload = function() {
  1459. $(obj).closest('li').find('.itp_img_img').attr('src', reader.result);
  1460. };
  1461. if (fileInfo) {
  1462. if(!/\.(jpg|jpeg)$/i.test(fileInfo.name)) {
  1463. itp_fn_modal_alert(ITP_MSG_LOCALE.message.form.onlyImage);
  1464. isLoad = false;
  1465. return;
  1466. }
  1467. var _URL = window.URL || window.webkitURL;
  1468. var img = new Image();
  1469. img.src = _URL.createObjectURL(fileInfo);
  1470. img.onload = function() {
  1471. //console.log(img.width + ' ' + img.height);
  1472. if (img.width != w || img.height != h) {
  1473. //itp_fn_modal_alert(ITP_MSG_LOCALE.message.form.noImageSize);
  1474. //isLoad = false;
  1475. //return;
  1476. }
  1477. reader.readAsDataURL(fileInfo);
  1478. }
  1479. }
  1480. return isLoad;
  1481. };
  1482. function itp_fn_set_upload_file(id) {
  1483. let fileInfo = document.getElementById(id).files[0];
  1484. $('#' + id + '_NM').html(fileInfo.name).show();
  1485. };
  1486. function itp_fn_set_smart_editor(oEditors, sLang, textarea) {
  1487. if (sLang == 'en') {
  1488. sLang = sLang + '_US';
  1489. } else {
  1490. sLang = sLang + '_KR';
  1491. }
  1492. const aAdditionalFontSet = [['MS UI Gothic', 'MS UI Gothic'], ['Comic Sans MS', 'Comic Sans MS']];
  1493. nhn.husky.EZCreator.createInIFrame({
  1494. oAppRef: oEditors,
  1495. elPlaceHolder: textarea,
  1496. sSkinURI: ITP_CONTEXTPATH + '/se2/SmartEditor2Skin_' + sLang + '.html',
  1497. htParams: {
  1498. bUseToolbar: true,
  1499. bUseVerticalResizer: false,
  1500. bUseModeChanger: true,
  1501. bSkipXssFilter: true,
  1502. aAdditionalFontList: aAdditionalFontSet,
  1503. fOnBeforeUnload: function() {
  1504. },
  1505. I18N_LOCALE: sLang
  1506. },
  1507. fOnAppLoad: function() {
  1508. var sDefaultFont = 'Times New Roman';
  1509. var nFontSize = 10;
  1510. oEditors.getById[textarea].setDefaultFont(sDefaultFont, nFontSize);
  1511. },
  1512. fCreator: 'createSEditor2'
  1513. });
  1514. };
  1515. function itp_fn_search_tabs_detail(tabs, wrap) {
  1516. $(wrap).on('click', tabs + ' li a', function() {
  1517. const href = $(this).attr('href');
  1518. itp_fn_load_tabs(wrap, href);
  1519. return false;
  1520. });
  1521. };
  1522. // [수발주 추가]
  1523. function itp_fn_grid_make_remote(option) {
  1524. var options = $.extend({
  1525. multiselect: false,
  1526. rownumbers: true,
  1527. loadBeforeSend: function(jqXHR) {
  1528. jqXHR.setRequestHeader('X-AUTH-TOKEN', CONN_KEY);
  1529. },
  1530. loadError: function(jqXHR, textStatus, errorThrown) {
  1531. itp_fn_grid_load_error(jqXHR, textStatus, errorThrown);
  1532. }
  1533. }, option);
  1534. $(options.gridId).jqGrid({
  1535. colModel: options.colModel,
  1536. postData: options.param,
  1537. url: options.url,
  1538. pager: options.pager,
  1539. multiselect: options.multiselect,
  1540. rownumbers: options.rownumbers,
  1541. loadBeforeSend: options.loadBeforeSend,
  1542. onCellSelect: options.onCellSelect,
  1543. loadComplete: options.loadComplete,
  1544. loadError: options.loadError,
  1545. onPaging: function(action) {
  1546. itp_fn_grid_paging(options.gridId, action, options.param);
  1547. }
  1548. }).navGrid(options.pager, ITP_GRID_NAV_DEFAULTS.navGrid);
  1549. }
  1550. function itp_fn_grid_make_local(option) {
  1551. var options = $.extend({
  1552. multiselect: false,
  1553. rownumbers: true
  1554. }, option);
  1555. $(option.gridId).jqGrid({
  1556. colModel: options.colModel,
  1557. data: options.data,
  1558. datatype: 'local',
  1559. pager: options.pager
  1560. }).navGrid(options.pager, ITP_GRID_NAV_DEFAULTS.navGrid);
  1561. }
  1562. function itp_fn_grid_paging(grid_id, action, args) {
  1563. var gridOption = $(grid_id).jqGrid('getGridParam');
  1564. const suffix = gridOption.pager;
  1565. let currentPage = gridOption.page;
  1566. const lastPage = gridOption.lastpage;
  1567. const userPage = $(suffix).find('.ui-pg-input').val();
  1568. if (action == 'next') {
  1569. if (currentPage < lastPage) {
  1570. currentPage += 1;
  1571. }
  1572. } else if (action == 'prev') {
  1573. if (currentPage > 0 && currentPage != 1) {
  1574. currentPage -= 1;
  1575. }
  1576. } else if (action == 'first') {
  1577. currentPage = 1;
  1578. } else if (action == 'last') {
  1579. currentPage = lastPage;
  1580. } else if (action == 'user') {
  1581. if (userPage > lastPage || userPage < 1) {
  1582. return 'stop';
  1583. } else {
  1584. currentPage = userPage;
  1585. }
  1586. }
  1587. args.gridPage = currentPage;
  1588. $(grid_id).setGridParam({
  1589. postData : JSON.stringify(args)
  1590. });
  1591. };
  1592. function itp_fn_grid_sorting(grid_id, index, sortOrder, args) {
  1593. args.sidx = index;
  1594. args.sord = sortOrder;
  1595. $(grid_id).setGridParam({
  1596. postData : JSON.stringify(args)
  1597. });
  1598. };
  1599. function itp_fn_grid_load_complete(data, gridId, paging, rn, menuId, isSrh, emptyFn, isView, totCnt, totPage, emptyMsg, helpMsg, excelDownloadId, excelUploadId) {
  1600. if (data.resultCd == 'E') {
  1601. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.failData);
  1602. } else {
  1603. const rowCnt = $(gridId).jqGrid('getGridParam', 'records');
  1604. const shrinkToFit = $(gridId).getGridParam('shrinkToFit');
  1605. const gridNm = gridId.slice(1);
  1606. if (emptyMsg === null || emptyMsg === undefined) {
  1607. emptyMsg = ITP_MSG_LOCALE.message.grid.noData;
  1608. }
  1609. if (isSrh) {
  1610. emptyMsg = ITP_MSG_LOCALE.message.grid.noSrh;
  1611. $('#ITP_' + menuId + '_jqGridEmpty').addClass('itp_noSrh');
  1612. } else {
  1613. $('#ITP_' + menuId + '_jqGridEmpty').removeClass('itp_noSrh');
  1614. }
  1615. if (rowCnt == 0) {
  1616. $(gridId + '_list').find('.ui-jqgrid-bdiv').css('min-height', '100px');
  1617. $('#ITP_' + menuId + '_jqGridEmpty').html(emptyMsg);
  1618. $('#ITP_' + menuId + '_jqGridEmpty').show();
  1619. } else {
  1620. $(gridId + '_list').find('.ui-jqgrid-bdiv').css('min-height', 'auto');
  1621. $('#ITP_' + menuId + '_jqGridEmpty').hide();
  1622. if (isSrh) {emptyFn.push();}
  1623. }
  1624. if (shrinkToFit) {
  1625. $(gridId + '_list').find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  1626. } else {
  1627. $(gridId + '_list').find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'auto');
  1628. }
  1629. if (paging) {
  1630. $(gridId + 'Pager_center').show();
  1631. if (!totPage) {
  1632. $(gridId + 'Pager_right').css('visibility', 'hidden');
  1633. }
  1634. } else {
  1635. $(gridId + 'Pager_center').hide();
  1636. $(gridId + 'Pager_right').hide();
  1637. }
  1638. if (rn == 'number') {$('#jqgh_' + gridNm + '_rn').text(ITP_MSG_LOCALE.label.numbering);}
  1639. if (rn == 'order') {$('#jqgh_' + gridNm + '_rn').text(ITP_MSG_LOCALE.label.ordering);}
  1640. if (rn == 'rank') {$('#jqgh_' + gridNm + '_rn').text(ITP_MSG_LOCALE.label.ranking);}
  1641. if (isView) {
  1642. let viewHtml = '';
  1643. viewHtml += '<span class="itp_shrv fix">';
  1644. viewHtml += '<span class="shrv_txt"><b>' + ITP_MSG_LOCALE.label.srhResult + '</b></span>';
  1645. viewHtml += '<span class="shrv_num">(<em>' + rowCnt + '</em>)</span>';
  1646. viewHtml += '<span class="shrv_bar">|</span>';
  1647. viewHtml += '<span class="shrv_txt">' + ITP_MSG_LOCALE.label.total + '</span>';
  1648. viewHtml += '<span class="shrv_num shrv_tot">(<em>' + totCnt + '</em>)</span>';
  1649. if (helpMsg !== null && helpMsg !== undefined && helpMsg != '') {
  1650. viewHtml += '<span class="shrv_help">' + helpMsg + '</span>';
  1651. }
  1652. viewHtml += '</span>';
  1653. if (excelDownloadId !== null && excelDownloadId !== undefined && excelDownloadId != '') {
  1654. viewHtml += '<span class="itp_shrx fix">';
  1655. viewHtml += '<span class="shrx_txt" id="'+excelDownloadId+'"><b>엑셀 다운로드</b></span>';
  1656. if (excelUploadId !== null && excelUploadId !== undefined && excelUploadId != '') {
  1657. viewHtml += '<span class="shrx_bar">|</span>';
  1658. viewHtml += '<span class="shrx_txt" id="'+excelUploadId+'"><b>엑셀 일괄저장</b></span>';
  1659. }
  1660. viewHtml += '</span>';
  1661. }
  1662. $('#ITP_' + menuId + '_jqGridView').html(viewHtml).show();
  1663. }
  1664. $(gridId).on('focus', 'td[role="gridcell"] .editable', function() {
  1665. $(this).closest('tr[editable="1"] td').trigger('click');
  1666. });
  1667. }
  1668. };
  1669. function itp_fn_grid_file_select(menuId, fileSelectId, helpMsg) {
  1670. let viewHtml = '';
  1671. viewHtml += '<span class="itp_shrv fix">';
  1672. if (helpMsg !== null && helpMsg !== undefined && helpMsg != '') {
  1673. viewHtml += '<span class="shrv_help">' + helpMsg + '</span>';
  1674. }
  1675. viewHtml += '</span>';
  1676. if (fileSelectId !== null && fileSelectId !== undefined && fileSelectId != '') {
  1677. viewHtml += '<span class="itp_shrx fix">';
  1678. viewHtml += '<input id="'+fileSelectId+'_FILE" type="file" style="display:none;" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">';
  1679. viewHtml += '<span class="shrx_txt" id="'+fileSelectId+'"><b>파일 선택</b></span>';
  1680. viewHtml += '</span>';
  1681. }
  1682. $('#ITP_' + menuId + '_jqGridView').html(viewHtml).show();
  1683. };
  1684. function itp_fn_grid_load_error(jqXHR, textStatus, errorThrown) {
  1685. // console.log(JSON.stringify(jqXHR));
  1686. if (jqXHR.status == 401) location.href = ITP_CONTEXTPATH + '/';
  1687. if(jqXHR.responseJSON.message) {
  1688. itp_fn_modal_alert(jqXHR.responseJSON.message);
  1689. } else {
  1690. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.failData);
  1691. }
  1692. };
  1693. function itp_fn_grid_validate_row(gridId, msg) {
  1694. const rids = $(gridId).jqGrid('getDataIDs');
  1695. for (var idx in rids) {
  1696. $(gridId).jqGrid('saveRow', rids[idx]);
  1697. }
  1698. var inputs = $(gridId).find('tr[editable="1"]');
  1699. if (inputs.length > 0) return false;
  1700. let isValidate = true;
  1701. $(gridId).find('tr[editable="0"]').children('td[role="gridcell"]').find('.editable').each(function() {
  1702. if ($(this).val() == '') {
  1703. $(this).closest('tr[editable="0"] td').trigger('click');
  1704. isValidate = false;
  1705. return false;
  1706. }
  1707. });
  1708. if (!isValidate) {return false;}
  1709. var rows = $(gridId).find('tr.jqgrow[role="row"]:visible');
  1710. if (rids.length == 0 || rows.length < 1) {
  1711. if (msg == undefined || typeof msg == 'undefined') {
  1712. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.noData);
  1713. } else {
  1714. itp_fn_modal_alert(msg);
  1715. }
  1716. return false;
  1717. }
  1718. return true;
  1719. };
  1720. function itp_fn_set_data_editable(rowId, cellIdx, lastrowid, gridId, cm, addRow) {
  1721. if (true == true && cellIdx == 0) return;
  1722. if (rowId) {
  1723. const viewCd = $(gridId).jqGrid('getRowData', rowId).viewCd;
  1724. if (viewCd == 'R') {
  1725. $(gridId).jqGrid('setCell', rowId, 'viewCd', 'U');
  1726. }
  1727. if (lastrowid && rowId != lastrowid) {
  1728. $(gridId).jqGrid('saveRow', lastrowid);
  1729. }
  1730. if (cm !== undefined || typeof cm !== 'undefined') {
  1731. if (cm !== null) {
  1732. let edittype = true;
  1733. if (addRow) {
  1734. edittype = false;
  1735. } else {
  1736. if (viewCd == 'C') {edittype = true;} else {edittype = false;}
  1737. }
  1738. const cols = $(gridId).jqGrid('getGridParam', 'colModel');
  1739. for (var i=0; i<cols.length; i++) {
  1740. for (var j=0; j<cm.length; j++) {
  1741. if (cols[i].name == cm[j]) {
  1742. $(gridId).jqGrid('setColProp', cols[i].name, {editable: edittype});
  1743. }
  1744. }
  1745. }
  1746. }
  1747. }
  1748. $(gridId).jqGrid('editRow', rowId, true);
  1749. lastrowid = rowId;
  1750. }
  1751. return lastrowid;
  1752. };
  1753. function itp_fn_set_all_row_editable(gridId) {
  1754. var ids = $(gridId).getDataIDs();
  1755. $.each(ids, function(idx, rowId) {
  1756. $(gridId).jqGrid('editRow', rowId, true);
  1757. });
  1758. var i, count, $grid = $(gridId);
  1759. var rowArray = $(gridId).jqGrid('getDataIDs');
  1760. for (i = 0, count = rowArray.length; i < count; i += 1) {
  1761. $grid.jqGrid('setSelection', rowArray[i], false);
  1762. }
  1763. $(gridId).find('tr[editable="1"]').children('td[role="gridcell"]').find('.editable').each(function() {
  1764. $(this).css({
  1765. 'border': '1px solid #ccc',
  1766. '-webkit-box-shadow': 'inset 0 1px 1px rgba(0,0,0,.075)',
  1767. 'box-shadow': 'inset 0 1px 1px rgba(0,0,0,.075)'
  1768. });
  1769. });
  1770. };
  1771. function itp_fn_set_row_editable(gridId, rowId) {
  1772. $(gridId).jqGrid('editRow', rowId, true);
  1773. };
  1774. function itp_fn_grid_save_rows(gridId) {
  1775. var rids = $(gridId).jqGrid('getDataIDs');
  1776. for(var idx in rids) {
  1777. $(gridId).jqGrid('saveRow', rids[idx]);
  1778. }
  1779. $(gridId).find('tr[editable="0"]').children('td[role="gridcell"]').find('.editable').each(function() {
  1780. if ($(this).val() == '') {
  1781. $(this).closest('tr[editable="0"] td').trigger('click');
  1782. return false;
  1783. }
  1784. });
  1785. };
  1786. function itp_fn_grid_reset_selection(e, lastrowid, gridId, menuId) {
  1787. if (lastrowid != '' && typeof lastrowid != 'undefined') {
  1788. if (e.target.id == 'cb_' + gridId) return;
  1789. if (e.target.id == 'ITP_BTN_' + menuId + '_ADDROW') return;
  1790. if (e.target.id == 'ITP_BTN_' + menuId + '_DELROW') return;
  1791. if ($(e.target).closest('#' + gridId).length == 0) {
  1792. var rids = $('#' + gridId).jqGrid('getDataIDs');
  1793. for(var idx in rids) {
  1794. $('#' + gridId).jqGrid('saveRow', rids[idx]);
  1795. }
  1796. //$('#' + gridId).jqGrid('saveRow', lastrowid);
  1797. $('#' + gridId).find('tr[editable="0"]').children('td[role="gridcell"]').find('.editable').each(function() {
  1798. if ($(this).val() == '') {
  1799. $(this).closest('tr[editable="0"] td').trigger('click');
  1800. return false;
  1801. }
  1802. });
  1803. $('#' + gridId).resetSelection();
  1804. }
  1805. }
  1806. };
  1807. function itp_fn_grid_add_row(gridId, fn, cm, menuId) {
  1808. if (cm !== undefined || typeof cm !== 'undefined') {
  1809. if (cm !== null) {
  1810. const cols = $(gridId).jqGrid('getGridParam', 'colModel');
  1811. for (var i=0; i<cols.length; i++) {
  1812. for (var j=0; j<cm.length; j++) {
  1813. if (cols[i].name == cm[j]) {
  1814. $(gridId).jqGrid('setColProp', cols[i].name, {editable: true});
  1815. }
  1816. }
  1817. }
  1818. }
  1819. }
  1820. $(gridId + '_list').find('.ui-jqgrid-bdiv').css('min-height', 'auto');
  1821. $('#ITP_' + menuId + '_jqGridEmpty').hide();
  1822. $(gridId).jqGrid('addRow', {position: 'last'});
  1823. var rids = $(gridId).jqGrid('getDataIDs');
  1824. var last_row_id = rids[rids.length - 1];
  1825. $(gridId).jqGrid('setCell', last_row_id, 'viewCd', 'C');
  1826. if (fn !== undefined || typeof fn !== 'undefined') {
  1827. fn(last_row_id, rids.length);
  1828. }
  1829. return last_row_id;
  1830. };
  1831. function itp_fn_add_grid_row(gridId, fn, cm, menuId) {
  1832. if (cm !== undefined || typeof cm !== 'undefined') {
  1833. if (cm !== null) {
  1834. const cols = $(gridId).jqGrid('getGridParam', 'colModel');
  1835. for (var i=0; i<cols.length; i++) {
  1836. for (var j=0; j<cm.length; j++) {
  1837. if (cols[i].name == cm[j]) {
  1838. $(gridId).jqGrid('setColProp', cols[i].name, {editable: false});
  1839. }
  1840. }
  1841. }
  1842. }
  1843. }
  1844. $(gridId + '_list').find('.ui-jqgrid-bdiv').css('min-height', 'auto');
  1845. $('#ITP_' + menuId + '_jqGridEmpty').hide();
  1846. $(gridId).jqGrid('addRow', {position: 'last'});
  1847. var rids = $(gridId).jqGrid('getDataIDs');
  1848. var last_row_id = rids[rids.length - 1];
  1849. $(gridId).jqGrid('setCell', last_row_id, 'viewCd', 'C');
  1850. if (fn !== undefined || typeof fn !== 'undefined') {
  1851. fn(last_row_id, rids.length);
  1852. }
  1853. return last_row_id;
  1854. };
  1855. function itp_fn_grid_del_row(gridId) {
  1856. const rowKey = $(gridId).getGridParam('selrow');
  1857. if (!rowKey) {
  1858. return;
  1859. }
  1860. var selectedIds = $(gridId).getGridParam('selarrrow');
  1861. for (var i=selectedIds.length-1; i>=0; i--) {
  1862. if ($(gridId).jqGrid('getRowData', selectedIds[i]).viewCd == 'C') {
  1863. $(gridId).delRowData(selectedIds[i]);
  1864. } else {
  1865. $(gridId).jqGrid('saveRow', selectedIds[i]);
  1866. $(gridId).jqGrid('setCell', selectedIds[i], 'viewCd', 'D');
  1867. $(gridId).find('tr#' + selectedIds[i]).css('display', 'none');
  1868. }
  1869. }
  1870. };
  1871. function itp_fn_grid_tree_select(gridList, gridId) {
  1872. $(gridList).on('click', 'input[name=chk]', function() {
  1873. if ($(this).is(':checked')) {
  1874. $(this).parent('td[role="gridcell"]').trigger('click');
  1875. } else {
  1876. $(gridId).jqGrid('resetSelection');
  1877. }
  1878. $(gridList).find('input[name=chk]').not($(this)).prop('checked', false);
  1879. });
  1880. };
  1881. function itp_fn_grid_tree_select_row(gridList, rowId) {
  1882. var checkbox = $(gridList).find('tr[role="row"]#' + rowId).find('input[name=chk]');
  1883. checkbox.prop('checked', true);
  1884. $(gridList).find('input[name=chk]').not(checkbox).prop('checked', false);
  1885. };
  1886. function itp_fn_check_grid_is_writing(gridId) {
  1887. const rowData = $(gridId).getRowData();
  1888. let isWriting = false;
  1889. $.each(rowData, function(key, value) {
  1890. if (value.viewCd != 'R') {
  1891. isWriting = true;
  1892. return;
  1893. }
  1894. });
  1895. return isWriting;
  1896. };
  1897. function itp_fn_jqgrid_resize(grid_id, parent_id, size) {
  1898. $(window).on('resize', function(e) {
  1899. //window.resizeEvt;
  1900. //clearTimeout(window.resizeEvt);
  1901. window.resizeEvt = setTimeout(function() {
  1902. $(grid_id).setGridWidth(782);
  1903. var outerwidth = $(parent_id).width();
  1904. if ($(window).width() < 1301 && size == 'sm') {
  1905. outerwidth = 782;
  1906. }
  1907. $(grid_id).setGridWidth(outerwidth);
  1908. }, 250);
  1909. });
  1910. };
  1911. function itp_fn_make_set_combine(gridId, label, width, cols, hideCols) {
  1912. $(gridId).jqGrid('setLabel', cols, label, '', {
  1913. style: 'width:' + width + 'px;',
  1914. colspan: '2'
  1915. });
  1916. $(gridId).jqGrid('setLabel', hideCols, '', '', {style: 'display:none;'});
  1917. };
  1918. function itp_fn_make_set_search(gridId, label, width, cols) {
  1919. $(gridId).jqGrid('setLabel', cols, label, '', {
  1920. style: 'width:' + width + 'px;',
  1921. colspan: '2'
  1922. });
  1923. $(gridId).jqGrid('setLabel', cols + 'Img', '', '', {style: 'display:none;'});
  1924. };
  1925. function itp_fn_make_btn_search(cellvalue, options, rowObject) {
  1926. var str = '<button class="btn btn-default btn-sm itp_btn" type="button"><i class="glyphicon glyphicon-search"></i></button>';
  1927. return str;
  1928. };
  1929. function itp_fn_make_checkbox(cellvalue, options, rowObject) {
  1930. var str = '<input type="checkbox" name="chk">';
  1931. return str;
  1932. };
  1933. function itp_fn_add_excel_btn(gridId, pagerId, fileNm, href, $params) {
  1934. $(gridId).navButtonAdd(pagerId, {
  1935. buttonicon: 'glyphicon glyphicon-download-alt',
  1936. title: ITP_MSG_LOCALE.button.excelDown,
  1937. caption: '',
  1938. position: 'last',
  1939. onClickButton: function() {
  1940. let params = $params.serializeObject();
  1941. let colsNm = [], colsLb = [], colsWd = [], colsAg = [];
  1942. const cols = $(gridId).jqGrid('getGridParam', 'colModel');
  1943. for (var i=0; i<cols.length; i++) {
  1944. if (cols[i].hidden == false && cols[i].name != 'rn') {
  1945. //console.log('colsNm==>>' + colsNm);
  1946. colsNm.push(cols[i].name);
  1947. colsLb.push(cols[i].label);
  1948. colsWd.push(cols[i].width);
  1949. colsAg.push(cols[i].align);
  1950. }
  1951. }
  1952. params.excelNm = fileNm;
  1953. params.pagingYn = false;
  1954. let inputs = '';
  1955. const data = $.param(params);
  1956. $.each(data.split('&'), function() {
  1957. var pair = this.split('=');
  1958. inputs += '<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />';
  1959. });
  1960. inputs += '<input type="hidden" name="colsNm" value="' + colsNm + '" />';
  1961. inputs += '<input type="hidden" name="colsLb" value="' + colsLb + '" />';
  1962. inputs += '<input type="hidden" name="colsWd" value="' + colsWd + '" />';
  1963. inputs += '<input type="hidden" name="colsAg" value="' + colsAg + '" />';
  1964. //console.log(inputs); return;
  1965. $('<form action="' + href + '" method="post">' + inputs + '</form>')
  1966. .appendTo('body').submit().remove();
  1967. }
  1968. });
  1969. };
  1970. function itp_fn_download_excel(fileNm, href, $params) {
  1971. let params = $params.serializeObject();
  1972. params.excelNm = fileNm;
  1973. params.pagingYn = false;
  1974. let inputs = '';
  1975. const data = $.param(params);
  1976. $.each(data.split('&'), function() {
  1977. var pair = this.split('=');
  1978. inputs += '<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />';
  1979. });
  1980. //console.log(inputs); return;
  1981. $('<form action="' + href + '" method="post">' + inputs + '</form>')
  1982. .appendTo('body').submit().remove();
  1983. };
  1984. function itp_fn_grid_make_cell_link(gridId, cells, text, css) {
  1985. var ids = $(gridId).jqGrid('getDataIDs');
  1986. var gridData = $(gridId).jqGrid('getRowData');
  1987. for (var i=0; i < gridData.length; i++) {
  1988. for (var j=0; j < cells.length; j++) {
  1989. $(gridId).jqGrid('setCell', ids[i], cells[j], text, css);
  1990. }
  1991. }
  1992. };
  1993. function itp_fn_grid_save_row(gridId) {
  1994. var rids = $(gridId).jqGrid('getDataIDs');
  1995. for (var idx in rids) {
  1996. $(gridId).jqGrid('saveRow', rids[idx]);
  1997. }
  1998. };
  1999. function itp_fn_fire_window_resize() {
  2000. var evt = document.createEvent('HTMLEvents');
  2001. evt.initEvent('resize', true, false);
  2002. window.dispatchEvent(evt);
  2003. };
  2004. function itp_fn_make_select(options, select_id) {
  2005. $(select_id).empty();
  2006. $('<option/>', {'value': '', 'text': ITP_MSG_LOCALE.label.selected}).prependTo(select_id);
  2007. $.each(options, function(key, value) {
  2008. $('<option/>', {
  2009. 'value': this.codeCd,
  2010. 'text': this.codeNm
  2011. }).appendTo(select_id);
  2012. });
  2013. };
  2014. String.prototype.rPad = function (n, c) {
  2015. var i; var a = this.split('');
  2016. for (i = 0; i < n - this.length; i++) {a.push (c);};
  2017. return a.join('');
  2018. };
  2019. var StringBuffer = function(){
  2020. this.buffer = new Array();
  2021. }
  2022. StringBuffer.prototype.append = function(obj){
  2023. this.buffer.push(obj);
  2024. }
  2025. StringBuffer.prototype.toString = function(){
  2026. return this.buffer.join("");
  2027. }
  2028. function itp_fn_number_comma(str, dec) {
  2029. var roundXL = function(n, digits) {
  2030. if (digits >= 0) return parseFloat(n.toFixed(digits));
  2031. digits = Math.pow(10, digits);
  2032. var t = Math.round(n * digits) / digits;
  2033. return parseFloat(t.toFixed(0));
  2034. };
  2035. var nStr = (str == undefined || str == 'null' ? '' : str) + '';
  2036. var nDec = (dec == undefined ? -1 : dec);
  2037. if (nStr == '') return nStr;
  2038. nStr = nStr.replace(/,/g, '');
  2039. var x = (nDec === -1 ? nStr : roundXL(Number(nStr), nDec) + '').split('.'),
  2040. x1 = x[0].replace(/,/g, ''),
  2041. x2 = x.length > 1 ? '.' + x[1] : '',
  2042. rgx = /(\d+)(\d{3})/;
  2043. while (rgx.test(x1)) x1 = x1.replace(rgx, '$1' + ',' + '$2');
  2044. if (nDec > 0) {
  2045. if (x2 =='') x2 = '.' + x2.rPad(nDec, '0');
  2046. else x2 = x2.rPad(nDec + 1, '0');
  2047. } else if (nDec == 0) x2 = '';
  2048. return x1 + x2;
  2049. };
  2050. function itp_fn_currency_fmatter(cellvalue, options, rowObject) {
  2051. const currCd = rowObject[options.colModel.formatoptions.currCd];
  2052. let dec = 0;
  2053. if (currCd !== undefined && typeof currCd !== 'undefined') {
  2054. if (currCd == 'USD') {
  2055. dec = 2;
  2056. }
  2057. }
  2058. return itp_fn_number_comma(cellvalue, dec);
  2059. };
  2060. function itp_fn_currency_fmatter_pop(currCd) {
  2061. let dec = 2;
  2062. if (currCd == 'USD') {
  2063. dec = 2;
  2064. }
  2065. return {formatter: 'number', formatoptions: {decimalPlaces: dec}};
  2066. };
  2067. function itp_fn_currency_unfmatter(cellvalue, options, cell) {
  2068. var value = cellvalue.replace(/,/gi, '');
  2069. return value;
  2070. };
  2071. function itp_fn_time_fmatter(cellvalue, options, rowObject) {
  2072. let time = '';
  2073. if (cellvalue !== undefined && typeof cellvalue !== 'undefined') {
  2074. if (cellvalue.length == 4) {
  2075. const hh = cellvalue.substring(0, 2);
  2076. const mm = cellvalue.substring(2, 4);
  2077. time = hh + ':' + mm;
  2078. }
  2079. }
  2080. return time;
  2081. };
  2082. function itp_fn_time_unfmatter(cellvalue, options, cell) {
  2083. var value = cellvalue.replace(/:/gi, '');
  2084. return value;
  2085. };
  2086. function itp_fn_modal_alert(msg) {
  2087. $('#ITP_MODAL_ALERT_CANCEL').hide();
  2088. $('#ITP_MODAL_ALERT').modal('show');
  2089. $('#ITP_MODAL_ALERT').find('.itp_alert_txt').html(msg);
  2090. $('#ITP_MODAL_ALERT_CONFIRM').off('click');
  2091. $('#ITP_MODAL_ALERT_CONFIRM').on('click', function() {
  2092. $('#ITP_MODAL_ALERT').modal('hide');
  2093. });
  2094. };
  2095. function itp_fn_modal_alert_ajax(msg) {
  2096. $('#ITP_MODAL_ALERT_AJAX').modal('show');
  2097. $('#ITP_MODAL_ALERT_AJAX').find('.itp_alert_txt').html(msg);
  2098. $('#ITP_MODAL_ALERT_AJAX_CONFIRM').off('click');
  2099. $('#ITP_MODAL_ALERT_AJAX_CONFIRM').on('click', function() {
  2100. $('#ITP_MODAL_ALERT_AJAX').modal('hide');
  2101. });
  2102. };
  2103. function itp_fn_modal_duplicate(label, input) {
  2104. let msg = ITP_MSG_LOCALE.message.form.duplicate;
  2105. msg = msg.replace('{0}', label);
  2106. $('#ITP_MODAL_ALERT_CANCEL').hide();
  2107. $('#ITP_MODAL_ALERT').modal('show');
  2108. $('#ITP_MODAL_ALERT').find('.itp_alert_txt').html(msg);
  2109. $('#ITP_MODAL_ALERT_CONFIRM').off('click');
  2110. $('#ITP_MODAL_ALERT_CONFIRM').on('click', function() {
  2111. $('#ITP_MODAL_ALERT').modal('hide');
  2112. if (input != null) {
  2113. $(input).focus();
  2114. }
  2115. });
  2116. };
  2117. function itp_fn_modal_confirm(msg, fn, args) {
  2118. $('#ITP_MODAL_ALERT_CANCEL').show();
  2119. $('#ITP_MODAL_ALERT').modal('show');
  2120. $('#ITP_MODAL_ALERT').find('.itp_alert_txt').html(msg);
  2121. if (fn !== undefined || typeof fn !== 'undefined') {
  2122. $('#ITP_MODAL_ALERT_CONFIRM').off('click');
  2123. $('#ITP_MODAL_ALERT_CONFIRM').on('click', function() {
  2124. fn.callBack(args);
  2125. $('#ITP_MODAL_ALERT').modal('hide');
  2126. });
  2127. }
  2128. };
  2129. function itp_fn_form_clear_validate(modal, form) {
  2130. $(form).find('.itp_ip').removeClass('has-error');
  2131. $(form).find('.help-block').remove();
  2132. if (modal != null) {
  2133. $(modal).on('hidden.bs.modal', function() {
  2134. $(form).find('.itp_ip').removeClass('has-error');
  2135. $(form).find('.help-block').remove();
  2136. });
  2137. }
  2138. };
  2139. function itp_fn_chnage_number_form(formId) {
  2140. $(formId).find('input.numberOnly').number(true);
  2141. $(formId).find('input.distanceOnly').number(true, 1);
  2142. $(formId).find('input.priceOnly').number(true, 2);
  2143. $(formId).find('input.unitOnly').number(true, 3);
  2144. };
  2145. function itp_fn_form_validate(form, element, arry, msg, type) {
  2146. var error = function(txt) {
  2147. if (type != 'ONLYCHK') {
  2148. if (msg == undefined || typeof msg == 'undefined') {
  2149. msg = txt;
  2150. }
  2151. $(element).closest('.itp_ip').addClass('has-error');
  2152. var error_msg = $('<span class="help-block">' + msg + '</span>');
  2153. if($(element).parent('.input-group').length) {
  2154. error_msg.insertAfter($(element).parent());
  2155. } else {
  2156. error_msg.insertAfter($(element));
  2157. }
  2158. }
  2159. };
  2160. if ($.inArray('empty', arry) > -1) {
  2161. if ($(element).val() == '' || $(element).val() < 1) {
  2162. error(ITP_MSG_LOCALE.message.form.mandatory);
  2163. return false;
  2164. }
  2165. }
  2166. if ($.inArray('emptyNum', arry) > -1) {
  2167. if ($(element).val() == '' || $(element).val() < 0) {
  2168. error(ITP_MSG_LOCALE.message.form.mandatory);
  2169. return false;
  2170. }
  2171. }
  2172. if ($.inArray('number', arry) > -1) {
  2173. const regExp = /^[0-9]+$/;
  2174. if (!regExp.test($(element).val())) {
  2175. error(ITP_MSG_LOCALE.message.form.onlynumber);
  2176. return false;
  2177. }
  2178. }
  2179. if ($.inArray('float', arry) > -1) {
  2180. if($(element).val() == '') return true;
  2181. const regExp = /^\d+.?\d?\d?\d?$/;
  2182. if (!regExp.test($(element).val())) {
  2183. error(ITP_MSG_LOCALE.message.form.onlynumber);
  2184. return false;
  2185. }
  2186. }
  2187. if ($.inArray('tel', arry) > -1) {
  2188. const regExp = /^\d{2,3}-\d{3,4}-\d{4}$/;
  2189. if (!regExp.test($(element).val())) {
  2190. error(ITP_MSG_LOCALE.message.form.wrongtelnumber);
  2191. return false;
  2192. }
  2193. }
  2194. if ($.inArray('email', arry) > -1) {
  2195. const regExp = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
  2196. if (!regExp.test($(element).val())) {
  2197. error(ITP_MSG_LOCALE.message.form.wrongemail);
  2198. return false;
  2199. }
  2200. }
  2201. if ($.inArray('id', arry) > -1) {
  2202. const regExp = /^[a-z]+[a-z0-9]{4,11}$/g;
  2203. if (!regExp.test($(element).val())) {
  2204. error(ITP_MSG_LOCALE.message.form.wronguserid);
  2205. return false;
  2206. }
  2207. }
  2208. if ($.inArray('id2', arry) > -1) {
  2209. const regExp = /^[A-Za-z0-9+]*$/;
  2210. if (!regExp.test($(element).val())) {
  2211. error(ITP_MSG_LOCALE.message.form.wronguserid2);
  2212. return false;
  2213. }
  2214. }
  2215. if ($.inArray('password', arry) > -1) {
  2216. const regExp = /^(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])(?=.*[0-9]).{8,16}$/;
  2217. if (!regExp.test($(element).val())) {
  2218. error(ITP_MSG_LOCALE.message.form.wrongpassword);
  2219. return false;
  2220. }
  2221. }
  2222. if ($.inArray('url', arry) > -1) {
  2223. const regExp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  2224. if (!regExp.test($(element).val())) {
  2225. error(ITP_MSG_LOCALE.message.form.wronglink);
  2226. return false;
  2227. }
  2228. }
  2229. return true;
  2230. };
  2231. function itp_fn_set_only_number_form(input) {
  2232. $(input).val($(input).val().replace(/[^0-9]/g, ''));
  2233. };
  2234. function itp_fn_set_telephone_form(input) {
  2235. $(input).val($(input).val().replace(/[^0-9]/g, '').replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})/, '$1-$2-$3').replace('--', '-'));
  2236. };
  2237. function itp_fn_set_business_reg_form(input) {
  2238. let companyNum = $(input).val();
  2239. companyNum = companyNum.replace(/[^0-9]/g, '');
  2240. var tempNum = '';
  2241. if (companyNum.length < 4) {
  2242. tempNum = companyNum;
  2243. } else if (companyNum.length < 6) {
  2244. tempNum += companyNum.substr(0,3);
  2245. tempNum += '-';
  2246. tempNum += companyNum.substr(3,2);
  2247. } else if (companyNum.length < 11) {
  2248. tempNum += companyNum.substr(0,3);
  2249. tempNum += '-';
  2250. tempNum += companyNum.substr(3,2);
  2251. tempNum += '-';
  2252. tempNum += companyNum.substr(5);
  2253. } else {
  2254. tempNum += companyNum.substr(0,3);
  2255. tempNum += '-';
  2256. tempNum += companyNum.substr(3,2);
  2257. tempNum += '-';
  2258. tempNum += companyNum.substr(5);
  2259. }
  2260. $(input).val(tempNum);
  2261. };
  2262. function itp_fn_set_comma(str) {
  2263. str = String(str);
  2264. return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
  2265. };
  2266. function itp_fn_set_uncomma(str) {
  2267. str = String(str);
  2268. return str.replace(/[^\d]+/g, '');
  2269. };
  2270. function itp_fn_set_plus_minus(num) {
  2271. var str = '';
  2272. if (num > -1) {
  2273. str = '+ ' + itp_fn_set_comma(itp_fn_set_uncomma(num));
  2274. } else {
  2275. str = '- ' + itp_fn_set_comma(itp_fn_set_uncomma(Math.abs(num)));
  2276. }
  2277. return str;
  2278. };
  2279. function itp_fn_load_page(href, tab, param, id) {
  2280. //console.log('[ITP_FN_LOAD_PAGE] href = ' + href + ', tab = ' + tab);
  2281. //로그인체크
  2282. itp_fn_logined_check();
  2283. $.ajax({
  2284. contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2285. url: href,
  2286. data: param,
  2287. type: 'POST',
  2288. dataType: 'html',
  2289. async: false,
  2290. timeout: 10000,
  2291. beforeSend: function() {
  2292. //$('#ITP_OVERLAY').show();
  2293. },
  2294. complete: function() {
  2295. //$('#ITP_OVERLAY').hide();
  2296. //$('#ITP_SIDEBAR').removeClass('itp_open_nav');srhResult
  2297. },
  2298. success: function(html) {
  2299. $('#ITP_HEADER .itp_tab_list li').removeClass('active');
  2300. $('#ITP_HEADER .itp_tab_list').append(tab);
  2301. $('#ITP_CONTAINER .itp_contents .itp_sec').removeClass('active');
  2302. $('#ITP_CONTAINER .itp_contents').append(html);
  2303. //$('#ITP_SIDEBAR').removeClass('itp_open_nav');
  2304. //JS파일적용
  2305. const js = "<script src=\"./js/app/"+id.substring(0, id.length - 5).toLowerCase()+"/ITP_"+id+".js?version="+js_version+"\"></script>";
  2306. $('#ITP_CONTAINER .itp_contents #ITP_TAB_'+id+' #ITP_TAP_JS').append(js);
  2307. },
  2308. error: function(xhr, status, error) {
  2309. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2310. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failPage);
  2311. },
  2312. fail: function() {
  2313. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failPage);
  2314. }
  2315. });
  2316. };
  2317. function itp_fn_load_tabs(wrap, href) {
  2318. $.ajax({
  2319. contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2320. url: href,
  2321. type: 'POST',
  2322. dataType: 'html',
  2323. async: false,
  2324. timeout: 10000,
  2325. beforeSend: function() {
  2326. //$('#ITP_OVERLAY').show();
  2327. },
  2328. complete: function() {
  2329. //$('#ITP_OVERLAY').hide();
  2330. },
  2331. success: function(html) {
  2332. $(wrap).remove();
  2333. $('#ITP_CONTAINER .itp_contents').append(html);
  2334. },
  2335. error: function(xhr, status, error) {
  2336. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2337. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failPage);
  2338. },
  2339. fail: function() {
  2340. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failPage);
  2341. }
  2342. });
  2343. };
  2344. function itp_fn_load_html(href, container, param, fn, args) {
  2345. $.ajax({
  2346. contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2347. url: href,
  2348. data: param,
  2349. type: 'POST',
  2350. dataType: 'html',
  2351. async: false,
  2352. timeout: 10000,
  2353. beforeSend: function() {
  2354. //$('#ITP_OVERLAY').show();
  2355. },
  2356. complete: function() {
  2357. //$('#ITP_OVERLAY').hide();
  2358. },
  2359. success: function(html) {
  2360. var append = function() {
  2361. var deferred = $.Deferred();
  2362. try {
  2363. $(container).empty();
  2364. $(container).append(html);
  2365. deferred.resolve();
  2366. } catch(err) {
  2367. deferred.reject(err);
  2368. }
  2369. return deferred.promise();
  2370. };
  2371. append().done(function() {
  2372. if (fn !== undefined || typeof fn !== 'undefined') {
  2373. fn.callBack(args);
  2374. }
  2375. });
  2376. },
  2377. error: function(xhr, status, error) {
  2378. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2379. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failData);
  2380. },
  2381. fail: function() {
  2382. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failData);
  2383. }
  2384. });
  2385. };
  2386. // itp_fn_call_popup(ITP_CONTEXTPATH + '/BIZPOP_BOSS', '#ITP_ASIDE', 'BIZPOP_BOSS', null, popFn, null, 'S');
  2387. function itp_fn_call_popup(href, container, fnm, param, popFn, args, returnType) {
  2388. $.ajax({
  2389. contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2390. url: href,
  2391. data: param,
  2392. type: 'POST',
  2393. dataType: 'html',
  2394. async: false,
  2395. timeout: 10000,
  2396. beforeSend: function() {
  2397. //$('#ITP_OVERLAY').show();
  2398. },
  2399. complete: function() {
  2400. //$('#ITP_OVERLAY').hide();
  2401. },
  2402. success: function(html) {
  2403. var append = function() {
  2404. var deferred = $.Deferred();
  2405. try {
  2406. $(container).empty();
  2407. $(container).append(html);
  2408. deferred.resolve();
  2409. } catch(err) {
  2410. deferred.reject(err);
  2411. }
  2412. return deferred.promise();
  2413. };
  2414. append().done(function() {
  2415. eval('itp_fn_' + fnm)(popFn, args, returnType);
  2416. $('.modal.itp_modal .modal-content').draggable();
  2417. });
  2418. },
  2419. error: function(xhr, status, error) {
  2420. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2421. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failData);
  2422. },
  2423. fail: function() {
  2424. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failData);
  2425. }
  2426. });
  2427. };
  2428. // 2021.07.07 송호성 추가
  2429. function fn_call_popup(type, popnm, container, popFn, args, returnType) {
  2430. console.log('[ITP_CALL_POPUP] type = ' + type + ', popnm = ' + popnm);
  2431. $.ajax({
  2432. contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2433. url: ITP_CONTEXTPATH + '/app/popup/'+type+'/'+popnm+'.html',
  2434. type: 'POST',
  2435. dataType: 'html',
  2436. async: false,
  2437. timeout: 10000,
  2438. beforeSend: function() {
  2439. //$('#ITP_OVERLAY').show();
  2440. },
  2441. complete: function() {
  2442. //$('#ITP_OVERLAY').hide();
  2443. },
  2444. success: function(html) {
  2445. var append = function() {
  2446. var deferred = $.Deferred();
  2447. try {
  2448. $(container).empty();
  2449. $(container).append(html);
  2450. deferred.resolve();
  2451. } catch(err) {
  2452. deferred.reject(err);
  2453. }
  2454. return deferred.promise();
  2455. };
  2456. append().done(function() {
  2457. const js = '<script src="'+ITP_CONTEXTPATH+'/js/app/popup/'+type+'/ITP_'+popnm+'.js?version='+js_version+'"></script>';
  2458. $('#ITP_ASIDE #ITP_'+popnm+' #ITP_POPUP_JS').empty();
  2459. $('#ITP_ASIDE #ITP_'+popnm+' #ITP_POPUP_JS').append(js);
  2460. eval('itp_fn_' + popnm)(popFn, args, returnType);
  2461. $('.modal.itp_modal .modal-content').draggable();
  2462. });
  2463. },
  2464. error: function(xhr, status, error) {
  2465. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2466. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failData);
  2467. },
  2468. fail: function() {
  2469. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failData);
  2470. }
  2471. });
  2472. };
  2473. function fn_popup_window_center(pageURL, popNm, w, h, mIdx) {
  2474. var left = (screen.width/2)-(w/2)+(mIdx*45);
  2475. var top = (screen.height/2)-(h/2)+(mIdx*90);
  2476. var targetWin = window.open (pageURL, popNm, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
  2477. if (window.focus) {
  2478. targetWin.focus();
  2479. }
  2480. return targetWin;
  2481. }
  2482. function itp_fn_ajax_call(href, param, fn, type) {
  2483. $.ajax({
  2484. contentType: 'application/json',
  2485. url: href,
  2486. data: JSON.stringify(param),
  2487. type: 'POST',
  2488. dataType: 'json',
  2489. async: false,
  2490. timeout: 10000,
  2491. beforeSend: function() {
  2492. $('#ITP_OVERLAY').show();
  2493. },
  2494. complete: function() {
  2495. $('#ITP_OVERLAY').hide();
  2496. },
  2497. success: function(result) {
  2498. if (result.resultCd == 'S') {
  2499. if (type == 'SAVE') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.successData);}
  2500. if (type == 'DELETE') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.deletedData);}
  2501. if (type == 'RESETPW') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.resetPw);}
  2502. if (type == 'RESETUSERPW') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.resetUserPw);}
  2503. if (type == 'CANCELPAY') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.cancelPay);}
  2504. if (fn !== undefined || typeof fn !== 'undefined') fn(result.resultData);
  2505. } else {
  2506. if (result.resultMsg != null && result.resultMsg != '') {
  2507. itp_fn_modal_alert_ajax(result.resultMsg);
  2508. } else {
  2509. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  2510. }
  2511. }
  2512. },
  2513. error: function(xhr, status, error) {
  2514. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2515. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  2516. },
  2517. fail: function() {
  2518. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  2519. }
  2520. });
  2521. };
  2522. function itp_fn_excel_upload(formId, href, fn) {
  2523. const form = $(formId)[0];
  2524. let param = new FormData(form);
  2525. $.ajax({
  2526. enctype: 'multipart/form-data',
  2527. method: 'POST',
  2528. url: ITP_CONTEXTPATH + href,
  2529. data: param,
  2530. processData: false,
  2531. contentType: false,
  2532. cache: false,
  2533. async: false,
  2534. timeout: 10000,
  2535. beforeSend: function() {
  2536. $('#ITP_OVERLAY').show();
  2537. },
  2538. complete: function() {
  2539. $('#ITP_OVERLAY').hide();
  2540. },
  2541. success: function(result) {
  2542. if (result.resultCd == 'S') {
  2543. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.upload.successUpload);
  2544. } else {
  2545. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.upload.failUpload);
  2546. }
  2547. if(typeof fn === 'function'){
  2548. fn(result.resultData);
  2549. }
  2550. },
  2551. error: function(xhr, status, error) {
  2552. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2553. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.upload.failUpload);
  2554. },
  2555. fail: function() {
  2556. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.upload.failUpload);
  2557. }
  2558. });
  2559. };
  2560. function itp_fn_ajax_form_call(href, param, fn, type) {
  2561. $.ajaxSettings.traditional = true;
  2562. $.ajax({
  2563. url: href,
  2564. type: 'POST',
  2565. data: param,
  2566. enctype: 'multipart/form-data',
  2567. cache: false,
  2568. contentType: false,
  2569. processData: false,
  2570. dataType: 'json',
  2571. async: false,
  2572. timeout: 10000,
  2573. beforeSend: function() {
  2574. $('#ITP_OVERLAY').show();
  2575. },
  2576. complete: function() {
  2577. $('#ITP_OVERLAY').hide();
  2578. },
  2579. success: function(result) {
  2580. if (result.resultCd == 'S') {
  2581. if (type == 'SAVE') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.successData);}
  2582. if (type == 'DELETE') {itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.deletedData);}
  2583. if (fn !== undefined || typeof fn !== 'undefined') fn(result.resultData);
  2584. } else {
  2585. if (result.resultMsg != null && result.resultMsg != '') {
  2586. itp_fn_modal_alert_ajax(result.resultMsg);
  2587. } else {
  2588. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  2589. }
  2590. }
  2591. },
  2592. error: function(xhr, status, error) {
  2593. if (xhr.status == 401) location.href = ITP_CONTEXTPATH + '/';
  2594. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  2595. },
  2596. fail: function() {
  2597. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.failProcess);
  2598. }
  2599. });
  2600. };
  2601. function itp_fn_date_format(date, type) {
  2602. let month = date.getMonth() + 1;
  2603. let day = date.getDate();
  2604. let hour = date.getHours();
  2605. let minute = date.getMinutes();
  2606. let second = date.getSeconds();
  2607. month = month >= 10 ? month : '0' + month;
  2608. day = day >= 10 ? day : '0' + day;
  2609. hour = hour >= 10 ? hour : '0' + hour;
  2610. minute = minute >= 10 ? minute : '0' + minute;
  2611. second = second >= 10 ? second : '0' + second;
  2612. if(type && type == 1) {
  2613. return date.getFullYear() + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
  2614. } else if(type && type == 2) {
  2615. return date.getFullYear() + '.' + month + '.' + day;
  2616. } else if(type && type == 3) {
  2617. return date.getFullYear() + '' + month + '' + day;
  2618. } else {
  2619. return date.getFullYear() + month + day + hour + minute + second;
  2620. }
  2621. }
  2622. // 쿠키 가져오기
  2623. var itp_fn_get_cookie = function (cname) {
  2624. var name = cname + "=";
  2625. var ca = document.cookie.split(';');
  2626. for(var i=0; i<ca.length; i++) {
  2627. var c = ca[i];
  2628. while (c.charAt(0)==' ') c = c.substring(1);
  2629. if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
  2630. }
  2631. return "";
  2632. }
  2633. // 24시간 기준 쿠키 설정하기
  2634. var itp_fn_set_cookie = function (cname, cvalue, exdays) {
  2635. var todayDate = new Date();
  2636. todayDate.setTime(todayDate.getTime() + (exdays*24*60*60*1000));
  2637. var expires = "expires=" + todayDate.toUTCString();
  2638. document.cookie = cname + "=" + cvalue + "; " + expires;
  2639. }
  2640. var itp_fn_contains_chars_only = function(value, chars) {
  2641. for (var inx = 0; inx < value.length; inx++) {
  2642. if (chars.indexOf(value.charAt(inx)) == -1)
  2643. return false;
  2644. }
  2645. return true;
  2646. }
  2647. var itp_fn_check_big_alpha_num = function(value) {
  2648. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  2649. return itp_fn_contains_chars_only(value,chars);
  2650. }
  2651. var itp_fn_s2ab = function(s) {
  2652. var buf = new ArrayBuffer(s.length);
  2653. var view = new Uint8Array(buf);
  2654. for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF;
  2655. return buf;
  2656. }
  2657. var itp_fn_export_excel = function(excelData, fileName, sheetName) {
  2658. // WORKBOOK 생성
  2659. var wb = XLSX.utils.book_new();
  2660. // 시트 만들기
  2661. var newWorksheet = XLSX.utils.json_to_sheet(excelData);
  2662. // WORKBOOK에 새로만든 워크시트에 이름을 주고 붙인다.
  2663. XLSX.utils.book_append_sheet(wb, newWorksheet, sheetName);
  2664. // 엑셀 파일 만들기
  2665. var wbout = XLSX.write(wb, {bookType:'xlsx', type: 'binary'});
  2666. // 엑셀 파일 내보내기
  2667. saveAs(new Blob([itp_fn_s2ab(wbout)],{type:"application/octet-stream"}), fileName);
  2668. }
  2669. var itp_fn_jqgrid_to_excel = function(gridId, fileName, sheetName){
  2670. var colModel = $(gridId).jqGrid('getGridParam', 'colModel');
  2671. let dataList = [];
  2672. var ids = $(gridId).getDataIDs();
  2673. $.each(ids, function(ridx, rowId) {
  2674. let data = new Object() ;
  2675. $.each(colModel, function(cidx, item) {
  2676. // console.log( item.label + ' : ' + $(gridId).jqGrid('getCell', rowId, item.name) );
  2677. if(item.name == 'rn') { // NO
  2678. data["NO"] = $(gridId).jqGrid('getCell', rowId, item.name);
  2679. } else if(item.label !== undefined) {
  2680. data[item.label] = $(gridId).jqGrid('getCell', rowId, item.name);
  2681. }
  2682. });
  2683. dataList.push(data);
  2684. });
  2685. itp_fn_export_excel(dataList, fileName, sheetName);
  2686. };
  2687. var itp_fn_set_timeout = {
  2688. init: function () {
  2689. this.action();
  2690. },
  2691. action: function () {
  2692. $(document).on('click', 'button', function() {
  2693. if(!$(this).hasClass('itp_out')) {
  2694. //로그인체크
  2695. itp_fn_logined_check();
  2696. }
  2697. });
  2698. }
  2699. };