List of bills working on index page

This commit is contained in:
Phyks 2013-09-15 15:28:27 +02:00
parent 4ff1ce890c
commit ccb89358bf
5 changed files with 41 additions and 17 deletions

7
TODO
View File

@ -2,11 +2,14 @@
* 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 ?
* User groups
* cf TODO in files * cf TODO in files
* French template * French template
* Favicon * Favicon
* Dépenses du dernier mois
Improvements :
==============
* User groups
* Search invoice
Manage paybacks : Manage paybacks :
================= =================

View File

@ -124,18 +124,22 @@ class Storage {
$value = array($value); $value = array($value);
} }
foreach($value as $value_array) { foreach($value as $key=>$value_array) {
if($value_array == 'AND' || $value_array == 'OR') { if($value_array == 'AND' || $value_array == 'OR') {
$query .= ' '.$value_array.' '; $query .= ' '.$value_array.' ';
continue; continue;
} }
if(substr($value_array, 0, 1) == "<") if(substr($value_array, 0, 2) == "<=")
$query .= $field.'<:'.$field; $query .= $field.'<=:'.$field.$key;
elseif(substr($value_array, 0, 1) == "<")
$query .= $field.'<:'.$field.$key;
elseif(substr($value_array, 0, 2) == ">=")
$query .= $field.'>=:'.$field.$key;
elseif(substr($value_array, 0, 1) == ">") elseif(substr($value_array, 0, 1) == ">")
$query .= $field.'>:'.$field; $query .= $field.'>:'.$field.$key;
else else
$query .= $field.'=:'.$field; $query .= $field.'=:'.$field.$key;
} }
} }
} }
@ -150,14 +154,16 @@ class Storage {
if($fields[$field] == 'date') if($fields[$field] == 'date')
$value = $value->format('Y-m-d H:i:s'); $value = $value->format('Y-m-d H:i:s');
foreach($value as $value_array) { foreach($value as $key=>$value_array) {
if($value_array == 'AND' || $value_array == 'OR') if($value_array == 'AND' || $value_array == 'OR')
continue; continue;
if(substr($value_array, 0, 1) == ">" || substr($value_array, 0, 1) == "<") if(substr($value_array, 0, 2) == ">=" || substr($value_array, 0, 2) == "<=")
$query->bindValue(':'.$field, substr($value_array, 0, 1)); $value_array = substr($value_array, 2);
else elseif(substr($value_array, 0, 1) == ">" || substr($value_array, 0, 1) == "<")
$query->bindValue(':'.$field, $value_array); $value_array = substr($value_array, 1);
$query->bindValue(':'.$field.$key, $value_array);
} }
} }
} }

View File

@ -606,8 +606,11 @@
default: default:
if(empty($_GET['all']))
$_GET['all'] = 0;
// Display cached page in priority // Display cached page in priority
if($cache = $tpl->cache('index', $expire_time = 600, $cache_id = $current_user->getLogin())) { if($cache = $tpl->cache('index', $expire_time = 600, $cache_id = $current_user->getLogin().$_GET['all'])) {
echo $cache; echo $cache;
} }
else { else {
@ -615,7 +618,14 @@
$users_list = $users_list->load(); $users_list = $users_list->load();
$invoices_list = new Invoice(); $invoices_list = new Invoice();
$invoices_list = $invoices_list->load(); if(empty($_GET['all'])) {
$invoices_list = $invoices_list->load(array('date'=>array('>='.date('Y-m').'-01 00:00:00', 'AND', '<='.date('Y-m').'-31 23:59:59')));
$tpl->assign('all', 0);
}
else {
$invoices_list = $invoices_list->load();
$tpl->assign('all', 1);
}
if($invoices_list === false) $invoices_list = array(); if($invoices_list === false) $invoices_list = array();
@ -678,7 +688,7 @@
$tpl->assign('balances', secureDisplay($balances)); $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().$_GET['all']);
$tpl->draw('index'); $tpl->draw('index');
break; break;

View File

@ -4,7 +4,6 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>{$instance_title}</title> <title>{$instance_title}</title>
<link rel="stylesheet" media="screen" type="text/css" href="css/style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="css/style.css" />
<link rel="icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width"/> <meta name="viewport" content="width=device-width"/>
</head> </head>
<body> <body>

View File

@ -29,7 +29,13 @@
</table> </table>
</div> </div>
<div id="detailed_summary"> <div id="detailed_summary">
<h2>Detailed list of bills for last month</h2> <h2>Detailed list of bills{if condition="$all == 0"} for last month{/if}</h2>
{if condition="$all == 0"}
<p class="center"><a href="?all=1">Display all bills</a></p>
{else}
<p class="center"><a href="?all=0">Only display bills for last month</a></p>
{/if}
{if condition="$invoices !== false && count($invoices)>=1"} {if condition="$invoices !== false && count($invoices)>=1"}
<table id="list_expenses"> <table id="list_expenses">