From ed8225407c0cd8f0602b817fa5e7b090e19f33cb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 Oct 2010 11:12:33 +0200 Subject: [PATCH 1/3] * Update web view with shared accounts * Update TODO --- INSTALL | 4 ++++ www/User.php | 2 +- www/database.php | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) 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..aee11de 100644 --- a/www/User.php +++ b/www/User.php @@ -30,7 +30,7 @@ class User 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..7b94323 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,6 @@ function LoadMonth($user, $month, $year) $req .= $user->preferences["operation_order"]; return $db->query($req); - } function GetAllOperations($user, &$last_year, &$last_month) From dc6ec437fa960cdf036bd68e109bddeece68aa66 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 Oct 2010 15:52:59 +0200 Subject: [PATCH 2/3] Fix bug with disconnect that never disappear on web view --- www/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/index.php b/www/index.php index ce59bf0..73781a4 100644 --- a/www/index.php +++ b/www/index.php @@ -54,7 +54,7 @@ if (!isset($_SESSION["user"])) { $users = GetUsers(); echo "

KissCount



\n"; - echo "
\n"; + echo "\n"; echo "Login : $month) From 13db50e271d751f18183cf019f938ffeeb0761cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 27 Oct 2010 21:00:40 +0200 Subject: [PATCH 3/3] Add Expand Group option to web view --- www/User.php | 12 ++++++++++++ www/database.php | 14 ++++++++++++++ www/index.php | 44 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/www/User.php b/www/User.php index aee11de..56f9411 100644 --- a/www/User.php +++ b/www/User.php @@ -27,6 +27,18 @@ 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; diff --git a/www/database.php b/www/database.php index 7b94323..77d5c7e 100644 --- a/www/database.php +++ b/www/database.php @@ -173,6 +173,20 @@ function LoadMonth($user, $month, $year) 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) { $res; diff --git a/www/index.php b/www/index.php index 73781a4..16f227f 100644 --- a/www/index.php +++ b/www/index.php @@ -86,6 +86,11 @@ else $_SESSION["cur_month"] = $_POST["month"]; } +if (isset($_POST["expand"])) + $_SESSION["expand"] = "1"; +else + $_SESSION["expand"] = "0"; + $operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cur_year"]); $cur_date = mktime(0, 0, 0, date("m") , date("d"), date("Y")); $total_incomes = $total_outcomes = $cur_incomes = $cur_outcomes = 0; @@ -162,6 +167,7 @@ function changeMonths() } ?> + >Expand groups Disconnect @@ -175,7 +181,10 @@ function changeMonths() { $val = GetAccountAmount($account["id"], $_SESSION["cur_month"], $_SESSION["cur_year"]); echo ""; - echo "" . $account["number"] . ""; + if ($account["shared"] == "1") + echo "" . $account["number"] . "*"; + else + echo "" . $account["number"] . ""; echo "" . $account["name"] . ""; echo "" . number_format($val, 2) . ""; if (($accounts[$account["id"]]["cur"] + $val) < 0) @@ -197,8 +206,17 @@ function changeMonths() $operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cur_year"]); while($operation = $operations->fetchArray()) { - if ($operation["meta"] == "1") continue; - + if ($_SESSION["expand"] == "1") + { + if ($operation["meta"] == "1") + continue; + } + else + { + if ($operation["parent"] != "") + continue; + } + $category = $_SESSION["user"]->GetCategory($operation["category"]); if ($operation["fix_cost"] == "0") { @@ -213,11 +231,23 @@ while($operation = $operations->fetchArray()) } echo "" . $operation["description"] . ""; echo "" . date("d/m/Y", mktime(0, 0, 0, $operation["month"]+1, $operation["day"]+1, $operation["year"])) . ""; - if ($operation["amount"] < 0) - echo "" . number_format(-$operation["amount"], 2) . ""; + if ($operation["meta"] == "1" && $operation["amount"] == 0) + { + $amount = MetaPositiveAmount($operation["id"]); + echo "" . number_format($amount, 2) . ""; + echo "" . number_format($amount, 2) . ""; + } else - echo "" . number_format($operation["amount"], 2) . ""; - echo "" . $category["name"] . ""; + { + if ($operation["amount"] < 0) + echo "" . number_format(-$operation["amount"], 2) . ""; + else + echo "" . number_format($operation["amount"], 2) . ""; + } + if ($operation["meta"] != "1") + echo "" . $category["name"] . ""; + else + echo ""; echo "" . $_SESSION["user"]->GetAccountName($operation["account"]) . ""; echo "\n"; }