예제 #1
0
파일: site.php 프로젝트: ChainBoy/wxfx
 public function doWebRedGifts()
 {
     global $_W, $_GPC;
     if (!$_W['ispost']) {
         $this->doWebAuth();
         checklogin();
     }
     $modulePublic = '../addons/wwx_fxxt/style/static/';
     $foo = $_GPC['foo'];
     $foos = array('list', 'create', 'modify', 'delete', 'search');
     $foo = in_array($foo, $foos) ? $foo : 'list';
     require_once WWX_FXXT_ROOT . '/class/Gift.class.php';
     if ($foo == 'search') {
         $fuzzy = $_GPC['fuzzy'];
         $filters = array();
         $filters['title'] = $fuzzy;
         $g = new Gift();
         $ds = $g->getAll($filters, 1, 20);
         /**GIFT:2.查询所有活动礼品分类**/
         $rs = array();
         if (!empty($ds)) {
             foreach ($ds as $row) {
                 $rs[] = array_elements(array('id', 'type', 'title'), $row);
             }
         }
         exit(json_encode($rs));
     }
     if ($foo == 'create') {
         if ($_W['ispost']) {
             $input = array_elements(array('title', 'type', 'remark'), $_GPC);
             $input['remark'] = htmlspecialchars_decode($input['remark']);
             if ($input['type'] == 'cash') {
                 $input['tag'] = serialize($_GPC['cash']);
             } else {
                 $input['tag'] = '';
             }
             $g = new Gift();
             $ret = $g->create($input);
             /**GIFT:3.编辑活动礼品分类**/
             if (is_error($ret)) {
                 message($ret['message']);
             } else {
                 message('成功保存礼品信息', $this->createWebUrl('redgifts'));
             }
         }
         $entity = array();
         $entity['type'] = 'cash';
         $entity['tag'] = array();
         load()->func('tpl');
         include $this->template('redgifts_form');
     }
     if ($foo == 'modify') {
         $id = $_GPC['id'];
         $g = new Gift();
         $entity = $g->getOne($id);
         /**GIFT:1.根据ID查询活动礼品分类**/
         if (empty($entity)) {
             message('访问错误');
         }
         if ($_W['ispost']) {
             $input = array_elements(array('title', 'type', 'remark'), $_GPC);
             $input['remark'] = htmlspecialchars_decode($input['remark']);
             if ($input['type'] == 'cash') {
                 $input['tag'] = serialize($_GPC['cash']);
             } else {
                 $input['tag'] = '';
             }
             $g = new Gift();
             $ret = $g->modify($id, $input);
             /**GIFT:4.根据ID编辑活动礼品分类**/
             if (is_error($ret)) {
                 message($ret['message']);
             } else {
                 message('成功保存礼品信息', $this->createWebUrl('redgifts'));
             }
         }
         load()->func('tpl');
         include $this->template('redgifts_form');
     }
     if ($foo == 'delete') {
         $id = $_GPC['id'];
         $g = new Gift();
         $g->remove($id);
         /**GIFT:5.根据ID删除活动礼品分类**/
         message('成功删除礼品信息', $this->createWebUrl('redgifts'));
     }
     if ($foo == 'list') {
         $a = new Gift();
         $ds = $a->getAll(array());
         /**GIFT:2.查询所有活动礼品分类**/
         include $this->template('redgifts_list');
     }
 }
예제 #2
0
    }
    if ($_W['ispost']) {
        $input = array_elements(array('title', 'type', 'remark'), $_GPC);
        $input['remark'] = htmlspecialchars_decode($input['remark']);
        if ($input['type'] == 'cash') {
            $input['tag'] = serialize($_GPC['cash']);
        } else {
            $input['tag'] = '';
        }
        $g = new Gift();
        $ret = $g->modify($id, $input);
        if (is_error($ret)) {
            message($ret['message']);
        } else {
            message('成功保存礼品信息', $this->createWebUrl('gifts'));
        }
    }
    load()->func('tpl');
    include $this->template('gifts-form');
}
if ($foo == 'delete') {
    $id = $_GPC['id'];
    $g = new Gift();
    $g->remove($id);
    message('成功删除礼品信息', $this->createWebUrl('gifts'));
}
if ($foo == 'list') {
    $a = new Gift();
    $ds = $a->getAll(array());
    include $this->template('gifts-list');
}