Excel-Export
[memberdb.git] / include / fees.php
index 787c158..c168a66 100644 (file)
@@ -77,7 +77,7 @@ function fees_get_list_for_member($member_id, $end_date) {
 
     static $cache = array();
 
-    $end_date = db_date2unixtime(db_unixtime2date($end_date)); // remove hours, minutes, seconds
+    $end_date = mktime(0, 0, 0, date('m', $end_date) + 1, 0, date('Y', $end_date)); // last day of given month
 
     if (isset($cache[$member_id][$end_date])) return $cache[$member_id][$end_date];
     if (isset($cache[$member_id])) {
@@ -401,7 +401,7 @@ function render_next_direct_debit() {/*{{{*/
 }
 
 function render_fees_for_member($member_id) {/*{{{*/
-    global $MEMBER_TYPES, $EARNING_TYPES;
+    global $MEMBER_TYPES, $EARNING_TYPES, $EXPENSE_TYPES;
 
     $member      = db_get_member_with_id($member_id);
     if (!isset($member)) redirect(link_to('fees'));
@@ -409,7 +409,7 @@ function render_fees_for_member($member_id) {/*{{{*/
     $membership_info = fees_get_list_for_member($member_id, time());
     $membership_info = array_reverse($membership_info, true);
 
-    $paid_fees = array_reverse(finance_list_paid_fees_for_member($member_id, time(), true));
+    $paid_fees = finance_list_paid_fees_for_member($member_id, time(), true);
 
     $sum_new_paid = finance_get_paid_fees_for_member($member_id);
     $sum_old_paid = finance_get_paid_fees_for_member($member_id, true);
@@ -507,7 +507,7 @@ function render_fees_for_member($member_id) {/*{{{*/
 <?php foreach ($paid_fees as $payment) : ?>
     <tr>
         <td><?=html_escape(format_date(db_date2unixtime($payment['date'])))?></td>
-        <td><?=$EARNING_TYPES[$payment['type']]?></td>
+        <td><?=($payment['value'] < 0) ? $EXPENSE_TYPES[$payment['type']]: $EARNING_TYPES[$payment['type']]?></td>
         <td style="text-align: right;"><?=format_money($payment['value'])?></td>
     </tr>
 <?php endforeach ?>