Jump to content

Adding Link on Service Admin Area


sonuyos

Recommended Posts

Preview:

sample-323.png.f6e76f72b7c8993e2eb2c5f191d059f0.png

Code:

<?php

/**
 * @writtenby   Kian
 */

use WHMCS\Database\Capsule;

add_hook('AdminAreaHeaderOutput', 1, function($vars)
{
    if ($vars['filename'] == 'clientsservices')
    {
        $moduleName = 'cpanel'; // Replace with your server module name

        if (Capsule::select(Capsule::raw('SELECT t1.id FROM tblhosting AS t1 LEFT JOIN tblproducts AS t2 ON t1.packageid = t2.id WHERE t1.id = "' . $_GET['productselect'] . '" AND t2.servertype = "' . $moduleName . '"')))
        {
            $output .= <<<HTML
<script type="text/javascript">
$(document).ready(function(){
    $("#inputDedicatedip").addClass("pull-left");
    $("#inputDedicatedip").closest(".fieldarea").append('<a href="https://google.com" class="btn btn-danger pull-right"><i class="fas fa-shower"></i> Bath Time</a>');

});
</script>
HTML;

            return $output;
        }
}
});

But there's a downside that I can't figure how to solve. When you click "Products/Services" tab WHMCS brings you to a "random" product/service. The ID for this specific product is not available hence the script can't be triggered.

Edited by Kian
Link to comment
Share on other sites

19 hours ago, Kian said:

Preview:

sample-323.png.f6e76f72b7c8993e2eb2c5f191d059f0.png

Code:


<?php

/**
 * @writtenby   Kian
 */

use WHMCS\Database\Capsule;

add_hook('AdminAreaHeaderOutput', 1, function($vars)
{
    if ($vars['filename'] == 'clientsservices')
    {
        $moduleName = 'cpanel'; // Replace with your server module name

        if (Capsule::select(Capsule::raw('SELECT t1.id FROM tblhosting AS t1 LEFT JOIN tblproducts AS t2 ON t1.packageid = t2.id WHERE t1.id = "' . $_GET['productselect'] . '" AND t2.servertype = "' . $moduleName . '"')))
        {
            $output .= <<<HTML
<script type="text/javascript">
$(document).ready(function(){
    $("#inputDedicatedip").addClass("pull-left");
    $("#inputDedicatedip").closest(".fieldarea").append('<a href="https://google.com" class="btn btn-danger pull-right"><i class="fas fa-shower"></i> Bath Time</a>');

});
</script>
HTML;

            return $output;
        }
}
});

But there's a downside that I can't figure how to solve. When you click "Products/Services" tab WHMCS brings you to a "random" product/service. The ID for this specific product is not available hence the script can't be triggered.

Thanks, however that didnt work, so i rectified the code a littlle, and now it works.

 

	$pid = (int) $_REQUEST['id'];
        if (Capsule::select(Capsule::raw('SELECT t1.id FROM tblhosting AS t1 LEFT JOIN tblproducts AS t2 ON t1.packageid = t2.id WHERE t1.id = "' . $pid . '" AND t2.servertype = "' . $moduleName . '"')))

 

Link to comment
Share on other sites

  • 1 month later...

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.

  • 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