source: branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php @ 22575

Revision 22575, 6.3 KB checked in by pineray, 11 years ago (diff)

#2155 pageクラスからdtb_holidayテーブルを直接指定している箇所をなくす

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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-2013 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
26
27/**
28 * 定休日管理のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Basis_Holiday extends LC_Page_Admin_Ex
35{
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init()
46    {
47        parent::init();
48        $this->tpl_mainpage = 'basis/holiday.tpl';
49        $this->tpl_subno = 'holiday';
50        $this->tpl_maintitle = '基本情報管理';
51        $this->tpl_subtitle = '定休日管理';
52        $this->tpl_mainno = 'basis';
53    }
54
55    /**
56     * Page のプロセス.
57     *
58     * @return void
59     */
60    function process()
61    {
62        $this->action();
63        $this->sendResponse();
64    }
65
66    /**
67     * Page のアクション.
68     *
69     * @return void
70     */
71    function action()
72    {
73
74        $objHoliday = new SC_Helper_Holiday_Ex();
75
76        $objDate = new SC_Date_Ex();
77        $this->arrMonth = $objDate->getMonth();
78        $this->arrDay = $objDate->getDay();
79
80        $mode = $this->getMode();
81
82        $objFormParam = new SC_FormParam_Ex();
83        $this->lfInitParam($mode, $objFormParam);
84        $objFormParam->setParam($_POST);
85        $objFormParam->convParam();
86
87        $holiday_id = $objFormParam->getValue('holiday_id');
88
89        // 要求判定
90        switch ($mode) {
91            // 編集処理
92            case 'edit':
93                $this->arrErr = $this->lfCheckError($objFormParam, $objHoliday);
94                if (!SC_Utils_Ex::isBlank($this->arrErr['holiday_id'])) {
95                    trigger_error('', E_USER_ERROR);
96                    return;
97                }
98
99                if (count($this->arrErr) <= 0) {
100                    // POST値の引き継ぎ
101                    $arrParam = $objFormParam->getHashArray();
102                    // 登録実行
103                    $res_holiday_id = $this->doRegist($holiday_id, $arrParam, $objHoliday);
104                    if ($res_holiday_id !== FALSE) {
105                        // 完了メッセージ
106                        $holiday_id = $res_holiday_id;
107                        $this->tpl_onload = "alert('登録が完了しました。');";
108                    }
109                }
110                // POSTデータを引き継ぐ
111                $this->tpl_holiday_id = $holiday_id;
112
113                break;
114            // 削除
115            case 'delete':
116                $objHoliday->delete($holiday_id);
117                break;
118            // 編集前処理
119            case 'pre_edit':
120                // 編集項目を取得する。
121                $arrHolidayData = $objHoliday->get($holiday_id);
122                $objFormParam->setParam($arrHolidayData);
123
124                // POSTデータを引き継ぐ
125                $this->tpl_holiday_id = $holiday_id;
126                break;
127            case 'down':
128                $objHoliday->rankDown($holiday_id);
129
130                // 再表示
131                $this->objDisplay->reload();
132                break;
133            case 'up':
134                $objHoliday->rankUp($holiday_id);
135
136                // 再表示
137                $this->objDisplay->reload();
138                break;
139            default:
140                break;
141        }
142
143        $this->arrForm = $objFormParam->getFormParamList();
144
145        $this->arrHoliday = $objHoliday->getList();
146    }
147
148    /**
149     * デストラクタ.
150     *
151     * @return void
152     */
153    function destroy()
154    {
155        parent::destroy();
156    }
157
158    /**
159     * 登録処理を実行.
160     *
161     * @param integer $holiday_id
162     * @param array $sqlval
163     * @param object $objHoliday
164     * @return multiple
165     */
166    function doRegist($holiday_id, $sqlval, SC_Helper_Holiday_Ex $objHoliday)
167    {
168        $sqlval['holiday_id'] = $holiday_id;
169        $sqlval['creator_id'] = $_SESSION['member_id'];
170        return $objHoliday->save($sqlval);
171    }
172
173    function lfInitParam($mode, &$objFormParam)
174    {
175        switch ($mode) {
176            case 'edit':
177            case 'pre_edit':
178                $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
179                $objFormParam->addParam('月', 'month', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
180                $objFormParam->addParam('日', 'day', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
181                $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
182                break;
183            case 'delete':
184            case 'down':
185            case 'up':
186            default:
187                $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
188                break;
189        }
190    }
191
192    /**
193     * 入力エラーチェック
194     *
195     * @param object $objFormParam
196     * @param object $objHoliday
197     * @return array
198     */
199    function lfCheckError(&$objFormParam, SC_Helper_Holiday_Ex &$objHoliday)
200    {
201        $arrErr = $objFormParam->checkError();
202        $arrForm = $objFormParam->getHashArray();
203
204        // 編集中のレコード以外に同じ日付が存在する場合
205        if ($objHoliday->isDateExist($arrForm['month'], $arrForm['day'], $arrForm['holiday_id'])) {
206            $arrErr['date'] = '※ 既に同じ日付の登録が存在します。<br>';
207        }
208        return $arrErr;
209    }
210}
Note: See TracBrowser for help on using the repository browser.