/** * Index controller */ public function indexAction() { try { $this->view->categories_documents = CategoriesDocuments::find(); $this->view->pesquisa = ''; if ($this->request->isPost()) { $categories_documents = $this->request->getPost('categories_documents', 'string'); $search = "UPPER(description) LIKE UPPER('%" . $categories_documents . "%')"; $this->view->categories_documents = CategoriesDocuments::find($search); $this->view->pesquisa = $this->request->getPost('categories_documents'); } } catch (Exception $exc) { $this->flash->error($e->getMessage()); } }
/** * * @param type $id * @param type $docs * @return ObjectPhalcon */ private function getMenu($id = null, $docs = false) { $return = []; $desc = ''; if (!$docs) { $desc = 'DESC'; } $param['order'] = "department {$desc}, category {$desc}"; $baseUri = $this->url->getBaseUri(); if (is_numeric($id)) { if ($id == 0) { $param['conditions'] = 'department IS NULL '; } else { $param['conditions'] = 'department = ' . (int) $id; } } if ($docs) { $catDocs = CategoriesDocuments::find($param); foreach ($catDocs as $catDoc) { $department = $catDoc->departments->id; $titleDepartment = $catDoc->departments->title; $ccDepartment = $catDoc->departments->cc; $iconDepartment = $catDoc->departments->icon; $category = $catDoc->categories->id; $titleCategory = $catDoc->categories->title; $descriptionCategory = $catDoc->categories->description; $iconCategory = $catDoc->categories->icon; $return[$department]['title'] = $titleDepartment; $return[$department]['cc'] = $ccDepartment; $return[$department]['icon'] = $iconDepartment; $return[$department]['category'][$category]['title'] = $titleCategory; $return[$department]['category'][$category]['description'] = $descriptionCategory; $return[$department]['category'][$category]['icon'] = $iconCategory; $return[$department]['category'][$category]['document'][$catDoc->id]['description'] = $catDoc->description; } } $param['order'] = "department {$desc}, title, category {$desc}"; $menus = Menus::find($param); $currentModule = $this->dispatcher->getModuleName(); $currentController = $this->dispatcher->getControllerName(); $currentAction = $this->dispatcher->getActionName(); $currentDepartment = ''; $currentCategory = ''; $baseUri = $this->url->getBaseUri(); foreach ($menus as $menu) { $modules = $menu->modules->slug; $controllers = $menu->controllers->slug; $actions = $menu->actions->slug; if ($this->access->isAllowed('private', $modules, $controllers, $actions) or $this->access->isAllowed('public', $modules, $controllers, $actions)) { if (is_null($menu->department)) { $department = 0; $titleDepartment = ''; $ccDepartment = ''; $iconDepartment = ''; } else { $department = $menu->departments->id; $titleDepartment = $menu->departments->title; $ccDepartment = $menu->departments->cc; $iconDepartment = $menu->departments->icon; } if (is_null($menu->category)) { $category = 0; $titleCategory = 0; $descriptionCategory = ''; $iconCategory = ''; } else { $category = $menu->categories->id; $titleCategory = $menu->categories->title; $descriptionCategory = $menu->categories->description; $iconCategory = $menu->categories->icon; } if ($currentModule == $modules && $currentController == $controllers && $currentAction == $actions) { $return[$department]['active'] = 'active toggled'; $return[$department]['category'][$category]['active'] = 'active toggled'; $return[$department]['category'][$category]['menus'][$menu->id]['active'] = 'active'; $currentDepartment = $department; $currentCategory = $category; } if ($currentDepartment != $department) { $return[$department]['active'] = ''; } if ($currentCategory != $category) { $return[$department]['category'][$category]['active'] = ''; } if ($currentAction != $actions) { $return[$department]['category'][$category]['menus'][$menu->id]['active'] = ''; } $return[$department]['title'] = $titleDepartment; $return[$department]['cc'] = $ccDepartment; $return[$department]['icon'] = $iconDepartment; $return[$department]['category'][$category]['title'] = $titleCategory; $return[$department]['category'][$category]['description'] = $descriptionCategory; $return[$department]['category'][$category]['icon'] = $iconCategory; $return[$department]['category'][$category]['menus'][$menu->id]['title'] = $menu->title; $return[$department]['category'][$category]['menus'][$menu->id]['slug'] = $baseUri . $menu->slug; $return[$department]['category'][$category]['menus'][$menu->id]['icon'] = $menu->icon; } } ksort($return); return new ObjectPhalcon($return); }