Accountcode Columns CDR Reports

I’m using trixbox FreePBX 2.2.0rc3, I added a pin set (with 12 pins) on a outbound route. When i look at my CDR database i have a column Accountcode with the an accountcode that was used to dial outside. Everything is working except the column Accountcode isn’t showing up in the CDR report. Is this a bug, or do i need to activate this? I’m hoping for a solution.

Regards

Daniel

Daniel,

I’d first upgrade to the latest 2.2 branch if at all possible. you are running a release canadate which had many bug fixes between then and the last version of 2.2.x.

Better yet would be to upgrade to either latest 2.3 or 2.4.

It is totaly possible it ia bug in the early 2.2 code that has already been addressed.

This issue seems to persist in FreePBX 2.5.1. Both export functions, PDF and CSV, only seem to return the follow fields:

  • calldate
  • channel
  • src
  • clid
  • dst
  • disposition
  • duration

I dug into the code, and it looks like in cdr/call-log.php the fields being accessed were changed for use in “AMP” (the old name of FreePBX, IIRC). I would imagine that changing things back would allow access to the “accesscode” field, but could also mess up other things. Hmmm. Perhaps a feature request is in order.

DionV

dionv, you are incorrect.

If you edit the cdr_mysql.conf file and add the line
userfield=1
and then restart asterisk it will then include that field.

Thanks for the tip, fskrotzki, but that doesn’t seem to work.

My test server already had that enabled, so I imported my CDR from my production server (because there are records in it with data in the accountcode field).

Ran a “Call Logs” report, and the accountcode field does not show up in the report, PDF or CSV. The data is in the database, but the Reports module won’t access it.

Test server has FreePBX 2.5.1 with all installed modules up-to-date as of today, 2009-04-09.

DionV

dionv,

Ok I’m sorry I was a little confused… We also keep the files from /var/log/asterisk/cdr-csv/Master.csv which have all those fields already defined in them and that’s what I was thinking of.

Way back the Web GUI reports were customized for some reason.

For the call-log you’ll need to edit /var/www/html/admin/cdr/call-log.php, go to about line 56. you should see the following:

