";
} else {
attachments += "
";
}
}
}
if (filenamearray.length > 0) {
for (var k = 0; k < filenamearray.length; k++) {
var attachstr = filenamearray[k].toString();
attachstr = CheckUrlSpecialChars(attachstr);
var attachstr = '"' + attachstr + '"';
if (attcount == 0) {
attcount = 1;
attachments += "
";
}
else {
attcount = parseInt(attcount, 10) + 1;
attachments += "
";
}
}
attachments += "
";
}
hdnattachcounts += "
";
if(attcount>0)
$j("#attachment-overlay").removeClass("d-none");
if (GetFieldIndex("axp_attachedfiles") != -1) {
var expAttField = GetActualFieldName("axp_attachedfiles");
var attValue = filenamearray.join(',');
var acFrNo = GetFieldsDcNo(expAttField);
var rowNum = GetDbRowNo(GetFieldsRowNo(expAttField), acFrNo);
var fldRowNo = GetFieldsRowNo(expAttField)
UpdateFieldArray(expAttField, rowNum, attValue, "parent");
CallSetFieldValue(expAttField, attValue);
}
}
//Function to remove the files which is uploaded attachments.
function RemoveNewFiles(filename) {
filename = ReplaceUrlSpecialChars(filename);
try {
ASB.WebService.RemoveNewFiles(filename, sid);
}
catch (exp) {
AxWaitCursor(false);
showAlertDialog("error", ServerErrMsg);
}
RemoveArrVal(filename, filenamearray);
var fld = $j("#attachment-overlay");
fld.hide();
ConstructAttachments();
adjustwin("100", window);
}
var attFileName = "";
var delFiles="";
//Function to call the webservice to remove the uploaded attachments.
function RemoveFile(fname, rid,delFileObj) {
if (typeof tstructCancelled != "undefined" && tstructCancelled.toLowerCase() === "cancelled") {
showAlertDialog("warning", eval(callParent('lcm[303]')));
return;
}
delFiles=delFileObj;
attFileName = ReplaceUrlSpecialChars(fname);
var cutMsg = eval(callParent('lcm[47]'));
var glType = eval(callParent('gllangType'));
var isRTL = false;
if (glType == "ar")
isRTL = true;
else
isRTL = false;
var RemoveFileCB = $.confirm({
theme: 'modern',
title: eval(callParent('lcm[155]')),
onContentReady: function () {
disableBackDrop('bind');
},
backgroundDismiss: 'false',
rtl: isRTL,
escapeKey: 'buttonB',
content: cutMsg,
buttons: {
buttonA: {
text: eval(callParent('lcm[164]')),
btnClass: 'btn btn-primary',
action: function () {
RemoveFileCB.close();
RemoveFileAfterConfirm();
}
},
buttonB: {
text: eval(callParent('lcm[192]')),
btnClass: 'btn btn-bg-light btn-color-danger btn-active-light-danger',
action: function () {
disableBackDrop('destroy');
return;
}
}
}
});
function RemoveFileAfterConfirm() {
var sxml = '
';
try {
ASB.WebService.RemoveAttachment(sxml, tstDataId, SuccessRemAttFile);
}
catch (exp) {
AxWaitCursor(false);
showAlertDialog("error", ServerErrMsg);
}
}
}
//Callback function for RemoveAttachedFiles.
function SuccessRemAttFile(result, eventArgs) {
if (CheckSessionTimeout(result))
return;
var myJSONObject = $j.parseJSON(result);
if (myJSONObject.message) {
var msg = myJSONObject.message[0].msg;
if (msg == "done") {
RemoveArrVal(attFileName, fileonloadarray);
//RemoveArrVal(attFileName, filenamearray);
const dropzone = document.querySelector("#attachment-overlay");
var myDropzone = Dropzone.forElement(dropzone);
myDropzone.removeFile(delFiles);
SetFormDirty(true);
}
else {
showAlertDialog("error", msg);
}
}
}
//Function to remove the file from the array , once removed from the path.
function RemoveArrVal(flname, arrayname) {
for (var i = 0; i < arrayname.length; i++) {
if (flname == arrayname[i]) {
arrayname.splice(i, 1);
break;
}
}
}
//Function to call the service to view the attachments.
function OpenAttachment(a, b, isNew) {
a = ReplaceUrlSpecialChars(a);
var ofXml = '';
try {
var ic = $j(".attachmentData a").length / 2;
if (b == 0 || b == "" || $j(".attachmentData .flagcount").length != ic || isNew) {
var str = "{\"command\":[{\"cmd\":\"openfile\",\"cmdval\":";
str = str + "\"" + a + "\",\"isatt\":\"T\"" + "}]}";
SuccChoicesOpenAtt(str, null);
}
else
ASB.WebService.ViewAttachment(ofXml, tstDataId, SuccChoicesOpenAtt);
}
catch (exp) {
AxWaitCursor(false);
showAlertDialog("error", ServerErrMsg);
}
}
//Callback function for ViewAttachment service call.
function SuccChoicesOpenAtt(result, eventArgs) {
if (CheckSessionTimeout(result))
return;
AssignLoadValues(result, "");
}
//Function to open a file which is attached newly.
//function OpenNewFile(openFileName) {
// var path = openFileName;
// if (path != "") {
// var na = "./openfile.aspx?fpath=" + path;
// var left = (screen.width / 2) - (500 / 2);
// var top = (screen.height / 2) - (400 / 2);
// window.open(na, "_blank");
// }
//}
//Function to clear the value from the html file control.
//function ClearInputFile() {
// // to clear the input file data [ supports only for IE ]
// var fileUploadCtrl = document.getElementById("filMyFile");
// var fileUploadClone = fileUploadCtrl.cloneNode(false);
// fileUploadClone.onchange = fileUploadCtrl.onchange;
// fileUploadCtrl.parentNode.replaceChild(fileUploadClone, fileUploadCtrl);
//}
//Function to find the duplicate attachment.
function FindDuplicate(fileupld) {
for (var j = 0; j < fileonloadarray.length; j++) {
if (fileupld == fileonloadarray[j])
return true;
}
for (var k = 0; k < filenamearray.length; k++) {
if (fileupld == filenamearray[j])
return true;
}
return false;
}
function EvalPrepared(fldName, rowNo, exprStr, exprType) {
if (exprStr != "")
exprStr = exprStr.replace(/♦/g, ",");
var fName = GetFieldsName(fldName);
wordlist = new Array();
var fldIdx = $j.inArray(fName, FNames);
var posStr = "";
if (fldIdx != -1) {
posStr = ExprPosArray[fldIdx];
}
//Add a function CheckEval to check for Eval() and return the expression
var estr = CheckEval(exprStr, rowNo);
if (estr != exprStr) {
posStr = "";
}
exprStr = estr;
if (posStr == "") {
posStr = PrepareExpression(fName, exprStr, exprType);
ExprPosArray[fldIdx] = posStr;
}
wordlist = new Array();
var startPos = posStr.toString().substring(0, posStr.toString().indexOf(","));
var endPos = posStr.toString().substring(posStr.toString().indexOf(",") + 1);
startPos = parseInt(startPos, 10);
endPos = parseInt(endPos, 10);
for (var i = startPos; i <= endPos; i++) {
var strExp = EWords[i];
var ch = strExp.split('');
var firstchar = ch[0];
if (firstchar == 'v') {
var fName = strExp.substring(1);
var fldVal = PrepareField(fName, rowNo);
strExp = fldVal;
}
else if (firstchar == 'c') {
//if tstruct field name and defined expression field name are not matched(case sensitive) then take the fields as lower case
var fName = strExp.substring(1);
fName = GetExactFieldName(fName);
strExp = 'c' + fName;
}
wordlist.push(strExp);
}
var fun = true;
for (var i = 0; i < wordlist.length; i++) {
if (wordlist[i] == "sFIELDCHANGED" || wordlist[i].toString().toLowerCase() == "sfieldchanged")
fun = false;
}
if (fun) {
EvalFun();
var s = GetExprString();
if (s == "")
return "";
try {
var res = eval(s);
}
catch (ex) {
try {
var res = eval("'" + s + "'");
}
catch (exp) {
res = "";
}
}
if (res == "Infinity") res = 0;
return res;
}
else {
return true;
}
}
function PrepareField(fldName, rowNo) {
var fldVal = "";
var templ = "";
if (fldName.toString().toLowerCase() == "activerow") {
fldVal = GetClientRowNo(AxActiveRowNo, AxActiveDc);
}
else if (fldName.toString().toLowerCase() == "activeprow") {
fldVal = GetClientRowNo(AxActivePRow, AxActivePDc);
}
else {
var dcNo = GetDcNo(fldName);
fldName = GetExactFieldName(fldName);
if (IsDcGrid(dcNo))
templ = fldName + GetClientRowNo(rowNo, dcNo) + "F" + dcNo;
else
templ = fldName + "000F" + dcNo;
if (document.getElementById(templ)) {
chrstate = false;
templ = templ;
}
else {
chrstate = false;
var dcNo = GetDcNo(fldName);
var clientRow = "";
if (IsDcPopGrid(dcNo)) {
clientRow = GetClientRowNo(AxActiveRowNo, AxActiveDc);
templ = fldName + clientRow + "F" + AxActiveDc;
}
else if (TstructHasPop && IsDcParentGrid(dcNo)) {
if (AxActivePRow != "" && AxActivePDc != "") {
clientRow = GetClientRowNo(AxActivePRow, AxActivePDc);
templ = fldName + clientRow + "F" + AxActivePDc;
}
else {
clientRow = GetClientRowNo(AxActiveRowNo, AxActiveDc);
templ = fldName + clientRow + "F" + AxActiveDc;
}
}
else if (IsDcGrid(dcNo) && rowNo == "000") {
clientRow = GetClientRowNo(AxActiveRowNo, dcNo);
templ = fldName + clientRow + "F" + dcNo;
}
else {
templ = fldName + rowNo + "F" + dcNo;
}
if (document.getElementById(templ)) {
templ = templ;
}
else {
//This condition is for fields in the unopened tabs. In this case the field is not available.
//If the field is a tstruct field and is a unopened tab field assign empty value else assign fieldname as value.
var fIdx = $j.inArray(fldName, FNames);
if (fIdx != -1)
fldv = "";
else
fldVal = fldName;
// begin for
for (var k = 0; k < varlist.length; k++) {
if (fldVal == varlist[k].toLowerCase()) {
chrstate = true;
fldVal = valuelist[k];
var dtlenth = fldVal.split('/');
//if (dtlenth[0].length == 2 && dtlenth[1].length == 2 && dtlenth[2].length == 4) {
if (dtlenth[0].length == 2 && (typeof dtlenth[1] != "undefined" && dtlenth[1].length == 2) && (typeof dtlenth[2] != "undefined" && dtlenth[2].length == 4)) {
s = 'd' + fldVal;
}
else if (isNaN(fldVal)) {
fldVal = 's' + fldVal;
}
else {
if (fldVal == "") fldVal = 0;
fldVal = fldVal;
fldVal = 'n' + fldVal;
if (fldVal.length == 1)
fldVal = 'n' + 0;
}
}
}
}
}
if (!chrstate) {
if (document.getElementById(templ)) {
fldVal = GetFieldValue(templ);
if (fldName == AxAutoGenFld && fldVal == "Auto")// //Refer Bug: HEA000077, Expression is autogenerate field and value is "Auto" so expression value should be empty.
fldVal = "";
var fldIdx = $j.inArray(fldName, FNames);
var fldDType = "";
if (fldIdx != -1)
fldDType = FDataType[fldIdx].toString();
if (fldDType != "") {
if (fldDType == "Date/Time") {
//var glCulture = eval(callParent('glCulture'));
//if (fldVal != "" && glCulture != undefined && glCulture == "en-us") {
// fldVal = GetDateStr(fldVal, "mm/dd/yyyy", "dd/mm/yyyy");
//}
////fldVal = "s" + fldVal;
fldVal = "d" + fldVal;
}
else if (fldDType == "Character") {
fldVal = "s" + fldVal;
}
else {
if (fldVal.length > 3) {
if (fldVal.indexOf(',') != -1)
fldVal = removeCommas(fldVal);
}
if (fldVal == "") fldVal = 0;
fldVal = 'n' + fldVal;
if (fldVal.length == 1)
fldVal = 'n' + 0;
}
}
else {
if (isNaN(fldVal)) {
fldVal = 's' + fldVal;
}
else {
if (fldVal.length > 3) {
if (fldVal.indexOf(',') != -1)
fldVal = removeCommas(fldVal);
}
if (fldVal == "") fldVal = 0;
fldVal = 'n' + fldVal;
if (fldVal.length == 1)
fldVal = 'n' + 0;
}
}
}
else {
templ = fldName;
if (fldVal != "") {
if (isNaN(fldVal))
t = 's';
else
t = 'n';
fldVal = t + fldVal;
}
}
}
}
for (var r = 0; r < funclist.length; r++) {
if (templ.toLowerCase() == funclist[r].toString().toLowerCase()) {
fldVal = 'f' + funclist[r];
chrstate = true;
break;
}
}
return fldVal;
}
function CheckSpecialCharInGlobalVar(str) {
str = str.replace(/;bkslh/g, "\\");
return str;
}
function PrepareExpression(FieldName, Expstr, exprtype) {
expressiontype = exprtype;
var i = 0;
var tem = '';
varlist = new Array();
valuelist = new Array();
wordlist = new Array();
var w = 0;
expFldname = FieldName;
var trid = transid;
var fIndx = FieldName.lastIndexOf("F");
var expression = Expstr;
if (Parameters.length > 1) {
for (var pki = 0; pki < Parameters.length; pki++) {
var list = Parameters[pki].toString();
list = list.split("~");
varlist[w] = list[0].toString();
valuelist[w] = CheckSpecialCharInGlobalVar(list[1].toString());
w++;
}
}
varlist[w] = "activerow";
valuelist[w] = AxActiveRowNo;
var tempvar = new Array();
var tempval = new Array();
var vi = 0;
var ji = 0;
var Isfound = false;
var tempcount = 0;
expression = TrimAll(expression);
expression = expression + " ";
var ch = expression.split('');
for (var j = 0; j < ch.length; j++) {
if (ch[j] == "{") {
if (bcount > 0) {
wordstring = wordstring + ch[j];
}
else {
constword = true;
wordstring = '';
}
bcount++;
continue;
}
if (ch[j] == "}") {
if (bcount == 1) {
constword = false;
s = "c" + wordstring;
wordlist[i] = s;
i++;
bcount = 0;
wordstring = '';
}
else {
bcount--;
wordstring = wordstring + ch[j];
}
continue;
}
if (constword) {
wordstring = wordstring + ch[j];
continue;
}
var t;
//begin checking for what type of data it is
if (isDelimiter(ch[j]) || isOperator(ch[j])) {
if (wordstring != "") {
wordstring = 'v' + wordstring;
wordlist[i] = wordstring;
i++;
}
wordstring = '';
}
if (ch[j] == "(") {
if (wordlist.length > 0) {
var fchar = wordlist[wordlist.length - 1];
fchar = fchar.substr(0, 1);
if (fchar == 'f' || fchar == 'v')
brackets = brackets + 'v';
else
brackets = brackets + '(';
}
else {
brackets = brackets + '(';
}
wordlist[i] = 'b(';
i++;
continue;
}
if (ch[j] == ")") {
if (brackets.charAt(brackets.length - 1) == "(") {
wordlist[i] = 'b)';
i++;
}
else {
wordlist[i] = 'e';
i++;
}
brackets = brackets.slice(0, -1);
continue;
}
if (isOperator(ch[j])) {
wordlist[i] = 'o' + ch[j];
i++;
continue;
}
if (ch[j] == ' ')
continue;
if (ch[j] == ',') {
wordlist[i] = 'l,';
i++;
wordstring = '';
continue;
}
wordstring = wordstring + ch[j];
}
var startIdx = EWords.length;
for (var eIdx = 0; eIdx < wordlist.length; eIdx++) {
EWords.push(wordlist[eIdx]);
}
var endIdx = EWords.length - 1;
return startIdx + "," + endIdx;
}
///Function to save the current tstruct as draft under the drafts folder.
function SaveAsDraft() {
// ShowDimmer(true);
try {
if (AxGlobalChange == true) {
var strTabDCStatus = getTabDCStatus();
ASB.WebService.SaveAsDraft(ChangedFields, ChangedFieldDbRowNo, ChangedFieldValues, DeletedDCRows, tst, tstDataId, strTabDCStatus, SuccessCallbackDrafts, OnSaveDraftException);
}
}
catch (exp) {
ShowDimmer(false);
AxWaitCursor(false);
}
}
function getTabDCStatus() {
var text = "";
for (i = 0; i < TabDCs.length; i++) {
text += "DC" + TabDCs[i] + "-" + TabDCStatus[i] + ",";
}
return text.slice(0, -1);
}
function SuccessCallbackDrafts(result, eventArgs) {
if (CheckSessionTimeout(result))
return;
ShowDimmer(false);
}
function OnSaveDraftException(result) {
AxWaitCursor(false);
ShowDimmer(false);
}
// function to get dependent array of auto generated field.BookingNo000F1substring(1)
function GetDependentArray() {
var depArray = new Array();
if (displayAutoGenVal != "true") {
// Below code will handle one autogenerated field per transaction
// if more than one autogenetated is present , needs to handle
if ($j(".autogen").length > 0) {
var fieldID = $j(".autogen")[0].id;
var fieldName = GetFieldsName(fieldID);
var fldIdx = GetFieldIndex(fieldName);
var depStr = "";
AxAutoGenFld = fieldName;
if (fldIdx != -1)
depStr = FldDependents[fldIdx].toString().substring(1);
if (depStr != "")
depArray = depStr.split(",");
}
}
return depArray
}
function ClearImageSrc(delObj) {
if (!IsFormDirty)
SetFormDirty(true);
var id = delObj.id;
var imgId = id.replace("del-", "").trim();
//if image control already has a image
$j("#" + imgId).hasClass("signaturePad") ? $j("#" + imgId).attr("src", "../AxpImages/signature.png") : "";//$j("#" + imgId).attr("src", "../AxpImages/upload.png");
$("#" + imgId).parents(".image-input").find(".delete-button").addClass("d-none");
$("#" + imgId).parents(".image-input").find(".imageFileUpload").removeClass("d-none");
$("#" + imgId).parents(".image-input").find(".profile-pic").addClass("d-none");
var rowNo = parseInt(GetFieldsRowNo(imgId), 10);
UpdateFieldArray(imgId, rowNo, "", "parent", "");
}
function CheckAllListItems(obj) {
//id = chkAll_ + chkid
var id = obj.id;
var checkAll = true;
if ($j("#" + id).prop("checked"))
checkAll = true;
else
checkAll = false;
var compId = id.replace("chkAll_", "").trim();
var showSelectedId = $j("#hideAll_" + compId);
var selectAllId = $j("#chkAll_" + compId);
var fldChkSep = GetChkSeparator(GetFieldsName(compId));
if (checkAll) {
var chkAllValue = '';
$j("input:checkbox[id='" + compId + "']").each(function () {
if ($j(this).prop("disabled") == false) {
$j(this).attr("checked", "checked");
$j(this).prop("checked", true);
var chkValue = $j(this).val();
if (chkAllValue == "")
chkAllValue = chkValue;
else
chkAllValue += fldChkSep + chkValue;
}
});
if (chkAllValue != '')
UpdateAssignedFld(compId);
//SetFieldValue(compId, chkAllValue, false, "SelectAll");
}
else {
$j("input:checkbox[id='" + compId + "']").each(function () {
$j(this).removeAttr("checked");
$j(this).prop("checked", false);
});
}
//when select all and show selected are checked show all the items in list
if (selectAllId.prop("checked") && showSelectedId.prop("checked")) {
ShowSelectedChkItems("hideAll_" + compId);
}
//when show selected is checked and uncheck the select all.
//remove checked from show selected.
if ((!selectAllId.prop("checked")) && showSelectedId.prop("checked")) {
showSelectedId.removeAttr("checked");
showSelectedId.prop("checked", false);
}
try {
AxAfterCheckAll();
}
catch (Ex) { }
if (typeof wsPerfEnabled != "undefined" && wsPerfEnabled)
CheckDependencyPerf(compId);
else
CheckDependency(compId);
}
function ShowSelectedChkItems(id) {
if (id != undefined) {
var checkAll = true;
if ($j("#" + id).prop("checked"))
checkAll = true;
else
checkAll = false;
var compId = id.replace("hideAll_", "").trim();
$j("input:checkbox[id='" + compId + "']").each(function () {
if (checkAll) {
if (!$j(this).attr('checked')) {
$j(this).parent().hide();
}
else {
$j(this).parent().show();
}
}
else {
$j(this).parent().show();
}
});
}
}
function SetDcCaption(dcNo, caption) {
//if (TabDCs.indexOf(dcNo) > -1) //indexof method does not support in IE8
if ($j.inArray(dcNo, TabDCs) > -1)
$j("#ank" + dcNo + " span.text").text(caption);
else
$j("#dcCaption" + dcNo).text(caption);
}
function SetDynamicDcCaptions(dcNo) {
dcNo = dcNo || "";
for (var i = 0; i < DCFrameNo.length; i++) {
if (dcNo == "" || dcNo == DCFrameNo[i]) {
var str = DCCaption[i].toString();
if (str.indexOf("{") != -1) {
var flds = GetWordsBetweenCurlies(str);
for (var j = 0; j < flds.length; j++) {
//if (flds[j].trim() == "rowcount") {
// str = str.replace("{" + flds[j] + "}", $j(".wrapperForGridData" + dcNo + " tbody tr").length);
//} else {
// str = str.replace("{" + flds[j] + "}", "");
//}
var fldName = GetExactFieldName(flds[j]);
var fldIdx = GetFieldIndex(fldName);
var value = "";
if (fldIdx != -1) {
var fldDcNo = GetDcNo(fldName);
if (IsGridField(fldName))
value = GetFieldValue(fldName + GetRowNoHelper(AxActiveRowNo) + "F" + fldDcNo);
else
value = GetFieldValue(fldName + "000F" + fldDcNo);
}
else
value = CheckGlobalVars(fldName);
str = str.replace("{" + flds[j] + "}", value);
}
SetDcCaption(DCFrameNo[i], str);
}
}
}
}
function GetWordsBetweenCurlies(str) {
var results = [], re = /{([^}]+)}/g, text;
while (text = re.exec(str)) {
results.push(text[1]);
}
return results;
}
function EvaluateDcCaption(depfName, fieldID) {
var depDcs = depfName.split(",");
for (var idx = 0; idx < depDcs.length; idx++) {
for (var i = 0; i < DCFrameNo.length; i++) {
if (DCFrameNo[i].toString() == depfName) {
var str = DCCaption[i].toString();
if (str.indexOf("{") != -1) {
var flds = GetWordsBetweenCurlies(str);
for (var j = 0; j < flds.length; j++) {
var fldName = GetExactFieldName(flds[j]);
var fldIdx = GetFieldIndex(fldName);
var value = "";
if (fldIdx != -1) {
EvaluateAxFunction(fldName, fldName);
var fldDcNo = GetDcNo(fldName);
var value = GetFieldValue(fldName + GetRowNoHelper(AxActiveRowNo) + "F" + fldDcNo);
}
else {
value = CheckGlobalVars(fldName);
}
str = str.replace("{" + flds[j] + "}", value);
}
SetDcCaption(DCFrameNo[i], str);
break;
}
}
}
}
}
var arrGlobalVars = new Array();
var arrGlobalVarValues = new Array();
function CheckGlobalVars(fldName) {
var pIndex = 0;
if (Parameters.length > 1 && arrGlobalVars.length == 0) {
for (var pki = 0; pki < Parameters.length; pki++) {
var list = Parameters[pki].toString();
list = list.split("~");
arrGlobalVars[pIndex] = list[0].toString();
arrGlobalVarValues[pIndex] = CheckSpecialCharInGlobalVar(list[1].toString());
pIndex++;
}
}
var idx = -1;
idx = $j.inArray(fldName, arrGlobalVars);
if (idx != -1)
return arrGlobalVarValues[idx];
else
return fldName;
}
//Updates the currency value from axpcurrencydec to the client arrays
function UpdateAxpCurrDec(fieldValue, calledFrom) {
var currFields = new Array(); var currDec = "";
currFields = fieldValue.split(',');
if (currFields.length > 0 && fieldValue != "") {
currDec = currFields[0].toString();
var fldIdx = -1;
for (var idx = 1; idx < currFields.length; idx++) {
var fName = currFields[idx];
if (currFields[idx].indexOf("~") > -1)
fName = currFields[idx].toString().substr(0, currFields[idx].indexOf('~'));
fldIdx = $j.inArray(fName, FNames);
//check this array
FDecimal[fldIdx] = currDec;
if (currFields[idx].indexOf("~") > -1)
currDec = currFields[idx].toString().substring((currFields[idx].toString().lastIndexOf('~') + 1));
//Refresh the fields in the axpcurrencydep to display the proper decimal values
if (calledFrom == "GetDep") {
currdecVal = "";
if (parseInt(currDec, 10) > parseInt(FDupDecimals[fldIdx], 10)) {
showAlertDialog("warning", 2031, "client", FCaption[fldIdx]);
currdecVal = FCaption[fldIdx];
return;
}
var fldId = "";
var dcNo = FldFrameNo[fldIdx];
if (IsGridField(fName)) {
var rowCnt = 0;
rowCnt = parseInt(GetDcRowCount(dcNo), 10);
for (var i = 1; i <= rowCnt; i++) {
var rowNo = GetClientRowNo(i, dcNo);
fldId = fName + rowNo + "F" + dcNo;
var newValue = NumericFldOnBlur(GetFieldValue(fldId), fldIdx);
SetFieldValue(fldId, newValue);
UpdateFieldArray(fldId, i, newValue, "parent");
}
}
else {
fldId = fName + "000F" + dcNo;
var newValue = NumericFldOnBlur(GetFieldValue(fldId), fldIdx);
SetFieldValue(fldId, newValue);
var fRowNo = GetFieldsRowNo(fldId);
var dbRowNo = GetDbRowNo(fRowNo, dcNo);
UpdateFieldArray(fldId, dbRowNo, newValue, "parent", "");
}
}
}
}
}
//In grid attachment, if reference is there, expression will contain the filepath.
//So no need of evaluating the expression
function GetReferExpr(exprFldName, clientRowNo, expression) {
var expr = expression;
if (expression.indexOf("@") > -1) {
expr = expression.substring(1, expression.indexOf("}"));
}
else if (expression.startsWith("{") > -1)
expr = expression.substring(1, expression.indexOf("}"));
else
expr = Evaluate(exprFldName, clientRowNo, expression, "expr");
return expr;
}
//var AxActiveAutoFld = "";
//function SetFastAutoComplete() {
// $j(".axlist").keypress(function (e) {
// var id = $(this).attr("id");
// var fldVal = GetFieldValue(id);
// AxActiveAutoFld = id;
// if (fldVal.length > 1) {
// var fldName = GetFieldsName(id);
// try {
// ASB.WebService.GetFastAjaxData(tstDataId, fldName, fldVal, SuccessFastAutoComp, OnException);
// }
// catch (exp) {
// AxWaitCursor(false);
// showAlertDialog("error", "Error: Name: " + exp.name + " Message: " + exp.message);
// }
// }
// });
//}
//function SuccessFastAutoComp(result, eventArgs)
//{
// if (result != "")
// {
// var fastItems = result.split("♣"); var i;
// var dtList = $j("#axlist-" + AxActiveAutoFld);
// for (i = 0;i -1) {
errMsg = errMsg.substring(0, errMsg.lastIndexOf("errfld") - 2);
errMsg = errMsg.replace("\",", "").replace("\" ,", "");
}
UpdateExceptionMessageInET(calledFrom+" Error : "+errMsg);
if(calledFrom=="Action"){
GetProcessTime();
GetTotalElapsTime();
}
showAlertDialog("error", errMsg);
if (calledFrom == "CancelTrans")
return;
var focusFldId = "";
if (errFld) {
var fldDetails = errFld.toString().split(",");
focusFldId = fldDetails[0];
var dcNo = GetDcNo(focusFldId)
var rowNo = GetClientRowNo(fldDetails[1], dcNo);
var fldName = focusFldId + rowNo + "F" + dcNo;
var focusFld = $j("#" + fldName);
if (focusFld.length > 0) {
focusFld.focus();
}
}
else if (AxActiveField != "") {
var rowNo = GetClientRowNo(AxActiveRowNo, AxActiveDc);
var fldName = AxActiveField + rowNo + "F" + AxActiveDc;
var focusFld = $j("#" + fldName);
if (focusFld.length > 0) {
focusFld.focus();
}
}
}
}
}
function getComntWf(showPopup) {
var recid = $j("#recordid000F0").val();
$.ajax({
url: 'tstruct.aspx/GetWrkFlwCmmt',
type: 'POST',
cache: false,
async: true,
data: JSON.stringify({ tid: tst, rid: recid }),
dataType: 'json',
contentType: "application/json",
success: function (data) {
var jsonstr = JSON.parse(data.d);
for (var k = 0; k < jsonstr.length; k++) {
var a = jsonstr[k];
for (var key in a) {
var temp = a[key];
delete a[key];
a[key.toLowerCase()] = temp;
}
jsonstr[k] = a;
}
var htmlTable = '| Date | Status | Comments | User |
'
for (var i = 0; i < jsonstr.length; i++) {
htmlTable += '';
htmlTable += '| ' + jsonstr[i].datetime + ' | ';
htmlTable += '' + (jsonstr[i].status == 'return' ? 'Returned' : jsonstr[i].status) + ' | ';
htmlTable += '' + jsonstr[i].comments + ' | ';
htmlTable += '' + jsonstr[i].username + ' | ';
htmlTable += '
';
}
htmlTable += '';
$("#tblWrk").addClass("d-none");
$("#tblWrk").html(htmlTable);
$("#collapseOneTable").html(htmlTable);
$("#consumergoods2").addClass("d-none");
$("#btnWrfSave").addClass("d-none");
$("#btnWrfCancel").addClass("d-none");
if (showPopup) {
$("#tblWrk").removeClass("d-none");
let myModal = new BSModal("modalIdWfHistory", "History", $("#tblWrk").html(), () => {
$("#tblWrk").addClass("d-none");
}, () => {
//hide callback
});
myModal.changeSize("lg");
myModal.hideFooter();
myModal.scrollableDialog();
}
},
error: function (data) {
console.log(data);
}
});
if (isWizardTstruct) {
$("body").append($("#consumergoods").detach());
}
}
function getWfUsrName(maxlevel, jsonStr) {
var usernames = [];
for (var i = 1; i < (parseInt(maxlevel) + 1); i++) {
var temp = "";
for (var j = 0; j < jsonStr.length; j++) {
if (jsonStr[j].lno == i && $j("#hdnWfLno").val() != "-1") {
if (temp == "")
temp += jsonStr[j].un;
else
temp += ',' + jsonStr[j].un;
} else if ($j("#hdnWfLno").val() == "-1") {
if (temp == "")
try {
temp += jsonStr[$j("#hdnWfELno").val()].un;
} catch (ex) {
temp += jsonStr[j].un;
}
}
}
usernames.push(temp);
}
return usernames;
}
function getWfStatus(maxlevel, jsonStr) {
var userSt = [];
var prevLabel = false;
for (var i = 1; i < (parseInt(maxlevel) + 1); i++) {
var temp = ""
if (!prevLabel)
temp = "Notapplicable";
for (var j = 0; j < jsonStr.length; j++) {
if (jsonStr[j].lno == i && $j("#hdnWfLno").val() != "-1") {
if (!prevLabel)
temp = "";
prevLabel = true;
if (temp == "") {
if (jsonStr[j].st.toLowerCase() == 'forwarded')
temp += 'reviewed';
else
temp += jsonStr[j].st;
}
else {
if (jsonStr[j].st.toLowerCase() == 'forwarded')
temp += ',' + 'reviewed';
else
temp += ',' + jsonStr[j].st;
}
} else if ($j("#hdnWfLno").val() == "-1") {
if (!prevLabel)
temp = "";
prevLabel = true;
if (temp == "") {
try {
if (jsonStr[$j("#hdnWfELno").val()].st.toLowerCase() == 'forwarded')
temp += 'reviewed';
else
temp += jsonStr[$j("#hdnWfELno").val()].st;
} catch (ex) {
if (jsonStr[j].st.toLowerCase() == 'forwarded')
temp += 'reviewed';
else
temp += jsonStr[j].st;
}
}
}
}
userSt.push(temp);
}
return userSt;
}
function getWfLevelUSsrs(lvlIdx, maxLevels, usernames, statusWrk, elno, levelJson) {
WrkflFlag = true;
ShowDimmer(true);
var recid = $j("#recordid000F0").val();
var htmlwrk = constructWrkHtml(maxLevels, usernames, statusWrk, elno, levelJson);
$(htmlwrk).insertAfter($(".icobtn"));
$("#stratWrkf").after($(".workflowMsg").detach());
popoverWrkFl();
}
function constructWrkHtml(maxLevels, usernames, statusWrk, elno, levelJson) {
var htmlwf = "";
var htmlwfNew = "";
var levelno = 0;
for (var l = 0; l < parseInt(maxLevels); l++) {
if (levelJson.length > levelno && $j("#hdnWfLno").val() == "-1") {
if (elno != levelJson[levelno].lno) {
levelno++;
}
}
if (typeof levelJson[levelno] != "undefined" && levelJson[levelno].lno != (l + 1) && $j("#hdnWfLno").val() != "-1")
continue;
var status = statusWrk[l].toLowerCase();
if (status.indexOf(',') > -1) {
status = status.split(',');
if (status.indexOf('pending') > -1)
status = "pending";
else
status = status[status.length - 1];
}
if (status.toLowerCase() == 'forwarded')
status = 'reviewed';
if (status.indexOf('pending') > -1 || status == '')
status = 'Pending';
if (status.indexOf('rejected') > -1) {
status = 'rejected';
}
if (statusWrk[l] == '') {
status = "Pending";
if (status.toLowerCase() == 'pending' && usernames[l] != "" && usernames[l] == user)
htmlwfNew = "Approval pending with you. "
else if (status.toLowerCase() == 'pending' && usernames[l] != "" && usernames[l] != user)
htmlwfNew = "Approval pending with " + usernames[l] + " ";
}
else if (typeof levelJson[levelno] != "undefined" && levelJson[levelno].lno == elno && parseInt(elno) == (l + 1)) {
var wfContent = $j("#lblStatus").text();
var wfContentUsr = wfContent.match(/'([^']+)'/g);
if (wfContentUsr != null) {
wfContentUsr.forEach(function (wfcu) {
if (wfcu.indexOf(".") > -1) {
let replwfcu = wfcu.replace(/[.]/ig, '♣');
wfContent = wfContent.replace(wfcu, replwfcu);
}
});
}
var lblst = wfContent.split('.');// $j("#lblStatus").text().split('.');
let wfUser = user.replace(/[.]/ig, '♣');
lblst.forEach(function (val) {
if ((val.startsWith("Pending ") || val.startsWith(" Pending ")) && val.indexOf("'" + wfUser + "'") > 0)
htmlwfNew = "Approval pending with you. ";
else if (val.startsWith("Returned ") && val.indexOf("'" + wfUser + "'") > 0)
htmlwfNew = val.replace(/'/g, "").replace(/♣/g, ".");
});
}
else {
if (status.toLowerCase() == 'pending' && usernames[l] == user)
htmlwfNew = "Approval pending with you. "
else if (status.toLowerCase() == 'pending' && usernames[l] != user) {
if (usernames[l].indexOf(',') > -1)
htmlwfNew = "Approval pending with " + usernames[l] + " ";
else
htmlwfNew = "Approval pending with " + usernames[l] + " ";
}
else if (status.toLowerCase() == 'approved' && usernames[l] == user) {
var wfContent = $j("#lblStatus").text();
var wfContentUsr = wfContent.match(/'([^']+)'/g);
if (wfContentUsr != null) {
wfContentUsr.forEach(function (wfcu) {
if (wfcu.indexOf(".") > -1) {
let replwfcu = wfcu.replace(/[.]/ig, '♣');
wfContent = wfContent.replace(wfcu, replwfcu);
}
});
}
//var lblst = $j("#lblStatus").text().split('.');//
var lblst = wfContent.split('.');
let wfUser = user.replace(/[.]/ig, '♣');
lblst.forEach(function (val) {
if (val.indexOf("'" + wfUser + "'") > 0)
htmlwfNew = val.replace(/'/g, "").replace(/♣/g, ".");;
});
}
else if (status.toLowerCase() == 'approved' && usernames[l] != user) {
htmlwfNew = $j("#lblStatus").text().replace(/'/g, "");
}
else if (status.toLowerCase() == 'rejected' && usernames[l] == user) {
htmlwfNew = "Approval rejected by you. "
}
else if (status.toLowerCase() == 'rejected' && usernames[l] != user) {
htmlwfNew = "Approval " + $j("#lblStatus").text().replace(/'/g, "");
}
else if (status.toLowerCase() == 'reviewed' && usernames[l] == user) {
htmlwfNew = "Approval Forwarded by you. "
}
else if (status.toLowerCase() == 'reviewed' && usernames[l] != user) {
htmlwfNew = "Approval " + $j("#lblStatus").text().replace(/'/g, "");
}
else if (status.toLowerCase() == 'autoforwarded' && usernames[l] == 'system')
htmlwfNew = $j("#lblStatus").text().replace(/'/g, "");
}
if (status === "notapplicable")
status = "NA";
//htmlwfNew = '' + htmlwfNew + '
';
for (var j = 0; j < levelJson.length; j++) {
if (levelJson[j].lno == elno && parseInt(elno) == (l + 1) && status == "Pending") {
htmlwf += 'more_vert
';
break;
}
}
levelno++;
}
htmlwfNew = '' + htmlwfNew + '
';
return htmlwfNew + htmlwf;
}
function capitalizeFirstLetter(status) {
return status.charAt(0).toUpperCase() + status.slice(1);
}
function popoverWrkFl() {
$('[data-toggle="popoverone"]').popover();
if ($("div[aria-expanded='false']")) {
$('#togglearrow').attr('title', 'Expand');
}
else {
$('#togglearrow').attr('title', 'Collapse');
}
}
function LimtCharacters(txtMsg, CharLength, indicator) {
chars = txtMsg.value.length;
if ((CharLength - chars) < 0)
document.getElementById(indicator).innerHTML = 0 + " " + "of 250";
else
document.getElementById(indicator).innerHTML = CharLength - chars + " " + "of 250";
if (chars > CharLength) {
txtMsg.value = txtMsg.value.substring(0, CharLength);
}
}
function popupFullPage(NavigationURL) {
callParentNew("splitfull()", 'function');
var frm = $j("#middle1", parent.document);
frm.attr("src", NavigationURL);
}
function setIviewNavigationData(paramsString, iviewName) {
if (iviewName != "") {
try {
ASB.WebService.SetIviewNavigationData(paramsString, iviewName, function () { });
} catch (ex) {
}
}
}
function callExecuteScriptApi(type,btnName,apiInfo)
{
if (actionCallFlag == actionCallbackFlag) {
actionCallFlag = Math.random();
$("#icons,#btnSaveTst,.BottomToolbarBar a").css({ "pointer-events": "auto" });
} else {
$("#icons,#btnSaveTst,.BottomToolbarBar a").css({ "pointer-events": "none" });
return;
}
AxWaitCursor(true);
ShowDimmer(true);
try {
ASB.WebService.CallExecuteScriptAPI(type, tstDataId,btnName,apiInfo, SuccessCallbackExecuteScriptApi, OnException);
}
catch (exp) {
actionCallbackFlag = actionCallFlag;
$("#icons,#btnSaveTst,.BottomToolbarBar a,.wizardNextPrevWrapper").css({ "pointer-events": "auto" });
AxWaitCursor(false);
ShowDimmer(false);
var execMess = exp.name + "^♠^" + exp.message;
showAlertDialog("error", 2030, "client", execMess);
}
}
function SuccessCallbackExecuteScriptApi(result, eventArgs) {
actionCallbackFlag = actionCallFlag;
$("#icons,#btnSaveTst,.BottomToolbarBar a,.wizardNextPrevWrapper").css({ "pointer-events": "auto" });
if (CheckSessionTimeout(result)) {
return;
}
let resJson=JSON.parse(result);
if(typeof resJson.result[0].error!="undefined")
{
if(typeof resJson.result[0].error.msg!="undefined")
showAlertDialog("error", resJson.result[0].error.msg);
else
showAlertDialog("error", resJson.result[0].error[0].msg);
}else{
showAlertDialog("success", resJson.result[0].msg);
}
ArrActionLog = "";
AxWaitCursor(false);
ShowDimmer(false);
}