Skip to content

Commit

Permalink
added missing signatures, file name and download button
Browse files Browse the repository at this point in the history
  • Loading branch information
Leone25 committed May 5, 2024
1 parent 96dd9ca commit fefe578
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions templates/sugo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
data() {
return {
users: <?= json_encode($users) ?>,
selectedUser: <?= $selectedUser ? "'" . json_encode($selectedUser, JSON_UNESCAPED_UNICODE) . "'" : 'null' ?>,
selectedUserData: null,
selectedUser: <?= $selectedUser ? json_encode($selectedUser, JSON_UNESCAPED_UNICODE) : 'null' ?>,
document: null,
finalDocument: null,
loading: false,
Expand Down Expand Up @@ -135,7 +134,19 @@
// add the signature
let signatureBuffer = Uint8Array.from(atob(signatureData.split(',')[1]), c => c.charCodeAt(0));
let signatureImage = await pdf.embedPng(signatureBuffer);
thirdPage.drawImage(signatureImage, {
thirdPage.drawImage(signatureImage, { // guanti
x: 355,
y: 592,
width: 80,
height: 40,
});
thirdPage.drawImage(signatureImage, { // cappa
x: 260,
y: 460,
width: 80,
height: 40,
});
thirdPage.drawImage(signatureImage, { // end of document
x: 360,
y: 110,
width: 180,
Expand All @@ -147,7 +158,7 @@
this.download(); // temp
this.loading = false;
},
send() {
send() { // currently unused as we don't have an email endpoint
if (!this.toEmail || this.loading) {
return;
}
Expand All @@ -168,15 +179,22 @@
}
});
},
async downloadBlank() {
await this.sign();
this.loading = true;
this.finalDocument = this.document;
this.download();
this.loading = false;
},
download() {
let pdfBlob = new Blob([this.finalDocument], {type: 'application/pdf'});
let pdfUrl = URL.createObjectURL(pdfBlob);
let a = document.createElement('a');
a.href = pdfUrl;
a.download = 'sir.pdf';
a.download = `sir-${this.selectedUser}.pdf`;
a.click();
URL.revokeObjectURL(pdfUrl);
if (this.users.length === 0) {
if (this.users.length === 1) {
// just redirect to the home page
window.location.href = '/';
}
Expand All @@ -202,7 +220,8 @@
<option v-for="user in isLocked" :value="user.uid"><b>{{ user.cn }}</b> ({{ user.uid }})</option>
</optgroup>
</select>
<button @click="sign" class="btn btn-primary ml-2">View and Sign</button>
<button @click="sign" class="btn btn-primary ml-2">Sign</button>
<button @click="downloadBlank" class="btn btn-outline-secondary ml-2">View</button>
</div>
</form>
</template>
Expand Down

0 comments on commit fefe578

Please sign in to comment.