Ejemplo n.º 1
0
 public function settingsDisplay($settings)
 {
     global $_GPC, $_W;
     $credits = uni_setting($_W['uniacid'], 'creditnames');
     $cls = new Prize();
     list($code, $groups) = $cls->groups();
     if (checksubmit()) {
         $cfg = array('times' => $_GPC['times'], 'start_time' => $_GPC['start_time'], 'end_time' => $_GPC['end_time'], 'prize_group' => $_GPC['prize_group'], 'credit_type' => $_GPC['credit_type'], 'credit' => intval($_GPC['credit']), 'rank' => intval($_GPC['rank']));
         $start_time = $cfg['start_time'];
         $start_time = strtotime($start_time);
         $end_time = $cfg['end_time'];
         $end_time = strtotime($end_time);
         if ($start_time >= $end_time) {
             message('开始时间不得晚于结束时间', 'refresh', 'error');
         } elseif ($this->saveSettings($cfg)) {
             message('保存成功', 'refresh');
         }
     }
     if (!isset($settings) || empty($settings)) {
         $UnIaCid = $_W['uniacid'];
         $par = array(':module' => $this->modulename, ':uniacid' => $UnIaCid);
         $sql = "SELECT COUNT(*) FROM " . tablename("uni_account_modules") . " WHERE module=:module AND uniacid=:uniacid";
         $row = pdo_fetchcolumn($sql, $par);
         if (empty($row) || intval($row) <= 0) {
             $cfg = array('module' => $this->modulename, 'uniacid' => $UnIaCid, 'enabled' => 1);
             pdo_insert("uni_account_modules", $cfg);
         }
     }
     if (!isset($settings['times'])) {
         $settings['times'] = '1';
     }
     if (!isset($settings['start_time'])) {
         $settings['start_time'] = '08:30';
     }
     if (!isset($settings['end_time'])) {
         $settings['end_time'] = '22:00';
     }
     if (!isset($settings['credit'])) {
         $settings['credit'] = '1';
     }
     if (!isset($settings['rank'])) {
         $settings['rank'] = '10';
     }
     include $this->template('setting');
 }
Ejemplo n.º 2
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');
 }