Пример #1
0
 public function doWebPrizes()
 {
     global $_GPC, $_W, $ptr_title;
     checklogin();
     load()->func('tpl');
     $op = $_GPC['op'];
     $group_id = intval($_GPC['group_id']);
     $settings = getModulesSettings($this->modulename);
     if ($group_id <= 0) {
         $group_id = $settings['prize_group'];
     }
     $_GPC['group_id'] = $group_id;
     $ops = array('display', 'edit', 'delete', 'test', 'record');
     $op = in_array($op, $ops) ? $op : 'display';
     $cls = new Prize();
     $ptr_title = '奖品例表';
     //ajax 按钮
     if ($_W['ispost'] && $_W['isajax']) {
         if (!empty($_GPC['fieldmap']) && $_GPC['fieldmap'] == 'status' && $cls->change()) {
             exit('success');
         } elseif (!empty($_GPC['fieldmap']) && $_GPC['fieldmap'] == 'release' && $cls->release()) {
             exit('success');
         }
         exit('操作失败');
     }
     if ($op == 'delete') {
         if ($cls->delete()) {
             message('删除成功!', $this->createWebUrl('Prizes'));
         }
     } elseif ($op == 'edit') {
         list($code, $groups) = $cls->groups();
         $id = $_GPC['id'];
         $_W['page']['title'] = intval($id) > 0 ? '奖品编辑 - 主要业务模块 - 签到' : '奖品添加 - 主要业务模块 - 签到';
         $ptr_title = intval($id) > 0 ? '奖品编辑' : '奖品添加';
         list($code, $message, $prize) = $cls->edit();
         if (!$code) {
             message($message);
         }
         if (intval($id) > 0 && empty($prize)) {
             message('奖品不存在.', $this->createWebUrl('Prizes', array('group_id' => $group_id)));
         }
         if ($code && !empty($message)) {
             message($message, $this->createWebUrl('Prizes', array('group_id' => $group_id)));
         }
     } elseif ($op == 'test') {
         $cls->test_lottery(1, $settings['prize_group']);
     } elseif ($op == 'record') {
         $prize = $cls->findPrize();
     }
     if (checksubmit('import')) {
         $cls->import();
     }
     //导入奖品
     list($list, $total, $pager) = $cls->_list();
     //未领
     include $this->template('prizes');
 }