Design Of Full Advance PDF Template using Suitescript PART 1:
Fri May 27 2022 09:03:23 GMT+0000 (Coordinated Universal Time)
Saved by @mdfaizi
/*
* Module Description: This script would generate PO PDF Layout.
* Modification logs
Date Modified By Requested By Remarks
04/02/2020 Pragati V.(Author) Jayesh D. Script Created.
04/05/2020 Pragati V.(Author) Sumit R. Changes in alignments and field values.
04/18/2020 Pragati V.(Author) Vaibhav S. Changes in alignments and field values.
*/
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
var f_item_basic_total = 0, f_item_tax_amt_total = 0, f_item_total_value = 0;
var f_expense_basic_total = 0, f_expense_tax_amt_total = 0, f_expense_total_value = 0;
var arr_ref_no = new Array();
var arr_tax_rate = new Array();
define(['N/ui/serverWidget', 'N/email', 'N/runtime', 'N/file', 'N/https','N/record', 'N/render', 'N/xml', 'N/format','N/search','N/format', 'N/config'],
function(ui, email, runtime, file, https,record, render, xmlrec, format,search,obj_Format, config )
{
//This function would get all values from record and generate PO PDF Layout.
function onRequest_PO_PDF_Layout(context)
{
if (context.request.method == 'GET')
{
var request = context.request;
var response = context.response;
var i_Flag= request.parameters.flag;
if(!i_Flag)
i_Flag = 0;
var i_rec_id= request.parameters.i_recordId;
var s_rec_type = request.parameters.s_recordtype;
log.debug({ title: 'Debug Entry',details: 'i_rec_id:==' + i_rec_id + 's_rec_type:==' + s_rec_type + 'i_Flag:==' + i_Flag});
var htmlMsg = "";
htmlMsg += "<head>";
htmlMsg += "<style>";
htmlMsg += ".textLargeBold { font-family:Arial, Helvetica; font-size: 10pt; font-weight: bold; text-align:center;}" +
".textHeader { font-family:Arial, Helvetica; font-size: 8pt; font-weight: bold; text-align:justify;}" +
".textGoodBold { font-family:Arial, Helvetica; font-size: 8.5pt; font-weight: bold;}" +
".textGoodThin { font-family:Arial, Helvetica; font-size: 8pt;}" +
" p{ word-spacing:0.3pt}" +
".textVeryLargeBold { font-family:Arial, Helvetica; font-size: 14pt;text-align:center; font-weight: bold;}" +
"</style>"
htmlMsg += "<macrolist>";
htmlMsg += "<macro id=\"header\">";
if ((_logValidation(s_rec_type) == true) && (_logValidation(i_rec_id) == true))
{
//Header level details:==
var s_Image;
var obj_purchase_order = record.load({ type: record.Type.PURCHASE_ORDER, id: i_rec_id ,isDynamic: true});
var i_po_tran_no = obj_purchase_order.getValue({ fieldId: 'tranid' });
var d_po_date = obj_purchase_order.getValue({ fieldId: 'trandate' });
var d_po_date_month = d_po_date.getMonth() + 1;
var d_po_Date = d_po_date.getDate();
var d_po_date_year = d_po_date.getFullYear();
if(d_po_Date < 10)
d_po_Date = '0' + d_po_Date;
if(d_po_date_month < 10)
d_po_date_month = '0' + d_po_date_month;
d_po_date = d_po_date_month + '/' + d_po_Date + '/' + d_po_date_year;
log.debug({ title: 'Debug Entry',details: 's_Image:== ' + s_Image + ' i_po_tran_no:== ' + i_po_tran_no + ' d_po_date:== ' + d_po_date });
//Bill To, Ship To and Vendor details:==
var i_Subsidiary = obj_purchase_order.getValue({ fieldId: 'subsidiary' });
var obj_Subsidiary = record.load({ type: record.Type.SUBSIDIARY, id: i_Subsidiary ,isDynamic: true});
var s_Subsidiary_Name = obj_Subsidiary.getValue({ fieldId: 'name' });
var s_bill_to_address = obj_Subsidiary.getValue({ fieldId: 'mainaddress_text' });//search.lookupFields({type: search.Type.SUBSIDIARY,id: parseInt(i_Subsidiary),columns: ['addrtext']});///obj_purchase_order.getValue({ fieldId: 'billaddress' });
s_bill_to_address = s_bill_to_address.toString().replace(s_Subsidiary_Name,'');
s_bill_to_address = xmlrec.escape({ xmlText : s_bill_to_address });
var i_subsidiary_logo = obj_Subsidiary.getValue({ fieldId: 'logo' });
var s_subsidiary_logo_id = file.load({ id: parseInt(i_subsidiary_logo) });
log.debug('s_subsidiary_logo_id URL:=='+s_subsidiary_logo_id.url);
s_Image = xmlrec.escape({ xmlText : s_subsidiary_logo_id.url });
if(parseInt(i_Subsidiary) == parseInt(36) || parseInt(i_Subsidiary) == parseInt(37))//if sub id SEZ and NON SEZ
{
s_Subsidiary_Name = s_Subsidiary_Name.toString().split(',');
log.debug('s_Subsidiary_Name[0]',s_Subsidiary_Name[0]);
log.debug('s_Subsidiary_Name[1]',s_Subsidiary_Name[1]);
s_Subsidiary_Name = s_Subsidiary_Name[0] .toString().toUpperCase();
s_Subsidiary_Name = xmlrec.escape({ xmlText : s_Subsidiary_Name });
}
else
{
s_Subsidiary_Name = s_Subsidiary_Name .toString().toUpperCase();
s_Subsidiary_Name = xmlrec.escape({ xmlText : s_Subsidiary_Name });
}
var s_bill_add3, s_bill_add2, s_bill_add1, s_bill_add1, s_bill_state, i_bill_zip;
var s_sub_add1, s_sub_add2, s_sub_add3, s_sub_city, s_sub_state, s_sub_zip;
var s_state_name;
var purchaseorderSearchObj = search.create({
type: "purchaseorder",
filters:
[
["type","anyof","PurchOrd"],
"AND",
["subsidiary","anyof",i_Subsidiary],
"AND",
["mainline","is","T"],
"AND",
["internalid","anyof",i_rec_id]
],
columns:
[
search.createColumn({ name: "address1",join: "shippingAddress",label: "Address 1" }),
search.createColumn({ name: "address2", join: "shippingAddress",label: "Address 2" }),
search.createColumn({ name: "address3",join: "shippingAddress", label: "Address 3" }),
search.createColumn({ name: "city", join: "shippingAddress",label: "City" }),
search.createColumn({ name: "state", join: "shippingAddress", label: "State/Province" }),
search.createColumn({ name: "zip", join: "shippingAddress",label: "Zip" }),
search.createColumn({ name: "city", join: "subsidiary",label: " City"}),
search.createColumn({ name: "address3", join: "subsidiary", label: " Address 3" }),
search.createColumn({ name: "address2",join: "subsidiary", label: " Address 2" }),
search.createColumn({ name: "address1",join: "subsidiary",label: " Address 1" }),
search.createColumn({ name: "state", join: "subsidiary",label: "State/Province" }),
search.createColumn({ name: "zip", join: "subsidiary",label: " Zip" })
]
});
var searchResultCount = purchaseorderSearchObj.runPaged().count;
log.debug("purchaseorderSearchObj result count",searchResultCount);
purchaseorderSearchObj.run().each(function(result)
{
s_sub_add1 = result.getValue({ name: "address1",join: "shippingAddress",label: "Address 1" });
s_sub_add1 = xmlrec.escape({ xmlText : s_sub_add1 });
log.debug('s_sub_add1=',s_sub_add1);
s_sub_add2 = result.getValue({ name: "address2", join: "shippingAddress",label: "Address 2" });
s_sub_add2 = xmlrec.escape({ xmlText : s_sub_add2 });
log.debug('s_sub_add2=',s_sub_add2);
s_sub_add3 = result.getValue({ name: "address3",join: "shippingAddress", label: "Address 3" });
s_sub_add3 = xmlrec.escape({ xmlText : s_sub_add3 });
log.debug('s_sub_add3=',s_sub_add3);
s_sub_city = result.getValue({ name: "city", join: "shippingAddress",label: "City" });
s_sub_city = xmlrec.escape({ xmlText : s_sub_city });
log.debug('s_sub_city=',s_sub_city);
s_sub_state = result.getValue({ name: "state", join: "shippingAddress", label: "State/Province" });
s_sub_state = xmlrec.escape({ xmlText : s_sub_state });
log.debug('s_sub_state=',s_sub_state);
s_sub_zip = result.getValue({ name: "zip", join: "shippingAddress",label: "Zip" });
s_sub_zip = xmlrec.escape({ xmlText : s_sub_zip });
log.debug('s_sub_zip=',s_sub_zip);
s_bill_add_city = result.getValue({ name: "city", join: "subsidiary",label: " City"}),
s_bill_add_city = xmlrec.escape({ xmlText : s_bill_add_city });
log.debug('s_bill_add_city=',s_bill_add_city);
s_bill_add3 = result.getValue({ name: "address3", join: "subsidiary", label: " Address 3" }),
s_bill_add3 = xmlrec.escape({ xmlText : s_bill_add3 });
log.debug('s_bill_add3=',s_bill_add3);
s_bill_add2 = result.getValue({ name: "address2",join: "subsidiary", label: " Address 2" }),
s_bill_add2 = xmlrec.escape({ xmlText : s_bill_add2 });
log.debug('s_bill_add2=',s_bill_add2);
s_bill_add1 = result.getValue({ name: "address1",join: "subsidiary",label: " Address 1" }),
s_bill_add1 = xmlrec.escape({ xmlText : s_bill_add1 });
log.debug('s_bill_add1=',s_bill_add1);
s_bill_state = result.getValue({ name: "state", join: "subsidiary",label: "State/Province" }),
s_bill_state = xmlrec.escape({ xmlText : s_bill_state });
log.debug('s_bill_state=',s_bill_state);
if(s_sub_state)
{
var stateSearchObj = search.create({
type: "state",
filters:
[
["shortname","is",s_sub_state]
],
columns:
[
search.createColumn({name: "fullname", label: "Full Name"}),
search.createColumn({name: "shortname", label: "Short Name"})
]
});
var searchResultCount = stateSearchObj.runPaged().count;
log.debug("stateSearchObj result count",searchResultCount);
stateSearchObj.run().each(function(result)
{
s_state_name = result.getValue({ name: "fullname",label: "Full Name" });
s_state_name = xmlrec.escape({ xmlText : s_state_name });
log.debug('s_state_name====',s_state_name);
});
}
i_bill_zip = result.getValue({ name: "zip", join: "subsidiary",label: " Zip" })
i_bill_zip = xmlrec.escape({ xmlText : i_bill_zip });
log.debug('i_bill_zip=',i_bill_zip);
});
var s_vendor_gst_no = obj_purchase_order.getText({ fieldId: 'entitytaxregnum' });
var s_sub_reg_gst_no = obj_purchase_order.getText({ fieldId: 'subsidiarytaxregnum' });
s_sub_reg_gst_no = s_sub_reg_gst_no.toString().split(' ');
var s_ship_to_address = obj_purchase_order.getValue({ fieldId: 'shipaddress' });
s_ship_to_address = xmlrec.escape({ xmlText : s_ship_to_address });
var i_po_contact = obj_purchase_order.getValue({ fieldId: 'custbody_ind_po_pmuser' });
i_po_contact = xmlrec.escape({ xmlText : i_po_contact });
var fieldLookUp_emp, i_emp_email;
if(i_po_contact)
{
fieldLookUp_emp = search.lookupFields({type: search.Type.EMPLOYEE,id: parseInt(i_po_contact),columns: ['email']});
i_emp_email = fieldLookUp_emp.email;
i_emp_email = xmlrec.escape({ xmlText : i_emp_email });
}
if(!i_emp_email)
i_emp_email = ' ' ;
var i_po_vendor_id = obj_purchase_order.getValue({ fieldId: 'entity' });
i_po_vendor_id = xmlrec.escape({ xmlText : i_po_vendor_id });
var i_po_pr_reference = obj_purchase_order.getValue({ fieldId: 'custbody_ind_pr_reference_no' });
i_po_pr_reference = xmlrec.escape({ xmlText : i_po_pr_reference });
log.debug({ title: 'Debug Entry',details: 's_bill_to_address:== ' + s_bill_to_address + ' s_vendor_gst_no:== ' + s_vendor_gst_no
+ ' s_sub_reg_gst_no:== ' + s_sub_reg_gst_no + ' s_ship_to_address:== ' + s_ship_to_address
+ ' i_po_contact:== ' + i_po_contact + ' i_po_vendor_id:== ' + i_po_vendor_id
+ ' i_po_pr_reference:== ' + i_po_pr_reference});
var obj_vendor = record.load({ type: record.Type.VENDOR, id: i_po_vendor_id ,isDynamic: true});
var i_vendor_id = obj_vendor.getValue({ fieldId: 'entityid' });
i_vendor_id = xmlrec.escape({ xmlText : i_vendor_id });
var arr_vendor = i_vendor_id.toString().split(' ');
var s_vendor_name = obj_vendor.getValue({ fieldId: 'companyname' });
s_vendor_name = xmlrec.escape({ xmlText : s_vendor_name });
var s_vendor_address = obj_vendor.getValue({ fieldId: 'defaultaddress' });
s_vendor_address = xmlrec.escape({ xmlText : s_vendor_address });
var i_vendor_phone_no = obj_vendor.getValue({ fieldId: 'phone' });
i_vendor_phone_no = xmlrec.escape({ xmlText : i_vendor_phone_no });
var s_vendor_email_address = obj_vendor.getValue({ fieldId: 'email' });
s_vendor_email_address = xmlrec.escape({ xmlText : s_vendor_email_address });
log.debug({ title: 'Debug Entry',details: 'i_vendor_id:== ' + i_vendor_id + ' s_vendor_name:== ' + s_vendor_name
+ ' s_vendor_address:== ' + s_vendor_address + ' i_vendor_phone_no:== ' + i_vendor_phone_no
+ ' s_vendor_email_address:== ' + s_vendor_email_address });
var i_line_cnt_add = obj_vendor.getLineCount({sublistId: 'addressbook' });
var s_default_vendor_add, s_default_vendor_phone_no,s_default_add1,s_default_city, s_default_state, i_default_pin_no, s_default_add2;
var vendor_s_state_name;
for (var t_add = 0; t_add < i_line_cnt_add; t_add++)
{
obj_vendor.selectLine({ sublistId: 'addressbook',line: t_add });
var b_default_shipping_add = obj_vendor.getSublistValue({ sublistId: 'addressbook', fieldId: 'defaultshipping', line: t_add });
var addressSubrecord = obj_vendor.getCurrentSublistSubrecord({ sublistId: 'addressbook', fieldId: 'addressbookaddress' });
var s_vendor_add = addressSubrecord.getValue({ fieldId: 'addrtext' });
s_vendor_add = xmlrec.escape({ xmlText : s_vendor_add });
if(b_default_shipping_add == true)
{
s_default_vendor_add = addressSubrecord.getValue({ fieldId: 'addrtext' });
s_default_vendor_add = xmlrec.escape({ xmlText : s_default_vendor_add });
s_default_vendor_phone_no = addressSubrecord.getValue({ fieldId: 'addrphone' });
s_default_vendor_phone_no = xmlrec.escape({ xmlText : s_default_vendor_phone_no });
s_default_add1 = addressSubrecord.getValue({ fieldId: 'addr1' });
s_default_add1 = xmlrec.escape({ xmlText : s_default_add1 });
log.debug('s_default_add1:==', s_default_add1);
s_default_add2 = addressSubrecord.getValue({ fieldId: 'addr2' });
s_default_add2 = xmlrec.escape({ xmlText : s_default_add2 });
log.debug('s_default_add2:==', s_default_add2);
s_default_city = addressSubrecord.getValue({ fieldId: 'city' });
s_default_city = xmlrec.escape({ xmlText : s_default_city });
log.debug('s_default_city:==', s_default_city);
s_default_state = addressSubrecord.getValue({ fieldId: 'dropdownstate' });
s_default_state = xmlrec.escape({ xmlText : s_default_state });
log.debug('s_default_state:==', s_default_state);
if(s_default_state)
{
var stateSearchObj = search.create({
type: "state",
filters:
[
["shortname","is",s_default_state]
],
columns:
[
search.createColumn({name: "fullname", label: "Full Name"}),
search.createColumn({name: "shortname", label: "Short Name"})
]
});
var searchResultCount = stateSearchObj.runPaged().count;
log.debug("stateSearchObj result count",searchResultCount);
stateSearchObj.run().each(function(result)
{
vendor_s_state_name = result.getValue({ name: "fullname",label: "Full Name" });
vendor_s_state_name = xmlrec.escape({ xmlText : vendor_s_state_name });
log.debug('vendor_s_state_name====',vendor_s_state_name);
});
}
i_default_pin_no = addressSubrecord.getValue({ fieldId: 'zip' });
i_default_pin_no = xmlrec.escape({ xmlText : i_default_pin_no });
log.debug('i_default_pin_no:==', i_default_pin_no);
}
}//end of for (var t_add = 0; t_add < i_line_cnt_add; t_add++)
var d_po_delivery_date = obj_purchase_order.getValue({ fieldId: 'duedate' });
if(d_po_delivery_date)
{
var d_po_delivery_date_month = d_po_delivery_date.getMonth() + 1;
var d_po_delivery_Date = d_po_delivery_date.getDate();
var d_po_delivery_date_year = d_po_delivery_date.getFullYear();
if(d_po_delivery_Date < 10)
d_po_delivery_Date = '0' + d_po_delivery_Date;
if(d_po_delivery_date_month < 10)
d_po_delivery_date_month = '0' + d_po_delivery_date_month;
d_po_delivery_date = d_po_delivery_date_month + '/' + d_po_delivery_Date + '/' + d_po_delivery_date_year;
d_po_delivery_date = xmlrec.escape({ xmlText : d_po_delivery_date });
}//end of if(d_po_delivery_date)
var s_po_currency = obj_purchase_order.getText({ fieldId: 'currency' });
s_po_currency = xmlrec.escape({ xmlText : s_po_currency });
var s_payment_terms = obj_purchase_order.getText({ fieldId: 'terms' });
s_payment_terms = xmlrec.escape({ xmlText : s_payment_terms });
var i_po_subsidiary = obj_purchase_order.getValue({ fieldId: 'subsidiary' });
i_po_subsidiary = xmlrec.escape({ xmlText : i_po_subsidiary });
var fieldLookUp = search.lookupFields({type: search.Type.SUBSIDIARY,id: parseInt(i_po_subsidiary),columns: ['custrecord_in_mobile_number','custrecord_ind_p2pteam_email','custrecord_ind_p2pcontactno']});
var i_sub_mobile_no = fieldLookUp.custrecord_ind_p2pcontactno;
i_sub_mobile_no = xmlrec.escape({ xmlText : i_sub_mobile_no });
var s_sub_email_add = fieldLookUp.custrecord_ind_p2pteam_email;
s_sub_email_add = xmlrec.escape({ xmlText : s_sub_email_add });
log.debug({ title: 'Debug Entry',details: 'i_line_cnt_add:== ' + i_line_cnt_add + ' d_po_delivery_date:== ' + d_po_delivery_date
+ ' s_po_currency:== ' + s_po_currency + ' s_payment_terms:== ' + s_payment_terms
+ ' i_po_subsidiary:== ' + i_po_subsidiary + ' i_sub_mobile_no:== ' + i_sub_mobile_no
+ ' s_sub_email_add:== ' + s_sub_email_add +' b_default_shipping_add:== '+ b_default_shipping_add});
var s_contact_name, i_contact_role;
var contactSearchObj = search.create({
type: "contact",
filters:
[
["vendor.internalid","anyof",i_po_vendor_id]
],
columns:
[
search.createColumn({name: "internalid", label: "Internal ID"}),
search.createColumn({ name: "entityid",sort: search.Sort.ASC, label: "Name" }),
search.createColumn({name: "contactrole", label: "Role"})
]
});
var searchResultCount = contactSearchObj.run().getRange(0, 1000);
if(searchResultCount)
{
for(var t_loop = 0 ; t_loop < searchResultCount.length ; t_loop++)
{
i_contact_role = searchResultCount[t_loop].getValue({name: "contactrole", label: "Role"});
// if(i_contact_role == '-10')
s_contact_name = searchResultCount[t_loop].getValue({ name: "entityid"});
}//end of for loop
}//end of if(searchResultCount)
if(!s_contact_name)
s_contact_name = '';
var i_delivery_terms = obj_purchase_order.getText({ fieldId: 'incoterm' });
i_delivery_terms = xmlrec.escape({ xmlText : i_delivery_terms });
var s_special_instruction = obj_purchase_order.getValue({ fieldId: 'custbody_ind_delivery_schedule' });
s_special_instruction = xmlrec.escape({ xmlText : s_special_instruction });
var s_amount_of_words = obj_purchase_order.getValue({ fieldId: 'custbody_amount_in_words' });
s_amount_of_words = xmlrec.escape({ xmlText : s_amount_of_words });
log.debug({ title: 'Debug Entry',details: 's_default_vendor_add:== ' + s_default_vendor_add + 's_default_vendor_phone_no:== ' + s_default_vendor_phone_no
+ ' s_contact_name:== ' + s_contact_name + ' i_delivery_terms:== ' + i_delivery_terms
+ ' s_special_instruction:== ' + s_special_instruction + ' s_amount_of_words:== ' + s_amount_of_words
+ ' i_contact_role:== ' + i_contact_role });
var s_quote_ref = obj_purchase_order.getValue({ fieldId: 'custbody_ind_quote_reference_no' });
if(s_quote_ref)
s_quote_ref = xmlrec.escape({ xmlText : s_quote_ref });
var i_warranty = obj_purchase_order.getValue({ fieldId: 'custbody_ind_warranty' });
var d_quote_date = obj_purchase_order.getValue({ fieldId: 'custbody_ind_quote_date' });
if(d_quote_date)
{
var d_quote_date_month = d_quote_date.getMonth() + 1;
var d_quote_date_Date = d_quote_date.getDate();
var d_quote_date_Year = d_quote_date.getFullYear();
if(d_quote_date_Date < 10)
d_quote_date_Date = '0' + d_quote_date_Date;
if(d_quote_date_month < 10)
d_quote_date_month = '0' + d_quote_date_month;
d_quote_date = d_quote_date_month + '/' + d_quote_date_Date + '/' + d_quote_date_Year;
d_quote_date = xmlrec.escape({ xmlText : d_quote_date });
}
var f_cgst = obj_purchase_order.getValue({ fieldId: 'taxtotal6' });
var f_sgst = obj_purchase_order.getValue({ fieldId: 'taxtotal7' });
var f_igst = obj_purchase_order.getValue({ fieldId: 'taxtotal5' });
var f_non_recovery_igst = obj_purchase_order.getValue({ fieldId: 'taxtotal9' });
if(!s_quote_ref)
s_quote_ref = '';
if(!i_warranty)
i_warranty = '';
if(!d_quote_date)
{
d_quote_date = '';
}
var i_item_cnt = obj_purchase_order.getLineCount({ sublistId: 'item' });
var i_expense_cnt = obj_purchase_order.getLineCount({ sublistId: 'expense' });
var i_tax_details = obj_purchase_order.getLineCount({ sublistId: 'taxdetails' });
if(!s_default_add1)
s_default_add1 = '';
if(!s_default_city)
s_default_city = '';
if(!vendor_s_state_name)
vendor_s_state_name = '';
if(!i_default_pin_no)
i_default_pin_no = '';
if(!s_default_vendor_phone_no)
s_default_vendor_phone_no = '';
log.debug({ title: 'Debug Entry',details: 'i_item_cnt:== ' + i_item_cnt + 'i_expense_cnt:== ' + i_expense_cnt
+ 'i_tax_details:== ' + i_tax_details });
//Header HTML Details:==
htmlMsg = htmlMsg + "<table>";
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td width=\"30%\" align=\"right\" font-family=\"sans-serif\" font-size=\"10\">Page <pagenumber\/> of <totalpages\/><\/td>";
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td>";
htmlMsg = htmlMsg + "<p><img width=\"150\" height=\"30\" align=\"left\" src=\"" + s_Image + "\"></img></p>";
htmlMsg = htmlMsg + "</td>";
htmlMsg = htmlMsg + "<td><br/>";
htmlMsg = htmlMsg + "<table>";
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td font-size=\"18\" align=\"left\" style=\"white-space: nowrap\"><b>PURCHASE ORDER </b></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
htmlMsg = htmlMsg + "<td></td>";
var i_Approval_Status = obj_purchase_order.getValue({fieldId:'approvalstatus'});
var i_po_amendement_no = obj_purchase_order.getValue({fieldId:'custbody_ind_po_amendment_number'});
if(i_po_amendement_no)
{
var i_po_amendement_no_value = i_po_amendement_no.toString().split('_');
if(i_po_amendement_no_value[1] != 'V1.0')
{
if(parseInt(i_Approval_Status) == parseInt(2))
{
htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Number "+ i_po_tran_no +"</b><br/><b>Date </b>"+ d_po_date +"<br/><b>PO Amendment </b>"+i_po_amendement_no_value[1]+"</td>";
}
else
{
htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Number DRAFT</b><br/><b>Date </b>"+ d_po_date +"<br/><b>PO Amendment </b>"+i_po_amendement_no_value[1]+"</td>";
}
}
else
{
if(parseInt(i_Approval_Status) == parseInt(2))
{
htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Number "+ i_po_tran_no +"</b><br/><b>Date </b>"+ d_po_date +"</td>";
}
else
{
htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Number DRAFT</b><br/><b>Date </b>"+ d_po_date +"</td>";
}
}
}
if(!i_po_amendement_no)
{
if(parseInt(i_Approval_Status) == parseInt(2))
{
htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Number "+ i_po_tran_no +"</b><br/><b>Date </b>"+ d_po_date +"</td>";
}
else
{
htmlMsg = htmlMsg + "<td font-size=\"10\" align=\"left\" style=\"white-space: nowrap\"><b>Number DRAFT</b><br/><b>Date </b>"+ d_po_date +"</td>";
}
}
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg + "</table>";
htmlMsg = htmlMsg + "</td>";
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg +"</table>";
htmlMsg = htmlMsg + "<\/macro>";
htmlMsg = htmlMsg + "</macrolist>";
htmlMsg = htmlMsg + "</head>";
htmlMsg = htmlMsg + "<body header=\"header\" header-height=\"7em\" font-size=\"10pt\">";
htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\" >";
//Bill To, Ship To and Vendor HTML Details:==
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"1\" width=\"30%\">";
htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\" >";
if(s_bill_add1 && s_bill_add2 && s_sub_add3)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\"><b>Bill To<br/>"+s_Subsidiary_Name+"</b><br/>"+ s_bill_add1 + "<br/>" +s_bill_add2 +"<br/>"+s_bill_add3+"<br/>"+s_bill_add_city+' '+ s_bill_state +' '+ i_bill_zip+"<br/>Phone No:"+ i_sub_mobile_no +"<br/>E-mail- "+ s_sub_email_add +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
else if(s_bill_add1 && s_bill_add2 && !s_sub_add3)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\"><b>Bill To<br/>"+s_Subsidiary_Name+"</b><br/>"+ s_bill_add1 + "<br/>" +s_bill_add2 +"<br/>"+s_bill_add_city+' '+ s_bill_state +' '+ i_bill_zip+"<br/>Phone No:"+ i_sub_mobile_no +"<br/>E-mail- "+ s_sub_email_add +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
else if(s_bill_add1 && !s_bill_add2 && !s_sub_add3)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\"><b>Bill To<br/>"+s_Subsidiary_Name+"</b><br/>"+ s_bill_add1 +"<br/>"+s_bill_add_city+' '+ s_bill_state +' '+ i_bill_zip+"<br/>Phone No:"+ i_sub_mobile_no +"<br/>E-mail- "+ s_sub_email_add +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-top=\"none\" width=\"30%\" font-size=\"9\" align=\"left\" >GST : "+ s_sub_reg_gst_no[0] +"</td>";
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-left=\"none\" border-right=\"none\" border-bottom=\"none\" width=\"30%\" font-size=\"9\" align=\"left\" ></td>";
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg + "</table>";
htmlMsg = htmlMsg + "</td>";
htmlMsg = htmlMsg + "<td width=\"5%\"></td>";
htmlMsg = htmlMsg + "<td border=\"1\" width=\"30%\">";
htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\" >";
if(s_sub_add1 && s_sub_add2 && s_sub_add3)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\"><b>Ship To<br/>"+s_Subsidiary_Name+"</b><br/>"+ s_sub_add1 + "<br/>" +s_sub_add2 +"<br/>"+s_sub_add3+"<br/>"+s_sub_city+' '+ s_state_name +' '+s_sub_zip +"<br/>Phone No:"+ i_sub_mobile_no +"<br/>E-mail- "+ s_sub_email_add +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
else if(s_sub_add1 && s_sub_add2 && !s_sub_add3)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\"><b>Ship To<br/>"+s_Subsidiary_Name+"</b><br/>"+ s_sub_add1 + "<br/>" +s_sub_add2 +"<br/>"+s_sub_city+' '+ s_state_name +' '+s_sub_zip +"<br/>Phone No:"+ i_sub_mobile_no +"<br/>E-mail- "+ s_sub_email_add +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
else if(s_sub_add1 && !s_sub_add2 && !s_sub_add3)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\"><b>Ship To<br/>"+s_Subsidiary_Name+"</b><br/>"+ s_sub_add1 +"<br/>"+s_sub_city+' '+ s_state_name +' '+s_sub_zip +"<br/>Phone No:"+ i_sub_mobile_no +"<br/>E-mail- "+ s_sub_email_add +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-top=\"none\" width=\"30%\" font-size=\"9\" align=\"left\" >GST : "+ s_sub_reg_gst_no[0] +"</td>";
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-left=\"none\" border-right=\"none\" border-bottom=\"none\" width=\"30%\" font-size=\"9\" align=\"left\">Our Contact:<br /> "+ i_emp_email +"</td>";
htmlMsg = htmlMsg + "</tr>";
htmlMsg = htmlMsg + "</table>";
htmlMsg = htmlMsg + "</td>";
htmlMsg = htmlMsg + "<td width=\"5%\"></td>";
htmlMsg = htmlMsg + "<td border=\"1\" width=\"30%\">";
htmlMsg = htmlMsg + "<table border=\"0\" width=\"100%\" align=\"center\" >";
if(s_default_add1 && !s_default_add2)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\">Vendor ID: "+ arr_vendor[0] +"<br/>Vendor Name: "+ s_vendor_name +"<br/><br/>Address : "+ s_sub_add1 + "<br/>" +s_sub_add2 +"<br/>"+s_sub_add3+"<br/>"+s_sub_city+' '+ s_state_name +' '+s_sub_zip +"<br/>Phone : "+ s_default_vendor_phone_no +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
else if(s_default_add1 && s_default_add2)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\">Vendor ID: "+ arr_vendor[0] +"<br/>Vendor Name: "+ s_vendor_name +"<br/><br/>Address : "+ s_sub_add1 + "<br/>" +s_sub_add2 +"<br/>"+s_sub_city+' '+ s_state_name +' '+s_sub_zip +"<br/>Phone : "+ s_default_vendor_phone_no +"</td>";
htmlMsg = htmlMsg + "</tr>";
}else if(!s_default_add1 && s_default_add2)
{
htmlMsg = htmlMsg + "<tr>";
htmlMsg = htmlMsg + "<td border=\"0\" border-bottom=\"none\" width=\"100%\" font-size=\"9\" align=\"left\">Vendor ID: "+ arr_vendor[0] +"<br/>Vendor Name: "+ s_vendor_name +"<br/><br/>Address : "+ s_sub_add1 +"<br/>"+s_sub_city+' '+ s_state_name +' '+s_sub_zip +"<br/>Phone : "+ s_default_vendor_phone_no +"</td>";
htmlMsg = htmlMsg + "</tr>";
}
htmlMsg = htmlMsg + "<tr>";



Comments