Module Guide

FusionPBX Autobill Enhanced (v2 & v3)

Documentation for the enhanced FusionPBX autobill interface, including execution methods, output behavior, and how WHMCS Automation and Prorata settings affect billing outcomes.

FusionPBX Autobill Enhanced (v2 & v3)

v1.4.4 Update: The autobill_v3.php script has been introduced as a consolidated version that combines the functionality of autobill_v2.php with additional enhancements. Both versions are available and fully supported.
Note: This page documents both autobill_v2.php (standard enhanced version) and autobill_v3.php (consolidated version) used for FusionPBX usage billing in WHMCS environments.

Overview

Enhanced versions of the FusionPBX autobill script provide a modern browser-based UI for debugging and monitoring. Version 3 consolidates all autobill functionality into a single script.

Version Comparison

Feature autobill_v2.php autobill_v3.php
Purpose Standard FusionPBX billing Consolidated all-in-one billing
Modern UI Yes Yes, enhanced
Real-time Statistics Yes Yes
Progress Tracking Yes Yes
Multi-Module Support FusionPBX only FusionPBX + VoIP + VoIPFax
Consolidated Logic No Yes
Recommended For FusionPBX-only setups Mixed or multi-module environments

Which Version Should I Use?

  • Use autobill_v2.php if you only have FusionPBX server module products and prefer a dedicated script.
  • Use autobill_v3.php if you have multiple server modules or want a single consolidated billing script.
  • Both versions maintain the same billing logic and WHMCS automation behavior.
  • Migration from v2 to v3 is normally a cron path update.

Features

Modern UI

  • ictVoIP-themed design with gradient backgrounds and professional styling.
  • Real-time statistics dashboard showing clients processed, services processed, skipped services, invoices created, and elapsed time.
  • Live progress bar and color-coded console output.

Performance Enhancements

  • High timeout limits for large CDR volumes.
  • 512MB memory limit for processing.
  • Real-time output flushing for immediate feedback.

Enhanced Debugging

  • Detailed CDR period information.
  • Call count per service.
  • Invoice amounts shown immediately.
  • Real-time billing skip notifications.
  • Email notification status.

Security

  • Requires the ?runfrom=cron parameter to execute.
  • Compatible with CLI and browser execution.
  • Maintains backward compatibility with cron jobs.

Usage

Browser Access

https://yourdomain.com/modules/servers/fusionpbx/autobill_v2.php?runfrom=cron
https://yourdomain.com/modules/servers/fusionpbx/autobill_v3.php?runfrom=cron

CLI/Cron

php /path/to/fusionpbx/autobill_v2.php runfrom=cron
php /path/to/fusionpbx/autobill_v3.php runfrom=cron

Cron Job Setup

Important - Timezone Configuration: On AlmaLinux 9 / systemd-based systems, the TZ= parameter is required to ensure cron jobs run in the correct timezone, not UTC.

Recommended schedule:

  • WHMCS Daily CRON: 1:00 AM
  • Autobill CRON: 12:55 AM, five minutes before WHMCS daily cron
  • Alternative: 12:45 AM for more time before WHMCS daily cron
# Run at 12:55 AM in America/Toronto timezone
55 00 * * * TZ=America/Toronto GET https://yourwhmcs.com/modules/servers/fusionpbx/autobill_v2.php?runfrom=cron

# Run at 12:55 AM in America/Toronto timezone
55 00 * * * TZ=America/Toronto GET https://yourwhmcs.com/modules/servers/fusionpbx/autobill_v3.php?runfrom=cron

# Alternative: More time before WHMCS daily cron
45 00 * * * TZ=America/Toronto GET https://yourwhmcs.com/modules/servers/fusionpbx/autobill_v3.php?runfrom=cron

# PHP CLI format
55 00 * * * TZ=America/Toronto /usr/bin/php -q /path/to/whmcs/modules/servers/fusionpbx/autobill_v3.php runfrom=cron
Tip: If you're using v3, you only need one cron job for all supported server modules. The consolidated script handles billing automatically.

Output Examples

Browser Mode

  • Gradient UI with real-time updates.
  • Statistics cards showing live counters.
  • Color-coded log output.
  • Progress bar showing completion percentage.
  • Spinning indicator while processing.
  • Green checkmark when complete.

CLI Mode

  • Clean text output.
  • Same processing information as browser mode.
  • Suitable for log files and email reports.

