No self bills

This commit is contained in:
Phyks 2013-09-15 16:28:44 +02:00
parent 1a9acc5ece
commit da0a51f997
3 changed files with 52 additions and 45 deletions

1
TODO
View File

@ -1,7 +1,6 @@
* Don't cache the username
* JSON output => do index view
* API
* Reattribute all invoices / paybacks to unknown user when deleting a user ?
* cf TODO in files
* French template
* Favicon

View File

@ -9,7 +9,8 @@
'unable_write_config'=>array('fr'=>'Impossible d\'écrire le fichier data/config.php. Vérifiez les permissions.', 'en'=>'Unable to write data/config.php file. Check permissions.'),
'negative_amount'=>array('fr'=>'Montant négatif non autorisé.', 'en'=>'Negative amount not allowed.'),
'template_error'=>array('fr'=>'Template non disponible.', 'en'=>'Template not available.'),
'unauthorized'=>array('fr'=>'Vous n\'avez pas le droit de faire cette action.', 'en'=>'You are not authorized to do that.')
'unauthorized'=>array('fr'=>'Vous n\'avez pas le droit de faire cette action.', 'en'=>'You are not authorized to do that.'),
'no_users'=>array('fr'=>'Vous devez ajouter au moins un autre utilisateur.', 'en'=>'You must add at least one more user beside you.')
);
$localized = array(
@ -284,7 +285,7 @@
$users_in = $invoice->getUsersIn()->get();
unset($users_in[$_GET['user_id']]);
if(empty($users_in))
if(empty($users_in) || array_keys($users_in) == array($invoice->getBuyer()))
$invoice->delete();
else {
$invoice->setUsersIn($users_in);
@ -437,6 +438,10 @@
if($_POST['amount'] <= 0) {
$tpl->assign('error', $errors['negative_amount'][LANG]);
}
else {
if(array_keys($users_in) == array($current_user->getId())) {
$tpl->assign('error', $errors['no_users'][LANG]);
}
else {
$invoice = new Invoice();
@ -463,6 +468,7 @@
exit();
}
}
}
else {
$tpl->assign('error', $errors['token_error'][LANG]);
}
@ -524,7 +530,7 @@
break;
case 'confirm_payback':
if(!empty($_GET['from']) && !empty($_GET['to']) && !empty($_GET['invoice_id'])) {
if(!empty($_GET['from']) && !empty($_GET['to']) && !empty($_GET['invoice_id']) && $_GET['from'] != $_GET['to']) {
if($_GET['to'] == $current_user->getId() || $current_user->getAdmin()) {
$invoice = new Invoice();
$invoice = $invoice->load(array('id'=>(int) $_GET['invoice_id']), true);

View File

@ -60,6 +60,7 @@
{elseif condition="$value2 == 1"}
({$value2} guest)
{/if}
{if condition="$value1->getBuyer() != $key2"}
-
{if condition="$paybacks[$value1->getId()] === false || !in_array($key2, array_keys($paybacks[$value1->getId()]))"}
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
@ -88,6 +89,7 @@
{/if}
{/if}
{/if}
{/if}
<br/>
{/loop}
</td>