function jsHistoryRecord(){

};
jsHistoryRecord.CurrentHisGridSql=null;/*当前列表的查询字符串*/
/*是否修改统计——全部*/
jsHistoryRecord.IsEditAllCount=true;
/*历史通话记录中当前选择的行*/
jsHistoryRecord.CurHistoryListSelectedMainRow=null;


jsHistoryRecord.LoadHistoryRecordUI=function(){
    var arrString=[];
    arrString.push('<div id="divHistorySearch" class="div-search div-multi-search" style="height:65px;">');
    arrString.push('<table id="tbHistorySearch" cellpadding="0" cellspacing="0">');
    arrString.push('<tr><td colspan="6" id="tdHisCallTypeContanier">');
    arrString.push('<input type="checkbox" onclick="jsHistoryRecord.HistoryRecordSearchString()" value="-1" /><span>全部[&nbsp;<span id="callTypeAll">0</span>&nbsp;]</span>');
    arrString.push('<input  type="checkbox" onclick="jsHistoryRecord.HistoryRecordSearchString()" value="1"/><span>来电[&nbsp;<span id="callTypeCome">0</span>&nbsp;]</span>');
    arrString.push('<input  type="checkbox" onclick="jsHistoryRecord.HistoryRecordSearchString()" value="2"/><span>去电[&nbsp;<span id="callTypeGo">0</span>&nbsp;]</span>');
    arrString.push('<input type="checkbox" onclick="jsHistoryRecord.HistoryRecordSearchString()" value="0"/><span>未接[&nbsp;<span  id="callTypeOther">0</span>&nbsp;]</span>');
    arrString.push("</td></tr>");
    arrString.push('<tr><td>通话时间:从</td><td class="td120"><input id="txtBeginHistoryTime" type="text" /></td>');
    arrString.push('<td>到</td><td class="td120"><input id="txtEndHistoryTime" type="text" /></td>');
    arrString.push("<td>电话号码:</td><td>");
    arrString.push('<input id="txtHisTeleNumber" type="text" class="inputbox"/>&nbsp;<input id="btnSearch" type="button" value="搜索" class="button"/></td>');
    arrString.push("</tr>");
    arrString.push("</table>");
    arrString.push("</div>");
    arrString.push('<table id="tbHistoryCallList" style="display:none;"></table>');
    document.getElementById("divHistoryCall").innerHTML=arrString.join("");
};



/*历史通话记录*/
jsHistoryRecord.HistoryCallGrid=null;
jsHistoryRecord.LoadHistoryCallList = function() {
    var w = $("#middleContanier").width() - 2;
    var gh = 145;
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    if (window.ActiveXObject) {
        Sys.ie = ua.match(/msie ([\d.]+)/)[1]
    }
    if (Sys.ie == "6.0") {
        gh = 112;
    }
    var Option =
    {
        height: gh,
        //        width: w,
        colModel: [
            { display: 'ID', name: 'BILLID', width: (w * 0.1), sortable: false, align: 'left', hide: true },
            { display: '电话号码', name: 'TELNUM', width: (w * 0.1), sortable: true, align: 'left' ,process:jsHistoryRecord.FormatTelnum},
            { display: '类型', name: 'CALLTYPE', width: (w * 0.05), sortable: true, align: 'left' },
            { display: '归属地', name: 'AREATXT', width: (w * 0.15), sortable: true, align: 'left' },
            { display: '名字', name: 'CUSTOMER', width: (w * 0.1), sortable: true, align: 'left' },
            { display: '通话时长', name: 'TALKLENGTH', width: (w * 0.08), sortable: true, align: 'left' },
            { display: '通话时间', name: 'CALLTIME', width: (w * 0.12), sortable: true, align: 'left' },
            { display: '录音', name: 'MP3ID', width: (w * 0.08), sortable: true, align: 'center', process: jsHistoryRecord.FormAudio },
            { display: '通话状态', name: 'Type', width: (w * 0.1), sortable: true, align: 'left', process: jsHistoryRecord.FormatCallState, processType: 'select' },
            { display: '通话备注', name: 'REMARK', width: (w * 0.08), sortable: true, align: 'left',process:jsHistoryRecord.FormatRemark }
        ],
        customFunction: jsHistoryRecord.ShowHistoryRecordPage,
        rowhandler: jsHistoryRecord.HistoryCallListRowClick,
            rowcheckboxselect: false,
            selectedonclick: true,
        rp: 5,
        rowbinddata: true,
        sortname: 'BILLID',
        sortorder: 'desc'
    };
    jsHistoryRecord.HistoryCallGrid = $("#tbHistoryCallList").ikegrid(Option);
    Option = null;
};

