$(function () {
  $("input[name=customer_type]").on("click", function () {
    if ($(this).val() == "reg_cust") $("#customer_list_modal_footer").show();
    else $("#customer_list_modal_footer").hide();
    get_customers($(this).val(), 0);
  });
  $("#check_all_customer").on("click", function () {
    $("input[name=check_customer]").prop("checked", $(this).prop("checked"));
  });
});
function click_customer_list_modal_check(obj) {
  if ($(obj).prop("checked") == false)
    $("#check_all_customer").prop("checked", false);
}
function delete_customer() {
  if (confirm("삭제하시겠습니까?")) {
    let type = $("input[name=customer_type]:checked").val();
    let id_array = [];
    $("input[name=check_customer]:checked").each(function () {
      id_array.push($(this).val());
    });
    $.ajax({
      method: "post",
      url: "/ajax/ajax.customer.php",
      dataType: "json",
      data: {
        mode: "delete_customer",
        type: type,
        ids: id_array,
      },
      success: function (data) {
        if ((data.result = "success")) {
          $("#check_all_customer").prop("checked", false);
          $("input[name=check_customer]:checked").each(function () {
            var customer = $(this).parents("tr");
            customer.remove();
          });
          toastr.success("성공적으로 삭제되었습니다.");
        }
      },
    });
  }
}
function changeNumber(evt, type, id, opt_price) {
  let value = $("#" + id)[0].value;
  let gwc_ori_price = $("#gwc_ori_price").val();
    let conts_cnt = $("#conts_cnt").val();

  if (type == "minus") {
        if (value == 1) {
      alert("최소 구매수량은 1 이상 입니다.");
        } else {
      $("#" + id)[0].value = parseInt(value) - 1;
      $("#gwc_conts_price").text(
        number_format(
          parseInt($("#gwc_conts_price")[0].innerText.replace(/,/g, "")) -
            parseInt(gwc_ori_price) -
            parseInt(opt_price)
        )
      );
            $("#conts_cnt").val(parseInt(conts_cnt) -  1);
        }
    } else {
        // gwc_ori_price
        // gwc_conts_price
        if (value == 49) {
      alert("최대 구매수량은 50 이하 입니다.");
        } else {
      $("#" + id)[0].value = parseInt(value) + 1;
      $("#gwc_conts_price").text(
        number_format(
          parseInt($("#gwc_conts_price")[0].innerText.replace(/,/g, "")) +
            parseInt(gwc_ori_price) +
            parseInt(opt_price)
        )
      );
            $("#conts_cnt").val(parseInt(conts_cnt) +  1);
        }
    }
}

function remove_option(id, txt, opt_price) {
  let gwc_ori_price = $("#gwc_ori_price").val();
    let conts_cnt = $("#conts_cnt").val();
    if (option_array.length == 1) {
    $("#gwc_conts_price").text(number_format(gwc_ori_price));
        $("#conts_cnt").val(1);
    } else {
    $("#gwc_conts_price").text(
            number_format(
        parseInt($("#gwc_conts_price")[0].innerText.replace(/,/g, "")) -
          (parseInt(gwc_ori_price) * parseInt($("#" + id).val()) +
            parseInt(opt_price) * parseInt($("#" + id).val()))
            )
        );
    $("#conts_cnt").val(parseInt(conts_cnt) - parseInt($("#" + id).val()));
    }
    for (let i = 0; i < option_array.length; i++) {
        if (option_array[i] == txt) {
            option_array.splice(i, i + 1);
        }
    }
    $('#' + id).parent().parent().remove();
}

