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 * i18n
* handle negative amounts
inc/Invoices.class.php : inc/Invoices.class.php :
======================== ========================
* Modify store() method to handle storage * 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) * Modify load() method to handle complex queries (such as WHERE date < DATE_1 AND date > DATE_2)
* Cache * Cache

View File

@ -100,10 +100,10 @@ class User extends Storage {
} }
// Check wether a user already exists or not // 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() { 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; return true;
} }
else { else {

View File

@ -365,15 +365,24 @@
break; break;
default: default:
$users_list = new User(); // Display cached page in priority
$users_list = $users_list->load(); 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 = new Invoice();
$invoices_list = $invoices_list->load(); $invoices_list = $invoices_list->load();
$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->draw('index'); // Cache the page (1 month to make it almost permanent and only regenerate it upon new invoice)
break; $tpl->cache('index', 108000, NULL);
$tpl->draw('index');
break;
}
} }

View File

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

View File

@ -27,27 +27,31 @@
<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>
<table id="list_expenses"> {if condition="count($invoices)>1"}
<tr> <table id="list_expenses">
<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"}
<tr> <tr>
<td>{$value->getDate()}</td> <th>Date</th>
<td>{$value->getBuyer()->getDisplayName()}</td> <th>Paid by</th>
<td>{$value->getUsersIn()}</td> <th>Users in</th>
<td>{$value->getAmount()}</td> <th>Amount</th>
<td>{$value->getWhat()}</td> <th>What ?</th>
<td><a href="index.php?do=edit_invoice&id={$value->getId()}">Edit</a></td> <th>Edit</th>
<td><a href="index.php?do=delete_invoice&id={$value->getId()}">Delete</a></td> <th>Delete</th>
</tr> </tr>
{/loop} {loop="invoices"}
</table> <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> </div>
{include="footer"} {include="footer"}