diff --git a/public/api.php b/public/api.php index e404a32..6a01db2 100644 --- a/public/api.php +++ b/public/api.php @@ -1133,6 +1133,7 @@ try { $custom_aor_params = trim((string)($payload['custom_aor_params'] ?? '')); $moh_sound_id = max(0, (int)($payload['moh_sound_id'] ?? 0)); $cid_name_prefix = trim((string)($payload['cid_name_prefix'] ?? '')); + $dial_options = preg_replace('/[^a-zA-Z0-9(),]/', '', trim((string)($payload['dial_options'] ?? 'tTR'))) ?: 'tTR'; $enabled = isset($payload['enabled']) ? (int)!empty($payload['enabled']) : 1; $didRoutesRaw = is_array($payload['did_routes'] ?? null) ? $payload['did_routes'] : []; @@ -1203,6 +1204,7 @@ try { ':custom_aor_params' => $custom_aor_params, ':moh_sound_id' => $moh_sound_id, ':cid_name_prefix' => $cid_name_prefix, + ':dial_options' => $dial_options, ':enabled' => $enabled, ]; @@ -1230,6 +1232,7 @@ try { outbound_prefix = :outbound_prefix, custom_endpoint_params = :custom_endpoint_params, custom_reg_params = :custom_reg_params, custom_aor_params = :custom_aor_params, moh_sound_id = :moh_sound_id, cid_name_prefix = :cid_name_prefix, + dial_options = :dial_options, enabled = :enabled WHERE id = :id '); @@ -1245,7 +1248,7 @@ try { qualify_frequency, max_channels, timers, language, rtp_keepalive, t38_udptl, fax_detect, inband_progress, match_ips, context, inbound_dest, did_routes_json, outbound_prefix, custom_endpoint_params, custom_reg_params, custom_aor_params, moh_sound_id, - cid_name_prefix, enabled + cid_name_prefix, dial_options, enabled ) VALUES ( :name, :host, :port, :outbound_proxy, :transport, :auth_mode, :username, :auth_username, :secret, :registration_mode, :register, :server_uri, :client_uri, :contact_user, :expiration, :retry_interval, @@ -1255,7 +1258,7 @@ try { :qualify_frequency, :max_channels, :timers, :language, :rtp_keepalive, :t38_udptl, :fax_detect, :inband_progress, :match_ips, :context, :inbound_dest, :did_routes_json, :outbound_prefix, :custom_endpoint_params, :custom_reg_params, :custom_aor_params, :moh_sound_id, - :cid_name_prefix, :enabled + :cid_name_prefix, :dial_options, :enabled ) ON CONFLICT(name) DO UPDATE SET host = excluded.host, port = excluded.port, outbound_proxy = excluded.outbound_proxy, @@ -1279,6 +1282,7 @@ try { custom_reg_params = excluded.custom_reg_params, custom_aor_params = excluded.custom_aor_params, moh_sound_id = excluded.moh_sound_id, cid_name_prefix = excluded.cid_name_prefix, + dial_options = excluded.dial_options, enabled = excluded.enabled '); $stmt->execute($params); diff --git a/public/assets/app.js b/public/assets/app.js index 8823b1f..243a13e 100644 --- a/public/assets/app.js +++ b/public/assets/app.js @@ -2032,6 +2032,13 @@ function syncTrunkHostDomain(hostVal) { form.elements['from_domain'].value = ''; } +function setTrunkDialOptionsPreset(val) { + const form = document.getElementById('form-trunk'); + if (form && form.elements['dial_options']) { + form.elements['dial_options'].value = val; + } +} + function populateInboundDestDropdown(selectedValue = '101') { const select = document.getElementById('trunk-inbound-select'); const form = document.getElementById('form-trunk'); @@ -2096,6 +2103,7 @@ function parseFreePbxConfig() { if (val.includes('toheader')) form.elements['context'].value = 'from-pstn-toheader'; else form.elements['context'].value = 'from-external'; } + else if (key === 'dialopts' || key === 'dial_options' || key === 'asterisk_trunk_dial_options') form.elements['dial_options'].value = val; else if (key === 'outboundproxy') form.elements['outbound_proxy'].value = val; }); @@ -2324,6 +2332,9 @@ function openTrunkModal(trunk = null) { if (form.elements['cid_name_prefix']) { form.elements['cid_name_prefix'].value = trunk ? (trunk.cid_name_prefix || '') : ''; } + if (form.elements['dial_options']) { + form.elements['dial_options'].value = trunk ? (trunk.dial_options || 'tTR') : 'tTR'; + } populateInboundDestDropdown(trunk ? (trunk.inbound_dest || '101') : '101'); // Musique d'attente (MoH) spécifique à ce Trunk diff --git a/public/index.php b/public/index.php index 18651a4..42aabb4 100644 --- a/public/index.php +++ b/public/index.php @@ -3517,6 +3517,28 @@ $currentUser = Auth::getUsername(); + + +
+
+ +

+ Paramètres transmis à l'application Asterisk Dial() pour ce Trunk. R génère la tonalité de sonnerie locale (indispensable pour les passerelles analogiques/FXO type HT813/Livebox). T/t autorise le transfert DTMF. +

+
+
+ +
+ + + +
+
+
diff --git a/src/ConfigGenerator.php b/src/ConfigGenerator.php index 2c6966a..41f129e 100644 --- a/src/ConfigGenerator.php +++ b/src/ConfigGenerator.php @@ -1174,8 +1174,9 @@ class ConfigGenerator $tEpName = ($tObj && ($tObj['registration_mode'] ?? '') === 'receive' && !empty($tObj['username'])) ? $tObj['username'] : "trunk-{$tSlug}"; + $dialOpts = ($tObj && !empty($tObj['dial_options'])) ? trim((string)$tObj['dial_options']) : 'tTR'; $sub[] = " same => n,NoOp(Route [{$rName}] - Tentative Trunk #{$validTrunkCount} [{$tEpName}] vers \${OUTNUM})"; - $sub[] = " same => n,Dial(PJSIP/\${OUTNUM}@{$tEpName},60,tTR)"; + $sub[] = " same => n,Dial(PJSIP/\${OUTNUM}@{$tEpName},60,{$dialOpts})"; $sub[] = " same => n,GotoIf(\$[\"\${DIALSTATUS}\" = \"ANSWER\" | \"\${DIALSTATUS}\" = \"BUSY\" | \"\${DIALSTATUS}\" = \"NOANSWER\" | \"\${DIALSTATUS}\" = \"CANCEL\"]?call_done)"; $sub[] = " same => n,NoOp(Trunk [{$tEpName}] indisponible [\${DIALSTATUS}] -> Passage au Trunk / Route suivant)"; } diff --git a/src/Database.php b/src/Database.php index 5fc63ed..3830098 100644 --- a/src/Database.php +++ b/src/Database.php @@ -164,6 +164,7 @@ class Database outbound_prefix VARCHAR(32) NOT NULL DEFAULT '', custom_endpoint_params TEXT NOT NULL DEFAULT '', cid_name_prefix VARCHAR(64) NOT NULL DEFAULT '', + dial_options VARCHAR(32) NOT NULL DEFAULT 'tTR', enabled INTEGER NOT NULL DEFAULT 1 CHECK (enabled IN (0, 1)), created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); @@ -578,6 +579,7 @@ class Database 'custom_aor_params' => "TEXT NOT NULL DEFAULT ''", 'moh_sound_id' => "INTEGER NOT NULL DEFAULT 0", 'cid_name_prefix' => "VARCHAR(64) NOT NULL DEFAULT ''", + 'dial_options' => "VARCHAR(32) NOT NULL DEFAULT 'tTR'", ]; foreach ($extraColumns as $colName => $colDef) {