Jump to content

Hide AU domain renew buttom


Recommended Posts

Here's another quick one that will hide the renew button in the clientarea if the AU domain is not within the 90 day renewal period.

 

Open clientareadomaindetails.tpl and find

<tr> {if $renew}

above it insert this

{php}
$autlds = array("asn.au","com.au","edu.au","org.au","net.au","id.au");
$result = mysql_query("SELECT * FROM tbldomains WHERE id='".$this->_tpl_vars['domainid']."' AND userid='".$_SESSION['uid']."' AND DATEDIFF(expirydate, NOW()) >= 90 AND status='Active'");
while ($data = mysql_fetch_array($result)) {
   foreach ($autlds as $xx) {
       $audomain = strstr($data['domain'], $xx);
       if ($audomain) break;
   }
   if ($audomain) $this->assign("renew", '0');
}
{/php}

Link to comment
Share on other sites

What is the rule for the UK domains for renewals and I can add it in

 

Like the 3 month rule for .au the rule for .uk is 6 months

so within the php block add after your code

 

$uktlds = array(".co.uk",".org.uk",".me.uk",".ltd.uk",".plc.uk",".net.uk");
$result = mysql_query("SELECT * FROM tbldomains WHERE id='".$this->_tpl_vars['domainid']."' AND userid='".$_SESSION['uid']."' AND DATEDIFF(expirydate, NOW()) >= 180 AND status='Active'");
while ($data = mysql_fetch_array($result)) {
   foreach ($uktlds as $xx) {
       $ukdomain = strstr($data['domain'], $xx);
       if ($ukdomain) break;
   }
   if ($ukdomain) $this->assign("renew", '0');
}

Link to comment
Share on other sites

Adding the "active" check is one i'd not thought of - stops people renewing domains you've set as fraud/cancelled etc

 

IMHO no need to check user, as you have the actual ID of the domain

 

cycling through the tlds works for some extensions where the CC in the ccTLD is not at the end, but quicker is to just do ...

 

$result = mysql_query("SELECT * FROM tbldomains WHERE id='".$this->_tpl_vars['domainid']."' AND DATEDIFF(expirydate, NOW()) >= 90 AND status='Active' AND domain like '%.au'");
while ($data = mysql_fetch_array($result)) 
{
   $this->assign("renew", '0');
}

Link to comment
Share on other sites

oh, and while we're sharing ....

{if $renew}<td align=right>
{php}
// get smarty variables $domain and $nextduedate
$domain = $this->get_template_vars('domain');
$duedate = explode("/",$this->get_template_vars('nextduedate'));
$duedate = array($duedate[2], $duedate[1], $duedate[0]);
$nextduedate=implode("-", $duedate);

// find in tblinvoiceitems to see if invoiced
$invoicequery = "SELECT * FROM tblinvoiceitems WHERE type='Domain' AND duedate ='".$nextduedate."' AND description LIKE 'Domain Renewal - ".$domain." -%';";
$invoiceresult = mysql_query($invoicequery);
$invoicedalready = mysql_num_rows($invoiceresult);
$renewalinvoice = 0;
if ($invoicedalready >= 1)
{
       $renewalinvoice = 1;
}
$this->assign('renewalinvoice',$renewalinvoice);
{/php}
<form method="post" action="{$smarty.server.PHP_SELF}?action={if $renewalinvoice}invoices{else}domainrenew{/if}">
<input type="hidden" name="domainid" value="{$domainid}">
<input type="submit" value="{$LANG.domainrenew}" class="button">
</form>
</td>
{/if}

instead of the existing if will divert them to the invoice if it exists for the renewal rather than letting them create another one :)

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

G'day Sparky & Rob,

Is the code I've got this code so far okay?

<p><strong> »  {$LANG.domainmanagementtools}</strong></p>

<table align="center"><tr>

 

{php}

$autlds = array("asn.au","com.au","edu.au","org.au","net.au","id.au");

$result = mysql_query("SELECT * FROM tbldomains WHERE id='".$this->_tpl_vars['domainid']."' AND userid='".$_SESSION['uid']."' AND DATEDIFF(expirydate, NOW()) >= 90 AND status='Active'");

