function stop_users_vms()
{
    logActivity("Starting to stop vms for users.");
    //Find all users whos credit is low
    $table = "tblclients";
    $fields = "*";
    $result = select_query($table, $fields);
    if ($result) {
        while ($data = mysql_fetch_array($result)) {
            $userid = $data['id'];
            $balanceLimit = get_balance_limit($userid);
            if (!$balanceLimit || !is_numeric($balanceLimit)) {
                $balanceLimit = 0;
            }
            logActivity("Balance limit for user " . $userid . ": " . $balanceLimit);
            if (getCreditForUserId($userid) + $balanceLimit < 0) {
                logActivity("Stopping vms for user: "******"Stopped vms for user: "******". Result:" . $res);
                } else {
                    logActivity("Stoping vms failed for user: "******"Stopping vms for users ended.");
}
 /**
  * Function that gets OMC VM data to display on template
  */
 public static function addOmsUsageClientAreaPage($vars)
 {
     global $oms_usage_db, $product_core_name, $product_disk_name, $product_memory_name;
     $userId = $_SESSION['uid'];
     if (!is_numeric($userId)) {
         return array();
     }
     //Get products prices
     $hours_per_month = 720;
     $p_core = getProductPriceByName($product_core_name) / $hours_per_month;
     $p_disk = getProductPriceByName($product_disk_name) / $hours_per_month;
     $p_memory = getProductPriceByName($product_memory_name) / $hours_per_month;
     //logActivity("Using product prices for calculations: Cores:" . $p_core . ". Disk:" . $p_disk . ".Memory:" . $p_memory);
     if (!$p_core || !$p_disk || !$p_memory) {
         logActivity("Error: Product prices not set.");
         return;
     }
     $username = $userId;
     // XXX a temporary solution due to the removal of usernames
     $balance_limit = get_balance_limit($userId);
     $table = $oms_usage_db . ".CONF_CHANGES";
     $sql = "select * from " . $table . " WHERE username='******' ORDER BY timestamp DESC LIMIT 1";
     $result = mysql_query($sql);
     if ($result) {
         $data = mysql_fetch_array($result);
         if ($data) {
             $id = $data['id'];
             $mbsInGb = 1024;
             $data['disk'] = $data['disk'] / $mbsInGb;
             $amount = $data['cores'] * $p_core + $data['disk'] * $p_disk + $data['memory'] * $p_memory;
             $data['vm_cost'] = \Opennode\Whmcs\Service\OmsReductionService::applyTax($userId, $amount);
         }
     }
     $data['currentcredit'] = getCreditForUserId($userId) + $balance_limit;
     return array('omsdata' => $data);
 }