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

Revision 23605, 6.6 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
  • 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-2014 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    public 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    public function process()
56    {
57        $this->action();
58        $this->sendResponse();
59    }
60
61    /**
62     * Page のアクション.
63     *
64     * @return void
65     */
66    public 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
91                    return;
92                }
93
94                if (count($this->arrErr) <= 0) {
95                    // POST値の引き継ぎ
96                    $arrParam = $objFormParam->getHashArray();
97                    // 登録実行
98                    $res_holiday_id = $this->doRegist($holiday_id, $arrParam, $objHoliday);
99                    if ($res_holiday_id !== FALSE) {
100                        // 完了メッセージ
101                        $holiday_id = $res_holiday_id;
102                        $this->tpl_onload = "alert('登録が完了しました。');";
103                    }
104                }
105                // POSTデータを引き継ぐ
106                $this->tpl_holiday_id = $holiday_id;
107
108                break;
109            // 削除
110            case 'delete':
111                $objHoliday->delete($holiday_id);
112                break;
113            // 編集前処理
114            case 'pre_edit':
115                // 編集項目を取得する。
116                $arrHolidayData = $objHoliday->get($holiday_id);
117                $objFormParam->setParam($arrHolidayData);
118
119                // POSTデータを引き継ぐ
120                $this->tpl_holiday_id = $holiday_id;
121                break;
122            case 'down':
123                $objHoliday->rankDown($holiday_id);
124
125                // 再表示
126                $this->objDisplay->reload();
127                break;
128            case 'up':
129                $objHoliday->rankUp($holiday_id);
130
131                // 再表示
132                $this->objDisplay->reload();
133                break;
134            default:
135                break;
136        }
137
138        $this->arrForm = $objFormParam->getFormParamList();
139
140        $this->arrHoliday = $objHoliday->getList();
141    }
142
143    /**
144     * 登録処理を実行.
145     *
146     * @param  integer  $holiday_id
147     * @param  array    $sqlval
148     * @param  SC_Helper_Holiday_Ex   $objHoliday
149     * @return multiple
150     */
151    public function doRegist($holiday_id, $sqlval, SC_Helper_Holiday_Ex $objHoliday)
152    {
153        $sqlval['holiday_id'] = $holiday_id;
154        $sqlval['creator_id'] = $_SESSION['member_id'];
155
156        return $objHoliday->save($sqlval);
157    }
158
159    /**
160     * @param string|null $mode
161     * @param SC_FormParam_Ex $objFormParam
162     */
163    public function lfInitParam($mode, &$objFormParam)
164    {
165        switch ($mode) {
166            case 'edit':
167            case 'pre_edit':
168                $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
169                $objFormParam->addParam('月', 'month', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
170                $objFormParam->addParam('日', 'day', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
171                $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
172                break;
173            case 'delete':
174            case 'down':
175            case 'up':
176            default:
177                $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
178                break;
179        }
180    }
181
182    /**
183     * 入力エラーチェック
184     *
185     * @param  object $objFormParam
186     * @param  SC_Helper_Holiday_Ex $objHoliday
187     * @return array
188     */
189    public function lfCheckError(&$objFormParam, SC_Helper_Holiday_Ex &$objHoliday)
190    {
191        $arrErr = $objFormParam->checkError();
192        $arrForm = $objFormParam->getHashArray();
193
194        // 日付の妥当性チェック
195        // 閏年への対応.
196        if ($arrForm['month'] == 2 && $arrForm['day'] == 29) {
197            $valid_date = true;
198        } else {
199            $valid_date = checkdate($arrForm['month'], $arrForm['day'], date('Y'));
200        }
201        if (!$valid_date) {
202            $arrErr['date'] = '※ 妥当な日付ではありません。<br />';
203        }
204
205        // 編集中のレコード以外に同じ日付が存在する場合
206        if ($objHoliday->isDateExist($arrForm['month'], $arrForm['day'], $arrForm['holiday_id'])) {
207            $arrErr['date'] = '※ 既に同じ日付の登録が存在します。<br />';
208        }
209
210        return $arrErr;
211    }
212}
Note: See TracBrowser for help on using the repository browser.