Jump to content


Senior Member
  • Content Count

  • Joined

  • Last visited

  • Days Won


DennisHermannsen last won the day on March 11

DennisHermannsen had the most liked content!

Community Reputation

45 Excellent

1 Follower

About DennisHermannsen

  • Rank
    Level 2 Member

Recent Profile Visitors

2007 profile views
  1. If he's using the DecryptPassword function, he should still get the same value - right?
  2. I figured it out after some googling: Session::delete("uid"); Session::delete("cid"); Session::delete("upw"); Cookie::delete("User"); Source: shhhhhhh Oddly enough, there's no official documentation on this 😛
  3. Hi. I'm currently building a module for WHMCS that allows clients to see a list of all logins and a list of unique logins. In the table that shows unique logins, the client has an option to prevent a certain IP from logging in to the client's account. I just need a way to force WHMCS to prevent the user from logging in. Any ideas?
  4. There's just a few issues with this: If an invoice has 4 lines: 2 products and 2 Late Fees (if that's even possible). If one of the products is terminated, while the other isn't, there's no way for me to know which late fee to remove. Anyways, you can use this: <?php use WHMCS\Database\Capsule; add_hook('PreModuleTerminate', 1, function($vars) { $invoices = Capsule::table('tblinvoiceitems') ->where('relid', $vars['params']['serviceid']) ->where('type', '!=', 'GroupDiscount') ->get(); logActivity('Auto Cancel Invoice: Starting...'); foreach($invoices as $key){ $invoiceIDs = Capsule::table('tblinvoices') ->where('id', $key->invoiceid) ->where('status', 'Unpaid') ->value('id'); $invoiceLine = Capsule::table('tblinvoiceitems') ->where('invoiceid', $invoiceIDs) ->where('relid', $vars['params']['serviceid']) ->value('id'); $invoiceLines = Capsule::table('tblinvoiceitems') ->where('invoiceid', $invoiceIDs) ->get(); $description = Capsule::table('tblinvoiceitems') ->where('relid', $vars['params']['serviceid']) ->where('invoiceid', $invoiceIDs) ->value('description'); $discountLine = Capsule::table('tblinvoiceitems') ->where('invoiceid', $invoiceIDs) ->where('type', 'GroupDiscount') ->where('description', 'like', '% '.$description.'%') ->value('id'); if($invoiceIDs){ logActivity('Auto Cancel Invoice: Invoice ' . $invoiceIDs . ' has had a line removed. This invoice previously had ' . count($invoiceLines) . ' lines.'); if(count($invoiceLines) > 1){ $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => $invoiceIDs, 'deletelineids' => array($invoiceLine), ); $results = localAPI($command, $postData); }elseif(count($invoiceLines) == 1){ logActivity('Auto Cancel Invoice: Invoice ' . $invoiceIDs . ' has been cancelled because the product was terminated.'); $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => $invoiceIDs, 'status' => 'Cancelled', ); $results = localAPI($command, $postData); } if(count($invoiceLines) <= 2 && Capsule::table('tblinvoiceitems')->where('invoiceid', $invoiceIDs)->where('type', 'LateFee')->get()){ logActivity('Auto Cancel Invoice: Invoice ' . $invoiceIDs . ' has been cancelled because the only line was a Late Fee.'); $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => $invoiceIDs, 'status' => 'Cancelled', ); $results = localAPI($command, $postData); } if($discountLine){ logActivity('Auto Cancel Invoice: Invoice ' . $invoiceIDs . ' had a Group Discount. This has been removed.'); $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => $invoiceIDs, 'deletelineids' => array($discountLine), ); $results = localAPI($command, $postData); } } } }); If there's 2 or less lines, and one of them is a Late Fee, it will cancel the invoice. When using the PreModuleTerminate hook, I can't do it for less than 2 lines because the LateFee doesn't have a relid. This should work just fine though.
  5. Great, that solves the issue 😃 So, if any LateFee is added to the invoice, the invoice should just be left alone?
  6. @Believe_ Ouch. It seems like something that is difficult to fix. The Late Fee line in tblinvoiceitems doesn't have anything to indicate that it's a Late Fee item. I tried to check with our own installation if 'type' being 0 had anything to do with it, but it doesn't - we have plenty of those in our database. It seems like the only thing to spot a Late Fee item is by looking at the description itself - but as @brian! says, it's just a string that can be translated. It would appear different depending on what language the user has. If anyone has an idea to work around that, let me know.
  7. Hi @Believe_ Thanks for your suggestions. The hook is in no way perfect - I'm well aware 😉 We don't use late fees, so I have no way of testing it unfortunately. If you could tell me how WHMCS tells that a line is for a late fee, please let me know. If it's stored as something specific in the database, that would be the best.
  8. No no no, I totally came up with that on my own, I swear 😜
  9. @brian! there's just one issue with how you're getting the amount of items in the cart - it also grabs any item that you're currently putting in the cart (on the confproduct page) before adding them to the cart. This can be done to get the correct amount: add_hook('ClientAreaSecondaryNavbar', 1, function(MenuItem $secondaryNavbar) { $orderfrm = new WHMCS\OrderForm(); $cartitemcount = $orderfrm->getNumItemsInCart(); $secondaryNavbar->addChild('View Cart', array( 'label' => '', 'uri' => 'cart.php?a=view', 'order' => '0' )) ->setIcon('fa-shopping-cart') ->setBadge($cartitemcount); });
  10. Nevermind. I was wrong about the update dates. We had already updated on April 22nd. We had another issue, and WHMCS took a look at it. One of the supporters made a lot of changes and moved our current installation to a new directory on the exact date we started experiencing issue. I guess there's a possibility something went wrong when he was investigating. The site was completely offline for more than an hour, and sometimes it gave an error where the database connection could not be established. I'm starting to think he may have taken a backup of the database (just in case), done something that messed everything up and imported a backup of the database - but somehow the backup must've not include indexes for that one table.
  11. See this: (72866, 'admin', '2020-04-27 12:46:23', '2020-04-27 12:46:23', 'xx.xx.xxx.xxx', 'xxxxxxxxxxxx', '2020-04-27 12:46:23'), (0, 'admin', '2020-04-27 13:09:24', '2020-04-27 13:09:24', 'xx.xx.xxx.xxx', 'yyyyyyyyyyyy', '2020-04-27 13:09:24'), After logging in on April 27th, I initiated the upgrade. I don't know the exact time, but it was before 12:00. Logging in after this is logged as id 0.
  12. It definately was the update. I don't know how, though. The last visible admin log in WHMCS was a few minutes before upgrading WHMCS.
  13. Figured I would post in this community, despite we've fixed the issue. On 27th of April, we upgraded to WHMCS 7.10.1. I didn't notice anything immediately, but a few days after my boss said the backend had been loading really slow for a couple of days. With that in mind, I started navigating the WHMCS backend, and it was incredibly slow. Loading the front page took between 5-7 seconds. Just today I was able to dump all MySQL trafic and saw something that started like this: UPDATE tbladminlog SET logouttime = lastvisit WHERE adminusername='admin' AND lastvisit < '2020-05.... This ran for seconds. I couldn't reproduce on our other installations. Checking the table, I could see it no longer had any indexes, primary key or AUTO INCREMENT. A lot of rows had id 0. Deleting all rows with id 0 and setting indexes, primary key and auto increment fixed the issue. I'm really interested if anyone else has had this issue?
  14. According to the Eloquent documentation, I would be able to run the refresh() or fresh() function to refresh my database query: https://laravel.com/docs/7.x/eloquent#retrieving-models This doesn't seem to be possible in WHMCS though. Is there any other way to do it?
  • 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