[% USE date %]

[%# RENDERING PDF #%]
[% IF block == 'render' %]
[%
  init_pdf(pdf);

  # PAGE 1
  pdf.prForm(path_to_template('pdf/eventlog.pdf'), 1);
  pdf.prFont('Helvetica-Bold');
  font(20, 'light blue');
  pdf.prText(40,400,'Event Report');
  font(15, 'dark grey');
  pdf.prText(40,350, "Report Timeperiod: " _ format_date(start, "%d.%m.%Y") _ ' - ' _ format_date((end - 1), "%d.%m.%Y"));
  pdf.prText(480, 440, format_date(date.now, "%d.%m.%Y"));

  # PAGE 2
  # legend
  pdf.prPage();
  pdf.prFont('Calibri');
  pdf.prForm(path_to_template('pdf/eventlog.pdf'), 3);
  font(20, 'dark grey');
  pdf.prText(40,680, 'Legend');
  print_event_totals(235, 612, 22.5);
  page = 2;
  page_footer(550, 58, page); page = page + 1;

  # PAGE 3
  # events
  pdf.prPage();
  pdf.prForm(path_to_template('pdf/eventlog.pdf'), 2);
  font(20, 'dark grey');
  pdf.prText(40,680, 'Events');
  page_footer(550, 58, page); page = page + 1;


  font(10, 'dark grey');
  IF logs.size == 0;
    pdf.prText(50,640, "no events during this timeperiod.");
  ELSE;
    x = 30;
    y = 640;
    FOREACH l = logs;
      IF y < 90;
        y = 640;
        pdf.prPage();
        pdf.prForm(path_to_template('pdf/eventlog.pdf'), 2);
        page_footer(550, 58, page); page = page + 1;
        font(20, 'dark grey');
        pdf.prText(40,680, 'Events');
        font(10, 'dark grey');
      END;
      PROCESS _logs_line.tt;

      log_icon(x, y - 6, pic, path_to_template('pdf/icons.pdf'));
      pdf.prText(x + 25,y, "[ " _ format_date(l.time, datetime_format) _ "] " _ l.type);
      y = y - 15;
      pdf.prText(x,y, l.options.substr(,0, 100));
      y = y - 20;
    END;
  END;

%]
[% END %]
