Пример #1
0
 function actionModify()
 {
     $id = (int) $this->_context->get('id');
     $rs = Plans::find('plan_id = ?', $id)->getOne();
     $form = Form_Common::createForm('', 'manage/plans');
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         $post = $this->_context->post();
         $dsp = array_combine($post['config']['val'], $post['config']['dsp']);
         $tmp = array();
         foreach ($dsp as $val => $dsp) {
             $tmp[] = array('price' => $val, 'print' => $dsp);
         }
         $sku = array_combine($post['config']['key'], $tmp);
         $rs->name = $post['name'];
         $rs->desc = $post['desc'];
         $rs->groupname = $post['groupname'];
         $rs->sku = phpversion() >= '5.4' ? json_encode($sku, JSON_UNESCAPED_UNICODE) : json_encode($sku);
         $rs->save();
         return $this->msg($tip = '修改成功', url('manage::plans/modify', array('id' => $id)));
     }
     $groupname_list = Radgroupcheck::find()->group('groupname')->getAll()->toHashMap('groupname', 'groupname');
     $form->element('groupname')->items = $groupname_list;
     $form->import($rs->toArray());
     $this->_view['_UDI'] = 'manage::plans/index';
     $this->_view['form'] = $form;
     $this->_view['rs'] = $rs;
 }
Пример #2
0
 function actionModgroup()
 {
     $type = $this->_context->type;
     $name = $this->_context->get('name');
     $page = (int) $this->_context->get('page', 1);
     if ($deleteid = $this->_context->deleteid) {
         if ($type == 'check') {
             Radgroupcheck::meta()->deleteWhere('id = ?', $deleteid);
         } else {
             Radgroupreply::meta()->deleteWhere('id = ?', $deleteid);
         }
         return $this->msg($tip = '删除成功', url('manage::radius/index'));
     }
     if ($this->_context->isPost()) {
         $post = $this->_context->post();
         $orm = $type == 'check' ? Radgroupcheck::find() : Radgroupreply::find();
         if (isset($post['id'])) {
             $orm->where('id = ?', (int) $post['id']);
             $orm = $orm->getOne();
             unset($post['type'], $post['id']);
             $orm->changeProps($post);
             $orm->save();
             return $this->msg($tip = '修改成功', url('manage::radius/modgroup', array('type' => $type, 'name' => $post['groupname'])));
         } else {
             $orm->where('id = ?', 0);
             $orm = $orm->getOne();
             unset($post['type']);
             $orm->changeProps($post);
             $orm->save();
             return $this->msg($tip = '添加成功', url('manage::radius/modgroup', array('type' => $type, 'name' => $post['groupname'])));
         }
     }
     $rs = $type == 'check' ? Radgroupcheck::find() : Radgroupreply::find();
     $rs->where('groupname = ?', $name);
     $rs->limitPage($page, 20);
     $this->_view['rs'] = $rs->getAll();
     $this->_view['pg'] = $rs->getPag();
     $this->_view['tg'] = $type == 'check' ? 'Radgroup Check' : 'Radgroup Reply';
     $this->_view['type'] = $type == 'check' ? 'check' : 'reply';
     $this->_view['_UDI'] = 'manage::radius/index';
 }