290 lines
8.1 KiB
JavaScript
290 lines
8.1 KiB
JavaScript
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<rows.length-1;rindx++)
|
|
{
|
|
var cindx=0;
|
|
var cols=rows[rindx].split(ColDelim);
|
|
records[rindx]=new Array(cols.length);
|
|
for(cindx=0;cindx<cols.length;cindx++)
|
|
{
|
|
records[rindx][cindx]=cols[cindx];
|
|
}
|
|
if(rindx == 11)
|
|
{
|
|
$("#emaillist").width('775px');
|
|
}
|
|
mailistHtml+="<tr style='cursor:pointer' onkeyup='keyListen(\"\",\"\",event)'>";
|
|
mailistHtml+="<td style='padding-left:-2px;font-size:8pt' ><input type='checkbox' id='chkrow"+rindx+"' onclick='checkList(\"chkrow\",\"selall\")' />";
|
|
mailistHtml+="</td>";
|
|
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 ? "<img src='/matrix/images/attachpin.png' align='absmiddle' /> ":"");
|
|
mailistHtml+="<td style='font-size:8pt' title='"+cols[4]+"'>"+img+""+port+"</td>";
|
|
mailistHtml+="<td style='font-size:8pt' title='"+cols[5]+"'>"+subj+"</td>";
|
|
mailistHtml+="<td style='font-size:8pt'>"+cols[6]+"</td>";
|
|
mailistHtml+="<td id='stat"+rindx+"' style='font-size:8pt' align='center'><img src='/matrix/images/"+cols[7]+"' title='"+cols[8]+" Mail sent by : "+cols[11]+"' />";
|
|
if(cols[13]=='Y')
|
|
{
|
|
mailistHtml+="<img src='/matrix/images/redo.png' />";
|
|
}
|
|
mailistHtml+="</td></tr>";
|
|
}
|
|
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("<img src='/matrix/images/"+records[curresendpos][7]+"' title='"+records[curresendpos][8]+"' Mail sent by : "+records[curresendpos][11]+"' /><img src='/matrix/images/redo.png' />");
|
|
}
|
|
else
|
|
{
|
|
records[curresendpos][7]="smsfailed.png";
|
|
records[curresendpos][8]=response;
|
|
records[curresendpos][11]="please refresh to get details";
|
|
mailistHtml="<img src='/matrix/images/"+records[curresendpos][7]+"' title='"+records[curresendpos][8]+"' Mail sent by : "+records[curresendpos][11]+"' />";
|
|
if(records[curresendpos][13]=='Y')
|
|
{
|
|
mailistHtml+="<img src='/matrix/images/redo.png' />";
|
|
}
|
|
$("#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]+"<br />";
|
|
senderinfo+="Subject: "+records[currow][5];
|
|
$("#senderinfo").html(senderinfo);
|
|
var filelist=records[currow][10].split('!SPLT!');
|
|
var attachmentList=$("#popup");
|
|
for(indx=0;indx<filelist.length;indx++)
|
|
{
|
|
var item=filelist[indx];
|
|
var extension=item.substring(item.length-3).toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
var attachment=$("<a>", {
|
|
href: item,
|
|
target: "_blank",
|
|
rel: "noopener noreferrer",
|
|
"class": "matrix-mail-attachment"
|
|
});
|
|
attachment.append($("<img>", {
|
|
src: "/matrix/images/"+extension+"_small.png",
|
|
alt: ""
|
|
}));
|
|
attachment.append($("<span>").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<records.length;indx++)
|
|
{
|
|
to=records[indx][4].trim().toUpperCase();
|
|
subj=records[indx][5].trim().toUpperCase();
|
|
resp=records[indx][8].trim().toUpperCase();
|
|
msgbdy=records[indx][9].trim().toUpperCase();
|
|
if((to.search(key)>-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("<img src='/matrix/images/loading_small.gif' width='30' height='7' title='sending email. please wait, it will take few minutes' />");
|
|
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);
|