public function addMenuItemAction() { $request = $this->getRequest(); $form = new Security_Form_Menu(); if ($request->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $model = new Security_Model_SystemMaster(); $model->setMasterCode("fdMenu"); $model->setMasterValue($options['title']); $model->setStatus($options['isActive']); $model->setStrval1($options['path']); $model->setStrval2($options['toolTip']); $model->setIntval1($options['parentMenuId']); $model->setBlnval1($options['isChild']); $id = $model->save(); if ($id) { $this->_flashMessenger->addMessage(array('success' => 'Menu item added successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } else { $this->_flashMessenger->addMessage(array('error' => 'Failed to add menu item!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } $form->reset(); } else { $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function createAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $parent_node_id = $this->_getParam('parent_node_id'); $child_master_value = $this->_getParam('node_title'); $arrNode = explode("_", $parent_node_id); $parent_master_code = $arrNode[0]; $parent_master_id = $arrNode[1]; $model = new Security_Model_SystemMaster(); if ($parent_master_code == "noderoot") { // create group $child_master_code = "fdUserGroup"; } else { if ($parent_master_code == "fdUserGroup") { //create sub group $child_master_code = "fdUserSubGroup"; $map_code = "fdGroupSubGroupMap"; } else { if ($parent_master_code == "fdUserSubGroup") { //create new role $child_master_code = "fdUserRole"; $map_code = "fdSubGroupRoleMap"; } } } $model->setMasterCode($child_master_code); $model->setMasterValue($child_master_value); $node_id = $model->save(); if ($parent_master_code !== "noderoot") { //mapping start $objMapping = new Security_Model_SystemMapping(); $objMapping->setMapId1($parent_master_id); $objMapping->setMapId2($node_id); $objMapping->setMapCode($map_code); if (true === $objMapping->save()) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } else { if ($node_id) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } echo $result; }
public function addMenuItemAction() { $request = $this->getRequest(); $form = new Security_Form_Menu(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); //$element->removeDecorator('Errors'); } //echo $this->getFrontController()->getBaseUrl(); $this->getIconsList(); if ($request->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $model = new Security_Model_SystemMaster(); $model->setMasterCode("fdMenu"); $model->setMasterValue($options['title']); $model->setStatus($options['isActive']); $model->setStrval1($options['path']); $model->setStrval2($options['toolTip']); $model->setIntval1($options['parentMenuId']); $model->setBlnval1($options['isChild']); $model->setBlnval2($options['isAction']); $model->setStrval3($options['menuIcon']); $id = $model->save(); if ($id) { $this->_flashMessenger->addMessage(array('success' => 'Menu item added successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } else { $this->_flashMessenger->addMessage(array('error' => 'Failed to add menu item!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/menu/add-menu-item')); } $form->reset(); } else { $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function createAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $parent_node_id = $this->_getParam('parent_node_id'); $child_master_value = $this->_getParam('node_title'); $arrNode = explode("_", $parent_node_id); $parent_master_code = $arrNode[0]; $parent_master_id = $arrNode[1]; $model = new Security_Model_SystemMaster(); if ($parent_master_code == "noderoot") { // create group $child_master_code = "fdAction"; } $model->setMasterCode($child_master_code); $model->setMasterValue($child_master_value); $node_id = $model->save(); if ($node_id) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } echo $result; }
public function deladdSystemMasterAction() { $guid = $this->_getParam('guid'); $delete = $this->_getParam("delete"); $guid2 = $this->_getParam("guid2"); //echo $delete.'----'.$guid2; if (!empty($guid) && empty($delete)) { //start Edit system master $this->view->pageHeading = "Edit System Master"; $this->view->assign('mode', 'edit'); $model1 = new Security_Model_SystemMaster(); $model = $model1->fetchRow("row_guid='" . $guid . "'"); if (false === $model) { $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/privilege/add-system-master/guid/' . $guid)); } $options['masterCode'] = $model->getMasterCode(); $options['masterValue'] = $model->getMasterValue(); // $options['intval1'] = $model->getIntval1(); $options['status'] = $model->getStatus(); $this->view->assign('guid', $model->getRowGuid()); $request = $this->getRequest(); $form = new Security_Form_SystemMaster(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } $usersNs = new Zend_Session_Namespace("members"); if ($usersNs->userId == guid) { $form->removeElement('status'); } $modelP = new Base_Security_Privilege(); // $form->populate($options); $form->populate($options); $options = $request->getPost(); if ($request->isPost()) { $modelP = new Base_Security_Privilege(); if ($form->isValid($options)) { $model->setOptions($options); $model->save(); $this->_flashMessenger->addMessage(array('success' => 'System Master information has been updated successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl("/security/privilege/add-system-master")); } else { $this->_flashMessenger->addMessage(array('error' => 'Unable to save the data. Please provide valid inputs and try again.')); $form->reset(); $form->populate($options); } } //End Edit system master } else { if (!empty($guid2) && !empty($delete) && $delete == 'yes') { //Start delete system master $this->view->pageHeading = "Delete System Master"; $model1 = new Security_Model_SystemMaster(); $model = $model1->delete("row_guid='" . $guid2 . "'"); if (true == $model || $model > 0) { $this->_flashMessenger->addMessage(array('success' => 'System Master information has been deleted successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl("/security/privilege/add-system-master")); } $request = $this->getRequest(); $form = new Security_Form_SystemMaster(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); //$element->removeDecorator('Errors'); } //End delete system master } else { //Add system master $request = $this->getRequest(); $form = new Security_Form_SystemMaster(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); //$element->removeDecorator('Errors'); } $search = trim($this->_getParam('search')); if ($request->isPost() && empty($search)) { $options = $request->getPost(); if ($form->isValid($options)) { //$options['status']='1'; $model = new Security_Model_SystemMaster($options); $id = $model->save(); if ($id) { $this->_flashMessenger->addMessage(array('success' => 'System master added successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/privilege/add-system-master')); } else { $this->_flashMessenger->addMessage(array('error' => 'Failed to add System master!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/privilege/add-system-master')); } $form->reset(); } else { $form->reset(); $form->populate($options); } } //End Add system master } } //Start system master listing $search = trim($this->_getParam('search')); $this->view->assign('searchText', $search); //$status = trim($this->_getParam('status')); /*---sorting ----*/ $order = trim($this->_getParam('order', "")); $col = trim($this->_getParam('col', "")); if ($order != "" && $col != "") { if ($col == "master_code") { $strOrderBy = "s.master_code {$order}"; } else { if ($col == "status") { $strOrderBy = "s.status {$order}"; } } } else { $strOrderBy = "s.created_on desc"; } $this->view->sortOptions = array(); /*-----sorting----------*/ $where = "1"; $this->view->linkArray = array(); $this->view->search = ""; if ($search != "") { $where = "(master_code like '%{$search}%' or master_value like '%{$search}%') and {$where} "; //$where="(master_code like '%{$search}%') and status='1'"; $this->view->linkArray = array('search' => $search); $this->view->search = $search; $this->view->sortOptions['master_code'] = $search; } $page_size = Zend_Registry::get('page_size'); $page = $this->_getParam('page', 1); $model = new Security_Model_SystemMaster(); $table = $model->getMapper()->getDbTable(); $select = $table->select()->setIntegrityCheck(false)->from(array("s" => 'system_master'))->order("{$strOrderBy}")->where($where); $sql = $select->__toString(); $paginator = Base_Paginator::factory($select); $paginator->setItemCountPerPage($page_size); $paginator->setCurrentPageNumber($page); $this->view->totalItems = $paginator->getTotalItemCount(); $this->view->paginator = $paginator; //End For listing $this->view->form = $form; }
public function createAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $parent_node_id = $this->_getParam('parent_node_id'); //print_r ($parent_node_id); $child_master_value = $this->_getParam('node_title'); $arrNode = explode("_", $parent_node_id); $parent_master_code = $arrNode[0]; $parent_master_id = $arrNode[1]; $model = new Security_Model_SystemMaster(); $entry_in_master_tbl = 'Yes'; if ($parent_master_code == "noderoot") { // create group $child_master_code = "fdAnimal"; $where = "master_value = '{$child_master_value}'"; $already_exists_validation = $model->fetchRow($where); if ($already_exists_validation) { return 0; } } else { if ($parent_master_code == "fdAnimal") { //create sub group $parent_master_id = $arrNode[1]; $child_master_code = "fdAnimalType"; $map_code = "fdAnimalAnimalTypeAnimalColorMap"; $where = "master_value = '{$child_master_value}'"; $already_exists_validation = $model->fetchRow($where); if ($already_exists_validation) { $entry_in_master_tbl = 'No'; } } else { if ($parent_master_code == "fdAnimalType") { //create new role $parent_master_id = $arrNode[2]; $child_master_id = $arrNode[1]; $child_master_code = "fdAnimalColor"; $map_code = "fdAnimalAnimalTypeAnimalColorMap"; $where = "master_value = '{$child_master_value}'"; $already_exists_validation = $model->fetchRow($where); if ($already_exists_validation) { $entry_in_master_tbl = 'No'; } } } } echo $entry_in_master_tbl; if ($entry_in_master_tbl == 'Yes') { $model->setMasterCode($child_master_code); $model->setMasterValue($child_master_value); $node_id = $model->save(); } else { if ($entry_in_master_tbl == 'No') { $node_id = $already_exists_validation->masterId; } } //echo $node_id ; if ($parent_master_code !== "noderoot") { //mapping start $objMapping = new Security_Model_SystemMapping(); $objMapping->setMapId1($parent_master_id); if ($child_master_id) { $objMapping->setMapId2($child_master_id); $objMapping->setMapId3($node_id); $objMapping->setMapCode($map_code); //$objMapping->UpdateMapId3_MapId2($map_code,$parent_master_id,$child_master_id,$node_id); $objMapping->save(); $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $objMapping->setMapId2($node_id); $objMapping->setMapCode($map_code); if (true === $objMapping->save()) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } } else { if ($node_id) { $result = Zend_Json::encode(array("status" => true, "node_id" => $child_master_code . "_" . $node_id)); } else { $result = Zend_Json::encode(array("status" => false)); } } return $result; }