-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPermit Action.html
111 lines (99 loc) · 6.54 KB
/
Permit Action.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function OpenOutlookDoc(bdy,to){
try {
var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.add('IPM.Note.FormA');
mailItem.Subject="Permit Action Needed";
mailItem.To = to;
mailItem.HTMLBody = bdy;
mailItem.display (0);
}
catch(e){
alert("You need to Access thes webpage from Internet Explorer");
// act on any error that you get
}
}
$(function(){
$(document).on("change","input", function(){
var allGood=true;
var lastInputField=0;
$("input").each(function() {
if ($(this).val() =="") {
allGood=false;
return false;
}else{
}
lastInputField++;
});
if (allGood) {
$("<span>Permit: <input placeholder='Paste URL to Permit Here' type='text' style='width :10%;' id='permits" + lastInputField +"'" + "name='permits" + lastInputField + "'> <input type='text' placeholder='Type a Short Descrption of the Permit and what is needed' style='width :80%;' id='desc" + lastInputField +"'" + "name='desc" + lastInputField + "'></span><br />").appendTo("form");
}
});
});
function formEmail() {
var msgBody = "<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:m=\"http:\/\/schemas.microsoft.com\/office\/2004\/12\/omml\" xmlns=\"http:\/\/www.w3.org\/TR\/REC-html40\"><head><meta http-equiv=Content-Type content=\"text\/html; charset=us-ascii\"><meta name=Generator content=\"Microsoft Word 15 (filtered medium)\"><!--[if !mso]><style>v\\:* {behavior:url(#default#VML);}\r\no\\:* {behavior:url(#default#VML);}\r\nw\\:* {behavior:url(#default#VML);}\r\n.shape {behavior:url(#default#VML);}\r\n<\/style><![endif]--><style><!--\r\n\/* Font Definitions *\/\r\n@font-face\r\n\t{font-family:\"Cambria Math\";\r\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;}\r\n@font-face\r\n\t{font-family:Calibri;\r\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;}\r\n@font-face\r\n\t{font-family:\"Arial Rounded MT Bold\";\r\n\tpanose-1:2 15 7 4 3 5 4 3 2 4;}\r\n\/* Style Definitions *\/\r\np.MsoNormal, li.MsoNormal, div.MsoNormal\r\n\t{margin:0in;\r\n\tmargin-bottom:.0001pt;\r\n\tfont-size:11.0pt;\r\n\tfont-family:\"Calibri\",sans-serif;}\r\na:link, span.MsoHyperlink\r\n\t{mso-style-priority:99;\r\n\tcolor:#0563C1;\r\n\ttext-decoration:underline;}\r\na:visited, span.MsoHyperlinkFollowed\r\n\t{mso-style-priority:99;\r\n\tcolor:#954F72;\r\n\ttext-decoration:underline;}\r\nspan.EmailStyle17\r\n\t{mso-style-type:personal-compose;\r\n\tfont-family:\"Calibri\",sans-serif;\r\n\tcolor:windowtext;}\r\n.MsoChpDefault\r\n\t{mso-style-type:export-only;\r\n\tfont-family:\"Calibri\",sans-serif;}\r\n@page WordSection1\r\n\t{size:8.5in 11.0in;\r\n\tmargin:1.0in 1.0in 1.0in 1.0in;}\r\ndiv.WordSection1\r\n\t{page:WordSection1;}\r\n--><\/style><!--[if gte mso 9]><xml>\r\n<o:shapedefaults v:ext=\"edit\" spidmax=\"1026\" \/>\r\n<\/xml><![endif]--><!--[if gte mso 9]><xml>\r\n<o:shapelayout v:ext=\"edit\">\r\n<o:idmap v:ext=\"edit\" data=\"1\" \/>\r\n<\/o:shapelayout><\/xml><![endif]--><\/head><body lang=EN-US link=\"#0563C1\" vlink=\"#954F72\"><div class=WordSection1><p class=MsoNormal> "
var to = "";
$.when( $.each($("#Permits").serializeArray(), function(_, field) {
if(field.name.match("^permits") && field.value != "" ){
// alert(field.name + field.value);
msgBody = msgBody + "<a href=\"" + field.value + "\">#" + field.value.slice(field.value.lastIndexOf('?')-6, field.value.lastIndexOf('?')) +"<\/a>";
// console.log("Permit #" +field.value.slice(field.value.lastIndexOf('?')-6, field.value.lastIndexOf('?')));
} else if(field.name.match("^desc") && field.value != "") {
// alert(field.name + field.value);
msgBody = msgBody +" --> "+ field.value + "<o:p><\/o:p><\/p>";
// console.log("Description is " + field.value);
}
if(field.name.match("^to")){
to = field.value;
}
})).then( function (){
msgBody = msgBody + "<br /><br /><p class=MsoNormal>If you have any questions, Let me know.<o:p><\/o:p><\/p>";
OpenOutlookDoc(msgBody,to);
// console.log(msgBody);
});
}
$.get("https://ecowalaska.bpweb.bp.com").done(function () {
// alert("success");
}).fail(function () {
$("#emails").empty();
alert("You are Not on a BP Network This Will Not Work");
});
</script>
</head>
<body>
<header style="text-align: center; font-size:30px;">
Permit Action Email Template
</header>
<form method="post" id="Permits" action="" style="width :100%;">
Facility Where Permits Need Action: <select name="to" id="emails" form="Permits">
<option></option>
<option value="[email protected]">FS1</option>
<option value="[email protected]">SIP/STP</option>
<option value="[email protected]">FS2</option>
<option value="[email protected]">FS3</option>
<option value="[email protected]">GC1</option>
<option value="[email protected]">GC2</option>
<option value="[email protected]">GC2 Field</option>
<option value="[email protected]">GC3</option>
<option value="[email protected]">CPS</option>
<option value="[email protected]">LPC/GPMA</option>
<option value="[email protected]">LPC/GPMA Field</option>
<option value="AKL&[email protected]">BOC</option>
<option value="AKL&[email protected]">MCC</option>
<option value="[email protected]">PBOC</option>
</select>
</br>
</br>
<span>Permit: </span>
<input type="text" name="permits1" id="permits1" placeholder="Paste URL to Permit Here" style="width :10%;"/> <input type="text" name="desc1" id="desc1" placeholder="Type a Short Descrption of the Permit and what is needed" style="width :80%;"/>
<br />
</form>
<input type="button" name="submit1" value="Generate and Open Outlook Message" onclick="formEmail()" />
<!-- <a href="javascript:">Click</a> -->
</body>
</html>