protected function getTableName()
 {
     $campaign = Campaign::search_by_domain($_SERVER['SERVER_NAME']);
     if ($campaign->id) {
         return '`' . $campaign->id . '_ProjectMessages`';
     } else {
         return "`ProjectMessages`";
     }
 }
 /**
  * Одобрение или нет заказа
  * @param $answer
  * @author Emericanec
  */
 public function actionModerationAnswer($id, $event_id, $answer)
 {
     $model = Zakaz::model()->resetScope()->findByPk($id);
     $event = Events::model()->findByPk($event_id);
     if (!$model->is_active && $event) {
         if ($answer == 1) {
             $model->is_active = 1;
             if ($model->save()) {
                 $event->delete();
                 // Заказчику проект принят
                 $type_id = Emails::TYPE_12;
                 $email = new Emails();
                 $order = Zakaz::model()->findByPk($id);
                 $user = User::model()->findByPk($order->user_id);
                 $email->from_id = 1;
                 $email->to_id = $user->id;
                 $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                 $campaign = Campaign::search_by_domain($_SERVER['SERVER_NAME']);
                 $email->campaign = $campaign->name;
                 $email->name = $user->full_name;
                 $email->num_order = $id;
                 $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $id;
                 //$email->login= $user->username;
                 //$email->password= $soucePassword;
                 $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id);
                 $this->redirect(Yii::app()->createUrl('project/zakaz/update', array('id' => $model->id)));
             }
         } else {
             // если нет то просто удаляем
             $model->delete();
             $event->delete();
             $this->redirect(Yii::app()->createUrl('project/event'));
         }
     } else {
         $event->delete();
         throw new CHttpException("Заказ не найден или его уже отмодерировали");
     }
 }