Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2010, 07:34 AM
midnz's Avatar
midnz midnz is offline
 
Join Date: Jul 2010
Location: New Zealand
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Plugin Help Pretty-Please

Thank-you to anyone who reads this with a view to helping me. I'm stuck

I'm trying to get a home-made addon that I used on my old 3.6.8 board to work on my 4.0.6 board. Everything works except one plugin that calculates the values of table rows to show total debits ($totaldebits), total credits ($totalcredits) and overall total ($totaltotal).

Values are entered in admincp fields and display on a table. Negative values entered in the admincp fields display within the Debit column & Balance column whereas positive values display within the Credit column & Balance column. I use the following to achieve that:
Sample of table ROW code:
PHP Code:
  </td>
    <
td class="alt1"><vb:if condition="$vboptions[vcaccounts_Row_1_Value]<0">{vb:raw vboptions.vcaccounts_Row_1_Value}<vb:else /> </vb:if></td>
    <
td class="alt1"><vb:if condition="$vboptions[vcaccounts_Row_1_Value]>0">{vb:raw vboptions.vcaccounts_Row_1_Value}<vb:else /> </vb:if></td>
    <
td class="alt1">{vb:raw vboptions.vcaccounts_Row_1_Value}</td>
  </
tr
Admincp Fields:


Table Result:


The old plugin (for 3.6.8) automatically calculated the totals of the Debit, Credit and Balance columns and looks like this:
PHP Code:
if (THIS_SCRIPT=='Accounts') {
$totaltotal $vbulletin->options['don_field1']+$vbulletin->options['don_field2']+$vbulletin->options['don_field3']+$vbulletin->options['don_field4']+$vbulletin->options['don_field5']+$vbulletin->options['don_field6']+$vbulletin->options['don_field7']+$vbulletin->options['don_field8']+$vbulletin->options['don_field9']+$vbulletin->options['don_field10'];
$totaltotal round($totaltotal2);
$totaldebits 0;
if(
$vbulletin->options['don_field1']<0) {
$totaldebits += $vbulletin->options['don_field1']; } else {
$totalcredits += $vbulletin->options['don_field1'];
}
if(
$vbulletin->options['don_field2']<0) {
$totaldebits += $vbulletin->options['don_field2']; } else {
$totalcredits += $vbulletin->options['don_field2'];
}
if(
$vbulletin->options['don_field3']<0) {
$totaldebits += $vbulletin->options['don_field3']; } else {
$totalcredits += $vbulletin->options['don_field3'];
}
if(
$vbulletin->options['don_field4']<0) {
$totaldebits += $vbulletin->options['don_field4']; } else {
$totalcredits += $vbulletin->options['don_field4'];
}
if(
$vbulletin->options['don_field5']<0) {
$totaldebits += $vbulletin->options['don_field5']; } else {
$totalcredits += $vbulletin->options['don_field5'];
}
if(
$vbulletin->options['don_field6']<0) {
$totaldebits += $vbulletin->options['don_field6']; } else {
$totalcredits += $vbulletin->options['don_field6'];
}
if(
$vbulletin->options['don_field7']<0) {
$totaldebits += $vbulletin->options['don_field7']; } else {
$totalcredits += $vbulletin->options['don_field7'];
}
if(
$vbulletin->options['don_field8']<0) {
$totaldebits += $vbulletin->options['don_field8']; } else {
$totalcredits += $vbulletin->options['don_field8'];
}
if(
$vbulletin->options['don_field9']<0) {
$totaldebits += $vbulletin->options['don_field9']; } else {
$totalcredits += $vbulletin->options['don_field9'];
}
if(
$vbulletin->options['don_field10']<0) {
$totaldebits += $vbulletin->options['don_field10']; } else {
$totalcredits += $vbulletin->options['don_field10'];
} } 
The new plugin for 4.0.6 currently looks like this and doesn't seem to work: (currently=many edits/trials)
PHP Code:
       <plugin active="1" product="vbulletin" executionorder="40">
        <
title><![CDATA[VC_Accounts Totals]]></title>
        <
hookname>misc_start</hookname>
        <
phpcode>if (THIS_SCRIPT=='vcaccounts') {
$totaltotal $vbulletin->options['vcaccounts_Row_1_Value']+$vbulletin->options['vcaccounts_Row_2_Value']+$vbulletin->options['vcaccounts_Row_3_Value']+$vbulletin->options['vcaccounts_Row_4_Value']+$vbulletin->options['vcaccounts_Row_5_Value']+$vbulletin->options['vcaccounts_Row_6_Value']+$vbulletin->options['vcaccounts_Row_7_Value']+$vbulletin->options['vcaccounts_Row_8_Value'];
$totaltotal round($totaltotal2);
$totaldebits 0;
if(
$vbulletin->options['vcaccounts_Row_1_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_1_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_1_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_2_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_2_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_2_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_3_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_3_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_3_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_4_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_4_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_4_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_5_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_5_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_5_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_6_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_6_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_6_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_7_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_7_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_7_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_8_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_8_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_8_Value'];
} }
        </
phpcode>
    </
plugin
I've registered what I think should be registered:
Code:
    $templater->register('totaldebits', $totaldebits);
    $templater->register('totalcredits', $totalcredits);
    $templater->register('totaltotal', $totaltotal);
The Totals Row of my table looks like this:
PHP Code:
  <tr>
    <
th class="alt3" style="width:25%">{vb:rawphrase vcaccounts_table_totals}</th>
    <
th class="alt3" style="width:15%">{vb:var vboptions.vcaccounts_currency_symbol}{vb:raw totaldebits}</th>
    <
th class="alt3" style="width:15%">{vb:var vboptions.vcaccounts_currency_symbol}{vb:raw totalcredits}</th>
    <
th class="alt3" style="width:15%">{vb:var vboptions.vcaccounts_currency_symbol}{vb:raw totaltotal}</th>
  </
tr
Note: It's all in an .xml document. I don't know if that matters but thought I'd mention it just in case. It all installs okay except for that plugin refusing to work for me.

I've tried using different Hook Locations but with no success. I'm guessing there is something wrong with my 4.0.6 plugin and was hoping someone might be able to spot something obvious and push me in the right direction.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:28 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07346 seconds
  • Memory Usage 2,311KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete