<?php
include(dirname(__FILE__) . '/../header1.php');
?>
<link rel="stylesheet" href="<?php echo base_url() ?>js/jquery/themes/base/jquery.ui.all.css">
<script src="<?php echo base_url() ?>js/jquery/jquery-1.4.2.js"></script>
<script src="<?php echo base_url() ?>js/jquery/ui/jquery.ui.core.js"></script>
<script src="<?php echo base_url() ?>js/jquery/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url() ?>js/jquery/ui/jquery.ui.datepicker.js"></script>
<script src="<?php echo base_url() ?>js/jquery/ui/i18n/jquery.ui.datepicker-ja.js"></script>
	<script>
	$(function() {
		$("#datepicker").datepicker({dateFormat: 'yy-mm-dd'});
	});
	</script>
	<script>
    function room_num_onChange()
    {
        set_room_table();
    }
    
    function set_room_table()
    {
        var room_num = parseInt(document.myform.room_num.value);
        //alert(room_num);
        for (i = 1;; i++)
        {
            var id = 'room_' + i;
            var obj = document.getElementById(id);
            if (obj == null)
            {
                break;
            }
            if (i <= room_num)
            {
                obj.style.display = "block";
            }
            else
            {
                obj.style.display = "none";
            }
        }
    }
    </script>
<?php
$body_js = 'onLoad="set_room_table()"';
include(dirname(__FILE__) . '/../header2.php');
?>
<image src="<?php echo site_url('images/step1.png') ?>">

<h2>宿泊内容入力</h2>

<?php
if (isset($error) && count($error))
{
    echo '<div class="form_error"><ul>' . "\n";
    foreach ($error as $err)
    {
        echo "<li>" . $err . "</li>" . "\n";
    }
    echo '</ul></div>' . "\n";
}
?>

<?php echo form_open('res/index/' . $hotelid . '/' . $planid . '/' . $d, array('name' => 'myform')); ?>

<table class="inp">
<tr>
<th>プラン :</th>
<td><?php echo $plan_name . '(' . $guest_min . '～' . $guest_max . '人)'; ?></td>
</tr>
<tr>
<th>チェックイン日 :</th><td>
<?php
$s_cin = substr($d, 0, 4) . '-' . substr($d, 4, 2) . '-' . substr($d, 6, 2);
echo $s_cin;
echo ' (' . $this->Common_model->week($s_cin) . ')';
?></td></tr>
<tr><th>* チェックアウト日 :</th>
<td>
<input type="text" name="cout" id="datepicker" value="<?php echo set_value('cout', isset($cout) ? $cout : ''); ?>" size="30" />
<?php echo form_error('cout'); ?>
</td></tr>
<tr><th>部屋タイプ :</th>
<td>
<?php echo $roomtype_name . '(' . $roomtypes_guest_min . '～' . $roomtypes_guest_max . '人)'; ?>
</td></tr>
<tr><th>* 部屋数 :</th>
<td>
<?php
$guest_options = array();
for ($i = 0; $i <= $guest_max; $i++)
{
    $guest_options[$i] = $i;
}
$room_options = array();
for ($i = 1; $i <= $max_rooms; $i++)
{
    $room_options[$i] = $i;
}
$js = 'id="room_num" onChange="room_num_onChange();"';
$value = set_value('room_num', isset($room_num) ? $room_num : '');
echo form_dropdown('room_num', $room_options, $value, $js) . ' 部屋';
?>
<?php echo form_error('room_num'); ?>
</td></tr>
<tr><th>* 人数 :</th><td>
<?php
$_basic_num = set_value('basic_num[]');
$_child1_num = set_value('child1_num[]');
$_child2_num = set_value('child2_num[]');
$_child3_num = set_value('child3_num[]');
$_child4_num = set_value('child4_num[]');
for ($i = 0; $i < $max_rooms; $i++)
{
    if (isset($_basic_num[$i]))
    {
        $basic_num = $_basic_num[$i];
        $child1_num = $_child1_num[$i];
        $child2_num = $_child2_num[$i];
        $child3_num = $_child3_num[$i];
        $child4_num = $_child4_num[$i];
    }
?>
<table class="table_temp" id="room_<?php echo ($i + 1); ?>">
<th><tr>
<td><?php echo ($i + 1) . '部屋目 :' ?></td>
<td>大人:</td><td>
<?php echo form_dropdown('basic_num[]', $guest_options, $basic_num) . ' 人'; ?>
</td><td>
子供A:</td><td>
<?php echo form_dropdown('child1_num[]', $guest_options, $child1_num) . ' 人'; ?>
</td><td>
子供B:</td><td>
<?php echo form_dropdown('child2_num[]', $guest_options, $child2_num) . ' 人'; ?>
</td><td>
子供C:</td><td>
<?php echo form_dropdown('child3_num[]', $guest_options, $child3_num) . ' 人'; ?>
</td><td>
子供D:</td><td>
<?php echo form_dropdown('child4_num[]', $guest_options, $child4_num) . ' 人'; ?>
</td></tr></table>
<?php
}
?>
<?php echo form_error('basic_num[]'); ?>
<?php echo form_error('child1_num[]'); ?>
<?php echo form_error('child2_num[]'); ?>
<?php echo form_error('child3_num[]'); ?>
<?php echo form_error('child4_num[]'); ?>
</td>
</tr>
</table>
<input type="submit" name="mysubmit" value="見積もりへ進む" />

</form>

<?php
include(dirname(__FILE__) . '/../footer.php');
?>
