var records=new Array(1); var maxrow=0; var currow=0; var lastrow=0; var prevSort=null; var rowId=''; var curresendpos=0; function InitPage() { InitEmaillist(); $(document).click(function(evt) { if(evt.target.id != "btnattachment") { $('#popup').hide(); } }); $('#btnattachment').bind('click', function (event) { event.stopPropagation(); $('#popup').toggle(); }); $("#btnattachment").hide(); RunAjax("POST","fetchmails","val0=&val1="+($("#branch").val())+"&val2="+($("#usid").val())+"&val3="+($("#mailtype").val())+"&val4=&val5=",1); } function InitEmaillist() { maxrow=$('#tabbody tr').length-1; ResetRow(); $('#tabbody tr').click(function (event) { currow=$(this).index(); changeRow(); ShowMail(); }); $('#tabbody tr').hover(function () { $(this).addClass('rowhover'); }, function () { $(this).removeClass('rowhover'); }); } function AfterResponse(response,oprID) { var rindx=0; var mailistHtml=''; if(oprID==1) { records=new Array(1); $("#tabbody").html(""); $("#senderinfo").html(""); $("#popup").html(""); $("#mailcontent").html(""); if(response.trim().search('Generating mail list failed.')==-1) { var rows=response.split(RowDelim); for(rindx=0;rindx"; mailistHtml+=""; mailistHtml+=""; port=cols[4]; if(cols[4].length > 21) { port=cols[4].substring(0,20)+"..."; } subj=cols[5]; if(cols[5].length > 63) { subj=cols[5].substring(0,60)+"..."; } var img=(cols[10].length > 0 ? " ":""); mailistHtml+=""+img+""+port+""; mailistHtml+=""+subj+""; mailistHtml+=""+cols[6]+""; mailistHtml+=""; if(cols[13]=='Y') { mailistHtml+=""; } mailistHtml+=""; } if(mailistHtml!='') { $("#tabbody").html(mailistHtml); InitEmaillist(); } } else { CallMessage(response,3000,200,300); } } if(oprID==2) { if(response.trim().search("success")>=0) { records[curresendpos][7]="check.png"; records[curresendpos][8]="success"; records[curresendpos][11]="please refresh to get details"; $("#stat"+curresendpos).html(""); } else { records[curresendpos][7]="smsfailed.png"; records[curresendpos][8]=response; records[curresendpos][11]="please refresh to get details"; mailistHtml=""; if(records[curresendpos][13]=='Y') { mailistHtml+=""; } $("#stat"+curresendpos).html(mailistHtml); } curresendpos=curresendpos+1; ResendEmail(); } } function ShowMail() { //m.mail_id,fromemail,m.toemailid,ccemailid,to,m.mailsubject,m.senton,mailstatus, //m.response,m.mailbody,m.attachmentpath,sentby,m.emailtype, //isresent,m.bank_branch_id,portfolio_id,m.archiveattachments $("#senderinfo").html(""); $("#popup").html(""); $("#mailcontent").html(""); if(records[currow][10]!='') { var senderinfo=''; var indx=0; $("#btnattachment").show(); senderinfo="From: "+records[currow][1]+" | To: "+records[currow][2]+" | CC: "+records[currow][3]+"
"; senderinfo+="Subject: "+records[currow][5]; $("#senderinfo").html(senderinfo); var filelist=records[currow][10].split('!SPLT!'); var attachmentList=$("#popup"); for(indx=0;indx", { href: item, target: "_blank", rel: "noopener noreferrer", "class": "matrix-mail-attachment" }); attachment.append($("", { src: "/matrix/images/"+extension+"_small.png", alt: "" })); attachment.append($("").text(item.substring(item.lastIndexOf("/")+1))); attachmentList.append(attachment); } } $("#mailcontent").html(records[currow][9]); } function ResetRow() { currow=0; lastrow=maxrow; changeRow(); } function changeRow() { var row=$('tr:eq('+currow+')', $("#tabbody")); row.addClass('rowhover'); if(maxrow>0) { var lrow=$('tr:eq('+lastrow+')', $("#tabbody")); lrow.removeClass('rowhover'); } lastrow=currow; } function keyListen(param1,param2,e) { var keycode = e.keyCode; if(keycode==13) { GetRowData($('tr:eq('+currow+')', $("#tabbody"))); } else { if(keycode==40) { currow=currow+1; if(currow>=$('#tabbody tr').length){currow=0;lastrow=maxrow;} changeRow(); } if(keycode==38) { currow=currow-1; if(currow<0){currow=maxrow;lastrow=0;} changeRow(); } } } function filterEmaillist(key) { key=key.trim().toUpperCase(); for(indx=0;indx-1) || (subj.search(key)>-1) || (resp.search(key)>-1) || (msgbdy.search(key)>-1)) { $("#tabbody tr").eq(indx).show(); } else { $("#tabbody tr").eq(indx).hide(); } } } function keyListen(param1,param2,e) { var keycode = e.keyCode; if(keycode==13) { ShowMail(); } else { if(keycode==40) { currow=currow+1; if(currow>=$('#tabbody tr').length){currow=0;lastrow=maxrow;} changeRow(); } if(keycode==38) { currow=currow-1; if(currow<0){currow=maxrow;lastrow=0;} changeRow(); } } } function ValidateSearch() { if(checkForm()) { var from=$("#txtfrom").val(); from=from.split("/")[2]+"/"+from.split("/")[1]+"/"+from.split("/")[0]; var to=$("#txtto").val(); to=to.split("/")[2]+"/"+to.split("/")[1]+"/"+to.split("/")[0]; RunAjax("POST","fetchmails","val0=&val1="+($("#branch").val())+"&val2="+($("#usid").val())+"&val3="+($("#mailtype").val())+"&val4="+from+"&val5="+to,1); } } function ResendEmail() { if(curresendpos <= maxrow) { $("#btnresend").hide(); var chk=$("#chkrow"+curresendpos); if(chk.attr("checked")=="checked") { $("#stat"+curresendpos).html(""); RunAjax("POST","resendmails","val0="+records[curresendpos][0]+"&val1="+($("#branch").val())+"&val2="+($("#usid").val()),2); } else { curresendpos=curresendpos+1; ResendEmail(); } } else { $("#btnresend").show(); curresendpos=0; } } function callkeydownhandler(evnt) { var ev = evnt; if(ev.target.id == "txtfrom" || ev.target.id == "txtto" || ev.target.id == "btnfilter" || ev.target.id == "txtskey") { return false; } keyListen('','',ev); } window.document.addEventListener("keydown", callkeydownhandler, false);