config.js 100 KB

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