Jump to content

Admin Home Page Widget for Upcoming Hosting Renewals v6 template


caisc

Recommended Posts

Hey Guys,

 

I have created the widget to show you Upcoming Hosting Renewals in 30 Days on Admin home page of WHMCS, it is updated using Sparky's Code.

 

This widget is fully tested on latest WHMCS v6 !

 

Installation Method -

Just create a new php file in modules/widgets and paste this code in.

 

Then head over to Setup > Staff Management > Administrator Roles > Edit and scroll down to Widgets and then tick yours (in this example it's called "Upcoming Hosting Renewals in 30 Days".

 

 

 

 


<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_hosting_expiring() {

$content = '<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>Domain</td><td>Billing Cycle</td><td>Payment Method</td><td>Next Due Date</td><td>Amount</td></tr>';

   $i=1; $range = "<= 30";
   $result = mysql_query("SELECT * FROM `tblhosting` WHERE DATEDIFF(`nextduedate`, Now()) $range AND `server` > 0 ORDER BY `nextduedate` ASC");
   while ($data = @mysql_fetch_array ($result)) {

   $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['billingcycle'].'</td><td>'.$data['paymentmethod'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;
   }
   if($i) $content =  '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No upcoming hosting renewals</td></tr>';
$content .= '</table>';

   return array( 'title' => 'Upcoming Hosting Renewals in 30 Days', 'content' => $content );
}

add_hook("AdminHomeWidgets",1,"widget_hosting_expiring");

?> 

 

 

If you have any suggestions, do post it here.

Link to comment
Share on other sites

I was going to post this in the existing Sparky thread or start a new one - but seeing as you've started this thread and posted your version for hosting solely, i'll post it here. :)

 

my widget is more advanced than the above code, because not only does it include Products (e.g Hosting), but also Product Addons and Domains.

 

there is an "invoice date" column which tells me when WHMCS should auto-generate the invoice - and I can then use that to check that the invoice was generated correctly.

 

for the Products table, it tells me the product name too; for Domains, it gives me the registrar, years, due date, expiry date, invoice date, payment method, amount and whether the client has disabled auto-renewal.

 

if you find there is too much information in a table, then either reduce the font size and/or remove unnecessary columns.

 

this widget is coded to work in both v5.3 and v6 - where I can, i've used existing Language values, but there is the odd bit of English in there which you may need to translate to another language.

 

there is only one variable that you will need to edit in the file and that is the number of days you want the widget to show.

 

$numberofdays = '30';

you only have to set it once, and all the tables will use that value.

 

so follow the same installation method as above, perhaps call it "upcoming_renewals" and paste the code in...

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_upcoming_renewals($vars) {
       global $_ADMINLANG,$CONFIG,$currency;

$title = "Upcoming Renewals";
$numberofdays = '30';
$dateformat = str_replace("y","Y",strtolower(preg_replace("/(.)\\1+/", "$1", $CONFIG["DateFormat"])));
$hostinginvdays = $CONFIG["CreateInvoiceDaysBefore"];
if ($CONFIG["CreateDomainInvoiceDaysBefore"])
{
   $domaininvdays = $CONFIG["CreateDomainInvoiceDaysBefore"];
}
else
{
   $domaininvdays = $CONFIG["CreateInvoiceDaysBefore"];
}

$content .= '<h3 align="center">'.$_ADMINLANG['services']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['product'].'</td><td>'.$_ADMINLANG['fields']['billingcycle'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhosting.*,
 tblpaymentgateways.*,
 tblproducts.name
FROM tblhosting
 INNER JOIN tblpaymentgateways
   ON tblhosting.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhosting.nextduedate, NOW()) <= $numberofdays AND tblhosting.server > 0 AND tblhosting.domainstatus = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhosting.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['name'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No Upcoming '.$_ADMINLANG['services']['title'].'</td></tr>';
$content .= '</table><br />';

$content =
$content .= '<h3 align="center">'.$_ADMINLANG['addons']['productaddons'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['product'].'</td><td>'.$_ADMINLANG['fields']['billingcycle'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhosting.*,
 tblpaymentgateways.*,
 tblproducts.name
FROM tblhosting
 INNER JOIN tblpaymentgateways
   ON tblhosting.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhosting.nextduedate, NOW()) <= $numberofdays AND tblhosting.server = 0 AND tblhosting.domainstatus = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhosting.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['name'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No Upcoming '.$_ADMINLANG['addons']['productaddons'].'</td></tr>';
$content .= '</table><br />';

$content .= '<h3 align="center">'.$_ADMINLANG['domains']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['registrar'].'</td><td>'.$_ADMINLANG['domains']['years'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['expirydate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td><td>'.$_ADMINLANG['domains']['renew'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tbldomains.*,
 tblpaymentgateways.*
FROM tbldomains
 INNER JOIN tblpaymentgateways
   ON tbldomains.paymentmethod = tblpaymentgateways.gateway
WHERE DATEDIFF(tbldomains.expirydate, NOW()) <= $numberofdays AND tbldomains.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tbldomains.expirydate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$domaininvdays.' days'));

if ($data['donotrenew']=="1" OR $data['donotrenew']=="on") 
{
   $renewdomain = $_ADMINLANG['global']['no'];
}
else
{
   $renewdomain = $_ADMINLANG['global']['yes'];
}

$currency=getCurrency($data['userid']);
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientsdomains.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.ucwords($data['registrar']).'</td><td>'.$data['registrationperiod'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.fromMySQLDate($data['expirydate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['recurringamount']).'</td><td>'.$renewdomain.'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="9">No Upcoming '.$_ADMINLANG['domains']['title'].'</td></tr>';
$content .= '</table><br />';

return array('title'=>$title,'content'=>$content);

}

add_hook("AdminHomeWidgets",1,"widget_upcoming_renewals");

?>

Link to comment
Share on other sites

@brian Thanks for sharing your version also :)

 

Also i wish to increase the width of the widget, right now with limited width it is not able to display all info properly on admin page.

 

My idea is somehow increase the width of widget and place it at the bottom of admin page, that will be better displayed.

 

Thanks

Link to comment
Share on other sites

Also i wish to increase the width of the widget, right now with limited width it is not able to display all info properly on admin page.

 

My idea is somehow increase the width of widget and place it at the bottom of admin page, that will be better displayed

you can't define the width of a widget in the widget code - so if you want to do this, you'd have to modify the style.css and the admin homepage.tpl template.

 

something along the lines of adding the following to style.css - the width should be changed to suit your needs (perhaps defined in px instead).

 

.homewidgetwide {
   width: 200%;
   margin: 5px 0 10px;
   padding: 0;
   border: 1px solid #efefef;
   border-top: 3px solid #efefef;
   border-bottom: 2px solid #efefef;
   -moz-border-radius: 4px;
   -webkit-border-radius: 4px;
   -o-border-radius: 4px;
   border-radius: 4px;
}

and then modify the widget foreach loop in homepage.tpl

 

            {foreach from=$widgets item=widget}
               {if $widget.name eq "upcoming_renewals"}<div class="homewidgetwide"{else}<div class="homewidget"{/if} id="{$widget.name}">
                   <div class="widget-header">{$widget.title}</div>
                   <div class="widget-content">{$widget.content}</div>
               </div>
           {/foreach}

this basically tells the upcoming widget to be double size, the rest remain at their standard widget size - however, I think for this to work, the upcoming renewals widget might have to be first and top left, with all the other widgets below it on the left.

 

personally, as I previously suggested, I think it would be easier to just reduce the font size and/or remove columns - these css and template changes could be overwritten each time you update WHMCS.

Link to comment
Share on other sites

thanks for sharing, most appreciated

everything works fine except the product addons is not showing any due addons and I know I have some due

just shows No Upcoming Product Addons

 

any ideas what to look for why its not working, running version 6.02

 

thank you

Link to comment
Share on other sites

try the following and see if that fixes the Addons issue...

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_upcoming_renewals($vars) {
       global $_ADMINLANG,$CONFIG,$currency;

$title = "Upcoming Renewals";
$numberofdays = '90';
$dateformat = str_replace("y","Y",strtolower(preg_replace("/(.)\\1+/", "$1", $CONFIG["DateFormat"])));
$hostinginvdays = $CONFIG["CreateInvoiceDaysBefore"];
if ($CONFIG["CreateDomainInvoiceDaysBefore"])
{
   $domaininvdays = $CONFIG["CreateDomainInvoiceDaysBefore"];
}
else
{
   $domaininvdays = $CONFIG["CreateInvoiceDaysBefore"];
}

$content .= '<h3 align="center">'.$_ADMINLANG['services']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['product'].'</td><td>'.$_ADMINLANG['fields']['billingcycle'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhosting.*,
 tblpaymentgateways.*,
 tblproducts.name
FROM tblhosting
 INNER JOIN tblpaymentgateways
   ON tblhosting.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhosting.nextduedate, NOW()) <= $numberofdays AND tblhosting.domainstatus = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhosting.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['name'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No Upcoming '.$_ADMINLANG['services']['title'].'</td></tr>';
$content .= '</table><br />';

$content =
$content .= '<h3 align="center">'.$_ADMINLANG['addons']['productaddons'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['product'].'</td><td>'.$_ADMINLANG['fields']['addon'].'</td><td>'.$_ADMINLANG['fields']['billingcycle'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhostingaddons.*,
 tblpaymentgateways.*,
   tblhosting.domain,
 tblproducts.name as productname,
 tbladdons.name as addonname
FROM tblhostingaddons
 INNER JOIN tblpaymentgateways
   ON tblhostingaddons.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tbladdons
   ON tblhostingaddons.addonid = tbladdons.id
 INNER JOIN tblhosting
   ON tblhostingaddons.hostingid = tblhosting.id
INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhostingaddons.nextduedate, NOW()) <= $numberofdays AND tblhostingaddons.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhostingaddons.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['productname'].'</td><td>'.$data['addonname'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No Upcoming '.$_ADMINLANG['addons']['productaddons'].'</td></tr>';
$content .= '</table><br />';

$content .= '<h3 align="center">'.$_ADMINLANG['domains']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['registrar'].'</td><td>'.$_ADMINLANG['domains']['years'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['expirydate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td><td>'.$_ADMINLANG['domains']['renew'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tbldomains.*,
 tblpaymentgateways.*
FROM tbldomains
 INNER JOIN tblpaymentgateways
   ON tbldomains.paymentmethod = tblpaymentgateways.gateway
WHERE DATEDIFF(tbldomains.expirydate, NOW()) <= $numberofdays AND tbldomains.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tbldomains.expirydate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$domaininvdays.' days'));

if ($data['donotrenew']=="1" OR $data['donotrenew']=="on") 
{
   $renewdomain = $_ADMINLANG['global']['no'];
}
else
{
   $renewdomain = $_ADMINLANG['global']['yes'];
}

$currency=getCurrency($data['userid']);
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientsdomains.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.ucwords($data['registrar']).'</td><td>'.$data['registrationperiod'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.fromMySQLDate($data['expirydate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['recurringamount']).'</td><td>'.$renewdomain.'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="9">No Upcoming '.$_ADMINLANG['domains']['title'].'</td></tr>';
$content .= '</table><br />';

return array('title'=>$title,'content'=>$content);

}

add_hook("AdminHomeWidgets",1,"widget_upcoming_renewals");

?> 

Link to comment
Share on other sites

Hi Gazza,

 

just noticed something else in product addons , in the amount it is showing 0.00 and not the correct amount. also when you click the domain name it does not go to the domain product/name it directed to a page with

an error Service ID Not Found

here's v1.4 - I think everything is working correctly now. :idea:

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_upcoming_renewals($vars) {
       global $_ADMINLANG,$CONFIG,$currency;

$title = "Upcoming Renewals";
$numberofdays = '90';
$dateformat = str_replace("y","Y",strtolower(preg_replace("/(.)\\1+/", "$1", $CONFIG["DateFormat"])));
$hostinginvdays = $CONFIG["CreateInvoiceDaysBefore"];
if ($CONFIG["CreateDomainInvoiceDaysBefore"])
{
   $domaininvdays = $CONFIG["CreateDomainInvoiceDaysBefore"];
}
else
{
   $domaininvdays = $CONFIG["CreateInvoiceDaysBefore"];
}

$content .= '<h3 align="center">'.$_ADMINLANG['services']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['product'].'</td><td>'.$_ADMINLANG['fields']['billingcycle'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhosting.*,
 tblpaymentgateways.*,
 tblproducts.name
FROM tblhosting
 INNER JOIN tblpaymentgateways
   ON tblhosting.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhosting.nextduedate, NOW()) <= $numberofdays AND tblhosting.domainstatus = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhosting.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['name'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No Upcoming '.$_ADMINLANG['services']['title'].'</td></tr>';
$content .= '</table><br />';

$content =
$content .= '<h3 align="center">'.$_ADMINLANG['addons']['productaddons'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['product'].'</td><td>'.$_ADMINLANG['fields']['addon'].'</td><td>'.$_ADMINLANG['fields']['billingcycle'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhostingaddons.*,
 tblpaymentgateways.*,
 tblhosting.domain,
 tblhosting.userid,
 tblproducts.name as productname,
 tbladdons.name as addonname
FROM tblhostingaddons
 INNER JOIN tblpaymentgateways
   ON tblhostingaddons.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tbladdons
   ON tblhostingaddons.addonid = tbladdons.id
 INNER JOIN tblhosting
   ON tblhostingaddons.hostingid = tblhosting.id
INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhostingaddons.nextduedate, NOW()) <= $numberofdays AND tblhostingaddons.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhostingaddons.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['hostingid'].'">'.$data['domain'].'</a></td><td>'.$data['productname'].'</td><td>'.$data['addonname'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['recurring']).'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="8">No Upcoming '.$_ADMINLANG['addons']['productaddons'].'</td></tr>';
$content .= '</table><br />';

$content .= '<h3 align="center">'.$_ADMINLANG['domains']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['registrar'].'</td><td>'.$_ADMINLANG['domains']['years'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['expirydate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td><td>'.$_ADMINLANG['domains']['renew'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tbldomains.*,
 tblpaymentgateways.*
FROM tbldomains
 INNER JOIN tblpaymentgateways
   ON tbldomains.paymentmethod = tblpaymentgateways.gateway
WHERE DATEDIFF(tbldomains.expirydate, NOW()) <= $numberofdays AND tbldomains.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tbldomains.expirydate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$domaininvdays.' days'));

if ($data['donotrenew']=="1" OR $data['donotrenew']=="on") 
{
   $renewdomain = $_ADMINLANG['global']['no'];
}
else
{
   $renewdomain = $_ADMINLANG['global']['yes'];
}

$currency=getCurrency($data['userid']);
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientsdomains.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.ucwords($data['registrar']).'</td><td>'.$data['registrationperiod'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.fromMySQLDate($data['expirydate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['recurringamount']).'</td><td>'.$renewdomain.'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="9">No Upcoming '.$_ADMINLANG['domains']['title'].'</td></tr>';
$content .= '</table><br />';

return array('title'=>$title,'content'=>$content);

}

add_hook("AdminHomeWidgets",1,"widget_upcoming_renewals");

?> 

Edited by brian!
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

I like this widget update, came across it looking for the update to the expiring domains widget, but since I've got a lot of monthly services, and even at 30 days it seems like the widget will always be a long list due to how many monthly services, I've got a couple of questions:

 

Is there an easy way to exclude monthly services from the widget?

Is there an easy way to just scale this back to domains only?

 

Thanks.

Link to comment
Share on other sites

Is there an easy way to exclude monthly services from the widget?

you could modify the line below and add an IF statement to it to check the billingcycle value - so change...

 

$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['name'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;

 

to...

if ($data['billingcycle'] !='Monthly') $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.$data['name'].'</td><td>'.$data['billingcycle'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['amount']).'</td></tr>'; $i=0;

 

Is there an easy way to just scale this back to domains only?

you would just need to remove the services and addons sections of the widget...

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_upcoming_renewals($vars) {
       global $_ADMINLANG,$CONFIG,$currency;

$title = "Upcoming Domain Renewals";
$numberofdays = '90';
$dateformat = str_replace("y","Y",strtolower(preg_replace("/(.)\\1+/", "$1", $CONFIG["DateFormat"])));
$hostinginvdays = $CONFIG["CreateInvoiceDaysBefore"];
if ($CONFIG["CreateDomainInvoiceDaysBefore"])
{
   $domaininvdays = $CONFIG["CreateDomainInvoiceDaysBefore"];
}
else
{
   $domaininvdays = $CONFIG["CreateInvoiceDaysBefore"];
}

$content .= '<h3 align="center">'.$_ADMINLANG['domains']['title'].' (Next '.$numberofdays.' Days)</h3>
<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;font-size:12px;" cellspacing="1">
<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['domain'].'</td><td>'.$_ADMINLANG['fields']['registrar'].'</td><td>'.$_ADMINLANG['domains']['years'].'</td><td>'.$_ADMINLANG['fields']['nextduedate'].'</td><td>'.$_ADMINLANG['fields']['expirydate'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td>'.$_ADMINLANG['fields']['amount'].'</td><td>'.$_ADMINLANG['domains']['renew'].'</td></tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tbldomains.*,
 tblpaymentgateways.*
FROM tbldomains
 INNER JOIN tblpaymentgateways
   ON tbldomains.paymentmethod = tblpaymentgateways.gateway
WHERE DATEDIFF(tbldomains.expirydate, NOW()) <= $numberofdays AND tbldomains.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tbldomains.expirydate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$domaininvdays.' days'));

if ($data['donotrenew']=="1" OR $data['donotrenew']=="on") 
{
   $renewdomain = $_ADMINLANG['global']['no'];
}
else
{
   $renewdomain = $_ADMINLANG['global']['yes'];
}

$currency=getCurrency($data['userid']);
$content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientsdomains.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td><td>'.ucwords($data['registrar']).'</td><td>'.$data['registrationperiod'].'</td><td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.fromMySQLDate($data['expirydate']).'</td><td>'.$invoicedate.'</td><td>'.$data['value'].'</td><td>'.formatCurrency($data['recurringamount']).'</td><td>'.$renewdomain.'</td></tr>'; $i=0;
}
if($i) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="9">No Upcoming '.$_ADMINLANG['domains']['title'].'</td></tr>';
$content .= '</table><br />';

return array('title'=>$title,'content'=>$content);

}

add_hook("AdminHomeWidgets",1,"widget_upcoming_renewals");

?>

Link to comment
Share on other sites

  • 1 month later...

Hi everyone,

 

Very nice widget! I'd like to contribute to this post with my customized one...

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_upcoming_renewals($vars) {
       global $_ADMINLANG,$CONFIG,$currency;

$numberofdays = '30';
$title = "Upcoming Renewals <span style='font-size:0.8em;'>(Next ".$numberofdays." Days)</span>";
$dateformat = str_replace("y","Y",strtolower(preg_replace("/(.)\\1+/", "$1", $CONFIG["DateFormat"])));
$hostinginvdays = $CONFIG["CreateInvoiceDaysBefore"];
if ($CONFIG["CreateDomainInvoiceDaysBefore"])
{
   $domaininvdays = $CONFIG["CreateDomainInvoiceDaysBefore"];
}
else
{
   $domaininvdays = $CONFIG["CreateInvoiceDaysBefore"];
}

$content .= '
<div id="upcoming-renewals">
   <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
       <li class="active"><a href="#services" data-toggle="tab">'.$_ADMINLANG['services']['title'].'</a></li>
       <li><a href="#domains" data-toggle="tab">'.$_ADMINLANG['domains']['title'].'</a></li>
       <li><a href="#addons" data-toggle="tab">'.$_ADMINLANG['addons']['productaddons'].'</a></li>
   </ul>
   <div class="tab-content" style="padding-top:5px;">
       <div class="tab-pane active" id="services">
           <table class="table table-condensed" style="font-size:0.9em;">
               <tr bgcolor="#efefef" style="text-align:left;font-weight:bold;">
                   <td>'.$_ADMINLANG['fields']['domain'].'</td>
                   <td>'.$_ADMINLANG['fields']['product'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['nextduedate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['amount'].'</td>
               </tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhosting.*,
 tblpaymentgateways.*,
 tblproducts.name
FROM tblhosting
 INNER JOIN tblpaymentgateways
   ON tblhosting.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhosting.nextduedate, NOW()) <= $numberofdays AND tblhosting.domainstatus = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhosting.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$currency=getCurrency($data['userid']);

$content .= '
               <tr>
                   <td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td>
                   <td>'.$data['name'].'</td>
                   <td style="text-align:right;">'.fromMySQLDate($data['nextduedate']).'</td>
                   <td style="text-align:right;">'.formatCurrency($data['amount']).'</td>
               </tr>'; $i=0;
}
if($i) $content .= '
               <tr style="text-align:center;">
                   <td colspan="4">No Upcoming '.$_ADMINLANG['services']['title'].'</td>
               </tr>';
$content .= '
           </table>
       </div>
       <div class="tab-pane" id="domains">';

$content .= '
           <table class="table table-condensed" style="font-size:0.9em;">
               <tr bgcolor="#efefef" style="text-align:left;font-weight:bold;">
                   <td>'.$_ADMINLANG['fields']['domain'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['nextduedate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['expirydate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['amount'].'</td>
               </tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tbldomains.*,
 tblpaymentgateways.*
FROM tbldomains
 INNER JOIN tblpaymentgateways
   ON tbldomains.paymentmethod = tblpaymentgateways.gateway
WHERE DATEDIFF(tbldomains.expirydate, NOW()) <= $numberofdays AND tbldomains.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tbldomains.expirydate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$domaininvdays.' days'));

if ($data['donotrenew']=="1" OR $data['donotrenew']=="on")
{
   $renewdomain = $_ADMINLANG['global']['no'];
}
else
{
   $renewdomain = $_ADMINLANG['global']['yes'];
}

$currency=getCurrency($data['userid']);
$content .= '
               <tr>
                   <td><a href="clientsdomains.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td>
                   <td style="text-align:right;">'.fromMySQLDate($data['nextduedate']).'</td>
                   <td style="text-align:right;">'.fromMySQLDate($data['expirydate']).'</td>
                   <td style="text-align:right;">'.formatCurrency($data['recurringamount']).'</td>
               </tr>'; $i=0;
}
if($i) $content .= '
               <tr style="text-align:center;">
                   <td colspan="4">No Upcoming '.$_ADMINLANG['domains']['title'].'</td>
               </tr>';
$content .= '
           </table>
       </div>
       <div class="tab-pane" id="addons">';

$content .= '
           <table class="table table-condensed" style="font-size:0.9em;">
               <tr bgcolor="#efefef" style="text-align:left;font-weight:bold;">
                   <td>'.$_ADMINLANG['fields']['domain'].'</td>
                   <td>'.$_ADMINLANG['fields']['product'].'</td>
                   <td>'.$_ADMINLANG['fields']['addon'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['nextduedate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['amount'].'</td>
               </tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhostingaddons.*,
 tblpaymentgateways.*,
 tblhosting.domain,
 tblhosting.userid,
 tblproducts.name as productname,
 tbladdons.name as addonname
FROM tblhostingaddons
 INNER JOIN tblpaymentgateways
   ON tblhostingaddons.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tbladdons
   ON tblhostingaddons.addonid = tbladdons.id
 INNER JOIN tblhosting
   ON tblhostingaddons.hostingid = tblhosting.id
INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhostingaddons.nextduedate, NOW()) <= $numberofdays AND tblhostingaddons.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhostingaddons.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));

$content .= '
               <tr>
                   <td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['hostingid'].'">'.$data['domain'].'</a></td>
                   <td>'.$data['productname'].'</td>
                   <td>'.$data['addonname'].'</td>
                   <td style="text-align:right;">'.fromMySQLDate($data['nextduedate']).'</td>
                   <td style="text-align:right;">'.formatCurrency($data['recurring']).'</td>
               </tr>'; $i=0;
}
if($i) $content .= '
               <tr style="text-align:center;">
                   <td colspan="5">No Upcoming '.$_ADMINLANG['addons']['productaddons'].'</td>
               </tr>';
$content .= '
           </table>
       </div>
   </div>
</div>';

return array('title'=>$title,'content'=>$content);

}

add_hook("AdminHomeWidgets",1,"widget_upcoming_renewals");

?>

 

Thanks for the widget

Link to comment
Share on other sites

  • 2 years later...

This is updated version of caisc widget.

<?php

add_hook('AdminHomeWidgets', 2, function() {
    return new Widget3();
});

/**
 * Widget3 Widget.
 */
class Widget3 extends \WHMCS\Module\AbstractWidget
{
    protected $title = 'Upcoming Renew';
    protected $description = 'Upcoming Renew';
    protected $weight = 40;
    protected $cache = false;
    protected $requiredPermission = '';

    public function getData()
    {

 $i=1; $range = "<= 7";
$result = 
mysql_query("SELECT * FROM `tblhosting` WHERE DATEDIFF(`nextduedate`, Now()) $range ORDER BY `nextduedate` ASC");
   while ($data = @mysql_fetch_array ($result)) {

 $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientssummary.php?userid='.$data['userid'].'">Plan</a></td><td>'.$data['billingcycle'].'</td>'.'<td>'.fromMySQLDate($data['nextduedate']).'</td><td>'.formatCurrency($data['amount']).'</td> <td>'.$data['domainstatus'].'</td></tr>'; 
        $i=0;
   }

        return array(
            'rowsdata' => $content,
        );

    }

    public function generateOutput($data)
    {
        $rowsdata=$data['rowsdata'];

        return <<<EOF

<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;" cellspacing="1">

<tr bgcolor="#efefef" style="text-align:center;font-weight:bold;">
<td>Service</td><td>Billing Cycle</td><td>Next Due Date</td><td>Amount</td><td>Status</td>
</tr>
$rowsdata

</table>
       
EOF;
    }
}

 

It works on the latest version 7.5.1

Link to comment
Share on other sites

  • 6 months later...
On 20/11/2018 at 13:41, mwchetan said:

We tried to upload all the codes mentioned here but it doesn't show on homepage. We are using WHMCS 7.4.1

because these were all written for v6, you may need to go to setup -> staff management -> *choose your admin role* ... and then enable the widget from the checkboxes available...

XTkSmkm.png

once enabled, the widget should work... ultimately, this will need to be rewritten for v7 (if only to improve the display), but i'll leave that until v7.7 is released.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 4 weeks later...
On 2/1/2016 at 1:49 PM, oscarch said:

Hi everyone,

 

Very nice widget! I'd like to contribute to this post with my customized one...

 

 


<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function widget_upcoming_renewals($vars) {
       global $_ADMINLANG,$CONFIG,$currency;

$numberofdays = '30';
$title = "Upcoming Renewals <span style='font-size:0.8em;'>(Next ".$numberofdays." Days)</span>";
$dateformat = str_replace("y","Y",strtolower(preg_replace("/(.)\\1+/", "$1", $CONFIG["DateFormat"])));
$hostinginvdays = $CONFIG["CreateInvoiceDaysBefore"];
if ($CONFIG["CreateDomainInvoiceDaysBefore"])
{
   $domaininvdays = $CONFIG["CreateDomainInvoiceDaysBefore"];
}
else
{
   $domaininvdays = $CONFIG["CreateInvoiceDaysBefore"];
}

$content .= '
<div id="upcoming-renewals">
   <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
       <li class="active"><a href="#services" data-toggle="tab">'.$_ADMINLANG['services']['title'].'</a></li>
       <li><a href="#domains" data-toggle="tab">'.$_ADMINLANG['domains']['title'].'</a></li>
       <li><a href="#addons" data-toggle="tab">'.$_ADMINLANG['addons']['productaddons'].'</a></li>
   </ul>
   <div class="tab-content" style="padding-top:5px;">
       <div class="tab-pane active" id="services">
           <table class="table table-condensed" style="font-size:0.9em;">
               <tr bgcolor="#efefef" style="text-align:left;font-weight:bold;">
                   <td>'.$_ADMINLANG['fields']['domain'].'</td>
                   <td>'.$_ADMINLANG['fields']['product'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['nextduedate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['amount'].'</td>
               </tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhosting.*,
 tblpaymentgateways.*,
 tblproducts.name
FROM tblhosting
 INNER JOIN tblpaymentgateways
   ON tblhosting.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhosting.nextduedate, NOW()) <= $numberofdays AND tblhosting.domainstatus = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhosting.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));
$currency=getCurrency($data['userid']);

$content .= '
               <tr>
                   <td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td>
                   <td>'.$data['name'].'</td>
                   <td style="text-align:right;">'.fromMySQLDate($data['nextduedate']).'</td>
                   <td style="text-align:right;">'.formatCurrency($data['amount']).'</td>
               </tr>'; $i=0;
}
if($i) $content .= '
               <tr style="text-align:center;">
                   <td colspan="4">No Upcoming '.$_ADMINLANG['services']['title'].'</td>
               </tr>';
$content .= '
           </table>
       </div>
       <div class="tab-pane" id="domains">';

$content .= '
           <table class="table table-condensed" style="font-size:0.9em;">
               <tr bgcolor="#efefef" style="text-align:left;font-weight:bold;">
                   <td>'.$_ADMINLANG['fields']['domain'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['nextduedate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['expirydate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['amount'].'</td>
               </tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tbldomains.*,
 tblpaymentgateways.*
FROM tbldomains
 INNER JOIN tblpaymentgateways
   ON tbldomains.paymentmethod = tblpaymentgateways.gateway
WHERE DATEDIFF(tbldomains.expirydate, NOW()) <= $numberofdays AND tbldomains.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tbldomains.expirydate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$domaininvdays.' days'));

if ($data['donotrenew']=="1" OR $data['donotrenew']=="on")
{
   $renewdomain = $_ADMINLANG['global']['no'];
}
else
{
   $renewdomain = $_ADMINLANG['global']['yes'];
}

$currency=getCurrency($data['userid']);
$content .= '
               <tr>
                   <td><a href="clientsdomains.php?userid='.$data['userid'].'&id='.$data['id'].'">'.$data['domain'].'</a></td>
                   <td style="text-align:right;">'.fromMySQLDate($data['nextduedate']).'</td>
                   <td style="text-align:right;">'.fromMySQLDate($data['expirydate']).'</td>
                   <td style="text-align:right;">'.formatCurrency($data['recurringamount']).'</td>
               </tr>'; $i=0;
}
if($i) $content .= '
               <tr style="text-align:center;">
                   <td colspan="4">No Upcoming '.$_ADMINLANG['domains']['title'].'</td>
               </tr>';
$content .= '
           </table>
       </div>
       <div class="tab-pane" id="addons">';

$content .= '
           <table class="table table-condensed" style="font-size:0.9em;">
               <tr bgcolor="#efefef" style="text-align:left;font-weight:bold;">
                   <td>'.$_ADMINLANG['fields']['domain'].'</td>
                   <td>'.$_ADMINLANG['fields']['product'].'</td>
                   <td>'.$_ADMINLANG['fields']['addon'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['nextduedate'].'</td>
                   <td style="text-align:right;">'.$_ADMINLANG['fields']['amount'].'</td>
               </tr>';

$i=1; $range = "<= ".$numberofdays;
$result = mysql_query("SELECT
 tblhostingaddons.*,
 tblpaymentgateways.*,
 tblhosting.domain,
 tblhosting.userid,
 tblproducts.name as productname,
 tbladdons.name as addonname
FROM tblhostingaddons
 INNER JOIN tblpaymentgateways
   ON tblhostingaddons.paymentmethod = tblpaymentgateways.gateway
 INNER JOIN tbladdons
   ON tblhostingaddons.addonid = tbladdons.id
 INNER JOIN tblhosting
   ON tblhostingaddons.hostingid = tblhosting.id
INNER JOIN tblproducts
   ON tblhosting.packageid = tblproducts.id
WHERE DATEDIFF(tblhostingaddons.nextduedate, NOW()) <= $numberofdays AND tblhostingaddons.status = 'Active' AND tblpaymentgateways.setting = 'name'
ORDER BY tblhostingaddons.nextduedate");
while ($data = @mysql_fetch_array ($result)) {
$invoicedate=date($dateformat,strtotime($data['nextduedate'].'-'.$hostinginvdays.' days'));

$content .= '
               <tr>
                   <td><a href="clientshosting.php?userid='.$data['userid'].'&id='.$data['hostingid'].'">'.$data['domain'].'</a></td>
                   <td>'.$data['productname'].'</td>
                   <td>'.$data['addonname'].'</td>
                   <td style="text-align:right;">'.fromMySQLDate($data['nextduedate']).'</td>
                   <td style="text-align:right;">'.formatCurrency($data['recurring']).'</td>
               </tr>'; $i=0;
}
if($i) $content .= '
               <tr style="text-align:center;">
                   <td colspan="5">No Upcoming '.$_ADMINLANG['addons']['productaddons'].'</td>
               </tr>';
$content .= '
           </table>
       </div>
   </div>
</div>';

return array('title'=>$title,'content'=>$content);

}

add_hook("AdminHomeWidgets",1,"widget_upcoming_renewals");

?>

 

 

 

Thanks for the widget

Hello Oscarch and Brian, can you please confirm that this code hyperlinks work fine in ver 7.7.1

widgets works perfectly fine, but the hyperlinks populated in the table have wrong user id/prod id

Let me know how it works with version 7.7.1 at your end.

Thanks

Link to comment
Share on other sites

21 minutes ago, caisc said:

Hello Oscarch and Brian, can you please confirm that this code hyperlinks work fine in ver 7.7.1

widgets works perfectly fine, but the hyperlinks populated in the table have wrong user id/prod id

Let me know how it works with version 7.7.1 at your end.

it looks like the SQL queries needed tweaking - i'll attach the updated file rather than posting the entire code, but basically i've just changed the three references of...

tblpaymentgateways.*

to...

tblpaymentgateways.value

.. and it's still on my list of things to do to update this widget properly for v7.7+ 📅

admin.php

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