<?php
// require login
if (UserPeer::enableUpgradePage() == 'no')
{
    // require login
    $Auth->requireUser(WEB_ROOT . '/login.' . SITE_CONFIG_PAGE_EXTENSION);
}
// page title
$title = UCWords(t('extend', 'extend'));
if ($Auth->level_id == 1)
{
    $title = UCWords(t('upgrade', 'upgrade'));
}
// setup page
define("PAGE_NAME", $title . ' ' . UCWords(t("account", "account")));
define("PAGE_DESCRIPTION", $title . ' ' . t("upgrade_meta_description", "Your Account"));
define("PAGE_KEYWORDS", strtolower($title) . t("upgrade_meta_keywords", ", account, paid, membership, upload, download, site"));
define("TITLE_DESCRIPTION_LEFT", t("upgrade_title_page_description_left", "See below for the various account and payment options."));
define("TITLE_DESCRIPTION_RIGHT", t("upgrade_title_page_description_right", ""));
define("CURRENT_PAGE_KEY", "upgrade");

// load user
$user = UserPeer::loadUserById($Auth->id);

// include header
require_once(SITE_TEMPLATES_PATH . '/partial/_header.inc.php');
?>
<link href="<?php echo SITE_THEME_PATH; ?>/hg/css/switch.css" rel="stylesheet">
<?php if(strlen($_REQUEST['payMethod'])): ?>
<script>
    $(document).ready(function() {
    $('.<?php echo $_REQUEST['payMethod']; ?><?php echo (int)$_REQUEST['priceId']; ?>').click();
            });</script>
<?php endif; ?>

<?php if(isset($_REQUEST['p'])): ?>
<script>
            $(document).ready(function() {
    $('#pricing<?php echo (int)$_REQUEST['p']; ?>').modal('show');
            });
</script>
<?php endif; ?>
<div class="pricing">
<div class="change">
  <span class="pt-left active"><?php echo t("hg_monthly", "Monthly")?></span>
  <div class="toggle-switch">
    <label class="switch">
      <input id="switch" type="checkbox" checked>
      <span class="slider round"></span>
    </label>
  </div>
  <span class="pt-right"><?php echo t("hg_yearly", "Yearly")?></span>
</div>
  <?php include_once(SITE_TEMPLATES_PATH . '/partial/_upgrade_boxes_by_package.inc.php'); ?>
</div>
<div <?php if(strlen($_REQUEST['payMethod'])): ?>style="display: none;"<?php endif; ?>>
    
<?php if ($Auth->loggedIn()): ?>
    <h2><?php echo t("account_status", "account status"); ?></h2>
    <div style="padding-bottom: 12px;">
        <table class="table table-bordered table-striped">
            <tbody>
                <tr>
                    <td style="width: 240px;">
                        <?php echo UCWords(t('account_type', 'account type')); ?>:
                    </td>
                    <td>
                        <?php echo t('account_type_' . str_replace(' ', '_', $Auth->level), UCWords($Auth->level)); ?>
                    </td>
                </tr>
                <?php 
				$userType = $db->getValue('SELECT level_type FROM user_level WHERE id = '.$user->level_id.' LIMIT 1');
				if(in_array($userType, array('paid', 'admin', 'moderator'))):
				?>
                    <tr>
                        <td>
                            <?php echo UCWords(t('reverts_to_free_account', 'reverts to free account')); ?>:
                        </td>
                        <td>
                            <?php echo(in_array($userType, array('admin', 'moderator'))) ? UCWords(t('never', 'never')) : coreFunctions::formatDate($user->paidExpiryDate); ?>
                        </td>
                    </tr>
                <?php endif ?>
            </tbody>
        </table>
    </div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="clearfix pt50"></div>
<div class="app">
	  <ul class="container">
    
      <li class="webdav">
        <a href="#"> <?php echo t('hg_1' , 'WebDav Sync')?> <i class="la la-arrow-right"></i></a>
        <p>
         <?php echo t('hg_2' , ' Access and manage all your files directly via desktop, phone or tablet with WebDav app.<br>
		  Most WebDav clients are supported ')?>
        </p>
      </li>
    
    
      <li class="aff">
        <a href="#"><?php echo t('hg_3' , 'Earn Money')?> <i class="la la-arrow-right"></i></a>
        <p>
          <?php echo t("hg_4" , "Join our Affiliate Scheme and you'll get paid for every downloads and sales. 
		  You will have extra storage and support for you account.")?>
        </p>
      </li>
    
      </ul>
	</div>
<script>
$('#switch').change(function(){
    if (this.checked) {
        $('span').css('color', '#4d4d4d');
		$('span.pt-right').css('color', '#4a8bfc');
		$('.pricing1M').css('display', 'none');
		$('.pricing1Y').css('display', 'block');
    }
	else {
	    $('span').css('color', '#4d4d4d');
		$('span.pt-left').css('color', '#4a8bfc');
		$('.pricing1Y').css('display', 'none');
		$('.pricing1M').css('display', 'block');
	}
});
</script>
<?php
// include footer
require_once(SITE_TEMPLATES_PATH . '/partial/_footer.inc.php');
?>

