[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2002 "stichting Blender Foundation, Timothy Kanters" 3 * Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: thermometer.php,v 1.5 2004/08/14 12:47:40 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/lib/thermometer.php,v $ 21 * 22 */ 23 24 /*! \file htdocs/lib/thermometer.php 25 \brief Classe permettant d'afficher un thermometre. 26 \author Rodolphe Quiedeville. 27 \author Timothy Kanters. 28 \version $Revision: 1.5 $ 29 30 Ensemble des fonctions permettant d'afficher un thermometre monetaire. 31 */ 32 33 34 /*! 35 \brief permet d'afficher un thermometre monetaire. 36 \param actualValue 37 \param pendingValue 38 \param intentValue 39 \return thermometer htmlLegenda 40 */ 41 function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0) 42 43 /* 44 This function returns the html for the moneymeter. 45 cachedValue: amount of actual money 46 pendingValue: amount of money of pending memberships 47 intentValue: amount of intended money (that's without the amount of actual money) 48 */ 49 { 50 51 // variables 52 $height="200"; 53 $maximumValue=125000; 54 55 $imageDir = "http://eucd.info/images/"; 56 57 $imageTop = $imageDir . "therm_top.png"; 58 $imageMiddleActual = $imageDir . "therm_actual.png"; 59 $imageMiddlePending = $imageDir . "therm_pending.png"; 60 $imageMiddleIntent = $imageDir . "therm_intent.png"; 61 $imageMiddleGoal = $imageDir . "therm_goal.png"; 62 $imageIndex = $imageDir . "therm_index.png"; 63 $imageBottom = $imageDir . "therm_bottom.png"; 64 $imageColorActual = $imageDir . "therm_color_actual.png"; 65 $imageColorPending = $imageDir . "therm_color_pending.png"; 66 $imageColorIntent = $imageDir . "therm_color_intent.png"; 67 68 $htmlThermTop = ' 69 <!-- Thermometer Begin --> 70 <table cellpadding="0" cellspacing="4" border="0"> 71 <tr><td> 72 <table cellpadding="0" cellspacing="0" border="0"> 73 <tr> 74 <td colspan="2"><img src="' . $imageTop . '" width="58" height="6" border="0"></td> 75 </tr> 76 <tr> 77 <td> 78 <table cellpadding="0" cellspacing="0" border="0">'; 79 80 $htmlSection = ' 81 <tr><td><img src="{image}" width="26" height="{height}" border="0"></td></tr>'; 82 83 $htmlThermbottom = ' 84 </table> 85 </td> 86 <td><img src="' . $imageIndex . '" width="32" height="200" border="0"></td> 87 </tr> 88 <tr> 89 <td colspan="2"><img src="' . $imageBottom . '" width="58" height="32" border="0"></td> 90 </tr> 91 </table> 92 </td> 93 </tr></table>'; 94 95 // legenda 96 97 $legendaActual = "€ " . round($actualValue); 98 $legendaPending = "€ " . round($pendingValue); 99 $legendaIntent = "€ " . round($intentValue); 100 $legendaTotal = "€ " . round($actualValue + $pendingValue + $intentValue); 101 $htmlLegenda = ' 102 103 <table cellpadding="0" cellspacing="0" border="0"> 104 <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> 105 <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> 106 <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> 107 <tr><td> </td><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Total:<br />' . $legendaTotal . '</font></td></tr> 108 </table> 109 110 <!-- Thermometer End -->'; 111 112 // check and edit some values 113 114 $error = 0; 115 if ( $maximumValue <= 0 || $height <= 0 || $actualValue < 0 || $pendingValue < 0 || $intentValue < 0) 116 { 117 return "The money meter could not be processed<br>\n"; 118 } 119 if ( $actualValue > $maximumValue ) 120 { 121 $actualValue = $maximumValue; 122 $pendingValue = 0; 123 $intentValue = 0; 124 } 125 else 126 { 127 if ( ($actualValue + $pendingValue) > $maximumValue ) 128 { 129 $pendingValue = $maximumValue - $actualValue; 130 $intentValue = 0; 131 } 132 else 133 { 134 if ( ($actualValue + $pendingValue + $intentValue) > $maximumValue ) 135 { 136 $intentValue = $maximumValue - $actualValue - $pendingValue; 137 } 138 } 139 } 140 141 // start writing the html (from bottom to top) 142 143 // bottom 144 $thermometer = $htmlThermbottom; 145 146 // actual 147 $sectionHeight = round(($actualValue / $maximumValue) * $height); 148 $totalHeight = $totalHeight + $sectionHeight; 149 if ( $sectionHeight > 0 ) 150 { 151 $section = $htmlSection; 152 $section = str_replace("{image}", $imageMiddleActual, $section); 153 $section = str_replace("{height}", $sectionHeight, $section); 154 $thermometer = $section . $thermometer; 155 } 156 157 // pending 158 $sectionHeight = round(($pendingValue / $maximumValue) * $height); 159 $totalHeight = $totalHeight + $sectionHeight; 160 if ( $sectionHeight > 0 ) 161 { 162 $section = $htmlSection; 163 $section = str_replace("{image}", $imageMiddlePending, $section); 164 $section = str_replace("{height}", $sectionHeight, $section); 165 $thermometer = $section . $thermometer; 166 } 167 168 // intent 169 $sectionHeight = round(($intentValue / $maximumValue) * $height); 170 $totalHeight = $totalHeight + $sectionHeight; 171 if ( $sectionHeight > 0 ) 172 { 173 $section = $htmlSection; 174 $section = str_replace("{image}", $imageMiddleIntent, $section); 175 $section = str_replace("{height}", $sectionHeight, $section); 176 $thermometer = $section . $thermometer; 177 } 178 179 // goal 180 $sectionHeight = $height- $totalHeight; 181 if ( $sectionHeight > 0 ) 182 { 183 $section = $htmlSection; 184 $section = str_replace("{image}", $imageMiddleGoal, $section); 185 $section = str_replace("{height}", $sectionHeight, $section); 186 $thermometer = $section . $thermometer; 187 } 188 189 // top 190 $thermometer = $htmlThermTop . $thermometer; 191 192 return $thermometer . $htmlLegenda; 193 } 194 195 ?> 196 197 198
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |