*** empty log message ***
This commit is contained in:
parent
4b9a7f15c7
commit
3f291bb98b
@ -291,5 +291,59 @@ class Don
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Somme des dons payés
|
||||||
|
* encaissés ou non
|
||||||
|
*/
|
||||||
|
Function sum_actual()
|
||||||
|
{
|
||||||
|
$sql = "SELECT sum(amount)";
|
||||||
|
$sql .= " FROM llx_don";
|
||||||
|
$sql .= " WHERE fk_statut = 3";
|
||||||
|
|
||||||
|
if ( $this->db->query( $sql) )
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row(0);
|
||||||
|
|
||||||
|
return $row[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* En attente de paiement
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function sum_pending()
|
||||||
|
{
|
||||||
|
$sql = "SELECT sum(amount)";
|
||||||
|
$sql .= " FROM llx_don";
|
||||||
|
$sql .= " WHERE fk_statut = 2";
|
||||||
|
|
||||||
|
if ( $this->db->query( $sql) )
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row(0);
|
||||||
|
|
||||||
|
return $row[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Somme des promesses de dons validées
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function sum_intent()
|
||||||
|
{
|
||||||
|
$sql = "SELECT sum(amount)";
|
||||||
|
$sql .= " FROM llx_don";
|
||||||
|
$sql .= " WHERE fk_statut = 1";
|
||||||
|
|
||||||
|
if ( $this->db->query( $sql) )
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row(0);
|
||||||
|
|
||||||
|
return $row[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
179
htdocs/lib/thermometer.php
Normal file
179
htdocs/lib/thermometer.php
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2002 "stichting Blender Foundation, Timothy Kanters"
|
||||||
|
* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* $Source$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0)
|
||||||
|
/*
|
||||||
|
This function returns the html for the moneymeter.
|
||||||
|
cachedValue: amount of actual money
|
||||||
|
pendingValue: amount of money of pending memberships
|
||||||
|
intentValue: amount of intended money (that's without the amount of actual money)
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
|
||||||
|
// variables
|
||||||
|
$height="200";
|
||||||
|
$maximumValue=125000;
|
||||||
|
|
||||||
|
$imageDir = "http://eucd.info/images/";
|
||||||
|
|
||||||
|
$imageTop = $imageDir . "therm_top.png";
|
||||||
|
$imageMiddleActual = $imageDir . "therm_actual.png";
|
||||||
|
$imageMiddlePending = $imageDir . "therm_pending.png";
|
||||||
|
$imageMiddleIntent = $imageDir . "therm_intent.png";
|
||||||
|
$imageMiddleGoal = $imageDir . "therm_goal.png";
|
||||||
|
$imageIndex = $imageDir . "therm_index.png";
|
||||||
|
$imageBottom = $imageDir . "therm_bottom.png";
|
||||||
|
$imageColorActual = $imageDir . "therm_color_actual.png";
|
||||||
|
$imageColorPending = $imageDir . "therm_color_pending.png";
|
||||||
|
$imageColorIntent = $imageDir . "therm_color_intent.png";
|
||||||
|
|
||||||
|
$htmlThermTop = '
|
||||||
|
<!-- Thermometer Begin -->
|
||||||
|
<table cellpadding="0" cellspacing="4" border="0">
|
||||||
|
<tr><td>
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><img src="' . $imageTop . '" width="58" height="6" border="0"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0">';
|
||||||
|
|
||||||
|
$htmlSection = '
|
||||||
|
<tr><td><img src="{image}" width="26" height="{height}" border="0"></td></tr>';
|
||||||
|
|
||||||
|
$htmlThermbottom = '
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td><img src="' . $imageIndex . '" width="32" height="200" border="0"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><img src="' . $imageBottom . '" width="58" height="32" border="0"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr></table>';
|
||||||
|
|
||||||
|
// legenda
|
||||||
|
|
||||||
|
$legendaActual = "€ " . round($actualValue);
|
||||||
|
$legendaPending = "€ " . round($pendingValue);
|
||||||
|
$legendaIntent = "€ " . round($intentValue);
|
||||||
|
$legendaTotal = "€ " . round($actualValue + $pendingValue + $intentValue);
|
||||||
|
$htmlLegenda = '
|
||||||
|
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0">
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
<tr><td> </td><td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Total:<br />' . $legendaTotal . '</font></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Thermometer End -->';
|
||||||
|
|
||||||
|
// check and edit some values
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
if ( $maximumValue <= 0 || $height <= 0 || $actualValue < 0 || $pendingValue < 0 || $intentValue < 0)
|
||||||
|
{
|
||||||
|
return "The money meter could not be processed<br>\n";
|
||||||
|
}
|
||||||
|
if ( $actualValue > $maximumValue )
|
||||||
|
{
|
||||||
|
$actualValue = $maximumValue;
|
||||||
|
$pendingValue = 0;
|
||||||
|
$intentValue = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ($actualValue + $pendingValue) > $maximumValue )
|
||||||
|
{
|
||||||
|
$pendingValue = $maximumValue - $actualValue;
|
||||||
|
$intentValue = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ($actualValue + $pendingValue + $intentValue) > $maximumValue )
|
||||||
|
{
|
||||||
|
$intentValue = $maximumValue - $actualValue - $pendingValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start writing the html (from bottom to top)
|
||||||
|
|
||||||
|
// bottom
|
||||||
|
$thermometer = $htmlThermbottom;
|
||||||
|
|
||||||
|
// actual
|
||||||
|
$sectionHeight = round(($actualValue / $maximumValue) * $height);
|
||||||
|
$totalHeight = $totalHeight + $sectionHeight;
|
||||||
|
if ( $sectionHeight > 0 )
|
||||||
|
{
|
||||||
|
$section = $htmlSection;
|
||||||
|
$section = str_replace("{image}", $imageMiddleActual, $section);
|
||||||
|
$section = str_replace("{height}", $sectionHeight, $section);
|
||||||
|
$thermometer = $section . $thermometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pending
|
||||||
|
$sectionHeight = round(($pendingValue / $maximumValue) * $height);
|
||||||
|
$totalHeight = $totalHeight + $sectionHeight;
|
||||||
|
if ( $sectionHeight > 0 )
|
||||||
|
{
|
||||||
|
$section = $htmlSection;
|
||||||
|
$section = str_replace("{image}", $imageMiddlePending, $section);
|
||||||
|
$section = str_replace("{height}", $sectionHeight, $section);
|
||||||
|
$thermometer = $section . $thermometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// intent
|
||||||
|
$sectionHeight = round(($intentValue / $maximumValue) * $height);
|
||||||
|
$totalHeight = $totalHeight + $sectionHeight;
|
||||||
|
if ( $sectionHeight > 0 )
|
||||||
|
{
|
||||||
|
$section = $htmlSection;
|
||||||
|
$section = str_replace("{image}", $imageMiddleIntent, $section);
|
||||||
|
$section = str_replace("{height}", $sectionHeight, $section);
|
||||||
|
$thermometer = $section . $thermometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// goal
|
||||||
|
$sectionHeight = $height- $totalHeight;
|
||||||
|
if ( $sectionHeight > 0 )
|
||||||
|
{
|
||||||
|
$section = $htmlSection;
|
||||||
|
$section = str_replace("{image}", $imageMiddleGoal, $section);
|
||||||
|
$section = str_replace("{height}", $sectionHeight, $section);
|
||||||
|
$thermometer = $section . $thermometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// top
|
||||||
|
$thermometer = $htmlThermTop . $thermometer;
|
||||||
|
|
||||||
|
return $thermometer . $htmlLegenda;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -19,53 +19,25 @@
|
|||||||
* $Source$
|
* $Source$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$thermlib = "/var/www/www.eucd.info/htdocs/thermometer.php";
|
$thermlib = "../../lib/thermometer.php";
|
||||||
|
|
||||||
if (file_exists ($thermlib))
|
if (file_exists ($thermlib))
|
||||||
{
|
{
|
||||||
include($thermlib);
|
include($thermlib);
|
||||||
|
|
||||||
$posten_file = "/var/www/www.eucd.info/htdocs/posten.txt";
|
|
||||||
$totaal_file = "/var/www/www.eucd.info/htdocs/totaal.txt";
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read Values
|
* Read Values
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (file_exists ($posten_file))
|
$conf = new Conf();
|
||||||
{
|
$db = new Db();
|
||||||
if (file_exists ($totaal_file))
|
$don = new Don($db);
|
||||||
{
|
|
||||||
|
|
||||||
/* lees posten uit file */
|
$actualValue = $don->sum_actual();
|
||||||
$fp = fopen($posten_file, 'r' );
|
$pendingValue = $don->sum_pending();
|
||||||
|
$intentValue = $don->sum_intent();
|
||||||
|
|
||||||
if ($fp)
|
print moneyMeter($actualValue, $pendingValue, $intentValue);
|
||||||
{
|
|
||||||
$post_donaties = fgets( $fp, 10 );
|
|
||||||
$post_sponsoring = fgets( $fp, 10 );
|
|
||||||
$post_intent = fgets( $fp, 10 );
|
|
||||||
fclose( $fp );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lees posten uit file */
|
|
||||||
$fp = fopen( $totaal_file, 'r' );
|
|
||||||
if ($fp)
|
|
||||||
{
|
|
||||||
$totaal_ontvangen = fgets( $fp, 10 );
|
|
||||||
$totaal_pending = fgets( $fp, 10 );
|
|
||||||
fclose( $fp );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Graph thermometer
|
|
||||||
*/
|
|
||||||
|
|
||||||
print moneyMeter($totaal_ontvangen+$post_donaties+$post_sponsoring, $totaal_pending, $post_intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user