Files
matrix/cygnus-onprem-app/build/WebContent/js/appjs/portfolio.js

288 lines
9.9 KiB
JavaScript

var maxrow=0;
var curelm='';
function InitPage()
{
var pid = $("#portfolio").val();
maxrow=$('#emaillistbody tr').length;
$('#emaillistbody tr').click(function () {
GetRowData(this);
});
}
function GetMoreDetails(SelectedRow)
{
//$('#table tr:eq(' + rowIndex + ') td:eq(' + columnIndex + ')')
alert($(SelectedRow).find('td').eq(0).html());
/*QueryStr="rand="+Math.round(Math.random()*4+1)+"&uuid="+$("#"+SelectedRow.id+"uuid").val()+"&pid="+$("#"+SelectedRow.id+"portid").val();
var retVal=0; // Legacy commented example retained without removed browser API.
if(retVal==1)
{
$("#"+SelectedRow.id+"col").html("<img src='/matrix/images/edited.png' title='Details has been edited successfully. Please click refresh button to see the changes' />");
}*/
$("#uuid").val($("#"+SelectedRow.id+"uuid").val());
SubmitForm("caseedit", "_blank", "caseGrid");
}
function ValidateEmailSearch()
{
var emailid = $("#emailid").val();
var portfolio = $("#portfolio").val();
var branch = $("#branch").val();
validate(document.getElementById("emailid"),'f','Email');
if(emailid.legth == 0 && portfolio == '-1' && branch == '-1')
{
CallMessage('INV:error:Please select any one criteria for search.',2000,200,300);
return false;
}
if(checkForm())
{
SubmitForm('filteremailids','_parent','emailmanager');
}
}
function fetchBranch(pid)
{
QueryStr="val0="+pid;
LoadingMsg("Fetching branch list, please wait...","ajaxmsg");
RunAjax("POST","branchlist",QueryStr,1);
}
function AfterResponse(AjaxResponse,OprID)
{
$("#ajaxmsg").remove();
if(OprID==1)
{
if(AjaxResponse.search('Error')>=0)
{
CallMessage(AjaxResponse,3000,200,300);
}
else
{
$("#branch").html("<option value='-1' selected>SELECT</option>");
recs=AjaxResponse.split(RowDelim);
for(indx=0;indx<recs.length-1;indx++)
{
$("#branch").append("<option value='"+recs[indx].split(ColDelim)[0]+"'>"+recs[indx].split(ColDelim)[1]+"</option>");
}
}
}
if(OprID==2)
{
if(AjaxResponse.search('Error')>=0)
{
CallMessage(AjaxResponse,3000,200,300);
}
else
{
CallMessage("9809:info:Recipient type changed CC -> TO",3000,200,300);
//SubmitForm('filteremailids','_parent','emailmanager');
var pElm = $("#"+$(curelm).attr("pid")+"-"+$(curelm).attr("bid"));
$("input[name=bt-"+$(pElm).val()+"]").removeClass("buttondisabled").addClass("button");
$("input[name=bt-"+$(pElm).val()+"]").attr("onclick","emailidActions(this,4)");
$("input[name=bd-"+$(pElm).val()+"]").removeClass("buttondisabled").addClass("button");
$("input[name=bd-"+$(pElm).val()+"]").attr("onclick","emailidActions(this,5)");
var html = '<input type="button" class="button" name="btncc" pid="'+$(curelm).attr("pid")+'" bid="'+$(curelm).attr("bid")+'" cid="'+$(pElm).val()+'" value="CC" style="margin-top:3px;text-indent:0px;padding:3px 3px;" id="btncc" title="Change recipient type CC -> TO " onclick="emailidActions(this,2)" />';
$(pElm).parent().html(html);
html = "TO <input type='hidden' value='"+$(curelm).attr("cid")+"' id='"+$(curelm).attr("pid")+"-"+$(curelm).attr("bid")+"' pid='"+$(curelm).attr("pid")+"' bid='"+$(curelm).attr("bid")+"' />";
$("input[name=bt-"+$(curelm).attr("cid")+"]").removeClass("button").addClass("buttondisabled");
$("input[name=bt-"+$(curelm).attr("cid")+"]").attr("onclick","return false");
$("input[name=bd-"+$(curelm).attr("cid")+"]").removeClass("button").addClass("buttondisabled");
$("input[name=bd-"+$(curelm).attr("cid")+"]").attr("onclick","return false");
$(curelm).parent().html(html);
}
}
if(OprID==3)
{
if(AjaxResponse.search('Error')>=0)
{
if(AjaxResponse.search('NULST')>=0)
{
CallMessage('2001:error:No records found.',3000,200,300);
}
else
{
CallMessage('2001:error:Fetching change history failed. '+AjaxResponse,3000,200,300);
}
}
else
{
showEditorList(AjaxResponse,"Email ID Editors");
}
}
if(OprID==4)
{
if(AjaxResponse.trim().search('Error')==-1)
{
emailTransferDialog(AjaxResponse,OprID);
}
else
{
CallMessage(AjaxResponse,2000,200,300);
}
}
if(OprID==5)
{
if(AjaxResponse.trim().search('Error')==-1)
{
CallMessage("9809:info:Transfer completed successfully.",2000,200,300);
SubmitForm('filteremailids','_parent','emailmanager');
}
else
{
var btn = $("input[name='b-btntransfer']");
$(btn).attr("id","btntransfer");
$(btn).removeAttr("disabled");
CallMessage(AjaxResponse,2000,200,300);
}
}
if(OprID==6)
{
if(AjaxResponse.trim().search('Error')==-1)
{
CallMessage("9809:info:Email ID removed successfully.",2000,200,300);
SubmitForm('filteremailids','_parent','emailmanager');
}
else
{
CallMessage(AjaxResponse,2000,200,300);
}
}
if(OprID==7)
{
if(AjaxResponse.trim().search('Error')==-1)
{
CallMessage("9809:info:Email ID revoked successfully.",2000,200,300);
SubmitForm('filteremailids','_parent','emailmanager');
}
else
{
CallMessage(AjaxResponse,2000,200,300);
}
}
}
function addEmailid()
{
OpenMatrixDialog("addemailid","Add Email Address",{width:"600px",height:"430px"}).then(function(retVal) {
if(retVal)
{
SubmitForm('filteremailids','_parent','emailmanager');
}
});
}
function ValidateNAddEmail()
{
validate(document.getElementById("portfolio"),'t','');
validate(document.getElementById("branch"),'t','');
validate(document.getElementById("contactperson"),'t','AlphaSpace');
validate(document.getElementById("emailid"),'t','Email');
if(checkForm())
{
SubmitForm('addemailid','_parent','addemail');
}
}
function emailidActions(elm,opr)
{
curelm = null;
if(opr==2)
{
if(preActionCall())
{
if(confirm("This action will change the recipient type CC - TO. Do you want to continue?"))
{
curelm = elm;
LoadingMsg("Changing recipient type, please wait...","ajaxmsg");
$(curelm).attr("id","btnajaxproc");
RunAjax("POST","emailmgractions","opr="+opr+"&cid="+$(curelm).attr("cid")+"&pid="+$(curelm).attr("pid")+"&bid="+$(curelm).attr("bid"),opr);
}
}
}
if(opr==3)
{
if(preActionCall())
{
LoadingMsg("Fetching editors list, please wait...","ajaxmsg");
RunAjax("POST","shwoemaileditors","cid="+elm,opr);
}
}
if(opr==4)
{
if(preActionCall())
{
curelm = elm;
LoadingMsg("Initializing transfer form, please wait...","ajaxmsg");
RunAjax("POST","getddvalues","val0=4&val1="+$(curelm).attr("pid"),opr);
}
}
if(opr==5)
{
if(preActionCall())
{
if(confirm("This action will deactivate this Email ID and the recipient will not receive any further email communication through Nimble. Do you want to continue?"))
{
curelm = elm;
LoadingMsg("Performing delete operation, please wait...","ajaxmsg");
RunAjax("POST","emailmgractions","opr="+opr+"&cid="+$(curelm).attr("cid")+"&pid="+$(curelm).attr("pid")+"&bid="+$(curelm).attr("bid"),(opr+1));
}
}
}
if(opr==6)
{
if(preActionCall())
{
if(confirm("This action will revoke this Email ID and the receipient will be able to receive further emails through Nimble. Do you want to continue?"))
{
curelm = elm;
LoadingMsg("Revoking Email ID, please wait...","ajaxmsg");
RunAjax("POST","emailmgractions","opr="+opr+"&cid="+$(curelm).attr("cid")+"&pid="+$(curelm).attr("pid")+"&bid="+$(curelm).attr("bid"),(opr+1));
}
}
}
}
function emailTransferDialog(respHtml,opr)
{
var optDiv=document.createElement("div");
optDiv.setAttribute("id","optDiv");
optDiv.setAttribute("class","FormPanel");
optDiv.setAttribute("style","font-family:Tahoma;overflow:visible;padding-right:15px");
var OptionPanel="<table border='0' cellspacing='0' width='100%' class='matrix-form-controls'><tr><td>";
OptionPanel=OptionPanel+"<div class=\"widget\"><div class=\"lblcontainer\" style=\"width:80px\" >Branch</div><div class=\"inputcontainer\">";
OptionPanel=OptionPanel+"<div class=\"divselect\" id=\"divtbranch\" style=\"width:200px;\">";
OptionPanel=OptionPanel+"<select id=\"tbranch\" style=\"width:218px\">";
OptionPanel=OptionPanel+respHtml;
OptionPanel=OptionPanel+"</select></div></div></div><br />";
OptionPanel=OptionPanel+"</td></tr><tr><td><input type='button' class='button' name='btncancel' style='margin-top:5px;float:right' value='Close' id='btncancel' accesskey='C' onclick=\"validate(document.getElementById('tbranch'),'f','');RemoveDialog(document.getElementById('inptDialog'));\" /><input type='button' class='button' name='b-btntransfer' style='margin-top:5px;float:right' value='Transfer' id='btntransfer' accesskey='T' onclick=\"validate(document.getElementById('tbranch'),'t','');if(checkForm()){initiateTransfer(document.getElementById('tbranch'),"+opr+");}\" /></td></tr>";
OptionPanel=OptionPanel+"</table>";
optDiv.innerHTML=OptionPanel;
if(ShowInputDialog(optDiv,"Transfer Email ID","hint","inptDialog"))
{
$("#tbranch option[value='"+$(curelm).attr("bid")+"']").remove();
if($('#tbranch > option').length <= 1)
{
$("input[name='b-btntransfer']").remove();
}
}
}
function initiateTransfer(branch,opr)
{
if(confirm("Do you want to transfer this email?"))
{
LoadingMsg("Transferring Email ID, please wait...","ajaxmsg");
var btn = $("input[name='b-btntransfer']");
$(btn).attr("id","btnajaxproc");
$(btn).attr("disabled","disabled");
RunAjax("POST","emailmgractions","opr="+opr+"&cid="+$(curelm).attr("cid")+"&pid=0&bid="+$(branch).val(),(opr+1));
}
}
function preActionCall()
{
if(document.getElementById("ajaxmsg") !== null)
{
CallMessage('1001AJX:warning:Another operation is being processed, please wait..',3000,200,300);
return false;
}
if(document.getElementById('inptDialog') !== null)
{
document.getElementById('inptDialog').parentNode.removeChild(document.getElementById('inptDialog'));
}
return true;
}