Add Expand Group option to web view
This commit is contained in:
parent
dc6ec437fa
commit
13db50e271
12
www/User.php
12
www/User.php
|
@ -27,6 +27,18 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,20 @@ function LoadMonth($user, $month, $year)
|
||||||
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)
|
||||||
{
|
{
|
||||||
$res;
|
$res;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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