[go: up one dir, main page]

Menu

[r99]: / tags / 1.3 / sharedentries.php  Maximize  Restore  History

Download this file

122 lines (118 with data), 6.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
# $Id: sharedentries.php 86 2010-10-05 12:19:27Z rediculum $
#
# Includes
####################################################################
include("includes/session.inc.php");
include("includes/layout.inc.php");
include("includes/functions.inc.php");
include("includes/db.inc.php");
include("includes/variables.inc.php");
# Main
#####################################################################?>
<html>
<head>
<?php echo "$headtitle $head";?>
</head>
<body>
<div id=menu>
<?include("includes/menu.inc.php");?>
</div>
<div id=mainframe>
<?php monatBlaetterZurueck("$activeuser","$activemonth","$activeyear");?>
&nbsp;
<?php monatBlaetterVor("$activeuser","$activemonth","$activeyear");?>
<p>
<table width=850 bgcolor="#FFFFFF">
<tr><td>
<?php echo "<b>$shared $entries $on $activemonthword $activeyear</b>";?>
</td></tr>
<?php $katresult = mysql_query("SELECT sk_id,sk_name,hauptkategorien.hk_name,hauptkategorien.hk_id FROM subkategorien LEFT JOIN hauptkategorien ON subkategorien.hk_id = hauptkategorien.hk_id ORDER BY hk_name,sk_name");
while ($kategorie = mysql_fetch_array($katresult)) {
$otheruser = mysql_result(mysql_query("SELECT username FROM users WHERE NOT username='$activeuser'"),0);
$totalactiveuser = mysql_result(mysql_query("SELECT SUM(betrag) FROM verbuchungen WHERE shared=1 AND monat='$activemonth' AND jahr='$activeyear' AND username='$activeuser' AND q_id='2' AND sk_id='$kategorie[0]'"),0);
$totalotheruser = mysql_result(mysql_query("SELECT SUM(betrag) FROM verbuchungen WHERE shared=1 AND monat='$activemonth' AND jahr='$activeyear' AND username='$otheruser' AND q_id='2' AND sk_id='$kategorie[0]'"),0);
$total = mysql_result(mysql_query("SELECT SUM(betrag) FROM verbuchungen WHERE shared=1 AND monat='$activemonth' AND jahr='$activeyear' AND sk_id='$kategorie[0]'"),0);
$diff = ($totalactiveuser)-($total/2);
if ($total == NULL) {
continue;
}?>
<tr><td valign=top>
<?php $entrymatch = mysql_fetch_row(mysql_query("SELECT $queryentriesjoin WHERE monat='$activemonth' AND jahr='$activeyear' AND text LIKE 'Diff% $otheruser' AND sk_name='$kategorie[1]'"));
if ($_REQUEST["$kategorie[2]_$kategorie[1]"] == "full") {
echo "<a href=\"?jahr=$activeyear&monat=$activemonth\" title=Collapse><img src=\"images/minus.gif\" border=0></a> $category <b>$kategorie[2] $kategorie[1]</b>";
$result = mysql_query("SELECT $queryentriesjoin WHERE shared=1 AND monat='$activemonth' AND jahr='$activeyear' AND q_name='Ausgaben' AND sk_name='$kategorie[1]' ORDER BY tag,monat ASC") or die (mysql_error());
tabelleVerbuchungen($result);
} else {
echo "<a href=\"?jahr=$activeyear&monat=$activemonth&$kategorie[2]_$kategorie[1]=full\" title=Expand><img src=\"images/plus.gif\" border=0></a> $category <b>$kategorie[2] $kategorie[1]</b>";
}?>
<br>
<table width=100% border=0 cellpadding=4 cellspacing=0><tr>
<td valign=bottom bgcolor=#DDDDFF><?php echo "$activeuser $currency " . zahlFormat($totalactiveuser);?></td>
<td valign=bottom bgcolor=#DDDDFF><?php echo "$otheruser $currency " . zahlFormat($totalotheruser) ;?> </td>
<td valign=bottom bgcolor=#DDDDFF><?php echo "$totally $currency " . zahlFormat($total);?></td>
<td valign=bottom bgcolor=#DDDDFF><?php echo "$half $currency " . zahlFormat(round($total/2,1));?></td>
<?$betrag = zahlFormat(round($diff,1));
$letztertag = letzterTag($activemonth,$activeyear);
if ($diff < "0") {
$betrag = zahlFormat(($betrag-($betrag*2))); # Convert negative to positive?>
<td valign=bottom align=right bgcolor="#FFDDAA"><img src="images/schuld.gif" border=0><?php echo "$activeuser $owes $currency $betrag";
if ($entrymatch) {
echo " <img src=images/ok.gif></td>";
}
if ($_REQUEST[setentries]) {
$entrymatch = mysql_fetch_row(mysql_query("SELECT $queryentriesjoin WHERE monat='$activemonth' AND jahr='$activeyear' AND text LIKE 'Diff% $otheruser' AND sk_name='$kategorie[1]'"));
if ($entrymatch) {
echo "<td align=right>$already $booked</td>";
} elseif ($betrag == "0.00") {
echo "<td align=right>$amount $is 0</td>";
} else {
echo "<td>$booked</td>";
mysql_query("INSERT INTO verbuchungen (id,tag,monat,jahr,betrag,q_id,hk_id,sk_id,username,shared,text) VALUES ('','$letztertag','$activemonth','$activeyear','$betrag','2','$kategorie[3]','$kategorie[0]','$activeuser','0','$difference $otheruser')");
}
}
} else {?>
<td valign=bottom align=right bgcolor="#CCFFBB"><img src="images/erhalten.gif" border=0><?php echo "$activeuser $obtains $currency $betrag";
if ($entrymatch) {
echo " <img src=images/ok.gif></td>";
}
if ($_REQUEST[setentries]) {
$entrymatch = mysql_fetch_row(mysql_query("SELECT $queryentriesjoin WHERE monat='$activemonth' AND jahr='$activeyear' AND text LIKE 'Diff% $otheruser' AND sk_name='$kategorie[1]'"));
if ($entrymatch) {
echo "<td align=right>$already $booked</td>";
} else {
echo "<td>$booked</td>";
mysql_query("INSERT INTO verbuchungen (id,tag,monat,jahr,betrag,q_id,hk_id,sk_id,username,shared,text) VALUES ('','$letztertag','$activemonth','$activeyear','$betrag','1','$kategorie[3]','$kategorie[0]','$activeuser','0','$difference $otheruser')");
}
}
}?>
</tr>
</table>
<hr>
<br>
</td></tr>
<?};?>
<tr><td align=right>
<table border=1 cellpadding=4 cellspacing=0>
<?php echo "$for_the_bank_transfer";?>
<tr align=right bgcolor="#DDDDDD">
<?php $totalgem = mysql_query("SELECT SUM(betrag) FROM verbuchungen WHERE shared=1 AND monat='$activemonth' AND jahr='$activeyear' AND q_id='2'") or die (mysql_error());
$tothalf = round(mysql_result($totalgem,0)/2,2);
$totaluser = mysql_query("SELECT SUM(betrag) FROM verbuchungen WHERE shared=1 AND monat='$activemonth' AND jahr='$activeyear' AND username='$activeuser' AND q_id='2'") or die (mysql_error());
$diff = (mysql_result($totaluser,0)-$tothalf);
$betrag = zahlFormat($diff);
if ($diff < "0") {
$betrag = zahlFormat(($betrag-($betrag*2))); # Wandle in positive Zahl um ?>
<td bgcolor="#FFDDAA"><b><img src="images/schuld.gif" border=0><?php echo "$activeuser $owes $totally $currency $betrag</b></td>";
} else {?>
<td bgcolor="#CCFFBB"><b><img src="images/erhalten.gif" border=0><?php echo "$activeuser $obtains $totally $currency $betrag</b></td>";
}?>
<tr><td align=right>
<form><input type=button class=button_click value="<?php echo "$entries $toconduct"?>" ><?php echo "?monat=$activemonth&jahr=$activeyear&setentries=true'";?>"></form>
</td>
</tr>
</table>
</td></tr>
</table>
</div>
</html>