Page principale | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe | Membres de fichier

htdocs/lib/thermometer.php

Aller à la documentation de ce fichier.
00001 <?php 00002 /* Copyright (C) 2002 "stichting Blender Foundation, Timothy Kanters" 00003 * Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 * 00019 * $Id$ 00020 * $Source$ 00021 * 00022 */ 00023 00042 function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0) 00043 00044 /* 00045 This function returns the html for the moneymeter. 00046 cachedValue: amount of actual money 00047 pendingValue: amount of money of pending memberships 00048 intentValue: amount of intended money (that's without the amount of actual money) 00049 */ 00050 { 00051 00052 // variables 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 // legenda 00097 00098 $legendaActual = "&euro; " . round($actualValue); 00099 $legendaPending = "&euro; " . round($pendingValue); 00100 $legendaIntent = "&euro; " . round($intentValue); 00101 $legendaTotal = "&euro; " . 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">&nbsp;</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">&nbsp;</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">&nbsp;</td><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Promesses:<br />' . $legendaIntent . '</font></td></tr> 00108 <tr><td>&nbsp;</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 // check and edit some values 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 // start writing the html (from bottom to top) 00143 00144 // bottom 00145 $thermometer = $htmlThermbottom; 00146 00147 // actual 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 // pending 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 // intent 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 // goal 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 // top 00191 $thermometer = $htmlThermTop . $thermometer; 00192 00193 return $thermometer . $htmlLegenda; 00194 } 00195 00196 ?> 00197 00198 00199

Généré le Thu Jul 15 20:50:38 2004 pour dolibarr par doxygen 1.3.7