/**
* @description - This function is used to create the email template
* @returns string
*/
function createEmailTemplate(requestBodyJSON, fileId) {
try {
let fileUrl = search.lookupFields({
type: 'file',
id: fileId,
columns: ['url']
});
if (requestBodyJSON.custname) {
let cusName = search.lookupFields({
type: 'customer',
id: requestBodyJSON.custname,
columns: ['altname']
});
let selectedCustomer = getCustomerSalesDetails(requestBodyJSON.custname)
let monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let currentDate = new Date();
let currentMonthIndex = currentDate.getMonth();
let currentMonthName = monthNames[currentMonthIndex];
let quarterlySales = selectedCustomer[requestBodyJSON.custname].quartersales;
let formattedSales = parseFloat(quarterlySales).toLocaleString();
let quarterlyDate = selectedCustomer[requestBodyJSON.custname].quartersdate
let formattedDate = parseFloat(quarterlyDate).toLocaleString();
let LastSales = selectedCustomer[requestBodyJSON.custname].lastsales
let formattedLastSales = parseFloat(LastSales).toLocaleString();
let yearDate = selectedCustomer[requestBodyJSON.custname].yeardate
let formattedYearDate = parseFloat(yearDate).toLocaleString();
let emailContent = `<html
xmlns:v="urn:schemas-microsoft-com:vml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<style type="text/css">* {
vertical-align: baseline;
/* font-weight: inherit; */
font-family: verdana;
font-style: inherit;
font-size: 100%;
border: 0 none;
outline: 0;
padding: 0;
margin: 0;
}
#content div,.email_body,#ability,#payment_method {
padding: 5px;
}
.email_body,#ability li,#payment_method_list li p {
line-height: 2em;
}
#ability,#payment_method_list {
padding-left: 30px;
}
td#footer p {
text-align: center;
}
</style>
</head><body>
<table id="content">
<tbody>
<tr>
<td>
<div id="main_content">
<p class="email_body"><br/>Hi ${cusName.altname} Team, <br/><br/>
Here is your Graph Tech Bonus scorecard for the month of ${currentMonthName} 2024
<br/><br/>2023 quarterly average to beat $${formattedSales}
<br/>To date this quarter $${formattedDate}
<br/>Your yearly goal to beat $${formattedLastSales}
<br/>Your current year-to-date purchase is $${formattedYearDate}
<br/><img src="https://6826574.app.netsuite.com${fileUrl.url}"/>
<br/><br/>Thank you.<br/></p>
</div>
</td>
</tr>
</tbody>
</table>
</body></html>`
return emailContent;
}
}
catch (e) {
log.error("error@documentSearch", e.message);
return '';
}
}