[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% PROCESS "global/field-descs.none.tmpl" %]

<!doctype html>
<html>

<head>
  <title>[[% terms.Bugzilla %]] Overdue Requests Report</title>
</head>

<body bgcolor="#ffffff">

<p>
  The following is a list of people who you are watching that are involved in
  overdue requests.
</p>

[% FOREACH login = requests.keys.sort %]
  [%
    target    = requests.item(login).target;
    requestee = requests.item(login).requestee;
    setter    = requests.item(login).setter;
    summary   = requests.item(login).summary;
    bug_ids   = requests.item(login).bug_ids;
  %]
  <h3>
    [% target.realname || target.login FILTER html %]
  </h3>
  <ul>
    [% IF requestee.size %]
      <li>
        Requested of: [% summary.requestee FILTER html %]
        (<a href="[% urlbase FILTER none %]buglist.cgi?bug_id=[% bug_ids.requestee.join(",") FILTER uri %]">buglist</a>)
      </li>
    [% END %]
    [% IF setter.size %]
      <li>
        Waiting on: [% summary.setter FILTER html %]
        (<a href="[% urlbase FILTER none %]buglist.cgi?bug_id=[% bug_ids.setter.join(",") FILTER uri %]">buglist</a>)
      </li>
    [% END %]
    </li>
  </ul>
[% END %]

[% FOREACH login = requests.keys.sort %]
  [%
    target    = requests.item(login).target;
    requestee = requests.item(login).requestee;
    setter    = requests.item(login).setter;
    summary   = requests.item(login).summary;
    types     = requests.item(login).types;
  %]

  <hr>

  <h3>
    [% target.realname || target.login FILTER html %]<br>
  </h3>

  [% PROCESS requests report="requestee" request_list=requestee %]
  [% PROCESS requests report="setter" request_list=setter %]

[% END %]

<div>
  <hr style="border: 1px dashed #969696">
  <a href="[% urlbase FILTER none %]userprefs.cgi?tab=request_nagging">
    Change who you are watching
  </a>
</div>

<div style="font-size: 90%; color: #666666">
  <hr style="border: 1px dashed #969696">
  <b>You are receiving this mail because:</b>
  <ul>
    <li>you are watching someone with overdue requests.</li>
  </ul>
</div>
@@body-headers@@
</body>
</html>

[% BLOCK requests %]
  [% RETURN UNLESS request_list.size %]
  [% FOREACH type IN types.item(report) %]

    <h3>
      [% type FILTER upper FILTER html %]
      [%= report == "requestee" ? "requested of" : "waiting on" FILTER none %]
    </h3>

    <ul>
      [% FOREACH request IN request_list.item(type) %]
        <li>
          <a href="[% urlbase FILTER none %]show_bug.cgi?id=[% request.bug.id FILTER none %]"
            title="[% request.bug.tooltip  FILTER html %]">
            [% request.bug.id FILTER none %] - [% request.bug.short_desc FILTER html %]
          </a><br>

          <b>[% request.flag.age FILTER html %]</b>
          [% IF report == "requestee" %]
            from [% request.setter.realname || request.setter.login FILTER html %]
          [% ELSE %]
            to [% request.requestee.realname || request.requestee.login FILTER html %]
          [% END %]

          [% IF request.flag.deferred %]
            <br>
            Deferred until [%+ request.flag.deferred.ymd FILTER html %]<br>
          [% END %]
        </li>
      [% END %]
    </ul>

  [% END %]

[% END %]
