View Single Post
  #144  
Old 11-14-2011, 11:03 PM
bitwise2000 bitwise2000 is offline
 
Join Date: Apr 2008
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's you go. Crude, and should be cleaned up, but it works for my purposes.

I sure wish Calorie would update this mod. It's one of very few things holding me back from vB4

Here's what the output looks like:Attachment 134403


Here's the script: (I put a link to this in the misc section of the UserCP sidebar.)
Code:
<?php


// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'ptpnt_stat');
define('CSRF_PROTECTION', true);

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('user');

// pre-cache templates used by all actions
$globaltemplates = array('USERCP_SHELL','usercp_nav_folderbit');

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ######################## START MAIN SCRIPT ############################
if ($vbulletin->userinfo['userid'] == 0)
{
	print_no_permission();
}

$userid = intval($vbulletin->userinfo['userid']);
$threadstatus = "";

$result=$db->query_read("SELECT f.title AS forum, sum(p.totalthreads) AS 'threads',
sum(p.totalpaid) AS cost, sum(p.livethreads) AS live FROM ptpnt_buythread p left join forum f
on p.forumid=f.forumid where p.userid=" . $userid . " GROUP BY f.forumid");

If (mysql_num_rows($result)){

   	while( $buy = $db->fetch_array( $result ) ) {
		$threadstatus .= "<tr><td>$buy[forum]</td><td>$buy[threads]</td><td>$buy[cost]</td><td>$buy[live]</td></tr></tr>";
}
	$result=$db->query_read("SELECT f.title AS forum, p.totalthreads AS 'threads',
	p.totalpaid AS cost, From_Unixtime(p.dateline, '%b %d %Y %r') AS purchased
	FROM ptpnt_buythread p left join forum f ON p.forumid=f.forumid
	WHERE p.userid=" . $userid . " ORDER BY p.dateline desc");

	$history = "";
		while( $buy = $db->fetch_array( $result ) ) {
		$history .= "<tr><td>$buy[forum]</td><td>$buy[threads]</td><td>$buy[cost]</td><td>$buy[purchased]</td></tr></tr>";
}
}

eval('$ptpnt_stat = "' . fetch_template('ptpnt_stat') . '";');

// start the navbar
$navbits = array('usercp.php' . $vbulletin->session->vars['sessionurl_q'] => $vbphrase['user_control_panel']);
$navbits['ptpnt_stat.php' . $vbulletin->session->vars['sessionurl_q']] = 'Purchased Thread Status';
$navbits[''] = 'Purchased Thread Status';

// build the cp nav
require_once(DIR . '/includes/functions_user.php');
construct_usercp_nav();

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
//	eval('$HTML = "' . fetch_template($ptpnt_stat) . '";');
$HTML = $ptpnt_stat;
eval('print_output("' . fetch_template('USERCP_SHELL') . '");');

?>
Here's the template:

Code:
<div align="center">
<if condition="$history">
<h2>Thread Credit Status</h2>
<table class='ptpnt'>
<tr>
<th>Forum</th>
<th>Total Credits</th>
<th>Total Cost</th>
<th>Balance</th>
</tr>
$threadstatus
</table>

<h3>Thread Credit Purchase History</h3>

<table class='ptpnt'>
<tr>
<th>Forum</th>
<th>Credits Purchased</th>
<th>Total Cost</th>
<th>Purchase Date</th>
</tr>
$history
</table>

<else />

<h3>You have not purchased any threads.</h3>

</if>
</div>

Here's the query I execute directly when I need to know monthly totals:
Code:
SELECT DISTINCT FROM_UNIXTIME(dateline,"%M, %Y") 
AS month, sum(totalpaid) as TotalPaid
FROM ptpnt_buythread
GROUP BY month
ORDER BY dateline
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01144 seconds
  • Memory Usage 1,784KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete