$request->setAttribute(PLUTON_NEEDAFFINITY_ATTR);
$request->setAttribute(PLUTON_ALL_ATTR);
print "Fetching attributes\n";
function checkAttribute($req, $name, $att, $val)
{
    $b = $req->getAttribute($att);
    if ($b != $val) {
        abortme("Attribute not as expected for {$name} as {$b} != {$val}", 1);
    }
    print "{$name}={$b} ok\n";
}
checkAttribute($request, "PLUTON_NOWAIT_ATTR", PLUTON_NOWAIT_ATTR, 1);
checkAttribute($request, "PLUTON_NOREMOTE_ATTR", PLUTON_NOREMOTE_ATTR, 1);
checkAttribute($request, "PLUTON_NORETRY_ATTR", PLUTON_NORETRY_ATTR, 1);
checkAttribute($request, "PLUTON_KEEPAFFINITY_ATTR", PLUTON_KEEPAFFINITY_ATTR, 1);
checkAttribute($request, "PLUTON_NEEDAFFINITY_ATTR", PLUTON_NEEDAFFINITY_ATTR, 1);
checkAttribute($request, "PLUTON_ALL_ATTR", PLUTON_ALL_ATTR, 1);
print "Checking one off\n";
$request->clearAttribute(PLUTON_NOWAIT_ATTR);
checkAttribute($request, "PLUTON_NOWAIT_ATTR", PLUTON_NOWAIT_ATTR, 0);
print "Checking all off\n";
$request->clearAttribute(PLUTON_ALL_ATTR);
checkAttribute($request, "PLUTON_NOWAIT_ATTR", PLUTON_NOWAIT_ATTR, 0);
checkAttribute($request, "PLUTON_NOREMOTE_ATTR", PLUTON_NOREMOTE_ATTR, 0);
checkAttribute($request, "PLUTON_NORETRY_ATTR", PLUTON_NORETRY_ATTR, 0);
checkAttribute($request, "PLUTON_KEEPAFFINITY_ATTR", PLUTON_KEEPAFFINITY_ATTR, 0);
checkAttribute($request, "PLUTON_NEEDAFFINITY_ATTR", PLUTON_NEEDAFFINITY_ATTR, 0);
checkAttribute($request, "PLUTON_ALL_ATTR", PLUTON_ALL_ATTR, 0);
?>

$matches = xtc_db_num_rows($result);
echo "<div class='col-xs-12'><table class='table table-bordered table-striped'>";
if ($matches) {
    while ($line = xtc_db_fetch_array($result)) {
        $current_product_option_name = $line['products_options_name'];
        $current_product_option_id = $line['products_options_id'];
        $query2 = "SELECT *\n                   FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . "\n                  WHERE products_options_id = '" . $current_product_option_id . "'\n               ORDER BY products_options_values_id ASC";
        $result2 = xtc_db_query($query2);
        $matches2 = xtc_db_num_rows($result2);
        if ($matches2) {
            $i = 0;
            while ($line = xtc_db_fetch_array($result2)) {
                $i++;
                $rowClass = rowClass($i);
                $current_value_id = $line['products_options_values_id'];
                $isSelected = checkAttribute($current_value_id, $_POST['current_product_id'], $current_product_option_id);
                $checked = $isSelected ? ' checked="checked"' : '';
                $query3 = "SELECT *\n                       FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . "\n                      WHERE products_options_values_id = '" . $current_value_id . "'\n                        AND language_id = '" . $_SESSION['languages_id'] . "'";
                $result3 = xtc_db_query($query3);
                while ($line = xtc_db_fetch_array($result3)) {
                    $current_value_name = $line['products_options_values_name'];
                    echo '<tr class="' . $rowClass . ' hidden-lg hidden-md">' . PHP_EOL;
                    #hidden-xs hidden-sm
                    echo '<td class="main" style="width:150px"><strong>' . $current_product_option_name . '</strong></td>' . PHP_EOL;
                    echo '<td class="main">' . PHP_EOL;
                    echo '<input type="checkbox" name="optionValues[]" value="' . $current_value_id . '"' . $checked . '>&nbsp;&nbsp;' . $current_value_name . '&nbsp;&nbsp;' . PHP_EOL;
                    echo '</td>' . PHP_EOL;
                    echo '</tr>';
                    echo '<tr class="' . $rowClass . ' hidden-lg hidden-md">' . PHP_EOL;
                    #hidden-xs hidden-sm
                    echo '<td class="main" style="width:80px"><strong>' . SORT_ORDER . '</strong></td>' . PHP_EOL;