Portal - allow editing client contacts, few tweaks to header incl session notifications

This commit is contained in:
wrongecho 2024-09-05 15:44:06 +01:00
parent 92681a86b3
commit 726aaac56a
2 changed files with 19 additions and 1 deletions

View File

@ -32,6 +32,7 @@ if ($row) {
$contact_primary = intval($row['contact_primary']);
$contact_technical = intval($row['contact_technical']);
$contact_billing = intval($row['contact_billing']);
$contact_auth_method = nullable_htmlentities($row['contact_auth_method']);
} else {
header("Location: portal_post.php?logout");
exit();
@ -96,6 +97,22 @@ if ($row) {
</div>
</div>
<div class="form-group">
<label>Portal authentication</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user-circle"></i></span>
</div>
<select class="form-control select2 authMethod" name="contact_auth_method">
<option value="">- No portal access -</option>
<option value="local" <?php if ($contact_auth_method == "local") { echo "selected"; } ?>>Local (Email and password)</option>
<?php if (!empty($config_azure_client_id)) { ?>
<option value="azure" <?php if ($contact_auth_method == "azure") { echo "selected"; } ?>>Azure (Microsoft 365)</option>
<?php } ?>
</select>
</div>
</div>
<?php if ($contact_primary) { echo "<i>Cannot edit the primary contact</i>"; } else { ?>
<button class="btn btn-primary" name="edit_contact">Save</button>
<?php } ?>

View File

@ -294,8 +294,9 @@ if (isset($_POST['edit_contact'])) {
$contact_email = sanitizeInput($_POST['contact_email']);
$contact_technical = intval($_POST['contact_technical']);
$contact_billing = intval($_POST['contact_billing']);
$contact_auth_method = sanitizeInput($_POST['contact_auth_method']);
mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$contact_name', contact_email = '$contact_email', contact_billing = $contact_billing, contact_technical = $contact_technical WHERE contact_id = $contact_id AND contact_client_id = $session_client_id AND contact_archived_at IS NULL AND contact_primary = 0");
mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$contact_name', contact_email = '$contact_email', contact_billing = $contact_billing, contact_technical = $contact_technical, contact_auth_method = '$contact_auth_method' WHERE contact_id = $contact_id AND contact_client_id = $session_client_id AND contact_archived_at IS NULL AND contact_primary = 0");
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = 'Client $session_contact_name modified contact $contact_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $session_client_id, log_entity_id = $contact_id");