<table>
    <colgroup>
        <col width="18px">
        <col width="calc(20% - 9px)">
        <col width="calc(20% - 9px)">
        <col width="10%">
        <col width="10%">
        <col width="10%">
        <col width="10%">
        <col width="10%">
        <col width="10%">
    </colgroup>
    <thead>
        <tr>
            <th></th>
            <th colspan="2">전송일시</th>
            <th colspan="2">소통정보</th>
            <th colspan="2">소통정보</th>
            <th colspan="2">민간교통정보</th>
        </tr>
        <tr>
            <th></th>
            <th>시작일시</th>
            <th>종료일시</th>
            <th>수신횟수</th>
            <th>수신건수</th>
            <th>송신횟수</th>
            <th>송신건수</th>
            <th>송신횟수</th>
            <th>송신건수</th>
        </tr>
    </thead>
    <tbody></tbody>
    <tfoot></tfoot>
</table>
<script>
    const endPoint = "getCenterSendRecCount";

    function callBack(data) {
        if (data && data.length) {
            let rcvTot = 0;
            let sendTot = 0;
            let moctTot = 0;
            let rcvDtTot = 0;
            let sendDtTot = 0;
            let moctDtTot = 0;
            data.forEach((obj)=>{
                rcvTot += Number(obj.recvCount) || 0;
                rcvDtTot += Number(obj.recvDataCnt) || 0;
                sendTot += Number(obj.sendCount) || 0;
                sendDtTot += Number(obj.sendDataCnt) || 0;
                moctTot += Number(obj.moctCount) || 0;
                moctDtTot += Number(obj.moctDataCnt) || 0;

            });
            return `<tr>
                      <td></td>
                      <td colspan="2">합계</td>
                      <td>${rcvTot.toLocaleString()}</td>
                      <td>${rcvDtTot.toLocaleString()}</td>
                      <td>${sendTot.toLocaleString()}</td>
                      <td>${sendDtTot.toLocaleString()}</td>
                      <td>${moctTot.toLocaleString()}</td>
                      <td>${moctDtTot.toLocaleString()}</td>
                    </tr>`;
        }
    }

    function getTableRow(obj, idx) {
        let recvCount  = Number(obj.recvCount) || 0;
        let recvDtCnt  = Number(obj.recvDataCnt) || 0;
        let sendCount = Number(obj.sendCount) || 0;
        let sendDtCnt = Number(obj.sendDataCnt) || 0;
        let moctCount = Number(obj.moctCount) || 0;
        let moctDtCnt = Number(obj.moctDataCnt) || 0;

        return `<tr onclick="rowClick(this, 'container-2 table tbody')" >
                    <td><input style="display: none" type="checkbox" id="check_${idx}" onchange="checkEvent(this, 'container-2 table tbody')"></td>
                    <td>${obj.startTime}</td>
                    <td>${obj.endTime}</td>
                    <td>${recvCount.toLocaleString()}</td>
                    <td>${recvDtCnt.toLocaleString()}</td>
                    <td>${sendCount.toLocaleString()}</td>
                    <td>${sendDtCnt.toLocaleString()}</td>
                    <td>${moctCount.toLocaleString()}</td>
                    <td>${moctDtCnt.toLocaleString()}</td>
                </tr>`;
    }
</script>