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

@@ -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">