Jump to content

DennisHermannsen

Member
  • Content Count

    666
  • Joined

  • Last visited

  • Days Won

    17

DennisHermannsen last won the day on May 12

DennisHermannsen had the most liked content!

Community Reputation

87 Excellent

2 Followers

About DennisHermannsen

  • Rank
    Level 2 Member

Recent Profile Visitors

4128 profile views
  1. I think I found a rather simple way of doing what I'm trying to achieve. https://pastebin.com/fYWhNxNr (I'm also having issues with their WAF, lol) I just need to call /modules/servers/myModule/script.php?serviceId=<serviceId>. The $server object has all the stuff I need to make API calls (access hash, hostname of the server etc.) Any thoughts on that way to do it?
  2. Thanks for the thorough explanation, @string! I actually managed to find method 1 myself. I'm not worried about SSL checks, though - the services that the module will manage does not have a domain set. I didn't consider that WHMCS would call hooks for the ClientArea function on each call. I'll see if I can get it working using your other example. One quick question: How would I access the module parameters if doing it that way? It's not just service params, it's stuff like the access hash that's defined in the provisioning module.
  3. I have no idea how to pull this off in WHMCS so I'm hoping for some help. I'm building a module that outputs some data to the client area (CPU usage and stuff like that). I really want this data to update every 5-10 seconds. I know how to query the data - I just don't know how I can do this in WHMCS. I thought about creating a custom function in the module that gets the relevant data and then returns it - but WHMCS seems to always want to render the client area 😅 What I basically need is a blank page where I can output json. I need the $params variable, so I can't do this outside of WHMCS. Any ideas?
  4. Since the variable name passed to the function is $vars, you won't be able to get any details with $params. This code will work: <?php add_hook('ClientAreaPageViewInvoice', 1, function($vars) { if($vars['client']['country'] === 'DE'){ // do stuff } });
  5. Maybe it would work if you check whether the the relid for the tblinvoiceitem row already exists for other rows? If it exists more than once, the product/domain has already been invoiced before.
  6. None of the "bugs" you mention are bugs. You're editing default templates - they are gonna get overwritten. WHMCS even tells you to copy the default theme and make changes to the copy.
  7. This issue is also a problem with 'Set Recurring Billing Information' during Server Sync for modules. If Client Date Format is set to "Monday, January 1st, 2000", you'll get the same error. Setting it to use the global format fixes the issue.
  8. It's the same "Active Products" panel that has existed since Homepage Panels were introduced. If the client has a lot of active products, the panel will have a scrollbar. It's only for active products.
  9. @Kian small thing to note about InvoiceCreationPreEmail: I haven't used that hook event for a long time, and I'm pretty sure that ^ is the reason I stopped using it 😅 I don't know if it has been changed since I last used it.
  10. If you're seeing a "Connection timed out" error, it's most definitely a firewall issue. Either your server is blocking the connection to port 995 on pop.gmail.com, or gmail is blocking your incoming request. Are you able to telnet to port 995 on pop.gmail.com?
  11. A few. You just can't use them for WHMCS. WHMCS will only run on IonCube (unless they start encoding using a different library). As support for PHP 7.4 ends on 28 Nov 2022, I'm sure WHMCS is already looking for a way to work around IonCube. Despite a lot of flaws, I doubt they're going to force their clients to use outdated PHP versions.
  12. Would that not cause a small issue when WHMCS is sending the invoice to the client? The documentation states this: Your regex pattern(s) are way better than what I suggested. Quick question that might be a bit off topic: Is there any difference on using models vs capsule? I know that they're basically the same thing but I'm just wondering if there's any reason to use one instead of the other.
  13. @leew87 hooks are to be placed in /includes/hooks/ - unless they are part of a module. I don't think the code should run on InvoiceCreated, though - that hook runs after the invoice has been sent to the client, and as such the client would see the dates on the invoice. Executing on InvoiceCreation should work for this. Hook documentation can be found here: https://developers.whmcs.com/hooks-reference This should do the trick for you: <?php use WHMCS\Billing\Invoice; add_hook('InvoiceCreation', 1, function($vars) { // $vars allows us to use get the specific invoice id $invoiceID = $vars['invoiceid']; // Get data related to the invoice. See this for documentation on models: https://docs.whmcs.com/Using_Models // It would also be possible to use Capsule to query the database instead of using the Invoice model. See information on database queries here: https://developers.whmcs.com/advanced/db-interaction/ $invoiceItems = Invoice::find($invoiceID)->items; $pattern = '/\(([0-3][0-9]|[0-1][0-9]|[\d]{4})(\/|\.|-)([0-1][0-9]|[0-3][0-9]|)(\/|\.|-)([\d]{4}|[0-1][0-9]|[0-3][0-9]) - ([0-3][0-9]|[0-1][0-9]|[\d]{4})(\/|\.|-)([0-1][0-9]|[0-3][0-9]|)(\/|\.|-)([\d]{4}|[0-1][0-9]|[0-3][0-9])\)/'; foreach ($invoiceItems as $invoiceItem) { preg_match($pattern, $invoiceItem->description, $matches); $invoiceItem->description = str_replace($matches[0], '', $invoiceItem->description); // Update the description of the invoice's line item $invoiceItem->save(); // Save to the database } }); Quickly explained: We use the Invoice model to find the related invoice during invoice creation. At this time, line items already exists. We define a regex pattern to search for the dates in the line item description. The pattern should match the following types of dates but I would test it thoroughly before using it: (28/04/2022 - 27/04/2023) (28.04.2022 - 27.04.2023) (28-04-2022 - 27-04-2023) (04/28/2022 - 04/27/2023) (2022/04/28 - 2023/04/27) (2022-04-28 - 2023-04-27) Loop through all line items. Whenever a string in the line item description matches the regex, we replace it with nothing (''). Save the new description for the line item. I hope that makes sense. There's probably a better way to do it but this was what I could with the 20 minutes I had to spare 😄
  14. What modules are installed on your WHMCS installation? Try disabling all modules and hooks to see if that solves your problem.
  15. You can use the ApplyCredit function: https://developers.whmcs.com/api-reference/applycredit/ Before doing that, I would recommend that you check if the client has enough credits on their account.
×
×
  • 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