NEW Show the latest date of subscription in member statistics reports

This commit is contained in:
Laurent Destailleur 2019-03-07 12:22:24 +01:00
parent a426c8e9bf
commit f54eb78260
4 changed files with 35 additions and 22 deletions

View File

@ -58,15 +58,16 @@ llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, arra
$title=$langs->trans("MembersStatisticsByProperties");
print load_fiche_titre($title, $mesg);
print load_fiche_titre($title, '');
dol_mkdir($dir);
$tab='byproperties';
$data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code";
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, 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.=" GROUP BY d.morphy";
@ -87,7 +88,7 @@ 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));
$data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
$i++;
}
@ -120,22 +121,21 @@ print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Nature").'</td>';
print '<td class="right">'.$langs->trans("NbOfMembers").'</td>';
print '<td align="center">'.$langs->trans("LastMemberDate").'</td>';
print '<td align="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
print '</tr>';
if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');
if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'');
if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>'');
if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>'');
$oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
print '<tr class="oddeven">';
print '<td>'.$memberstatic->getmorphylib($val['label']).'</td>';
print '<td class="right">'.$val['nb'].'</td>';
print '<td align="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
print '<td align="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
print '</tr>';
$oldyear=$year;
}
print '</table>';

View File

@ -77,8 +77,10 @@ if ($mode)
$tab='statscountry';
$data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
$sql.="SELECT COUNT(d.rowid) as nb, 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.=" GROUP BY c.label, c.code";
@ -92,10 +94,12 @@ if ($mode)
$tab='statsstate';
$data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, c.nom as label2"; //
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$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.=" 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.=" GROUP BY co.label, co.code, c.nom";
@ -108,10 +112,12 @@ if ($mode)
$tab='statsregion'; //onglet
$data = array(); //tableau de donnée
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, r.nom as label2";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$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.=" 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.=" GROUP BY co.label, co.code, r.nom"; //+
@ -124,9 +130,10 @@ if ($mode)
$tab='statstown';
$data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2";
$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.=" 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.=" GROUP BY c.label, c.code, d.town";
@ -154,7 +161,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'code'=>$obj->code,
'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate)
'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
if ($mode == 'memberbyregion') //+
@ -164,7 +172,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate)
'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
if ($mode == 'memberbystate')
@ -173,7 +182,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate)
'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
if ($mode == 'memberbytown')
@ -182,7 +192,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate)
'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
@ -289,9 +300,9 @@ if ($mode)
if ($label2) print '<td align="center">'.$label2.'</td>';
print '<td class="right">'.$langs->trans("NbOfMembers").'</td>';
print '<td align="center">'.$langs->trans("LastMemberDate").'</td>';
print '<td align="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
print '</tr>';
$oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
@ -300,8 +311,8 @@ if ($mode)
if ($label2) print '<td align="center">'.$val['label2'].'</td>';
print '<td class="right">'.$val['nb'].'</td>';
print '<td align="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
print '<td align="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
print '</tr>';
$oldyear=$year;
}
print '</table>';

View File

@ -58,6 +58,8 @@ CREATE TABLE llx_pos_cash_fence(
-- For 10.0
DROP TABLE llx_cotisation;
ALTER TABLE llx_loan ADD COLUMN insurance_amount double(24,8) DEFAULT 0;
ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber;

View File

@ -109,4 +109,4 @@ UserLogoff=User logout
UserLogged=User logged
DateEmployment=Employment Start Date
DateEmploymentEnd=Employment End Date
CantDisableYourself=You can disable your own user record
CantDisableYourself=You can't disable your own user record