Exemplo n.º 1
0
 public static function formatResultsTotal(&$total, &$columnInfo, $bFormatOnly = false)
 {
     parent::formatResultsTotal($total, $columnInfo);
     foreach ($total as $k => &$v) {
         // Formatting of monetary fields.
         foreach (self::$monetaryFields as $monField) {
             if (preg_match('/' . $monField . '$/', $k)) {
                 if (!$bFormatOnly) {
                     $v = self::calculateInReportCurrency($v);
                 }
                 $v = number_format(doubleval($v), 2, '.', ' ');
                 break;
             }
         }
         // Formatting fields with goods quantity.
         foreach (self::$goodsQuantityFields as $qField) {
             if (preg_match('/' . $qField . '$/', $k)) {
                 if (!empty($v) && !is_null($v) && $v != ' ') {
                     if (self::$fDecimalQuant) {
                         $v = sprintf('%.3f', round($v, 3));
                     } else {
                         $v = sprintf('%d', round($v, 0));
                     }
                 }
                 break;
             }
         }
         // Formatting fields without summary calculation.
         foreach (self::$withoutTotalFields as $wtField) {
             if (preg_match('/TOTAL_' . $wtField . '$/', $k)) {
                 unset($total[$k]);
                 break;
             }
         }
         // Formatting fields of price types
         if (!$bFormatOnly) {
             if (preg_match('/[A-Za-z_]*PRICE_TYPE_[0-9]+$/', $k) && !empty($v) && $v !== ' ') {
                 $v = trim($v);
                 $spacePos = strpos($v, ' ');
                 $v = number_format(doubleval(substr($v, 0, $spacePos)), 2, '.', ' ') . substr($v, $spacePos);
             }
         }
     }
 }