/* ////////////////////////////////////////////////////////////////////////////////////////////// @ 초기설정 ////////////////////////////////////////////////////////////////////////////////////////////// */ var url_host = "https://" + window.location.host; var url_ajax = url_host + "/page/ajax"; var url_theme = url_host + "/theme/bootstrap5-basic"; var url_search_temp = window.location.search.split("="); var url_search = url_search_temp[1]; var url_path = window.location.pathname; var url_page = url_path.split("/").pop(); const tmp_url = $(location).attr('search'); var urlParams = new URLSearchParams( tmp_url ); // 페이지네이션 출력 갯수 var cf_write_pages = 5; /* ////////////////////////////////////////////////////////////////////////////////////////////// @ 전처리 ////////////////////////////////////////////////////////////////////////////////////////////// */ /*************************************** @ 통합검색 옵션 불러오기 ***************************************/ var hd_qcaid = ""; $("#hd_qcaid option").append(hd_qcaid); /* ////////////////////////////////////////////////////////////////////////////////////////////// @ 이벤트 ////////////////////////////////////////////////////////////////////////////////////////////// */ $(document).ready(function(){ }); /* ////////////////////////////////////////////////////////////////////////////////////////////// @ FUNCTION ////////////////////////////////////////////////////////////////////////////////////////////// */ /*************************************** @ 버튼 > 통합검색 ***************************************/ function search_submit(f) { if (f.q.value.length < 2) { alert("검색어는 두글자 이상 입력하십시오."); f.q.select(); f.q.focus(); return false; } return true; } /*************************************** @ ajax > 아웃 로그인 ***************************************/ function out_login(){ var result = ""; $.ajax({ type : "POST", data : { action : "menu_login" }, async: true, url : url_ajax + "/ajax_common.php", dataType : "html", success:function(data){ // result = data; $("#hd_login").html( data); }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); return result; } /*************************************** @ ajax > 메인메뉴 ***************************************/ function main_menu(){ var result = ""; $.ajax({ type : "POST", data : { action : "main_menu" }, async: true, url : url_ajax + "/ajax_common.php", dataType : "html", success:function(data){ // result = data; $("#main_menu").html( data); }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); return result; } /*************************************** @ ajax > 사이드 메뉴 ***************************************/ function side_menu(){ var result = ""; $.ajax({ type : "POST", data : { action : "side_menu" }, async: true, url : url_ajax + "/ajax_common.php", dataType : "html", success:function(data){ // result = data; $("#side_menu .offcanvas-body").html( data); }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); return result; } /*************************************** @ ajax > 메인 베너 ***************************************/ function main_banner(){ var result = ""; $.ajax({ type : "POST", data : { action : "main_banner" }, async: true, url : url_ajax + "/ajax_common.php", dataType : "html", success:function(data){ // result = data; $("#main_banner").html( data); }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); return result; } /*************************************** @ ajax > 메인 최신글 ***************************************/ function main_notice(){ var result = ""; $.ajax({ type : "POST", data : { action : "latest", params : "theme/shop_basic_notitle|page4_1|5|30" }, async: true, url : url_ajax + "/ajax_common.php", dataType : "html", success:function(data){ // result = data; $("#main_notice").html( data); }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); return result; } /*************************************** @ 선택박스 > 약재선택 > 약재 제품 로드 ***************************************/ function query_item_list( select_object ) { $.ajax({ type : "POST", data : { action : "select_item" }, async: false, url : url_ajax + "/ajax_common.php", dataType : "jsonp", success:function(data){ $(select_object).empty(); //죄회자료 if( data.length > 0 ) { $(select_object).append(``); //LOOP $(data).each( function(index, item) { $(select_object).append(``); }); } }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); } /*************************************** @ 리스트 페이지네이션 ***************************************/ function get_pagination( p_total_page, p_total_count ) { let toggle_arrow = ""; let current_page = parseInt( $("#current_page").val() ); let total_page = parseInt( p_total_page ); let total_count = parseInt( p_total_count ); let start_page = 0; let end_page = 0; let write_pages = cf_write_pages; if(total_count > 0) $("#page_nav_div").removeClass(".d-none"); //페이지 정보 출력 $("#page_info").text( current_page + '/' + total_page + ' page' ); $("#total_page").val( total_page ); start_page = (( ((current_page - 1) / write_pages)) * write_pages) + 1; end_page = start_page + write_pages - 1; //페이지네이션 초기화 $(document).find("#nav_page ul").empty(); if( total_page <= 1 ) return false; //첫 페이지로 이동 toggle_arrow = '' if( current_page <= 1 ) toggle_arrow = " disabled "; $(document).find("#nav_page ul").append( '
  • ' + ''+ '
  • '); //이전 페이지로 이동 toggle_arrow = '' if( start_page <= 1 ) toggle_arrow = " disabled "; $(document).find("#nav_page ul").append( '
  • ' + ''+ '
  • '); //페이지 버튼 생성 toggle_arrow = ''; for(let i=0; i < $("#total_page").val(); i++ ){ if( current_page == (i+1) ) toggle_arrow = ' active '; else toggle_arrow=''; $(document).find("#nav_page ul").append( '
  • ' + ''+ '
  • '); } //다음 페이지로 이동 $(document).find("#nav_page ul").append( '
  • ' + ''+ '
  • '); //끝 페이지로 이동 $(document).find("#nav_page ul").append( '
  • ' + ''+ '
  • '); } /*************************************** @ 오늘날자를 문자형으로 ***************************************/ function getToday() { var date = new Date(); return date.getFullYear() + "-" + ("0"+(date.getMonth()+1)).slice(-2) + "-" + ("0"+date.getDate()).slice(-2); } /*************************************** @ 현재 DATE TIME 을 숫자로 표기 ***************************************/ function getDateTime() { var date = new Date(); return date.getTime(); } /*************************************** @ 오늘날자에서 달계산 ***************************************/ function calc_month( fdate, fmonth ) { var date = new Date( fdate ); date.setMonth( date.getMonth() + fmonth ); return date.toISOString().substring(0,10); } /*************************************** @ 오늘날자에서 이월 다음달 1일 ***************************************/ function next_month( fdate, fmonth ) { var date = new Date( fdate ); return date.getFullYear() + "-" + ("0"+(date.getMonth()+( fmonth + 1 ))).slice(-2) + "-" + "01"; } /*************************************** @ 천단위 콤마 펑션 ***************************************/ function addComma(value){ value = value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); return value } /***************************************************************************************************** @ alert confirm 팝업창 선 // 콜백함수 있을 때 MsgBox.Alert("Alert Message!", function() {MsgBox.Alert("OK");}); // 콜백함수 없을 때 MsgBox.Alert("Alert Message!"); // YES버튼에만 콜백 함수 넣을 경우 MsgBox.Confirm("Confirm Message!", function() {MsgBox.Alert("YES");}); // NO버튼에도 콜백 함수 넣을 경우 MsgBox.Confirm("Confirm Message!", function() {MsgBox.Alert("YES");} , function() {MsgBox.Alert("NO");}); ********************************************************************************************************/ var MsgBox = { /* Alert */ Alert: function(msg, okhandler) { new Promise((resolve, reject) => { $("#msg_popup #btn_confirm").hide(); $("#msg_popup #btn_alert").show(); $("#msg_popup #alert_ok").unbind(); $("#msg_popup .modal-body").html(msg); $('#msg_popup').modal('show'); $("#msg_popup #alert_ok").click(function() { $('#msg_popup').modal('hide'); }); $("#msg_popup").on("hidden.bs.modal", function(e) { e.stopPropagation(); if(okhandler != null) resolve(); else reject(); }); }).then(okhandler).catch(function() {}); }, /* Confirm */ Confirm: function(msg, yeshandler, nohandler) { new Promise((resolve, reject) => { var flag = false; $("#msg_popup #btn_alert").hide(); $("#msg_popup #btn_confirm").show(); $("#msg_popup #confirm_yes").unbind(); $("#msg_popup #confirm_no").unbind(); $("#msg_popup .modal-body").html(msg); $('#msg_popup').modal('show'); $('#msg_popup').on('keypress', function (e) { var keycode = (e.keyCode ? e.keyCode : e.which); if(keycode == '13') { flag = true; $('#msg_popup').modal('hide'); } }); $("#msg_popup #confirm_yes").click(function() { flag = true; $('#msg_popup').modal('hide'); }); $("#msg_popup #confirm_no").click(function() { flag = false; $('#msg_popup').modal('hide'); }); $("#msg_popup").on("hidden.bs.modal", function(e) { e.stopPropagation(); if(yeshandler != null && flag == true) resolve(1); else if(nohandler != null && flag == false) resolve(2); else reject(); }); }).then(function(value) { if(value == 1) yeshandler(); else if(value == 2) nohandler(); }).catch(function() {}); }, } /*************************************** @ 공용 SQL 문장 실행 ***************************************/ function my_sql( sql ){ var result = ""; $.ajax({ type : "POST", data : { action : "my_sql", sql : sql }, async: false, url : url_ajax + "/common.php", dataType : "jsonp", success:function(data){ result = data; }, error : function(request, status, error) { console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); return result; } /*************************************** @ 프린터 출력 함수 ***************************************/ function printDiv(divName) { var printContents = document.getElementById(divName).innerHTML; var originalContents = document.body.innerHTML; var win = window.open("", "winprint", "left=10,top=10,width=670,height=800,menubar=yes,toolbar=yes,scrollbars=yes"); self.focus(); win.document.open(); win.document.write(` 프린트출력 `+ printContents.replace('text-nowrap','text-wrap').replace(' `); win.document.close //win.document.reload(); //win.print(); //win.close(); } /*************************************** @ 약재 계산 단위 값 계산 ***************************************/ function get_unit_value(get_model) { var it_model = get_model.replaceAll(' ',''); var arr_calc=[], arr_unit=[], arr_val=[]; //수량 단위 var arr_result = [0,0,'']; // 용량 , vial , g if( it_model.indexOf('*') > 0 ){ //1. 3단계 계산 공식 (10:vial * 20:ml * 0.1:g) if( it_model.indexOf('mg') > -1 ){ //2. mg 단위 계산 arr_unit = it_model.toString().split("*"); //단계별 수치 추출 $(arr_unit).each(function(){ arr_calc.push( parseFloat( this.toString().split(":")[0] ) ); arr_result[2] = this.toString().split(":")[1]; }); arr_result[0] = (arr_calc[0] * arr_calc[1]) * arr_calc[2]; //용량 arr_result[1] = arr_calc[0]; // vial return arr_result; } else { //2. g 단위 계산 arr_unit = it_model.toString().split("*"); //단계별 수치 추출 $(arr_unit).each(function(){ arr_val = this.toString().split(":"); arr_calc.push( parseFloat( arr_val[0] ) ); arr_result[2] = arr_val[1]; //단위 }); arr_result[0] = (arr_calc[0] * arr_calc[1]) * arr_calc[2]; arr_result[1] = arr_calc[0]; return arr_result; } } else { //1. ea 계산 [수량][단위] arr_result[0] = it_model.toString().split(":")[0]; arr_result[1] = it_model.toString().split(":")[0]; arr_result[2] = it_model.toString().split(":")[1]; return arr_result; } }