mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
Text messaging Receive only: database 4.3.6 adds sms_providers.sms_provider_send, and a provider set to Receive only in its window takes texts in as tickets, replies and codes and texts nothing out (no Text reply, ticket number, STOP or HELP answers, texts to clients or test texts), needs no SID or secret, cancels the texts waiting to go when switched, and is shown on Text Messaging, Text Messages, Notifications and Tickets settings and in the reply box of a ticket that came in by text, with the number to call; 26.12.3 changelog
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
/*
|
||||
* Admin > Text Messaging - one provider's window: Add (no id, or from sms_provider_add.php)
|
||||
* or Edit. Its SID and secret - the secret never put back into the page, so left empty it
|
||||
* stays - the number texts go from, and whether it is on. Save asks first (check_sms_provider,
|
||||
* or Edit. Whether it sends and receives or is Receive only (database 4.3.6), its SID and
|
||||
* secret - needed only to send; the secret never put back into the page, so left empty it
|
||||
* stays - your number, and whether it is on. Save asks first (check_sms_provider,
|
||||
* admin/post/sms_provider.php): what is wrong shows beside each field and the window stays
|
||||
* open; once all is right, it saves.
|
||||
*/
|
||||
@@ -28,6 +29,9 @@ $free_kinds = array_diff_key($kinds, $taken);
|
||||
$name = $row ? (string) $row['sms_provider_name'] : (string) (array_key_first($free_kinds) ?? array_key_first($kinds));
|
||||
$kind = $kinds[$name] ?? reset($kinds);
|
||||
$number = $row ? smsNumberText($row['sms_provider_number']) : '';
|
||||
// Send and receive, or Receive only - after the 4.3.6 database update
|
||||
$can_receive_only = smsColumnExists('sms_providers', 'sms_provider_send');
|
||||
$sends = !$row || smsSends($row);
|
||||
|
||||
// Where what is wrong with a field shows
|
||||
$error_for = function ($field) {
|
||||
@@ -69,12 +73,26 @@ ob_start();
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" class="form-check-input" name="active" value="1" id="smsProviderActive" <?= intval($row['sms_provider_active']) ? 'checked' : '' ?>>
|
||||
<label class="form-check-label" for="smsProviderActive">On - texts go out, and texts to the number come in</label>
|
||||
<label class="form-check-label" for="smsProviderActive">On - texts to the number come in<?= $sends ? ', and texts go out' : '' ?></label>
|
||||
</div>
|
||||
<div class="form-text ps-5">Off, nothing is texted and texts to the number aren't taken in. Texts waiting to go wait.</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($can_receive_only) { ?>
|
||||
<div class="mb-3" data-sms-send-choice>
|
||||
<label class="form-label d-block">Texts</label>
|
||||
<div class="btn-group flex-wrap" role="group" aria-label="Texts">
|
||||
<input type="radio" class="btn-check" name="send" value="1" id="smsProviderSend" <?= $sends ? 'checked' : '' ?>>
|
||||
<label class="btn btn-outline-secondary" for="smsProviderSend"><i class="fas fa-fw fa-exchange-alt me-1"></i>Send and receive</label>
|
||||
<input type="radio" class="btn-check" name="send" value="0" id="smsProviderReceiveOnly" <?= $sends ? '' : 'checked' ?>>
|
||||
<label class="btn btn-outline-secondary" for="smsProviderReceiveOnly"><i class="fas fa-fw fa-inbox me-1"></i>Receive only</label>
|
||||
</div>
|
||||
<div class="form-text" data-sms-send-help="1" <?= $sends ? '' : 'hidden' ?>>Texts come in, and ITFlow texts back: replies on tickets, the ticket number for a new one, and the texts to clients in Settings > Notifications.</div>
|
||||
<div class="form-text" data-sms-send-help="0" <?= $sends ? 'hidden' : '' ?>>Texts to your number still become tickets, replies on tickets and verification codes - nothing is texted out. Replies go by email or the portal. No keys are needed, and the number doesn't have to be registered for sending.<?= $row && $sends ? ' Texts waiting to go are cancelled when you save.' : '' ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="smsProviderDescription">Description</label>
|
||||
<div class="input-group has-validation">
|
||||
@@ -85,20 +103,21 @@ ob_start();
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="smsProviderNumber">Number texts go from <strong class="text-danger">*</strong></label>
|
||||
<label class="form-label" for="smsProviderNumber">Your number <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-phone"></i></span>
|
||||
<input type="tel" class="form-control" name="number" id="smsProviderNumber" maxlength="30" placeholder="+1 412 555 0100" value="<?= escapeHtml($number) ?>">
|
||||
</div>
|
||||
<?= $error_for('number') ?>
|
||||
<div class="form-text">SMS-enabled in <?= escapeHtml($name) ?>'s portal - and, for a US number, registered for texting there, or carriers block what it sends.</div>
|
||||
<div class="form-text">SMS-enabled in <?= escapeHtml($name) ?>'s portal - and, to send from a US number, registered for texting there, or carriers block what it sends.</div>
|
||||
</div>
|
||||
|
||||
<h6 class="fw-semibold mt-4 mb-1">Keys</h6>
|
||||
<p class="small text-body-secondary mb-2">From <a href="<?= escapeHtml($kind['portal_url']) ?>" target="_blank" rel="noopener noreferrer"><?= escapeHtml($name) ?>'s portal <i class="fas fa-external-link-alt fa-xs"></i></a> - the gear at the top right, then API Keys.</p>
|
||||
<p class="small text-body-secondary mb-2">From <a href="<?= escapeHtml($kind['portal_url']) ?>" target="_blank" rel="noopener noreferrer"><?= escapeHtml($name) ?>'s portal <i class="fas fa-external-link-alt fa-xs"></i></a> - the gear at the top right, then API Keys.
|
||||
<span data-sms-keys-optional <?= $sends ? 'hidden' : '' ?>>Only needed to send - leave them empty for Receive only, or fill them in now for later.</span></p>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="smsProviderUsername"><?= escapeHtml($kind['username_label']) ?> <strong class="text-danger">*</strong></label>
|
||||
<label class="form-label" for="smsProviderUsername"><?= escapeHtml($kind['username_label']) ?> <strong class="text-danger" data-sms-key-needed <?= $sends ? '' : 'hidden' ?>>*</strong></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-id-badge"></i></span>
|
||||
<input type="text" class="form-control font-monospace" name="username" id="smsProviderUsername" maxlength="250" spellcheck="false" value="<?= escapeHtml($row['sms_provider_username'] ?? '') ?>">
|
||||
@@ -107,7 +126,7 @@ ob_start();
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="smsProviderSecret"><?= escapeHtml($kind['secret_label']) ?> <?= $row ? '' : '<strong class="text-danger">*</strong>' ?></label>
|
||||
<label class="form-label" for="smsProviderSecret"><?= escapeHtml($kind['secret_label']) ?> <?= $row ? '' : '<strong class="text-danger" data-sms-key-needed' . ($sends ? '' : ' hidden') . '>*</strong>' ?></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-key"></i></span>
|
||||
<input type="password" class="form-control font-monospace" name="secret" id="smsProviderSecret" maxlength="500" spellcheck="false" autocomplete="new-password"
|
||||
@@ -147,6 +166,16 @@ ob_start();
|
||||
var save = form.querySelector('[data-sms-provider-save]');
|
||||
var checked = false;
|
||||
|
||||
// Send and receive, or Receive only - which help shows, and whether the keys are needed
|
||||
form.querySelectorAll('input[name="send"]').forEach(function (radio) {
|
||||
radio.addEventListener('change', function () {
|
||||
var sends = form.querySelector('input[name="send"]:checked').value === '1';
|
||||
form.querySelectorAll('[data-sms-send-help]').forEach(function (el) { el.hidden = el.getAttribute('data-sms-send-help') !== (sends ? '1' : '0'); });
|
||||
form.querySelectorAll('[data-sms-key-needed]').forEach(function (el) { el.hidden = !sends; });
|
||||
form.querySelectorAll('[data-sms-keys-optional]').forEach(function (el) { el.hidden = sends; });
|
||||
});
|
||||
});
|
||||
|
||||
function clearErrors() {
|
||||
form.querySelectorAll('.is-invalid').forEach(function (el) { el.classList.remove('is-invalid'); });
|
||||
form.querySelectorAll('[data-error-for]').forEach(function (el) {
|
||||
|
||||
Reference in New Issue
Block a user