Split the long windows into tabs: New Ticket gets a Planning tab for its due date, starting status, schedule, tags and billing; a product or service has Details, Billing, Ordering and Asset; a service has Service, Recovery and notes, and Depends on; an event has When, and Who and where; an expense has Expense, and Client and receipt; in Admin a payment provider has Keys, Payments and Card fee, an RMM provider or network platform Connection, Alerts and Asset types, an identity provider Setup, Who it signs in and The app, and a ticket status Details and What it does; a payment or RMM provider check that finds something wrong opens that field's tab; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-30 00:14:40 -05:00
parent 024220e94d
commit 285aae13b4
11 changed files with 1415 additions and 1183 deletions

View File

@@ -37,6 +37,8 @@ Update from Maintenance > Update as usual - this release has four database chang
- Printing a ticket prints a work order instead of the page as it looks on screen: your letterhead, the client and contact, the site with its access notes, the job's details, its assets, the description, the fill-ins the client can see, the tasks as boxes to tick, the public replies oldest first, and a sign-off with arrival and departure times, lines for the work done and signatures. Internal notes never print. It's Print Work Order in the ticket's menu, or the browser's own print.
- Printing an asset prints a spec sheet: its hardware, network, where it is and who has it, its interfaces, the devices in it, its licenses and services and its quick notes, with a QR code that opens it in ITFlow. Credentials and license keys never print. The new print button sits beside Copy Details.
- Writing a document in the client portal works as it does for you: the editor shows it as it will read, with headings, lists, quotes, code, tables and lines on its toolbar, or contacts can write it in Markdown, with the Markdown toolbar and Preview, switching either way as they write. The next document starts in the way they wrote last.
- Long windows are split into tabs, so they are shorter. New Ticket has a Planning tab for the due date, the status it starts in, the work booked, tags and billing, leaving who it is for and what it is about on Details. A product or service has Details, Billing, Ordering and, for a product, Asset. A service has Service, Recovery & notes and, when it is new, Depends on. An event has When and Who & where. An expense has Expense, and Client & receipt. In Admin, a payment provider has Keys, Payments and Card fee, an RMM provider or network platform Connection, Alerts and Asset types, an identity provider Setup, Who it signs in and The app (or The mail server), and a ticket status Details and What it does.
- When the check on saving a payment provider or an RMM provider finds something wrong, the window opens the tab that field is on, so the message is next to it. A required field left empty on a hidden tab already opened its tab.
### Bug Fixes
@@ -77,6 +79,7 @@ Update from Maintenance > Update as usual - this release has four database chang
- functions/print_sheet.php draws the work order (ticketWorkOrderHtml()) and spec sheet (assetSpecSheetHtml()) into their pages, hidden on screen; css .itflow-print-sheet hides the rest of the page when printing (the .container-fluid:has() rule). [data-print-page] buttons call window.print() (js/app.js). The ticket's actions bar and menu now show for every agent.
- includes/document_editors.php is a document's two editors and the switch between them, shared by agent/modals/document/document_form.php and client/document_add.php (which now posts format, content and markdown, saved through documentPostedContent()). js/document_markdown.js converts at the address its script tag gives (data-markdown-url, client/post.php markdown_to_html and html_to_markdown in the portal). itflowProseContentStyle() moved to js/tinymce_defaults.js; js/portal.js sets up .tinymce-document, and its required check looks in the Markdown box when that is shown.
- agent/includes/inc_all_client.php: without a client_id, or with one that isn't there, it draws That client isn't here in the agent layout and exits, before anything queries with no client - it was an SQL error (or a tagPills() TypeError) and a blank page. admin/modules.php and its commented-out menu entry are removed.
- Tabs in agent/modals/product/product_form.php, service/service_form.php, calendar/calendar_event_form.php, expense/expense_form.php and ticket/ticket_add.php, and in admin/modals/payment_provider/payment_provider_edit.php, rmm/rmm_provider_edit.php, identity_provider/identity_provider_edit.php and ticket_status/ticket_status_form.php - the same field names, so the posts and their handlers are unchanged. js/app.js has window.itflowRevealTab(field), used by the invalid-field handler and by the provider windows' server-check errors, to open the tab a field is on.
## [26.12.2]

View File

