Jump to content

Add "Upcoming Domain Renewals" to client area


RPS

Recommended Posts

Here's the problem..

 

When clients receive an e-mail to renew their domain (ours is set to e-mail 45 days prior to expiration), the link in the e-mail takes the client directly to the client area.

 

The client then needs to navigate to the domain renewal button by clicking "My Domains" -> "View Details" next to the domain name -> Scroll down to bottom and click "Renew Domain"

 

Pretty easy for someone who knows where they are looking, but incredibly frustrating for a client that barely knows how to login.

 

The following code will display on the Client Area homepage, right below where the unpaid invoice section appears.

 

Open:

whmcs/templates/default/clientareahome.tpl

whmcs/templates/portal/clientareahome.tpl

 

At the end of the file, add:

 

<p><strong>Upcoming Domain Renewals</strong></p>
<table align="center" style="width:90%" class="clientareatable" cellspacing="1">
<tr class="clientareatableheading"><td>Domain</td><td>Expiration Date</td><td></td></tr>
{php}
$year=date("Y");
$month=date("m")+2;
$day=date("d");
if($month>="12"){$month="02";$year+=1;}
if($month!="12"){$month="0".$month;}
$date=$year."-".$month."-".$day;

$i=1;
$result = mysql_query("SELECT * FROM tbldomains WHERE userid='".$_SESSION['uid']."' AND expirydate<'".$date."' AND status='Active' ORDER BY `expirydate` ASC ");
while($data = mysql_fetch_array($result))
{
echo '<tr class="clientareatableactive"><td>'.$data['domain'].'</td><td>'.$data['expirydate'].'</td><td><form method="post" action="clientarea.php?action=domainrenew"><input name="domainid" value="'.$data['id'].'" type="hidden"><input value="Renew Domain" class="button" type="submit"></form></td></tr>';
$i=0;
}
{/php}
{php}
if($i)echo '<tr class="clientareatableactive"><td colspan="2">No upcoming domain renewals</td><td><a href="clientarea.php?action=domains">View Domains</a></td></tr>';
{/php}
</table>

 

The script will return all domains that are due to expire within 2 months. Now when a client follows the link in their domain renewal email notice, they will be presented with a page that contains all of the domains that they can renew.

Link to comment
Share on other sites

  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

It will require another lookup within the database...

 

{php}
$display_domain=0;
$result = mysql_query("SELECT *  FROM tbldomains WHERE userid = ".$_SESSION['uid']." AND status = 'Active' LIMIT 1");
while($data = mysql_fetch_array($result))
{
$display_domain=1;
}
{/php}

{php}
if($display_domain){
{/php}
<p><strong>Upcoming Domain Renewals</strong></p>
<table align="center" style="width:90%" class="clientareatable" cellspacing="1">
<tr class="clientareatableheading"><td>Domain</td><td>Expiration Date</td><td></td></tr>
{php}
$year=date("Y");
$month=date("m")+2;
$day=date("d");
if($month>="12"){$month="02";$year+=1;}
if($month!="12"){$month="0".$month;}
$date=$year."-".$month."-".$day;

$i=1;
$result = mysql_query("SELECT * FROM tbldomains WHERE userid='".$_SESSION['uid']."' AND expirydate<'".$date."' AND status='Active' ORDER BY `expirydate` ASC ");
while($data = mysql_fetch_array($result))
{
echo '<tr class="clientareatableactive"><td>'.$data['domain'].'</td><td>'.$data['expirydate'].'</td><td><form method="post" action="clientarea.php?action=domainrenew"><input name="domainid" value="'.$data['id'].'" type="hidden"><input value="Renew Domain" class="button" type="submit"></form></td></tr>';
$i=0;
}
{/php}
{php}
if($i)echo '<tr class="clientareatableactive"><td colspan="2">No upcoming domain renewals</td><td><a href="clientarea.php?action=domains">View Domains</a></td></tr>';
{/php}
</table>
{php}
}
{/php}

Link to comment
Share on other sites

It will require another lookup within the database...

 

{php}
$display_domain=0;
$result = mysql_query("SELECT *  FROM tbldomains WHERE userid = ".$_SESSION['uid']." AND status = 'Active' LIMIT 1");
while($data = mysql_fetch_array($result))
{
$display_domain=1;
}

