public function ajaxNewNode()
 {
     $name = mb_capitalize(filter_input(INPUT_POST, 'node', FILTER_SANITIZE_SPECIAL_CHARS));
     if (mb_strlen($name) === 0) {
         $this->preparePopup('Имя узла не может быть пустым!', 'alert-warning');
         return;
     }
     $id = $this->model->newNode($name);
     if (count($this->model->getErrors())) {
         $this->preparePopup($this->model->getErrorList());
     } else {
         $this->preparePopup('Новый узел создан', 'alert-success');
         echo CHtml::createOption($name, $id);
     }
 }
 public function actionReject()
 {
     $ticket_id = filter_input(INPUT_POST, 'ticket_id', FILTER_VALIDATE_INT);
     $reason = filter_input(INPUT_POST, 'reason');
     if (!$this->isGrantToMe('ACE_DELETE')) {
         $this->preparePopup('Нет прав на удаление заявок!', 'alert-warning');
     } else {
         $ok = $this->model->deleteTicket($ticket_id, mb_capitalize($reason));
         if ($ok) {
             $this->model->setTicketStatus($ticket_id, STATUS_DELETE);
             $this->preparePopup('Заявка удалена');
         } else {
             $this->preparePopup($this->model->getErrorList());
         }
     }
     $this->redirect('/');
 }
 public function actionSyncDevice()
 {
     $st = $this->mdb->prepare("select Oborudovanie, MEHANIZM from mehanizm order by 1, 2");
     $st->execute();
     $data = $this->prepareData($st);
     $result = [];
     foreach ($data as $device) {
         $node = mb_capitalize(get_param($device, 'Oborudovanie'));
         $device = mb_capitalize(get_param($device, 'MEHANIZM'));
         $result[$node][] = $device;
     }
     $nid = 0;
     $did = 0;
     $this->model->startTransaction();
     foreach ($result as $node => $deviceList) {
         $this->model->saveNode(++$nid, $node);
         foreach ($deviceList as $dname) {
             $this->model->saveDevice(++$did, $dname, $nid);
         }
     }
     $this->model->stopTransaction();
     var_dump($this->model->getErrors());
 }