Calculated Column Not Working
Posted: 2021-03-25 15:52
Hello,
Will someone please help me. So, I have this page where users can print the order summary, and on the page, it has all the order items. But for some reason, the last column is not showing the right calculation. Please see the attached pic.
/* grant access to all users who have access to the orders table */
$sales_from = get_sql_from('sales');
if(!$sales_from) exit(error_message('Access denied!', false));
/* get po */
$sales_id = intval($_REQUEST['SalesID']);
if(!$sales_id) exit(error_message('Invalid Sales ID!', false));
/* retrieve orders info */
$sales_info = get_sql_fields('sales');
$res = sql("select {$sales_info} from {$sales_from} and SalesID={$sales_id}", $eo);
if(!($sale = db_fetch_assoc($res))) exit(error_message('Sales not found!', false));
//var_dump($sale);
/* retrieve salesdetails info */
$items = array();
$weight_total = 0;
$item_fields = get_sql_fields('salesdetails');
$item_from = get_sql_from('salesdetails');
$res = sql("select {$item_fields} from {$item_from} and salesdetails.SalesID={$sales_id}", $eo);
while($row = db_fetch_assoc($res)){
$row['Weight'] = str_replace('$', '', $row['NosUnits']) * $row['WU'] ;
$items[] = $row;
$jars_total += $row['Weight'];
}
<tbody>
<?php foreach($items as $i => $item){ ?>
<tr>
<td class="text-center"><?php echo ($i + 1); ?></td>
<td><?php echo $item['LotCode']; ?></td>
<td class="text-right"><?php echo $item['NosUnits']; ?></td>
<td class="text-right"><?php echo $item['WU']; ?></td>
<td class="text-right"><?php echo number_format($item['Weight'], 2); ?></td>
</tr>
<?php } ?>
</tbody>
Will someone please help me. So, I have this page where users can print the order summary, and on the page, it has all the order items. But for some reason, the last column is not showing the right calculation. Please see the attached pic.
/* grant access to all users who have access to the orders table */
$sales_from = get_sql_from('sales');
if(!$sales_from) exit(error_message('Access denied!', false));
/* get po */
$sales_id = intval($_REQUEST['SalesID']);
if(!$sales_id) exit(error_message('Invalid Sales ID!', false));
/* retrieve orders info */
$sales_info = get_sql_fields('sales');
$res = sql("select {$sales_info} from {$sales_from} and SalesID={$sales_id}", $eo);
if(!($sale = db_fetch_assoc($res))) exit(error_message('Sales not found!', false));
//var_dump($sale);
/* retrieve salesdetails info */
$items = array();
$weight_total = 0;
$item_fields = get_sql_fields('salesdetails');
$item_from = get_sql_from('salesdetails');
$res = sql("select {$item_fields} from {$item_from} and salesdetails.SalesID={$sales_id}", $eo);
while($row = db_fetch_assoc($res)){
$row['Weight'] = str_replace('$', '', $row['NosUnits']) * $row['WU'] ;
$items[] = $row;
$jars_total += $row['Weight'];
}
<tbody>
<?php foreach($items as $i => $item){ ?>
<tr>
<td class="text-center"><?php echo ($i + 1); ?></td>
<td><?php echo $item['LotCode']; ?></td>
<td class="text-right"><?php echo $item['NosUnits']; ?></td>
<td class="text-right"><?php echo $item['WU']; ?></td>
<td class="text-right"><?php echo number_format($item['Weight'], 2); ?></td>
</tr>
<?php } ?>
</tbody>