public function QpageAction($id)
 {
     $qpage = new Consult($this->context);
     $qdate = new ConsQue($this->context, 'id = "' . $id . '"');
     $cat = new ConsultUser($this->context, 'uid = "' . $_SESSION['auth']['id'] . '"');
     if (!empty($_SESSION['auth']['id'])) {
         if ($qdate->uid == 0 && $qdate->cid == $cat->cid) {
             $this->db->prepare('update consult_questions set uid =' . $_SESSION['auth']['id'] . ' where id =' . $id)->execute();
             return AddAlertMessage('success', 'Вопрос стал личным.', '/consult/q-' . $qdate->id);
         }
         if (!empty($_POST)) {
             $ans_wer = Tools::getValue('body');
             $time = date("Y-m-d H:i:s", time());
             $email = $qdate->email;
             $uri = $qdate->pid == 0 ? $uri = 'http://dev.karapuz/consult/ask/?cn=' . $qdate->cid . '&ex=' . $qdate->uid . '&q=' . $qdate->id : ($uri = 'http://dev.karapuz/consult/ask/?cn=' . $qdate->cid . '&ex=' . $qdate->uid . '&q=' . $qdate->pid);
             $content = array('title' => 'Вы получили ответ', 'template' => 'expert_answer', 'data' => array('year' => date("Y,M,D", time()), 'name' => $qdate->name, 'answer' => $ans_wer, 'uri' => $uri));
             $this->db->prepare('update consult_questions set answer = "' . $ans_wer . '", isAnswer = 0, answerdate = "' . $time . '" where id =' . $id)->execute();
             //$sendAnswer = SendEmailSMTP('', '', $email, $content);
             //if ($sendAnswer !== true) return AddAlertMessage('danger', 'Ошибка при отправке письма!', '/');
             return AddAlertMessage('success', 'Ответ был успешно добавлен.', '/consult/cn-' . $qdate->cid . '/ex-' . $qdate->uid);
         }
     }
     $qdate->pid != 0 ? $pid = $qdate->pid : ($pid = $qdate->id);
     $qdate->uid > 0 ? $qpuid = $qdate->uid : ($qpuid = 1);
     $disquz = $this->db->query('
 		select CQ.id, CQ.title, CQ.body, CQ.name, CQ.answer, CQ.isAnswer, CQ.pid pid, CQ.questiondate, CQ.answerdate, CQ.uid, CQ.cid, UD.FirstName, UD.LastName, CC.name cname
 		from consult_questions CQ, userdata UD, consult_category CC
 		where CQ.isActive = 1 and CQ.pid=' . $pid . ' and UD.UserID = ' . $qpuid . ' and CQ.cid=CC.id
 		order by CQ.id ASC 
 		')->fetchall();
     $disquzz = $this->db->query('
 		select CQ.id, CQ.title, CQ.body, CQ.name, CQ.answer, CQ.isAnswer, CQ.pid pid, CQ.questiondate, CQ.answerdate, CQ.uid, CQ.cid, UD.FirstName, UD.LastName, CC.name cname
 		from consult_questions CQ, userdata UD, consult_category CC
 		where CQ.isActive = 1 and CQ.id=' . $pid . ' and UD.UserID = ' . $qpuid . ' and CQ.cid=CC.id
 		order by CQ.id ASC 
 		')->fetch();
     $qpage->getPOST();
     $category = $this->db->query('select id, name, alt_name, small_img from consult_category')->fetchall();
     $questions = $this->db->query('select id, title, body, answer from consult_questions where isActive = 1 ORDER BY id DESC ')->fetchall();
     $expert = $this->db->query('
     	SELECT cc.id, cc.name, cc.alt_name, ud.FirstName, ud.LastName, ud.UserID 
     	FROM UserData as ud, consult_category as cc, consult_user_category as cu  
     	WHERE ud.UserID=cu.uid and cc.id=cu.cid
     	')->fetchall();
     $this->view->breadcrumbs = array(array('url' => '/', 'title' => 'Главная'), array('url' => '/consult/', 'title' => 'Консультации'), array('url' => '../consult/q-' . $id, 'title' => $qdate->title));
     $this->view->setVars(array('category' => $category, 'expert' => $expert, 'questions' => $questions, 'qdate' => $qdate, 'disquz' => $disquz, 'disquzz' => $disquzz));
     $this->view->generate();
 }