<?php
/**
 * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
 *
 * @author Double Bastion LLC
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

declare(strict_types=1);

style('sip_trip_phone', 'style');
script('sip_trip_phone', 'settings');

?>

<div id="sip_trip_phone_adm">
	<div class="section">
           <h2><?php p($l->t('SIP Trip Phone'));?></h2>
	   <p id="settings-dscr"><?php p($l->t('Enter your credentials and options in the fields from below:')); ?></p><br>

           <div class="stp_followupsection">

                <form id="asterisk_credentials" action="#" >

                   <p><label for="pdisplayname"><b><?php p($l->t('Display Name:'));?></b></label></p>
                   <input type="text" class="sip_trip_box" id="pdisplayname" name="pdisplayname" autocomplete="false"
                          placeholder="E.g.: Ben Dove or +15012345670" /><br>

                   <p><label for="sipusername"><b><?php p($l->t('SIP User:'));?></b></label></p>
                   <input type="text" class="sip_trip_box" id="sipusername" name="sipusername" autocomplete="false"
                          placeholder="E.g.: 1610  or john_doe" /><br>

                   <p><label for="sipuserpassword"><b><?php p($l->t('SIP User Password:'));?></b></label></p>
                   <input type="password" class="sip_trip_box" id="sipuserpassword" name="sipuserpassword" autocomplete="false"
                          placeholder="E.g.: r?2V!s5w9Q&d7W?8" /><br>

                   <p><label for="stphwssurl"><b><?php p($l->t('WSS URL:'));?></b></label></p>
                   <input type="text" class="sip_trip_box" id="stphwssurl" name="stphwssurl" autocomplete="false"
                          placeholder="E.g.: wss://cloud.example.com:8089/ws" /><br>

                   <p id="labelSipRealm"><label for="siprealm"><b><?php p($l->t('SIP Realm  (the IPv4 address of your Asterisk server or the domain from the WSS URL offered by the SIP provider):'));?></b></label></p>
                   <input type="text" class="sip_trip_box" id="siprealm" name="siprealm" autocomplete="false"
                          placeholder="E.g.: 123.123.123.123 or sip.example.com" /><br>

                   <p id="stunServer"><label for="stunserver"><b><?php p($l->t("STUN Server's IPv4 address and port number or domain and port number (optional):"));?></b></label></p>
                   <input type="text" class="sip_trip_box" id="stunserver" name="stunserver" autocomplete="false"
                          placeholder="E.g.: 123.123.123.123:8443 or stun.domain.com:3478" /><br>

                   <p id="debugLogging"><label for="tracesipmsg"><b><?php p($l->t("Show debug logging in my browser's console:"));?></b></label></p>
                   <input type="checkbox" id="tracesipmsg" name="tracesipmsg" autocomplete="false" /><br>

                   <div id="voiceNumbers"><label for="voicenumbers"><b><?php p($l->t('Available phone number(s):'));?></b><div class="stpVoicePhNoTip"><span id="stpVoicePhNoInfo">i</span><div class="stpVoicePhNoText">Enter all the phone numbers that you have configured in Asterisk and your SIP provider(s), for making voice phone calls. Each number must be preceded by the <a href="https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_order" target="_blank" rel="noreferrer noopener" style="color:#1b60ba">country calling code</a>, the plus sign and the 2 letter abbreviation of your SIP provider's name. For example, if you use the US phone number 3076543210 rented from Telnyx, and the UK phone number 7654321012 rented from Localphone, you should enter:<br> Tx: +13076543210,Ln: +447654321012 <br>where Tx stands for Telnyx, 1 is the country calling code for US, Ln stands for Localphone and 44 is the country calling code for UK. There is a space before each plus sign and there is no space before each comma. The 2 letter abbreviation for Telnyx is Tx , for Localphone is Ln , for Flowroute is Fl , for Twilio is Tw and for Vonage is Vn . If you use other providers you can create a different 2 letter abbreviation for each, so as to easily identify it. You have to treat each abbreviation differently in the dial plan, as explained in the <a href="https://www.doublebastion.com/install-asterisk/#testing-asterisk" target="_blank" rel="noreferrer noopener" style="color:#1b60ba">documentation</a>, so that Asterisk knows which SIP provider and phone number to use for each outbound call. <b>This list of phone numbers allows you to set any of them as the 'From' number, when making phone calls.</b> If you are not using Asterisk and you connect SIP Trip Phone directly to the SIP provider, you can leave this field empty.</div></div></label></div>
                   <input type="text" class="sip_trip_box" id="voicenumbers" name="voicenumbers" autocomplete="false" placeholder="Eg: Tx: +15676543210,Ln: +491234567891,Fl: +347865432101" /><br>

                   <div id="dftVoiceNumber"><label for="defaultvoicenumber"><b><?php p($l->t('Default phone number for outgoing calls (optional):'));?></b><div class="stpdtVoicePhNoTip"><span id="stpdtVoicePhNoInfo">i</span><div class="stpdtVoicePhNoText">Enter the phone number configured for voice calls in Asterisk and your SIP provider, that you want to use as the default 'From' number when making phone calls. If you set a number here and you make a phone call without choosing a 'From' number from the drop-down list on the phone window, the number from this field is automatically chosen as the 'From' number and the receiver sees the call as coming from this number. If you leave this field empty, the first phone number from the numbers listed in the 'Available phone number(s)' field from above is used as the 'From' number for outbound phone calls. The phone number must be preceded by the <a href="https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_order" target="_blank" rel="noreferrer noopener" style="color:#1b60ba">country calling code</a>, the plus sign and the 2 letter abbreviation of your SIP provider's name. For example, if you want to set as default 'From' number for outbound calls the US number 3076543210 rented from Telnyx, you have to enter Tx: +13076543210 . There is a space before the plus sign. The 2 letter abbreviation for Telnyx is Tx , for Localphone is Ln , for Flowroute is Fl , for Twilio is Tw and for Vonage is Vn . If you use other providers you can create a different 2 letter abbreviation for each, so as to easily identify it. You have to treat each abbreviation differently in the dial plan, as explained in the <a href="https://www.doublebastion.com/install-asterisk/#testing-asterisk" target="_blank" rel="noreferrer noopener" style="color:#1b60ba">documentation</a>, so that Asterisk knows which SIP provider and phone number to use for each outbound call. If you are not using Asterisk and you connect SIP Trip Phone directly to the SIP provider, you can leave this field empty.</div></div></label></div>
                   <input type="text" class="sip_trip_box" id="defaultvoicenumber" name="defaultvoicenumber" autocomplete="false" placeholder="Eg: Tx: +15676543210" /><br>

                   <input type="hidden" id="user_id" name="user_id" /><br>

                   <input id="save_sipph_settings" type="submit" value="<?php p($l->t('Save')) ?>" />

                   <span id="sip_trip_phone_save_msg"></span>

               </form>
           </div>
        </div>
</div>
