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

Revision 22926, 6.1 KB checked in by Seasoft, 11 years ago (diff)

#2287 (環境によりデストラクタが正しく動作しないケースがある)
#2288 (リクエスト単位で実行されるべきログ出力がブロックにも適用されている)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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