POSSA / freepbx-trunk-balancing

Restrict outbound calls or balance calls over multiple trunks based on user specified parameters
http://pbxossa.org/files/trunkbalance/
37 stars 30 forks source link

Feature request: allow billing period for less than 1 day #7

Closed FeratEnver closed 11 years ago

FeratEnver commented 11 years ago

Hi, can You add to this module function limits the number of calls in time? For example no more than 30 (ALL or ANSWERED) calls in 60 minutes. I'am ready to donate this work with 50 $ in WMZ.

lgaetz commented 11 years ago

Edit the file: <webroot>/admin/modules/trunkbalance/agi-bin/trunkbalance.php and locate line 218 that looks like this: $sqldate=' AND calldate>=DATE_SUB(curdate(), INTERVAL '.$billingperiod.' DAY)'; and change it to look like this: $sqldate=' AND calldate>=DATE_SUB(NOW(), INTERVAL '.$billingperiod.' MINUTE)'; now do an amportal restart.

This modification will allow the module to accept a Billing Period in minutes instead of days. Now if you want to create a trunk balance that will only permit 30 answered calls in 60 minutes, create a new balance with the following details: Trunk Description: whatever you want Trunk Destination: whatever trunk you want to limit Billing Period: 60 Max number of calls: 30

Then make sure to use the balanced trunk in your outbound route. This module only counts calls that are "Answered" and it will take a fair bit of work to modify it to allow the user to select non answered calls. Do you really need this feature?

FeratEnver commented 11 years ago

Thank You. its working.

Yes we need to count all calls passed to a trunk. Can You modify module for us? And write You WMZ Purse. :)

lgaetz commented 11 years ago

I don't really want to rewrite this module with proper user inputs for a feature that nobody will want. If you want to permanently change this module to always ignore the answer status when calculating the number of calls you can do this:

in the file: <webroot>/admin/modules/trunkbalance/agi-bin/trunkbalance.php locate the line: $sql='SELECT COUNT(*) FROMcdrWHERE disposition=\'ANSWERED\' AND dstchannel LIKE \''.$channel_filter.'\''.$sqldate.$sqlpattern; and change it to: $sql='SELECT COUNT(*) FROMcdrWHERE dstchannel LIKE \''.$channel_filter.'\''.$sqldate.$sqlpattern;

Do an amportal restart then do some testing because I haven't.

If these modifications are helpful, please direct a paypal donation to: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RPE6RBHXDRWJ add a note in the comment section that it is a donation from trunkbalance

lgaetz commented 11 years ago

this ticket addressed with ver. 1.1.0