<?php
if (is_object($column)) {
    $columnName = $column->name;
} else {

    $columnName = $column;
}

$name = 'Tiers['.$row.']['.$columnName.']';
$htmlOptions = array(
    'name'=>$name,
    'data-custom-contexthelp-key' => 'TIERS_FOOTER_'.  strtoupper($columnName).'_CONTEXT_HELP'
);

if ($columnName == 'static_member') {
    $htmlOptions['class'] = 'span1';
    $html = CHtml::activeCheckBox($data,$columnName,$htmlOptions);
    echo $html;
} else if ($columnName == 'level') {
        $htmlOptions['class'] = 'span1';
        $html = CHtml::activeDropDownList($data,$columnName,range(1,10),$htmlOptions);
        echo $html;
    } else if ($columnName == 'userId') {
        if (isset($data->userId)) {

            //FIXME generate UserData and Options Html Attributes
            $UserData = array();
            $optionsHtmlAttributes = array();
            foreach ($availableUsers as $user) {
                $availableUsersData[$user->extension][$user->id] = CHtml::encode(getFormatedUsername($user));
                $optionsHtmlAttributes[$user->id] = array('title' => $user->name);
            }
            ksort($availableUsersData);
            $availableUsers = array();
            foreach ( $availableUsersData as $extension => $UserData) {
                foreach ($UserData as $id => $userName) {

                    $availableUsers[$id] = $userName;
                }
            }
            $UserData = array();
            $UserData = $availableUsers;
            if (isset($optionsHtmlAttributes[$data->userId])) {
                echo '<div title="'.$optionsHtmlAttributes[$data->userId]['title'].'">'.$UserData[$data->userId].'</div>';
            }

            echo CHtml::activeHiddenField($data,'userId',array('name'=>$name));
        }
    } else if ($columnName == 'position' ) {
        $htmlOptions['class'] = 'span1';
        $htmlOptions['style'] = 'width:30px';
        echo CHtml::activeHiddenField($data,'id',array('name'=>'Tiers['.$row.'][dataId]'));
        echo CHtml::activeHiddenField($data,'type',array('name'=>'Tiers['.$row.'][type]'));
        $html = CHtml::activeTextField($data,$columnName,$htmlOptions);
        echo $html;
    } else if ($columnName == 'timeout' ) {
        
        $htmlOptions['maxlength'] = '2';
        $htmlOptions['class'] = 'span1';
        $htmlOptions['style'] = 'width:18px';
        $html = '<div class="input-append">';
        $html .= CHtml::activeTextField($data,$columnName,$htmlOptions);
        $html .= '<span class="add-on">'.__('QUEUE_MODEL_WAITING_TIME_SECONDS').'</span></div>';
        
        echo $html;
        
    }

///TEST
if ($columnName == 'buttons') {
    echo '<div class="icon-trash removeMember" ></div>';
}
///TEST end
