public function actionActivateClientState() { $field = isset($_GET['field']) ? $_GET['field'] : 'state'; $this->scenario = 'update_client_state'; $action = Yii::app()->request->getParam('value', null); $id = Yii::app()->request->getParam('id', null); $availableStates = Clients::getClientsStatesArray(); if (!array_key_exists($action, $availableStates)) { $action = 0; } if (!(!$id && $action === null)) { $model = $this->loadModel($id); if ($this->scenario) { $model->scenario = $this->scenario; } if ($model) { $model->{$field} = $action; $model->save(false); } } echo CHtml::link($availableStates[$action]); }
<p class="note"><?php echo Yii::t('common', 'Fields with <span class="required">*</span> are required.'); ?> </p> <?php echo $form->errorSummary($model); ?> <div class="rowold"> <?php echo $form->labelEx($model, 'state'); ?> <?php echo $form->dropDownList($model, 'state', Clients::getClientsStatesArray(), array('class' => 'width175')); ?> <?php echo $form->error($model, 'state'); ?> </div> <div class="rowold"> <?php echo $form->labelEx($model, 'contract_number'); ?> <?php echo $form->textField($model, 'contract_number', array('class' => 'width100', 'maxlength' => 255)); ?> <?php echo $form->error($model, 'contract_number');
<?php $this->breadcrumbs = array(tt('Manage clients', 'clients')); $this->menu = array(array('label' => tt('Add client', 'clients'), 'url' => array('create'))); $this->adminTitle = tt('Manage clients', 'clients'); $columns = array(array('class' => 'CCheckBoxColumn', 'id' => 'itemsSelected', 'selectableRows' => '2', 'htmlOptions' => array('class' => 'center')), array('name' => 'id', 'htmlOptions' => array('class' => 'id_column'), 'sortable' => false), array('name' => 'state', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnControllerClientStateHtml($data, "clients-grid")', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Clients::getClientsStatesArray()), array('name' => 'contract_number', 'htmlOptions' => array('class' => 'id_column'), 'sortable' => false), array('name' => 'first_name', 'sortable' => false), array('name' => 'second_name', 'sortable' => false), array('name' => 'middle_name', 'sortable' => false), array('name' => 'birthdate', 'sortable' => false), array('name' => 'phone', 'sortable' => false)); $columns[] = array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{view}{update}{delete}', 'deleteConfirmation' => tc('Are you sure you want to delete this item?')); $this->widget('CustomGridView', array('id' => 'clients-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove();}', 'columns' => $columns)); $this->renderPartial('//site/admin-select-items', array('url' => '/clients/backend/main/itemsSelected', 'id' => 'clients-grid', 'model' => $model, 'options' => array('delete' => Yii::t('common', 'Delete')))); Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.jeditable.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('editable_select_state', "\n\t\tfunction ajaxSetModerationClientState(elem, id, id_elem, items){\n\t\t\t\$('#editable_select_state-'+id_elem).editable('" . Yii::app()->controller->createUrl("activateclientstate") . "', {\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);