source: branches/feature-module-update/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php @ 15307

Revision 15307, 3.8 KB checked in by nanasess, 17 years ago (diff)

クラス化対応

  • Property svn:keywords set to Id Revision Date
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * ポイント設定 のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_Admin_Basis_Point extends LC_Page {
19
20    // {{{ properties
21
22    /** フォームパラメータの配列 */
23    var $objFormParam;
24
25    // }}}
26    // {{{ functions
27
28    /**
29     * Page を初期化する.
30     *
31     * @return void
32     */
33    function init() {
34        parent::init();
35        $this->tpl_mainpage = 'basis/point.tpl';
36        $this->tpl_subnavi = 'basis/subnavi.tpl';
37        $this->tpl_subno = 'point';
38        $this->tpl_mainno = 'basis';
39        $this->tpl_subtitle = 'ポイント設定';
40    }
41
42    /**
43     * Page のプロセス.
44     *
45     * @return void
46     */
47    function process() {
48        $conn = new SC_DBConn();
49        $objView = new SC_AdminView();
50        $objSess = new SC_Session();
51        $objQuery = new SC_Query();
52
53        // 認証可否の判定
54        SC_Utils_Ex::sfIsSuccess($objSess);
55
56        // パラメータ管理クラス
57        $this->objFormParam = new SC_FormParam();
58        // パラメータ情報の初期化
59        $this->lfInitParam();
60        // POST値の取得
61        $this->objFormParam->setParam($_POST);
62
63        $cnt = $objQuery->count("dtb_baseinfo");
64
65        if ($cnt > 0) {
66            $this->tpl_mode = "update";
67        } else {
68            $this->tpl_mode = "insert";
69        }
70
71        if(isset($_POST['mode']) && !empty($_POST['mode'])) {
72            // 入力値の変換
73            $this->objFormParam->convParam();
74            $this->arrErr = $this->objFormParam->checkError();
75
76            if(count($this->arrErr) == 0) {
77                switch($_POST['mode']) {
78                case 'update':
79                    $this->lfUpdateData(); // 既存編集
80                    break;
81                case 'insert':
82                    $this->lfInsertData(); // 新規作成
83                    break;
84                default:
85                    break;
86                }
87                // 再表示
88                //sfReload();
89                $this->tpl_onload = "window.alert('ポイント設定が完了しました。');";
90            }
91        } else {
92            $arrCol = $this->objFormParam->getKeyList(); // キー名一覧を取得
93            $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
94            $arrRet = $objQuery->select($col, "dtb_baseinfo");
95            // POST値の取得
96            $this->objFormParam->setParam($arrRet[0]);
97        }
98
99        $this->arrForm = $this->objFormParam->getFormParamList();
100        $objView->assignobj($this);
101        $objView->display(MAIN_FRAME);
102    }
103
104    /**
105     * デストラクタ.
106     *
107     * @return void
108     */
109    function destroy() {
110        parent::destroy();
111    }
112
113    /* パラメータ情報の初期化 */
114    function lfInitParam() {
115        $this->objFormParam->addParam("ポイント付与率", "point_rate", PERCENTAGE_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
116        $this->objFormParam->addParam("会員登録時付与ポイント", "welcome_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
117    }
118
119    function lfUpdateData() {
120        // 入力データを渡す。
121        $sqlval = $this->objFormParam->getHashArray();
122        $sqlval['update_date'] = 'Now()';
123        $objQuery = new SC_Query();
124        // UPDATEの実行
125        $ret = $objQuery->update("dtb_baseinfo", $sqlval);
126    }
127
128    function lfInsertData() {
129        // 入力データを渡す。
130        $sqlval = $this->objFormParam->getHashArray();
131        $sqlval['update_date'] = 'Now()';
132        $objQuery = new SC_Query();
133        // INSERTの実行
134        $ret = $objQuery->insert("dtb_baseinfo", $sqlval);
135    }
136}
137?>
Note: See TracBrowser for help on using the repository browser.