RSS Git Download  Clone
Raw Blame History
[% # PROCESS dumper.tt dump = params %]
<div class="container">
  [%
      USE Utils; # App::TT::Utils between() function
      USE date(format = '%d/%m/%Y');
      SET max_num = settings.max_records_per_page;  # max number of records to show without filter
      SET filter_title = params.category ? 'Filter selected' : 'SELECT FILTER';
  %]
    <div class="row">
	    <div class="container alert alert-info my-3" role="alert">
			  Found <strong>[% records.size %]</strong> record[% 's' IF records.size != 1 %]
			  [% IF params.category; ' in '; params.category.upper; ' category ' %]
        [% ELSIF params.search; ' matching search term "'; params.search; '" ' %]
			  [% ELSIF records.size > max_num AND NOT params.search %]
				  [too many to display, please select a filter below or enter a search term above]
			  [% END %]
	    </div><!-- // .alert -->
	    <div class="input-group" id="filter-menu">
			  <span class="input-group-text col-md-2" id="title">[% filter_title %]</span>
        <form>
          [% # TODO: combine this section with search function, don't need separate %]
          <select name="category" id="category_select" class="form-control"
              hx-post="[% uri_for_section.dpw.summary # ${route_name} %]"
              hx-target="#hx-container" hx-trigger="change">
            <option value="">--- select ---</option>
			      [% FOREACH opt in dpw_categories.sort %]
			        <option value="[% opt %]" [% 'selected' IF params.category.match(opt) %]>
					    [% opt.ucfirst %]</option>
			      [% END %]
          </select>
        </form>
	    </div><!-- // #filter-menu -->

		  [% # display records IF size between 1 & $max_size OR is a search result
         # OR a category aleady been selected
		    IF records.size AND
			    ( params.category OR params.search OR Utils.is_between(records.size, 1, max_num) ) 
      %]
        <table class="table table-bordered table-striped table-condensed">
          <tr>
            <th>Date</th>
            <th>Category</th>
            <th>Detail</th>
            <th>Retained</th>
       		  <th>Uploaded</th>
          </tr>
        [% FOREACH entry IN records %]
          <tr>
            <td>[% date.format(entry.date _ " 00:00:00") # add time to satisfy requirement %]
            </td>
            <td>[% entry.category.ucfirst %]</td>
            <td>
              <a href='#' hx-get="[% uri_for_section.dpw.document %]/[% entry.id %]"
						    hx-target="#hx-container">[% entry.description %]</a> [[%-
         			  IF entry.comment.match('^http') %]<a href="[% entry.comment %]"
							  target="_blank">[% entry.comment %]</a>[%- ELSE %][% entry.comment %][% END %]]
					    [% IF entry.filename %]
                <a href="[% uri_for_section.dpw.download %]/[% entry.category %]/[% entry.filename %]"
                  target="_blank"><i class="bi bi-file-pdf"></i>
                </a>	
	        	  [% END %]
            </td>
            <td>[% entry.retained.upper %]</td>
				    <td>[% date.format(entry.time) %]</td>
          </tr>
          [% END # entry IN records %]
        </table>
		  [% END # record.size between 1 and 100 %]
    </div><!-- // .row -->
</div><!-- // .container -->