1+ <?php
2+ require_once ('../../lib/config.inc.php ' );
3+ require_once ('../../lib/app.inc.php ' );
4+
5+ /******************************************
6+ * Begin Form configuration
7+ ******************************************/
8+
9+ $ list_def_file = "list/mail_user_stats.list.php " ;
10+
11+ /******************************************
12+ * End Form configuration
13+ ******************************************/
14+
15+ // Checking module permissions
16+ if (!stristr ($ _SESSION ["s " ]["user " ]["modules " ],'mail ' )) {
17+ header ("Location: ../index.php " );
18+ exit ;
19+ }
20+
21+ $ app ->load ('listform_actions ' );
22+
23+ class list_action extends listform_actions {
24+
25+ function prepareDataRow ($ rec )
26+ {
27+ global $ app ;
28+
29+ $ rec = $ app ->listform ->decode ($ rec );
30+
31+ //* Alternating datarow colors
32+ $ this ->DataRowColor = ($ this ->DataRowColor == '#FFFFFF ' ) ? '#EEEEEE ' : '#FFFFFF ' ;
33+ $ rec ['bgcolor ' ] = $ this ->DataRowColor ;
34+
35+ //* Set the statistics colums
36+ //** Traffic of the current month
37+ $ tmp_date = date ('Y-m ' );
38+ $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = " .$ rec ['mailuser_id ' ]." AND month = ' $ tmp_date' " );
39+ $ rec ['this_month ' ] = number_format (intval ($ tmp_rec ['t ' ])/1024 , 0 , '. ' , ' ' );
40+
41+ //** Traffic of the current year
42+ $ tmp_date = date ('Y ' );
43+ $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = " .$ rec ['mailuser_id ' ]." AND month like ' $ tmp_date%' " );
44+ $ rec ['this_year ' ] = number_format (intval ($ tmp_rec ['t ' ])/1024 , 0 , '. ' , ' ' );
45+
46+ //** Traffic of the last month
47+ $ tmp_date = date ('Y-m ' ,mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
48+ $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = " .$ rec ['mailuser_id ' ]." AND month = ' $ tmp_date' " );
49+ $ rec ['last_month ' ] = number_format (intval ($ tmp_rec ['t ' ])/1024 , 0 , '. ' , ' ' );
50+
51+ //** Traffic of the last year
52+ $ tmp_date = date ('Y ' ,mktime (0 , 0 , 0 , date ("m " ), date ("d " ), date ("Y " )-1 ));
53+ $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = " .$ rec ['mailuser_id ' ]." AND month like ' $ tmp_date%' " );
54+ $ rec ['last_year ' ] = number_format (intval ($ tmp_rec ['t ' ])/1024 , 0 , '. ' , ' ' );
55+
56+ //* The variable "id" contains always the index variable
57+ $ rec ['id ' ] = $ rec [$ this ->idx_key ];
58+ return $ rec ;
59+ }
60+ }
61+
62+ $ list = new list_action ;
63+ $ list ->onLoad ();
64+
65+
66+ ?>
0 commit comments