Merge branch 'master' of cybelle:kisscount
This commit is contained in:
commit
6cb7b0ccf0
4
INSTALL
4
INSTALL
|
@ -4,7 +4,11 @@ libsqlite3-dev
|
||||||
libwxgtk2.8-dev
|
libwxgtk2.8-dev
|
||||||
g++
|
g++
|
||||||
make
|
make
|
||||||
|
gettext
|
||||||
|
|
||||||
|
Optionnal :
|
||||||
|
poeditor
|
||||||
|
php5
|
||||||
|
|
||||||
** Compilation of extra libraries **
|
** Compilation of extra libraries **
|
||||||
cd lib/wxsqlite3-1.9.9
|
cd lib/wxsqlite3-1.9.9
|
||||||
|
|
14
www/User.php
14
www/User.php
|
@ -27,10 +27,22 @@ class User
|
||||||
|
|
||||||
function GetCategory($id)
|
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)
|
foreach($this->categories as $i => $category)
|
||||||
if ($category["id"] == "$id") return $category;
|
if ($category["id"] == "$id") return $category;
|
||||||
|
|
||||||
return "";
|
return LoadCategory($this, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetAccountName($id)
|
function GetAccountName($id)
|
||||||
|
|
|
@ -92,6 +92,12 @@ function LoadUser($name)
|
||||||
|
|
||||||
$user->accounts = array();
|
$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())
|
while ($row = $result->fetchArray())
|
||||||
array_push($user->accounts, $row);
|
array_push($user->accounts, $row);
|
||||||
|
|
||||||
|
@ -117,6 +123,21 @@ function LoadUser($name)
|
||||||
return $user;
|
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)
|
function GetAccountAmount($id, $month, $year)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -150,7 +171,20 @@ function LoadMonth($user, $month, $year)
|
||||||
$req .= $user->preferences["operation_order"];
|
$req .= $user->preferences["operation_order"];
|
||||||
|
|
||||||
return $db->query($req);
|
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)
|
function GetAllOperations($user, &$last_year, &$last_month)
|
||||||
|
|
|
@ -54,7 +54,7 @@ if (!isset($_SESSION["user"]))
|
||||||
{
|
{
|
||||||
$users = GetUsers();
|
$users = GetUsers();
|
||||||
echo "<center><h1>KissCount</h1><br /><br/>\n";
|
echo "<center><h1>KissCount</h1><br /><br/>\n";
|
||||||
echo "<form id=\"login\" method=\"post\">\n";
|
echo "<form id=\"login\" method=\"post\" action='index.php'>\n";
|
||||||
echo "Login : <select name=\"user\">\n";
|
echo "Login : <select name=\"user\">\n";
|
||||||
foreach($users as $i => $name)
|
foreach($users as $i => $name)
|
||||||
echo "<option value=\"$name\">$name</option>\n";
|
echo "<option value=\"$name\">$name</option>\n";
|
||||||
|
@ -86,6 +86,11 @@ else
|
||||||
$_SESSION["cur_month"] = $_POST["month"];
|
$_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"]);
|
$operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cur_year"]);
|
||||||
$cur_date = mktime(0, 0, 0, date("m") , date("d"), date("Y"));
|
$cur_date = mktime(0, 0, 0, date("m") , date("d"), date("Y"));
|
||||||
$total_incomes = $total_outcomes = $cur_incomes = $cur_outcomes = 0;
|
$total_incomes = $total_outcomes = $cur_incomes = $cur_outcomes = 0;
|
||||||
|
@ -139,7 +144,7 @@ function changeMonths()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<form id="date" method="POST">
|
<form id="date" method="POST" action="index.php">
|
||||||
<select name="month" id="date_month">
|
<select name="month" id="date_month">
|
||||||
<?php
|
<?php
|
||||||
foreach($_SESSION["operations"][$_SESSION["cur_year"]] as $i => $month)
|
foreach($_SESSION["operations"][$_SESSION["cur_year"]] as $i => $month)
|
||||||
|
@ -162,6 +167,7 @@ function changeMonths()
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
<input type="checkbox" name="expand" <?php if ($_SESSION["expand"] == "1") echo "checked";?>>Expand groups</input>
|
||||||
<input type="submit" value="OK"/>
|
<input type="submit" value="OK"/>
|
||||||
</form>
|
</form>
|
||||||
<a id="disconnect" href="?disconnect=1">Disconnect</a>
|
<a id="disconnect" href="?disconnect=1">Disconnect</a>
|
||||||
|
@ -175,6 +181,9 @@ function changeMonths()
|
||||||
{
|
{
|
||||||
$val = GetAccountAmount($account["id"], $_SESSION["cur_month"], $_SESSION["cur_year"]);
|
$val = GetAccountAmount($account["id"], $_SESSION["cur_month"], $_SESSION["cur_year"]);
|
||||||
echo "<tr class='bordered'>";
|
echo "<tr class='bordered'>";
|
||||||
|
if ($account["shared"] == "1")
|
||||||
|
echo "<td>" . $account["number"] . "*</td>";
|
||||||
|
else
|
||||||
echo "<td>" . $account["number"] . "</td>";
|
echo "<td>" . $account["number"] . "</td>";
|
||||||
echo "<td>" . $account["name"] . "</td>";
|
echo "<td>" . $account["name"] . "</td>";
|
||||||
echo "<td align='right'>" . number_format($val, 2) . "</td>";
|
echo "<td align='right'>" . number_format($val, 2) . "</td>";
|
||||||
|
@ -197,7 +206,16 @@ function changeMonths()
|
||||||
$operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cur_year"]);
|
$operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cur_year"]);
|
||||||
while($operation = $operations->fetchArray())
|
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"]);
|
$category = $_SESSION["user"]->GetCategory($operation["category"]);
|
||||||
if ($operation["fix_cost"] == "0")
|
if ($operation["fix_cost"] == "0")
|
||||||
|
@ -213,11 +231,23 @@ while($operation = $operations->fetchArray())
|
||||||
}
|
}
|
||||||
echo "<tr $tr_class style='" . $category["style"] . "'><td>" . $operation["description"] . "</td>";
|
echo "<tr $tr_class style='" . $category["style"] . "'><td>" . $operation["description"] . "</td>";
|
||||||
echo "<td>" . date("d/m/Y", mktime(0, 0, 0, $operation["month"]+1, $operation["day"]+1, $operation["year"])) . "</td>";
|
echo "<td>" . date("d/m/Y", mktime(0, 0, 0, $operation["month"]+1, $operation["day"]+1, $operation["year"])) . "</td>";
|
||||||
|
if ($operation["meta"] == "1" && $operation["amount"] == 0)
|
||||||
|
{
|
||||||
|
$amount = MetaPositiveAmount($operation["id"]);
|
||||||
|
echo "<td align='right'>" . number_format($amount, 2) . "</td>";
|
||||||
|
echo "<td align='right'>" . number_format($amount, 2) . "</td>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if ($operation["amount"] < 0)
|
if ($operation["amount"] < 0)
|
||||||
echo "<td align='right'>" . number_format(-$operation["amount"], 2) . "</td><td />";
|
echo "<td align='right'>" . number_format(-$operation["amount"], 2) . "</td><td />";
|
||||||
else
|
else
|
||||||
echo "<td /><td align='right'>" . number_format($operation["amount"], 2) . "</td>";
|
echo "<td /><td align='right'>" . number_format($operation["amount"], 2) . "</td>";
|
||||||
|
}
|
||||||
|
if ($operation["meta"] != "1")
|
||||||
echo "<td>" . $category["name"] . "</td>";
|
echo "<td>" . $category["name"] . "</td>";
|
||||||
|
else
|
||||||
|
echo "<td />";
|
||||||
echo "<td>" . $_SESSION["user"]->GetAccountName($operation["account"]) . "</td>";
|
echo "<td>" . $_SESSION["user"]->GetAccountName($operation["account"]) . "</td>";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user