Bug correction in User::isUnique method + Start of caching system

This commit is contained in:
Phyks 2013-09-01 23:09:37 +02:00
parent 63f0d881a8
commit e4fd74e6ee
5 changed files with 49 additions and 42 deletions

2
TODO
View File

@ -1,10 +1,8 @@
* i18n
* handle negative amounts
inc/Invoices.class.php :
========================
* Modify store() method to handle storage
* Modify load() method to handle JOIN
* Modify load() method to handle complex queries (such as WHERE date < DATE_1 AND date > DATE_2)
* Cache

View File

@ -100,10 +100,10 @@ class User extends Storage {
}
// Check wether a user already exists or not
// (a user = aunique login and display_name)
// (a user = a unique login and display_name)
// =========================================
public function isUnique() {
if(count($this->load(array('login'=>$this->login))) == 0 && count($this->load(array('display_name'=>$this->display_name)))) {
if($this->load(array('login'=>$this->login)) === false && $this->load(array('display_name'=>$this->display_name)) === false) {
return true;
}
else {

View File

@ -365,15 +365,24 @@
break;
default:
$users_list = new User();
$users_list = $users_list->load();
// Display cached page in priority
if($cache = $tpl->cache('index', $expire_time = 600, $cache_id = NULL)) {
echo $cache;
}
else {
$users_list = new User();
$users_list = $users_list->load();
$invoices_list = new Invoice();
$invoices_list = $invoices_list->load();
$invoices_list = new Invoice();
$invoices_list = $invoices_list->load();
$tpl->assign('users', secureDisplay($users_list));
$tpl->assign('invoices', secureDisplay($invoices_list));
$tpl->assign('users', secureDisplay($users_list));
$tpl->assign('invoices', secureDisplay($invoices_list));
$tpl->draw('index');
break;
// Cache the page (1 month to make it almost permanent and only regenerate it upon new invoice)
$tpl->cache('index', 108000, NULL);
$tpl->draw('index');
break;
}
}

View File

@ -95,6 +95,10 @@ input[type=submit] {
padding: 0.1em;
}
#detailed_summary {
margin-top: 2.5em;
}
#connexion_form {
margin: auto;
width: 67%;
@ -122,16 +126,8 @@ textarea#what {
width: 75%;
}
#list_expenses tr:hover {
background-color: #00bd00;
}
#balance_table tr:not(:first-child):hover * {
background-color: #00bd00;
}
.highlight_td {
background-color: #00bd00;
#list_expenses tr:hover, #balance_table tr:not(:first-child):hover *, .highlight_td {
background-color: green;
}
#user_connected {

View File

@ -27,27 +27,31 @@
<div id="detailed_summary">
<h2>Detailed list of bills for last month</h2>
<table id="list_expenses">
<tr>
<th>Date</th>
<th>Paid by</th>
<th>Users in</th>
<th>Amount</th>
<th>What ?</th>
<th>Edit</th>
<th>Delete</th>
</tr>
{loop="invoices"}
{if condition="count($invoices)>1"}
<table id="list_expenses">
<tr>
<td>{$value->getDate()}</td>
<td>{$value->getBuyer()->getDisplayName()}</td>
<td>{$value->getUsersIn()}</td>
<td>{$value->getAmount()}</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=delete_invoice&id={$value->getId()}">Delete</a></td>
<th>Date</th>
<th>Paid by</th>
<th>Users in</th>
<th>Amount</th>
<th>What ?</th>
<th>Edit</th>
<th>Delete</th>
</tr>
{/loop}
</table>
{loop="invoices"}
<tr>
<td>{$value->getDate()}</td>
<td>{$value->getBuyer()->getDisplayName()}</td>
<td>{$value->getUsersIn()}</td>
<td>{$value->getAmount()}</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=delete_invoice&id={$value->getId()}">Delete</a></td>
</tr>
{/loop}
</table>
{else}
<p class="center">No bills added.</p>
{/if}
</div>
{include="footer"}