jsHistoryRecord.FormatRemark=function(value,pid,rows){
    if(value.toString()!="")
    {
        var strValue=unescape(value.toString()).length>10?unescape(value.toString()).substring(0,10)+"...":unescape(value.toString());
        return '<a href="#" title='+unescape(value.toString())+'>'+strValue+'</a>';
    }
};

/*电话号码播号*/
jsHistoryRecord.FormatTelnum=function( value, pid, rows) {
    if($.trim(value.toString())!="")
    {
        var strContent=value.toString();
        var PhoneTypeName=window.parent.jsTitle.TelephoneTypeName;
        var strShowContent="";
        
        if(PhoneTypeName=="E6" || PhoneTypeName=="E7")
        {
            strShowContent = '<img alt="拨打" src="images/Tel.Gif" onclick="jsHistoryRecord.PeopleDialImageClick(\'' + rows["TELNUM"] + '\')" width="13px" height="13px" title="拨打电话"/>';
        }
        strShowContent+='<img alt="添加到拨号台" src="../AppFrame/APICss/default/images/icons/Item.Add.gif" onclick="jsHistoryRecord.TurnToTxtDialTelNo(\'' + rows["TELNUM"] + '\',\'\')" width="13px" height="13px" title="添加到拨号台"/>&nbsp;' + value.toString() + '';

        return strShowContent;
    }
};

jsHistoryRecord.PeopleDialImageClick=function(telNum){
    try
    {
       if(window.parent.PhoneHelper.Telphone_IsConnection()){
            /*只有不是在拨打电话的状态下才能促发拨号事件*/
            if(window.parent.jsRightMessage.isPhoning==false)
            {
                window.parent.jsRightMessage.isPhoning=true;
                if(telNum!="")
                {
                    window.parent.execScript("jsTitle.Dial('"+telNum+"');");
                }
                telNum=null;
            }
        }else{
            alert("话机未连接！");
        }
    }
    catch(e)
    {
        alert("jsTelBillCenterContent.PeopleDialImageClick:"+e.message);
    }
    CollectGarbage();
};
/*添加到拨号台*/
jsHistoryRecord.TurnToTxtDialTelNo=function(telNum, userName) {
    var strInnerHTML = "";
    var editorbody = window.parent.jsRightMessage.GetTxtWaitCallItem();
    /*创建号码集合载体*/
    var itemList = editorbody.getElementsByTagName("P");
    if (itemList.length == 0 && editorbody.innerText !="") {
        strInnerHTML += "<p>" + editorbody.innerText + "</p>";
    }
    else {
        for (var i = 0; i < itemList.length; i++) {
            if(itemList[i].innerText !=""){
                 strInnerHTML += "<p>" + itemList[i].innerText + "</p>";
            }
        }
    }
    if ($.trim(telNum) != "" && telNum != undefined && strInnerHTML.indexOf(telNum) == -1) {
        if (userName != "" && userName.toString() != "undefined") {
            strInnerHTML += "<p>" + telNum + "|" + userName + "</p>";
        } else {
            strInnerHTML += "<p>" + telNum + "</p>";
        }
        window.parent.jsRightMessage.LoadInfoToTxtWaitCall(strInnerHTML);
        strInnerHTML = null;
        CollectGarbage();
    }
};

