Browse files

Add more statistics

  • Loading branch information...
1 parent 96fd440 commit a202f7cbe4ecdba406d22ce98d94a3c5462534c9 @simonewebdesign committed Feb 9, 2013
Showing with 29 additions and 8 deletions.
  1. +29 −8 statistics.php
View
37 statistics.php
@@ -6,7 +6,6 @@
#########################
-#$newsletters = Newsletter::all();
$most_active_users_db = $db->query("SELECT
u.id, u.name, u.email, u.is_active, u.is_subscribed, u.has_received_mail, u.created_at,
e.id, e.user_id, e.resource_id, e.requested_at, e.ip_address, e.user_agent,
@@ -26,10 +25,16 @@
ORDER BY number_of_users DESC");
$browsers = $browsers_db->fetchAll(PDO::FETCH_OBJ);
-$lists = Lista::all();
+$lists_db = $db->query("SELECT
+lists.`name`,
+(select count(id) from users where list_id= lists.id and is_active=1) as active_users,
+(select count(id) from users where list_id= lists.id) as total_users
+from lists
+GROUP BY lists.id");
+$lists = $lists_db->fetchAll(PDO::FETCH_OBJ);
?>
-<h1>Statistics</h1>
+<h1>Statistiche</h1>
<table>
<thead>
@@ -41,20 +46,36 @@
</tr>
</thead>
<tbody>
-<?php foreach ($lists as $list) { ?>
+<?php
+ $total_active_users = 0;
+ $total_inactive_users = 0;
+ $grand_total_users = 0;
+?>
+<?php foreach ($lists as $list) {?>
+<?php
+ $total_active_users += $list->active_users;
+ $total_inactive_users += $list->total_users - $list->active_users;
+ $grand_total_users += $list->total_users;
+?>
<tr>
<td><?=$list->name?></td>
- <td></td>
- <td></td>
- <td></td>
+ <td><?=$list->active_users?></td>
+ <td><?=$list->total_users - $list->active_users?></td>
+ <td><?=$list->total_users?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
-
+ <tr>
+ <td>Totale</td>
+ <td><?=$total_active_users?></td>
+ <td><?=$total_inactive_users?></td>
+ <td><?=$grand_total_users?></td>
+ </tr>
</tfoot>
</table>
+
<table><caption>Top 50 most active users</caption>
<thead>
<tr>

0 comments on commit a202f7c

Please sign in to comment.