Beitragsprognose
authorPascal Hofmann <mail@pascalhofmann.de>
Mon, 25 Oct 2010 12:12:36 +0000 (14:12 +0200)
committerPascal Hofmann <mail@pascalhofmann.de>
Mon, 25 Oct 2010 12:12:36 +0000 (14:12 +0200)
include/fees.php
include/finances.php
index.php

index 7551a91..58011ce 100644 (file)
@@ -231,6 +231,7 @@ function action_fees() {/*{{{*/
     render_fees_by_member();
     render_accrued_fees_by_month();
     render_next_direct_debit();
+    render_future_fees();
 
 }/*}}}*/
 
@@ -270,6 +271,53 @@ function render_fees_by_member() {/*{{{*/
 <?php
 }/*}}}*/
 
+function render_future_fees() {/*{{{*/
+    $total_paid = finance_get_total_paid_fees();
+    $this_year = date('Y');
+    $this_month = date('m');
+    $fees = fees_sum_by_month(mktime(0, 0, 0, date('m') + 6,   date('d'),   date('Y')+1));
+    $total = 0;
+    foreach ($fees as $year => $months) {
+        foreach ($months as $month => $fee) {
+            $total = bcadd($total, $fee);
+            $fees[$year][$month] = array('total' => $total, 'fee' => $fee);
+        }
+    }
+    $fees = array_reverse($fees, true);
+?>
+<h2>Beitragsprognose nach Monat</h2>
+<table>
+    <tr>
+        <th>Monat</th>
+        <th style="text-align: right;">Mitgliedsbeitr&auml;ge</th>
+        <th style="text-align: right;">kummuliert</th>
+        <th style="text-align: right;">eingenommen</th>
+        <th style="text-align: right;"><strong>offen</strong></th>
+    </tr>
+<?php foreach ($fees as $year => $months) : ?>
+    <?php $months = array_reverse($months, true); ?>
+    <?php foreach ($months as $month => $data) : ?>
+    <tr<?php if ($year == $this_year && $month == $this_month) : ?> class="current"<?php endif?>>
+        <td><a href="<?=html_escape(link_to('fees', array('year' => $year, 'month'=> $month)))?>"><?=html_escape(format_month($year, $month))?></a></td>
+        <td style="text-align: right;"><?=html_escape(format_money($data['fee']))?></td>
+        <td style="text-align: right;"><?=html_escape(format_money($data['total']))?></td>
+        <td style="text-align: right;">
+        <?php if ($year == $this_year && $month == $this_month) : ?>
+            <?=html_escape(format_money($total_paid))?>
+        <?php endif ?>
+        </td>
+        <td style="text-align: right;">
+        <?php if ($year > $this_year || ($year >= $this_year && $month >= $this_month)) : ?>
+            <?=html_escape(format_money(bcsub($data['total'], $total_paid)))?>
+        <?php endif ?>
+        </td>
+    </tr>
+    <?php endforeach ?>
+<?php endforeach ?>
+</table>
+<?php
+}/*}}}*/
+
 function render_accrued_fees_by_month() {/*{{{*/
     $fees = fees_sum_by_month(time());
     $fees = array_reverse($fees, true);
index 179f206..57ac176 100644 (file)
@@ -1,6 +1,17 @@
 <?php
 
 
+function finance_get_total_paid_fees() {
+    $row = db_select_single(sprintf('SELECT SUM(value) as paid_fees FROM %1$s WHERE type IN(\'old_fee\', \'fee\') AND status=\'paid\'',
+        DB_TABLE_EARNINGS
+    ));
+
+    $paid_fees = $row['paid_fees'];
+
+    return $paid_fees;
+}
+
+
 function finance_get_paid_fees_for_member($member_id, $old_fees = false) {
     // $old_fees: Beiträge die nicht durch Lastschrift eingezogen werden.
     //            Falls zu viel bezahlt, müssen diese auf die per Lastschrift
@@ -35,7 +46,7 @@ function action_finances() {/*{{{*/
 <?php
     action_create_expense();
     action_create_earning();
-       echo '<br style="clear: left;"/>';
+    echo '<br style="clear: left;"/>';
     render_open_payments();
     render_finished_payments();
 }/*}}}*/
index 0cdb1ac..3f191f4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -88,6 +88,7 @@ ob_end_clean();
             tr.earning:hover { background-color: #dfd; }
             tr.expense:hover { background-color: #fdd; }
             tr.total { background-color: #eee; font-weight: bold; }
+            tr.current { background-color: #eee; font-weight: bold; }
             th { text-align: left; background-color: #eee; font-weight: normal; border-bottom: 1px solid #ccc;  }
             h1, h2, h3, legend { font-family: Georgia, Sans-Serif, Verdana; font-weight: normal; color: #333;}
             #header h1 { font-size: 4em; color: #fff; }
@@ -111,9 +112,9 @@ ob_end_clean();
             .modal_window { position:absolute; display:none; background-color: #fff; padding: 1em; }
             #mask { position:absolute; top:0px; left:0px; height:100%; width:100%; display:none; background-color: black; }
 
-                       .pagination { text-align: center; margin: 10px 0; font-weight: bold; }
-                       .pagination .prev { float: left; }
-                       .pagination .next { float: right; }
+            .pagination { text-align: center; margin: 10px 0; font-weight: bold; }
+            .pagination .prev { float: left; }
+            .pagination .next { float: right; }
 
         </style>
         <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>