mirror of
https://github.com/itflow-org/itflow
synced 2026-11-18 10:27:25 +00:00
Settings stage 2: move Tickets, Projects, Quotes, Invoices and billing and Defaults onto the settings frame with sections and live next-number previews that refuse a number already in use, validate email addresses instead of blanking them, check the ticket close time and stop its PHP warnings, warn when late fees are on but reminders are off, limit the start page to real ITFlow pages and escape it where shown, keep archived default accounts, rename the Defaults fields to their columns, and keep the reminder, billing time, expense and mileage anchors
This commit is contained in:
@@ -1,228 +1,95 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Admin > Settings > Defaults - the page ITFlow opens on, the calendar new
|
||||
* events go on, what a new client starts with, and - with accounting on - the
|
||||
* accounts and payment methods payments, expenses and transfers start with.
|
||||
* Each is what a form starts with; it can be changed there. Saved by
|
||||
* edit_default_settings (admin/post/settings_default.php).
|
||||
*/
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
$start_page_select_array = array (
|
||||
'dashboard.php'=>'Dashboard',
|
||||
'clients.php'=> 'Client Management',
|
||||
'tickets.php'=> 'Support Tickets',
|
||||
'invoices.php' => 'Invoices'
|
||||
);
|
||||
// The start page - the usual ones, and the one saved should it be another
|
||||
$start_pages = settingsStartPages();
|
||||
if ((string) $config_start_page !== '' && !isset($start_pages[$config_start_page])) {
|
||||
$start_pages[$config_start_page] = $config_start_page;
|
||||
}
|
||||
$kept_start_page = (string) settingsValue('config_start_page', $config_start_page);
|
||||
if ($kept_start_page !== '' && !isset($start_pages[$kept_start_page])) {
|
||||
$start_pages[$kept_start_page] = $kept_start_page;
|
||||
}
|
||||
|
||||
$net_terms_array = array (
|
||||
'0'=>'On Receipt',
|
||||
'7'=>'7 Days',
|
||||
'10'=>'10 Days',
|
||||
'15'=>'15 Days',
|
||||
'30'=>'30 Days',
|
||||
'45'=>'45 Days',
|
||||
'60'=>'60 Days',
|
||||
'90'=>'90 Days'
|
||||
);
|
||||
$calendars = [0 => '- None -'];
|
||||
$sql = mysqli_query($mysqli, "SELECT calendar_id, calendar_name FROM calendars ORDER BY calendar_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$calendars[intval($row['calendar_id'])] = $row['calendar_name'];
|
||||
}
|
||||
|
||||
// Accounts in use, and any saved one since archived - so saving doesn't lose it
|
||||
$saved_accounts = array_map('intval', [$config_default_payment_account, $config_default_expense_account, $config_default_transfer_from_account, $config_default_transfer_to_account]);
|
||||
$accounts = [0 => '- None -'];
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name, account_archived_at FROM accounts
|
||||
WHERE account_archived_at IS NULL OR account_id IN (" . implode(',', $saved_accounts) . ") ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$accounts[intval($row['account_id'])] = $row['account_name'] . ($row['account_archived_at'] ? ' (archived)' : '');
|
||||
}
|
||||
|
||||
// Admin > Payment Methods - and a saved one, should it no longer be among them
|
||||
$methods = function ($saved) {
|
||||
$choices = ['' => '- None -'];
|
||||
foreach (paymentMethods() as $method) {
|
||||
$choices[$method] = $method;
|
||||
}
|
||||
if ((string) $saved !== '' && !isset($choices[(string) $saved])) {
|
||||
$choices[(string) $saved] = $saved;
|
||||
}
|
||||
return $choices;
|
||||
};
|
||||
|
||||
echo settingsPageStart('default');
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-cogs me-2"></i>Defaults</h3>
|
||||
<form action="post.php" method="post" autocomplete="off" data-settings-form>
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="card itflow-settings-card">
|
||||
<div class="card-body">
|
||||
|
||||
<?= settingsSectionStart('opening', 'Opening ITFlow', 'Where everyone lands on signing in or clicking the logo, and the calendar a new event goes on.') ?>
|
||||
<?= settingsSelect('config_start_page', $config_start_page, $start_pages, ['icon' => 'fa-home', 'search' => true, 'required' => true, 'data' => ['tags' => 'true'],
|
||||
'help' => 'Or type another page, as it is after /agent/ in its address - tickets.php?status=Open.']) ?>
|
||||
<?= settingsSelect('config_default_calendar', intval($config_default_calendar), $calendars, ['icon' => 'fa-calendar']) ?>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?= settingsSectionStart('clients', 'New clients', 'What a new client starts with - each can have its own, on its Billing tab.') ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_net_terms', intval($config_default_net_terms), settingsNetTerms(), ['icon' => 'fa-calendar-check',
|
||||
'help' => 'When an invoice is due.']) ?></div>
|
||||
<div class="col-md-6"><?= settingsInput('config_default_hourly_rate', number_format(floatval($config_default_hourly_rate), 2, '.', ''), ['icon' => 'fa-clock', 'inputmode' => 'decimal',
|
||||
'placeholder' => '0.00', 'suffix' => escapeHtml($session_company_currency) . ' an hour', 'help' => 'And what time bills at for a client with none of its own.']) ?></div>
|
||||
</div>
|
||||
<?= settingsSectionEnd() ?>
|
||||
|
||||
<?php if ($config_module_enable_accounting) { ?>
|
||||
<?= settingsSectionStart('accounts', 'Accounts', 'The account and payment method a payment, an expense or a transfer starts with.') ?>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_payment_account', intval($config_default_payment_account), $accounts, ['icon' => 'fa-piggy-bank', 'search' => true]) ?></div>
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_payment_method', (string) $config_default_payment_method, $methods($config_default_payment_method), ['icon' => 'fa-credit-card', 'search' => true]) ?></div>
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_expense_account', intval($config_default_expense_account), $accounts, ['icon' => 'fa-shopping-cart', 'search' => true]) ?></div>
|
||||
<div class="col-md-6"><?= settingsSelect('config_default_expense_payment_method', (string) $config_default_expense_payment_method, $methods($config_default_expense_payment_method), ['icon' => 'fa-credit-card', 'search' => true]) ?></div>
|
||||
<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>
|
||||
<?= settingsSectionEnd() ?>
|
||||
<?php } ?>
|
||||
|
||||
<?= settingsSaveBar('edit_default_settings') ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Start Page</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-home"></i></span>
|
||||
<select class="form-select select2" name="start_page" data-tags="true" required>
|
||||
<?php if (!in_array($config_start_page, array_keys($start_page_select_array))) { ?>
|
||||
<option selected> <?= escapeHtml($config_start_page) ?></option>
|
||||
<?php } ?>
|
||||
<?php foreach ($start_page_select_array as $start_page_value => $start_page_name) { ?>
|
||||
<option <?php if ($start_page_value == $config_start_page) { echo "selected"; } ?>
|
||||
value="<?= escapeHtml($start_page_value) ?>">
|
||||
<?= escapeHtml($start_page_name) ?>
|
||||
</option>
|
||||
<?php }?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Calendar</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
<select class="form-select select2" name="calendar">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT calendar_id, calendar_name FROM calendars ORDER BY calendar_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$calendar_id = intval($row['calendar_id']);
|
||||
$calendar_name = escapeHtml($row['calendar_name']); ?>
|
||||
<option <?php if ($config_default_calendar == $calendar_id) {
|
||||
echo "selected";
|
||||
} ?> value="<?= $calendar_id ?>"><?= $calendar_name ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Transfer From Account</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-exchange-alt"></i></span>
|
||||
<select class="form-select select2" name="transfer_from_account">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
<option <?php if ($config_default_transfer_from_account == $account_id) {
|
||||
echo "selected";
|
||||
} ?> value="<?= $account_id ?>"><?= $account_name ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Transfer To Account</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-exchange-alt"></i></span>
|
||||
<select class="form-select select2" name="transfer_to_account">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
<option <?php if ($config_default_transfer_to_account == $account_id) {
|
||||
echo "selected";
|
||||
} ?> value="<?= $account_id ?>"><?= $account_name ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Payment Account</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-credit-card"></i></span>
|
||||
<select class="form-select select2" name="payment_account">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
<option <?php if ($config_default_payment_account == $account_id) {
|
||||
echo "selected";
|
||||
} ?> value="<?= $account_id ?>"><?= $account_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Expense Account</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-shopping-cart"></i></span>
|
||||
<select class="form-select select2" name="expense_account">
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
<option <?php if ($config_default_expense_account == $account_id) {
|
||||
echo "selected";
|
||||
} ?> value="<?= $account_id ?>"><?= $account_name ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Payment Method</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-credit-card"></i></span>
|
||||
<select class="form-select select2" name="payment_method">
|
||||
<option value="">- None -</option>
|
||||
<?php
|
||||
// Admin > Payment Methods - and the saved one, should it no longer be among them
|
||||
$default_methods = paymentMethods();
|
||||
if ((string) $config_default_payment_method !== '' && !in_array((string) $config_default_payment_method, $default_methods, true)) {
|
||||
$default_methods[] = (string) $config_default_payment_method;
|
||||
}
|
||||
foreach ($default_methods as $payment_method) { ?>
|
||||
<option <?= (string) $config_default_payment_method === $payment_method ? 'selected' : '' ?> value="<?= escapeHtml($payment_method) ?>"><?= escapeHtml($payment_method) ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Expense Payment Method</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-credit-card"></i></span>
|
||||
<select class="form-select select2" name="expense_payment_method">
|
||||
<option value="">- None -</option>
|
||||
<?php
|
||||
// Admin > Payment Methods - and the saved one, should it no longer be among them
|
||||
$default_methods = paymentMethods();
|
||||
if ((string) $config_default_expense_payment_method !== '' && !in_array((string) $config_default_expense_payment_method, $default_methods, true)) {
|
||||
$default_methods[] = (string) $config_default_expense_payment_method;
|
||||
}
|
||||
foreach ($default_methods as $payment_method) { ?>
|
||||
<option <?= (string) $config_default_expense_payment_method === $payment_method ? 'selected' : '' ?> value="<?= escapeHtml($payment_method) ?>"><?= escapeHtml($payment_method) ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Net Terms</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
<select class="form-select select2" name="net_terms">
|
||||
<?php foreach ($net_terms_array as $net_term_value => $net_term_name) { ?>
|
||||
<option <?php if ($config_default_net_terms == $net_term_value) {
|
||||
echo "selected";
|
||||
} ?> value="<?= $net_term_value ?>"><?= $net_term_name ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Client Hourly Rate</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,2}" name="hourly_rate" value="<?= number_format($config_default_hourly_rate, 2, '.', '') ?>" placeholder="0.00" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<button type="submit" name="edit_default_settings" class="btn btn-primary text-bold"><i class="fa fa-check me-2"></i>Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
|
||||
Reference in New Issue
Block a user