mirror of https://github.com/itflow-org/itflow
Modified the way the app detects setup mode, added an alerts setting page and other minor fixes and cleanups
This commit is contained in:
parent
be1b4d50fb
commit
89762313c5
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
if(!isset($config_enable_setup) or $config_enable_setup == 1){
|
||||
header("Location: setup.php");
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
||||
if(!$_SESSION['logged']){
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//Rebuild URL
|
||||
|
||||
//$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
if(isset($_GET['p'])){
|
||||
$p = intval($_GET['p']);
|
||||
|
|
|
|||
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
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
//General Settings
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM settings WHERE company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$sql_settings = mysqli_query($mysqli,"SELECT * FROM settings WHERE company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_settings);
|
||||
|
||||
$config_start_page = $row['config_start_page'];
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||
<?php
|
||||
if($invoice_status != "Paid" and $invoice_status != "Cancelled" and $invoice_status != "Draft"){
|
||||
?>
|
||||
<a class="btn btn-success" href="guest_pay.php?invoice_id=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-credit-card"></i> Pay Online</a>
|
||||
<a class="btn btn-success" href="guest_pay.php?invoice_id=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-credit-card"></i> Pay Online (Comming Soon)</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@
|
|||
|
||||
<?php
|
||||
|
||||
if(!file_exists('config.php')){
|
||||
header("Location: setup.php");
|
||||
}
|
||||
|
||||
include("config.php");
|
||||
include("check_login.php");
|
||||
include("vendor/Parsedown.php");
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ if(isset($_GET['quote_id'])){
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right">QUO-<?php echo $quote_number; ?></div></li>
|
||||
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right"><?php echo $quote_number; ?></div></li>
|
||||
<li class="mb-1"><strong>Quote Date:</strong> <div class="float-right"><?php echo $quote_date; ?></div></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php include("settings-nav.php"); ?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-fw fa-bell mr-2"></i>Alerts and Reminders</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="p-3" action="post.php" method="post" autocomplete="off">
|
||||
|
||||
<div class="custom-control custom-switch mb-2">
|
||||
<input type="checkbox" class="custom-control-input" name="config_alerts_domains" <?php if($config_alerts_domains == 1){ echo "checked"; } ?> value="1" id="customSwitch">
|
||||
<label class="custom-control-label" for="customSwitch">Enable Domain Expiration Alerts</label>
|
||||
</div>
|
||||
|
||||
<?php if($config_alerts_domains == 1){ ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Domain (Number of Days)</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_alert_domain_days" placeholder="Alert Before Days" value="<?php echo $config_alert_domain_days; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<div class="custom-control custom-switch mb-2">
|
||||
<input type="checkbox" class="custom-control-input" name="config_alerts_domains" <?php if($config_alerts_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_alerts_domains == 1){ ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Account 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-5">
|
||||
<input type="checkbox" class="custom-control-input" name="config_alerts_domains" <?php if($config_alerts_domains == 1){ echo "checked"; } ?> value="1" id="customSwitch3">
|
||||
<label class="custom-control-label" for="customSwitch3">Enable Domain Expiration Alerts</label>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<button type="submit" name="edit_default_settings" class="btn btn-primary">Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fab fa-fw fa-usps"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_company_zip" placeholder="Zip Code" value="<?php echo $config_company_zip; ?>" >
|
||||
<input type="text" class="form-control" name="config_company_zip" placeholder="Zip Code" value="<?php echo $config_company_zip; ?>" data-inputmask="'mask': '99999'">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<?php include("settings-nav.php"); ?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-fw fa-cog mr-2"></i>Defaults Settings</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
|
|
|||
|
|
@ -25,16 +25,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Account 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; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>API Key</label>
|
||||
<div class="input-group">
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_invoice_next_number" placeholder="Next Invoice Number" value="<?php echo $config_invoice_next_number; ?>" required>
|
||||
<input type="number" min="0" class="form-control" name="config_invoice_next_number" placeholder="Next Invoice Number" value="<?php echo $config_invoice_next_number; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-plug"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_smtp_port" placeholder="Mail Server Port Number" value="<?php echo $config_smtp_port; ?>" required>
|
||||
<input type="number" min="0" class="form-control" name="config_smtp_port" placeholder="Mail Server Port Number" value="<?php echo $config_smtp_port; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-general.php") { echo "active"; } ?>"
|
||||
href="settings-general.php">
|
||||
<i class="fa fa-2x fa-cog"></i><br>
|
||||
<i class="fa fa-fw fa-2x fa-cog"></i><br>
|
||||
General
|
||||
</a>
|
||||
</li>
|
||||
|
|
@ -55,6 +55,14 @@
|
|||
Ticket
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-alerts.php") { echo "active"; } ?>"
|
||||
href="settings-alerts.php">
|
||||
<i class="fa fa-fw fa-2x fa-bell"></i><br>
|
||||
Alerts
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-backup.php") { echo "active"; } ?>"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_quote_next_number" placeholder="Next Quote Number" value="<?php echo $config_quote_next_number; ?>" required>
|
||||
<input type="number" min="0" class="form-control" name="config_quote_next_number" placeholder="Next Quote Number" value="<?php echo $config_quote_next_number; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
27
setup.php
27
setup.php
|
|
@ -1,7 +1,12 @@
|
|||
<?php
|
||||
|
||||
|
||||
include("config.php");
|
||||
include("functions.php");
|
||||
|
||||
if(!isset($config_enable_setup) or $config_enable_setup == 0){
|
||||
header("Location: login.php");
|
||||
}
|
||||
|
||||
$states_array = array(
|
||||
'AL'=>'Alabama',
|
||||
'AK'=>'Alaska',
|
||||
|
|
@ -84,14 +89,8 @@ if(isset($_POST['add_database'])){
|
|||
|
||||
fwrite($myfile, $txt);
|
||||
|
||||
$txt = "?>";
|
||||
|
||||
fwrite($myfile, $txt);
|
||||
|
||||
fclose($myfile);
|
||||
|
||||
include("config.php");
|
||||
|
||||
// Name of the file
|
||||
$filename = 'db.sql';
|
||||
// Temporary variable, used to store current query
|
||||
|
|
@ -191,6 +190,18 @@ if(isset($_POST['add_company_settings'])){
|
|||
|
||||
mysqli_query($mysqli,"INSERT INTO calendars SET calendar_name = 'Default', calendar_color = 'blue', calendar_created_at = NOW(), company_id = $company_id");
|
||||
|
||||
$myfile = fopen("config.php", "a");
|
||||
|
||||
$txt = "\$config_enable_setup = 0;\n\n";
|
||||
|
||||
fwrite($myfile, $txt);
|
||||
|
||||
$txt = "?>";
|
||||
|
||||
fwrite($myfile, $txt);
|
||||
|
||||
fclose($myfile);
|
||||
|
||||
header("Location: login.php");
|
||||
|
||||
}
|
||||
|
|
@ -445,7 +456,7 @@ if(isset($_POST['add_company_settings'])){
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fab fa-fw fa-usps"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_company_zip" placeholder="Zip Code">
|
||||
<input type="text" class="form-control" name="config_company_zip" placeholder="Zip Code" data-inputmask="'mask': '99999'">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue