feat: Implement invoice generation and emailing functionality
- Added invoice generation logic using DomPDF. - Integrated invoice data retrieval from the API. - Implemented language determination for invoices based on customer data. - Added options to email invoices to customers and admin. - Included HTML output option for direct viewing in the browser. - Ensured proper redirection and error handling throughout the process.
This commit is contained in:
@@ -161,7 +161,13 @@ async function connectDeviceForSoftware() {
|
||||
|
||||
} catch (error) {
|
||||
await logCommunication(`Connection error: ${error.message}`, 'error');
|
||||
progressBar("0", "Error: " + error.message, "#ff6666");
|
||||
|
||||
// Check for specific "No port selected" error and show user-friendly message
|
||||
if (error.message && error.message.includes('No port selected by the user')) {
|
||||
progressBar("100", "No device selected, please try again", "#ff6666");
|
||||
} else {
|
||||
progressBar("100", "Error: " + error.message, "#ff6666");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1193,14 +1199,50 @@ async function downloadAndInstallSoftware(option, customerData = null) {
|
||||
console.log("Click the 'Install Software' button to test if upload.js can handle the file");
|
||||
alert("DEBUG MODE: Download complete!\n\nBlob size: " + blob.size + " bytes\n\nClick the 'Install Software' button to test upload.js");
|
||||
} else {
|
||||
// PRODUCTION MODE: Show upload button and automatically trigger
|
||||
// PRODUCTION MODE: Hide button and show installation in progress
|
||||
document.getElementById("uploadSection").style.display = "block";
|
||||
const uploadBtn = document.getElementById("uploadSoftware");
|
||||
uploadBtn.style.display = "block";
|
||||
uploadBtn.disabled = false;
|
||||
uploadBtn.style.display = "none";
|
||||
|
||||
// Hide device version information during installation
|
||||
const softwareOptions = document.getElementById("softwareOptions");
|
||||
if (softwareOptions) {
|
||||
softwareOptions.style.display = "none";
|
||||
}
|
||||
|
||||
// Create installation status indicator
|
||||
const installStatus = document.createElement("div");
|
||||
installStatus.id = "installationStatus";
|
||||
installStatus.style.cssText = `
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
||||
border-radius: 8px;
|
||||
margin: 10px 0;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
`;
|
||||
installStatus.innerHTML = `
|
||||
<i class="fa-solid fa-spinner fa-spin" style="font-size: 32px; color: #04AA6D; margin-bottom: 10px;"></i>
|
||||
<p style="margin: 0; font-size: 18px; font-weight: 600; color: #333;">Installing Software...</p>
|
||||
<p style="margin: 5px 0 0 0; color: #666; font-size: 14px;">Please keep your device connected and do not close this page</p>
|
||||
`;
|
||||
|
||||
// Insert status before the hidden upload section
|
||||
document.getElementById("uploadSection").parentNode.insertBefore(installStatus, document.getElementById("uploadSection"));
|
||||
|
||||
progressBar("60", "Ready to install, starting upload...", "#04AA6D");
|
||||
uploadBtn.click();
|
||||
progressBar("60", "Starting automatic installation...", "#04AA6D");
|
||||
|
||||
// Enable the upload button and automatically click it
|
||||
setTimeout(() => {
|
||||
uploadBtn.disabled = false;
|
||||
|
||||
// Start monitoring for completion
|
||||
if (typeof startUploadMonitoring === 'function') {
|
||||
startUploadMonitoring();
|
||||
}
|
||||
|
||||
uploadBtn.click();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user