diff --git a/INSTALL b/INSTALL index ced7d13..2fe7364 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,11 @@ libsqlite3-dev libwxgtk2.8-dev g++ make +gettext +Optionnal : +poeditor +php5 ** Compilation of extra libraries ** cd lib/wxsqlite3-1.9.9 diff --git a/www/User.php b/www/User.php index b1fd6ba..56f9411 100644 --- a/www/User.php +++ b/www/User.php @@ -27,10 +27,22 @@ class User function GetCategory($id) { + if ($id == "") + { + $cat["id"] = ""; + $cat["forecolor"] = "black"; + $cat["backcolor"] = "#3DEB3D"; + $s = "background-color:" . $cat["backcolor"] . ";"; + $s .= "color:" . $cat["forecolor"] . ";"; + $cat["style"] = $s; + + return $cat; + } + foreach($this->categories as $i => $category) if ($category["id"] == "$id") return $category; - return ""; + return LoadCategory($this, $id); } function GetAccountName($id) diff --git a/www/database.php b/www/database.php index 28b79bb..77d5c7e 100644 --- a/www/database.php +++ b/www/database.php @@ -92,6 +92,12 @@ function LoadUser($name) $user->accounts = array(); + while ($row = $result->fetchArray()) + array_push($user->accounts, $row); + + // Shared accounts + $result = $db->query("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='$user->id') ORDER BY name ASC"); + while ($row = $result->fetchArray()) array_push($user->accounts, $row); @@ -117,6 +123,21 @@ function LoadUser($name) return $user; } +function LoadCategory(&$user, $id) +{ + $result = $db->query("SELECT * FROM category WHERE id='$id'"); + + if ($row = $result->fetchArray()) + { + ExtractStyle($row); + array_push($user->categories, $row); + + return $row; + } + + return ""; +} + function GetAccountAmount($id, $month, $year) { global $db; @@ -150,7 +171,20 @@ function LoadMonth($user, $month, $year) $req .= $user->preferences["operation_order"]; return $db->query($req); +} +function MetaPositiveAmount($id) +{ + global $db; + + $req = "SELECT SUM(amount) as amount FROM operation WHERE amount > 0 AND parent='$id'"; + + $result = $db->query($req); + + if ($row = $result->fetchArray()) + return $row["amount"]; + else + return 0.0; } function GetAllOperations($user, &$last_year, &$last_month) diff --git a/www/index.php b/www/index.php index ce59bf0..16f227f 100644 --- a/www/index.php +++ b/www/index.php @@ -54,7 +54,7 @@ if (!isset($_SESSION["user"])) { $users = GetUsers(); echo "