diff --git a/add_client_application_modal.php b/add_client_application_modal.php
index acb761d5..195ae3e7 100644
--- a/add_client_application_modal.php
+++ b/add_client_application_modal.php
@@ -46,26 +46,6 @@
-
-
-
-
Add a pasword
+
+
+
+
diff --git a/client_vendors.php b/client_vendors.php
index fa9df1b1..a4cc1d12 100644
--- a/client_vendors.php
+++ b/client_vendors.php
@@ -49,8 +49,22 @@
diff --git a/config.php b/config.php
index 8ef06b6b..de1a225e 100644
--- a/config.php
+++ b/config.php
@@ -34,7 +34,7 @@
$config_invoice_footer = "Please make checks payable to PittPC
Visit us at pittpc.com";
//Mail Settings (Host must require TLS Support)
- $config_smtp_host = "";
+ $config_smtp_host = "mail.pittpc.com";
$config_smtp_username = "";
$config_smtp_password = "";
$config_smtp_port = 587;
diff --git a/cron.php b/cron.php
index f8d46b52..702a2b15 100644
--- a/cron.php
+++ b/cron.php
@@ -59,6 +59,15 @@ $invoice_date_due = $row['invoice_date_due'];
//Send Recurring Invoices
+$sql = mysqli_query($mysqli,"SELECT * FROM recurring_invoices WHERE recurring_invoice_active = 1");
+
+$recurring_invoice_id = $row['recurring_invoice_id'];
+$recurring_invoice_frequency = $row['recurring_invoice_frequency'];
+$recurring_invoice_amount = $row['recurring_invoice_amount'];
+$recurring_invoice_start_date = $row['recurring_invoice_start_date'];
+$recurring_invoice_last_sent = $row['recurring_invoice_last_sent'];
+
+
//Send Past Due Invoice Reminders
$sql = mysqli_query($mysqli,"SELECT * FROM accounts ORDER BY account_id DESC");
diff --git a/email_invoice.php b/email_invoice.php
index 4810d842..4b120a3a 100644
--- a/email_invoice.php
+++ b/email_invoice.php
@@ -1,5 +1,4 @@
diff --git a/post.php b/post.php
index 09018ee5..f7c95856 100644
--- a/post.php
+++ b/post.php
@@ -4,6 +4,12 @@ include("config.php");
include("check_login.php");
//include("functions.php");
+require("vendor/PHPMailer-6.0.7/src/PHPMailer.php");
+require("vendor/PHPMailer-6.0.7/src/SMTP.php");
+
+use PHPMailer\PHPMailer\PHPMailer;
+use PHPMailer\PHPMailer\Exception;
+
$todays_date = date('Y-m-d');
if(isset($_POST['add_user'])){
@@ -575,6 +581,7 @@ if(isset($_POST['add_payment'])){
$amount = $_POST['amount'];
$account = intval($_POST['account']);
$payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']));
+ $email_receipt = intval($_POST['email_receipt']);
//Check to see if amount entered is greater than the balance of the invoice
if($amount > $balance){
@@ -589,18 +596,96 @@ if(isset($_POST['add_payment'])){
$total_payments_amount = $row['payments_amount'];
//Get the invoice total
- $sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id");
+ $sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients WHERE invoices.client_id = clients.client_id AND invoices.invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql);
$invoice_amount = $row['invoice_amount'];
+ $invoice_number = $row['invoice_number'];
+ $client_name = $row['client_name'];
+ $client_email = $row['client_email'];
//Calculate the Invoice balance
$invoice_balance = $invoice_amount - $total_payments_amount;
+
//Determine if invoice has been paid then set the status accordingly
if($invoice_balance == 0){
- $invoice_status = "Paid";
+ $invoice_status = "Paid";
+ if($email_receipt == 1){
+ $mail = new PHPMailer(true);
+
+ try {
+
+ //Mail Server Settings
+
+ //$mail->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
+
+ // Content
+ $mail->isHTML(true); // Set email format to HTML
+ $mail->Subject = "Thank You! - Payment Recieved for Invoice INV-$invoice_number";
+ $mail->Body = "Hello $client_name,
We have recieved your payment of $amount on $date for invoice INV-$invoice_number by $payment_method
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 Receipt!', invoice_id = $invoice_id");
+
+ } catch (Exception $e) {
+ echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
+ }
+ }
+
+
+
}else{
$invoice_status = "Partial";
+ if($email_receipt == 1){
+ $mail = new PHPMailer(true);
+
+ try {
+
+ //Mail Server Settings
+
+ //$mail->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
+
+ // Content
+ $mail->isHTML(true); // Set email format to HTML
+ $mail->Subject = "Thank You! - Partial Payment Recieved for Invoice INV-$invoice_number";
+ $mail->Body = "Hello $client_name,
We have recieved your payment of $amount on $date for invoice INV-$invoice_number by $payment_method, although you still have a balance of $balance
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 Receipt!', invoice_id = $invoice_id");
+
+ } catch (Exception $e) {
+ echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
+ }
+ }
+
}
//Update Invoice Status
@@ -831,7 +916,7 @@ if(isset($_POST['add_client_vendor'])){
$vendor_id = mysqli_insert_id($mysqli);
$username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']));
$password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['password']));
-
+
mysqli_query($mysqli,"INSERT INTO client_logins SET client_login_username = '$username', client_login_password = '$password', client_vendor_id = $vendor_id, client_id = $client_id");
}
diff --git a/uploads/invoice.pdf b/uploads/invoice.pdf
index e1cfc5ab..c7a5102d 100644
Binary files a/uploads/invoice.pdf and b/uploads/invoice.pdf differ