Punching, Dedupe and CutOff Features Done
This commit is contained in:
263
cygnus-onprem-app/build/WebContent/js/edp/cutoff/cutoff.js
Normal file
263
cygnus-onprem-app/build/WebContent/js/edp/cutoff/cutoff.js
Normal file
@@ -0,0 +1,263 @@
|
||||
"use strict";
|
||||
|
||||
var curPos = 0;
|
||||
var maxRow = 0;
|
||||
|
||||
function cutoffMessage(message) {
|
||||
if (window.CygnusNotifications) {
|
||||
window.CygnusNotifications.showLegacy(message);
|
||||
return;
|
||||
}
|
||||
CallMessage(message, 4000, 200, 300);
|
||||
}
|
||||
|
||||
function submitCutoffForm(formName, endpoint) {
|
||||
var form = document.forms[formName] || document.getElementById(formName);
|
||||
if (!form) return false;
|
||||
form.action = endpoint;
|
||||
form.target = "_self";
|
||||
form.submit();
|
||||
return false;
|
||||
}
|
||||
|
||||
function withCsrf(parameters) {
|
||||
var token = document.querySelector('input[name="_csrf"]');
|
||||
if (!token) return parameters;
|
||||
return parameters + "&" + encodeURIComponent(token.name) + "=" + encodeURIComponent(token.value);
|
||||
}
|
||||
|
||||
function requireSelection(prefix, message, formName, endpoint) {
|
||||
if (ValidateList(prefix) > 0) return submitCutoffForm(formName, endpoint);
|
||||
cutoffMessage(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
function ValidateSubmitCutOff(formName) {
|
||||
if (ValidateList("chkrow") < 1) {
|
||||
cutoffMessage("VLFRM:error:Please select at least one portfolio to start the cut-off process.");
|
||||
return false;
|
||||
}
|
||||
validate(document.getElementById("batchlist"), "t", "");
|
||||
if (invalidFields > 0) {
|
||||
cutoffMessage("VLFRM:error:Correct the highlighted fields and try again.");
|
||||
return false;
|
||||
}
|
||||
return submitCutoffForm(formName, "savecut");
|
||||
}
|
||||
|
||||
function ValidateSubmitSms(formName) { return submitCutoffForm(formName, "Sms"); }
|
||||
function ValidateSubmitAllocation(formName) {
|
||||
return requireSelection("chkchild", "VLFRM:error:Select at least one case to allocate.", formName, "savealloc");
|
||||
}
|
||||
function ValidateSubmitSopr(formName) {
|
||||
return requireSelection("chkchild", "VLFRM:error:Select at least one case to send to operations.", formName, "sendcasestoopr");
|
||||
}
|
||||
function ValidateSubmitTelesheet(formName) {
|
||||
return requireSelection("chkchild", "VLFRM:error:Select at least one case for the Tele-Sheet.", formName, "gentelesheet");
|
||||
}
|
||||
function ValidateSubmitRefsheet(formName) {
|
||||
return requireSelection("chkchild", "VLFRM:error:Select at least one case for the Reference Sheet.", formName, "genrefsheet");
|
||||
}
|
||||
|
||||
function InitPage() {
|
||||
maxRow = document.querySelectorAll("#cutlist > tbody > tr").length;
|
||||
var saveButton = document.getElementById("btnsave");
|
||||
if (saveButton) saveButton.hidden = maxRow < 1;
|
||||
}
|
||||
|
||||
function ExpandList(elementId) {
|
||||
var child = document.getElementById(elementId + "child");
|
||||
if (child) child.style.display = child.style.display === "none" ? "table-row" : "none";
|
||||
}
|
||||
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
|
||||
{
|
||||
cutoffMessage('EMPTOBX:info:Outbox is empty.');
|
||||
}
|
||||
}
|
||||
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=withCsrf("val0="+encodeURIComponent(uuid)+"&val1="+encodeURIComponent(mvcode)+"&val2="+encodeURIComponent($("#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user