diff --git a/ressources/icons/search.png b/ressources/icons/search.png index 04d0b5e..f98759e 100644 Binary files a/ressources/icons/search.png and b/ressources/icons/search.png differ diff --git a/www/User.php b/www/User.php index 41895e6..32c8c63 100755 --- a/www/User.php +++ b/www/User.php @@ -27,14 +27,13 @@ class User function GetCategory($id) { - if ($id == "") + if ($id == "" || $id == "0") { - $cat["id"] = ""; + $cat["id"] = "0"; $cat["forecolor"] = "black"; $cat["backcolor"] = "#3DEB3D"; - $s = "background-color:" . $cat["backcolor"] . ";"; - $s .= "color:" . $cat["forecolor"] . ";"; - $cat["style"] = $s; + $cat["font"] = ""; + ExtractStyle($cat); return $cat; } diff --git a/www/database.php b/www/database.php index bf2c361..8ab6e65 100755 --- a/www/database.php +++ b/www/database.php @@ -88,7 +88,7 @@ function LoadUser($name) $user->id = $row["id"]; - $result = $db->query("SELECT * FROM account WHERE user='$user->id' ORDER BY default_account DESC, virtual, blocked, name ASC"); + $result = $db->query("SELECT * FROM account WHERE user='$user->id' ORDER BY default_account DESC, hidden, blocked, virtual, name ASC"); $user->accounts = array(); @@ -96,7 +96,7 @@ function LoadUser($name) 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, blocked, virtual ASC"); + $result = $db->query("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='$user->id') ORDER BY default_account DESC, hidden, blocked, virtual, name ASC"); while ($row = $result->fetchArray()) array_push($user->accounts, $row); @@ -125,6 +125,8 @@ function LoadUser($name) function LoadCategory(&$user, $id) { + global $db; + $result = $db->query("SELECT * FROM category WHERE id='$id'"); if ($row = $result->fetchArray()) diff --git a/www/index.php b/www/index.php index 2d4afe0..cd7e7b6 100755 --- a/www/index.php +++ b/www/index.php @@ -90,6 +90,18 @@ $operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cu $cur_date = mktime(0, 0, 0, date("m") , date("d"), date("Y")); $total_incomes = $total_outcomes = $cur_incomes = $cur_outcomes = 0; $categories = array(); +$accounts = array(); + +// Init arrays +foreach($_SESSION["user"]->accounts as $i => $account) +{ + $accounts[$account["id"]]["total"] = 0; + $accounts[$account["id"]]["cur"] = 0; +} +foreach($_SESSION["user"]->categories as $i => $category) +{ + $categories[$category["id"]] = 0; +} // Statistics foreach($operations as $i => $operation) @@ -104,7 +116,12 @@ foreach($operations as $i => $operation) if ($date <= $cur_date) $accounts[$operation["account"]]["cur"] += $operation["amount"]; - if (!($operation["transfert"] == "" || ($operation["amount"] > 0 && $_SESSION["user"]->IsAccountBlocked($operation["account"])))) + // Forgive transfert on non blocked accounts + if ($operation["transfert"] != "" && !$_SESSION["user"]->IsAccountBlocked($operation["account"])) + continue; + + // Forgive credit on blocked account + if ($operation["transfert"] == "" && $_SESSION["user"]->IsAccountBlocked($operation["account"])) continue; @@ -206,7 +223,7 @@ function toggleOperations(parent, operations) accounts as $i => $account) { - if ($accounts["hidden"] == "1") continue; + if ($account["hidden"] == "1") continue; $val = GetAccountAmount($account["id"], $_SESSION["cur_month"], $_SESSION["cur_year"]); echo ""; if ($account["shared"] == "1") @@ -214,12 +231,12 @@ function toggleOperations(parent, operations) else echo "" . $account["number"] . ""; echo "" . $account["name"] . ""; - echo "" . number_format($val, 2) . ""; + echo "" . number_format($val/100, 2) . ""; if (($accounts[$account["id"]]["cur"] + $val) < 0) - echo "" . number_format($accounts[$account["id"]]["cur"] + $val, 2) . "" ; + echo "" . number_format(($accounts[$account["id"]]["cur"] + $val)/100, 2) . "" ; else - echo "" . number_format($accounts[$account["id"]]["cur"] + $val, 2) . "" ; - echo "" . number_format($accounts[$account["id"]]["total"] + $val, 2) . "" ; + echo "" . number_format(($accounts[$account["id"]]["cur"] + $val)/100, 2) . "" ; + echo "" . number_format(($accounts[$account["id"]]["total"] + $val)/100, 2) . "" ; echo "\n"; } ?> @@ -247,6 +264,8 @@ foreach($operations as $i => $operation) else $tr_class = ""; } + else + $tr_class = ""; if ($operation["meta"] == "1") echo "" . $operation["description"] . ""; else @@ -259,16 +278,16 @@ foreach($operations as $i => $operation) echo "" . date("d/m/Y", mktime(0, 0, 0, $operation["month"]+1, $operation["day"]+1, $operation["year"])) . ""; if ($operation["meta"] == "1" && $operation["amount"] == 0) { - $amount = MetaPositiveAmount($operation["id"]); + $amount = MetaPositiveAmount($operation["id"])/100; echo "" . number_format($amount, 2) . ""; echo "" . number_format($amount, 2) . ""; } else { if ($operation["amount"] < 0) - echo "" . number_format(-$operation["amount"], 2) . ""; + echo "" . number_format(-$operation["amount"]/100, 2) . ""; else - echo "" . number_format($operation["amount"], 2) . ""; + echo "" . number_format($operation["amount"]/100, 2) . ""; } if ($operation["meta"] != "1" && $category["id"] > 1) echo "" . $category["name"] . ""; @@ -284,16 +303,16 @@ foreach($operations as $i => $operation)
- - - - + + + + " . number_format($total_incomes - $total_outcomes, 2) . ""; + echo ""; else - echo ""; + echo ""; ?> @@ -313,7 +332,7 @@ foreach($operations as $i => $operation) $percent = ($percent < 10) ? "0$percent" : "$percent"; } - echo "\n"; + echo "\n"; } if ($total_outcomes == 0) @@ -325,7 +344,7 @@ foreach($operations as $i => $operation) $percent = ($percent < 10) ? "0$percent" : "$percent"; } - echo "\n"; + echo "\n"; } ?>
Cur credit
Cur debit
Total credit
Total debit
Cur credit
Cur debit
Total credit
Total debit
Remains " . number_format(($total_incomes - $total_outcomes)/100, 2) . " " . number_format($total_incomes - $total_outcomes, 2) . " " . number_format(($total_incomes - $total_outcomes)/100, 2) . "
_
Non fix" . number_format($value, 2) . " ($percent %)
Non fix" . number_format($value/100, 2) . " ($percent %)
" . $category["name"]. "" . number_format($categories[$category["id"]], 2) . " ($percent %)
" . $category["name"]. "" . number_format($categories[$category["id"]]/100, 2) . " ($percent %)