").hide().appendTo(parent).fadeIn("slow");
});
},
statusCode: null,
onProgress: null,
onComplete: null
},
files: null,
addMore: false,
allowDuplicates: true,
clipBoardPaste: true,
excludeName: null,
beforeRender: null,
afterRender: null,
beforeShow: null,
beforeSelect: null,
onSelect: null,
afterShow: null,
onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){
var filerKit = inputEl.prop("jFiler"),
file_name = filerKit.files_list[id].name;
},
onEmpty: null,
options: null,
dialogs: {
alert: function(text) {
return alertMsg(text);
},
confirm: function (text, callback) {
confirm(text) ? callback() : null;
}
},
captions: {
button: "Choose Files",
feedback: "Choose files To Upload",
feedback2: "files were chosen",
drop: "Drop file here to Upload",
removeConfirmation: "Are you sure you want to remove this file?",
errors: {
filesLimit: "Only {{fi-limit}} files are allowed to be uploaded.",
filesType: "This file type is not supported here.",
filesSize: "{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.",
filesSizeAll: "Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB."
}
}
});
}
}
$(document).ready(function() {
$('#ModalEmailText').summernote({
tabsize: 2,
height: 175,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear', 'fontname', 'fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['fullscreen', 'codeview', 'help']]
]
});
});
/*
Screens that include email must include this JS file and prepare an array as follows:
Element 0:
- list = "on/off" If ON then listname is used.
- listname = "The Name of the List if emailing more than one recipent"
- role = "Role required to send this email"
- from = "Name of Email Sender like NVblu Service"
- replyto = "Reply To Email Address"
- direct = "on/off" If bypassing pop up screen -- subject/text required for this to work
- codes = array of codes that match fields in recipent objects. codes can be selected in
email pop up screen to insert matching data from recipient
- bcc = BCC Email
- subject = Email Subject
- text = Email Text
- attachment = Description of attachment file for list
Element 1: First recipient (always required whether list is on or not)
Element 2-n: Rest of recipents for a list....only used if list is on
- email: Email for this recipent (required)
- name: Name for this recipent (required)
- attachment: URI with recipient parms for file being attached
- CODES: Object of codes matching codes in Element 0 {CODE_NAME:"VALUE",CODE_NAME:"VALUE"}
*/
var modal_emails = [];
function prepareEmail(emails) {
//SET MASTER FOR SENDING
modal_emails = emails;
if ( emails[0].direct && emails[0].direct.toUpperCase() == "ON" ) {
if ( (!emails[0].subject || emails[0].subject == "") || (!emails[0].text || emails[0].text == "") ) {
alertMsg("You must provide a subject and email text for a direct email request.");
} else {
modalEmailSendEmail();
}
return;
}
$("#ModalEmailCodes").html("");
var email_codes = "";
for ( var i=0; i < emails[0].codes.length; i++ ) {
email_codes = email_codes + "[[" + emails[0].codes[i] + "]]
";
}
$("#ModalEmailCodes").html(email_codes);
if ( email_codes != "" )
$("#ModalEmailCodesBlock").show();
else
$("#ModalEmailCodesBlock").hide();
$("#ModalEmails").empty();
if ( emails[0].list && emails[0].list.toUpperCase() == "ON" ) {
$("#ModalEmailLabel").html("" + emails[0].listname + ":");
$("#ModalEmail").hide();
$("#ModalEmails").show();
for ( var i=1; i < emails.length; i++ ) {
$("#ModalEmails").append('');
}
} else {
$("#ModalEmailLabel").html("Email " + emails[1].name + ":");
$("#ModalEmail").show();
$("#ModalEmails").hide();
$("#ModalEmail").val(emails[1].email);
}
if ( emails[0].attachment ) {
$("#ModalEmailAttachment").html("Attachment: " + emails[0].attachment );
$("#ModalEmailAttachment").show();
} else {
$("#ModalEmailAttachment").html("");
$("#ModalEmailAttachment").hide();
}
if ( emails[0].bcc )
$("#ModalBCCEmail").val(emails[0].bcc);
else
$("#ModalBCCEmail").val("");
if ( emails[0].subject )
$("#ModalEmailSubject").val(emails[0].subject);
else
$("#ModalEmailSubject").val("");
if ( emails[0].text )
$('#ModalEmailText').summernote('code', emails[0].text);
else
$('#ModalEmailText').summernote('code', '');
//PRE PREPARED EMAILS CAN SKIP THE MODAL POPUP
$("#ModalEmailModule").modal();
}
function modalEmailSendEmailPrepare() {
if ( $("#ModalEmailSubject").val() == "" || $('#ModalEmailText').summernote('code') == "" ) {
alertMsg("EMAIL FAILED! Emails require a Subject and Text!");
return;
}
if ( emails[0].list && emails[0].list.toUpperCase() == "ON" ) {
modal_emails[0].email = "";
} else {
if ( $("#ModalEmail").val() == "" ) {
alertMsg("EMAIL FAILED! You need to enter an email address!");
return;
}
emails[1].email = $("#ModalEmail").val();
}
modal_emails[0].bcc = $("#ModalBCCEmail").val();
modal_emails[0].subject = $("#ModalEmailSubject").val();
modal_emails[0].text = $('#ModalEmailText').summernote('code');
modalEmailSendEmail();
}
function modalEmailSendEmail() {
var email_codes = "";
for ( var i=0; i < modal_emails[0].codes.length; i++ ) {
if ( i > 0 )
email_codes = email_codes + "|";
email_codes = email_codes + modal_emails[0].codes[i];
}
var emails = "";
for ( var i=1; i < modal_emails.length; i++ ) {
if ( i > 1 )
emails = emails + "|";
var user_codes = "";
if ( modal_emails[i].codes ) {
for ( var ii=0; ii < modal_emails[0].codes.length; ii++ ) {
if ( ii > 0 )
user_codes = user_codes + ":";
if ( modal_emails[i].codes[modal_emails[0].codes[ii]] ) {
user_codes = user_codes + modal_emails[0].codes[ii] + "=" + modal_emails[i].codes[modal_emails[0].codes[ii]];
} else {
user_codes = user_codes + modal_emails[0].codes[ii] + "=";
}
}
}
if ( !modal_emails[i].attachment )
modal_emails[i].attachment = "";
emails = emails + modal_emails[i].email + ";"
+ modal_emails[i].name + ";"
+ modal_emails[i].attachment + ";"
+ user_codes;
}
if ( !modal_emails[0].role )
modal_emails[0].role = "ROOT";
if ( !modal_emails[0].replyto )
modal_emails[0].replyto = "eric@nvblu.com";
if ( !modal_emails[0].from )
modal_emails[0].from = "NVblu Service";
var data = {};
data['sf'] = 'sendemail';
data['Subject'] = modal_emails[0].subject;
data['EmailText'] = modal_emails[0].text;
data['BCC'] = modal_emails[0].bcc;
data['Role'] = modal_emails[0].role;
data['ReplyTo'] = modal_emails[0].replyto;
data['From'] = modal_emails[0].from;
data['Attachment'] = modal_emails[0].attachment;
data['CODES'] = email_codes;
data['EMAILS'] = emails;
$.ajax({
url: '/data/documents/',
type: 'post',
data: data,
dataType: 'json',
success: function(data) {
if ( data.message != "" ) {
alertMsg(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown)
{
alertMsg(jqXHR.responseText);
}
});
}
function modalEmailSelectEmail() {
if ( $("#ModalEmailID").val() == "" ) {
$("#ModalEmailSubject").val("");
$('#ModalEmailText').summernote('code', "");
return;
}
var data = {};
data['sf'] = 'emailtemplate';
data['EmailTemplateID'] = $("#ModalEmailID").val();
$.ajax({
url: '/data/configuration/',
type: 'get',
data: data,
dataType: 'json',
success: function(data) {
if ( data.message != "" )
alertMsg(data.message);
else {
$("#ModalEmailSubject").val(data.emailtemplate.Subject);
$('#ModalEmailText').summernote('code', data.emailtemplate.EmailText);
}
},
error: function (jqXHR, textStatus, errorThrown)
{
alertMsg(jqXHR.responseText);
}
});
}