<div class="page-title">
    <h1><?php echo $this->user->lang('Support Settings - Site Widget'); ?></h1>
    <p class="alert-content"><?php echo $this->user->lang("Create a site widget for clients to submit tickets and search your KB articles"); ?></p>
</div>


<div class="cm-holder settings-wrapper">
    <form name="settings" id="sitesettings">
        <div class="sec-box">
            <div class="texting">
                <h4>Tab Title</h4>
                <p>Select the text to place on your Feedback Tab.</p>
                <div class="form-elem">
                    <select class="normalSelect2" id="tabimageid" name="tabimageid">
                        <option selected="true" value="support">Support&nbsp;&nbsp;</option>
                        <option value="ask-us">Ask Us&nbsp;&nbsp;</option>
                        <option value="feedback">Feedback&nbsp;&nbsp;</option>
                        <option value="help">Help&nbsp;&nbsp;</option>
                        <option value="comments">Comments&nbsp;&nbsp;</option>
                        <option value="questions">Questions&nbsp;&nbsp;</option>
                        <option value="service">Service&nbsp;&nbsp;</option>
                    </select>
                </div>
            </div>

             <div class="texting">
                <h4>Tab Position</h4>
                <p>Select the position of the screen the tab will appear at.</p>
                <div class="form-elem">
                    <select class="normalSelect2" id="tabposition" name="tabposition">
                        <option selected="true" value="left">Left&nbsp;&nbsp;</option>
                        <option value="right">Right&nbsp;&nbsp;</option>
                    </select>
                </div>
            </div>

            <div class="texting">
                <h4>Require Knowledge Base Search</h4>
                <p>
                    If Yes then users will first be asked to enter keywords about their question and will be shown results from the knowledge base before being taken to the ticket submission page. Users may search the knowledge base from the ticket submission page as well.
                </p>
            </div>
            <div class="right-box">
                <div class="switch-box">
                    <label class="active">
                        <span class="icon-ic-13 yes"></span>
                        <input type="radio" class="cm-radio" id="value_forcesearch1" name="value_forcesearch" value="1" checked>
                    </label>
                    <label>
                        <span class="icon-ic-10 no"></span>
                        <input type="radio" class="cm-radio" id="value_forcesearch0" name="value_forcesearch" value="0">
                    </label>
               </div>
            </div>

            <div class="texting">
                <h4>Default Ticket Type</h4>
                <p>Select the ticket type you want to associate the tickets opened via the Support Widget.</p>
                <div class="form-elem">
                    <select id="tickettypeid" name="tickettypeid" class="normalSelect2">
                    <?php foreach ($this->tickettypes as $tickettype) { ?>
                        <option value="<?php echo $tickettype['value'];?>"><?php echo $tickettype['name'];?>&nbsp;&nbsp;</option>
                    <?php }?>
                    </select>
                </div>
            </div>
        </div>
         <div class="sec-box">
            <div class="texting">
                <input type="submit" id="btnGetSnippet" value="<?php echo $this->user->lang("Grab Snippet");?>" class="cm-btns orange">
             </div>
         </div>
    </form>
</div>

<script data-cfasync="false" type="text/javascript">
    $(document).ready(function() {

        $('#btnGetSnippet').click(function(e) {
            e.preventDefault();

            $.ajax({
                url: "index.php?fuse=support&action=getfeedbacktabsnippet&controller=index",
                dataType: 'json',
                data: {
                    tabimageid : $('#tabimageid').val(),
                    position: $('#tabposition').val(),
                    requireSearch : $("input[name='value_forcesearch']:checked").val(),
                    tickettypeid: $('#tickettypeid').val()
                },
                success: function(json){
                    if (!json.error) {
                        var window = new RichHTML.window({
                             content: clientexec.lang('Paste this code into each web page where you want your Tab to appear') + ':<br/><br/><pre>' + clientexec.htmlentities(json.snippet) + '</pre>',
                             title: clientexec.lang("Feedback Tab Code Snippet"),
                             size: 'modal-lg'
                         });
                         window.show();
                    }
                }
            });
        });
    });
</script>