| Id | Name | Rate | Inventory | First Use | Last Use | ';
var query = new QSqlQuery();
query.prepare("SELECT id, name, (rate/:conversion1)::numeric(12,3), (stock/:conversion2)::numeric(12,3), (SELECT min(time)::date FROM use WHERE item = id) AS first_use, (SELECT max(time)::date FROM use WHERE item = id) AS last_use FROM coffee_history WHERE origin = :origin AND id IN (SELECT id FROM " + tableref + ") ORDER BY first_use DESC");
var conversion = 1;
if(unitBox.currentIndex == 0) {
conversion = 2.2;
}
query.bind(":conversion1", conversion);
query.bind(":conversion2", conversion);
query.bind(":origin", origin);
query.exec();
while(query.next()) {
details += "";
for(var i = 0; i < 6; i++) {
details += "" + query.value(i) + " | ";
}
details += " ";
}
query = query.invalidate();
details += "
|
";
element.appendOutside(details);
});
]]>