Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleComplete code
Code Block
#set($numItems = $items.size())
#set($range = $numItems - 1)
#foreach ($i in [0..$range])
  #set($subRange = $range - $i - 1)
  #if ($subRange >= 0)
    #foreach ($j in [0..$subRange])
      #if ($items.get($j).specimen.ppid.compareTo($items.get($j + 1).specimen.ppid) > 0)
        #set ($temp = $items[$j])
        #set ($items[$j] = $items[$j + 1])
        #set ($items[$j + 1] = $temp)
      #end
    #end
  #end
#end

<html>
  <head>
    <style>
      @page {
        size: A4 portrait;
        margin: 20mm 15mm;

        @top-left {
          content: element(top-left);
          padding: 1mm;
          border: 1px solid white;
          background: transparent;
        }

        @top-right {
          content: element(top-right);
          text-align: right;
        }

        @bottom-right {
          content: counter(page) " of " counter(pages);
        }
      }

      .order-info:after {
        clear: both;
        content: ' ';
        display: block;
      }

      .order-info table {
        border-collapse: collapse;
        border-spacing: 0;
        margin-bottom: 20px;
        width: 60%;
        float: left;
      }

      .order-info table td.label {
        font-weight: bold;
      }

      .order-info .barcode {
        float: right;
        width: 40%;
      }

      .order-info .barcode img {
        display: block;
        width: 100%;
      }

      table.specimens {
        -fs-table-paginate: paginate;
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        margin-bottom: 20px;
      }

      table.specimens tr {
        page-break-inside: avoid;
      }

      table.specimens td {
        padding: 15px;
        border: 1px solid black;
        word-wrap: break-word;
      }

      table.specimens th {
        padding: 15px;
        background: #eee;
        border: 1px solid black;
        text-align: center;
        font-weight: 400;
        font-size: 16px;
      }

      .title, .sub-title {
        text-align: center;
        width: 100%;
      }

      #top-left {
        position: running(top-left);
      }

      #top-right {
        position: running(top-right);
        text-align: right;
        display: block;
      }
    </style>

    <title>Order manifest</title>
  </head>

  <body>
    <span id="top-left">
      <img src="$appUrl/images/os_email_logo.png"></img>
    </span>

    <span id="top-right"><![CDATA[$dp.shortTitle]]></span>

    <h3 class="title"><![CDATA[$dp.shortTitle]]></h3>
    <h4 class="sub-title">Order Manifest</h4>
    <hr></hr>

    <div class="order-info">
          
      <table>
        <tbody>
          <tr>
            <td class="label">Order ID</td>
            <td>: $order.id</td>
          </tr>
          <tr>
            <td class="label">Requester</td>
            <td>:
              <span><![CDATA[$order.requester.firstName]]></span>
              <span><![CDATA[$order.requester.lastName]]></span>
            </td>
          </tr>
          #if ($order.status == 'EXECUTED')
            <tr>
              <td class="label">Distributor</td>
              <td>:
                <span><![CDATA[$order.distributor.firstName]]></span>
                <span><![CDATA[$order.distributor.lastName]]></span>
              </td>
            </tr>
          #end
          #if ($order.siteName)
            <tr>
              <td class="label">Receiving Site</td>
              <td>: <![CDATA[$order.siteName ($order.instituteName)]]> </td>
            </tr>
          #end
          <tr>
            <td class="label">Status</td>
            <td>:
              #if ($order.status == 'EXECUTED')
                <span>Executed</span>
              #else
                <span>Draft</span>
              #end
            </td>
          </tr>
          #if ($order.status == 'EXECUTED')
            <tr>
              <td class="label">Distribution Date</td>
              <td>: $dateFmt.format($order.executionDate) </td>
            </tr>
          #end
          #if ($order.trackingUrl)
            <tr>
              <td class="label">Tracking URL</td>
              <td>: <![CDATA[$order.trackingUrl]]> </td>
            </tr>
          #end
        </tbody>
      </table>
      <div class="barcode">
        #if ($order.name)
          <img src="data:image/png;base64, $barcodeGenerator.base64Png('CODE_128', $order.name, 0, 40)"></img>
        #end
      </div>
    </div>

    <hr></hr>

    <h3> Specimens </h3>

    <table class="specimens">
      <thead>
        <tr>
          <th>Label</th>
          <th>Lineage</th>
          <th>Type</th>
          <th>Collection Protocol</th>
          <th>PPID</th>
          <th>Visit Name</th>
          <th>Tracking URL</th>
          <th>Status</th>
        </tr>
      </thead>

      <tbody>
        #foreach ($item in $items)
          <tr>
            <td>
              <span><![CDATA[$item.specimen.label]]></span>
            </td>
            <td>
              <span><![CDATA[$item.specimen.lineage]]></span>
            </td>
            <td>
              <span><![CDATA[$item.specimen.type]]></span>
            </td>
            <td>
              <span><![CDATA[$item.specimen.cpShortTitle]]></span>
            </td>
            <td>
              <span><![CDATA[$item.specimen.ppid]]></span>
            </td>
            <td>
              <span><![CDATA[$item.specimen.visitName]]></span>
            </td>
            <td>
              <span><![CDATA[$order.trackingUrl]]></span>
            </td>
            <td>
              #if ($item.status == 'DISTRIBUTED')
                <span>Distributed</span>
              #elseif ($item.status == 'DISTRIBUTED_AND_CLOSED')
                <span>Distributed &amp; Closed</span>
              #elseif ($item.status == 'RETURNED')
                <span>Returned</span>
              #end
            </td>
          </tr>
        #end
      </tbody>
    </table>
  </body>
</html>

HTML Templete

View file
namesortingSpecimenTablebyPPID.html

Order Manifest PDF

View file
namesortingSpecimenTablebyPPID.pdf