function get_sms()   {
  if ($("input[name=seller_mem_phone]").val() == "") {
    alert("인증받으실 휴대폰번호를 입력해주세요.");
        return;
    }
  if (
    $("input[name=seller_mem_phone]").val().substring(0, 3) != "010" &&
    $("input[name=seller_mem_phone]").val().substring(0, 3) != "011" &&
    $("input[name=seller_mem_phone]").val().substring(0, 3) != "016" &&
    $("input[name=seller_mem_phone]").val().substring(0, 3) != "017" &&
    $("input[name=seller_mem_phone]").val().substring(0, 3) != "018" &&
    $("input[name=seller_mem_phone]").val().substring(0, 3) != "019"
  ) {
    alert("전화번호 첫번째 자리는 010, 011, 016, 017, 018, 019만 가능합니다.");
        return;
    }

  if (
    $("input[name=seller_mem_phone]").val().length < 10 ||
    $("input[name=seller_mem_phone]").val().length > 12
  ) {
    alert("인증받으실 전화번호를 확인해주세요.");
        return;
    }

    $.ajax({
        type:"POST",
        url:"/ajax/join.proc.php",
        cache: false,
        dataType:"json",
        data:{
            mode:"send_sms",
      rphone: $("input[name=seller_mem_phone]").val(),
      test: "",
        },
        success:function(data){
            if(data.result == "success") {
        $("#check_rnum").val("Y");
      } else $("#check_rnum").val("");

            alert(data.msg);
    },
  });
}

function chk_sms()   {
    $.ajax({
        type:"POST",
        url:"/ajax/join.proc.php",
        cache: false,
        dataType:"json",
        data:{
            mode:"check_sms",
      rphone: $("input[name=seller_mem_phone]").val(),
      rnum: $("#seller_rnum").val(),
        },
        success:function(data){
            if(data.result == "success") {
        $("#check_rnum").val("Y");
                // $('#check_sms').html('<img src="/images/check.gif"> 인증되었습니다.</p>');
            } else {
        $("#check_rnum").val("");
        $("#check_sms").html("");
            }

            alert(data.msg);
    },
  });
}
function show_customers() {
  $("#mypage-modalwindow").modal("hide");
  $("#customer_list_modal").modal("show");
  $("#reg_cust").prop("checked", true);
  get_customers("reg_cust", 0);
}

