Jump to content
sentq

Admin Area Intelligent Search While Typing

Recommended Posts

To activate the intelligent search to query results while typing instead of pressing the "Enter" key each time I have created simple ActionHook function that will integrate the code for both built-in template (v4 and Blend), the integration tested and is valid for WHMCS v6+ and v7+

1) Create new PHP file inside /includes/hooks/ directory, you may use "IntelliSearchWhileTyping.php" as the file name or whatever you prefer.

2) Copy the following code inside it.

3) Done.

<?php
/**
 * Get Results From Intelligent Search While Typing
 *
 * Compatible with WHMCS v6+ and v7+
 * Works with v4 and Blend templates
 *
 * @author     SENTQ <development@sentq.com>
 * 
 */

if (!defined("WHMCS")){
    die("This file cannot be accessed directly");
}

add_hook("AdminAreaHeadOutput", 1, function($vars){
    
    # Template Blend
    if ($vars['template'] === "blend"){
        
        return <<<EOF
<script type="text/javascript">
/* Intelligent Search On Typing */
$(document).ready(function(){
   $(document).on("input", "#intellisearchval", function(){
       $("#intellisearchval").css("background-image","url('images/loading.gif')");
       $.post("search.php", $("#frmintellisearch").serialize(),
       function(data){
           $("#searchresultsscroller").html(data);
           $("#searchresults").slideDown("slow",function(){
                   $("#intellisearchval").css("background-image","url('images/icons/search.png')");
               });
       });
   });
});
</script>
EOF;
    
    }
    # Template v4
    elseif ($vars['template'] === "v4"){
        
        return <<<EOF
<script type="text/javascript">
/* Intelligent Search On Typing */
$(document).ready(function(){
    $(document).on("input", "#intellisearchval", function() {
       $.post("search.php", $("#frmintellisearch").serialize(),
       function(data){
           if (data) {
               $("#searchresults").html(data);
               $("#btnIntelliSearch").hide();
               $("#btnIntelliSearchCancel").removeClass('hidden').show();
               $("#searchresults").hide().removeClass('hidden').slideDown();
           }
       });
   });
});
</script>
EOF;
        
    }
        
});
 

IntelliSearchWhileTyping.php

Edited by sentq
improvements and v7.1+ integration

Share this post


Link to post
Share on other sites

Thanks for that. Shame it does not work for the V4 templates.

Share this post


Link to post
Share on other sites
Thanks for that. Shame it does not work for the V4 templates.

Use the following code instead to apply the same functionality to v4 template:

/* Intelligent Search On Typing */
$(document).ready(function(){
    $("#intellisearchval").on("keyup", function() {
       $.post("search.php", $("#frmintellisearch").serialize(),
       function(data){
           if (data) {
               $("#searchresults").html(data);
               $("#btnIntelliSearch").hide();
               $("#btnIntelliSearchCancel").removeClass('hidden').show();
               $("#searchresults").hide().removeClass('hidden').slideDown();
           }
       });
   });
});

Share this post


Link to post
Share on other sites

Hi,

 

are they still work-able ? because i add them at v 6.2.1,it seems un-working ?

Share this post


Link to post
Share on other sites

@sentq

Hey there! As I see your new hook works great, however, I'm facing search window blinking on v4 template (seems like it's trying to search after each symbol inserted). Is it the same for you?

 

 

Share this post


Link to post
Share on other sites
On 10/2/2015 at 10:36 AM, sentq said:

To activate the intelligent search to query results while typing instead of pressing the "Enter" key each time I have created simple ActionHook function that will integrate the code for both built-in template (v4 and Blend), the integration tested and is valid for WHMCS v6+ and v7+

1) Create new PHP file inside /includes/hooks/ directory, you may use "IntelliSearchWhileTyping.php" as the file name or whatever you prefer.

2) Copy the following code inside it.

3) Done.


<?php
/**
 * Get Results From Intelligent Search While Typing
 *
 * Compatible with WHMCS v6+ and v7+
 * Works with v4 and Blend templates
 *
 * @author     SENTQ <development@sentq.com>
 * 
 */

if (!defined("WHMCS")){
    die("This file cannot be accessed directly");
}

