From 533a1cfe9a83d6dc9b1cc8e4213d9570edad8972 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 8 Sep 2013 16:12:30 +0200 Subject: [PATCH] Bug correction in invoice display --- inc/functions.php | 21 +++++++++++++++++++++ index.php | 5 +++++ tpl/default_en/index.html | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index a464681..b7ca44b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -79,3 +79,24 @@ return $return; } + + function formatUsersIn($users_in, $all_users) { + // TODO : Move this function to somewhere else ? + $return = ''; + $users_in = $users_in->get(); + + $i = false; + foreach($users_in as $user_in=>$guests) { + if($i) { $return .= '
'; } else { $i = true; } + + $return .= $all_users[$user_in]->getDisplayName(); + if($guests != 0) { + if($guest > 1) + $return .= ' ('.$guests.' '.$localized['guest'].'s)'; + else + $return .= ' ('.$guests.' '.$localized['guest'].')'; + } + } + + return $return; + } diff --git a/index.php b/index.php index 0aaceb6..e3759f6 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,10 @@ 'template_error'=>array('fr'=>'Template non disponible.', 'en'=>'Template not available.') ); + $localized = array( + 'guest'=>array('fr'=>'invité', 'en'=>'guest') + ); + // Include necessary files if(!file_exists('data/config.php')) { header('location: install.php'); exit(); } require_once('data/config.php'); @@ -444,6 +448,7 @@ break; case 'delete_invoice': + // TODO : Check user has right to do it if(!empty($_GET['id'])) { $invoice = new Invoice(); $invoice->setId($_GET['id']); diff --git a/tpl/default_en/index.html b/tpl/default_en/index.html index bd8f77a..f5b45cb 100755 --- a/tpl/default_en/index.html +++ b/tpl/default_en/index.html @@ -27,7 +27,7 @@

Detailed list of bills for last month

- {if condition="count($invoices)>1"} + {if condition="count($invoices)>=1"} @@ -42,7 +42,7 @@ - +
Date
{$value->getDate()} {$users[$value->getBuyer()]->getDisplayName()}{$value->getUsersIn()}{function="formatUsersIn($value->getUsersIn(), $users)"} {$value->getAmount()} {$value->getWhat()} Edit