[FE][Certs] Generate Matpel 3 carnet (complete)
This commit is contained in:
parent
172ec76908
commit
1089da5f0f
@ -11,6 +11,18 @@
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inconsolata&family=Inter:wght@400;700;900&display=swap" rel="stylesheet">
|
||||
|
||||
<style type="text/css">
|
||||
@font-face {
|
||||
font-family: "Amirt";
|
||||
font-weight: bold;
|
||||
src: url(/fonts/Amiri-Bold.ttf) format("truetype");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "'Franklin Gothic Demi Cond'";
|
||||
font-weight: bold;
|
||||
src: url(/fonts/FRADMCN.ttf) format("truetype");
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
BIN
frontend/public/fonts/Amiri-Bold.ttf
Normal file
BIN
frontend/public/fonts/Amiri-Bold.ttf
Normal file
Binary file not shown.
BIN
frontend/public/fonts/FRADMCN.TTF
Normal file
BIN
frontend/public/fonts/FRADMCN.TTF
Normal file
Binary file not shown.
@ -6,6 +6,7 @@ import { formatDate, numberToMonth } from "../../utils/functions";
|
||||
import { Canvg } from "canvg";
|
||||
import { Show } from "solid-js";
|
||||
import { Person } from "../../types/Person";
|
||||
import QR from "qrcode";
|
||||
|
||||
export function RegisterSidebar(props: {
|
||||
register: Register,
|
||||
@ -34,32 +35,45 @@ export function RegisterSidebar(props: {
|
||||
const p = props.person;
|
||||
const r = props.register;
|
||||
|
||||
const [,month] = r.register_display_date.split("-");
|
||||
const [expiryYear, month] = r.register_display_date.split("-");
|
||||
|
||||
const monthStr = numberToMonth(parseInt(month, 10));
|
||||
const expiryMonth = numberToMonth(parseInt(month, 10));
|
||||
|
||||
if (monthStr === null) {
|
||||
if (expiryMonth === null) {
|
||||
alert(`El cert. tiene un mes invalido (${month}), no se puede generar carnet`);
|
||||
return;
|
||||
}
|
||||
|
||||
const svgHtml = genCarnet(
|
||||
`${p.person_names} ${p.person_paternal_surname} ${p.person_maternal_surname}`,
|
||||
p.person_dni.toString(),
|
||||
r.register_code.toString().padStart(4, "0"),
|
||||
monthStr,
|
||||
);
|
||||
// QR code
|
||||
QR.toDataURL(`https://eegsac.com/certificado/${p.person_dni}`, {margin: 1}, (err, base64) => {
|
||||
if (err) {
|
||||
alert("Error creando codigo QR para el carnet.");
|
||||
console.error("Error creating QR code");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
const fullname = `${p.person_names} ${p.person_paternal_surname} ${p.person_maternal_surname}`;
|
||||
const svgHtml = genCarnet({
|
||||
fullname,
|
||||
dni: p.person_dni.toString(),
|
||||
code: r.register_code.toString().padStart(4, "0"),
|
||||
expiryMonth,
|
||||
expiryYear,
|
||||
qrBase64: base64,
|
||||
});
|
||||
const v = Canvg.fromString(ctx, svgHtml);
|
||||
v.start();
|
||||
v.ready().then(() => {
|
||||
canvas.toBlob((blob) => {
|
||||
if (blob !== null) {
|
||||
saveAs(blob, "carnet.png");
|
||||
saveAs(blob, `CARNET MATPEL - ${fullname}.png`);
|
||||
} else {
|
||||
console.log("blob is null... :c");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user