mirror of
https://github.com/itflow-org/itflow
synced 2026-11-23 21:07:22 +00:00
78 lines
5.3 KiB
PHP
78 lines
5.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Admin > Phone Systems - how to set a phone system up to send ITFlow what happens on it: the
|
|
* lines to put in its configuration, with this system's addresses and key in them, each with Copy.
|
|
* Nothing in ITFlow connects to it - it sends, to api/phone/ (functions/phone.php).
|
|
*/
|
|
|
|
require_once '../../includes/modal_header.php';
|
|
|
|
$row = phoneSystemRow($_GET['id'] ?? 0);
|
|
if (!$row || !phoneKind($row)) {
|
|
echo json_encode(['error' => $row ? 'This ITFlow doesn\'t know that phone system\'s kind.' : 'That phone system no longer exists.']);
|
|
exit;
|
|
}
|
|
$phone_system_id = intval($row['phone_system_id']);
|
|
$name = phoneSystemName($row);
|
|
$kind = phoneKind($row);
|
|
$heard = $row['phone_system_heard_at'];
|
|
|
|
// What goes in FreeSWITCH's XML - & written as & there
|
|
$xml = function (string $url) {
|
|
return htmlspecialchars($url, ENT_QUOTES | ENT_XML1, 'UTF-8');
|
|
};
|
|
$cdr_url = phoneUrl($row, 'cdr');
|
|
$cid_url = phoneUrl($row, 'cid', 'number=${caller_id_number}&domain=${domain_name}');
|
|
|
|
$snippets = [
|
|
'cdr' => '<param name="url" value="' . $xml($cdr_url) . "\"/>\n<param name=\"log-http-and-disk\" value=\"true\"/>\n<param name=\"retries\" value=\"2\"/>\n<param name=\"delay\" value=\"5\"/>",
|
|
'cid' => '<param name="url" value="' . $xml($cid_url) . "\"/>\n<param name=\"cache\" value=\"false\"/>",
|
|
'dialplan' => "<extension name=\"itflow_caller_id\" continue=\"true\">\n <condition field=\"\${caller_id_number}\" expression=\"^\\+?\\d{7,15}\$\">\n <action application=\"set\" data=\"itflow_cid=\${cidlookup(\${caller_id_number})}\" inline=\"true\"/>\n </condition>\n <condition field=\"\${itflow_cid}\" expression=\"^(?!UNKNOWN\$|-ERR).+\$\">\n <action application=\"set\" data=\"effective_caller_id_name=\${itflow_cid}\"/>\n </condition>\n</extension>",
|
|
];
|
|
|
|
$copy_block = function (string $id, string $text) {
|
|
return '<div class="position-relative">'
|
|
. '<pre class="itflow-phone-snippet small mb-0" id="' . $id . '">' . escapeHtml($text) . '</pre>'
|
|
. '<button type="button" class="btn btn-sm btn-light border position-absolute top-0 end-0 m-1 clipboardjs" data-clipboard-target="#' . $id . '" title="Copy"><i class="far fa-fw fa-copy"></i></button>'
|
|
. '</div>';
|
|
};
|
|
|
|
ob_start();
|
|
|
|
?>
|
|
<div class="modal-header bg-dark">
|
|
<h5 class="modal-title"><i class="fas fa-fw fa-plug me-2"></i>Set up <strong><?= escapeHtml($name) ?></strong></h5>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p class="small mb-2">ITFlow doesn't connect to <?= escapeHtml($kind['short']) ?> - nothing is asked of its API or its database. Instead FreeSWITCH, underneath it, is set to send ITFlow what happens, to addresses with this system's key in them. Keep them to yourself - if one gets out, New Key in its Domains page's menu changes them.</p>
|
|
<div class="small mb-3" data-phone-heard="<?= $heard ? 'yes' : 'never' ?>">
|
|
<?php if ($heard) { ?>
|
|
<i class="fas fa-fw fa-check-circle text-success me-1"></i>Heard from <span title="<?= formatDateTime($heard) ?>"><?= escapeHtml(timeAgo($heard)) ?></span>.
|
|
<?php } else { ?>
|
|
<i class="fas fa-fw fa-hourglass-half text-secondary me-1"></i>Not heard from yet - this says when it is.
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<h6 class="fw-semibold"><i class="fas fa-fw fa-history text-secondary me-1"></i>Calls</h6>
|
|
<p class="small mb-2">Each call's record comes to ITFlow as it hangs up, and is kept with the contact it was with. In <?= escapeHtml($kind['short']) ?>'s <strong>Advanced > XML Editor</strong>, or on the server, open <code>autoload_configs/xml_cdr.conf.xml</code> and set these in its <code><settings></code>, leaving its <code>log-dir</code> as it is so <?= escapeHtml($kind['short']) ?> goes on importing its own records:</p>
|
|
<?= $copy_block('phoneSnippetCdr', $snippets['cdr']) ?>
|
|
<p class="small text-body-secondary mt-2 mb-3">Then run <code>fs_cli -x 'reload mod_xml_cdr'</code>. If its <code>url</code> still points at <?= escapeHtml($kind['short']) ?>'s own <code>xml_cdr_import.php</code>, switch it to importing from files first - each record goes to one address only.</p>
|
|
|
|
<h6 class="fw-semibold"><i class="fas fa-fw fa-id-badge text-secondary me-1"></i>Caller ID</h6>
|
|
<p class="small mb-2">Calls coming in show the contact and their client on the phones - "Marla Whitfield - Ravenwood Dental". In <code>autoload_configs/cidlookup.conf.xml</code>, set:</p>
|
|
<?= $copy_block('phoneSnippetCid', $snippets['cid']) ?>
|
|
<p class="small mt-2 mb-2">Load it with <code>fs_cli -x 'reload mod_cidlookup'</code> (add <code>mod_cidlookup</code> to <code>modules.conf.xml</code> if it isn't). Then, in <strong>Dialplan > Dialplan Manager</strong>, add this to the <code>public</code> context, ordered before the inbound routes - the name is only set when ITFlow knows the number, so the carrier's stays otherwise:</p>
|
|
<?= $copy_block('phoneSnippetDialplan', $snippets['dialplan']) ?>
|
|
|
|
</div>
|
|
<div class="modal-footer">
|
|
<a class="btn btn-outline-secondary me-auto" href="phone_domains.php?phone_system_id=<?= $phone_system_id ?>"><i class="fas fa-globe me-2"></i>Domains</a>
|
|
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Close</button>
|
|
</div>
|
|
<?php
|
|
require_once '../../../includes/modal_footer.php';
|