inital commit
This commit is contained in:
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])
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user