Changed month selection behaviour.

This commit is contained in:
Alexis Lahouze
2013-01-08 18:50:47 +01:00
parent 7d54015970
commit 5ccddb0511
3 changed files with 33 additions and 43 deletions

View File

@ -129,21 +129,17 @@ class EntryAPI extends RestAPI {
protected function get_months() {
$year=$this->_request['year'];
$account=$this->_request['account'];
$connection=$this->get_db_connection();
$statement=$connection->prepare("select distinct extract(month from value_date) as month from entry where value_date between date (:year || '-01-01') and date(:year || '-01-01') + interval '1 year' - interval '1 day' order by month desc");
$statement->bindParam("year", $year);
$statement=$connection->prepare("select distinct extract(year from value_date) as year, extract(month from value_date) as month from entry where account_id = :account order by year, month");
$statement->bindParam("account", $account);
$return=$statement->execute();
if($return) {
$result=[];
foreach($statement->fetchAll(PDO::FETCH_NUM) as $value) {
array_push($result, $value[0]);
}
$this->response($result);
$this->response($statement->fetchAll(PDO::FETCH_ASSOC));
} else {
$this->response($statement->errorInfo()[2], 500);
}