config.js 107 KB

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