/*单击行*/
jsHistoryRecord.HistoryCallListRowClick=function(target){
    $(target).click(function() {
        if (!window.parent.jsTitle.IsHoldOn) {/*非通话状态下查看通话备注*/
            jsHistoryRecord.CurHistoryListSelectedMainRow = $(target);
            window.parent.jsRightMessage.LoadRemarkWhenClickCallBillRow($(target).attr("REMARK"));
        }

       /* $(target).addClass("trSelected");
        target.childNodes[0].childNodes[0].children[0].checked = true;
        ===============*/
    });  
}

/*通话状态*/
jsHistoryRecord.FormatCallState=function(value,pid,rows){
    var valueArr;
    if(rows["CALLTYPE"].toString()=="去电")
    {
         valueArr=[{Value:"无"},{Value:"对方已接"},{Value:"对方拒接"},{Value:"对方没空"},{Value:"非本人接听"},{Value:"无人接听"},{Value:"号码不对"},{Value:"对方回拨"},{Value:"稍候再拨"},{Value:"对方通话中"}];
    }
    else
    {
        valueArr=[{Value:"无"},{Value:"咨询"},{Value:"投诉"},{Value:"报修"},{Value:"推销"}];
    }       
     var strSelect='<select style="width:98%;" id="selCallType_'+pid+'" onchange="jsHistoryRecord.WhenChangCallState(this,\''+rows["BILLID"]+'\')">';
       for(var i=0;i< valueArr.length;i++)
       {
            if(valueArr[i].Value==value.toString())
            {
               strSelect+=" <option selected='selected'>"+valueArr[i].Value+"</option>";
            }
            else
            {
                strSelect+=" <option>"+valueArr[i].Value+"</option>";
            }
       }
        strSelect+= "</select>";
        valueArr.length=0;
        valueArr=null;
        CollectGarbage();
        return strSelect;
}

/*更改通话状态*/
jsHistoryRecord.WhenChangCallState=function(obj,billID){
    var curSelType=obj.options[obj.selectedIndex].text; 
    var entity=jsEntity.CreateEntityByTableName_access("T_CALLBILL","","","","BILLID");   
    entity.Fields.BILLID=billID;
    entity.Fields.Type=curSelType;
    entity.Update(entity); 
    curSelType=null;
    DBReader.DisposeEntity(entity);
    CollectGarbage();
};

