<?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>
		<th>日付</th>
	<?php for( $GLOBALS['page.hour']=9; $GLOBALS['page.hour']<19; $GLOBALS['page.hour']++ ) { ?>
		<th style="font-size:x-small;font-weight:100;">{write:sprintf('%02d',page.hour)}:00</th>
	<?php } ?>
	</tr>
	</thead>
	<tbody>
	<?php for( $GLOBALS['page.day']=1; $GLOBALS['page.day']<=$GLOBALS['shopping.calendar.targetMonthDayCount']; $GLOBALS['page.day']++ ) { ?>
	{set:dayOpenTimes shopping.calendar.scheduleHash[sprintf('%02d',page.day)]}
	{set:targetTime strtotime( shopping.calendar.targetYear . '-' . shopping.calendar.targetMonth . '-' . page.day . ' 12:00:00' )}
	{if:page.day>1 && date('w',targetTime)==1}
	</tbody>
	<thead>
	<tr>
		<th>日付</th>
	<?php for( $GLOBALS['page.hour']=9; $GLOBALS['page.hour']<19; $GLOBALS['page.hour']++ ) { ?>
		<th style="font-size:x-small;font-weight:100;">{write:sprintf('%02d',page.hour)}:00</th>
	<?php } ?>
	</tr>
	</thead>
	<tbody>
	{/if}
	<tr>
		<th style="{if:date('w',targetTime)==0}background-color:#fff0f0;{else-if:date('w',targetTime)==6}background-color:#f0f0ff;{/if}">
			{write:page.day}日({write:WEEK_DAY_NAME_ARRAY[date('w',targetTime)]})
		</th>
		<?php for( $GLOBALS['page.hour']=9; $GLOBALS['page.hour']<19; $GLOBALS['page.hour']++ ) { ?>
		{set:targetTime strtotime( shopping.calendar.targetYear . '-' . shopping.calendar.targetMonth . '-' . page.day . ' ' . sprintf('%02d',page.hour) . ':00:00' )}
		{set:isOpen 'false'}{if:is_array(dayOpenTimes)}{foreach:dayOpenTimes openInfo}{if:strtotime(openInfo['start_date'])<=targetTime && strtotime(openInfo['close_date'])>targetTime}{set:isOpen 'true'}{/if}{/foreach}{/if}
		<td{if:isOpen=='true'}{else} style="background-color:#c0c0c0;"{/if}>
			<input type="hidden" name="page_date[]" value="{write:date('Y-m-d H:i:s',targetTime)}" />
			{if:isOpen=='true'}
			{set:realStock maxStock-shopping.product.unit.orderedCountHash[sprintf('%02d',page.day)][date('Hi',targetTime)]}
				{if:realStock>0}
				<input type="checkbox" name="target_date[]" value="{write:date('Y-m-d H:i:s',targetTime)}"
					{if:in_array(date('Y-m-d H:i:s',targetTime),shopping.order.selectedDateHash[shopping.product.unit.unit_object->'unit_id'])} checked{/if}
				>
				{else}×{/if}
			{else}-{/if}
		</td>
		<?php } ?>
	</tr>
	<?php } ?>
	</tbody>
	</table>
	{/if}