source: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php @ 18820

Revision 18820, 6.8 KB checked in by nanasess, 14 years ago (diff)

#781(規格のデータベースを木構造に)

  • 規格の無い商品が品切れになってしまう不具合修正
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_PATH . "pages/LC_Page.php");
26
27/**
28 * 会員規約設定 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Basis_Kiyaku extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'basis/kiyaku.tpl';
47        $this->tpl_subnavi = 'basis/subnavi.tpl';
48        $this->tpl_subno = 'kiyaku';
49        $this->tpl_subtitle = '会員規約登録';
50        $this->tpl_mainno = 'basis';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        $objView = new SC_AdminView();
60        $objSess = new SC_Session();
61        $objQuery = new SC_Query();
62        $objDb = new SC_Helper_DB_Ex();
63
64        // 認証可否の判定
65        SC_Utils_Ex::sfIsSuccess($objSess);
66
67        if (!isset($_POST['mode'])) $_POST['mode'] = "";
68
69        // 要求判定
70        switch($_POST['mode']) {
71        // 編集処理
72        case 'edit':
73            // POST値の引き継ぎ
74            $this->arrForm = $_POST;
75            // 入力文字の変換
76            $this->arrForm = $this->lfConvertParam($this->arrForm);
77
78            // エラーチェック
79            $this->arrErr = $this->lfErrorCheck();
80            if(count($this->arrErr) <= 0) {
81                if($_POST['kiyaku_id'] == "") {
82                    $this->lfInsertClass($this->arrForm);   // 新規作成
83                } else {
84                    $this->lfUpdateClass($this->arrForm);   // 既存編集
85                }
86                // 再表示
87                $this->reload();
88            } else {
89                // POSTデータを引き継ぐ
90                $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
91            }
92            break;
93        // 削除
94        case 'delete':
95            $objDb->sfDeleteRankRecord("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id'], "", true);
96            // 再表示
97            $this->reload();
98            break;
99        // 編集前処理
100        case 'pre_edit':
101            // 編集項目をDBより取得する。
102            $where = "kiyaku_id = ?";
103            $arrRet = $objQuery->select("kiyaku_text, kiyaku_title", "dtb_kiyaku", $where, array($_POST['kiyaku_id']));
104            // 入力項目にカテゴリ名を入力する。
105            $this->arrForm['kiyaku_title'] = $arrRet[0]['kiyaku_title'];
106            $this->arrForm['kiyaku_text'] = $arrRet[0]['kiyaku_text'];
107            // POSTデータを引き継ぐ
108            $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
109        break;
110        case 'down':
111            $objDb->sfRankDown("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id']);
112            // 再表示
113            $this->reload();
114            break;
115        case 'up':
116            $objDb->sfRankUp("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id']);
117            // 再表示
118            $this->reload();
119            break;
120        default:
121            break;
122        }
123
124        // 規格の読込
125        $where = "del_flg <> 1";
126        $objQuery->setOrder("rank DESC");
127        $this->arrKiyaku = $objQuery->select("kiyaku_title, kiyaku_text, kiyaku_id", "dtb_kiyaku", $where);
128
129        $objView->assignobj($this);
130        $objView->display(MAIN_FRAME);
131    }
132
133    /**
134     * デストラクタ.
135     *
136     * @return void
137     */
138    function destroy() {
139        parent::destroy();
140    }
141
142    /* DBへの挿入 */
143    function lfInsertClass($arrData) {
144        $objQuery = new SC_Query();
145        // INSERTする値を作成する。
146        $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
147        $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
148        $sqlval['creator_id'] = $_SESSION['member_id'];
149        $sqlval['rank'] = $objQuery->max("dtb_kiyaku", "rank") + 1;
150        $sqlval['update_date'] = "Now()";
151        $sqlval['create_date'] = "Now()";
152        // INSERTの実行
153        $sqlval['kiyaku_id'] = $objQuery->nextVal('dtb_kiyaku_kiyaku_id');
154        $ret = $objQuery->insert("dtb_kiyaku", $sqlval);
155        return $ret;
156    }
157
158    /* DBへの更新 */
159    function lfUpdateClass($arrData) {
160        $objQuery = new SC_Query();
161        // UPDATEする値を作成する。
162        $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
163        $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
164        $sqlval['update_date'] = "Now()";
165        $where = "kiyaku_id = ?";
166        // UPDATEの実行
167        $ret = $objQuery->update("dtb_kiyaku", $sqlval, $where, array($_POST['kiyaku_id']));
168        return $ret;
169    }
170
171    /* 取得文字列の変換 */
172    function lfConvertParam($array) {
173        // 文字変換
174        $arrConvList['kiyaku_title'] = "KVa";
175        $arrConvList['kiyaku_text'] = "KVa";
176
177        foreach ($arrConvList as $key => $val) {
178            // POSTされてきた値のみ変換する。
179            if(isset($array[$key])) {
180                $array[$key] = mb_convert_kana($array[$key] ,$val);
181            }
182        }
183        return $array;
184    }
185
186    /* 入力エラーチェック */
187    function lfErrorCheck() {
188        $objErr = new SC_CheckError();
189        $objErr->doFunc(array("規約タイトル", "kiyaku_title", SMTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
190        $objErr->doFunc(array("規約内容", "kiyaku_text", MLTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
191        if(!isset($objErr->arrErr['name'])) {
192            $objQuery = new SC_Query();
193            $arrRet = $objQuery->select("kiyaku_id, kiyaku_title", "dtb_kiyaku", "del_flg = 0 AND kiyaku_title = ?", array($_POST['kiyaku_title']));
194            // 編集中のレコード以外に同じ名称が存在する場合
195            if ($arrRet[0]['kiyaku_id'] != $_POST['kiyaku_id'] && $arrRet[0]['kiyaku_title'] == $_POST['kiyaku_title']) {
196                $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
197            }
198        }
199        return $objErr->arrErr;
200    }
201}
202?>
Note: See TracBrowser for help on using the repository browser.