"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=""; ControlsPanel=ControlsPanel+""; for(indx=0;indx"; ControlsPanel=ControlsPanel+""; ControlsPanel=ControlsPanel+""; } ControlsPanel=ControlsPanel+"
Message Data
"; ControlsPanel=ControlsPanel+"
"; 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(""); 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(""); 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(""); $("#svstatus-"+curPos).val("1"); } else { $("#vid-"+curPos).html(""); } curPos=curPos+1; SendToMnimble(); } if(OprID==3) { if(AjaxResponse.search("successfully") > -1) { $("#upid-"+curPos).html(""); $("#upstatus-"+curPos).val("1"); FinalizePhotoCase(); } else { $("#upid-"+curPos).html(""); curPos=curPos+1; SendToMnimble(); } } }