Esempio n. 1
0
/**
 * 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;
}
Esempio n. 2
0
 /**
  * returns user cash data with round and colorize if needed
  * 
  * @return string
  */
 protected function getUserCash()
 {
     //rounding cash if needed
     if ($this->alterCfg['ROUND_PROFILE_CASH']) {
         $Cash = web_roundValue($this->userdata['Cash'], 2);
     } else {
         $Cash = $this->userdata['Cash'];
     }
     //optional cash colorizing
     if (isset($this->alterCfg['COLORIZE_PROFILE_CASH'])) {
         if ($this->alterCfg['COLORIZE_PROFILE_CASH']) {
             if ($this->userdata['Cash'] >= 0) {
                 $color = '#0e7600';
             } else {
                 $color = '#c80000';
             }
             $Cash = wf_tag('font', false, '', 'color="' . $color . '"') . $Cash . wf_tag('font', true);
         }
     }
     return $Cash;
 }
Esempio n. 3
0
 /**
  * shows payments graph for some year
  * 
  * @param string $year year to show
  * 
  * @return void
  */
 protected function paymentsShowGraph($year)
 {
     $months = months_array();
     $year_summ = $this->paymentsGetYearSumm($year);
     $curtime = time();
     $yearPayData = array();
     $cells = wf_TableCell('');
     $cells .= wf_TableCell(__('Month'));
     $cells .= wf_TableCell(__('Payments count'));
     $cells .= wf_TableCell(__('ARPU'));
     $cells .= wf_TableCell(__('Cash'));
     $cells .= wf_TableCell(__('Visual'), '50%');
     $rows = wf_TableRow($cells, 'row1');
     //caching subroutine
     $renewTime = zb_StorageGet('UKVYPD_LAST');
     if (empty($renewTime)) {
         //first usage
         $renewTime = $curtime;
         zb_StorageSet('UKVYPD_LAST', $renewTime);
         $updateCache = true;
     } else {
         //cache time already set
         $timeShift = $curtime - $renewTime;
         if ($timeShift > 3600) {
             //cache update needed
             $updateCache = true;
         } else {
             //load data from cache or init new cache
             $yearPayData_raw = zb_StorageGet('UKVYPD_CACHE');
             if (empty($yearPayData_raw)) {
                 //first usage
                 $emptyCache = array();
                 $emptyCache = serialize($emptyCache);
                 $emptyCache = base64_encode($emptyCache);
                 zb_StorageSet('UKVYPD_CACHE', $emptyCache);
                 $updateCache = true;
             } else {
                 // data loaded from cache
                 $yearPayData = base64_decode($yearPayData_raw);
                 $yearPayData = unserialize($yearPayData);
                 $updateCache = false;
                 //check is current year already cached?
                 if (!isset($yearPayData[$year]['graphs'])) {
                     $updateCache = true;
                 }
                 //check is manual cache refresh is needed?
                 if (wf_CheckGet(array('forcecache'))) {
                     $updateCache = true;
                     rcms_redirect(self::URL_REPORTS_MGMT . 'reportFinance');
                 }
             }
         }
     }
     if ($updateCache) {
         foreach ($months as $eachmonth => $monthname) {
             $month_summ = $this->paymentsGetMonthSumm($year, $eachmonth);
             $paycount = $this->paymentsGetMonthCount($year, $eachmonth);
             $cells = wf_TableCell($eachmonth);
             $cells .= wf_TableCell(wf_Link(self::URL_REPORTS_MGMT . 'reportFinance&month=' . $year . '-' . $eachmonth, rcms_date_localise($monthname)));
             $cells .= wf_TableCell($paycount);
             $cells .= wf_TableCell(@round($month_summ / $paycount, 2));
             $cells .= wf_TableCell(web_roundValue($month_summ, 2));
             $cells .= wf_TableCell(web_bar($month_summ, $year_summ));
             $rows .= wf_TableRow($cells, 'row3');
         }
         $result = wf_TableBody($rows, '100%', '0', 'sortable');
         $yearPayData[$year]['graphs'] = $result;
         //write to cache
         zb_StorageSet('UKVYPD_LAST', $curtime);
         $newCache = serialize($yearPayData);
         $newCache = base64_encode($newCache);
         zb_StorageSet('UKVYPD_CACHE', $newCache);
     } else {
         //take data from cache
         if (isset($yearPayData[$year]['graphs'])) {
             $result = $yearPayData[$year]['graphs'];
             $result .= __('Cache state at time') . ': ' . date("Y-m-d H:i:s", $renewTime) . ' ';
             $result .= wf_Link(self::URL_REPORTS_MGMT . 'reportFinance&forcecache=true', wf_img('skins/icon_cleanup.png', __('Renew')), false, '');
         } else {
             $result = __('Strange exeption');
         }
     }
     show_window(__('Payments by') . ' ' . $year, $result);
 }
