mirror of https://github.com/itflow-org/itflow
DB Structure Change - Removed the useless Low Account Balance alert
This commit is contained in:
parent
85cdc42d0f
commit
c88e6b851a
|
|
@ -66,9 +66,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
<div class="card card-dark">
|
<div class="card card-dark">
|
||||||
<div class="card-header py-2">
|
<div class="card-header py-2">
|
||||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-desktop"></i> Assets</h3>
|
<h3 class="card-title mt-2"><i class="fa fa-fw fa-desktop"></i> Client Assets</h3>
|
||||||
<div class="card-tools">
|
<div class="card-tools">
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addAssetModal"><i class="fas fa-fw fa-plus"></i> New Asset</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -77,7 +76,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search Assets">
|
<input type="search" class="form-control" name="q" value="<?php if(isset($q)){echo stripslashes($q);} ?>" placeholder="Search all client assets">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#advancedFilter"><i class="fas fa-filter"></i></button>
|
||||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||||
|
|
|
||||||
34
cron.php
34
cron.php
|
|
@ -30,8 +30,6 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||||
$config_mail_from_email = $row['config_mail_from_email'];
|
$config_mail_from_email = $row['config_mail_from_email'];
|
||||||
$config_mail_from_name = $row['config_mail_from_name'];
|
$config_mail_from_name = $row['config_mail_from_name'];
|
||||||
$config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice'];
|
$config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice'];
|
||||||
$config_enable_alert_low_balance = $row['config_enable_alert_low_balance'];
|
|
||||||
$config_account_balance_threshold = $row['config_account_balance_threshold'];
|
|
||||||
$config_base_url = $row['config_base_url'];
|
$config_base_url = $row['config_base_url'];
|
||||||
|
|
||||||
if($config_enable_cron == 1){
|
if($config_enable_cron == 1){
|
||||||
|
|
@ -163,38 +161,6 @@ while($row = mysqli_fetch_array($sql_companies)){
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//LOW BALANCE ALERTS
|
|
||||||
if($config_enable_alert_low_balance == 1){
|
|
||||||
|
|
||||||
$sql = mysqli_query($mysqli,"SELECT * FROM accounts WHERE company_id = $company_id ORDER BY account_id DESC");
|
|
||||||
|
|
||||||
while($row = mysqli_fetch_array($sql)){
|
|
||||||
$account_id = $row['account_id'];
|
|
||||||
$account_name = $row['account_name'];
|
|
||||||
$opening_balance = $row['opening_balance'];
|
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_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 revenue_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 expense_account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_expenses);
|
|
||||||
$total_expenses = $row['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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Send Recurring Invoices that match todays date and are active
|
//Send Recurring Invoices that match todays date and are active
|
||||||
|
|
||||||
|
|
|
||||||
4
db.sql
4
db.sql
|
|
@ -847,8 +847,6 @@ CREATE TABLE `settings` (
|
||||||
`config_ticket_prefix` varchar(200) DEFAULT NULL,
|
`config_ticket_prefix` varchar(200) DEFAULT NULL,
|
||||||
`config_ticket_next_number` int(11) DEFAULT NULL,
|
`config_ticket_next_number` int(11) DEFAULT NULL,
|
||||||
`config_enable_cron` tinyint(1) DEFAULT NULL,
|
`config_enable_cron` tinyint(1) DEFAULT NULL,
|
||||||
`config_enable_alert_low_balance` tinyint(1) DEFAULT NULL,
|
|
||||||
`config_account_balance_threshold` decimal(15,2) DEFAULT NULL,
|
|
||||||
`config_recurring_auto_send_invoice` tinyint(1) DEFAULT NULL,
|
`config_recurring_auto_send_invoice` tinyint(1) DEFAULT NULL,
|
||||||
`config_enable_alert_domain_expire` tinyint(1) DEFAULT NULL,
|
`config_enable_alert_domain_expire` tinyint(1) DEFAULT NULL,
|
||||||
`config_send_invoice_reminders` tinyint(1) DEFAULT NULL,
|
`config_send_invoice_reminders` tinyint(1) DEFAULT NULL,
|
||||||
|
|
@ -1100,4 +1098,4 @@ CREATE TABLE `vendors` (
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2021-12-08 22:12:04
|
-- Dump completed on 2021-12-08 22:31:20
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,6 @@ $config_ticket_next_number = $row['config_ticket_next_number'];
|
||||||
//Alerts
|
//Alerts
|
||||||
$config_enable_cron = $row['config_enable_cron'];
|
$config_enable_cron = $row['config_enable_cron'];
|
||||||
|
|
||||||
$config_enable_alert_low_balance = $row['config_enable_alert_low_balance'];
|
|
||||||
$config_account_balance_threshold = $row['config_account_balance_threshold'];
|
|
||||||
|
|
||||||
$config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice'];
|
$config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice'];
|
||||||
$config_enable_alert_domain_expire = $row['config_enable_alert_domain_expire'];
|
$config_enable_alert_domain_expire = $row['config_enable_alert_domain_expire'];
|
||||||
$config_send_invoice_reminders = $row['config_send_invoice_reminders'];
|
$config_send_invoice_reminders = $row['config_send_invoice_reminders'];
|
||||||
|
|
|
||||||
4
post.php
4
post.php
|
|
@ -709,12 +709,10 @@ if(isset($_POST['edit_alert_settings'])){
|
||||||
|
|
||||||
$config_enable_cron = intval($_POST['config_enable_cron']);
|
$config_enable_cron = intval($_POST['config_enable_cron']);
|
||||||
$config_enable_alert_domain_expire = intval($_POST['config_enable_alert_domain_expire']);
|
$config_enable_alert_domain_expire = intval($_POST['config_enable_alert_domain_expire']);
|
||||||
$config_enable_alert_low_balance = intval($_POST['config_enable_alert_low_balance']);
|
|
||||||
$config_send_invoice_reminders = intval($_POST['config_send_invoice_reminders']);
|
$config_send_invoice_reminders = intval($_POST['config_send_invoice_reminders']);
|
||||||
$config_invoice_overdue_reminders = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_overdue_reminders']));
|
$config_invoice_overdue_reminders = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_overdue_reminders']));
|
||||||
$config_account_balance_threshold = floatval($_POST['config_account_balance_threshold']);
|
|
||||||
|
|
||||||
mysqli_query($mysqli,"UPDATE settings SET config_send_invoice_reminders = $config_send_invoice_reminders, config_invoice_overdue_reminders = '$config_invoice_overdue_reminders', config_enable_cron = $config_enable_cron, config_enable_alert_domain_expire = $config_enable_alert_domain_expire, config_enable_alert_low_balance = $config_enable_alert_low_balance, config_account_balance_threshold = '$config_account_balance_threshold' WHERE company_id = $session_company_id");
|
mysqli_query($mysqli,"UPDATE settings SET config_send_invoice_reminders = $config_send_invoice_reminders, config_invoice_overdue_reminders = '$config_invoice_overdue_reminders', config_enable_cron = $config_enable_cron, config_enable_alert_domain_expire = $config_enable_alert_domain_expire WHERE company_id = $session_company_id");
|
||||||
|
|
||||||
//Logging
|
//Logging
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modified', log_description = 'Alerts', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modified', log_description = 'Alerts', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
|
||||||
|
|
|
||||||
|
|
@ -14,25 +14,6 @@
|
||||||
<label class="custom-control-label" for="customSwitch1">Enable Cron <small>(cron.php must also be added to cron and run nightly at 11:00PM for alerts to work)</small></label>
|
<label class="custom-control-label" for="customSwitch1">Enable Cron <small>(cron.php must also be added to cron and run nightly at 11:00PM for alerts to work)</small></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="custom-control custom-switch mb-2">
|
|
||||||
<input type="checkbox" class="custom-control-input" name="config_enable_alert_low_balance" <?php if($config_enable_alert_low_balance == 1){ echo "checked"; } ?> value="1" id="customSwitch2">
|
|
||||||
<label class="custom-control-label" for="customSwitch2">Enable Low Balance Alerts</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if($config_enable_alert_low_balance == 1){ ?>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Threshold</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-piggy-bank"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" name="config_account_balance_threshold" placeholder="Set an alert for dollar amount" value="<?php echo $config_account_balance_threshold; ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<div class="custom-control custom-switch mb-2">
|
<div class="custom-control custom-switch mb-2">
|
||||||
<input type="checkbox" class="custom-control-input" name="config_enable_alert_domain_expire" <?php if($config_enable_alert_domain_expire == 1){ echo "checked"; } ?> value="1" id="customSwitch3">
|
<input type="checkbox" class="custom-control-input" name="config_enable_alert_domain_expire" <?php if($config_enable_alert_domain_expire == 1){ echo "checked"; } ?> value="1" id="customSwitch3">
|
||||||
<label class="custom-control-label" for="customSwitch3">Enable Domain Expiration Alerts</label>
|
<label class="custom-control-label" for="customSwitch3">Enable Domain Expiration Alerts</label>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue