<tr><td height=50><a href="<?=$g4[path]?>/bbs/board.php?bo_table=static&wr_id=1&page=0""><b><u>회계</u></b></a></td></tr>

<tr>
    <td height=30 style="color:#888;">


<?
		if($want_year =="")  $here = date("Y"); else $here = $want_year;

// 입출금 내역
$i=0;


		$query5 = "select  wr_datetime, sum(wr_1) as sum_wr1, sum(wr_2) as sum_wr2 from g4_write_finance where left(wr_datetime,4) = '$here' group by left(wr_datetime,7)    ";
		$result5 = sql_query($query5);
		while($row  = sql_fetch_array($result5)) {
			$ex_total[$i] = $row[sum_wr1];
			$in_total[$i] = $row[sum_wr2];
			$date[$i] = substr($row[wr_datetime], 0, 7);
			$i++;
		}
?>

	
<table class="t_ex2">
	<tr><th bgcolor=#E2F2D3 width=50>&nbsp;월&nbsp;</th>
		<?

	for($i=1; $i < 13; $i++) {

		echo "<th class='c1' width=7% align=center> ".$i." </th>";
	}
?><th class="c1" width=7%>Total</th> </tr>
<?

	for($i=0; $i < 12; $i++) {
		
		$check = str_replace("0", "", substr($date[$i], 5, 2));
		$check = $check -1;
		$expen[$check] = $ex_total[$i];
		$incom[$check] = $in_total[$i]; 
		$expen_year = $expen[$check] + $expen_year;
		$incom_year = $incom[$check] + $incom_year;

		}
?>

<tr><td bgcolor=#CCFFFF  align=center>&nbsp;지출&nbsp;</td>
<?

	for($i=0; $i < 12; $i++) {
	
		
if($expen[$i] == "") $expen[$i] =0;
		echo "<td  class='c2' width=7% align=right> ".number_format($expen[$i])."&nbsp;</td>";
			}
?>
<td class='c2'  width=7%>    <?=number_format($expen_year)?>           </td>
</tr><tr><td bgcolor=#FFFF00 align=center>&nbsp;수입&nbsp;</td>
<?

	for($i=0; $i < 12; $i++) {
	
		
if($incom[$i] == "") $incom[$i] =0;
		echo "<td  class='c4' width=7% align=right> ".number_format($incom[$i])."&nbsp;</td>";
			}
?><td width=7% class='c4'>    <?=number_format($incom_year)?>           </td>
</tr>
<tr ><td bgcolor=#CB9696  align=center>&nbsp;balance&nbsp;</td>
<?

	for($i=0; $i < 12; $i++) {
		$balance[$i] = $balance[$i-1] + $incom[$i] + $expen[$i];
	echo "<td  class='c3' width=7% align=right> ".number_format($balance[$i])."&nbsp;</td>";
			}
?><td width=7% class='c3'>  <?    $balance_year = $incom_year +   $expen_year ; echo  number_format($balance_year);  ?></td>
</tr>
</table>



    </td>
</tr>

<tr><td>
		