$this->adminTitle = tt('Export'); ?> <div> <p><?php echo tt('The file is exported to the UTP-8 without BOM charset.'); ?> </p> <p><?php echo tt('Separators are ";".'); ?> </p> </div> <?php $columns = array(array('class' => 'CCheckBoxColumn', 'header' => tt('Select'), 'id' => 'itemsSelectedExport'), array('name' => 'id', 'htmlOptions' => array('class' => 'apartments_id_column', 'style' => 'text-align: center;'), 'sortable' => false), array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnControllerStatusHtml($data, "apartments-grid", 1)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'filter' => Apartment::getModerationStatusArray(), 'sortable' => false), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'htmlOptions' => array('style' => 'width: 100px;'), 'filter' => Apartment::getTypesArray(), 'sortable' => false)); if (issetModule('location')) { $columns[] = array('name' => 'loc_country', 'value' => '$data->loc_country ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1)); $columns[] = array('name' => 'loc_region', 'value' => '$data->loc_region ? $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 ? $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' => '(isset($data->city ) && $data->city_id) ? $data->city->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'filter' => ApartmentCity::getAllCity(), 'sortable' => false); } $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('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->{"title_".Yii::app()->language}), $data->getUrl())', 'sortable' => false); ?> <div class="form"> <?php $this->widget('CustomHistoryGridView', array('id' => 'export-grid', 'dataProvider' => $model->searchExport(), 'filter' => $model, 'selectableRows' => 2, 'selectionChanged' => 'js:selItemsSelected', 'columns' => $columns));
public function actionActivate() { $field = isset($_GET['field']) ? $_GET['field'] : 'active'; $useModuleUserAds = false; if (param('useUserads', 1) && Yii::app()->request->getParam('id') && Yii::app()->request->getParam('value') != null) { $useModuleUserAds = true; $this->scenario = 'update_status'; $action = Yii::app()->request->getParam('value', null); $id = Yii::app()->request->getParam('id', null); $availableStatuses = Apartment::getModerationStatusArray(); if (!array_key_exists($action, $availableStatuses)) { $action = 0; } } else { $action = $_GET['action']; $id = $_GET['id']; } if (!(!$id && $action === null)) { $model = $this->loadModel($id); if ($this->scenario) { $model->scenario = $this->scenario; } if ($model) { if ($useModuleUserAds) { $model->{$field} = $action; } else { $model->{$field} = $action == 'activate' ? 1 : 0; } $className = get_class($model); if ($model->{$field} == 1 && ($className == 'UserAds' || $className == 'Apartment')) { $_POST['set_period_activity'] = 1; } $model->save(false); } } if (!Yii::app()->request->isAjaxRequest) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } elseif ($useModuleUserAds) { echo CHtml::link($availableStatuses[$action]); } }
$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()->request->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)', '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' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'filter' => Apartment::getTypesArray(), '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') && param('useLocation', 1)) { $columns[] = array('name' => 'loc_country', 'value' => '$data->loc_country ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1)); $columns[] = array('name' => 'loc_region', 'value' => '$data->loc_region ? $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 ? $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->location_id ? $data->location->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Location::getLocationArrayWithoutChooseOption()); } $columns[] = array('name' => 'ownerEmail', 'htmlOptions' => array('style' => 'width: 150px;'), 'type' => 'raw', 'value' => '(isset($data->user) && $data->user->id != 1) ? 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 : ""'); $columns[] = array('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->{"title_".Yii::app()->language}),array("/apartments/backend/main/view","id" => $data->id))', 'sortable' => false); if (issetModule('paidservices')) { $columns[] = array('header' => tc('Paid services'), 'value' => '$data->getPaidHtml(true, true)', 'type' => 'raw', 'htmlOptions' => array('style' => 'width: 200px;')); } $columns[] = array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{up}{down}{view}{update}{delete}', 'deleteConfirmation' => tc('Are you sure you want to delete this item?'), 'viewButtonUrl' => "Yii::app()->createUrl('/apartments/backend/main/view', array('id' => \$data->id))", 'htmlOptions' => array('class' => 'width120'), 'buttons' => array('up' => array('label' => tc('Move an item up'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/up.gif'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/move", array("id"=>$data->id, "direction" => "down", "catid" => "0"))', 'options' => array('class' => 'infopages_arrow_image_up'), 'visible' => '$data->sorter < "' . $maxSorter . '"', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}"), 'down' => array('label' => tc('Move an item down'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/down.gif'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/move", array("id"=>$data->id, "direction" => "up", "catid" => "0"))', 'options' => array('class' => 'infopages_arrow_image_down'), 'visible' => '$data->sorter > 1', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}"))); $this->widget('CustomGridView', array('id' => 'apartments-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove();}', 'columns' => $columns));
<?php Yii::app()->getModule('userads'); //if(!Yii::app()->request->isAjaxRequest){ // echo '<h1>'.tt('Manage apartments', 'apartments').'</h1>'; //} $this->pageTitle .= ' - ' . tt('Manage apartments', 'apartments'); if (!isset($this->breadcrumbs)) { $this->breadcrumbs = array(Yii::t('common', 'Control panel') => array('/usercpanel/main/index'), tt('Manage apartments', 'apartments')); } //echo CHtml::button(tc('Add ad', 'apartments'), array('onclick' => 'document.location.href="'.Yii::app()->createUrl('/userads/main/create').'"', 'class' => 'button-blue')); Yii::app()->clientScript->registerScript('ajaxSetStatus', "\n\t\tfunction ajaxSetStatus(elem, id){\n\t\t\t\$.ajax({\n\t\t\t\turl: \$(elem).attr('href'),\n\t\t\t\tsuccess: function(){\n\t\t\t\t\t\$('#'+id).yiiGridView.update(id);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD); $columns = array(array('name' => 'id', 'headerHtmlOptions' => array('class' => 'apartments_id_column')), array('name' => 'active', 'type' => 'raw', 'value' => 'UserAds::returnStatusHtml($data, "userads-grid", 0)', 'headerHtmlOptions' => array('class' => 'userads_status_column'), 'filter' => Apartment::getModerationStatusArray(), 'sortable' => false), array('name' => 'owner_active', 'type' => 'raw', 'value' => 'UserAds::returnStatusOwnerActiveHtml($data, "userads-grid", 1)', 'headerHtmlOptions' => array('class' => 'userads_owner_status_column'), 'filter' => array('0' => tc('Inactive'), '1' => tc('Active')), 'sortable' => false), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'filter' => Apartment::getTypesArray(), 'sortable' => false), array('name' => 'obj_type_id', 'type' => 'raw', 'value' => '(isset($data->objType) && $data->objType) ? $data->objType->name : ""', 'filter' => Apartment::getObjTypesArray(), 'sortable' => false), array('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->{"title_".Yii::app()->language}), $data->getUrl())')); if (issetModule('location') && param('useLocation', 1)) { $columns[] = array('name' => 'loc_country', 'value' => '$data->loc_country ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1)); $columns[] = array('name' => 'loc_region', 'value' => '$data->loc_region ? $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 ? $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 ? $data->city->name : ""', 'sortable' => false, 'filter' => ApartmentCity::getAllCity()); } if (issetModule('paidservices')) { $columns[] = array('header' => tc('Paid services'), 'value' => '$data->getPaidHtml(false, false, true)', 'type' => 'raw', 'htmlOptions' => array('class' => 'width70 center')); } $columns[] = array('class' => 'CButtonColumn', 'deleteConfirmation' => tc('Are you sure you want to delete this item?'), 'viewButtonUrl' => '$data->getUrl()', 'buttons' => array('update' => array('url' => 'Yii::app()->createUrl("/userads/main/update", array("id" => $data->id))'), 'delete' => array('url' => 'Yii::app()->createUrl("/userads/main/delete", array("id" => $data->id))'))); $this->widget('NoBootstrapGridView', array('id' => 'userads-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => $columns));
$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 : ""' //);