Jump to content

How can I get the service of an overdue invoice using API?


tsvetanakos

Recommended Posts

Hello! :)

 

I'm trying to create a hook which is supposed to run when an invoice is overdue and update some data on our servers, but so far I'm unable to get the service of the invoice. I mean the invoice details are not containing the service that is tied with the invoice.

 

Here is what I have inside of my hook:

 

    
   $command = "logactivity"; 
   $adminuser = "admin"; 
   $invoiceId = print_r($vars[invoiceid], true);


   $command1 = "getinvoice";
   $values1["invoiceid"] = $invoiceId;

   $results1 = localAPI($command1,$values1,$adminuser);

   // The client's ID - I need it in order to get the email. So far, so good.
   $clientId = print_r($results1[userid], true);

   $command2 = "getclientsdetails";
   $values["clientid"] = $clientId;
   $values["stats"] = true;
   $values["responsetype"] = "xml";

   $results2 = localAPI($command2,$values,$adminuser);

   // The client's email - excellent!
   $userEmail = print_r($results2[client][email], true);


   $values["description"] = "proof wr_hook_InvoiceChange was called userId: ".$clientId." invoiceId: ".$invoiceId." email: ".$userEmail;

   // Log the values - cool!
   $results = localAPI($command,$values,$adminuser);

 

As you can see in the code above I'm getting the user email - because I need it in order to update some info on our servers, but how am I supposed to get the service that provoked the invoice?! There should be a way to know which service is overdue, right?

 

So far the documentation is not helping me. Can you give me a push? I know that I'm missing a really small point here, but I'm not able to spot it.

 

Thanks in advance for any help! :)

Link to comment
Share on other sites

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