<th>Summa</th>
			<th>Kommentar</th>
		</tr>
	</thead>
	<tbody>
		<? foreach(Delivery::selection(array('@order' => 'timestamp:desc')) as $delivery): ?>
			<tr>
				<td><a href="/view_delivery/<?php 
echo $delivery->id;
?>
"><?php 
echo $delivery->timestamp;
?>
</a></td>
				<td><?php 
echo $delivery->User;
?>
</td>
				<td class="numeric"><?php 
echo number(DeliveryContent::sum(array('cost', '*', 'count'), array('delivery_id' => $delivery->id)));
?>
 kr</td>
				<td class="pre"><?php 
echo $delivery->description;
?>
</td>
			</tr>
		<? endforeach ?>
	</tbody>
</table>
$db->autoCommit(false);
$products = ClientData::post('product_id');
$counts = ClientData::post('product_count');
$money_diff = 0;
$delivery = new Delivery();
$delivery->description = "Inventering";
$delivery->user = $_SESSION['login'];
$delivery->commit();
foreach ($products as $i => $product_id) {
    // Create purchase
    $product = Product::from_id($product_id);
    $diff = $counts[$i] - $product->count;
    $money_diff += $diff * $product->value;
    $product->count = $counts[$i];
    $product->commit();
    $contents = new DeliveryContent();
    $contents->cost = 0;
    $contents->delivery_id = $delivery->id;
    $contents->product_id = $product_id;
    $contents->count = $diff;
    var_dump($contents->count);
    $contents->commit();
}
if ($money_diff != 0) {
    $from_account = Account::from_code_name('stock_diff');
    $to_account = Account::from_code_name('stock');
    $transaction = new AccountTransaction();
    $transaction->description = "inventering: {$delivery->id}";
    $transaction->user = $_SESSION['login'];
    $from = new AccountTransactionContent();
    $from->amount = $money_diff;
</td>
	</tr>
	<tr>
		<th>Kategori</th>
		<td><a href="/category/<?php 
echo $product->category_id;
?>
"><?php 
echo $product->Category->name;
?>
</a></td>
	</tr>
	<tr>
		<th>Totalt levererat</th>
		<td><?php 
echo DeliveryContent::sum('count', array('product_id' => $product->id));
?>
</td>
	</tr>
	<tr>
		<th>Totalt sålt</th>
		<td><?php 
echo TransactionContent::sum('count', array('product_id' => $product->id));
?>
</td>
	</tr>
	<tr>
		<th>Totalt sålt för</th>
		<td><?php 
echo TransactionContent::sum('amount', array('product_id' => $product->id));
?>