<td><?php 
echo $transaction->amount;
?>
 kr</td>
			</tr>
			<tr>
				<td>Mottaget</td>
				<td><?php 
echo ClientData::request("last_recieved");
?>
 kr</td>
			</tr>
			<tr>
				<td>Växel</td>
				<td><?php 
echo ClientData::request("last_recieved") - $transaction->amount;
?>
 kr</td>
			</tr>
		</table>
		<table>
			<? foreach($transaction->TransactionContent(array('@limit' => 5)) as $content): ?>
				<tr>
					<td><?php 
echo $content->Product;
?>
</td>
					<td><?php 
echo $content->count;
?>
 st</td>
<?php

$post = ClientData::session('loggin_form');
?>
<h1>Logga in</h1>
<form action="/scripts/authenticate.php" method="post">
	<table>
		<tr>
			<th>Användarnamn<input type="hidden" name="kickback" value="<?php 
echo $post ? $post['kickback'] : ClientData::request('kickback');
?>
" /></th>
			<td><input type="text" name="username" id="initial_focus" <?php 
echo $post ? "value=\"{$post['username']}\"" : '';
?>
 /></td>
		</tr>
		<tr>
			<th>Lösenord</th>
			<td><input type="password" name="password" /></td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit" value="Logga in" /></td>
		</tr>
	</table>
</form>
<?php

if (empty($_SESSION['login'])) {
    kick('login?kickback=' . htmlspecialchars(kickback_url()));
}
$last_page = ceil(Transaction::count() / 10) - 1;
$curr_page = ClientData::request('page');
?>
<h1>Transaktionslogg</h1>
<div>
<? if($curr_page > 0): ?>
	<a href="transaction_log?page=0">&lt;&lt;&lt;</a>
	<a href="transaction_log?page=<?php 
echo $curr_page - 1;
?>
">föregående</a>
<? else: ?>
	&lt;&lt;&lt;
	föregående
<? endif ?>
<? if($curr_page < $last_page): ?>
	<a href="transaction_log?page=<?php 
echo $curr_page + 1;
?>
">nästa</a>
	<a href="transaction_log?page=<?php 
echo $last_page;
?>
">&gt;&gt;&gt;</a>
<? else: ?>
	nästa
<?php

require "../../includes.php";
$result = array(&$count, &$date, &$product_id);
$stmt = $db->prepare_full("\n\tSELECT\n\t\tSUM(`transaction_contents`.`count`),\n\t\tDATE(`transactions`.`timestamp`) as d,\n\t\tproduct_id\n\tFROM\n\t\t`transaction_contents` JOIN\n\t\t`transactions` ON (`transaction_contents`.`transaction_id` = `transactions`.`transaction_id`)\n\tWHERE\n\t\t`transactions`.`timestamp` > ? AND\n\t\t`transaction_contents`.`product_id` in (?)\n\tGROUP BY\n\t\tDATE(`transactions`.`timestamp`), product_id\n\tORDER BY\n\t\tproduct_id,\n\t\td", $result, 'si', date('Y') - 1 . date('-m-d'), ClientData::request('id'));
$image = new Graph();
$image->slide = 7;
$image->period = 365;
$image->height = 200;
$image->width = 730;
$image->vertical_lable = 5;
$start = gregoriantojd(date('m'), date('d'), date('Y') - 1);
$old_product_id = null;
while ($stmt->fetch()) {
    if ($old_product_id != $product_id) {
        $product = Product::from_id($product_id);
    }
    $s_date = explode('-', $date);
    $image->add($count, gregoriantojd($s_date[1], $s_date[2], $s_date[0]) - $start, $product->name);
}
$image->draw();