Новое поле справочника зависит от настройки показа для "продажи", "аренды"
Файл protected\modules\formeditor\models\HFormEditor.php
Замените:
- Код: Выделить всё
echo CHtml::activeDropDownList($model, $row['field'], CMap::mergeArray(array("" => Yii::t('common', 'Please select')), FormDesigner::getListByCategoryID($row->reference_id)));
На:
echo CHtml::activeDropDownList($model, $row['field'], CMap::mergeArray(array("" => Yii::t('common', 'Please select')), FormDesigner::getListByCategoryID($row->reference_id, $model->type)));
Файл protected\modules\formdesigner\models\FormDesigner.php
Замените:
- Код: Выделить всё
public static function getListByCategoryID($categoryID){
$tmp = 'title_' . Yii::app()->language;
$sql = "SELECT id, $tmp AS name FROM {{apartment_reference_values}} WHERE reference_category_id = :id ORDER BY sorter";
$items = Yii::app()->db->createCommand($sql)
->queryAll(true, array(
':id' => $categoryID
));
return CHtml::listData($items, 'id', 'name');
}
На:
- Код: Выделить всё
public static function getListByCategoryID($categoryID, $adType = 0){
$addWhere = '';
if(in_array($adType, array(Apartment::TYPE_RENT, Apartment::TYPE_RENTING))){
$addWhere = ' AND for_rent = 1 ';
}
if(in_array($adType, array(Apartment::TYPE_SALE, Apartment::TYPE_BUY))){
$addWhere = ' AND for_sale = 1 ';
}
$tmp = 'title_' . Yii::app()->language;
$sql = "SELECT id, $tmp AS name FROM {{apartment_reference_values}} WHERE reference_category_id = :id {$addWhere} ORDER BY sorter";
$items = Yii::app()->db->createCommand($sql)
->queryAll(true, array(
':id' => $categoryID
));
return CHtml::listData($items, 'id', 'name');
}