| Line 560... |
Line 560... |
| 560 |
fetch('/indent/rbm_call_target/called_details?authId=' + authId + '&agentName=' + encodeURIComponent(rbmName) + dateParam)
|
560 |
fetch('/indent/rbm_call_target/called_details?authId=' + authId + '&agentName=' + encodeURIComponent(rbmName) + dateParam)
|
| 561 |
.then(function (response) {
|
561 |
.then(function (response) {
|
| 562 |
return response.json();
|
562 |
return response.json();
|
| 563 |
})
|
563 |
})
|
| 564 |
.then(function (data) {
|
564 |
.then(function (data) {
|
| 565 |
// Filter out break log entries — only show actual calls
|
- |
|
| 566 |
var calls = (data || []).filter(function (d) {
|
- |
|
| 567 |
return !d.breakLog;
|
- |
|
| 568 |
});
|
- |
|
| 569 |
if (calls.length > 0) {
|
565 |
if (data && data.length > 0) {
|
| 570 |
var html = '<table class="table table-bordered table-sm"><thead><tr><th>S.No</th><th style="width: 200px;">Party Name</th><th>Code</th><th style="width: 350px;">Remark</th><th>Call Status</th><th>Call Duration</th><th>Call Date/Time</th><th>Recording</th></tr></thead><tbody>';
|
566 |
var html = '<table class="table table-bordered table-sm"><thead><tr><th>S.No</th><th style="width: 200px;">Party Name</th><th>Code</th><th style="width: 350px;">Remark</th><th>Call Status</th><th>Call Duration</th><th>Call Date/Time</th><th>Recording</th></tr></thead><tbody>';
|
| 571 |
for (var i = 0; i < calls.length; i++) {
|
567 |
for (var i = 0; i < data.length; i++) {
|
| - |
|
568 |
var rowStyle = '';
|
| 572 |
var recordingHtml = '-';
|
569 |
var recordingHtml = '-';
|
| - |
|
570 |
|
| - |
|
571 |
// Break log entry — show inline with calls (sorted by time)
|
| - |
|
572 |
if (data[i].breakLog) {
|
| - |
|
573 |
var status = (data[i].breakStatus || '').toLowerCase();
|
| - |
|
574 |
if (status.indexOf('available') >= 0) {
|
| - |
|
575 |
rowStyle = 'style="background-color: #f8d7da; color: #721c24;"'; // Light red
|
| - |
|
576 |
} else if (status.indexOf('trying') >= 0) {
|
| - |
|
577 |
rowStyle = 'style="background-color: #fff3cd; color: #856404;"'; // Light yellow
|
| - |
|
578 |
} else if (status.indexOf('logged out') >= 0 || status.indexOf('logout') >= 0) {
|
| - |
|
579 |
rowStyle = 'style="background-color: #e2e3e5; color: #383d41;"'; // Light grey
|
| - |
|
580 |
} else if (status.indexOf('break') >= 0) {
|
| - |
|
581 |
rowStyle = 'style="background-color: #ffe5cc; color: #c45200;"'; // Light orange
|
| - |
|
582 |
} else {
|
| - |
|
583 |
rowStyle = 'style="background-color: #f8f9fa; color: #333;"'; // Default light
|
| - |
|
584 |
}
|
| - |
|
585 |
var timeRange = data[i].callDateTime || '-';
|
| - |
|
586 |
if (data[i].breakEndTime) {
|
| - |
|
587 |
var startTime = timeRange.split(' ').slice(-2).join(' '); // Get "hh:mm AM/PM"
|
| - |
|
588 |
timeRange = startTime + ' to ' + data[i].breakEndTime;
|
| - |
|
589 |
}
|
| - |
|
590 |
html += '<tr ' + rowStyle + '><td>' + (i + 1) + '</td><td colspan="4"><i class="fa fa-coffee"></i> ' + (data[i].breakStatus || 'On Break') + '</td><td>' + (data[i].callDuration || '-') + '</td><td>' + timeRange + '</td><td>-</td></tr>';
|
| - |
|
591 |
} else {
|
| 573 |
if (calls[i].recordingUrl) {
|
592 |
if (data[i].recordingUrl) {
|
| 574 |
recordingHtml = '<audio controls style="width: 150px; height: 30px;"><source src="' + calls[i].recordingUrl + '" type="audio/mpeg">Your browser does not support audio.</audio>';
|
593 |
recordingHtml = '<audio controls style="width: 150px; height: 30px;"><source src="' + data[i].recordingUrl + '" type="audio/mpeg">Your browser does not support audio.</audio>';
|
| - |
|
594 |
}
|
| - |
|
595 |
html += '<tr><td>' + (i + 1) + '</td><td>' + data[i].partyName + '</td><td>' + data[i].code + '</td><td>' + data[i].remark + '- ' + (data[i].message || '-') + '</td><td>' + (data[i].callStatus || '-') + '</td><td>' + (data[i].callDuration || '-') + '</td><td>' + (data[i].callDateTime || '-') + '</td><td>' + recordingHtml + '</td></tr>';
|
| 575 |
}
|
596 |
}
|
| 576 |
html += '<tr><td>' + (i + 1) + '</td><td>' + calls[i].partyName + '</td><td>' + calls[i].code + '</td><td>' + calls[i].remark + '- ' + (calls[i].message || '-') + '</td><td>' + (calls[i].callStatus || '-') + '</td><td>' + (calls[i].callDuration || '-') + '</td><td>' + (calls[i].callDateTime || '-') + '</td><td>' + recordingHtml + '</td></tr>';
|
- |
|
| 577 |
}
|
597 |
}
|
| 578 |
html += '</tbody></table>';
|
598 |
html += '</tbody></table>';
|
| 579 |
document.getElementById('calledDetailsContent').innerHTML = html;
|
599 |
document.getElementById('calledDetailsContent').innerHTML = html;
|
| 580 |
} else {
|
600 |
} else {
|
| 581 |
document.getElementById('calledDetailsContent').innerHTML = '<p>No called partners found.</p>';
|
601 |
document.getElementById('calledDetailsContent').innerHTML = '<p>No called partners found.</p>';
|