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