source: branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_ClassCategory.php @ 15532

Revision 15532, 7.0 KB checked in by nanasess, 17 years ago (diff)

svn:mime-type 修正

  • 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 * 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_Products_ClassCategory extends LC_Page {
19
20    // }}}
21    // {{{ functions
22
23    /**
24     * Page を初期化する.
25     *
26     * @return void
27     */
28    function init() {
29        parent::init();
30        $this->tpl_mainpage = 'products/classcategory.tpl';
31        $this->tpl_subnavi = 'products/subnavi.tpl';
32        $this->tpl_subno = 'class';
33        $this->tpl_subtitle = '規格登録';
34        $this->tpl_mainno = 'products';
35    }
36
37    /**
38     * Page のプロセス.
39     *
40     * @return void
41     */
42    function process() {
43        $conn = new SC_DBConn();
44        $objView = new SC_AdminView();
45        $objQuery = new SC_Query();
46        $objDb = new SC_Helper_DB_Ex();
47
48        // 認証可否の判定
49        $objSess = new SC_Session();
50        SC_Utils_Ex::sfIsSuccess($objSess);
51
52        $get_check = false;
53
54        // 規格IDのチェック
55        if(SC_Utils_Ex::sfIsInt($_GET['class_id'])) {
56            // 規格名の取得
57            $this->tpl_class_name = $objQuery->get("dtb_class", "name", "class_id = ?", array($_GET['class_id']));
58            if($this->tpl_class_name != "") {
59                // 規格IDの引き継ぎ
60                $this->arrHidden['class_id'] = $_GET['class_id'];
61                $get_check = true;
62            }
63        }
64
65        if(!$get_check) {
66            // 規格登録ページに飛ばす。
67            $this->sendRedirect($this->getLocation(URL_CLASS_REGIST));
68            exit;
69        }
70
71        if (!isset($_POST['mode'])) $_POST['mode'] = "";
72
73        // 新規作成 or 編集
74        switch($_POST['mode']) {
75            // 登録ボタン押下
76        case 'edit':
77            // POST値の引き継ぎ
78            $this->arrForm = $_POST;
79            // 入力文字の変換
80            $_POST = $this->lfConvertParam($_POST);
81            // エラーチェック
82            $this->arrErr = $this->lfErrorCheck();
83            if(count($this->arrErr) <= 0) {
84                if($_POST['classcategory_id'] == "") {
85                    $this->lfInsertClass(); // DBへの書き込み
86                } else {
87                    $this->lfUpdateClass(); // DBへの書き込み
88                }
89                // 再表示
90                $this->reload($_GET['class_id']);
91                //sfReload("class_id=" . $_GET['class_id']);
92            } else {
93                // POSTデータを引き継ぐ
94                $this->tpl_classcategory_id = $_POST['classcategory_id'];
95            }
96            break;
97            // 削除
98        case 'delete':
99            // ランク付きレコードの削除
100            $where = "class_id = " . addslashes($_POST['class_id']);
101            $objDb->sfDeleteRankRecord("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where, true);
102            break;
103            // 編集前処理
104        case 'pre_edit':
105            // 編集項目をDBより取得する。
106            $where = "classcategory_id = ?";
107            $name = $objQuery->get("dtb_classcategory", "name", $where, array($_POST['classcategory_id']));
108            // 入力項目にカテゴリ名を入力する。
109            $this->arrForm['name'] = $name;
110            // POSTデータを引き継ぐ
111            $this->tpl_classcategory_id = $_POST['classcategory_id'];
112            break;
113        case 'down':
114            $where = "class_id = " . addslashes($_POST['class_id']);
115            $objDb->sfRankDown("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
116            break;
117        case 'up':
118            $where = "class_id = " . addslashes($_POST['class_id']);
119            $objDb->sfRankUp("dtb_classcategory", "classcategory_id", $_POST['classcategory_id'], $where);
120            break;
121        default:
122            break;
123        }
124
125        // 規格分類の読込
126        $where = "del_flg <> 1 AND class_id = ?";
127        $objQuery->setorder("rank DESC");
128        $this->arrClassCat = $objQuery->select("name, classcategory_id", "dtb_classcategory", $where, array($_GET['class_id']));
129
130        $objView->assignobj($this);
131        $objView->display(MAIN_FRAME);
132
133    }
134
135    /**
136     * デストラクタ.
137     *
138     * @return void
139     */
140    function destroy() {
141        parent::destroy();
142    }
143
144    /* DBへの挿入 */
145    function lfInsertClass() {
146        $objQuery = new SC_Query();
147        $objQuery->begin();
148        // 親規格IDの存在チェック
149        $where = "del_flg <> 1 AND class_id = ?";
150        $ret =  $objQuery->get("dtb_class", "class_id", $where, array($_POST['class_id']));
151        if($ret != "") {
152            // INSERTする値を作成する。
153            $sqlval['name'] = $_POST['name'];
154            $sqlval['class_id'] = $_POST['class_id'];
155            $sqlval['creator_id'] = $_SESSION['member_id'];
156            $sqlval['rank'] = $objQuery->max("dtb_classcategory", "rank", $where, array($_POST['class_id'])) + 1;
157            $sqlval['create_date'] = "now()";
158            $sqlval['update_date'] = "now()";
159            // INSERTの実行
160            $ret = $objQuery->insert("dtb_classcategory", $sqlval);
161        }
162        $objQuery->commit();
163        return $ret;
164    }
165
166    /* DBへの更新 */
167    function lfUpdateClass() {
168        $objQuery = new SC_Query();
169        // UPDATEする値を作成する。
170        $sqlval['name'] = $_POST['name'];
171        $sqlval['update_date'] = "Now()";
172        $where = "classcategory_id = ?";
173        // UPDATEの実行
174        $ret = $objQuery->update("dtb_classcategory", $sqlval, $where, array($_POST['classcategory_id']));
175        return $ret;
176    }
177
178    /* 取得文字列の変換 */
179    function lfConvertParam($array) {
180        // 文字変換
181        $arrConvList['name'] = "KVa";
182
183        foreach ($arrConvList as $key => $val) {
184            // POSTされてきた値のみ変換する。
185            if(isset($array[$key])) {
186                $array[$key] = mb_convert_kana($array[$key] ,$val);
187            }
188        }
189        return $array;
190    }
191
192    /* 入力エラーチェック */
193    function lfErrorCheck() {
194        $objErr = new SC_CheckError();
195        $objErr->doFunc(array("分類名", "name", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
196        if(!isset($objErr->arrErr['name'])) {
197            $objQuery = new SC_Query();
198            $where = "class_id = ? AND name = ?";
199            $arrRet = $objQuery->select("classcategory_id, name", "dtb_classcategory", $where, array($_GET['class_id'], $_POST['name']));
200            // 編集中のレコード以外に同じ名称が存在する場合
201            if ($arrRet[0]['classcategory_id'] != $_POST['classcategory_id'] && $arrRet[0]['name'] == $_POST['name']) {
202                $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
203            }
204        }
205        return $objErr->arrErr;
206    }
207}
208?>
Note: See TracBrowser for help on using the repository browser.