<?php
$user_id = get_current_user_id();
$plans = yascode_vip::get_plans();
$message = (!empty($_GET['msg'])) ? $_GET['msg'] : '';
$status = (!empty($_GET['status'])) ? $_GET['status'] : 'error';
$vip_active = yascode_vip::is_active();
if ($vip_active) :
    $user_vip = yascode_vip::get_user_vip_status($user_id); ?>
    <div class="plans rt rt-relative rt-overflow rt-center">
        <div class="ins rt">
            <div class="entery rt">
                <div class="main">
                    <h1 class="title rt rt-333 rt-bold rt-18 rt-align">خرید اشتراک ویژه</h1>
                    <?php if (!empty($message)) : ?><div class="panel-alert <?php echo $status; ?>"><?php echo $message; ?></div><?php endif; ?>
                    <?php if (!empty($plans['items'])) { ?>
                        <div class="list rt">
                            <?php foreach ($plans['items'] as $plan) :
                                $price = 0;
                                $ID = (!empty($plan->ID)) ? $plan->ID : '';
                                $time = (!empty($plan->time)) ? change_days_to_human($plan->time) : '';
                                $real_price = (!empty($plan->price) && is_numeric($plan->price)) ? number_format($plan->price) : '';
                                $discount_price = (!empty($plan->discount_price) && is_numeric($plan->discount_price)) ? number_format($plan->discount_price) : '';
                                if (!empty($discount_price)) $price = $discount_price;
                                else $price = $real_price; ?>
                                <a href="<?php echo PANEL_URL . '/plans/checkout/' . $ID; ?>" class="rt rt-14 rt-10px rt-bg">
                                    <img class="right" src="<?php echo THEME_TEMPLATE_URL . '/assets/front/img/vip.png'; ?>">
                                    <div class="inside right">
                                        <h2 class="rt rt-16 rt-222 rt-bold"><?php echo $time['number'] . " " . $time['type'] . 'ه'; ?></h2>
                                        <div class="price rt-444 rt">
                                            <?php if (!empty($real_price) && !empty($discount_price)) : ?>
                                                <span class="rt-13 offer"><del><?php echo $real_price; ?></del> تومان</span>
                                            <?php endif; ?>
                                            <samp class="rt-15 rt-bold" style="color:green"><?php echo $price; ?><span class="rt-12"> تومان</span></samp>
                                        </div>
                                    </div>
                                    <span class="sub rt-10px rt-pointer rt-fff rt-bold left rt-14">انتخاب و خرید <i class="fa fa-angle-left rt-19 left"></i></span>
                                </a>
                            <?php endforeach; ?>
                        </div>
                    <?php } ?>
                    <?php if ($user_vip['status'] == true) : ?><p class="rt rt-10px rt-13 rt-fff notic">اشتراک شما <b><?php echo (!empty($user_vip['days_left'])) ? $user_vip['days_left'] . ' روز' : 'نامحدود'; ?></b> روز دیگر منقضی می شود. شما می توانید مدت زمان اشتراک ویژه خود را افزایش دهید.</p><?php endif; ?>

                    <div class="rt rt-align"><a href="/ticket" target="_blank" class="rt-30px rt-bold rt-666 rt-14 ticket-btn"><i class="fa fa-headphones"></i> پشتیبانی</a></div>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>