/**
  * Test the number formatting method
  *
  */
 function test_formatNumber()
 {
     $dec_point_save = $GLOBALS['phpAds_DecimalPoint'];
     $thousands_save = $GLOBALS['phpAds_ThousandsSeperator'];
     $decimals_save = $GLOBALS['_MAX']['PREF']['ui_percentage_decimals'];
     $GLOBALS['phpAds_DecimalPoint'] = '.';
     $GLOBALS['phpAds_ThousandsSeperator'] = ',';
     $GLOBALS['_MAX']['PREF']['ui_percentage_decimals'] = 2;
     $number = 3.141592653589793 * 1000;
     $this->assertEqual('1,234', OA_Admin_NumberFormat::formatNumber("1234", 0));
     $this->assertEqual('3,141.59', OA_Admin_NumberFormat::formatNumber($number));
     $this->assertEqual('3,141.593', OA_Admin_NumberFormat::formatNumber($number, 3));
     $this->assertEqual('3,141,5927', OA_Admin_NumberFormat::formatNumber($number, 4, ','));
     $this->assertEqual('3.141,59265', OA_Admin_NumberFormat::formatNumber($number, 5, ',', '.'));
     // Change defaults
     $GLOBALS['phpAds_DecimalPoint'] = ',';
     $GLOBALS['phpAds_ThousandsSeperator'] = '.';
     $GLOBALS['_MAX']['PREF']['ui_percentage_decimals'] = 4;
     $this->assertEqual('3.141,5927', OA_Admin_NumberFormat::formatNumber($number));
     $this->assertEqual('3.141,593', OA_Admin_NumberFormat::formatNumber($number, 3));
     $this->assertEqual('3.141,5927', OA_Admin_NumberFormat::formatNumber($number, 4, ','));
     $this->assertEqual('3.141,59265', OA_Admin_NumberFormat::formatNumber($number, 5, ',', '.'));
     // Test NAN (NotANumber)
     $this->assertFalse(OA_Admin_NumberFormat::formatNumber('string'));
     // Clean up
     $GLOBALS['phpAds_DecimalPoint'] = $dec_point_save;
     $GLOBALS['phpAds_ThousandsSeperator'] = $thousands_save;
     $GLOBALS['_MAX']['PREF']['ui_percentage_decimals'] = $decimals_save;
 }
function smarty_modifier_formatNumber($number)
{
    return OA_Admin_NumberFormat::formatNumber($number, 0);
}
    }
    if ($end) {
        $endDate = date('Y-m-d', strtotime($end));
    } else {
        $endDate = null;
    }
    if (is_null($deliveryDataLoaded) && !empty($campaignid)) {
        $dalData_intermediate_ad = OA_Dal::factoryDAL('data_intermediate_ad');
        $record = $dalData_intermediate_ad->getDeliveredByCampaign($campaignid);
        $data = $record->toArray();
        $impressions = $data['impressions_delivered'];
        $clicks = $data['clicks_delivered'];
        $conversions = $data['conversions_delivered'];
    }
    $ecpm = OX_Util_Utils::getEcpm($revenue_type, $revenue, $impressions, $clicks, $conversions, $startDate, $endDate);
    echo OA_Admin_NumberFormat::formatNumber($ecpm, 4);
    exit;
}
//build campaign form
//var_dump($campaign);
$oComponent = null;
if (isset($GLOBALS['_MAX']['CONF']['plugins']['openXThorium']) && $GLOBALS['_MAX']['CONF']['plugins']['openXThorium']) {
    $oComponent =& OX_Component::factory('admin', 'oxThorium', 'oxThorium');
}
$campaignForm = buildCampaignForm($campaign, $oComponent);
if ($campaignForm->isSubmitted() && $campaignForm->validate()) {
    //process submitted values
    $errors = processCampaignForm($campaignForm, $oComponent);
    if (!empty($errors)) {
        //need to redisplay page with general errors
        displayPage($campaign, $campaignForm, $statusForm, $errors);