/**
 * Renders user profile
 * 
 * @param string $login
 * @return string
 */
function zbs_UserShowProfile($login)
{
    $us_config = zbs_LoadConfig();
    $us_currency = $us_config['currency'];
    $userdata = zbs_UserGetStargazerData($login);
    $alladdress = zbs_AddressGetFulladdresslist();
    $allrealnames = zbs_UserGetAllRealnames();
    $contract = zbs_UserGetContract($login);
    $email = zbs_UserGetEmail($login);
    $mobile = zbs_UserGetMobile($login);
    $phone = zbs_UserGetPhone($login);
    $passive = $userdata['Passive'];
    $down = $userdata['Down'];
    //public offer mode
    if (isset($us_config['PUBLIC_OFFER'])) {
        if (!empty($us_config['PUBLIC_OFFER'])) {
            $publicOfferUrl = $us_config['PUBLIC_OFFER'];
            $contract = la_Link($publicOfferUrl, __('Public offer'), false, '');
        }
    }
    // START OF ONLINELEFT COUNTING <<
    if ($us_config['ONLINELEFT_COUNT'] != 0) {
        $userBalance = $userdata['Cash'];
        $userTariff = $userdata['Tariff'];
        $balanceExpire = zbs_GetOnlineLeftCount($login, $userBalance, $userTariff, false);
    } else {
        $balanceExpire = '';
    }
    // >> END OF ONLINELEFT COUNTING
    if ($userdata['CreditExpire'] != 0) {
        $credexpire = date("d-m-Y", $userdata['CreditExpire']);
    } else {
        $credexpire = '';
    }
    // pasive state check
    if ($passive) {
        $passive_state = __('Account frozen');
    } else {
        $passive_state = __('Account active');
    }
    //down state check
    if ($down) {
        $down_state = ' + ' . __('Disabled');
    } else {
        $down_state = '';
    }
    //hiding passwords
    if ($us_config['PASSWORDSHIDE']) {
        $userpassword = str_repeat('*', 8);
    } else {
        $userpassword = $userdata['Password'];
    }
    //payment id handling
    if ($us_config['OPENPAYZ_REALID']) {
        $paymentid = zbs_PaymentIDGet($login);
    } else {
        $paymentid = ip2int($userdata['IP']);
    }
    //payment id qr dialog
    $paymentidqr = '';
    if (isset($us_config['PAYMENTID_QR'])) {
        if ($us_config['PAYMENTID_QR']) {
            $paymentidqr = la_modal(la_img('iconz/qrcode.png', 'QR-code'), __('Payment ID'), la_tag('center') . la_img('qrgen.php?data=' . $paymentid) . la_tag('center', true), '', '300', '250');
        }
    }
    //draw order link
    if ($us_config['DOCX_SUPPORT']) {
        $zdocsLink = ' ' . la_Link('?module=zdocs', __('Draw order'), false, 'printorder');
    } else {
        $zdocsLink = '';
    }
    //tariff speeds
    if ($us_config['SHOW_SPEED']) {
        $speedOffset = 1024;
        $userSpeedOverride = zbs_SpeedGetOverride($login);
        if ($userSpeedOverride == 0) {
            $showSpeed = zbs_TariffGetSpeed($userdata['Tariff']);
        } else {
            if ($userSpeedOverride < $speedOffset) {
                $showSpeed = $userSpeedOverride . ' ' . __('Kbit/s');
            } else {
                $showSpeed = $userSpeedOverride / $speedOffset . ' ' . __('Mbit/s');
            }
        }
        $tariffSpeeds = la_TableRow(la_TableCell(__('Tariff speed'), '', 'row1') . la_TableCell($showSpeed));
    } else {
        $tariffSpeeds = '';
    }
    if ($us_config['ROUND_PROFILE_CASH']) {
        $Cash = web_roundValue($userdata['Cash'], 2);
    } else {
        $Cash = $userdata['Cash'];
    }
    $profile = la_tag('table', false, '', 'width="100%" border="0" cellpadding="2" cellspacing="3"');
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Address'), '', 'row1');
    $profile .= la_TableCell(@$alladdress[$login]);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Real name'), '', 'row1');
    $profile .= la_TableCell(@$allrealnames[$login]);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Login'), '', 'row1');
    $profile .= la_TableCell($login);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Password'), '', 'row1');
    $profile .= la_TableCell($userpassword);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('IP'), '', 'row1');
    $profile .= la_TableCell($userdata['IP']);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Phone'), '', 'row1');
    $profile .= la_TableCell($phone);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Mobile'), '', 'row1');
    $profile .= la_TableCell($mobile);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Email'), '', 'row1');
    $profile .= la_TableCell($email);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $payIdAbbr = la_tag('abbr', false, '', 'title="' . __('Payment ID is used to make online payments using a variety of payment systems as well as the funding of accounts using the terminals') . '"');
    $payIdAbbr .= __('Payment ID');
    $payIdAbbr .= la_tag('abbr', true);
    $profile .= la_TableCell($payIdAbbr, '', 'row1');
    $profile .= la_TableCell($paymentid . ' ' . $paymentidqr);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Contract'), '', 'row1');
    $profile .= la_TableCell($contract);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Balance'), '', 'row1');
    $profile .= la_TableCell($Cash . ' ' . $us_currency . $balanceExpire . $zdocsLink);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Credit'), '', 'row1');
    $profile .= la_TableCell($userdata['Credit'] . ' ' . $us_currency);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Credit Expire'), '', 'row1');
    $profile .= la_TableCell($credexpire);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Tariff'), '', 'row1');
    $profile .= la_TableCell(__($userdata['Tariff']));
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Tariff price'), '', 'row1');
    $profile .= la_TableCell(@zbs_UserGetTariffPrice($userdata['Tariff']) . ' ' . $us_currency);
    $profile .= la_tag('tr', true);
    $profile .= $tariffSpeeds;
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Tariff change'), '', 'row1');
    $profile .= la_TableCell(__($userdata['TariffChange']));
    $profile .= la_tag('tr', true);
    $profile .= la_tag('tr');
    $profile .= la_TableCell(__('Account state'), '', 'row1');
    $profile .= la_TableCell($passive_state . $down_state);
    $profile .= la_tag('tr', true);
    $profile .= la_tag('table', true);
    //show assigned virtual services if available
    if (isset($us_config['VSERVICES_SHOW'])) {
        if ($us_config['VSERVICES_SHOW']) {
            $profile .= zbs_vservicesShow($login, $us_currency);
        }
    }
    return $profile;
}
 /**
  * loads user data for template processing 
  * 
  * @return void
  */
 public function loadAllUserData()
 {
     $userdata = array();
     $alluserdata = zbs_UserGetStargazerData($this->userLogin);
     $tariffspeeds = zbs_TariffGetSpeed($alluserdata['Tariff']);
     $tariffprices = zbs_TariffGetAllPrices();
     $allcontract = zbs_UserGetContract($this->userLogin);
     $contractDates = $this->getContractDatesAll();
     $allrealnames = zbs_UserGetAllRealnames();
     $alladdress = zbs_AddressGetFulladdresslist();
     $allemail = zbs_UserGetEmail($this->userLogin);
     $lastDocId = $this->getDocumentLastId();
     $newDocId = $lastDocId + 1;
     $curdate = date("Y-m-d");
     if ($this->altcfg['OPENPAYZ_REALID']) {
         $allopcustomer = zbs_PaymentIDGet($this->userLogin);
     }
     if (!empty($alluserdata)) {
         $userdata[$alluserdata['login']]['LOGIN'] = $alluserdata['login'];
         $userdata[$alluserdata['login']]['PASSWORD'] = $alluserdata['Password'];
         $userdata[$alluserdata['login']]['TARIFF'] = $alluserdata['Tariff'];
         @($userdata[$alluserdata['login']]['TARIFFPRICE'] = $tariffprices[$alluserdata['Tariff']]);
         $userdata[$alluserdata['login']]['CASH'] = $alluserdata['Cash'];
         $userdata[$alluserdata['login']]['CREDIT'] = $alluserdata['Credit'];
         $userdata[$alluserdata['login']]['DOWN'] = $alluserdata['Down'];
         $userdata[$alluserdata['login']]['PASSIVE'] = $alluserdata['Passive'];
         $userdata[$alluserdata['login']]['AO'] = $alluserdata['AlwaysOnline'];
         @($userdata[$alluserdata['login']]['CONTRACT'] = $allcontract);
         @($userdata[$alluserdata['login']]['CONTRACTDATE'] = $contractDates[$this->userLogin]['contractdate']);
         @($userdata[$alluserdata['login']]['REALNAME'] = $allrealnames[$alluserdata['login']]);
         @($userdata[$alluserdata['login']]['ADDRESS'] = $alladdress[$alluserdata['login']]);
         @($userdata[$alluserdata['login']]['EMAIL'] = $allemail);
         //openpayz payment ID
         if ($this->altcfg['OPENPAYZ_REALID']) {
             @($userdata[$alluserdata['login']]['PAYID'] = $allopcustomer);
         } else {
             @($userdata[$alluserdata['login']]['PAYID'] = ip2int($alluserdata['IP']));
         }
         //traffic params
         $userdata[$alluserdata['login']]['TRAFFIC'] = $alluserdata['D0'] + $alluserdata['U0'];
         $userdata[$alluserdata['login']]['TRAFFICDOWN'] = $alluserdata['D0'];
         $userdata[$alluserdata['login']]['TRAFFICUP'] = $alluserdata['U0'];
         //net params
         $userdata[$alluserdata['login']]['IP'] = $alluserdata['IP'];
         //tariffs speed
         $userdata[$alluserdata['login']]['SPEEDDOWN'] = $tariffspeeds;
         //other document data
         @($userdata[$alluserdata['login']]['CURDATE'] = $curdate);
         @($userdata[$alluserdata['login']]['DOCID'] = $newDocId);
     }
     $this->userData = $userdata;
 }