You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
766 lines
23 KiB
766 lines
23 KiB
var subscribers_list = (function ($, window, jQuery) {
|
|
var _vars_ = {};
|
|
|
|
return {
|
|
set_vars: function (options) {
|
|
$.extend(_vars_, options || {});
|
|
},
|
|
get_vars: function () {
|
|
return _vars_;
|
|
},
|
|
|
|
load: function () {
|
|
var table = $("#subscribers_list").DataTable({
|
|
responsive: true,
|
|
autoWidth: false,
|
|
processing: true, //Feature control the processing indicator.
|
|
serverSide: true, //Feature control DataTables' server-side processing mode.
|
|
order: [0], //Initial no order.
|
|
oLanguage: fr_onload_lang.oLanguage,
|
|
// Load data for the table's content from an Ajax source
|
|
ajax: {
|
|
url:
|
|
app.get_vars().baseurl + "reports/subscribers/get_subscribers_list",
|
|
type: "POST",
|
|
},
|
|
searching: true,
|
|
columns: [
|
|
{ data: "subscriber" },
|
|
{ data: "email_address" },
|
|
// { "data": "membership" },
|
|
// { "data": "expiration_date" },
|
|
// { "data": "telephone_number" },
|
|
{ data: "telephone_number" },
|
|
{ data: "address" },
|
|
// { "data": "noshow_complete" },
|
|
// { "data": "noshow_partial" },
|
|
// { "data": "noshow_moderation" },
|
|
// { "data": "status" },
|
|
{ data: "actions", orderable: false },
|
|
],
|
|
fnDrawCallback: function () {
|
|
app._tooltip._hide();
|
|
$("#subscribers_list tbody tr td").each(function (x, y) {
|
|
var _this = $(this);
|
|
if (_this.hasClass("truncate-content-text")) {
|
|
// _this.css('max-width', '140px');
|
|
this.setAttribute("title", _this.text());
|
|
this.setAttribute("data-toggle", "tooltip");
|
|
}
|
|
});
|
|
app._tooltip._pop();
|
|
},
|
|
//Set column definition initialisation properties.
|
|
columnDefs: [
|
|
{
|
|
targets: [0],
|
|
className: "truncate-content-text custom-popover-tooltip",
|
|
},
|
|
{ targets: [0, 1, 2, 3], orderable: false },
|
|
// {
|
|
// "targets": [ 4 ],
|
|
// "visible": false
|
|
// },
|
|
{
|
|
// "targets": [ 5, 6, 7 ],
|
|
width: "10px",
|
|
},
|
|
],
|
|
initComplete: function (settings, json) {
|
|
//run tooltip
|
|
app._tooltip._hide();
|
|
app._tooltip._pop();
|
|
|
|
//add custom button beside searchbox
|
|
$("#subscribers_list_length").css({ width: "30%", float: "left" });
|
|
$(".dataTables_filter").each(function () {
|
|
if (
|
|
authorize(
|
|
PAGE_CODE["subscribers"],
|
|
PRIVS[PAGE_CODE["subscribers"]]["export"]
|
|
)
|
|
) {
|
|
$(this).append(
|
|
'<a href="javascript:;" onclick="subscribers_list._export(this);" style="padding: 7px;" ' +
|
|
'class="btn btn-primary btn-sm mr-xs subscribe">' +
|
|
'<span class="glyphicon glyphicon-export"></span> ' +
|
|
app.get_vars().reports.btn.export_subscriber_list +
|
|
"</a>"
|
|
);
|
|
}
|
|
});
|
|
|
|
//fire search filter event
|
|
app.grid.search_filter(
|
|
"subscribers_list",
|
|
subscribers_list.get_vars().subscribers
|
|
);
|
|
},
|
|
});
|
|
|
|
subscribers_list.set_vars({ subscribers: table });
|
|
},
|
|
|
|
_export: function (event) {
|
|
var data = subscribers_list.get_vars().subscribers.ajax.params();
|
|
var x = JSON.stringify(data, null, 4);
|
|
$(event).attr(
|
|
"href",
|
|
app.get_vars().baseurl + "export_subscribers_list/" + $.param(data)
|
|
);
|
|
},
|
|
token_modal: function (params) {
|
|
var redirect_button = $("#go_token");
|
|
var url = app.get_vars().baseurl + "" + $(params).attr("data-id");
|
|
var subcriber = $(params).attr("id");
|
|
|
|
var http_request = subscribers_list.checkIfUserIsLoggedIn(params);
|
|
|
|
//check subscriber if online
|
|
http_request.success(function (result) {
|
|
let isLoggedIn = result
|
|
? "<b>" + $(params).attr("name") + "</b> is currently logged in.<br/>"
|
|
: "";
|
|
app.modal.confirm_box({
|
|
message:
|
|
isLoggedIn +
|
|
"Voulez-vous vous connecter à la place de <b>" +
|
|
$(params).attr("name") +
|
|
"</b> ? <br/><br><span class='label label-danger' style='font-size: 12px;'>" +
|
|
app.get_vars()._app.cma_msg.note +
|
|
"</span>",
|
|
_continue: function () {
|
|
//check subscriber if online
|
|
subscribers_list
|
|
.checkIfUserIsLoggedIn(params)
|
|
.success(function (result) {
|
|
// if(result){
|
|
// app._notify("warning", "<b>"+$(params).attr('name')+"</b> is currently logged in. "+
|
|
// "You cannot access his/her account right now.");
|
|
// } else {
|
|
window.open(
|
|
app.get_vars().baseurl + "" + $(params).attr("data-id"),
|
|
"_self"
|
|
);
|
|
// }
|
|
});
|
|
},
|
|
id: "delete_confirm_box",
|
|
className: "delete_confirm_box",
|
|
});
|
|
});
|
|
},
|
|
|
|
checkIfUserIsLoggedIn: function (params) {
|
|
return $.ajax({
|
|
url: app.get_vars().baseurl + "authentication/subscriber_login_check",
|
|
type: "POST",
|
|
data: { subcriber: $(params).attr("id") },
|
|
});
|
|
},
|
|
|
|
delete: function (params) {
|
|
app.modal.confirm_box({
|
|
message:
|
|
"Voulez-vous vraiment supprimer le compte de <b>" +
|
|
$(params).attr("name") +
|
|
"</b> ? <br/><br><span class='label label-danger' style='font-size: 12px;'>" +
|
|
app.get_vars()._app.cma_msg.note +
|
|
"</span>",
|
|
_continue: function () {
|
|
Helper.help.ajax(
|
|
app.get_vars().baseurl + "delete_subscriber",
|
|
"post",
|
|
"user_id=" + $(params).attr("data-id"),
|
|
function (result) {
|
|
if (app.isalive(result)) {
|
|
if (result.is_success > 0) {
|
|
subscribers_list
|
|
.get_vars()
|
|
.subscribers.ajax.reload(null, false);
|
|
}
|
|
}
|
|
}
|
|
);
|
|
},
|
|
id: "delete_confirm_box",
|
|
className: "delete_confirm_box",
|
|
});
|
|
},
|
|
|
|
disableEnableModeration: function (params) {
|
|
var ask_modal = $("#enable_disable_moderation");
|
|
var form = $("#form_enable_disable_moderation");
|
|
var subscriber_id_input_box = form.find("#subscriber_id");
|
|
var subscriber_id = $(params).attr("data-id");
|
|
|
|
app.modal.focusout_solution("on");
|
|
|
|
Helper.help.ajax(
|
|
app.get_vars().baseurl + "get_user_moderation/" + subscriber_id,
|
|
"get",
|
|
"",
|
|
function (result) {
|
|
if (result.isModerationDisabled == "1") {
|
|
$("#switch2").prop("checked", true);
|
|
$("#numberOfDaysModeratedField").show();
|
|
$("#number_of_days_in_moderation").val(
|
|
result.numberOfDaysModerated
|
|
);
|
|
} else {
|
|
$("#switch2").prop("checked", false);
|
|
$("#numberOfDaysModeratedField").hide();
|
|
}
|
|
|
|
ask_modal
|
|
.modal({ backdrop: "static", keyboard: true })
|
|
.on("shown.bs.modal", function () {
|
|
subscriber_id_input_box.val(subscriber_id);
|
|
$("#subscriber-fullname").text($(params).attr("data-name"));
|
|
$(this).off("shown.bs.modal");
|
|
})
|
|
.on("hidden.bs.modal", function () {
|
|
$(this).data("bs.modal", null);
|
|
$("#form_enable_disable_moderation").off("hidden.bs.modal");
|
|
app.modal.focusout_solution("off");
|
|
$("#switch2").prop("checked", false);
|
|
$("#subscriber-fullname").text("");
|
|
})
|
|
.modal("show");
|
|
}
|
|
);
|
|
},
|
|
edit_info_modal: function (params) {
|
|
var ask_modal = $("#edit-info");
|
|
var subsciber_id = $(params).attr("data-id");
|
|
var $inputs = $("#edit_subscriber :input");
|
|
var form = $("form#edit_subscriber");
|
|
var user_id = $(params).attr("name");
|
|
|
|
var save_subscriber_btn = $(".save_subscriber");
|
|
|
|
app.modal.focusout_solution("on");
|
|
ask_modal
|
|
.modal({ backdrop: "static", keyboard: true })
|
|
.on("shown.bs.modal", function () {
|
|
app._form._form_submit_on_keypress("edit_subscriber", function () {
|
|
subscribers_list.validate();
|
|
});
|
|
$("#first_name").focus();
|
|
// subscribers_list.postal_code_validation(".select2","#country","#postal_code","france");
|
|
|
|
// //create prefix
|
|
// Helper._create_prefixif_contains("#phone","+[33] X XX XX XX XX");
|
|
// Helper._create_prefixif_contains("#mobile","+[33] X XX XX XX XX");
|
|
})
|
|
.on("hidden.bs.modal", function () {
|
|
app._form._resetFormValidation("#edit_subscriber");
|
|
app._form._reset(this);
|
|
$(this).data("bs.modal", null);
|
|
$("#edit_subscriber").off("hidden.bs.modal");
|
|
app.modal.focusout_solution("off");
|
|
});
|
|
|
|
Helper.help.ajax(
|
|
app.get_vars().baseurl + "get_subscriber",
|
|
"post",
|
|
"s_id=" + subsciber_id,
|
|
function (result) {
|
|
if (app.isalive(result)) {
|
|
$("#subscriber_id").val(result.subscriber_id);
|
|
$("#user_id").val(result.user_id);
|
|
/*data = Helper.country_list().sort(function(a, b){
|
|
A = a.toLowerCase();
|
|
B = b.toLowerCase();
|
|
if (A > B) {
|
|
if( A=="france" )
|
|
return -1
|
|
else
|
|
return 1
|
|
}
|
|
if (A < B) {
|
|
return -1;
|
|
}
|
|
return 0;
|
|
});
|
|
|
|
$.map(data, function (value, i) {
|
|
$("#country").append("<option value="+value+">"+value+"</option>")
|
|
});*/
|
|
|
|
/*$.map(Helper.country_list(), function (value, i) {
|
|
$("#country").append("<option value="+value+">"+value+"</option>")
|
|
});
|
|
|
|
var $select = $('#country').selectize({
|
|
create: false,
|
|
//sortField: 'text',
|
|
});*/
|
|
|
|
$("#country").autocomplete({
|
|
source: [Helper.country_list()],
|
|
maxShowItems: 5,
|
|
});
|
|
|
|
Helper.help.loop(result, function (index, value) {
|
|
$inputs.each(function (i) {
|
|
if ($(this).attr("id") === index && index !== "birthday") {
|
|
$(this).val(value);
|
|
}
|
|
// if( index == "civility"){
|
|
// $('#civil_status').val(value)
|
|
// }
|
|
/*if( index == 'country'){
|
|
if( value !== null) {
|
|
$select[0].selectize.setValue(value);
|
|
}
|
|
}*/
|
|
if ($(this).attr("id") === index && index === "birthday") {
|
|
$("#birthday").val(value);
|
|
// $('#birthday').datetimepicker({
|
|
// locale: 'fr',
|
|
// format: 'MM/DD/YYYY'
|
|
// }).on('dp.change',function(e){
|
|
// // if ( $(e.target).val().length > 0) {
|
|
// // $(e.target).closest('.form-group').removeClass('has-error').find("span.help-block").text('')
|
|
// // }
|
|
// })
|
|
// /* '2017-10-08','-','/',[day[index],month[index],year[index]] */
|
|
// $("#birthday").val(((value!=null && value!="" && ($.trim(value) != "--") )?Helper.date_split(value,'-','/',[2,1,0]):""))
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
);
|
|
},
|
|
save: function (form) {
|
|
var values = {
|
|
user_id: $("#user_id").val(),
|
|
civility: $("#civility").val(),
|
|
subscriber_id: $("#subscriber_id").val(),
|
|
first_name: $("#first_name").val(),
|
|
last_name: $("#last_name").val(),
|
|
birthday: $("#birthday").val(),
|
|
address: $("#address").val(),
|
|
profession: $("#profession").val(),
|
|
news_subscription: $("#news_subscription").val(),
|
|
sponsorship: $("#sponsorship").val(),
|
|
country: $("#country").val(),
|
|
postal_code: $("#postal_code").val(),
|
|
city: $("#city").val(),
|
|
email_address: $("#email_address").val(),
|
|
phone: $("#phone").val(),
|
|
company: $("#company").val(),
|
|
//mobile : $("#mobile").val(),
|
|
//status : $("#status").val()
|
|
};
|
|
var ask_modal = $("#edit-info");
|
|
Helper.help.ajax(
|
|
app.get_vars().baseurl + "put_subscriber",
|
|
"post",
|
|
values,
|
|
function (result) {
|
|
if (app.isalive(result)) {
|
|
if (result.error) {
|
|
app._form._populate_field_error(result.field, result.message, 0);
|
|
// }else if(Helper._prefix($("#phone").val()) < 9 ){
|
|
// app._form._populate_field_error("phone", "Entrez au moins 9 chiffres.", 0);
|
|
// }else if(Helper._prefix($("#mobile").val()) < 9 ){
|
|
// app._form._populate_field_error("mobile", "Entrez au moins 9 chiffres.", 0);
|
|
} else {
|
|
subscribers_list.get_vars().subscribers.ajax.reload(null, false);
|
|
ask_modal.modal("hide");
|
|
}
|
|
}
|
|
}
|
|
);
|
|
},
|
|
validate: function () {
|
|
var r_news_subscription,
|
|
r_sponsorship,
|
|
r_civility,
|
|
r_first_name,
|
|
r_last_name,
|
|
r_bday,
|
|
r_address,
|
|
r_additional_address,
|
|
r_country,
|
|
r_postal_code,
|
|
r_city,
|
|
r_email_address,
|
|
r_mobile,
|
|
r_phone;
|
|
|
|
$.getJSON(
|
|
app.get_vars().baseurl + "personalize/create_reg_form_rules",
|
|
function (jsonData) {
|
|
for (var i = 0; i < jsonData.length; i++) {
|
|
switch (jsonData[i].name) {
|
|
case "first_name":
|
|
r_first_name = jsonData[i].required;
|
|
break;
|
|
case "last_name":
|
|
r_last_name = jsonData[i].required;
|
|
break;
|
|
case "birthday":
|
|
r_bday = jsonData[i].required;
|
|
break;
|
|
case "civility":
|
|
r_civility = jsonData[i].required;
|
|
break;
|
|
case "news_subscription":
|
|
r_news_subscription = jsonData[i].required;
|
|
break;
|
|
case "sponsorship":
|
|
r_sponsorship = jsonData[i].required;
|
|
break;
|
|
case "address":
|
|
r_address = jsonData[i].required;
|
|
break;
|
|
// case "additional_address":
|
|
// r_additional_address = jsonData[i].required;
|
|
// break;
|
|
case "country":
|
|
r_country = jsonData[i].required;
|
|
break;
|
|
case "postal_code":
|
|
r_postal_code = jsonData[i].required;
|
|
break;
|
|
case "city":
|
|
r_city = jsonData[i].required;
|
|
break;
|
|
case "email_address":
|
|
r_email_address = jsonData[i].required;
|
|
break;
|
|
// case "mobile":
|
|
// r_mobile = jsonData[i].required;
|
|
// break;
|
|
case "phone":
|
|
r_phone = jsonData[i].required;
|
|
break;
|
|
}
|
|
}
|
|
/*start validation*/
|
|
var options = {
|
|
boot_box: {
|
|
message: app.get_vars()._app.cma_msg.save_changes,
|
|
_continue: function () {
|
|
subscribers_list.save($("form#edit_subscriber"));
|
|
},
|
|
},
|
|
validation: {
|
|
ignore:
|
|
":hidden:not([class~=selectized]),:hidden > .selectized, .selectize-control .selectize-input input",
|
|
// "custom" : {
|
|
// "rules": {
|
|
// "phone_number": {
|
|
// // "_fnc": function (value, element, options) {
|
|
// // if(value.trim() != "") {
|
|
// // var phone = $('#phone').inputmask('unmaskedvalue');
|
|
// // if($("#phone").val() != "+[33] X XX XX XX XX" )
|
|
// // return true;
|
|
// // }
|
|
// // return false;
|
|
// // },
|
|
// // msg: "Entrez au moins 9 chiffres."
|
|
// },
|
|
// "mobile_number": {
|
|
// "_fnc": function (value, element, options) {
|
|
// if(value.trim() != "") {
|
|
// var mobile = $('#mobile').inputmask('unmaskedvalue');
|
|
// if($("#mobile").val() != "+[33] X XX XX XX XX" )
|
|
// return true;
|
|
// }
|
|
// return false;
|
|
// },
|
|
// msg: "Entrez au moins 9 chiffres."
|
|
// }
|
|
// }
|
|
// },
|
|
form_id: "form#edit_subscriber",
|
|
rules: {
|
|
first_name: {
|
|
//"required": r_first_name
|
|
required: true,
|
|
},
|
|
last_name: {
|
|
//"required": r_last_name
|
|
required: true,
|
|
},
|
|
birthday: {
|
|
//"required": r_bday
|
|
required: false,
|
|
},
|
|
address: {
|
|
//"required": r_address,
|
|
required: true,
|
|
},
|
|
// "additional_address" : {
|
|
// //"required": r_additional_address,
|
|
// "required" : false
|
|
// },
|
|
country: {
|
|
//"required": r_country,
|
|
required: true,
|
|
},
|
|
postal_code: {
|
|
//"required" : r_postal_code
|
|
required: true,
|
|
},
|
|
city: {
|
|
//"required" : r_city
|
|
required: true,
|
|
},
|
|
email_address: {
|
|
required: true,
|
|
email: true,
|
|
},
|
|
// "mobile" : {
|
|
// //"required": r_mobile,
|
|
// "required" : false
|
|
// },
|
|
phone: {
|
|
//"required": r_phone,
|
|
required: true,
|
|
},
|
|
news_subscription: {
|
|
//"required": r_news_subscription,
|
|
required: true,
|
|
},
|
|
sponsorship: {
|
|
//"required": r_news_subscription,
|
|
required: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
app._form._validate(options);
|
|
/*end validation*/
|
|
},
|
|
"json"
|
|
);
|
|
},
|
|
postal_code_validation: function (elem1, elem2, change_elem, needle) {
|
|
$(elem2).change(function (e) {
|
|
if (
|
|
$(elem1).text().toLowerCase() === needle ||
|
|
$(elem2).text().toLowerCase() === needle
|
|
) {
|
|
$(change_elem).val("");
|
|
$(change_elem).attr("minlength", 5);
|
|
$(change_elem).attr("maxlength", 5);
|
|
Helper.no_letters(change_elem);
|
|
} else {
|
|
$(change_elem).removeAttr("minlength");
|
|
$(change_elem).removeAttr("maxlength");
|
|
$(change_elem).unbind("keydown");
|
|
}
|
|
});
|
|
|
|
if (
|
|
$(elem1).text().toLowerCase() === needle ||
|
|
$(elem2).text().toLowerCase() === needle
|
|
) {
|
|
$(change_elem).attr("minlength", 5);
|
|
$(change_elem).attr("maxlength", 5);
|
|
Helper.no_letters(change_elem);
|
|
} else {
|
|
$(change_elem).removeAttr("minlength");
|
|
$(change_elem).removeAttr("maxlength");
|
|
}
|
|
},
|
|
|
|
save_moderation: function () {
|
|
/*start validation*/
|
|
var options = {
|
|
boot_box: {
|
|
message: app.get_vars()._app.cma_msg.save_changes,
|
|
_continue: function () {
|
|
var formData = $("#form_enable_disable_moderation").serialize();
|
|
|
|
if (formData.indexOf("isModerationDisabled") <= -1)
|
|
formData += "&isModerationDisabled=0";
|
|
|
|
Helper.help.ajax(
|
|
app.get_vars().baseurl + "enable_disable_user_moderation",
|
|
"post",
|
|
formData,
|
|
function (result) {
|
|
if (app.isalive(result)) {
|
|
$(".disableEnableModeration").off("click");
|
|
subscribers_list
|
|
.get_vars()
|
|
.subscribers.ajax.reload(null, false);
|
|
$("#enable_disable_moderation").modal("hide");
|
|
}
|
|
}
|
|
);
|
|
},
|
|
},
|
|
validation: {
|
|
form_id: "#form_enable_disable_moderation",
|
|
rules: {
|
|
number_of_days_in_moderation: {
|
|
required: false,
|
|
digits: true,
|
|
minlength: 0,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
app._form._validate(options);
|
|
},
|
|
edit_subscription_modal: function (user_id) {
|
|
$("#transactionDateTime").val("");
|
|
$("#subscriptionId").val("");
|
|
$("#expirationDate").val("");
|
|
$("#btn_update_subscription").css("cursor", "no-drop");
|
|
$("#btn_update_subscription").attr("disabled", true);
|
|
$.ajax({
|
|
url:
|
|
app.get_vars().baseurl +
|
|
"subscription/get-subscription?user_id=" +
|
|
user_id,
|
|
type: "GET",
|
|
success: function (result) {
|
|
if (result) {
|
|
$("#update_subscription").modal("show");
|
|
if (result.subscriptionId === "1") {
|
|
$("#adhesionType").text(
|
|
"Adhésion de soutien " + "(" + result.amount + "MGA)"
|
|
);
|
|
}
|
|
if (result.subscriptionId === "2") {
|
|
$("#adhesionType").text(
|
|
"Adhésion préférentielle actionnaire " +
|
|
"(" +
|
|
result.amount +
|
|
"MGA)"
|
|
);
|
|
}
|
|
if (result.subscriptionId === "3") {
|
|
$("#adhesionType").text(
|
|
"Adhésion parrainée " + "(" + result.amount + "MGA)"
|
|
);
|
|
}
|
|
if (result.subscriptionId === "4") {
|
|
$("#adhesionType").text(
|
|
"Adhésion étudiant " + "(" + result.amount + "MGA)"
|
|
);
|
|
}
|
|
if (result.transactionDateTime)
|
|
$("#transactionDateTime").val(
|
|
moment(result.transactionDateTime).format("YYYY-MM-DD")
|
|
);
|
|
if (result.expirationDate)
|
|
$("#expirationDate").val(
|
|
moment(result.expirationDate).format("YYYY-MM-DD")
|
|
);
|
|
$("#subscriptionId").val(result.id);
|
|
$("#paymentMethod").text(
|
|
"Mode de paiement: " +
|
|
(result.payment_mode === "card" ? "Carte bancaire" : "Chèque")
|
|
);
|
|
$("#subscriberName").text(
|
|
`${result.first_name} ${result.last_name}`
|
|
);
|
|
} else {
|
|
$("#invalid_subscription").modal("show");
|
|
}
|
|
},
|
|
});
|
|
},
|
|
update_subscription: function () {
|
|
if ($("#transactionDateTime").val() && $("#expirationDate").val()) {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "subscription/update-subscription",
|
|
type: "POST",
|
|
data: {
|
|
id: $("#subscriptionId").val(),
|
|
transactionDateTime: $("#transactionDateTime").val(),
|
|
expirationDate: $("#expirationDate").val(),
|
|
},
|
|
success: function (result) {
|
|
$("#update_subscription").modal("hide");
|
|
},
|
|
});
|
|
}
|
|
},
|
|
}; //end of return
|
|
// Pass in jQuery.
|
|
})(jQuery, this);
|
|
|
|
$(function () {
|
|
subscribers_list.load();
|
|
if (typeof userId !== "undefined") {
|
|
subscribers_list.edit_subscription_modal(userId);
|
|
}
|
|
//remove validation errors on keypress
|
|
app._form._form_on_keypress("edit_subscriber", function () {
|
|
subscriber.validation();
|
|
});
|
|
|
|
//mask phone and mobile
|
|
//Helper.input_mask("#phone", "[~][~][~] X XX XX XX XX" );
|
|
//Helper.input_mask("#mobile", "[~][~][~] X XX XX XX XX" );
|
|
|
|
/* Set input mask for mobile number depending on the country */
|
|
$("#country").on("change", function (event) {
|
|
event.preventDefault();
|
|
/* Act on the event */
|
|
let countryCode = countryListCode[$("#country").val()];
|
|
|
|
let num = {
|
|
code: "33",
|
|
format: "X XX XX XX XX",
|
|
};
|
|
/* Get phone input mask format */
|
|
if (countryCode != "FR") {
|
|
$.ajax({
|
|
url:
|
|
app.get_vars().baseurl +
|
|
"setPreferences/getPhoneNumberFormat/" +
|
|
countryCode,
|
|
async: false,
|
|
success: function (response) {
|
|
num.code = response.code;
|
|
num.format = response.format;
|
|
},
|
|
});
|
|
}
|
|
// $('#phone').val('');
|
|
// $('#mobile').val('');
|
|
// Helper._create_prefix("#phone", num.code, num.format);
|
|
// Helper._create_prefix("#mobile", num.code, num.format);
|
|
|
|
// Helper.mask("#phone",`floooor ${num.format}`, `+[${num.code}] ${num.format}` );
|
|
// Helper.mask("#mobile",`floooor ${num.format}`, `+[${num.code}] ${num.format}` );
|
|
});
|
|
$("#phone").keyup(function (e) {
|
|
if (/\D/g.test($(this).val())) {
|
|
this.value = this.value.replace(/\D/g, "");
|
|
}
|
|
});
|
|
$("#postal_code").keyup(function (e) {
|
|
if (/\D/g.test($(this).val())) {
|
|
this.value = this.value.replace(/\D/g, "");
|
|
}
|
|
});
|
|
$("#switch2").on("change", function (e) {
|
|
if ($(e.target).is(":checked")) {
|
|
$("#numberOfDaysModeratedField").show();
|
|
} else {
|
|
$("#numberOfDaysModeratedField").hide();
|
|
}
|
|
});
|
|
|
|
$("#transactionDateTime").on("change", function () {
|
|
$("#btn_update_subscription").css("cursor", "pointer");
|
|
$("#btn_update_subscription").removeAttr("disabled");
|
|
});
|
|
$("#expirationDate").on("change", function () {
|
|
$("#btn_update_subscription").css("cursor", "pointer");
|
|
$("#btn_update_subscription").removeAttr("disabled");
|
|
});
|
|
});
|
|
|