New Feature Enable/Disable ITFlow Modules now using the automated DB updater

This commit is contained in:
johnnyq 2022-04-14 22:59:36 -04:00
parent 344276ca33
commit fd8188095e
14 changed files with 153 additions and 50 deletions

View File

@ -48,6 +48,7 @@
</a>
</li>
<?php if($config_module_enable_accounting){ ?>
<li class="nav-item">
<a class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "settings-defaults.php") { echo "active"; } ?>"
href="settings-defaults.php">
@ -72,14 +73,6 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "settings-ticket.php") { echo "active"; } ?>"
href="settings-ticket.php">
<i class="nav-icon fas fa-ticket-alt"></i>
<p>Ticket</p>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "settings-alerts.php") { echo "active"; } ?>"
href="settings-alerts.php">
@ -96,6 +89,32 @@
</a>
</li>
<li class="nav-item">
<a href="categories.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "categories.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-list"></i>
<p>Categories</p>
</a>
</li>
<li class="nav-item">
<a href="taxes.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "taxes.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-balance-scale"></i>
<p>Taxes</p>
</a>
</li>
<?php } ?>
<?php if($config_module_enable_ticketing){ ?>
<li class="nav-item">
<a class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "settings-ticket.php") { echo "active"; } ?>"
href="settings-ticket.php">
<i class="nav-icon fas fa-ticket-alt"></i>
<p>Ticket</p>
</a>
</li>
<?php } ?>
<li class="nav-item">
<a href="settings-integrations.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "settings-integrations.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-puzzle-piece"></i>
@ -127,26 +146,23 @@
</a>
</li>
<li class="nav-header mt-3">MORE SETTINGS</li>
<li class="nav-item">
<a href="categories.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "categories.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-list"></i>
<p>Categories</p>
<a class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "settings-modules.php") { echo "active"; } ?>"
href="settings-modules.php">
<i class="nav-icon fas fa-puzzle-piece"></i>
<p>Modules</p>
</a>
</li>
<li class="nav-header mt-3">MORE SETTINGS</li>
<li class="nav-item">
<a href="custom_links.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "custom_links.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-link"></i>
<p>Custom Links</p>
</a>
</li>
<li class="nav-item">
<a href="taxes.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "taxes.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-balance-scale"></i>
<p>Taxes</p>
</a>
</li>
<li class="nav-item">
<a href="logs.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "logs.php") { echo "active"; } ?>">
<i class="nav-icon far fa-eye"></i>

View File

