n2972s Posted December 13, 2008 Share Posted December 13, 2008 We recently moved all of our customers over from MB and soon realized that the due dates for domains were the same as the expiry dates and there was no way to move them up within the configuration of WHMCS. We use the eNom script to sync or dates but we also wanted to create invoices with due dates of at least 15 days in advance of the domain expiring. I checked with Matt and he said the only way to do this was to write a script to accomplish the task. This script is pretty simple and it does what we need it to do. I thought there may be others out there that are looking for something similar. What it does: 1. Pulls all ACTIVE domains in your database. 2. Determines a new due date based on the current expiry date. 3. Checks that no invoice items are due for the domain. 4. Updates remaining domains with the new due dates. 5. Prints summary to either the screen or in an email. We use ours via a cron set to run about 20 minutes after the enom sync script runs. Any questions or thoughts let me know. DomainDueDate.zip 0 Quote Link to comment Share on other sites More sharing options...
nielsenj Posted December 23, 2008 Share Posted December 23, 2008 Nice script, thanks for contributing! 0 Quote Link to comment Share on other sites More sharing options...
Matt Wade Posted January 7, 2009 Share Posted January 7, 2009 Nice script...it works really well! I'd love to see a feature for this in WHMCS though. 0 Quote Link to comment Share on other sites More sharing options...
bettysue Posted January 25, 2009 Share Posted January 25, 2009 Thank you so much for this very helpful script, it saved me from manually update close to 400 domains. For some reason though I get an intermittent error message. The first time I ran it, I got it on all listings, second time I ran it no errors, the last time I ran it, I got the error message above the on screen report. PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/domainduedate.php on line 69 I'm not sure what it means, or if it's anything I need to be concerned about. I am basically php ignorant so am clueless. any information greatly appreciated. thank you, betty 0 Quote Link to comment Share on other sites More sharing options...
n2972s Posted January 26, 2009 Author Share Posted January 26, 2009 Betty, Please download this updated file: DomainDueDate.zip This will give a better explanation of the errors that I need to see what is wrong. Gustave 0 Quote Link to comment Share on other sites More sharing options...
shed Posted February 3, 2009 Share Posted February 3, 2009 Hi, Does this script affect hosting accountw or only domains? how about hosting accounts with free domains? Also can the due date for invoices be moved to 2 days earlier... we have issues with customers sending payments on due dates via online transfer but due to bank processing times their acocunts are suspended while awaiting funds...we'd like to avoid this by simply moving all due dates forwad a couple of days for all hosting/domains... TIA. 0 Quote Link to comment Share on other sites More sharing options...
n2972s Posted February 5, 2009 Author Share Posted February 5, 2009 Does this script affect hosting accountw or only domains? Just domains. How about hosting accounts with free domains? It will affect those domain due dates as well, I do not offer free domains no thought was put into that scenario if it has to be different. Also can the due date for invoices be moved to 2 days earlier... we have issues with customers sending payments on due dates via online transfer but due to bank processing times their acocunts are suspended while awaiting funds...we'd like to avoid this by simply moving all due dates forwad a couple of days for all hosting/domains... TIA You can change the due date advance for domains only in the settings at the beginning of the script to whatever date you want. This script is for domains only though and is used for us at least to modify the date after the enom synchronization script runs. Feel free to modify it as you need to, the basics should all apply. Gustave 0 Quote Link to comment Share on other sites More sharing options...
bettysue Posted February 5, 2009 Share Posted February 5, 2009 Betty, Please download this updated file: DomainDueDate.zip This will give a better explanation of the errors that I need to see what is wrong. Gustave Thank you Gustave! So far I've run the new script once in test mode and once live and no errors thus far. I will monitor it and post back if I get any more error messages in future runs. thank you again! betty 0 Quote Link to comment Share on other sites More sharing options...
jozeph Posted February 6, 2009 Share Posted February 6, 2009 This routines must be called when a invoice is create, right? Maybe we can use the 'actionhooks' to call script... 0 Quote Link to comment Share on other sites More sharing options...
n2972s Posted February 7, 2009 Author Share Posted February 7, 2009 This routines must be called when a invoice is create, right? Maybe we can use the 'actionhooks' to call script... No, this should be called before an invoice is created. The purpose here is to set the next due date in advance of invoice creation. Gustave 0 Quote Link to comment Share on other sites More sharing options...
Patty Posted February 10, 2009 Share Posted February 10, 2009 Tks for your nice contribution, n2972s. Works like a charm! 0 Quote Link to comment Share on other sites More sharing options...
headout Posted February 11, 2009 Share Posted February 11, 2009 Would it be possible with this script to: * to invoice customers on a fixed date? We invoice our customers every 1st day of a new month. The enom sync script changes the expiry date, but also the due date. We don't want that. 0 Quote Link to comment Share on other sites More sharing options...
n2972s Posted February 12, 2009 Author Share Posted February 12, 2009 Would it be possible with this script to:* to invoice customers on a fixed date? We invoice our customers every 1st day of a new month. The enom sync script changes the expiry date, but also the due date. We don't want that. Yes, see new file: DomainDueDate.zip You will need to set the configuration variable: $dayofmonthbilling to 1 and then set the day of the month you want the due date set too. You will have to figure out the logic of where to set the reset date, but I would imagine you would want to set it to something so domains with an expiration date of the 2nd or 3rd of the month get pushed to the month before. i.e. Current Expiration Date is 7/3/2010 So set the reset date to something larger than 3 to push it back to the the previous month. Run it a few times in test mode until you get the results you need. Gustave 0 Quote Link to comment Share on other sites More sharing options...
efisher Posted April 14, 2009 Share Posted April 14, 2009 This script is great. I just tried it for the first time today. No major issues to report and it does what I would expect. There is one minor issue, however, and I'm wondering if anyone has found a fix. Every time the script is run, the output suggests that the script is updating every domain again and the email report contains every single domain. I would have expected to see something like 'if old_due_date != new_due_date then update and print result, else dont_update'. Maybe it is there and just not working. Can someone confirm? Thanks, -Eric 0 Quote Link to comment Share on other sites More sharing options...
growe Posted April 19, 2009 Share Posted April 19, 2009 There is one minor issue, however, and I'm wondering if anyone has found a fix. Every time the script is run, the output suggests that the script is updating every domain again and the email report contains every single domain. I would have expected to see something like 'if old_due_date != new_due_date then update and print result, else dont_update'. Maybe it is there and just not working. Can someone confirm? Thanks, -Eric Same problem exists in the Enom Sync script 0 Quote Link to comment Share on other sites More sharing options...
sanfranciscohost Posted May 12, 2009 Share Posted May 12, 2009 Hi n2972s, everyone, Thanks for contributing! This community is part of the reason we migrated here from MB as well. So many great ideas .... We using this script to update the domain due dates to coincide with the billing dates and we are not sure what we are doing wrong but its not working on our installation as expected. It will calculate the correct due date and set it to be the 1st day of the month in the screen output but when we look at the database it is still setting the due date to the number of days we have in the script and ignores the billing date of the month option. Here are the options we have set at the top of the script: // Path to WHMC Confiruation File include("/path/to/my/configuration.php"); // Mode (1 = Test Mode / 2 = Live) $mode = 2; // Output Format (1 = Screen / 2 = Email) $output = 1; // Reset Date $resetdate = "-30 days"; // Day of the Month Billing ( 0 = False / 1 = True ) $dayofmonthbilling = 1; // If Day of the Month Billing is True then What Day ( Number ) $dayofmonth = 1; // Email Addresses - Used if an email is sent. $to = "email@email.com"; $from = "email@email.com"; The script runs without errors and the screen report says this: somedomain.com 2011-01-27 2010-12-01 Success! somedomain.com 2010-03-14 2010-02-01 Success! somedomain.com 2011-08-12 2011-07-01 Success! somedomain.com 2010-05-30 2010-04-01 Success! somedomain.com 2009-08-19 2009-07-01 Success! So you can see that it tells us that the script has done its job and reset the due dates to be the first of the month. Yay! When we query the database for those same domains, we see these dates instead: somedomain.com 2011-01-27 2010-12-28 somedomain.com 2010-03-14 2010-02-12 somedomain.com 2011-08-12 2011-07-13 somedomain.com 2010-05-30 2010-04-30 somedomain.com 2009-08-19 2009-07-20 Boo! Why is it not updating the due date to the 1st day of the month in the database when it is calculating it correctly on the screen output? How can we fix this? We just recently moved to v4 but the behaviour of the script was the same before the upgrade. We were hoping there was something in the upgrade that would fix this but we have no joy. Thanks for your help, as this is driving us crazy! Deborah 0 Quote Link to comment Share on other sites More sharing options...
n2972s Posted May 13, 2009 Author Share Posted May 13, 2009 Hello, There is a line missing in the script. I am not sure how I missed this one: Change: if ( $dayofmonthbilling == 1 ) { $newfirstofmonth = mktime(0, 0, 0, date('n',$newdateunix), date($dayofmonth), date('Y',$newdateunix)); $newdate = date('Y-m-d', $newfirstofmonth); } elseif ( $dayofmonthbilling == 0 ) { $newdate = date('Y-m-d', $newdateunix); } to: if ( $dayofmonthbilling == 1 ) { $newfirstofmonth = mktime(0, 0, 0, date('n',$newdateunix), date($dayofmonth), date('Y',$newdateunix)); $newdate = date('Y-m-d', $newfirstofmonth); [i][b][color="red"]$newdateunix = strtotime($newdate);[/color][/b][/i] } elseif ( $dayofmonthbilling == 0 ) { $newdate = date('Y-m-d', $newdateunix); } Gustave 0 Quote Link to comment Share on other sites More sharing options...
sanfranciscohost Posted May 15, 2009 Share Posted May 15, 2009 TY Gustave! Now I see the expected due date in the database but it is not showing up correctly on the clientsdomainlist.php page. It is showing up correctly on the client's profile however so I will let Matt know to take a look. Deborah 0 Quote Link to comment Share on other sites More sharing options...
sanfranciscohost Posted May 15, 2009 Share Posted May 15, 2009 The behaviour I mentioned in the reply above has already been discovered in v4 and reported to Matt here: http://forum.whmcs.com/showthread.php?t=20231 Just FYI. Deborah 0 Quote Link to comment Share on other sites More sharing options...
Patty Posted September 23, 2009 Share Posted September 23, 2009 Is this still working on v4.0.2? I can't run the script. It will give me a blank page on Firefox after a while and a page not found on IE7. 0 Quote Link to comment Share on other sites More sharing options...
UltraUnix Posted September 26, 2009 Share Posted September 26, 2009 Added some feature into the script but it is base on the first script Gustav posted. Hopefully to find time to integrate update script into this. Basically, I want domain invoice to be included in hosting(if available) so that customer pays both hosting and domain in single receipt. To avoid confusion. However, for domain only account. It will follow Gustav's script to reset due date base on the specified reset date. Didn't really dwell into time function and perhaps someone could look into it // - Set domain due date equal to hosting (if available) // - Set domain due date base on $resetdate (domain only acc) // - Also checks if domain is renewed ahead of hosting // -- If true, set the same day as hosting(for monthly renewal check) // - Also checks if domain active and hosting is not (set due date to $resetdate) 0 Quote Link to comment Share on other sites More sharing options...
UltraUnix Posted September 26, 2009 Share Posted September 26, 2009 Sorry, reupload the attachment. Forgot to remove my email in it. DomainDueDateUU.zip 0 Quote Link to comment Share on other sites More sharing options...
Patty Posted September 26, 2009 Share Posted September 26, 2009 Tks for the update. But I still can't run this on my v4.0.2. Still getting a "Internet Explorer cannot display the webpage" What could be wrong? File is there under my WHMCS directory. TIA for any clues. 0 Quote Link to comment Share on other sites More sharing options...
UltraUnix Posted September 26, 2009 Share Posted September 26, 2009 have you tried with different browser? the error message is too generic to tell... See if other browser tells different message and a look into apache's error_log would help too 0 Quote Link to comment Share on other sites More sharing options...
Patty Posted September 26, 2009 Share Posted September 26, 2009 Yeap. Firefox will give me a blank page. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.