This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
generated from Arquisoft/dede_0
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from Arquisoft/productCategories
Product categories
- Loading branch information
Showing
19 changed files
with
302 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { orderModel } from "../orders/Order"; | ||
import { userModel } from "../users/User"; | ||
import { sendInvoiceEmail } from "./emailSender"; | ||
|
||
const fs = require("fs"); | ||
const PDFGenerator = require("pdfkit"); | ||
|
@@ -11,7 +11,7 @@ export const createPDF = async (code: string) => { | |
const orderFound = await orderModel.findOne({ | ||
orderCode: code, | ||
}); | ||
const user = await userModel.findOne({ email: orderFound.userEmail }); | ||
/*const user = await userModel.findOne({ email: orderFound.userEmail }); | ||
const invoiceData = { | ||
addresses: { | ||
shipping: { | ||
|
@@ -29,27 +29,17 @@ export const createPDF = async (code: string) => { | |
}; | ||
const ig = new InvoiceGenerator(invoiceData); | ||
ig.generate(); | ||
|
||
/*var html = fs.readFileSync(process.cwd() + "/utils/template.html", "utf-8"); | ||
ig.generate();*/ | ||
var html = fs.readFileSync(process.cwd() + "/utils/template.html", "utf-8"); | ||
const parse = require("node-html-parser").parse; | ||
|
||
const options: CreateOptions = { | ||
format: "A4", | ||
orientation: "portrait", | ||
}; | ||
const orderFound = await orderModel.findOne({ | ||
orderCode: code, | ||
}); | ||
const root = parse(html); | ||
const body = root.querySelector("body"); | ||
let aux = | ||
'<header class="clearfix">' + | ||
'<div id="company">' + | ||
'<h2 class="name">DeDe</h2>' + | ||
'<div><a href="mailto:[email protected]">[email protected]</a></div>' + | ||
'<div><a href="mailto:[email protected]">[email protected]</a></div><br><br>' + | ||
"</div> </div>" + | ||
"</header>" + | ||
"<main>" + | ||
|
@@ -146,12 +136,5 @@ export const createPDF = async (code: string) => { | |
|
||
body.insertAdjacentHTML("beforeend", aux); | ||
|
||
.create(root.toString(), options) | ||
.toFile("./pdf/" + orderFound.orderCode + ".pdf", function (err, res) { | ||
if (err) console.log(err); | ||
else { | ||
sendInvoiceEmail(orderFound.userEmail, orderFound.orderCode); | ||
} | ||
});*/ | ||
sendInvoiceEmail(orderFound.userEmail, orderFound.orderCode, root.toString()); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.