diff --git a/automation/composer.json b/automation/composer.json index 7ba4450..b766db8 100644 --- a/automation/composer.json +++ b/automation/composer.json @@ -11,6 +11,7 @@ "predis/predis": "^2.2", "guzzlehttp/guzzle": "^7.9", "league/flysystem-ftp": "^3.29", - "phpmailer/phpmailer": "^6.9" + "phpmailer/phpmailer": "^6.9", + "league/plates": "^3.6" } } diff --git a/automation/send-invoice.php b/automation/send-invoice.php index 842cbc8..708b1a2 100644 --- a/automation/send-invoice.php +++ b/automation/send-invoice.php @@ -1,5 +1,7 @@ error('DB Connection failed: ' . $e->getMessage()); } +$stmt = $pdo->prepare("SELECT value FROM settings WHERE name = :name"); +$stmt->execute(['name' => 'email']); +$row = $stmt->fetch(); +if ($row) { + $supportEmail = $row['value']; +} else { + $supportEmail = 'default-support@example.com'; +} + +$stmt = $pdo->prepare("SELECT value FROM settings WHERE name = :name"); +$stmt->execute(['name' => 'phone']); +$row = $stmt->fetch(); +if ($row) { + $supportPhoneNumber = $row['value']; +} else { + $supportPhoneNumber = '+1.23456789'; +} + +$stmt = $pdo->prepare("SELECT value FROM settings WHERE name = :name"); +$stmt->execute(['name' => 'company_name']); +$row = $stmt->fetch(); +if ($row) { + $registryName = $row['value']; +} else { + $registryName = 'Example Registry LLC'; +} + $previous = date("Y-m", strtotime("first day of previous month")); try { @@ -96,11 +125,12 @@ try { "- Due Date: " . $dueDate . "\n" . "- Total Amount: " . $totalAmount . "\n\n" . "The invoice is available in your account for review and payment. Please ensure that the payment is made by the due date to avoid any late fees or service interruptions.\n\n" . - "Should you have any questions or require further assistance, please do not hesitate to contact us at [Your Contact Information].\n\n" . + "Should you have any questions or require further assistance, please do not hesitate to contact us at {$supportEmail}.\n\n" . "Thank you for your prompt attention to this matter.\n\n" . "Warm regards,\n\n" . - "[Your Company Name]\n" . - "[Your Contact Details]"; + "{$registryName}\n" . + "{$supportEmail}\n" . + "{$supportPhoneNumber}"; // Prepare the data array for the cURL request $data = [