fltGoal = $fltGoal; $this->fltAmount = $fltAmount; if (floatval($fltGoal) <= 0) { $this->fltGoal = $fltAmount; } if (floatval($fltAmount) <= 0) { $this->fltProgress = 0; } else { if (floatval($fltAmount) >= floatval($fltGoal)){ $this->fltProgress = 100; } else { $this->fltProgress = floatval($fltAmount) / floatval($fltGoal) * 100; } } } public function fxShow($strOrientation = 'h', $intDecimal = 0, $strFormat = 'money', $strSuffix = '', $strAmountLabel = '', $strGoalLabel = '', $strLanguage = 'fr') { $strHTML = $strAmountValue = $strGoalValue = ''; switch (trim(strval($strFormat))) { case 'money': $strAmountValue = $this->fxSetMoney($this->fltAmount, $strLanguage); $strGoalValue = $this->fxSetMoney($this->fltGoal, $strLanguage); break; case 'time': $strAmountValue = fxSecondsToTime($this->fltAmount); $strGoalValue = fxSecondsToTime($this->fltGoal); break; case 'distance': default: $strAmountValue = $this->fxSetNumberFormat($this->fltAmount, $intDecimal, $strLanguage); $strGoalValue = $this->fxSetNumberFormat($this->fltGoal, $intDecimal, $strLanguage); break; } if ($strOrientation == 'h') { $strHTML = '
' . $strAmountLabel . ': ' . $strAmountValue . $strSuffix . '
' . $strGoalLabel . ': ' . $strGoalValue . $strSuffix . '
' . round($this->fltProgress) . '%
' . round($this->fltProgress) . '%
'; } elseif ($strOrientation == 'v') { $strHTML = '
' . $strAmountLabel . ': ' . $strAmountValue . $strSuffix . '
' . $strGoalLabel . ': ' . $strGoalValue . $strSuffix . '
' . round($this->fltProgress) . '%
'; } return $strHTML; } private function fxSetMoney($strValue, $strLanguage) { if ($strLanguage == 'fr') { $strValue = number_format($strValue, 2, ',', ' '); $strValue .= ' $'; } else { $strValue = number_format($strValue, 2, '.', ','); $strValue = '$ ' . $strValue; } return $strValue; } private function fxSetNumberFormat($strValue, $intDecimal, $strLanguage) { if ($strLanguage == 'fr') { $strValue = number_format($strValue, intval($intDecimal), ',', ' '); } else { $strValue = number_format($strValue, intval($intDecimal), '.', ','); } return $strValue; } }