14 define(
'IN_PEEL_ADMIN',
true);
15 include(
"../configuration.inc.php");
19 require(
$GLOBALS[
'dirroot'] .
'/modules/chart/advisto-chart.php');
21 foreach(array(
'date1',
'date2',
'type',
'renewals',
'width') as $item) {
22 if (isset($_GET[$item])) {
23 $$item = $_GET[$item];
36 if(
vb(
$GLOBALS[
'site_parameters'][
'chart_product']) ==
'flot') {
37 $date_format =
'timestamp1000';
38 }
elseif (strtotime($date2) - strtotime($date1) < 6300 * 24 * 30 * 6) {
39 $date_format =
'veryshort';
41 $date_format =
'short';
43 if (strlen($date2) ==
'10') {
44 $date2 .=
' 23:59:00';
46 if ($type ==
'users-by-age' &&
a_priv(
'admin_users',
true)) {
54 $sql_age_formula =
'IF(date_naissance>"' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 18 * 24 * 3600)) .
'", 18,IF(date_naissance BETWEEN "' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 25 * 24 * 3600)) .
'" AND "' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 18 * 24 * 3600)) .
'", 25,IF(date_naissance BETWEEN "' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 35 * 24 * 3600)) .
'" AND "' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 25 * 24 * 3600)) .
'", 35,IF(date_naissance BETWEEN "' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 45 * 24 * 3600)) .
'" AND "' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 35 * 24 * 3600)) .
'", 45,IF(date_naissance<"' . date(
'Y-m-d 12:00:00', round(time() - 365.25 * 45 * 24 * 3600)) .
'", 50,0)))))';
55 $type_names = array(18 =>
'- de 18 ans', 25 =>
'18 à 25 ans', 35 =>
'25 à 35 ans', 45 =>
'35 à 45 ans', 50 =>
'45 ans et +');
56 $sex_names = array(
'M.' =>
'H',
'Mlle' =>
'F',
'Mme' =>
'F');
57 $res =
query(
'SELECT count(*) AS this_count, civilite, ' . $sql_age_formula .
' AS tranche
58 FROM peel_utilisateurs
60 GROUP BY civilite, ' . $sql_age_formula);
61 $data[
'Tous'] = array();
63 $data[$sex_names[$row[
'sexe']]][($type_names[$row[
'tranche']])] = $row[
'this_count'];
64 if (empty(
$data[
'Tous'][($type_names[$row[
'tranche']])])) {
65 $data[
'Tous'][($type_names[$row[
'tranche']])] = 0;
67 $data[
'Tous'][($type_names[$row[
'tranche']])] += $row[
'this_count'];
73 }
elseif ($type ==
'forums-count' &&
a_priv(
'admin_content',
true)) {
74 $res =
query(
'SELECT count(*) AS this_count, date
77 GROUP BY TO_DAYS(a.date)');
81 $total += $row[
'this_count'];
84 }
elseif ($type ==
'forums-categories' &&
a_priv(
'admin_content',
true)) {
85 $res =
query(
'SELECT count(*) AS this_count, c.nom
87 INNER JOIN peel_forums_cat c ON c.id=a.id_cat
93 $total += $row[
'this_count'];
98 }
elseif ($type ==
'users-count' &&
a_priv(
'admin_users',
true)) {
100 if (empty(
$graph_type[$GLOBALS[
"STR_ADMIN_INSCRIPTIONS"]]) ||
$graph_type[$GLOBALS[
"STR_ADMIN_INSCRIPTIONS"]] !=
'dot') {
101 if (!empty($date1)) {
102 $t2 = strtotime($date2);
103 for($t = strtotime($date1);$t <= $t2;$t += 3600 * 24) {
108 $res =
query(
'SELECT count(*) AS this_count, date_insert AS date_inscription, 1 AS actif
109 FROM peel_utilisateurs
111 GROUP BY TO_DAYS(date_insert)');
119 $colors[$GLOBALS[
"STR_ADMIN_INSCRIPTIONS"]] =
'0000FF';
121 }
elseif ($type ==
'product-categories' &&
a_priv(
'admin_products',
true)) {
122 $res =
query(
'SELECT count(*) AS this_count, c.nom_'.
$_SESSION[
'session_langue'].
' AS nom_categorie
124 INNER JOIN peel_produits_categories pc ON pc.produit_id=p.id
125 INNER JOIN peel_categories c ON c.id=pc.categorie_id AND ' .
get_filter_site_cond(
'categories',
'c') .
'
134 }
elseif ($type ==
'users-by-sex' &&
a_priv(
'admin_users',
true)) {
135 $res =
query(
'SELECT count(*) AS this_count, civilite
136 FROM peel_utilisateurs
140 if ($row[
'civilite'] ==
'M.') {
145 $data[$type_name] = $row[
'this_count'];
148 $title = $GLOBALS[
'STR_ADMIN_CHART_DATA_USERS_BY_SEX'] .
' ' . (!empty($date1)?
' ' . $GLOBALS[
'strStartingOn'] .
' ' .
get_formatted_date($date1) .
' ' . $GLOBALS[
'strTillDay'] .
' ' .
get_formatted_date($date2):
'');
149 }
elseif ($type ==
'users-by-country' &&
a_priv(
'admin_users',
true)) {
150 $res =
query(
'SELECT count(*) AS this_count, c.nom_'.
$_SESSION[
'session_langue'].
' AS country_name
151 FROM `peel_utilisateurs` a
156 $data[$row[
'country_name']] = $row[
'this_count'];
159 $title = $GLOBALS[
'STR_ADMIN_CHART_DATA_USERS_BY_COUNTRY'] . (!empty($date1)?
' ' . $GLOBALS[
'strStartingOn'] .
' ' .
get_formatted_date($date1) .
' ' . $GLOBALS[
'strTillDay'] .
' ' .
get_formatted_date($date2):
'');
161 $data[
'CA'] = array();
164 if (!empty($date1)) {
165 $t2 = strtotime($date2);
166 for($t = strtotime($date1);$t <= $t2;$t += 3600 * 24) {
171 $res =
query(
'SELECT SUM(c.montant_ht) AS this_total, c.a_timestamp
172 FROM peel_commandes c
173 LEFT JOIN peel_statut_paiement sp ON sp.id=c.id_statut_paiement AND ' .
get_filter_site_cond(
'statut_paiement',
'sp') .
'
175 GROUP BY TO_DAYS(c.a_timestamp)');
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
necessite_priv($priv, $demo_allowed=true, $configuration_modification=false)
Cette fonction vérifie si l'utilisateur a les privilèges de $priv.
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
advistoChart(&$data, $title=null, $all_graph_type=null, $graph_type=array(), $colors=array(), $legend_font_size=12, $width=300, $force_chart_product=null)
advistoChart()
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
necessite_identification()
Si l'utilisateur n'est pas connecté à un compte, on affiche une page d'identification et arrête le sc...
fetch_assoc($query_result)
fetch_assoc()
$GLOBALS['page_columns_count']
a_priv($requested_priv, $demo_allowed=false, $site_configuration_modification=false, $user_id=null)
Renvoie true si l'utilisateur de la session a le privilège $requested_priv ou un droit supérieur Des ...
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']