<?php
include("includes/site_info.php");
include('session_handler.inc');

$WUserID = $_SESSION['Sess_UserId'];
$WUsername = $_SESSION['Sess_UserName'];

$now = getdate();
$initial_date = date ("Y-m-d H:i:s", mktime (0,0,0,$now['mon'],1,$now['year'])); //current month
$final_date = date ("Y-m-d H:i:s", mktime (23,59,59,$now['mon']+1,0,$now['year']));

	$date_str="and ((date_submitted >= '$initial_date' and date_submitted <= '$final_date')";
	$date_str.=" or (date_submitted <= '$initial_date' and date_submitted >= '$final_date'))";	

$sql2="select *,DATE_FORMAT(date_submitted, '%b %d, %Y') as t from transactions where mem_userid=$WUserID $date_str order by date_submitted";
//echo $sql2;
$query=mysql_query($sql2);
$bank_TOTAL=mysql_num_rows($query);
?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
});
</script>

<div class="p5 width_700">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb">
		<tr class="p0">
			<td><form action="" method="post" name="formAccount" id="formAccount">
				<div id="AccountSearch">
					<fieldset>
					<p>
						<label for="dateoptions">SelectDateRange</label>
						<input id="dateoptions" <?php if ($_REQUEST["dateoption"] == "dateselect") echo "checked=\"checked\"";?> name="dateoption" value="dateselect" type="radio" />
					</p>
					<p>
						<label for="from_date">From</label>
						<input autocomplete="off" maxlength="10" size="15" id="from_date" name="from_date" value="<?=$from_date?>" type="text" class="datepicker" />
						<script type="text/javascript">
                new Control.DatePicker('from_date', { locale : '<?=tep_get_langCode($_SESSION['lang_id'])?>', icon: 'js/datePicker/calendar.png' });
            </script>
					</p>
					<p>
						to
					</p>
					<p>
						<label for="to_date">To</label>
						<input autocomplete="off" maxlength="10" size="15" id="to_date" name="to_date" value="<?=$to_date?>" type="text" />
						<script type="text/javascript">
                new Control.DatePicker('to_date', { locale : '<?=tep_get_langCode($_SESSION['lang_id'])?>', icon: 'js/datePicker/calendar.png' });
            </script>
					</p>
					<input disabled="disabled" id="show" name="show" value="Show" type="submit" class="submit" />
					</fieldset>
				</div>
			</form></td>
		</tr>
		<tr class="grey_12 orange_row_back solid_line_separator">
			<td><div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div> </td>
		</tr>
		<tr>
			<td><table width="100%" border="0" cellpadding="5" cellspacing="1" id="structureTable">
					<tr>
						<th width="15%" align="left">Date</th>
						<th width="55%" align="left">Description</th>
						<th width="10%" align="left">Status</th>
						<th width="10%" align="left">Amount</th>
					</tr>
					<?php if ($bank_TOTAL > 0) { 
							while($rs_query=mysql_fetch_object($query)) { ?>
					<tr id="<?=$rs_query->id?>">
						<td valign="baseline" nowrap="nowrap"><?=$rs_query->t?></td>
						<td valign="baseline"><?=$rs_query->description?></td>
						<td valign="baseline" nowrap="nowrap"><?=$rs_query->pstatus?></td>
						<td valign="baseline" nowrap="nowrap"><?=$rs_query->ptype?> <?=$rs_query->amount?></td>
					</tr>
					<?php } } else {?>
					<tr>
						<td colspan="4">No transactions that meet your criteria.</td>
					</tr>
					<?php } ?>
				</table></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>
</div>
