JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Acorn 3
Project Updates / Testing
Discussion
Acorn 3
Users
Stores
Products
Customers
Transactions
Reporting
Settings
Acorn 3
Data Import/ Migration
More
Transactions
Diamond Calculations
public static function diamondCalc($size, $colour, $clarity, $count) {
global $db;
$pricing = array('poor'=>'price_1',
'good'=>'price_2',
'excellent'=>'price_3');
$sql = "SELECT *
FROM gold_diamond
WHERE size_min <= ?
AND size_max >= ?";
$params = array("dd",$size,$size);
$res = $db->cleanQueryArr($sql,$params);
if($db->getLastnumrows() > 0) {
$price = 0.00;
foreach($res as $row) {
if($row['price_type'] == 'colour') {
$price = $price + $row[$pricing[$colour]];
} elseif($row['price_type'] == 'clarity') {
$price = $price + $row[$pricing[$clarity]];
}
}
$price = number_format($price * $count, 2, '.', '');
return $price;
} else {
return 0.00;
}
}
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.