inital commit
This commit is contained in:
640
webroot/rtgv3/js/affiliate.client.js
Normal file
640
webroot/rtgv3/js/affiliate.client.js
Normal file
@@ -0,0 +1,640 @@
|
||||
|
||||
if (typeof isVelocityOrRTG == 'undefined') {
|
||||
var isVelocityOrRTG = false;
|
||||
}
|
||||
|
||||
if (typeof isEpicVelocity == 'undefined') {
|
||||
var isEpicVelocity = false;
|
||||
}
|
||||
function generateAffiliateClientList(elem){
|
||||
var value = $(elem).val();
|
||||
$('#affiliate_client_type_id').val(value);
|
||||
var data = {'crmuser_id':value,'action':'AFFILIATE_CLIENT_LIST'};
|
||||
$('#epic-affiliate-loader').show()
|
||||
$('#affiliate-loader').show()
|
||||
$(elem).next('img').show()
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: data,
|
||||
url: AFFILIATE_URL,
|
||||
success: function (response) {
|
||||
$(elem).next('img').hide()
|
||||
$('#epic-affiliate-loader').hide();
|
||||
$('#affiliate-loader').hide();
|
||||
response = JSON.parse(response);
|
||||
|
||||
var s = $('select[name=client_id]');
|
||||
var isRTG = false;
|
||||
if(s.length == 0){
|
||||
s = $('#client-contact-id');
|
||||
isRTG = true;
|
||||
}
|
||||
|
||||
s.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(s);
|
||||
var clientList = {};
|
||||
if(response.is_employee){
|
||||
$.each(response.affiliate_list, function (key, value) {
|
||||
clientList[value.id] = value.first_name+" "+value.last_name+" ("+value.email+")";
|
||||
});
|
||||
}else{
|
||||
clientList = response
|
||||
}
|
||||
// if(isRTG){
|
||||
// $.each(clientList, function (key, value) {
|
||||
// clientList[value.id] = value.first_name+" "+value.last_name+" ("+value.email+")";
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
console.log(clientList)
|
||||
var temp = [];
|
||||
$.each(clientList, function (key, value) {
|
||||
temp.push({v: value, k: key});
|
||||
});
|
||||
if(isVelocityOrRTG || isEpicVelocity){
|
||||
var temp_client_list = [];
|
||||
$.each(clientList, function (key, value) {
|
||||
var currentObj = {
|
||||
v: value.first_name+" "+ value.last_name+" ("+value.email+")",
|
||||
k: value.id,
|
||||
contact_id:value.contact_id,
|
||||
email:value.email
|
||||
}
|
||||
temp_client_list.push(currentObj);
|
||||
});
|
||||
temp = temp_client_list;
|
||||
}
|
||||
temp.sort(function (a, b) {
|
||||
if (a.v > b.v) {
|
||||
return 1
|
||||
}
|
||||
if (a.v < b.v) {
|
||||
return -1
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
if(isVelocityOrRTG){
|
||||
var clientDropdownHtml = "";
|
||||
var current_obj = {};
|
||||
var attributes = {};
|
||||
$.each(temp, function (key, obj) {
|
||||
current_obj = {
|
||||
value: obj.contact_id,
|
||||
text: obj.v
|
||||
};
|
||||
attributes = {
|
||||
'data-id':obj.k,
|
||||
'data-email':obj.email
|
||||
}
|
||||
$('<option />', current_obj).attr(attributes).appendTo(s);
|
||||
|
||||
})
|
||||
}else{
|
||||
$.each(temp, function (key, obj) {
|
||||
var current_obj = {
|
||||
value: obj.k,
|
||||
text: obj.v
|
||||
};
|
||||
$('<option />', current_obj).appendTo(s);
|
||||
});
|
||||
}
|
||||
|
||||
},error: function () {
|
||||
$(elem).next('img').hide();
|
||||
alert("Failed. Try again later.111");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function generateEmployeeClientList(elem){
|
||||
|
||||
var value = $(elem).val();
|
||||
if(value){
|
||||
var client_id = $('#client-contact-id').attr('data-cid');
|
||||
|
||||
$('#affiliate_client_type_id').val(value);
|
||||
var data = {'employee_id':value,'action':'EMPLOYEE_CLIENT_LIST'};
|
||||
$('#epic-employee-loader').show()
|
||||
$('#employee-loader').show()
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: data,
|
||||
url: AFFILIATE_URL,
|
||||
success: function (response) {
|
||||
$('#epic-employee-loader').hide();
|
||||
$('#employee-loader').hide()
|
||||
var show_client_checkbox = $('input[name=show_client_checkbox]');
|
||||
response = JSON.parse(response);
|
||||
console.log('hhhh',response);
|
||||
if($('button[name=checkConsole]').length){
|
||||
$('button[name=checkConsole]').prop('disabled',true);
|
||||
}
|
||||
|
||||
var s = $('select[name=client_id]');
|
||||
if(s.length == 0){
|
||||
s = $('#client-contact-id')
|
||||
}
|
||||
s.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(s);
|
||||
|
||||
var temp = [];
|
||||
$.each(response, function (key, value) {
|
||||
if(key > 0){
|
||||
temp.push({v: value, k: key});
|
||||
}
|
||||
});
|
||||
|
||||
if(isVelocityOrRTG || isEpicVelocity){
|
||||
|
||||
var temp_client_list = [];
|
||||
$.each(response, function (key, value) {
|
||||
var currentObj = {
|
||||
v: value.name+" ("+value.email+")",
|
||||
k: key,
|
||||
contact_id:value.contact_id,
|
||||
email:value.email
|
||||
}
|
||||
temp_client_list.push(currentObj);
|
||||
});
|
||||
temp = temp_client_list;
|
||||
}
|
||||
temp.sort(function (a, b) {
|
||||
if (a.v > b.v) {
|
||||
return 1
|
||||
}
|
||||
if (a.v < b.v) {
|
||||
return -1
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
if(isVelocityOrRTG){
|
||||
|
||||
var current_obj = {};
|
||||
var attributes = {};
|
||||
$.each(temp, function (key, obj) {
|
||||
current_obj = {
|
||||
value: obj.contact_id,
|
||||
text: obj.v
|
||||
};
|
||||
attributes = {
|
||||
'data-id':obj.k,
|
||||
'data-email':obj.email
|
||||
}
|
||||
if(client_id > 0){
|
||||
attributes['selected'] = "selected";
|
||||
}
|
||||
$('<option />', current_obj).attr(attributes).appendTo(s);
|
||||
|
||||
})
|
||||
}else{
|
||||
|
||||
$.each(temp, function (key, obj) {
|
||||
$('<option />', {value: obj.k, text: obj.v}).appendTo(s);
|
||||
});
|
||||
}
|
||||
if(!isEpicVelocity)
|
||||
if(response.employee_affiliste_list && show_client_checkbox.prop('checked')){
|
||||
$('select[name=affiliate_client_id]').html(response.employee_affiliste_list);
|
||||
}
|
||||
|
||||
},error: function () {
|
||||
$(elem).next('img').hide();
|
||||
alert("Failed. Try again later.111");
|
||||
}
|
||||
});
|
||||
}else{
|
||||
if(isVelocityOrRTG){
|
||||
|
||||
var clientDropdown = $('#client-contact-id');
|
||||
if(typeof CLIENT_DEFAULT_LIST != 'undefined'){
|
||||
response = CLIENT_DEFAULT_LIST;
|
||||
}else{
|
||||
response = DEFAULT_CLENT_LIST;
|
||||
}
|
||||
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
var attributes = {};
|
||||
var per_values = {};
|
||||
console.log('response',response,client_id);
|
||||
for(var val in response) {
|
||||
var row = response[val];
|
||||
attributes = {
|
||||
'data-id':row.contact_id,
|
||||
'data-email':row.email
|
||||
}
|
||||
|
||||
var name = row.name;
|
||||
if(row.first_name){
|
||||
name = row.first_name;
|
||||
}
|
||||
if(row.last_name){
|
||||
if(name){
|
||||
name += " "+row.last_name;
|
||||
}else{
|
||||
name = row.last_name;
|
||||
}
|
||||
}
|
||||
per_values = {value: row.id, text: name+" ("+row.email+")"};
|
||||
$('<option />', per_values).attr(attributes).appendTo(clientDropdown);
|
||||
}
|
||||
}else{
|
||||
|
||||
var isAffiliatechecked = $('input[name=show_client_checkbox]').prop('checked');
|
||||
var affiliate_client_id = $('select[name=affiliate_client_id]').val();
|
||||
response = JSON.parse(DEFAULT_CLENT_LIST);
|
||||
console.log('DEFAULT_CLENT_LIST',response);
|
||||
var clientDropdown = $('select[name=client_id]');
|
||||
clientDropdown.empty()
|
||||
if(isAffiliatechecked){
|
||||
$('input[name=show_client_checkbox]').prop('checked',false);
|
||||
$('input[name=show_client_checkbox]').click();
|
||||
isAffiliatechecked = true;
|
||||
}
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
if(isAffiliatechecked && affiliate_client_id > 0){
|
||||
for(var val in response) {
|
||||
if(isAffiliatechecked && affiliate_client_id == response[val].crmuser_id){
|
||||
$('<option />', {value: response[val].id, text: response[val].name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
for(var val in response) {
|
||||
$('<option />', {value: response[val].id, text: response[val].name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function affiliateShow(elem){
|
||||
var employee_checkbox = $('input[name=employee_client_type]');
|
||||
if($('.affiliate-list').hasClass('isCms')){
|
||||
$('.affiliate-list').removeClass('affiliate-show').removeClass('affiliate-hide').removeClass('affiliate-common-hide').addClass('affiliate-hide-op')
|
||||
}else{
|
||||
|
||||
$('.affiliate-list').hide();
|
||||
|
||||
}
|
||||
$('#client_type_id').val(1);
|
||||
$('#affiliate_client_type_id').val('');
|
||||
$('select[name=affiliate_client_id]').attr('disabled',true);
|
||||
if($(elem).prop('checked') && $(elem).val() == 2){
|
||||
if(employee_checkbox.prop('checked')){
|
||||
employee_checkbox.click();
|
||||
$('.employee-list').hide();
|
||||
}
|
||||
$('#client_type_id').val($(elem).val());
|
||||
$('#affiliate_client_type_id').val(-1);
|
||||
$('#affiliate-loader').show();
|
||||
var formData = {'action':'AFFILIATE_LIST','employee_id':$('select[name=employee_id]').val()};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: AFFILIATE_URL,
|
||||
success: function (response) {
|
||||
$('#affiliate-loader').hide();
|
||||
var show_client_checkbox = $('input[name=show_client_checkbox]');
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
var s = $('select[name=affiliate_client_id]');
|
||||
s.empty()
|
||||
//$('<option />', {value: -1, text: "All"}).appendTo(s);
|
||||
if(response.iscmsuser){
|
||||
s.html(response.affilistHTML)
|
||||
|
||||
}else{
|
||||
$('<option />', {value: -1, text: "All"}).appendTo(s);
|
||||
|
||||
for(var val in response.affiliateList) {
|
||||
$('<option />', {value: val, text: response.affiliateList[val]}).appendTo(s);
|
||||
}
|
||||
}
|
||||
|
||||
var clientDropdown = $('select[name=client_id]');
|
||||
if(clientDropdown.length == 0){
|
||||
clientDropdown = $('#client-contact-id');
|
||||
}
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
var temp_affiliate_list = {};
|
||||
if(!response.iscmsuser){
|
||||
$.each(response.affiliate_client_list, function (key, value) {
|
||||
temp_affiliate_list[value.id] = value.first_name+" "+value.last_name+" ("+value.email+")";
|
||||
});
|
||||
}else{
|
||||
temp_affiliate_list = response.affiliate_client_list
|
||||
}
|
||||
var temp = [];
|
||||
$.each(temp_affiliate_list, function (key, value) {
|
||||
temp.push({v: value, k: key});
|
||||
});
|
||||
temp.sort(function (a, b) {
|
||||
if (a.v > b.v) {
|
||||
return 1
|
||||
}
|
||||
if (a.v < b.v) {
|
||||
return -1
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
$.each(temp, function (key, obj) {
|
||||
$('<option />', {value: obj.k, text: obj.v}).appendTo(clientDropdown);
|
||||
});
|
||||
|
||||
if(response.iscmsuser){
|
||||
$('.affiliate-list').addClass('affiliate-show').show();
|
||||
}else{
|
||||
$('.affiliate-list').removeClass('affiliate-hide-op').removeClass('affiliate-hide').removeClass('affiliate-common-hide').show();
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
for (var val in response.affiliate_client_list) {
|
||||
var clientInfo = response.affiliate_client_list[val];
|
||||
$('<option />', {
|
||||
'data-email': clientInfo.email,
|
||||
'data-id': clientInfo.id,
|
||||
value: clientInfo.contact_id,
|
||||
text: clientInfo.first_name + " " + clientInfo.last_name + " (" + clientInfo.email + ")"
|
||||
}).appendTo(clientDropdown);
|
||||
}
|
||||
}
|
||||
|
||||
$('select[name=affiliate_client_id]').attr('disabled',false);
|
||||
if(response.employee_affiliste_list && show_client_checkbox.prop('checked')){
|
||||
$('select[name=affiliate_client_id]').html(response.employee_affiliste_list);
|
||||
}
|
||||
},error: function () {
|
||||
$(elem).next('img').hide();
|
||||
alert("Failed. Try again later.111");
|
||||
}
|
||||
});
|
||||
|
||||
}else if(!$(elem).prop('checked')){
|
||||
var clientDropdown = $('select[name=client_id]');
|
||||
if(isVelocityOrRTG){
|
||||
clientDropdown = $('#client-contact-id');
|
||||
if(typeof CLIENT_DEFAULT_LIST != 'undefined'){
|
||||
response = CLIENT_DEFAULT_LIST;
|
||||
}else{
|
||||
response = DEFAULT_CLENT_LIST;
|
||||
}
|
||||
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
var attributes = {};
|
||||
var per_values = {};
|
||||
for(var val in response) {
|
||||
var row = response[val];
|
||||
attributes = {
|
||||
'data-id':row.id,
|
||||
'data-email':row.email
|
||||
}
|
||||
var name = row.name;
|
||||
if(row.first_name){
|
||||
name = row.first_name;
|
||||
}
|
||||
if(row.last_name){
|
||||
if(name){
|
||||
name += " "+row.last_name;
|
||||
}else{
|
||||
name = row.last_name;
|
||||
}
|
||||
}
|
||||
per_values = {value: row.contact_id, text: name+" ("+row.email+")"};
|
||||
$('<option />', per_values).attr(attributes).appendTo(clientDropdown);
|
||||
}
|
||||
}else{
|
||||
response = JSON.parse(DEFAULT_CLENT_LIST);
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
for(var val in response) {
|
||||
if(isEpicVelocity){
|
||||
var full_name = response[val].first_name+" "+response[val].last_name;
|
||||
$('<option />', {value: response[val].id, text: full_name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
}else{
|
||||
$('<option />', {value: response[val].id, text: response[val].name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
} }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function employeeShow(elem, crmuser_id = 0,client_id =0) {
|
||||
$('.employee-list').hide();
|
||||
if(client_id > 0){
|
||||
$('#client-contact-id').attr('data-cid',client_id)
|
||||
}
|
||||
var affiliate_checkbox = $('input[name=client_type]');
|
||||
$('select[name=affiliate_client_id]').attr('disabled', true);
|
||||
if ($(elem).prop('checked') && $(elem).val() == 2) {
|
||||
if(affiliate_checkbox.prop('checked')){
|
||||
affiliate_checkbox.click();
|
||||
$('.affiliate-list').hide();
|
||||
}
|
||||
$('#employee-loader').show();
|
||||
var formData = {
|
||||
'action': 'EMPLOYEE_LIST'
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: AFFILIATE_URL,
|
||||
success: function (response) {
|
||||
$('#employee-loader').hide();
|
||||
response = JSON.parse(response);
|
||||
|
||||
var s = $('select[name=dropdown_employee_id]');
|
||||
s.empty()
|
||||
$('<option />', {
|
||||
value: -1,
|
||||
text: "All"
|
||||
}).appendTo(s);
|
||||
for (var val in response.affiliateList) {
|
||||
var attr = {
|
||||
value: val,
|
||||
text: response.affiliateList[val]
|
||||
}
|
||||
var selected = "";
|
||||
if (crmuser_id == val) {
|
||||
attr['selected'] = "selected";
|
||||
}
|
||||
$('<option />', attr).appendTo(s);
|
||||
}
|
||||
|
||||
if (crmuser_id == 0) {
|
||||
|
||||
var clientDropdown = $('#client-contact-id');
|
||||
if(isEpicVelocity){
|
||||
clientDropdown = $('select[name=client_id]');
|
||||
}
|
||||
clientDropdown.empty()
|
||||
$('<option />', {
|
||||
value: "0",
|
||||
text: "Please select client"
|
||||
}).appendTo(clientDropdown);
|
||||
for (var val in response.affiliate_client_list) {
|
||||
var clientInfo = response.affiliate_client_list[val];
|
||||
var attributes= {
|
||||
'data-email': clientInfo.email,
|
||||
'data-id': clientInfo.id,
|
||||
value: clientInfo.contact_id,
|
||||
text: clientInfo.first_name + " " + clientInfo.last_name + " (" + clientInfo.email + ")"
|
||||
}
|
||||
if(client_id == clientInfo.id){
|
||||
attributes['selected'] = "selected";
|
||||
}
|
||||
$('<option />', attributes).appendTo(clientDropdown);
|
||||
}
|
||||
}
|
||||
$('.employee-list').show();
|
||||
$('select[name=affiliate_client_id]').attr('disabled', false);
|
||||
if (crmuser_id > 0) {
|
||||
// s.val(crmuser_id).trigger('change');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function () {
|
||||
$(elem).next('img').hide();
|
||||
alert("Failed. Try again later.111");
|
||||
}
|
||||
});
|
||||
|
||||
} else if(!$(elem).prop('checked')){
|
||||
var clientDropdown = $('select[name=client_id]');
|
||||
if(isVelocityOrRTG){
|
||||
clientDropdown = $('#client-contact-id');
|
||||
|
||||
if(typeof CLIENT_DEFAULT_LIST != 'undefined'){
|
||||
response = CLIENT_DEFAULT_LIST;
|
||||
}else{
|
||||
response = DEFAULT_CLENT_LIST;
|
||||
}
|
||||
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
var attributes = {};
|
||||
var per_values = {};
|
||||
|
||||
for(var val in response) {
|
||||
var row = response[val];
|
||||
attributes = {
|
||||
'data-id':row.id,
|
||||
'data-email':row.email
|
||||
}
|
||||
|
||||
var name = row.name;
|
||||
if(row.first_name){
|
||||
name = row.first_name;
|
||||
}
|
||||
if(row.last_name){
|
||||
if(name){
|
||||
name += " "+row.last_name;
|
||||
}else{
|
||||
name = row.last_name;
|
||||
}
|
||||
}
|
||||
per_values = {value: row.contact_id, text: name+" ("+row.email+")"};
|
||||
$('<option />', per_values).attr(attributes).appendTo(clientDropdown);
|
||||
}
|
||||
}else{
|
||||
response = JSON.parse(DEFAULT_CLENT_LIST);
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
for(var val in response) {
|
||||
if(isEpicVelocity){
|
||||
var full_name = response[val].first_name+" "+response[val].last_name;
|
||||
$('<option />', {value: response[val].id, text: full_name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
}else{
|
||||
$('<option />', {value: response[val].id, text: response[val].name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function employeeFormShow(elem, crmuser_id = 0,client_id =0) {
|
||||
$('.form-employee-list').hide();
|
||||
if(client_id > 0){
|
||||
$('#client-contact-id').attr('data-cid',client_id)
|
||||
}
|
||||
var affiliate_checkbox = $('input[name=client_type]');
|
||||
$('select[name=affiliate_client_id]').attr('disabled', true);
|
||||
if ($(elem).prop('checked') && $(elem).val() == 1) {
|
||||
|
||||
|
||||
} else if(!$(elem).prop('checked')){
|
||||
var clientDropdown = $('select[name=client_id]');
|
||||
if(isVelocityOrRTG){
|
||||
clientDropdown = $('#client-contact-id');
|
||||
if(typeof CLIENT_DEFAULT_LIST != 'undefined'){
|
||||
response = CLIENT_DEFAULT_LIST;
|
||||
}else{
|
||||
response = DEFAULT_CLENT_LIST;
|
||||
}
|
||||
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
var attributes = {};
|
||||
var per_values = {};
|
||||
|
||||
for(var val in response) {
|
||||
var row = response[val];
|
||||
attributes = {
|
||||
'data-id':row.id,
|
||||
'data-email':row.email
|
||||
}
|
||||
|
||||
var name = row.name;
|
||||
if(row.first_name){
|
||||
name = row.first_name;
|
||||
}
|
||||
if(row.last_name){
|
||||
if(name){
|
||||
name += " "+row.last_name;
|
||||
}else{
|
||||
name = row.last_name;
|
||||
}
|
||||
}
|
||||
per_values = {value: row.contact_id, text: name+" ("+row.email+")"};
|
||||
$('<option />', per_values).attr(attributes).appendTo(clientDropdown);
|
||||
}
|
||||
}else{
|
||||
response = JSON.parse(DEFAULT_CLENT_LIST);
|
||||
clientDropdown.empty()
|
||||
$('<option />', {value: "", text: "Please select client"}).appendTo(clientDropdown);
|
||||
for(var val in response) {
|
||||
$('<option />', {value: response[val].id, text: response[val].name+" ("+response[val].email+")"}).appendTo(clientDropdown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7
webroot/rtgv3/js/bootstrap.min.js
vendored
Normal file
7
webroot/rtgv3/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15243
webroot/rtgv3/js/dataTables.js
Normal file
15243
webroot/rtgv3/js/dataTables.js
Normal file
File diff suppressed because it is too large
Load Diff
210
webroot/rtgv3/js/email_campaign.js
Normal file
210
webroot/rtgv3/js/email_campaign.js
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
var SELECTED_TEMPLATE_IDS = [];
|
||||
$('#client_ids').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
|
||||
function clearClient() {
|
||||
event.preventDefault();
|
||||
$('#client_ids').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
}
|
||||
|
||||
function formsubmit(value) {
|
||||
$('input[name=submit_type]').val(value);
|
||||
var set_automation = $('input[name=set_automation]');
|
||||
var automtion_schedule_types = $('select[name=automtion_schedule_types]').val();
|
||||
var automation_days = $('input[name=automation_days]').val();
|
||||
var descLenght = tinyMCE.get('message').getContent().length;
|
||||
var title = $('input[name=campaign_name]').val();
|
||||
var client_id = $('#client_ids').val();
|
||||
var status = $('select[name=status]').val();
|
||||
var result = 0;
|
||||
|
||||
$('span.help-block label').text('');
|
||||
if (!title) {
|
||||
//event.preventDefault();
|
||||
$('label.help-block-title').text('Please enter title');
|
||||
result += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if (!client_id) {
|
||||
//
|
||||
// $('label.help-block-client').text('Please select client');
|
||||
// result += 1;
|
||||
// }
|
||||
|
||||
|
||||
if(SELECTED_TEMPLATE_IDS.length == 0){
|
||||
result += 1;
|
||||
alert('Please select template from template list')
|
||||
}
|
||||
|
||||
|
||||
if (result > 0) {
|
||||
return false;
|
||||
} else {
|
||||
document.getElementById('client_form').submit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getTemplateListForEdit() {
|
||||
var URL = $('#campaign-form').attr('action');
|
||||
var formData = {
|
||||
'action': 'TEMPLATE_LIST'
|
||||
};
|
||||
|
||||
if($('#campaign-fbody tbody').children().length == 0){
|
||||
var table = $('#campaign-fbody');
|
||||
table.DataTable().clear();
|
||||
table.DataTable().destroy();
|
||||
table.DataTable({
|
||||
"columnDefs": [{
|
||||
"targets": 'no-sort',
|
||||
"orderable": false,
|
||||
}],
|
||||
'pageLength': 25,
|
||||
'processing': true,
|
||||
|
||||
'language': {
|
||||
'processing': '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> '
|
||||
},
|
||||
'serverSide': true,
|
||||
'serverMethod': 'POST',
|
||||
'ajax': {
|
||||
'url': URL,
|
||||
'data': formData
|
||||
|
||||
},
|
||||
'columns': [
|
||||
{data: 'a'},
|
||||
{data: 'id'},
|
||||
{data: 'title'},
|
||||
{data: 'b'},
|
||||
{data: 'c'}
|
||||
|
||||
]
|
||||
})
|
||||
}
|
||||
var checked_length = $('#campaign-fbody tbody tr input[type="checkbox"]:checked').length
|
||||
var all_length = $('#campaign-fbody tbody tr input[type="checkbox"]').length
|
||||
|
||||
$('input#ContentSelect').prop('checked',false);
|
||||
if(all_length != 0 && checked_length == all_length){
|
||||
$('input#ContentSelect').prop('checked',true);
|
||||
}
|
||||
$('#campaign-setup').modal('show');
|
||||
|
||||
}
|
||||
|
||||
function getTemplateList() {
|
||||
var URL = $('#campaign-form').attr('action');
|
||||
var formData = {
|
||||
'action': 'TEMPLATE_LIST'
|
||||
};
|
||||
|
||||
if($('#campaign-fbody tbody').children().length == 0){
|
||||
var table = $('#campaign-fbody');
|
||||
table.DataTable().clear();
|
||||
table.DataTable().destroy();
|
||||
table.DataTable({
|
||||
"columnDefs": [{
|
||||
"targets": 'no-sort',
|
||||
"orderable": false,
|
||||
}],
|
||||
'pageLength': 25,
|
||||
'processing': true,
|
||||
|
||||
'language': {
|
||||
'processing': '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> '
|
||||
},
|
||||
'serverSide': true,
|
||||
'serverMethod': 'POST',
|
||||
'ajax': {
|
||||
'url': URL,
|
||||
'data': formData
|
||||
|
||||
},
|
||||
'columns': [
|
||||
{data: 'a'},
|
||||
{data: 'id'},
|
||||
{data: 'title'},
|
||||
{data: 'b'},
|
||||
{data: 'c'}
|
||||
|
||||
]
|
||||
})
|
||||
}
|
||||
var checked_length = $('#campaign-fbody tbody tr input[type="checkbox"]:checked').length
|
||||
var all_length = $('#campaign-fbody tbody tr input[type="checkbox"]').length
|
||||
|
||||
$('input#ContentSelect').prop('checked',false);
|
||||
if(all_length != 0 && checked_length == all_length){
|
||||
$('input#ContentSelect').prop('checked',true);
|
||||
}
|
||||
$('#campaign-setup').modal('show');
|
||||
|
||||
}
|
||||
|
||||
function viewEmailBody(template_id, is_preventDefault = true) {
|
||||
|
||||
if(is_preventDefault){
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if(template_id > 0){
|
||||
var loader = $('#template_list_loader');
|
||||
var URL = $('#client_form').attr('action');
|
||||
|
||||
var formData = {};
|
||||
formData['action'] = "GET_EMAIL_BODY";
|
||||
formData['template_id'] = template_id;
|
||||
loader.show();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: URL,
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
if(response.status){
|
||||
$('input[name=title]').val(response.title);
|
||||
tinyMCE.get('message').setContent(response.content);
|
||||
tinyMCE.get('message').getBody().setAttribute('contenteditable', false);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function removeThisRow(elem, value) {
|
||||
event.preventDefault();
|
||||
if (confirm('Are you sure want to remove this ?')) {
|
||||
SELECTED_TEMPLATE_IDS = $.grep(SELECTED_TEMPLATE_IDS, function(val) {
|
||||
return val != value;
|
||||
});
|
||||
$(elem).parents('tr').first().remove();
|
||||
$('input[name="template_ids['+value+']"]').prop('checked',false);
|
||||
$('input#ContentSelect').prop('checked',false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
223
webroot/rtgv3/js/epic_client_files_modal.js
Normal file
223
webroot/rtgv3/js/epic_client_files_modal.js
Normal file
@@ -0,0 +1,223 @@
|
||||
function sertgAffiliateFormList(elem){
|
||||
var employee_id = $('input[name=employee_id]').val()
|
||||
var formData = {
|
||||
'action':'CLIENT_FILES_BY_CLIENT_CATEGORY',
|
||||
'member_id': $('input[name=member_id]').val(),
|
||||
'form_afiiliate_id':$(elem).val(),
|
||||
'employee_id':employee_id
|
||||
};
|
||||
|
||||
$('#affiliate-loader-form').show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: EPICVELOCITY_AJAX_URL,
|
||||
data: formData,
|
||||
success: function (data) {
|
||||
$('#affiliate-loader-form').hide();
|
||||
var data = JSON.parse(data);
|
||||
|
||||
//console.log('member_id');
|
||||
//console.log('dashboard_data',data);
|
||||
var table = $('#form-table').DataTable();
|
||||
|
||||
table.clear().draw();
|
||||
table.order([6,'desc'])
|
||||
$.each(data, function (index, json) {
|
||||
var next_section_date = "";
|
||||
if(json.next_section_date){
|
||||
next_section_date = moment(json.next_section_date).format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
|
||||
var rows = [json.id, json.personal_info, json.dob, json.ssn,json.source_type, json.slected_letter, moment(json.created_on).format('YYYY-MM-DD'),next_section_date, '<a href="javascript:;" onclick="deleteLetter('+json.letter_id+',this)" data-toggle="tooltip" title="Delete" data-id="' + json.id + '" id="formDelete_"' + json.id + '"><span style="color:#dd4b39;padding-left:10px;font-size:18px;"><i class="fa fa-trash" aria-hidden="true"></i></span></a>' + ' ' + '<a href="javascript:;" onclick="letterLoad('+json.letter_id+')" data-toggle="tooltip" title="Load" data-id="' + json.id + '" id="formLoad_"' + json.id + '"><span style="color:#00a65a;padding-left:5px;font-size:18px;"><i class="fa fa-external-link-square" aria-hidden="true"></i></span></a>'];
|
||||
table.row.add(rows).draw();
|
||||
});
|
||||
|
||||
|
||||
//console.log(get_page);
|
||||
// if (action === 1) {
|
||||
// //console.log(info);
|
||||
// if (info === get_page) {
|
||||
// table.page(info - 1).draw('page');
|
||||
// } else {
|
||||
// table.page(info).draw('page');
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function sertgEmployeeFormList(elem){
|
||||
var formData = {
|
||||
'action':'CLIENT_FILES_BY_CLIENT_CATEGORY',
|
||||
'member_id': $('input[name=member_id]').val(),
|
||||
'form_employee_id':$(elem).val()
|
||||
};
|
||||
$('#employee-loader-form').show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: EPICVELOCITY_AJAX_URL,
|
||||
data: formData,
|
||||
success: function (data) {
|
||||
$('#employee-loader-form').hide();
|
||||
var data = JSON.parse(data);
|
||||
|
||||
//console.log('member_id');
|
||||
|
||||
var table = $('#form-table').DataTable();
|
||||
|
||||
table.clear().draw();
|
||||
table.order([6,'desc'])
|
||||
$.each(data, function (index, json) {
|
||||
var next_section_date = "";
|
||||
if(json.next_section_date){
|
||||
next_section_date = moment(json.next_section_date).format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
|
||||
var rows = [json.id, json.personal_info, json.dob, json.ssn,json.source_type, json.slected_letter, moment(json.created_on).format('YYYY-MM-DD'),next_section_date, '<a href="javascript:;" onclick="deleteLetter('+json.letter_id+',this)" data-toggle="tooltip" title="Delete" data-id="' + json.id + '" id="formDelete_"' + json.id + '"><span style="color:#dd4b39;padding-left:10px;font-size:18px;"><i class="fa fa-trash" aria-hidden="true"></i></span></a>' + ' ' + '<a href="javascript:;" onclick="letterLoad('+json.letter_id+')" data-toggle="tooltip" title="Load" data-id="' + json.id + '" id="formLoad_"' + json.id + '"><span style="color:#00a65a;padding-left:5px;font-size:18px;"><i class="fa fa-external-link-square" aria-hidden="true"></i></span></a>'];
|
||||
table.row.add(rows).draw();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function affiliateFormShow(elem){
|
||||
$('.form-affiliate-list').hide();
|
||||
$('.form-employee-list').hide();
|
||||
if($(elem).prop('checked')){
|
||||
if($(elem).val() == 2){
|
||||
$('#client_type_id').val($(elem).val());
|
||||
$('#affiliate_client_type_id').val(-1);
|
||||
$('#affiliate-loader-form').show();
|
||||
var formData = {'action':'AFFILIATE_LIST','employee_id':0};
|
||||
//formData[''] =
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: AFFILIATE_URL,
|
||||
success: function (response) {
|
||||
$('#affiliate-loader-form').hide();
|
||||
var show_client_checkbox = $('input[name=show_client_checkbox]');
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
var s = $('select[name=form_affiliate_client_id]');
|
||||
s.empty()
|
||||
//$('<option />', {value: -1, text: "All"}).appendTo(s);
|
||||
if(response.iscmsuser){
|
||||
s.html(response.affilistHTML)
|
||||
|
||||
}else{
|
||||
$('<option />', {value: -1, text: "All"}).appendTo(s);
|
||||
|
||||
for(var val in response.affiliateList) {
|
||||
$('<option />', {value: val, text: response.affiliateList[val]}).appendTo(s);
|
||||
}
|
||||
}
|
||||
|
||||
s.trigger('change')
|
||||
$('.form-affiliate-list').show();
|
||||
|
||||
|
||||
$('select[name=affiliate_client_id]').attr('disabled',false);
|
||||
if(response.employee_affiliste_list && show_client_checkbox.prop('checked')){
|
||||
$('select[name=affiliate_client_id]').html(response.employee_affiliste_list);
|
||||
}
|
||||
},error: function () {
|
||||
$(elem).next('img').hide();
|
||||
alert("Failed. Try again later.111");
|
||||
}
|
||||
});
|
||||
}else if($(elem).val() == 1){
|
||||
$('#employee-loader-form').show();
|
||||
var formData = {
|
||||
'action': 'EMPLOYEE_LIST'
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: AFFILIATE_URL,
|
||||
success: function (response) {
|
||||
$('#employee-loader-form').hide();
|
||||
response = JSON.parse(response);
|
||||
|
||||
var s = $('select[name=form_dropdown_employee_id]');
|
||||
s.empty()
|
||||
$('<option />', {
|
||||
value: -1,
|
||||
text: "All"
|
||||
}).appendTo(s);
|
||||
for (var val in response.affiliateList) {
|
||||
var attr = {
|
||||
value: val,
|
||||
text: response.affiliateList[val]
|
||||
}
|
||||
var selected = "";
|
||||
|
||||
$('<option />', attr).appendTo(s);
|
||||
}
|
||||
s.trigger('change')
|
||||
|
||||
$('.form-employee-list').show();
|
||||
$('select[name=affiliate_client_id]').attr('disabled', false);
|
||||
|
||||
|
||||
|
||||
},
|
||||
error: function () {
|
||||
$(elem).next('img').hide();
|
||||
alert("Failed. Try again later.111");
|
||||
}
|
||||
});
|
||||
} else if($(elem).val() == 3){
|
||||
var formData = {
|
||||
'action':'GET_CLIENT_FILES_LIST_POPUP',
|
||||
'member_id': $('input[name=member_id]').val(),
|
||||
'employee_id': $('input[name=employee_id]').val(),
|
||||
'form_employee_id':0
|
||||
};
|
||||
|
||||
$('#all-loader-form').show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: EPICVELOCITY_AJAX_URL,
|
||||
data: formData,
|
||||
success: function (data) {
|
||||
$('#all-loader-form').hide();
|
||||
var data = JSON.parse(data);
|
||||
|
||||
//console.log('member_id');
|
||||
console.log('dashboard_data',data);
|
||||
var table = $('#form-table').DataTable();
|
||||
|
||||
table.clear().draw();
|
||||
table.order([6,'desc'])
|
||||
$.each(data, function (index, json) {
|
||||
var next_section_date = "";
|
||||
if(json.next_section_date){
|
||||
next_section_date = moment(json.next_section_date).format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
|
||||
var rows = [json.id, json.personal_info, json.dob, json.ssn,json.source_type, json.slected_letter, moment(json.created_on).format('YYYY-MM-DD'),next_section_date, '<a href="javascript:;" onclick="deleteLetter('+json.letter_id+',this)" data-toggle="tooltip" title="Delete" data-id="' + json.id + '" id="formDelete_"' + json.id + '"><span style="color:#dd4b39;padding-left:10px;font-size:18px;"><i class="fa fa-trash" aria-hidden="true"></i></span></a>' + ' ' + '<a href="javascript:;" onclick="letterLoad('+json.letter_id+')" data-toggle="tooltip" title="Load" data-id="' + json.id + '" id="formLoad_"' + json.id + '"><span style="color:#00a65a;padding-left:5px;font-size:18px;"><i class="fa fa-external-link-square" aria-hidden="true"></i></span></a>'];
|
||||
table.row.add(rows).draw();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
21
webroot/rtgv3/js/jquery-ui-datepicker.min.js
vendored
Normal file
21
webroot/rtgv3/js/jquery-ui-datepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3688
webroot/rtgv3/js/moment.js
Normal file
3688
webroot/rtgv3/js/moment.js
Normal file
File diff suppressed because it is too large
Load Diff
1
webroot/rtgv3/js/select2.full.min.js
vendored
Normal file
1
webroot/rtgv3/js/select2.full.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
258
webroot/rtgv3/js/setup_email.js
Normal file
258
webroot/rtgv3/js/setup_email.js
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
var SMTP_URL = '';
|
||||
|
||||
|
||||
$('#client_ids, #selected_templates').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
$('#imagefile_1').change(function() {
|
||||
var i = $(this).prev('label').clone();
|
||||
var file = $('#imagefile_1')[0].files[0].name;
|
||||
$('#fname').text(file);
|
||||
});
|
||||
|
||||
function clearClient(){
|
||||
event.preventDefault();
|
||||
$('#client_ids').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
}
|
||||
|
||||
function viewAttachment() {
|
||||
event.preventDefault();
|
||||
$('#view_att').submit();
|
||||
}
|
||||
|
||||
function formsubmit(value) {
|
||||
$('input[name=submit_type]').val(value);
|
||||
var set_automation = $('input[name=set_automation]');
|
||||
var automtion_schedule_types = $('select[name=automtion_schedule_types]').val();
|
||||
var automation_days = $('input[name=automation_days]').val();
|
||||
var descLenght = tinyMCE.get('message').getContent().length;
|
||||
var title = $('input[name=title]').val();
|
||||
var client_id = $('#client_ids').val();
|
||||
var status = $('select[name=status]').val();
|
||||
var result = 0;
|
||||
|
||||
$('span.help-block label').text('');
|
||||
if (!title) {
|
||||
//event.preventDefault();
|
||||
$('label.help-block-title').text('Please enter title');
|
||||
result += 1;
|
||||
}
|
||||
if (descLenght < 1) {
|
||||
// event.preventDefault();
|
||||
$('label.help-block-description').text('Please enter email body');
|
||||
result += 1;
|
||||
}
|
||||
|
||||
|
||||
if (!client_id) {
|
||||
|
||||
$('label.help-block-client').text('Please select client');
|
||||
result += 1;
|
||||
}
|
||||
|
||||
if((value == 2 || value == 3) && set_automation.prop('checked')){
|
||||
if(!automtion_schedule_types){
|
||||
$('label.help-block-sch-type').text('Please select automation type');
|
||||
result += 1;
|
||||
}
|
||||
|
||||
if(!automation_days){
|
||||
$('label.help-block-days').text('Please enter days value');
|
||||
result += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (result > 0) {
|
||||
return false;
|
||||
} else {
|
||||
if (is_smtp_active == 0) {
|
||||
if (value == 2 || value == 3) {
|
||||
|
||||
Swal.fire({
|
||||
width: '40rem',
|
||||
text: "To send your first email, please set up your Personalized Account email SMTP. Would you like to set up Now ?",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes',
|
||||
cancelButtonText: 'No'
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
$('#smtp-setup').modal('show');
|
||||
}
|
||||
});
|
||||
|
||||
} else if (value == 1) {
|
||||
document.getElementById('client_form').submit();
|
||||
}
|
||||
|
||||
} else {
|
||||
document.getElementById('client_form').submit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getTemplateById(elem) {
|
||||
var template_id = $(elem).val();
|
||||
if (template_id > 0) {
|
||||
var loader = $('#template-loader');
|
||||
loader.show();
|
||||
var formData = {
|
||||
action: 'GET_TEMPLATE',
|
||||
template_id: template_id,
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: $('#client_form').attr('action'),
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('input[name=title]').val(response.title);
|
||||
//$('textare[name=content]').html(response.content);
|
||||
tinyMCE.get('message').setContent(response.content);
|
||||
//$('.modal-body').html(response)
|
||||
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function setAutomation(elem) {
|
||||
|
||||
var automation_class = $('.automation-class');
|
||||
var value = $(elem).val();
|
||||
var isChecked = $(elem).prop('checked');
|
||||
var automtion_schedule_types = $('select[name=automtion_schedule_types]');
|
||||
var automation_days = $('input[name=automation_days]');
|
||||
automation_class.hide();
|
||||
|
||||
automtion_schedule_types.attr('required',false);
|
||||
automation_days.attr('required',false);
|
||||
|
||||
$('.automation-class a.label').removeClass('required')
|
||||
|
||||
if (isChecked) {
|
||||
automation_class.show();
|
||||
automtion_schedule_types.attr('required',true);
|
||||
automation_days.attr('required',true);
|
||||
$('.automation-class a.label').addClass('required')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function viewEmailBody(elem ,isLoder = true) {
|
||||
event.preventDefault();
|
||||
var template_id = $(elem).val()
|
||||
if(template_id > 0){
|
||||
|
||||
var loader = $('#template_list_loader-d');
|
||||
|
||||
var formData = {};
|
||||
formData['action'] = "GET_EMAIL_BODY";
|
||||
formData['template_id'] = template_id;
|
||||
if(isLoder){
|
||||
loader.show();
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: $('#client_form').attr('action'),
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('input[name=title]').val(response.title);
|
||||
tinyMCE.get('message').setContent(response.content);
|
||||
tinyMCE.get('message').getBody().setAttribute('contenteditable', false);
|
||||
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getCampaignInfo(elem){
|
||||
var campaign_id = $(elem).val();
|
||||
if (campaign_id > 0) {
|
||||
var loader = $('#campaign-loader');
|
||||
loader.show();
|
||||
var formData = {
|
||||
action: 'CAMPAIGN_TEMPLATE_LIST',
|
||||
campaign_id: campaign_id,
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: $('#client_form').attr('action'),
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
if(response.template_ids){
|
||||
|
||||
$('.dynamic select[name=template_id]').attr('disabled',false);
|
||||
$('.dynamic select[name=template_id]').html(response.template_html);
|
||||
$('.dynamic').show()
|
||||
|
||||
$('.non-dynamic').hide()
|
||||
$('.non-dynamic select[name=template_id]').attr('disabled',true)
|
||||
console.log('vvv',response.template_ids);
|
||||
if(response.first_title){
|
||||
$('input[name=title]').val(response.first_title);
|
||||
}
|
||||
if(response.first_email_body){
|
||||
tinyMCE.get('message').setContent(response.first_email_body);
|
||||
}
|
||||
var studentSelect = $('#selected_templates');
|
||||
$('#selected_templates').next('.select2').remove();
|
||||
studentSelect.attr('disabled',true).val(response.template_ids).trigger('change').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
$('.selected-template_list').show();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}else{
|
||||
$('.dynamic').hide()
|
||||
$('.selected-template_list').hide()
|
||||
$('.dynamic select[name=template_id]').attr('disabled',true)
|
||||
|
||||
$('.non-dynamic').show()
|
||||
$('.non-dynamic select[name=template_id]').attr('disabled',false)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//studentSelect.select2('val',[1,2])
|
||||
|
||||
|
||||
}
|
||||
211
webroot/rtgv3/js/setup_email_template.js
Normal file
211
webroot/rtgv3/js/setup_email_template.js
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
var SMTP_URL = '';
|
||||
|
||||
|
||||
$('#client_ids, #selected_templates').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
$('#imagefile_1').change(function() {
|
||||
var i = $(this).prev('label').clone();
|
||||
var file = $('#imagefile_1')[0].files[0].name;
|
||||
$('#fname').text(file);
|
||||
});
|
||||
|
||||
function clearClient(){
|
||||
event.preventDefault();
|
||||
$('#client_ids').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
}
|
||||
|
||||
function viewAttachment() {
|
||||
event.preventDefault();
|
||||
$('#view_att').submit();
|
||||
}
|
||||
|
||||
function formsubmit(value) {
|
||||
$('input[name=submit_type]').val(value);
|
||||
var set_automation = $('input[name=set_automation]');
|
||||
var automtion_schedule_types = $('select[name=automtion_schedule_types]').val();
|
||||
var automation_days = $('input[name=automation_days]').val();
|
||||
var descLenght = tinyMCE.get('message').getContent().length;
|
||||
var title = $('input[name=title]').val();
|
||||
var client_id = $('#client_ids').val();
|
||||
var status = $('select[name=status]').val();
|
||||
var result = 0;
|
||||
|
||||
$('span.help-block label').text('');
|
||||
if (!title) {
|
||||
//event.preventDefault();
|
||||
$('label.help-block-title').text('Please enter title');
|
||||
result += 1;
|
||||
}
|
||||
if (descLenght < 1) {
|
||||
// event.preventDefault();
|
||||
$('label.help-block-description').text('Please enter email body');
|
||||
result += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (result > 0) {
|
||||
return false;
|
||||
} else {
|
||||
document.getElementById('client_form').submit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getTemplateById(elem) {
|
||||
var template_id = $(elem).val();
|
||||
if (template_id > 0) {
|
||||
var loader = $('#template-loader');
|
||||
loader.show();
|
||||
var formData = {
|
||||
action: 'GET_TEMPLATE',
|
||||
template_id: template_id,
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: $('#client_form').attr('action'),
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('input[name=title]').val(response.title);
|
||||
//$('textare[name=content]').html(response.content);
|
||||
tinyMCE.get('message').setContent(response.content);
|
||||
//$('.modal-body').html(response)
|
||||
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function setAutomation(elem) {
|
||||
|
||||
var automation_class = $('.automation-class');
|
||||
var value = $(elem).val();
|
||||
var isChecked = $(elem).prop('checked');
|
||||
var automtion_schedule_types = $('select[name=automtion_schedule_types]');
|
||||
var automation_days = $('input[name=automation_days]');
|
||||
automation_class.hide();
|
||||
|
||||
automtion_schedule_types.attr('required',false);
|
||||
automation_days.attr('required',false);
|
||||
|
||||
$('.automation-class a.label').removeClass('required')
|
||||
|
||||
if (isChecked) {
|
||||
automation_class.show();
|
||||
automtion_schedule_types.attr('required',true);
|
||||
automation_days.attr('required',true);
|
||||
$('.automation-class a.label').addClass('required')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function viewEmailBody(elem) {
|
||||
event.preventDefault();
|
||||
var template_id = $(elem).val()
|
||||
if(template_id > 0){
|
||||
var loader = $('#template_list_loader-d');
|
||||
|
||||
var formData = {};
|
||||
formData['action'] = "GET_EMAIL_BODY";
|
||||
formData['template_id'] = template_id;
|
||||
loader.show();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: $('#client_form').attr('action'),
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('input[name=title]').val(response.title);
|
||||
//$('textare[name=content]').html(response.content);
|
||||
tinyMCE.get('message').setContent(response.content);
|
||||
tinyMCE.get('message').getBody().setAttribute('contenteditable', false);
|
||||
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getCampaignInfo(elem){
|
||||
var campaign_id = $(elem).val();
|
||||
if (campaign_id > 0) {
|
||||
var loader = $('#campaign-loader');
|
||||
loader.show();
|
||||
var formData = {
|
||||
action: 'CAMPAIGN_TEMPLATE_LIST',
|
||||
campaign_id: campaign_id,
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: formData,
|
||||
url: $('#client_form').attr('action'),
|
||||
success: function (response) {
|
||||
loader.hide();
|
||||
response = JSON.parse(response);
|
||||
if(response.template_ids){
|
||||
|
||||
$('.dynamic select[name=template_id]').attr('disabled',false);
|
||||
$('.dynamic select[name=template_id]').html(response.template_html);
|
||||
$('.dynamic').show()
|
||||
|
||||
$('.non-dynamic').hide()
|
||||
$('.non-dynamic select[name=template_id]').attr('disabled',true)
|
||||
console.log('vvv',response.template_ids);
|
||||
var studentSelect = $('#selected_templates');
|
||||
$('#selected_templates').next('.select2').remove();
|
||||
studentSelect.attr('disabled',true).val(response.template_ids).trigger('change').select2({
|
||||
placeholder: "Please select",
|
||||
allowClear: true
|
||||
});
|
||||
$('.selected-template_list').show();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
loader.hide();
|
||||
}
|
||||
})
|
||||
}else{
|
||||
$('.dynamic').hide()
|
||||
$('.selected-template_list').hide()
|
||||
$('.dynamic select[name=template_id]').attr('disabled',true)
|
||||
|
||||
$('.non-dynamic').show()
|
||||
$('.non-dynamic select[name=template_id]').attr('disabled',false)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//studentSelect.select2('val',[1,2])
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user