From c01acadba0f725b14b542c9c333daaf54004d06c Mon Sep 17 00:00:00 2001 From: root Date: Sat, 30 Mar 2019 23:28:46 -0400 Subject: [PATCH] Added PHPMailer library, send invoice email now works, badge colors change based off invoice status add client now adds a location, contact and domain. --- add_client_modal.php | 12 +- config.php | 15 +- email_invoice.php | 96 + invoice.php | 29 +- invoices.php | 28 +- post.php | 10 + vendor/PHPMailer-6.0.7/COMMITMENT | 46 + vendor/PHPMailer-6.0.7/LICENSE | 502 ++ vendor/PHPMailer-6.0.7/README.md | 218 + vendor/PHPMailer-6.0.7/SECURITY.md | 28 + vendor/PHPMailer-6.0.7/VERSION | 1 + vendor/PHPMailer-6.0.7/composer.json | 55 + vendor/PHPMailer-6.0.7/get_oauth_token.php | 144 + .../language/phpmailer.lang-am.php | 26 + .../language/phpmailer.lang-ar.php | 27 + .../language/phpmailer.lang-az.php | 26 + .../language/phpmailer.lang-ba.php | 26 + .../language/phpmailer.lang-be.php | 26 + .../language/phpmailer.lang-bg.php | 26 + .../language/phpmailer.lang-ca.php | 26 + .../language/phpmailer.lang-ch.php | 26 + .../language/phpmailer.lang-cs.php | 25 + .../language/phpmailer.lang-da.php | 26 + .../language/phpmailer.lang-de.php | 25 + .../language/phpmailer.lang-el.php | 25 + .../language/phpmailer.lang-eo.php | 25 + .../language/phpmailer.lang-es.php | 26 + .../language/phpmailer.lang-et.php | 27 + .../language/phpmailer.lang-fa.php | 27 + .../language/phpmailer.lang-fi.php | 27 + .../language/phpmailer.lang-fo.php | 26 + .../language/phpmailer.lang-fr.php | 29 + .../language/phpmailer.lang-gl.php | 26 + .../language/phpmailer.lang-he.php | 26 + .../language/phpmailer.lang-hi.php | 26 + .../language/phpmailer.lang-hr.php | 26 + .../language/phpmailer.lang-hu.php | 26 + .../language/phpmailer.lang-id.php | 27 + .../language/phpmailer.lang-it.php | 27 + .../language/phpmailer.lang-ja.php | 27 + .../language/phpmailer.lang-ka.php | 26 + .../language/phpmailer.lang-ko.php | 26 + .../language/phpmailer.lang-lt.php | 26 + .../language/phpmailer.lang-lv.php | 26 + .../language/phpmailer.lang-mg.php | 25 + .../language/phpmailer.lang-ms.php | 26 + .../language/phpmailer.lang-nb.php | 25 + .../language/phpmailer.lang-nl.php | 26 + .../language/phpmailer.lang-pl.php | 26 + .../language/phpmailer.lang-pt.php | 26 + .../language/phpmailer.lang-pt_br.php | 29 + .../language/phpmailer.lang-ro.php | 26 + .../language/phpmailer.lang-ru.php | 27 + .../language/phpmailer.lang-sk.php | 27 + .../language/phpmailer.lang-sl.php | 27 + .../language/phpmailer.lang-sr.php | 27 + .../language/phpmailer.lang-sv.php | 26 + .../language/phpmailer.lang-tl.php | 27 + .../language/phpmailer.lang-tr.php | 30 + .../language/phpmailer.lang-uk.php | 27 + .../language/phpmailer.lang-vi.php | 26 + .../language/phpmailer.lang-zh.php | 28 + .../language/phpmailer.lang-zh_cn.php | 28 + vendor/PHPMailer-6.0.7/src/Exception.php | 39 + vendor/PHPMailer-6.0.7/src/OAuth.php | 138 + vendor/PHPMailer-6.0.7/src/PHPMailer.php | 4502 +++++++++++++++++ vendor/PHPMailer-6.0.7/src/POP3.php | 419 ++ vendor/PHPMailer-6.0.7/src/SMTP.php | 1326 +++++ 68 files changed, 8917 insertions(+), 12 deletions(-) create mode 100644 email_invoice.php create mode 100644 vendor/PHPMailer-6.0.7/COMMITMENT create mode 100644 vendor/PHPMailer-6.0.7/LICENSE create mode 100644 vendor/PHPMailer-6.0.7/README.md create mode 100644 vendor/PHPMailer-6.0.7/SECURITY.md create mode 100644 vendor/PHPMailer-6.0.7/VERSION create mode 100644 vendor/PHPMailer-6.0.7/composer.json create mode 100644 vendor/PHPMailer-6.0.7/get_oauth_token.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-am.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ar.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-az.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ba.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-be.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-bg.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ca.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ch.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-cs.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-da.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-de.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-el.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-eo.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-es.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-et.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-fa.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-fi.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-fo.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-fr.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-gl.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-he.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-hi.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-hr.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-hu.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-id.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-it.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ja.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ka.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ko.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-lt.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-lv.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-mg.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ms.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-nb.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-nl.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-pl.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-pt.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-pt_br.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ro.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-ru.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-sk.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-sl.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-sr.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-sv.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-tl.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-tr.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-uk.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-vi.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-zh.php create mode 100644 vendor/PHPMailer-6.0.7/language/phpmailer.lang-zh_cn.php create mode 100644 vendor/PHPMailer-6.0.7/src/Exception.php create mode 100644 vendor/PHPMailer-6.0.7/src/OAuth.php create mode 100644 vendor/PHPMailer-6.0.7/src/PHPMailer.php create mode 100644 vendor/PHPMailer-6.0.7/src/POP3.php create mode 100644 vendor/PHPMailer-6.0.7/src/SMTP.php diff --git a/add_client_modal.php b/add_client_modal.php index 1da6436a..a5621593 100644 --- a/add_client_modal.php +++ b/add_client_modal.php @@ -24,7 +24,7 @@
- +
@@ -32,7 +32,7 @@
- $state_name) { ?> @@ -40,7 +40,7 @@
- +
@@ -50,7 +50,7 @@
- +
@@ -59,7 +59,7 @@
- +
@@ -69,7 +69,7 @@
- + 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"; + } + + + ?>

Invoice # INV- - +

@@ -58,7 +81,7 @@ if(isset($_GET['invoice_id'])){ diff --git a/invoices.php b/invoices.php index c33975bf..fa5f2e1d 100644 --- a/invoices.php +++ b/invoices.php @@ -39,6 +39,26 @@ $client_id = $row['client_id']; $client_name = $row['client_name']; + $unixtime_invoice_due = strtotime($invoice_due); + if($unixtime_invoice_due < time()){ + $overdue_color = "text-danger"; + $invoice_status = "Overdue"; + }else{ + $overdue_color = "text-success"; + } + + 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"; + } + ?> @@ -46,8 +66,12 @@ $ - - +
+ + + + +