config.js 96 KB

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