@@ -3,7 +3,8 @@
/*
* Admin > Identity Providers - one identity provider's window: Add (?kind=, no id) or Edit (?id=).
* Which kind it is is picked from the New menu and stays. How to set it up on the provider's side
* is at the top, with the redirect address to register there. The secret is never put back into
* is on its first tab, with the redirect address to register there; then Who it signs in, and the
* app (or the mail server). The secret is never put back into
* the page - left empty, it stays as saved. Saved by save_identity_provider
* (admin/post/identity_provider.php).
*/
@@ -51,174 +52,193 @@ ob_start();
<div class="modal-body">
<div class="alert alert-light border small mb-3" data-identity-provider-setup>
<div class="fw-semibold mb-1"><i class="fas fa-fw fa-info-circle me-1"></i>Setting it up</div>
<?php if ($kind_key === 'microsoft') { ?>
In the Microsoft Entra admin center, under App registrations, make a New registration for accounts in any organizational directory (or only yours), with a Web redirect address of the one below. Copy its Application (client) ID here, then under Certificates &amp; secrets make a client secret and copy its Value. The Microsoft Graph User.Read permission it starts with is all it needs.
<?php } elseif ($kind_key === 'google') { ?>
In the Google Cloud console, under APIs &amp; Services &gt; Credentials, create an OAuth client ID for a Web application, with an authorized redirect address of the one below, and copy its Client ID and Client secret here. Make its OAuth consent screen Internal to keep it to your own Google Workspace.
<?php } elseif ($kind_key === 'nextcloud') { ?>
Install the OIDC Identity Provider app (oidc) on your Nextcloud. In its Administration settings, under OpenID Connect, add a client with the redirect address below, of the Confidential type, and copy its client identifier and secret here.
<div class="mt-1"><i class="fas fa-fw fa-exclamation-triangle text-warning me-1"></i>ITFlow goes by the email address Nextcloud gives - make sure its users can't change their own, or one of them could sign in here as another.</div>
<?php } else { ?>
Nothing is set up on the mail server: the password typed on the sign-in page is tried there, in place of the ITFlow password, and the ITFlow two-step code is still asked for. An agent with an administrator role can still use their ITFlow password, for when the mail server is down. Use a server that takes TLS, and list only domains whose mailboxes are on it.
<?php } ?>
<?php if ($kind['oauth']) { ?>
<div class="input-group input-group-sm mt-2">
<span class="input-group-text"><i class="fas fa-fw fa-link"></i></span>
<input type="text" class="form-control font-monospace" id="<?= $form_id ?>Redirect" value="<?= escapeHtml($redirect_uri) ?>" readonly aria-label="Redirect address" data-identity-provider-redirect>
<button type="button" class="btn btn-outline-secondary clipboardjs" data-clipboard-target="#<?= $form_id ?>Redirect" title="Copy"><i class="far fa-fw fa-copy"></i></button>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#<?= $form_id ?>SetupTab"><i class="fas fa-fw fa-info-circle me-2 d-none d-lg-inline"></i>Setup</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_id ?>WhoTab"><i class="fas fa-fw fa-users me-2 d-none d-lg-inline"></i>Who it signs in</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_id ?>AppTab"><i class="fas fa-fw <?= $kind['oauth'] ? 'fa-th-large' : 'fa-server' ?> me-2 d-none d-lg-inline"></i><?= $kind['oauth'] ? 'The app' : 'The mail server' ?></a>
</li>
</ul>
<div class="tab-content">
<!-- How to set it up on the provider's side, whether it is on, and its name -->
<div class="tab-pane fade show active" id="<?= $form_id ?>SetupTab">
<div class="alert alert-light border small mb-3" data-identity-provider-setup>
<?php if ($kind_key === 'microsoft') { ?>
In the Microsoft Entra admin center, under App registrations, make a New registration for accounts in any organizational directory (or only yours), with a Web redirect address of the one below. Copy its Application (client) ID here, then under Certificates &amp; secrets make a client secret and copy its Value. The Microsoft Graph User.Read permission it starts with is all it needs.
<?php } elseif ($kind_key === 'google') { ?>
In the Google Cloud console, under APIs &amp; Services &gt; Credentials, create an OAuth client ID for a Web application, with an authorized redirect address of the one below, and copy its Client ID and Client secret here. Make its OAuth consent screen Internal to keep it to your own Google Workspace.
<?php } elseif ($kind_key === 'nextcloud') { ?>
Install the OIDC Identity Provider app (oidc) on your Nextcloud. In its Administration settings, under OpenID Connect, add a client with the redirect address below, of the Confidential type, and copy its client identifier and secret here.
<div class="mt-1"><i class="fas fa-fw fa-exclamation-triangle text-warning me-1"></i>ITFlow goes by the email address Nextcloud gives - make sure its users can't change their own, or one of them could sign in here as another.</div>
<?php } else { ?>
Nothing is set up on the mail server: the password typed on the sign-in page is tried there, in place of the ITFlow password, and the ITFlow two-step code is still asked for. An agent with an administrator role can still use their ITFlow password, for when the mail server is down. Use a server that takes TLS, and list only domains whose mailboxes are on it.
<?php } ?>
<?php if ($kind['oauth']) { ?>
<div class="input-group input-group-sm mt-2">
<span class="input-group-text"><i class="fas fa-fw fa-link"></i></span>
<input type="text" class="form-control font-monospace" id="<?= $form_id ?>Redirect" value="<?= escapeHtml($redirect_uri) ?>" readonly aria-label="Redirect address" data-identity-provider-redirect>
<button type="button" class="btn btn-outline-secondary clipboardjs" data-clipboard-target="#<?= $form_id ?>Redirect" title="Copy"><i class="far fa-fw fa-copy"></i></button>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="enabled" value="1" id="<?= $form_id ?>Enabled" <?= !$row || intval($row['identity_provider_enabled']) ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Enabled">On<?= $kind['oauth'] ? ' - its button is on the sign-in page' : ' - it checks the passwords on its email domains' ?></label>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Name">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" id="<?= $form_id ?>Name" maxlength="100" required value="<?= escapeHtml($value('name', $kind['name'])) ?>" placeholder="What you call it">
</div>
<div class="form-text"><?= $kind['oauth'] ? 'Its button on the sign-in page says &quot;Sign in with&quot; and this name.' : 'What the audit log calls it.' ?></div>
</div>
<div class="itflow-form-section">Who it signs in</div>
<div class="mb-3">
<div class="d-flex flex-wrap gap-4">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="agents" value="1" id="<?= $form_id ?>Agents" <?= $value('agents', '1') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Agents"><i class="fas fa-fw fa-user-tie text-secondary me-1"></i>Agents</label>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="enabled" value="1" id="<?= $form_id ?>Enabled" <?= !$row || intval($row['identity_provider_enabled']) ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Enabled">On<?= $kind['oauth'] ? ' - its button is on the sign-in page' : ' - it checks the passwords on its email domains' ?></label>
</div>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="contacts" value="1" id="<?= $form_id ?>Contacts" <?= $value('contacts', '0') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Contacts"><i class="fas fa-fw fa-user-friends text-secondary me-1"></i>Client contacts</label>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Name">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" id="<?= $form_id ?>Name" maxlength="100" required value="<?= escapeHtml($value('name', $kind['name'])) ?>" placeholder="What you call it">
</div>
<div class="form-text"><?= $kind['oauth'] ? 'Its button on the sign-in page says &quot;Sign in with&quot; and this name.' : 'What the audit log calls it.' ?></div>
</div>
</div>
<div class="form-text">
Only accounts already in ITFlow - an agent, or a contact with portal access - with the same email address. No one new is added.
<?php if (!$config_client_portal_enable) { ?>The client portal is off, so it signs in agents only until it is on.<?php } ?>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Domains">Email domains<?= $kind['domains_optional'] ? '' : ' <strong class="text-danger">*</strong>' ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-at"></i></span>
<input type="text" class="form-control" name="domains" id="<?= $form_id ?>Domains" maxlength="1000" spellcheck="false" <?= $kind['domains_optional'] ? '' : 'required' ?> value="<?= escapeHtml($value('domains')) ?>" placeholder="example.com, example.org">
</div>
<div class="form-text">
<?php if ($kind['domains_optional']) { ?>
The accounts it signs in are the ones on these domains. Empty, it signs in any <?= escapeHtml($kind['name']) ?> account whose address is in ITFlow - <?= escapeHtml($kind_key === 'microsoft' ? 'Microsoft' : 'Google') ?> vouches for it.
<?php } else { ?>
The accounts it signs in are the ones on these domains - <?= $kind_key === 'imap' ? 'list only domains whose mailboxes are all on this server.' : 'a Nextcloud\'s users can set their own email address, so list only domains whose people are all on yours.' ?>
<!-- Agents and/or contacts, on which email domains, and whether it is the only way in -->
<div class="tab-pane fade" id="<?= $form_id ?>WhoTab">
<div class="mb-3">
<div class="d-flex flex-wrap gap-4">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="agents" value="1" id="<?= $form_id ?>Agents" <?= $value('agents', '1') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Agents"><i class="fas fa-fw fa-user-tie text-secondary me-1"></i>Agents</label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="contacts" value="1" id="<?= $form_id ?>Contacts" <?= $value('contacts', '0') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Contacts"><i class="fas fa-fw fa-user-friends text-secondary me-1"></i>Client contacts</label>
</div>
</div>
<div class="form-text">
Only accounts already in ITFlow - an agent, or a contact with portal access - with the same email address. No one new is added.
<?php if (!$config_client_portal_enable) { ?>The client portal is off, so it signs in agents only until it is on.<?php } ?>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Domains">Email domains<?= $kind['domains_optional'] ? '' : ' <strong class="text-danger">*</strong>' ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-at"></i></span>
<input type="text" class="form-control" name="domains" id="<?= $form_id ?>Domains" maxlength="1000" spellcheck="false" <?= $kind['domains_optional'] ? '' : 'required' ?> value="<?= escapeHtml($value('domains')) ?>" placeholder="example.com, example.org">
</div>
<div class="form-text">
<?php if ($kind['domains_optional']) { ?>
The accounts it signs in are the ones on these domains. Empty, it signs in any <?= escapeHtml($kind['name']) ?> account whose address is in ITFlow - <?= escapeHtml($kind_key === 'microsoft' ? 'Microsoft' : 'Google') ?> vouches for it.
<?php } else { ?>
The accounts it signs in are the ones on these domains - <?= $kind_key === 'imap' ? 'list only domains whose mailboxes are all on this server.' : 'a Nextcloud\'s users can set their own email address, so list only domains whose people are all on yours.' ?>
<?php } ?>
</div>
</div>
<?php if ($kind['oauth']) { ?>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="required" value="1" id="<?= $form_id ?>Required" <?= $value('required', '0') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Required">Required - the accounts on its email domains can't sign in with a password</label>
</div>
<div class="form-text ps-5">Passkeys still work, and an agent with an administrator role keeps their password, to get back in when it is down. Needs email domains.</div>
</div>
<?php } ?>
</div>
<!-- The app registered at the provider, or the mail server it asks -->
<div class="tab-pane fade" id="<?= $form_id ?>AppTab">
<?php if ($kind_key === 'nextcloud') { ?>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Url">Address <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-globe"></i></span>
<input type="url" class="form-control" name="url" id="<?= $form_id ?>Url" maxlength="500" spellcheck="false" required value="<?= escapeHtml($value('url')) ?>" placeholder="https://cloud.example.com">
</div>
<div class="form-text">Where your Nextcloud is. ITFlow asks it for its OpenID Connect settings when you save.</div>
</div>
<?php } ?>
<?php if (in_array('client_id', $fields, true)) { ?>
<div class="row g-3 mb-3">
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>ClientId"><?= $kind_key === 'microsoft' ? 'Application (client) ID' : 'Client ID' ?> <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-fingerprint"></i></span>
<input type="text" class="form-control font-monospace" name="client_id" id="<?= $form_id ?>ClientId" maxlength="255" spellcheck="false" required value="<?= escapeHtml($value('client_id')) ?>"
placeholder="<?= $kind_key === 'microsoft' ? 'e721e3b6-01d6-50e8-7f22-c84d951a52e7' : ($kind_key === 'google' ? '…apps.googleusercontent.com' : 'From its client') ?>">
</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Secret">Client secret <?= $secret_saved ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-key"></i></span>
<input type="password" class="form-control" name="client_secret" id="<?= $form_id ?>Secret" maxlength="1000" autocomplete="new-password" <?= $secret_saved ? '' : 'required' ?>
placeholder="<?= $secret_saved ? 'Saved - type a new one to replace it' : ($kind_key === 'microsoft' ? 'Its Value, not its ID' : 'From its client') ?>">
</div>
<?php if ($kind_key === 'microsoft') { ?><div class="form-text">A secret runs out - put the new one here before it does.</div><?php } ?>
</div>
</div>
<?php } ?>
<?php if (in_array('tenant', $fields, true)) { ?>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Tenant">Directory (tenant) ID</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<input type="text" class="form-control font-monospace" name="tenant" id="<?= $form_id ?>Tenant" maxlength="100" spellcheck="false" value="<?= escapeHtml($value('tenant')) ?>" placeholder="Any organization">
</div>
<div class="form-text">Only for an app registered for your directory alone - its ID, from the app's Overview. Empty takes work accounts from any organization; personal Microsoft accounts never sign in.</div>
</div>
<?php } ?>
<?php if ($kind_key === 'imap') { ?>
<div class="row g-3 mb-3">
<div class="col-md-8">
<label class="form-label" for="<?= $form_id ?>Host">Server <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-server"></i></span>
<input type="text" class="form-control" name="url" id="<?= $form_id ?>Host" maxlength="255" spellcheck="false" required value="<?= escapeHtml($value('url')) ?>" placeholder="mail.example.com">
</div>
</div>
<div class="col-md-4">
<label class="form-label" for="<?= $form_id ?>Port">Port</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-plug"></i></span>
<input type="number" class="form-control" name="port" id="<?= $form_id ?>Port" min="1" max="65535" value="<?= $row ? intval($row['identity_provider_port']) : '' ?>" placeholder="993">
</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Security">Security</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
<select class="form-select select2" name="security" id="<?= $form_id ?>Security">
<?php foreach (['ssl' => 'SSL/TLS', 'starttls' => 'STARTTLS', 'none' => 'None - the password goes unencrypted'] as $option => $label) { ?>
<option value="<?= $option ?>" <?= $security === $option ? 'selected' : '' ?><?= selectOptionData(['icon' => $option === 'none' ? 'fas fa-lock-open' : 'fas fa-lock']) ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
</div>
<div class="form-text">Empty port is 993 for SSL/TLS, 143 otherwise. Its certificate has to be a valid one.</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Username">It is signed in to with</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="username" id="<?= $form_id ?>Username">
<option value="email" <?= $value('username', 'email') !== 'local' ? 'selected' : '' ?><?= selectOptionData(['icon' => 'fas fa-at', 'description' => 'name@example.com']) ?>>The whole email address</option>
<option value="local" <?= $value('username') === 'local' ? 'selected' : '' ?><?= selectOptionData(['icon' => 'fas fa-user', 'description' => 'name']) ?>>The part before the @</option>
</select>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<?php if ($kind['oauth']) { ?>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="required" value="1" id="<?= $form_id ?>Required" <?= $value('required', '0') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Required">Required - the accounts on its email domains can't sign in with a password</label>
</div>
<div class="form-text ps-5">Passkeys still work, and an agent with an administrator role keeps their password, to get back in when it is down. Needs email domains.</div>
</div>
<?php } ?>
<div class="itflow-form-section"><?= $kind['oauth'] ? 'The app' : 'The mail server' ?></div>
<?php if ($kind_key === 'nextcloud') { ?>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Url">Address <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-globe"></i></span>
<input type="url" class="form-control" name="url" id="<?= $form_id ?>Url" maxlength="500" spellcheck="false" required value="<?= escapeHtml($value('url')) ?>" placeholder="https://cloud.example.com">
</div>
<div class="form-text">Where your Nextcloud is. ITFlow asks it for its OpenID Connect settings when you save.</div>
</div>
<?php } ?>
<?php if (in_array('client_id', $fields, true)) { ?>
<div class="row g-3 mb-3">
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>ClientId"><?= $kind_key === 'microsoft' ? 'Application (client) ID' : 'Client ID' ?> <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-fingerprint"></i></span>
<input type="text" class="form-control font-monospace" name="client_id" id="<?= $form_id ?>ClientId" maxlength="255" spellcheck="false" required value="<?= escapeHtml($value('client_id')) ?>"
placeholder="<?= $kind_key === 'microsoft' ? 'e721e3b6-01d6-50e8-7f22-c84d951a52e7' : ($kind_key === 'google' ? '…apps.googleusercontent.com' : 'From its client') ?>">
</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Secret">Client secret <?= $secret_saved ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-key"></i></span>
<input type="password" class="form-control" name="client_secret" id="<?= $form_id ?>Secret" maxlength="1000" autocomplete="new-password" <?= $secret_saved ? '' : 'required' ?>
placeholder="<?= $secret_saved ? 'Saved - type a new one to replace it' : ($kind_key === 'microsoft' ? 'Its Value, not its ID' : 'From its client') ?>">
</div>
<?php if ($kind_key === 'microsoft') { ?><div class="form-text">A secret runs out - put the new one here before it does.</div><?php } ?>
</div>
</div>
<?php } ?>
<?php if (in_array('tenant', $fields, true)) { ?>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Tenant">Directory (tenant) ID</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<input type="text" class="form-control font-monospace" name="tenant" id="<?= $form_id ?>Tenant" maxlength="100" spellcheck="false" value="<?= escapeHtml($value('tenant')) ?>" placeholder="Any organization">
</div>
<div class="form-text">Only for an app registered for your directory alone - its ID, from the app's Overview. Empty takes work accounts from any organization; personal Microsoft accounts never sign in.</div>
</div>
<?php } ?>
<?php if ($kind_key === 'imap') { ?>
<div class="row g-3 mb-3">
<div class="col-md-8">
<label class="form-label" for="<?= $form_id ?>Host">Server <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-server"></i></span>
<input type="text" class="form-control" name="url" id="<?= $form_id ?>Host" maxlength="255" spellcheck="false" required value="<?= escapeHtml($value('url')) ?>" placeholder="mail.example.com">
</div>
</div>
<div class="col-md-4">
<label class="form-label" for="<?= $form_id ?>Port">Port</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-plug"></i></span>
<input type="number" class="form-control" name="port" id="<?= $form_id ?>Port" min="1" max="65535" value="<?= $row ? intval($row['identity_provider_port']) : '' ?>" placeholder="993">
</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Security">Security</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
<select class="form-select select2" name="security" id="<?= $form_id ?>Security">
<?php foreach (['ssl' => 'SSL/TLS', 'starttls' => 'STARTTLS', 'none' => 'None - the password goes unencrypted'] as $option => $label) { ?>
<option value="<?= $option ?>" <?= $security === $option ? 'selected' : '' ?><?= selectOptionData(['icon' => $option === 'none' ? 'fas fa-lock-open' : 'fas fa-lock']) ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
</div>
<div class="form-text">Empty port is 993 for SSL/TLS, 143 otherwise. Its certificate has to be a valid one.</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Username">It is signed in to with</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="username" id="<?= $form_id ?>Username">
<option value="email" <?= $value('username', 'email') !== 'local' ? 'selected' : '' ?><?= selectOptionData(['icon' => 'fas fa-at', 'description' => 'name@example.com']) ?>>The whole email address</option>
<option value="local" <?= $value('username') === 'local' ? 'selected' : '' ?><?= selectOptionData(['icon' => 'fas fa-user', 'description' => 'name']) ?>>The part before the @</option>
</select>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="submit" name="save_identity_provider" class="btn btn-primary fw-bold"><i class="fas fa-check me-2"></i><?= $row ? 'Save' : 'Create' ?></button>

View File

@@ -5,9 +5,10 @@
* payment_provider_add.php) or Edit. Its keys - the secret one never put back
* into the page, so left empty it stays - whether it is on, the account its
* payments go into, the card limit, whether its fees are recorded as
* expenses, and whether clients pay a card fee to cover them. Save asks first (check_payment_provider,
* admin/post/payment_provider.php): what is wrong shows beside each field and
* the window stays open; once all is right, it saves.
* expenses, and whether clients pay a card fee to cover them - on its Keys,
* Payments and Card fee tabs. Save asks first (check_payment_provider,
* admin/post/payment_provider.php): what is wrong shows beside each field,
* its tab opened, and the window stays open; once all is right, it saves.
*/
require_once '../../includes/modal_header.php';
@@ -104,145 +105,166 @@ ob_start();
</div>
<?php } ?>
<div class="mb-3">
<label class="form-label" for="paymentProviderDescription">Description</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" id="paymentProviderDescription" maxlength="250" placeholder="What it is for, if you like" value="<?= escapeHtml($row['payment_provider_description'] ?? '') ?>">
</div>
<?= $error_for('description') ?>
</div>
<h6 class="fw-semibold mt-4 mb-1">Keys</h6>
<p class="small text-body-secondary mb-2">From <a href="<?= escapeHtml($kind['keys_url']) ?>" target="_blank" rel="noopener noreferrer"><?= escapeHtml($name) ?>'s Developers &gt; API keys <i class="fas fa-external-link-alt fa-xs"></i></a> - both live, or both test while you try it out.</p>
<div class="mb-3">
<label class="form-label" for="paymentProviderPublicKey">Publishable key <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-eye"></i></span>
<input type="text" class="form-control font-monospace" name="public_key" id="paymentProviderPublicKey" maxlength="250" spellcheck="false" placeholder="<?= escapeHtml($kind['public_example']) ?>" value="<?= escapeHtml($row['payment_provider_public_key'] ?? '') ?>">
</div>
<?= $error_for('public_key') ?>
</div>
<div class="mb-3">
<label class="form-label" for="paymentProviderSecretKey">Secret key <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-key"></i></span>
<input type="password" class="form-control font-monospace" name="private_key" id="paymentProviderSecretKey" maxlength="250" spellcheck="false" autocomplete="new-password"
placeholder="<?= $row && trim((string) $row['payment_provider_private_key']) !== '' ? 'Saved - type a new one to replace it' : escapeHtml($kind['secret_example']) ?>">
</div>
<?= $error_for('private_key') ?>
<div class="form-text">A restricted key (rk_...) does too, with write access to payment intents, customers, setup intents and payment methods, and read on the account.</div>
</div>
<div class="alert alert-success py-2 small d-none" data-provider-account></div>
<h6 class="fw-semibold mt-4 mb-2">Payments</h6>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#paymentProviderKeys"><i class="fas fa-fw fa-key me-2 d-none d-lg-inline"></i>Keys</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#paymentProviderPayments"><i class="fas fa-fw fa-piggy-bank me-2 d-none d-lg-inline"></i>Payments</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#paymentProviderCardFeeTab"><i class="fas fa-fw fa-percent me-2 d-none d-lg-inline"></i>Card fee</a>
</li>
</ul>
<?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">
<span class="input-group-text"><i class="fas fa-fw fa-piggy-bank"></i></span>
<select class="form-select select2" name="account" id="paymentProviderAccount">
<option value="">- Select an account -</option>
<?php while ($account = mysqli_fetch_assoc($accounts)) { ?>
<option value="<?= intval($account['account_id']) ?>" <?= intval($account['account_id']) === $account_id ? 'selected' : '' ?>><?= escapeHtml($account['account_name']) ?><?= $account['account_archived_at'] ? ' (archived)' : '' ?></option>
<?php } ?>
</select>
</div>
<?= $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="tab-content">
<div class="mb-3">
<label class="form-label" for="paymentProviderThreshold">Card limit</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-shopping-cart"></i></span>
<input type="text" class="form-control" name="threshold" id="paymentProviderThreshold" inputmode="decimal" maxlength="16" placeholder="No limit" value="<?= $threshold > 0 ? escapeHtml(number_format($threshold, 2, '.', '')) : '' ?>">
<?php if ($currency !== '') { ?><span class="input-group-text"><?= escapeHtml($currency) ?></span><?php } ?>
</div>
<?= $error_for('threshold') ?>
<div class="form-text">An invoice of this much or more can't be paid by card. Empty for no limit.</div>
</div>
<h6 class="fw-semibold mt-4 mb-2">Fees</h6>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="record_fees" value="1" id="paymentProviderRecordFees" <?= $records_fees ? 'checked' : '' ?> data-provider-fees-switch>
<label class="form-check-label" for="paymentProviderRecordFees">Record its fees as expenses</label>
</div>
<div class="form-text ps-5">Its fee on each card payment is recorded as an expense from the account above, a few minutes after Stripe settles the payment.</div>
</div>
<div data-provider-fees>
<div class="mb-3">
<label class="form-label" for="paymentProviderVendor">Paid to <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="expense_vendor" id="paymentProviderVendor">
<option value="">- Select a vendor -</option>
<?php while ($vendor = mysqli_fetch_assoc($vendors)) { ?>
<option value="<?= intval($vendor['vendor_id']) ?>" <?= intval($vendor['vendor_id']) === $vendor_id ? 'selected' : '' ?>><?= escapeHtml($vendor['vendor_name']) ?><?= $vendor['vendor_archived_at'] ? ' (archived)' : '' ?></option>
<?php } ?>
</select>
</div>
<?= $error_for('expense_vendor') ?>
<div class="form-text">One of your own vendors - <?= escapeHtml($name) ?> itself.</div>
</div>
<div class="mb-3">
<label class="form-label" for="paymentProviderCategory">Category <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-list"></i></span>
<select class="form-select select2" name="expense_category" id="paymentProviderCategory">
<option value="">- Select a category -</option>
<?= categoryOptionsHtml('Expense', $category_id ?: null) ?>
</select>
<?= categoryAddButtonHtml('Expense') ?>
</div>
<?= $error_for('expense_category') ?>
<div class="form-text">Processing Fee, or the like.</div>
</div>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="card_fee" value="1" id="paymentProviderCardFee" <?= $card_fee ? 'checked' : '' ?> data-provider-card-fee-switch>
<label class="form-check-label" for="paymentProviderCardFee">Clients pay the card fee</label>
</div>
<div class="form-text ps-5">Each card payment is made bigger by what <?= escapeHtml($name) ?> takes of it, so you get what the invoice is for. The fee goes on the invoice as a Card Fee line, and clients see it before they pay - in the client portal, through an invoice's link, by autopay, or when you charge a saved card. A client can be let off it on their Billing tab.</div>
</div>
<div data-provider-card-fee>
<div class="row">
<div class="col-sm-6 mb-3">
<label class="form-label" for="paymentProviderCardFeePercent">Percent</label>
<!-- What it is for, and its keys -->
<div class="tab-pane fade show active" id="paymentProviderKeys">
<div class="mb-3">
<label class="form-label" for="paymentProviderDescription">Description</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-percent"></i></span>
<input type="text" class="form-control" name="card_fee_percent" id="paymentProviderCardFeePercent" inputmode="decimal" maxlength="5" placeholder="2.9" value="<?= $card_fee_percent > 0 ? escapeHtml(rtrim(rtrim(number_format($card_fee_percent, 2, '.', ''), '0'), '.')) : '' ?>">
<span class="input-group-text">%</span>
<span class="input-group-text"><i class="fas fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" id="paymentProviderDescription" maxlength="250" placeholder="What it is for, if you like" value="<?= escapeHtml($row['payment_provider_description'] ?? '') ?>">
</div>
<?= $error_for('card_fee_percent') ?>
<?= $error_for('description') ?>
</div>
<div class="col-sm-6 mb-3">
<label class="form-label" for="paymentProviderCardFeeFixed">Plus</label>
<p class="small text-body-secondary mb-3">From <a href="<?= escapeHtml($kind['keys_url']) ?>" target="_blank" rel="noopener noreferrer"><?= escapeHtml($name) ?>'s Developers &gt; API keys <i class="fas fa-external-link-alt fa-xs"></i></a> - both live, or both test while you try it out.</p>
<div class="mb-3">
<label class="form-label" for="paymentProviderPublicKey">Publishable key <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-coins"></i></span>
<input type="text" class="form-control" name="card_fee_fixed" id="paymentProviderCardFeeFixed" inputmode="decimal" maxlength="6" placeholder="0.30" value="<?= $card_fee_fixed > 0 ? escapeHtml(number_format($card_fee_fixed, 2, '.', '')) : '' ?>">
<span class="input-group-text"><i class="fas fa-fw fa-eye"></i></span>
<input type="text" class="form-control font-monospace" name="public_key" id="paymentProviderPublicKey" maxlength="250" spellcheck="false" placeholder="<?= escapeHtml($kind['public_example']) ?>" value="<?= escapeHtml($row['payment_provider_public_key'] ?? '') ?>">
</div>
<?= $error_for('public_key') ?>
</div>
<div class="mb-3">
<label class="form-label" for="paymentProviderSecretKey">Secret key <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-key"></i></span>
<input type="password" class="form-control font-monospace" name="private_key" id="paymentProviderSecretKey" maxlength="250" spellcheck="false" autocomplete="new-password"
placeholder="<?= $row && trim((string) $row['payment_provider_private_key']) !== '' ? 'Saved - type a new one to replace it' : escapeHtml($kind['secret_example']) ?>">
</div>
<?= $error_for('private_key') ?>
<div class="form-text">A restricted key (rk_...) does too, with write access to payment intents, customers, setup intents and payment methods, and read on the account.</div>
</div>
</div>
<!-- Where its payments go, the most a card can pay, and its fees as expenses -->
<div class="tab-pane fade" id="paymentProviderPayments">
<?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">
<span class="input-group-text"><i class="fas fa-fw fa-piggy-bank"></i></span>
<select class="form-select select2" name="account" id="paymentProviderAccount">
<option value="">- Select an account -</option>
<?php while ($account = mysqli_fetch_assoc($accounts)) { ?>
<option value="<?= intval($account['account_id']) ?>" <?= intval($account['account_id']) === $account_id ? 'selected' : '' ?>><?= escapeHtml($account['account_name']) ?><?= $account['account_archived_at'] ? ' (archived)' : '' ?></option>
<?php } ?>
</select>
</div>
<?= $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>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-shopping-cart"></i></span>
<input type="text" class="form-control" name="threshold" id="paymentProviderThreshold" inputmode="decimal" maxlength="16" placeholder="No limit" value="<?= $threshold > 0 ? escapeHtml(number_format($threshold, 2, '.', '')) : '' ?>">
<?php if ($currency !== '') { ?><span class="input-group-text"><?= escapeHtml($currency) ?></span><?php } ?>
</div>
<?= $error_for('card_fee_fixed') ?>
<?= $error_for('threshold') ?>
<div class="form-text">An invoice of this much or more can't be paid by card. Empty for no limit.</div>
</div>
<div class="itflow-form-section">Fees</div>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="record_fees" value="1" id="paymentProviderRecordFees" <?= $records_fees ? 'checked' : '' ?> data-provider-fees-switch>
<label class="form-check-label" for="paymentProviderRecordFees">Record its fees as expenses</label>
</div>
<div class="form-text ps-5">Its fee on each card payment is recorded as an expense from the account above, a few minutes after Stripe settles the payment.</div>
</div>
<div data-provider-fees>
<div class="mb-3">
<label class="form-label" for="paymentProviderVendor">Paid to <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="expense_vendor" id="paymentProviderVendor">
<option value="">- Select a vendor -</option>
<?php while ($vendor = mysqli_fetch_assoc($vendors)) { ?>
<option value="<?= intval($vendor['vendor_id']) ?>" <?= intval($vendor['vendor_id']) === $vendor_id ? 'selected' : '' ?>><?= escapeHtml($vendor['vendor_name']) ?><?= $vendor['vendor_archived_at'] ? ' (archived)' : '' ?></option>
<?php } ?>
</select>
</div>
<?= $error_for('expense_vendor') ?>
<div class="form-text">One of your own vendors - <?= escapeHtml($name) ?> itself.</div>
</div>
<div class="mb-3">
<label class="form-label" for="paymentProviderCategory">Category <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-list"></i></span>
<select class="form-select select2" name="expense_category" id="paymentProviderCategory">
<option value="">- Select a category -</option>
<?= categoryOptionsHtml('Expense', $category_id ?: null) ?>
</select>
<?= categoryAddButtonHtml('Expense') ?>
</div>
<?= $error_for('expense_category') ?>
<div class="form-text">Processing Fee, or the like.</div>
</div>
</div>
</div>
<div class="form-text mt-n2 mb-3">What <?= escapeHtml($name) ?> charges you on a card payment - your account's rate, as 2.9% plus 0.30. Card surcharges have rules where you and your clients are: in the US, for one, the card networks cap them and don't allow them on debit cards, and some states limit them further.</div>
</div>
<!-- Clients paying the card fee -->
<div class="tab-pane fade" id="paymentProviderCardFeeTab">
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="card_fee" value="1" id="paymentProviderCardFee" <?= $card_fee ? 'checked' : '' ?> data-provider-card-fee-switch>
<label class="form-check-label" for="paymentProviderCardFee">Clients pay the card fee</label>
</div>
<div class="form-text ps-5">Each card payment is made bigger by what <?= escapeHtml($name) ?> takes of it, so you get what the invoice is for. The fee goes on the invoice as a Card Fee line, and clients see it before they pay - in the client portal, through an invoice's link, by autopay, or when you charge a saved card. A client can be let off it on their Billing tab.</div>
</div>
<div data-provider-card-fee>
<div class="row">
<div class="col-sm-6 mb-3">
<label class="form-label" for="paymentProviderCardFeePercent">Percent</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-percent"></i></span>
<input type="text" class="form-control" name="card_fee_percent" id="paymentProviderCardFeePercent" inputmode="decimal" maxlength="5" placeholder="2.9" value="<?= $card_fee_percent > 0 ? escapeHtml(rtrim(rtrim(number_format($card_fee_percent, 2, '.', ''), '0'), '.')) : '' ?>">
<span class="input-group-text">%</span>
</div>
<?= $error_for('card_fee_percent') ?>
</div>
<div class="col-sm-6 mb-3">
<label class="form-label" for="paymentProviderCardFeeFixed">Plus</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-coins"></i></span>
<input type="text" class="form-control" name="card_fee_fixed" id="paymentProviderCardFeeFixed" inputmode="decimal" maxlength="6" placeholder="0.30" value="<?= $card_fee_fixed > 0 ? escapeHtml(number_format($card_fee_fixed, 2, '.', '')) : '' ?>">
<?php if ($currency !== '') { ?><span class="input-group-text"><?= escapeHtml($currency) ?></span><?php } ?>
</div>
<?= $error_for('card_fee_fixed') ?>
</div>
</div>
<div class="form-text mt-n2 mb-3">What <?= escapeHtml($name) ?> charges you on a card payment - your account's rate, as 2.9% plus 0.30. Card surcharges have rules where you and your clients are: in the US, for one, the card networks cap them and don't allow them on debit cards, and some states limit them further.</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="<?= $row ? 'edit_payment_provider' : 'add_payment_provider' ?>" class="btn btn-primary fw-bold" data-provider-save <?= !$row && !$free_kinds ? 'disabled' : '' ?>>
@@ -312,6 +334,9 @@ ob_start();
box.classList.add('d-block');
}
});
if (first && window.itflowRevealTab) {
window.itflowRevealTab(first);
}
if (first && first.offsetParent !== null) {
first.focus();
}

View File

@@ -3,10 +3,10 @@
/*
* Admin > RMM Providers - one provider's window: Add (no id) or Edit. Which RMM it is is
* picked when it is added and stays; each kind brings its own fields (rmmProviderKinds() in
* functions/rmm.php) - addresses, a key, a secret. A key or secret is never put back into the
* functions/rmm.php) - addresses, a key, a secret - on the Connection tab. A key or secret is never put back into the
* page, so left empty it stays. A kind that has alerts can have them open tickets, from the
* level picked, in a category. Desktops, laptops, servers and virtual machines each come in as
* the asset type picked for them (rmmProviderAssetTypes()). Save asks first (check_rmm_provider, admin/post/rmm.php): what
* level picked, in a category, on its Alerts tab. Desktops, laptops, servers and virtual machines
* each come in as the asset type picked for them (rmmProviderAssetTypes()), on Asset types. Save asks first (check_rmm_provider, admin/post/rmm.php): what
* is wrong shows beside each field and the window stays open; once all is right it saves, and
* tries the connection. A network platform's window (family=network, or one being edited)
* offers the network kinds - UniFi - in its words.
@@ -70,129 +70,154 @@ ob_start();
</div>
<?php } ?>
<div class="mb-3">
<label class="form-label" for="rmmProviderKind"><?= $words['kind'] ?> <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-shapes"></i></span>
<select class="form-select select2" name="kind" id="rmmProviderKind" data-rmm-kind <?= $row ? 'disabled' : '' ?>>
<?php foreach ($kinds as $key => $info) { ?>
<option value="<?= escapeHtml($key) ?>" <?= $key === $kind_key ? 'selected' : '' ?><?= selectOptionData(['icon' => $info['icon'], 'description' => $info['about']]) ?>><?= escapeHtml($info['name']) ?></option>
<?php } ?>
</select>
</div>
<?= $error_for('kind') ?>
<?php if ($row) { ?><div class="form-text"><?= $family === 'network' ? 'Which kind it is stays - add another platform for another one.' : 'Which RMM it is stays - add another provider for another one.' ?></div><?php } ?>
</div>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#rmmProviderConnection"><i class="fas fa-fw fa-plug me-2 d-none d-lg-inline"></i>Connection</a>
</li>
<?php if ($alerts_offered) { ?>
<li class="nav-item <?= isset($kind['alerts'], $kind['alert']) ? '' : 'd-none' ?>" data-rmm-alerts>
<a class="nav-link" data-bs-toggle="pill" href="#rmmProviderAlerts"><i class="fas fa-fw fa-bell me-2 d-none d-lg-inline"></i>Alerts</a>
</li>
<?php } ?>
<?php if (rmmAssetTypesReady()) { ?>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#rmmProviderAssetTypes"><i class="fas fa-fw fa-laptop me-2 d-none d-lg-inline"></i>Asset types</a>
</li>
<?php } ?>
</ul>
<div class="mb-3">
<label class="form-label" for="rmmProviderName">Name <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" id="rmmProviderName" maxlength="100" value="<?= escapeHtml($row ? $row['rmm_provider_name'] : ($kind['default_name'] ?? $kind['name'])) ?>" placeholder="What you call it">
</div>
<?= $error_for('name') ?>
<div class="form-text">What assets and the audit log call it. Two of the same kind need names of their own.</div>
</div>
<div class="tab-content">
<?php foreach ($kinds as $key => $info) {
$shown = $key === $kind_key; ?>
<div data-rmm-kind-fields="<?= escapeHtml($key) ?>" class="<?= $shown ? '' : 'd-none' ?>">
<?php foreach ($info['fields'] as $field => $about) {
$id = 'rmmProvider' . ucfirst($key) . str_replace('_', '', ucwords($field, '_'));
$saved = $row && $shown ? (string) ($row["rmm_provider_$field"] ?? '') : '';
$secret = $about['type'] === 'secret';
if ($about['type'] === 'switch') { ?>
<!-- Which kind, its name, and how ITFlow reaches it -->
<div class="tab-pane fade show active" id="rmmProviderConnection">
<div class="mb-3">
<label class="form-label" for="rmmProviderKind"><?= $words['kind'] ?> <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-shapes"></i></span>
<select class="form-select select2" name="kind" id="rmmProviderKind" data-rmm-kind <?= $row ? 'disabled' : '' ?>>
<?php foreach ($kinds as $key => $info) { ?>
<option value="<?= escapeHtml($key) ?>" <?= $key === $kind_key ? 'selected' : '' ?><?= selectOptionData(['icon' => $info['icon'], 'description' => $info['about']]) ?>><?= escapeHtml($info['name']) ?></option>
<?php } ?>
</select>
</div>
<?= $error_for('kind') ?>
<?php if ($row) { ?><div class="form-text"><?= $family === 'network' ? 'Which kind it is stays - add another platform for another one.' : 'Which RMM it is stays - add another provider for another one.' ?></div><?php } ?>
</div>
<div class="mb-3">
<label class="form-label" for="rmmProviderName">Name <strong class="text-danger">*</strong></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" id="rmmProviderName" maxlength="100" value="<?= escapeHtml($row ? $row['rmm_provider_name'] : ($kind['default_name'] ?? $kind['name'])) ?>" placeholder="What you call it">
</div>
<?= $error_for('name') ?>
<div class="form-text">What assets and the audit log call it. Two of the same kind need names of their own.</div>
</div>
<?php foreach ($kinds as $key => $info) {
$shown = $key === $kind_key; ?>
<div data-rmm-kind-fields="<?= escapeHtml($key) ?>" class="<?= $shown ? '' : 'd-none' ?>">
<?php foreach ($info['fields'] as $field => $about) {
$id = 'rmmProvider' . ucfirst($key) . str_replace('_', '', ucwords($field, '_'));
$saved = $row && $shown ? (string) ($row["rmm_provider_$field"] ?? '') : '';
$secret = $about['type'] === 'secret';
if ($about['type'] === 'switch') { ?>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="<?= $field ?>" value="1" id="<?= $id ?>" <?= intval($saved) ? 'checked' : '' ?> <?= $shown ? '' : 'disabled' ?>>
<label class="form-check-label" for="<?= $id ?>"><?= escapeHtml($about['label']) ?></label>
</div>
<?= $error_for($field) ?>
<div class="form-text ps-5"><?= escapeHtml($about['help']) ?></div>
</div>
<?php continue;
}
$placeholder = $secret ? ($saved !== '' ? 'Saved - type a new one to replace it' : '') : $about['placeholder'];
if ($field === 'web_url' && $row && $shown && isset($info['dashboard'])) {
// The address it works out when this is left empty
$placeholder = (string) call_user_func($info['dashboard'], array_merge($row, ['rmm_provider_web_url' => ''])) ?: $placeholder;
} ?>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="<?= $field ?>" value="1" id="<?= $id ?>" <?= intval($saved) ? 'checked' : '' ?> <?= $shown ? '' : 'disabled' ?>>
<label class="form-check-label" for="<?= $id ?>"><?= escapeHtml($about['label']) ?></label>
<label class="form-label" for="<?= $id ?>"><?= escapeHtml($about['label']) ?> <?= !empty($about['required']) && !($secret && $saved !== '') ? '<strong class="text-danger">*</strong>' : '' ?></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw <?= escapeHtml($about['icon']) ?>"></i></span>
<?php if ($secret) { ?>
<input type="password" class="form-control font-monospace" name="<?= $field ?>" id="<?= $id ?>" maxlength="500" spellcheck="false" autocomplete="new-password" placeholder="<?= escapeHtml($placeholder) ?>" <?= $shown ? '' : 'disabled' ?>>
<?php } elseif ($about['type'] === 'text') { ?>
<input type="text" class="form-control" name="<?= $field ?>" id="<?= $id ?>" maxlength="255" spellcheck="false" autocomplete="off" placeholder="<?= escapeHtml($placeholder) ?>" value="<?= escapeHtml($saved) ?>" <?= $shown ? '' : 'disabled' ?>>
<?php } else { ?>
<input type="url" class="form-control" name="<?= $field ?>" id="<?= $id ?>" maxlength="500" spellcheck="false" placeholder="<?= escapeHtml($placeholder) ?>" value="<?= escapeHtml($saved) ?>" <?= $shown ? '' : 'disabled' ?>>
<?php } ?>
</div>
<?= $error_for($field) ?>
<div class="form-text ps-5"><?= escapeHtml($about['help']) ?></div>
</div>
<?php continue;
}
$placeholder = $secret ? ($saved !== '' ? 'Saved - type a new one to replace it' : '') : $about['placeholder'];
if ($field === 'web_url' && $row && $shown && isset($info['dashboard'])) {
// The address it works out when this is left empty
$placeholder = (string) call_user_func($info['dashboard'], array_merge($row, ['rmm_provider_web_url' => ''])) ?: $placeholder;
} ?>
<div class="mb-3">
<label class="form-label" for="<?= $id ?>"><?= escapeHtml($about['label']) ?> <?= !empty($about['required']) && !($secret && $saved !== '') ? '<strong class="text-danger">*</strong>' : '' ?></label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw <?= escapeHtml($about['icon']) ?>"></i></span>
<?php if ($secret) { ?>
<input type="password" class="form-control font-monospace" name="<?= $field ?>" id="<?= $id ?>" maxlength="500" spellcheck="false" autocomplete="new-password" placeholder="<?= escapeHtml($placeholder) ?>" <?= $shown ? '' : 'disabled' ?>>
<?php } elseif ($about['type'] === 'text') { ?>
<input type="text" class="form-control" name="<?= $field ?>" id="<?= $id ?>" maxlength="255" spellcheck="false" autocomplete="off" placeholder="<?= escapeHtml($placeholder) ?>" value="<?= escapeHtml($saved) ?>" <?= $shown ? '' : 'disabled' ?>>
<?php } else { ?>
<input type="url" class="form-control" name="<?= $field ?>" id="<?= $id ?>" maxlength="500" spellcheck="false" placeholder="<?= escapeHtml($placeholder) ?>" value="<?= escapeHtml($saved) ?>" <?= $shown ? '' : 'disabled' ?>>
<?php } ?>
</div>
<?= $error_for($field) ?>
<div class="form-text"><?= escapeHtml($about['help']) ?>
<?php if ($secret && $info['docs_url'] !== '') { ?><a href="<?= escapeHtml($info['docs_url']) ?>" target="_blank" rel="noopener noreferrer"><?= escapeHtml($info['short']) ?>'s API keys <i class="fas fa-external-link-alt fa-xs"></i></a><?php } ?>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
<?php if ($alerts_offered) { ?>
<div data-rmm-alerts class="<?= isset($kind['alerts'], $kind['alert']) ? '' : 'd-none' ?>">
<div class="mb-3">
<label class="form-label" for="rmmProviderAlertLevel">Alerts open tickets</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-bell"></i></span>
<select class="form-select select2" name="alert_level" id="rmmProviderAlertLevel" data-rmm-alert-level>
<?php foreach (rmmAlertLevels() as $level_key => $level_label) { ?>
<option value="<?= $level_key ?>" <?= $level_key === $alert_level ? 'selected' : '' ?>><?= escapeHtml($level_label) ?></option>
<?php } ?>
</select>
</div>
<?= $error_for('alert_level') ?>
<div class="form-text">A new alert on a device of a linked <?= $words['client'] ?> opens a ticket on its asset - High for an error, Medium for a warning, Low for the rest - and the same alert again goes on that ticket while it is open. When the alert clears, the ticket is resolved unless someone has written on it. Alerts already open when this is turned on don't open tickets.
<span data-rmm-alerts-help><?= escapeHtml((string) ($kind['alerts_help'] ?? '')) ?></span></div>
</div>
<div class="mb-3 <?= $alert_level === '' ? 'd-none' : '' ?>" data-rmm-alert-more>
<label class="form-label" for="rmmProviderAlertCategory">Ticket category</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-layer-group"></i></span>
<select class="form-select select2" name="alert_category_id" id="rmmProviderAlertCategory">
<option value="0">- Not categorized -</option>
<?= categoryOptionsHtml('Ticket', $alert_category_id ?: null) ?>
</select>
<?= categoryAddButtonHtml('Ticket') ?>
</div>
</div>
</div>
<?php } ?>
<?php if (rmmAssetTypesReady()) {
$device_types = rmmProviderAssetTypes($row, $kind); ?>
<div class="mb-3" data-rmm-asset-types>
<label class="form-label">Asset types</label>
<div class="row g-2">
<?php foreach (rmmDeviceKinds($kind) as $guessed => $kind_label) {
$type_id = 'rmmProviderType' . str_replace(' ', '', $guessed); ?>
<div class="col-sm-6">
<label class="form-label small text-body-secondary mb-1" for="<?= $type_id ?>"><?= escapeHtml($kind_label) ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw <?= escapeHtml(assetTypeInfo($guessed)['icon']) ?>"></i></span>
<select class="form-select select2" name="asset_types[<?= escapeHtml($guessed) ?>]" id="<?= $type_id ?>">
<?php foreach (assetTypePicker($device_types[$guessed]) as $type_name => $type_icon) { ?>
<option <?= $type_name === $device_types[$guessed] ? 'selected' : '' ?><?= selectOptionData(['icon' => "fas $type_icon"]) ?>><?= escapeHtml($type_name) ?></option>
<?php } ?>
</select>
<div class="form-text"><?= escapeHtml($about['help']) ?>
<?php if ($secret && $info['docs_url'] !== '') { ?><a href="<?= escapeHtml($info['docs_url']) ?>" target="_blank" rel="noopener noreferrer"><?= escapeHtml($info['short']) ?>'s API keys <i class="fas fa-external-link-alt fa-xs"></i></a><?php } ?>
</div>
</div>
<?php } ?>
</div>
<?= $error_for('asset_types') ?>
<div class="form-text">What its devices come in as. A device the sync typed follows a change here at the next sync; one whose type you changed on the asset keeps yours.<?= $family === 'rmm' ? ' Recurring invoice lines that count managed devices by type count these.' : '' ?></div>
<?php } ?>
</div>
<?php } ?>
<?php if ($alerts_offered) { ?>
<!-- Whether its alerts open tickets, and in which category -->
<div class="tab-pane fade" id="rmmProviderAlerts">
<div class="mb-3">
<label class="form-label" for="rmmProviderAlertLevel">Alerts open tickets</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="fas fa-fw fa-bell"></i></span>
<select class="form-select select2" name="alert_level" id="rmmProviderAlertLevel" data-rmm-alert-level>
<?php foreach (rmmAlertLevels() as $level_key => $level_label) { ?>
<option value="<?= $level_key ?>" <?= $level_key === $alert_level ? 'selected' : '' ?>><?= escapeHtml($level_label) ?></option>
<?php } ?>
</select>
</div>
<?= $error_for('alert_level') ?>
<div class="form-text">A new alert on a device of a linked <?= $words['client'] ?> opens a ticket on its asset - High for an error, Medium for a warning, Low for the rest - and the same alert again goes on that ticket while it is open. When the alert clears, the ticket is resolved unless someone has written on it. Alerts already open when this is turned on don't open tickets.
<span data-rmm-alerts-help><?= escapeHtml((string) ($kind['alerts_help'] ?? '')) ?></span></div>
</div>
<div class="mb-3 <?= $alert_level === '' ? 'd-none' : '' ?>" data-rmm-alert-more>
<label class="form-label" for="rmmProviderAlertCategory">Ticket category</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-layer-group"></i></span>
<select class="form-select select2" name="alert_category_id" id="rmmProviderAlertCategory">
<option value="0">- Not categorized -</option>
<?= categoryOptionsHtml('Ticket', $alert_category_id ?: null) ?>
</select>
<?= categoryAddButtonHtml('Ticket') ?>
</div>
</div>
</div>
<?php } ?>
<?php if (rmmAssetTypesReady()) {
$device_types = rmmProviderAssetTypes($row, $kind); ?>
<!-- What each kind of device comes in as -->
<div class="tab-pane fade" id="rmmProviderAssetTypes">
<div class="mb-3" data-rmm-asset-types>
<div class="row g-2">
<?php foreach (rmmDeviceKinds($kind) as $guessed => $kind_label) {
$type_id = 'rmmProviderType' . str_replace(' ', '', $guessed); ?>
<div class="col-sm-6">
<label class="form-label small text-body-secondary mb-1" for="<?= $type_id ?>"><?= escapeHtml($kind_label) ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw <?= escapeHtml(assetTypeInfo($guessed)['icon']) ?>"></i></span>
<select class="form-select select2" name="asset_types[<?= escapeHtml($guessed) ?>]" id="<?= $type_id ?>">
<?php foreach (assetTypePicker($device_types[$guessed]) as $type_name => $type_icon) { ?>
<option <?= $type_name === $device_types[$guessed] ? 'selected' : '' ?><?= selectOptionData(['icon' => "fas $type_icon"]) ?>><?= escapeHtml($type_name) ?></option>
<?php } ?>
</select>
</div>
</div>
<?php } ?>
</div>
<?= $error_for('asset_types') ?>
<div class="form-text">What its devices come in as. A device the sync typed follows a change here at the next sync; one whose type you changed on the asset keeps yours.<?= $family === 'rmm' ? ' Recurring invoice lines that count managed devices by type count these.' : '' ?></div>
</div>
</div>
<?php } ?>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="<?= $row ? 'edit_rmm_provider' : 'add_rmm_provider' ?>" class="btn btn-primary fw-bold" data-rmm-provider-save>
@@ -231,11 +256,14 @@ ob_start();
block.classList.toggle('d-none', !shown);
block.querySelectorAll('input').forEach(function (input) { input.disabled = !shown; });
});
// Alerts only for a kind that has them
// Alerts only for a kind that has them - its tab goes, back to Connection if it was open
var alerts = form.querySelector('[data-rmm-alerts]');
if (alerts) {
alerts.classList.toggle('d-none', !kinds[kind].alerts);
alerts.querySelector('[data-rmm-alerts-help]').textContent = kinds[kind].alertsHelp;
form.querySelector('[data-rmm-alerts-help]').textContent = kinds[kind].alertsHelp;
if (!kinds[kind].alerts && alerts.querySelector('.nav-link.active') && window.bootstrap) {
bootstrap.Tab.getOrCreateInstance(form.querySelector('[href="#rmmProviderConnection"]')).show();
}
}
});
@@ -263,6 +291,7 @@ ob_start();
}
function showErrors(errors) {
var first = null;
var firstBox = null;
Object.keys(errors).forEach(function (field) {
var input = find(field, 'input');
var box = find(field, 'box');
@@ -273,8 +302,13 @@ ob_start();
if (box) {
box.textContent = errors[field];
box.classList.add('d-block');
firstBox = firstBox || box;
}
});
// Its tab opened - a field's, or where the message is when it has no field of its own (Asset types)
if (window.itflowRevealTab) {
window.itflowRevealTab(first || firstBox);
}
if (first) {
first.focus();
}

View File

@@ -3,7 +3,9 @@
/*
* A ticket status's fields - for ticket_status_add.php and
* ticket_status_edit.php, which set $ticket_status (a ticketStatusRow(), or
* null when new). A built-in status keeps its name and has a fixed answer for
* null when new). Under the preview of its badge, two tabs: Details (name,
* description, color) and What it does (the SLA clock, a client's reply, the
* first response). A built-in status keeps its name and has a fixed answer for
* the SLA clock - shown, not asked; a client's reply moves a ticket in one
* back to Open or to a status picked, and Closed takes none. The preview of its
* badge and the colour swatches are js/ticket_status_form.js. The server
@@ -43,101 +45,120 @@ $s_reply_value = $s_reply_to && isset($s_reply_choices["to-$s_reply_to"]) ? "to-
<span data-ticket-status-preview><?= ticketStatusBadgeHtml($s_name !== '' ? $s_name : 'New status', $s_color, 'list') ?></span>
</div>
<div class="mb-3">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" maxlength="200" placeholder="Waiting on Vendor, Scheduled, Parts Ordered" value="<?= escapeHtml($s_name) ?>" required<?= $s_builtin ? ' readonly' : ($s ? '' : ' autofocus') ?> data-ticket-status-name>
</div>
<?php if ($s_builtin) { ?>
<div class="form-text"><i class="fas fa-fw fa-lock me-1"></i>ITFlow's own statuses keep their names. <?= escapeHtml($s_builtin['set_by']) ?></div>
<?php } ?>
</div>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#ticketStatusFormDetails<?= $s_id ?>"><i class="fas fa-fw fa-tag me-2 d-none d-lg-inline"></i>Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#ticketStatusFormDoes<?= $s_id ?>"><i class="fas fa-fw fa-cogs me-2 d-none d-lg-inline"></i>What it does</a>
</li>
</ul>
<div class="mb-3">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" maxlength="255" placeholder="<?= escapeHtml($s_builtin ? $s_builtin['about'] : 'What it means, and when to use it') ?>" value="<?= escapeHtml($s_description) ?>">
</div>
<div class="form-text">Shown when the status is hovered - in the pickers, on the board and on tickets.</div>
</div>
<div class="tab-content">
<div class="mb-3">
<label class="form-label">Color</label>
<input type="hidden" name="color" value="<?= $s_color ?>" data-ticket-status-color>
<div class="d-flex flex-wrap align-items-center gap-2">
<div class="d-flex flex-wrap gap-1" role="group" aria-label="Colors">
<?php foreach (CATEGORY_COLORS as $swatch) { ?>
<button type="button" class="itflow-tag-swatch<?= $swatch === $s_color ? ' active' : '' ?>" style="--itflow-tag-color: <?= $swatch ?>; --itflow-tag-text: <?= tagTextColor($swatch) ?>" data-ticket-status-swatch="<?= $swatch ?>" title="<?= $swatch ?>" aria-label="Color <?= $swatch ?>" aria-pressed="<?= $swatch === $s_color ? 'true' : 'false' ?>"><i class="fas fa-check" aria-hidden="true"></i></button>
<!-- Its name, what it means, its color -->
<div class="tab-pane fade show active" id="ticketStatusFormDetails<?= $s_id ?>">
<div class="mb-3">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" maxlength="200" placeholder="Waiting on Vendor, Scheduled, Parts Ordered" value="<?= escapeHtml($s_name) ?>" required<?= $s_builtin ? ' readonly' : ($s ? '' : ' autofocus') ?> data-ticket-status-name>
</div>
<?php if ($s_builtin) { ?>
<div class="form-text"><i class="fas fa-fw fa-lock me-1"></i>ITFlow's own statuses keep their names. <?= escapeHtml($s_builtin['set_by']) ?></div>
<?php } ?>
</div>
<div class="input-group input-group-sm w-auto" title="Any other color">
<span class="input-group-text"><i class="fas fa-fw fa-paint-brush"></i></span>
<input type="color" class="form-control form-control-color" value="<?= $s_color ?>" aria-label="Custom color" data-ticket-status-color-pick>
<input type="text" class="form-control font-monospace" style="width: 6rem" maxlength="7" value="<?= $s_color ?>" pattern="#?[0-9a-fA-F]{6}" aria-label="Color as hex" data-ticket-status-color-hex>
<div class="mb-3">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" maxlength="255" placeholder="<?= escapeHtml($s_builtin ? $s_builtin['about'] : 'What it means, and when to use it') ?>" value="<?= escapeHtml($s_description) ?>">
</div>
<div class="form-text">Shown when the status is hovered - in the pickers, on the board and on tickets.</div>
</div>
<div class="mb-3">
<label class="form-label">Color</label>
<input type="hidden" name="color" value="<?= $s_color ?>" data-ticket-status-color>
<div class="d-flex flex-wrap align-items-center gap-2">
<div class="d-flex flex-wrap gap-1" role="group" aria-label="Colors">
<?php foreach (CATEGORY_COLORS as $swatch) { ?>
<button type="button" class="itflow-tag-swatch<?= $swatch === $s_color ? ' active' : '' ?>" style="--itflow-tag-color: <?= $swatch ?>; --itflow-tag-text: <?= tagTextColor($swatch) ?>" data-ticket-status-swatch="<?= $swatch ?>" title="<?= $swatch ?>" aria-label="Color <?= $swatch ?>" aria-pressed="<?= $swatch === $s_color ? 'true' : 'false' ?>"><i class="fas fa-check" aria-hidden="true"></i></button>
<?php } ?>
</div>
<div class="input-group input-group-sm w-auto" title="Any other color">
<span class="input-group-text"><i class="fas fa-fw fa-paint-brush"></i></span>
<input type="color" class="form-control form-control-color" value="<?= $s_color ?>" aria-label="Custom color" data-ticket-status-color-pick>
<input type="text" class="form-control font-monospace" style="width: 6rem" maxlength="7" value="<?= $s_color ?>" pattern="#?[0-9a-fA-F]{6}" aria-label="Color as hex" data-ticket-status-color-hex>
</div>
</div>
</div>
</div>
</div>
<div class="mb-3">
<label class="form-label">SLA resolution clock</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-stopwatch"></i></span>
<?php if ($s_builtin) { ?>
<input type="text" class="form-control" value="<?= $s_id === TICKET_STATUS_CLOSED ? 'Stopped - the ticket is finished' : ($s_paused ? 'Paused while a ticket is in it' : 'Keeps running') ?>" readonly>
<?php } else { ?>
<select class="form-select select2" name="pauses_sla">
<option value="0"<?= $s_paused ? '' : ' selected' ?>>Keeps running - the ticket is being worked</option>
<option value="1"<?= $s_paused ? ' selected' : '' ?>>Paused - waiting on someone else</option>
</select>
<?php } ?>
</div>
<div class="form-text">
<?php if ($s_builtin) { ?><i class="fas fa-fw fa-lock me-1"></i>Fixed for ITFlow's own statuses. <?php } ?>
A ticket in a paused status never warns or breaches on resolution - the time already spent is kept, and the deadline moves out when it comes back. The response clock always runs.
</div>
</div>
<div class="<?= $s_id && !ticketStatusCanBeFirstResponse($s_id) ? 'mb-1' : 'mb-3' ?>">
<label class="form-label">When the client replies</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-reply"></i></span>
<?php if ($s_id === TICKET_STATUS_CLOSED || ($s_builtin && !ticketStatusReplyReady())) { ?>
<input type="text" class="form-control" value="<?= [TICKET_STATUS_OPEN => 'It stays Open', TICKET_STATUS_RESOLVED => 'It is reopened - back to Open', TICKET_STATUS_CLOSED => 'They can\'t - they are told to raise a new ticket'][$s_id] ?? 'It moves back to Open' ?>" readonly>
<?php } else { ?>
<select class="form-select select2" name="client_reply">
<?php foreach ($s_reply_choices as $value => $label) { ?>
<option value="<?= escapeHtml($value) ?>"<?= (string) $value === $s_reply_value ? ' selected' : '' ?>><?= escapeHtml($label) ?></option>
<!-- The SLA clock, a client's reply, the first response -->
<div class="tab-pane fade" id="ticketStatusFormDoes<?= $s_id ?>">
<div class="mb-3">
<label class="form-label">SLA resolution clock</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-stopwatch"></i></span>
<?php if ($s_builtin) { ?>
<input type="text" class="form-control" value="<?= $s_id === TICKET_STATUS_CLOSED ? 'Stopped - the ticket is finished' : ($s_paused ? 'Paused while a ticket is in it' : 'Keeps running') ?>" readonly>
<?php } else { ?>
<select class="form-select select2" name="pauses_sla">
<option value="0"<?= $s_paused ? '' : ' selected' ?>>Keeps running - the ticket is being worked</option>
<option value="1"<?= $s_paused ? ' selected' : '' ?>>Paused - waiting on someone else</option>
</select>
<?php } ?>
</select>
<?php } ?>
</div>
<div class="form-text">
<?php if ($s_id === TICKET_STATUS_CLOSED) { ?>
<i class="fas fa-fw fa-lock me-1"></i>A closed ticket takes no replies.
<?php } else { ?>
By email, in the portal or by text. Move it to a status such as "Client responded" to see at a glance which tickets have a new answer; back to Open suits a status that waits on the client<?= $s_builtin ? '' : '; leave it for one like Scheduled, where a "thanks, see you then" shouldn\'t put it back in the queue' ?>. Whoever it is assigned to is told either way.
<?php } ?>
</div>
</div>
</div>
<div class="form-text">
<?php if ($s_builtin) { ?><i class="fas fa-fw fa-lock me-1"></i>Fixed for ITFlow's own statuses. <?php } ?>
A ticket in a paused status never warns or breaches on resolution - the time already spent is kept, and the deadline moves out when it comes back. The response clock always runs.
</div>
</div>
<?php if (ticketStatusReplyReady() && (!$s_id || ticketStatusCanBeFirstResponse($s_id))) { ?>
<div class="mb-1">
<label class="form-label">Counts as the first response</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-comment-dots"></i></span>
<select class="form-select select2" name="first_response">
<?php foreach (TICKET_STATUS_FIRST_RESPONSE as $value => $first_response) { ?>
<option value="<?= $value ?>"<?= $value === $s_first_response ? ' selected' : '' ?>><?= escapeHtml($first_response['label']) ?></option>
<div class="<?= $s_id && !ticketStatusCanBeFirstResponse($s_id) ? 'mb-1' : 'mb-3' ?>">
<label class="form-label">When the client replies</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-reply"></i></span>
<?php if ($s_id === TICKET_STATUS_CLOSED || ($s_builtin && !ticketStatusReplyReady())) { ?>
<input type="text" class="form-control" value="<?= [TICKET_STATUS_OPEN => 'It stays Open', TICKET_STATUS_RESOLVED => 'It is reopened - back to Open', TICKET_STATUS_CLOSED => 'They can\'t - they are told to raise a new ticket'][$s_id] ?? 'It moves back to Open' ?>" readonly>
<?php } else { ?>
<select class="form-select select2" name="client_reply">
<?php foreach ($s_reply_choices as $value => $label) { ?>
<option value="<?= escapeHtml($value) ?>"<?= (string) $value === $s_reply_value ? ' selected' : '' ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
<?php } ?>
</select>
</div>
<div class="form-text">
An agent moving a ticket into this status before anyone has answered the client meets - or misses - the SLA's response target then: setting it by hand or in a reply, or assigning a new ticket, which moves it to Open. Once per ticket. With the email, the contact and watchers get the "ticket assigned" message from <a href="settings_ticket.php#messages">Settings &gt; Tickets</a>, kept on the ticket as a public note; if nobody could be emailed, it doesn't count.
</div>
<div class="form-text">
<?php if ($s_id === TICKET_STATUS_CLOSED) { ?>
<i class="fas fa-fw fa-lock me-1"></i>A closed ticket takes no replies.
<?php } else { ?>
By email, in the portal or by text. Move it to a status such as "Client responded" to see at a glance which tickets have a new answer; back to Open suits a status that waits on the client<?= $s_builtin ? '' : '; leave it for one like Scheduled, where a "thanks, see you then" shouldn\'t put it back in the queue' ?>. Whoever it is assigned to is told either way.
<?php } ?>
</div>
</div>
<?php if (ticketStatusReplyReady() && (!$s_id || ticketStatusCanBeFirstResponse($s_id))) { ?>
<div class="mb-1">
<label class="form-label">Counts as the first response</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-comment-dots"></i></span>
<select class="form-select select2" name="first_response">
<?php foreach (TICKET_STATUS_FIRST_RESPONSE as $value => $first_response) { ?>
<option value="<?= $value ?>"<?= $value === $s_first_response ? ' selected' : '' ?>><?= escapeHtml($first_response['label']) ?></option>
<?php } ?>
</select>
</div>
<div class="form-text">
An agent moving a ticket into this status before anyone has answered the client meets - or misses - the SLA's response target then: setting it by hand or in a reply, or assigning a new ticket, which moves it to Open. Once per ticket. With the email, the contact and watchers get the "ticket assigned" message from <a href="settings_ticket.php#messages">Settings &gt; Tickets</a>, kept on the ticket as a public note; if nobody could be emailed, it doesn't count.
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<script src="<?= staticFileUrl('/js/ticket_status_form.js') ?>"></script>

View File

@@ -11,6 +11,8 @@
*
* The agents on it are who it is assigned to - Assigned to, beside the title;
* the calendar it is kept on is picked only when there is more than one.
* Under them, two tabs: When (its time, repeats and reminder) and Who &
* where (the client, its site, the place, who is invited, notes).
*/
isset($mysqli) || die("Direct file access is not allowed");
@@ -72,188 +74,202 @@ $form_agents = calendarEventAgentChoices($form_attendees['agents']);
<?php } ?>
</div>
<div class="itflow-cal-form-when border rounded p-3 mb-3">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2">
<div class="fw-semibold"><i class="far fa-fw fa-clock text-secondary me-1"></i>When</div>
<div class="form-check form-switch mb-0">
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#eventFormWhen"><i class="far fa-fw fa-clock me-2 d-none d-lg-inline"></i>When</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#eventFormWhere"><i class="fas fa-fw fa-map-marker-alt me-2 d-none d-lg-inline"></i>Who &amp; where</a>
</li>
</ul>
<div class="tab-content">
<!-- When it is, whether it repeats, and the reminder -->
<div class="tab-pane fade show active" id="eventFormWhen">
<div class="form-check form-switch mb-2">
<input type="checkbox" class="form-check-input" id="event_form_all_day" name="all_day" value="1" <?= $form_all_day ? 'checked' : '' ?>>
<label class="form-check-label" for="event_form_all_day">All day</label>
</div>
</div>
<div class="row g-2">
<div class="col-6 col-md-3">
<label class="form-label small text-body-secondary mb-1" for="event_form_start_date">Starts</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
<input type="date" class="form-control event-start-date" id="event_form_start_date" name="start_date" value="<?= date('Y-m-d', $form_start_ts) ?>" required>
</div>
</div>
<div class="col-6 col-md-3<?= $form_all_day ? ' d-none' : '' ?> event_form_time_fields">
<label class="form-label small text-body-secondary mb-1" for="event_form_start_time">at</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-clock"></i></span>
<input type="time" class="form-control event-start-time" id="event_form_start_time" name="start_time" value="<?= date('H:i', $form_start_ts) ?>"<?= $form_all_day ? '' : ' required' ?>>
</div>
</div>
<div class="col-6 col-md-3">
<label class="form-label small text-body-secondary mb-1" for="event_form_end_date">Ends</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
<input type="date" class="form-control" id="event_form_end_date" name="end_date" value="<?= date('Y-m-d', $form_end_ts) ?>" required>
</div>
</div>
<div class="col-6 col-md-3<?= $form_all_day ? ' d-none' : '' ?> event_form_time_fields">
<label class="form-label small text-body-secondary mb-1" for="event_form_end_time">at</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-clock"></i></span>
<input type="time" class="form-control" id="event_form_end_time" name="end_time" value="<?= date('H:i', $form_end_ts) ?>"<?= $form_all_day ? '' : ' required' ?>>
</div>
</div>
<?php if (timezoneShifted()) { ?>
<div class="col-12 mt-0"><?= timezoneFormHint() ?></div>
<?php } ?>
</div>
<div class="row g-2 align-items-end mt-1">
<div class="col-md-4">
<label class="form-label small text-body-secondary mb-1" for="eventRepeat">Repeats</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-redo"></i></span>
<select class="form-select select2" name="repeat" id="eventRepeat">
<option value="" <?= $form_repeat === '' ? 'selected' : '' ?>>Does not repeat</option>
<?php foreach (['Day' => 'Daily', 'Week' => 'Weekly', 'Month' => 'Monthly', 'Year' => 'Yearly'] as $value => $label) { ?>
<option value="<?= $value ?>" data-one="<?= CALENDAR_REPEATS[$value][1] ?>" data-many="<?= CALENDAR_REPEATS[$value][2] ?>" <?= $form_repeat === $value ? 'selected' : '' ?>><?= $label ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-6 col-md-4" id="eventRepeatEvery" <?= $form_repeat ? '' : 'hidden' ?>>
<label class="form-label small text-body-secondary mb-1" for="eventRepeatInterval">Every</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-sync-alt"></i></span>
<input type="number" class="form-control" name="repeat_interval" id="eventRepeatInterval" min="1" max="99" value="<?= $form_interval ?>">
<span class="input-group-text" id="eventRepeatUnit"><?= $form_repeat ? CALENDAR_REPEATS[$form_repeat][$form_interval === 1 ? 1 : 2] : 'weeks' ?></span>
</div>
</div>
<div class="col-6 col-md-4" id="eventRepeatUntilField" <?= $form_repeat ? '' : 'hidden' ?>>
<label class="form-label small text-body-secondary mb-1" for="eventRepeatUntil">Until <span class="fw-normal">(optional)</span></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hourglass-end"></i></span>
<input type="date" class="form-control" name="repeat_until" id="eventRepeatUntil" value="<?= escapeHtml($form['event_repeat_until'] ?? '') ?>">
</div>
</div>
<?= byDayField('[name=start_date]', '[name=repeat]', ['Month', 'Year'], ['Year'], $form['event_repeat_by_day'] ?? '', 'col-md-8', 'form-label small text-body-secondary mb-1') ?>
</div>
<?php if (calendarRemindersReady()) { ?>
<!-- A reminder for the agents on it - functions/calendar_reminders.php -->
<div class="row g-2 align-items-end mt-1">
<div class="col-md-6">
<input type="hidden" name="reminder_field" value="1">
<label class="form-label small text-body-secondary mb-1" for="eventReminder">Remind</label>
<div class="row g-2">
<div class="col-6 col-md-3">
<label class="form-label small text-body-secondary mb-1" for="event_form_start_date">Starts</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-bell"></i></span>
<select class="form-select select2" name="reminder" id="eventReminder">
<?= calendarReminderOptions(isset($form['event_reminder']) && $form['event_reminder'] !== '' && $form['event_reminder'] !== null ? intval($form['event_reminder']) : null) ?>
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
<input type="date" class="form-control event-start-date" id="event_form_start_date" name="start_date" value="<?= date('Y-m-d', $form_start_ts) ?>" required>
</div>
</div>
<div class="col-6 col-md-3<?= $form_all_day ? ' d-none' : '' ?> event_form_time_fields">
<label class="form-label small text-body-secondary mb-1" for="event_form_start_time">at</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-clock"></i></span>
<input type="time" class="form-control event-start-time" id="event_form_start_time" name="start_time" value="<?= date('H:i', $form_start_ts) ?>"<?= $form_all_day ? '' : ' required' ?>>
</div>
</div>
<div class="col-6 col-md-3">
<label class="form-label small text-body-secondary mb-1" for="event_form_end_date">Ends</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar-day"></i></span>
<input type="date" class="form-control" id="event_form_end_date" name="end_date" value="<?= date('Y-m-d', $form_end_ts) ?>" required>
</div>
</div>
<div class="col-6 col-md-3<?= $form_all_day ? ' d-none' : '' ?> event_form_time_fields">
<label class="form-label small text-body-secondary mb-1" for="event_form_end_time">at</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-clock"></i></span>
<input type="time" class="form-control" id="event_form_end_time" name="end_time" value="<?= date('H:i', $form_end_ts) ?>"<?= $form_all_day ? '' : ' required' ?>>
</div>
</div>
<?php if (timezoneShifted()) { ?>
<div class="col-12 mt-0"><?= timezoneFormHint() ?></div>
<?php } ?>
</div>
<div class="row g-2 align-items-end mt-1">
<div class="col-md-4">
<label class="form-label small text-body-secondary mb-1" for="eventRepeat">Repeats</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-redo"></i></span>
<select class="form-select select2" name="repeat" id="eventRepeat">
<option value="" <?= $form_repeat === '' ? 'selected' : '' ?>>Does not repeat</option>
<?php foreach (['Day' => 'Daily', 'Week' => 'Weekly', 'Month' => 'Monthly', 'Year' => 'Yearly'] as $value => $label) { ?>
<option value="<?= $value ?>" data-one="<?= CALENDAR_REPEATS[$value][1] ?>" data-many="<?= CALENDAR_REPEATS[$value][2] ?>" <?= $form_repeat === $value ? 'selected' : '' ?>><?= $label ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-6 form-text">The agents it's assigned to - or whoever made it, when nobody is - get a notification, and an email too if they asked for that in their Preferences.</div>
<div class="col-6 col-md-4" id="eventRepeatEvery" <?= $form_repeat ? '' : 'hidden' ?>>
<label class="form-label small text-body-secondary mb-1" for="eventRepeatInterval">Every</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-sync-alt"></i></span>
<input type="number" class="form-control" name="repeat_interval" id="eventRepeatInterval" min="1" max="99" value="<?= $form_interval ?>">
<span class="input-group-text" id="eventRepeatUnit"><?= $form_repeat ? CALENDAR_REPEATS[$form_repeat][$form_interval === 1 ? 1 : 2] : 'weeks' ?></span>
</div>
</div>
<div class="col-6 col-md-4" id="eventRepeatUntilField" <?= $form_repeat ? '' : 'hidden' ?>>
<label class="form-label small text-body-secondary mb-1" for="eventRepeatUntil">Until <span class="fw-normal">(optional)</span></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hourglass-end"></i></span>
<input type="date" class="form-control" name="repeat_until" id="eventRepeatUntil" value="<?= escapeHtml($form['event_repeat_until'] ?? '') ?>">
</div>
</div>
<?= byDayField('[name=start_date]', '[name=repeat]', ['Month', 'Year'], ['Year'], $form['event_repeat_by_day'] ?? '', 'col-md-8', 'form-label small text-body-secondary mb-1') ?>
</div>
<?php } ?>
<?php if (calendarSkippedDates($form)) { ?>
<div class="small text-body-secondary mt-2"><i class="fas fa-fw fa-forward me-1"></i>Skipped: <?= escapeHtml(implode(', ', array_map(function ($date) {
return date('M j, Y', strtotime($date));
}, calendarSkippedDates($form)))) ?></div>
<?php } ?>
</div>
<?php if (calendarRemindersReady()) { ?>
<!-- A reminder for the agents on it - functions/calendar_reminders.php -->
<div class="row g-2 align-items-end mt-1">
<div class="col-md-6">
<input type="hidden" name="reminder_field" value="1">
<label class="form-label small text-body-secondary mb-1" for="eventReminder">Remind</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-bell"></i></span>
<select class="form-select select2" name="reminder" id="eventReminder">
<?= calendarReminderOptions(isset($form['event_reminder']) && $form['event_reminder'] !== '' && $form['event_reminder'] !== null ? intval($form['event_reminder']) : null) ?>
</select>
</div>
</div>
<div class="col-md-6 form-text">The agents it's assigned to - or whoever made it, when nobody is - get a notification, and an email too if they asked for that in their Preferences.</div>
</div>
<?php } ?>
<?php if (calendarSkippedDates($form)) { ?>
<div class="small text-body-secondary mt-2"><i class="fas fa-fw fa-forward me-1"></i>Skipped: <?= escapeHtml(implode(', ', array_map(function ($date) {
return date('M j, Y', strtotime($date));
}, calendarSkippedDates($form)))) ?></div>
<?php } ?>
</div>
<div class="row g-3 mb-3">
<?php if ($form_locked_client) { ?>
<input type="hidden" name="client_id" value="<?= $form_client_id ?>">
<?php } else { ?>
<div class="col-md-6">
<label class="form-label">Client</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="client_id" id="eventClientSelect">
<option value="0">- Internal, no client -</option>
<?php
// A client's event takes Clients at Modify (calendarEventCan())
$form_can_clients = calendarEventCan(['event_client_id' => -1], 'edit');
$sql = $form_can_clients ? mysqli_query($mysqli, "SELECT client_id, client_name, client_abbreviation FROM clients WHERE (client_archived_at IS NULL OR client_id = $form_client_id)" . clientNotLeadSql($form_client_id) . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC") : false;
while ($sql && $row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?= intval($row['client_id']) ?>"<?= selectOptionClient($row['client_id'], $row['client_name'], $row['client_abbreviation'] ?? '') ?> <?= intval($row['client_id']) === $form_client_id ? 'selected' : '' ?>><?= escapeHtml($row['client_name']) ?></option>
<!-- The client, where it is, who else is on it -->
<div class="tab-pane fade" id="eventFormWhere">
<div class="row g-3 mb-3">
<?php if ($form_locked_client) { ?>
<input type="hidden" name="client_id" value="<?= $form_client_id ?>">
<?php } else { ?>
<div class="col-md-6">
<label class="form-label">Client</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="client_id" id="eventClientSelect">
<option value="0">- Internal, no client -</option>
<?php
// A client's event takes Clients at Modify (calendarEventCan())
$form_can_clients = calendarEventCan(['event_client_id' => -1], 'edit');
$sql = $form_can_clients ? mysqli_query($mysqli, "SELECT client_id, client_name, client_abbreviation FROM clients WHERE (client_archived_at IS NULL OR client_id = $form_client_id)" . clientNotLeadSql($form_client_id) . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC") : false;
while ($sql && $row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?= intval($row['client_id']) ?>"<?= selectOptionClient($row['client_id'], $row['client_name'], $row['client_abbreviation'] ?? '') ?> <?= intval($row['client_id']) === $form_client_id ? 'selected' : '' ?>><?= escapeHtml($row['client_name']) ?></option>
<?php } ?>
</select>
</div>
<?php if (!$form_can_clients) { ?>
<div class="form-text">An event for a client takes Clients at Modify in your role.</div>
<?php } ?>
</select>
</div>
<?php if (!$form_can_clients) { ?>
<div class="form-text">An event for a client takes Clients at Modify in your role.</div>
</div>
<?php } ?>
</div>
<?php } ?>
<div class="<?= $form_locked_client ? 'col-md-6' : 'col-md-6' ?>" id="eventSiteField" <?= $form_client_id ? '' : 'hidden' ?>>
<label class="form-label">Site</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="location_id" id="eventSiteSelect" data-selected="<?= intval($form['event_location_id'] ?? 0) ?>">
<option value="0">- No site -</option>
<?php
if ($form_client_id) {
$sql = mysqli_query($mysqli, "SELECT location_id, location_name, location_address, location_city FROM locations WHERE location_client_id = $form_client_id AND (location_archived_at IS NULL OR location_id = " . intval($form['event_location_id'] ?? 0) . ") ORDER BY location_primary DESC, location_name");
while ($row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?= intval($row['location_id']) ?>" data-icon="fas fa-map-marker-alt" data-description="<?= escapeHtml(implode(', ', array_filter([$row['location_address'], $row['location_city']]))) ?>" <?= intval($row['location_id']) === intval($form['event_location_id'] ?? 0) ? 'selected' : '' ?>><?= escapeHtml($row['location_name']) ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="col-12">
<label class="form-label">Location <span class="text-body-secondary small fw-normal">- a room, an address, or a Teams / Zoom link</span></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-map-marker-alt"></i></span>
<input type="text" class="form-control" name="location" maxlength="500" value="<?= escapeHtml($form['event_location'] ?? '') ?>" placeholder="Server room, 2nd floor - or https://teams.microsoft.com/...">
</div>
</div>
</div>
<div class="mb-3">
<label class="form-label d-block">Invite <span class="text-body-secondary small fw-normal">- the client's contacts, and anyone else by email</span></label>
<div class="row g-2">
<div class="col-12" id="eventContactsField" <?= $form_client_id ? '' : 'hidden' ?>>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-address-book"></i></span>
<select class="form-select select2" name="contacts[]" id="eventContactsSelect" multiple data-placeholder="Contacts">
<?php
if ($form_client_id) {
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_title, contact_email, contact_photo FROM contacts WHERE contact_client_id = $form_client_id AND contact_archived_at IS NULL ORDER BY contact_primary DESC, contact_technical DESC, contact_name");
while ($row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?= intval($row['contact_id']) ?>"<?= selectOptionContact($form_client_id, $row['contact_name'], $row['contact_photo'], $row['contact_email'] ?: 'No email', $row['contact_id']) ?> <?= in_array(intval($row['contact_id']), $form_attendees['contacts'], true) ? 'selected' : '' ?>><?= escapeHtml($row['contact_name']) ?></option>
<?php }
} ?>
</select>
<div class="<?= $form_locked_client ? 'col-md-6' : 'col-md-6' ?>" id="eventSiteField" <?= $form_client_id ? '' : 'hidden' ?>>
<label class="form-label">Site</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="location_id" id="eventSiteSelect" data-selected="<?= intval($form['event_location_id'] ?? 0) ?>">
<option value="0">- No site -</option>
<?php
if ($form_client_id) {
$sql = mysqli_query($mysqli, "SELECT location_id, location_name, location_address, location_city FROM locations WHERE location_client_id = $form_client_id AND (location_archived_at IS NULL OR location_id = " . intval($form['event_location_id'] ?? 0) . ") ORDER BY location_primary DESC, location_name");
while ($row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?= intval($row['location_id']) ?>" data-icon="fas fa-map-marker-alt" data-description="<?= escapeHtml(implode(', ', array_filter([$row['location_address'], $row['location_city']]))) ?>" <?= intval($row['location_id']) === intval($form['event_location_id'] ?? 0) ? 'selected' : '' ?>><?= escapeHtml($row['location_name']) ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="col-12">
<label class="form-label">Location <span class="text-body-secondary small fw-normal">- a room, an address, or a Teams / Zoom link</span></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-map-marker-alt"></i></span>
<input type="text" class="form-control" name="location" maxlength="500" value="<?= escapeHtml($form['event_location'] ?? '') ?>" placeholder="Server room, 2nd floor - or https://teams.microsoft.com/...">
</div>
</div>
</div>
<div class="col-12">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-envelope"></i></span>
<input type="text" class="form-control" name="emails" value="<?= escapeHtml(implode(', ', $form_attendees['emails'])) ?>" placeholder="Others by email - vendor@example.com, ...">
<div class="mb-3">
<label class="form-label d-block">Invite <span class="text-body-secondary small fw-normal">- the client's contacts, and anyone else by email</span></label>
<div class="row g-2">
<div class="col-12" id="eventContactsField" <?= $form_client_id ? '' : 'hidden' ?>>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-address-book"></i></span>
<select class="form-select select2" name="contacts[]" id="eventContactsSelect" multiple data-placeholder="Contacts">
<?php
if ($form_client_id) {
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_title, contact_email, contact_photo FROM contacts WHERE contact_client_id = $form_client_id AND contact_archived_at IS NULL ORDER BY contact_primary DESC, contact_technical DESC, contact_name");
while ($row = mysqli_fetch_assoc($sql)) { ?>
<option value="<?= intval($row['contact_id']) ?>"<?= selectOptionContact($form_client_id, $row['contact_name'], $row['contact_photo'], $row['contact_email'] ?: 'No email', $row['contact_id']) ?> <?= in_array(intval($row['contact_id']), $form_attendees['contacts'], true) ? 'selected' : '' ?>><?= escapeHtml($row['contact_name']) ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="col-12">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-envelope"></i></span>
<input type="text" class="form-control" name="emails" value="<?= escapeHtml(implode(', ', $form_attendees['emails'])) ?>" placeholder="Others by email - vendor@example.com, ...">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="mb-3">
<label class="form-label">Notes</label>
<textarea class="form-control" rows="3" name="description" placeholder="What it is for, what to bring, who to ask for at reception..."><?= escapeHtml($form['event_description'] ?? '') ?></textarea>
</div>
<div class="mb-3">
<label class="form-label">Notes</label>
<textarea class="form-control" rows="3" name="description" placeholder="What it is for, what to bring, who to ask for at reception..."><?= escapeHtml($form['event_description'] ?? '') ?></textarea>
</div>
<?php if ($form_can_email) { ?>
<div class="form-check form-switch mb-0">
<input type="checkbox" class="form-check-input" id="eventSendInvites" name="send_invites" value="1" <?= $form_invited ? 'checked' : '' ?>>
<label class="form-check-label" for="eventSendInvites">
<?= $form_invited ? 'Email the change to the people on it' : 'Email the invitation to the people on it' ?>
<span class="d-block small text-body-secondary">With a calendar invitation their Outlook, Google or phone calendar adds<?= $form_invited ? ' - and updates when it changes' : '' ?></span>
</label>
<?php if ($form_can_email) { ?>
<div class="form-check form-switch mb-0">
<input type="checkbox" class="form-check-input" id="eventSendInvites" name="send_invites" value="1" <?= $form_invited ? 'checked' : '' ?>>
<label class="form-check-label" for="eventSendInvites">
<?= $form_invited ? 'Email the change to the people on it' : 'Email the invitation to the people on it' ?>
<span class="d-block small text-body-secondary">With a calendar invitation their Outlook, Google or phone calendar adds<?= $form_invited ? ' - and updates when it changes' : '' ?></span>
</label>
</div>
<?php } else { ?>
<div class="small text-body-secondary"><i class="fas fa-fw fa-info-circle me-1"></i>Email is not set up, so invitations cannot be sent - the people on it can still subscribe to their calendar link.</div>
<?php } ?>
</div>
<?php } else { ?>
<div class="small text-body-secondary"><i class="fas fa-fw fa-info-circle me-1"></i>Email is not set up, so invitations cannot be sent - the people on it can still subscribe to their calendar link.</div>
<?php } ?>
</div>

View File

@@ -1,7 +1,9 @@
<?php
/*
* The fields of an expense - shared by New Expense, Edit, Copy and Refund.
* The fields of an expense - shared by New Expense, Edit, Copy and Refund,
* on two tabs: Expense (who, how much, what for, where it was paid from) and
* Client & receipt (the client it was for, billing it on, the receipt).
* Set before including:
*
* $form_mode new | edit | copy | refund
@@ -85,238 +87,264 @@ $form_billable = $form_row && !$form_refund ? intval($form_row['expense_billable
$form_markup = $form_row && !$form_refund ? floatval($form_row['expense_markup']) : expenseMarkupDefault();
?>
<div class="row g-3" id="<?= $form_id ?>" data-expense-form="<?= $form_mode ?>">
<?= reconcileFormNoteHtml($form_lock) ?>
<div id="<?= $form_id ?>" data-expense-form="<?= $form_mode ?>">
<?php if ($form_lock || $form_refund) { ?>
<div class="row g-3 mb-3">
<?= reconcileFormNoteHtml($form_lock) ?>
<?php if ($form_refund) { ?>
<input type="hidden" name="refund_of" value="<?= intval($form_row['expense_id']) ?>">
<div class="col-12">
<div class="d-flex align-items-center gap-3 p-3 rounded bg-body-tertiary">
<?= vendorTile($form_row['vendor_name'] ?? '') ?>
<div class="flex-grow-1 min-w-0">
<div class="fw-semibold text-truncate"><?= escapeHtml($form_row['vendor_name'] ?? '') ?></div>
<div class="small text-body-secondary text-truncate"><?= escapeHtml(implode(' · ', array_filter([$form_row['expense_date'], $form_row['category_name'], truncate((string) $form_row['expense_description'], 60)]))) ?></div>
</div>
<div class="text-end">
<div class="fw-semibold itflow-money"><?= escapeHtml(billingMoney($form_row['expense_amount'], $form_currency)) ?></div>
<?php if (floatval($form_row['refunded_amount']) > 0) { ?>
<div class="small text-success-emphasis"><?= escapeHtml(billingMoney($form_row['refunded_amount'], $form_currency)) ?> back already</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
<div class="col-md-7">
<label class="form-label">Vendor <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="vendor" required data-expense-vendor <?= $form_refund ? 'disabled' : '' ?>>
<option value="">- Select a vendor -</option>
<?php foreach ($form_vendors as $vendor_id => $vendor) { ?>
<option value="<?= $vendor_id ?>" <?= $form_vendor === $vendor_id ? 'selected' : '' ?><?= selectOptionVendor($vendor['vendor_name'], $vendor['vendor_archived_at'] ? 'Archived' : (string) $vendor['vendor_description']) ?>><?= escapeHtml($vendor['vendor_name']) ?></option>
<?php } ?>
</select>
<?php if ($form_refund) { ?>
<input type="hidden" name="vendor" value="<?= $form_vendor ?>">
<?php } else { ?>
<a class="btn btn-outline-secondary" title="Add a vendor - opens Vendors in a new tab" href="vendors.php" target="_blank" rel="noopener"><i class="fas fa-fw fa-plus"></i></a>
<input type="hidden" name="refund_of" value="<?= intval($form_row['expense_id']) ?>">
<div class="col-12">
<div class="d-flex align-items-center gap-3 p-3 rounded bg-body-tertiary">
<?= vendorTile($form_row['vendor_name'] ?? '') ?>
<div class="flex-grow-1 min-w-0">
<div class="fw-semibold text-truncate"><?= escapeHtml($form_row['vendor_name'] ?? '') ?></div>
<div class="small text-body-secondary text-truncate"><?= escapeHtml(implode(' · ', array_filter([$form_row['expense_date'], $form_row['category_name'], truncate((string) $form_row['expense_description'], 60)]))) ?></div>
</div>
<div class="text-end">
<div class="fw-semibold itflow-money"><?= escapeHtml(billingMoney($form_row['expense_amount'], $form_currency)) ?></div>
<?php if (floatval($form_row['refunded_amount']) > 0) { ?>
<div class="small text-success-emphasis"><?= escapeHtml(billingMoney($form_row['refunded_amount'], $form_currency)) ?> back already</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="form-text" data-expense-filled hidden>Filled in from the last expense with them.</div>
</div>
<?php } ?>
<div class="col-md-5">
<label class="form-label"><?= $form_refund ? 'Amount back' : 'Amount' ?> <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
<input type="text" class="form-control text-end fw-semibold" inputmode="decimal" pattern="-?[0-9,]*\.?[0-9]{0,2}" name="amount" placeholder="0.00" required
value="<?= $form_amount === null ? '' : number_format($form_amount, 2, '.', '') ?>" <?= $form_mode === 'new' ? 'autofocus' : '' ?> <?= $form_lock ? 'readonly' : '' ?>>
<span class="input-group-text"><?= escapeHtml($form_currency) ?></span>
</div>
<?php if ($form_refund) { ?>
<div class="form-text">Saved as money back - a negative expense.</div>
<?php } elseif ($form_edit && floatval($form_row['expense_amount']) < 0) { ?>
<div class="form-text">Negative - money back from the vendor.</div>
<?php } ?>
</div>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#<?= $form_id ?>Expense"><i class="fas fa-fw fa-shopping-cart me-2 d-none d-lg-inline"></i>Expense</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_id ?>Client"><i class="fas fa-fw fa-receipt me-2 d-none d-lg-inline"></i>Client &amp; receipt</a>
</li>
</ul>
<div class="col-md-7">
<label class="form-label">Category <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-list"></i></span>
<select class="form-select select2" name="category" required data-expense-category>
<option value="">- Select a category -</option>
<?= categoryOptionsHtml('Expense', $form_category) ?>
</select>
<?= categoryAddButtonHtml('Expense') ?>
</div>
</div>
<div class="tab-content">
<div class="col-md-5">
<label class="form-label">Date <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
<input type="date" class="form-control" name="date" max="2999-12-31" value="<?= escapeHtml($form_date) ?>" required <?= $form_lock ? 'readonly' : '' ?>>
</div>
</div>
<!-- Who was paid, how much, what for, and from where -->
<div class="tab-pane fade show active" id="<?= $form_id ?>Expense">
<div class="row g-3">
<div class="col-md-7">
<label class="form-label">Vendor <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="vendor" required data-expense-vendor <?= $form_refund ? 'disabled' : '' ?>>
<option value="">- Select a vendor -</option>
<?php foreach ($form_vendors as $vendor_id => $vendor) { ?>
<option value="<?= $vendor_id ?>" <?= $form_vendor === $vendor_id ? 'selected' : '' ?><?= selectOptionVendor($vendor['vendor_name'], $vendor['vendor_archived_at'] ? 'Archived' : (string) $vendor['vendor_description']) ?>><?= escapeHtml($vendor['vendor_name']) ?></option>
<?php } ?>
</select>
<?php if ($form_refund) { ?>
<input type="hidden" name="vendor" value="<?= $form_vendor ?>">
<?php } else { ?>
<a class="btn btn-outline-secondary" title="Add a vendor - opens Vendors in a new tab" href="vendors.php" target="_blank" rel="noopener"><i class="fas fa-fw fa-plus"></i></a>
<?php } ?>
</div>
<div class="form-text" data-expense-filled hidden>Filled in from the last expense with them.</div>
</div>
<?php
$tax_form_id = $form_id;
$tax_selected = $form_row ? intval($form_row['expense_tax_id']) : 0;
$tax_amount = $form_edit ? floatval($form_row['expense_tax_amount']) : null;
$tax_currency = $form_currency;
$tax_lock = (bool) $form_lock;
require __DIR__ . '/expense_tax_fields.php';
?>
<div class="col-md-7">
<label class="form-label">Paid from <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-piggy-bank"></i></span>
<select class="form-select select2" name="account" required data-expense-account <?= $form_reimbursed || $form_lock ? 'disabled' : '' ?>>
<?php if (!moduleOn('bookkeeping')) {
// Bookkeeping off - the business (the account it's in, or the default) or an agent personally
$form_business_account = $form_edit && !$form_paid_by && isset($form_accounts[$form_account]) ? $form_account : bookkeepingAccount('expense'); ?>
<option value="<?= $form_business_account ?>" <?= !$form_paid_by ? 'selected' : '' ?> data-icon="fas fa-building" data-description="Paid by the business">The business</option>
<?php } else { ?>
<option value="">- Select an account -</option>
<?php foreach ($form_accounts as $account_id => $account) { ?>
<option value="<?= $account_id ?>" <?= !$form_paid_by && $form_account === $account_id ? 'selected' : '' ?> data-icon="fas fa-piggy-bank"
data-description="<?= escapeHtml(billingMoney($account['balance'], $account['account_currency_code'])) ?><?= $account['account_archived_at'] ? ' - archived' : '' ?>"><?= escapeHtml($account['account_name']) ?></option>
<?php } ?>
<?php } ?>
<?php if (!$form_refund) { ?>
<option value="personal" <?= $form_paid_by ? 'selected' : '' ?> data-icon="fas fa-hand-holding-usd" data-description="An agent paid it - to pay them back">Paid personally</option>
<?php } ?>
</select>
<?php if ($form_reimbursed) { ?>
<input type="hidden" name="account" value="personal">
<?php } elseif ($form_lock) { ?>
<input type="hidden" name="account" value="<?= $form_account ?>">
<?php } ?>
</div>
</div>
<div class="col-md-5">
<label class="form-label">Paid by</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-credit-card"></i></span>
<select class="form-select select2" name="payment_method" data-expense-method>
<option value="">- Select a payment method -</option>
<?php foreach ($form_methods as $method) { ?>
<option value="<?= escapeHtml($method) ?>" <?= $form_method === $method ? 'selected' : '' ?>><?= escapeHtml($method) ?></option>
<?php } ?>
</select>
</div>
</div>
<?php if (!$form_refund) { ?>
<div class="col-md-7" data-expense-payer <?= $form_paid_by ? '' : 'hidden' ?>>
<label class="form-label">Paid personally by <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hand-holding-usd"></i></span>
<select class="form-select select2" name="paid_by" data-expense-paid-by <?= $form_reimbursed ? 'disabled' : '' ?>>
<option value="">- Who paid it -</option>
<?php foreach ($form_payers as $payer_id => $payer_name) { ?>
<option value="<?= $payer_id ?>" <?= ($form_paid_by ?: intval($session_user_id)) === $payer_id ? 'selected' : '' ?>><?= escapeHtml($payer_name) ?><?= $payer_id === intval($session_user_id) ? ' (me)' : '' ?></option>
<div class="col-md-5">
<label class="form-label"><?= $form_refund ? 'Amount back' : 'Amount' ?> <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
<input type="text" class="form-control text-end fw-semibold" inputmode="decimal" pattern="-?[0-9,]*\.?[0-9]{0,2}" name="amount" placeholder="0.00" required
value="<?= $form_amount === null ? '' : number_format($form_amount, 2, '.', '') ?>" <?= $form_mode === 'new' ? 'autofocus' : '' ?> <?= $form_lock ? 'readonly' : '' ?>>
<span class="input-group-text"><?= escapeHtml($form_currency) ?></span>
</div>
<?php if ($form_refund) { ?>
<div class="form-text">Saved as money back - a negative expense.</div>
<?php } elseif ($form_edit && floatval($form_row['expense_amount']) < 0) { ?>
<div class="form-text">Negative - money back from the vendor.</div>
<?php } ?>
</select>
<?php if ($form_reimbursed) { ?>
<input type="hidden" name="paid_by" value="<?= $form_paid_by ?>">
<?php } ?>
</div>
<div class="form-text">
<?php if ($form_reimbursed) { ?>
Paid back on <?= escapeHtml(date('M j, Y', strtotime($form_row['reimbursement_date']))) ?> from <?= escapeHtml($form_row['reimbursed_account_name'] ?: 'an account') ?> - undo that reimbursement to change who paid it.
<?php } else { ?>
It counts as spent on its date, and comes out of an account when they are paid back - from To reimburse on the expenses list.
<?php } ?>
</div>
</div>
<div class="col-md-5 d-none d-md-block" data-expense-payer <?= $form_paid_by ? '' : 'hidden' ?>></div>
<?php } ?>
</div>
<div class="col-md-7">
<label class="form-label">Client</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="client_id" data-expense-client <?= $form_billed ? 'disabled' : '' ?>>
<option value="0">- Not for a client -</option>
<?php foreach ($form_clients as $client) { ?>
<option value="<?= intval($client['client_id']) ?>" <?= $form_client === intval($client['client_id']) ? 'selected' : '' ?><?= selectOptionClient($client['client_id'], $client['client_name'], $client['client_abbreviation'] ?? '') ?>><?= escapeHtml($client['client_name']) ?></option>
<?php } ?>
</select>
<?php if ($form_billed) { ?>
<input type="hidden" name="client_id" value="<?= $form_client ?>">
<?php } ?>
</div>
<div class="form-text">A direct cost of theirs - it counts against them in Client Profitability.</div>
</div>
<div class="col-md-5">
<label class="form-label">Reference</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hashtag"></i></span>
<input type="text" class="form-control" name="reference" maxlength="200" placeholder="Their invoice or order number" value="<?= escapeHtml($form_reference) ?>">
</div>
</div>
<?php if (!$form_refund) { ?>
<div class="col-12" data-expense-billing <?= $form_client ? '' : 'hidden' ?>>
<div class="d-flex flex-wrap align-items-center gap-3 p-2 px-3 rounded border bg-body-tertiary">
<?php if ($form_billed) { ?>
<i class="fas fa-check-circle text-success"></i>
<div class="flex-grow-1 small">
Billed on <a href="invoice.php?invoice_id=<?= intval($form_row['expense_invoice_id']) ?>"><?= escapeHtml($form_row['invoice_prefix'] . $form_row['invoice_number']) ?></a><?= $form_row['billed_subtotal'] !== null ? ' at ' . escapeHtml(billingMoney($form_row['billed_subtotal'], $form_row['expense_currency_code'])) : '' ?>.
<span class="text-body-secondary">Changing the amount here doesn't change the invoice - take it off the invoice to bill it again.</span>
<div class="col-md-7">
<label class="form-label">Category <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-list"></i></span>
<select class="form-select select2" name="category" required data-expense-category>
<option value="">- Select a category -</option>
<?= categoryOptionsHtml('Expense', $form_category) ?>
</select>
<?= categoryAddButtonHtml('Expense') ?>
</div>
<input type="hidden" name="billable" value="1">
<input type="hidden" name="markup" value="<?= number_format($form_markup, 2, '.', '') ?>">
<?php } else { ?>
<div class="form-check form-switch mb-0">
<input class="form-check-input" type="checkbox" role="switch" name="billable" value="1" id="<?= $form_id ?>Billable" <?= $form_billable ? 'checked' : '' ?> data-expense-billable>
<label class="form-check-label" for="<?= $form_id ?>Billable">Bill it on to them</label>
</div>
<div class="col-md-5">
<label class="form-label">Date <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
<input type="date" class="form-control" name="date" max="2999-12-31" value="<?= escapeHtml($form_date) ?>" required <?= $form_lock ? 'readonly' : '' ?>>
</div>
<div class="input-group input-group-sm" style="max-width: 11rem;" data-expense-billable-only>
<span class="input-group-text"><i class="fas fa-fw fa-percent"></i></span>
<input type="text" class="form-control text-end" name="markup" inputmode="decimal" value="<?= rtrim(rtrim(number_format($form_markup, 2, '.', ''), '0'), '.') ?>" aria-label="Markup" data-expense-markup>
<span class="input-group-text">markup</span>
</div>
<?php
$tax_form_id = $form_id;
$tax_selected = $form_row ? intval($form_row['expense_tax_id']) : 0;
$tax_amount = $form_edit ? floatval($form_row['expense_tax_amount']) : null;
$tax_currency = $form_currency;
$tax_lock = (bool) $form_lock;
require __DIR__ . '/expense_tax_fields.php';
?>
<div class="col-md-7">
<label class="form-label">Paid from <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-piggy-bank"></i></span>
<select class="form-select select2" name="account" required data-expense-account <?= $form_reimbursed || $form_lock ? 'disabled' : '' ?>>
<?php if (!moduleOn('bookkeeping')) {
// Bookkeeping off - the business (the account it's in, or the default) or an agent personally
$form_business_account = $form_edit && !$form_paid_by && isset($form_accounts[$form_account]) ? $form_account : bookkeepingAccount('expense'); ?>
<option value="<?= $form_business_account ?>" <?= !$form_paid_by ? 'selected' : '' ?> data-icon="fas fa-building" data-description="Paid by the business">The business</option>
<?php } else { ?>
<option value="">- Select an account -</option>
<?php foreach ($form_accounts as $account_id => $account) { ?>
<option value="<?= $account_id ?>" <?= !$form_paid_by && $form_account === $account_id ? 'selected' : '' ?> data-icon="fas fa-piggy-bank"
data-description="<?= escapeHtml(billingMoney($account['balance'], $account['account_currency_code'])) ?><?= $account['account_archived_at'] ? ' - archived' : '' ?>"><?= escapeHtml($account['account_name']) ?></option>
<?php } ?>
<?php } ?>
<?php if (!$form_refund) { ?>
<option value="personal" <?= $form_paid_by ? 'selected' : '' ?> data-icon="fas fa-hand-holding-usd" data-description="An agent paid it - to pay them back">Paid personally</option>
<?php } ?>
</select>
<?php if ($form_reimbursed) { ?>
<input type="hidden" name="account" value="personal">
<?php } elseif ($form_lock) { ?>
<input type="hidden" name="account" value="<?= $form_account ?>">
<?php } ?>
</div>
<div class="small text-body-secondary" data-expense-billable-only>Bills <strong data-expense-bills></strong> - it waits in Unbilled Time and on their invoices until it goes on one.</div>
</div>
<div class="col-md-5">
<label class="form-label">Paid by</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-credit-card"></i></span>
<select class="form-select select2" name="payment_method" data-expense-method>
<option value="">- Select a payment method -</option>
<?php foreach ($form_methods as $method) { ?>
<option value="<?= escapeHtml($method) ?>" <?= $form_method === $method ? 'selected' : '' ?>><?= escapeHtml($method) ?></option>
<?php } ?>
</select>
</div>
</div>
<?php if (!$form_refund) { ?>
<div class="col-md-7" data-expense-payer <?= $form_paid_by ? '' : 'hidden' ?>>
<label class="form-label">Paid personally by <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hand-holding-usd"></i></span>
<select class="form-select select2" name="paid_by" data-expense-paid-by <?= $form_reimbursed ? 'disabled' : '' ?>>
<option value="">- Who paid it -</option>
<?php foreach ($form_payers as $payer_id => $payer_name) { ?>
<option value="<?= $payer_id ?>" <?= ($form_paid_by ?: intval($session_user_id)) === $payer_id ? 'selected' : '' ?>><?= escapeHtml($payer_name) ?><?= $payer_id === intval($session_user_id) ? ' (me)' : '' ?></option>
<?php } ?>
</select>
<?php if ($form_reimbursed) { ?>
<input type="hidden" name="paid_by" value="<?= $form_paid_by ?>">
<?php } ?>
</div>
<div class="form-text">
<?php if ($form_reimbursed) { ?>
Paid back on <?= escapeHtml(date('M j, Y', strtotime($form_row['reimbursement_date']))) ?> from <?= escapeHtml($form_row['reimbursed_account_name'] ?: 'an account') ?> - undo that reimbursement to change who paid it.
<?php } else { ?>
It counts as spent on its date, and comes out of an account when they are paid back - from To reimburse on the expenses list.
<?php } ?>
</div>
</div>
<div class="col-md-5 d-none d-md-block" data-expense-payer <?= $form_paid_by ? '' : 'hidden' ?>></div>
<?php } ?>
<div class="col-12">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text align-items-start pt-2"><i class="fas fa-fw fa-align-left"></i></span>
<textarea class="form-control" rows="3" name="description" placeholder="What it was - 24 port switch for Ravenwood, October M365 licensing"><?= escapeHtml($form_description) ?></textarea>
</div>
</div>
</div>
</div>
<?php } ?>
<div class="col-12">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text align-items-start pt-2"><i class="fas fa-fw fa-align-left"></i></span>
<textarea class="form-control" rows="3" name="description" placeholder="What it was - 24 port switch for Ravenwood, October M365 licensing"><?= escapeHtml($form_description) ?></textarea>
</div>
</div>
<!-- The client it was for, whether they pay for it, and the receipt -->
<div class="tab-pane fade" id="<?= $form_id ?>Client">
<div class="row g-3">
<div class="col-md-7">
<label class="form-label">Client</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="client_id" data-expense-client <?= $form_billed ? 'disabled' : '' ?>>
<option value="0">- Not for a client -</option>
<?php foreach ($form_clients as $client) { ?>
<option value="<?= intval($client['client_id']) ?>" <?= $form_client === intval($client['client_id']) ? 'selected' : '' ?><?= selectOptionClient($client['client_id'], $client['client_name'], $client['client_abbreviation'] ?? '') ?>><?= escapeHtml($client['client_name']) ?></option>
<?php } ?>
</select>
<?php if ($form_billed) { ?>
<input type="hidden" name="client_id" value="<?= $form_client ?>">
<?php } ?>
</div>
<div class="form-text">A direct cost of theirs - it counts against them in Client Profitability.</div>
</div>
<div class="col-12">
<label class="form-label d-block">Receipt</label>
<?php
// A photo of it, cropped in the Picture window, or a PDF as it is (js/picture_field.js)
$form_receipt_url = $form_receipt ? 'expense_receipt.php?expense_id=' . intval($form_row['expense_id']) . '&action=view' : '';
$form_receipt_shows = !$form_receipt ? picturePhotoEmpty('Add a receipt', 'fa-receipt')
: (expenseReceiptKind($form_receipt) === 'pdf' ? pictureFile('PDF') : picturePhoto($form_receipt_url, 'Receipt'));
?>
<div class="d-flex align-items-center gap-3">
<?= pictureField('file', $form_receipt ? 'receipt_remove' : '', $form_receipt_shows, picturePhotoEmpty('Add a receipt', 'fa-receipt'),
['title' => 'Receipt', 'shapes' => 'free', 'box' => 'tall', 'max' => 2400, 'accept' => 'image/*,application/pdf']) ?>
<div class="form-text mt-0">
<?php if ($form_receipt) { ?>
<a href="<?= escapeHtml($form_receipt_url) ?>" target="_blank" rel="noopener"><?= escapeHtml(expenseReceiptName($form_row)) ?></a><br>
<div class="col-md-5">
<label class="form-label">Reference</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hashtag"></i></span>
<input type="text" class="form-control" name="reference" maxlength="200" placeholder="Their invoice or order number" value="<?= escapeHtml($form_reference) ?>">
</div>
</div>
<?php if (!$form_refund) { ?>
<div class="col-12" data-expense-billing <?= $form_client ? '' : 'hidden' ?>>
<div class="d-flex flex-wrap align-items-center gap-3 p-2 px-3 rounded border bg-body-tertiary">
<?php if ($form_billed) { ?>
<i class="fas fa-check-circle text-success"></i>
<div class="flex-grow-1 small">
Billed on <a href="invoice.php?invoice_id=<?= intval($form_row['expense_invoice_id']) ?>"><?= escapeHtml($form_row['invoice_prefix'] . $form_row['invoice_number']) ?></a><?= $form_row['billed_subtotal'] !== null ? ' at ' . escapeHtml(billingMoney($form_row['billed_subtotal'], $form_row['expense_currency_code'])) : '' ?>.
<span class="text-body-secondary">Changing the amount here doesn't change the invoice - take it off the invoice to bill it again.</span>
</div>
<input type="hidden" name="billable" value="1">
<input type="hidden" name="markup" value="<?= number_format($form_markup, 2, '.', '') ?>">
<?php } else { ?>
<div class="form-check form-switch mb-0">
<input class="form-check-input" type="checkbox" role="switch" name="billable" value="1" id="<?= $form_id ?>Billable" <?= $form_billable ? 'checked' : '' ?> data-expense-billable>
<label class="form-check-label" for="<?= $form_id ?>Billable">Bill it on to them</label>
</div>
<div class="input-group input-group-sm" style="max-width: 11rem;" data-expense-billable-only>
<span class="input-group-text"><i class="fas fa-fw fa-percent"></i></span>
<input type="text" class="form-control text-end" name="markup" inputmode="decimal" value="<?= rtrim(rtrim(number_format($form_markup, 2, '.', ''), '0'), '.') ?>" aria-label="Markup" data-expense-markup>
<span class="input-group-text">markup</span>
</div>
<div class="small text-body-secondary" data-expense-billable-only>Bills <strong data-expense-bills></strong> - it waits in Unbilled Time and on their invoices until it goes on one.</div>
<?php } ?>
</div>
</div>
<?php } ?>
Click it to <?= $form_receipt ? 'change it, or take it off' : 'add a photo or a PDF' ?> - on a phone, Take a photo opens the camera.
<div class="col-12">
<label class="form-label d-block">Receipt</label>
<?php
// A photo of it, cropped in the Picture window, or a PDF as it is (js/picture_field.js)
$form_receipt_url = $form_receipt ? 'expense_receipt.php?expense_id=' . intval($form_row['expense_id']) . '&action=view' : '';
$form_receipt_shows = !$form_receipt ? picturePhotoEmpty('Add a receipt', 'fa-receipt')
: (expenseReceiptKind($form_receipt) === 'pdf' ? pictureFile('PDF') : picturePhoto($form_receipt_url, 'Receipt'));
?>
<div class="d-flex align-items-center gap-3">
<?= pictureField('file', $form_receipt ? 'receipt_remove' : '', $form_receipt_shows, picturePhotoEmpty('Add a receipt', 'fa-receipt'),
['title' => 'Receipt', 'shapes' => 'free', 'box' => 'tall', 'max' => 2400, 'accept' => 'image/*,application/pdf']) ?>
<div class="form-text mt-0">
<?php if ($form_receipt) { ?>
<a href="<?= escapeHtml($form_receipt_url) ?>" target="_blank" rel="noopener"><?= escapeHtml(expenseReceiptName($form_row)) ?></a><br>
<?php } ?>
Click it to <?= $form_receipt ? 'change it, or take it off' : 'add a photo or a PDF' ?> - on a phone, Take a photo opens the camera.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php if (!$form_refund) { ?>

View File

@@ -1,7 +1,10 @@
<?php
/*
* The fields of a product or service - shared by the New and Edit windows.
* The fields of a product or service - shared by the New and Edit windows,
* under the Service / Product switch on tabs: Details (name, category, tax,
* price and cost), Billing (how it is billed, what the client sees), Ordering
* (where it comes from, a product's stock, notes) and, for a product, Asset.
* Set before including:
*
* $form_product productRow() when editing, null for a new one
@@ -46,221 +49,256 @@ if ($form_vendor_id && !isset($form_vendors[$form_vendor_id]) && $form_value('ve
}
?>
<div class="row g-3" id="<?= $form_id ?>" data-product-form data-currency="<?= escapeHtml($form_currency) ?>" data-locale="<?= escapeHtml(str_replace('_', '-', (string) $session_company_locale)) ?>">
<div id="<?= $form_id ?>" data-product-form data-currency="<?= escapeHtml($form_currency) ?>" data-locale="<?= escapeHtml(str_replace('_', '-', (string) $session_company_locale)) ?>">
<!-- What it is -->
<div class="col-12">
<div class="btn-group w-100 itflow-product-type" role="group" aria-label="Type">
<?php foreach (productTypes() as $type_key => $type) { ?>
<input type="radio" class="btn-check" name="type" value="<?= $type_key ?>" id="<?= $form_id ?>Type<?= ucfirst($type_key) ?>" autocomplete="off" <?= $form_type === $type_key ? 'checked' : '' ?> data-product-type>
<label class="btn btn-outline-secondary text-start d-flex align-items-center gap-2" for="<?= $form_id ?>Type<?= ucfirst($type_key) ?>">
<i class="fas fa-fw <?= $type['icon'] ?> fa-lg"></i>
<span>
<span class="fw-semibold d-block"><?= $type['label'] ?></span>
<span class="small opacity-75 d-none d-sm-block"><?= $type_key === 'service' ? 'Labor, managed services, hosting, licenses' : 'Hardware and goods - can track stock' ?></span>
</span>
</label>
<?php } ?>
</div>
<div class="btn-group w-100 itflow-product-type mb-3" role="group" aria-label="Type">
<?php foreach (productTypes() as $type_key => $type) { ?>
<input type="radio" class="btn-check" name="type" value="<?= $type_key ?>" id="<?= $form_id ?>Type<?= ucfirst($type_key) ?>" autocomplete="off" <?= $form_type === $type_key ? 'checked' : '' ?> data-product-type>
<label class="btn btn-outline-secondary text-start d-flex align-items-center gap-2" for="<?= $form_id ?>Type<?= ucfirst($type_key) ?>">
<i class="fas fa-fw <?= $type['icon'] ?> fa-lg"></i>
<span>
<span class="fw-semibold d-block"><?= $type['label'] ?></span>
<span class="small opacity-75 d-none d-sm-block"><?= $type_key === 'service' ? 'Labor, managed services, hosting, licenses' : 'Hardware and goods - can track stock' ?></span>
</span>
</label>
<?php } ?>
</div>
<div class="col-12">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" maxlength="200" value="<?= escapeHtml($form_value('product_name')) ?>" placeholder="Managed Workstation, 24 port PoE switch, Microsoft 365 Business Premium" required <?= $form_edit ? '' : 'autofocus' ?>>
</div>
</div>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#<?= $form_id ?>Details"><i class="fas fa-fw fa-tag me-2 d-none d-lg-inline"></i>Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_id ?>Billing"><i class="fas fa-fw fa-file-invoice-dollar me-2 d-none d-lg-inline"></i>Billing</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_id ?>Ordering"><i class="fas fa-fw fa-truck me-2 d-none d-lg-inline"></i>Ordering</a>
</li>
<li class="nav-item" data-product-only>
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_id ?>Asset"><i class="fas fa-fw fa-laptop me-2 d-none d-lg-inline"></i>Asset</a>
</li>
</ul>
<div class="col-sm-7">
<label class="form-label">Category <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-list"></i></span>
<select class="form-select select2" name="category" required>
<option value="">- Select a category -</option>
<?= categoryOptionsHtml('Income', $form_category_id) ?>
</select>
<?= categoryAddButtonHtml('Income') ?>
</div>
</div>
<div class="col-sm-5">
<label class="form-label">Tax</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-balance-scale"></i></span>
<select class="form-select select2" name="tax">
<?= taxOptionsHtml($form_taxes, $form_tax_id) ?>
</select>
</div>
<div class="form-text">Taxed, its lines take the client's own rate when it has one</div>
</div>
<div class="tab-content">
<!-- What it sells for, what it costs us -->
<div class="col-sm-6">
<label class="form-label">Price <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
<input type="text" class="form-control text-end" name="price" inputmode="decimal" value="<?= $form_price ?>" placeholder="0.00" required data-product-price>
</div>
</div>
<div class="col-sm-6">
<label class="form-label">Cost <span class="text-body-secondary fw-normal small">what it costs you</span></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-shopping-cart"></i></span>
<input type="text" class="form-control text-end" name="cost" inputmode="decimal" value="<?= $form_cost ?>" placeholder="0.00" data-product-cost>
</div>
</div>
<div class="col-12 mt-1">
<div class="form-text" data-product-margin>Add a cost to see your margin - only agents see it.</div>
</div>
<!-- Its name and price -->
<div class="tab-pane fade show active" id="<?= $form_id ?>Details">
<div class="row g-3">
<div class="col-12">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" maxlength="200" value="<?= escapeHtml($form_value('product_name')) ?>" placeholder="Managed Workstation, 24 port PoE switch, Microsoft 365 Business Premium" required <?= $form_edit ? '' : 'autofocus' ?>>
</div>
</div>
<!-- How it is billed by default -->
<div class="col-sm-6">
<label class="form-label">Billed</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-redo-alt"></i></span>
<select class="form-select select2" name="frequency" data-product-frequency>
<?php foreach (quoteFrequencies() as $frequency_value => $frequency_label) { ?>
<option value="<?= $frequency_value ?>" <?= $form_frequency === $frequency_value ? 'selected' : '' ?>><?= $frequency_label ?></option>
<div class="col-sm-7">
<label class="form-label">Category <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-list"></i></span>
<select class="form-select select2" name="category" required>
<option value="">- Select a category -</option>
<?= categoryOptionsHtml('Income', $form_category_id) ?>
</select>
<?= categoryAddButtonHtml('Income') ?>
</div>
</div>
<div class="col-sm-5">
<label class="form-label">Tax</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-balance-scale"></i></span>
<select class="form-select select2" name="tax">
<?= taxOptionsHtml($form_taxes, $form_tax_id) ?>
</select>
</div>
<div class="form-text">Taxed, its lines take the client's own rate when it has one</div>
</div>
<!-- What it sells for, what it costs us -->
<div class="col-sm-6">
<label class="form-label">Price <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
<input type="text" class="form-control text-end" name="price" inputmode="decimal" value="<?= $form_price ?>" placeholder="0.00" required data-product-price>
</div>
</div>
<div class="col-sm-6">
<label class="form-label">Cost <span class="text-body-secondary fw-normal small">what it costs you</span></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-shopping-cart"></i></span>
<input type="text" class="form-control text-end" name="cost" inputmode="decimal" value="<?= $form_cost ?>" placeholder="0.00" data-product-cost>
</div>
</div>
<div class="col-12 mt-1">
<div class="form-text" data-product-margin>Add a cost to see your margin - only agents see it.</div>
</div>
</div>
</div>
<!-- How it is billed by default, and what the client sees -->
<div class="tab-pane fade" id="<?= $form_id ?>Billing">
<div class="row g-3">
<div class="col-sm-6">
<label class="form-label">Billed</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-redo-alt"></i></span>
<select class="form-select select2" name="frequency" data-product-frequency>
<?php foreach (quoteFrequencies() as $frequency_value => $frequency_label) { ?>
<option value="<?= $frequency_value ?>" <?= $form_frequency === $frequency_value ? 'selected' : '' ?>><?= $frequency_label ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-sm-6" data-product-counted>
<label class="form-label">Counted</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-users"></i></span>
<select class="form-select select2" name="seat_source">
<?php foreach (productSeatSources() as $seat_value => $seat_label) { ?>
<option value="<?= $seat_value ?>" <?= $form_seat === $seat_value ? 'selected' : '' ?>><?= $seat_label ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-12 mt-1">
<div class="form-text" data-product-billed-help>Picked on a quote, it fills in Billed. On a recurring invoice, per user or per device takes the quantity from the client's count - per managed device, from the devices your RMM has.</div>
</div>
<div class="col-12">
<label class="form-label">Description <span class="text-body-secondary fw-normal small">on invoices and quotes</span></label>
<div class="input-group">
<span class="input-group-text align-items-start pt-2"><i class="fas fa-fw fa-align-left"></i></span>
<textarea class="form-control" name="description" rows="3" placeholder="What the client sees under the line - what it covers, per user per month, what is included"><?= escapeHtml($form_value('product_description')) ?></textarea>
</div>
</div>
<?php if (quoteImagesReady()) { // a quote line added from it takes a copy (functions/quote_images.php) ?>
<?= quoteImageField('product_image', $form_edit ? ($form_product['product_image'] ?? '') : '', 'A quote line added from it takes a copy.') ?>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="col-sm-6" data-product-counted>
<label class="form-label">Counted</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-users"></i></span>
<select class="form-select select2" name="seat_source">
<?php foreach (productSeatSources() as $seat_value => $seat_label) { ?>
<option value="<?= $seat_value ?>" <?= $form_seat === $seat_value ? 'selected' : '' ?>><?= $seat_label ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-12 mt-1">
<div class="form-text" data-product-billed-help>Picked on a quote, it fills in Billed. On a recurring invoice, per user or per device takes the quantity from the client's count - per managed device, from the devices your RMM has.</div>
</div>
<!-- Where it comes from -->
<div class="col-sm-6">
<label class="form-label">Code</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-barcode"></i></span>
<input type="text" class="form-control" name="code" maxlength="200" value="<?= escapeHtml($form_value('product_code')) ?>" placeholder="Your SKU - MS-WKS, HW-SW24">
</div>
</div>
<div class="col-sm-6">
<label class="form-label">Vendor</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="vendor">
<option value="0">- Select a vendor -</option>
<?php foreach ($form_vendors as $vendor_id => $vendor_name) { ?>
<option value="<?= intval($vendor_id) ?>" <?= $form_vendor_id === intval($vendor_id) ? 'selected' : '' ?>><?= escapeHtml($vendor_name) ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-12">
<label class="form-label">Vendor part number</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hashtag"></i></span>
<input type="text" class="form-control" name="vendor_part" maxlength="200" value="<?= escapeHtml($form_value('product_vendor_part')) ?>" placeholder="What to order it as - the vendor's SKU or the manufacturer part number">
</div>
</div>
<!-- Where it comes from, and the stock of a product -->
<div class="tab-pane fade" id="<?= $form_id ?>Ordering">
<div class="row g-3">
<div class="col-sm-6">
<label class="form-label">Code</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-barcode"></i></span>
<input type="text" class="form-control" name="code" maxlength="200" value="<?= escapeHtml($form_value('product_code')) ?>" placeholder="Your SKU - MS-WKS, HW-SW24">
</div>
</div>
<div class="col-sm-6">
<label class="form-label">Vendor</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<select class="form-select select2" name="vendor">
<option value="0">- Select a vendor -</option>
<?php foreach ($form_vendors as $vendor_id => $vendor_name) { ?>
<option value="<?= intval($vendor_id) ?>" <?= $form_vendor_id === intval($vendor_id) ? 'selected' : '' ?>><?= escapeHtml($vendor_name) ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-12">
<label class="form-label">Vendor part number</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-hashtag"></i></span>
<input type="text" class="form-control" name="vendor_part" maxlength="200" value="<?= escapeHtml($form_value('product_vendor_part')) ?>" placeholder="What to order it as - the vendor's SKU or the manufacturer part number">
</div>
</div>
<!-- Stock - products only -->
<div class="col-12" data-product-only>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" name="track_stock" value="1" id="<?= $form_id ?>Track" <?= $form_track ? 'checked' : '' ?> data-product-track>
<label class="form-check-label" for="<?= $form_id ?>Track">Track stock</label>
</div>
<div class="form-text" data-product-track-on>Invoicing it takes it off the shelf, and it can't be sold past what is there. Add stock as it comes in.</div>
<div class="form-text" data-product-track-off>Ordered as needed - invoicing it doesn't touch stock.<?= $form_edit && $form_track && $form_stock ? ' The ' . billingQuantity($form_stock) . ' on the shelf stay on record but stop moving.' : '' ?></div>
</div>
<div class="col-sm-6" data-product-only data-product-tracked>
<label class="form-label">Reorder at</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-bell"></i></span>
<input type="text" class="form-control text-end" name="reorder_level" inputmode="decimal" value="<?= $form_reorder_level ?>" placeholder="When it is out">
</div>
</div>
<div class="col-sm-6" data-product-only data-product-tracked>
<label class="form-label">Order</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-shopping-basket"></i></span>
<input type="text" class="form-control text-end" name="reorder_qty" inputmode="decimal" value="<?= $form_reorder_qty ?>" placeholder="How many to buy">
</div>
</div>
<div class="col-12 mt-1" data-product-only data-product-tracked>
<div class="form-text">Agents are told when it gets down to this, and it is listed under Reorder with the vendor and part number.</div>
</div>
<div class="col-12" data-product-only data-product-tracked data-product-location>
<label class="form-label">Location</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-map-marker-alt"></i></span>
<input type="text" class="form-control" name="location" maxlength="250" value="<?= escapeHtml($form_value('product_location')) ?>" placeholder="Where it is kept - shelf B2, the van, the back office">
</div>
</div>
<!-- Stock - products only -->
<div class="col-12" data-product-only>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" name="track_stock" value="1" id="<?= $form_id ?>Track" <?= $form_track ? 'checked' : '' ?> data-product-track>
<label class="form-check-label" for="<?= $form_id ?>Track">Track stock</label>
</div>
<div class="form-text" data-product-track-on>Invoicing it takes it off the shelf, and it can't be sold past what is there. Add stock as it comes in.</div>
<div class="form-text" data-product-track-off>Ordered as needed - invoicing it doesn't touch stock.<?= $form_edit && $form_track && $form_stock ? ' The ' . billingQuantity($form_stock) . ' on the shelf stay on record but stop moving.' : '' ?></div>
</div>
<div class="col-sm-6" data-product-only data-product-tracked>
<label class="form-label">Reorder at</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-bell"></i></span>
<input type="text" class="form-control text-end" name="reorder_level" inputmode="decimal" value="<?= $form_reorder_level ?>" placeholder="When it is out">
</div>
</div>
<div class="col-sm-6" data-product-only data-product-tracked>
<label class="form-label">Order</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-shopping-basket"></i></span>
<input type="text" class="form-control text-end" name="reorder_qty" inputmode="decimal" value="<?= $form_reorder_qty ?>" placeholder="How many to buy">
</div>
</div>
<div class="col-12 mt-1" data-product-only data-product-tracked>
<div class="form-text">Agents are told when it gets down to this, and it is listed under Reorder with the vendor and part number.</div>
</div>
<div class="col-12" data-product-only data-product-tracked data-product-location>
<label class="form-label">Location</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-map-marker-alt"></i></span>
<input type="text" class="form-control" name="location" maxlength="250" value="<?= escapeHtml($form_value('product_location')) ?>" placeholder="Where it is kept - shelf B2, the van, the back office">
</div>
</div>
<!-- Hardware - becomes a client asset when it is sold -->
<div class="col-sm-6" data-product-only>
<label class="form-label">Client asset</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-laptop"></i></span>
<select class="form-select select2" name="asset_type" data-product-asset-type>
<option value="">- Not an asset -</option>
<?php foreach (productAssetTypes($form_asset_type) as $asset_type_option => $asset_type_icon) { ?>
<option value="<?= escapeHtml($asset_type_option) ?>" <?= $form_asset_type === $asset_type_option ? 'selected' : '' ?><?= selectOptionData(['icon' => "fas $asset_type_icon"]) ?>><?= escapeHtml($asset_type_option) ?></option>
<?php } ?>
<?php if ($form_asset_type !== '' && !isset(productAssetTypes($form_asset_type)[$form_asset_type])) { ?>
<option value="<?= escapeHtml($form_asset_type) ?>" selected><?= escapeHtml($form_asset_type) ?></option>
<?php } ?>
</select>
<div class="col-12">
<label class="form-label">Notes <span class="text-body-secondary fw-normal small">for agents only</span></label>
<div class="input-group">
<span class="input-group-text align-items-start pt-2"><i class="fas fa-fw fa-sticky-note"></i></span>
<textarea class="form-control" name="notes" rows="2" placeholder="Lead time, where to order it, what to check before quoting"><?= escapeHtml($form_value('product_notes')) ?></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6" data-product-only data-product-asset>
<label class="form-label">Warranty</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-shield-alt"></i></span>
<input type="text" class="form-control text-end" name="warranty_months" inputmode="numeric" maxlength="3" value="<?= $form_warranty ?>" placeholder="None">
<span class="input-group-text">months</span>
</div>
</div>
<div class="col-sm-6" data-product-only data-product-asset>
<label class="form-label">Make</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-industry"></i></span>
<input type="text" class="form-control" name="make" maxlength="200" value="<?= escapeHtml($form_value('product_make')) ?>" placeholder="Who makes it - Dell, Ubiquiti, Synology">
</div>
</div>
<div class="col-sm-6" data-product-only data-product-asset>
<label class="form-label">Model</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-cube"></i></span>
<input type="text" class="form-control" name="model" maxlength="200" value="<?= escapeHtml($form_value('product_model')) ?>" placeholder="OptiPlex 7020, U6-Pro, RS1221+">
</div>
</div>
<div class="col-12 mt-1" data-product-only>
<div class="form-text" data-product-asset-on>When it is sold, the invoice offers to add each one to the client's assets with its serial number, this make and model, and the warranty counted from the invoice date.</div>
<div class="form-text" data-product-asset-off>Pick an asset type for hardware the client keeps - a laptop, a switch, a firewall - and selling it offers to add it to their assets.</div>
</div>
<div class="col-12">
<label class="form-label">Description <span class="text-body-secondary fw-normal small">on invoices and quotes</span></label>
<div class="input-group">
<span class="input-group-text align-items-start pt-2"><i class="fas fa-fw fa-align-left"></i></span>
<textarea class="form-control" name="description" rows="3" placeholder="What the client sees under the line - what it covers, per user per month, what is included"><?= escapeHtml($form_value('product_description')) ?></textarea>
</div>
</div>
<?php if (quoteImagesReady()) { // a quote line added from it takes a copy (functions/quote_images.php) ?>
<?= quoteImageField('product_image', $form_edit ? ($form_product['product_image'] ?? '') : '', 'A quote line added from it takes a copy.') ?>
<?php } ?>
<div class="col-12">
<label class="form-label">Notes <span class="text-body-secondary fw-normal small">for agents only</span></label>
<div class="input-group">
<span class="input-group-text align-items-start pt-2"><i class="fas fa-fw fa-sticky-note"></i></span>
<textarea class="form-control" name="notes" rows="2" placeholder="Lead time, where to order it, what to check before quoting"><?= escapeHtml($form_value('product_notes')) ?></textarea>
<!-- Hardware - becomes a client asset when it is sold -->
<div class="tab-pane fade" id="<?= $form_id ?>Asset">
<div class="row g-3">
<div class="col-sm-6" data-product-only>
<label class="form-label">Client asset</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-laptop"></i></span>
<select class="form-select select2" name="asset_type" data-product-asset-type>
<option value="">- Not an asset -</option>
<?php foreach (productAssetTypes($form_asset_type) as $asset_type_option => $asset_type_icon) { ?>
<option value="<?= escapeHtml($asset_type_option) ?>" <?= $form_asset_type === $asset_type_option ? 'selected' : '' ?><?= selectOptionData(['icon' => "fas $asset_type_icon"]) ?>><?= escapeHtml($asset_type_option) ?></option>
<?php } ?>
<?php if ($form_asset_type !== '' && !isset(productAssetTypes($form_asset_type)[$form_asset_type])) { ?>
<option value="<?= escapeHtml($form_asset_type) ?>" selected><?= escapeHtml($form_asset_type) ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-sm-6" data-product-only data-product-asset>
<label class="form-label">Warranty</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-shield-alt"></i></span>
<input type="text" class="form-control text-end" name="warranty_months" inputmode="numeric" maxlength="3" value="<?= $form_warranty ?>" placeholder="None">
<span class="input-group-text">months</span>
</div>
</div>
<div class="col-sm-6" data-product-only data-product-asset>
<label class="form-label">Make</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-industry"></i></span>
<input type="text" class="form-control" name="make" maxlength="200" value="<?= escapeHtml($form_value('product_make')) ?>" placeholder="Who makes it - Dell, Ubiquiti, Synology">
</div>
</div>
<div class="col-sm-6" data-product-only data-product-asset>
<label class="form-label">Model</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-cube"></i></span>
<input type="text" class="form-control" name="model" maxlength="200" value="<?= escapeHtml($form_value('product_model')) ?>" placeholder="OptiPlex 7020, U6-Pro, RS1221+">
</div>
</div>
<div class="col-12 mt-1" data-product-only>
<div class="form-text" data-product-asset-on>When it is sold, the invoice offers to add each one to the client's assets with its serial number, this make and model, and the warranty counted from the invoice date.</div>
<div class="form-text" data-product-asset-off>Pick an asset type for hardware the client keeps - a laptop, a switch, a firewall - and selling it offers to add it to their assets.</div>
</div>
</div>
</div>
</div>
</div>
@@ -297,6 +335,11 @@ if ($form_vendor_id && !isset($form_vendors[$form_vendor_id]) && $form_value('ve
form.querySelectorAll('[data-product-only]').forEach(function (el) {
el.hidden = type !== 'product';
});
// The Asset tab is a product's - switched to a service while on it, back to Details
var assetTab = form.querySelector('[href="#' + form.id + 'Asset"]');
if (type !== 'product' && assetTab.classList.contains('active') && window.bootstrap) {
bootstrap.Tab.getOrCreateInstance(form.querySelector('[href="#' + form.id + 'Details"]')).show();
}
if (type === 'product') {
form.querySelectorAll('[data-product-tracked]').forEach(function (el) {
el.hidden = !track.checked;

View File

@@ -5,8 +5,9 @@
* and service_edit.php, which set $form (the values, raw), $form_client_id
* (the service's client, 0 when not picked yet) and $is_new. A new service
* picks its client here when opened outside one; opened inside one it can
* link what it depends on straight away. Afterwards that is done from the
* service page.
* link what it depends on straight away, on its Depends on tab. Afterwards
* that is done from the service page. Its other tabs: Service (what it is,
* how much it matters, its reviews) and Recovery & notes.
*/
isset($mysqli) || die("Direct file access is not allowed");
@@ -50,93 +51,10 @@ $importance_styles = [
<input type="hidden" name="client_id" value="<?= $form_client_id ?>">
<?php } ?>
<div class="row g-3 mb-3">
<div class="col-md-7">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-concierge-bell"></i></span>
<input type="text" class="form-control" name="name" placeholder="Email, Backup, Practice management, Phones..." maxlength="200" value="<?= escapeHtml($form['service_name'] ?? '') ?>" required autofocus>
</div>
</div>
<div class="col-md-5">
<label class="form-label">Category</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-folder"></i></span>
<input type="text" class="form-control" name="category" list="serviceCategorySuggestions" placeholder="Email, Backup, Network..." maxlength="50" value="<?= escapeHtml($form['service_category'] ?? '') ?>">
</div>
<datalist id="serviceCategorySuggestions">
<?php foreach ($category_suggestions as $suggestion) { ?>
<option value="<?= escapeHtml($suggestion) ?>"></option>
<?php } ?>
</datalist>
</div>
</div>
<div class="mb-3">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" placeholder="Microsoft 365 mail for all staff, Veeam to the NAS and offsite..." maxlength="200" value="<?= escapeHtml($form['service_description'] ?? '') ?>">
</div>
</div>
<div class="mb-3">
<?= tagFormFieldHtml('service', $is_new ? [] : tagIdsForRecord('service', $form['service_id']), 'Managed, Client-run, Business hours only') ?>
</div>
<div class="mb-3">
<label class="form-label d-block">Importance <span class="text-body-secondary small fw-normal">- how bad is it when it is down?</span></label>
<div class="btn-group w-100 itflow-service-importance" role="group">
<?php foreach ($importance_styles as $importance => [$tone, $icon, $hint]) { ?>
<input type="radio" class="btn-check" name="importance" id="serviceImportance<?= $importance ?>" value="<?= $importance ?>" <?= $form_importance === $importance ? 'checked' : '' ?> autocomplete="off">
<label class="btn btn-outline-<?= $tone ?> text-start" for="serviceImportance<?= $importance ?>">
<i class="fas <?= $icon ?> me-1"></i><span class="fw-semibold"><?= $importance ?></span>
<span class="d-none d-md-block small opacity-75"><?= $hint ?></span>
</label>
<?php } ?>
</div>
</div>
<div class="mb-3">
<label class="form-label">Backup and recovery</label>
<textarea class="form-control" name="backup" rows="2" maxlength="500" placeholder="How it is backed up, where to, and how it comes back - and how long that takes"><?= escapeHtml($form['service_backup'] ?? '') ?></textarea>
</div>
<div class="mb-3">
<label class="form-label">Notes</label>
<textarea class="form-control" name="notes" rows="4" placeholder="How it fits together, the known quirks, what to check first when it breaks"><?= escapeHtml($form['service_notes'] ?? '') ?></textarea>
</div>
<div class="row g-3 <?= $is_new && $form_client_id ? 'mb-3' : 'mb-0' ?>">
<div class="col-md-6">
<label class="form-label">Review it</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-redo"></i></span>
<select class="form-select select2" name="review_interval" id="serviceReviewInterval">
<?php foreach (SERVICE_REVIEW_INTERVALS as $months => $label) { ?>
<option value="<?= $months ?>" <?= $form_interval === $months ? 'selected' : '' ?> data-icon="far <?= $months ? 'fa-calendar-check' : 'fa-calendar' ?>"><?= $label ?></option>
<?php } ?>
</select>
</div>
<div class="form-text">Check it still matches what is out there - a QBR is a good time.</div>
</div>
<div class="col-md-6">
<label class="form-label">Next review</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar-check"></i></span>
<input type="date" class="form-control" name="review_due" id="serviceReviewDue" value="<?= escapeHtml($form['service_review_due'] ?? '') ?>">
</div>
<?php if (!empty($form['service_reviewed_at'])) { ?>
<div class="form-text">Last reviewed <?= escapeHtml(date('M j, Y', strtotime($form['service_reviewed_at']))) ?>.</div>
<?php } else { ?>
<div class="form-text">Leave it empty to follow the schedule.</div>
<?php } ?>
</div>
</div>
<?php if ($is_new && $form_client_id) {
// What it depends on - the client's own, unarchived records, the kinds this agent may link
$pickers = [];
<?php
// What it depends on - opened inside a client, a new one can link the client's own, unarchived records, the kinds this agent may link
$pickers = [];
if ($is_new && $form_client_id) {
foreach (SERVICE_LINK_TYPES as $type) {
if (!linkCanEdit('service', $type)) {
continue;
@@ -146,11 +64,121 @@ $importance_styles = [
$pickers[$type] = $candidates;
}
}
$picker_hints = ['asset' => 'The servers, firewalls, NAS it runs on', 'credential' => 'Admin consoles, portals', 'domain' => 'Its mail or web domains',
'certificate' => 'What keeps it on https', 'contact' => 'Who owns it at the client, who to tell', 'vendor' => 'Who to call when it breaks', 'document' => 'Runbooks, diagrams'];
if ($pickers) { ?>
<div class="border-top pt-3">
<div class="small text-body-secondary fw-semibold text-uppercase mb-2">What it depends on</div>
}
$picker_hints = ['asset' => 'The servers, firewalls, NAS it runs on', 'credential' => 'Admin consoles, portals', 'domain' => 'Its mail or web domains',
'certificate' => 'What keeps it on https', 'contact' => 'Who owns it at the client, who to tell', 'vendor' => 'Who to call when it breaks', 'document' => 'Runbooks, diagrams'];
$form_tabs = 'serviceForm' . ($is_new ? 'New' : intval($form['service_id']));
?>
<ul class="nav nav-pills nav-fill flex-nowrap overflow-auto mb-3 itflow-asset-form-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#<?= $form_tabs ?>Service"><i class="fas fa-fw fa-concierge-bell me-2 d-none d-lg-inline"></i>Service</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_tabs ?>Recovery"><i class="fas fa-fw fa-history me-2 d-none d-lg-inline"></i>Recovery &amp; notes</a>
</li>
<?php if ($pickers) { ?>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#<?= $form_tabs ?>Depends"><i class="fas fa-fw fa-project-diagram me-2 d-none d-lg-inline"></i>Depends on</a>
</li>
<?php } ?>
</ul>
<div class="tab-content">
<!-- What it is, how much it matters, when to look at it again -->
<div class="tab-pane fade show active" id="<?= $form_tabs ?>Service">
<div class="row g-3 mb-3">
<div class="col-md-7">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-concierge-bell"></i></span>
<input type="text" class="form-control" name="name" placeholder="Email, Backup, Practice management, Phones..." maxlength="200" value="<?= escapeHtml($form['service_name'] ?? '') ?>" required autofocus>
</div>
</div>
<div class="col-md-5">
<label class="form-label">Category</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-folder"></i></span>
<input type="text" class="form-control" name="category" list="serviceCategorySuggestions" placeholder="Email, Backup, Network..." maxlength="50" value="<?= escapeHtml($form['service_category'] ?? '') ?>">
</div>
<datalist id="serviceCategorySuggestions">
<?php foreach ($category_suggestions as $suggestion) { ?>
<option value="<?= escapeHtml($suggestion) ?>"></option>
<?php } ?>
</datalist>
</div>
</div>
<div class="mb-3">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" placeholder="Microsoft 365 mail for all staff, Veeam to the NAS and offsite..." maxlength="200" value="<?= escapeHtml($form['service_description'] ?? '') ?>">
</div>
</div>
<div class="mb-3">
<?= tagFormFieldHtml('service', $is_new ? [] : tagIdsForRecord('service', $form['service_id']), 'Managed, Client-run, Business hours only') ?>
</div>
<div class="mb-3">
<label class="form-label d-block">Importance <span class="text-body-secondary small fw-normal">- how bad is it when it is down?</span></label>
<div class="btn-group w-100 itflow-service-importance" role="group">
<?php foreach ($importance_styles as $importance => [$tone, $icon, $hint]) { ?>
<input type="radio" class="btn-check" name="importance" id="serviceImportance<?= $importance ?>" value="<?= $importance ?>" <?= $form_importance === $importance ? 'checked' : '' ?> autocomplete="off">
<label class="btn btn-outline-<?= $tone ?> text-start" for="serviceImportance<?= $importance ?>">
<i class="fas <?= $icon ?> me-1"></i><span class="fw-semibold"><?= $importance ?></span>
<span class="d-none d-md-block small opacity-75"><?= $hint ?></span>
</label>
<?php } ?>
</div>
</div>
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">Review it</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-redo"></i></span>
<select class="form-select select2" name="review_interval" id="serviceReviewInterval">
<?php foreach (SERVICE_REVIEW_INTERVALS as $months => $label) { ?>
<option value="<?= $months ?>" <?= $form_interval === $months ? 'selected' : '' ?> data-icon="far <?= $months ? 'fa-calendar-check' : 'fa-calendar' ?>"><?= $label ?></option>
<?php } ?>
</select>
</div>
<div class="form-text">Check it still matches what is out there - a QBR is a good time.</div>
</div>
<div class="col-md-6">
<label class="form-label">Next review</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar-check"></i></span>
<input type="date" class="form-control" name="review_due" id="serviceReviewDue" value="<?= escapeHtml($form['service_review_due'] ?? '') ?>">
</div>
<?php if (!empty($form['service_reviewed_at'])) { ?>
<div class="form-text">Last reviewed <?= escapeHtml(date('M j, Y', strtotime($form['service_reviewed_at']))) ?>.</div>
<?php } else { ?>
<div class="form-text">Leave it empty to follow the schedule.</div>
<?php } ?>
</div>
</div>
</div>
<!-- How it comes back, and what to know about it -->
<div class="tab-pane fade" id="<?= $form_tabs ?>Recovery">
<div class="mb-3">
<label class="form-label">Backup and recovery</label>
<textarea class="form-control" name="backup" rows="4" maxlength="500" placeholder="How it is backed up, where to, and how it comes back - and how long that takes"><?= escapeHtml($form['service_backup'] ?? '') ?></textarea>
</div>
<div>
<label class="form-label">Notes</label>
<textarea class="form-control" name="notes" rows="6" placeholder="How it fits together, the known quirks, what to check first when it breaks"><?= escapeHtml($form['service_notes'] ?? '') ?></textarea>
</div>
</div>
<?php if ($pickers) { ?>
<!-- What it depends on - afterwards linked from the service's page -->
<div class="tab-pane fade" id="<?= $form_tabs ?>Depends">
<div class="row g-3">
<?php foreach ($pickers as $type => $candidates) {
$entity = LINK_ENTITIES[$type]; ?>
@@ -168,8 +196,9 @@ $importance_styles = [
<?php } ?>
</div>
</div>
<?php }
} ?>
<?php } ?>
</div>
<script>
(function () {

View File

@@ -3,12 +3,14 @@
require_once '../../../includes/modal_header.php';
/*
* New Ticket - who it is for and what it is about, what it is related to,
* and its tasks. Opened from a client, contact, asset, site, vendor,
* project or service, it starts with that filled in; picking an asset fills
* in the person it is assigned to and its site. When the person or the asset
* already has open tickets, they show under the contact - so a second ticket
* for the same problem gets noticed before it is raised.
* New Ticket - who it is for and what it is about (Details), when it is
* due, the status it starts in, the work booked, its tags and billing
* (Planning), what it is related to, and its tasks. Opened from a client,
* contact, asset, site, vendor, project or service, it starts with that
* filled in; picking an asset fills in the person it is assigned to and its
* site. When the person or the asset already has open tickets, they show
* under the contact - so a second ticket for the same problem gets noticed
* before it is raised.
*
* Copy of a ticket (copy_ticket_id - its More actions > Copy as a new ticket): it starts with
* that ticket's subject, details, priority, category, billing, contact, asset, site, vendor and
@@ -135,6 +137,9 @@ ob_start();
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#pills-add-details"><i class="fas fa-fw fa-life-ring me-2"></i>Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#pills-add-planning"><i class="fas fa-fw fa-calendar-alt me-2"></i>Planning</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#pills-add-relationships"><i class="fas fa-fw fa-link me-2"></i>Related</a>
</li>
@@ -252,7 +257,7 @@ ob_start();
</div>
<div class="row">
<div class="col">
<div class="col-sm-6">
<div class="mb-3">
<label class="form-label">Assign to</label>
<div class="input-group">
@@ -275,6 +280,15 @@ ob_start();
</div>
</div>
</div>
</div>
</div>
<!-- When it is due, where it starts, the work booked, its tags and billing -->
<div class="tab-pane fade" id="pills-add-planning">
<!-- When it is due, and where it starts - as the ticket's own status menu -->
<div class="row">
<div class="col">
<div class="mb-3">
<label class="form-label">Due</label>
@@ -284,10 +298,6 @@ ob_start();
</div>
</div>
</div>
</div>
<!-- Where it starts - as the ticket's own status menu - and its tags -->
<div class="row">
<div class="col">
<div class="mb-3">
<label class="form-label">Status</label>
@@ -302,11 +312,6 @@ ob_start();
</div>
</div>
</div>
<div class="col">
<div class="mb-3">
<?= tagFormFieldHtml('ticket', [], 'Onboarding, Hardware, Escalated', 'Tags', 'data-template-field="tags"') ?>
</div>
</div>
</div>
<!-- The work booked, as the ticket's own Schedule window - a row of its own, so the date has room beside how long and where -->
@@ -328,6 +333,10 @@ ob_start();
<div class="form-text">Leave it empty to book the work later.</div>
</div>
<div class="mb-3">
<?= tagFormFieldHtml('ticket', [], 'Onboarding, Hardware, Escalated', 'Tags', 'data-template-field="tags"') ?>
</div>
<?php if ($config_module_enable_accounting) { ?>
<div class="mb-3">
<div class="form-check form-switch">

View File

@@ -1172,8 +1172,9 @@ if (!window.itflowWindowGuard) {
*/
if (!window.itflowInvalidTab) {
window.itflowInvalidTab = true;
document.addEventListener('invalid', function (e) {
const pane = e.target.closest ? e.target.closest('.tab-pane') : null;
// Also for a window that checks with the server first and marks what is wrong itself (Admin > Payment Providers, RMM Providers)
window.itflowRevealTab = function (field) {
const pane = field && field.closest ? field.closest('.tab-pane') : null;
if (!pane || pane.classList.contains('active') || !pane.id || !window.bootstrap) {
return;
}
@@ -1183,6 +1184,9 @@ if (!window.itflowInvalidTab) {
if (trigger) {
bootstrap.Tab.getOrCreateInstance(trigger).show();
}
};
document.addEventListener('invalid', function (e) {
window.itflowRevealTab(e.target);
}, true);
}