Small improvement in send-invoice automation

This commit is contained in:
Pinga 2025-02-11 13:01:02 +02:00
parent 276cbb1c0d
commit e0eeaed83c
2 changed files with 35 additions and 4 deletions

View file

@ -11,6 +11,7 @@
"predis/predis": "^2.2", "predis/predis": "^2.2",
"guzzlehttp/guzzle": "^7.9", "guzzlehttp/guzzle": "^7.9",
"league/flysystem-ftp": "^3.29", "league/flysystem-ftp": "^3.29",
"phpmailer/phpmailer": "^6.9" "phpmailer/phpmailer": "^6.9",
"league/plates": "^3.6"
} }
} }

View file

@ -1,5 +1,7 @@
<?php <?php
require_once 'vendor/autoload.php';
$c = require_once 'config.php'; $c = require_once 'config.php';
require_once 'helpers.php'; require_once 'helpers.php';
@ -16,6 +18,33 @@ try {
$log->error('DB Connection failed: ' . $e->getMessage()); $log->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")); $previous = date("Y-m", strtotime("first day of previous month"));
try { try {
@ -96,11 +125,12 @@ try {
"- Due Date: " . $dueDate . "\n" . "- Due Date: " . $dueDate . "\n" .
"- Total Amount: " . $totalAmount . "\n\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" . "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" . "Thank you for your prompt attention to this matter.\n\n" .
"Warm regards,\n\n" . "Warm regards,\n\n" .
"[Your Company Name]\n" . "{$registryName}\n" .
"[Your Contact Details]"; "{$supportEmail}\n" .
"{$supportPhoneNumber}";
// Prepare the data array for the cURL request // Prepare the data array for the cURL request
$data = [ $data = [