<script>
	$('#name_page_cat').html('{MY_LAST_BUY_LABEL} <?php echo date('d/m/Y',(time()-(3600*24*30))); ?> - <?php echo date('d/m/Y'); ?>');
</script>

<script type="text/javascript">
	function showPurchase(id){
		if($('#table-content-'+id).is(':visible')){
			$('#table-content-'+id).hide();
			$('#show-purchase-button-'+id).removeClass('show-purchase-button-open');
			$('#show-purchase-button-'+id).addClass('show-purchase-button-close');
		}else{
			$('#table-content-'+id).show();
			$('#show-purchase-button-'+id).removeClass('show-purchase-button-close');
			$('#show-purchase-button-'+id).addClass('show-purchase-button-open');
		}
		
	}
</script>

<div class="purchaseHeadline">
	<h1>
		<span><?php echo date('d/m/Y',(time()-(3600*24*30))); ?> - <?php echo date('d/m/Y'); ?></span>{MY_LAST_BUY_LABEL}</h1>
	</div>
	<div class="purchaseArea">
		<div class="surroundingDynContent">
			<div class="purchasesContent">
				<?php
	$LIST_DATE = array();
	$LIST_DATE_TIME = array();
	$GET_DATE = mysqli_query(ConnectiShopDb(),"SELECT date from ".ISHOP_MYSQL_DB.".buy_log where account_id=('".$_SESSION['ISHOP_SESSION_ID']."') order by date DESC");
		while($row = mysqli_fetch_array($GET_DATE)){
			$DATE = date('d/m/Y',$row['date']);
			$DATE_TIME = date('d-m-Y',$row['date']);
			$LIST_DATE[] = $DATE;
			$LIST_DATE_TIME[] = strtotime($DATE_TIME);
		}
		
		$LIST_DATE = array_unique($LIST_DATE);
		$LIST_DATE_TIME = array_unique($LIST_DATE_TIME);
		foreach($LIST_DATE as $id => $date){
		?>
		
		<div class="purchase-item">
					<div class="purchase-date-header-bg">
						<div class="purchase-date-header-img">
							<?php if ($id == 0){ ?>
							<a href="javascript:showPurchase(<?php echo $id; ?>);" class="show-purchase-button-open" id="show-purchase-button-<?php echo $id; ?>">{ITEM_BUY_THE_LABEL} <?php echo $date; ?></a>
							<?php } else { ?>
							<a href="javascript:showPurchase(<?php echo $id; ?>);" class="show-purchase-button-close" id="show-purchase-button-<?php echo $id; ?>">{ITEM_BUY_THE_LABEL} <?php echo $date; ?></a>
							<?php } ?>
						</div>
					</div>
					<?php if ($id == 0){ ?>
							<div class="purchase-dyn-content" id="table-content-<?php echo $id; ?>">
							<?php } else { ?>
							<div class="purchase-dyn-content" id="table-content-<?php echo $id; ?>" style="display:none;">
							<?php } ?>
					
						<table class="purchase-table">
						<?php 
							$QUERY_ITEM = mysqli_query(ConnectiShopDb(),"SELECT *, SUM(item_count) as item_total_count from ".ISHOP_MYSQL_DB.".buy_log where date >= '".$LIST_DATE_TIME[$id]."' and date < '".($LIST_DATE_TIME[$id]+(3600*24))."' and account_id=('".$_SESSION['ISHOP_SESSION_ID']."') GROUP by item_id,item_count HAVING item_total_count ORDER by date DESC");
							while($row = mysqli_fetch_array($QUERY_ITEM)){
								$TEXT_REPLACE['DC'] = "{MONEY_SHORT_NAME}";
								$TEXT_REPLACE['MD'] = "{SECOND_MONEY_SHORT_NAME}";
								$SELECT_ITEM_INFOS = mysqli_fetch_array(mysqli_query(ConnectiShopDb(),"SELECT * from ".ISHOP_MYSQL_DB.".item_list where item_id=('".$row['item_id']."') LIMIT 1"));
								if($SELECT_ITEM_INFOS['item_id']){ 
						?>
							<tr class="row">
								<td class="img-col">
									<div>
										<img class="item-img" src="<?php echo $SELECT_ITEM_INFOS['item_img']; ?>" alt="<?php echo utf8_encode($SELECT_ITEM_INFOS['item_name']); ?>"/>
									</div>
								</td>
								<td class="col">
									<span class="purchase-article-name"><?php echo $row['item_total_count']; ?> x <?php echo utf8_encode($SELECT_ITEM_INFOS['item_name']); ?></span>
									<span class="line">
									</span>
									<?php echo utf8_encode(nl2br($SELECT_ITEM_INFOS['item_desc'])); ?></td>
								<td class="buy-col">
									<div class="purchaseOptionsWrapper">
										<div class="itemPrice">
											<div class="priceValue"><?php echo $SELECT_ITEM_INFOS['item_count']; ?> {FOR_LABEL} :<span class="price">&nbsp;<?php echo $SELECT_ITEM_INFOS['item_price']; ?> <?php echo $TEXT_REPLACE[$SELECT_ITEM_INFOS['item_type']]; ?></span>
										</div>
									</div>
									<a href="./ajax/display_item_infos/<?php echo $SELECT_ITEM_INFOS['item_id']; ?>/" title="{MORE_INFORMATION_LABEL}" class="purchaseInfo openinformation">
									{DETAIL_LABEL}    </a>
									<br class="clearfloat" />
								</div>
								</td>
							</tr>
							<?php
							}
							}
							
							?>
					</table>
				</div>
				<div class="purchase-endContent">
				</div>
			</div>
		
		
		
		<?php
		}
?>
		</div>
		<div class="surroundingEndContent">
		</div>
	</div>
	</div>
	<div class="overviewButtonArea">
		<a class="gotoOverview" href="./my_account/">{PLAYER_DATA_STRING}</a>
	</div>