public function __construct($postIds, $periodFirst, $periodSecond, $fetchEmps = true, $fetchSubEmps = true, $func)
 {
     if (!empty($postIds)) {
         $table = 'user_rp_tree_posts_employees_PM';
         if ($fetchEmps) {
             $this->rows = $this->_fetch('post_id', $postIds, $periodFirst, $periodSecond, $table);
             $treePosts = new Rp_Db_View_TreePosts();
             $this->postNames = $treePosts->fetchNames($postIds);
         }
         if ($fetchSubEmps) {
             $this->subRows = $this->_fetch('post_pid', $postIds, $periodFirst, $periodSecond, $table);
         }
         if ($func) {
             $table = 'user_rp_tree_posts_func';
             $this->subRows = $this->_fetch('post_func_id', $postIds, $periodFirst, $periodSecond, $table);
         }
     } else {
         if ($fetchEmps) {
             $this->rows = array();
         }
         if ($fetchSubEmps) {
             $this->subRows = array();
         }
         if ($func) {
             $this->subRows = array();
         }
     }
     $this->periodFirst = $periodFirst;
     $this->periodSecond = $periodSecond;
 }
 /**
  * Возвращает объект строки должности сотрудника
  * из дерева должностей.
  *
  * @return Rp_Db_View_Row_TreePost
  * @throws Exception
  */
 public function getTreePost()
 {
     if (empty($this->_treePost)) {
         $treePosts = new Rp_Db_View_TreePosts();
         $this->_treePost = $treePosts->findByEmployeeId($this->person_id);
         if (empty($this->_treePost)) {
             throw new Zend_Exception('Сотрудник не определен в иерархической структуре должностей.');
         }
     }
     return $this->_treePost;
 }
 public function subPostsAction()
 {
     $request = $this->getRequest();
     $uri_arr = explode('=', $request->getRequestUri());
     $_GET['JSQUERYID'] = array_pop($uri_arr);
     Zend_Loader::loadFile('JsDataLoader.php', 'Rp');
     $id = $request->getParam('id');
     $treePosts = new Rp_Db_View_TreePosts();
     $result['pid'] = $id;
     $result['posts'] = $treePosts->findChildPosts($id, true)->toArray();
     $GLOBALS['_RESULT'] = $result;
     exit;
 }