Statistics Tracked

  1. Clients: Total number of clients processed.
  2. Processed: Services that were processed for billing.
  3. Skipped (RT): Services skipped because real-time billing is enabled.
  4. Invoices: Total invoices created.
  5. Time: Total execution time in seconds.

Key Differences from v1

Feature autobill.php (v1) autobill_v2.php autobill_v3.php
UI Plain text Modern styled UI Modern styled UI
Real-time updates No Yes Yes
Progress bar No Yes Yes
Statistics dashboard No Yes Enhanced
Icons/Emojis No Yes Yes
Responsive layout No Yes Yes
Time tracking No Yes Yes
Multi-module support FusionPBX only FusionPBX only FusionPBX + VoIP + VoIPFax
Consolidated billing No No Yes

Compatibility

  • Works with existing cron jobs.
  • Compatible with all FusionPBX billing features.
  • Maintains real-time billing skip logic.
  • Email notifications work identically.
  • No database changes required.
  • PHP 7.4+ and PHP 8.x compatible.

WHMCS Automation and Prorata Behavior

autobill_v2.php follows WHMCS billing dates rather than inventing its own cycle. This means the service Next Due Date, WHMCS Automation Settings, and product prorata settings all influence when usage invoices are created and what date range they represent.

Automation Settings

  • Monthly invoice generation lead time: CreateInvoiceDaysBeforeMonthly is used first for Monthly services. If blank or 0, the script falls back to CreateInvoiceDaysBefore.
  • Invoice creation day: If WHMCS generates invoices in advance, autobill_v2.php selects services whose Next Due Date matches the automation target date.
  • Invoice due date: Usage invoices use the same due date target expected by WHMCS automation.

Prorata Settings

WHMCS product settings such as Prorata Billing, Prorata Date, and Charge Next Month affect the service billing cycle that WHMCS establishes. autobill_v2.php follows the dates WHMCS assigns to the service.

  • Prorata Billing: Determines whether WHMCS aligns the service onto a calendar billing point.
  • Prorata Date: Controls the target calendar day for the service cycle.
  • Charge Next Month: Affects initial order/prorata behavior and can change the first invoice outcome depending on signup date.

First Cycle vs Subsequent Cycles

  • First cycle: cdr_class.php can use the service Date Registered (regdate) as the start of the first usage billing period when no prior non-cancelled WHMCS Hosting invoice item exists for that service.
  • Subsequent cycles: Once WHMCS has created the normal Hosting invoice item for the service, later autobill runs use the standard rolling cycle for Monthly billing.

Desired Outcome Examples

  • Invoice on the 15th, due on the 1st: If CreateInvoiceDaysBeforeMonthly = 15 and the service Next Due Date is the 1st, autobill_v2.php creates the usage invoice on the 15th of the prior month and sets the due date to the 1st.
  • Same-day invoicing: If both CreateInvoiceDaysBeforeMonthly and CreateInvoiceDaysBefore are 0, the script behaves as same-day billing and only targets services due today.

Operational Notes

  • WHMCS daily cron matters: WHMCS daily automation creates the standard service renewal invoice item that marks the service as having entered its normal cycle.
  • Payment progression matters: After the renewal invoice is paid, WHMCS typically advances the service Next Due Date; once advanced, the same cycle should no longer be selected by autobill_v2.php.
  • Best practice: Configure WHMCS Automation Settings and product prorata settings together, then verify the resulting service Next Due Date.

Version History

v1.4.4 (Current - Stable)

  • autobill_v3.php introduced as a consolidated billing script supporting FusionPBX, VoIP, and VoIPFax modules.
  • autobill_v2.php maintained and fully supported for FusionPBX-only environments.
  • Enhanced browser UI with real-time statistics dashboard.
  • Progress tracking and color-coded output.
  • Comprehensive debugging output.
  • Improved performance with higher limits.
  • WHMCS v9 compatibility verified.

Key Improvements in v3

  • Unified billing logic across supported server module types.
  • Reduced maintenance with one cron job instead of multiple.
  • Enhanced statistics with module-specific counters and breakdowns.
  • Better error handling and reporting.
  • Future-proof design for additional modules.

Document Last Updated: April 19, 2026

Modules: FusionPBX Autobill Enhanced (autobill_v2.php and autobill_v3.php)

Current Version: v1.4.4 Stable

Ownership: Developed and maintained by ictVoIP Canada