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

Revision 22856, 8.8 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
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: LC_Page_Admin_Basis_Tax_Ex.php 22567 2013-03-09 12:18:54Z yomoro $
32 */
33class LC_Page_Admin_Basis_Tax extends LC_Page_Admin_Ex
34{
35    /** エラー情報 */
36    var $arrErr;
37
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init()
45    {
46        parent::init();
47        $this->tpl_mainpage = 'basis/tax.tpl';
48        $this->tpl_subno = 'tax';
49        $this->tpl_mainno = 'basis';
50        $this->tpl_maintitle = '基本情報管理';
51        $this->tpl_subtitle = '税金管理';
52        $masterData = new SC_DB_MasterData_Ex();
53        $this->arrPref = $masterData->getMasterData('mtb_pref');
54        $this->arrTAXCALCRULE = $masterData->getMasterData('mtb_taxrule');
55
56        //適用時刻の項目値設定
57        $this->objDate = new SC_Date();
58        //適用時間の年を、「現在年~現在年+2」の範囲に設定
59        for ($year=date("Y"); $year<=date("Y") + 2;$year++){
60            $arrYear[$year] = $year;
61        }
62        $this->arrYear = $arrYear;
63
64        for ($minutes=0; $minutes< 60; $minutes++){
65            $arrMinutes[$minutes] = $minutes;
66        }
67        $this->arrMinutes = $arrMinutes;
68
69    }
70
71    /**
72     * Page のプロセス.
73     *
74     * @return void
75     */
76    function process()
77    {
78        $this->action();
79        $this->sendResponse();
80    }
81
82    /**
83     * Page のアクション.
84     *
85     * @return void
86     */
87    function action()
88    {
89        $objTaxRule = new SC_Helper_TaxRule_Ex();
90        $objFormParam = new SC_FormParam_Ex();
91
92        // パラメーター情報の初期化
93        $this->lfInitParam($objFormParam);
94
95        // POST値をセット
96        $objFormParam->setParam($_POST);
97
98        // POST値の入力文字変換
99        $objFormParam->convParam();
100
101        //tax_rule_idを変数にセット
102        $tax_rule_id = $objFormParam->getValue('tax_rule_id');
103
104        // モードによる処理切り替え
105        switch ($this->getMode()) {
106            // 編集処理
107            case 'edit':
108                // エラーチェック
109                $this->arrErr = $this->lfCheckError($objFormParam, $objTaxRule);
110
111                if (count($this->arrErr) <= 0) {
112                    // POST値の引き継ぎ
113                    $arrParam = $objFormParam->getHashArray();
114                    // 登録実行
115                    $res_tax_rule_id = $this->doRegist($tax_rule_id, $arrParam, $objTaxRule);
116                    if ($res_tax_rule_id !== FALSE) {
117                        // 完了メッセージ
118                        $this->tpl_onload = "alert('登録が完了しました。');";
119                        // リロード
120                        SC_Response_Ex::reload();
121                    }
122                }
123
124                break;
125
126            // 編集前処理
127            case 'pre_edit':
128                $TaxRule = $objTaxRule->getTaxRuleData($tax_rule_id);
129
130                $tmp = explode(" ", $TaxRule['apply_date']);
131                $tmp_ymd = explode("-", $tmp[0]);
132                $TaxRule['apply_date_year'] = $tmp_ymd[0];
133                $TaxRule['apply_date_month'] = $tmp_ymd[1];
134                $TaxRule['apply_date_day'] = $tmp_ymd[2];
135                $tmp_hm = explode(":", $tmp[1]);
136                $TaxRule['apply_date_hour'] = $tmp_hm[0];
137                $TaxRule['apply_date_minutes'] = $tmp_hm[1];
138
139                $objFormParam->setParam($TaxRule);
140
141                // POSTデータを引き継ぐ
142                $this->tpl_tax_rule_id = $tax_rule_id;
143                break;
144
145            // 削除
146            case 'delete':
147                $objTaxRule->deleteTaxRuleData($tax_rule_id);
148
149                // リロード
150                SC_Response_Ex::reload();
151                break;
152
153            default:
154                break;
155        }
156
157        $this->arrForm = $objFormParam->getFormParamList();
158
159        // 税規約情報読み込み
160        $this->arrTaxrule = $objTaxRule->getTaxRuleList();
161
162    }
163
164    /**
165     * デストラクタ.
166     *
167     * @return void
168     */
169    function destroy()
170    {
171        parent::destroy();
172    }
173
174    /**
175     * パラメーター情報の初期化を行う.
176     *
177     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
178     * @return void
179     */
180    function lfInitParam(&$objFormParam)
181    {
182        $objFormParam->addParam('税規約ID', 'tax_rule_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
183        $objFormParam->addParam('消費税率', 'tax_rate', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
184        $objFormParam->addParam('課税規則', 'calc_rule', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
185        // 適用日時
186        $objFormParam->addParam('適用年', 'apply_date_year', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
187        $objFormParam->addParam('適用月', 'apply_date_month', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
188        $objFormParam->addParam('適用日', 'apply_date_day', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
189        $objFormParam->addParam('適用時', 'apply_date_hour', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
190        $objFormParam->addParam('適用分', 'apply_date_minutes', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
191        $objFormParam->addParam('適用日時', 'apply_date_year', 'apply_date_month', 'apply_date_day', INT_LEN, 'n', array("CHECK_DATE"));
192
193    }
194
195    /**
196     * 登録処理を実行.
197     *
198     * @param integer $tax_rule_id
199     * @param array $sqlval
200     * @param object $objTaxRule
201     * @return multiple
202     */
203    function doRegist($tax_rule_id, $arrParam, SC_Helper_TaxRule_Ex $objTaxRule)
204    {
205        $apply_date = SC_Utils_Ex::sfGetTimestampistime($arrParam['apply_date_year'], sprintf("%02d",$arrParam['apply_date_month']), sprintf("%02d",$arrParam['apply_date_day']),sprintf("%02d",$arrParam['apply_date_hour']), sprintf("%02d",$arrParam['apply_date_minutes']));
206
207        $calc_rule = $arrParam['calc_rule'];
208        $tax_rate = $arrParam['tax_rate'];
209
210        return $objTaxRule->setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_id);
211    }
212
213    /**
214     * 入力エラーチェック.
215     *
216     * @return array $objErr->arrErr エラー内容
217     */
218    function lfCheckError(&$objFormParam, SC_Helper_TaxRule_Ex &$objTaxRule)
219    {
220        $arrErr = $objFormParam->checkError();
221        $arrForm = $objFormParam->getHashArray();
222
223        // tax_rule_id の正当性チェック
224        if (!empty($arrForm['tax_rule_id'])) {
225            if (!SC_Utils_Ex::sfIsInt($arrForm['tax_rule_id'])
226                || !$objTaxRule->getTaxRuleData($arrForm['tax_rule_id'])
227            ) {
228                // tax_rule_idが指定されていて、且つその値が不正と思われる場合はエラー
229                $arrErr['tax_rule_id'] = '※ 税規約IDが不正です<br />';
230            }
231        }
232
233        if ($arrForm['tax_rule_id'] != '0') {
234        $apply_date = SC_Utils_Ex::sfGetTimestampistime($arrForm['apply_date_year'], sprintf("%02d",$arrForm['apply_date_month']), sprintf("%02d",$arrForm['apply_date_day']),sprintf("%02d",$arrForm['apply_date_hour']), sprintf("%02d",$arrForm['apply_date_minutes']));
235
236        // 税規約情報読み込み
237        $arrTaxRuleByTime = $objTaxRule->getTaxRuleByTime($apply_date);
238        // 編集中のレコード以外に同じ消費税率、課税規則が存在する場合
239            if (
240                !SC_Utils_Ex::isBlank($arrTaxRuleByTime)
241                && $arrTaxRuleByTime['tax_rule_id'] != $arrForm['tax_rule_id']
242                && $arrTaxRuleByTime['apply_date'] == $apply_date
243            ) {
244                $arrErr['apply_date'] = '※ 既に同じ適用日時で登録が存在します。<br />';
245            }
246        }
247
248        return $arrErr;
249    }
250}
Note: See TracBrowser for help on using the repository browser.