/*获取数据源*/
jsHistoryRecord.ShowHistoryRecordPage=function(pageSize, pageIndex, searchStr,extpara,order){
     var countTop=pageSize*(pageIndex-1);
     var strSql = "SELECT T_CALLBILL.BILLID,T_CALLBILL.TELNUM,iif(T_CALLBILL.CALLTYP=0,'未接',iif(T_CALLBILL.CALLTYP=1,'来电',iif(T_CALLBILL.CALLTYP=2,'去电'))) as CALLTYPE,T_CALLBILL.AREATXT,iif(ISNULL(T_CALLBILL.CUSTOMER),'无',T_CALLBILL.CUSTOMER) as CUSTOMER,T_CALLBILL.TALKLENGTH,T_CALLBILL.CALLTIME,T_MP3RECORD.MP3ID,T_CALLBILL.Type,T_CALLBILL.REMARK FROM T_Callbill left join T_MP3RECORD ON T_CALLBILL.BILLID=T_MP3RECORD.BILLID ";
    var strWhere =" where 1=1 " ;
  if (searchStr != "" && searchStr != undefined) {
        if(searchStr[0]._selType=="InComCall")
        {/*来电查询*/
            if(jsCommunicationQueryCondition.queryObj[0]._curTelNum!=""){
              strWhere += " and T_CALLBILL.TELNUM = '"+ jsCommunicationQueryCondition.queryObj[0]._curTelNum+"'";
            }
        }
         if(searchStr[0]._BeginTime !="" && searchStr[0]._BeginTime != null)
          {/*开始时间*/
               strWhere += " and T_CALLBILL.CALLTIME >=#"+ searchStr[0]._BeginTime +"#";
          }
         if(searchStr[0]._EndTime !="" && searchStr[0]._EndTime != null)
          {/*结束时间*/
              strWhere +=  " and T_CALLBILL.CALLTIME <= "+ searchStr[0]._EndTime ;
          }
         if(searchStr[0]._TelNum !="" && searchStr[0]._TelNum != null)
          {/*电话号码*/
            strWhere += " and T_CALLBILL.TELNUM like '%"+ searchStr[0]._TelNum +"%'";
          }
          /*通讯簿—联系人列表单击行电话参数*/
         if(searchStr[0]._EmpSearch !="" && searchStr[0]._EmpSearch!=null)
          {
            strWhere +=  " and ("+ searchStr[0]._EmpSearch   +")" ;
          }
          /*通讯簿—公司信息列表电话参数*/
         if(searchStr[0]._ComSearch!="" && searchStr[0]._ComSearch!=null)
          {
            strWhere += " and("+ searchStr[0]._ComSearch+")";
          }
         if(searchStr[0]._callType != "" && searchStr[0]._callType.toString().indexOf("-1")==-1)
         {/*值为-1时全部，0去电，1来电，2未接*/
            var arrType= searchStr[0]._callType.split(":");
            if(arrType.length>0){
                for(var i=0;i<arrType.length;i++){
                    if(arrType[i]!=-1){
                        if(strWhere.indexOf("T_CALLBILL.CALLTYP")!=-1){
                                strWhere += " or T_CALLBILL.CALLTYP = "+ arrType[i] ;
                        }
                        else{
                               strWhere += " and (T_CALLBILL.CALLTYP = "+ arrType[i] ;
                        }
                    }
                }
                strWhere+=")";
            }
            arrType.length=0;
            arrType=null;
        }

        if(strWhere.length==11)
        {
            strWhere+=" and T_CALLBILL.CALLTYP=-1";
        }
    }
    else{
        strWhere+=" and T_CALLBILL.CALLTYP=-1";
    }

    var strOrderBy="";
    if(order !="" && order != null)
   {
        if(order.indexOf("MP3ID") !=-1){
            order="T_MP3RECORD."+order
        }
        else{
            order="T_CALLBILL."+order;
        }
         var str=order.toUpperCase().replace(/ASC/i,"").replace(/DESC/i,"").replace(/\s/g, "");
        if(str !="T_CALLBILL.BILLID")
         {
            strOrderBy=order+",T_CALLBILL.BILLID DESC";
         }
        else
         {
            strOrderBy=order;
         }   
   }
   

  strSql += strWhere+" Order By "+strOrderBy;   
     //window.clipboardData.setData("text",strSql);
      /*记录当前查询语句，为获取话务数量查询使用*/
    jsHistoryRecord.CurrentHisGridSql=strSql;

    /*分页代码*/
    if(countTop >0){
         strSql="select TOP "+ pageSize +" (select count(T_CALLBILL.BILLID) from ( " + strSql +")) as AllCount, * from (" + strSql +") where T_CALLBILL.BILLID NOT IN (SELECT TOP "+ countTop +" T_CALLBILL.BILLID from (" + strSql + "))";
    }
    else{
        strSql="select TOP "+ pageSize +" (select count(T_CALLBILL.BILLID) from ( " + strSql +")) as AllCount,  * from (" + strSql +") ";
    }

    var strResult=DBReader.selectSqlForJson(strSql);
    var result;
    /*设置全部话务默认值*/
//    $("#callTypeAll").text("0");
    if(strResult!=null)
    {
        result=eval("[{"+strResult+"}]");
        /*设置全部数量*/
        if(jsHistoryRecord.IsEditAllCount){
            if(result[0].result=="1"){
                $("#sCallTypeAll").text(result[0].table[0].AllCount);
            }   
            else{
                 $("#sCallTypeAll").text("0");
            }
        }
        result[0].pageIndex=pageIndex;    
    }
    strResult=null;strOrderBy=null;

    CollectGarbage();
    return strResult=null?null:result[0];
};

