Jump to content

Open Invoices Widget


Recommended Posts

With the new release of WHMCS the Open Invoices Widget was removed. I had to go over my old files and found this. Hope you find it useful. Create a new .php file (I used open_invoices.php) and upload it to whmcs/modules/widgets/  It is working fine with 8.1.0

<?php

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

function widget_open_invoices($vars) {
    global $_ADMINLANG,$currency;

    $title = $_ADMINLANG['home']['openinvoices'];

    if (!function_exists("getGatewaysArray")) require(ROOTDIR."/includes/gatewayfunctions.php");
    $gatewaysarray = getGatewaysArray();

    $content = '<table class="table table-condensed">
<tr style="background-color:#efefef;font-weight:bold;text-align:center"><td>'.$_ADMINLANG['fields']['invoicenum'].'</td><td>'.$_ADMINLANG['fields']['clientname'].'</td><td>'.$_ADMINLANG['fields']['invoicedate'].'</td><td>'.$_ADMINLANG['fields']['duedate'].'</td><td>'.$_ADMINLANG['fields']['totaldue'].'</td><td>'.$_ADMINLANG['fields']['paymentmethod'].'</td><td width="20"></td></tr>
';

    $id = '';
    $query = "SELECT tblinvoices.*,tblinvoices.total-COALESCE((SELECT SUM(amountin) FROM tblaccounts WHERE tblaccounts.invoiceid=tblinvoices.id),0) AS invoicebalance,tblclients.firstname,tblclients.lastname FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.status='Unpaid' ORDER BY duedate,date ASC LIMIT 0,5";
    $result = full_query($query);
    while ($data = mysql_fetch_array($result)) {
        $id = $data["id"];
        $invoicenum = $data["invoicenum"];
        $userid = $data["userid"];
        $firstname = $data["firstname"];
        $lastname = $data["lastname"];
        $date = $data["date"];
        $duedate = $data["duedate"];
        $total = $data["total"];
        $invoicebalance = $data["invoicebalance"];
        $paymentmethod = $data["paymentmethod"];
        $paymentmethod = $gatewaysarray[$paymentmethod];
        $date = fromMySQLDate($date);
        $duedate = fromMySQLDate($duedate);
        $currency = getCurrency($userid);
        if (!$invoicenum) $invoicenum = $id;
        $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="invoices.php?action=edit&id='.$id.'">'.$invoicenum.'</a></td><td>'.$firstname.' '.$lastname.'</td><td>'.$date.'</td><td>'.$duedate.'</td><td>'.formatCurrency($total).'</td><td>'.$paymentmethod.'</td><td><a href="invoices.php?action=edit&id='.$id.'"><img src="images/edit.gif" border="0" /></a></td></tr>';
    }
    if (!$id) $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">'.$_ADMINLANG['global']['norecordsfound'].'</td></tr>';

    $content .= '</table>
<div class="widget-footer">
    <a href="invoices.php?status=Unpaid" class="btn btn-info btn-sm">'.$_ADMINLANG['home']['viewall'].' &raquo;</a>
</div>';

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

}

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

 

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