while ($data = mysql_fetch_array($result)) {

foreach ($autlds as $xx) {

$audomain = strstr($data['domain'], $xx);

if ($audomain) break;

}

if ($audomain) $this->assign("renew", '0');

}

 

$uktlds = array(".co.uk",".org.uk",".me.uk",".ltd.uk",".plc.uk",".net.uk");

$result = mysql_query("SELECT * FROM tbldomains WHERE id='".$this->_tpl_vars['domainid']."' AND userid='".$_SESSION['uid']."' AND DATEDIFF(expirydate, NOW()) >= 180 AND status='Active'");

while ($data = mysql_fetch_array($result)) {

foreach ($uktlds as $xx) {

$ukdomain = strstr($data['domain'], $xx);

if ($ukdomain) break;

}

if ($ukdomain) $this->assign("renew", '0');

}

 

{/php}

 

{if $renew}<td>

 

But don't understand Smarty, etc. well enough to work out where that last bit goes.

Link to comment
Share on other sites

  • 10 months later...

The code provided only works if the client is renewing there domain name via the management section, otherwise if a client was to visit this link: domain.com/whmcs/cart.php?gid=renewals -> looks like a section of php code will also need to be added to this page from preventing users from renewing domain names which cannot be renewed before a X amount of days.

Link to comment
Share on other sites

  • 2 months later...

For the /cart.php?gid=renewalswrite something like this in domainrenewals.tpl

 

{* Set 'cantrenew' for the domain if the .au domain cant be renewed *}

<code>

{php}

$autlds = array("asn.au","com.au","edu.au","org.au","net.au","id.au");

$renewalArray = $this->_tpl_vars['renewals'];

$renewalsCopy = $renewalArray;

 

for ($i = 0; $i < count($renewalArray); $i++) {

$sql = "SELECT * FROM tbldomains WHERE id=".$renewalArray[$i]['id']." AND userid='".$_SESSION['uid']."' AND DATEDIFF(expirydate, NOW()) >= 90 AND status='Active'";

$result = mysql_query($sql);

 

while ($data = mysql_fetch_array($result)) {

foreach ($autlds as $xx) {

$audomain = strstr($data['domain'], $xx);

if ($audomain) break;

}

if ($audomain){ // Can't renew this .au domain name

 

$renewalsCopy[$i][cantrenew] = '1';

$this->append('renewals', $renewalsCopy,TRUE);

}

}

}

//echo '<PRE>'.print_r( $this->get_template_vars(renewals),1 ).'</PRE>';

{/php}

</code>

 

Then lower down in template:

{if !$renewal.pastgraceperiod AND !$renewal.cantrenew} etc etc

Edited by downunder
fix code layout
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
oh, and while we're sharing ....

{if $renew}<td align=right>
{php}
// get smarty variables $domain and $nextduedate
$domain = $this->get_template_vars('domain');
$duedate = explode("/",$this->get_template_vars('nextduedate'));
$duedate = array($duedate[2], $duedate[1], $duedate[0]);
$nextduedate=implode("-", $duedate);

// find in tblinvoiceitems to see if invoiced
$invoicequery = "SELECT * FROM tblinvoiceitems WHERE type='Domain' AND duedate ='".$nextduedate."' AND description LIKE 'Domain Renewal - ".$domain." -%';";
$invoiceresult = mysql_query($invoicequery);
$invoicedalready = mysql_num_rows($invoiceresult);
$renewalinvoice = 0;
if ($invoicedalready >= 1)
{
       $renewalinvoice = 1;
}
$this->assign('renewalinvoice',$renewalinvoice);
{/php}
<form method="post" action="{$smarty.server.PHP_SELF}?action={if $renewalinvoice}invoices{else}domainrenew{/if}">
<input type="hidden" name="domainid" value="{$domainid}">
<input type="submit" value="{$LANG.domainrenew}" class="button">
</form>
</td>
{/if}

instead of the existing if will divert them to the invoice if it exists for the renewal rather than letting them create another one :)

 

Thanks for this, but tried it and the link is always for the invoices page (renewal link is never built)?

Double checked no invoices exist for the domain under any accounts.

Using latest 4.3.1 version.

Any ideas? Thanks :)

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