/*清空*/
jsHistoryRecord.ClearHisSearch=function(){
   $("#txtBeginHistoryTime").val("");
   $("#txtEndHistoryTime").val("");
   $("#txtHisTeleNumber").val("");
   var chkItem = document.getElementsByName("chkHisoryCallType");
   chkItem[0].checked=true;   
   jsHistoryRecord.HistoryRecordSearchString();
};

 /*通话记录列表搜索*/
jsHistoryRecord.HistoryRecordSearchString=function(strType,val)
{
    try
    {
        var strWhere=[];
        var htxt_BeginTime=$("#txtBeginHistoryTime").val();
        var htxt_EndTime=$("#txtEndHistoryTime").val();
        var callNum=$("#txtHisTeleNumber").val().split('\"').join('“').split('\'').join('‘');
        var empID=jsOtherInfo.GetEmpID();            var comID=jsOtherInfo.GetComID();
         var strCallType=""; 
         if(empID>0 || comID>0){
             var parObj=document.getElementById("tdHisCallTypeContanier");
             var chkItem=parObj.getElementsByTagName("input"); 
                 if (val == -1) {
                strCallType = val;
            }
            for (var i = 0; i < chkItem.length; i++) {
                if (chkItem[i].type == "checkbox") {
                    if (val != undefined) {
                        if (val == -1 && chkItem[i].value != -1) {
                            chkItem[i].checked = false;
                        } else if (val != -1) {
                            if (chkItem[i].value == -1) {
                                chkItem[i].checked = false;
                            } else {
                                if (chkItem[i].checked == true) {
                                    if (strCallType != "") {
                                        strCallType += ":";
                                    }
                                    strCallType += chkItem[i].value;
                                }
                            }
                        }
                    } else {
                        if (chkItem[i].checked == true) {
                            if (strCallType != "") {
                                strCallType += ":";
                            }
                            strCallType += chkItem[i].value;
                        }
                    }
                }
            }
            parObj=null;
            chkItem=null;
        }
        var strEmpSearch="";
        if(strType!="InComCall"){
             if(empID!=undefined && empID>0){
                 strEmpSearch= jsHistoryRecord.GetTelSearchStringForEmpModel(empID);
             }
        }

        var strComSearch="";
        if(strType!="InComCall"){
            if(comID!=undefined && comID>0){
                  strComSearch= jsHistoryRecord.GetTelSearchStringForComModel(comID);
            }
        }  
        /*主表没有选择数据时无法查询*/
        if(empID=="" && comID==""){
            htxt_BeginTime="";htxt_EndTime="";
            callNum="";
        }
        strWhere.push({_BeginTime:htxt_BeginTime,_EndTime:htxt_EndTime,_TelNum:callNum,_callType:strCallType,_selType:strType,_EmpSearch:strEmpSearch,_ComSearch:strComSearch});
        if (strType != "chk") {
            jsHistoryRecord.IsEditAllCount = true;
        }
        else {/*单击统计复选框时不再统计数目*/
            jsHistoryRecord.IsEditAllCount = false;
        }
        $("#tbHistoryCallList").DoSearch(strWhere);
        
        if(strType!="chk"){
            jsHistoryRecord.GetCallRecordCount();
        }
    }
    catch(e)
    {
        alert("jsHistoryRecord.HistoryRecordSearchString:"+e.message);
    }
    htxt_BeginTime=null;htxt_EndTime=null;
    callNum=null;empID=null;comID=null;
    strCallType=null;
    strBookListSearch=null;
    CollectGarbage();
}

