Files
itflow/client/includes/contact_form.php
johnnyq 5e77edb077 Client portal stage 3: Your IT - Devices with tabs by kind (Computers, Servers, Network, Phones and tablets, Other) with counts, an Everyone's or Mine filter, search and warranty badges when expired or expiring; a device page with make and model, serial, OS, user, location, purchase date and age, warranty, status, open tickets and licenses on it, Report a problem opening a new ticket with the device picked and plain contacts reaching their own devices from home; Licenses with All, Renewing soon and Expired tabs showing seats in use and renewal state without license keys; Domains and certificates on one page with registrar, DNS, website and email vendors, expiry and auto-renew, and a certificates tab with short-lived certificates shown as renewing themselves, the old certificates page redirecting there; Documents as a help library of client-visible documents with folder tabs and full-text search, a document page keeping its own tables and colours under a widened style policy, files to open or download with the first PDF or image shown inline, Print and Ask us about it, and new documents written in the editor or uploaded as a file with an agent notification; Contacts listing everyone primary first with roles and search, and the primary contact alone adding and editing contacts, giving portal access with an emailed set-password or Microsoft 365 invite, resending it, turning access off and marking someone as left, which turns off access and opens an offboarding ticket, all audited and notified; home renewals and devices linking to their pages; fixes a technical contact being able to change the primary contact's login email, revoked contacts staying signed in, portal documents recording the contact id as author, the upload stub going in unescaped and gated pages leaving a bare header; check_login ends sessions without a sign-in method, header.php buffers output so gates redirect properly, enforceContactCan sends contacts home with a message instead of logging them out, add_contact and edit_contact replaced by portal_contact_save, portal_contact_access and portal_contact_left, new Your IT helpers in client/functions.php and portal tile, roles, PDF and document styles; changelog updated
2026-10-17 02:40:59 -04:00

120 lines
7.4 KiB
PHP

<?php
/*
* Client Portal
* The contact form - adding a person, or the primary contact changing one -
* for client/contact.php, which sets $new, $contact (null when new), $value
* (what to show in each field) and $methods (portalSignInMethods()).
* Posts portal_contact_save to post.php.
*/
isset($value) || die("Direct file access is not allowed");
$phone_input = $value('contact_phone') !== '' ? formatPhoneNumber($value('contact_phone'), $value('contact_phone_country_code'), false) : '';
$mobile_input = $value('contact_mobile') !== '' ? formatPhoneNumber($value('contact_mobile'), $value('contact_mobile_country_code'), false) : '';
?>
<form class="itflow-portal-panel" action="post.php" method="post" autocomplete="off" data-portal-once>
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="contact_id" value="<?= intval($contact['contact_id'] ?? 0) ?>">
<div class="itflow-portal-panel-head">
<h2><i class="fas fa-address-card"></i>Details</h2>
</div>
<div class="itflow-portal-panel-body">
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label" for="contactName">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
<input type="text" class="form-control" id="contactName" name="contact_name" value="<?= escapeHtml($value('contact_name')) ?>" required maxlength="200"<?= $new ? ' autofocus' : '' ?>>
</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label" for="contactTitle">Job title</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-id-badge"></i></span>
<input type="text" class="form-control" id="contactTitle" name="contact_title" value="<?= escapeHtml($value('contact_title')) ?>" maxlength="200">
</div>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="contactEmail">Email <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
<input type="email" class="form-control" id="contactEmail" name="contact_email" value="<?= escapeHtml($value('contact_email')) ?>" required maxlength="200">
</div>
<?php if (!$new && !empty($contact['user_id'])) { ?><div class="form-text">It is also the address they sign in with.</div><?php } ?>
</div>
<div class="row">
<div class="col-sm-8 mb-3">
<label class="form-label" for="contactPhone">Phone</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<input type="hidden" name="contact_phone_country_code" value="<?= escapeHtml($value('contact_phone_country_code')) ?>">
<input type="tel" class="form-control" id="contactPhone" name="contact_phone" value="<?= escapeHtml($phone_input) ?>" maxlength="200" data-itflow-phone="contact_phone_country_code">
</div>
</div>
<div class="col-sm-4 mb-3">
<label class="form-label" for="contactExtension">Extension</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-hashtag"></i></span>
<input type="text" class="form-control" id="contactExtension" name="contact_extension" inputmode="numeric" maxlength="20" value="<?= escapeHtml($value('contact_extension')) ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-8 mb-3">
<label class="form-label" for="contactMobile">Mobile</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
<input type="hidden" name="contact_mobile_country_code" value="<?= escapeHtml($value('contact_mobile_country_code')) ?>">
<input type="tel" class="form-control" id="contactMobile" name="contact_mobile" value="<?= escapeHtml($mobile_input) ?>" maxlength="200" data-itflow-phone="contact_mobile_country_code">
</div>
</div>
<div class="col-sm-4 mb-3">
<label class="form-label" for="contactDepartment">Department</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-sitemap"></i></span>
<input type="text" class="form-control" id="contactDepartment" name="contact_department" value="<?= escapeHtml($value('contact_department')) ?>" maxlength="200">
</div>
</div>
</div>
<fieldset class="mb-3">
<legend class="form-label fs-6">Roles</legend>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="contactBilling" name="contact_billing" value="1"<?= intval($value('contact_billing', '0')) ? ' checked' : '' ?>>
<label class="form-check-label" for="contactBilling">Billing <span class="d-block small text-body-secondary">Sees and pays invoices, quotes and statements, and gets the billing emails</span></label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="contactTechnical" name="contact_technical" value="1"<?= intval($value('contact_technical', '0')) ? ' checked' : '' ?>>
<label class="form-check-label" for="contactTechnical">Technical <span class="d-block small text-body-secondary">Sees every ticket at <?= escapeHtml($session_client_name) ?>, and the devices, licenses and documents</span></label>
</div>
</fieldset>
<?php if ($new) { ?>
<fieldset class="itflow-portal-note d-block mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="contactInvite" name="invite" value="1"<?= !isset($form) || !empty($form['invite']) ? ' checked' : '' ?>>
<label class="form-check-label" for="contactInvite">Give them portal access and email an invite <span class="d-block small text-body-secondary">So they can raise and follow tickets here themselves</span></label>
</div>
<?php if (count($methods) > 1) { ?>
<div class="input-group mt-2">
<span class="input-group-text"><i class="fa fa-fw fa-sign-in-alt"></i></span>
<select class="form-select" name="method" aria-label="How they sign in">
<?php foreach ($methods as $key => $label) { ?>
<option value="<?= $key ?>"<?= ($form['method'] ?? '') === $key ? ' selected' : '' ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
</div>
<?php } ?>
</fieldset>
<?php } ?>
<button type="submit" class="btn btn-primary" name="portal_contact_save"><i class="fas fa-check me-2"></i><?= $new ? 'Add them' : 'Save' ?></button>
</div>
</form>