public function init() { $roles = new Model_Roles(); $result = $roles->getRoles(); if ($result) { foreach ($result as $row) { $this->_list["role"][$row->getPkId()] = $row->getRoleName(); } } $resources = new Model_Resources(); $result2 = $resources->getAllResources(); if ($result2) { foreach ($result2 as $row2) { $resource = $row2->getResourceName(); $arr_resources = explode("/", $resource); $second_name = !empty($arr_resources[1]) ? ucfirst($arr_resources[1]) . " - " : ""; $this->_list["resource"][$row2->getPkId()] = ucfirst($arr_resources[0]) . " - " . $second_name . $row2->getDescription(); } } foreach ($this->_fields as $col => $name) { if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } }
public function indexAction() { $form = new Form_Iadmin_RoleSearch(); $form_add = new Form_Iadmin_Roles(); $params = array(); $roles = new Model_Roles(); if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { $role_name = $form->getValue('role_name'); $description = $form->getValue('description'); if (!empty($role_name)) { $params['roleName'] = $role_name; } if (!empty($description)) { $params['description'] = $description; } } } else { $role_name = $this->_getParam('role_name'); $description = $this->_getParam('description'); if (!empty($role_name)) { $params['roleName'] = $role_name; $form->role_name->setValue($role_name); } if (!empty($description)) { $params['description'] = $description; $form->description->setValue($description); } } $sort = $this->_getParam("sort", "asc"); $order = $this->_getParam("order", "role_name"); $roles->form_values = $params; $result = $roles->getRoles($order, $sort); //Paginate the contest results $paginator = Zend_Paginator::factory($result); $page = $this->_getParam("page", 1); $counter = $this->_getParam("counter", 10); $paginator->setCurrentPageNumber((int) $page); $paginator->setItemCountPerPage((int) $counter); $this->view->form = $form; $this->view->form_add = $form_add; $this->view->paginator = $paginator; $this->view->sort = $sort; $this->view->order = $order; $this->view->counter = $counter; $this->view->pagination_params = $params; }
public function init() { $roles = new Model_Roles(); $result = $roles->getRoles(); $action = Zend_Registry::get("action"); if ($action == 'role-resources') { $this->_list["role"][""] = 'Select'; } if ($result) { foreach ($result as $row) { $this->_list["role"][$row->getPkId()] = $row->getRoleName(); } } $em = Zend_Registry::get("doctrine"); $result = $em->getRepository("ResourceTypes")->findAll(); $this->_list["resource_type"][''] = "Select"; foreach ($result as $rs) { $this->_list["resource_type"][$rs->getPkId()] = $rs->getResourceType(); } foreach ($this->_fields as $col => $name) { switch ($col) { case "description": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; case "resource_name": $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); break; default: break; } if (in_array($col, array_keys($this->_list))) { $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array())); $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag"); } } }