[% META title = 'Resources &raquo; Stats &amp; Audit &raquo; Trend Analysis' %]
	[% addcss =	[ 'bootstrap.css' ] %]
<!-- BEGIN [% template.name %] -->
    [% # INCLUDE dumper.tt dump = cfg %]
		<script src="/js/vendor/bootstrap.min.js"></script>

    [% IF cfg;
        FOREACH section IN cfg;   # INCLUDE dumper.tt dump = section;
            name = section.key;   # INCLUDE dumper.tt dump = title;
            data = section.value; # INCLUDE dumper.tt dump = data;
    %]
        <h4>Lab-test trend analysis for [% name %] section (past 24 months):</h4>
        <dl class="indent">
        [% FOREACH t IN data; # INCLUDE dumper.tt dump = t;
            test_diag = t.key;
            heading   = t.value.title;
            div_id    = t.key.replace('_','-'); # replace underscores (cosmetic)
        %]
            <dt data-toggle="collapse" data-target="#collapse-[% div_id %]">
                [% heading %] <i class="icon-fullscreen"></i>
            </dt>
            [% USE img_url =
                url(app_url _ "/chart/trend_analysis/${name}/${test_diag}") %]
            <dd id="collapse-[% div_id %]" class="collapse" style="margin-top: 10px">
                <img src="[% img_url %]" />
            </dd>
        [% END %]
        </dl>
    [% END; ELSE %]
        <p class="info">Trend analysis not configured</p>
    [% END %]
<!-- END [% template.name %] -->

[% BLOCK accordionGroup # accordion-group version of above %]
        <div class="accordion indent" id="[% name %]">
          [% FOREACH t IN data; # INCLUDE dumper.tt dump = t;
            test_diag = t.key;
            heading   = t.value.title;
            target_id = t.key.replace('_', '-');
          %]
            <div class="accordion-group">
              <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse"
                   data-parent="#[% name %]" href="#collapse-[% target_id %]">
                    [% heading %]
                </a>
              </div>
              <div id="collapse-[% target_id %]" class="accordion-body collapse">
                <div class="accordion-inner">
                   [% USE img_url = url(app_url _
											"/chart/trend_analysis/${name}/${test_diag}") %]
                   <img src="[% img_url %]" />
                </div>
              </div>
            </div>
          [% END %]
        </div>
[% END %]
