aboutsummaryrefslogtreecommitdiffstats
path: root/report.php
blob: 06f7316077515b2460430c4c83c9655c6c0997d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Bitcoin Payment Report</title>
    <script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
    <style>
      body, input { font-family: 'Arial'; font-size: 20px; }
      body { width: 100% }
      #total { font-size: 32px; }
      table { width: 100%; }
      td, th { min-width: 200px; text-align: left; }
    </style>
  </head>
  <body>
    <div id="container">
      Date: <input id="date" name="date" type="text" />
      <table>
        <tr>
          <th>Date</th>
          <th>Address</th>
          <th>Exchange Rate</th>
          <th>BTC</th>
          <th>CAD</th>
        </tr>
<?
$row = 1;
if (($handle = fopen("transactions.csv", "r")) !== FALSE) {
  $total_amount = 0;
  $total_value = 0;
  while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    $row++;
    $value = $data[2] * $data[3];
    $total_amount += $data[2];
    $total_value += $value;
?>
        <tr>
          <td><? echo $data[1] . "<br />\n"; ?></td>
          <td><? echo $data[0] . "<br />\n"; ?></td>
          <td><? echo $data[3] . "<br />\n"; ?></td>
          <td><? echo $data[2] . "<br />\n"; ?></td>
          <td>$<? echo $value . "<br />\n"; ?></td>
        </tr>
<? }} ?>
      </table>
      <br />
      <b>
        Total BTC: <? echo $total_amount . "<br />\n"; ?>
        Total CAD: <? echo $total_value . "<br />\n"; ?>
      </b>
    </div>
  </body>
</html>