Jump to content

[SCRIPT] Update Domain Due Dates


n2972s

Recommended Posts

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

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 3 weeks later...

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

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 months later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 months later...

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)

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