-
+
diff --git a/config.php b/config.php
index c21ff8a9..2e45e883 100644
--- a/config.php
+++ b/config.php
@@ -1,11 +1,15 @@
'Alabama',
'AK'=>'Alaska',
diff --git a/email_invoice.php b/email_invoice.php
new file mode 100644
index 00000000..495cbd3a
--- /dev/null
+++ b/email_invoice.php
@@ -0,0 +1,96 @@
+
+
+2){
+ $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
+ }
+ $client_website = $row['client_website'];
+
+?>
+
+SMTPDebug = 2; // Enable verbose debug output
+ $mail->isSMTP(); // Set mailer to use SMTP
+ $mail->Host = $config_smtp_host; // Specify main and backup SMTP servers
+ $mail->SMTPAuth = true; // Enable SMTP authentication
+ $mail->Username = $config_smtp_username; // SMTP username
+ $mail->Password = $config_smtp_password; // SMTP password
+ $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
+ $mail->Port = $config_smtp_port; // TCP port to connect to
+
+
+ //Recipients
+ $mail->setFrom($config_mail_from_email, $config_mail_from_name);
+ $mail->addAddress("$client_email", "$client_name"); // Add a recipient
+
+ // Attachments
+ //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
+ //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
+
+ // Content
+ $mail->isHTML(true); // Set email format to HTML
+ $mail->Subject = "Invoice $invoice_number - $invoice_date - Due $invoice_due";
+ $mail->Body = "Hello $client_name,
Thank you for choosing $config_company_name! -- attached to this email is your invoice in PDF form due on $invoice_due Please make all checks payable to $config_company_name and mail to $config_company_address $config_company_city $config_company_state $config_company_zip before $invoice_due.
If you have any questions please contact us at the number below.
~ $config_company_name Automated Billing Department $config_company_phone";
+ //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
+
+ $mail->send();
+ echo 'Message has been sent';
+
+ mysqli_query($mysqli,"INSERT INTO invoice_history SET invoice_history_date = CURDATE(), invoice_history_status = 'Sent', invoice_history_description = 'Emailed Invoice!', invoice_id = $invoice_id");
+
+ mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Sent', client_id = $client_id");
+
+ $_SESSION['alert_message'] = "Invoice has been sent";
+
+ header("Location: invoice.php?invoice_id=$invoice_id");
+
+
+} catch (Exception $e) {
+ echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
+}
+
+?>
\ No newline at end of file
diff --git a/invoice.php b/invoice.php
index ab29f554..515544f9 100644
--- a/invoice.php
+++ b/invoice.php
@@ -42,12 +42,35 @@ if(isset($_GET['invoice_id'])){
$sql2 = mysqli_query($mysqli,"SELECT * FROM invoice_history WHERE invoice_id = $invoice_id ORDER BY invoice_history_id DESC");
$sql3 = mysqli_query($mysqli,"SELECT * FROM invoice_payments, accounts WHERE invoice_payments.account_id = accounts.account_id AND invoice_payments.invoice_id = $invoice_id ORDER BY invoice_payments.invoice_payment_id DESC");
+ //check to see if overdue
+
+ $unixtime_invoice_due = strtotime($invoice_due);
+ if($unixtime_invoice_due < time()){
+ $invoice_status = "Overdue";
+ $invoice_color = "text-danger";
+ }
+
+ //Set Badge color based off of invoice status
+ if($invoice_status == "Sent"){
+ $invoice_badge_color = "warning";
+ }elseif($invoice_status == "Partial"){
+ $invoice_badge_color = "primary";
+ }elseif($invoice_status == "Paid"){
+ $invoice_badge_color = "success";
+ }elseif($invoice_status == "Overdue"){
+ $invoice_badge_color = "danger";
+ }else{
+ $invoice_badge_color = "secondary";
+ }
+
+
+
?>