Jump to content

Enhanced Auto Release Hook


Remitur

Recommended Posts

This simple hook adds details about services managed by the WHMCS auto-release module.

Auto-release is handy, but it may be annoying because WHMCS will report in TO-DO just the service ID and a short description of action required (renew, suspend, etc.)

This simple hook will add also service name, making the following job easier faster, and even more safe (it may happen that you open the service with a wrong ID, so i.e. you go on renewing the wrong service...)

This hook is also available on GitHub repository: https://github.com/DomainRegister/WHMCS-enhanced-auto-release 

<?php
//
// enhanced to-do
// WHMCS hook to enrich details about services managed by auto-release module
//
// https://domainregister.international/
//

add_hook('AfterCronJob', 100, function($vars) {

try {
$todoitem = Capsule::table('tbltodolist')
->where('status', '!=', 'Completed')
->where('description', 'like', 'Service ID # %')
->select('id','description')
->first();

} catch (\Exception $e) {
echo "error {$e->getMessage()}";
}

$descr2=substr($todoitem->description,12);
$serviceid=intval($descr2);
$descr3=preg_replace( '/Service ID # \d+/', '', $todoitem->description );


try {
$servicename = Capsule::table('tblhosting')
->where("id", $serviceid)
->select('domain')
->first();
echo "<pre>"; print_r($servicename);

} catch(\Illuminate\Database\QueryException $ex){
echo $ex->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}

$newdescription = 'Service ID #'.$serviceid.' ( '.$servicename->domain.' ) '.$descr3.PHP_EOL;

try {
$update_data = [
'description' => $newdescription
];
Capsule::table('tbltodolist')
->where('id', '=', $todoitem->id)
->update($update_data);
} catch(\Illuminate\Database\QueryException $ex){
echo $ex->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}

});

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 years 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