Work on web view :
Add Button to show/hide sub operations Re order accounts Pack operations and their sub operations
This commit is contained in:
		
							
								
								
									
										0
									
								
								www/User.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								www/User.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										63
									
								
								www/database.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										63
									
								
								www/database.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -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, name ASC"); | ||||
|     $result = $db->query("SELECT * FROM account WHERE user='$user->id' ORDER BY default_account DESC, virtual, blocked, 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 ASC"); | ||||
|     $result = $db->query("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='$user->id') ORDER BY name, blocked, virtual ASC"); | ||||
|  | ||||
|     while ($row = $result->fetchArray()) | ||||
|         array_push($user->accounts, $row); | ||||
| @@ -152,9 +152,19 @@ function GetAccountAmount($id, $month, $year) | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| function array_insert($array,$pos,$val) | ||||
| { | ||||
|     $array2 = array_splice($array,$pos); | ||||
|     $array[] = $val; | ||||
|     $array = array_merge($array,$array2); | ||||
|     | ||||
|     return $array; | ||||
| } | ||||
|  | ||||
| function LoadMonth($user, $month, $year) | ||||
| { | ||||
|     global $db; | ||||
|     $res = array(); | ||||
|  | ||||
|     if (!isset($user->accounts[0])) return; | ||||
|  | ||||
| @@ -170,7 +180,37 @@ function LoadMonth($user, $month, $year) | ||||
|     $req .= " ORDER BY fix_cost DESC, year, month ASC, day "; | ||||
|     $req .= $user->preferences["operation_order"]; | ||||
|  | ||||
|     return $db->query($req); | ||||
|     $result = $db->query($req); | ||||
|  | ||||
|     // Pack operations and their sub operations | ||||
|     while ($row = $result->fetchArray()) | ||||
|     { | ||||
|         $inserted = 0; | ||||
|         foreach($res as $i => $value) | ||||
|         { | ||||
|             if ($value["parent"] == $row["id"]) | ||||
|             { | ||||
|                 $res = array_insert($res, $i, $row); | ||||
|                 $inserted = 1; | ||||
|                 break; | ||||
|             } | ||||
|  | ||||
|             if ($row["parent"] == $value["id"]) | ||||
|             { | ||||
|                 $res = array_insert($res, $i+1, $row); | ||||
|                 $inserted = 1; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Append | ||||
|         if ($inserted == 0) | ||||
|         { | ||||
|             $res = array_insert($res, $i+1, $row); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     return $res; | ||||
| } | ||||
|  | ||||
| function MetaPositiveAmount($id) | ||||
| @@ -250,4 +290,21 @@ function GetAllOperations($user, &$last_year, &$last_month) | ||||
|      | ||||
|     return $res; | ||||
| } | ||||
| function GetSubOperations($parent) | ||||
| { | ||||
|     $res = "["; | ||||
|     global $db; | ||||
|  | ||||
|     $req = "SELECT id FROM operation WHERE parent=\"" . $parent . "\""; | ||||
|  | ||||
|     $result = $db->query($req); | ||||
|  | ||||
|     while ($row = $result->fetchArray()) | ||||
|         $res .= $row["id"] . ", "; | ||||
|      | ||||
|     if (strlen($res) > 1) | ||||
|         $res = substr($res, 0, strlen($res)-2); | ||||
|  | ||||
|     return $res . "]"; | ||||
| } | ||||
| ?> | ||||
							
								
								
									
										89
									
								
								www/index.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										89
									
								
								www/index.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -86,16 +86,13 @@ 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; | ||||
| $categories = array(); | ||||
|  | ||||
| while($operation = $operations->fetchArray()) | ||||
| // Statistics | ||||
| foreach($operations as $i => $operation) | ||||
| { | ||||
|     if ($operation["meta"] == "1")  | ||||
|         continue; | ||||
| @@ -151,6 +148,29 @@ function changeMonths() | ||||
|     ?> | ||||
|     } | ||||
| } | ||||
| function toggleOperations(parent, operations) | ||||
| { | ||||
|     var obj = document.getElementById(operations[0]); | ||||
|     var obj2 = document.getElementById(parent); | ||||
|     var visibility; | ||||
|  | ||||
|     if (obj.style.display == "none") | ||||
|     { | ||||
|         obj2.value = "-"; | ||||
|         visibility = "table-row"; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         obj2.value = "+"; | ||||
|         visibility = "none"; | ||||
|     } | ||||
|  | ||||
|     for (var i=0; i<operations.length; i++) | ||||
|     { | ||||
|         obj = document.getElementById(operations[i]); | ||||
|         obj.style.display = visibility; | ||||
|     } | ||||
| } | ||||
| </script> | ||||
| <form id="date" method="POST" action="index.php"> | ||||
|     <select name="month" id="date_month"> | ||||
| @@ -175,7 +195,6 @@ function changeMonths() | ||||
| } | ||||
|     ?> | ||||
|     </select> | ||||
|     <input type="checkbox" name="expand" <?php if ($_SESSION["expand"] == "1") echo "checked";?>>Expand groups</input> | ||||
|     <input type="submit" value="OK"/> | ||||
| </form> | ||||
|     <a id="disconnect" href="?disconnect=1">Disconnect</a> | ||||
| @@ -208,23 +227,13 @@ function changeMonths() | ||||
| <br /><br /> | ||||
| <div id="operations"> | ||||
|     <table> | ||||
|     <tr class="header" bgcolor="#99CCFF"><td>Description</td><td>Date</td><td>Debit</td><td>Credit</td><td>Category</td><td>Account</td></tr> | ||||
|     <tr class="header" bgcolor="#99CCFF"><td/><td>Description</td><td>Date</td><td>Debit</td><td>Credit</td><td>Category</td><td>Account</td></tr> | ||||
|     <?php | ||||
|     $prev_week=-1; | ||||
| $operations = LoadMonth($_SESSION["user"], $_SESSION["cur_month"], $_SESSION["cur_year"]); | ||||
| while($operation = $operations->fetchArray()) | ||||
| { | ||||
|     if ($_SESSION["expand"] == "1") | ||||
|     { | ||||
|         if ($operation["meta"] == "1")  | ||||
|             continue; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if ($operation["parent"] != "")  | ||||
|             continue; | ||||
|     } | ||||
|  | ||||
| foreach($operations as $i => $operation) | ||||
| { | ||||
|     $category = $_SESSION["user"]->GetCategory($operation["category"]); | ||||
|     if ($operation["fix_cost"] == "0") | ||||
|     { | ||||
| @@ -237,7 +246,15 @@ while($operation = $operations->fetchArray()) | ||||
| 	else | ||||
|             $tr_class = ""; | ||||
|     } | ||||
|     echo "<tr $tr_class style='" . $category["style"] . "'><td>" . $operation["description"] . "</td>"; | ||||
|     if ($operation["meta"] == "1")  | ||||
|         echo "<tr $tr_class style='" . $category["style"] . "'><td><input id=\"" . $operation["id"] . "\" type=\"button\" value=\"+\" onClick=\"var ids = " . GetSubOperations($operation["id"]) . " ; toggleOperations(" . $operation["id"] . ", ids);\"/></td><td>" . $operation["description"] . "</td>"; | ||||
|     else | ||||
|     { | ||||
|         if ($operation["parent"] == "")  | ||||
|             echo "<tr id=\"" . $operation["id"] . "\" $tr_class style='" . $category["style"] . "'><td></td><td>" . $operation["description"] . "</td>"; | ||||
|         else | ||||
|             echo "<tr id=\"" . $operation["id"] . "\" $tr_class style='" . $category["style"] . ";display:none'><td></td><td>    " . $operation["description"] . "</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) | ||||
|     { | ||||
| @@ -252,7 +269,7 @@ while($operation = $operations->fetchArray()) | ||||
|         else | ||||
|             echo "<td /><td align='right'>" . number_format($operation["amount"], 2) . "</td>"; | ||||
|     } | ||||
|     if ($operation["meta"] != "1") | ||||
|     if ($operation["meta"] != "1" && $category["id"] > 1) | ||||
|         echo "<td>" . $category["name"] . "</td>"; | ||||
|     else | ||||
|         echo "<td />"; | ||||
| @@ -282,9 +299,31 @@ while($operation = $operations->fetchArray()) | ||||
|     <?php | ||||
|     foreach($_SESSION["user"]->categories as $i => $category) | ||||
| { | ||||
|     $percent = ($categories[$category["id"]] * 100) / $total_outcomes; | ||||
|     $percent = round($percent, 0);  | ||||
|     $percent = ($percent < 10) ? "0$percent" : "$percent"; | ||||
|     // Non fix | ||||
|     if ($i == 1) | ||||
|     { | ||||
|         $value = $total_outcomes - $categories[1]; | ||||
|         if ($total_outcomes == 0) | ||||
|             $percent = 0; | ||||
|         else | ||||
|         { | ||||
|             $percent = ($value * 100) / $total_outcomes; | ||||
|             $percent = round($percent, 0);  | ||||
|             $percent = ($percent < 10) ? "0$percent" : "$percent"; | ||||
|         } | ||||
|  | ||||
|         echo "<tr class=\"bordered\"><td>Non fix</td><td align=\"right\">" . number_format($value, 2) . " ($percent %)</td></tr>\n"; | ||||
|     } | ||||
|  | ||||
|     if ($total_outcomes == 0) | ||||
|         $percent = 0; | ||||
|     else | ||||
|     { | ||||
|         $percent = ($categories[$category["id"]] * 100) / $total_outcomes; | ||||
|         $percent = round($percent, 0);  | ||||
|         $percent = ($percent < 10) ? "0$percent" : "$percent"; | ||||
|     } | ||||
|  | ||||
|     echo "<tr class=\"bordered\"><td>" . $category["name"]. "</td><td align=\"right\">" . number_format($categories[$category["id"]], 2) . " ($percent %)</td></tr>\n"; | ||||
| } | ||||
| ?> | ||||
|   | ||||
							
								
								
									
										0
									
								
								www/kisscount.css
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								www/kisscount.css
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								www/kisscount.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								www/kisscount.php
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
		Reference in New Issue
	
	Block a user