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

274 lines
7.3 KiB
JavaScript

var curPos=0;
var maxRow=0;
function ValidateSubmitCutOff(FormName)
{
if(ValidateList('chkrow')>0)
{
validate(document.getElementById('batchlist'),'t','');
if (invalidFields>0)
{
CallMessage('VLFRM:error:There are one or more error(s) in form. Please correct them and try again.',3000,200,300);
}
else
{
SubmitForm('savecut','_parent',FormName);
}
}
else
{
CallMessage('VLFRM:error:Please select atleast one portfolio to start cut-off process.',3000,200,300);
}
}
function ValidateSubmitSms(FormName)
{
SubmitForm('Sms','_parent',FormName);
}
function ValidateSubmitAllocation(FormName)
{
if(ValidateList('chkchild')>0)
{
SubmitForm('savealloc','_parent',FormName);
}
else
{
CallMessage('VLFRM:error:Please select atleast one portfolio to start allocation process.',3000,200,300);
}
}
function ValidateSubmitSopr(FormName)
{
if(ValidateList('chkchild')>0)
{
SubmitForm('sendcasestoopr','_parent',FormName);
}
else
{
CallMessage('VLFRM:error:Please select atleast one portfolio to start send to operation process.',3000,200,300);
}
}
function ValidateSubmitTelesheet(FormName)
{
if(ValidateList('chkchild')>0)
{
SubmitForm('gentelesheet','_parent',FormName);
}
else
{
CallMessage('VLFRM:error:Please select atleast one portfolio to start telesheet process.',3000,200,300);
}
}
function ValidateSubmitRefsheet(FormName)
{
if(ValidateList('chkchild')>0)
{
SubmitForm('genrefsheet','_parent',FormName);
}
else
{
CallMessage('VLFRM:error:Please select atleast one portfolio to start reference sheet process.',3000,200,300);
}
}
function InitPage()
{
maxRow=$("#cutlist >tbody >tr").length;
if(maxRow<1)
{
document.getElementById("btnsave").style.display="none";
}
}
function ExpandList(elmId)
{
$("#"+elmId+"child").toggle();
}
function editMessage(elm,msgfieldId)
{
var msgValues=$("#"+msgfieldId).val().split('!SPLT!');
var optDiv=document.createElement("div");
optDiv.setAttribute("id","FormPanel");
optDiv.setAttribute("class","FormPanel");
optDiv.setAttribute("style","font-family:Tahoma;overflow:visible;padding-right:3px");
var ControlsPanel="<table border='0' cellspacing='0' width='100%' class='matrix-form-controls'>";
ControlsPanel=ControlsPanel+"<tr><td>Message Data</td></tr>";
for(indx=0;indx<msgValues.length-1;indx++)
{
ControlsPanel=ControlsPanel+"<tr>";
ControlsPanel=ControlsPanel+"<td><input type='text' id='field'"+indx+" value='"+msgValues[indx]+"' onblur=\"validate(this,'f','SMS');\" /></td>";
ControlsPanel=ControlsPanel+"</tr>";
}
ControlsPanel=ControlsPanel+"<tr><td><input type='button' class='button' name='btnsave' style='margin-top:5px;float:right' value='Save' id='btnsave' accesskey='K' onclick=\"updateMessage(document.getElementById('inptDialog'),'"+elm+"','"+msgfieldId+"','inptDialog')\" />";
ControlsPanel=ControlsPanel+"<input type='button' class='button' name='btncancel' style='margin-top:5px;float:right' value='Close' id='btncancel' accesskey='C' onclick=\"hideDialog(document.getElementById('inptDialog'))\" /></td></tr></table>";
optDiv.innerHTML=ControlsPanel;
ShowInputDialog(optDiv,"Edit SMS","hint","inptDialog");
}
function hideDialog(ElemToRemove)
{
if(checkForm())
{
RemoveDialog(ElemToRemove);
}
}
function updateMessage(ElemToRemove,rowElem,msgHfieldId,dialogID)
{
if(checkForm())
{
msgValues='';
$('#'+ElemToRemove.id+' :input').each(function(){
if('text'==$(this).attr("type"))
{
msgValues=msgValues+$(this).val()+'!SPLT!';
}
});
$("#"+rowElem).html(msgValues.substring(0,40));
$("#"+msgHfieldId).val(msgValues);
ElemToRemove.parentNode.removeChild(ElemToRemove);
}
}
function sendSMS(tableId)
{
success=0;
failed=0;
nextPos=1;
skipped=0;
progresswidth=0;
curPos=1;
SourceTable=tableId;
RowId='';
found=$("#"+SourceTable+" tr").length-1;
progbarwidth=$("#progressbar").width();
ProgPerRec=(progbarwidth/found).toFixed(2);
if(found>0)
{
getExtractMessage(1);
}
else
{
CallMessage('EMPTOBX:info:Outbox is empty.',3000,200,300);
}
}
function getExtractMessage(oprId)
{
RowId=$("#"+SourceTable+" tr:eq("+curPos+")").attr("id").replace("row","");
var smsgate=$("#smsgatelist").val();
var uid=$("#uid"+RowId).val();
var uuid=$("#uuid"+RowId).val();
var msg=$("#message"+RowId).val()+"ENDMSG!SPLT!";
msg=msg.replace(/&/g,'~AmP~');
var sms=$("#sms"+RowId);
var vistype=$("#vistype"+RowId).val();
var mno=$("#mno"+RowId).val();
var qid=$("#qid").val();
if($(sms).is(':checked'))
{
QryStr="val="+uid+"&val1="+uuid+"&val2="+msg+"&val3="+vistype+"&val4=1&val5="+smsgate+"&val6="+mno+"&val7="+oprId+"&val8="+qid;
RunAjax("GET","sendsms",QryStr,oprId);
}
else
{
skipped=skipped+1;
UpdateProgress();
nextPos=nextPos+1;
curPos=curPos+1;
getExtractMessage(oprId);
}
}
function FinalizePhotoCase()
{
if(curPos < maxRow)
{
uuid=$("#uuid-"+curPos).val();
mvcode=$("#fmvcode-"+curPos).val();
svstatus=$("#svstatus-"+curPos).val();
upstatus=$("#upstatus-"+curPos).val();
if(svstatus==0 && upstatus==1)
{
$("#vid-"+curPos).html("<img src='/matrix/images/loading_small.gif' width='16' height='7' title='please wait, it will take few minutes' />");
QryStr="val0="+uuid+"&val1="+mvcode+"&val2="+($("#usid").val());
RunAjax("POST","finalizepcases",QryStr,2);
}
else
{
curPos=curPos+1;
SendToMnimble();
//FinalizePhotoCase();
}
}
}
function SendToMnimble()
{
if(curPos < maxRow)
{
$("#btnsave").hide();
var params="params="+encodeURIComponent($('#form-'+curPos+' input').serialize()+"&opt=1");
uuid=$("#uuid-"+curPos).val();
mvcode=$("#fmvcode-"+curPos).val();
upstatus=$("#upstatus-"+curPos).val();
if(upstatus == 0)
{
$("#upid-"+curPos).html("<img src='/matrix/images/loading_small.gif' width='16' height='7' title='please wait, it will take few minutes' />");
RunAjax("POST","uploadservice",params,3);
}
else
{
curPos=curPos+1;
SendToMnimble();
}
}
/*else
{
curPos=0;
FinalizePhotoCase();
}*/
}
function AfterResponse(AjaxResponse,OprID)
{
if(OprID==1)
{
if(AjaxResponse.search("success:")==0)
{
success=success+1;
$("#row"+RowId).remove();
}
else
{
curPos=curPos+1;
failed=failed+1;
$("#imgstatus"+RowId).attr("src", "/matrix/images/smsfailed.png");
$("#imgstatus"+RowId).attr("title", AjaxResponse);
}
if(nextPos<=found)
{
UpdateProgress();
nextPos=nextPos+1;
getExtractMessage(OprID);
}
}
if(OprID==2)
{
if(AjaxResponse.search("success")==0)
{
$("#vid-"+curPos).html("<img src='/matrix/images/check.png' title='success' />");
$("#svstatus-"+curPos).val("1");
}
else
{
$("#vid-"+curPos).html("<img src='/matrix/images/exclm_red.png' title='"+AjaxResponse+"' />");
}
curPos=curPos+1;
SendToMnimble();
}
if(OprID==3)
{
if(AjaxResponse.search("successfully") > -1)
{
$("#upid-"+curPos).html("<img src='/matrix/images/check.png' title='success' />");
$("#upstatus-"+curPos).val("1");
FinalizePhotoCase();
}
else
{
$("#upid-"+curPos).html("<img src='/matrix/images/exclm_red.png' title='"+AjaxResponse+"' />");
curPos=curPos+1;
SendToMnimble();
}
}
}