config.js 93 KB

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