<?php include_once( "../../../../spider.inc.php" ); ?>
{module:shopping.category.LoadList}
{module:shopping.flag.LoadList}
{module:shopping.product.unit.Load}
{module:shopping.calendar.Load force}
{module:shopping.product.unit.LoadOrderItems}
	{if:IS_ERROR}
		<h2>エラー</h2>
		<ul class="error">
		{foreach:errors error}
			<li>{write:error}</li>
		{/foreach}
	</ul>
	{else}
	{set:maxStock shopping.product.unit.unit_object->getStock(request)}
	<table class="calendar" style="width:96%;margin:0 auto;">
	<thead>
	<tr>{foreach:WEEK_DAY_NAME_ARRAY wkey wday}<th>{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( $GLOBALS['page.day']=1; $GLOBALS['page.day']<=$GLOBALS['shopping.calendar.targetMonthDayCount']; $GLOBALS['page.day']++ ) { ?>
		<td style="height:5em;<?php if( !array_key_exists(sprintf('%02d',$GLOBALS['page.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;"
		>
			{set:realStock maxStock-shopping.product.unit.orderedCountHash[sprintf('%02d',page.day)]}
			<input type="hidden" name="page_date[]" value="{write:targetDate}" />
			<?php if( !array_key_exists(sprintf('%02d',$GLOBALS['page.day']),$GLOBALS['shopping.calendar.scheduleHash'])) { ?>
				×
			<?php } else if( $GLOBALS['realStock']<=0 ) { ?>
				×
			<?php } else { ?>
			{set:targetDate shopping.calendar.targetYear . '-' . shopping.calendar.targetMonth . '-' . sprintf('%02d', page.day)}
			<input type="checkbox" name="target_date[]" value="{write:targetDate}"
			{if:in_array(targetDate,shopping.order.selectedDateHash[shopping.product.unit.unit_object->'unit_id'])} checked{/if}
			><?php } ?><?php echo $GLOBALS['page.day']; ?>
			<div style="text-align:center;">
			<?php if( !array_key_exists(sprintf('%02d',$GLOBALS['page.day']),$GLOBALS['shopping.calendar.scheduleHash']) ) { ?>
				休業日
			<?php } else { ?>
				空{write:realStock}室
			<?php } ?>
			</div>
		</td>
		<?php $num++; if( $num % 7 == 0 ) { ?></tr><tr><?php } ?>
	<?php } ?>
	<?php for( $GLOBALS['page.day']=1; $GLOBALS['page.day']<7 && $num%7!=0; $GLOBALS['page.day']++ ) { ?>
		<td style="height:5em;color:#c0c0c0;background-color:#e0e0e0;"><?php echo $GLOBALS['page.day']; ?></td>
		<?php $num++; ?>
	<?php } ?>
	</tr>
	</tbody>
	</table>
	{/if}