inital commit
This commit is contained in:
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