Esempio n. 4
0
/**
 * Shows payments year graph with caching
 * 
 * @param int $year
 */
function web_PaymentsShowGraph($year)
{
    $months = months_array();
    $year_summ = zb_PaymentsGetYearSumm($year);
    $curtime = time();
    $yearPayData = array();
    $yearStats = array();
    $cacheTime = 3600;
    //sec intervall to cache
    $cells = wf_TableCell('');
    $cells .= wf_TableCell(__('Month'));
    $cells .= wf_TableCell(__('Payments count'));
    $cells .= wf_TableCell(__('ARPU'));
    $cells .= wf_TableCell(__('Cash'));
    $cells .= wf_TableCell(__('Visual'), '50%');
    $rows = wf_TableRow($cells, 'row1');
    //caching subroutine
    $renewTime = zb_StorageGet('YPD_LAST');
    if (empty($renewTime)) {
        //first usage
        $renewTime = $curtime;
        zb_StorageSet('YPD_LAST', $renewTime);
        $updateCache = true;
    } else {
        //cache time already set
        $timeShift = $curtime - $renewTime;
        if ($timeShift > $cacheTime) {
            //cache update needed
            $updateCache = true;
        } else {
            //load data from cache or init new cache
            $yearPayData_raw = zb_StorageGet('YPD_CACHE');
            if (empty($yearPayData_raw)) {
                //first usage
                $emptyCache = array();
                $emptyCache = serialize($emptyCache);
                $emptyCache = base64_encode($emptyCache);
                zb_StorageSet('YPD_CACHE', $emptyCache);
                $updateCache = true;
            } else {
                // data loaded from cache
                $yearPayData = base64_decode($yearPayData_raw);
                $yearPayData = unserialize($yearPayData);
                $updateCache = false;
                //check is current year already cached?
                if (!isset($yearPayData[$year]['graphs'])) {
                    $updateCache = true;
                }
                //check is manual cache refresh is needed?
                if (wf_CheckGet(array('forcecache'))) {
                    $updateCache = true;
                    rcms_redirect("?module=report_finance");
                }
            }
        }
    }
    if ($updateCache) {
        //extracting all of needed payments in one query
        $allYearPayments_q = "SELECT * from `payments` WHERE `date` LIKE '" . $year . "-%' AND `summ`>'0';";
        $allYearPayments = simple_queryall($allYearPayments_q);
        if (!empty($allYearPayments)) {
            foreach ($allYearPayments as $idx => $eachYearPayment) {
                //Here we can get up to 50% of CPU time on month extraction, but this hacks is to ugly :(
                //Benchmark results: http://pastebin.com/i7kadpN7
                $statsMonth = date("m", strtotime($eachYearPayment['date']));
                if (isset($yearStats[$statsMonth])) {
                    $yearStats[$statsMonth]['count']++;
                    $yearStats[$statsMonth]['summ'] = $yearStats[$statsMonth]['summ'] + $eachYearPayment['summ'];
                } else {
                    $yearStats[$statsMonth]['count'] = 1;
                    $yearStats[$statsMonth]['summ'] = $eachYearPayment['summ'];
                }
            }
        }
        foreach ($months as $eachmonth => $monthname) {
            $month_summ = isset($yearStats[$eachmonth]) ? $yearStats[$eachmonth]['summ'] : 0;
            $paycount = isset($yearStats[$eachmonth]) ? $yearStats[$eachmonth]['count'] : 0;
            $cells = wf_TableCell($eachmonth);
            $cells .= wf_TableCell(wf_Link('?module=report_finance&month=' . $year . '-' . $eachmonth, rcms_date_localise($monthname)));
            $cells .= wf_TableCell($paycount);
            $cells .= wf_TableCell(@round($month_summ / $paycount, 2));
            $cells .= wf_TableCell(web_roundValue($month_summ, 2));
            $cells .= wf_TableCell(web_bar($month_summ, $year_summ));
            $rows .= wf_TableRow($cells, 'row3');
        }
        $result = wf_TableBody($rows, '100%', '0', 'sortable');
        $yearPayData[$year]['graphs'] = $result;
        //write to cache
        zb_StorageSet('YPD_LAST', $curtime);
        $newCache = serialize($yearPayData);
        $newCache = base64_encode($newCache);
        zb_StorageSet('YPD_CACHE', $newCache);
    } else {
        //take data from cache
        if (isset($yearPayData[$year]['graphs'])) {
            $result = $yearPayData[$year]['graphs'];
            $result .= __('Cache state at time') . ': ' . date("Y-m-d H:i:s", $renewTime) . ' ';
            $result .= wf_Link("?module=report_finance&forcecache=true", wf_img('skins/icon_cleanup.png', __('Renew')), false, '');
        } else {
            $result = __('Strange exeption');
        }
    }
    show_window(__('Payments by') . ' ' . $year, $result);
}