function show_edit_input(val, type, list_id = 0) {
  if (type == "creat") {
    $("#reg_cust_mode").val("creat");
    //$("#customer_list_modal").modal("hide");
    $("#customer_edit_modal").modal("show");
  } else {
    $.ajax({
      type: "POST",
      url: "/admin/ajax/manage_customers.php",
      dataType: "json",
      data: {
        mode: "edit_table",
        type: type,
        idx: val,
      },
      success: function (data) {
        $("#reg_cust_mode").val(type);
        $("#edit_reg_idx").val(val);
        $("#list_reg_idx").val(list_id);
        if (type == "reg_cust_edit" || type == "member_reg_edit") {
          $("#reg_name").val(data.reg_name);
          $("#reg_phone1").val(data.reg_phone1);
          $("#reg_phone2").val(data.reg_phone2);
          $("#reg_email").val(data.reg_email);
          $("#reg_birthday").val(data.reg_birthday);
          $("#reg_work_type").val(data.reg_work_type);
          $("#reg_company_name").val(data.reg_company_name);
          $("#reg_job").val(data.reg_job);
          $("#reg_company_addr").val(data.reg_company_addr);
          $("#reg_home_addr").val(data.reg_home_addr);
          $("#reg_link").val(data.reg_link);
          $("#reg_memo").val(data.reg_memo);
        } else if (type == "req_cust_edit" || type == "member_req_edit") {
          $("#reg_name").val(data.req_name);
          $("#reg_phone1").val(data.req_phone1);
          $("#reg_phone2").val(data.req_phone2);
          $("#reg_email").val(data.req_email);
          $("#reg_birthday").val(data.req_birthday);
          $("#reg_work_type").val(data.req_work_type);
          $("#reg_company_name").val(data.req_company_name);
          $("#reg_job").val(data.req_job);
          $("#reg_company_addr").val(data.req_company_addr);
          $("#reg_home_addr").val(data.req_home_addr);
          $("#reg_link").val(data.req_link);
          $("#reg_memo").val(data.req_memo);
        } else if (type == "get_cust_edit" || type == "member_get_edit") {
          $("#reg_name").val(data.get_name);
          $("#reg_phone1").val(data.get_phone1);
          $("#reg_phone2").val(data.get_phone2);
          $("#reg_email").val(data.get_email);
          $("#reg_birthday").val(data.get_birthday);
          $("#reg_work_type").val(data.get_work_type);
          $("#reg_company_name").val(data.get_company_name);
          $("#reg_job").val(data.get_job);
          $("#reg_company_addr").val(data.get_company_addr);
          $("#reg_home_addr").val(data.get_home_addr);
          $("#reg_link").val(data.get_link);
          $("#reg_memo").val(data.get_memo);
        } else if (type == "member_recom_edit") {
          $("#reg_name").val(data.recom_name);
          $("#reg_phone1").val(data.recom_phone1);
          $("#reg_phone2").val(data.recom_phone2);
          $("#reg_email").val(data.recom_email);
          $("#reg_birthday").val(data.recom_birthday);
          $("#reg_work_type").val(data.recom_work_type);
          $("#reg_company_name").val(data.recom_company_name);
          $("#reg_job").val(data.recom_job);
          $("#reg_company_addr").val(data.recom_company_addr);
          $("#reg_home_addr").val(data.recom_home_addr);
          $("#reg_link").val(data.recom_link);
          $("#reg_memo").val(data.recom_memo);
        } else if (type == "paper_edit") {
          $("#paper_name").val(data.name);
          $("#paper_job").val(data.job);
          $("#paper_org").val(data.org_name);
          $("#paper_addr").val(data.address);
          $("#paper_phone1").val(data.phone1);
          $("#paper_phone2").val(data.phone2);
          $("#paper_mobile").val(data.mobile);
          $("#paper_fax").val(data.fax);
          $("#paper_email1").val(data.email1);
          $("#paper_email2").val(data.email2);
          $("#paper_memo").val(data._memo);
        }
        //$("#customer_list_modal").modal("hide");
        $("#customer_edit_modal").modal("show");
      },
      error: function () {
        alert("가져오기 실패");
      },
    });
  }
}
function save_reg_cust(mem_id) {
  var action_mode = $("#reg_cust_mode").val();
  if (action_mode == "creat") {
    var mode = "creat";
    var msg = "저장 하시겠습니까?";
    var idx = 0;
  } else {
    var mode = "edit";
    var msg = "수정 하시겠습니까?";
    var idx = $("#edit_reg_idx").val();
    var list_idx = $("#list_reg_idx").val();
  }

  var name = $("#reg_name").val();
  var phone1 = $("#reg_phone1").val();
  var phone2 = $("#reg_phone2").val();
  var email = $("#reg_email").val();
  var birthday = $("#reg_birthday").val();
  var work_type = $("#reg_work_type").val();
  var company_name = $("#reg_company_name").val();
  var job = $("#reg_job").val();
  var company_addr = $("#reg_company_addr").val();
  var home_addr = $("#reg_home_addr").val();
  var link = $("#reg_link").val();
  var memo = $("#reg_memo").val();

  if (confirm(msg)) {
    $.ajax({
      type: "POST",
      url: "/admin/ajax/manage_customers.php",
      data: {
        mode: mode,
        type: action_mode,
        idx: idx,
        mem_id: mem_id,
        name: name,
        phone1: phone1,
        phone2: phone2,
        email: email,
        birthday: birthday,
        work_type: work_type,
        company_name: company_name,
        job: job,
        company_addr: company_addr,
        home_addr: home_addr,
        link: link,
        memo: memo,
        list_idx: list_idx,
      },
      success: function () {
        if (action_mode == "creat") {
          alert("저장되었습니다.");
        } else {
          alert("수정되었습니다.");
        }
        $("#customer_list_modal").modal("show");
        $("#customer_edit_modal").modal("hide");
        if (
          action_mode == "creat" ||
          action_mode == "reg_cust_edit" ||
          action_mode == "member_reg_edit"
        )
          get_customers("reg_cust", 0);
        else if (
          action_mode == "req_cust_edit" ||
          action_mode == "member_req_edit"
        )
          get_customers("req_cust", 0);
        else if (
          action_mode == "member_recom_edit"
        )
          get_customers("recom_cust", 0);
        else if (
          action_mode == "get_cust_edit" ||
          action_mode == "member_get_edit"
        )
          get_customers("get_cust", 0);
      },
      error: function () {
        alert("등록목록 수정 실패");
      },
    });
  }
}
function show_customer_memo(no) {
  $("#customer_list_modal").modal("hide");
  let memo = $("#customer_list_modal_memo_" + no).val();
  $("#customer_memo").html(memo);
  $("#customer_memo_modal").modal("show");
}

