[% USE Whostmgr; USE CPGraph; USE CPMath; USE CPSort; USE JSON; SET barsize = 80; WRAPPER 'master_templates/master.tmpl' theme="yui" app_key = 'view_bandwidth_usage' stylesheets = ['/css/graphs.css'] canvas = 1 extrastyle = ' table { width: 100%; } .text-right { text-align: right; } .top-warning { margin-bottom: 1.5em; } '; SET months=[ '', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; IF data.month == 1; SET lastyear = data.year - 1; SET lastmonth = 12; SET nextyear = data.year; SET nextmonth = 2; ELSIF data.month == 12; SET lastyear = data.year; SET lastmonth = 11; SET nextyear = data.year + 1; SET nextmonth = 1; ELSE; SET lastyear = data.year; SET lastmonth = data.month - 1; SET nextyear = data.year; SET nextmonth = data.month + 1; END; #what to put in the links for sorting descending SET link_descs = { 'user' => 0, 'maindomain' => 0, 'totalbytes' => 0, }; IF data.month == data.current_month && data.year == data.current_year; SET current_view = 1; ELSE; SET current_view = 0; END; SET sorter = { 'field' => data.sortreq || 'user', }; IF data.sortreq == 'totalbytes'; #check for numeric sort SET sorter.num = 1; ELSE; #we want case-insensitive sorting SET sorter.case = 0; END; IF data.sort_desc; #check for descending sort SET sorter.desc = 1; ELSE; link_descs.${data.sortreq} = 1; END; -%] [% IF data.db_creation_in_progress %]
[% locale.maketext('This interface is temporarily unavailable while the system rebuilds root’s bandwidth cache database.') %]
[% ELSE %] [% IF data.warnings && data.warnings.size -%]

[% locale.maketext('[numerate,_1,Warning,Warnings]:', data.warnings.size) -%]

[% IF 1 == data.warnings.size -%]

[% data.warnings.0.html() %]

[% ELSE -%]
    [% FOR warning = data.warnings -%]
  1. [% warning.html() -%]
  2. [% END -%]
[% END -%]
[% END -%]
[% WRAPPER '_brick.tmpl' bricktitle='Notes' -%] [% END -%]
Last Month ([% months.$lastmonth _ ' ' _ lastyear %]) [% months.${data.month} _ ' ' _ data.year %] [% IF data.current_month > data.month || data.current_year > data.year -%] Next Month ([% months.$nextmonth _ ' ' _ nextyear %]) [% ELSE -%] Next Month ([% months.$nextmonth _ ' ' _ nextyear %]) [% END -%]
[% SET bw_count=0; FOR acct = data.accts.cpsort( sorter ); IF (acct.limit == 'unlimited'); SET acct.limit = 0; END; SET fractionused = (acct.limit && acct.totalbytes / acct.limit) || 0; SET percent = CPMath.ceil( fractionused * 100 ); SET has_plus_domains = 0; SET bw_numbers = []; SET sorted_bwusage = acct.bwusage.sort('domain'); FOR bw=sorted_bwusage; IF ( ! has_plus_domains && bw.domain != acct.maindomain ); SET has_plus_domains = 1; SET pie_colors = CPGraph.get_graph_colors_css(acct.bwusage.size); END; bw_numbers.push(bw.usage); END; SET color = 'green'; SET tclass = ''; IF ( percent >= 85 ); SET tclass = 'tdshadered'; SET color = 'red'; ELSIF ( percent >= 70 ); SET tclass = 'tdshadeyellow'; SET color = 'yellow'; END; IF ( ! tclass ); SET tclass = loop.index % 2 ? 'tdshade1' : 'tdshade2'; END; SET bar_width_pct = fractionused * 100; IF (bar_width_pct > 100); bar_width_pct = 100; END -%] [% SET megs_gigs_xfer = gethumanbw(acct.totalbytes); IF acct.limit == 'N/A'; SET bwlimit = 'N/A'; SET meg = 'N/A'; ELSIF acct.limit == 0; SET bwlimit = 'unlimited Meg'; SET meg = 'unlimited'; ELSE; SET display_limits = gethumanbw( acct.limit ); SET bwlimit = display_limits.2; SET meg = display_limits.0; END; -%] [% ELSE -%] [% END -%] [% END #data.accts -%]
[% locale.maketext('User') %] [% locale.maketext('Domain') %] Xfer
(Best Fit)
Limit
(Best Fit)
[% locale.maketext('Usage') %]
[% acct.user -%] [% IF data.showres == '' && acct.reseller && Whostmgr.hasroot() -%] [% END -%] [% acct.maindomain -%] [% IF acct.deleted; ' (deleted)'; END %] [% IF has_plus_domains -%] [%# IMPORTANT: make space for the graph BEFORE it is rendered, or else IE8 (maybe others) will draw it in a 0x0
with overflow: "hidden". Alternatively, adjust the width/height of the
inside the after rendering. -%] [% END -%]
[% megs_gigs_xfer.2 -%] [% bwlimit %] [% IF ! acct.deleted && Whostmgr.checkacl('limit-bandwidth') -%]
 
[% percent %]% used
[% IF acct.bwlimited -%] [% END # acct.bwlimited -%]

[% WRAPPER '_brick.tmpl' bricktitle='Legend' -%] [% IF Whostmgr.hasroot() -%] [% END -%] [% IF current_view -%]
Show only accounts that belong to this reseller.
Show the list of subdomains, addon domains, and parked domains that belong to the corresponding account.
Adjust the bandwidth limit for the corresponding account.
The system is enforcing a bandwidth limit on the corresponding account. [% ELSE # NOT current_view -%] Accounts are over their bandwidth limits for the displayed month. [% END # current_view -%]
Accounts are under 70% of their bandwidth limits.
Accounts reached 70% of their bandwidth limits.
Accounts reached 85% of their bandwidth limits.
[% END -%]
[% WRAPPER '_brick.tmpl' bricktitle='Total Bandwidth Usage' -%] [% SET megs_gigs_xfer = gethumanbw( data.totalbw ) -%]
[% megs_gigs_xfer.2 %]
[% END -%] [%# endsqtable -%] [% IF data.showres != '' -%] [% WRAPPER '_brick.tmpl' bricktitle='Limited Output' -%] Only accounts belonging to [% data.showres -%] are being shown. If you wish to see all accounts, click here. [% END -%]
[% END -%]
[% END #db_creation_in_progress %] [% END #wrapper -%]