RPS Posted February 17, 2008 Share Posted February 17, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
JasonO Posted February 17, 2008 Share Posted February 17, 2008 That's pretty neat. Thanks for contributing (again I think? ) RPS. 0 Quote Link to comment Share on other sites More sharing options...
amnesia Posted February 18, 2008 Share Posted February 18, 2008 Is there a way to only make this code appear if they have ordered domains? If they have no domains, then I would like to make this section hidden. Does anyone know how to do that? 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 18, 2008 Author Share Posted February 18, 2008 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} 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 18, 2008 Author Share Posted February 18, 2008 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} 0 Quote Link to comment Share on other sites More sharing options...
amnesia Posted February 18, 2008 Share Posted February 18, 2008 perfect, thank you! 0 Quote Link to comment Share on other sites More sharing options...
arhost Posted February 18, 2008 Share Posted February 18, 2008 Great , thank you!. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted February 18, 2008 WHMCS CEO Share Posted February 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
Si Posted February 18, 2008 Share Posted February 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 18, 2008 Author Share Posted February 18, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 18, 2008 Author Share Posted February 18, 2008 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 - When the month is either 11 or 12, that will change it to 13 or 14, right? 0 Quote Link to comment Share on other sites More sharing options...
Si Posted February 18, 2008 Share Posted February 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
ask21900 Posted February 18, 2008 Share Posted February 18, 2008 - 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. 0 Quote Link to comment Share on other sites More sharing options...
ask21900 Posted February 18, 2008 Share Posted February 18, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 18, 2008 Author Share Posted February 18, 2008 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} 0 Quote Link to comment Share on other sites More sharing options...
Si Posted February 18, 2008 Share Posted February 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
Si Posted February 18, 2008 Share Posted February 18, 2008 Or, it would be even better if it showed the upcoming domain, but changed the button from RENEW DOMAIN to VIEW INVOICE. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 18, 2008 Author Share Posted February 18, 2008 Or, it would be even better if it showed the upcoming domain, but changed the button from RENEW DOMAIN to VIEW INVOICE. - 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. 0 Quote Link to comment Share on other sites More sharing options...
ask21900 Posted February 18, 2008 Share Posted February 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
Si Posted February 18, 2008 Share Posted February 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
jack10k Posted February 21, 2008 Share Posted February 21, 2008 That's pretty cool. Makes it easy for clients to see what is going on with their domains. Thanks for contributing. 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted February 21, 2008 Share Posted February 21, 2008 @RPS A great idea here. unfortunately all I get is a blank screen when I insert any of the versions into the specifed tpl file. is it compliant with WHMCS v3.6.0? Any suggestion to debugging would be much appreciated. 0 Quote Link to comment Share on other sites More sharing options...
lynnette Posted February 21, 2008 Share Posted February 21, 2008 I was just taking a look around your site Zorro (very informative by the way) and noticed a link to a website designed by you http://www.newclarity.com.au/ but its been hacked, I don't know if you knew already, but thought I would tell you just in case. 0 Quote Link to comment Share on other sites More sharing options...
RPS Posted February 21, 2008 Author Share Posted February 21, 2008 Any suggestion to debugging would be much appreciated. - 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. 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted February 26, 2008 Share Posted February 26, 2008 - 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 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.