ich stelle mir vor, dass viele/die meisten Vereine so eine Meldung abgeben müssen und hab da mal was zusammengehackt. Mein Ergebnis stelle ich gerne der Allgemeinheit zur Verfügung.
Disclaimer:
Unten stehender Code hat nicht den Anspruch, besonders elegant zu sein oder allgemeingültig und ohne Anpassungen direkt auf anderen Installation zu funktionieren; und ich bin weit davon entfernt, ein Programmierer oder Entwickler zu sein, ich arbeite eher "lösungsorientiert"
Die Lösung funktioniert hier auf meiner eigenen Admidio Installation V2.2.6 in einer für mich ausreichenden Qualität. Wenn aber jemand eine Idee hat, wie das eleganter geht - nur zu, korrigiert mich
PS: Großes Lob an die Admidio Entwickler, das ist ein wirklich feines Stück Software und löst hier bei mir einige Probleme!
Zurück zur LSB Meldung
Schritt 1: unterhalb von adm_program/modules ein neues Verzeichnis "statistics" anlegen
Schritt 2: die korrekten Id's für
gender.usd_usf_id und birthday.usd_usf_id herausfinden. Sind bei mir 11 und 10. Kann bei anderen Installationen abweichen. Ein Blick in die Tabelle "adm_user_fields" und dort in die Spalte usf_id sollte reichen.
Schritt 3:
in adm_program/modules/statistics eine Datei statistic.php mit folgendem Inhalt anlegen:
--- cut ---
Code: Alles auswählen
<?php
require_once('../../system/common.php');
require_once('../../system/classes/table_roles.php');
// nur eingeloggte Benutzer duerfen auf das Modul zugreifen
require_once('../../system/login_valid.php');
// Html-Kopf Seitentitel ausgeben
$g_layout['title'] = 'Statistiken';
$g_layout['header'] = '
<script type="text/javascript"><!--
$(document).ready(function()
{
$("a[rel=\'lnkDelete\']").colorbox({rel:\'nofollow\', scrolling:false, onComplete:function(){$("#admButtonNo").focus();}});
});
//--></script>';
require(SERVER_PATH. '/adm_program/system/overall_header.php');
//LSB Meldungen
echo "<hr>";
echo "<h3><strong>LSB Meldung</strong></h3>";
//Anzahl Mitglieder <=25 Jahre
$sql ="select distinct gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=25
;";
$result = $g_db->query($sql);
$mitglieder_bis_25 = $g_db->num_rows($result);
//Anzahl maennlich 0-6
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=6
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_0_bis_6 = $g_db->num_rows($result);
//Anzahl maennlich 7-14
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>6
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=14
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_7_bis_14 = $g_db->num_rows($result);
//Anzahl maennlich 15-18
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>14
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=18
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_15_bis_18 = $g_db->num_rows($result);
//Anzahl maennlich 19-26
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>18
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=26
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_19_bis_26 = $g_db->num_rows($result);
//Anzahl maennlich 27-40
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>26
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=40
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_27_bis_40 = $g_db->num_rows($result);
//Anzahl maennlich 41-60
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>40
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=60
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_41_bis_60 = $g_db->num_rows($result);
//Anzahl maennlich >60
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>60
and
gender.usd_value =1
;";
$result = $g_db->query($sql);
$maennlich_ab_61 = $g_db->num_rows($result);
//Anzahl weiblich 0-6
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=6
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_0_bis_6 = $g_db->num_rows($result);
//Anzahl weiblich 7-14
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>6
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=14
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_7_bis_14 = $g_db->num_rows($result);
//Anzahl weiblich 15-18
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>14
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=18
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_15_bis_18 = $g_db->num_rows($result);
//Anzahl weiblich 19-26
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>18
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=26
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_19_bis_26 = $g_db->num_rows($result);
//Anzahl weiblich 27-40
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>26
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=40
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_27_bis_40 = $g_db->num_rows($result);
//Anzahl weiblich 41-60
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>40
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))<=60
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_41_bis_60 = $g_db->num_rows($result);
//Anzahl weiblich >60
$sql ="select distinct status.usd_value as status,gender.usd_value as gender,birthday.usd_value
from adm_user_data
left join adm_members on adm_user_data.usd_usr_id = adm_members.mem_usr_id
left join adm_user_data as status on status.usd_usr_id = adm_members.mem_usr_id and status.usd_usf_id = 24
left join adm_user_data as gender on gender.usd_usr_id = adm_members.mem_usr_id and gender.usd_usf_id = 11
left join adm_user_data as birthday on birthday.usd_usr_id = adm_members.mem_usr_id and birthday.usd_usf_id=10
where
adm_members.mem_end > curdate()
and
adm_members.mem_rol_id = 2
and
(year(curdate())-year(birthday.usd_value)) - (right(curdate(),5)<right(birthday.usd_value,5))>60
and
gender.usd_value =2
;";
$result = $g_db->query($sql);
$weiblich_ab_61 = $g_db->num_rows($result);
echo "<p>";
echo "<strong>alle Mitglieder bis einschliesslich 25 Jahre</strong>: $mitglieder_bis_25 <br>";
echo "<table>";
echo "<tr>";
echo "<td>";
echo "<table>";
echo "<tr><td><strong>männlich</strong></td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td> </td><td>0 - 6 Jahre:</td><td>  </td><td align=right>$maennlich_0_bis_6 </td></tr>";
echo "<tr><td> </td><td>7 - 14 Jahre:</td><td>  </td><td align=right>$maennlich_7_bis_14 </td></tr>";
echo "<tr><td> </td><td>15 - 18 Jahre:</td><td>  </td><td align=right>$maennlich_15_bis_18 </td></tr>";
echo "<tr><td> </td><td>19 - 26 Jahre:</td><td>  </td><td align=right>$maennlich_19_bis_26 </td></tr>";
echo "<tr><td> </td><td>27 - 40 Jahre:</td><td>  </td><td align=right>$maennlich_27_bis_40 </td></tr>";
echo "<tr><td> </td><td>41 - 60 Jahre:</td><td>  </td><td align=right>$maennlich_41_bis_60 </td></tr>";
echo "<tr><td> </td><td>61+ Jahre:</td><td>  </td><td align=right>$maennlich_ab_61 </td></tr>";
echo "</table>";
echo "</td><td>";
echo "<table>";
echo "<tr><td><strong>weiblich</strong></td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td> </td><td>0 - 6 Jahre:</td><td>  </td><td align=right>$weiblich_0_bis_6 </td></tr>";
echo "<tr><td> </td><td>7 - 14 Jahre:</td><td>  </td><td align=right>$weiblich_7_bis_14 </td></tr>";
echo "<tr><td> </td><td>15 - 18 Jahre:</td><td>  </td><td align=right>$weiblich_15_bis_18 </td></tr>";
echo "<tr><td> </td><td>19 - 26 Jahre:</td><td>  </td><td align=right>$weiblich_19_bis_26 </td></tr>";
echo "<tr><td> </td><td>27 - 40 Jahre:</td><td>  </td><td align=right>$weiblich_27_bis_40 </td></tr>";
echo "<tr><td> </td><td>41 - 60 Jahre:</td><td>  </td><td align=right>$weiblich_41_bis_60 </td></tr>";
echo "<tr><td> </td><td>61+ Jahre:</td><td>  </td><td align=right>$weiblich_ab_61 </td></tr>";
echo "</table>";
echo "<td>";
echo "</tr>";
echo "</table>";
require(SERVER_PATH. '/adm_program/system/overall_footer.php');
?>
Schritt 4
Der rechten Seitenleiste einen Link hinzufügen:
adm_themes/modern/my_body_bottom.php editieren und unterhalb von
--- cut ---
<a href="'. $g_root_path. '/adm_program/index.php">'.$g_l10n->get('SYS_OVERVIEW').'</a></span>';
--- cut ---
(sollte so Zeile 17, 18 oder 19 sein)
folgendes einfügen:
--- cut ---
{
echo '
<span class="menu"><a href="'. $g_root_path. '/adm_program/modules/statistics/statistic.php" "><img
style="vertical-align: middle;" src="'. THEME_PATH. '/icons/statistics.png" alt="Statistiken" title="Statistiken" /></a>
<a href="'. $g_root_path. '/adm_program/modules/statistics/statistic.php">Statistiken</a></span>';
}
--- cut ---
Wer mag, kann sich noch ein nettes Icon statistics.png basteln und nach adm_themes/modern/icons legen.
Diese Anleitung erhebt keinen Anspruch auf Vollständigeit und die Änderungen werden das nächste Admidio Update möglicherweise auch nicht überleben.
So. Mein erster Post ist fertig.
Gruss, Arthur.