@extends('includes.master')
@section('title', 'Membership Form')

@section('style-section')
    <link rel="stylesheet" href="{{ asset('assets/css/membership-plan.css') }}">
@endsection
@php
    $cartList = session('membership_cart');
    $cart_count = isset($cartList['service_id']) && $cartList['service_id'] ? 1 : 0;
    $cart_count = $cart_count != '' ? $cart_count : 0;
    if (empty($cartList['service_id'])) {
        $cartList = ['totalPrice' => 0.0, 'service_id' => ''];
    }
    $fgh = getFullPaymentSettings();
    // dd($fgh);
    // die();
    $dsbj = $fgh['result']['data'][0]['paymentGatewayoffon'];
    foreach ($dsbj as $key => $dd) {
        if ($dd['source'] == 'WEBSITE') {
            $paymentSeverOn = $dd['isenable'];
            $paymentSeverText = $dd['desc'];
        }
    }

    $paymentSetting = @getPaymentGatewaySettings();

    if (session('logged_in') == 1) {
        $current_user = @getUserDetails()->data[0];
    }

    $getclientInfoById = @getclientInfoById()['data'][0];

    $CAW_MerchantId = @$getclientInfoById['ChargeAnywhereMerchantId'];
    $CAW_TerminalId = @$getclientInfoById['ChargeAnywhereTerminalId'];