/*公司模式下根据公司ID获得查询条件串*/
jsHistoryRecord.GetTelSearchStringForComModel=function(comID){
   var returnResult="";
   var strSql="SELECT MOBILE as TEL,TEL1,TEL2 FROM T_EMPLOYEE  WHERE COMPANY_ID="+comID;
   strSql+=" union ";
   strSql+=" SELECT TEL,'' as TEL1, '' as TEL2 from T_COMPANY where COMPANY_ID="+comID;
   var obj= DBReader.selectSqlForJson(strSql);
    if(obj!=null)
    {
        var result=eval("[{"+obj+"}]");
        if(result[0].result==1 && result[0].table!=undefined)
        {
            for(var i=0;i<result[0].table.length;i++){
               if (result[0].table[i].TEL != undefined && result[0].table[i].TEL != "" ) {
                    if (returnResult != ""){
                        returnResult += " or ";
                    }
                    returnResult += "  T_CALLBILL.TELNUM='" + result[0].table[i].TEL+ "'";
                }
                if (result[0].table[i].TEL1 != undefined && result[0].table[i].TEL1 != "" ) {
                    if (returnResult != "") {
                        returnResult += " or ";
                    }
                    returnResult += " T_CALLBILL.TELNUM='" +result[0].table[i].TEL1  + "'";
                }
                if (result[0].table[i].TEL2  != undefined && result[0].table[i].TEL2 != "" ) {
                    if (returnResult != "") {
                        returnResult += " or ";
                    }
                    returnResult += "  T_CALLBILL.TELNUM='" + result[0].table[i].TEL2+ "'";
                }
            }
        }
        result=null;
    }    
    strSql=null;
    obj=null;
    CollectGarbage();
    return returnResult;
}

/*获取联系人模式下号码查询条件*/
jsHistoryRecord.GetTelSearchStringForEmpModel=function(empID){
    var returnResult="";
     /*联系人模式*/
    var strSql="SELECT T_COMPANY.TEL,T_EMPLOYEE.MOBILE,T_EMPLOYEE.TEL1,T_EMPLOYEE.TEL2 FROM T_EMPLOYEE LEFT JOIN T_COMPANY ON T_EMPLOYEE.COMPANY_ID=T_COMPANY.COMPANY_ID WHERE T_EMPLOYEE.EMPLOYEE_ID="+empID;
    var strResult=DBReader.selectSqlForJson(strSql);
    var result;
    if(strResult!=null)
    {
        result=eval("[{"+strResult+"}]");
        if(result[0].result==1 && result[0].table!=undefined){
             if (result[0].table[0].TEL != undefined && result[0].table[0].TEL!= "") {
                 returnResult += " T_CALLBILL.TELNUM='" + result[0].table[0].TEL+ "'";
            }
            if (result[0].table[0].MOBILE != undefined && result[0].table[0].MOBILE != "") {
                if (returnResult != "") {
                    returnResult += " or ";
                }
                returnResult += "  T_CALLBILL.TELNUM='" + result[0].table[0].MOBILE+ "'";
            }
            if (result[0].table[0].TEL1 != undefined && result[0].table[0].TEL1 != "") {
                if (returnResult != "") {
                    returnResult += " or ";
                }
                returnResult += " T_CALLBILL.TELNUM='" +result[0].table[0].TEL1  + "'";
            }
            if (result[0].table[0].TEL2  != undefined && result[0].table[0].TEL2 != "") {
                if (returnResult != "") {
                    returnResult += " or ";
                }
                returnResult += "  T_CALLBILL.TELNUM='" + result[0].table[0].TEL2+ "'";
            }
        }
    }      
    result=null;
    strResult=null;
    strSql=null;
    CollectGarbage();
    return returnResult;
};

/*播放按钮*/
jsHistoryRecord.FormAudio=function(value,pid,rows){
    var resultStr="";
    if(rows["MP3ID"]==0)
    {
        resultStr='无';
    }
    else
    { 
        resultStr='<button class="button" onclick="jsHistoryRecord.BindPlayEvent(this,'+rows["MP3ID"]+',\''+value+'\');">播放</button>';
    }
    return resultStr;
};

