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