@ -170,7 +170,7 @@ $location_phone = formatPhoneNumber($location_phone);
<div class="card mb-3">
<div class="card-body">
<div class="row">
<div class="col-md-3">
<div class="col-md">
<h4 class="text-secondary"><strong><?php echo $client_name; ?></strong></h4>
<?php if(!empty($location_address)){ ?>
<a href="//maps.<?php echo $session_map_source; ?>.com/?q=<?php echo "$location_address $location_zip"; ?>" target="_blank">
@ -194,7 +194,7 @@ $location_phone = formatPhoneNumber($location_phone);
}
?>
</div>
<div class="col-md-3 border-left">
<div class="col-md border-left">
<h4 class="text-secondary">Contact</h4>
<?php
if(!empty($contact_name)){
@ -235,18 +235,20 @@ $location_phone = formatPhoneNumber($location_phone);
}
?>
</div>
<?php if($session_user_role == 1 || $session_user_role == 3){ ?>
<div class="col-md-3 border-left">
<?php if($session_user_role == 1 || $session_user_role == 3 AND $config_module_enable_accounting == 1){ ?>
<div class="col-md border-left">
<h4 class="text-secondary">Billing</h4>
<h6 class="ml-1 text-secondary">Paid <div class="text-dark float-right"> <?php echo numfmt_format_currency($currency_format, $amount_paid, $client_currency_code); ?></div></h6>
<h6 class="ml-1 text-secondary">Balance <div class="<?php if($balance > 0){ echo "text-danger"; }else{ echo "text-dark"; } ?> float-right"> <?php echo numfmt_format_currency($currency_format, $balance, $client_currency_code); ?></div></h6>
<h6 class="ml-1 text-secondary">Net Terms <div class="text-dark float-right"><?php echo $client_net_terms; ?> <small class="text-secondary">Days</small></div></h6>
</div>
<?php } ?>
<div class="col-md-2 border-left">
<?php if($config_module_enable_ticketing == 1){ ?>
<div class="col-md border-left">
<h4 class="text-secondary">Support</h4>
<h6 class="ml-1 text-secondary">Open Tickets <div class="text-dark float-right"><?php echo $num_active_tickets; ?></div></h6>
</div>
<?php } ?>
<div class="col-md-1 border-left">
<?php if($session_user_role == 3) { ?>
<div class="dropdown dropleft text-center">

View File

@ -227,6 +227,7 @@
<div class="tab-pane fade" id="pills-additional">
<?php if($config_module_enable_accounting){ ?>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
@ -255,6 +256,12 @@
</select>
</div>
</div>
<?php }else{ ?>
<input type="hidden" name="currency_code" value="<?php echo $session_company_currency; ?>">
<input type="hidden" name="net_terms" value="0">
<?php } ?>
<div class="form-group">
<label>Notes</label>

View File

@ -87,7 +87,8 @@
<input type="text" class="form-control" name="website" placeholder="ex. google.com" value="<?php echo $client_website; ?>">
</div>
</div>
<?php if($config_module_enable_accounting){ ?>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
@ -117,6 +118,12 @@
</select>
</div>
</div>
<?php }else{ ?>
<input type="hidden" name="currency_code" value="<?php echo $currency_code; ?>">
<input type="hidden" name="net_terms" value="<?php echo $net_term_value; ?>">
<?php } ?>
</div>

View File

@ -148,6 +148,7 @@
<li class="nav-header mt-3">SUPPORT</li>
<?php if($config_module_enable_ticketing == 1){ ?>
<li class="nav-item">
<a href="?client_id=<?php echo $client_id; ?>&tab=tickets" class="nav-link <?php if($_GET['tab'] == "tickets") { echo "active"; } ?>">
<i class="nav-icon fas fa-ticket-alt"></i>
@ -160,18 +161,19 @@
</p>
</a>
</li>
<?php } ?>
<li class="nav-item">
<a href="?client_id=<?php echo $client_id; ?>&tab=services" class="nav-link <?php if($_GET['tab'] == "services") { echo "active"; } ?>">
<i class="nav-icon fas fa-stream"></i>
<p>
Services
<?php
if($num_services > 0){ ?>
<span class="right badge badge-light"><?php echo $num_services; ?></span>
<?php } ?>
</p>
</a>
<a href="?client_id=<?php echo $client_id; ?>&tab=services" class="nav-link <?php if($_GET['tab'] == "services") { echo "active"; } ?>">
<i class="nav-icon fas fa-stream"></i>
<p>
Services
<?php
if($num_services > 0){ ?>
<span class="right badge badge-light"><?php echo $num_services; ?></span>
<?php } ?>
</p>
</a>
</li>
<li class="nav-item">
@ -226,7 +228,7 @@
</a>
</li>
<?php if($session_user_role == 1 || $session_user_role > 2){ ?>
<?php if($session_user_role == 1 || $session_user_role > 2 AND $config_module_enable_accounting == 1){ ?>
<li class="nav-header mt-3">ACCOUNTING</li>
@ -305,13 +307,15 @@
<p>Shared Links</p>
</a>
</li>
<?php if($config_module_enable_ticketing == 1){ ?>
<li class="nav-item">
<a href="?client_id=<?php echo $client_id; ?>&tab=scheduled-tickets" class="nav-link <?php if($_GET['tab'] == "scheduled-tickets") { echo "active"; } ?>">
<i class="nav-icon fas fa-sync"></i>
<p>Scheduled Tickets</p>
</a>
</li>
<?php } ?>
<li class="nav-item">
<a href="?client_id=<?php echo $client_id; ?>&tab=logs" class="nav-link <?php if($_GET['tab'] == "logs") { echo "active"; } ?>">

View File

@ -167,7 +167,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<th><a class="text-dark" href="?<?php echo $url_query_strings_sortby; ?>&sortby=client_name&order=<?php echo $order_display; ?>">Name</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sortby; ?>&sortby=location_city&order=<?php echo $order_display; ?>">Address </a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sortby; ?>&sortby=contact_name&order=<?php echo $order_display; ?>">Contact</a></th>
<?php if($session_user_role == 3 || $session_user_role == 1) { ?> <th class="text-right">Billing</th> <?php } ?>
<?php if($session_user_role == 3 || $session_user_role == 1 AND $config_module_enable_accounting == 1) { ?> <th class="text-right">Billing</th> <?php } ?>
<?php if($session_user_role == 3) { ?> <th class="text-center">Action</th> <?php } ?>
</tr>
</thead>
@ -309,8 +309,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
?>
</td>
<!-- Show Billing for Admin/Accountant roles only -->
<?php if($session_user_role == 3 || $session_user_role == 1) { ?>
<!-- Show Billing for Admin/Accountant roles only and if accounting module is enabled -->
<?php if($session_user_role == 3 || $session_user_role == 1 AND $config_module_enable_accounting == 1) { ?>
<td class="text-right">
<span class="text-secondary">Balance</span> <span class="<?php echo $balance_text_color; ?>"><?php echo numfmt_format_currency($currency_format, $balance, $session_company_currency); ?></span>
<br>

View File

@ -12,24 +12,24 @@ if(!defined("LATEST_DATABASE_VERSION") || !defined("CURRENT_DATABASE_VERSION") |
exit();
}
// Check if we need an update
if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){
// We need updates!
if(CURRENT_DATABASE_VERSION == '0.0.1'){
// Insert queries here required to update to DB version 0.0.2
// mysqli_query($mysqli, "ALTER TABLE .....");
ALTER TABLE `settings` ADD `config_module_enable_itdoc` TINYINT(1) DEFAULT 1 AFTER `config_backup_path `;
ALTER TABLE `settings` ADD `config_module_enable_ticketing` TINYINT(1) DEFAULT 1 AFTER `config_module_enable_itdoc`;
ALTER TABLE `settings` ADD `config_module_enable_accounting` TINYINT(1) DEFAULT 1 AFTER `config_module_enable_ticketing`;
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE settings SET config_current_database_version = '0.0.2' WHERE company_id = '1'");
UPDATE `settings` SET `config_current_database_version` = '0.0.2';
}
if(CURRENT_DATABASE_VERSION == '0.0.2'){
// Insert queries here required to update to DB version 0.0.3
// mysqli_query($mysqli, "ALTER TABLE .....");

View File

@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "0.0.1");
DEFINE("LATEST_DATABASE_VERSION", "0.0.2");

5
db.sql
View File

@ -1134,6 +1134,9 @@ CREATE TABLE `settings` (
`config_azure_client_secret` varchar(200) DEFAULT NULL,
`config_backup_enable` tinyint(1) NOT NULL DEFAULT 0,
`config_backup_path` varchar(250) DEFAULT NULL,
`config_module_enable_itdoc` tinyint(1) NOT NULL DEFAULT 1,
`config_module_enable_accounting` tinyint(1) NOT NULL DEFAULT 1,
`config_module_enable_ticketing` tinyint(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -1487,4 +1490,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-04-02 16:01:13
-- Dump completed on 2022-04-14 22:58:14

View File

@ -79,6 +79,11 @@ $config_stripe_secret = $row['config_stripe_secret'];
$config_backup_enable = $row['config_backup_enable'];
$config_backup_path = $row['config_backup_path'];
// Modules
$config_module_enable_itdoc = $row['config_module_enable_itdoc'];
$config_module_enable_ticketing = $row['config_module_enable_ticketing'];
$config_module_enable_accounting = $row['config_module_enable_accounting'];
// Currency
$config_currency_format = "US_en";

View File

@ -1119,6 +1119,30 @@ if(isset($_POST['edit_backup_settings'])){
}
if(isset($_POST['edit_module_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = "You are not permitted to do that!";
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
$config_module_enable_itdoc = intval($_POST['config_module_enable_itdoc']);
$config_module_enable_ticketing = intval($_POST['config_module_enable_ticketing']);
$config_module_enable_accounting = intval($_POST['config_module_enable_accounting']);
mysqli_query($mysqli,"UPDATE settings SET config_module_enable_itdoc = $config_module_enable_itdoc, config_module_enable_ticketing = $config_module_enable_ticketing, config_module_enable_accounting = $config_module_enable_accounting WHERE company_id = $session_company_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified module settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_user_id = $session_user_id, company_id = $session_company_id");
$_SESSION['alert_message'] = "Module Settings updated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_POST['enable_2fa'])){
$token = mysqli_real_escape_string($mysqli,$_POST['token']);

33
settings-modules.php Normal file
View File

@ -0,0 +1,33 @@
<?php include("inc_all_admin.php"); ?>
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title"><i class="fa fa-fw fa-puzzle-piece"></i> Modules</h3>
</div>
<div class="card-body">
<form action="post.php" method="post" autocomplete="off">
<div class="custom-control custom-switch mb-3">
<input type="checkbox" class="custom-control-input" name="config_module_enable_itdoc" <?php if($config_module_enable_itdoc == 1){ echo "checked"; } ?> value="1" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Enable IT Documentation</label>
</div>
<div class="custom-control custom-switch mb-3">
<input type="checkbox" class="custom-control-input" name="config_module_enable_ticketing" <?php if($config_module_enable_ticketing == 1){ echo "checked"; } ?> value="1" id="customSwitch2">
<label class="custom-control-label" for="customSwitch2">Enable Ticketing</label>
</div>
<div class="custom-control custom-switch mb-3">
<input type="checkbox" class="custom-control-input" name="config_module_enable_accounting" <?php if($config_module_enable_accounting == 1){ echo "checked"; } ?> value="1" id="customSwitch3">
<label class="custom-control-label" for="customSwitch3">Enable Invoicing / Accounting</label>
</div>
<hr>
<button type="submit" name="edit_module_settings" class="btn btn-primary">Save</button>
</form>
</div>
</div>
<?php include("footer.php");

View File

@ -74,7 +74,7 @@
</a>
</li>
<?php if($session_user_role >= 2){ ?>
<?php if($session_user_role >= 2 && $config_module_enable_ticketing == 1){ ?>
<li class="nav-header mt-3">SUPPORT</li>
<li class="nav-item">
@ -105,7 +105,7 @@
<?php } ?>
<?php if($session_user_role == 1 OR $session_user_role == 3){ ?>
<?php if($session_user_role == 1 OR $session_user_role == 3 && $config_module_enable_accounting == 1){ ?>
<li class="nav-header mt-3">SALES</li>
<li class="nav-item">

View File

@ -578,8 +578,9 @@ if(isset($_GET['ticket_id'])){
</div>
</form>
<?php if($config_module_enable_accounting){ ?>
<div class="card card-body card-outline card-dark mb-2">
<div class="">
<div class="">
<a href="#" class="btn btn-outline-success btn-block" href="#" data-toggle="modal" data-target="#addInvoiceFromTicketModal">Invoice Ticket</a>
<?php
if($ticket_status !== "Closed"){
@ -588,6 +589,7 @@ if(isset($_GET['ticket_id'])){
<?php } ?>
</div>
</div>
<?php } ?>
</div>