@endphp
@section('content')
    <!-- ======= Temple Services Section ======= -->
    <section id="temple-services" class="temple-services"
        style="background-image: url({{ asset('assets/img/elegant-background-with-mandala.png') }});background-size: auto;">
        <center>
            <h2 class="text-center mb-0"
                style="font-weight:bold!important;font-size: 2em!important;text-shadow: 1px 1px 5px #FA9D1E;padding:20px;">
                Membership Plans<br />
                <img src="{{ asset('assets/img/border.png') }}" width="20%">
            </h2>
        </center>
        <span hidden class="cart-count">{{ $cart_count }}</span>
        <?php
        $color = ['#40CBB4', '#1D95D2', '#FFC20B', 'warning'];
        $icon = ['fa fa-paper-plane', 'fa fa-diamond', 'fa fa-rocket', 'warning'];
        ?>

        <section class="pricing-section">
            <div class="container">
                <div class="outer-box">
                    <div class="row">
                        <!-- Pricing Block -->
                        <?php
						$mm = SettingsApi()['result']['data'][0]['membershipSettings']['membershipTypes'];
						if (@$current_user->isMember == 1 && @$current_user->membershipPaymentStatus == 'COMPLETED') {
							if (@$current_user->membershipStatus == 'ACTIVE') {
								foreach ($mm as $key => $value) {
									if ($current_user->membershipAmount < $value['membershipPrice']) {
										$button_disabled = '';
										$bg_color = '';
										$onclick = "onclick=\"loginCheck('". htmlspecialchars(@$value['membershipPrice'], ENT_QUOTES, 'UTF-8') . "', '" . str_replace("'", "`", htmlspecialchars(@$value['membershipType'], ENT_QUOTES, 'UTF-8')) . "', '" . str_replace("'", "`", htmlspecialchars(@$value['membershipDesc'], ENT_QUOTES, 'UTF-8')) . "', '" . htmlspecialchars(@$value['_id'], ENT_QUOTES, 'UTF-8') . "')\"";
									} else {
										$button_disabled = 'disabled';
										$bg_color = 'filter: grayscale(1);';
										$onclick = ''; 
									}
									?>
                        <div class="pricing-block col-lg-4 col-md-6 col-sm-12 wow fadeInUp" data-wow-delay="800ms"
                            style="<?= $bg_color ?>">
                            <div class="inner-box">
                                <div class="icon-box <?= @$color[$key] ?>">
                                    <div class="icon-outer"><i class="<?= $icon[$key] ?>"></i></div>
                                </div>
                                <div class="price-box">
                                    <div class="title"><?= @camelCase($value['membershipType']) ?></div>
                                    <h4 class="price <?= @$color[$key] ?>">
                                        <?= getCurrencySymbol() . ' ' . price_format(@$value['membershipPrice'], 2) ?></h4>
                                </div>
                                <p class="features">
                                    <?php echo @$value['membershipDesc']; ?>
                                </p>
                                <ul class="fa-ul mb-3">
                                    <?php foreach ($value['Child Grid'] as $key => $val) {
													if ($val['benefit']) { ?>
                                    <li><i class="fa fa-check-square"></i> <?= $val['benefit'] ?></li>
                                    <?php }
												} ?>
                                </ul>
                                <div class="btn-box">
                                    <a href="javascript:void(0)" <?= $onclick ?> class="theme-btn <?= @$color[$key] ?>"
                                        <?= $button_disabled ?>>Select Plan</a>
                                </div>
                            </div>
                        </div>
                        <?php 
						}
							} elseif (@$current_user->membershipStatus == 'EXPIRED') {
								foreach ($mm as $key => $value) { ?>
                        <div class="pricing-block col-lg-4 col-md-6 col-sm-12 wow fadeInUp" data-wow-delay="800ms">
                            <div class="inner-box">
                                <!-- style="box-shadow: 1px 1px 38px <?= @$color[$key] ?>;" -->
                                <div class="icon-box <?= @$color[$key] ?>">
                                    <div class="icon-outer"><i class="<?= $icon[$key] ?>"></i></div>
                                </div>
                                <div class="price-box">
                                    <div class="title"><?= @camelCase($value['membershipType']) ?></div>
                                    <h4 class="price <?= @$color[$key] ?>">
                                        <?= getCurrencySymbol() . ' ' . price_format(@$value['membershipPrice'], 2) ?></h4>
                                </div>
                                <p class="features">
                                    <?php echo @$value['membershipDesc']; ?>
                                </p>
                                <ul class="fa-ul mb-3">
                                    <?php foreach ($value['Child Grid'] as $key => $val) {
													if ($val['benefit']) { ?>
                                    <li><i class="fa fa-check-square"></i> <?= $val['benefit'] ?></li>
                                    <?php }
												} ?>
                                </ul>
                                <div class="btn-box">
                                    <a href="javascript:void(0)"
                                        onclick="loginCheck('<?= @$value['membershipPrice'] ?>', '<?= str_replace("'", '`' ,
                                        @$value['membershipType']) ?>',
                                        '<?= str_replace("'", '`', @$value['membershipDesc']) ?>', '<?= @$value['_id'] ?>')"
                                        class="theme-btn <?= @$color[$key] ?>" <?= $button_disabled ?>>Select Plan</a>
                                </div>
                            </div>
                        </div>
                        <?php }
							}
						} else {
							foreach ($mm as $key => $value) { ?>
                        <div class="pricing-block col-lg-4 col-md-6 col-sm-12 wow fadeInUp" data-wow-delay="800ms">
                            <div class="inner-box">
                                <!-- style="box-shadow: 1px 1px 38px <?= @$color[$key] ?>;" -->
                                <div class="icon-box <?= @$color[$key] ?>">
                                    <div class="icon-outer"><i class="<?= $icon[$key] ?>"></i></div>
                                </div>
                                <div class="price-box">
                                    <div class="title"><?= @camelCase($value['membershipType']) ?></div>
                                    <h4 class="price <?= @$color[$key] ?>">
                                        <?= getCurrencySymbol() . ' ' . price_format(@$value['membershipPrice'], 2) ?></h4>
                                </div>
                                <p class="features">
                                    <?php echo @$value['membershipDesc']; ?>
                                </p>
                                <ul class="fa-ul mb-3">
                                    <?php foreach ($value['Child Grid'] as $key => $val) {
												if ($val['benefit']) { ?>
                                    <li><i class="fa fa-check-square"></i> <?= $val['benefit'] ?></li>
                                    <?php }
											} ?>
                                </ul>
                                <div class="btn-box">
                                    <a href="javascript:void(0)"
                                        onclick="loginCheck('<?= @$value['membershipPrice'] ?>', '<?= str_replace("'", '`' ,
                                        @$value['membershipType']) ?>',
                                        '<?= str_replace("'", '`', @$value['membershipDesc']) ?>', '<?= @$value['_id'] ?>')"
                                        class="theme-btn <?= @$color[$key] ?>">Select Plan</a>
                                </div>
                            </div>
                        </div>
                        <?php }
						} ?>

                    </div>
                </div>

            </div>
        </section>

    </section><!-- End Temple Services Section -->
@endsection