if($display_domain){
{/php}
<p><strong>Upcoming Domain Renewals</strong></p>
<table align="center" style="width:90%" class="clientareatable" cellspacing="1">
<tr class="clientareatableheading"><td>Domain</td><td>Expiration Date</td><td></td></tr>
{php}
$year=date("Y");
$month=date("m")+2;
$day=date("d");
if($month>="12"){$month="02";$year+=1;}
if($month!="12"){$month="0".$month;}
$date=$year."-".$month."-".$day;

$i=1;
$result = mysql_query("SELECT * FROM tbldomains WHERE userid='".$_SESSION['uid']."' AND expirydate<'".$date."' AND status='Active' ORDER BY `expirydate` ASC ");
while($data = mysql_fetch_array($result))
{
echo '<tr class="clientareatableactive"><td>'.$data['domain'].'</td><td>'.$data['expirydate'].'</td><td><form method="post" action="clientarea.php?action=domainrenew"><input name="domainid" value="'.$data['id'].'" type="hidden"><input value="Renew Domain" class="button" type="submit"></form></td></tr>';
$i=0;
}

if($i)echo '<tr class="clientareatableactive"><td colspan="2">No upcoming domain renewals</td><td><a href="clientarea.php?action=domains">View Domains</a></td></tr>';
{/php}
</table>
{php}
}
{/php}

Link to comment
Share on other sites

Works great, thank you!

 

One question though. I'm concerned about double invoicing. ie, we raise the upcoming domain renewal emails 60 days before expiry and then raise the automated invoices 30 days before. If a client logs in after the invoice has been raised for the domain renewal and the upcoming domain renewal notice is used on the home page, would they not be raising another invoice for the domain by using it?

 

If so, wondering if this feature could be made to display invoices due for renewal between 60 and 30 days?

 

Si

Link to comment
Share on other sites

Si,

 

This script will just grab the domain names that are expiring within a given amount of time. You can set the time constraints as you wish.

 

I'm not sure about returning within a certain date range (such as between 30 and 60 days). Maybe someone can post a modified version of the SQL to return domains within a specific range.

Link to comment
Share on other sites

For the date, a better way of calculating it is as follows:

 

$date = date("Ymd",mktime(0,0,0,date("m")+2,date("d"),date("Y")));

 

Matt

 

Hi Matt,

Is there a way to get this to show upcoming domains due for renewal between say 60 and 30 days before renewal date?

 

Si

Link to comment
Share on other sites

- When the month is either 11 or 12, that will change it to 13 or 14, right?

 

Yes, but that is exactly why you want to do that. mktime returns the seconds as it is in relation to server time. If you do not add the two months then in Nov and Dec it will make a time of Jan or Feb of the current year... Showing the domain as 10 months expired.

 

When making it months plus 2 it will "loop" for lack of a better word.

Link to comment
Share on other sites

Hi Matt,

Is there a way to get this to show upcoming domains due for renewal between say 60 and 30 days before renewal date?

 

Si

 

This does show domains that expire within 60 days. If you want to separate the domains from within 60 days and withing 30 days you would have to do another query.

 

I have to go for a few, but I will change the code and post in about an hour.

Link to comment
Share on other sites

Here's the updated code using the better way to handle the dates (the one Matt posted)

 

{php}
$display_domain=0;
$result = mysql_query("SELECT *  FROM tbldomains WHERE userid = ".$_SESSION['uid']." AND status = 'Active' LIMIT 1");
while($data = mysql_fetch_array($result))
{
   $display_domain=1;
}

if($display_domain){
{/php}
<p><strong>Upcoming Domain Renewals</strong></p>
<table align="center" style="width:90%" class="clientareatable" cellspacing="1">
<tr class="clientareatableheading"><td>Domain</td><td>Expiration Date</td><td></td></tr>
{php}
$date = date("Ymd",mktime(0,0,0,date("m")+2,date("d"),date("Y")));
$i=1;
$result = mysql_query("SELECT * FROM tbldomains WHERE userid='".$_SESSION['uid']."' AND expirydate<'".$date."' AND status='Active' ORDER BY `expirydate` ASC ");
while($data = mysql_fetch_array($result))
{
   echo '<tr class="clientareatableactive"><td>'.$data['domain'].'</td><td>'.$data['expirydate'].'</td><td><form method="post" action="clientarea.php?action=domainrenew"><input name="domainid" value="'.$data['id'].'" type="hidden"><input value="Renew Domain" class="button" type="submit"></form></td></tr>';
   $i=0;
}

if($i)echo '<tr class="clientareatableactive"><td colspan="2">No upcoming domain renewals</td><td><a href="clientarea.php?action=domains">View Domains</a></td></tr>';
{/php}
</table>
{php}
}
{/php}

