Modify FreePBX call reports to show destination channel

FreePBX‘s Reports module does not show the destination channel–for example, the outbound trunk, or the device that received an incoming call–by default. But you can customize the call log display without editing the module itself. The Reports module looks for a file at /etc/asterisk/call-log-table.php, and if it finds the file, uses the declarations within to redefine the column layout. I took the default and modified it to include the Destination Channel column.

Just create a new file at /etc/asterisk/call-log-table.php with the following contents:

<?php   $FG_TABLE_COL[]=array ("Timestamp", "calldate", "12%", "center", "SORT", "19");
        $FG_TABLE_COL[]=array ("Src Chan", "channel", "14%", "center", "", "30", "",
"", "", "", "", "display_acronym");
        $FG_TABLE_COL[]=array ("Source", "src", "10%", "center", "", "30");
        $FG_TABLE_COL[]=array ("CLID", "clid", "25%", "center", "", "80",'','','','',
'','filter_html');
        $FG_TABLE_COL[]=array ("Dest", "dst", "10%", "center", "SORT", "30");
        $FG_TABLE_COL[]=array ("Dst Chan", "dstchannel", "14%", "center", "", "30",
"", "", "", "", "", "display_acronym");
        $FG_TABLE_COL[]=array ("Disposition", "disposition", "9%", "center", "", "30");
        if ((!isset($resulttype)) || ($resulttype=="min"))
$minute_function= "display_minute";
        $FG_TABLE_COL[]=array ("Duration", "duration", "6%", "center", "SORT", "30",
"", "", "", "", "", "$minute_function");

        $FG_TABLE_DEFAULT_ORDER = "calldate";
        $FG_TABLE_DEFAULT_SENS = "DESC";

        // This Variable stores the argument for the SQL query
        $FG_COL_QUERY='calldate, channel, src, clid, dst, dstchannel, disposition,
duration';
        $FG_COL_QUERY_GRAPH='calldate, duration';

        // The variable LIMITE_DISPLAY define the limit of record to display by page
        $FG_LIMITE_DISPLAY=25;

        // Number of column in the html table
        $FG_NB_TABLE_COL=count($FG_TABLE_COL);

        // The variable $FG_EDITION define if you want process to the edition of the
// database record
        $FG_EDITION=true;

        //This variable will store the total number of columns
        $FG_TOTAL_TABLE_COL = $FG_NB_TABLE_COL;
        if ((isset($FG_DELETION) && $FG_DELETION) || $FG_EDITION)
$FG_TOTAL_TABLE_COL++;

        //This variable define the Title of the HTML table
        $FG_HTML_TABLE_TITLE=" - Call Logs - ";

        //This variable define the width of the HTML table
        $FG_HTML_TABLE_WIDTH="100%";
?>

6 thoughts on “Modify FreePBX call reports to show destination channel”

  1. Just put this code in my etc/asterisk directory with MT’s mod to show more detail and sort. Very nice! No more digging around in the logfile to determine if outbound calls are using the right trunk. Thanks!!!

  2. THANK YOU!! I changed the first few lines (only about three or four of them, actually) as shown below and now it is perfect (for me, anyway):

    <?php $FG_TABLE_COL[]=array (“Timestamp”, “calldate”, “12%”, “center”, “SORT”, “19”);
    $FG_TABLE_COL[]=array (“Source Channel”, “channel”, “14%”, “center”, “”, “32”);
    $FG_TABLE_COL[]=array (“Source”, “src”, “10%”, “center”, “SORT”, “30”);
    $FG_TABLE_COL[]=array (“CLID”, “clid”, “25%”, “center”, “”, “80”,”,”,”,”,
    ”,’filter_html’);
    $FG_TABLE_COL[]=array (“Dest.”, “dst”, “10%”, “center”, “SORT”, “30”);
    $FG_TABLE_COL[]=array (“Dest. Channel”, “dstchannel”, “14%”, “center”, “”, “32”);

    Channels are now truncated to 32 characters (changed from 30, just needed a couple more to make it readily apparent in a few cases) but no trailing … which is fine by me.

    One thing I noticed is it appears you can make any column sortable just by adding the word “SORT” in the correct place (right after the field containing “center”). So I made the Source field sortable, so I can see calls placed sorted by source.

    This is great stuff, don’t know how you ever figured this out but if you have any more like this, please don’t hold back! 🙂

  3. Yes, this is totally customizable. Here are a couple ways.

    If you replace the “display_acronym” parameter at the end of the Src Chan and Dst Chan definitions with “”, or just remove all the parameters after the “30”, you’ll see the full string.

    Or you can write your own display_acronym function and put it in this same file, at the bottom before the ?>. For example, if you want the channels to be 14 characters long before the … instead of 10 characters:

    function display_acronym2($field) {
    echo ‘<acronym title=”‘.$field.'”>’.substr($field,0,14).’…</acronym>’;
    }

    Then in the original code I posted, just change display_acronym to display_acronym2 in the two places it appears.

  4. This is great, Bill! There’s just one other thing I’ve always disliked about the reports (especially since most of us are now using wide-screen displays) and that is how they truncate the Src Chan and now your new Dst Chan fields to an unreasonably low 10 characters, for example Gtalk/+121… which is so little information as to be useless. By any chance would you know how to increase that to say 20 characters on each field? The information must be available because the Elastix folks have their own reports module that displays the full source and destination channels (and even an account code, if one was used) but they omit the CLID field, which is every bit as important.

Comments are closed.