function BuildCashFlowTable($total) { global $query, $connection, $dateToQuery, $MoneyFlow, $linha, $totalcolumn, $totalflow, $period; //first, we call the function to fill the array with the months to query DateIntervalArray($period); echo "\r\n<table id=\"cftable\"><thead><th></th>\r\n"; foreach ($dateToQuery as $eachdate => $firstandlastday) { echo "<th>" . $eachdate . "</th>"; } //then we call the function to get the initial balance of the selected accounts //FIXME: it is not bringing the initial balance, but the balance as of the end of the first day BalanceAsOfQuery(); $resultado = mysql_query($query, $connection); while ($linha = mysql_fetch_array($resultado)) { echo "<tr><td class=\"col\">" . $linha['accname'] . " - Saldo inicial</td>"; foreach ($dateToQuery as $eachdate => $firstandlastday) { echo "<td>" . number_format($linha[$eachdate], 2, ',', '.') . "</td>"; } } //then we call the function to create the main query CashFlowQuery(); echo "</tr></thead><tbody>\r\n"; echo "<tr class=\"header\"><td class=\"col\">Dinheiro entrando nas contas selecionadas vem de</td>\r\n"; foreach ($dateToQuery as $eachdate => $firstandlastday) { echo "<td></td>"; } echo "</tr>\r\n"; $resultado = mysql_query($query, $connection); while ($linha = mysql_fetch_array($resultado)) { foreach ($dateToQuery as $eachdate => $firstandlastday) { if ($linha[$MoneyFlow[0] . "-" . $eachdate] < 0) { printrow_plain($MoneyFlow[0], withtotal); break; } } } if (isset($total)) { echo "<tr class=\"total\"><td class=\"col\">Dinheiro Entrando</td>"; foreach ($totalflow as $eachcollum) { echo "<td> " . number_format(-$eachcollum, 2, ',', '.') . "</td>"; } echo "</tr>\r\n"; } $totalflow = array(); echo "<tr class=\"header\"><td class=\"col\">Dinheiro saindo das contas selecionadas vai para</td>\r\n"; foreach ($dateToQuery as $eachdate => $firstandlastday) { echo "<td></td>"; } echo "</tr>\r\n"; mysql_data_seek($resultado, 0); while ($linha = mysql_fetch_array($resultado)) { foreach ($dateToQuery as $eachdate => $firstandlastday) { if ($linha[$MoneyFlow[1] . "-" . $eachdate] > 0) { printrow_plain($MoneyFlow[1], withtotal); break; } } } if (isset($total)) { echo "<tr class=\"total\"><td class=\"col\">Dinheiro Saindo</td>"; foreach ($totalflow as $eachcollum) { echo "<td> " . number_format(-$eachcollum, 2, ',', '.') . "</td>"; } echo "</tr>\r\n"; } if (isset($total)) { echo "<tr class=\"total\"><td class=\"col\">Diferença</td>"; foreach ($totalcolumn as $eachcollum) { echo "<td> " . number_format(-$eachcollum, 2, ',', '.') . "</td>"; } echo "</tr>\r\n"; } echo "</tbody></table>\r\n"; }
<meta name="keywords" content=""> <meta name="description" content=""> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" > <script type="text/javascript" src="includes/jsfunctions.js"></script> <link rel="stylesheet" href="includes/gnucashreports.css" type="text/css" media="screen" /> </head> <body> <div id="headercontainer"> <div id="topheader"> <?php include 'includes/topmenu.php'; ?> <div id="report-nav"> </div> </div> </div> <div id="content"> <?php include 'functions.php'; BalanceAsOfDateArray(); BalanceAsOfQuery(); BuildTable(); ?> </div> </body> </html>