public function actionEdit_client_group($id)
    {
        $groups = ClientsGroups::model()->findByPk($id);
        if (isset($_POST['ajax']) && $_POST['ajax'] == 'edit-group') {
            echo CActiveForm::validate($groups);
            Yii::app()->end();
        }
        if ($_POST['MainClientsGroups']) {
            $groups->attributes = $_POST['MainClientsGroups'];
            if ($groups->validate() && $groups->update()) {
                $this->redirect(array('settings_clients_group'));
            } else {
                $this->redirect(array('settings_clients_group'));
            }
        }
        $delete_button = CHtml::button("Удалить", array('onClick' => 'window.location.href="' . Yii::app()->createUrl("page/delete_client_group", array("id" => $id)) . '"', 'class' => 'btn'));
        echo '<div class="popup" id="popup-edit-group" style="display: block;">
	<div class="popup__head">
		<div class="title">Редактор группы</div>
	</div>
	<div class="popup__form">';
        $form = $this->beginWidget('CActiveForm', array('id' => 'edit-group', 'enableAjaxValidation' => true, 'clientOptions' => array('validateOnSubmit' => true)));
        echo '<div class="form-group">
				' . $form->textField($groups, 'name', array('class' => 'form-control', 'placeholder' => 'Имя группы')) . $form->error($groups, 'name', array('class' => 'form-error')) . '
				<span class="star">*</span>
			</div>
			<div class="form-group">
				' . CHtml::submitButton('Редактировать группу', array('class' => 'btn')) . '
			</div>
			<div class="function-delete">
				<a class="delete" href="#">Удалить группу</a>
			</div>
			<div class="function-delete-confirm">
				<ul class="horizontal">
					<li class="big">Клиенты из этой группы примут параметр - "Главная группа"</li>
					<li><a class="delete" href="#">Отмена</a></li>
					<li>' . $delete_button . '</li>
				</ul>
			</div>
	</div>
</div>' . $this->actionGetJSStyle('edit-group', '[{
                "id": "MainClientsGroups_name",
                "inputID": "MainClientsGroups_name",
                "errorID": "MainClientsGroups_name_em_",
                "model": "MainClientsGroups",
                "name": "name",
                "enableAjaxValidation": true
            }]');
        $this->endWidget();
    }
            Параметры клиента:
        </div>
        <div class="form-group">
            <select name="MainClients[priority_id]" class="styled status circle" data-placeholder="Все приоритеты">
                <?php 
$statuses_array = ClientsPriority::model()->findAll();
foreach ($statuses_array as $status) {
    echo '<option ' . ($client->priority_id == $status->id ? ' selected="selected"' : '') . ' class="' . $status->color . '" value="' . $status->id . '">' . $status->name . '</option>';
}
?>
            </select>
            <span class="star">*</span>
        </div>
        <div class="form-group">
            <?php 
echo $form->dropDownList($client, 'group_id', CHtml::listData(ClientsGroups::model()->findAll('company_id=' . $user->company_id), "id", "name"), array('class' => 'styled', 'data-placeholder' => 'Группа клиента'));
?>
            <span class="star">*</span>
        </div>
        <div class="form-group">
            <?php 
echo $form->dropDownList($client, 'goal_id', CHtml::listData(ClientsGoals::model()->findAll('company_id=' . $user->company_id), "id", "name"), array('class' => 'styled', 'data-placeholder' => 'Цель клиента'));
?>
        </div>
        <div class="form-group">
            <?php 
echo $form->dropDownList($client, 'source_id', CHtml::listData(ClientsSources::model()->findAll('company_id=' . $user->company_id), "id", "name"), array('class' => 'styled', 'data-placeholder' => 'Источник'));
?>
        </div>
        <div class="form-group">
            <div class="client_info1">
            Поиск сделок
        </div>
        <div class="box-gray__body">
            <div class="box-gray__form">
                <?php 
$form = $this->beginWidget('CActiveForm', array('enableAjaxValidation' => false));
?>
                <div class="form-group">
                    <?php 
echo $form->textField($deals, 'keyword', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Имя сделки'));
?>
                </div>
                <div class="form-group">
                    <label class="label">Группа клиентов:</label>
                    <?php 
$groups_array = ClientsGroups::model()->findAll('company_id=' . $user->company_id);
$client_groups = array(0 => 'Все группы');
foreach ($groups_array as $group) {
    $client_groups[$group->id] = $group->name;
}
?>
                    <?php 
echo $form->dropDownList($deals, 'client_group_id', $client_groups, array('class' => 'styled', 'data-placeholder' => 'Все группы'));
?>
                </div>
                <?php 
$role = UsersRoles::model()->find('user_id=' . Yii::app()->user->id)->itemname;
if ($role != 'manager') {
    ?>
                    <div class="form-group">
                        <label class="label">Ответственный:</label>