This commit is contained in:
Laurent Destailleur 2020-09-14 03:34:03 +02:00
parent 78a999e6f3
commit 419ac91a7a
3 changed files with 57 additions and 17 deletions

View File

@ -61,16 +61,16 @@ print load_fiche_titre($title, '', 'object_group');
dol_mkdir($dir);
$tab = 'byproperties';
$data = array();
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code";
$sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions,";
$sql .= " MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate,";
$sql .= " d.morphy as code";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut = 1";
$sql .= " AND d.statut != -1"; // Not draft
$sql .= " GROUP BY d.morphy";
$foundphy = $foundmor = 0;
// Define $data array
@ -85,7 +85,38 @@ if ($resql) {
if ($obj->code == 'phy') $foundphy++;
if ($obj->code == 'mor') $foundmor++;
$data[] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
$data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
$i++;
}
$db->free($resql);
} else {
dol_print_error($db);
}
$sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions,";
$sql .= " MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate,";
$sql .= " d.morphy as code";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0)
$sql .= " GROUP BY d.morphy";
$foundphy = $foundmor = 0;
// Define $data array
dol_syslog("Count member still active", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj->code == 'phy') $foundphy++;
if ($obj->code == 'mor') $foundmor++;
$data[$obj->code]['nbactive'] = $obj->nb;
$i++;
}
@ -114,18 +145,26 @@ print '<table class="liste centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("MemberNature").'</td>';
print '<td class="right">'.$langs->trans("NbOfMembers").'</td>';
print '<td class="right">'.$langs->trans("NbOfActiveMembers").'</td>';
print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
print '<td class="right">'.$langs->trans("NbOfSubscriptions").'</td>';
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
print '</tr>';
if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>'');
foreach ($data as $val) {
$nb = $val['nb'];
$nbsubscriptions = $val['nbsubscriptions'];
$nbactive = $val['nbactive'];
print '<tr class="oddeven">';
print '<td>'.$memberstatic->getmorphylib($val['label']).'</td>';
print '<td class="right">'.$val['nb'].'</td>';
print '<td class="right">'.$nb.'</td>';
print '<td class="right">'.$nbactive.'</td>';
print '<td class="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
print '<td class="right">'.$nbsubscriptions.'</td>';
print '<td class="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
print '</tr>';
}

View File

@ -74,12 +74,12 @@ if ($mode) {
$tab = 'statscountry';
$data = array();
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut = 1";
$sql .= " AND d.statut != -1";
$sql .= " GROUP BY c.label, c.code";
//print $sql;
}
@ -90,14 +90,14 @@ if ($mode) {
$tab = 'statsstate';
$data = array();
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut = 1";
$sql .= " AND d.statut != -1";
$sql .= " GROUP BY co.label, co.code, c.nom";
//print $sql;
}
@ -107,14 +107,14 @@ if ($mode) {
$tab = 'statsregion'; //onglet
$data = array(); //tableau de donnée
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut = 1";
$sql .= " AND d.statut != -1";
$sql .= " GROUP BY co.label, co.code, r.nom"; //+
//print $sql;
}
@ -124,12 +124,12 @@ if ($mode) {
$tab = 'statstown';
$data = array();
$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut = 1";
$sql .= " AND d.statut != -1";
$sql .= " GROUP BY c.label, c.code, d.town";
//print $sql;
}

View File

@ -168,6 +168,7 @@ MembersStatisticsByState=Members statistics by state/province
MembersStatisticsByTown=Members statistics by town
MembersStatisticsByRegion=Members statistics by region
NbOfMembers=Number of members
NbOfActiveMembers=Number of still active members
NoValidatedMemberYet=No validated members found
MembersByCountryDesc=This screen show you statistics on members by countries. Graphic depends however on Google online graph service and is available only if an internet connection is is working.
MembersByStateDesc=This screen show you statistics on members by state/provinces/canton.