public static function ensureGroupNodes() { $db = Database::connection(); $tree = GroupTree::get(); $rootNode = $tree->getRootTreeNodeObject(); $rows = $db->GetCol('select Groups.gID from Groups left join TreeGroupNodes on Groups.gID = TreeGroupNodes.gID where TreeGroupNodes.gID is null'); foreach ($rows as $gID) { $g = static::getByID($gID); GroupTreeNode::add($g, $rootNode); } }
?> <?php $tp = new TaskPermission(); if (!$tp->canAccessGroupSearch()) { ?> <p><?php echo t('You do not have access to the group search.'); ?> </p> <?php } else { $form = Loader::helper('form'); $searchRequest = $_REQUEST; $result = Loader::helper('json')->encode($controller->getSearchResultObject()->getJSONObject()); $tree = GroupTree::get(); $guestGroupNode = GroupTreeNode::getTreeNodeByGroupID(GUEST_GROUP_ID); $registeredGroupNode = GroupTreeNode::getTreeNodeByGroupID(REGISTERED_GROUP_ID); ?> <style type="text/css"> div[data-search=groups] form.ccm-search-fields { margin-left: 0px !important; } </style> <div data-search="groups"> <script type="text/template" data-template="search-form"> <form role="form" data-search-form="groups" action="<?php echo URL::to('/ccm/system/search/groups/submit'); ?>
/** * edit method * * @throws NotFoundException * @param string $id * @return void */ public function edit($id = null) { $this->set('title_for_layout', __d('webzash', 'Edit Account Ledger')); /* Check for valid ledger */ if (empty($id)) { $this->Session->setFlash(__d('webzash', 'Account ledger not specified.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } $ledger = $this->Ledger->findById($id); if (!$ledger) { $this->Session->setFlash(__d('webzash', 'Account ledger not found.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } /* Create list of parent groups */ $parentGroups = new GroupTree(); $parentGroups->Group =& $this->Group; $parentGroups->current_id = -1; $parentGroups->build(0); $parentGroups->toList($parentGroups, -1); $this->set('parents', $parentGroups->groupList); /* on POST */ if ($this->request->is('post') || $this->request->is('put')) { /* Check if acccount is locked */ if (Configure::read('Account.locked') == 1) { $this->Session->setFlash(__d('webzash', 'Sorry, no changes are possible since the account is locked.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } /* If code is empty set it as NULL */ if (empty($this->request->data['Ledger']['code'])) { $this->request->data['Ledger']['code'] = NULL; } /* If opening balance is not set or empty make it 0 */ if (empty($this->request->data['Ledger']['op_balance'])) { $this->request->data['Ledger']['op_balance'] = 0; } /* Count number of decimal places */ if (countDecimal($this->request->data['Ledger']['op_balance']) > Configure::read('Account.decimal_places')) { $this->Session->setFlash(__d('webzash', 'Invalid amount specified. Maximum %s decimal places allowed.', Configure::read('Account.decimal_places')), 'danger'); return; } /* Set ledger id */ unset($this->request->data['Ledger']['id']); $this->Ledger->id = $id; /* Save ledger */ $ds = $this->Ledger->getDataSource(); $ds->begin(); if ($this->Ledger->save($this->request->data)) { $this->Log->add('Edited Ledger : ' . $this->request->data['Ledger']['name'], 1); $ds->commit(); $this->Session->setFlash(__d('webzash', 'Account ledger "%s" updated.', $this->request->data['Ledger']['name']), 'success'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } else { $ds->rollback(); $this->Session->setFlash(__d('webzash', 'Failed to update account ledger. Please, try again.'), 'danger'); return; } } else { $this->request->data = $ledger; return; } }
/** * edit method * * @throws NotFoundException * @throws ForbiddenException * @param string $id * @return void */ public function edit($id = null) { $this->set('title_for_layout', __d('webzash', 'Edit Account Group')); /* Check for valid group */ if (empty($id)) { $this->Session->setFlash(__d('webzash', 'Account group not specified.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } $group = $this->Group->findById($id); if (!$group) { $this->Session->setFlash(__d('webzash', 'Account group not found.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } if ($id <= 4) { $this->Session->setFlash(__d('webzash', 'Cannot edit basic account groups.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } /* Create list of parent groups */ $parentGroups = new GroupTree(); $parentGroups->Group =& $this->Group; $parentGroups->current_id = $id; $parentGroups->build(0); $parentGroups->toList($parentGroups, -1); $this->set('parents', $parentGroups->groupList); /* on POST */ if ($this->request->is('post') || $this->request->is('put')) { /* Check if acccount is locked */ if (Configure::read('Account.locked') == 1) { $this->Session->setFlash(__d('webzash', 'Sorry, no changes are possible since the account is locked.'), 'danger'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } /* Set group id */ unset($this->request->data['Group']['id']); $this->Group->id = $id; /* Check if group and parent group are not same */ if ($id == $this->request->data['Group']['parent_id']) { $this->Session->setFlash(__d('webzash', 'Account group and parent group cannot be same.'), 'danger'); return; } /* If code is empty set it as NULL */ if (empty($this->request->data['Group']['code'])) { $this->request->data['Group']['code'] = NULL; } /* Save group */ $ds = $this->Group->getDataSource(); $ds->begin(); if ($this->Group->save($this->request->data)) { $this->Log->add('Edited Group : ' . $this->request->data['Group']['name'], 1); $ds->commit(); $this->Session->setFlash(__d('webzash', 'Account group "%s" updated.', $this->request->data['Group']['name']), 'success'); return $this->redirect(array('plugin' => 'webzash', 'controller' => 'accounts', 'action' => 'show')); } else { $ds->rollback(); $this->Session->setFlash(__d('webzash', 'Failed to update account group. Please, try again.'), 'danger'); return; } } else { $this->request->data = $group; return; } }