28require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
43$graphheight = round($graphwidth * $mapratio);
47 $mode =
'memberbycountry';
51if ($user->socid > 0) {
53 $socid = $user->socid;
62$langs->loadLangs(array(
"companies",
"members",
"banks"));
71$arrayjs = array(
'https://www.google.com/jsapi');
72if (!empty(
$conf->dol_use_jmobile)) {
76$title = $langs->trans(
"Members");
78$help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Mitglieder';
80llxHeader(
'', $title, $help_url,
'', 0, 0, $arrayjs,
'',
'',
'mod-member page-stats_geo');
85$queryforbutton = array();
86$queryforbutton[
'mode'] =
'common';
87$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode',
dolBuildUrl(DOL_URL_ROOT.
'/adherents/list.php', $queryforbutton),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
88$queryforbutton[
'mode'] =
'kanban';
89$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode',
dolBuildUrl(DOL_URL_ROOT.
'/adherents/list.php', $queryforbutton),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
90$newcardbutton .= dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode',
dol_buildpath(
'/adherents/stats/index.php', 1).
'?objecttype=adherent@adherent'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', 2, array(
'morecss' =>
'reposition'));
91$newcardbutton .= dolGetButtonTitleSeparator();
92$newcardbutton .= dolGetButtonTitle($langs->trans(
'NewMember'),
'',
'fa fa-plus-circle',
dolBuildUrl(DOL_URL_ROOT.
'/adherents/card.php', [
'action' =>
'create']),
'', $user->hasRight(
'adherent',
'creer'));
94print_barre_liste($title, 0, $_SERVER[
"PHP_SELF"], $param,
'',
'',
'', 0, $langs->trans(
"Statistics"), $memberstatic->picto, 0, $newcardbutton,
'', 0, 0, 0, 1);
103if ($mode ==
'memberbycountry') {
104 $label = $langs->trans(
"Country");
105 $tab =
'statscountry';
107 $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";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
109 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c on d.country = c.rowid";
110 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
111 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
112 $sql .=
" AND d.statut <> ".Adherent::STATUS_DRAFT;
113 $sql .=
" GROUP BY c.label, c.code";
114} elseif ($mode ==
'memberbystate') {
115 $label = $langs->trans(
"Country");
116 $label2 = $langs->trans(
"State");
120 $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";
121 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
122 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c on d.state_id = c.rowid";
123 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as r on c.fk_region = r.code_region";
124 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co on d.country = co.rowid";
125 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
126 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
127 $sql .=
" AND d.statut <> ".Adherent::STATUS_DRAFT;
128 $sql .=
" GROUP BY co.label, co.code, c.nom";
130} elseif ($mode ==
'memberbyregion') {
131 $label = $langs->trans(
"Country");
132 $label2 = $langs->trans(
"Region");
133 $tab =
'statsregion';
136 $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";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
138 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c on d.state_id = c.rowid";
139 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as r on c.fk_region = r.code_region";
140 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co on d.country = co.rowid";
141 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
142 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
143 $sql .=
" AND d.statut <> ".Adherent::STATUS_DRAFT;
144 $sql .=
" GROUP BY co.label, co.code, r.nom";
145} elseif ($mode ==
'memberbytown') {
146 $label = $langs->trans(
"Country");
147 $label2 = $langs->trans(
"Town");
151 $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";
152 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
153 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c on d.country = c.rowid";
154 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"subscription as s ON s.fk_adherent = d.rowid";
155 $sql .=
" WHERE d.entity IN (".getEntity(
'adherent').
")";
156 $sql .=
" AND d.statut <> ".Adherent::STATUS_DRAFT;
157 $sql .=
" GROUP BY c.label, c.code, d.town";
161$langsen->setDefaultLang(
'en_US');
162$langsen->load(
"dict");
168 $resql =
$db->query($sql);
171 dol_syslog(__FILE__.
":No SQL, invalid mode '$mode'", LOG_ERR);
174 $num =
$db->num_rows($resql);
177 $obj =
$db->fetch_object($resql);
178 if ($mode ==
'memberbycountry') {
180 'label' => (
string) (($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ?
picto_from_langcode($obj->code,
'class="saturatemedium paddingrightonly"', 1).
' '.$langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
181 'label_en' => (
string) (($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
182 'code' => (
string) $obj->code,
183 'nb' => (int) $obj->nb,
184 'lastdate' =>
$db->jdate($obj->lastdate),
185 'lastsubscriptiondate' =>
$db->jdate($obj->lastsubscriptiondate)
187 } elseif ($mode ==
'memberbyregion') {
189 'label' => (
string) (($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ?
picto_from_langcode($obj->code,
'class="saturatemedium paddingrightonly"', 1).
' '.$langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
190 'label_en' => (
string) (($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
191 'label2' => ($obj->label2 ? $obj->label2 :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>'),
192 'nb' => (int) $obj->nb,
193 'lastdate' =>
$db->jdate($obj->lastdate),
194 'lastsubscriptiondate' =>
$db->jdate($obj->lastsubscriptiondate)
196 } elseif ($mode ==
'memberbystate') {
198 'label' => (
string) (($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ?
picto_from_langcode($obj->code,
'class="saturatemedium paddingrightonly"', 1).
' '.$langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
199 'label_en' => (
string) (($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
200 'label2' => ($obj->label2 ? $obj->label2 :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>'),
201 'nb' => (int) $obj->nb,
202 'lastdate' =>
$db->jdate($obj->lastdate),
203 'lastsubscriptiondate' =>
$db->jdate($obj->lastsubscriptiondate)
205 } elseif ($mode ==
'memberbytown') {
207 'label' => (
string) (($obj->code && $langs->trans(
"Country".$obj->code) !=
"Country".$obj->code) ?
picto_from_langcode($obj->code,
'class="saturatemedium paddingrightonly"', 1).
' '.$langs->trans(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
208 'label_en' => (
string) (($obj->code && $langsen->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langsen->transnoentitiesnoconv(
"Country".$obj->code) : ($obj->label ? $obj->label :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>')),
209 'label2' => (
string) ($obj->label2 ? $obj->label2 :
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>'),
210 'nb' => (int) $obj->nb,
211 'lastdate' =>
$db->jdate($obj->lastdate),
212 'lastsubscriptiondate' =>
$db->jdate($obj->lastsubscriptiondate)
231 print
'<span class="opacitymedium">'.$langs->trans(
"NoValidatedMemberYet").
'</span><br>';
234 if (empty($mode) || $mode ==
'memberbycountry') {
235 print
'<span class="opacitymedium">'.$langs->trans(
"MembersByCountryDesc");
237 print $langs->trans(
"MembersByCountryDesc2");
240 } elseif ($mode ==
'memberbystate') {
241 print
'<span class="opacitymedium">'.$langs->trans(
"MembersByStateDesc").
'</span><br>';
242 } elseif ($mode ==
'memberbytown') {
243 print
'<span class="opacitymedium">'.$langs->trans(
"MembersByTownDesc").
'</span><br>';
244 } elseif ($mode ==
'memberbyregion') {
245 print
'<span class="opacitymedium">'.$langs->trans(
"MembersByRegion").
'</span><br>';
247 print
'<span class="opacitymedium">'.$langs->trans(
"DraftMembersAreExcluded").
'</span><br>';
254 global $theme_bordercolor,
$theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet;
255 $color_file = DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
256 if (is_readable($color_file)) {
262 print
"\n<script type='text/javascript'>\n";
263 print
"google.load('visualization', '1', {'packages': ['geomap']});\n";
264 print
"google.setOnLoadCallback(drawMap);\n";
265 print
"function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
268 print
"\tdata.addRows(".count($data).
");\n";
269 print
"\tdata.addColumn('string', 'Country');\n";
270 print
"\tdata.addColumn('number', 'Number');\n";
274 foreach ($data as $val) {
275 $valcountry = strtoupper($val[
'code']);
280 print
"\tdata.setValue(".$i.
", 0, \"".$valcountry.
"\");\n";
281 print
"\tdata.setValue(".$i.
", 1, ".$val[
'nb'].
");\n";
289 print
"\tvar options = {};\n";
290 print
"\toptions['dataMode'] = 'regions';\n";
291 print
"\toptions['showZoomOut'] = false;\n";
293 print
"\toptions['width'] = ".$graphwidth.
";\n";
294 print
"\toptions['height'] = ".$graphheight.
";\n";
296 print
"\tvar container = document.getElementById('".$mode.
"');\n";
297 print
"\tvar geomap = new google.visualization.GeoMap(container);\n";
298 print
"\tgeomap.draw(data, options);\n";
303 print
'<div class="center" id="'.$mode.
'"></div>'.
"\n";
307print
'<div class="div-table-responsive">';
308print
'<table class="liste centpercent noborder">';
309print
'<tr class="liste_titre">';
310print
'<th>'.$label.
'</th>';
312 print
'<th class="center">'.$label2.
'</th>';
314print
'<th class="right">'.$langs->trans(
"NbOfMembers").
' <span class="opacitymedium">('.$langs->trans(
"AllTime").
')</span></th>';
315print
'<th class="center">'.$langs->trans(
"LastMemberDate").
'</th>';
316print
'<th class="center">'.$langs->trans(
"LatestSubscriptionDate").
'</th>';
319foreach ($data as $val) {
320 print
'<tr class="oddeven">';
321 print
'<td>'.$val[
'label'].
'</td>';
322 if (isset($label2)) {
323 print
'<td class="center">'.$val[
'label2'].
'</td>';
325 print
'<td class="right">'.$val[
'nb'].
'</td>';
326 print
'<td class="center">'.dol_print_date($val[
'lastdate'],
'dayhour',
'auto',
null,
false, 1).
'</td>';
327 print
'<td class="center">'.dol_print_date($val[
'lastsubscriptiondate'],
'dayhour',
'auto',
null,
false, 1).
'</td>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage translations.
colorArrayToHex($arraycolor, $colorifnotfound='888888')
Convert an array with RGB value into hex RGB value.
dol_now($mode='gmt')
Return date for now.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats information.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.