/* --original--

Now look at the lines below that and you will see how to define those columns. Yes it’s all commented out down to line 82, and the current configuration it is using start at line 84.

so tweak it as you need.

fskrotzki,

That’s what I thought. I saw that in the code when I had replied before, which is why I mentioned it.

I didn’t have my test server going at that point, but now I do, so I am going to hack away.

If I can start displaying the accountcode in the reports, my accounting people will love me. They’d love me even more if I make it a searchable item. :wink:

DionV

Well, I tested it out on my test server, even added back the Account Code search field.

In my /var/www/html/admin/cdr/call-log.php, line 75 in the “original” section contains:

$FG_TABLE_COL[]=array ("Accountcode", "accountcode", "8%", "center", "", "20");

So I copied and pasted it to line 97, just after the line for the Duration field.

Note, change the “” there just before the “20” so that it says “SORT”, and the Accountcode column will be sortable. Nice! Like this:

$FG_TABLE_COL[]=array ("Accountcode", "accountcode", "8%", "center", "SORT", "20");

EDIT: I forgot! Also around Line 105, add “accountcode” to the query variable:

$FG_COL_QUERY='calldate, channel, src, clid, dst, disposition, duration, accountcode';

I noticed later in the file, around line 484 through to around 521, that some lines were commented out with “AMP”, including the Account Code search box. So, I uncommented the Account code search box lines.

After saving, and refreshing the reports page, I now have a search box for Account Code showing up in between “Source” and “Channel”, and a new column at the end of the search results for Account Code.

Now, on my test box at least, I can search by Account code if I want, but all search will show the Accountcode column, and the CSV and PDF export have it. My accounting folks are itching to try it for real! :smiley:

DionV

Dion,

Thanks for the information so far, this is exactly what my accounts people are crying out for as well.

I have made the changes you detail above, but not being a php person I am struggling with the piece where you say between lines 484 and 521.

Would it be possible to show which lines these are please and what needs to be done to them?

Thanks again.

rlm

rlm,

Sorry for the delay. Here’s the section you are requesting,

Original file:

<!-- AMP                        <tr>
                                <td class="bar-search" align="left" bgcolor="#555577">
                                        <font face="verdana" size="1" color="#ffffff"><b>&nbsp;&nbsp;CLI</b></font>
                                </td>
                                <td class="bar-search" align="left" bgcolor="#cddeff">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;&nbsp;<INPUT TYPE="text" NAME="clid" value="<?php echo $clid?>
"></td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="1" <?php if((!isset($clidtype))||($clidt
ype==1)){?>checked<?php }?>>Exact</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="2" <?php if($clidtype==2){?>checked<?php
 }?>>Begins with</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="3" <?php if($clidtype==3){?>checked<?php
 }?>>Contains</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="4" <?php if($clidtype==4){?>checked<?php
 }?>>Ends with</td>
                                </tr></table></td>
                        </tr>
                        <tr>
                                <td align="left" bgcolor="#000033">
                                        <font face="verdana" size="1" color="#ffffff"><b>&nbsp;&nbsp;USERFIELD</b></font>
                                </td>
                                <td class="bar-search" align="left" bgcolor="#acbdee">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#acbdee"><tr><td>&nbsp;&nbsp;<INPUT TYPE="text" NAME="userfield" va
lue="<?php echo "$userfield";?>"></td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="1" <?php if((!isset($userfieldtype)
)||($userfieldtype==1)){?>checked<?php }?>>Exact</td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="2" <?php if($userfieldtype==2){?>ch
ecked<?php }?>>Begins with</td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="3" <?php if($userfieldtype==3){?>ch
ecked<?php }?>>Contains</td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="4" <?php if($userfieldtype==4){?>ch
ecked<?php }?>>Ends with</td>
                                </tr></table></td>
                        </tr>
                        <tr>
                                <td class="bar-search" align="left" bgcolor="#555577">
                                        <font face="verdana" size="1" color="#ffffff"><b>&nbsp;&nbsp;ACCOUNTCODE</b></font>
                                </td>
                                <td class="bar-search" align="left" bgcolor="#cddeff">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;&nbsp;<INPUT TYPE="text" NAME="accountcode" value="<?php echo
$accountcode?>"></td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="1" <?php if((!isset($accountcodet
ype))||($accountcodetype==1)){?>checked<?php }?>>Exact</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="2" <?php if($accountcodetype==2){
?>checked<?php }?>>Begins with</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="3" <?php if($accountcodetype==3){
?>checked<?php }?>>Contains</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="4" <?php if($accountcodetype==4){
?>checked<?php }?>>Ends with</td>
                                </tr></table></td>
                        </tr>
-->

And then the changes I made:

<!-- AMP                        <tr>
                                <td class="bar-search" align="left" bgcolor="#555577">
                                        <font face="verdana" size="1" color="#ffffff"><b>&nbsp;&nbsp;CLI</b></font>
                                </td>
                                <td class="bar-search" align="left" bgcolor="#cddeff">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;&nbsp;<INPUT TYPE="text" NAME="clid" value="<?php echo $clid?>
"></td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="1" <?php if((!isset($clidtype))||($clidt
ype==1)){?>checked<?php }?>>Exact</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="2" <?php if($clidtype==2){?>checked<?php
 }?>>Begins with</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="3" <?php if($clidtype==3){?>checked<?php
 }?>>Contains</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="clidtype" value="4" <?php if($clidtype==4){?>checked<?php
 }?>>Ends with</td>
                                </tr></table></td>
                        </tr>
                        <tr>
                                <td align="left" bgcolor="#000033">
                                        <font face="verdana" size="1" color="#ffffff"><b>&nbsp;&nbsp;USERFIELD</b></font>
                                </td>
                                <td class="bar-search" align="left" bgcolor="#acbdee">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#acbdee"><tr><td>&nbsp;&nbsp;<INPUT TYPE="text" NAME="userfield" va
lue="<?php echo "$userfield";?>"></td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="1" <?php if((!isset($userfieldtype)
)||($userfieldtype==1)){?>checked<?php }?>>Exact</td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="2" <?php if($userfieldtype==2){?>ch
ecked<?php }?>>Begins with</td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="3" <?php if($userfieldtype==3){?>ch
ecked<?php }?>>Contains</td>
                                <td class="bar-search" align="center" bgcolor="#acbdee"><input type="radio" NAME="userfieldtype" value="4" <?php if($userfieldtype==4){?>ch
ecked<?php }?>>Ends with</td>
                                </tr></table></td>
                        </tr>
-->
                        <tr>
                                <td class="bar-search" align="left" bgcolor="#555577">
                                        <font face="verdana" size="1" color="#ffffff"><b>&nbsp;&nbsp;ACCOUNTCODE</b></font>
                                </td>
                                <td class="bar-search" align="left" bgcolor="#cddeff">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;&nbsp;<INPUT TYPE="text" NAME="accountcode" value="<?php echo
$accountcode?>"></td>

                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="1" <?php if((!isset($accountcodet
ype))||($accountcodetype==1)){?>checked<?php }?>>Exact</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="2" <?php if($accountcodetype==2){
?>checked<?php }?>>Begins with</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="3" <?php if($accountcodetype==3){
?>checked<?php }?>>Contains</td>
                                <td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="accountcodetype" value="4" <?php if($accountcodetype==4){
?>checked<?php }?>>Ends with</td>
                                </tr></table></td>
                        </tr>

It’s very subtle, but the first line in each code section starts with <!-- AMP which indicates that everything after that until the --> is to be commented out.

In the first section you’ll see that the --> is the last line. In the second section it has been moved up to just before the <tr> that starts the “ACCOUNTCODE” section.

I hope this helps.

So far it’s been working fine in production, although I have to remember to keep an eye on this file when upgrading FreePBX modules, in case it gets updated and my changes are overwritten. Not a big deal to go back and hand-edit the file if that happens, but best to check before the number-crunchers run their next report! :wink:

DionV

DionV

Thanks for clarifying that for me. Got the search running perfectly now.

Do you know how to add the accountcode column to the actual report as well. That way if I export to CSV I could filter on the accountcode for reporting.

Thanks again.

rlm

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.
serrurier tours