@@ -14,14 +14,14 @@  | 
                                                    ||
| 14 | 14 | class NotFoundPlugin extends Plugin  | 
                                                        
| 15 | 15 |  { | 
                                                        
| 16 | 16 | |
| 17 | - /**  | 
                                                        |
| 18 | - * This action is executed before execute any action in the application  | 
                                                        |
| 19 | - *  | 
                                                        |
| 20 | - * @param Event $event  | 
                                                        |
| 21 | - * @param Dispatcher $dispatcher  | 
                                                        |
| 22 | - */  | 
                                                        |
| 23 | - public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)  | 
                                                        |
| 24 | -	{ | 
                                                        |
| 17 | + /**  | 
                                                        |
| 18 | + * This action is executed before execute any action in the application  | 
                                                        |
| 19 | + *  | 
                                                        |
| 20 | + * @param Event $event  | 
                                                        |
| 21 | + * @param Dispatcher $dispatcher  | 
                                                        |
| 22 | + */  | 
                                                        |
| 23 | + public function beforeException(Event $event, MvcDispatcher $dispatcher, Exception $exception)  | 
                                                        |
| 24 | +    { | 
                                                        |
| 25 | 25 |      if ($exception instanceof DispatcherException) { | 
                                                        
| 26 | 26 |          switch ($exception->getCode()) { | 
                                                        
| 27 | 27 | case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:  | 
                                                        
@@ -27,36 +27,36 @@  | 
                                                    ||
| 27 | 27 | */  | 
                                                        
| 28 | 28 | public function beforeDispatch(Event $event, Dispatcher $dispatcher)  | 
                                                        
| 29 | 29 |      { | 
                                                        
| 30 | -		if($_SERVER['REMOTE_ADDR'] == '127.0.0.1'){ | 
                                                        |
| 31 | - return true;  | 
                                                        |
| 32 | - }  | 
                                                        |
| 30 | +        if($_SERVER['REMOTE_ADDR'] == '127.0.0.1'){ | 
                                                        |
| 31 | + return true;  | 
                                                        |
| 32 | + }  | 
                                                        |
| 33 | 33 | |
| 34 | - $controller = strtoupper( $dispatcher->getControllerName() );  | 
                                                        |
| 35 | -		if ($this->request->isAjax()){ | 
                                                        |
| 36 | -			if ( $controller !== 'SESSION'){ | 
                                                        |
| 37 | -				if (!is_array($this->sessionRO) || !key_exists('auth', $this->sessionRO )){ | 
                                                        |
| 38 | - $this->response->setStatusCode( 403, "Forbidden" )  | 
                                                        |
| 39 | - ->sendHeaders();  | 
                                                        |
| 40 | - $this->response->setContent( 'The user isn\'t authenticated' );  | 
                                                        |
| 41 | - $this->response->send();  | 
                                                        |
| 42 | - return FALSE;  | 
                                                        |
| 43 | - }  | 
                                                        |
| 44 | - }  | 
                                                        |
| 45 | -		} else { // не AJAX запрос | 
                                                        |
| 46 | - $auth = $this->session->get( 'auth' );  | 
                                                        |
| 47 | -			if ( ! $auth && $controller !== 'SESSION' ) { | 
                                                        |
| 48 | - $dispatcher->forward( [  | 
                                                        |
| 49 | - 'controller' => 'session',  | 
                                                        |
| 50 | - 'action' => 'index',  | 
                                                        |
| 51 | - ] );  | 
                                                        |
| 52 | -			} elseif ($controller == 'INDEX'){ | 
                                                        |
| 53 | - // TODO: когда будет главная страница сделаем переадресацию на нее  | 
                                                        |
| 54 | - $dispatcher->forward( [  | 
                                                        |
| 55 | - 'controller' => 'extensions',  | 
                                                        |
| 56 | - 'action' => 'index',  | 
                                                        |
| 57 | - ] );  | 
                                                        |
| 58 | - }  | 
                                                        |
| 59 | - }  | 
                                                        |
| 34 | + $controller = strtoupper( $dispatcher->getControllerName() );  | 
                                                        |
| 35 | +        if ($this->request->isAjax()){ | 
                                                        |
| 36 | +            if ( $controller !== 'SESSION'){ | 
                                                        |
| 37 | +                if (!is_array($this->sessionRO) || !key_exists('auth', $this->sessionRO )){ | 
                                                        |
| 38 | + $this->response->setStatusCode( 403, "Forbidden" )  | 
                                                        |
| 39 | + ->sendHeaders();  | 
                                                        |
| 40 | + $this->response->setContent( 'The user isn\'t authenticated' );  | 
                                                        |
| 41 | + $this->response->send();  | 
                                                        |
| 42 | + return FALSE;  | 
                                                        |
| 43 | + }  | 
                                                        |
| 44 | + }  | 
                                                        |
| 45 | +        } else { // не AJAX запрос | 
                                                        |
| 46 | + $auth = $this->session->get( 'auth' );  | 
                                                        |
| 47 | +            if ( ! $auth && $controller !== 'SESSION' ) { | 
                                                        |
| 48 | + $dispatcher->forward( [  | 
                                                        |
| 49 | + 'controller' => 'session',  | 
                                                        |
| 50 | + 'action' => 'index',  | 
                                                        |
| 51 | + ] );  | 
                                                        |
| 52 | +            } elseif ($controller == 'INDEX'){ | 
                                                        |
| 53 | + // TODO: когда будет главная страница сделаем переадресацию на нее  | 
                                                        |
| 54 | + $dispatcher->forward( [  | 
                                                        |
| 55 | + 'controller' => 'extensions',  | 
                                                        |
| 56 | + 'action' => 'index',  | 
                                                        |
| 57 | + ] );  | 
                                                        |
| 58 | + }  | 
                                                        |
| 59 | + }  | 
                                                        |
| 60 | 60 | }  | 
                                                        
| 61 | 61 | |
| 62 | 62 | }  | 
                                                        
@@ -27,34 +27,34 @@  | 
                                                    ||
| 27 | 27 | */  | 
                                                        
| 28 | 28 | public function beforeDispatch(Event $event, Dispatcher $dispatcher)  | 
                                                        
| 29 | 29 |      { | 
                                                        
| 30 | -		if($_SERVER['REMOTE_ADDR'] == '127.0.0.1'){ | 
                                                        |
| 30 | +		if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') { | 
                                                        |
| 31 | 31 | return true;  | 
                                                        
| 32 | 32 | }  | 
                                                        
| 33 | 33 | |
| 34 | - $controller = strtoupper( $dispatcher->getControllerName() );  | 
                                                        |
| 35 | -		if ($this->request->isAjax()){ | 
                                                        |
| 36 | -			if ( $controller !== 'SESSION'){ | 
                                                        |
| 37 | -				if (!is_array($this->sessionRO) || !key_exists('auth', $this->sessionRO )){ | 
                                                        |
| 38 | - $this->response->setStatusCode( 403, "Forbidden" )  | 
                                                        |
| 34 | + $controller = strtoupper($dispatcher->getControllerName());  | 
                                                        |
| 35 | +		if ($this->request->isAjax()) { | 
                                                        |
| 36 | +			if ($controller !== 'SESSION') { | 
                                                        |
| 37 | +				if (!is_array($this->sessionRO) || !key_exists('auth', $this->sessionRO)) { | 
                                                        |
| 38 | + $this->response->setStatusCode(403, "Forbidden")  | 
                                                        |
| 39 | 39 | ->sendHeaders();  | 
                                                        
| 40 | - $this->response->setContent( 'The user isn\'t authenticated' );  | 
                                                        |
| 40 | +					$this->response->setContent('The user isn\'t authenticated'); | 
                                                        |
| 41 | 41 | $this->response->send();  | 
                                                        
| 42 | 42 | return FALSE;  | 
                                                        
| 43 | 43 | }  | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 |  		} else { // не AJAX запрос | 
                                                        
| 46 | - $auth = $this->session->get( 'auth' );  | 
                                                        |
| 47 | -			if ( ! $auth && $controller !== 'SESSION' ) { | 
                                                        |
| 48 | - $dispatcher->forward( [  | 
                                                        |
| 46 | +			$auth = $this->session->get('auth'); | 
                                                        |
| 47 | +			if (!$auth && $controller !== 'SESSION') { | 
                                                        |
| 48 | + $dispatcher->forward([  | 
                                                        |
| 49 | 49 | 'controller' => 'session',  | 
                                                        
| 50 | 50 | 'action' => 'index',  | 
                                                        
| 51 | - ] );  | 
                                                        |
| 52 | -			} elseif ($controller == 'INDEX'){ | 
                                                        |
| 51 | + ]);  | 
                                                        |
| 52 | +			} elseif ($controller == 'INDEX') { | 
                                                        |
| 53 | 53 | // TODO: когда будет главная страница сделаем переадресацию на нее  | 
                                                        
| 54 | - $dispatcher->forward( [  | 
                                                        |
| 54 | + $dispatcher->forward([  | 
                                                        |
| 55 | 55 | 'controller' => 'extensions',  | 
                                                        
| 56 | 56 | 'action' => 'index',  | 
                                                        
| 57 | - ] );  | 
                                                        |
| 57 | + ]);  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | 60 | }  | 
                                                        
@@ -15,7 +15,7 @@ discard block  | 
                                                    ||
| 15 | 15 | /**  | 
                                                        
| 16 | 16 | * Сервис для работы с JS и CSS файлами  | 
                                                        
| 17 | 17 | */  | 
                                                        
| 18 | -        $di->set('assets', function (){ | 
                                                        |
| 18 | +        $di->set('assets', function() { | 
                                                        |
| 19 | 19 |              $config     = $this->get('config'); | 
                                                        
| 20 | 20 | $manager = new Phalcon\Assets\Manager();  | 
                                                        
| 21 | 21 |              $dispatcher = $this->get('dispatcher'); | 
                                                        
@@ -549,7 +549,7 @@ discard block  | 
                                                    ||
| 549 | 549 | // Сохраним перевод в файл если его еще нет  | 
                                                        
| 550 | 550 |              $language   = $this->get('language'); | 
                                                        
| 551 | 551 |              $langJSFile = "public/js/cache/localization-{$language}-{$version}.min.js"; | 
                                                        
| 552 | -            if ( ! file_exists($langJSFile)) { | 
                                                        |
| 552 | +            if (!file_exists($langJSFile)) { | 
                                                        |
| 553 | 553 | $arrStr = [];  | 
                                                        
| 554 | 554 |                  foreach ($this->get('messages') as $key => $value) { | 
                                                        
| 555 | 555 |                      $arrStr[$key] = str_replace("'", "\\'", | 
                                                        
@@ -566,8 +566,8 @@ discard block  | 
                                                    ||
| 566 | 566 | |
| 567 | 567 | |
| 568 | 568 | // Название получаемого файла  | 
                                                        
| 569 | - $resultCombinedName = Text::uncamelize(ucfirst($controller) . ucfirst($action), '-');  | 
                                                        |
| 570 | - $resultCombinedName = strlen($resultCombinedName) !== '' ? $resultCombinedName . '-' : '';  | 
                                                        |
| 569 | + $resultCombinedName = Text::uncamelize(ucfirst($controller).ucfirst($action), '-');  | 
                                                        |
| 570 | + $resultCombinedName = strlen($resultCombinedName) !== '' ? $resultCombinedName.'-' : '';  | 
                                                        |
| 571 | 571 | |
| 572 | 572 | |
| 573 | 573 | $headerCollectionCSS->join(true);  | 
                                                        
@@ -582,16 +582,16 @@ discard block  | 
                                                    ||
| 582 | 582 |              $headerCollectionJS->setPrefix('public/'); | 
                                                        
| 583 | 583 |              $footerCollectionJS->setPrefix('public/'); | 
                                                        
| 584 | 584 |              foreach ($headerCollectionJS as $resource) { | 
                                                        
| 585 | - $resource->setPath($resource->getPath() . '?v=' . $version);  | 
                                                        |
| 585 | + $resource->setPath($resource->getPath().'?v='.$version);  | 
                                                        |
| 586 | 586 | }  | 
                                                        
| 587 | 587 |              foreach ($footerCollectionJS as $resource) { | 
                                                        
| 588 | - $resource->setPath($resource->getPath() . '?v=' . $version);  | 
                                                        |
| 588 | + $resource->setPath($resource->getPath().'?v='.$version);  | 
                                                        |
| 589 | 589 | }  | 
                                                        
| 590 | 590 |              foreach ($semanticCollectionJS as $resource) { | 
                                                        
| 591 | - $resource->setPath($resource->getPath() . '?v=' . $version);  | 
                                                        |
| 591 | + $resource->setPath($resource->getPath().'?v='.$version);  | 
                                                        |
| 592 | 592 | }  | 
                                                        
| 593 | 593 |              foreach ($semanticCollectionCSS as $resource) { | 
                                                        
| 594 | - $resource->setPath($resource->getPath() . '?v=' . $version);  | 
                                                        |
| 594 | + $resource->setPath($resource->getPath().'?v='.$version);  | 
                                                        |
| 595 | 595 | }  | 
                                                        
| 596 | 596 | |
| 597 | 597 | $headerCollectionJSForExtensions->join(true);  | 
                                                        
@@ -20,14 +20,14 @@  | 
                                                    ||
| 20 | 20 | class NormalizeControllerNamePlugin extends Plugin  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | 22 | |
| 23 | - /**  | 
                                                        |
| 24 | - * This action is executed before execute any action in the application  | 
                                                        |
| 25 | - *  | 
                                                        |
| 26 | - * @param Event $event  | 
                                                        |
| 27 | - * @param Dispatcher $dispatcher  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | - public function beforeDispatch(Event $event, Dispatcher $dispatcher) :void  | 
                                                        |
| 30 | -	{ | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * This action is executed before execute any action in the application  | 
                                                        |
| 25 | + *  | 
                                                        |
| 26 | + * @param Event $event  | 
                                                        |
| 27 | + * @param Dispatcher $dispatcher  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | + public function beforeDispatch(Event $event, Dispatcher $dispatcher) :void  | 
                                                        |
| 30 | +    { | 
                                                        |
| 31 | 31 | $controller = $dispatcher->getControllerName();  | 
                                                        
| 32 | 32 |          if ( strpos( $controller, '-' ) > 0 ) { | 
                                                        
| 33 | 33 |              $controller = str_replace('-', '_', $controller); | 
                                                        
@@ -29,15 +29,15 @@ discard block  | 
                                                    ||
| 29 | 29 | public function beforeDispatch(Event $event, Dispatcher $dispatcher) :void  | 
                                                        
| 30 | 30 |  	{ | 
                                                        
| 31 | 31 | $controller = $dispatcher->getControllerName();  | 
                                                        
| 32 | -        if ( strpos( $controller, '-' ) > 0 ) { | 
                                                        |
| 32 | +        if (strpos($controller, '-') > 0) { | 
                                                        |
| 33 | 33 |              $controller = str_replace('-', '_', $controller); | 
                                                        
| 34 | 34 | }  | 
                                                        
| 35 | 35 | $dispatcher->setControllerName(ucfirst($controller));  | 
                                                        
| 36 | 36 | |
| 37 | -        if ( stripos( $controller, 'module' ) === 0 ) { | 
                                                        |
| 38 | - $dispatcher->setModuleName( 'PBXExtension' );  | 
                                                        |
| 37 | +        if (stripos($controller, 'module') === 0) { | 
                                                        |
| 38 | +            $dispatcher->setModuleName('PBXExtension'); | 
                                                        |
| 39 | 39 |          } else { | 
                                                        
| 40 | - $dispatcher->setModuleName( 'PBXCore' );  | 
                                                        |
| 40 | +            $dispatcher->setModuleName('PBXCore'); | 
                                                        |
| 41 | 41 | }  | 
                                                        
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
@@ -51,10 +51,10 @@ discard block  | 
                                                    ||
| 51 | 51 |      { | 
                                                        
| 52 | 52 | $controller = $dispatcher->getControllerName();  | 
                                                        
| 53 | 53 | |
| 54 | -        if ( strpos( $controller, '_' ) > 0 ) { | 
                                                        |
| 55 | - $dispatcher->setControllerName(Text::camelize( $controller));  | 
                                                        |
| 54 | +        if (strpos($controller, '_') > 0) { | 
                                                        |
| 55 | + $dispatcher->setControllerName(Text::camelize($controller));  | 
                                                        |
| 56 | 56 |          } else { | 
                                                        
| 57 | - $dispatcher->setControllerName(ucfirst( $controller ));  | 
                                                        |
| 57 | + $dispatcher->setControllerName(ucfirst($controller));  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | 60 | }  | 
                                                        
@@ -15,40 +15,40 @@ discard block  | 
                                                    ||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | /**  | 
                                                        
| 18 | - * Построение списка конференц комнат  | 
                                                        |
| 19 | - */  | 
                                                        |
| 18 | + * Построение списка конференц комнат  | 
                                                        |
| 19 | + */  | 
                                                        |
| 20 | 20 | public function indexAction()  | 
                                                        
| 21 | 21 |      { | 
                                                        
| 22 | - $records = ConferenceRooms::find();  | 
                                                        |
| 22 | + $records = ConferenceRooms::find();  | 
                                                        |
| 23 | 23 | $this->view->records = $records;  | 
                                                        
| 24 | 24 | }  | 
                                                        
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | /**  | 
                                                        
| 28 | - * Карточка редактирования конференц комнаты  | 
                                                        |
| 29 | - *  | 
                                                        |
| 30 | - * @param string|NULL $uniqid  | 
                                                        |
| 31 | - */  | 
                                                        |
| 32 | -	public function modifyAction(string $uniqid=null){ | 
                                                        |
| 33 | - $record = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        |
| 28 | + * Карточка редактирования конференц комнаты  | 
                                                        |
| 29 | + *  | 
                                                        |
| 30 | + * @param string|NULL $uniqid  | 
                                                        |
| 31 | + */  | 
                                                        |
| 32 | +    public function modifyAction(string $uniqid=null){ | 
                                                        |
| 33 | + $record = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        |
| 34 | 34 |          if (!$record){ | 
                                                        
| 35 | 35 | $record = new ConferenceRooms();  | 
                                                        
| 36 | -	        $record->uniqid    = strtoupper('CONFERENCE-'.md5(time())); | 
                                                        |
| 37 | - $record->extension = Extensions::getNextFreeApplicationNumber();  | 
                                                        |
| 36 | +            $record->uniqid    = strtoupper('CONFERENCE-'.md5(time())); | 
                                                        |
| 37 | + $record->extension = Extensions::getNextFreeApplicationNumber();  | 
                                                        |
| 38 | 38 | }  | 
                                                        
| 39 | 39 | $this->view->form = new ConferenceRoomEditForm($record);  | 
                                                        
| 40 | - $this->view->represent = $record->getRepresent();  | 
                                                        |
| 40 | + $this->view->represent = $record->getRepresent();  | 
                                                        |
| 41 | 41 | |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /**  | 
                                                        |
| 46 | - * Сохранение конференц комнаты  | 
                                                        |
| 47 | - */  | 
                                                        |
| 48 | - public function saveAction()  | 
                                                        |
| 45 | + /**  | 
                                                        |
| 46 | + * Сохранение конференц комнаты  | 
                                                        |
| 47 | + */  | 
                                                        |
| 48 | + public function saveAction()  | 
                                                        |
| 49 | 49 |      { | 
                                                        
| 50 | 50 | if (!$this->request->isPost()) return;  | 
                                                        
| 51 | - $this->db->begin();  | 
                                                        |
| 51 | + $this->db->begin();  | 
                                                        |
| 52 | 52 | $data = $this->request->getPost();  | 
                                                        
| 53 | 53 | $room = ConferenceRooms::findFirstByUniqid($data['uniqid']);  | 
                                                        
| 54 | 54 |          if (!$room)  { | 
                                                        
@@ -62,105 +62,105 @@ discard block  | 
                                                    ||
| 62 | 62 | $extension->public_access = 1;  | 
                                                        
| 63 | 63 | |
| 64 | 64 |          } else { | 
                                                        
| 65 | - $extension = $room->Extensions;  | 
                                                        |
| 65 | + $extension = $room->Extensions;  | 
                                                        |
| 66 | + }  | 
                                                        |
| 67 | +  | 
                                                        |
| 68 | + // Заполним параметры внутреннего номера  | 
                                                        |
| 69 | +        if (!$this->updateExtension($extension, $data)){ | 
                                                        |
| 70 | + $this->view->success=false;  | 
                                                        |
| 71 | + $this->db->rollback();  | 
                                                        |
| 72 | + return;  | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | +  | 
                                                        |
| 75 | + // Заполним параметры участников очереди  | 
                                                        |
| 76 | +        if (!$this->updateConferenceRoom($room, $data)){ | 
                                                        |
| 77 | + $this->view->success=false;  | 
                                                        |
| 78 | + $this->db->rollback();  | 
                                                        |
| 79 | + return;  | 
                                                        |
| 66 | 80 | }  | 
                                                        
| 67 | 81 | |
| 68 | - // Заполним параметры внутреннего номера  | 
                                                        |
| 69 | -	    if (!$this->updateExtension($extension, $data)){ | 
                                                        |
| 70 | - $this->view->success=false;  | 
                                                        |
| 71 | - $this->db->rollback();  | 
                                                        |
| 72 | - return;  | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | -  | 
                                                        |
| 75 | - // Заполним параметры участников очереди  | 
                                                        |
| 76 | -	    if (!$this->updateConferenceRoom($room, $data)){ | 
                                                        |
| 77 | - $this->view->success=false;  | 
                                                        |
| 78 | - $this->db->rollback();  | 
                                                        |
| 79 | - return;  | 
                                                        |
| 80 | - }  | 
                                                        |
| 81 | -  | 
                                                        |
| 82 | -	    $this->flash->success($this->translation->_('ms_SuccessfulSaved')); | 
                                                        |
| 83 | - $this->view->success=true;  | 
                                                        |
| 84 | - $this->db->commit();  | 
                                                        |
| 85 | -  | 
                                                        |
| 86 | - // Если это было создание карточки то надо перегрузить страницу с указанием ID  | 
                                                        |
| 87 | -	    if (empty($data['id'])){ | 
                                                        |
| 88 | -		    $this->view->reload = "conference-rooms/modify/{$data['uniqid']}"; | 
                                                        |
| 89 | - }  | 
                                                        |
| 82 | +        $this->flash->success($this->translation->_('ms_SuccessfulSaved')); | 
                                                        |
| 83 | + $this->view->success=true;  | 
                                                        |
| 84 | + $this->db->commit();  | 
                                                        |
| 85 | +  | 
                                                        |
| 86 | + // Если это было создание карточки то надо перегрузить страницу с указанием ID  | 
                                                        |
| 87 | +        if (empty($data['id'])){ | 
                                                        |
| 88 | +            $this->view->reload = "conference-rooms/modify/{$data['uniqid']}"; | 
                                                        |
| 89 | + }  | 
                                                        |
| 90 | + }  | 
                                                        |
| 91 | +  | 
                                                        |
| 92 | +  | 
                                                        |
| 93 | + /**  | 
                                                        |
| 94 | + * Удаление конференцкомнаты  | 
                                                        |
| 95 | + * @param string|NULL $uniqid  | 
                                                        |
| 96 | + */  | 
                                                        |
| 97 | +    public function deleteAction(string $uniqid=null){ | 
                                                        |
| 98 | + $this->db->begin();  | 
                                                        |
| 99 | + $queue = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        |
| 100 | +  | 
                                                        |
| 101 | + $errors = false;  | 
                                                        |
| 102 | + if($queue && !$queue->Extensions->delete())  | 
                                                        |
| 103 | + $errors = $queue->Extensions->getMessages();  | 
                                                        |
| 104 | +  | 
                                                        |
| 105 | +        if ($errors){ | 
                                                        |
| 106 | +            $this->flash->warning(implode('<br>', $errors)); | 
                                                        |
| 107 | + $this->db->rollback();  | 
                                                        |
| 108 | + }  | 
                                                        |
| 109 | + else  | 
                                                        |
| 110 | +        { | 
                                                        |
| 111 | + $this->db->commit();  | 
                                                        |
| 112 | + }  | 
                                                        |
| 113 | +        return $this->forward('conference-rooms/index'); | 
                                                        |
| 90 | 114 | }  | 
                                                        
| 91 | 115 | |
| 92 | 116 | |
| 93 | 117 | /**  | 
                                                        
| 94 | - * Удаление конференцкомнаты  | 
                                                        |
| 95 | - * @param string|NULL $uniqid  | 
                                                        |
| 96 | - */  | 
                                                        |
| 97 | -	public function deleteAction(string $uniqid=null){ | 
                                                        |
| 98 | - $this->db->begin();  | 
                                                        |
| 99 | - $queue = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        |
| 100 | -  | 
                                                        |
| 101 | - $errors = false;  | 
                                                        |
| 102 | - if($queue && !$queue->Extensions->delete())  | 
                                                        |
| 103 | - $errors = $queue->Extensions->getMessages();  | 
                                                        |
| 104 | -  | 
                                                        |
| 105 | -	    if ($errors){ | 
                                                        |
| 106 | -		    $this->flash->warning(implode('<br>', $errors)); | 
                                                        |
| 107 | - $this->db->rollback();  | 
                                                        |
| 108 | - }  | 
                                                        |
| 109 | - else  | 
                                                        |
| 110 | -	    { | 
                                                        |
| 111 | - $this->db->commit();  | 
                                                        |
| 112 | - }  | 
                                                        |
| 113 | -	    return $this->forward('conference-rooms/index'); | 
                                                        |
| 118 | + * Обновление параметров внутреннего номера  | 
                                                        |
| 119 | + * @param \Models\Extensions $extension  | 
                                                        |
| 120 | + * @param array $data массив полей из POST запроса  | 
                                                        |
| 121 | + * @return bool update result  | 
                                                        |
| 122 | + */  | 
                                                        |
| 123 | +    private function updateExtension(Extensions $extension, array $data){ | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | + $extension->number=$data['extension'];  | 
                                                        |
| 126 | + $extension->callerid=parent::transliterate($data['name']);  | 
                                                        |
| 127 | +        if ($extension->save()=== false){ | 
                                                        |
| 128 | + $errors = $extension->getMessages();  | 
                                                        |
| 129 | +            $this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 130 | + return false;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | +  | 
                                                        |
| 133 | + return TRUE;  | 
                                                        |
| 134 | +  | 
                                                        |
| 114 | 135 | }  | 
                                                        
| 115 | 136 | |
| 116 | 137 | |
| 117 | 138 | /**  | 
                                                        
| 118 | - * Обновление параметров внутреннего номера  | 
                                                        |
| 119 | - * @param \Models\Extensions $extension  | 
                                                        |
| 120 | - * @param array $data массив полей из POST запроса  | 
                                                        |
| 121 | - * @return bool update result  | 
                                                        |
| 122 | - */  | 
                                                        |
| 123 | -	private function updateExtension(Extensions $extension, array $data){ | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | - $extension->number=$data['extension'];  | 
                                                        |
| 126 | - $extension->callerid=parent::transliterate($data['name']);  | 
                                                        |
| 127 | -		if ($extension->save()=== false){ | 
                                                        |
| 128 | - $errors = $extension->getMessages();  | 
                                                        |
| 129 | -			$this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 130 | - return false;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 132 | -  | 
                                                        |
| 133 | - return TRUE;  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | - }  | 
                                                        |
| 136 | -  | 
                                                        |
| 137 | -  | 
                                                        |
| 138 | - /**  | 
                                                        |
| 139 | - * Обновление параметров очереди  | 
                                                        |
| 140 | - * @param \Models\ConferenceRooms $room  | 
                                                        |
| 141 | - * @param array $data массив полей из POST запроса  | 
                                                        |
| 142 | - * @return bool update result  | 
                                                        |
| 143 | - */  | 
                                                        |
| 144 | -	private function updateConferenceRoom(ConferenceRooms $room, array $data){ | 
                                                        |
| 145 | -		foreach ($room as $name => $value) { | 
                                                        |
| 146 | -			switch ($name){ | 
                                                        |
| 147 | - case "extension":  | 
                                                        |
| 148 | - $room->$name = $data[$name];  | 
                                                        |
| 149 | - break;  | 
                                                        |
| 150 | - case "name":  | 
                                                        |
| 151 | - $room->$name = $data[$name];  | 
                                                        |
| 152 | - break;  | 
                                                        |
| 153 | - default:  | 
                                                        |
| 154 | - if (!array_key_exists( $name, $data)) continue;  | 
                                                        |
| 155 | - $room->$name = $data[$name];  | 
                                                        |
| 156 | - }  | 
                                                        |
| 157 | - }  | 
                                                        |
| 158 | -		if ($room->save()=== false){ | 
                                                        |
| 159 | - $errors = $room->getMessages();  | 
                                                        |
| 160 | -			$this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 161 | - return false;  | 
                                                        |
| 162 | - }  | 
                                                        |
| 163 | -  | 
                                                        |
| 164 | - return TRUE;  | 
                                                        |
| 165 | - }  | 
                                                        |
| 139 | + * Обновление параметров очереди  | 
                                                        |
| 140 | + * @param \Models\ConferenceRooms $room  | 
                                                        |
| 141 | + * @param array $data массив полей из POST запроса  | 
                                                        |
| 142 | + * @return bool update result  | 
                                                        |
| 143 | + */  | 
                                                        |
| 144 | +    private function updateConferenceRoom(ConferenceRooms $room, array $data){ | 
                                                        |
| 145 | +        foreach ($room as $name => $value) { | 
                                                        |
| 146 | +            switch ($name){ | 
                                                        |
| 147 | + case "extension":  | 
                                                        |
| 148 | + $room->$name = $data[$name];  | 
                                                        |
| 149 | + break;  | 
                                                        |
| 150 | + case "name":  | 
                                                        |
| 151 | + $room->$name = $data[$name];  | 
                                                        |
| 152 | + break;  | 
                                                        |
| 153 | + default:  | 
                                                        |
| 154 | + if (!array_key_exists( $name, $data)) continue;  | 
                                                        |
| 155 | + $room->$name = $data[$name];  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | + }  | 
                                                        |
| 158 | +        if ($room->save()=== false){ | 
                                                        |
| 159 | + $errors = $room->getMessages();  | 
                                                        |
| 160 | +            $this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 161 | + return false;  | 
                                                        |
| 162 | + }  | 
                                                        |
| 163 | +  | 
                                                        |
| 164 | + return TRUE;  | 
                                                        |
| 165 | + }  | 
                                                        |
| 166 | 166 | }  | 
                                                        
| 167 | 167 | \ No newline at end of file  | 
                                                        
@@ -29,15 +29,15 @@ discard block  | 
                                                    ||
| 29 | 29 | *  | 
                                                        
| 30 | 30 | * @param string|NULL $uniqid  | 
                                                        
| 31 | 31 | */  | 
                                                        
| 32 | -	public function modifyAction(string $uniqid=null){ | 
                                                        |
| 32 | +	public function modifyAction(string $uniqid = null) { | 
                                                        |
| 33 | 33 | $record = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        
| 34 | -        if (!$record){ | 
                                                        |
| 35 | - $record = new ConferenceRooms();  | 
                                                        |
| 34 | +        if (!$record) { | 
                                                        |
| 35 | + $record = new ConferenceRooms();  | 
                                                        |
| 36 | 36 |  	        $record->uniqid    = strtoupper('CONFERENCE-'.md5(time())); | 
                                                        
| 37 | 37 | $record->extension = Extensions::getNextFreeApplicationNumber();  | 
                                                        
| 38 | 38 | }  | 
                                                        
| 39 | 39 | $this->view->form = new ConferenceRoomEditForm($record);  | 
                                                        
| 40 | - $this->view->represent = $record->getRepresent();  | 
                                                        |
| 40 | + $this->view->represent = $record->getRepresent();  | 
                                                        |
| 41 | 41 | |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
@@ -51,7 +51,7 @@ discard block  | 
                                                    ||
| 51 | 51 | $this->db->begin();  | 
                                                        
| 52 | 52 | $data = $this->request->getPost();  | 
                                                        
| 53 | 53 | $room = ConferenceRooms::findFirstByUniqid($data['uniqid']);  | 
                                                        
| 54 | -        if (!$room)  { | 
                                                        |
| 54 | +        if (!$room) { | 
                                                        |
| 55 | 55 | $room = new ConferenceRooms();  | 
                                                        
| 56 | 56 | $extension = new Extensions();  | 
                                                        
| 57 | 57 | $extension->type = "CONFERENCE";  | 
                                                        
@@ -66,25 +66,25 @@ discard block  | 
                                                    ||
| 66 | 66 | }  | 
                                                        
| 67 | 67 | |
| 68 | 68 | // Заполним параметры внутреннего номера  | 
                                                        
| 69 | -	    if (!$this->updateExtension($extension, $data)){ | 
                                                        |
| 70 | - $this->view->success=false;  | 
                                                        |
| 69 | +	    if (!$this->updateExtension($extension, $data)) { | 
                                                        |
| 70 | + $this->view->success = false;  | 
                                                        |
| 71 | 71 | $this->db->rollback();  | 
                                                        
| 72 | 72 | return;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
| 75 | 75 | // Заполним параметры участников очереди  | 
                                                        
| 76 | -	    if (!$this->updateConferenceRoom($room, $data)){ | 
                                                        |
| 77 | - $this->view->success=false;  | 
                                                        |
| 76 | +	    if (!$this->updateConferenceRoom($room, $data)) { | 
                                                        |
| 77 | + $this->view->success = false;  | 
                                                        |
| 78 | 78 | $this->db->rollback();  | 
                                                        
| 79 | 79 | return;  | 
                                                        
| 80 | 80 | }  | 
                                                        
| 81 | 81 | |
| 82 | 82 |  	    $this->flash->success($this->translation->_('ms_SuccessfulSaved')); | 
                                                        
| 83 | - $this->view->success=true;  | 
                                                        |
| 83 | + $this->view->success = true;  | 
                                                        |
| 84 | 84 | $this->db->commit();  | 
                                                        
| 85 | 85 | |
| 86 | 86 | // Если это было создание карточки то надо перегрузить страницу с указанием ID  | 
                                                        
| 87 | -	    if (empty($data['id'])){ | 
                                                        |
| 87 | +	    if (empty($data['id'])) { | 
                                                        |
| 88 | 88 |  		    $this->view->reload = "conference-rooms/modify/{$data['uniqid']}"; | 
                                                        
| 89 | 89 | }  | 
                                                        
| 90 | 90 | }  | 
                                                        
@@ -94,15 +94,15 @@ discard block  | 
                                                    ||
| 94 | 94 | * Удаление конференцкомнаты  | 
                                                        
| 95 | 95 | * @param string|NULL $uniqid  | 
                                                        
| 96 | 96 | */  | 
                                                        
| 97 | -	public function deleteAction(string $uniqid=null){ | 
                                                        |
| 97 | +	public function deleteAction(string $uniqid = null) { | 
                                                        |
| 98 | 98 | $this->db->begin();  | 
                                                        
| 99 | 99 | $queue = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        
| 100 | 100 | |
| 101 | 101 | $errors = false;  | 
                                                        
| 102 | - if($queue && !$queue->Extensions->delete())  | 
                                                        |
| 102 | + if ($queue && !$queue->Extensions->delete())  | 
                                                        |
| 103 | 103 | $errors = $queue->Extensions->getMessages();  | 
                                                        
| 104 | 104 | |
| 105 | -	    if ($errors){ | 
                                                        |
| 105 | +	    if ($errors) { | 
                                                        |
| 106 | 106 |  		    $this->flash->warning(implode('<br>', $errors)); | 
                                                        
| 107 | 107 | $this->db->rollback();  | 
                                                        
| 108 | 108 | }  | 
                                                        
@@ -120,11 +120,11 @@ discard block  | 
                                                    ||
| 120 | 120 | * @param array $data массив полей из POST запроса  | 
                                                        
| 121 | 121 | * @return bool update result  | 
                                                        
| 122 | 122 | */  | 
                                                        
| 123 | -	private function updateExtension(Extensions $extension, array $data){ | 
                                                        |
| 123 | +	private function updateExtension(Extensions $extension, array $data) { | 
                                                        |
| 124 | 124 | |
| 125 | - $extension->number=$data['extension'];  | 
                                                        |
| 126 | - $extension->callerid=parent::transliterate($data['name']);  | 
                                                        |
| 127 | -		if ($extension->save()=== false){ | 
                                                        |
| 125 | + $extension->number = $data['extension'];  | 
                                                        |
| 126 | + $extension->callerid = parent::transliterate($data['name']);  | 
                                                        |
| 127 | +		if ($extension->save() === false) { | 
                                                        |
| 128 | 128 | $errors = $extension->getMessages();  | 
                                                        
| 129 | 129 |  			$this->flash->error(implode('<br>', $errors)); | 
                                                        
| 130 | 130 | return false;  | 
                                                        
@@ -141,9 +141,9 @@ discard block  | 
                                                    ||
| 141 | 141 | * @param array $data массив полей из POST запроса  | 
                                                        
| 142 | 142 | * @return bool update result  | 
                                                        
| 143 | 143 | */  | 
                                                        
| 144 | -	private function updateConferenceRoom(ConferenceRooms $room, array $data){ | 
                                                        |
| 144 | +	private function updateConferenceRoom(ConferenceRooms $room, array $data) { | 
                                                        |
| 145 | 145 |  		foreach ($room as $name => $value) { | 
                                                        
| 146 | -			switch ($name){ | 
                                                        |
| 146 | +			switch ($name) { | 
                                                        |
| 147 | 147 | case "extension":  | 
                                                        
| 148 | 148 | $room->$name = $data[$name];  | 
                                                        
| 149 | 149 | break;  | 
                                                        
@@ -151,11 +151,11 @@ discard block  | 
                                                    ||
| 151 | 151 | $room->$name = $data[$name];  | 
                                                        
| 152 | 152 | break;  | 
                                                        
| 153 | 153 | default:  | 
                                                        
| 154 | - if (!array_key_exists( $name, $data)) continue;  | 
                                                        |
| 154 | + if (!array_key_exists($name, $data)) continue;  | 
                                                        |
| 155 | 155 | $room->$name = $data[$name];  | 
                                                        
| 156 | 156 | }  | 
                                                        
| 157 | 157 | }  | 
                                                        
| 158 | -		if ($room->save()=== false){ | 
                                                        |
| 158 | +		if ($room->save() === false) { | 
                                                        |
| 159 | 159 | $errors = $room->getMessages();  | 
                                                        
| 160 | 160 |  			$this->flash->error(implode('<br>', $errors)); | 
                                                        
| 161 | 161 | return false;  | 
                                                        
@@ -47,7 +47,9 @@ discard block  | 
                                                    ||
| 47 | 47 | */  | 
                                                        
| 48 | 48 | public function saveAction()  | 
                                                        
| 49 | 49 |      { | 
                                                        
| 50 | - if (!$this->request->isPost()) return;  | 
                                                        |
| 50 | +        if (!$this->request->isPost()) { | 
                                                        |
| 51 | + return;  | 
                                                        |
| 52 | + }  | 
                                                        |
| 51 | 53 | $this->db->begin();  | 
                                                        
| 52 | 54 | $data = $this->request->getPost();  | 
                                                        
| 53 | 55 | $room = ConferenceRooms::findFirstByUniqid($data['uniqid']);  | 
                                                        
@@ -99,14 +101,14 @@ discard block  | 
                                                    ||
| 99 | 101 | $queue = ConferenceRooms::findFirstByUniqid($uniqid);  | 
                                                        
| 100 | 102 | |
| 101 | 103 | $errors = false;  | 
                                                        
| 102 | - if($queue && !$queue->Extensions->delete())  | 
                                                        |
| 103 | - $errors = $queue->Extensions->getMessages();  | 
                                                        |
| 104 | +	    if($queue && !$queue->Extensions->delete()) { | 
                                                        |
| 105 | + $errors = $queue->Extensions->getMessages();  | 
                                                        |
| 106 | + }  | 
                                                        |
| 104 | 107 | |
| 105 | 108 |  	    if ($errors){ | 
                                                        
| 106 | 109 |  		    $this->flash->warning(implode('<br>', $errors)); | 
                                                        
| 107 | 110 | $this->db->rollback();  | 
                                                        
| 108 | - }  | 
                                                        |
| 109 | - else  | 
                                                        |
| 111 | + } else  | 
                                                        |
| 110 | 112 |  	    { | 
                                                        
| 111 | 113 | $this->db->commit();  | 
                                                        
| 112 | 114 | }  | 
                                                        
@@ -151,7 +153,9 @@ discard block  | 
                                                    ||
| 151 | 153 | $room->$name = $data[$name];  | 
                                                        
| 152 | 154 | break;  | 
                                                        
| 153 | 155 | default:  | 
                                                        
| 154 | - if (!array_key_exists( $name, $data)) continue;  | 
                                                        |
| 156 | +					if (!array_key_exists( $name, $data)) { | 
                                                        |
| 157 | + continue;  | 
                                                        |
| 158 | + }  | 
                                                        |
| 155 | 159 | $room->$name = $data[$name];  | 
                                                        
| 156 | 160 | }  | 
                                                        
| 157 | 161 | }  | 
                                                        
@@ -24,7 +24,7 @@ discard block  | 
                                                    ||
| 24 | 24 |      { | 
                                                        
| 25 | 25 |          $licKey = PbxSettings::getValueByKey('PBXLicense'); | 
                                                        
| 26 | 26 | if (strlen($licKey) !== 28  | 
                                                        
| 27 | -            || ! Text::startsWith($licKey, 'MIKO-')) { | 
                                                        |
| 27 | +            || !Text::startsWith($licKey, 'MIKO-')) { | 
                                                        |
| 28 | 28 |              return $this->forward('licensing/modify/pbx-extension-modules'); | 
                                                        
| 29 | 29 | }  | 
                                                        
| 30 | 30 | // Очистим кеш хранилища для получения актульной информации о свободном месте  | 
                                                        
@@ -62,7 +62,7 @@ discard block  | 
                                                    ||
| 62 | 62 | $unCamelizedControllerName = Text::uncamelize($uniqid, '-');  | 
                                                        
| 63 | 63 | $previousMenuSettings = PbxSettings::findFirstByKey($menuSettings);  | 
                                                        
| 64 | 64 | $this->view->showAtMainMenu = $previousMenuSettings !== false;  | 
                                                        
| 65 | -        if ( ! $previousMenuSettings) { | 
                                                        |
| 65 | +        if (!$previousMenuSettings) { | 
                                                        |
| 66 | 66 | $previousMenuSettings = new PbxSettings();  | 
                                                        
| 67 | 67 | $previousMenuSettings->key = $menuSettings;  | 
                                                        
| 68 | 68 | $value = [  | 
                                                        
@@ -77,7 +77,7 @@ discard block  | 
                                                    ||
| 77 | 77 | }  | 
                                                        
| 78 | 78 | $options = json_decode($previousMenuSettings->value, true);  | 
                                                        
| 79 | 79 | $this->view->form = new PbxExtensionModuleSettingsForm($previousMenuSettings, $options);  | 
                                                        
| 80 | -        $this->view->title      = $this->translation->_('ext_SettingsForModule') . ' ' . $this->translation->_("Breadcrumb$uniqid"); | 
                                                        |
| 80 | +        $this->view->title      = $this->translation->_('ext_SettingsForModule').' '.$this->translation->_("Breadcrumb$uniqid"); | 
                                                        |
| 81 | 81 | $this->view->submitMode = null;  | 
                                                        
| 82 | 82 | $this->view->indexUrl = $unCamelizedControllerName;  | 
                                                        
| 83 | 83 | }  | 
                                                        
@@ -89,17 +89,17 @@ discard block  | 
                                                    ||
| 89 | 89 | public function saveModuleSettingsAction(): void  | 
                                                        
| 90 | 90 |      { | 
                                                        
| 91 | 91 | |
| 92 | -        if ( ! $this->request->isPost()) { | 
                                                        |
| 92 | +        if (!$this->request->isPost()) { | 
                                                        |
| 93 | 93 | return;  | 
                                                        
| 94 | 94 | }  | 
                                                        
| 95 | 95 | $data = $this->request->getPost();  | 
                                                        
| 96 | 96 | |
| 97 | 97 | $record = PbxSettings::findFirstByKey($data['key']);  | 
                                                        
| 98 | -        if ( ! $record) { | 
                                                        |
| 98 | +        if (!$record) { | 
                                                        |
| 99 | 99 | $record = new PbxSettings();  | 
                                                        
| 100 | 100 | $record->key = $data['key'];  | 
                                                        
| 101 | 101 | }  | 
                                                        
| 102 | - $value = [  | 
                                                        |
| 102 | + $value = [  | 
                                                        |
| 103 | 103 | 'uniqid' => $data['uniqid'],  | 
                                                        
| 104 | 104 | 'href' => $data['href'],  | 
                                                        
| 105 | 105 | 'group' => $data['menu-group'],  | 
                                                        
@@ -163,8 +163,8 @@ discard block  | 
                                                    ||
| 163 | 163 | $controller = new $controllerClass();  | 
                                                        
| 164 | 164 |              if ($controller->enableAction() === false) { | 
                                                        
| 165 | 165 | $messages = $this->flash->getMessages();  | 
                                                        
| 166 | -                if ($messages){ | 
                                                        |
| 167 | -                    foreach ($messages as $index=>$message){ | 
                                                        |
| 166 | +                if ($messages) { | 
                                                        |
| 167 | +                    foreach ($messages as $index=>$message) { | 
                                                        |
| 168 | 168 | $this->flash->$index($message[0]);  | 
                                                        
| 169 | 169 | }  | 
                                                        
| 170 | 170 |                  } else { | 
                                                        
@@ -179,8 +179,8 @@ discard block  | 
                                                    ||
| 179 | 179 | // Проверим нет ли битых ссылок, которые мешают включить модуль  | 
                                                        
| 180 | 180 | // например удалили сотрудника, а модуль указывает на его extension  | 
                                                        
| 181 | 181 | //  | 
                                                        
| 182 | - $moduleModelsDir = $this->config->application->modulesDir . $uniqid . '/Models';  | 
                                                        |
| 183 | - $results = glob($moduleModelsDir . '/*.php', GLOB_NOSORT);  | 
                                                        |
| 182 | + $moduleModelsDir = $this->config->application->modulesDir.$uniqid.'/Models';  | 
                                                        |
| 183 | + $results = glob($moduleModelsDir.'/*.php', GLOB_NOSORT);  | 
                                                        |
| 184 | 184 |          foreach ($results as $file) { | 
                                                        
| 185 | 185 | $className = pathinfo($file)['filename'];  | 
                                                        
| 186 | 186 |              $moduleModelClass = "\\Modules\\{$uniqid}\\Models\\{$className}"; | 
                                                        
@@ -213,18 +213,18 @@ discard block  | 
                                                    ||
| 213 | 213 | }  | 
                                                        
| 214 | 214 | }  | 
                                                        
| 215 | 215 | }  | 
                                                        
| 216 | -        if (!$error){ | 
                                                        |
| 216 | +        if (!$error) { | 
                                                        |
| 217 | 217 | $this->flash->clear();  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | 219 |          $this->db->rollback('temporary'); // Откатываем временную транзакцию | 
                                                        
| 220 | 220 | |
| 221 | 221 | // Если ошибок нет, включаем Firewall и модуль  | 
                                                        
| 222 | -        if ( ! $error && ! $this->enableFirewallSettings($uniqid)) { | 
                                                        |
| 222 | +        if (!$error && !$this->enableFirewallSettings($uniqid)) { | 
                                                        |
| 223 | 223 |              $this->flash->error('Error on enable firewall settings'); | 
                                                        
| 224 | 224 | |
| 225 | 225 | return;  | 
                                                        
| 226 | 226 | }  | 
                                                        
| 227 | -        if ( ! $error) { | 
                                                        |
| 227 | +        if (!$error) { | 
                                                        |
| 228 | 228 | $module = PbxExtensionModules::findFirstByUniqid($uniqid);  | 
                                                        
| 229 | 229 |              if ($module) { | 
                                                        
| 230 | 230 | $module->disabled = '0';  | 
                                                        
@@ -252,7 +252,7 @@ discard block  | 
                                                    ||
| 252 | 252 | $this->view->success = false;  | 
                                                        
| 253 | 253 | |
| 254 | 254 |          $controllerClass = "{$uniqid}Controller"; | 
                                                        
| 255 | -        if ( ! class_exists($controllerClass)) { | 
                                                        |
| 255 | +        if (!class_exists($controllerClass)) { | 
                                                        |
| 256 | 256 |              $this->flash->error("Class {$controllerClass} doesn't exist"); | 
                                                        
| 257 | 257 | |
| 258 | 258 | return;  | 
                                                        
@@ -268,8 +268,8 @@ discard block  | 
                                                    ||
| 268 | 268 | $controller = new $controllerClass();  | 
                                                        
| 269 | 269 |              if ($controller->disableAction() === false) { | 
                                                        
| 270 | 270 | $messages = $this->flash->getMessages();  | 
                                                        
| 271 | -                if ($messages){ | 
                                                        |
| 272 | -                    foreach ($messages as $index=>$message){ | 
                                                        |
| 271 | +                if ($messages) { | 
                                                        |
| 272 | +                    foreach ($messages as $index=>$message) { | 
                                                        |
| 273 | 273 | $this->flash->$index($message[0]);  | 
                                                        
| 274 | 274 | }  | 
                                                        
| 275 | 275 |                  } else { | 
                                                        
@@ -285,8 +285,8 @@ discard block  | 
                                                    ||
| 285 | 285 | // Попытаемся удалить текущий модуль, если ошибок не будет, значит можно выклчать  | 
                                                        
| 286 | 286 | // Например на модуль может ссылаться запись в таблице Extensions, которую надо удалить при отключении  | 
                                                        
| 287 | 287 | // модуля  | 
                                                        
| 288 | - $moduleModelsDir = $this->config->application->modulesDir . $uniqid . '/Models';  | 
                                                        |
| 289 | - $results = glob($moduleModelsDir . '/*.php', GLOB_NOSORT);  | 
                                                        |
| 288 | + $moduleModelsDir = $this->config->application->modulesDir.$uniqid.'/Models';  | 
                                                        |
| 289 | + $results = glob($moduleModelsDir.'/*.php', GLOB_NOSORT);  | 
                                                        |
| 290 | 290 |          foreach ($results as $file) { | 
                                                        
| 291 | 291 | $className = pathinfo($file)['filename'];  | 
                                                        
| 292 | 292 |              $moduleModelClass = "\\Modules\\{$uniqid}\\Models\\{$className}"; | 
                                                        
@@ -314,12 +314,12 @@ discard block  | 
                                                    ||
| 314 | 314 | $parameters['bind'] = [];  | 
                                                        
| 315 | 315 |                              foreach ($mappedFields as $index => $mappedField) { | 
                                                        
| 316 | 316 | $parameters['conditions'] .= $index > 0 ? ' OR ' : '';  | 
                                                        
| 317 | - $parameters['conditions'] .= $mappedField . '= :field' . $index . ':';  | 
                                                        |
| 317 | + $parameters['conditions'] .= $mappedField.'= :field'.$index.':';  | 
                                                        |
| 318 | 318 | $bindField = $referencedFields[$index];  | 
                                                        
| 319 | - $parameters['bind']['field' . $index] = $record->$bindField;  | 
                                                        |
| 319 | + $parameters['bind']['field'.$index] = $record->$bindField;  | 
                                                        |
| 320 | 320 | }  | 
                                                        
| 321 | 321 | $relatedRecords = $relatedModel::find($parameters);  | 
                                                        
| 322 | -                            if ( ! $error && ! $relatedRecords->delete()) { | 
                                                        |
| 322 | +                            if (!$error && !$relatedRecords->delete()) { | 
                                                        |
| 323 | 323 | $error = true;  | 
                                                        
| 324 | 324 | $this->flash->error($relatedRecords->getMessages());  | 
                                                        
| 325 | 325 | }  | 
                                                        
@@ -328,19 +328,19 @@ discard block  | 
                                                    ||
| 328 | 328 | }  | 
                                                        
| 329 | 329 | }  | 
                                                        
| 330 | 330 | }  | 
                                                        
| 331 | -        if (!$error){ | 
                                                        |
| 331 | +        if (!$error) { | 
                                                        |
| 332 | 332 | $this->flash->clear();  | 
                                                        
| 333 | 333 | }  | 
                                                        
| 334 | 334 |          $this->db->rollback('temporary'); // Откатываем временную транзакцию | 
                                                        
| 335 | 335 | |
| 336 | 336 | // Если ошибок нет, выключаем Firewall и модуль  | 
                                                        
| 337 | -        if ( ! $error && ! $this->disableFirewallSettings($uniqid)) { | 
                                                        |
| 337 | +        if (!$error && !$this->disableFirewallSettings($uniqid)) { | 
                                                        |
| 338 | 338 |              $this->flash->error('Error on disable firewall settings'); | 
                                                        
| 339 | 339 | |
| 340 | 340 | return;  | 
                                                        
| 341 | 341 | }  | 
                                                        
| 342 | 342 | |
| 343 | -        if ( ! $error) { | 
                                                        |
| 343 | +        if (!$error) { | 
                                                        |
| 344 | 344 | $module = PbxExtensionModules::findFirstByUniqid($uniqid);  | 
                                                        
| 345 | 345 |              if ($module) { | 
                                                        
| 346 | 346 | $module->disabled = '1';  | 
                                                        
@@ -368,7 +368,7 @@ discard block  | 
                                                    ||
| 368 | 368 | protected function enableFirewallSettings($uniqid): bool  | 
                                                        
| 369 | 369 |      { | 
                                                        
| 370 | 370 |          $class = "\\Modules\\{$uniqid}\\setup\\FirewallRules"; | 
                                                        
| 371 | -        if ( ! class_exists($class)) { | 
                                                        |
| 371 | +        if (!class_exists($class)) { | 
                                                        |
| 372 | 372 | return true;  | 
                                                        
| 373 | 373 | }  | 
                                                        
| 374 | 374 | $this->db->begin();  | 
                                                        
@@ -402,7 +402,7 @@ discard block  | 
                                                    ||
| 402 | 402 |                  if (array_key_exists($network->id, $previousRules)) { | 
                                                        
| 403 | 403 | $newRule->action = $previousRules[$network->id];  | 
                                                        
| 404 | 404 | }  | 
                                                        
| 405 | -                if ( ! $newRule->save()) { | 
                                                        |
| 405 | +                if (!$newRule->save()) { | 
                                                        |
| 406 | 406 | $errors[] = $newRule->getMessages();  | 
                                                        
| 407 | 407 | }  | 
                                                        
| 408 | 408 | }  | 
                                                        
@@ -430,7 +430,7 @@ discard block  | 
                                                    ||
| 430 | 430 | protected function disableFirewallSettings($uniqid): bool  | 
                                                        
| 431 | 431 |      { | 
                                                        
| 432 | 432 |          $class = "\\Modules\\{$uniqid}\\setup\\FirewallRules"; | 
                                                        
| 433 | -        if ( ! class_exists($class)) { | 
                                                        |
| 433 | +        if (!class_exists($class)) { | 
                                                        |
| 434 | 434 | return true;  | 
                                                        
| 435 | 435 | }  | 
                                                        
| 436 | 436 | $errors = [];  | 
                                                        
@@ -442,7 +442,7 @@ discard block  | 
                                                    ||
| 442 | 442 | $savedState[$detailRule->networkfilterid] = $detailRule->action;  | 
                                                        
| 443 | 443 | }  | 
                                                        
| 444 | 444 | $this->db->begin();  | 
                                                        
| 445 | -        if ( ! $currentRules->delete()) { | 
                                                        |
| 445 | +        if (!$currentRules->delete()) { | 
                                                        |
| 446 | 446 | $errors[] = $currentRules->getMessages();  | 
                                                        
| 447 | 447 | }  | 
                                                        
| 448 | 448 | |
@@ -452,7 +452,7 @@ discard block  | 
                                                    ||
| 452 | 452 |              $previousRuleSettings->key = "{$uniqid}FirewallSettings"; | 
                                                        
| 453 | 453 | }  | 
                                                        
| 454 | 454 | $previousRuleSettings->value = json_encode($savedState);  | 
                                                        
| 455 | -        if ( ! $previousRuleSettings->save()) { | 
                                                        |
| 455 | +        if (!$previousRuleSettings->save()) { | 
                                                        |
| 456 | 456 | $errors[] = $previousRuleSettings->getMessages();  | 
                                                        
| 457 | 457 | }  | 
                                                        
| 458 | 458 |          if (count($errors) > 0) { | 
                                                        
@@ -8,143 +8,143 @@  | 
                                                    ||
| 8 | 8 | */  | 
                                                        
| 9 | 9 | |
| 10 | 10 | use Models\AsteriskManagerUsers,  | 
                                                        
| 11 | - Models\NetworkFilters;  | 
                                                        |
| 11 | + Models\NetworkFilters;  | 
                                                        |
| 12 | 12 | use Phalcon\Mvc\Model\Resultset;  | 
                                                        
| 13 | 13 | |
| 14 | 14 |  class AsteriskManagersController extends BaseController { | 
                                                        
| 15 | 15 | |
| 16 | - private $arrCheckBoxes;  | 
                                                        |
| 17 | -  | 
                                                        |
| 18 | - /**  | 
                                                        |
| 19 | - * Инициализация базового класса  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | -	public function initialize() :void{ | 
                                                        |
| 22 | - $this->arrCheckBoxes = [  | 
                                                        |
| 23 | - 'call',  | 
                                                        |
| 24 | - 'cdr',  | 
                                                        |
| 25 | - 'originate',  | 
                                                        |
| 26 | - 'reporting',  | 
                                                        |
| 27 | - 'agent',  | 
                                                        |
| 28 | - 'config',  | 
                                                        |
| 29 | - 'dialplan',  | 
                                                        |
| 30 | - 'dtmf',  | 
                                                        |
| 31 | - 'log',  | 
                                                        |
| 32 | - 'system',  | 
                                                        |
| 33 | - 'user',  | 
                                                        |
| 34 | - 'verbose',  | 
                                                        |
| 35 | - ];  | 
                                                        |
| 36 | - parent::initialize();  | 
                                                        |
| 37 | - }  | 
                                                        |
| 38 | -  | 
                                                        |
| 39 | - /**  | 
                                                        |
| 40 | - * Построение списка пользователей Asterisk Managers  | 
                                                        |
| 41 | - */  | 
                                                        |
| 42 | -	public function indexAction() { | 
                                                        |
| 43 | - $amiUsers = AsteriskManagerUsers::find();  | 
                                                        |
| 44 | - $amiUsers->setHydrateMode(  | 
                                                        |
| 45 | - Resultset::HYDRATE_ARRAYS  | 
                                                        |
| 46 | - );  | 
                                                        |
| 47 | -  | 
                                                        |
| 48 | - $arrNetworkFilters = [];  | 
                                                        |
| 49 | - $networkFilters = NetworkFilters::find();  | 
                                                        |
| 50 | -		foreach ( $networkFilters as $filter ) { | 
                                                        |
| 51 | - $arrNetworkFilters[ $filter->id ] = $filter->getRepresent();  | 
                                                        |
| 52 | - }  | 
                                                        |
| 53 | - $this->view->networkFilters = $arrNetworkFilters;  | 
                                                        |
| 54 | - $this->view->amiUsers = $amiUsers;  | 
                                                        |
| 55 | - }  | 
                                                        |
| 56 | -  | 
                                                        |
| 57 | -  | 
                                                        |
| 58 | - /**  | 
                                                        |
| 59 | - * Форма настроек пользователя Asterisk Managers  | 
                                                        |
| 60 | - *  | 
                                                        |
| 61 | - * @param string $id идентификатор редактируемого пользователя  | 
                                                        |
| 62 | - */  | 
                                                        |
| 63 | -	public function modifyAction( $id = NULL ) { | 
                                                        |
| 64 | -  | 
                                                        |
| 65 | - $manager = AsteriskManagerUsers::findFirstById( $id );  | 
                                                        |
| 66 | -		if ( ! $manager ) { | 
                                                        |
| 67 | - $manager = new AsteriskManagerUsers();  | 
                                                        |
| 68 | - }  | 
                                                        |
| 69 | -  | 
                                                        |
| 70 | - $arrNetworkFilters = [];  | 
                                                        |
| 71 | - $networkFilters = NetworkFilters::getAllowedFiltersForType( [  | 
                                                        |
| 72 | - 'AJAM',  | 
                                                        |
| 73 | - 'AMI',  | 
                                                        |
| 74 | - ] );  | 
                                                        |
| 75 | - $arrNetworkFilters['none']  | 
                                                        |
| 76 | - = $this->translation->_( 'ex_NoNetworkFilter' );  | 
                                                        |
| 77 | -		foreach ( $networkFilters as $filter ) { | 
                                                        |
| 78 | - $arrNetworkFilters[ $filter->id ] = $filter->getRepresent();  | 
                                                        |
| 79 | - }  | 
                                                        |
| 80 | -  | 
                                                        |
| 81 | -  | 
                                                        |
| 82 | - $this->view->form = new AsteriskManagerEditForm( $manager,  | 
                                                        |
| 83 | - [  | 
                                                        |
| 84 | - 'network_filters' => $arrNetworkFilters,  | 
                                                        |
| 85 | - 'array_of_checkboxes' => $this->arrCheckBoxes,  | 
                                                        |
| 86 | - ] );  | 
                                                        |
| 87 | -  | 
                                                        |
| 88 | - $this->view->arrCheckBoxes = $this->arrCheckBoxes;  | 
                                                        |
| 89 | - $this->view->represent = $manager->getRepresent();  | 
                                                        |
| 90 | - }  | 
                                                        |
| 91 | -  | 
                                                        |
| 92 | -  | 
                                                        |
| 93 | - /**  | 
                                                        |
| 94 | - * Сохраенение настроек Asterisk Manager  | 
                                                        |
| 95 | - */  | 
                                                        |
| 96 | -	public function saveAction() { | 
                                                        |
| 97 | - if ( ! $this->request->isPost()) return;  | 
                                                        |
| 98 | -  | 
                                                        |
| 99 | - $data = $this->request->getPost();  | 
                                                        |
| 100 | - $manager = false;  | 
                                                        |
| 101 | -		if (isset($data['id'])){ | 
                                                        |
| 102 | - $manager = AsteriskManagerUsers::findFirst( $data['id'] );  | 
                                                        |
| 103 | - }  | 
                                                        |
| 104 | -		if (!$manager) { | 
                                                        |
| 105 | - $manager = new AsteriskManagerUsers();  | 
                                                        |
| 106 | - }  | 
                                                        |
| 107 | -  | 
                                                        |
| 108 | -		foreach ( $manager as $name => $value ) { | 
                                                        |
| 109 | -			if ( in_array( $name, $this->arrCheckBoxes ) ) { | 
                                                        |
| 110 | - $manager->$name = '';  | 
                                                        |
| 111 | - $manager->$name .= ( $data[ $name . '_read' ] === 'on' ) ? 'read' : '';  | 
                                                        |
| 112 | - $manager->$name .= ( $data[ $name . '_write' ] === 'on' ) ? 'write' : '';  | 
                                                        |
| 113 | - continue;  | 
                                                        |
| 114 | - }  | 
                                                        |
| 115 | -  | 
                                                        |
| 116 | -			if ( ! array_key_exists( $name, $data ) ) { | 
                                                        |
| 117 | - continue;  | 
                                                        |
| 118 | - }  | 
                                                        |
| 119 | - $manager->$name = $data[ $name ];  | 
                                                        |
| 120 | -  | 
                                                        |
| 121 | - }  | 
                                                        |
| 122 | - $errors = FALSE;  | 
                                                        |
| 123 | -		if ( ! $manager->save() ) { | 
                                                        |
| 124 | - $errors = $manager->getMessages();  | 
                                                        |
| 125 | - }  | 
                                                        |
| 126 | -  | 
                                                        |
| 127 | -		if ( $errors ) { | 
                                                        |
| 128 | - $this->flash->warning( implode( '<br>', $errors ) );  | 
                                                        |
| 129 | - $this->view->success = false;  | 
                                                        |
| 130 | -		} else { | 
                                                        |
| 131 | - $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) );  | 
                                                        |
| 132 | - $this->view->success = TRUE;  | 
                                                        |
| 133 | -			$this->view->reload = "asterisk-managers/modify/{$manager->id}"; | 
                                                        |
| 134 | - }  | 
                                                        |
| 135 | - }  | 
                                                        |
| 136 | -  | 
                                                        |
| 137 | - /**  | 
                                                        |
| 138 | - * Удаление Asterisk Manager  | 
                                                        |
| 139 | - */  | 
                                                        |
| 140 | -	public function deleteAction( $amiId = NULL ) { | 
                                                        |
| 141 | -  | 
                                                        |
| 142 | - $manager = AsteriskManagerUsers::findFirstByid( $amiId );  | 
                                                        |
| 143 | -		if ( $manager ) { | 
                                                        |
| 144 | - $manager->delete();  | 
                                                        |
| 145 | - }  | 
                                                        |
| 146 | -  | 
                                                        |
| 147 | - return $this->forward( 'asterisk-managers/index' );  | 
                                                        |
| 148 | -  | 
                                                        |
| 149 | - }  | 
                                                        |
| 16 | + private $arrCheckBoxes;  | 
                                                        |
| 17 | +  | 
                                                        |
| 18 | + /**  | 
                                                        |
| 19 | + * Инициализация базового класса  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | +    public function initialize() :void{ | 
                                                        |
| 22 | + $this->arrCheckBoxes = [  | 
                                                        |
| 23 | + 'call',  | 
                                                        |
| 24 | + 'cdr',  | 
                                                        |
| 25 | + 'originate',  | 
                                                        |
| 26 | + 'reporting',  | 
                                                        |
| 27 | + 'agent',  | 
                                                        |
| 28 | + 'config',  | 
                                                        |
| 29 | + 'dialplan',  | 
                                                        |
| 30 | + 'dtmf',  | 
                                                        |
| 31 | + 'log',  | 
                                                        |
| 32 | + 'system',  | 
                                                        |
| 33 | + 'user',  | 
                                                        |
| 34 | + 'verbose',  | 
                                                        |
| 35 | + ];  | 
                                                        |
| 36 | + parent::initialize();  | 
                                                        |
| 37 | + }  | 
                                                        |
| 38 | +  | 
                                                        |
| 39 | + /**  | 
                                                        |
| 40 | + * Построение списка пользователей Asterisk Managers  | 
                                                        |
| 41 | + */  | 
                                                        |
| 42 | +    public function indexAction() { | 
                                                        |
| 43 | + $amiUsers = AsteriskManagerUsers::find();  | 
                                                        |
| 44 | + $amiUsers->setHydrateMode(  | 
                                                        |
| 45 | + Resultset::HYDRATE_ARRAYS  | 
                                                        |
| 46 | + );  | 
                                                        |
| 47 | +  | 
                                                        |
| 48 | + $arrNetworkFilters = [];  | 
                                                        |
| 49 | + $networkFilters = NetworkFilters::find();  | 
                                                        |
| 50 | +        foreach ( $networkFilters as $filter ) { | 
                                                        |
| 51 | + $arrNetworkFilters[ $filter->id ] = $filter->getRepresent();  | 
                                                        |
| 52 | + }  | 
                                                        |
| 53 | + $this->view->networkFilters = $arrNetworkFilters;  | 
                                                        |
| 54 | + $this->view->amiUsers = $amiUsers;  | 
                                                        |
| 55 | + }  | 
                                                        |
| 56 | +  | 
                                                        |
| 57 | +  | 
                                                        |
| 58 | + /**  | 
                                                        |
| 59 | + * Форма настроек пользователя Asterisk Managers  | 
                                                        |
| 60 | + *  | 
                                                        |
| 61 | + * @param string $id идентификатор редактируемого пользователя  | 
                                                        |
| 62 | + */  | 
                                                        |
| 63 | +    public function modifyAction( $id = NULL ) { | 
                                                        |
| 64 | +  | 
                                                        |
| 65 | + $manager = AsteriskManagerUsers::findFirstById( $id );  | 
                                                        |
| 66 | +        if ( ! $manager ) { | 
                                                        |
| 67 | + $manager = new AsteriskManagerUsers();  | 
                                                        |
| 68 | + }  | 
                                                        |
| 69 | +  | 
                                                        |
| 70 | + $arrNetworkFilters = [];  | 
                                                        |
| 71 | + $networkFilters = NetworkFilters::getAllowedFiltersForType( [  | 
                                                        |
| 72 | + 'AJAM',  | 
                                                        |
| 73 | + 'AMI',  | 
                                                        |
| 74 | + ] );  | 
                                                        |
| 75 | + $arrNetworkFilters['none']  | 
                                                        |
| 76 | + = $this->translation->_( 'ex_NoNetworkFilter' );  | 
                                                        |
| 77 | +        foreach ( $networkFilters as $filter ) { | 
                                                        |
| 78 | + $arrNetworkFilters[ $filter->id ] = $filter->getRepresent();  | 
                                                        |
| 79 | + }  | 
                                                        |
| 80 | +  | 
                                                        |
| 81 | +  | 
                                                        |
| 82 | + $this->view->form = new AsteriskManagerEditForm( $manager,  | 
                                                        |
| 83 | + [  | 
                                                        |
| 84 | + 'network_filters' => $arrNetworkFilters,  | 
                                                        |
| 85 | + 'array_of_checkboxes' => $this->arrCheckBoxes,  | 
                                                        |
| 86 | + ] );  | 
                                                        |
| 87 | +  | 
                                                        |
| 88 | + $this->view->arrCheckBoxes = $this->arrCheckBoxes;  | 
                                                        |
| 89 | + $this->view->represent = $manager->getRepresent();  | 
                                                        |
| 90 | + }  | 
                                                        |
| 91 | +  | 
                                                        |
| 92 | +  | 
                                                        |
| 93 | + /**  | 
                                                        |
| 94 | + * Сохраенение настроек Asterisk Manager  | 
                                                        |
| 95 | + */  | 
                                                        |
| 96 | +    public function saveAction() { | 
                                                        |
| 97 | + if ( ! $this->request->isPost()) return;  | 
                                                        |
| 98 | +  | 
                                                        |
| 99 | + $data = $this->request->getPost();  | 
                                                        |
| 100 | + $manager = false;  | 
                                                        |
| 101 | +        if (isset($data['id'])){ | 
                                                        |
| 102 | + $manager = AsteriskManagerUsers::findFirst( $data['id'] );  | 
                                                        |
| 103 | + }  | 
                                                        |
| 104 | +        if (!$manager) { | 
                                                        |
| 105 | + $manager = new AsteriskManagerUsers();  | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | +  | 
                                                        |
| 108 | +        foreach ( $manager as $name => $value ) { | 
                                                        |
| 109 | +            if ( in_array( $name, $this->arrCheckBoxes ) ) { | 
                                                        |
| 110 | + $manager->$name = '';  | 
                                                        |
| 111 | + $manager->$name .= ( $data[ $name . '_read' ] === 'on' ) ? 'read' : '';  | 
                                                        |
| 112 | + $manager->$name .= ( $data[ $name . '_write' ] === 'on' ) ? 'write' : '';  | 
                                                        |
| 113 | + continue;  | 
                                                        |
| 114 | + }  | 
                                                        |
| 115 | +  | 
                                                        |
| 116 | +            if ( ! array_key_exists( $name, $data ) ) { | 
                                                        |
| 117 | + continue;  | 
                                                        |
| 118 | + }  | 
                                                        |
| 119 | + $manager->$name = $data[ $name ];  | 
                                                        |
| 120 | +  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | + $errors = FALSE;  | 
                                                        |
| 123 | +        if ( ! $manager->save() ) { | 
                                                        |
| 124 | + $errors = $manager->getMessages();  | 
                                                        |
| 125 | + }  | 
                                                        |
| 126 | +  | 
                                                        |
| 127 | +        if ( $errors ) { | 
                                                        |
| 128 | + $this->flash->warning( implode( '<br>', $errors ) );  | 
                                                        |
| 129 | + $this->view->success = false;  | 
                                                        |
| 130 | +        } else { | 
                                                        |
| 131 | + $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) );  | 
                                                        |
| 132 | + $this->view->success = TRUE;  | 
                                                        |
| 133 | +            $this->view->reload = "asterisk-managers/modify/{$manager->id}"; | 
                                                        |
| 134 | + }  | 
                                                        |
| 135 | + }  | 
                                                        |
| 136 | +  | 
                                                        |
| 137 | + /**  | 
                                                        |
| 138 | + * Удаление Asterisk Manager  | 
                                                        |
| 139 | + */  | 
                                                        |
| 140 | +    public function deleteAction( $amiId = NULL ) { | 
                                                        |
| 141 | +  | 
                                                        |
| 142 | + $manager = AsteriskManagerUsers::findFirstByid( $amiId );  | 
                                                        |
| 143 | +        if ( $manager ) { | 
                                                        |
| 144 | + $manager->delete();  | 
                                                        |
| 145 | + }  | 
                                                        |
| 146 | +  | 
                                                        |
| 147 | + return $this->forward( 'asterisk-managers/index' );  | 
                                                        |
| 148 | +  | 
                                                        |
| 149 | + }  | 
                                                        |
| 150 | 150 | }  | 
                                                        
| 151 | 151 | \ No newline at end of file  | 
                                                        
@@ -47,8 +47,8 @@ discard block  | 
                                                    ||
| 47 | 47 | |
| 48 | 48 | $arrNetworkFilters = [];  | 
                                                        
| 49 | 49 | $networkFilters = NetworkFilters::find();  | 
                                                        
| 50 | -		foreach ( $networkFilters as $filter ) { | 
                                                        |
| 51 | - $arrNetworkFilters[ $filter->id ] = $filter->getRepresent();  | 
                                                        |
| 50 | +		foreach ($networkFilters as $filter) { | 
                                                        |
| 51 | + $arrNetworkFilters[$filter->id] = $filter->getRepresent();  | 
                                                        |
| 52 | 52 | }  | 
                                                        
| 53 | 53 | $this->view->networkFilters = $arrNetworkFilters;  | 
                                                        
| 54 | 54 | $this->view->amiUsers = $amiUsers;  | 
                                                        
@@ -60,30 +60,30 @@ discard block  | 
                                                    ||
| 60 | 60 | *  | 
                                                        
| 61 | 61 | * @param string $id идентификатор редактируемого пользователя  | 
                                                        
| 62 | 62 | */  | 
                                                        
| 63 | -	public function modifyAction( $id = NULL ) { | 
                                                        |
| 63 | +	public function modifyAction($id = NULL) { | 
                                                        |
| 64 | 64 | |
| 65 | - $manager = AsteriskManagerUsers::findFirstById( $id );  | 
                                                        |
| 66 | -		if ( ! $manager ) { | 
                                                        |
| 65 | + $manager = AsteriskManagerUsers::findFirstById($id);  | 
                                                        |
| 66 | +		if (!$manager) { | 
                                                        |
| 67 | 67 | $manager = new AsteriskManagerUsers();  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
| 70 | 70 | $arrNetworkFilters = [];  | 
                                                        
| 71 | - $networkFilters = NetworkFilters::getAllowedFiltersForType( [  | 
                                                        |
| 71 | + $networkFilters = NetworkFilters::getAllowedFiltersForType([  | 
                                                        |
| 72 | 72 | 'AJAM',  | 
                                                        
| 73 | 73 | 'AMI',  | 
                                                        
| 74 | - ] );  | 
                                                        |
| 74 | + ]);  | 
                                                        |
| 75 | 75 | $arrNetworkFilters['none']  | 
                                                        
| 76 | - = $this->translation->_( 'ex_NoNetworkFilter' );  | 
                                                        |
| 77 | -		foreach ( $networkFilters as $filter ) { | 
                                                        |
| 78 | - $arrNetworkFilters[ $filter->id ] = $filter->getRepresent();  | 
                                                        |
| 76 | +		                   = $this->translation->_('ex_NoNetworkFilter'); | 
                                                        |
| 77 | +		foreach ($networkFilters as $filter) { | 
                                                        |
| 78 | + $arrNetworkFilters[$filter->id] = $filter->getRepresent();  | 
                                                        |
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
| 81 | 81 | |
| 82 | - $this->view->form = new AsteriskManagerEditForm( $manager,  | 
                                                        |
| 82 | + $this->view->form = new AsteriskManagerEditForm($manager,  | 
                                                        |
| 83 | 83 | [  | 
                                                        
| 84 | 84 | 'network_filters' => $arrNetworkFilters,  | 
                                                        
| 85 | 85 | 'array_of_checkboxes' => $this->arrCheckBoxes,  | 
                                                        
| 86 | - ] );  | 
                                                        |
| 86 | + ]);  | 
                                                        |
| 87 | 87 | |
| 88 | 88 | $this->view->arrCheckBoxes = $this->arrCheckBoxes;  | 
                                                        
| 89 | 89 | $this->view->represent = $manager->getRepresent();  | 
                                                        
@@ -94,41 +94,41 @@ discard block  | 
                                                    ||
| 94 | 94 | * Сохраенение настроек Asterisk Manager  | 
                                                        
| 95 | 95 | */  | 
                                                        
| 96 | 96 |  	public function saveAction() { | 
                                                        
| 97 | - if ( ! $this->request->isPost()) return;  | 
                                                        |
| 97 | + if (!$this->request->isPost()) return;  | 
                                                        |
| 98 | 98 | |
| 99 | 99 | $data = $this->request->getPost();  | 
                                                        
| 100 | 100 | $manager = false;  | 
                                                        
| 101 | -		if (isset($data['id'])){ | 
                                                        |
| 102 | - $manager = AsteriskManagerUsers::findFirst( $data['id'] );  | 
                                                        |
| 101 | +		if (isset($data['id'])) { | 
                                                        |
| 102 | + $manager = AsteriskManagerUsers::findFirst($data['id']);  | 
                                                        |
| 103 | 103 | }  | 
                                                        
| 104 | 104 |  		if (!$manager) { | 
                                                        
| 105 | 105 | $manager = new AsteriskManagerUsers();  | 
                                                        
| 106 | 106 | }  | 
                                                        
| 107 | 107 | |
| 108 | -		foreach ( $manager as $name => $value ) { | 
                                                        |
| 109 | -			if ( in_array( $name, $this->arrCheckBoxes ) ) { | 
                                                        |
| 108 | +		foreach ($manager as $name => $value) { | 
                                                        |
| 109 | +			if (in_array($name, $this->arrCheckBoxes)) { | 
                                                        |
| 110 | 110 | $manager->$name = '';  | 
                                                        
| 111 | - $manager->$name .= ( $data[ $name . '_read' ] === 'on' ) ? 'read' : '';  | 
                                                        |
| 112 | - $manager->$name .= ( $data[ $name . '_write' ] === 'on' ) ? 'write' : '';  | 
                                                        |
| 111 | + $manager->$name .= ($data[$name.'_read'] === 'on') ? 'read' : '';  | 
                                                        |
| 112 | + $manager->$name .= ($data[$name.'_write'] === 'on') ? 'write' : '';  | 
                                                        |
| 113 | 113 | continue;  | 
                                                        
| 114 | 114 | }  | 
                                                        
| 115 | 115 | |
| 116 | -			if ( ! array_key_exists( $name, $data ) ) { | 
                                                        |
| 116 | +			if (!array_key_exists($name, $data)) { | 
                                                        |
| 117 | 117 | continue;  | 
                                                        
| 118 | 118 | }  | 
                                                        
| 119 | - $manager->$name = $data[ $name ];  | 
                                                        |
| 119 | + $manager->$name = $data[$name];  | 
                                                        |
| 120 | 120 | |
| 121 | 121 | }  | 
                                                        
| 122 | 122 | $errors = FALSE;  | 
                                                        
| 123 | -		if ( ! $manager->save() ) { | 
                                                        |
| 123 | +		if (!$manager->save()) { | 
                                                        |
| 124 | 124 | $errors = $manager->getMessages();  | 
                                                        
| 125 | 125 | }  | 
                                                        
| 126 | 126 | |
| 127 | -		if ( $errors ) { | 
                                                        |
| 128 | - $this->flash->warning( implode( '<br>', $errors ) );  | 
                                                        |
| 127 | +		if ($errors) { | 
                                                        |
| 128 | +			$this->flash->warning(implode('<br>', $errors)); | 
                                                        |
| 129 | 129 | $this->view->success = false;  | 
                                                        
| 130 | 130 |  		} else { | 
                                                        
| 131 | - $this->flash->success( $this->translation->_( 'ms_SuccessfulSaved' ) );  | 
                                                        |
| 131 | +			$this->flash->success($this->translation->_('ms_SuccessfulSaved')); | 
                                                        |
| 132 | 132 | $this->view->success = TRUE;  | 
                                                        
| 133 | 133 |  			$this->view->reload = "asterisk-managers/modify/{$manager->id}"; | 
                                                        
| 134 | 134 | }  | 
                                                        
@@ -137,14 +137,14 @@ discard block  | 
                                                    ||
| 137 | 137 | /**  | 
                                                        
| 138 | 138 | * Удаление Asterisk Manager  | 
                                                        
| 139 | 139 | */  | 
                                                        
| 140 | -	public function deleteAction( $amiId = NULL ) { | 
                                                        |
| 140 | +	public function deleteAction($amiId = NULL) { | 
                                                        |
| 141 | 141 | |
| 142 | - $manager = AsteriskManagerUsers::findFirstByid( $amiId );  | 
                                                        |
| 143 | -		if ( $manager ) { | 
                                                        |
| 142 | + $manager = AsteriskManagerUsers::findFirstByid($amiId);  | 
                                                        |
| 143 | +		if ($manager) { | 
                                                        |
| 144 | 144 | $manager->delete();  | 
                                                        
| 145 | 145 | }  | 
                                                        
| 146 | 146 | |
| 147 | - return $this->forward( 'asterisk-managers/index' );  | 
                                                        |
| 147 | +		return $this->forward('asterisk-managers/index'); | 
                                                        |
| 148 | 148 | |
| 149 | 149 | }  | 
                                                        
| 150 | 150 | }  | 
                                                        
| 151 | 151 | \ No newline at end of file  | 
                                                        
@@ -94,7 +94,9 @@  | 
                                                    ||
| 94 | 94 | * Сохраенение настроек Asterisk Manager  | 
                                                        
| 95 | 95 | */  | 
                                                        
| 96 | 96 |  	public function saveAction() { | 
                                                        
| 97 | - if ( ! $this->request->isPost()) return;  | 
                                                        |
| 97 | +		if ( ! $this->request->isPost()) { | 
                                                        |
| 98 | + return;  | 
                                                        |
| 99 | + }  | 
                                                        |
| 98 | 100 | |
| 99 | 101 | $data = $this->request->getPost();  | 
                                                        
| 100 | 102 | $manager = false;  | 
                                                        
@@ -17,8 +17,8 @@ discard block  | 
                                                    ||
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | /**  | 
                                                        
| 20 | - * Построение списка IVR меню  | 
                                                        |
| 21 | - */  | 
                                                        |
| 20 | + * Построение списка IVR меню  | 
                                                        |
| 21 | + */  | 
                                                        |
| 22 | 22 | public function indexAction()  | 
                                                        
| 23 | 23 |      { | 
                                                        
| 24 | 24 | $this->view->ivrmenu = IvrMenu::find();  | 
                                                        
@@ -26,24 +26,24 @@ discard block  | 
                                                    ||
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /**  | 
                                                        
| 29 | - * Карточка редактирования IVR меню  | 
                                                        |
| 30 | - *  | 
                                                        |
| 31 | - * @param null $ivrmenuid идентификатор меню  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | -	public function modifyAction($ivrmenuid=null){ | 
                                                        |
| 29 | + * Карточка редактирования IVR меню  | 
                                                        |
| 30 | + *  | 
                                                        |
| 31 | + * @param null $ivrmenuid идентификатор меню  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | +    public function modifyAction($ivrmenuid=null){ | 
                                                        |
| 34 | 34 | |
| 35 | 35 | $ivrmenu = IvrMenu::findFirstByUniqid($ivrmenuid);  | 
                                                        
| 36 | 36 | $ivrActionsList =[];  | 
                                                        
| 37 | - $soundfilesList[""] = $this->translation->_( "sf_SelectAudioFile" );  | 
                                                        |
| 38 | - $extensionList[""] = $this->translation->_( "ex_SelectNumber" );  | 
                                                        |
| 37 | + $soundfilesList[""] = $this->translation->_( "sf_SelectAudioFile" );  | 
                                                        |
| 38 | + $extensionList[""] = $this->translation->_( "ex_SelectNumber" );  | 
                                                        |
| 39 | 39 | $extensionListForFilter =[];  | 
                                                        
| 40 | 40 |          if (!$ivrmenu) { | 
                                                        
| 41 | 41 | $ivrmenu = new IvrMenu();  | 
                                                        
| 42 | 42 |              $ivrmenu->uniqid           =   strtoupper('IVR-'.md5($ivrmenu->id.time())); | 
                                                        
| 43 | - $ivrmenu->number_of_repeat = 3;  | 
                                                        |
| 44 | - $ivrmenu->extension  | 
                                                        |
| 45 | - = Extensions::getNextFreeApplicationNumber();  | 
                                                        |
| 46 | - $ivrmenu->timeout = 7;  | 
                                                        |
| 43 | + $ivrmenu->number_of_repeat = 3;  | 
                                                        |
| 44 | + $ivrmenu->extension  | 
                                                        |
| 45 | + = Extensions::getNextFreeApplicationNumber();  | 
                                                        |
| 46 | + $ivrmenu->timeout = 7;  | 
                                                        |
| 47 | 47 | |
| 48 | 48 |          } else { | 
                                                        
| 49 | 49 | $extensionListForFilter[]= $ivrmenu->timeout_extension;  | 
                                                        
@@ -58,11 +58,11 @@ discard block  | 
                                                    ||
| 58 | 58 | $actions=IvrMenuActions::find($parameters);  | 
                                                        
| 59 | 59 |              foreach ($actions as $action){ | 
                                                        
| 60 | 60 | $ivrActionsList[]=[  | 
                                                        
| 61 | - 'id' =>$action->id,  | 
                                                        |
| 62 | - 'extension' =>$action->extension,  | 
                                                        |
| 63 | - 'extensionRepresent' => str_replace( '"', '\\"',  | 
                                                        |
| 64 | - $action->Extensions->getRepresent() ),  | 
                                                        |
| 65 | - 'digits' =>$action->digits  | 
                                                        |
| 61 | + 'id' =>$action->id,  | 
                                                        |
| 62 | + 'extension' =>$action->extension,  | 
                                                        |
| 63 | + 'extensionRepresent' => str_replace( '"', '\\"',  | 
                                                        |
| 64 | + $action->Extensions->getRepresent() ),  | 
                                                        |
| 65 | + 'digits' =>$action->digits  | 
                                                        |
| 66 | 66 | ];  | 
                                                        
| 67 | 67 | $extensionListForFilter[]= $action->extension;  | 
                                                        
| 68 | 68 | }  | 
                                                        
@@ -83,9 +83,9 @@ discard block  | 
                                                    ||
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | // Список звуковых файлов для IVR  | 
                                                        
| 86 | - $soundFiles = SoundFiles::find();  | 
                                                        |
| 86 | + $soundFiles = SoundFiles::find();  | 
                                                        |
| 87 | 87 |          foreach ($soundFiles as $soundFile){ | 
                                                        
| 88 | - $soundfilesList[ $soundFile->id ] = $soundFile->getRepresent();  | 
                                                        |
| 88 | + $soundfilesList[ $soundFile->id ] = $soundFile->getRepresent();  | 
                                                        |
| 89 | 89 | }  | 
                                                        
| 90 | 90 | |
| 91 | 91 | $form = new IvrMenuEditForm($ivrmenu, [  | 
                                                        
@@ -94,14 +94,14 @@ discard block  | 
                                                    ||
| 94 | 94 | ]);  | 
                                                        
| 95 | 95 | $this->view->form = $form;  | 
                                                        
| 96 | 96 | $this->view->ivractions=$ivrActionsList;  | 
                                                        
| 97 | - $this->view->represent = $ivrmenu->getRepresent();  | 
                                                        |
| 97 | + $this->view->represent = $ivrmenu->getRepresent();  | 
                                                        |
| 98 | 98 | |
| 99 | 99 | }  | 
                                                        
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | /**  | 
                                                        
| 103 | - * Сохранение ivr меню  | 
                                                        |
| 104 | - */  | 
                                                        |
| 103 | + * Сохранение ivr меню  | 
                                                        |
| 104 | + */  | 
                                                        |
| 105 | 105 | public function saveAction()  | 
                                                        
| 106 | 106 |      { | 
                                                        
| 107 | 107 | if (!$this->request->isPost()) return;  | 
                                                        
@@ -122,43 +122,43 @@ discard block  | 
                                                    ||
| 122 | 122 | $extension->public_access = 1;  | 
                                                        
| 123 | 123 | |
| 124 | 124 |          } else { | 
                                                        
| 125 | - $extension = $ivrMenuRecord->Extensions;  | 
                                                        |
| 125 | + $extension = $ivrMenuRecord->Extensions;  | 
                                                        |
| 126 | 126 | }  | 
                                                        
| 127 | 127 | |
| 128 | - // Заполним параметры внутреннего номера  | 
                                                        |
| 129 | -	    if (!$this->updateExtension($extension, $data)){ | 
                                                        |
| 130 | - $this->view->success=false;  | 
                                                        |
| 131 | - $this->db->rollback();  | 
                                                        |
| 132 | - return;  | 
                                                        |
| 133 | - }  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | - // Заполним параметры IVR меню  | 
                                                        |
| 136 | -	    if (!$this->updateIVRMenu($ivrMenuRecord, $data)){ | 
                                                        |
| 137 | - $this->view->success=false;  | 
                                                        |
| 138 | - $this->db->rollback();  | 
                                                        |
| 139 | - return;  | 
                                                        |
| 140 | - }  | 
                                                        |
| 141 | -  | 
                                                        |
| 142 | - // Заполним параметры участников IVR Меню  | 
                                                        |
| 143 | -	    if (!$this->updateIVRMenuActions($data)){ | 
                                                        |
| 144 | - $this->view->success=false;  | 
                                                        |
| 145 | - $this->db->rollback();  | 
                                                        |
| 146 | - return;  | 
                                                        |
| 147 | - }  | 
                                                        |
| 148 | -  | 
                                                        |
| 149 | - $this->view->success=true;  | 
                                                        |
| 150 | - $this->db->commit();  | 
                                                        |
| 151 | -  | 
                                                        |
| 152 | - // Если это было создание карточки то надо перегрузить страницу с указанием ID  | 
                                                        |
| 153 | -	    if (empty($data['id'])){ | 
                                                        |
| 154 | -		    $this->view->reload = "ivr-menu/modify/{$data['uniqid']}"; | 
                                                        |
| 155 | - }  | 
                                                        |
| 128 | + // Заполним параметры внутреннего номера  | 
                                                        |
| 129 | +        if (!$this->updateExtension($extension, $data)){ | 
                                                        |
| 130 | + $this->view->success=false;  | 
                                                        |
| 131 | + $this->db->rollback();  | 
                                                        |
| 132 | + return;  | 
                                                        |
| 133 | + }  | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | + // Заполним параметры IVR меню  | 
                                                        |
| 136 | +        if (!$this->updateIVRMenu($ivrMenuRecord, $data)){ | 
                                                        |
| 137 | + $this->view->success=false;  | 
                                                        |
| 138 | + $this->db->rollback();  | 
                                                        |
| 139 | + return;  | 
                                                        |
| 140 | + }  | 
                                                        |
| 141 | +  | 
                                                        |
| 142 | + // Заполним параметры участников IVR Меню  | 
                                                        |
| 143 | +        if (!$this->updateIVRMenuActions($data)){ | 
                                                        |
| 144 | + $this->view->success=false;  | 
                                                        |
| 145 | + $this->db->rollback();  | 
                                                        |
| 146 | + return;  | 
                                                        |
| 147 | + }  | 
                                                        |
| 148 | +  | 
                                                        |
| 149 | + $this->view->success=true;  | 
                                                        |
| 150 | + $this->db->commit();  | 
                                                        |
| 151 | +  | 
                                                        |
| 152 | + // Если это было создание карточки то надо перегрузить страницу с указанием ID  | 
                                                        |
| 153 | +        if (empty($data['id'])){ | 
                                                        |
| 154 | +            $this->view->reload = "ivr-menu/modify/{$data['uniqid']}"; | 
                                                        |
| 155 | + }  | 
                                                        |
| 156 | 156 | }  | 
                                                        
| 157 | 157 | |
| 158 | - /**  | 
                                                        |
| 159 | - * Удаление ivr меню  | 
                                                        |
| 160 | - * @param null $uniqid  | 
                                                        |
| 161 | - */  | 
                                                        |
| 158 | + /**  | 
                                                        |
| 159 | + * Удаление ivr меню  | 
                                                        |
| 160 | + * @param null $uniqid  | 
                                                        |
| 161 | + */  | 
                                                        |
| 162 | 162 |      public function deleteAction($uniqid=null){ | 
                                                        
| 163 | 163 | $this->db->begin();  | 
                                                        
| 164 | 164 | $ivrmenu = IvrMenu::findFirstByUniqid($uniqid);  | 
                                                        
@@ -181,123 +181,123 @@ discard block  | 
                                                    ||
| 181 | 181 | }  | 
                                                        
| 182 | 182 | |
| 183 | 183 | |
| 184 | - /**  | 
                                                        |
| 185 | - * Обновление параметров внутреннего номера  | 
                                                        |
| 186 | - * @param \Models\Extensions $extension  | 
                                                        |
| 187 | - * @param array $data массив полей из POST запроса  | 
                                                        |
| 188 | - * @return bool update result  | 
                                                        |
| 189 | - */  | 
                                                        |
| 190 | -	private function updateExtension(Extensions $extension, array $data){ | 
                                                        |
| 191 | -  | 
                                                        |
| 192 | - $extension->number=$data['extension'];  | 
                                                        |
| 193 | - $extension->callerid=parent::transliterate($data['name']);  | 
                                                        |
| 194 | -		if ($extension->save()=== false){ | 
                                                        |
| 195 | - $errors = $extension->getMessages();  | 
                                                        |
| 196 | -			$this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 197 | - return false;  | 
                                                        |
| 198 | - }  | 
                                                        |
| 199 | -  | 
                                                        |
| 200 | - return TRUE;  | 
                                                        |
| 201 | -  | 
                                                        |
| 202 | - }  | 
                                                        |
| 203 | -  | 
                                                        |
| 204 | -  | 
                                                        |
| 205 | - /**  | 
                                                        |
| 206 | - * Обновление параметров IVR меню  | 
                                                        |
| 207 | - *  | 
                                                        |
| 208 | - * @param \Models\IvrMenu $ivrMenu  | 
                                                        |
| 209 | - * @param array $data массив полей из POST запроса  | 
                                                        |
| 210 | - *  | 
                                                        |
| 211 | - * @return bool update result  | 
                                                        |
| 212 | - */  | 
                                                        |
| 213 | -	private function updateIVRMenu(IvrMenu $ivrMenu, array $data ) { | 
                                                        |
| 214 | -  | 
                                                        |
| 215 | - // Заполним параметры записи Ivr Menu  | 
                                                        |
| 216 | -		foreach ($ivrMenu as $name => $value) { | 
                                                        |
| 217 | -			switch ($name) { | 
                                                        |
| 218 | - case "extension":  | 
                                                        |
| 219 | - $ivrMenu->$name = $data[$name];  | 
                                                        |
| 220 | - break;  | 
                                                        |
| 221 | - case "name":  | 
                                                        |
| 222 | - $ivrMenu->$name = $data[$name];  | 
                                                        |
| 223 | - break;  | 
                                                        |
| 224 | - case "allow_enter_any_internal_extension":  | 
                                                        |
| 225 | - if (array_key_exists($name, $data) && $data[$name]=="on")  | 
                                                        |
| 226 | - $ivrMenu->$name = "1";  | 
                                                        |
| 227 | - else  | 
                                                        |
| 228 | - $ivrMenu->$name = "0";  | 
                                                        |
| 229 | - break;  | 
                                                        |
| 230 | - default:  | 
                                                        |
| 231 | - if (!array_key_exists($name, $data)) continue;  | 
                                                        |
| 232 | - $ivrMenu->$name = $data[$name];  | 
                                                        |
| 233 | - }  | 
                                                        |
| 234 | - }  | 
                                                        |
| 235 | -		if ( $ivrMenu->save()=== false){ | 
                                                        |
| 236 | - $errors = $ivrMenu->getMessages();  | 
                                                        |
| 237 | -			$this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 238 | - return false;  | 
                                                        |
| 239 | - }  | 
                                                        |
| 240 | -  | 
                                                        |
| 241 | - return TRUE;  | 
                                                        |
| 242 | -  | 
                                                        |
| 243 | - }  | 
                                                        |
| 244 | -  | 
                                                        |
| 245 | -  | 
                                                        |
| 246 | - /**  | 
                                                        |
| 247 | - * Обновление действий в IVR меню  | 
                                                        |
| 248 | - * @param array $data массив полей из POST запроса  | 
                                                        |
| 249 | - * @return bool update result  | 
                                                        |
| 250 | - */  | 
                                                        |
| 251 | -	private function updateIVRMenuActions(array $data){ | 
                                                        |
| 252 | -  | 
                                                        |
| 253 | - $existDigits = [];  | 
                                                        |
| 254 | -  | 
                                                        |
| 255 | - // Заполним параметры IvrMenuActions  | 
                                                        |
| 256 | - $arrActions=json_decode($data['actions']);  | 
                                                        |
| 257 | -		foreach ($arrActions as $value) { | 
                                                        |
| 258 | -  | 
                                                        |
| 259 | - $parameters=[  | 
                                                        |
| 260 | - 'conditions'=>'ivr_menu_id = :uniqid: AND digits=:digits:',  | 
                                                        |
| 261 | - 'bind' =>[  | 
                                                        |
| 262 | - 'digits'=>$value->digits,  | 
                                                        |
| 263 | - 'uniqid'=> $data['uniqid']  | 
                                                        |
| 264 | - ]  | 
                                                        |
| 265 | - ];  | 
                                                        |
| 266 | - $newRule = IvrMenuActions::findFirst($parameters);  | 
                                                        |
| 267 | -			if ($newRule==false){ | 
                                                        |
| 268 | - $newRule = new IvrMenuActions();  | 
                                                        |
| 269 | - $newRule->digits = $value->digits;  | 
                                                        |
| 270 | - $newRule->ivr_menu_id = $data['uniqid'];  | 
                                                        |
| 271 | - }  | 
                                                        |
| 272 | - $newRule->extension = $value->extension;  | 
                                                        |
| 273 | -			if ($newRule->save() === false) { | 
                                                        |
| 274 | - $errors = $newRule->getMessages();  | 
                                                        |
| 275 | -				$this->flash->warning(implode('<br>', $errors)); | 
                                                        |
| 276 | - $this->view->success = false;  | 
                                                        |
| 277 | - return FALSE;  | 
                                                        |
| 278 | - }  | 
                                                        |
| 279 | - $existDigits[] = $value->digits;  | 
                                                        |
| 280 | - }  | 
                                                        |
| 281 | -  | 
                                                        |
| 282 | - // Удалим лишние элементы меню  | 
                                                        |
| 283 | - $parameters = [  | 
                                                        |
| 284 | -			'conditions'=>'digits NOT IN ({numbers:array}) AND ivr_menu_id=:uniqid:', | 
                                                        |
| 285 | - 'bind' =>[  | 
                                                        |
| 286 | - 'numbers'=>$existDigits,  | 
                                                        |
| 287 | - 'uniqid'=> $data['uniqid']  | 
                                                        |
| 288 | - ]  | 
                                                        |
| 289 | - ];  | 
                                                        |
| 290 | -  | 
                                                        |
| 291 | - $deletedActions = IvrMenuActions::find($parameters);  | 
                                                        |
| 292 | -		if ($deletedActions && $deletedActions->delete()=== FALSE){ | 
                                                        |
| 293 | - $errors = $deletedActions->getMessages();  | 
                                                        |
| 294 | -			$this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 295 | - return FALSE;  | 
                                                        |
| 296 | - }  | 
                                                        |
| 297 | -  | 
                                                        |
| 298 | - return TRUE;  | 
                                                        |
| 299 | -  | 
                                                        |
| 300 | - }  | 
                                                        |
| 184 | + /**  | 
                                                        |
| 185 | + * Обновление параметров внутреннего номера  | 
                                                        |
| 186 | + * @param \Models\Extensions $extension  | 
                                                        |
| 187 | + * @param array $data массив полей из POST запроса  | 
                                                        |
| 188 | + * @return bool update result  | 
                                                        |
| 189 | + */  | 
                                                        |
| 190 | +    private function updateExtension(Extensions $extension, array $data){ | 
                                                        |
| 191 | +  | 
                                                        |
| 192 | + $extension->number=$data['extension'];  | 
                                                        |
| 193 | + $extension->callerid=parent::transliterate($data['name']);  | 
                                                        |
| 194 | +        if ($extension->save()=== false){ | 
                                                        |
| 195 | + $errors = $extension->getMessages();  | 
                                                        |
| 196 | +            $this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 197 | + return false;  | 
                                                        |
| 198 | + }  | 
                                                        |
| 199 | +  | 
                                                        |
| 200 | + return TRUE;  | 
                                                        |
| 201 | +  | 
                                                        |
| 202 | + }  | 
                                                        |
| 203 | +  | 
                                                        |
| 204 | +  | 
                                                        |
| 205 | + /**  | 
                                                        |
| 206 | + * Обновление параметров IVR меню  | 
                                                        |
| 207 | + *  | 
                                                        |
| 208 | + * @param \Models\IvrMenu $ivrMenu  | 
                                                        |
| 209 | + * @param array $data массив полей из POST запроса  | 
                                                        |
| 210 | + *  | 
                                                        |
| 211 | + * @return bool update result  | 
                                                        |
| 212 | + */  | 
                                                        |
| 213 | +    private function updateIVRMenu(IvrMenu $ivrMenu, array $data ) { | 
                                                        |
| 214 | +  | 
                                                        |
| 215 | + // Заполним параметры записи Ivr Menu  | 
                                                        |
| 216 | +        foreach ($ivrMenu as $name => $value) { | 
                                                        |
| 217 | +            switch ($name) { | 
                                                        |
| 218 | + case "extension":  | 
                                                        |
| 219 | + $ivrMenu->$name = $data[$name];  | 
                                                        |
| 220 | + break;  | 
                                                        |
| 221 | + case "name":  | 
                                                        |
| 222 | + $ivrMenu->$name = $data[$name];  | 
                                                        |
| 223 | + break;  | 
                                                        |
| 224 | + case "allow_enter_any_internal_extension":  | 
                                                        |
| 225 | + if (array_key_exists($name, $data) && $data[$name]=="on")  | 
                                                        |
| 226 | + $ivrMenu->$name = "1";  | 
                                                        |
| 227 | + else  | 
                                                        |
| 228 | + $ivrMenu->$name = "0";  | 
                                                        |
| 229 | + break;  | 
                                                        |
| 230 | + default:  | 
                                                        |
| 231 | + if (!array_key_exists($name, $data)) continue;  | 
                                                        |
| 232 | + $ivrMenu->$name = $data[$name];  | 
                                                        |
| 233 | + }  | 
                                                        |
| 234 | + }  | 
                                                        |
| 235 | +        if ( $ivrMenu->save()=== false){ | 
                                                        |
| 236 | + $errors = $ivrMenu->getMessages();  | 
                                                        |
| 237 | +            $this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 238 | + return false;  | 
                                                        |
| 239 | + }  | 
                                                        |
| 240 | +  | 
                                                        |
| 241 | + return TRUE;  | 
                                                        |
| 242 | +  | 
                                                        |
| 243 | + }  | 
                                                        |
| 244 | +  | 
                                                        |
| 245 | +  | 
                                                        |
| 246 | + /**  | 
                                                        |
| 247 | + * Обновление действий в IVR меню  | 
                                                        |
| 248 | + * @param array $data массив полей из POST запроса  | 
                                                        |
| 249 | + * @return bool update result  | 
                                                        |
| 250 | + */  | 
                                                        |
| 251 | +    private function updateIVRMenuActions(array $data){ | 
                                                        |
| 252 | +  | 
                                                        |
| 253 | + $existDigits = [];  | 
                                                        |
| 254 | +  | 
                                                        |
| 255 | + // Заполним параметры IvrMenuActions  | 
                                                        |
| 256 | + $arrActions=json_decode($data['actions']);  | 
                                                        |
| 257 | +        foreach ($arrActions as $value) { | 
                                                        |
| 258 | +  | 
                                                        |
| 259 | + $parameters=[  | 
                                                        |
| 260 | + 'conditions'=>'ivr_menu_id = :uniqid: AND digits=:digits:',  | 
                                                        |
| 261 | + 'bind' =>[  | 
                                                        |
| 262 | + 'digits'=>$value->digits,  | 
                                                        |
| 263 | + 'uniqid'=> $data['uniqid']  | 
                                                        |
| 264 | + ]  | 
                                                        |
| 265 | + ];  | 
                                                        |
| 266 | + $newRule = IvrMenuActions::findFirst($parameters);  | 
                                                        |
| 267 | +            if ($newRule==false){ | 
                                                        |
| 268 | + $newRule = new IvrMenuActions();  | 
                                                        |
| 269 | + $newRule->digits = $value->digits;  | 
                                                        |
| 270 | + $newRule->ivr_menu_id = $data['uniqid'];  | 
                                                        |
| 271 | + }  | 
                                                        |
| 272 | + $newRule->extension = $value->extension;  | 
                                                        |
| 273 | +            if ($newRule->save() === false) { | 
                                                        |
| 274 | + $errors = $newRule->getMessages();  | 
                                                        |
| 275 | +                $this->flash->warning(implode('<br>', $errors)); | 
                                                        |
| 276 | + $this->view->success = false;  | 
                                                        |
| 277 | + return FALSE;  | 
                                                        |
| 278 | + }  | 
                                                        |
| 279 | + $existDigits[] = $value->digits;  | 
                                                        |
| 280 | + }  | 
                                                        |
| 281 | +  | 
                                                        |
| 282 | + // Удалим лишние элементы меню  | 
                                                        |
| 283 | + $parameters = [  | 
                                                        |
| 284 | +            'conditions'=>'digits NOT IN ({numbers:array}) AND ivr_menu_id=:uniqid:', | 
                                                        |
| 285 | + 'bind' =>[  | 
                                                        |
| 286 | + 'numbers'=>$existDigits,  | 
                                                        |
| 287 | + 'uniqid'=> $data['uniqid']  | 
                                                        |
| 288 | + ]  | 
                                                        |
| 289 | + ];  | 
                                                        |
| 290 | +  | 
                                                        |
| 291 | + $deletedActions = IvrMenuActions::find($parameters);  | 
                                                        |
| 292 | +        if ($deletedActions && $deletedActions->delete()=== FALSE){ | 
                                                        |
| 293 | + $errors = $deletedActions->getMessages();  | 
                                                        |
| 294 | +            $this->flash->error(implode('<br>', $errors)); | 
                                                        |
| 295 | + return FALSE;  | 
                                                        |
| 296 | + }  | 
                                                        |
| 297 | +  | 
                                                        |
| 298 | + return TRUE;  | 
                                                        |
| 299 | +  | 
                                                        |
| 300 | + }  | 
                                                        |
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | }  | 
                                                        
| 304 | 304 | \ No newline at end of file  | 
                                                        
@@ -21,7 +21,7 @@ discard block  | 
                                                    ||
| 21 | 21 | */  | 
                                                        
| 22 | 22 | public function indexAction()  | 
                                                        
| 23 | 23 |      { | 
                                                        
| 24 | - $this->view->ivrmenu = IvrMenu::find();  | 
                                                        |
| 24 | + $this->view->ivrmenu = IvrMenu::find();  | 
                                                        |
| 25 | 25 | }  | 
                                                        
| 26 | 26 | |
| 27 | 27 | |
@@ -30,62 +30,62 @@ discard block  | 
                                                    ||
| 30 | 30 | *  | 
                                                        
| 31 | 31 | * @param null $ivrmenuid идентификатор меню  | 
                                                        
| 32 | 32 | */  | 
                                                        
| 33 | -	public function modifyAction($ivrmenuid=null){ | 
                                                        |
| 33 | +	public function modifyAction($ivrmenuid = null) { | 
                                                        |
| 34 | 34 | |
| 35 | 35 | $ivrmenu = IvrMenu::findFirstByUniqid($ivrmenuid);  | 
                                                        
| 36 | - $ivrActionsList =[];  | 
                                                        |
| 37 | - $soundfilesList[""] = $this->translation->_( "sf_SelectAudioFile" );  | 
                                                        |
| 38 | - $extensionList[""] = $this->translation->_( "ex_SelectNumber" );  | 
                                                        |
| 39 | - $extensionListForFilter =[];  | 
                                                        |
| 36 | + $ivrActionsList = [];  | 
                                                        |
| 37 | +		$soundfilesList[""]     = $this->translation->_("sf_SelectAudioFile"); | 
                                                        |
| 38 | +		$extensionList[""]      = $this->translation->_("ex_SelectNumber"); | 
                                                        |
| 39 | + $extensionListForFilter = [];  | 
                                                        |
| 40 | 40 |          if (!$ivrmenu) { | 
                                                        
| 41 | 41 | $ivrmenu = new IvrMenu();  | 
                                                        
| 42 | -            $ivrmenu->uniqid           =   strtoupper('IVR-'.md5($ivrmenu->id.time())); | 
                                                        |
| 42 | +            $ivrmenu->uniqid           = strtoupper('IVR-'.md5($ivrmenu->id.time())); | 
                                                        |
| 43 | 43 | $ivrmenu->number_of_repeat = 3;  | 
                                                        
| 44 | 44 | $ivrmenu->extension  | 
                                                        
| 45 | 45 | = Extensions::getNextFreeApplicationNumber();  | 
                                                        
| 46 | - $ivrmenu->timeout = 7;  | 
                                                        |
| 46 | + $ivrmenu->timeout = 7;  | 
                                                        |
| 47 | 47 | |
| 48 | 48 |          } else { | 
                                                        
| 49 | - $extensionListForFilter[]= $ivrmenu->timeout_extension;  | 
                                                        |
| 49 | + $extensionListForFilter[] = $ivrmenu->timeout_extension;  | 
                                                        |
| 50 | 50 | // Списк экстеншенов очереди  | 
                                                        
| 51 | - $parameters =[  | 
                                                        |
| 51 | + $parameters = [  | 
                                                        |
| 52 | 52 | 'order'=>'digits',  | 
                                                        
| 53 | 53 | 'conditions'=>'ivr_menu_id=:menu:',  | 
                                                        
| 54 | 54 | 'bind'=>[  | 
                                                        
| 55 | 55 | 'menu'=>$ivrmenu->uniqid  | 
                                                        
| 56 | 56 | ]  | 
                                                        
| 57 | 57 | ];  | 
                                                        
| 58 | - $actions=IvrMenuActions::find($parameters);  | 
                                                        |
| 59 | -            foreach ($actions as $action){ | 
                                                        |
| 60 | - $ivrActionsList[]=[  | 
                                                        |
| 58 | + $actions = IvrMenuActions::find($parameters);  | 
                                                        |
| 59 | +            foreach ($actions as $action) { | 
                                                        |
| 60 | + $ivrActionsList[] = [  | 
                                                        |
| 61 | 61 | 'id' =>$action->id,  | 
                                                        
| 62 | 62 | 'extension' =>$action->extension,  | 
                                                        
| 63 | - 'extensionRepresent' => str_replace( '"', '\\"',  | 
                                                        |
| 64 | - $action->Extensions->getRepresent() ),  | 
                                                        |
| 63 | +	                'extensionRepresent' => str_replace('"', '\\"', | 
                                                        |
| 64 | + $action->Extensions->getRepresent()),  | 
                                                        |
| 65 | 65 | 'digits' =>$action->digits  | 
                                                        
| 66 | 66 | ];  | 
                                                        
| 67 | - $extensionListForFilter[]= $action->extension;  | 
                                                        |
| 67 | + $extensionListForFilter[] = $action->extension;  | 
                                                        |
| 68 | 68 | }  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | |
| 71 | 71 | // Список всех эктеншенов выбранных ранее для правил адресации  | 
                                                        
| 72 | -        if (count($extensionListForFilter)>0){ | 
                                                        |
| 73 | - $parameters =[  | 
                                                        |
| 72 | +        if (count($extensionListForFilter) > 0) { | 
                                                        |
| 73 | + $parameters = [  | 
                                                        |
| 74 | 74 |              'conditions'=>'number IN ({ids:array})', | 
                                                        
| 75 | 75 | 'bind'=>[  | 
                                                        
| 76 | 76 | 'ids'=>$extensionListForFilter  | 
                                                        
| 77 | 77 | ]  | 
                                                        
| 78 | 78 | ];  | 
                                                        
| 79 | 79 | $extensions = Extensions::find($parameters);  | 
                                                        
| 80 | -        foreach ($extensions as $record){ | 
                                                        |
| 81 | - $extensionList[$record->number]=$record->getRepresent();  | 
                                                        |
| 80 | +        foreach ($extensions as $record) { | 
                                                        |
| 81 | + $extensionList[$record->number] = $record->getRepresent();  | 
                                                        |
| 82 | 82 | }  | 
                                                        
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | // Список звуковых файлов для IVR  | 
                                                        
| 86 | 86 | $soundFiles = SoundFiles::find();  | 
                                                        
| 87 | -        foreach ($soundFiles as $soundFile){ | 
                                                        |
| 88 | - $soundfilesList[ $soundFile->id ] = $soundFile->getRepresent();  | 
                                                        |
| 87 | +        foreach ($soundFiles as $soundFile) { | 
                                                        |
| 88 | + $soundfilesList[$soundFile->id] = $soundFile->getRepresent();  | 
                                                        |
| 89 | 89 | }  | 
                                                        
| 90 | 90 | |
| 91 | 91 | $form = new IvrMenuEditForm($ivrmenu, [  | 
                                                        
@@ -93,8 +93,8 @@ discard block  | 
                                                    ||
| 93 | 93 | 'soundfiles'=>$soundfilesList  | 
                                                        
| 94 | 94 | ]);  | 
                                                        
| 95 | 95 | $this->view->form = $form;  | 
                                                        
| 96 | - $this->view->ivractions=$ivrActionsList;  | 
                                                        |
| 97 | - $this->view->represent = $ivrmenu->getRepresent();  | 
                                                        |
| 96 | + $this->view->ivractions = $ivrActionsList;  | 
                                                        |
| 97 | + $this->view->represent = $ivrmenu->getRepresent();  | 
                                                        |
| 98 | 98 | |
| 99 | 99 | }  | 
                                                        
| 100 | 100 | |
@@ -110,7 +110,7 @@ discard block  | 
                                                    ||
| 110 | 110 | |
| 111 | 111 | $data = $this->request->getPost();  | 
                                                        
| 112 | 112 | $ivrMenuRecord = IvrMenu::findFirstByUniqid($data['uniqid']);  | 
                                                        
| 113 | -        if ($ivrMenuRecord==false) { | 
                                                        |
| 113 | +        if ($ivrMenuRecord == false) { | 
                                                        |
| 114 | 114 | $ivrMenuRecord = new IvrMenu();  | 
                                                        
| 115 | 115 | |
| 116 | 116 | $extension = new Extensions();  | 
                                                        
@@ -118,39 +118,39 @@ discard block  | 
                                                    ||
| 118 | 118 | $extension->number = $data["extension"];  | 
                                                        
| 119 | 119 | $extension->callerid = parent::transliterate($data["name"]);  | 
                                                        
| 120 | 120 | $extension->userid = null;  | 
                                                        
| 121 | - $extension->show_in_phonebook = 1;  | 
                                                        |
| 122 | - $extension->public_access = 1;  | 
                                                        |
| 121 | + $extension->show_in_phonebook = 1;  | 
                                                        |
| 122 | + $extension->public_access = 1;  | 
                                                        |
| 123 | 123 | |
| 124 | 124 |          } else { | 
                                                        
| 125 | 125 | $extension = $ivrMenuRecord->Extensions;  | 
                                                        
| 126 | 126 | }  | 
                                                        
| 127 | 127 | |
| 128 | 128 | // Заполним параметры внутреннего номера  | 
                                                        
| 129 | -	    if (!$this->updateExtension($extension, $data)){ | 
                                                        |
| 130 | - $this->view->success=false;  | 
                                                        |
| 129 | +	    if (!$this->updateExtension($extension, $data)) { | 
                                                        |
| 130 | + $this->view->success = false;  | 
                                                        |
| 131 | 131 | $this->db->rollback();  | 
                                                        
| 132 | 132 | return;  | 
                                                        
| 133 | 133 | }  | 
                                                        
| 134 | 134 | |
| 135 | 135 | // Заполним параметры IVR меню  | 
                                                        
| 136 | -	    if (!$this->updateIVRMenu($ivrMenuRecord, $data)){ | 
                                                        |
| 137 | - $this->view->success=false;  | 
                                                        |
| 136 | +	    if (!$this->updateIVRMenu($ivrMenuRecord, $data)) { | 
                                                        |
| 137 | + $this->view->success = false;  | 
                                                        |
| 138 | 138 | $this->db->rollback();  | 
                                                        
| 139 | 139 | return;  | 
                                                        
| 140 | 140 | }  | 
                                                        
| 141 | 141 | |
| 142 | 142 | // Заполним параметры участников IVR Меню  | 
                                                        
| 143 | -	    if (!$this->updateIVRMenuActions($data)){ | 
                                                        |
| 144 | - $this->view->success=false;  | 
                                                        |
| 143 | +	    if (!$this->updateIVRMenuActions($data)) { | 
                                                        |
| 144 | + $this->view->success = false;  | 
                                                        |
| 145 | 145 | $this->db->rollback();  | 
                                                        
| 146 | 146 | return;  | 
                                                        
| 147 | 147 | }  | 
                                                        
| 148 | 148 | |
| 149 | - $this->view->success=true;  | 
                                                        |
| 149 | + $this->view->success = true;  | 
                                                        |
| 150 | 150 | $this->db->commit();  | 
                                                        
| 151 | 151 | |
| 152 | 152 | // Если это было создание карточки то надо перегрузить страницу с указанием ID  | 
                                                        
| 153 | -	    if (empty($data['id'])){ | 
                                                        |
| 153 | +	    if (empty($data['id'])) { | 
                                                        |
| 154 | 154 |  		    $this->view->reload = "ivr-menu/modify/{$data['uniqid']}"; | 
                                                        
| 155 | 155 | }  | 
                                                        
| 156 | 156 | }  | 
                                                        
@@ -159,15 +159,15 @@ discard block  | 
                                                    ||
| 159 | 159 | * Удаление ivr меню  | 
                                                        
| 160 | 160 | * @param null $uniqid  | 
                                                        
| 161 | 161 | */  | 
                                                        
| 162 | -    public function deleteAction($uniqid=null){ | 
                                                        |
| 162 | +    public function deleteAction($uniqid = null) { | 
                                                        |
| 163 | 163 | $this->db->begin();  | 
                                                        
| 164 | 164 | $ivrmenu = IvrMenu::findFirstByUniqid($uniqid);  | 
                                                        
| 165 | 165 | |
| 166 | 166 | $errors = false;  | 
                                                        
| 167 | - if($ivrmenu && !$ivrmenu->Extensions->delete())  | 
                                                        |
| 167 | + if ($ivrmenu && !$ivrmenu->Extensions->delete())  | 
                                                        |
| 168 | 168 | $errors = $ivrmenu->Extensions->getMessages();  | 
                                                        
| 169 | 169 | |
| 170 | -        if ($errors){ | 
                                                        |
| 170 | +        if ($errors) { | 
                                                        |
| 171 | 171 |              $this->flash->warning(implode('<br>', $errors)); | 
                                                        
| 172 | 172 | $this->db->rollback();  | 
                                                        
| 173 | 173 | }  | 
                                                        
@@ -187,11 +187,11 @@ discard block  | 
                                                    ||
| 187 | 187 | * @param array $data массив полей из POST запроса  | 
                                                        
| 188 | 188 | * @return bool update result  | 
                                                        
| 189 | 189 | */  | 
                                                        
| 190 | -	private function updateExtension(Extensions $extension, array $data){ | 
                                                        |
| 190 | +	private function updateExtension(Extensions $extension, array $data) { | 
                                                        |
| 191 | 191 | |
| 192 | - $extension->number=$data['extension'];  | 
                                                        |
| 193 | - $extension->callerid=parent::transliterate($data['name']);  | 
                                                        |
| 194 | -		if ($extension->save()=== false){ | 
                                                        |
| 192 | + $extension->number = $data['extension'];  | 
                                                        |
| 193 | + $extension->callerid = parent::transliterate($data['name']);  | 
                                                        |
| 194 | +		if ($extension->save() === false) { | 
                                                        |
| 195 | 195 | $errors = $extension->getMessages();  | 
                                                        
| 196 | 196 |  			$this->flash->error(implode('<br>', $errors)); | 
                                                        
| 197 | 197 | return false;  | 
                                                        
@@ -210,7 +210,7 @@ discard block  | 
                                                    ||
| 210 | 210 | *  | 
                                                        
| 211 | 211 | * @return bool update result  | 
                                                        
| 212 | 212 | */  | 
                                                        
| 213 | -	private function updateIVRMenu(IvrMenu $ivrMenu, array $data ) { | 
                                                        |
| 213 | +	private function updateIVRMenu(IvrMenu $ivrMenu, array $data) { | 
                                                        |
| 214 | 214 | |
| 215 | 215 | // Заполним параметры записи Ivr Menu  | 
                                                        
| 216 | 216 |  		foreach ($ivrMenu as $name => $value) { | 
                                                        
@@ -222,7 +222,7 @@ discard block  | 
                                                    ||
| 222 | 222 | $ivrMenu->$name = $data[$name];  | 
                                                        
| 223 | 223 | break;  | 
                                                        
| 224 | 224 | case "allow_enter_any_internal_extension":  | 
                                                        
| 225 | - if (array_key_exists($name, $data) && $data[$name]=="on")  | 
                                                        |
| 225 | + if (array_key_exists($name, $data) && $data[$name] == "on")  | 
                                                        |
| 226 | 226 | $ivrMenu->$name = "1";  | 
                                                        
| 227 | 227 | else  | 
                                                        
| 228 | 228 | $ivrMenu->$name = "0";  | 
                                                        
@@ -232,7 +232,7 @@ discard block  | 
                                                    ||
| 232 | 232 | $ivrMenu->$name = $data[$name];  | 
                                                        
| 233 | 233 | }  | 
                                                        
| 234 | 234 | }  | 
                                                        
| 235 | -		if ( $ivrMenu->save()=== false){ | 
                                                        |
| 235 | +		if ($ivrMenu->save() === false) { | 
                                                        |
| 236 | 236 | $errors = $ivrMenu->getMessages();  | 
                                                        
| 237 | 237 |  			$this->flash->error(implode('<br>', $errors)); | 
                                                        
| 238 | 238 | return false;  | 
                                                        
@@ -248,15 +248,15 @@ discard block  | 
                                                    ||
| 248 | 248 | * @param array $data массив полей из POST запроса  | 
                                                        
| 249 | 249 | * @return bool update result  | 
                                                        
| 250 | 250 | */  | 
                                                        
| 251 | -	private function updateIVRMenuActions(array $data){ | 
                                                        |
| 251 | +	private function updateIVRMenuActions(array $data) { | 
                                                        |
| 252 | 252 | |
| 253 | 253 | $existDigits = [];  | 
                                                        
| 254 | 254 | |
| 255 | 255 | // Заполним параметры IvrMenuActions  | 
                                                        
| 256 | - $arrActions=json_decode($data['actions']);  | 
                                                        |
| 256 | + $arrActions = json_decode($data['actions']);  | 
                                                        |
| 257 | 257 |  		foreach ($arrActions as $value) { | 
                                                        
| 258 | 258 | |
| 259 | - $parameters=[  | 
                                                        |
| 259 | + $parameters = [  | 
                                                        |
| 260 | 260 | 'conditions'=>'ivr_menu_id = :uniqid: AND digits=:digits:',  | 
                                                        
| 261 | 261 | 'bind' =>[  | 
                                                        
| 262 | 262 | 'digits'=>$value->digits,  | 
                                                        
@@ -264,7 +264,7 @@ discard block  | 
                                                    ||
| 264 | 264 | ]  | 
                                                        
| 265 | 265 | ];  | 
                                                        
| 266 | 266 | $newRule = IvrMenuActions::findFirst($parameters);  | 
                                                        
| 267 | -			if ($newRule==false){ | 
                                                        |
| 267 | +			if ($newRule == false) { | 
                                                        |
| 268 | 268 | $newRule = new IvrMenuActions();  | 
                                                        
| 269 | 269 | $newRule->digits = $value->digits;  | 
                                                        
| 270 | 270 | $newRule->ivr_menu_id = $data['uniqid'];  | 
                                                        
@@ -289,7 +289,7 @@ discard block  | 
                                                    ||
| 289 | 289 | ];  | 
                                                        
| 290 | 290 | |
| 291 | 291 | $deletedActions = IvrMenuActions::find($parameters);  | 
                                                        
| 292 | -		if ($deletedActions && $deletedActions->delete()=== FALSE){ | 
                                                        |
| 292 | +		if ($deletedActions && $deletedActions->delete() === FALSE) { | 
                                                        |
| 293 | 293 | $errors = $deletedActions->getMessages();  | 
                                                        
| 294 | 294 |  			$this->flash->error(implode('<br>', $errors)); | 
                                                        
| 295 | 295 | return FALSE;  | 
                                                        
@@ -104,7 +104,9 @@ discard block  | 
                                                    ||
| 104 | 104 | */  | 
                                                        
| 105 | 105 | public function saveAction()  | 
                                                        
| 106 | 106 |      { | 
                                                        
| 107 | - if (!$this->request->isPost()) return;  | 
                                                        |
| 107 | +        if (!$this->request->isPost()) { | 
                                                        |
| 108 | + return;  | 
                                                        |
| 109 | + }  | 
                                                        |
| 108 | 110 | |
| 109 | 111 | $this->db->begin();  | 
                                                        
| 110 | 112 | |
@@ -164,15 +166,14 @@ discard block  | 
                                                    ||
| 164 | 166 | $ivrmenu = IvrMenu::findFirstByUniqid($uniqid);  | 
                                                        
| 165 | 167 | |
| 166 | 168 | $errors = false;  | 
                                                        
| 167 | - if($ivrmenu && !$ivrmenu->Extensions->delete())  | 
                                                        |
| 168 | - $errors = $ivrmenu->Extensions->getMessages();  | 
                                                        |
| 169 | +        if($ivrmenu && !$ivrmenu->Extensions->delete()) { | 
                                                        |
| 170 | + $errors = $ivrmenu->Extensions->getMessages();  | 
                                                        |
| 171 | + }  | 
                                                        |
| 169 | 172 | |
| 170 | 173 |          if ($errors){ | 
                                                        
| 171 | 174 |              $this->flash->warning(implode('<br>', $errors)); | 
                                                        
| 172 | 175 | $this->db->rollback();  | 
                                                        
| 173 | - }  | 
                                                        |
| 174 | -  | 
                                                        |
| 175 | - else  | 
                                                        |
| 176 | + } else  | 
                                                        |
| 176 | 177 |          { | 
                                                        
| 177 | 178 | $this->db->commit();  | 
                                                        
| 178 | 179 | }  | 
                                                        
@@ -222,13 +223,16 @@ discard block  | 
                                                    ||
| 222 | 223 | $ivrMenu->$name = $data[$name];  | 
                                                        
| 223 | 224 | break;  | 
                                                        
| 224 | 225 | case "allow_enter_any_internal_extension":  | 
                                                        
| 225 | - if (array_key_exists($name, $data) && $data[$name]=="on")  | 
                                                        |
| 226 | - $ivrMenu->$name = "1";  | 
                                                        |
| 227 | - else  | 
                                                        |
| 228 | - $ivrMenu->$name = "0";  | 
                                                        |
| 226 | +					if (array_key_exists($name, $data) && $data[$name]=="on") { | 
                                                        |
| 227 | + $ivrMenu->$name = "1";  | 
                                                        |
| 228 | +					} else { | 
                                                        |
| 229 | + $ivrMenu->$name = "0";  | 
                                                        |
| 230 | + }  | 
                                                        |
| 229 | 231 | break;  | 
                                                        
| 230 | 232 | default:  | 
                                                        
| 231 | - if (!array_key_exists($name, $data)) continue;  | 
                                                        |
| 233 | +					if (!array_key_exists($name, $data)) { | 
                                                        |
| 234 | + continue;  | 
                                                        |
| 235 | + }  | 
                                                        |
| 232 | 236 | $ivrMenu->$name = $data[$name];  | 
                                                        
| 233 | 237 | }  | 
                                                        
| 234 | 238 | }  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | $arrEth['new'] = $template;  | 
                                                        
| 32 | 32 | |
| 33 | 33 | $internetInterface = LanInterfaces::findFirstByInternet(1);  | 
                                                        
| 34 | -        if ( ! $internetInterface) { | 
                                                        |
| 34 | +        if (!$internetInterface) { | 
                                                        |
| 35 | 35 | $internetInterface = new LanInterfaces();  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | // Найдем дополнительные интерфейсы, которые можно удалить  | 
                                                        
@@ -54,7 +54,7 @@ discard block  | 
                                                    ||
| 54 | 54 | */  | 
                                                        
| 55 | 55 | public function saveAction(): void  | 
                                                        
| 56 | 56 |      { | 
                                                        
| 57 | -        if ( ! $this->request->isPost()) { | 
                                                        |
| 57 | +        if (!$this->request->isPost()) { | 
                                                        |
| 58 | 58 | return;  | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | 60 | |
@@ -120,9 +120,9 @@ discard block  | 
                                                    ||
| 120 | 120 | case 'extipaddr':  | 
                                                        
| 121 | 121 |                      if ($itIsInternetInterfce) { | 
                                                        
| 122 | 122 |                          if (array_key_exists($name, $data)) { | 
                                                        
| 123 | - $eth->$name = ($data['usenat'] == 'on') ? $data[$name] : $data['ipaddr_' . $eth->id];  | 
                                                        |
| 123 | + $eth->$name = ($data['usenat'] == 'on') ? $data[$name] : $data['ipaddr_'.$eth->id];  | 
                                                        |
| 124 | 124 |                          } else { | 
                                                        
| 125 | - $eth->$name = $data['ipaddr_' . $eth->id];  | 
                                                        |
| 125 | + $eth->$name = $data['ipaddr_'.$eth->id];  | 
                                                        |
| 126 | 126 | }  | 
                                                        
| 127 | 127 |                      } else { | 
                                                        
| 128 | 128 | $eth->$name = '';  | 
                                                        
@@ -141,8 +141,8 @@ discard block  | 
                                                    ||
| 141 | 141 | }  | 
                                                        
| 142 | 142 | break;  | 
                                                        
| 143 | 143 | case 'dhcp':  | 
                                                        
| 144 | -                    if (array_key_exists($name . '_' . $eth->id, $data)) { | 
                                                        |
| 145 | - $eth->$name = ($data['dhcp_' . $eth->id]) == 'on' ? "1" : "0";  | 
                                                        |
| 144 | +                    if (array_key_exists($name.'_'.$eth->id, $data)) { | 
                                                        |
| 145 | + $eth->$name = ($data['dhcp_'.$eth->id]) == 'on' ? "1" : "0";  | 
                                                        |
| 146 | 146 | }  | 
                                                        
| 147 | 147 | break;  | 
                                                        
| 148 | 148 | case 'internet':  | 
                                                        
@@ -151,13 +151,13 @@ discard block  | 
                                                    ||
| 151 | 151 | case 'ipaddr':  | 
                                                        
| 152 | 152 | case 'subnet':  | 
                                                        
| 153 | 153 | $eth->$name = '';  | 
                                                        
| 154 | -                    if (array_key_exists($name . '_' . $eth->id, $data)) { | 
                                                        |
| 155 | - $eth->$name = ($data['dhcp_' . $eth->id]) == 'on' ? '' : $data[$name . '_' . $eth->id];  | 
                                                        |
| 154 | +                    if (array_key_exists($name.'_'.$eth->id, $data)) { | 
                                                        |
| 155 | + $eth->$name = ($data['dhcp_'.$eth->id]) == 'on' ? '' : $data[$name.'_'.$eth->id];  | 
                                                        |
| 156 | 156 | }  | 
                                                        
| 157 | 157 | break;  | 
                                                        
| 158 | 158 | case 'interface':  | 
                                                        
| 159 | 159 |                      if ($eth->id == 'new') { | 
                                                        
| 160 | - $eth->$name = LanInterfaces::findFirstById($data[$name . '_' . $eth->id])->interface;  | 
                                                        |
| 160 | + $eth->$name = LanInterfaces::findFirstById($data[$name.'_'.$eth->id])->interface;  | 
                                                        |
| 161 | 161 | }  | 
                                                        
| 162 | 162 | break;  | 
                                                        
| 163 | 163 | case 'domain':  | 
                                                        
@@ -172,8 +172,8 @@ discard block  | 
                                                    ||
| 172 | 172 | }  | 
                                                        
| 173 | 173 | break;  | 
                                                        
| 174 | 174 | default:  | 
                                                        
| 175 | -                    if (array_key_exists($name . '_' . $eth->id, $data)) { | 
                                                        |
| 176 | - $eth->$name = $data[$name . '_' . $eth->id];  | 
                                                        |
| 175 | +                    if (array_key_exists($name.'_'.$eth->id, $data)) { | 
                                                        |
| 176 | + $eth->$name = $data[$name.'_'.$eth->id];  | 
                                                        |
| 177 | 177 | }  | 
                                                        
| 178 | 178 | |
| 179 | 179 | }  | 
                                                        
@@ -188,7 +188,7 @@ discard block  | 
                                                    ||
| 188 | 188 | public function deleteAction($ethId = '')  | 
                                                        
| 189 | 189 |      { | 
                                                        
| 190 | 190 | $eth = LanInterfaces::findFirstById($ethId);  | 
                                                        
| 191 | -        if ( ! $eth || $eth->delete() === false) { | 
                                                        |
| 191 | +        if (!$eth || $eth->delete() === false) { | 
                                                        |
| 192 | 192 | $errors = $eth->getMessages();  | 
                                                        
| 193 | 193 |              $this->flash->warning(implode('<br>', $errors)); | 
                                                        
| 194 | 194 | $this->view->success = false;  |