parent
1d12de7045
commit
e0add846bb
@ -98,6 +98,18 @@ export class PdfCreator {
|
|||||||
return config.sponor_logos[index];
|
return config.sponor_logos[index];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
await Handlebars.registerHelper('--format_kilometers',
|
||||||
|
function (str) {
|
||||||
|
let meters = parseInt(str);
|
||||||
|
return ((meters / 1000).toFixed(3).toString())
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await Handlebars.registerHelper('--format_currency',
|
||||||
|
function (str) {
|
||||||
|
let meters = parseInt(str);
|
||||||
|
return ((meters / 100).toFixed(2).toString())
|
||||||
|
}
|
||||||
|
);
|
||||||
this.browser = await puppeteer.launch({ headless: true, args: minimal_args });
|
this.browser = await puppeteer.launch({ headless: true, args: minimal_args });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +191,7 @@ export class PdfCreator {
|
|||||||
await i18next.changeLanguage(locale);
|
await i18next.changeLanguage(locale);
|
||||||
const template_source = fs.readFileSync(`${this.templateDir}/runner_certificate.html`, 'utf8');
|
const template_source = fs.readFileSync(`${this.templateDir}/runner_certificate.html`, 'utf8');
|
||||||
const template = Handlebars.compile(template_source);
|
const template = Handlebars.compile(template_source);
|
||||||
let result = template({ runners, eventname: config.eventname });
|
let result = template({ runners, eventname: config.eventname, currency_symbol: config.currency_symbol });
|
||||||
result = await awaitAsyncHandlebarHelpers(result);
|
result = await awaitAsyncHandlebarHelpers(result);
|
||||||
const pdf = await this.renderPdf(result, { format: "A4", landscape: false, printBackground: true });
|
const pdf = await this.renderPdf(result, { format: "A4", landscape: false, printBackground: true });
|
||||||
return pdf;
|
return pdf;
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
{{this.middlename}} {{this.lastname}}
|
{{this.middlename}} {{this.lastname}}
|
||||||
</p>
|
</p>
|
||||||
<p style="font-size: 1cm; margin-bottom: 0;">{{__ "hat-beim-eventname"}}</p>
|
<p style="font-size: 1cm; margin-bottom: 0;">{{__ "hat-beim-eventname"}}</p>
|
||||||
<p style="font-size: 2cm; font-weight: bold; margin-bottom: 0;">{{this.distance}}km</p>
|
<p style="font-size: 2cm; font-weight: bold; margin-bottom: 0;">{{--format_kilometers this.distance}}km</p>
|
||||||
<p style="font-size: 1cm;">{{__ "fuer-den-guten-zweck-zurueckgelegt"}}</p>
|
<p style="font-size: 1cm;">{{__ "fuer-den-guten-zweck-zurueckgelegt"}}</p>
|
||||||
</main>
|
</main>
|
||||||
<footer class="certificate-footer">
|
<footer class="certificate-footer">
|
||||||
@ -72,15 +72,15 @@
|
|||||||
{{#each this.distanceDonations}}
|
{{#each this.distanceDonations}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{this.donor.firstname}} {{this.donor.middlename}} {{this.donor.lastname}}</td>
|
<td>{{this.donor.firstname}} {{this.donor.middlename}} {{this.donor.lastname}}</td>
|
||||||
<td>{{this.amountPerDistance}}</td>
|
<td>{{--format_currency this.amountPerDistance}} {{../../currency_symbol}}</td>
|
||||||
<td>{{this.amount}}</td>
|
<td>{{--format_currency this.amount}} {{../../currency_symbol}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<td>{{__ "gesamt"}}</td>
|
<td>{{__ "gesamt"}}</td>
|
||||||
<td>0.5€</td>
|
<td>0.5 {{../currency_symbol}}</td>
|
||||||
<td>1€</td>
|
<td>1 {{../currency_symbol}}</td>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</main>
|
</main>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user