<?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}

	{set:productObject shopping.product.unit.unit_object->'shoppingProductObject'}

{if:IS_ERROR}
	<ul class="error">
	{foreach:errors error}
		<li>{write:error}</li>
	{/foreach}
	</ul>
	<br />
{else}

	{set:fileIdArray shopping.product.unit.unit_object->'fileIdArray'}
	{set:productFileIdArray productObject->'fileIdArray'}

	<!-- {write:SHOPPING_LABEL_PRODUCT}名 表示	-->
	<h1>{write:productObject->'product_name'} {write:shopping.product.unit.unit_object->'unit_name'}</h1>
	<p>予約ご希望のご利用日時にチェックを入れて予約するボタンをクリックしてください。</p>
	{set:maxStock shopping.product.unit.unit_object->getStock(request)}
	<form name="calsform" method="get" action="./index.php">
	<input type="hidden" name="shpdi" value="{write:shopping.calendar.productId}" />
	<input type="hidden" name="shpui" value="{write:shopping.calendar.unitId}" />
	<div style="width:96%;margin:0 auto;font-size:large;">
		<select name="sclty" onchange="shoppingCalendarRenew();">
		<?php for( $year = date('Y')+1; $year>date('Y')-3; $year-- ) { ?>
			<option value="<?php echo $year; ?>"
				<?php if($year==$GLOBALS['shopping.calendar.targetYear'] ) { ?> selected<?php } ?>
			><?php echo $year; ?></option>
		<?php } ?>
		</select>年<select name="scltm" onchange="shoppingCalendarRenew();">
		<?php for( $month = 1; $month<=12; $month++ ) { ?>
			<option value="<?php echo $month; ?>"
				<?php if($month==$GLOBALS['shopping.calendar.targetMonth'] ) { ?> selected<?php } ?>
			><?php echo $month; ?></option>
		<?php } ?>
		</select>月
	</div>
	<div style="width:96%;margin:0 auto;text-align:right;">
		<a href="javascript:shoppingCalendarCheckAllOn()">全て選択</a>
		/
		<a href="javascript:shoppingCalendarCheckAllOff()">全て解除</a>
		/
		<a href="javascript:shoppingCalendarCheckAllRev()">選択反転</a>
	</div>
	</form>

	<form name="mform" method="post" action="./order/purchaser.php">
	<input type="hidden" name="product_id" value="{write:shopping.calendar.productId}" />
	<input type="hidden" name="unit_id" value="{write:shopping.product.unit.unit_object->'unit_id'}" />
	<input type="hidden" name="order_count" value="1" />
	<input type="hidden" name="address_order" value="0" />
	<input type="hidden" name="command" value="" />
	<div id="shopping-calendar-area">
	<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>
	</div>
	<p style="text-align:right;">
		単価&yen;<input type="text" name="price_unit" size="8" value="{write:shopping.product.unit.unit_object->'price_sell'}" style="text-align:right;" />で
		<input type="button" value="予約する" onclick="shoppingCalendarGoReserve();" />
	</p>
	<p style="text-align:right;">
		<input type="button" value="キャンセル" onclick="shoppingOrderViewCalendarPanelClose()" />
	</p>
	</form>

<style type="text/css"><!--
table.calendar {
}
table.calendar thead tr th {
	border: solid 1px #c0c0c0;
	padding: 3px;
	background-color: #e0e0e0;
}
table.calendar tbody tr td {
	vertical-align: top;
}
//--></style>
{/if}
