forked from Wavyzz/dolibarr
194 lines
13 KiB
HTML
194 lines
13 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>dolibarr: htdocs/lib/thermometer.php Source File</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Généré par Doxygen 1.3.7 -->
|
|
<div class="qindex"><a class="qindex" href="index.html">Page principale</a> | <a class="qindex" href="files.html">Liste des fichiers</a> | <a class="qindex" href="globals.html">Membres de fichier</a></div>
|
|
<h1>htdocs/lib/thermometer.php</h1><a href="thermometer_8php.html">Aller à la documentation de ce fichier.</a><pre class="fragment"><div>00001 <?php
|
|
00002 <span class="comment">/* Copyright (C) 2002 "stichting Blender Foundation, Timothy Kanters"</span>
|
|
00003 <span class="comment"> * Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org></span>
|
|
00004 <span class="comment"> *</span>
|
|
00005 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
|
00006 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
|
|
00007 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
|
|
00008 <span class="comment"> * (at your option) any later version.</span>
|
|
00009 <span class="comment"> *</span>
|
|
00010 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
|
00011 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
|
00012 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
|
00013 <span class="comment"> * GNU General Public License for more details.</span>
|
|
00014 <span class="comment"> *</span>
|
|
00015 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
|
00016 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
|
00017 <span class="comment"> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
|
|
00018 <span class="comment"> *</span>
|
|
00019 <span class="comment"> * $Id$</span>
|
|
00020 <span class="comment"> * $Source$</span>
|
|
00021 <span class="comment"> *</span>
|
|
00022 <span class="comment"> */</span>
|
|
00023
|
|
<a name="l00042"></a><a class="code" href="thermometer_8php.html#a0">00042</a> function <a class="code" href="thermometer_8php.html#a0">moneyMeter</a>($actualValue=0, $pendingValue=0, $intentValue=0)
|
|
00043
|
|
00044 <span class="comment">/*</span>
|
|
00045 <span class="comment"> This function returns the html for the moneymeter.</span>
|
|
00046 <span class="comment"> cachedValue: amount of actual money</span>
|
|
00047 <span class="comment"> pendingValue: amount of money of pending memberships</span>
|
|
00048 <span class="comment"> intentValue: amount of intended money (that's without the amount of actual money)</span>
|
|
00049 <span class="comment"> */</span>
|
|
00050 {
|
|
00051
|
|
00052 <span class="comment">// variables</span>
|
|
00053 $height=<span class="stringliteral">"200"</span>;
|
|
00054 $maximumValue=125000;
|
|
00055
|
|
00056 $imageDir = <span class="stringliteral">"http://eucd.info/images/"</span>;
|
|
00057
|
|
00058 $imageTop = $imageDir . <span class="stringliteral">"therm_top.png"</span>;
|
|
00059 $imageMiddleActual = $imageDir . <span class="stringliteral">"therm_actual.png"</span>;
|
|
00060 $imageMiddlePending = $imageDir . <span class="stringliteral">"therm_pending.png"</span>;
|
|
00061 $imageMiddleIntent = $imageDir . <span class="stringliteral">"therm_intent.png"</span>;
|
|
00062 $imageMiddleGoal = $imageDir . <span class="stringliteral">"therm_goal.png"</span>;
|
|
00063 $imageIndex = $imageDir . <span class="stringliteral">"therm_index.png"</span>;
|
|
00064 $imageBottom = $imageDir . <span class="stringliteral">"therm_bottom.png"</span>;
|
|
00065 $imageColorActual = $imageDir . <span class="stringliteral">"therm_color_actual.png"</span>;
|
|
00066 $imageColorPending = $imageDir . <span class="stringliteral">"therm_color_pending.png"</span>;
|
|
00067 $imageColorIntent = $imageDir . <span class="stringliteral">"therm_color_intent.png"</span>;
|
|
00068
|
|
00069 $htmlThermTop = '
|
|
00070 <!-- Thermometer Begin -->
|
|
00071 <table cellpadding=<span class="stringliteral">"0"</span> cellspacing=<span class="stringliteral">"4"</span> border=<span class="stringliteral">"0"</span>>
|
|
00072 <tr><td>
|
|
00073 <table cellpadding=<span class="stringliteral">"0"</span> cellspacing=<span class="stringliteral">"0"</span> border=<span class="stringliteral">"0"</span>>
|
|
00074 <tr>
|
|
00075 <td colspan=<span class="stringliteral">"2"</span>><img src=<span class="stringliteral">"' . $imageTop . '"</span> width=<span class="stringliteral">"58"</span> height=<span class="stringliteral">"6"</span> border=<span class="stringliteral">"0"</span>></td>
|
|
00076 </tr>
|
|
00077 <tr>
|
|
00078 <td>
|
|
00079 <table cellpadding=<span class="stringliteral">"0"</span> cellspacing=<span class="stringliteral">"0"</span> border=<span class="stringliteral">"0"</span>>';
|
|
00080
|
|
00081 $htmlSection = '
|
|
00082 <tr><td><img src=<span class="stringliteral">"{image}"</span> width=<span class="stringliteral">"26"</span> height=<span class="stringliteral">"{height}"</span> border=<span class="stringliteral">"0"</span>></td></tr>';
|
|
00083
|
|
00084 $htmlThermbottom = '
|
|
00085 </table>
|
|
00086 </td>
|
|
00087 <td><img src=<span class="stringliteral">"' . $imageIndex . '"</span> width=<span class="stringliteral">"32"</span> height=<span class="stringliteral">"200"</span> border=<span class="stringliteral">"0"</span>></td>
|
|
00088 </tr>
|
|
00089 <tr>
|
|
00090 <td colspan=<span class="stringliteral">"2"</span>><img src=<span class="stringliteral">"' . $imageBottom . '"</span> width=<span class="stringliteral">"58"</span> height=<span class="stringliteral">"32"</span> border=<span class="stringliteral">"0"</span>></td>
|
|
00091 </tr>
|
|
00092 </table>
|
|
00093 </td>
|
|
00094 </tr></table>';
|
|
00095
|
|
00096 <span class="comment">// legenda</span>
|
|
00097
|
|
00098 $legendaActual = <span class="stringliteral">"&euro; "</span> . round($actualValue);
|
|
00099 $legendaPending = <span class="stringliteral">"&euro; "</span> . round($pendingValue);
|
|
00100 $legendaIntent = <span class="stringliteral">"&euro; "</span> . round($intentValue);
|
|
00101 $legendaTotal = <span class="stringliteral">"&euro; "</span> . round($actualValue + $pendingValue + $intentValue);
|
|
00102 $htmlLegenda = '
|
|
00103
|
|
00104 <table cellpadding=<span class="stringliteral">"0"</span> cellspacing=<span class="stringliteral">"0"</span> border=<span class="stringliteral">"0"</span>>
|
|
00105 <tr><td><img src=<span class="stringliteral">"' . $imageColorActual . '"</span> width=<span class="stringliteral">"9"</span> height=<span class="stringliteral">"9"</span>>&nbsp;</td><td><font size=<span class="stringliteral">"1"</span> face=<span class="stringliteral">"Verdana, Arial, Helvetica, sans-serif"</span>><b>Payé:<br />' . $legendaActual . '</b></font></td></tr>
|
|
00106 <tr><td><img src=<span class="stringliteral">"' . $imageColorPending . '"</span> width=<span class="stringliteral">"9"</span> height=<span class="stringliteral">"9"</span>>&nbsp;</td><td><font size=<span class="stringliteral">"1"</span> face=<span class="stringliteral">"Verdana, Arial, Helvetica, sans-serif"</span>>En attente:<br />' . $legendaPending . '</font></td></tr>
|
|
00107 <tr><td><img src=<span class="stringliteral">"' . $imageColorIntent . '"</span> width=<span class="stringliteral">"9"</span> height=<span class="stringliteral">"9"</span>>&nbsp;</td><td><font size=<span class="stringliteral">"1"</span> face=<span class="stringliteral">"Verdana, Arial, Helvetica, sans-serif"</span>>Promesses:<br />' . $legendaIntent . '</font></td></tr>
|
|
00108 <tr><td>&nbsp;</td><td><font size=<span class="stringliteral">"1"</span> face=<span class="stringliteral">"Verdana, Arial, Helvetica, sans-serif"</span>>Total:<br />' . $legendaTotal . '</font></td></tr>
|
|
00109 </table>
|
|
00110
|
|
00111 <!-- Thermometer End -->';
|
|
00112
|
|
00113 <span class="comment">// check and edit some values</span>
|
|
00114
|
|
00115 $error = 0;
|
|
00116 <span class="keywordflow">if</span> ( $maximumValue <= 0 || $height <= 0 || $actualValue < 0 || $pendingValue < 0 || $intentValue < 0)
|
|
00117 {
|
|
00118 <span class="keywordflow">return</span> <span class="stringliteral">"The money meter could not be processed<br>\n"</span>;
|
|
00119 }
|
|
00120 <span class="keywordflow">if</span> ( $actualValue > $maximumValue )
|
|
00121 {
|
|
00122 $actualValue = $maximumValue;
|
|
00123 $pendingValue = 0;
|
|
00124 $intentValue = 0;
|
|
00125 }
|
|
00126 <span class="keywordflow">else</span>
|
|
00127 {
|
|
00128 <span class="keywordflow">if</span> ( ($actualValue + $pendingValue) > $maximumValue )
|
|
00129 {
|
|
00130 $pendingValue = $maximumValue - $actualValue;
|
|
00131 $intentValue = 0;
|
|
00132 }
|
|
00133 <span class="keywordflow">else</span>
|
|
00134 {
|
|
00135 <span class="keywordflow">if</span> ( ($actualValue + $pendingValue + $intentValue) > $maximumValue )
|
|
00136 {
|
|
00137 $intentValue = $maximumValue - $actualValue - $pendingValue;
|
|
00138 }
|
|
00139 }
|
|
00140 }
|
|
00141
|
|
00142 <span class="comment">// start writing the html (from bottom to top)</span>
|
|
00143
|
|
00144 <span class="comment">// bottom </span>
|
|
00145 $thermometer = $htmlThermbottom;
|
|
00146
|
|
00147 <span class="comment">// actual</span>
|
|
00148 $sectionHeight = round(($actualValue / $maximumValue) * $height);
|
|
00149 $totalHeight = $totalHeight + $sectionHeight;
|
|
00150 <span class="keywordflow">if</span> ( $sectionHeight > 0 )
|
|
00151 {
|
|
00152 $section = $htmlSection;
|
|
00153 $section = str_replace(<span class="stringliteral">"{image}"</span>, $imageMiddleActual, $section);
|
|
00154 $section = str_replace(<span class="stringliteral">"{height}"</span>, $sectionHeight, $section);
|
|
00155 $thermometer = $section . $thermometer;
|
|
00156 }
|
|
00157
|
|
00158 <span class="comment">// pending</span>
|
|
00159 $sectionHeight = round(($pendingValue / $maximumValue) * $height);
|
|
00160 $totalHeight = $totalHeight + $sectionHeight;
|
|
00161 <span class="keywordflow">if</span> ( $sectionHeight > 0 )
|
|
00162 {
|
|
00163 $section = $htmlSection;
|
|
00164 $section = str_replace(<span class="stringliteral">"{image}"</span>, $imageMiddlePending, $section);
|
|
00165 $section = str_replace(<span class="stringliteral">"{height}"</span>, $sectionHeight, $section);
|
|
00166 $thermometer = $section . $thermometer;
|
|
00167 }
|
|
00168
|
|
00169 <span class="comment">// intent</span>
|
|
00170 $sectionHeight = round(($intentValue / $maximumValue) * $height);
|
|
00171 $totalHeight = $totalHeight + $sectionHeight;
|
|
00172 <span class="keywordflow">if</span> ( $sectionHeight > 0 )
|
|
00173 {
|
|
00174 $section = $htmlSection;
|
|
00175 $section = str_replace(<span class="stringliteral">"{image}"</span>, $imageMiddleIntent, $section);
|
|
00176 $section = str_replace(<span class="stringliteral">"{height}"</span>, $sectionHeight, $section);
|
|
00177 $thermometer = $section . $thermometer;
|
|
00178 }
|
|
00179
|
|
00180 <span class="comment">// goal </span>
|
|
00181 $sectionHeight = $height- $totalHeight;
|
|
00182 <span class="keywordflow">if</span> ( $sectionHeight > 0 )
|
|
00183 {
|
|
00184 $section = $htmlSection;
|
|
00185 $section = str_replace(<span class="stringliteral">"{image}"</span>, $imageMiddleGoal, $section);
|
|
00186 $section = str_replace(<span class="stringliteral">"{height}"</span>, $sectionHeight, $section);
|
|
00187 $thermometer = $section . $thermometer;
|
|
00188 }
|
|
00189
|
|
00190 <span class="comment">// top</span>
|
|
00191 $thermometer = $htmlThermTop . $thermometer;
|
|
00192
|
|
00193 <span class="keywordflow">return</span> $thermometer . $htmlLegenda;
|
|
00194 }
|
|
00195
|
|
00196 ?>
|
|
00197
|
|
00198
|
|
00199
|
|
</div></pre><hr size="1"><address style="align: right;"><small>Généré le Thu Jul 15 14:51:57 2004 pour dolibarr par
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
|
|
</body>
|
|
</html>
|