public function loadtypesAction() { $query = new Query(); $this->view->title = 'Добавление нового типа'; $this->view->header = 'Добавление нового типа'; $page = intval($_POST['page']); $onPage = intval($_POST['onPage']); if ($page) { if (!$onPage) { $onPage = 10; } $start = $page * $onPage - $onPage; } else { $start = 0; $page = 1; $onPage = 10; } if (isset($_POST['name'])) { $where[] = 'type_name Like ' . K_Db_Quote::quote('%' . $_POST['name'] . '%'); } if (isset($_POST['desc'])) { $where[] = 'type_desc Like ' . K_Db_Quote::quote('%' . $_POST['desc'] . '%'); } if ($where && count($where)) { $where = ' WHERE ' . implode(' AND ', $where); } $query = new Query(); $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM types {$where} order by type_name LIMIT {$start}, {$onPage}"; $itemsRes = $query->q($sql); $sql = "SELECT FOUND_ROWS() as countItems;"; $countItems = $query->q($sql); $countItems = $countItems[0]['countItems']; $items = array(); foreach ($itemsRes as $v) { $itemRow['type_id'] = $v['type_id']; $itemRow['name'] = htmlspecialchars($v['type_name']); $itemRow['desc'] = htmlspecialchars($v['type_desc']); $items[] = $itemRow; } $returnJson = array('error' => false, 'items' => $items, 'countItems' => $countItems); $this->putJSON($returnJson); }
public function indexAction() { $query = new Query(); $this->view->title = 'Инструменты разработчика'; $this->view->header = 'Инструменты разработчика'; $this->view->headers = array(array('title' => 'Менеджер типов', 'href' => '/admin/typesmanager/'), array('title' => 'Инструменты разработчика')); $this->view->formStructure = Gcontroller::loadFormStructure('/forms/add_type/', get_class()); $this->view->types = $query->q('SELECT type_name FROM types ORDER BY type_name'); $this->view->actionType = 'create'; $this->render('devtools'); }