Bug correction in invoice display

This commit is contained in:
Phyks 2013-09-08 16:12:30 +02:00
parent c79cfe100c
commit 533a1cfe9a
3 changed files with 28 additions and 2 deletions

View File

@ -79,3 +79,24 @@
return $return; 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 .= '<br/>'; } 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;
}

View File

@ -11,6 +11,10 @@
'template_error'=>array('fr'=>'Template non disponible.', 'en'=>'Template not available.') 'template_error'=>array('fr'=>'Template non disponible.', 'en'=>'Template not available.')
); );
$localized = array(
'guest'=>array('fr'=>'invité', 'en'=>'guest')
);
// Include necessary files // Include necessary files
if(!file_exists('data/config.php')) { header('location: install.php'); exit(); } if(!file_exists('data/config.php')) { header('location: install.php'); exit(); }
require_once('data/config.php'); require_once('data/config.php');
@ -444,6 +448,7 @@
break; break;
case 'delete_invoice': case 'delete_invoice':
// TODO : Check user has right to do it
if(!empty($_GET['id'])) { if(!empty($_GET['id'])) {
$invoice = new Invoice(); $invoice = new Invoice();
$invoice->setId($_GET['id']); $invoice->setId($_GET['id']);

View File

@ -27,7 +27,7 @@
<div id="detailed_summary"> <div id="detailed_summary">
<h2>Detailed list of bills for last month</h2> <h2>Detailed list of bills for last month</h2>
{if condition="count($invoices)>1"} {if condition="count($invoices)>=1"}
<table id="list_expenses"> <table id="list_expenses">
<tr> <tr>
<th>Date</th> <th>Date</th>
@ -42,7 +42,7 @@
<tr> <tr>
<td>{$value->getDate()}</td> <td>{$value->getDate()}</td>
<td>{$users[$value->getBuyer()]->getDisplayName()}</td> <td>{$users[$value->getBuyer()]->getDisplayName()}</td>
<td>{$value->getUsersIn()}</td> <td>{function="formatUsersIn($value->getUsersIn(), $users)"}</td>
<td>{$value->getAmount()}</td> <td>{$value->getAmount()}</td>
<td>{$value->getWhat()}</td> <td>{$value->getWhat()}</td>
<td><a href="index.php?do=edit_invoice&id={$value->getId()}">Edit</a></td> <td><a href="index.php?do=edit_invoice&id={$value->getId()}">Edit</a></td>