00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00042 function
moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0)
00043
00044
00045
00046
00047
00048
00049
00050 {
00051
00052
00053 $height=
"200";
00054 $maximumValue=125000;
00055
00056 $imageDir =
"http://eucd.info/images/";
00057
00058 $imageTop = $imageDir .
"therm_top.png";
00059 $imageMiddleActual = $imageDir .
"therm_actual.png";
00060 $imageMiddlePending = $imageDir .
"therm_pending.png";
00061 $imageMiddleIntent = $imageDir .
"therm_intent.png";
00062 $imageMiddleGoal = $imageDir .
"therm_goal.png";
00063 $imageIndex = $imageDir .
"therm_index.png";
00064 $imageBottom = $imageDir .
"therm_bottom.png";
00065 $imageColorActual = $imageDir .
"therm_color_actual.png";
00066 $imageColorPending = $imageDir .
"therm_color_pending.png";
00067 $imageColorIntent = $imageDir .
"therm_color_intent.png";
00068
00069 $htmlThermTop = '
00070 <!-- Thermometer Begin -->
00071 <table cellpadding=
"0" cellspacing=
"4" border=
"0">
00072 <tr><td>
00073 <table cellpadding=
"0" cellspacing=
"0" border=
"0">
00074 <tr>
00075 <td colspan=
"2"><img src=
"' . $imageTop . '" width=
"58" height=
"6" border=
"0"></td>
00076 </tr>
00077 <tr>
00078 <td>
00079 <table cellpadding=
"0" cellspacing=
"0" border=
"0">';
00080
00081 $htmlSection = '
00082 <tr><td><img src=
"{image}" width=
"26" height=
"{height}" border=
"0"></td></tr>';
00083
00084 $htmlThermbottom = '
00085 </table>
00086 </td>
00087 <td><img src=
"' . $imageIndex . '" width=
"32" height=
"200" border=
"0"></td>
00088 </tr>
00089 <tr>
00090 <td colspan=
"2"><img src=
"' . $imageBottom . '" width=
"58" height=
"32" border=
"0"></td>
00091 </tr>
00092 </table>
00093 </td>
00094 </tr></table>';
00095
00096
00097
00098 $legendaActual =
"€ " . round($actualValue);
00099 $legendaPending =
"€ " . round($pendingValue);
00100 $legendaIntent =
"€ " . round($intentValue);
00101 $legendaTotal =
"€ " . round($actualValue + $pendingValue + $intentValue);
00102 $htmlLegenda = '
00103
00104 <table cellpadding=
"0" cellspacing=
"0" border=
"0">
00105 <tr><td><img src=
"' . $imageColorActual . '" width=
"9" height=
"9"> </td><td><font size=
"1" face=
"Verdana, Arial, Helvetica, sans-serif"><b>Payé:<br />' . $legendaActual . '</b></font></td></tr>
00106 <tr><td><img src=
"' . $imageColorPending . '" width=
"9" height=
"9"> </td><td><font size=
"1" face=
"Verdana, Arial, Helvetica, sans-serif">En attente:<br />' . $legendaPending . '</font></td></tr>
00107 <tr><td><img src=
"' . $imageColorIntent . '" width=
"9" height=
"9"> </td><td><font size=
"1" face=
"Verdana, Arial, Helvetica, sans-serif">Promesses:<br />' . $legendaIntent . '</font></td></tr>
00108 <tr><td> </td><td><font size=
"1" face=
"Verdana, Arial, Helvetica, sans-serif">Total:<br />' . $legendaTotal . '</font></td></tr>
00109 </table>
00110
00111 <!-- Thermometer End -->';
00112
00113
00114
00115 $error = 0;
00116
if ( $maximumValue <= 0 || $height <= 0 || $actualValue < 0 || $pendingValue < 0 || $intentValue < 0)
00117 {
00118
return "The money meter could not be processed<br>\n";
00119 }
00120
if ( $actualValue > $maximumValue )
00121 {
00122 $actualValue = $maximumValue;
00123 $pendingValue = 0;
00124 $intentValue = 0;
00125 }
00126
else
00127 {
00128
if ( ($actualValue + $pendingValue) > $maximumValue )
00129 {
00130 $pendingValue = $maximumValue - $actualValue;
00131 $intentValue = 0;
00132 }
00133
else
00134 {
00135
if ( ($actualValue + $pendingValue + $intentValue) > $maximumValue )
00136 {
00137 $intentValue = $maximumValue - $actualValue - $pendingValue;
00138 }
00139 }
00140 }
00141
00142
00143
00144
00145 $thermometer = $htmlThermbottom;
00146
00147
00148 $sectionHeight = round(($actualValue / $maximumValue) * $height);
00149 $totalHeight = $totalHeight + $sectionHeight;
00150
if ( $sectionHeight > 0 )
00151 {
00152 $section = $htmlSection;
00153 $section = str_replace(
"{image}", $imageMiddleActual, $section);
00154 $section = str_replace(
"{height}", $sectionHeight, $section);
00155 $thermometer = $section . $thermometer;
00156 }
00157
00158
00159 $sectionHeight = round(($pendingValue / $maximumValue) * $height);
00160 $totalHeight = $totalHeight + $sectionHeight;
00161
if ( $sectionHeight > 0 )
00162 {
00163 $section = $htmlSection;
00164 $section = str_replace(
"{image}", $imageMiddlePending, $section);
00165 $section = str_replace(
"{height}", $sectionHeight, $section);
00166 $thermometer = $section . $thermometer;
00167 }
00168
00169
00170 $sectionHeight = round(($intentValue / $maximumValue) * $height);
00171 $totalHeight = $totalHeight + $sectionHeight;
00172
if ( $sectionHeight > 0 )
00173 {
00174 $section = $htmlSection;
00175 $section = str_replace(
"{image}", $imageMiddleIntent, $section);
00176 $section = str_replace(
"{height}", $sectionHeight, $section);
00177 $thermometer = $section . $thermometer;
00178 }
00179
00180
00181 $sectionHeight = $height- $totalHeight;
00182
if ( $sectionHeight > 0 )
00183 {
00184 $section = $htmlSection;
00185 $section = str_replace(
"{image}", $imageMiddleGoal, $section);
00186 $section = str_replace(
"{height}", $sectionHeight, $section);
00187 $thermometer = $section . $thermometer;
00188 }
00189
00190
00191 $thermometer = $htmlThermTop . $thermometer;
00192
00193
return $thermometer . $htmlLegenda;
00194 }
00195
00196 ?>
00197
00198
00199