<?php

// all users & clienttypes
$allUsers = getAllUsers();
$allClienttypes = getAllClienttypes();
$allServers = getAllServers();

// users & clienttypes & servers - right selectboxes
$clienttypes_assoc = array();
$users_assoc = array();
$servers_assoc = array();

foreach ($clienttypes as $id_clienttype) {
    if (array_key_exists($id_clienttype, $allClienttypes)) {
        $clienttypes_assoc[$id_clienttype] = $allClienttypes[$id_clienttype];
    }
}
foreach ($users as $id_user) {
    if (array_key_exists($id_user, $allUsers)) {
        $users_assoc[$id_user] = $allUsers[$id_user];
    }
}
foreach ($servers as $id_server) {
    if (array_key_exists($id_server, $allServers)) {
        $servers_assoc[$id_server] = $allServers[$id_server];
    }
}

?>
<tr class="secondarycolor">
    <td><?php echo $this->lang('Visible to client types'); ?>:<br>
        <?php echo NE_Lib::returnPopUpString($this->lang('Client types will be automatically inherited from upper categories. You can add more of them by using these select boxes.'), $this->settings); ?></td>
    <td>
        <table>
        <tr>
            <td>
                <select id="clienttypes1" size="10" style="width: 150px;"><?php echo Template::htmlOptions($allClienttypes); ?></select>
            </td>
            <td valign="top"><input type="button" class="button_small" value="<?php echo $this->lang('Add'); ?>" onclick="selectboxAdd('clienttypes1', 'clienttypes2');this.blur();"></td>
            <td>
                <select name="clienttypes[]" id="clienttypes2" size="10" style="width: 150px;"><?php echo Template::htmlOptions($clienttypes_assoc); ?></select>
            </td>
            <td valign="top"><input type="button" class="button_medium" value="<?php echo $this->lang('Delete'); ?>" onclick="selectboxRemove('clienttypes2');this.blur();"></td>
        </tr>
        </table>
    </td>
</tr>
<tr class="primarycolor">
    <td><?php echo $this->lang('Visible to users'); ?>:<br>
        <?php echo NE_Lib::returnPopUpString('Users will be automatically inherited from upper categories. You can add more of them by using these select boxes.', $this->settings); ?></td>
    <td>
        <table>
        <tr>
            <td>
                <select id="users1" size="10" style="width: 150px;"><?php echo Template::htmlOptions($allUsers); ?></select>
            </td>
            <td valign="top"><input type="button" class="button_small" value="<?php echo $this->lang('Add'); ?>" onclick="selectboxAdd('users1', 'users2');this.blur();"></td>
            <td>
                <select name="users[]" id="users2" size="10" style="width: 150px;"><?php echo Template::htmlOptions($users_assoc); ?></select>
            </td>
            <td valign="top"><input type="button" class="button_medium" value="<?php echo $this->lang('Delete'); ?>" onclick="selectboxRemove('users2');this.blur();"></td>
        </tr>
        </table>
    </td>
</tr>
<tr class="secondarycolor">
    <td><?php echo $this->lang('Visible to servers'); ?>:<br>
        <?php echo NE_Lib::returnPopUpString($this->lang('Servers will be automatically inherited from upper categories. You can add more of them by using these select boxes.'), $this->settings); ?></td>
    <td>
        <table>
        <tr>
            <td>
                <select id="servers1" size="10" style="width: 150px;"><?php echo Template::htmlOptions($allServers); ?></select>
            </td>
            <td valign="top"><input type="button" class="button_small" value="<?php echo $this->lang('Add'); ?>" onclick="selectboxAdd('servers1', 'servers2');this.blur();"></td>
            <td>
                <select name="servers[]" id="servers2" size="10" style="width: 150px;"><?php echo Template::htmlOptions($servers_assoc); ?></select>
            </td>
            <td valign="top"><input type="button" class="button_medium" value="<?php echo $this->lang('Delete'); ?>" onclick="selectboxRemove('servers2');this.blur();"></td>
        </tr>
        </table>
    </td>
</tr>
