<?php
include(dirname(__FILE__) . '/../header.php');
?>
<image src="<?php echo site_url('images/step2.png') ?>">
<h2>お見積もり</h2>
<?php
$reservation = $this->phpsession->get('reservation');
$reservation_detail = $this->phpsession->get('resrooms');
//var_dump($resrooms);
$resoptions = $this->phpsession->get('resoptions');
?>
<table class="inp">
<tr><th width="200px">チェックイン :</th>
<td>
<?php
$s_cin = $reservation['cin'];
echo $s_cin;
echo ' (' . $this->Common_model->week($s_cin) . ')';
?>
</td></tr>
<tr><th>チェックアウト :</th>
<td>
<?php
$s_cout = $reservation['cout'];
echo $s_cout;
echo ' (' . $this->Common_model->week($s_cout) . ')';
?></td>
</tr>

<tr><th>宿泊日数 :</th>
<td>
<?php
echo $reservation['stay_days'] . ' 日';
?>
</td></tr>

<tr>
<th>プラン :</th>
<td><?php echo $plan_name ?></td>
</tr>
<tr><th>部屋タイプ :</th>
<td>
<?php echo $roomtype_name . ' (' . $roomtypes_guest_min . '～' . $roomtypes_guest_max . '人)'; ?>
</td></tr>
<tr>
<th>部屋数 :</th>
<td><?php echo $reservation['room_num'] . '部屋'; ?></td>
</tr>
<tr>
<th>人数 :</th>
<td>
<?php
for ($i = 0; $i < $reservation['room_num']; $i++)
{
    $room_i = $resrooms[$i];
    echo $room_i['room_no'] . '部屋目' . "<br />\n";
    if ($room_i['basic_num'] > 0)
    {
        echo "大人:"  . $room_i['basic_num']  . "人&nbsp;";
    }
    if ($room_i['child1_num'] > 0)
    {
        echo "子供A:" . $room_i['child1_num'] . "人&nbsp;";
    }
    if ($room_i['child2_num'] > 0)
    {
        echo "子供B:" . $room_i['child2_num'] . "人&nbsp;";
    }
    if ($room_i['child3_num'] > 0)
    {
        echo "子供C:" . $room_i['child3_num'] . "人&nbsp;";
    }
    if ($room_i['child4_num'] > 0)
    {
        echo "子供D:" . $room_i['child4_num'] . "人";
    }
    echo "<br />\n";
}
?></td>
</tr>
<tr>
<th>料金 :</th>
<td>
<?php
$resrooms = $this->phpsession->get('resrooms');
//var_dump($resrooms);
$strDay = '';
foreach ($resrooms as $room_i)
{
    if ($strDay != $room_i['day'])
    {
        echo $room_i['day'] . "<br />\n";
        $strDay = $room_i['day'];
    }
    echo $room_i['room_no'] . '部屋目' . "<br />\n";
    if ($room_i['basic_num'] > 0)
    {
        echo "・大人 : ";
        $temp = $room_i['basic_num'] * $room_i['basic_price'];
        echo $room_i['basic_num'] . '人 x ' . number_format($room_i['basic_price']) . '円 = ' . number_format($temp) . '円' . "<br />\n";
    }
    if ($room_i['child1_num'] > 0)
    {
        echo "・子供A : ";
        $temp = $room_i['child1_num'] * $room_i['child1_price'];
        echo $room_i['child1_num'] . '人 x ' . number_format($room_i['child1_price']) . '円 = ' . number_format($temp) . '円' . "<br />\n";
    }
    if ($room_i['child2_num'] > 0)
    {
        echo "・子供B : ";
        $temp = $room_i['child2_num'] * $room_i['child2_price'];
        echo $room_i['child2_num'] . '人 x ' . number_format($room_i['child2_price']) . '円 = ' . number_format($temp) . '円' . "<br />\n";
    }
    if ($room_i['child3_num'] > 0)
    {
        echo "・子供C : ";
        $temp = $room_i['child3_num'] * $room_i['child3_price'];
        echo $room_i['child3_num'] . '人 x ' . number_format($room_i['child3_price']) . '円 = ' . number_format($temp) . '円' . "<br />\n";
    }
    if ($room_i['child4_num'] > 0)
    {
        echo "・子供D : ";
        $temp = $room_i['child4_num'] * $room_i['child4_price'];
        echo $room_i['child4_num'] . '人 x ' . number_format($room_i['child4_price']) . '円 = ' . number_format($temp) . '円' . "<br />\n";
    }
}
?>
</td>
</tr>

<?php
if (count($resoptions) > 0) {
?>

<tr>
<th>オプション :</th>
<td>
<?php
//var_dump($resoptions);
foreach ($resoptions as $key => $value)
{
    echo $key . "<br />\n";
    foreach ($value as $key2 => $value2)
    {
        if ($value2['num'] > 0)
        {
            echo $value2['option_name'] . ':';
            echo number_format($value2['price']) . '円' . " x ";
            echo $value2['num'] . " " . $value2['unitname'] . " = ";
            $option_subtotal = $value2['price'] * $value2['num'];
            echo number_format($option_subtotal) . '円' . "<br />\n";
        }
    }
}
?>
</td></tr>

<?php
}
?>

<tr>
<th>合計 :</th>
<td>
<?php echo number_format($reservation['total_price']) . "円"; ?>
</td>
</tr>
</table>

<?php
$system = $this->phpsession->get('system');
if ($isloggedin == false)
{
    // 非ログイン時
    if (isset($system['ssl']) && $system['ssl'] == 'true')
    {
        echo '<a href="' . site_url('res/login/' . $hotelid, true) . '">ログイン</a>' . "&nbsp;/&nbsp";
        echo '<a href="' . site_url('res/userinp/' . $hotelid, true) . '">未登録で予約する</a>' . "&nbsp;/&nbsp";
    }
    else
    {
        echo '<a href="' . site_url('res/login/' . $hotelid) . '">ログイン</a>' . "&nbsp;/&nbsp";
        echo '<a href="' . site_url('res/userinp/' . $hotelid) . '">未登録で予約する</a>' . "&nbsp;/&nbsp";
    }
}
else
{
    // ユーザログイン時
    if (isset($system['ssl']) && $system['ssl'] == 'true')
    {
        echo '<a href="' . site_url('res/userinp/' . $hotelid, true) . '">お客様情報入力へ進む</a>' . "<br />";
    }
    else
    {
        echo '<a href="' . site_url('res/userinp/' . $hotelid) . '">お客様情報入力へ進む</a>' . "<br />";
    }
}
?>

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