public static function pm()
 {
     $wallets = WalletsPm::getAllWallets();
     $perfectMoney = new PerfectMoney();
     foreach ($wallets as $key => $value) {
         $perfectMoney->setAccountID($value['account_id']);
         $perfectMoney->setPassPhrase($value['pass_phrase']);
         $response = $perfectMoney->balance();
         if ($response != null) {
             $balance = $response[$value['account']];
         } else {
             $balance = "currently unavailable";
             // always on the localhost
         }
         $wallets[$key]['current_balance'] = $balance;
     }
     Core::runView('ViewTemplate/account', array('pageName' => 'PM wallets', 'activeMenu' => 'PM wallets', 'pagePath' => 'Administration/admin_pm', 'user' => self::$user, 'wallets' => $wallets));
 }
 private static function PM_MinAndMaxWallets($units)
 {
     $pm_wallets = WalletsPm::findBy(array('units' => $units));
     if (empty($pm_wallets)) {
         return null;
     }
     $maxBalance = null;
     $keyMax = null;
     $minBalance = null;
     $keyMin = null;
     $perfectMoney = new PerfectMoney();
     foreach ($pm_wallets as $key => $value) {
         $perfectMoney->setAccountID($value['account_id']);
         $perfectMoney->setPassPhrase($value['pass_phrase']);
         $response = $perfectMoney->balance();
         if ($response !== null) {
             $balance = $response[$value['account']];
             $pm_wallets[$key]['current_balance'] = $balance;
             if ($minBalance === null || $minBalance > $balance) {
                 $minBalance = $balance;
                 $keyMin = $key;
             }
             if ($maxBalance === null || $maxBalance < $balance) {
                 $maxBalance = $balance;
                 $keyMax = $key;
             }
         }
     }
     $result['min'] = $pm_wallets[$keyMin];
     $result['max'] = $pm_wallets[$keyMax];
     return $result;
 }