Jump to content

Log File


hmaddy

Recommended Posts

i created a small hook file and added in dailycron and its not working. But in syntax all are correct and clear. so how can i check the error or how to know the real issue.

 

is there any way to get the output by line by line to a file or how can i setup a log file on this hook

Link to comment
Share on other sites

following code added in hooks folder with a file name of servermanagement

<?php

 use WHMCS\User\Client;
 use WHMCS\Database\Capsule;


    if (!defined('WHMCS')){
     die('You cannot access this file directly.');
     }else{
        add_hook('AfterCronJob', 1, function($vars) {
        
            foreach (Capsule::table('tblhosting')->where("domainstatus", "=", "Active")  ->whereIn("packageid", [264,265])    ->get() as $hosting) {
            
 

    
                $auditdate=date_create(date('Y-m-d', strtotime($hosting->nextinvoicedate. ' - 26 days')));
                $auditordate=$hosting->nextinvoicedate;
                $Cdate=date("Y/m/d");
                $CurDate=date_create(date("Y/m/d"));
                $ndiff=date_diff($CurDate,$auditdate);
                $datediff=$ndiff->format("%R%a");
                $myuserid=$hosting->userid;
                $userdomain=$hosting->domain;
                
                ##Condition Checking.
                
                if (( $datediff  == "+0" )) {
                create_servermanagementticket($myuserid,$userdomain);
                }
           }
        });
    }

 
 

function create_servermanagementticket($myuserid,$userdomain){

$adminUsername = 'gilty'; // Optional for WHMCS 7.2 and later

    //$client = get_client($userId);
    

    $command = 'OpenTicket';
    $postData = array(
    'deptid' => '6',
    'subject' => 'Monthly Server Audit' . $userdomain,
    'message' => 'Dear Sir,' . PHP_EOL . PHP_EOL . ' Audit the Server .' . PHP_EOL . PHP_EOL . ucfirst($adminUsername) . PHP_EOL . 'Server Manager/RAF Team',
    'clientid' => $myuserid,
    'priority' => 'Medium',
    'markdown' => true);

    $results = localAPI($command, $postData, $adminUsername);


    return $results;
}

Edited by hmaddy
Link to comment
Share on other sites

  • 2 weeks 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