function close_customer_memo() {
  $("#customer_list_modal").modal("show");
  $("#customer_memo_modal").modal("hide");
}
function draw_paging(totalCnt, pageCnt, naviSize, nowPage, type) {
  let pageStr = "";
  let totalPage = Math.ceil(totalCnt / pageCnt);
  let total_block = Math.ceil(totalPage / naviSize);
  let block = Math.ceil(nowPage / naviSize);

  let first_page = (block - 1) * naviSize;
  let last_page = block * naviSize;
  let go_page = first_page + 1;
  let prevPG = first_page;
  let nextPG = last_page + 1;

  if (total_block <= block) last_page = totalPage;
  pageStr +=
    '<div class="dataTables_paginate paging_simple_numbers" id="list_paginate">';
  pageStr += '<ul class="pagination">';

  //이전 페이지 block 보기
  if (totalPage > 1) {
    let prev_b = "";
    let next_b = "";
    if (block > 1)
      prev_b +=
        "<li class='paginate_button previous' id='list_previous'><a href=\"javascript:get_customers('" +
        type +
        "','" +
        (prevPG - 1) +
        "')\" >Prev</a></li>";
    else
      prev_b +=
        "<li class='paginate_button previous disabled' id='list_previous'><a href=\"javascript:void(0)\">Prev</a></li>";

    //다음 페이지 block 보기
    if (block < total_block)
      next_b +=
        "<li class='paginate_button next' id='list_next'><a href=\"javascript:get_customers('" +
        type +
        "','" +
        (nextPG - 1) +
        "')\" >Next</a></li>";
    else
      next_b +=
        "<li class='paginate_button next' id='list_next'><a href=\"javascript:void(0)\">Next</a></li>";

    pageStr += prev_b;

    for (go_page = go_page; go_page <= last_page; go_page++) {
      if (nowPage == go_page)
        pageStr +=
          "<li class='paginate_button active'><a href='#'>" +
          go_page +
          "</a></li>";
      else
        pageStr +=
          "<li class='paginate_button'><a href=\"javascript:get_customers('" +
          type +
          "','" +
          parseInt(go_page - 1) +
          "')\">" +
          go_page +
          "</a></li>";
    }
    pageStr += next_b;
  }
  pageStr += "</ul>";
  pageStr += "</div>";
  return pageStr;
}
function get_customers(type, page) {
  $.ajax({
    method: "post",
    url: "/ajax/ajax.customer.php",
    dataType: "json",
    data: {
      mode: "get_list",
      type: type,
      page: page,
    },
    success: function (data) {
      $("#check_all_customer").prop("checked", false);
      if (data.totalCnt == 0) {
        var cont =
          '<tr><td colspan="15" style="text-align:center;background:#fff">등록된 내용이 없습니다.</td></tr>';
        $("#customer_list_body").html(cont);
      } else {
        $("#customer_list_body").empty();
        $.each(data.result, function (i, customer) {
          var cont = "<tr>";
          var edit_type = "";
          if (customer["mem_id"] != "") {
            if (type == "reg_cust") edit_type = "member_reg_edit";
            else if (type == "req_cust") edit_type = "member_req_edit";
            else if (type == "get_cust") edit_type = "member_get_edit";
            else if (type == "recom_cust") edit_type = "member_recom_edit";
          } else {
            edit_type = type + "_edit";
          }
          cont +=
            '<td class="iam_table" style="text-align:center;">' +
            '<input type="checkbox" class="check" id="check_customer" name="check_customer" onclick="click_customer_list_modal_check(this)" value="' +
            customer["id"] +
            '"></input>&nbsp' +
            customer["no"] +
            "<br> <a href=\"javascript:show_edit_input('" +
            customer["id"] +
            "', '" +
            edit_type +
            "', '" +
            customer["mem_code"] +
            '\')"><img src="/iam/img/Picture_iama1.png" style="width:20px;"></a>';
          if (type != "reg_cust" && type != "recom_cust")
            cont +=
              "<a href=\"javascript:move_reg_list('" +
              customer["id"] +
              "', '" +
              type +
              '\')"><img src="/iam/img/Picture_iama2.png" style="width:20px;"></a>';
          cont += "</td>";
          cont += '<td class="iam_table">' + customer["mem_id"] + "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_name"] === null ? "" : customer["mem_name"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_phone"] === null ? "" : customer["mem_phone"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_phone1"] === null ? "" : customer["mem_phone1"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_email"] === null ? "" : customer["mem_email"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_birth"] === null ? "" : customer["mem_birth"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["com_type"] === null ? "" : customer["com_type"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["zy"] === null ? "" : customer["zy"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_leb"] === null ? "" : customer["mem_leb"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["com_add1"] === null ? "" : customer["com_add1"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            (customer["mem_add1"] === null ? "" : customer["mem_add1"]) +
            "</td>";
          cont +=
            '<td class="iam_table">' +
            '<a href="' +
            customer["link"] +
            '">' +
            (customer["link_str"] === null ? "" : customer["link_str"]) +
            "</a></td>";
          cont +=
            '<td class="iam_table">' +
            (customer["first_regist"] === null
              ? ""
              : customer["first_regist"]) +
            "</td>";
          if (customer["memo_style"] == "default")
            customer["memo_style"] = "color:#99cc00";
          else customer["memo_style"] = "color:black";
          cont +=
            '<td class="iam_table">' +
            "<a href=\"javascript:show_customer_memo('" +
            customer["no"] +
            '\');" style="' +
            customer["memo_style"] +
            '">메모</a>';
          cont +=
            '<input type="hidden" value="' +
            (customer["mem_memo"] === null ? "" : customer["mem_memo"]) +
            '" id="customer_list_modal_memo_' +
            customer["no"] +
            '">';
          cont += "</td>";
          cont += "</tr>";
          $("#customer_list_body").append(cont);
        });
        $("#customer_list_modal_page").val(data.nowPage);
        $("#customer_list_page_bar").html(
          draw_paging(
            data.totalCnt,
            data.pageCnt,
            10,
            parseInt(data.nowPage) + parseInt(1),
            type
          )
        );
      }
    },
  });
}
function move_reg_list(val, type) {
  var msg = "이동 하시겠습니까?";
  if (confirm(msg)) {
    $.ajax({
      type: "POST",
      url: "/admin/ajax/manage_customers.php",
      data: {
        mode: "move",
        type: type,
        idx: val,
      },
      success: function (data) {
        alert("이동되었습니다.");
        get_customers(type, $("#customer_list_modal_page").val());
      },
      error: function () {
        alert("이동 실패");
      },
    });
  }
        }
function edit_ev(id, mem_id) {
  $("#auto_list_modal").modal("hide");
  start = "";
  end = "";
  item_type = "";
  see = "";
  $.ajax({
    type: "POST",
    url: "/ajax/edit_event.php",
    dataType: "json",
    data: {
      edit_ev: true,
      start: start,
      end: end,
      item_type: item_type,
      ID: mem_id,
      more: see,
      id: id,
    },
    success: function (data) {
      $("#event_idx").val(data.id);
      $("#event_title").val(data.event_title);
      $("#event_desc").val(data.event_desc);
      $("#btn_title").val(data.btn_title);
      $("#btn_link").val(data.btn_link);
      $("#short_url").val(data.short_url);
      $("#read_cnt").val(data.read_cnt);
      $("#autojoin_img_event").html(data.autojoin_img);
      $("#regdate1").val(data.regdate);
      if (data.reserv_sms_id != undefined) {
        $("#step_title").val(data.step_title);
        $("#step_phone").val(data.send_num);
        $("#step_cnt").val(data.step);
        $("#step_allow_state").val(data.step_idx);

        if (data.step_allow_state == 1) {
          $("#step_allow_state").prop("checked", true);
        } else {
          $("#step_allow_state").prop("checked", false);
}

        var href =
          '<a class="reserv_btn" href="javascript:view_step_list(' +
          data.id +
          ', `update`)">리스트변경</a> <a class="reserv_btn" href="/mypage_reservation_create.php?sms_idx=' +
          data.reserv_sms_id +
          '" target="_blank">내용수정</a>';
        $("#step_info").html(href);
      } else {
        $("#step_title").val("");
        $("#step_phone").val("");
        $("#step_cnt").val("");
        $("#step_allow_state").val("");
        $("#step_allow_state").prop("checked", false);
        var href =
          '<a class="reserv_btn" href="javascript:view_step_list(' +
          data.id +
          ', `insert`)">퍼널문자조회</a>';
        $("#step_info").html(href);
      }

      $("input[class=we_story_radio1]").prop("checked", false);
      card_short_url = data.card_short_url;
      var pos = card_short_url.search(",");
      if (pos == -1) {
        $("input[id=multi_westory_card_url1_" + card_short_url + "]").prop(
          "checked",
          true
        );
      } else {
        var arr = card_short_url.split(",");
        for (var k = 0; k < arr.length; k++) {
          $("input[id=multi_westory_card_url1_" + arr[k] + "]").prop(
            "checked",
            true
          );
        }
      }
      $("#auto_list_edit_modal").modal("show");
    },
  });
}
function view_step_list(idx, type) {
  var win = window.open(
    "../mypage_pop_message_list_for_edit_autolist.php?event_idx=" +
      idx +
      "&type=" +
      type,
    "event_pop",
    "toolbar=yes,scrollbars=yes,resizable=yes,top=200,left=200,width=1000,height=1000"
  );
}
function save_edit_ev() {
  $("#dForm_edit").submit();
}
function notice_send_settle() {
  $("#point_pay_type").val(9);
  point_settle();
}
function show_share_user_list(val) {
  var win = window.open(
    "/iam/_pop_public_profile_info.php?sendtype=" + val,
    "event_pop",
    "toolbar=yes,scrollbars=yes,resizable=yes,top=200,left=200,width=1000,height=1000"
  );
}
//공지사항 전송 팝업
function send_notice() {
  $("#mypage-modalwindow").modal("hide");
  $("#notice_send_id").val($("#send_ids").val());
  $("#notice_send_id_count").val($("#send_ids_cnt").val() + "건");
  $("#notice_send_id_count").data("num", $("#send_ids_cnt").val());
  $("#notice_send_modal_mem").modal("show");
}
function daily_list() {
  $("#mypage-modalwindow").modal("hide");
  $("#daily_list_modal").modal("show");
}
function form_save_daily() {
  if ($("#msgtitle_daily").val() == "" || $("#msgdesc_daily").val() == "") {
    alert("제목/메시지 내용을 입력해 주세요.");
    return;
  }
  if ($("#daily_cnt").val() == "") {
    alert("일발송량을 입력해 주세요.");
    return;
  }
  if ($("#daily_cnt").val() > 100) {
    alert("일발송량의 최대수는 100입니다.");
    return;
  }
  var formData = new FormData($("#dForm_daily")[0]);
  $.ajax({
    method: "post",
    processData: false,
    contentType: false,
    cache: false,
    enctype: "multipart/form-data",
    url: "/iama/daily_msg_save.php",
    data: formData,
    // dataType:"json",
    success: function (data) {
      arr = data.split("{");
      data = "{" + arr[1];
      res = JSON.parse(data);
      short_url = res.shorturl;
      $("#daily_msg_surl").val(res.shorturl);
      alert("등록되었습니다.");
    },
  });
}
function delete_ev_daily(id) {
  if (confirm("삭제하시겠습니까?")) {
    $.ajax({
      type: "POST",
      url: "/ajax/edit_event_daily.php",
      dataType: "json",
      data: {
        del: true,
        id: id,
      },
      success: function (data) {
        console.log(data);
        if (data == 1) {
          alert("삭제 되었습니다.");
          location.reload();
        }
      },
    });
  } else {
    return;
  }
}
function edit_ev_daily(id, mem_id) {
  $("#daily_list_modal").modal("hide");
  start = "";
  end = "";
  item_type = "";
  see = "";
  $.ajax({
    type: "POST",
    url: "/ajax/edit_event_daily.php",
    dataType: "json",
    data: {
      edit_ev: true,
      start: start,
      end: end,
      item_type: item_type,
      ID: mem_id,
      more: see,
      id: id,
    },
    success: function (data) {
      $("#daily_event_idx").val(data.id);
      $("#daily_event_title_intro").val(data.event_title_daily_intro);
      $("#daily_event_desc_intro").val(data.event_desc_daily_intro);
      $("#daily_event_title").val(data.msg_title_daily);
      $("#daily_event_desc").val(data.msg_desc_daily);
      $("#daily_img_event").html(data.img);
      $("#daily_short_url").val(data.short_url);
      $("#daily_read_cnt").val(data.read_cnt);
      $("#daily_regdate1").val(data.regdate);
      $("#daily_send_cnt").val(data.send_cnt);
      $("#daily_req_link").val(data.daily_req_link);
      $("select[name=htime]").val(data.htime);
      $("select[name=mtime]").val(data.mtime);
      $("#daily_list_edit_modal").modal("show");
    },
  });
}
function save_daily_edit_ev() {
  $("#dForm_daily_edit").submit();
}
function form_save_call() {
  if ($("#call_title").val() == "") {
    alert("메시지 타이틀을 입력해주세요.");
    return;
  }
  if ($("#call_content").val() == "") {
    alert("메시지 콘텐츠를 입력해주세요.");
    return;
  }
  if ($("#msgtitle_call").val() == "" || $("#msgdesc_call").val() == "") {
    alert("제목/메시지 내용을 입력해 주세요.");
    return;
  }
  var formData = new FormData($("#dForm_call")[0]);
  $.ajax({
    method: "post",
    processData: false,
    contentType: false,
    cache: false,
    enctype: "multipart/form-data",
    url: "/admin/ajax/mms_callback_save.php",
    data: formData,
    success: function (data) {
      arr = data.split("{");
      data = "{" + arr[1];
      res = JSON.parse(data);
      short_url = res.shorturl;
      $("#call_msg_surl").val(res.shorturl);
      alert("등록되었습니다.");
    },
  });
}
function automaking_preview() {
  window.open($("#reg_msg_surl").val());
}
function copy_msg_link(type) {
  var shortlink = $("#" + type).val();
  // 글을 쓸 수 있는 란을 만든다.
  var aux = document.createElement("input");
  // 지정된 요소의 값을 할당 한다.
  aux.setAttribute("value", shortlink);
  // bdy에 추가한다.
  document.body.appendChild(aux);
  // 지정된 내용을 강조한다.
  aux.select();
  // 텍스트를 카피 하는 변수를 생성
  document.execCommand("copy");
  // body 로 부터 다시 반환 한다.
  document.body.removeChild(aux);
  alert("URL이 복사되었습니다. 원하는 곳에 붙여 넣으세요.");
}
//오토회원가입리스트 보여주기
function show_automember_list() {
  $("#mypage-modalwindow").modal("hide");
  //$("#auto_list_modal").modal("show");
  $.ajax({
    type: "GET",
    url: "/iam/ajax/modal_auto_list.php",
    /*data: "start_date=" + '<?= $_REQUEST['search_start_date'] ?>' +
            "&end_date=" + '<?= $_REQUEST['search_end_date'] ?>',*/
    success: function (html) {
      $("#auto_list_modal").html("");
      $("#auto_list_modal").append(html);
      $("#auto_list_modal").modal("show");
    },
  });
}
function copyHtml(url) {
  var aux1 = document.createElement("input");
  // 지정된 요소의 값을 할당 한다.
  aux1.setAttribute("value", url);
  // bdy에 추가한다.
  document.body.appendChild(aux1);
  // 지정된 내용을 강조한다.
  aux1.select();
  // 텍스트를 카피 하는 변수를 생성
  document.execCommand("copy");
  // body 로 부터 다시 반환 한다.
  document.body.removeChild(aux1);
  alert("URL이 복사되었습니다. 원하는 곳에 붙여 넣으세요.");
}
