forked from derekallard/BambooInvoice
-
Notifications
You must be signed in to change notification settings - Fork 6
/
emailinvoice.js
executable file
·57 lines (49 loc) · 1.63 KB
/
emailinvoice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function initEmail() {
// reveal email invoice menu option
if ($('invemailli')) {
$('invemailli').style.display = "block";
// $('emailInvoice').setAttribute ("onsubmit", "return ajaxEmail()"); // for future functionality.
$('emailInvoice').style.display = "none";
// $('isAjax').value = 'true'; // for future functionality.
}
var checkboxArray = document.getElementsByTagName("input");
for (i=0; i<checkboxArray.length; ++i) {
if (checkboxArray[i].name == "recipients[]" && checkboxArray[i].value != "1") {
checkboxArray[i].onclick = function() {
$("emailError").innerHTML = "";
}
}
}
}
function ajaxEmail() {
if (inspect_recipients()) {
$("emailError").innerHTML = "";
startLoading();
new Ajax.Request(base_url+'invoices/email', {postBody: Form.serialize($('emailInvoice')), onComplete: stopLoading});
} else {
$("emailError").innerHTML = lang_error_email_recipients;
}
return false;
}
function startLoading() {
// put loading up
}
function stopLoading() {
// stop loading
// invoiceHistory
$('emailSuccess').toggle();
new Effect.Highlight ('emailSuccess', {startcolor:'#F7E47D', endcolor:'#FFFFFF'});
Effect.BlindUp('emailInvoice', {duration: '0.4'});
}
function inspect_recipients() {
var checkboxArray = document.getElementsByTagName("input");
for (i=0; i<checkboxArray.length; ++i) {
if (checkboxArray[i].name == "recipients[]" && checkboxArray[i].value != "1") {
if (checkboxArray[i].checked) {
return true;
}
}
}
return false;
}
addEvent(window,'load', initEmail);