/**
  * Возвращает список должностей диллера
  * @param $params -- набор параметров поиска диллера
  * @return array -- список должностей
  */
 public static function getPostsByDealer($params)
 {
     $dealer = \Dealers::findFirst($params);
     $stafflists = \Stafflist::find("stafflist_group=" . $dealer->stafflist_group_id);
     $posts = array();
     foreach ($stafflists as $stafflist) {
         $posts[] = $stafflist->Posts;
     }
     return $posts;
 }
 public function getPostsAction($gid = NULL)
 {
     if ($gid == NULL) {
         if ($this->request->get("stafflistGroup")) {
             $gid = $this->request->get("stafflistGroup");
         } else {
             $result = NULL;
         }
     } else {
         $posts = \Posts::find();
         $stafflists = \Stafflist::find("stafflist_group=" . $gid);
         $result = array();
         foreach ($posts as $post) {
             if (!$this->checkPostInStaff($post, $stafflists)) {
                 $result[] = $post->toArray(true);
             }
         }
     }
     $this->view->disable();
     $this->response->setContentType('application/json', 'UTF-8');
     echo json_encode($result);
 }
 public function editAction($gid)
 {
     $this->view->stafflist = is_null($gid) ? new \Stafflist() : \Stafflist::find("stafflist_group='" . $gid . "'");
     $this->view->gid = $gid;
     $this->view->title = "Редагувати штатний розклад \"" . \StafflistGroup::findFirst($gid)->title . "\"";
 }