Jump to content

Post New Support Ticket Knowledgebase check


cjsmith87

Recommended Posts

I am trying to tweak /plugins/support_manager/views/default/client_tickets_add.pdt so that is shows similar knowledgebase questions to what the user types in the Ticket Summary box. So far i have added a DIV to put the similar KB's in and set a key press event:

<div class="form-group">
                <?php
                $this->Form->label($this->_('ClientTickets.add.field_summary', true), 'summary');
                $this->Form->fieldText('summary', $this->Html->ifSet($vars->summary), ['id' => 'summary', 'class' => 'form-control', 'onkeyup' => 'loadKBArticles(event)', 'placeholder' => $this->_('ClientTickets.add.placeholder_summary', true)]);
                ?>
                <div id="matchingKB" style="display: none;">
 
                </div>
            </div>

I have added a script to the bottom of the page but I cant seem to get anywhere with accessing the model to search the KBs:

<script>
function loadKBArticles( value ) {

    $element = document.getElementById("matchingKB");
     $element.style.display="block";
    $element.innerText =<Similar KB Links Here>;
}
</script>

I have tried lots of different ways of accessing the API to get the data. I know I need to access the model SupportManagerKbArticles and use the search function but i cant work it out. Anyone able to help a novice out?! I am keen to learn

Link to comment
Share on other sites

It sounds like you're trying to create your own "auto-complete". Auto-complete functionality is already supported. You can call the jQuery function "autocomplete()". Take a look at the admin_tickets.pdt template file for reference.

You'll probably need to create a new controller method to retrieve the information you're going to fetch in an AJAX request.

Link to comment
Share on other sites

I am not trying to auto complete the text, I am trying to lookup content, we currently use Hesk for our ticketing system and I want to switch this over to blesta. http://help.4matrix.com/index.php?a=add that is our current ticket page, if you type 'install' in the subject and message box, it will auto suggest some Knowledgebase articles related to what you have typed. ClientExec also have an this feature, http://demo.clientexec.com/index.php?fuse=support&controller=ticket&view=submitticket type 'totam' in the subject form and it will suggest articles. I want them to then be able to click the link and hopefully not need to post a ticket!

 $('#ticket_number').autocomplete({
                    minLength: 3,
                    appendTo: ".with_ticket",
                    position: { my: "left bottom", at: "left top"},
                    source: function(request, response) {
                        $(document).blestaRequest('POST', '<?php echo $this->Html->safe($this->base_uri . 'plugin/support_manager/admin_tickets/searchbycode/');?>',
                            { _csrf_token: $('#tickets').find('input[name=_csrf_token]').val(), search: request.term},
                            function(data) {
                                if (data && data.tickets) {
                                    // Build the response to show
                                    var tickets = new Array();
                                    for (var id in data.tickets)
                                        tickets.push({label:data.tickets[id], value:data.tickets[id], id:id});
                                    response(tickets);

                                    // No results
                                    if (tickets.length == 0)
                                        $('#no_tickets').show();
                                    else
                                        $('#no_tickets').hide();
                                }
                            },
                            null,
                            {dataType:'json'}
                        );
                    },
                    select: function(event, ui) {
                        $('#ticket_id').val(ui.item.id);
                    }
                });

I have tried using variations of this but I cant get it to work. I am probably missing something obvious, bit of a newbie!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...