<?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);

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

?>

<div id="sms_relentless_adm">
        <div class="section">
           <h2><?php p($l->t('SMS Relentless'));?></h2>

           <div id="appTitlePrg"></div>

           <div class="sms_followupsection">

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

                   <div id="nadmProvSection"></div>

                   <p><label for="messagesperpage" class="setlabeltext"><b>Number of messages per page</b> (Enter the number of messages to be displayed on one page of the
                          received/sent/grouped messages tables. If you leave this field empty, the default of 100 messages per page will be used.):</label></p>
                   <input type="number" class="smsr_textbox" id="messagesperpage" name="messagesperpage" autocomplete="false" placeholder="e.g. 100"/><br><br>

                   <p><label for="messagesperpage" class="setlabeltext"><b>Number of archived conversations to display</b> (Enter the number of archived conversations that 
                          will be listed on the Conversations page. If you enter 10, only the last 10 archived conversations will be displayed. To list all the archived 
                          conversations, leave this field empty. After you make a change here, reload the app in the browser to see the results.):</label></p>
                   <input type="number" class="smsr_textbox" id="archivedconvnmbr" name="archivedconvnmbr" autocomplete="false" placeholder="e.g. 10"/><br><br>

                   <p><label for="msgcheckinterval" class="setlabeltext"><b>Time interval in seconds before checking for new messages</b> (Enter the number of seconds
                          before the app checks the database in the background to find if a new message has arrived, so as to know if it needs to refresh the list of received 
                          messages. If you leave this field empty, the default of 5 seconds will be used.):</label></p>
                   <input type="number" class="smsr_textbox" id="msgcheckinterval" name="msgcheckinterval" autocomplete="false" placeholder="e.g. 5"/><br><br>

                   <p><label for="showdisplaynames" class="setlabeltext"><b>Show the display name of the message author, before each message:</b></label></p>
                   <input type="checkbox" class="sms_rel_checkbox" id="showdisplaynames" name="showdisplaynames" autocomplete="false" /><br>

                   <p><label for="adddisplaynames" class="setlabeltext"><b>Include the display name of the message author in the text of the message itself, like this: 
                          "John Doe: The weather has improved.":</b></label></p>
                   <input type="checkbox" class="sms_rel_checkbox" id="adddisplaynames" name="adddisplaynames" autocomplete="false" /><br>

                   <p><label for="get_notify" class="setlabeltext"><b>I want to see a notification in Nextcloud when a new SMS/MMS is received:</b></label></p>
                   <input type="checkbox" class="sms_rel_checkbox" id="get_notify" name="get_notify" autocomplete="false" /><br>

                   <p class="setlabeltext">To enable email notifications for every received SMS/MMS, the "sendmail" utility ("/usr/sbin/sendmail" on Debian Linux),
                          has to be present on the server. "sendmail" is a binary which gets installed when Postfix is installed. Also the server user (www-data) has to be
                          allowed to send emails from command line (by specifying "authorized_submit_users = www-data" in "/etc/postfix/main.cf" for Postfix on a Debian based Linux 
                          distribution).</p><br>

                   <p><label for="notification_email" class="setlabeltext"><b>I want to receive a notification to the email address from below, when a new SMS/MMS is
                          received:</b></label></p>
                   <input type="text" class="smsr_textbox" id="notification_email" name="notification_email" autocomplete="false"
                          placeholder="e.g. john.doe@example.com" /><br><br>

                   <p><label for="includesmsinemail" class="setlabeltext"><b>Include the SMS/MMS message in the email notification itself:</b></label></p>
                   <input type="checkbox" class="sms_rel_checkbox" id="includesmsinemail" name="includesmsinemail" autocomplete="false" /><br>

                   <p><label for="showdisplaynames" class="setlabeltext"><b>Set auto-reply messages for the following phone numbers:</b></label></p><br>
                   <table id="autoReplyTbl">
                          <tr><th>Auto-reply Author</th><th id="autoRplPhoneNb">Phone Number <div class="tooltipautoreplypn"><div id="infoautoreplypn">i</div>
                          <div class="autorpltooltippn">Sending a message to a phone number with a configured auto-reply from another phone number with a configured auto-reply must 
                          be avoided because it will trigger an infinite loop: the 2 numbers will send auto-replies to each other incessantly, until they will consume all the available 
                          funds in the balance.</div></div></th><th>Mode</th><th>Message</th><tr>
                   </table><br>

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

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

                   <span id="smsr_save_msg"></span>

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