Link to comment
Share on other sites

This does show domains that expire within 60 days. If you want to separate the domains from within 60 days and withing 30 days you would have to do another query.

 

I have to go for a few, but I will change the code and post in about an hour.

 

Cheers.

 

I only want to show domains due for renewal between 60 and 30 days prior to renewal date as once the 30 days comes, there will be an invoice due displayed above on the home page which has already been generated for domains which have reached 30 days prior to renewal date. Hope that makes sense.

 

Si

Link to comment
Share on other sites

Or, it would be even better if it showed the upcoming domain, but changed the button from RENEW DOMAIN to VIEW INVOICE. 8)

- The problem with this is that the invoice isn't created when the renewal e-mail is sent out.

 

1) So WHMCS sends out renewal e-mail based on the domain renewal email notice within the Automation settings.

2) Client receives e-mail telling client the domain is due for renewal within X days. Within that e-mail, client is linked to the clientarea.php page. No invoice to pay, no link to renew the domain (I believe Matt is planning to implement the latter)

3) Client clicks the link, and is presented with clientarea.php. No invoice, and no notice regarding the upcoming domain renewal is displayed.

 

At this point, the client has to navigate to "View Domains" then select the domain, then scroll down to the bottom and click "Renew Domain"

 

If there was another setting with WHMCS that created the invoice when the domain renewal email was sent, then I think this would make the process much easier.

 

The entire system works, but this should be improved. I'm not saying it needs to be improved, but it would make it much easier for the client if it was.

Link to comment
Share on other sites

Cheers.

 

I only want to show domains due for renewal between 60 and 30 days prior to renewal date as once the 30 days comes, there will be an invoice due displayed above on the home page which has already been generated for domains which have reached 30 days prior to renewal date. Hope that makes sense.

 

Si

 

In that case, change the date variable to:

 

$date30 = date("Ymd",mktime(0,0,0,date("m")+1,date("d"),date("Y")));
$date60 = date("Ymd",mktime(0,0,0,date("m")+2,date("d"),date("Y")));

 

and then change the result variable to:

 

$result = mysql_query("SELECT * FROM tbldomains WHERE userid='".$_SESSION['uid']."' AND expirydate<'".$date60."' AND expirydate>'".$date30."' AND status='Active' ORDER BY `expirydate` ASC ");

 

I should note that I took the easy way out... This will not display between 30 and 60 days, but rather 1 month and two months (so it might be off a few days).

 

Sorry for the delay... I got busy all of a sudden

Link to comment
Share on other sites

In that case, change the date variable to:

 

$date30 = date("Ymd",mktime(0,0,0,date("m")+1,date("d"),date("Y")));
$date60 = date("Ymd",mktime(0,0,0,date("m")+2,date("d"),date("Y")));

 

and then change the result variable to:

 

$result = mysql_query("SELECT * FROM tbldomains WHERE userid='".$_SESSION['uid']."' AND expirydate<'".$date60."' AND expirydate>'".$date30."' AND status='Active' ORDER BY `expirydate` ASC ");

 

I should note that I took the easy way out... This will not display between 30 and 60 days, but rather 1 month and two months (so it might be off a few days).

 

Sorry for the delay... I got busy all of a sudden

 

Cheers for this. On first testing it looks like it works perfectly.

 

Si

Link to comment
Share on other sites

- Redo your changes to the tpl file. A blank screen means there is a php error somewhere I believe.

 

So restore your tpl file, then apply the change again.

 

thnaks RPS,

 

as you suggested. i was pasting code direct from this thread and notice that acouple of non-displaying charactres were coming in, which of course affected the code.

 

Now works (almost) perfectly. If i could just get the table formatting to match the 2 boxes above it.. it would be just right.

 

Well done on a grat mod.

 

Cheers

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