Jump to content

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.

Link to comment
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;
    
});

 

Link to comment
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?

 

Link to comment
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
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

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