/** * титульная страница со списком клиентов */ public function action_index() { $search = $this->request->post('search'); $clients = Model_Client::getClientsList($search); $popupClientAdd = Common::popupForm('Добавление нового клиента', 'client/add'); $this->tpl->bind('clients', $clients)->bind('popupClientAdd', $popupClientAdd); }
/** * грузим список клиентов по менеджеру */ public function action_load_clients() { $managerId = $this->request->post('manager_id'); $clients = Model_Client::getClientsList(false, ['manager_id' => $managerId]); if ($clients === false) { $this->jsonResult(0); } $this->jsonResult(1, $clients); }
/** * получаем список клиентов для combobox */ public function action_list_client() { $res = Model_Client::getClientsList($this->_search, ['ids' => $this->_ids]); if (empty($res)) { $this->jsonResult(false); } $return = []; foreach ($res as $item) { $return[] = ['name' => $item['LONG_NAME'], 'value' => $item['CLIENT_ID']]; } $this->jsonResult(true, $return); }
/** * проверка доступов * * @param $type * @param $id */ public static function check($type, $id) { $allow = false; if (!empty($type)) { switch ($type) { case 'client': if (!empty($id)) { $clients = Model_Client::getClientsList(); if (!empty($clients[$id])) { $allow = true; } } break; } } if (!$allow) { throw new HTTP_Exception_404(); } }