<?php
$session = new \Zend\Session\Container('userlogin');
$user_id = $session->userData['user_id'];
$adultFare = 0;
$childFare = 0;
$taxFare = 0;
$totaladultFare = 0;
$totalchildFare = 0;
$totalFare = 0;
$totalPrice = 0;
$cartCount = 0;

if (!empty($sessionCartIds)) {
    //echo "Mohit";
    $cartCount = count($sessionCartIds);
    foreach ($sessionCartIds as $val) {
        $data1 = $payData[$val['s_id']];
        //echo '<pre>';print_r($data['tourfaredata']);
        if (!empty($data1['tourfaredata'])) {
            $fareData = json_decode($data1['tourfaredata'], true);
            $adultFare += $fareData[0]['adult_price'];
            $childFare += $fareData[0]['child_price'];
            $totaladultFare = $adultFare * $data['adults'];
            $totalchildFare = $childFare * $data['childs'];
            $totalFare = $totaladultFare + $totalchildFare;

            if ($data1['tax_type'] == 2) {
                if ($data1['tax_per_fixed'] == 1) { // percentage
                    $taxValue = $data1['tax_value'];
                    $taxFare += round(($totalFare * $taxValue) / 100);
                } else {
                    $taxFare += $data1['tax_value'];
                }
            } else {
                $taxFare = 0;
            }
        } else {
            $adultFare = 0;
            $childFare = 0;
            $totaladultFare = 0;
            $totalchildFare = 0;
            $totalFare = 0;
            $taxFare = 0;
        }
    }
    $totalPrice = round($totalFare + $taxFare);
}
/*else {
    if(!empty($vehicleList)){
    $dataArray = current($vehicleList);
    $vehicleList[0] = $dataArray;
//echo '<pre>';print_r($vehicleList[0]);//die();

    if (!empty($vehicleList[0]['tourfaredata'])) {
        $fareData = json_decode($vehicleList[0]['tourfaredata'], true);
        $adultFare = $fareData[0]['adult_price'];
        $childFare = $fareData[0]['child_price'];
        $totaladultFare = $fareData[0]['adult_price'] * $data['adults'];
        $totalchildFare = $fareData[0]['child_price'] * $data['childs'];
        $totalFare = $totaladultFare + $totalchildFare;
    } else {
        $adultFare = 0;
        $childFare = 0;
        $totaladultFare = 0;
        $totalchildFare = 0;
        $totalFare = $totaladultFare + $totalchildFare;
    }

    if ($vehicleList[0]['tax_type'] == 2) {
        if ($vehicleList[0]['tax_per_fixed'] == 1) { // percentage
            $taxFare = round(($totalFare * $vehicleList[0]['tax_value']) / 100);
        } else {
            $taxFare = $vehicleList[0]['tax_value'];
        }
    } else {
        $taxFare = 0;
    }

    $totalPrice = round($totalFare + $taxFare);
    $cartCount = 0;
    }
}*/
?>