add_hook("AdminAreaHeadOutput", 1, function($vars){
    
    # Template Blend
    if ($vars['template'] === "blend"){
        
        return <<<EOF
<script type="text/javascript">
/* Intelligent Search On Typing */
$(document).ready(function(){
   $(document).on("input", "#intellisearchval", function(){
       $("#intellisearchval").css("background-image","url('images/loading.gif')");
       $.post("search.php", $("#frmintellisearch").serialize(),
       function(data){
           $("#searchresultsscroller").html(data);
           $("#searchresults").slideDown("slow",function(){
                   $("#intellisearchval").css("background-image","url('images/icons/search.png')");
               });
       });
   });
});
</script>
EOF;
    
    }
    # Template v4
    elseif ($vars['template'] === "v4"){
        
        return <<<EOF
<script type="text/javascript">
/* Intelligent Search On Typing */
$(document).ready(function(){
    $(document).on("input", "#intellisearchval", function() {
       $.post("search.php", $("#frmintellisearch").serialize(),
       function(data){
           if (data) {
               $("#searchresults").html(data);
               $("#btnIntelliSearch").hide();
               $("#btnIntelliSearchCancel").removeClass('hidden').show();
               $("#searchresults").hide().removeClass('hidden').slideDown();
           }
       });
   });
});
</script>
EOF;
        
    }
        
});
 

IntelliSearchWhileTyping.php

It appears to have crashed in the latest stable version of WHMCS (v7.6.1)

Share this post


Link to post
Share on other sites
13 minutes ago, edvancombr said:

It appears to have crashed in the latest stable version of WHMCS (v7.6.1)

it works fine on my v7.6.1 dev using the Blend admin template.

Share this post


Link to post
Share on other sites
Just now, brian! said:

it works fine on my v7.6.1 dev using the Blend admin template.

I cleared the browser cache and it worked again, thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By vasil_uhmk
      I upgraded our WHMCS from version 5.3.14 to version 7.5. After upgrading I have problem with domains/services search from admin area. I'm getting 500 internal server error on AJAX call from whmcs/admin/templates/blend/js/scripts.min.js to whmcs/admin/search.php. I'm using PHP 7.2. Is this problem maybe is related to cUrl version (currently it is 7.59.0)?
      If someone had a similar problem, or have some idea how to overcome this problem I'd be happy to hear some potential solution.
      Thanks in davnace!
    • By mtindor
      Wondering if anyone else is having this issue.
      When logged into WHMCS 7.4.1 as an admin, do this:
      1.   Select Orders --> Add New Order
      2.   Start typing (a known existing) client name in the "Client" box
      What should happen is that it should start displaying possible clients as you type, just as the search boxes autofill the possibilities when you start typing a search.
      This used to work in 7.2.x for me.   After I upgraded to 7.4.1 (via the auto update feature), this stopped working.   I then renamed public_html and replaced it with a full WHMCS 7.4.1 distribution.   Same thing happens.
      Normally, if I typed something like "Tin" in the Orders --> Add Order --> Client box, it would automatically show my own billing account.   Now it doesn't bother to display anything.
      Mike
       
    • By stormy
      I've been testing the knowledgebase suggestions that appear before ticket submission, and they are way off. I'm posting very specific questions that have very specific articles and either they never appear, or flash for a few seconds while you type the ticket text, and then are replaced by more generic ones.
       
      I think this is due to the fact that they are ordered by the number of votes ("useful"). Also, there are some words that are bound to appear a lot, like "domains" or "hosting", so whenever the question includes those, you are shown the top-rated articles that features the words domains and hosting the most.
       
      Is there a way to replace these suggestions, maybe with a different MySQL query? A module with some configuration/weighting options would be very useful here.
    • By stormy
      I've just realised that by default, MySQL doesn't return any search results for 3-letter words, such as DNS, FTP, etc. Obviously, this could be improved.
       
      There's some official documentation here:
      http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html
       
      The parameter "ft_min_word_len=3" is the one controlling this.
       
      Has any of you tried fine tuning MySQL so it will return these searches? Have you found any adverse effects?
    • By ebmocwen
      Hello!
       
      Since upgrading to 5.2.7 from 5.1.9 we have found that the search under Clients Tab, Search/Filter box does not return any results for clients that signed up PRIOR to the upgrade.
       
      Any clients that signed up SINCE the upgrade and also any client profiles that have been modified SINCE the upgrade DO show up in the search results.
       
      Strangely, if we use the Sidebar Advanced Search Clients/Clients Email it works every time and returns the correct results.
       
      Any ideas please?! TIA!
  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated