Example #1
0
$cs = Yii::app()->clientScript;
$cs->registerCoreScript('jquery.ui');
$cs->registerScriptFile($cs->getCoreScriptUrl() . '/jui/js/jquery-ui-i18n.min.js');
$cs->registerCssFile($cs->getCoreScriptUrl() . '/jui/css/base/jquery-ui.css');
$this->breadcrumbs = array(tt('Manage apartments'));
$this->menu = array(array('label' => tt('Add apartment'), 'url' => array('create')));
$this->adminTitle = tt('Manage apartments');
if (Yii::app()->user->hasFlash('mesIecsv')) {
    echo "<div class='flash-success'>" . Yii::app()->user->getFlash('mesIecsv') . "</div>";
}
if (param('useUserads', 1)) {
    Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.jeditable.js', CClientScript::POS_END);
    Yii::app()->clientScript->registerScript('editable_select', "\n\t\tfunction ajaxSetModerationStatus(elem, id, id_elem, owner_id, items){\n\t\t\t\$('#editable_select-'+id_elem).editable('" . Yii::app()->controller->createUrl("activate") . "', {\n\t\t\t\tdata   : items,\n\t\t\t\ttype   : 'select',\n\t\t\t\tcancel : '" . tc('Cancel') . "',\n\t\t\t\tsubmit : '" . tc('Ok') . "',\n\t\t\t\tstyle  : 'inherit',\n\t\t\t\tsubmitdata : function() {\n\t\t\t\t\treturn {id : id_elem};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD);
}
$columns = array(array('class' => 'CCheckBoxColumn', 'id' => 'itemsSelected', 'selectableRows' => '2', 'htmlOptions' => array('class' => 'center')), array('name' => 'id', 'htmlOptions' => array('class' => 'apartments_id_column'), 'sortable' => false), array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnControllerStatusHtml($data, "apartments-grid", 1).
				(($data->deleted && !param("notDeleteListings", 0))  ? tt("Listing is deleted", "apartments") : "")', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getModerationStatusArray()), array('name' => 'owner_active', 'type' => 'raw', 'value' => 'Apartment::getApartmentsStatus($data->owner_active)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getApartmentsStatusArray()), array('name' => 'deleted', 'type' => 'raw', 'value' => 'Apartment::getApartmentsDeleted($data->deleted)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getApartmentsDeletedArray(), 'visible' => param("notDeleteListings", 0)), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'filter' => Apartment::getTypesArray(), 'sortable' => false), array('name' => 'price', 'type' => 'raw', 'value' => '$data->getPrettyPrice(false)', 'htmlOptions' => array('style' => 'width: 100px;'), 'filter' => false, 'sortable' => false), array('name' => 'obj_type_id', 'type' => 'raw', 'value' => '(isset($data->objType) && $data->objType) ? $data->objType->name : ""', 'filter' => Apartment::getObjTypesArray(), 'sortable' => false));
if (issetModule('location')) {
    $columns[] = array('name' => 'loc_country', 'value' => '($data->loc_country && isset($data->locCountry)) ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1));
    $columns[] = array('name' => 'loc_region', 'value' => '($data->loc_region && isset($data->locRegion)) ? $data->locRegion->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Region::getRegionsArray($model->loc_country, 0, 1));
    $columns[] = array('name' => 'loc_city', 'value' => '($data->loc_city && isset($data->locCity)) ? $data->locCity->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => City::getCitiesArray($model->loc_region, 0, 1));
} else {
    $columns[] = array('name' => 'city_id', 'value' => '($data->city_id && isset($data->city)) ? $data->city->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => ApartmentCity::getAllCity());
}
$columns[] = array('name' => 'ownerEmail', 'htmlOptions' => array('style' => 'width: 150px;'), 'type' => 'raw', 'value' => '(isset($data->user) && $data->user->role != "admin") ? CHtml::link(CHtml::encode($data->user->email), array("/users/backend/main/view","id" => $data->user->id)) : tt("administrator", "common")');
//$columns[]=array(
//    'name' => 'ownerUsername',
//    'htmlOptions' => array(
//        'style' => 'width: 150px;',
//    ),
//    'value' => 'isset($data->user->username) ? $data->user->username : ""'
//);