24 require
'../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
31 $graphheight = round($graphwidth * $mapratio);
37 if ($user->socid > 0) {
39 $socid = $user->socid;
43 $year = strftime(
"%Y", time());
44 $startyear = $year - 2;
48 $langs->loadLangs(array(
"companies",
"members",
"banks"));
55 $arrayjs = array(
'https://www.google.com/jsapi');
56 if (!empty($conf->dol_use_jmobile)) $arrayjs = array();
58 $title = $langs->trans(
"Statistics");
59 if ($mode ==
'memberbycountry') $title = $langs->trans(
"MembersStatisticsByCountries");
60 if ($mode ==
'memberbystate') $title = $langs->trans(
"MembersStatisticsByState");
61 if ($mode ==
'memberbytown') $title = $langs->trans(
"MembersStatisticsByTown");
62 if ($mode ==
'memberbyregion') $title = $langs->trans(
"MembersStatisticsByRegion");
64 llxHeader(
'', $title,
'',
'', 0, 0, $arrayjs);
72 if ($mode ==
'memberbycountry') {
73 $label = $langs->trans(
"Country");
74 $tab =
'statscountry';
77 $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";
78 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
79 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c on d.country = c.rowid";
80 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
81 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
82 $sql .=
" AND d.statut != -1";
83 $sql .=
" GROUP BY c.label, c.code";
87 if ($mode ==
'memberbystate') {
88 $label = $langs->trans(
"Country");
89 $label2 = $langs->trans(
"State");
93 $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";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
95 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c on d.state_id = c.rowid";
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as r on c.fk_region = r.code_region";
97 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co on d.country = co.rowid";
98 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
99 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
100 $sql .=
" AND d.statut != -1";
101 $sql .=
" GROUP BY co.label, co.code, c.nom";
104 if ($mode ==
'memberbyregion') {
105 $label = $langs->trans(
"Country");
106 $label2 = $langs->trans(
"Region");
107 $tab =
'statsregion';
110 $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";
111 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
112 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c on d.state_id = c.rowid";
113 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as r on c.fk_region = r.code_region";
114 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co on d.country = co.rowid";
115 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
116 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
117 $sql .=
" AND d.statut != -1";
118 $sql .=
" GROUP BY co.label, co.code, r.nom";
121 if ($mode ==
'memberbytown') {
122 $label = $langs->trans(
"Country");
123 $label2 = $langs->trans(
"Town");
127 $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";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
129 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c on d.country = c.rowid";
130 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
131 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
132 $sql .=
" AND d.statut != -1";
133 $sql .=
" GROUP BY c.label, c.code, d.town";
138 $langsen->setDefaultLang(
'en_US');
139 $langsen->load(
"dict");
144 $resql = $db->query($sql);
146 $num = $db->num_rows(
$resql);
149 $obj = $db->fetch_object(
$resql);
150 if ($mode ==
'memberbycountry') {
151 $data[] = array(
'label'=>(($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
152 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
155 'lastdate'=>$db->jdate($obj->lastdate),
156 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
159 if ($mode ==
'memberbyregion') {
161 'label'=>(($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
162 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
163 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans(
"Unknown")),
165 'lastdate'=>$db->jdate($obj->lastdate),
166 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
169 if ($mode ==
'memberbystate') {
170 $data[] = array(
'label'=>(($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
171 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
172 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans(
"Unknown")),
174 'lastdate'=>$db->jdate($obj->lastdate),
175 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
178 if ($mode ==
'memberbytown') {
179 $data[] = array(
'label'=>(($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
180 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans(
"Unknown"))),
181 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans(
"Unknown")),
183 'lastdate'=>$db->jdate($obj->lastdate),
184 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
203 if ($mode && !count($data)) {
204 print $langs->trans(
"NoValidatedMemberYet").
'<br>';
207 if ($mode ==
'memberbycountry')
print '<span class="opacitymedium">'.$langs->trans(
"MembersByCountryDesc").
'</span><br>';
208 elseif ($mode ==
'memberbystate')
print '<span class="opacitymedium">'.$langs->trans("MembersByStateDesc").'</span><br>';
209 elseif ($mode == 'memberbytown')
print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
210 elseif ($mode == 'memberbyregion')
print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>';
212 print '<span class="opacitymedium">'.$langs->trans(
"MembersStatisticsDesc").
'</span><br>';
214 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?mode=memberbycountry">'.$langs->trans(
"MembersStatisticsByCountries").
'</a><br>';
216 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?mode=memberbystate">'.$langs->trans(
"MembersStatisticsByState").
'</a><br>';
218 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?mode=memberbytown">'.$langs->trans(
"MembersStatisticsByTown").
'</a><br>';
220 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?mode=memberbyregion">'.$langs->trans(
"MembersStatisticsByRegion").
'</a><br>';
227 if (count($arrayjs) && $mode ==
'memberbycountry') {
228 $color_file = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
229 if (is_readable($color_file)) include_once $color_file;
233 print "\n<script type='text/javascript'>\n";
234 print "google.load('visualization', '1', {'packages': ['geomap']});\n";
235 print "google.setOnLoadCallback(drawMap);\n";
236 print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
239 print "\tdata.addRows(".count($data).
");\n";
240 print "\tdata.addColumn('string', 'Country');\n";
241 print "\tdata.addColumn('number', 'Number');\n";
245 foreach ($data as $val) {
246 $valcountry = strtoupper($val[
'code']);
248 if ($valcountry ==
'Great Britain') { $valcountry =
'United Kingdom'; }
249 print "\tdata.setValue(".$i.
", 0, \"".$valcountry.
"\");\n";
250 print "\tdata.setValue(".$i.
", 1, ".$val[
'nb'].
");\n";
252 if ($i >= 400) {
break; }
256 print "\tvar options = {};\n";
257 print "\toptions['dataMode'] = 'regions';\n";
258 print "\toptions['showZoomOut'] = false;\n";
260 print "\toptions['width'] = ".$graphwidth.
";\n";
261 print "\toptions['height'] = ".$graphheight.
";\n";
262 print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1],
'BBBBBB').
", 0x".
colorArrayToHex($theme_datacolor[0],
'444444').
"];\n";
263 print "\tvar container = document.getElementById('".$mode.
"');\n";
264 print "\tvar geomap = new google.visualization.GeoMap(container);\n";
265 print "\tgeomap.draw(data, options);\n";
270 print '<div class="center" id="'.$mode.
'"></div>'.
"\n";
276 print '<div class="div-table-responsive">';
277 print '<table class="liste centpercent">';
278 print '<tr class="liste_titre">';
279 print '<td>'.$label.
'</td>';
280 if ($label2)
print '<td class="center">'.$label2.
'</td>';
281 print '<td class="right">'.$langs->trans(
"NbOfMembers").
' <span class="opacitymedium">('.$langs->trans(
"AllTime").
')</span></td>';
282 print '<td class="center">'.$langs->trans(
"LastMemberDate").
'</td>';
283 print '<td class="center">'.$langs->trans(
"LatestSubscriptionDate").
'</td>';
286 foreach ($data as $val) {
287 $year = $val[
'year'];
288 print '<tr class="oddeven">';
289 print '<td>'.$val[
'label'].
'</td>';
290 if ($label2)
print '<td class="center">'.$val[
'label2'].
'</td>';
291 print '<td class="right">'.$val[
'nb'].
'</td>';
292 print '<td class="center">'.dol_print_date($val[
'lastdate'],
'dayhour').
'</td>';
293 print '<td class="center">'.dol_print_date($val[
'lastsubscriptiondate'],
'dayhour').
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage translations.
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats informations.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
static getDefaultGraphSizeForStats($direction, $defaultsize= '')
getDefaultGraphSizeForStats
colorArrayToHex($arraycolor, $colorifnotfound= '888888')
Convert an array with RGB value into hex RGB value.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)