Index page almost done. TODO : balance table
This commit is contained in:
parent
4824b05219
commit
3696a6566a
4
TODO
4
TODO
@ -2,12 +2,10 @@
|
|||||||
* JSON output => do index view
|
* JSON output => do index view
|
||||||
* API
|
* API
|
||||||
* Reattribute all invoices / paybacks to unknown user when deleting a user ?
|
* Reattribute all invoices / paybacks to unknown user when deleting a user ?
|
||||||
* Check that all is ok when deleting an invoice
|
|
||||||
* Use PHP constant in tpl instead of variables
|
|
||||||
* User groups
|
* User groups
|
||||||
* cf TODO in files
|
* cf TODO in files
|
||||||
|
|
||||||
Manage paybacks :
|
Manage paybacks :
|
||||||
=================
|
=================
|
||||||
* TODO : Payback system (class should be ok)
|
* TODO : Index balance table
|
||||||
* TODO : Global payback
|
* TODO : Global payback
|
||||||
|
@ -85,6 +85,12 @@
|
|||||||
$this->users_in->set($users_in);
|
$this->users_in->set($users_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the amount to pay by person
|
||||||
|
// ===============================
|
||||||
|
public function getAmountPerPerson() {
|
||||||
|
return round($this->amount / count($this->users_in->get()), 2);
|
||||||
|
}
|
||||||
|
|
||||||
// Maps htmlspecialchars on the class before display
|
// Maps htmlspecialchars on the class before display
|
||||||
// =================================================
|
// =================================================
|
||||||
public function secureDisplay() {
|
public function secureDisplay() {
|
||||||
|
14
index.php
14
index.php
@ -569,9 +569,23 @@
|
|||||||
$paybacks[$invoice->getId()] = $paybacks[$invoice->getId()]->load(array('invoice_id'=>$invoice->getId()), false, 'from_user');
|
$paybacks[$invoice->getId()] = $paybacks[$invoice->getId()]->load(array('invoice_id'=>$invoice->getId()), false, 'from_user');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$balances = array();
|
||||||
|
foreach($users_list as $user1) {
|
||||||
|
foreach($users_list as $user2) {
|
||||||
|
if($user1->getId() == $user2->getId()) {
|
||||||
|
$balances[$user1->getId()][$user2->getId()] = 'X';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO : Balances between users
|
||||||
|
$balances[$user1->getId()][$user2->getId()] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$tpl->assign('users', secureDisplay($users_list));
|
$tpl->assign('users', secureDisplay($users_list));
|
||||||
$tpl->assign('invoices', secureDisplay($invoices_list));
|
$tpl->assign('invoices', secureDisplay($invoices_list));
|
||||||
$tpl->assign('paybacks', secureDisplay($paybacks));
|
$tpl->assign('paybacks', secureDisplay($paybacks));
|
||||||
|
$tpl->assign('balances', secureDisplay($balances));
|
||||||
|
|
||||||
// Cache the page (1 month to make it almost permanent and only regenerate it upon new invoice)
|
// Cache the page (1 month to make it almost permanent and only regenerate it upon new invoice)
|
||||||
$tpl->cache('index', 108000, $current_user->getLogin());
|
$tpl->cache('index', 108000, $current_user->getLogin());
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{$value->getDisplayName()}</th>
|
<th>{$value->getDisplayName()}</th>
|
||||||
{loop="users"}
|
{loop="users"}
|
||||||
<td><a href="">{$value->getDisplayName()}</a></td>
|
<td>{$balances[$value1->getId()][$value2->getId()]}</td>
|
||||||
{/loop}
|
{/loop}
|
||||||
</tr>
|
</tr>
|
||||||
{/loop}
|
{/loop}
|
||||||
@ -55,13 +55,12 @@
|
|||||||
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
||||||
<a href="?do=confirm_payback&from={$key2}&to={$value1->getBuyer()}&invoice_id={$value1->getId()}" title="Confirm payback">
|
<a href="?do=confirm_payback&from={$key2}&to={$value1->getBuyer()}&invoice_id={$value1->getId()}" title="Confirm payback">
|
||||||
{/if}
|
{/if}
|
||||||
Remains {$value1->getAmount()} {$currency}
|
Remains {$value1->getAmountPerPerson()} {$currency}
|
||||||
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
{* TODO : partial payback *}
|
{if condition="$paybacks[$value1->getId()][$key2]->getAmount() == $value1->getAmountPerPerson()"}
|
||||||
{if condition="$paybacks[$value1->getId()][$key2]->getAmount() == $value1->getAmount()"}
|
|
||||||
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
||||||
<a href="?do=delete_payback&from={$key2}&to={$value1->getBuyer()}&invoice_id={$value1->getId()}" title="Delete payback">
|
<a href="?do=delete_payback&from={$key2}&to={$value1->getBuyer()}&invoice_id={$value1->getId()}" title="Delete payback">
|
||||||
{/if}
|
{/if}
|
||||||
@ -73,7 +72,7 @@
|
|||||||
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
||||||
<a href="?do=confirm_payback&from={$key2}&to={$value1->getBuyer()}&invoice_id={$value1->getId()}&payback_id={$paybacks[$value1->getId()][$key2]->getId()}" title="Confirm payback">
|
<a href="?do=confirm_payback&from={$key2}&to={$value1->getBuyer()}&invoice_id={$value1->getId()}&payback_id={$paybacks[$value1->getId()][$key2]->getId()}" title="Confirm payback">
|
||||||
{/if}
|
{/if}
|
||||||
Remains {$value1->getAmount() - $paybacks[$value1->getId()][$key2]->getAmount()}{$currency}
|
Remains {$value1->getAmountPerPerson() - $paybacks[$value1->getId()][$key2]->getAmount()}{$currency}
|
||||||
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
{if condition="$current_user->getId() == $value1->getBuyer() || $current_user->getAdmin()"}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user