<?php
$this->setPageTitle(LANG_BILLING_BALANCE, $profile['nickname']);
$this->addBreadcrumb(LANG_USERS, href_to('users'));
$this->addBreadcrumb($profile['nickname'], href_to('users', $profile['id']));
$this->addBreadcrumb(LANG_BILLING_BALANCE);
$b_spellcount = $this->controller->options['currency'];
$is_admin = cmsUser::isAdmin();
$is_own_profile = $user->id == $profile['id'];
if ($is_admin){
$this->addToolButton(array( 'class' => 'settings',
'title' => LANG_BILLING_CONFIGURE,
'href' => href_to('admin/controllers/edit/billing')
));
}
$deposit_url = $this->href_to('deposit');
if ($is_admin){ $deposit_url = href_to('admin/controllers/edit/billing/add_balance_ajax/' . $profile['id']); }
$dep_link_title = LANG_BILLING_OP_DEPOSIT;
if ($is_admin) { $dep_link_title = $profile['nickname'] . ': ' . LANG_BILLING_BALANCE_CHANGE; }
$dep_link_text = $is_admin ? LANG_BILLING_BALANCE_CHANGE : LANG_BILLING_BALANCE_ADD;
$plan_link_title = $plan ? LANG_BILLING_EXTEND_PLAN : LANG_BILLING_BUY_PLAN;
$plan_url = $this->href_to('plan');
if ($plan) { $plan_url .= "?plan_id={$plan['id']}"; }
$is_exchange = ($this->controller->options['is_rtp'] || $this->controller->options['is_ptr']) && $user->isInGroups($this->controller->options['rtp_groups']);
$is_out = $this->controller->options['is_out'] && $is_own_profile && $user->isInGroups($this->controller->options['out_groups']);
?>
<div class="balance-info balance card">
<div class="card-body">
<h4 class="card-title">
<?php echo LANG_BILLING_BALANCE_INFO; ?>
<span class="<?php echo $profile['balance'] ? 'text-success' : 'text-muted'; ?>"><?php echo html_spellcount($profile['balance'], $b_spellcount); ?></span>
</h4>
<div class="balance-actions mt-4">
<?php if ($this->controller->options['in_mode'] == 'enabled' || $is_admin) { ?>
<a class="btn btn-success deposit<?php if($is_admin) { ?> ajax-modal<?php } ?>" href="<?php echo $deposit_url ?>" title="<?php echo $dep_link_title; ?>">
<svg class="icms-svg-icon w-16" >
<use xlink:href="/templates/modern/images/icons/solid.svg#coins"></use>
</svg>
<?php echo $dep_link_text; ?>
</a>
<?php } ?>
<?php if ($this->controller->options['is_plans'] && $is_own_profile) { ?>
<a class="btn btn-outline-success" href="<?php echo $plan_url ?>">
<svg class="icms-svg-icon w-16" >
<use xlink:href="/templates/modern/images/icons/solid.svg#clock"></use>
</svg>
<?php echo $plan_link_title; ?>
</a>
<?php } ?>
<?php if ($is_exchange && $user->id == $profile['id']) { ?>
<a class="btn btn-outline-primary exchange" href="<?php echo $this->href_to('exchange') ?>">
<svg class="icms-svg-icon w-16" >
<use xlink:href="/templates/modern/images/icons/solid.svg#exchange-alt"></use>
</svg>
<?php echo LANG_BILLING_EXCHANGE; ?>
</a>
<?php } ?>
<?php if ($this->controller->options['is_refs'] && ($is_own_profile || $is_admin)) { ?>
<a class="btn btn-outline-primary refs" href="<?php echo $this->href_to('refs', $is_own_profile ? '' : $profile['id']) ?>">
<svg class="icms-svg-icon w-16" >
<use xlink:href="/templates/modern/images/icons/solid.svg#link"></use>
</svg>
<?php echo LANG_BILLING_REFERALS; ?>
</a>
<?php } ?>
<?php if ($is_out) { ?>
<a class="btn btn-outline-primary out" href="<?php echo $this->href_to('out') ?>">
<svg class="icms-svg-icon w-16" >
<use xlink:href="/templates/modern/images/icons/solid.svg#sign-out-alt"></use>
</svg>
<?php echo LANG_BILLING_OUT; ?>
</a>
<?php } ?>
</div>
</div>
</div>
<?php if ($plan && $this->controller->options['is_plans']) { ?>
<div class="balance-info plan card mt-2">
<div class="card-body">
<h4 class="card-title">
<?php echo LANG_BILLING_PLAN; ?>
</h4>
<h5 class="font-weight-normal">
<?php echo $plan['title'] ?>
<span class="badge badge-light mx-2">
<?php printf(LANG_BILLING_PLAN_UNTIL
, html_date_time
($plan['date_until'])); ?></span>
</h5>
</div>
</div>
<?php } ?>
<div class="billing-history mt-4">
<?php
$this->renderChild('history', array( 'operations' => $operations,
'total' => $total,
'page' => $page,
'perpage' => $perpage
));
?>
</div>
<?php if ($is_admin) { ?>
<script>
function balanceUpdated() { window.location.href = ''; }
</script>
<?php } ?>