Server IP : 213.176.29.180 / Your IP : 18.117.74.47 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/modules/reports/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php use WHMCS\Carbon; use WHMCS\Database\Capsule; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } $dateFilter = Carbon::create( $year, $month, 1 ); $startOfMonth = $dateFilter->startOfMonth()->toDateTimeString(); $endOfMonth = $dateFilter->endOfMonth()->toDateTimeString(); $reportdata["title"] = "Monthly Transactions Report for " . $months[(int) $month] . " " . $year; $reportdata["description"] = "This report provides a summary of daily payments activity for a given month. The Amount Out figure includes both expenditure transactions and refunds."; $reportdata["currencyselections"] = true; $reportdata["monthspagination"] = true; $reportdata["tableheadings"] = array( "Date", "Amount In", "Fees", "Amount Out", "Balance" ); $reportvalues = array(); $dateFormat = Capsule::raw('date_format(date, "%e")'); $result = Capsule::table('tblaccounts') ->join('tblclients', 'tblclients.id', '=', 'tblaccounts.userid') ->where('tblclients.currency', $currencyid) ->whereBetween( 'date', [ $startOfMonth, $endOfMonth ] ) ->orderBy('date') ->groupBy($dateFormat) ->get( [ Capsule::raw('date_format(date, "%e") as day_of_month'), Capsule::raw('SUM(amountin) as in_amount'), Capsule::raw('SUM(fees) as fee_amount'), Capsule::raw('SUM(amountout) as out_amount'), ] ) ->all(); foreach ($result as $data) { $reportvalues[$data->day_of_month] = array( 'amountin' => $data->in_amount, 'fees' => $data->fee_amount, 'amountout' => $data->out_amount, ); } $result = Capsule::table('tblaccounts') ->where('userid', 0) ->where('currency', $currencyid) ->whereBetween( 'date', [ $startOfMonth, $endOfMonth ] ) ->orderBy('date') ->groupBy($dateFormat) ->get( [ Capsule::raw('date_format(date, "%e") as day_of_month'), Capsule::raw('SUM(amountin) as in_amount'), Capsule::raw('SUM(fees) as fee_amount'), Capsule::raw('SUM(amountout) as out_amount'), ] ) ->all(); foreach ($result as $data) { $reportvalues[$data->day_of_month] = array( 'amountin' => $data->in_amount, 'fees' => $data->fee_amount, 'amountout' => $data->out_amount, ); } for ($dayOfTheMonth = 1; $dayOfTheMonth <= $dateFilter->lastOfMonth()->day; $dayOfTheMonth++) { $amountin = isset($reportvalues[$dayOfTheMonth]['amountin']) ? $reportvalues[$dayOfTheMonth]['amountin'] : '0'; $fees = isset($reportvalues[$dayOfTheMonth]['fees']) ? $reportvalues[$dayOfTheMonth]['fees'] : '0'; $amountout = isset($reportvalues[$dayOfTheMonth]['amountout']) ? $reportvalues[$dayOfTheMonth]['amountout'] : '0'; $dailybalance = $amountin-$fees-$amountout; $overallbalance += $dailybalance; $chartdata['rows'][] = array('c'=>array(array('v'=>$dayOfTheMonth),array('v'=>$amountin,'f'=>formatCurrency($amountin)),array('v'=>$fees,'f'=>formatCurrency($fees)),array('v'=>$amountout,'f'=>formatCurrency($amountout)))); $amountin = formatCurrency($amountin); $fees = formatCurrency($fees); $amountout = formatCurrency($amountout); $dailybalance = formatCurrency($dailybalance); $dayOfTheMonth = str_pad($dayOfTheMonth, 2, "0", STR_PAD_LEFT); $reportdata["tablevalues"][] = array( fromMySQLDate("$year-$month-$dayOfTheMonth"), $amountin, $fees, $amountout, $dailybalance, ); } $reportdata["footertext"] = '<p align="center"><strong>Balance: ' . formatCurrency($overallbalance) . '</strong></p>'; $chartdata['cols'][] = array('label'=>'Days Range','type'=>'string'); $chartdata['cols'][] = array('label'=>'Amount In','type'=>'number'); $chartdata['cols'][] = array('label'=>'Fees','type'=>'number'); $chartdata['cols'][] = array('label'=>'Amount Out','type'=>'number'); $args['colors'] = '#80D044,#F9D88C,#CC0000'; $reportdata["headertext"] = $chart->drawChart('Area', $chartdata, $args, '450px');