<div class="col-md-2 banner-bottom-grid widthpercent20 pull-right payment-div">
    <div style="float: right;"><a href="<?php echo $this->url('sight-seeing', ['action' => 'cart-list']); ?>">Cart (<span class="cart-count"><?php echo $cartCount; ?></span>)</a></div>
    <div class="top-destinations-grids margin0">
        <div class="top-destinations-bottom padding_margin0">
            <div class="td-grids">
                <div class="left-div-form border_bottom">
                    <h4>Payment Detail</h4>
                </div>
                <form id="payment-detail-form">
                    <div class="infopay">

                        <div class="left-div-form">
                            <div class="title">Adult Price</div>
                            <div class="price">
                                <span class=""></span><span class="adult-fare"><?php echo $adultFare; ?></span>
                                <input type="hidden" name="adult_fare" id="adult-fare" value="<?php echo $adultFare; ?>">
                            </div>
                        </div>

                        <div class="left-div-form">
                            <div class="title">Child Price</div>
                            <div class="price">
                                <span class=""></span><span class="child-fare"><?php echo $childFare; ?></span>
                                <input type="hidden" name="child_fare" id="child-fare" value="<?php echo $childFare; ?>">
                            </div>
                        </div>

                        <div class="left-div-form">
                            <div class="title">No of Adults</div>
                            <div class="price">
                                <span class=""></span><span><?php echo $data['adults']; ?></span>
                            </div>
                        </div>

                        <div class="left-div-form">
                            <div class="title">No of Childs</div>
                            <div class="price">
                                <span class=""></span><span><?php echo $data['childs']; ?></span>
                            </div>
                        </div>

                        <div class="left-div-form">
                            <div class="title">Total Adult Price</div>
                            <div class="price">
                                <span class=""></span><span class="total-adult-fare"><?php echo $totaladultFare; ?></span>
                                <input type="hidden" name="total_adult_fare" id="total-adult-fare" value="<?php echo $totaladultFare; ?>">
                            </div>
                        </div>

                        <div class="left-div-form">
                            <div class="title">Total Child Price</div>
                            <div class="price">
                                <span class=""></span><span class="total-child-price"><?php echo $totalchildFare; ?></span>
                                <input type="hidden" name="total_child_price" id="total-child-price" value="<?php echo $totalchildFare; ?>">
                            </div>
                        </div>

                        <div class="left-div-form">
                            <div class="title red_text" title="Only for booking amount">Running Amount</div>
                            <div class="price red_text" title="Only for booking amount"><span class="WebRupee"></span> <span class="running-amt"> <?php echo $totalFare; ?></span> </div>
                            <input type="hidden" name="running_amt" id="running-amt" value="<?php echo $totalFare; ?>">
                        </div>





                        <div class="left-div-form">
                            <div class="title">Tax</div>
                            <div class="price"> <span class="tax-price"><?php echo $taxFare; ?></span> </div>
                            <input type="hidden" name="tax_price" id="tax-price" value="<?php echo $taxFare; ?>">
                        </div>


                        <div class="clear"></div>
                        <div class="left-div-form">
                            <div class="title">Payable Amount</div>
                            <div class="price"> <i class="fa fa-inr"></i> <span class="total-price"><?php echo $totalPrice; ?></span><span id="usdvalue"></span> </div>
                            <input type="hidden" name="total_price" id="total-price" value="<?php echo $totalPrice; ?>">
                        </div>
                        <div class="left-div-form">

                            <div class="radio-inline specs padding-left0 widthpercent100">
                                <div class="radioWrap">
                                    <input type="text" name="coupon_code" placeholder="Coupan Code" class="height34px" id="coupon-code" onClick="">
                                    <input type="hidden" name="coupon_code_id" id="coupon-code-id">
                                    <input type="hidden" name="coupon_discount_type" id="coupon-discount-type">
                                    <input type="hidden" name="coupon_discount_value" id="coupon-discount-value">
                                    <div class="coupon-code-msg"></div>
                                </div>
                                <div class="pull-right">
                                    <div id="apply_coupancode" class="pull-right padding0"><a class="apply-coupon"> Apply</a></div>
                                </div>
                                <div id="coupan_disount"></div>
                                <small id="booklater_conditions_local"></small>
                            </div>
                        </div>
                        <div class="left-div-form">
                            <div class="title"><span class="WebRupee"><b>Discount</b></span></div>
                            <div class="price"><span class="WebRupee"><span class="WebRupee">  </span></span><span class="total-discount">0</span></div>
                            <input type="hidden" name="total_discount" id="total-discount" value="0">
                        </div>
                        <div class="left-div-form">
                            <div class="title"><span class="WebRupee"><b>Total Charge</b></span></div>
                            <div class="price"><span class="WebRupee"><span class="WebRupee"> <i class="fa fa-inr"></i> </span></span><span class="total-charge"><?php echo $totalPrice; ?></span></div>
                            <input type="hidden" name="total_charge" id="total-charge" value="<?php echo $totalPrice; ?>">
                            <input type="hidden" name="currency_type" id="currency-type" value="1">
                        </div>
                        <div class="left-div-form">
                            <!--<label class="booking-check"><a href="javascript: void(0);" class="terms-color" onclick="termsCondition()">Terms & Conditions</a>
                                <input type="checkbox" checked="checked" disabled="">
                                <span class="checkmark"></span>
                            </label>-->


                            <?php if (empty($form->getMessages())) { ?>
                                <div id="accordion_login" class="title widthpercent100">
                                    <?php if (empty($user_id)) { ?>
                                        <div class="overviueimg31"><a class="guestlogin" id="asguest">As a Guest</a></div>
                                        <div class="overviueimg32">or</div>
                                        <div class="overviueimg31"><a href="<?php echo $this->url('login'); ?>" data-target="#ajax-modal" data-toggle="modal" data-remote="true" data-keyboard="false" data-backdrop="static" class="aslogin">As login</a></div>
                                        <div></div>
                                    <?php } else { if($pageType=="list" || $pageType=="detail" ){ ?>
                                        <div class="overviueimg31"><a href="<?php echo $this->url('sight-seeing', ['action' => 'cart-list']); ?>" class="aslogin">Continue</a></div>
                                        <?php } elseif ($cartCount>0 && $pageType=="cart") { ?>
                                        <input type="hidden" id="continue-sight-submit" action="<?php echo $this->url('sight-seeing', ['action' => 'continue-submit']); ?>">
                                        <div class="overviueimg31"><a href="#" class="aslogin continue-sight-submit">Continue</a></div>
                                        <?php }} ?>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </form>
                <div class="clearfix"> </div>
            </div>
        </div>
    </div>
</div>