var eMessageBoxStyle = new Object(); eMessageBoxStyle.okOnly = 1; eMessageBoxStyle.okCancel = 2; eMessageBoxStyle.yesNo = 4; eMessageBoxStyle.yesNoCancel = 8; eMessageBoxStyle.information = 128; eMessageBoxStyle.question = 256; eMessageBoxStyle.exclamation = 512; eMessageBoxStyle.critical = 1024; eMessageBoxStyle.homeOffice = 2048; function getSoftwareControlsPath(software) { switch (software.toLowerCase()) { case "contacts": return "/applications/Automation/Contacts/Pages"; case "documentmanager": return "/applications/Automation/DocumentManager/Pages"; case "common": return "/applications/Common/pages"; case "tracking": return "/applications/Tracking/Pages"; case "workflow": return "/applications/Workflow/pages"; } } function validateAllowExtensionsFileUpload(filename) { var extensions = ''; if( extensions.length > 0) { extensions = extensions.split(','); filename = '' + filename; for (var i = 0; i < extensions.length; i++) { extensions[i] = extensions[i].trim(); if(extensions[i].length > 0) { if(extensions[i].substr(0, 1) != '.') extensions[i] = '.' + extensions[i]; if (filename.substr(filename.length - extensions[i].length, extensions[i].length).toLowerCase() == extensions[i].toLowerCase()) return true; } } messageBox("NotAllowAttachFileExtensions"); return false; } return true; } function messageBox(prompt, buttons, extraOptions) { var param = new Object(); var optionCheckBoxCaption = ""; var optionCheckBoxCookie = ""; var optionCheckBoxComments = ""; if (extraOptions!=undefined) { optionCheckBoxCaption = importData(extraOptions, "optionCheckBoxCaption"); optionCheckBoxCookie = importData(extraOptions, "optionCheckBoxCookie"); optionCheckBoxComments = importData(extraOptions, "optionCheckBoxComments"); } param.prompt = prompt; param.buttons = parseInt(buttons, 10); param.optionCheckBoxCaption = optionCheckBoxCaption; param.optionCheckBoxCookie = optionCheckBoxCookie; param.optionCheckBoxComments = optionCheckBoxComments; if (optionCheckBoxCaption!="") { var retVal = getSoftwareCookie("b90f03a0-5b3b-4027-b9ec-247c2d6ddaac", optionCheckBoxCookie); if (!((buttons & eMessageBoxStyle.yesNo)==eMessageBoxStyle.yesNo && retVal=="no")) { //Don't remember "NO" answer to DidgahConfirm if (retVal!=null) return retVal; } } try { return window.showModalDialog("/MessageBox.html?p=" + prompt + "&b=" + parseInt(buttons, 10), param, "dialogWidth:260px; dialogHeight:131px; resizable:no; scroll:no; status:no; center:yes; help:no;"); } catch(e) { var ret = "cancel"; if ((buttons & eMessageBoxStyle.okCancel) != 0 || (buttons & eMessageBoxStyle.yesNoCancel) != 0) ret = "cancel"; else if (buttons & eMessageBoxStyle.yesNo) ret = "no"; alert("Pop-up Blocker\nمرورگر شما (یا نرم‌افزارهای مشابه) منجر به عدم امکان عملکرد صحیح\nاین قسمت از سیستم می‌گردد\nلطفاً پس از رفع مشکل دوباره اقدام کنید و یا با مدیر سیستم تماس بگیرید"); return ret; } } function DidgahConfirm(message, icon, optionCheckBoxCookie, optionCheckBoxCaption, optionCheckBoxComments) { var extraOptions = undefined; if (message==undefined) message = "AreYouSure"; if (icon==undefined || isNaN(icon)) { optionCheckBoxComments = optionCheckBoxCaption; optionCheckBoxCaption = optionCheckBoxCookie; optionCheckBoxCookie = icon; icon = eMessageBoxStyle.question; } if (optionCheckBoxCaption==undefined) { optionCheckBoxCaption = "ثبت گزينه و عدم پرسش دوباره"; optionCheckBoxComments = "با انتخاب اين گزينه، پاسخ انتخابی شما به اين پرسش ذخيره خواهد شد و در دفعات آينده، به‌جای نمايش اين پنجره، همين انتخاب مدنظر قرار خواهد گرفت."; } if (optionCheckBoxCookie!=undefined) extraOptions = "optionCheckBoxCookie{(" + optionCheckBoxCookie + ")}optionCheckBoxCaption{(" + optionCheckBoxCaption + ")}optionCheckBoxComments{(" + optionCheckBoxComments + ")}"; return messageBox(message, eMessageBoxStyle.yesNo + icon, extraOptions)=="yes"; } function inputBox(prompt, defaultValue, inputCssClass, multiLine) { var param = new Object(); if (defaultValue==undefined) defaultValue = ""; if (inputCssClass=="" || inputCssClass==undefined) inputCssClass = "textInput"; param.prompt = prompt; param.multiLine = multiLine; param.defaultValue = defaultValue; param.inputCssClass = inputCssClass; return window.showModalDialog("/InputBox.html?p=" + prompt + "&m=" + (multiLine ? "1" : "0") + "&c=" + inputCssClass + "&d=" + toUTF8(defaultValue), param, "dialogWidth:320px; dialogHeight:165px; resizable:no; scroll:no; status:no; center:yes; help:no;"); } function showReferencedObject(referenceId, referenceFlag, referenceSoftwareGuid, alertId, extendedData) { if (referenceSoftwareGuid=="cc1361db-a8f4-48d6-bbb9-d714479d84f5") { } if (referenceSoftwareGuid=="7c48f1ee-18c0-4406-84b0-3ad426ce5aee") { switch (val(referenceFlag)) { case 1: showControlModal("110067&LetterId=" + referenceId); return true; case 2: showControlModal("110067&LetterInstanceId=" + referenceId); return true; case 3: showControlModal("110017&DraftId=" + referenceId); return true; case 29: showControlModal("110017&DraftInstanceId=" + referenceId); return true; case 61: showControlModal("110099&AnnouncementReceiverId=" + referenceId); return true; case 4: showControlModal("110082&MessageId=" + referenceId); return true; case 30: showControlModal("110082&MessageInstanceId=" + referenceId); return true; case 10: windowOpen("/applications/Automation/DocumentManager/pages/email/showEmail.aspx?" + referenceId, undefined, "location=no, titlebar=no, scrollbars=yes, resizable=yes"); return true; case 11: showControlModal("110023&EmailAccountID=" + referenceId); return true; case 5: showControlModal("110030&DeleteAlert=1&FaxInboxID=" + referenceId); return true; case 14: showControlModal("110087&PendingLetterId=" + referenceId); return true; case 55: showControlModal("110067&LetterInstanceId=" + referenceId + "&AlertId=" + alertId + "&TracePersonId=" + importData(extendedData, "tracePersonId")); return true; } } if (referenceSoftwareGuid=="b90f03a0-5b3b-4027-b9ec-247c2d6ddaac") { switch (val(referenceFlag)) { case 101: showFrozenObjectReference(referenceId); return true; case 13: processDeadlineAlert(referenceId); return true; } } if (referenceSoftwareGuid=="27b0f385-20dd-4446-885e-5f3bea7a80cf") { } if (referenceSoftwareGuid=="940829df-9ebe-46e6-874d-8f8c4c322f8e") { switch (val(referenceFlag)) { case 39: return (showControlModal("180000&flowNodeId=" + referenceId)=="true"); } } } function showModal(URL, data) { var retVal; try { retVal = window.showModalDialog("/GenericModal.aspx?" + URL, data, "dialogWidth:120px; dialogHeight:140px; dialogTop:0px; dialogLeft:0px; resizable:no; scroll:no; status:no; center:no; help:no;"); } catch(e) { if (messageBox("ErrorInOpeningModalWindow", eMessageBoxStyle.okCancel + eMessageBoxStyle.critical)=="cancel") alert(e.description); } if (retVal == "loginNotOK") { handleLoginNotOK(); } else return retVal; } function showControlModal(control, args) { if (args==null) args = new Object(); args.window = getRootWindowObject(); return showModal("/Loader.aspx?c=" + control, args); } function getRootWindowObject() { var win = null; try { var x = dialogArguments.window.location.href; win = dialogArguments.window; } catch (e) { win = window; } return win; } function showModalControl(control, data) { var retVal; try { retVal = window.showModalDialog("/GenericModal.aspx?" + URL, data, "dialogWidth:150px; dialogHeight:210px; dialogTop:0px; dialogLeft:0px; resizable:no; scroll:no; status:no; center:no; help:no;"); } catch(e) { if (messageBox("ErrorInOpeningModalWindow", eMessageBoxStyle.okCancel + eMessageBoxStyle.critical)=="cancel") alert(e.description); } if(retVal == "loginNotOK") handleLoginNotOK(); else return retVal; } function downloadTempFile(encryptedFilename, forceDownload, openNewWindow) { var url = "/TempDownloader.aspx?Filename=" + encryptedFilename + "&forceDownload=" + (forceDownload ? "1" : "0"); if (openNewWindow==true) { try { windowOpen(url); } catch(e) { window.open(url); } } else { var downloadWindow = document.createElement("iframe"); Container.appendChild(downloadWindow); downloadWindow.style.display = "none"; document.location.href = url; } } function downloadFile(fileID, forceDownload, downloadWindow, bpsc, extension) { if (forceDownload == null || forceDownload == undefined) forceDownload = true; var url = "/Downloader.aspx?Id=" + fileID + "&forceDownload=" + (forceDownload ? "1" : "0"); if (!(extension == null || extension == undefined)) url += "&ext=" + extension; var downloadAllowed = bpsc || false; if (!downloadAllowed) { messageBox("YouDontHaveAccessToDownloadFiles", eMessageBoxStyle.exclamation); return; } if (forceDownload) { if (downloadWindow == null || downloadWindow == undefined) window.location.href = url; else downloadWindow.location.href = url; } else { try { windowOpen(url, "_download", "location=no, titlebar=no, scrollbars=yes, resizable=yes"); } catch(e) { window.open(url, "_download", "location=no, titlebar=no, scrollbars=yes, resizable=yes"); } } } function handleHotkeys() { if (window.event.ctrlKey && window.event.keyCode==78 && window.parent.location.href.toLowerCase().indexOf("genericmodal.aspx")!=-1) { windowOpen("/"); window.event.returnValue=false; return; } if (event.srcElement.className=="textInput") { var hotkeyValue = null; switch (window.event.keyCode) { case 112: if (window.event.ctrlKey) { hotkeyValue = showControlModal("100010"); } else { hotkeyValue = ""; } break; case 113: hotkeyValue = ""; break; case 114: hotkeyValue = ""; break; case 115: hotkeyValue = ""; break; case 116: hotkeyValue = ""; break; case 117: hotkeyValue = ""; break; case 118: hotkeyValue = ""; break; case 119: hotkeyValue = ""; break; case 120: hotkeyValue = ""; break; case 121: hotkeyValue = ""; break; case 122: hotkeyValue = ""; break; case 123: hotkeyValue = ""; break; } if (hotkeyValue!=null) { insertTextAtCursor(window.event.srcElement.value, replaceString(hotkeyValue, "{خ}", "\n")); window.event.returnValue=false; } } } try { document.onhelp=new Function("return false;"); window.onhelp=new Function("return false;"); } catch(e) {} function getDirection() { return "rtl"; } function selectStaff(targetDropDown, workSectionDropDown, errorMessage, staffValidationFunction, softwareGuid) { var retVal = showControlModal("100018&softwareGuid=" + softwareGuid); if (retVal!="") { var selStaffId = importData(retVal, "id"); if (staffValidationFunction!=undefined) { eval("var staffIsValid = " + staffValidationFunction + "(" + selStaffId + ");"); if (!staffIsValid) return false; } for (i=0; i < cboAllStaff.children.length; i++) { if (importData(cboAllStaff.children[i].value, "id")==selStaffId) { workSectionDropDown.value = importData(cboAllStaff.children[i].value, "workSectionId"); workSectionDropDown.fireEvent("onchange"); targetDropDown.value = selStaffId; targetDropDown.fireEvent("onchange"); } } if (targetDropDown.value=="" && errorMessage!="") messageBox(errorMessage, eMessageBoxStyle.exclamation); } } function selectDeptFor(idBox, titleBox, selectableFlag, selectedId) { var url = "100014&selectableFlag=" + val(selectableFlag); if (selectedId!=undefined) url += "&selectedId=" + selectedId; else url += "&selectedId=" + idBox.value; var retVal = showControlModal(url); if (retVal!="") { if (titleBox!=undefined) idBox.value = importData(retVal, "id"); if (titleBox!=undefined) titleBox.value = importData(retVal, "title"); } return retVal; } function selectCostCenterFor(typeBox, titleBox, idBox) { retVal = showControlModal("100035&Select=1&costCenterTypeId=" + typeBox.value); if (retVal=="") return false; titleBox.value = importData(retVal, "title"); typeBox.value = importData(retVal, "typeId"); if (idBox!=undefined) idBox.value = importData(retVal, "id"); } function selectStaffFor(idBox, titleBox, selectedStaffId, idList, sessionVariable, softwareGuid, disableUnassignedStaff) { var url = "100018"; if (selectedStaffId!=undefined) url += "&selectedStaffId=" + selectedStaffId; else url += "&selectedStaffId=" + idBox.value; if (idList!=undefined && idList!="" && idList!=null){ url += "&StaffIdList=" + idList; } if (sessionVariable!=undefined) url += "&StaffIdListSessionVariable=" + sessionVariable; if (softwareGuid!=undefined) url += "&softwareGuid=" + softwareGuid; if (disableUnassignedStaff != undefined) if (disableUnassignedStaff) url += "&disableUnassignedStaff=1"; var retVal = showControlModal(url); if (retVal!="") { if (titleBox!=undefined) idBox.value = importData(retVal, "id"); if (titleBox!=undefined) titleBox.value = importData(retVal, "title"); } return retVal; } function selectUserFor(usernameBox, idBox, firstNameBox, lastNameBox, operationGuid) { var retVal = showControlModal("100060&OpenForSelect=1&OperationGuid=" + operationGuid); if (retVal=="") return false; usernameBox.value = importData(retVal, "username"); if (idBox!=undefined) idBox.value = importData(retVal, "id"); if (firstNameBox!=undefined) firstNameBox.value = importData(retVal, "firstName"); if (lastNameBox!=undefined) lastNameBox.value = importData(retVal, "lastName"); if (firstNameBox==lastNameBox && lastNameBox!=undefined) firstNameBox.value = importData(retVal, "firstName") + " " + importData(retVal, "lastName"); return retVal; } function replaceEditControlWithDisplayValue(editControl) { var displayValue = null; switch (editControl.tagName.toLowerCase()) { case "input": if (editControl.type=="radio" || editControl.type=="checkbox") displayValue = editControl.checked ? "بله" : "خير"; else if (editControl.type=="select") displayValue = getSelectText(editControl); else if (editControl.parentElement.innerHTML.indexOf("datePicker")!=-1) displayValue = editControl.parentElement.innerHTML.toLowerCase().indexOf("showtime")!=-1 ? getPersianShortDateTime(new Date(Date.parse(editControl.value))) : getPersianDateString(new Date(Date.parse(editControl.value))); else if (editControl.parentElement.innerHTML.indexOf("selectButton")!=-1) displayValue = editControl.parentElement.children(1).value; else displayValue = editControl.value; break; case "select": displayValue = getSelectText(editControl); break; case "textarea": displayValue = editControl.innerText; break; case "a": displayValue = editControl.outerHTML; break; case "editor": editControl = editControl.parentElement.parentElement.parentElement.parentElement.parentElement.children(0); displayValue = editControl.value; break; } if (displayValue != null) editControl.parentElement.innerHTML = displayValue; } function setFTPClientObjectAttributes(oFTP) { oFTP.ServerName = "chargoon"; oFTP.Port = 21; oFTP.Username = "chargoonUpload"; oFTP.Password = "chargoonUpload"; oFTP.RemoteDir = "didgahUpload"; try {oFTP.PassiveMode = true;} catch(e) {} } function showFrozenObjectReference(referenceID) { if(!DidgahConfirm("FrozenObjectAndAlertDeleteAfterUnfreeze.YouMustFreezeItAgain.AreYouSure", "frozenObjectView")) return false; var controlOpener = getServerResponse("Common", "GetFrozenReferenceOpenerControl", "FrozenObjectId=" + referenceID); showControlModal(controlOpener + "&frozenObjectId=" + referenceID + "&unfreezeObject=1"); } function processDeadlineAlert(referenceID) { var references = getServerResponse("Common", "ProcessDeadlineAlert", "DeadlineID=" + referenceID); showReferencedObject(importData(references, "referenceID"), importData(references, "referenceFlag"), importData(references, "referenceSoftwareGuid")); } function getStandardizeCharacters(inputString) { t = replaceString(inputString, "'", "`"); var persianKeyboardBehavior = "arabic"; if (persianKeyboardBehavior=="arabic") { re = /ى/i; while (t.search(re)!=-1) t=t.replace(re, "ي"); re = /ی/i; while (t.search(re)!=-1) t=t.replace(re, "ي"); re = /ک/i; while (t.search(re)!=-1) t=t.replace(re, "ك"); } else { re = /ي/i; while (t.search(re)!=-1) t=t.replace(re, "ی"); re = /ى/i; while (t.search(re)!=-1) t=t.replace(re, "ی"); re = /ك/i; while (t.search(re)!=-1) t=t.replace(re, "ک"); } return t; } var rootWindow = getRootWindowObject(); function setTrackingStatus(softwareGuid, tableKey, recordID, departmentID) { showControlModal("140002&SoftwareGuid=" + softwareGuid + "&TableKey=" + tableKey + "&RecordID=" + recordID + "&DepartmentID=" + departmentID); } function selectUser(excludeUserList, excludeGroupList, windowParams) { var sessionVarName = ""; var data = ""; if (excludeUserList != undefined && excludeUserList != "") data += "excludeUserList{(" + excludeUserList + ")}"; if (excludeGroupList != undefined && excludeGroupList != "") data += "excludeGroupList{(" + excludeGroupList + ")}"; if (data != "") { sessionVarName = getServerResponse("Common", "SetUserSelectionExcludeLists", null, data); if (sessionVarName == "") return; } return showControlModal("100019" + (sessionVarName == "" ? "" : "&excludeListsSessionVarName=" + sessionVarName) + "&" + windowParams); }