mirror of
https://github.com/itflow-org/itflow
synced 2026-11-21 20:07:24 +00:00
Module switches: Dispatch, Bookkeeping, Purchasing, Trips and Calendar can be switched off in Admin > Settings > Modules, Dispatch coming with ticketing and the other three with invoicing, each hidden from menus, dashboard, search, reports and the API and refused on its pages, windows and handlers while off; Purchasing starts off unless already in use, Bookkeeping off posts the default accounts in place of account pickers, database 3.9.4, new moduleOn, moduleOffText and bookkeepingAccount helpers, purchase order settings tile summary, 26.11.9 changelog entries
This commit is contained in:
43
admin/database_updates/3.9.4.php
Normal file
43
admin/database_updates/3.9.4.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 3.9.4 (from 3.9.3)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* Five more parts of ITFlow an admin can switch off in Admin > Settings >
|
||||
* Modules (moduleOn() in functions/settings.php) - nothing in one is deleted:
|
||||
* config_module_enable_purchasing - To Order, purchase orders and
|
||||
* receiving. Off to start with - on where purchasing is already in use.
|
||||
* config_module_enable_bookkeeping - accounts, transactions and transfers,
|
||||
* reconciling and statement imports. With it off, money goes into and out
|
||||
* of the default accounts without asking.
|
||||
* config_module_enable_dispatch - the Dispatch board.
|
||||
* config_module_enable_trips - trips and mileage.
|
||||
* config_module_enable_calendar - the calendar, its events and feeds.
|
||||
* Purchasing, Bookkeeping and Trips come with invoicing, Dispatch with
|
||||
* ticketing. All but Purchasing are on, as they were.
|
||||
*
|
||||
* Re-runnable: each column is added only where it isn't there yet.
|
||||
*/
|
||||
|
||||
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
|
||||
|
||||
$itflow_column = function ($table, $column) use ($mysqli) {
|
||||
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' AND COLUMN_NAME = '$column' LIMIT 1");
|
||||
return $result && mysqli_num_rows($result) > 0;
|
||||
};
|
||||
|
||||
$after = 'config_module_enable_ticketing';
|
||||
foreach (['purchasing' => 0, 'bookkeeping' => 1, 'dispatch' => 1, 'trips' => 1, 'calendar' => 1] as $module => $default) {
|
||||
$column = "config_module_enable_$module";
|
||||
if (!$itflow_column('settings', $column)) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `$column` tinyint(1) NOT NULL DEFAULT $default AFTER `$after`");
|
||||
if ($module === 'purchasing') {
|
||||
// Purchasing already in use stays on
|
||||
mysqli_query($mysqli, "UPDATE settings SET config_module_enable_purchasing = 1
|
||||
WHERE EXISTS (SELECT 1 FROM order_items) OR EXISTS (SELECT 1 FROM purchase_orders)");
|
||||
}
|
||||
}
|
||||
$after = $column;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ if (!$payment_method) { ?>
|
||||
<?php if ($usage['total']) { ?>
|
||||
<div class="alert alert-warning small py-2">
|
||||
<i class="fas fa-fw fa-exchange-alt me-1"></i>Used on <strong><?= escapeHtml(paymentMethodUsageText($usage)) ?></strong>.
|
||||
<a href="/agent/transactions.php?<?= escapeHtml(http_build_query(['method' => $payment_method['payment_method_name']])) ?>" target="_blank">See them</a>
|
||||
<?php if (moduleOn('bookkeeping')) { ?><a href="/agent/transactions.php?<?= escapeHtml(http_build_query(['method' => $payment_method['payment_method_name']])) ?>" target="_blank">See them</a><?php } ?>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Change them to <strong class="text-danger">*</strong></label>
|
||||
|
||||
@@ -140,6 +140,9 @@ ob_start();
|
||||
|
||||
<h6 class="fw-semibold mt-4 mb-2">Payments</h6>
|
||||
|
||||
<?php if (!moduleOn('bookkeeping')) { // Bookkeeping off - into the account it's set to, or the default ?>
|
||||
<input type="hidden" name="account" value="<?= $account_id ?: bookkeepingAccount('payment') ?>">
|
||||
<?php } else { ?>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="paymentProviderAccount">Payments go into <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group has-validation">
|
||||
@@ -154,6 +157,7 @@ ob_start();
|
||||
<?= $error_for('account') ?>
|
||||
<div class="form-text">An account of its own, named for it, makes its payouts easy to match.</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="paymentProviderThreshold">Card limit</label>
|
||||
|
||||
@@ -150,7 +150,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
$records_url = '/agent/transactions.php?' . http_build_query(['method' => $row['payment_method_name']]);
|
||||
$edit_url = "modals/payment_method/payment_method_edit.php?id=$payment_method_id";
|
||||
$use_html = '<span class="text-body-secondary text-nowrap" title="' . escapeHtml($use_info['about']) . '"><i class="fas fa-fw ' . $use_info['icon'] . ' me-1"></i>' . escapeHtml($use_info['short']) . '</span>';
|
||||
$used_html = $used['total'] ? '<a href="' . escapeHtml($records_url) . '" class="text-reset" title="See them in Transactions">' . escapeHtml($used_text) . '</a>' : '<span class="text-body-tertiary">Not used yet</span>';
|
||||
$used_html = $used['total'] ? (moduleOn('bookkeeping') ? '<a href="' . escapeHtml($records_url) . '" class="text-reset" title="See them in Transactions">' . escapeHtml($used_text) . '</a>' : escapeHtml($used_text)) : '<span class="text-body-tertiary">Not used yet</span>';
|
||||
?>
|
||||
<tr data-payment-method-id="<?= $payment_method_id ?>">
|
||||
<td class="ps-3">
|
||||
|
||||
@@ -142,7 +142,7 @@ $csrf = $_SESSION['csrf_token'];
|
||||
<?php if ($row['account_name'] === null) { ?>
|
||||
<span class="text-danger-emphasis"><i class="fas fa-fw fa-exclamation-triangle me-1"></i>No account - pick one in Edit</span>
|
||||
<?php } else { ?>
|
||||
<a class="text-reset" href="/agent/accounts.php"><?= escapeHtml($row['account_name']) ?></a>
|
||||
<?php if (moduleOn('bookkeeping')) { ?><a class="text-reset" href="/agent/accounts.php"><?= escapeHtml($row['account_name']) ?></a><?php } else { ?><?= escapeHtml($row['account_name']) ?><?php } ?>
|
||||
<?php if ($row['account_archived_at']) { ?><div class="text-danger-emphasis"><i class="fas fa-fw fa-archive me-1"></i>Archived - pick another in Edit</div><?php } ?>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
@@ -15,11 +15,15 @@ if (isset($_POST['edit_module_settings'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
$before = settingsCurrent(['config_module_enable_itdoc', 'config_module_enable_ticketing', 'config_module_enable_accounting', 'config_client_portal_enable',
|
||||
'config_whitelabel_enabled', 'config_whitelabel_key']);
|
||||
$modules = ['config_module_enable_itdoc', 'config_module_enable_ticketing', 'config_module_enable_accounting', 'config_client_portal_enable'];
|
||||
if (isset($config_module_enable_calendar)) {
|
||||
// Database 3.9.4's five
|
||||
array_push($modules, 'config_module_enable_dispatch', 'config_module_enable_bookkeeping', 'config_module_enable_purchasing', 'config_module_enable_trips', 'config_module_enable_calendar');
|
||||
}
|
||||
$before = settingsCurrent(array_merge($modules, ['config_whitelabel_enabled', 'config_whitelabel_key']));
|
||||
|
||||
$after = [];
|
||||
foreach (['config_module_enable_itdoc', 'config_module_enable_ticketing', 'config_module_enable_accounting', 'config_client_portal_enable'] as $module) {
|
||||
foreach ($modules as $module) {
|
||||
$after[$module] = empty($_POST[$module]) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,15 @@ $days = function ($n) {
|
||||
// How each page is set now - a line or two, and whether it is switched off
|
||||
$start_pages = settingsStartPages();
|
||||
$modules_on = array_keys(array_filter([
|
||||
'IT documentation' => $config_module_enable_itdoc,
|
||||
'Ticketing' => $config_module_enable_ticketing,
|
||||
'Invoicing' => $config_module_enable_accounting,
|
||||
'Client portal' => $config_client_portal_enable,
|
||||
'IT documentation' => moduleOn('itdoc'),
|
||||
'Ticketing' => moduleOn('ticketing'),
|
||||
'Dispatch' => isset($config_module_enable_dispatch) && moduleOn('dispatch'),
|
||||
'Invoicing' => moduleOn('accounting'),
|
||||
'Bookkeeping' => isset($config_module_enable_bookkeeping) && moduleOn('bookkeeping'),
|
||||
'Purchasing' => isset($config_module_enable_purchasing) && moduleOn('purchasing'),
|
||||
'Trips' => isset($config_module_enable_trips) && moduleOn('trips'),
|
||||
'Calendar' => isset($config_module_enable_calendar) && moduleOn('calendar'),
|
||||
'Client portal' => moduleOn('portal'),
|
||||
]));
|
||||
$where = array_filter([$company['company_city'] ?? '', $company['company_country'] ?? '']);
|
||||
$summaries = [
|
||||
@@ -41,6 +46,7 @@ $summaries = [
|
||||
'ticket' => 'Next ' . escapeHtml($config_ticket_prefix . $config_ticket_next_number) . ' · email to ticket ' . $on_off($config_ticket_email_parse),
|
||||
'project' => 'Next ' . escapeHtml($config_project_prefix . $config_project_next_number),
|
||||
'quote' => 'Next ' . escapeHtml($config_quote_prefix . $config_quote_next_number),
|
||||
'purchase_order' => poReady() ? 'Next ' . escapeHtml(poSettings()['prefix'] . poSettings()['next']) . ' · approval ' . $on_off(poSettings()['approval']) : 'Needs the database update',
|
||||
'invoice' => 'Next ' . escapeHtml($config_invoice_prefix . $config_invoice_next_number) . ' · reminders ' . $on_off($config_send_invoice_reminders) . ' · late fees ' . $on_off($config_invoice_late_fee_enable)
|
||||
. ' · cards ' . $on_off(billingStripeProvider()),
|
||||
'mail' => 'Sending ' . ($config_smtp_provider ? 'on' : '<span class="text-danger-emphasis">off</span>') . ' · receiving ' . $on_off($config_imap_provider)
|
||||
|
||||
@@ -88,7 +88,7 @@ echo settingsPageStart('default');
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_transfer_from_account', intval($config_default_transfer_from_account), $accounts, ['icon' => 'fa-sign-out-alt', 'search' => true]) ?></div>
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_transfer_to_account', intval($config_default_transfer_to_account), $accounts, ['icon' => 'fa-sign-in-alt', 'search' => true]) ?></div>
|
||||
</div>
|
||||
<div class="form-text mt-2">Accounts are in <a href="/agent/accounts.php">Accounts</a>, payment methods in <a href="payment_methods.php">Payment methods</a>.</div>
|
||||
<div class="form-text mt-2"><?php if (moduleOn('bookkeeping')) { ?>Accounts are in <a href="/agent/accounts.php">Accounts</a>, payment methods in <a href="payment_methods.php">Payment methods</a>.<?php } else { ?>With Bookkeeping off, payments go into the default payment account and expenses come out of the default expense account. Payment methods are in <a href="payment_methods.php">Payment methods</a>.<?php } ?></div>
|
||||
<?= settingsSectionEnd() ?>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
/*
|
||||
* Admin > Settings > Modules - the parts of ITFlow in use: IT documentation,
|
||||
* ticketing, invoicing and the client portal, each switched off hiding it
|
||||
* (nothing is deleted); and white-labelling the client portal with a key.
|
||||
* ticketing with Dispatch, invoicing with Bookkeeping, Purchasing and Trips,
|
||||
* the calendar and the client portal, each switched off hiding it (nothing is
|
||||
* deleted; moduleOn() in functions/settings.php); and white-labelling the
|
||||
* client portal with a key.
|
||||
* Saved by edit_module_settings (admin/post/settings_module.php).
|
||||
*/
|
||||
|
||||
@@ -17,12 +19,22 @@ $whitelabel_expires = $whitelabel ? strtotime((string) $whitelabel['expires']) :
|
||||
// A managed instance whose manager sets the key - shown, not changed here (functions/managed.php)
|
||||
$whitelabel_managed = managedLocks()['white_label'];
|
||||
|
||||
// Each: whether it's on, its icon, what it holds, and the switch of the module it comes with - shown under that one, faded while it's off
|
||||
$modules = [
|
||||
'config_module_enable_itdoc' => [$config_module_enable_itdoc, 'fa-laptop', 'A client\'s assets, credentials, documents, networks, domains, certificates and the rest of their IT documentation.'],
|
||||
'config_module_enable_ticketing' => [$config_module_enable_ticketing, 'fa-life-ring', 'Tickets, recurring tickets and projects - and their settings.'],
|
||||
'config_module_enable_accounting' => [$config_module_enable_accounting, 'fa-file-invoice-dollar', 'Quotes, invoices, payments, expenses, accounts and the money reports - and their settings.'],
|
||||
'config_client_portal_enable' => [$config_client_portal_enable, 'fa-user-shield', 'Where your clients\' contacts sign in to raise tickets, see their invoices and pay.'],
|
||||
'config_module_enable_itdoc' => [$config_module_enable_itdoc, 'fa-laptop', 'A client\'s assets, credentials, documents, networks, domains, certificates and the rest of their IT documentation.', ''],
|
||||
'config_module_enable_ticketing' => [$config_module_enable_ticketing, 'fa-life-ring', 'Tickets, recurring tickets and projects - and their settings.', ''],
|
||||
'config_module_enable_dispatch' => [$config_module_enable_dispatch ?? 1, 'fa-people-arrows', 'The Dispatch board - each technician\'s booked work side by side, and the tickets waiting for a time.', 'config_module_enable_ticketing'],
|
||||
'config_module_enable_accounting' => [$config_module_enable_accounting, 'fa-file-invoice-dollar', 'Quotes, invoices, payments, expenses and the money reports - and their settings.', ''],
|
||||
'config_module_enable_bookkeeping' => [$config_module_enable_bookkeeping ?? 1, 'fa-piggy-bank', 'Accounts and their balances, transactions and transfers, reconciling statements and importing them. Off, payments and expenses go into and out of your default accounts without asking - for when your books are kept somewhere else.', 'config_module_enable_accounting'],
|
||||
'config_module_enable_purchasing' => [$config_module_enable_purchasing ?? 0, 'fa-truck-loading', 'To Order, purchase orders to your vendors, and receiving into stock or client assets.', 'config_module_enable_accounting'],
|
||||
'config_module_enable_trips' => [$config_module_enable_trips ?? 1, 'fa-route', 'Trips and mileage - logged, billed to clients and claimed back.', 'config_module_enable_accounting'],
|
||||
'config_module_enable_calendar' => [$config_module_enable_calendar ?? 1, 'fa-calendar-alt', 'The calendar, its events and the calendar feeds. Tickets are still booked, and show on Dispatch.', ''],
|
||||
'config_client_portal_enable' => [$config_client_portal_enable, 'fa-user-shield', 'Where your clients\' contacts sign in to raise tickets, see their invoices and pay.', ''],
|
||||
];
|
||||
// Before database 3.9.4 adds them, only the first four are there to switch
|
||||
if (!isset($config_module_enable_calendar)) {
|
||||
$modules = array_intersect_key($modules, array_flip(['config_module_enable_itdoc', 'config_module_enable_ticketing', 'config_module_enable_accounting', 'config_client_portal_enable']));
|
||||
}
|
||||
|
||||
echo settingsPageStart('module');
|
||||
|
||||
@@ -35,11 +47,11 @@ echo settingsPageStart('module');
|
||||
<div class="card-body">
|
||||
|
||||
<?= settingsSectionStart('modules', 'Modules', 'Switching one off takes it out of the menus for everyone. Nothing in it is deleted - switched back on, it is all there.') ?>
|
||||
<?php foreach ($modules as $name => [$on, $icon, $about]) { ?>
|
||||
<div class="itflow-settings-module d-flex gap-3 align-items-start">
|
||||
<?php foreach ($modules as $name => [$on, $icon, $about, $comes_with]) { ?>
|
||||
<div class="itflow-settings-module d-flex gap-3 align-items-start<?= $comes_with ? ' itflow-settings-module-part' : '' ?>"<?= $comes_with ? ' data-settings-depends-on="' . $comes_with . '"' : '' ?>>
|
||||
<span class="itflow-settings-tile-icon"><i class="fas fa-fw <?= $icon ?>"></i></span>
|
||||
<div class="flex-grow-1 min-w-0">
|
||||
<?= settingsSwitch($name, $on, ['help' => $about]) ?>
|
||||
<?= settingsSwitch($name, $on, ['help' => $about . ($comes_with ? ' Comes with ' . ($comes_with === 'config_module_enable_ticketing' ? 'Ticketing' : 'Invoicing and accounting') . ' - off while it is.' : '')]) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
Reference in New Issue
Block a user