Jump to content
jas8522

Override autosuspend should auto check when selecting a date

Recommended Posts

On multiple occasions now I've set a date for override auto-suspend and managed to miss checking the box beside it. While this is obviously user error, it's not the first time it has happened and unfortunately results in some serious problems where client's systems are auto-suspended because of my negligence.

I think that to prevent this, the checkbox should auto-check when you click in the date field to select a date.

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, jas8522 said:

On multiple occasions now I've set a date for override auto-suspend and managed to miss checking the box beside it. While this is obviously user error, it's not the first time it has happened and unfortunately results in some serious problems where client's systems are auto-suspended because of my negligence.

I think that to prevent this, the checkbox should auto-check when you click in the date field to select a date.

the following ActionHook code will add few Javascript lines to product details page, once you specify a date for the "Override Auto-Suspend" it will automatically tick the checkbox beside it, create new PHP file inside /includes/hooks/ directory and copy this code inside it

<?php
/**
 * Automatically tick/untick "Override Auto-Suspend" checkbox 
 * when you specify/removed the date accordingly
 *
 * @author SENTQ
 */

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

add_hook("AdminAreaHeadOutput", 1, function($vars){

    if ($vars['filename'] !== "clientsservices"){
        return;
    }
    
return <<<EOF
<script type="text/javascript">
$(document).ready(function(){
    $(document).on("change", "[name='overidesuspenduntil']", function(){
        var overrideAutoSuspend = $(this).val();
        if (overrideAutoSuspend.length > 0){
            $('[name="overideautosuspend"]').prop({checked: "checked"});
        }
        else {
            $('[name="overideautosuspend"]').prop({checked: ""});
        }
    });
});
</script>
EOF;
    
});

 

  • Thanks 1

Share this post


Link to post
Share on other sites
8 hours ago, jas8522 said:

I think that to prevent this, the checkbox should auto-check when you click in the date field to select a date.

Aaaand you would be correct.
I mean, yes, as you said, this is a user error, but one would think that software should be able to anticipate what could go wrong, and prevent this. In this case, don't let it submit if it's not checked.
Or maybe remove the checkbox all together?  I mean this is one of those things silly like 

Quote

Are you sure you want to exit the game?

 

Share this post


Link to post
Share on other sites
5 hours ago, sentq said:

the following ActionHook code will add few Javascript lines to product details page, once you specify a date for the "Override Auto-Suspend" it will automatically tick the checkbox beside it, create new PHP file inside /includes/hooks/ directory and copy this code inside it

Awesome, thanks for the hook!

Edited by jas8522
  • Thanks 1

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines