<metal:block use-macro="container/standard_template.pt/macros/page">
  <metal:block fill-slot="content">
    <div tal:replace="structure python:context.envelope_tabs(tab='history_section')"/>
    <h1 i18n:translate="">
      History of <span tal:replace="string:${context/title_or_id}" i18n:name="title"/>
    </h1>
    <p i18n:translate="">
        This page displays all the history of tasks that have executed in this envelope.
        If you want to see more details about a task, just expand the <img
          src="/misc_/Reportek/plus_gif" alt="Expand item for more information"
          i18n:name="plus-icon"
          i18n:attributes="alt alt-expand-item"/> icon next to it.
    </p>

    <table cellpadding="2" cellspacing="2">
    <tal:block define="actives python:[]" repeat="item python:context.objectValues('Workitem')">
      <tr tal:define="condition python:request.has_key('w' + item.id) and request['w' + item.id] == '1';
                      activity_name python:item.getActivityAttribute('title')">
        <tal:block condition="condition">
        <td valign="top">
          <a rel="nofollow"
            tal:define="url0 request/URL0;
                        query_string python:context.changeQueryString(
                          request['QUERY_STRING'], 'w' + item.id, '0'
                        )"
            tal:attributes="href string:${url0}?${query_string}">
            <img src="/misc_/Reportek/minus_gif" alt="Collapse item" i18n:attributes="alt alt-collapse-item"/>
          </a>
        </td>
        <td><strong tal:condition="activity_name" tal:content="activity_name"></strong>
            <strong tal:condition="not:activity_name"
                    tal:define="copied_activity_name python:item.activity_id"
                    tal:content="string:${copied_activity_name} (activity renamed or missing)"
                    style="color:red;">replace activity name</strong>
            (<span tal:define="date python:item.lastActivityDate().strftime('%Y/%m/%d')"
                   tal:replace="string:${item/status} ${date}"></span>
           <span 
             tal:condition="python:item.actor not in ['', 'Anonymous User', 'openflow_engine']"
             tal:content="string: by ${item/actor}"></span>)
          <div tal:replace="structure item/workitemDetails"/>
        </td>
        </tal:block>

        <tal:block condition="not:condition">
          <td valign="top">
            <a rel="nofollow"
              tal:define="url0 request/URL0;
                          query_string python:context.changeQueryString(
                            request['QUERY_STRING'], 'w' + item.id, '1'
                          )"
              tal:attributes="href string:${url0}?${query_string}">
              <img src="/misc_/Reportek/plus_gif"
              alt="Expand item for more information" border="0" i18n:attributes="alt alt-expand-item"/>
            </a>
          </td>
          <td><strong tal:condition="activity_name" tal:content="activity_name"></strong>
            <strong tal:condition="not:activity_name"
                    tal:define="copied_activity_name python:item.activity_id"
                    tal:content="string:${copied_activity_name} (activity renamed or missing)"
                    style="color:red;"> replace with activity name</strong>
            (<span tal:define="date python:item.lastActivityDate().strftime('%Y/%m/%d')"
                   tal:replace="string:${item/status} ${date}"></span>
             <span 
               tal:condition="python:item.actor not in ['', 'Anonymous User', 'openflow_engine']"
               tal:content="string: by ${item/actor}"></span>)
          </td>
        </tal:block>

      </tr>
    </tal:block>
    </table>
  </metal:block>
</metal:block>
