mirror of
https://github.com/itflow-org/itflow
synced 2026-11-23 21:07:22 +00:00
Have Yealink and Polycom desk phones report themselves to ITFlow and become Phone assets of their domain client, matched by MAC address and kept up to date unless changed in ITFlow, with a phone system card on the asset and a Phones count on the Domains page
This commit is contained in:
@@ -24,10 +24,30 @@ $xml = function (string $url) {
|
||||
};
|
||||
$cdr_url = phoneUrl($row, 'cdr');
|
||||
$cid_url = phoneUrl($row, 'cid', 'number=${caller_id_number}&domain=${domain_name}');
|
||||
$hook_url = phoneUrl($row, 'hook');
|
||||
|
||||
// Yealink action URLs - the phone fills in its own $variables
|
||||
$account = 'line=$active_user&domain=$active_host';
|
||||
$yealink = [
|
||||
'setup_completed' => 'e=setup&mac=$mac&ip=$ip&model=$model&fw=$firmware',
|
||||
'registered' => "e=registered&mac=\$mac&ip=\$ip&model=\$model&fw=\$firmware&$account",
|
||||
'unregistered' => "e=unregistered&mac=\$mac&$account",
|
||||
'register_failed' => "e=failed&mac=\$mac&$account",
|
||||
'incoming_call' => "e=ringing&mac=\$mac&$account&number=\$remote&name=\$display_remote&call=\$call_id",
|
||||
'outgoing_call' => "e=outgoing&mac=\$mac&$account&number=\$remote&name=\$display_remote&call=\$call_id",
|
||||
'call_established' => "e=answered&mac=\$mac&$account&number=\$remote&call=\$call_id",
|
||||
'call_terminated' => "e=ended&mac=\$mac&$account&number=\$remote&call=\$call_id",
|
||||
];
|
||||
$yealink_lines = [];
|
||||
foreach ($yealink as $event => $query) {
|
||||
$yealink_lines[] = "action_url.$event = $hook_url&$query";
|
||||
}
|
||||
|
||||
$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\"/>",
|
||||
'yealink' => implode("\n", $yealink_lines),
|
||||
'polycom' => '<telNotification apps.telNotification.URL="' . $xml($hook_url) . "\"\n apps.telNotification.incomingEvent=\"1\" apps.telNotification.outgoingEvent=\"1\"\n apps.telNotification.callStateChangeEvent=\"1\" apps.telNotification.lineRegistrationEvent=\"1\"\n apps.telNotification.uiInitializationEvent=\"1\"/>",
|
||||
'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>",
|
||||
];
|
||||
|
||||
@@ -68,6 +88,12 @@ ob_start();
|
||||
<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']) ?>
|
||||
|
||||
<h6 class="fw-semibold mt-3"><i class="fas fa-fw fa-phone text-secondary me-1"></i>Phones</h6>
|
||||
<p class="small mb-2">Desk phones tell ITFlow their model, firmware, IP address and line as they start up and register, and each becomes a Phone asset of its domain's client, kept by its MAC address. They reach ITFlow themselves, so they need to be able to get to its address. For Yealink phones, add these lines to the template <?= escapeHtml($kind['short']) ?> provisions them with and have the phones check for new settings - or, for one phone, enter each address in its web page under <strong>Features > Action URL</strong>:</p>
|
||||
<?= $copy_block('phoneSnippetYealink', $snippets['yealink']) ?>
|
||||
<p class="small mt-2 mb-2">For Polycom phones, add this to the configuration they are provisioned with:</p>
|
||||
<?= $copy_block('phoneSnippetPolycom', $snippets['polycom']) ?>
|
||||
|
||||
</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>
|
||||
|
||||
@@ -59,6 +59,7 @@ $filter_url = function (array $change) {
|
||||
$sortable_columns = [
|
||||
'phone_domain_name' => "phone_domain_name $order",
|
||||
'calls_month' => "calls_month $order, phone_domain_name ASC",
|
||||
'phones' => "phones $order, phone_domain_name ASC",
|
||||
'client_name' => "client_name IS NULL, client_name $order, phone_domain_name ASC",
|
||||
'phone_domain_seen_at' => "phone_domain_seen_at IS NULL, phone_domain_seen_at $order, phone_domain_name ASC",
|
||||
];
|
||||
@@ -67,7 +68,8 @@ if (!isset($sortable_columns[$sort])) {
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS phone_domains.*, client_name, client_abbreviation, client_archived_at,
|
||||
(SELECT COUNT(*) FROM phone_calls WHERE phone_call_domain_id = phone_domains.phone_domain_id AND phone_call_started_at >= NOW() - INTERVAL 30 DAY) AS calls_month
|
||||
(SELECT COUNT(*) FROM phone_calls WHERE phone_call_domain_id = phone_domains.phone_domain_id AND phone_call_started_at >= NOW() - INTERVAL 30 DAY) AS calls_month,
|
||||
(SELECT COUNT(*) FROM phone_devices WHERE phone_device_domain_id = phone_domains.phone_domain_id) AS phones
|
||||
FROM phone_domains
|
||||
LEFT JOIN clients ON client_id = phone_domain_client_id AND phone_domain_client_id > 0
|
||||
WHERE phone_domain_system_id = $phone_system_id AND {$shows[$show]['sql']}
|
||||
@@ -170,6 +172,7 @@ $own_client = intval($config_internal_client_id ?? 0);
|
||||
<tr>
|
||||
<th class="ps-3"><?= sortLink('phone_domain_name', 'Domain') ?></th>
|
||||
<th class="d-none d-md-table-cell"><?= sortLink('calls_month', 'Calls, 30 days') ?></th>
|
||||
<th class="d-none d-lg-table-cell"><?= sortLink('phones', 'Phones') ?></th>
|
||||
<th><?= sortLink('client_name', 'ITFlow client') ?></th>
|
||||
<th class="d-none d-lg-table-cell"><?= sortLink('phone_domain_seen_at', 'Last heard from') ?></th>
|
||||
<th></th>
|
||||
@@ -186,7 +189,7 @@ $own_client = intval($config_internal_client_id ?? 0);
|
||||
<tr data-phone-domain-id="<?= $phone_domain_id ?>">
|
||||
<td class="ps-3">
|
||||
<div class="fw-semibold font-monospace small"><?= escapeHtml($row['phone_domain_name']) ?></div>
|
||||
<div class="d-md-none small text-body-secondary"><?= number_format(intval($row['calls_month'])) ?> calls</div>
|
||||
<div class="d-md-none small text-body-secondary"><?= number_format(intval($row['calls_month'])) ?> calls<?= intval($row['phones']) ? ' · ' . number_format(intval($row['phones'])) . ' phones' : '' ?></div>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell text-nowrap">
|
||||
<?php if ($linked && intval($row['calls_month'])) { ?>
|
||||
@@ -196,6 +199,7 @@ $own_client = intval($config_internal_client_id ?? 0);
|
||||
<?= number_format(intval($row['calls_month'])) ?>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="d-none d-lg-table-cell" title="Desk phones on it that told ITFlow about themselves"><?= number_format(intval($row['phones'])) ?></td>
|
||||
<td>
|
||||
<?php if ($linked) { ?>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user