/*记录播放按钮对象*/
jsHistoryRecord.PlayActionButton=null;
/*播放录音*/
jsHistoryRecord.BindPlayEvent=function(obj,MP3ID,value){
 if($(obj).text()=="播放")
    {
        /*只有在不提机状态才能播放*/
        if(parent.jsTitle.IsHoldOn==false)
        {
            if(jsHistoryRecord.PlayActionButton!=null)
            {
                $(jsHistoryRecord.PlayActionButton).text("播放");
            }
            /*因为现在播放完录音的时候无法让播放按钮恢复成停止状态，所以需要先注释*/
            /*$(obj).text("停止");*/
            /*---------------------------------------------------------------------*/
            /*播放录音，传入录音文件名"."表示程序当前目录*/
            var getMp3Sql="SELECT FNAME FROM T_MP3RECORD WHERE MP3ID="+MP3ID;
            var DataString=DBReader.selectSqlForJson(getMp3Sql);
            if(DataString!=null)
            {
                var dataObj=eval("[{"+DataString+"}]");
                if(dataObj[0].result==1)
                {
                    var FileName=dataObj[0].table[0].FNAME;
                    var path=App.ApplicationPath()+"\Records\\"+FileName;
                    window.parent.jsRightAudio.Play(path.split('\\').join('\\\\'));//"./Records/梦里水乡.MP3");
                    path=null;
                    FileName=null;
                }
                dataObj.length=0;
                dataObj=null;
            }
            DataString=null;
            jsHistoryRecord.PlayActionButton=obj;
            /*显示播放器*/
            window.parent.jsRightMessage.RightUIShow("audioCondition");
        }
    }
    else
    {
         $(obj).text("播放");
        /*传入参数，是否为播放本地文件，本次是播放本地文件*/
         window.parent.jsRightAudio.StopPlay(true);
         jsHistoryRecord.PlayActionButton=null;
    }
    CollectGarbage();
};

/*获取话务数量*/
jsHistoryRecord.GetCallRecordCount=function(){
    try
    {
        /*设置话务默认值*/
        /*去电数量*/
        $("#scallTypeGo").text("0");
        /*来电数量*/
        $("#scallTypeCome").text("0"); 
        /*未接数量*/
        $("#scallTypeNot").text("0");
        /*从当前查询语句中抽取出对应类型的数据量*/
        if(jsHistoryRecord.CurrentHisGridSql!="")
        {
            var strSql='select Count(CALLTYPE) as CALLTYPCount,CALLTYPE from('+jsHistoryRecord.CurrentHisGridSql+')_AllDataBill group by CALLTYPE';
            var dataString=DBReader.selectSqlForJson(strSql);
            if(dataString!=null)
            {
                var dataObj=eval("[{"+dataString+"}]");
                if(dataObj[0].result=="1")
                {
                    var itemLen=dataObj[0].table.length;
                    for(var i=0;i<itemLen;i++)
                    {
                        if(dataObj[0].table[i].CALLTYPE=="去电")
                        {
                            /*去电数量*/
                            $("#scallTypeGo").text(dataObj[0].table[i].CALLTYPCount);
                        }
                        else if(dataObj[0].table[i].CALLTYPE=="来电")
                        {
                            /*来电数量*/
                            $("#scallTypeCome").text(dataObj[0].table[i].CALLTYPCount); 
                        }
                        else if(dataObj[0].table[i].CALLTYPE=="未接")
                        {
                            /*未接数量*/
                            $("#scallTypeNot").text(dataObj[0].table[i].CALLTYPCount);
                        }
                    }
                    itemLen=null;
                }
                dataObj=null;
            }
            strSql=null;
            dataString=null;
        }
    }
    catch(e)
    {
        alert("jsHistoryRecord.GetCallRecordCount Eorr:"+e.message);
    }
    CollectGarbage();
}

/*单击历史通话记录便签时操作*/
jsHistoryRecord.LoadHistoryCallListTab=function()
{   
    jsCallMiddlePanel.listNo="HistoryRecord";     
    showTime("txtBeginHistoryTime","txtEndHistoryTime",false,80);/*服务记录搜索开始与结束时间*/  
    jsHistoryRecord.LoadHistoryCallList();/*加载列表*/
    jsHistoryRecord.GetCallRecordCount();/*绑定统计*/
    
    if(jsOtherInfo.GetComID()>0 || jsOtherInfo.GetEmpID()>0){
         jsHistoryRecord.HistoryRecordSearchString('','',jsOtherInfo.GetComID(),jsOtherInfo.GetEmpID());
    }
}
