<?
include_once("./_common.php");
if($excel == "y") {
 $title = "Report";
 header( "Content-type: application/vnd.ms-excel" );  
 header( "Content-Disposition: attachment; filename=".date("dmYmsh").".xls");  
// $title 변수명으로 저장됩니다. 원하는 이름으로 바꾸세요
 header( "Content-Description: PHP4 Generated Data" );
}
?>
<style type="text/css">
<!--
body {
font: small Verdana, Geneva, Arial, Helvetica, sans-serif;
color: #666666;
background-color: #ffffff;
border: 1px solid #999999;
}
td {font-size: 8pt;}
th {font-size: 8pt;}
-->
</style>
<link rel="stylesheet" href="./css.css" />  
<script src="<?=$g4[path]?>/js/jquery-1.9.1.js"></script>  
<script src="<?=$g4[path]?>/js/jquery-ui.js"></script>  

<script>  $(function() {
$( "#from" ).datepicker({dateFormat:"dd-mm-yy", numberOfMonths: 2, showButtonPanel: true});
$( "#end" ).datepicker({dateFormat:"dd-mm-yy", numberOfMonths: 2, showButtonPanel: true});
});  
</script>
<script language=javascript>
  function win_print() {
              self.print();
  }
</script> 
<? if($print== "y") { ?>
<body onload="javascript:win_print()" oncontextmenu="return false" onselectstart="return false" ondragstart="return false"> 
<? } ?>
<table width=100% cellpadding="5" cellspacing="0" border="1" align="center" style="border-collapse:collapse; border:1px gray solid;">
<col width="30" />

    
    <col width="10%" />
    <col width="10%" />

    <col width="10%" />
    <col width="10%" />
<col  />
    <col width="10%" />
    <col width="10%" />
    <col width="8%" />

	<tr>
        <th colspan=18  align=center>
	<table >
	<form id="inputForm" action="print.php" method="POST">
	<tr>
	<td  align=center>Date to print From <input type="text" id=from name="from" readonly> End <input  id=end type="text" name="end" readonly> </form><input type="submit" value="List up"/>
</td>	<td  width=130 align=center><a href="print.php?print=y"> Print </a>
</td><td width=200  align=center><a href="print.php?excel=y">Export to excel</a></td>
	</tr>
	</table>
	</td>
	</tr>
	<tr bgcolor=#CCFFCC>
        <th><img src="./img/list_no.gif" border='0'></th>

       <th>Expenses</th>
        <th>Income</th>
        <th>Balance </a></th>
        <th>Category </a></th>
	    <th>Description of Expense</th>
        <th>Debit/CC/Check </th>
        <th>Name </th>
        <th>Date</th>

    </tr>
<tr>
	<td>
<?
if($from != "" && $end != "") {
$from_sep = explode("-", $from);
$end_sep = explode("-", $end);
$from = $from_sep[2]."-".$from_sep[1]."-".$from_sep[0]." 00:00:00";
$end = $end_sep[2]."-".$end_sep[1]."-".$end_sep[0]." 00:00:00";
$i=1;
$query5 = "select * from g4_write_finance where wr_datetime BETWEEN '$from' AND '$end'   ";
$result5 = sql_query($query5);
while($row  = sql_fetch_array($result5)) {
	?>

<tr>
	<td align=center><?=$i?></td>

	<td  align=center><?=$row[wr_1]?></td>
	<td  align=center><?=$row[wr_2]?></td>
	<td  align=center><?=$row[wr_3]?></td>
	<td align=center><?=$row[wr_subject]?></td>
	<td  align=center><?=$row[wr_4]?></td>
	<td  align=center><?=$row[wr_5]?></td>
	<td  align=center><?=$row[wr_6]?></td>

<? 
			$date_sep = explode(" ", $row[wr_datetime]);
			$date_exp = explode("-", $date_sep[0]);
			$local_date = $date_exp[2]."-".$date_exp[1]."-".$date_exp[0]." ".$date_sep[1];
			?>
        <td class="datetime" ><?=$local_date?></td>
	


</tr>

	<?
	$i++;
}
	}
?>
</td>
	
</tr>
</table>

