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>
Calculated Column Not Working
Calculated Column Not Working
- Attachments
-
- ordersum.png (179.71 KiB) Viewed 1283 times
- landinialejandro
- AppGini Super Hero
- Posts: 126
- Joined: 2016-03-06 00:59
- Location: Argentina
- Contact:
Re: Calculated Column Not Working
hi! the problem is the number format.
Instead of multiplying 15000 * 25, you are multiplying 15 * 25. I think I would have to convert string values to numbers.
Use intval() or floatval()
or get de values without format: use * instead {$sales_info}
Instead of multiplying 15000 * 25, you are multiplying 15 * 25. I think I would have to convert string values to numbers.
Use intval() or floatval()
or get de values without format: use * instead {$sales_info}
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.
Some of my posts that may interest you:
Landini Admin Template: Template for Appgini like AdminLTE
Profile image plugin: add and changue image user profile
Field editor in table view: Configurable fast edit fields in TV
my personal page
AppGini 5.98 - Linux OpenSuse Tumblewweed.
Some of my posts that may interest you:
Landini Admin Template: Template for Appgini like AdminLTE
Profile image plugin: add and changue image user profile
Field editor in table view: Configurable fast edit fields in TV
my personal page
Re: Calculated Column Not Working
Thanks, landinialejandro! I will def try this out.