<?php include_once( "../../../spider.inc.php" ); ?>
{charset:UTF-8}
{module:shopping.calendar.Load}

	{if:IS_ERROR}
	<ul class="error">
		{foreach:errors error}
			<li>{write:error}</li>
		{/foreach}
	</ul>
	{else}
	<table class="list" style="width:96%;margin:0 auto;">
	<thead>
	<tr>{foreach:WEEK_DAY_NAME_ARRAY wkey wday}<th style="width:14%;">{write:wday}</th>{/foreach}</tr>
	</thead>
	<tbody>
	<tr>
	<?php for( $num=0; $num<$GLOBALS['shopping.calendar.firstWeekDay']; $num++ ) { ?>
		<td style="height:5em;color:#c0c0c0;background-color:#e0e0e0;"> - </td>
	<?php } ?>
	<?php for( $day=1; $day<=$GLOBALS['shopping.calendar.targetMonthDayCount']; $day++ ) { ?>
		<td style="height:5em;<?php if( !array_key_exists(sprintf('%02d',$day),$GLOBALS['shopping.calendar.scheduleHash']) ) { ?>background-color:#e0e0ef;<?php } ?>;"
			onmouseover="this.orgColor=this.style.backgroundColor;this.style.backgroundColor='#fff0f0'"
			onmouseout="this.style.backgroundColor=this.orgColor;"
		>
			<input type="checkbox" name="target_date[]" value="{write:shopping.calendar.targetYear}-{write:shopping.calendar.targetMonth}-<?php echo sprintf('%02d',$day); ?>"
			><?php echo $day; ?>
			<?php if( count($GLOBALS['shopping.calendar.scheduleHash'][sprintf('%02d',$day)])>0 ){ ?>
			<div style="font-size:x-small;text-align:center;">
			<?php foreach( $GLOBALS['shopping.calendar.scheduleHash'][sprintf('%02d',$day)] as $row ) { ?>
				<?php echo date('H:i',strtotime($row['start_date'])); ?>-<?php echo date('H:i',strtotime($row['close_date'])); ?>[<a
				href="javascript:shoppingCalendarDeleteTime(<?php echo $row['schedule_number']; ?>)"
				>x</a>]
			{if:is_object(shopping.product.unit.unit_object)}
			<?php if(strlen($row['price_sell'])>0) { ?>
				<?php echo number_format($row['price_sell']); ?>円
			<?php } else { ?>
				{write:number_format(shopping.product.unit.unit_object->'price_sell')}円
			<?php } ?>
			<?php if(strlen($row['stock'])>0) { ?>
				<?php echo number_format($row['stock']); ?>{write:shopping.product.unit.unit_object->'unit_string'}
			<?php } else { ?>
				{write:shopping.product.unit.unit_object->getStock(request)}{write:shopping.product.unit.unit_object->'unit_string'}
			<?php } ?>
			{/if}
			<?php } ?>
			</div>
			<?php } ?>
		</td>
		<?php $num++; if( $num % 7 == 0 ) { ?></tr><tr><?php } ?>
	<?php } ?>
	<?php for( $day=1; $day<7 && $num%7!=0; $day++ ) { ?>
		<td style="height:5em;color:#c0c0c0;background-color:#e0e0e0;"><?php echo $day; ?></td>
		<?php $num++; ?>
	<?php } ?>
	</tr>
	</tbody>
	</table>
	{/if}