Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
- <style>
- @page {
- margin: 9cm 1.5cm 3cm 1.5cm;
- size: A4;
- font-size: 9pt;
- font-family: Arial;
- @top-center {
- content: element(header);
- vertical-align: center;
- }
- @bottom-left {
- content: "Page "counter(page) "/"counter(pages);
- width: 3cm;
- font-size: 8pt;
- content: element(footer);
- }
- @bottom-right {
- content: "Printed: {{todayDate}}";
- width: 4cm;
- font-size: 8pt;
- }
- }
- #page_header {
- position: running(header);
- }
- body {}
- table {
- border-collapse: collapse;
- }
- table * {
- font-weight: normal;
- font-size: 9pt;
- vertical-align: top;
- }
- #paper {
- font-size: 9pt;
- }
- #company_header {
- text-align: center;
- margin-bottom: 1em;
- }
- #company_header h1 {
- margin-bottom: 1.4em;
- }
- #document_title {
- text-align: center;
- font-weight: bold;
- font-size: 12pt;
- margin-bottom: 2em;
- }
- #invoice_info {
- margin-bottom: 1em;
- }
- #page_header_invoice_info {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- padding: 1em 0em;
- }
- #page_header_right_column {
- display: flex;
- flex-direction: column;
- }
- #page_header_left_column {
- display: flex;
- flex-direction: column;
- margin-right: 20px;
- }
- table td {
- padding: 3px;
- }
- </style>
- </head>
- <body>
- <div id="page_header">
- <div id="company_header">
- <h1>TANJONG EXPRESS (M) SDN BHD</h1>
- </div>
- <div id="document_title">
- Incentive Voucher
- </div>
- <div id="page_header_invoice_info">
- <div id='page_header_left_column'>
- <div style="display: flex; flex-direction: row;padding: 0.5em 0em;">
- <div style="display: flex;width: 80px;justify-content: space-between;">
- <span>Driver(s)</span>
- <span>:</span>
- </div>
- <span style="margin-left: 10px;margin-right: 10px; text-align: left;">{{driversArray}}</span>
- </div>
- <div style="display: flex; flex-direction: row;padding: 0.5em 0em;">
- <div style="display: flex;width: 80px;justify-content: space-between;">
- <span>Vehicle(s)</span>
- <span>:</span>
- </div>
- <span style="margin-left: 10px;text-align: left;">{{vehiclesArray}}</span>
- </div>
- </div>
- <div id='page_header_right_column'>
- <div style="display: flex; flex-direction: row;padding: 0.5em 0em;">
- <div style="display: flex;width: 80px;justify-content: space-between;">
- <span>Date</span>
- <span>:</span>
- </div>
- <span style="margin-left: 10px;">{{date}}</span>
- </div>
- <div style="display: flex; flex-direction: row;padding: 0.5em 0em;">
- <div style="display: flex;width: 80px;justify-content: space-between;">
- <span>Voucher No</span>
- <span>:</span>
- </div>
- <span style="margin-left: 10px;">{{voucherNo}}</span>
- </div>
- </div>
- </div>
- </div>
- <div id='page_body'>
- <h4 style="text-align: left;">Summary</h4>
- <table style="width:100%;">
- <thead>
- <tr style="text-align:left;border-bottom: 1px solid black;border-top: 1px solid black;">
- <th style="text-align: left;font-weight: bold;width: 100px;">Code</th>
- <th style="text-align: left;font-weight: bold;">Desc</th>
- <th style="text-align: right;font-weight: bold;width: 150px;">Incentive</th>
- <th style="text-align: right;font-weight: bold;width: 150px;">Expenses</th>
- </tr>
- </thead>
- <tbody>
- {{#each summary}}
- <tr>
- <td style="text-align: left;">{{ code }}</td>
- <td style="text-align: left;">{{ name }}</td>
- {{#each categorySum}}
- <td style="text-align: right;">{{ this }}</td>
- {{/each }}
- </tr>
- {{/each }}
- </tbody>
- <tr style="border-top: 1px solid black;border-bottom: 1px solid black;border-top: 1px solid black;">
- <td style="font-weight: bold;text-align: left;">Total:</td>
- <td></td>
- <td style="font-weight: bold;text-align: right;">{{totals.[0]}}</td>
- <td style="font-weight: bold;text-align: right;">{{totals.[1]}}</td>
- </tr>
- </table>
- <h4 style="text-align: left;margin-top: 2em;">Jobs</h4>
- <table style="width:100%;">
- <tr style="text-align:left;border-bottom: 1px solid black;border-top: 1px solid black;">
- <th style="text-align: left;font-weight: bold;width: 100px;">Date</th>
- <th style="text-align: left;font-weight: bold;width: 150px;">Desc</th>
- <th style="text-align: left;font-weight: bold;">Pickup - Drop</th>
- <th style="text-align: right;font-weight: bold;width: 150px;">Incentive</th>
- <th style="text-align: right;font-weight: bold;width: 150px;">Expenses</th>
- </tr>
- {{#each jobs}}
- <tr>
- <td style="text-align: left;">{{ date }}</td>
- <td style="text-align: left;">{{ description }}</td>
- <td style="text-align: left;">{{ pickUpDrop }}</td>
- {{#each categorySum}}
- <td style="text-align: right;">{{ this }}</td>
- {{/each }}
- </tr>
- {{/each }}
- <tr style="border-top: 1px solid black;border-bottom: 1px solid black;border-top: 1px solid black;">
- <td style="font-weight: bold;text-align: left;">Total:</td>
- <td></td>
- <td></td>
- <td style="font-weight: bold;text-align: right;">{{totals.[0]}}</td>
- <td style="font-weight: bold;text-align: right;">{{totals.[1]}}</td>
- </tr>
- </table>
- <h4 style="text-align: left;margin-top: 2em;">Details</h4>
- <table style="width:100%;">
- <tr style="text-align:left;border-bottom: 1px solid rgb(126, 124, 124);border-top: 1px solid black;">
- <th style="text-align: left;font-weight: bold;width: 100px;">Date</th>
- <th style="text-align: left;font-weight: bold;width: 150px;">Code</th>
- <th style="text-align: left;font-weight: bold;">Desc</th>
- <th style="text-align: right;font-weight: bold;width: 150px;">Incentive</th>
- <th style="text-align: right;font-weight: bold;width: 150px;">Expenses</th>
- </tr>
- {{#each incentives}}
- <tr>
- <td style="text-align: left;">{{ date }}</td>
- <td style="text-align: left;">{{ code }}</td>
- <td style="text-align: left;">{{ description }}</td>
- <td style="text-align: right;">{{categorySum.[0]}}</td>
- <td style="text-align: right;">{{categorySum.[1]}}</td>
- </tr>
- {{/each }}
- <tr style="border-top: 1px solid black;border-bottom: 1px solid black;border-top: 1px solid black;">
- <td style="font-weight: bold;text-align: left;">Total:</td>
- <td></td>
- <td></td>
- <td style="font-weight: bold;text-align: right;">{{totals.[0]}}</td>
- <td style="font-weight: bold;text-align: right;">{{totals.[1]}}</td>
- </tr>
- </table>
- </div>
- <script>
- class RepeatingTableHeaders extends Paged.Handler {
- constructor(chunker, polisher, caller) {
- super(chunker, polisher, caller);
- }
- afterPageLayout(pageElement, page, breakToken, chunker) {
- // Find all split table elements
- let tables = pageElement.querySelectorAll("table[data-split-from]");
- tables.forEach((table) => {
- // Get the reference UUID of the node
- let ref = table.dataset.ref;
- // Find the node in the original source
- let sourceTable = chunker.source.querySelector("[data-ref='" + ref + "']");
- // Find if there is a header
- let header = sourceTable.querySelector("thead");
- if (header) {
- // Clone the header element
- let clonedHeader = header.cloneNode(true);
- // Insert the header at the start of the split table
- table.insertBefore(clonedHeader, table.firstChild);
- }
- });
- }
- }
- Paged.registerHandlers(RepeatingTableHeaders);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement