<html><head><meta charset="utf-8"></head><body>
<link href="../StylesheetLibrary/payperioddashboardstyles.css" rel="Stylesheet" type="text/css">
<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="../JavaScriptLibrary/jquery1.6.2.min.js" type="text/javascript"></script>
<title>EEPRs</title>
<script language="javascript" type="text/javascript">
/************************************************
getParameters - function to handle the extraction
of the extraqs parameters
************************************************/
function getParameters(values, unescapeValues) {
//Taken from samples in the CRM SDK
var parameters = new Array();
var vals = ('?' == values.charAt(0) ? values.substr(1) : values).split("&");
for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
if (unescapeValues) {
parameters[unescape(vals[i][0])] = unescape(vals[i][1]);
}
else {
parameters[vals[i][0]] = vals[i][1];
}
}
return parameters;
}
/*** end getParameters ***/
function openPayperiodFee(feeId) {
Xrm.Utility.openEntityForm("cel_payperiodfee", feeId);
}
function loadData() {
var requestUrl = serverUrl + "/xrmservices/2011/OrganizationData.svc/cel_payperiodfeeSet?$select=cel_payperiodfeeId,cel_FeeParty,cel_name,cel_Quantity,cel_Amount,cel_ExtendedAmount,cel_TotaltoSendtoICP&$filter=cel_PayPeriod/Id eq (guid'" + payperiodId + "')";
// prompt("the url", requestUrl);
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: requestUrl,
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
var results = data.d["results"];
for (resultKey in results) {
var rowHTML = "<tr onclick=\"openPayperiodFee('" + results[resultKey].cel_payperiodfeeId + "')\">";
rowHTML += "<td>" + getFeePartyName(getVal("cel_FeeParty", results[resultKey])) + "</td>";
rowHTML += "<td>" + getVal("cel_name", results[resultKey]);
rowHTML += "<td>" + getVal("cel_Quantity", results[resultKey]);
rowHTML += "<td>" + getAmountValue(getVal("cel_Amount", results[resultKey]));
rowHTML += "<td>" + getVal("cel_ExtendedAmount", results[resultKey]);
rowHTML += "<td>" + getVal("cel_TotaltoSendtoICP", results[resultKey]);
rowHTML += "</tr>";
$("#resultsTable > tbody:last").append(rowHTML);
}
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
alert(XmlHttpRequest.status + "\n" + textStatus + "\n" + errorThrown);
}
});
}
function getAmountValue(objAmount) {
return (objAmount != null) ? objAmount.Value : "";
}
function getFeePartyName(objFeeParty) {
var feePartyName = '';
if (objFeeParty != null) {
if (objFeeParty.Value == '279140000')
feePartyName = "Celergo"
else if (objFeeParty.Value == '279140001')
feePartyName = "One Price"
else if (objFeeParty.Value == '279140002')
feePartyName = "ICP"
}
return feePartyName;
}
function getVal(field, fileData) {
if (fileData && fileData.hasOwnProperty(field)) {
var tmpData = "no data";
if (fileData[field] != null) {
if (fileData[field].hasOwnProperty("__metadata")) {
switch (fileData[field].__metadata.type) {
case "Microsoft.Crm.Sdk.Data.Services.EntityReference":
tmpData = fileData[field].Name;
break;
default:
tmpData = fileData[field];
break;
}
}
else {
tmpData = fileData[field];
}
}
else {
tmpData = " ";
}
return tmpData;
}
}
</script>
<table><tbody><tr><td>Click anywhere in the row to open the record</td></tr></tbody></table>
<table id="resultsTable" style="vertical-align: top;" border="1">
<tbody>
<tr>
<td style="width: 100px; font-weight: bold;">
Fee Party
</td>
<td style="width: 100px; font-weight: bold;">
Invoice Description
</td>
<td style="width: 100px; font-weight: bold;">
Celergo Quantity
</td>
<td style="width: 100px; font-weight: bold;">
Amount
</td>
<td style="width: 100px; font-weight: bold;">
Total to Bill to Client
</td>
<td style="width: 100px; font-weight: bold;">
Total to Send to ICP
</td>
</tr>
</tbody>
</table>
<script language="javascript" type="text/javascript">
var context = GetGlobalContext();
var serverUrl = context.getClientUrl();
var userId = context.getUserId();
var parameters = getParameters(location.search, true);
var payperiodId = parameters["id"] || "noid";
if (payperiodId != "noid") {
loadData();
}
else {
}
</script>
</body></html>
Hope it will Help!!
No comments:
Post a Comment