Delegate class file not working after update [SOLVED]
Posted: Fri Mar 26, 2010 10:42 pm
I had a working Table Delegate class in my Work_Orders table before I upgraded to 1.2.2. The Work_Orders.php calculates the totals for several fields. I ran an echo statement and nothing is shown for the variables below:
I upgraded from 1.1.4 so that I could utilise the lookup function. I ran all the sql statements in mysql commandline and they are ok. I do get the correct value for the $txab variable when i run the echo statement after it. Any suggestions?
TIA
Jason
- Code: Select all
<?php
class tables_Work_Orders{
function beforeSave(&$record){
$txab=$record->val('tax');
$notx = '0';
list($lab) = mysql_fetch_row(mysql_query("Select sum(labor_time) from Time_Entry t where t.workorder_id=$record->val('workorder_id')", df_db()));
list($trv) = mysql_fetch_row(mysql_query("Select sum(travel_time) from Time_Entry t where t.workorder_id=$record->val('workorder_id')", df_db()));
list($lrate) = mysql_fetch_row(mysql_query("Select c.labor_rate from Customers c left join Equipment e on c.customer_id=e.customer_id
left join Work_Orders w on e.control_number = w.control_number where w.workorder_id = $record->val('workorder_id')", df_db()));
list($trate) = mysql_fetch_row(mysql_query("Select c.travel_rate from Customers c left join Equipment e on c.customer_id=e.customer_id
left join Work_Orders w on e.control_number = w.control_number where w.workorder_id =$record->val('workorder_id')", df_db()));
list($ptot) = mysql_fetch_row(mysql_query("Select sum(p.total) from Part_Entry p where p.workorder_id =$record->val('workorder_id')", df_db()));
echo "$lab","$trv","$lrate","$trate","$ptot";exit;
list($txrt) = mysql_fetch_row(mysql_query("Select a.taxrate from account_taxes a left join Customers c on a.id = c.taxid left join Equipment e on
c.customer_id=e.customer_id left join Work_Orders w on e.control_number = w.control_number where w.workorder_id =$record->val('workorder_id')",
df_db()));
$tott =($trate*$trv);
$totl =($lrate*$lab);
$sub = ($ptot+$tott+totl);
$tax = ($sub*$txrt);
$wotl = ($sub+$tax);
if ($txab==1) {
$record->setValue('tax_total', $tax);
$record->setValue('total', $wotl);
}else{
$record->setValue('tax_total', $notx);
$record->setValue('total', $sub);
}
$record->setValue('total_labor', $totl);
$record->setValue('total_travel', $tott);
$record->setValue('total_parts', $ptot);
$record->setValue('subtotal', $sub);
}
}
?>
I upgraded from 1.1.4 so that I could utilise the lookup function. I ran all the sql statements in mysql commandline and they are ok. I do get the correct value for the $txab variable when i run the echo statement after it. Any suggestions?
TIA
Jason