diff --git a/TODO b/TODO index 2515386..e245951 100755 --- a/TODO +++ b/TODO @@ -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 diff --git a/inc/User.class.php b/inc/User.class.php index 4a94ecd..3a2f38d 100644 --- a/inc/User.class.php +++ b/inc/User.class.php @@ -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 { diff --git a/index.php b/index.php index 390540e..b7510a1 100644 --- a/index.php +++ b/index.php @@ -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; + } } diff --git a/tpl/css/style.css b/tpl/css/style.css index a3b922a..6212b21 100644 --- a/tpl/css/style.css +++ b/tpl/css/style.css @@ -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 { diff --git a/tpl/index.html b/tpl/index.html index 82d7b33..8fe48ad 100755 --- a/tpl/index.html +++ b/tpl/index.html @@ -27,27 +27,31 @@

Detailed list of bills for last month

- - - - - - - - - - - {loop="invoices"} + {if condition="count($invoices)>1"} +
DatePaid byUsers inAmountWhat ?EditDelete
- - - - - - - + + + + + + + - {/loop} -
{$value->getDate()}{$value->getBuyer()->getDisplayName()}{$value->getUsersIn()}{$value->getAmount()}{$value->getWhat()}EditDeleteDatePaid byUsers inAmountWhat ?EditDelete
+ {loop="invoices"} + + {$value->getDate()} + {$value->getBuyer()->getDisplayName()} + {$value->getUsersIn()} + {$value->getAmount()} + {$value->getWhat()} + Edit + Delete + + {/loop} + + {else} +

No bills added.

+ {/if}
{include="footer"}