mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Modified the way the app detects setup mode, added an alerts setting page and other minor fixes and cleanups
This commit is contained in:
18
cron.php
18
cron.php
@@ -29,6 +29,7 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||
$config_mail_from_email = $row['config_mail_from_email'];
|
||||
$config_mail_from_name = $row['config_mail_from_name'];
|
||||
$config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice'];
|
||||
$config_base_url = $row['config_base_url'];
|
||||
|
||||
if($config_enable_cron == 1){
|
||||
|
||||
@@ -36,7 +37,7 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||
|
||||
//DOMAINS EXPIRING
|
||||
|
||||
$domainAlertArray = [1, 14, 30, 90];
|
||||
$domainAlertArray = [1,7,14,30,90,120];
|
||||
|
||||
foreach($domainAlertArray as $day){
|
||||
|
||||
@@ -61,8 +62,7 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||
|
||||
}
|
||||
|
||||
//PAST DUE INVOICES
|
||||
|
||||
//PAST DUE INVOICE ALERTS
|
||||
$invoiceAlertArray = [$config_invoice_overdue_reminders];
|
||||
|
||||
foreach($invoiceAlertArray as $day){
|
||||
@@ -91,7 +91,7 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//LOW BALANCE ALERTS
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM accounts WHERE company_id = $company_id ORDER BY account_id DESC");
|
||||
|
||||
@@ -103,12 +103,16 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$total_payments = $row['total_payments'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$total_revenues = $row['total_revenues'];
|
||||
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$total_expenses = $row['total_expenses'];
|
||||
|
||||
$balance = $opening_balance + $total_payments - $total_expenses;
|
||||
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
||||
|
||||
if($balance < $config_account_balance_threshold){
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Account Low Balance', alert_message = 'Threshold of $config_account_balance_threshold triggered low balance of $balance on account $account_name', alert_date = NOW(), company_id = $company_id");
|
||||
@@ -219,14 +223,14 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||
|
||||
$mail->send();
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'Auto Emailed Invoice!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'Cron Emailed Invoice!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $company_id");
|
||||
|
||||
//Update Invoice Status to Sent
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Sent', invoice_updated_at = NOW(), client_id = $client_id WHERE invoice_id = $new_invoice_id");
|
||||
|
||||
}catch (Exception $e) {
|
||||
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'Failed to send Invoice!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'Cron Failed to send Invoice!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $company_id");
|
||||
} //End Mail Try
|
||||
} //End if Autosend is on
|
||||
} //End Recurring Invoices Loop
|
||||
|
||||
Reference in New Issue
Block a user