function reload() {
$("#pincode").val("");
$("#amount_creditcard").val("0");
$("#amount_cash").val("0");
$("#reloadDialog").dialog({
autoOpen: false,
height: 270,
width: 350,
modal: true,
buttons: {
"確定": function() {
if (validate()) {
$.ajax({
url: "prepaidcard.php",
type: "POST",
data: {act: "reload", pincode: $("#pincode").val(), amount_creditcard: Number($("#amount_creditcard").val()), amount_cash: Number($("#amount_cash").val()), userId: $("#userId").val()},
dataType: "text",
aysnc: false,
success: function (msg) {
var response = JSON.parse(msg);
if (response.StatusCode == "0000") {
$("#username").html(response.username);
$("#cardno").html(response.cardno);
$("#addtime").html(response.addtime);
$("#storename").html(response.storename);
$("#adminname").html(response.adminname);
$("#balance").html(response.amount);
$("#bonus").html(response.PointsLeft);
$("#status").html(response.CardStatus);
$("#bonus").html(response.bonus);
$("#history-table-body").empty();
$.each(response.history, function(i, item){
var td = "
" + item.add_time + " | ";
td += "" + item.staff_name + " | ";
switch (item.type) {
case "11":
td += "現金開卡儲值 | ";
break;
case "12":
td += "信用卡開卡儲值 | ";
break;
case "21":
td += "現金儲值 | ";
break;
case "22":
td += "信用卡儲值 | ";
break;
}
td += "" + item.amount + " | ";
td += " |
";
$("#history-table-body").append(td);
});
alert("儲值成功");
} else
alert("查詢餘額發生錯誤 [" + response.RespCode + "]\n" + response.ErrorMessage);
},
error: function (xhr, options, error) {
alert("error: " + error);
}
});
$(this).dialog("close");
}
},
"取消": function() {
$(this).dialog("close");
}
}
});
$('#reloadDialog').dialog("open");
}
function activate() {
$("#cardNo").val("");
$("#pincode").val("");
$("#amount_creditcard").val("0");
$("#amount_cash").val("0");
$("#recommend_user").val("");
$("#recommend_id").val("");
$("#recommend_name").html("");
$("#activationDialog").dialog({
autoOpen: false,
height: 300,
width: 500,
modal: true,
buttons: {
"確定": function() {
if (validate()) {
$.ajax({
url: "prepaidcard.php",
type: "POST",
data: {act: "activate", cardNo: $("#cardNo").val(), pincode: $("#pincode").val(), amount_creditcard: Number($("#amount_creditcard").val()), amount_cash: Number($("#amount_cash").val()), userId: $("#userId").val(), recommend_id: $("#recommend_id").val()},
dataType: "text",
aysnc: false,
success: function (msg) {
var response = JSON.parse(msg);
if (response.StatusCode == "0000") {
$("#username").html(response.username);
$("#cardno").html(response.cardno);
$("#addtime").html(response.addtime);
$("#storename").html(response.storename);
$("#adminname").html(response.adminname);
$("#balance").html(response.amount);
$("#status").html(response.CardStatus);
$("#bonus").html(response.bonus);
$("#activate").remove();
$("#history-table-body").empty();
$.each(response.history, function(i, item){
var td = "" + item.add_time + " | ";
td += "" + item.staff_name + " | ";
switch (item.type) {
case "11":
td += "現金開卡儲值 | ";
break;
case "12":
td += "信用卡開卡儲值 | ";
break;
case "21":
td += "現金儲值 | ";
break;
case "22":
td += "信用卡儲值 | ";
break;
}
td += "" + item.amount + " | ";
td += " |
";
$("#history-table-body").append(td);
});
alert("開卡成功");
} else
alert("開卡發生錯誤 [" + response.RespCode + "]\n" + response.ErrorMessage);
},
error: function (xhr, options, error) {
alert("error: " + error);
}
});
$(this).dialog("close");
}
},
"取消": function() {
$(this).dialog("close");
}
}
});
$('#activationDialog').dialog("open");
}
function validate() {
var max_deposit = parseInt($("#prepaidcard_max_active").val());
var min_deposit = parseInt($("#prepaidcard_min_active").val());
var total = parseInt($("#amount_creditcard").val()) + parseInt($("#amount_cash").val());
if (total < min_deposit) {
alert("儲值總額(" + total + ")不可小於 " + min_deposit);
return false;
}
if (total > max_deposit) {
alert("儲值總額(" + total + ")不可大於 " + max_deposit);
return false;
}
return true;
}
function getPrepaidcardMember(element) {
$.ajax({
url: "users.php?act=get_prepaidcard_member",
type: "GET",
data: "mobile=" + element.value,
dataType: "text",
success: function (msg) {
var response = JSON.parse(msg);
$("#recommend_name").html(response.recommend_name);
$("#recommend_id").val(response.recommend_id);
},
error: function (xhr, options, error) {
alert("error: " + error);
}
});
}