|
@@ -24,16 +24,24 @@ class DocumentPage {
|
|
|
|
|
|
|
|
$table.find(".btn-delete-document-item").on("click", event => {
|
|
$table.find(".btn-delete-document-item").on("click", event => {
|
|
|
const documentItemId = $(event.currentTarget).data("document-item-id");
|
|
const documentItemId = $(event.currentTarget).data("document-item-id");
|
|
|
- const confirmed = confirm("Are you sure you want to delete this item?");
|
|
|
|
|
- if(confirmed) {
|
|
|
|
|
- $.post(window.location + "/delete-item", {
|
|
|
|
|
- document_item_id: documentItemId
|
|
|
|
|
- }).then(response => {
|
|
|
|
|
- toastr.success("Item deleted successfully.");
|
|
|
|
|
- $("#document-items-section").html(response.html);
|
|
|
|
|
- DocumentPage.InitItemsSection();
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ swal.fire({
|
|
|
|
|
+ icon: "question",
|
|
|
|
|
+ title: "Deleting Item",
|
|
|
|
|
+ text: "Are you sure you want to delete this item?",
|
|
|
|
|
+ confirmButtonText: "Delete",
|
|
|
|
|
+ showCancelButton: true
|
|
|
|
|
+ }).then(result => {
|
|
|
|
|
+ if(result.isConfirmed) {
|
|
|
|
|
+ $.post(window.location + "/delete-item", {
|
|
|
|
|
+ document_item_id: documentItemId
|
|
|
|
|
+ }).then(response => {
|
|
|
|
|
+ toastr.success("Item deleted successfully.");
|
|
|
|
|
+ $("#document-items-section").html(response.html);
|
|
|
|
|
+ DocumentPage.InitItemsSection();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -54,15 +62,43 @@ class DocumentPage {
|
|
|
const { variant } = $element.data();
|
|
const { variant } = $element.data();
|
|
|
|
|
|
|
|
DocumentPage.SaveForm().then(() => {
|
|
DocumentPage.SaveForm().then(() => {
|
|
|
- toastr.info("Emailing PDF...");
|
|
|
|
|
- $.post(window.location + "/email-pdf", {
|
|
|
|
|
- variant: variant
|
|
|
|
|
- }).then(() => {
|
|
|
|
|
- toastr.success("Email sent successfully.");
|
|
|
|
|
- }).catch(error => {
|
|
|
|
|
- const { responseJSON } = error;
|
|
|
|
|
- if(responseJSON && responseJSON.message) {
|
|
|
|
|
- toastr.error(responseJSON.message);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const showErrorAlert = (error) => {
|
|
|
|
|
+ swal.fire("Error", error, "error");
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const contactName = $("#contact-name").val();
|
|
|
|
|
+ if(!contactName) {
|
|
|
|
|
+ showErrorAlert("Contact Name must be set.")
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const contactEmail = $("#contact-email").val();
|
|
|
|
|
+ if(!contactEmail) {
|
|
|
|
|
+ showErrorAlert("Contact Email must be set.")
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const $p1 = $("<p>").text("Are you sure you want to email the PDF to:");
|
|
|
|
|
+ const $p2 = $("<div>").text(`${contactName} <${contactEmail}>`);
|
|
|
|
|
+
|
|
|
|
|
+ swal.fire({
|
|
|
|
|
+ icon: "question",
|
|
|
|
|
+ title: "Emailing PDF",
|
|
|
|
|
+ html: $p1.get(0).outerHTML + $p2.get(0).outerHTML,
|
|
|
|
|
+ confirmButtonText: "Send Email",
|
|
|
|
|
+ showCancelButton: true,
|
|
|
|
|
+ preConfirm: () => {
|
|
|
|
|
+ return $.post(window.location + "/email-pdf", {
|
|
|
|
|
+ variant: variant
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ toastr.success("Email sent successfully.");
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ const { responseJSON } = error;
|
|
|
|
|
+ if(responseJSON && responseJSON.message) {
|
|
|
|
|
+ toastr.error(responseJSON.message);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|