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 "/DIDGAH/applications/Automation/Contacts/Pages"; case "documentmanager": return "/DIDGAH/applications/Automation/DocumentManager/Pages"; case "budgets": return "/DIDGAH/applications/bureau/Budgets/Pages"; case "financialaccounting": return "/DIDGAH/applications/bureau/FinancialAccounting/Pages"; case "common": return "/DIDGAH/applications/Common/pages"; case "payroll": return "/DIDGAH/applications/HumanResources/Payroll/Pages"; case "personnelsystem": return "/DIDGAH/applications/HumanResources/PersonnelSystem/Pages"; case "timekeeper": return "/DIDGAH/applications/HumanResources/Timekeeper/Pages"; case "commercial": return "/DIDGAH/applications/Logistics/Commercial/Pages"; case "logisticscommon": return "/DIDGAH/applications/Logistics/Common/Pages"; case "fixedassets": return "/DIDGAH/applications/Logistics/FixedAssets/Pages"; case "inventory": return "/DIDGAH/applications/Logistics/Inventory/Pages"; case "tracking": return "/DIDGAH/applications/Tracking/Pages"; case "workflow": return "/DIDGAH/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("/DIDGAH/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("/DIDGAH/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("110070&LetterId=" + referenceId); return true; case 2: showControlModal("110070&LetterInstanceId=" + referenceId); return true; case 3: showControlModal("110019&DraftId=" + referenceId); return true; case 29: showControlModal("110019&DraftInstanceId=" + referenceId); return true; case 61: showControlModal("110102&AnnouncementReceiverId=" + referenceId); return true; case 4: showControlModal("110085&MessageId=" + referenceId); return true; case 30: showControlModal("110085&MessageInstanceId=" + referenceId); return true; case 10: windowOpen("/DIDGAH/applications/Automation/DocumentManager/pages/email/showEmail.aspx?" + referenceId); return true; case 11: showControlModal("110026&EmailAccountID=" + referenceId); return true; case 5: showControlModal("110033&DeleteAlert=1&FaxInboxID=" + referenceId); return true; case 14: showControlModal("110090&PendingLetterId=" + referenceId); return true; case 55: showControlModal("110070&LetterInstanceId=" + referenceId + "&AlertId=" + alertId + "&TracePersonId=" + importData(extendedData, "tracePersonId")); return true; } } if (referenceSoftwareGuid=="320ec7e4-e040-4574-bf8b-278d7b56ee18") { } if (referenceSoftwareGuid=="eb8ec091-42e8-45a3-b13e-0423097bcb0d") { switch (val(referenceFlag)) { case 37: var retVal = showControlModal("310057&VoucherId=" + referenceId); return (retVal != 'CANCELLED'); } } if (referenceSoftwareGuid=="b90f03a0-5b3b-4027-b9ec-247c2d6ddaac") { switch (val(referenceFlag)) { case 101: showFrozenObjectReference(referenceId); return true; case 13: processDeadlineAlert(referenceId); return true; } } if (referenceSoftwareGuid=="b2dfd9ec-776f-4169-80fd-0888bf7de601") { } if (referenceSoftwareGuid=="66944d9c-31f4-4594-9407-4e1f64c079d9") { switch (val(referenceFlag)) { case 15: return (showControlModal("510006&id=" + referenceId)=="true"); case 35: return (showControlModal("510006&mode=cc&id=" + referenceId)=="true"); case 16: return (showControlModal("510011&id=" + referenceId)=="true"); case 36: return (showControlModal("510011&mode=cc&id=" + referenceId)=="true"); case 17: return (showControlModal("510016&id=" + referenceId)=="true"); case 37: return (showControlModal("510016&mode=cc&id=" + referenceId)=="true"); case 49: return (showControlModal("510019&id=" + referenceId)=="true"); case 60: return (showControlModal("510122&id=" + referenceId)=="true"); case 25: return (showControlModal("510071&decreeId=" + referenceId)=="true"); case 26: return (showControlModal("510071&decreeId=" + referenceId)=="true"); case 39: return (showControlModal("510071&decreeId=" + referenceId)=="true"); case 20: return (showControlModal("510071&decreeId=" + referenceId)=="true"); case 62: return (showControlModal("510072&personnelBaseId=" + referenceId + "&formMode=upgradeGroup")=="true"); case 61: return (showControlModal("510072&personnelBaseId=" + referenceId + "&formMode=summonResponse")=="true"); } } if (referenceSoftwareGuid=="0e80338a-135f-4f89-b9ae-85b2ee582656") { switch (val(referenceFlag)) { case 43: return (showControlModal("520037&id=" + referenceId)=="true"); case 23: return (showControlModal("520041&id=" + referenceId)=="true"); case 42: return (showControlModal("520045&id=" + referenceId)=="true"); case 49: return (showControlModal("520045&id=" + referenceId)=="true"); } } if (referenceSoftwareGuid=="d37ed890-d722-4ba9-bb0d-84e3ef3a8101") { switch (val(referenceFlag)) { case 1: showControlModal("340030&itemRequestId=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; case 2: showControlModal("340034&itemOrderID=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; case 3: showControlModal("340049&serviceRequestId=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; case 4: showControlModal("340052&serviceOrderID=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; } } if (referenceSoftwareGuid=="644c8c27-2422-4ecf-9308-0d33166b7160") { } if (referenceSoftwareGuid=="4de9e389-539d-4653-81d2-af2baf6a2a0e") { switch (val(referenceFlag)) { case 4: showControlModal("350048&operationRequestID=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; case 5: showControlModal("350048&operationRequestID=" + referenceId + "&isApprovalMode=1&isNewApproval=0&alertID=" + alertId); return true; } } if (referenceSoftwareGuid=="c27421b8-0f80-4e67-8fec-d49cec05a251") { switch (val(referenceFlag)) { case 4: showControlModal("330017&itemRequestId=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; case 7: showControlModal("330017&itemRequestId=" + referenceId + "&isApprovalMode=1&isNewApproval=1&alertID=" + alertId); return true; case 12: showControlModal("330017&itemRequestId=" + referenceId + "&isApprovalMode =1&isNewApproval=0&alertID=" + alertId); return true; case 8: showControlModal("330021&itemPermitId=" + referenceId + "&alertID=" + alertId); return true; case 13: showControlModal("330017&itemRequestId=" + referenceId + "&isApprovalMode=1&DeletedMode=1&isNewApproval=0&alertID=" + alertId); return true; case 14: showControlModal("330017&itemRequestId=" + referenceId + "&isApprovalMode=1&DeletedMode=1&isNewApproval=0&alertID=" + alertId); 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("/DIDGAH/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("/DIDGAH/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("/DIDGAH/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 openTempDownloadWindow(encryptedFilename, forceDownload, openNewWindow) { var downloadWindow = document.createElement("iframe"); Container.appendChild(downloadWindow); downloadWindow.style.display = "none"; var url = "/DIDGAH/TempDownloader.aspx?Filename=" + encryptedFilename + "&forceDownload=" + (forceDownload ? "1" : "0"); if (openNewWindow==true) window.open(url); else downloadWindow.document.location.href = url; } function openDownloadWindow(fileId, forceDownload, downloadWindow, bpsc, extention) { var url; if(extention == null || extention == undefined) url = "/DIDGAH/Downloader.aspx?Id=" + fileId + "&forceDownload=" + (forceDownload ? "1" : "0"); else url = "/DIDGAH/Downloader.aspx?Id=" + fileId + "&forceDownload=" + (forceDownload ? "1" : "0") + "&ext=" + extention; if (forceDownload == null || forceDownload == undefined) forceDownload = false; if (forceDownload) { var downloadAllowed = bpsc || false; if (downloadAllowed) { if (downloadWindow==null || downloadWindow==undefined) { window.location.href = url; } else { downloadWindow.location.href = url; } } else { messageBox("YouDontHaveAccessToDownloadFiles", eMessageBoxStyle.exclamation); } } else 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("/DIDGAH/"); 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("100012"); } 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("100025&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 = "100019&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("100044&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 = "100025"; 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("100071&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 = "persian"; 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); }