midnz
09-05-2010, 07:34 AM
Thank-you to anyone who reads this with a view to helping me. I'm stuck :confused:
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:
</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:
http://img5.imageshack.us/img5/5761/accountsadmincp.jpg
Table Result:
http://img709.imageshack.us/img709/902/accountstable.jpg
The old plugin (for 3.6.8) automatically calculated the totals of the Debit, Credit and Balance columns and looks like this:
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($totaltotal, 2);
$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)
<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($totaltotal, 2);
$totaldebits = 0;
if($vbulletin->options['vcaccounts_Row_1_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_1_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_1_Value'];
}
if($vbulletin->options['vcaccounts_Row_2_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_2_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_2_Value'];
}
if($vbulletin->options['vcaccounts_Row_3_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_3_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_3_Value'];
}
if($vbulletin->options['vcaccounts_Row_4_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_4_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_4_Value'];
}
if($vbulletin->options['vcaccounts_Row_5_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_5_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_5_Value'];
}
if($vbulletin->options['vcaccounts_Row_6_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_6_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_6_Value'];
}
if($vbulletin->options['vcaccounts_Row_7_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_7_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_7_Value'];
}
if($vbulletin->options['vcaccounts_Row_8_Value']<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:
$templater->register('totaldebits', $totaldebits);
$templater->register('totalcredits', $totalcredits);
$templater->register('totaltotal', $totaltotal);
The Totals Row of my table looks like this:
<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.
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:
</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:
http://img5.imageshack.us/img5/5761/accountsadmincp.jpg
Table Result:
http://img709.imageshack.us/img709/902/accountstable.jpg
The old plugin (for 3.6.8) automatically calculated the totals of the Debit, Credit and Balance columns and looks like this:
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($totaltotal, 2);
$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)
<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($totaltotal, 2);
$totaldebits = 0;
if($vbulletin->options['vcaccounts_Row_1_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_1_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_1_Value'];
}
if($vbulletin->options['vcaccounts_Row_2_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_2_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_2_Value'];
}
if($vbulletin->options['vcaccounts_Row_3_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_3_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_3_Value'];
}
if($vbulletin->options['vcaccounts_Row_4_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_4_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_4_Value'];
}
if($vbulletin->options['vcaccounts_Row_5_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_5_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_5_Value'];
}
if($vbulletin->options['vcaccounts_Row_6_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_6_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_6_Value'];
}
if($vbulletin->options['vcaccounts_Row_7_Value']<0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_7_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_7_Value'];
}
if($vbulletin->options['vcaccounts_Row_8_Value']<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:
$templater->register('totaldebits', $totaldebits);
$templater->register('totalcredits', $totalcredits);
$templater->register('totaltotal', $totaltotal);
The Totals Row of my table looks like this:
<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.