Current File : //root/panel/modules/maillogtrack/module.zpm
<style>

.datepickerhomeimage{background-image:url('modules/maillogtrack/datepickerimage.png');background-repeat:no-repeat;background-position:-72px -8px; 
width:15px;height:14px;overflow:hidden;margin-right:5px;margin-top:7px;float:right;cursor:pointer;}
.datepickerleftarrow{background-image:url('modules/maillogtrack/datepickerimage.png');background-repeat:no-repeat;background-position:-25px -8px; 
width:8px;height:14px;overflow:hidden;margin-left:30px;margin-top:7px;float:left;cursor:pointer;}
.datepickermonthdetail{width:28px;height:18px;overflow:hidden;margin-left:8px;margin-top:7px;float:left;}
.datepickeryearleftarrow{background-image:url('modules/maillogtrack/datepickerimage.png');background-repeat:no-repeat;background-position:-25px -8px; 
width:8px;height:14px;overflow:hidden;margin-left:40px;margin-top:7px;float:left;cursor:pointer;}
.datepickeryeardetail{width:28px;height:14px;overflow:hidden;margin-left:8px;margin-top:7px;float:left;}
.datepickeryearrightarrow{background-image:url('modules/maillogtrack/datepickerimage.png');background-repeat:no-repeat;background-position:-7px -8px; 
width:8px;height:14px;overflow:hidden;margin-left:10px;margin-top:7px;float:left;cursor:pointer;}
.datepickerrightarrow{background-image:url('modules/maillogtrack/datepickerimage.png');background-repeat:no-repeat;background-position:-7px -8px; 
width:8px;height:14px;overflow:hidden;margin-left:1px;margin-top:7px;float:left;cursor:pointer;}
.datepickerdownarrow{background-image:url('modules/maillogtrack/datepickerimage.png');background-repeat:no-repeat;background-position:-92px -25px;width:10px;height:8px;overflow:hidden;margin-left:2px;margin-top:3px;float:left;cursor:pointer;}
.dateboxdate{ float:left;width:35px;height:27px;padding-top:8px;text-align:center;border-top:1px solid #FFFFFF;border-left:1px solid #FFFFFF;background-color:#F0F0F0;cursor:pointer;}
.dateboxdate:hover{ float:left;width:35px;height:27px;padding-top:8px;text-align:center;border-top:1px solid #FFFFFF;border-left:1px solid #FFFFFF;background-color:#F7F7F7;cursor:pointer;color:red;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}
.dateblankdate{float:left;width:35px;height:27px;padding-top:8px;text-align:center;border-top:1px solid #FFFFFF;border-left:1px solid #FFFFFF;background-color:#F8F8F8;}
.dateheaderdate{float:left;width:35px;text-align:center;border-top:1px solid #FFFFFF;border-left:1px solid #FFFFFF;background-color:#dddddd;}
.datecurrentdate{background-color:#3399CC;color:#FFFFFF;}
.datecurrentdate:hover{background-color:#3399CC;color:#FFFFFF;}
#msg_disg img{display:inline-block;}
#doubledatepick{margin-bottom: 20px;width: 100%;height: 410px;position: absolute;padding: 10px 10px 20px 10px;border: 1px solid #FFFFFF; background-color: white;box-shadow: 2px 2px 5px #d0d0d0;max-width: 550px;}
#smbd_box{width:255px;min-height:273px;background: #F8F8F8;color: #333;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:13px;float:left;}
#embd_box{width:255px;min-height:273px;background: #F8F8F8;color: #333;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:13px;float:left;margin-left:10px;}
#stext_box{width:245px;height:30px;background: #FEFEFE;color: #000000;float:left;border:1px solid #dedede;
font-family: arial, sans-serif;font-size: 13px;padding-left:5px;}
#etext_box{width:245px;height:30px;background: #FEFEFE;color: #000000;float:left;border:1px solid #dedede;
margin-left:10px;font-family: arial, sans-serif;font-size: 13px;padding-left:5px;}
.datepickbutton{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;
line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;
touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;
user-select:none;background-image:none;border:1px solid transparent;outline:none;
color:#FFFFFF;background-color:#3399CC;float:right;margin-left:5px;}
input::-moz-focus-inner{border:0}
.clearboth1{width:100%;height:1px;clear:both;}
.clearboth2{width:100%;height:2px;clear:both;}
.clearboth5{width:100%;height:5px;clear:both;}
.clearboth10{width:100%;height:10px;clear:both;}
.clearboth20{width:100%;height:20px;clear:both;}




.error_txt {color:#629338;font-weight:bold;font-size:13px;}
.t_h{background-color:#dedede;color:#3b7eb0;font-size:13px;font-weight:bold;text-align:center;}
.t_txt{font-size:12px;text-align:center;width:100px; word-wrap: break-word;}


.brd{font-size:12px;text-align:center;width:120px; word-wrap: break-word;}
.wrapper {
 
  position: relative;
  text-align: center;
  
  -webkit-transform: translateZ(0); /* webkit flicker fix */
  -webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}

.wrapper .tooltip {
  background: #1496bb;
  bottom: 100%;
  color: #fff;
  display: block;
  left: -25px;
  margin-bottom: 15px;
  opacity: 0;
  padding: 20px;
  pointer-events: none;
  position: absolute;
  width: 100%;
  -webkit-transform: translateY(10px);
     -moz-transform: translateY(10px);
      -ms-transform: translateY(10px);
       -o-transform: translateY(10px);
          transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
     -moz-transition: all .25s ease-out;
      -ms-transition: all .25s ease-out;
       -o-transition: all .25s ease-out;
          transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
     -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
      -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
       -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
          box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}

/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
  bottom: -20px;
  content: " ";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}  

/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
  
  content: " ";
  height: 0;
  left: 50%;
  margin-left: -13px;
  position: absolute;
  width: 0;
}
  
.wrapper:hover .tooltip {
  opacity: 1;
    width:300px;
font-size:13px;
  pointer-events: auto;
  -webkit-transform: translateY(0px);
     -moz-transform: translateY(0px);
      -ms-transform: translateY(0px);
       -o-transform: translateY(0px);
          transform: translateY(0px);
}

/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
  display: none;
}

.lte8 .wrapper:hover .tooltip {
  display: block;
}
.cur_c{cursor:pointer;}

#format_dis{color:#3b7eb0;font-size:11px;float:left;margin-left:0px;}
#error_dis{width:100%;height:20px;text-align:center;}
#error_id{color:#629338;}
#mail_log_input{width:300px;height:30px;color:#000000;outline:none;border:1px solid #dedede;background-color:#FFFFFF;}
#mail_ft{width::150px;height:30px;color:#000000;outline:none;border:1px solid #dedede;background-color:#FFFFFF;}
#maillogbtn{width:150px;height:30px;color:#000000;outline:none;border:1px solid #dedede;background-color:#dedede;}
.brd{border:1px solid #dedede;}
#ins_txt{color:#3b7eb0;font-size:12px;}
#ins_img{color:#387eb0;font-size:12px;}
#sta_time{width:120px;height:30px;outline:none;border:1px solid #dedede;background-color:#FFFFFF;float:left;}
#end_time{width:120px;height:30px;outline:none;border:1px solid #dedede;background-color:#FFFFFF;float:left;margin-left:10px;}
</style>
<div class="zmodule_content panel" id="zmodule_header_<@ ModuleName @>">
    <div class="panel-heading">
        <img src="<@ ModuleIcon @>" width="35" height="35" border="0" alt="<@ ModuleName @>">
        <div class="zmodule_title">
            <@ ModuleName @>
        </div>
        <div class="zmodule_desc" id="zmodule_desc_<@ ModuleName @>"><@ ModuleDesc @></div>
        <div  class="clearboth5" >&nbsp;</div>
    </div>

<style>
.helpicon {
display: block;
float: right;
border: 1px solid #ccc;
background-color: #f3f3f3;
padding: 5px 10px;
font-size: 12px;
margin-top:-98px;
margin-right:6px;
-webkit-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-webkit-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
}
</style>
<div class="helpicon">
<a href="<@ helpicon @>" target="_blank"><img src="etc/styles/CstyleX-master/images/help.png" style="float:left;" ><span style="float:left;margin-top:8px;font-weight:bold;font-size:12px;" >Video Tutorial</span></a>
</div>


    <div id="error_dis" ><span id="error_id" >&nbsp;</span></div>
    <span id ="ins_img"  >Message status detail</span>
    <div class="clearboth1" >&nbsp;</div>
    <div  id="msg_disg" >&nbsp;</div>
    <div class="clearboth1" >&nbsp;</div>
    
    <span id="ins_txt" >Date time format(YYYY-mm-dd HH:mm:ss)</span>  
    <div  class="clearboth5" >&nbsp;</div>
    <input type = "text" id = "mail_log_input" placeholder="Enter date time" readonly="readonly" >
    <input type = "text" id = "mail_ft" placeholder="Search Email Id " >
    <input type = "button" onclick = "isd.getmaillog()" value="Submit" id="maillogbtn"   > 
    <div class="clearboth1" >&nbsp;</div>
    <input type ="checkbox" id ="send_exist"  checked  onchange="isd.getmaillog()" >Mail sender&nbsp;&nbsp;<input type ="checkbox" id="recv_exist" checked  onchange="isd.getmaillog()" > Mail receiver
    
    <div class="zform_wrapper " id="maillog_display" > Please select date and time to display mail log </div>
</div>
<script>
var isd="";
var er_msg="Sorry something wrong, please contact System admin to fixed this issue.";
var no_mail_msg = " No mail log data";
var m_site = document.location.origin;
var igi ={"sent":"msent.png","bounce":"mbounce.png","softmsg":"msoft.png","defer":"mdeferred.png"};
 var igim ={"sent":"Msg sent ","bounce":"Msg bounced","softmsg":"Msg soft bounced","defer":"Msg deferred"};
var i_path = "/modules/maillogtrack/assets/";
var stad ="",end_t ="";
function  mhrpanel()
{
    var _self = this;
    _self.getmaillog = function()
    {
    
    //var stad = document.getElementById("sta_time").value.trim();
   // var end_t = document.getElementById("end_time").value.trim();
    
   stad = stad.replace(/\s+/g,' ').trim();
   end_t = end_t.replace(/\s+/g,' ').trim();
   // alert(stad+" "+end_t);
    var mail_ft =document.getElementById("mail_ft").value.trim();
    var send_stat = 2;
    var recv_stat = 2;
    if(document.getElementById("send_exist").checked) {  send_stat =1;  }
    if(document.getElementById("recv_exist").checked) {  recv_stat =1;  }
        //alert(stad+"  "+end_t+is_valid_date(stad)+" "+is_valid_date(end_t));
        if (is_valid_date(stad) && is_valid_date(end_t) )
        {
             document.getElementById("maillog_display").innerHTML ="Processing  mail log,Please wait";
             
	        var ajaxdata1={
                "ajaxurl":"./?module=maillogtrack&action=maillog",
                "ajaxmethod":"POST",
                "ajaxsync":true,
                "calldetail":2,
                "statusdetail":3,
                "datadetail":"start_tb="+encodeURIComponent(stad)+"&end_tb="+encodeURIComponent(end_t)+"&mail_id="+encodeURIComponent(mail_ft)+"&rcv_stat="+encodeURIComponent(recv_stat)+"&snd_stat="+encodeURIComponent(send_stat),
                "callback":function(response)
                    {
                    
                        if(typeof response['status'] != "undefined" )
                        {
                            if(response['status'] == 1)
                            {
                                var dis = "<table style='width:100%;' ><tr>";
                                    dis +="<td class='t_h' >Mail time</td>";
                                    dis +="<td class='t_h' >Sender </td>";
                                    dis +="<td class='t_h' >Receiver</td>";
                                    dis +="<td class='t_h' >Delivery</td>";
                                    dis +="<td class='t_h' >Msg status</td>";
                                    dis +="<td class='t_h' >Msg</td></tr>";
                                    
                                var count_d = 0,key_d="";
                                if(typeof response['res_data'] != "undefined" )
                                {
                                    var d_arr = response['res_data'];
                                    for(key_d in  d_arr)
                                    {
                                        var m_arr = d_arr[key_d];
                                        dis +="<tr class='brd' >";
                                        
                                        dis +="<td class='t_txt' >";
                                        if(typeof m_arr['t_time'] !="undefined" ){ dis +=m_arr['t_time'];}else { dis +=" ";}
                                        dis +="</td>";                                    
                                        
                                        dis +="<td class='t_txt' >";
                                        if(typeof m_arr['from'] !="undefined" ){ 
                                        
                                        dis +="<div class='brd' >";
                                        
                                        dis +=m_arr['from'];
                                        dis +="</div>";
                                        
                                        
                                        }else { dis +=" ";}
                                        dis +="</td>";
                                        
                                        dis +="<td class='t_txt' >";
                                        if(typeof m_arr['to'] !="undefined" ){
                                        
                                            var z="";
                                            var zm = m_arr['to'];
                                            for(z in zm)
                                            {
                                                dis +="<div class='brd' >";
                                                dis +=zm[z];
                                                dis +="</div>";
                                                dis +="<div class='clearboth1' >&nbsp;</div>";
                                            }
                                         
                                         
                                        }else { dis +=" ";}
                                        dis +="</td>";
                                        dis +="<td calss='t_txt' >";
                                        if(typeof m_arr['s'] != "undefined" && m_arr['r'] !="undefined"  )
                                        {
                                        
                                        
                                            if(typeof m_arr['status'] !="undefined" ){ 
                                        
                                                var zb="";
                                                var zn = m_arr['status'];
                                                for(zb in zn)
                                                {
                                                    if(zn[zb] =="sent")
                                                    {
                                                    
                                                        if(m_arr['s']  ==1 )
                                                        {
                                                        dis +="Send<br>";
                                                        }
                                                        else
                                                        {
                                                            dis +="Recv<br>";
                                                        }
                                                    }
                                                    else
                                                    {
                                                        dis += "Not send<br>";
                                                    
                                                    }

                                                }
                                        
                                        
                                            }else { dis +=" ";}
                                        
                                                                                    
                                        }
                                        else
                                        {
                                            
                                            
                                            if(typeof m_arr['status'] !="undefined" ){ 
                                                var zb="";
                                                var zn = m_arr['status'];
                                                for(zb in zn)
                                                {
                                                    if(zn[zb] =="sent")
                                                    {
                                                        dis += "Sent<br>";
                                                        
                                                    }
                                                    else
                                                    {
                                                        dis += "Not sent<br>";
                                                    
                                                    }

                                                }
                                        
                                        
                                            }else { dis +=" ";}
                                            
                                        }                                     
                                        dis +="</td>";
                                        
                                        
                                        dis +="<td class='t_txt' >";
                                        if(typeof m_arr['status'] !="undefined" ){ 
                                        
                                        
                                            var zb="";
                                            var zn = m_arr['status'];
                                            for(zb in zn)
                                            {
                                                var jh = zn[zb];
                                                if( jh == "sent" )
                                                {
                                                    dis +="<img src='"+m_site+i_path+igi['sent']+"' >";
                                                }
                                                else if (jh == "deferred" )
                                                {
                                                    dis +="<img src='"+m_site+i_path+igi['defer']+"' >";
                                                }
                                                else if ( jh == "softbounce" )
                                                {
                                                    dis +="<img src='"+m_site+i_path+igi['softmsg']+"' >";     
                                                }
                                                else if (jh == "bounced" )
                                                {
                                                    dis +="<img src='"+m_site+i_path+igi['bounce']+"' >";
                                                }
                                                else
                                                {
                                                
                                                }
                                            dis +="<div class='clearboth1' >&nbsp;</div>";
                                            }
                                        
                                        
                                        }else { dis +=" ";}
                                        dis +="</td>";
                                        
                                        dis +="<td class='t_txt' >";
                                        
                                        if(typeof m_arr['msg'] !="undefined" ){ 
                                            var m_msg = m_arr['msg'];
                                            var zz ="";
                                            for (zz in m_msg)
                                            {
                                                var zm_msg = m_msg[zz];
                                                var res_dg = zm_msg.substr(0,7); 
                                                res_dg +=".";
                                                dis +="<div class=\"wrapper\" >";
                                                        
                                                dis +="<span class='cur_c' >"+res_dg+"</span>";
                                                dis +="<div class=\"tooltip\">"+zm_msg+"</div>";
                                                dis +="</div>";   
                                            }                              
                                        
                                        }else { dis +=" ";}
                                        
                                        
                                        dis +="</td>";
                                        
                                        dis += "</tr>";
                                        count_d++;
                                    }
                                    dis +="</table>";
                                    if(count_d >0)
                                    {
                                        document.getElementById("maillog_display").innerHTML = dis;
                                    }
                                    else
                                    {
                                        document.getElementById("maillog_display").innerHTML = no_mail_msg;
                                    }
                                }
                                else
                                {
                                    document.getElementById("maillog_display").innerHTML="<span class='error_txt' >"+er_msg+"</span>";
                                }
                                
                            }
                            else
                            {
                                if(typeof response['msg'] != "undefined"  )
                                {
                                    document.getElementById("maillog_display").innerHTML="<span class='error_txt' >"+response['msg']+"</span>";
                                }
                                elese
                                {
                                    document.getElementById("maillog_display").innerHTML="<span class='error_txt' >"+er_msg+"</span>";
                                }
                            }
                        }
                        else
                        {
                            document.getElementById("maillog_display").innerHTML="<span class='error_txt' >"+er_msg+"</span>";
                        }

                    }
                        
                }
                _self.ajaxcall(ajaxdata1);
           }
            else
            {
                var strd = document.getElementById("error_id");
                strd.innerHTML = "Please Enter valid date and time. ";
                setTimeout(function(){
                strd.innerHTML = "";
                },4000);       
            
            }
            
            
    }
    _self.ajaxcall = function(ajaxdata) {
        var xmlhttp = ""; // The variable that makes Ajax possible!
        try {
            // Opera 8.0+, Firefox, Safari
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer Browsers
            try {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    // Something went wrong
                    console.log("Your browser broke!");
                    return false;
                }
            }
        }
        // Create a function that will receive data sent from the server
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        console.log(xmlhttp.responseText);
                        try{
                            var jsondata = JSON.parse(xmlhttp.responseText);
                           ajaxdata.callback(jsondata)
                        
                        }
                        catch(ex)
                        {
                             console.log(ex);
                        }        
                                   
            } else if (xmlhttp.status == 404 || xmlhttp.status == 500) {
                console.log("404 or 505 error");
            } else {}
        }
        if (ajaxdata.ajaxsync == true) {
            xmlhttp.open(ajaxdata.ajaxmethod, ajaxdata.ajaxurl, ajaxdata.ajaxsync);
        } else {
            xmlhttp.open(ajaxdata.ajaxmethod, ajaxdata.ajaxurl);
        }
        if (ajaxdata.statusdetail == 4) {
            xmlhttp.send(ajaxdata.formdata);
        } else {
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send(ajaxdata.datadetail);
        }
    }
}


function mydatepick()
{
	var _self = this;
	var todaydate = new Date();
	var daydisplaychar = 3;
	var monthnamearray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	var weekdayarray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
	var DaysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];	
	var  newdatedetail;
	_self.end=todaydate;
	_self.start=todaydate;
	_self.curr=todaydate;
	_self.startid="smbd_box";
	_self.endid="embd_box";
	_self.starttext="stext_box";
	_self.endtext="etext_box";
	_self.datepick = {};
	_self.myobjid=""; 
	_self.init=function(callback)
	{
	    
            if(document.getElementById("doubledatepick")){ 
		var d=document.getElementById("doubledatepick");
		var y=0;
			while (y<3)
			{
			d.removeChild(d.lastChild);
			y++;
			}
				_self.createhtml("input",d,function(t)
				{ 
						t.setAttribute("type","button");
						t.setAttribute("class","datepickbutton");
						t.setAttribute("value","Save");
						t.addEventListener("click",function()
						{
                        document.getElementById("doubledatepick").style.display="none";
						_self.callmytime();
						
						});
						
				});
				_self.createhtml("input",d,function(o)
				{ 
					o.setAttribute("type","button");
					o.setAttribute("class","datepickbutton");
					o.setAttribute("value","Close");
					o.addEventListener("click",function()
					{
					document.getElementById("doubledatepick").style.display="none";
					});
				
				});
				_self.createhtml("div",d,function(w)
				{ 
				w.setAttribute("class","clearboth10");
				});
		}
		else{
		_self.createhtml("div",document.body,function(d)
			{
			d.setAttribute("id","doubledatepick");
				if(document.getElementById("stext_box")){ }
				else{
 					_self.createhtml("input",d,function(a)
						{ 
						a.setAttribute("id","stext_box");
						a.setAttribute("type","text");
						a.setAttribute("placeholder","Start date");
						});
                                    }
				if(document.getElementById("etext_box")){ }
				else{
 					_self.createhtml("input",d,function(b)
						{ 
						b.setAttribute("id","etext_box");
						b.setAttribute("type","text");
						b.setAttribute("placeholder","End date");
						});
                                    }
				_self.createhtml("div",d,function(c)
				{ 
				c.setAttribute("class","clearboth10");
				});
				if(document.getElementById("smbd_box")){ }
				else{
 					_self.createhtml("div",d,function(f)
						{ 
						f.setAttribute("id","smbd_box");
						});
                                    }
				if(document.getElementById("embd_box")){ }
				else{
 					_self.createhtml("div",d,function(g)
						{ 
						g.setAttribute("id","embd_box");
						});
                                    }
				_self.createhtml("div",d,function(h)
				{ 
				h.setAttribute("class","clearboth20");
				});
				
				_self.createhtml("span",d,function(sap)
				{
				    sap.setAttribute("id","format_dis");
				    sap.innerHTML="Use 24 hour format HH:MM:SS(23:59:59)";
				
				});
				_self.createhtml("div",d,function(wd)
				{ 
				wd.setAttribute("class","clearboth2");
				});
				_self.createhtml("input",d,function(stg)
				{
				    stg.setAttribute("type","input");
				    stg.setAttribute("placeholder","Start time");
				    stg.setAttribute("id","sta_time");
				
				
				});
				_self.createhtml("input",d,function(sth)
				{
				    sth.setAttribute("type","input");
				    sth.setAttribute("placeholder","End time");
				    sth.setAttribute("id","end_time");
				
				
				});
				_self.createhtml("input",d,function(t)
				{ 
						t.setAttribute("type","button");
						t.setAttribute("class","datepickbutton");
						t.setAttribute("value","Save");
						t.addEventListener("click",function()
						{
                            document.getElementById("doubledatepick").style.display="none";
						_self.callmytime();
						});
						
				});
				_self.createhtml("input",d,function(o)
				{ 
					o.setAttribute("type","button");
					o.setAttribute("class","datepickbutton");
					o.setAttribute("value","Close");
					o.addEventListener("click",function()
					{
					document.getElementById("doubledatepick").style.display="none";
					});
				
				});
				
				_self.createhtml("div",d,function(w)
				{ 
				w.setAttribute("class","clearboth10");
				});
				
			});
		}
	_self.constructdatepicker(1,function(){ 
		_self.constructdatepicker(2,function(){ 
		callback();
		});
	});
	
	
	}
	_self.callmytime = function(){

		var stdm={"startdate":0,"enddate":0};
		_self.displaytime(1,function(sf){
		stdm.startdate=sf;
			_self.displaytime(2,function(sf){
			stdm.enddate=sf;
			_self.mycallback(stdm);
			});
		});
	}
	_self.createhtml=function(nhtml,targ,callback)
	{
		var d=document.createElement(nhtml);
		targ.appendChild(d);
		callback(d);
	}
	_self.constructdatepicker=function(statusd,callback) {
		
		if(statusd ==1)	{_self.curr=_self.start;_self.iddetail=_self.startid;}
		else{_self.curr=_self.end;_self.iddetail=_self.endid;}
		_self.datepicker(_self.curr,function()
		{
			    var datepickerheaderpart = "",
			    i, j, currentmonthstatus, daycountdetail = 0;
			    datepickerheaderpart += "<div style='width:100%;height:30px;'>";
			    datepickerheaderpart += "<div class='datepickerleftarrow'  >&nbsp;</div>";
			    datepickerheaderpart += "<div class='datepickermonthdetail' >" + monthnamearray[_self.datepick.month].substring(0, daydisplaychar) + "</div>";
			    datepickerheaderpart += "<div class='datepickerrightarrow'  >&nbsp;</div>";
			    datepickerheaderpart += "<div class='datepickeryearleftarrow'  >&nbsp;</div>";
			    datepickerheaderpart += "<div class='datepickeryeardetail' >" + _self.datepick.year + "</div>";
			    datepickerheaderpart += "<div class='datepickeryearrightarrow'  >&nbsp;</div>";
			    datepickerheaderpart += "<div class='datepickerhomeimage'  >&nbsp;</div>";
			    datepickerheaderpart += "<div style=\"clear:both;height:2px;\">&nbsp;</div></div>";
			    for (i = 0; i < 7; i++) {
				datepickerheaderpart += "<div  class='dateheaderdate'  >" + weekdayarray[i].substring(0, daydisplaychar) + "</div>";
			    }
			    datepickerheaderpart += "<div style=\"clear:both;height:1px;\">&nbsp;</div>";
			    newdatedetail = new Date(_self.datepick.year, _self.datepick.month);
			    newdatedetail.setDate(1);
			    firstdayofmonth = newdatedetail.getDay();
			    for (i = 0; i < firstdayofmonth; i++) {
				datepickerheaderpart += "<div  class='dateblankdate' >&nbsp;</div>";
				daycountdetail++;
			    }
			    var newboxpart = "";
			    for (j = 1; j <= _self.getmonthdays(); j++) {
				if (daycountdetail % 7 == 0) {
				    newboxpart += "<div style=\"clear:both;height:1px;\">&nbsp;</div>";
				}
				if (j == _self.datepick.date) {
				    newboxpart += "<div  class='dateboxdate datecurrentdate'  >" + j + "</div>";
				} else {
				    newboxpart += "<div  class='dateboxdate'  >" + j + "</div>";
				}
				daycountdetail++;
			    }
			    newboxpart += "<div style=\"clear:both;height:1px;\">&nbsp;</div>";
			    document.getElementById(_self.iddetail).innerHTML = datepickerheaderpart + newboxpart;
				if(statusd == 1)
				{
_self.attachevent("dateboxdate",document.getElementById(_self.startid),function(e) { _self.selectdisplaydate(statusd,e); });
_self.attachevent("datepickerleftarrow",document.getElementById(_self.startid),function(e) { _self.getprevmonth(statusd,e); });
_self.attachevent("datepickerrightarrow",document.getElementById(_self.startid),function(e) { _self.getnextmonth(statusd,e); });
_self.attachevent("datepickeryearleftarrow",document.getElementById(_self.startid),function(e) { _self.getprevyear(statusd,e); });
_self.attachevent("datepickeryearrightarrow",document.getElementById(_self.startid),function(e) { _self.getnextyear(statusd,e); });
_self.attachevent("datepickerhomeimage",document.getElementById(_self.startid),function(e) { _self.displaycurrenttime(statusd,e); });
_self.displaytime(statusd,function(tf){ document.getElementById(_self.starttext).value=tf; });
				}
				else
				{
_self.attachevent("dateboxdate",document.getElementById(_self.endid),function(e) { _self.selectdisplaydate(statusd,e); });
_self.attachevent("datepickerleftarrow",document.getElementById(_self.endid),function(e) { _self.getprevmonth(statusd,e); });
_self.attachevent("datepickerrightarrow",document.getElementById(_self.endid),function(e) { _self.getnextmonth(statusd,e); });
_self.attachevent("datepickeryearleftarrow",document.getElementById(_self.endid),function(e) { _self.getprevyear(statusd,e); });
_self.attachevent("datepickeryearrightarrow",document.getElementById(_self.endid),function(e) { _self.getnextyear(statusd,e); });
_self.attachevent("datepickerhomeimage",document.getElementById(_self.endid),function(e) { _self.displaycurrenttime(statusd,e); });
_self.displaytime(statusd,function(tf){ document.getElementById(_self.endtext).value=tf; });
				}
				
				
				
				
				
	callback();
		});

	}
_self.displaytime = function(stat,callback)
{
	if(stat ==1){_self.curr=_self.start;}
	else{_self.curr=_self.end;}
//alert(_self.curr);
	_self.datepicker(_self.curr,function()
	{
	  var nmonth = parseInt(_self.datepick.month);
    	  var nyear = parseInt(_self.datepick.year);
	  var ndate = parseInt(_self.datepick.date);
          var ydis=nyear,mdis="00",ddis="00";
	    if ((parseInt(nmonth) ) < 9) {
		mdis = "0" + (nmonth + 1);
	    } else {
		mdis = nmonth + 1;
	    }
	    if (parseInt(ndate) < 10) {
		ddis = "0" + ndate;
	    } else {
		ddis = ndate;
	    }
	var did=ydis+"-"+mdis+"-"+ddis;
	callback(did);
	});
}
_self.attachevent=function(dated1,hbox,fund)
{
	var dcd=hbox.getElementsByClassName(dated1);
	var dlength=dcd.length,i=0;
	if(dlength >0)
	{
		for( ;i<dlength;i++)
		{
			dcd[i].addEventListener("click", fund, false);
		}
	}
}
_self.datepicker=function(datedetail,callback) {
	var dt=new Date(datedetail);
	_self.datepick.date = dt.getDate();
	_self.datepick.month = dt.getMonth();
	_self.datepick.year = dt.getFullYear();
	_self.datepick.hour = dt.getHours();
	callback();
}
_self.IsLeapYear=function() {
	if ((_self.datepick.year % 4) == 0) {
		if ((_self.datepick.year % 100 == 0) && (_self.datepick.year % 400) != 0) {
		    return false;
		} else {
		    return true;
		}
	} else {
	return false;
	}
}
_self.getmonthdays=function() {
	
	if (_self.IsLeapYear()) {
	DaysInMonth[1] = 29;
	}
	return DaysInMonth[_self.datepick.month];
}
_self.selectdisplaydate=function(stat,e)
{

	if (!e) e = window.event;
	var tda = (typeof e.target != "undefined")?e.target:e.srcElement;
	var selectdate=parseInt(tda.innerHTML);
	if(stat ==1)	{_self.curr=_self.start;_self.textdetail=_self.starttext;}
	else{_self.curr=_self.end;_self.textdetail=_self.endtext;}
	_self.datepicker(_self.curr,function()
	{
	    var monthdisplay;
	    var nmonth=parseInt(_self.datepick.month);
	    if ((parseInt(nmonth) ) < 9) {
		monthdisplay = "0" + (nmonth + 1);
	    } else {
		monthdisplay = nmonth + 1;
	    }
	    if (parseInt(selectdate) < 10) {
		datedisplay = "0" + selectdate;
	    } else {
		datedisplay = selectdate;
	    }
		var ndate=_self.datepick.year + "-" + monthdisplay + "-" + datedisplay;
		if(stat ==1)	{_self.start=ndate;}
		else{_self.end=ndate;}
	    	document.getElementById(_self.textdetail).value = ndate;
		_self.constructdatepicker(stat,function() { });
	});	
}
	
	_self.getnextmonth = function(stat,e) {

		if(stat ==1)	{_self.curr=_self.start;_self.iddetail=_self.startid;}
		else{_self.curr=_self.end;_self.iddetail=_self.endid;}
		_self.datepicker(_self.curr,function()
		{
		    var currentmonth = _self.datepick.month;
		    if (currentmonth == 11) {
			_self.datepick.year = _self.datepick.year + 1;
			_self.datepick.month = 0;
		    } else {
			_self.datepick.month = _self.datepick.month + 1;
			
		    }
	    		var nmonth=_self.datepick.month,monthdisplay=_self.datepick.month;
			 if ((parseInt(nmonth) ) < 9) {
				monthdisplay = "0" + (nmonth + 1);
			    } else {
				monthdisplay = nmonth + 1;
			    }
			
			var ndate=_self.datepick.year + "-" + monthdisplay + "-" +"01";

			if(stat ==1)	{_self.start=ndate;}
			else{_self.end=ndate;}
			_self.constructdatepicker(stat,function(){ });
		});
	}
	_self.getprevmonth = function(stat,e){
		if(stat ==1)	{_self.curr=_self.start;_self.iddetail=_self.startid;}
		else{_self.curr=_self.end;_self.iddetail=_self.endid;}
		_self.datepicker(_self.curr,function()
		{
		    var currentmonth = _self.datepick.month;
		    if (currentmonth == 0) {
			_self.datepick.month = 11;
			_self.datepick.year = _self.datepick.year - 1;
		    } else {
			_self.datepick.month = _self.datepick.month - 1;
		    }
		    var nmonth=_self.datepick.month,monthdisplay=_self.datepick.month;
			 if ((parseInt(nmonth) ) < 9) {
				monthdisplay = "0" + (nmonth + 1);
			    } else {
				monthdisplay = nmonth + 1;
			    }
			
			var ndate=_self.datepick.year + "-" + monthdisplay + "-" +"01";

			if(stat ==1)	{_self.start=ndate;}
			else{_self.end=ndate;}
			_self.constructdatepicker(stat,function(){ });
		});
	}
	_self.getprevyear = function(stat,e) {

		if(stat ==1)	{_self.curr=_self.start;_self.iddetail=_self.startid;}
		else{_self.curr=_self.end;_self.iddetail=_self.endid;}
		_self.datepicker(_self.curr,function()
		{
		    _self.datepick.year = _self.datepick.year - 1;
		     var nmonth=_self.datepick.month,monthdisplay=_self.datepick.month;
			 if ((parseInt(nmonth) ) < 9) {
				monthdisplay = "0" + (nmonth + 1);
			    } else {
				monthdisplay = nmonth + 1;
			    }
		    var ndate=_self.datepick.year + "-" + monthdisplay+ "-" +"01";

			if(stat ==1)	{_self.start=ndate;}
			else{_self.end=ndate;}
		    _self.constructdatepicker(stat,function(){ });
		});
	}
	_self.getnextyear = function(stat,e) {
	   	if(stat ==1)	{_self.curr=_self.start;_self.iddetail=_self.startid;}
		else{_self.curr=_self.end;_self.iddetail=_self.endid;}
		_self.datepicker(_self.curr,function()
		{
		    _self.datepick.year = _self.datepick.year + 1;
		    var nmonth=_self.datepick.month,monthdisplay=_self.datepick.month;
			 if ((parseInt(nmonth) ) < 9) {
				monthdisplay = "0" + (nmonth + 1);
			    } else {
				monthdisplay = nmonth + 1;
			    }
		    var ndate=_self.datepick.year + "-" + monthdisplay+ "-" +"01";
			if(stat ==1)	{_self.start=ndate;}
			else{_self.end=ndate;}
		    _self.constructdatepicker(stat,function(){ });
		});
	}
	_self.displaycurrenttime=function(stat,ev) 
	{
	   if(stat == 1){ _self.start = todaydate;}
	   else {   _self.end = todaydate;   }
	    _self.constructdatepicker(stat,function(){ });
	}
	
	_self.daterangepicker = function(objid,ncallback,callback)
	{
		var idb=document.getElementById(objid);
		idb.addEventListener("click",function()
		{	
			_self.myobjid=objid;
			_self.init(function()
			{
			var nobjid = document.getElementById(objid);
			var dheight =getStyle(nobjid,"height");
			var pos=GetelementTopLeft(nobjid);
			var scd=getScrollXY();
			var objectbox=document.getElementById("doubledatepick");
			objectbox.style.left=(parseInt(pos.posX)+parseInt(scd.scrOfX))+"px";
			objectbox.style.top=(parseInt(pos.posY)+parseInt(scd.scrOfY)+parseInt(dheight)+5)+"px";
			objectbox.style.display="block";
			});
			//_self.mycallback("asdfg");
			_self.mycallback=ncallback;
		});
		
		callback();
	}
	_self.alertd = function(asde)
	{
	alert(asde);
	}
	_self.addclassname = function(classname, element) {
		var cn = element.className;
		if (cn.indexOf(classname) != -1) {   return;   	}
		if (cn != '') {   classname = ' ' + classname;	}
		element.className = cn + classname;
	}
	_self.removeclassname = function(classname,d)  
	{
		d.className = d.className.replace(classname,"");
	} 
}
function daterangepicker(myid,callback)
{
	var text = "";
	var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var rlength=10;
	for( var i=0; i < 5; i++ )
	{
	text += possible.charAt(Math.floor(Math.random() * rlength));
	}
	text=text+(new Date().getTime());
    	text=new mydatepick();
	text.daterangepicker(myid,callback,function(){ 

	});
	//callback({"startdate":0,"enddate":0});
}

function getStyle(el, cssprop) {
    if (el.currentStyle) //IE
        return el.currentStyle[cssprop]
    else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox
        return document.defaultView.getComputedStyle(el, "")[cssprop]
    else //try and get inline style
        return el.style[cssprop]
}
function GetelementOffset(object, offset) {
    if (!object) return;
    offset.x += object.offsetLeft;
    offset.y += object.offsetTop;
    GetelementOffset(object.offsetParent, offset);
}

function GetelementScrolled(object, scrolled) {
    if (!object) return;
    scrolled.x += object.scrollLeft;
    scrolled.y += object.scrollTop;
    if (object.tagName.toLowerCase() != "html") {
        GetelementScrolled(object.parentNode, scrolled);
    }
}
function GetelementTopLeft(divelementobject) {
    var res = new Object();
    var offset = {
        x: 0,
        y: 0
    };
    GetelementOffset(divelementobject, offset);
    var scrolled = {
        x: 0,
        y: 0
    };
    GetelementScrolled(divelementobject.parentNode, scrolled);
    res.posX = offset.x - scrolled.x;
    res.posY = offset.y - scrolled.y;
    return res;
}
function getScrollXY() {
    var scrd = new Object();
    if (typeof(window.pageYOffset) == 'number') {
        //Netscape compliant
        scrd.scrOfY = window.pageYOffset;
        scrd.scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrd.scrOfY = document.body.scrollTop;
        scrd.scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrd.scrOfY = document.documentElement.scrollTop;
        scrd.scrOfX = document.documentElement.scrollLeft;
    }
    return scrd;
}

function is_valid_date(value) {
    // capture all the parts
    var matches = value.match(/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
    if (matches === null) {
        return false;
    } else{
        // now lets check the date sanity
        var year = parseInt(matches[1], 10);
        var month = parseInt(matches[2], 10) - 1; // months are 0-11
        var day = parseInt(matches[3], 10);
        var hour = parseInt(matches[4], 10);
        var minute = parseInt(matches[5], 10);
        var second = parseInt(matches[6], 10);
        var date = new Date(year, month, day, hour, minute, second);
        //alert(date.getFullYear()+"  "+year+"  "+date.getMonth()+" "+month+"  "+date.getDate()+" "+day+"  "+date.getHours()+" "+hour+"  "+date.getMinutes()+" "+minute+" "+date.getSeconds()+" "+second); 
        if (date.getFullYear() !== year
          || date.getMonth() != month
          || date.getDate() !== day
          || date.getHours() !== hour
          || date.getMinutes() !== minute
          || date.getSeconds() !== second  ) {
           return false;
        } else {
           return true;
        }
    
    }
}
document.addEventListener("DOMContentLoaded",function()
{

    isd  = new mhrpanel();
    if(document.getElementById("msg_disg"))
    {
        var yg = "",disf="";
       
        for (yg in igi)
        {
            disf +="<img src='"+m_site+i_path+igi[yg]+"' > &nbsp;"+igim[yg]+"&nbsp;&nbsp;";
        
        } 
        document.getElementById("msg_disg").innerHTML=disf;
        
    }
   
   
   daterangepicker("mail_log_input",function(d){ 

        var nst_time = document.getElementById("sta_time").value.trim();
        var nd_time  = document.getElementById("end_time").value.trim();
        
        nst_time = nst_time.replace(/\s+/g,' ').trim();
        nd_time =  nd_time.replace(/\s+/g,' ').trim();
        if(nst_time == ""){
        nst_time ="00:00:00";

        }
        //var start111 = new Date(d.startdate);
       // var end111 = new Date(d.enddate);
       if(nd_time == "")
        {
        
        
           // if (start111.toDateString() === end111.toDateString()) {

            nd_time = "23:59:59";

            
 
            
        }
       stad = d.startdate+" "+nst_time;
       end_t = d.enddate+" "+nd_time;
       
       document.getElementById("mail_log_input").value = stad+" to "+ end_t;
        //isd.getmaillog(start_dt,end_dt);
    
    });
    
});
</script>