source: branches/comu-ver2/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php @ 17444

Revision 17444, 31.2 KB checked in by Seasoft, 13 years ago (diff)

数量表記の統一。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.php");
26
27/* ペイジェント決済モジュール連携用 */
28if (file_exists(MODULE_PATH . 'mdl_paygent/include.php') === TRUE) {
29  require_once(MODULE_PATH . 'mdl_paygent/include.php');
30}
31
32/**
33 * 受注修正 のページクラス.
34 *
35 * @package Page
36 * @author LOCKON CO.,LTD.
37 * @version $Id$
38 */
39class LC_Page_Admin_Order_Edit extends LC_Page {
40
41    // {{{ properties
42
43    /** 表示モード */
44    var $disp_mode;
45
46    // }}}
47    // {{{ functions
48
49    /**
50     * Page を初期化する.
51     *
52     * @return void
53     */
54    function init() {
55        parent::init();
56        $this->tpl_mainpage = 'order/edit.tpl';
57        $this->tpl_subnavi = 'order/subnavi.tpl';
58        $this->tpl_mainno = 'order';
59        $this->tpl_subno = 'index';
60        $this->tpl_subtitle = '受注管理';
61        if (empty($_GET['order_id']) && empty($_POST['order_id'])) {
62            $this->tpl_subno = 'add';
63            $this->tpl_mode = 'add';
64            $this->tpl_subtitle = '新規受注入力';
65        }
66
67        $masterData = new SC_DB_MasterData_Ex();
68        $this->arrPref = $masterData->getMasterData("mtb_pref",
69                                 array("pref_id", "pref_name", "rank"));
70        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
71       
72        /* ペイジェント決済モジュール連携用 */
73        if(function_exists("sfPaygentOrderPage")) {
74            $this->arrFormKind = sfPaygentOrderPage();
75        }
76    }
77
78    /**
79     * Page のプロセス.
80     *
81     * @return void
82     */
83    function process() {
84        $conn = new SC_DBConn();
85        $objView = new SC_AdminView();
86        $objSess = new SC_Session();
87        $objSiteInfo = new SC_SiteInfo();
88        $objDb = new SC_Helper_DB_Ex();
89        $arrInfo = $objSiteInfo->data;
90
91        // パラメータ管理クラス
92        $this->objFormParam = new SC_FormParam();
93        // パラメータ情報の初期化
94        $this->lfInitParam();
95
96        // 認証可否の判定
97        SC_Utils_Ex::sfIsSuccess($objSess);
98
99        // 検索パラメータの引き継ぎ
100        foreach ($_POST as $key => $val) {
101            if (ereg("^search_", $key)) {
102                $this->arrSearchHidden[$key] = $val;
103            }
104        }
105
106        // 表示モード判定
107        if(isset($_GET['order_id']) &&
108            SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
109            $this->disp_mode = true;
110            $order_id = $_GET['order_id'];
111        } else {
112            $order_id = $_POST['order_id'];
113        }
114        $this->tpl_order_id = $order_id;
115
116        // DBから受注情報を読み込む
117        $this->lfGetOrderData($order_id);
118
119        switch($_POST['mode']) {
120        case 'pre_edit':
121        case 'order_id':
122            break;
123        case 'edit':
124        case 'add':
125            // POST情報で上書き
126            $this->objFormParam->setParam($_POST);
127
128            // 入力値の変換
129            $this->objFormParam->convParam();
130            $this->arrErr = $this->lfCheek($arrInfo);
131            $this->arrErr = $this->lfCheckError();
132            if(count($this->arrErr) == 0) {
133                #if(count($this->arrErr) == 0) {
134                    if ($_POST['mode'] == 'add') {
135                        $this->lfRegistNewData();
136                        $text = "'新規受注を登録しました。'";
137                    } else {
138                        $this->lfRegistData($_POST['order_id']);
139                        $text = "'受注履歴を編集しました。'";
140                    }
141                    // DBから受注情報を再読込
142                    $this->lfGetOrderData($order_id);
143                    $this->tpl_onload = "window.alert(".$text.");";
144                #}
145            }
146            break;
147            // 再計算
148        case 'cheek':
149            // POST情報で上書き
150            $this->objFormParam->setParam($_POST);
151            // 入力値の変換
152            $this->objFormParam->convParam();
153            $this->arrErr = $this->lfCheckError();
154            #if(count($this->arrErr) == 0) {
155                $this->arrErr = $this->lfCheek($arrInfo);
156            #}
157            break;
158        /* ペイジェント決済モジュール連携用 */
159        case 'paygent_order':
160            $this->paygent_return = sfPaygentOrder($_POST['paygent_type'], $order_id);
161            break;
162        // 商品削除
163        case 'delete_product':
164            $delete_no = $_POST['delete_no'];
165            foreach ($_POST AS $key=>$val) {
166                if (is_array($val)) {
167                    foreach ($val AS $k=>$v) {
168                        if ($k != $delete_no) {
169                            $arrData[$key][] = $v;
170                        }
171                    }
172                } else {
173                    $arrData[$key] = $val;
174                }
175            }
176            $this->lfReCheek($arrData, $arrInfo);
177            break;
178        // 商品追加ポップアップより商品選択後、商品情報取得
179        case 'select_product_detail':
180            // POST情報で上書き
181            $this->objFormParam->setParam($_POST);
182            if (!empty($_POST['add_product_id'])) {
183                $this->lfInsertProduct($_POST['add_product_id'], $_POST['add_classcategory_id1'], $_POST['add_classcategory_id2']);
184
185            } elseif (!empty($_POST['edit_product_id'])) {
186                $this->lfUpdateProduct($_POST['edit_product_id'], $_POST['edit_classcategory_id1'], $_POST['edit_classcategory_id2'], $_POST['no']);
187            }
188
189            $arrData = $_POST;
190            foreach ($this->arrForm AS $key=>$val) {
191                if (is_array($val)) {
192                    $arrData[$key] = $this->arrForm[$key]['value'];
193                } else {
194                    $arrData[$key] = $val;
195                }
196            }
197            $this->lfReCheek($arrData, $arrInfo);
198            break;
199        default:
200            break;
201        }
202
203        // 支払い方法の取得
204        $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method");
205        // 配送時間の取得
206        $arrRet = $objDb->sfGetDelivTime($this->objFormParam->getValue('payment_id'));
207        $this->arrDelivTime = SC_Utils_Ex::sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
208
209        $this->arrForm = $this->objFormParam->getFormParamList();
210        $this->product_count = count($this->arrForm['quantity']['value']);
211
212        // アンカーを設定
213        if (isset($_POST['anchor_key']) && !empty($_POST['anchor_key'])) {
214            $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'";
215        } else {
216            $anchor_hash = "";
217        }
218        $this->tpl_onload .= $anchor_hash;
219
220        $this->arrInfo = $arrInfo;
221
222        $objView->assignobj($this);
223        // 表示モード判定
224        if(!$this->disp_mode) {
225            $objView->display(MAIN_FRAME);
226        } else {
227            $objView->display('order/disp.tpl');
228        }
229    }
230
231
232    /**
233     * デストラクタ.
234     *
235     * @return void
236     */
237    function destroy() {
238        parent::destroy();
239    }
240
241    /* パラメータ情報の初期化 */
242    function lfInitParam() {
243        if ($_POST['mode'] == 'edit') {
244            $this->lfInitParamEdit();
245        } else {
246            $this->lfInitParamAdd();
247        }
248
249        // 受注商品情報
250        $this->objFormParam->addParam("値引き", "discount", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
251        $this->objFormParam->addParam("送料", "deliv_fee", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
252        $this->objFormParam->addParam("手数料", "charge", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
253        $this->objFormParam->addParam("利用ポイント", "use_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
254        $this->objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
255        $this->objFormParam->addParam("配送時間ID", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
256        $this->objFormParam->addParam("対応状況", "status", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
257        $this->objFormParam->addParam("配達日", "deliv_date", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
258        $this->objFormParam->addParam("お支払方法名称", "payment_method");
259        $this->objFormParam->addParam("配送時間", "deliv_time");
260
261        // 受注詳細情報
262        $this->objFormParam->addParam("単価", "price", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
263        $this->objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
264        $this->objFormParam->addParam("商品ID", "product_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0');
265        $this->objFormParam->addParam("ポイント付与率", "point_rate");
266        $this->objFormParam->addParam("商品コード", "product_code");
267        $this->objFormParam->addParam("商品名", "product_name");
268        $this->objFormParam->addParam("規格1", "classcategory_id1");
269        $this->objFormParam->addParam("規格2", "classcategory_id2");
270        $this->objFormParam->addParam("規格名1", "classcategory_name1");
271        $this->objFormParam->addParam("規格名2", "classcategory_name2");
272        $this->objFormParam->addParam("メモ", "note", MTEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
273        // DB読込用
274        $this->objFormParam->addParam("小計", "subtotal");
275        $this->objFormParam->addParam("合計", "total");
276        $this->objFormParam->addParam("支払い合計", "payment_total");
277        $this->objFormParam->addParam("加算ポイント", "add_point");
278        $this->objFormParam->addParam("お誕生日ポイント", "birth_point");
279        $this->objFormParam->addParam("消費税合計", "tax");
280        $this->objFormParam->addParam("最終保持ポイント", "total_point");
281        $this->objFormParam->addParam("顧客ID", "customer_id");
282        $this->objFormParam->addParam("現在のポイント", "point");
283        $this->objFormParam->addParam("受注番号", "order_id");
284        $this->objFormParam->addParam("受注日", "create_date");
285    }
286
287    /* パラメータ情報の初期化(編集時) */
288    function lfInitParamEdit() {
289        // お客様情報
290        $this->objFormParam->addParam("顧客名1", "order_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
291        $this->objFormParam->addParam("顧客名2", "order_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
292        $this->objFormParam->addParam("顧客名カナ1", "order_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
293        $this->objFormParam->addParam("顧客名カナ2", "order_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
294        $this->objFormParam->addParam("メールアドレス", "order_email", MTEXT_LEN, "KVCa", array("EXIST_CHECK", "NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
295        $this->objFormParam->addParam("郵便番号1", "order_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
296        $this->objFormParam->addParam("郵便番号2", "order_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
297        $this->objFormParam->addParam("都道府県", "order_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
298        $this->objFormParam->addParam("住所1", "order_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
299        $this->objFormParam->addParam("住所2", "order_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
300        $this->objFormParam->addParam("電話番号1", "order_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
301        $this->objFormParam->addParam("電話番号2", "order_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
302        $this->objFormParam->addParam("電話番号3", "order_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
303
304        // 配送先情報
305        $this->objFormParam->addParam("お名前1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
306        $this->objFormParam->addParam("お名前2", "deliv_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
307        $this->objFormParam->addParam("フリガナ1", "deliv_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
308        $this->objFormParam->addParam("フリガナ2", "deliv_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
309        $this->objFormParam->addParam("郵便番号1", "deliv_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
310        $this->objFormParam->addParam("郵便番号2", "deliv_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK"));
311        $this->objFormParam->addParam("都道府県", "deliv_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
312        $this->objFormParam->addParam("住所1", "deliv_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
313        $this->objFormParam->addParam("住所2", "deliv_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
314        $this->objFormParam->addParam("電話番号1", "deliv_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
315        $this->objFormParam->addParam("電話番号2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
316        $this->objFormParam->addParam("電話番号3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK"));
317
318    }
319
320    /* パラメータ情報の初期化(追加時) */
321    function lfInitParamAdd() {
322        // お客様情報
323        $this->objFormParam->addParam("顧客名1", "order_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
324        $this->objFormParam->addParam("顧客名2", "order_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
325        $this->objFormParam->addParam("顧客名カナ1", "order_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
326        $this->objFormParam->addParam("顧客名カナ2", "order_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
327        $this->objFormParam->addParam("メールアドレス", "order_email", MTEXT_LEN, "KVCa", array("NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
328        $this->objFormParam->addParam("郵便番号1", "order_zip01", ZIP01_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK"));
329        $this->objFormParam->addParam("郵便番号2", "order_zip02", ZIP02_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK"));
330        $this->objFormParam->addParam("都道府県", "order_pref", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
331        $this->objFormParam->addParam("住所1", "order_addr01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
332        $this->objFormParam->addParam("住所2", "order_addr02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
333        $this->objFormParam->addParam("電話番号1", "order_tel01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
334        $this->objFormParam->addParam("電話番号2", "order_tel02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
335        $this->objFormParam->addParam("電話番号3", "order_tel03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
336
337        // 配送先情報
338        $this->objFormParam->addParam("お名前1", "deliv_name01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
339        $this->objFormParam->addParam("お名前2", "deliv_name02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
340        $this->objFormParam->addParam("フリガナ1", "deliv_kana01", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
341        $this->objFormParam->addParam("フリガナ2", "deliv_kana02", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
342        $this->objFormParam->addParam("郵便番号1", "deliv_zip01", ZIP01_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK"));
343        $this->objFormParam->addParam("郵便番号2", "deliv_zip02", ZIP02_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK"));
344        $this->objFormParam->addParam("都道府県", "deliv_pref", INT_LEN, "n", array( "MAX_LENGTH_CHECK", "NUM_CHECK"));
345        $this->objFormParam->addParam("住所1", "deliv_addr01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
346        $this->objFormParam->addParam("住所2", "deliv_addr02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
347        $this->objFormParam->addParam("電話番号1", "deliv_tel01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
348        $this->objFormParam->addParam("電話番号2", "deliv_tel02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
349        $this->objFormParam->addParam("電話番号3", "deliv_tel03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
350
351    }
352
353
354
355    function lfGetOrderData($order_id) {
356        if(SC_Utils_Ex::sfIsInt($order_id)) {
357            // DBから受注情報を読み込む
358            $objQuery = new SC_Query();
359            $objDb = new SC_Helper_DB_Ex();
360            $where = "order_id = ?";
361            $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
362            $this->objFormParam->setParam($arrRet[0]);
363            list($point, $total_point) = $objDb->sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
364            $this->objFormParam->setValue('total_point', $total_point);
365            $this->objFormParam->setValue('point', $point);
366            $this->arrForm = $arrRet[0];
367            // 受注詳細データの取得
368            $arrRet = $this->lfGetOrderDetail($order_id);
369            $arrRet = SC_Utils_Ex::sfSwapArray($arrRet);
370            $this->arrForm = array_merge($this->arrForm, $arrRet);
371            $this->objFormParam->setParam($arrRet);
372
373            // その他支払い情報を表示
374            if($this->arrForm["memo02"] != "") $this->arrForm["payment_info"] = unserialize($this->arrForm["memo02"]);
375            if($this->arrForm["memo01"] == PAYMENT_CREDIT_ID){
376                $this->arrForm["payment_type"] = "クレジット決済";
377            }elseif($this->arrForm["memo01"] == PAYMENT_CONVENIENCE_ID){
378                $this->arrForm["payment_type"] = "コンビニ決済";
379            }else{
380                $this->arrForm["payment_type"] = "お支払い";
381            }
382        }
383    }
384
385    // 受注詳細データの取得
386    function lfGetOrderDetail($order_id) {
387        $objQuery = new SC_Query();
388        $col = "product_id, classcategory_id1, classcategory_id2, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate";
389        $where = "order_id = ?";
390        $objQuery->setorder("classcategory_id1, classcategory_id2");
391        $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id));
392        return $arrRet;
393    }
394
395    /* 入力内容のチェック */
396    function lfCheckError() {
397        // 入力データを渡す。
398        $arrRet =  $this->objFormParam->getHashArray();
399        $objErr = new SC_CheckError($arrRet);
400        $objErr->arrErr = $this->objFormParam->checkError();
401
402        return $objErr->arrErr;
403    }
404
405    /* 計算処理 */
406    function lfCheek($arrInfo) {
407        $objDb = new SC_Helper_DB_Ex();
408        $arrVal = $this->objFormParam->getHashArray();
409        $arrErr = array();
410
411        // 商品の種類数
412        $max = count($arrVal['quantity']);
413        $subtotal = 0;
414        $totalpoint = 0;
415        $totaltax = 0;
416        for($i = 0; $i < $max; $i++) {
417            // 小計の計算
418            $subtotal += SC_Utils_Ex::sfPreTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i];
419            // 小計の計算
420            $totaltax += SC_Utils_Ex::sfTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i];
421            // 加算ポイントの計算
422            $totalpoint += SC_Utils_Ex::sfPrePoint($arrVal['price'][$i], $arrVal['point_rate'][$i]) * $arrVal['quantity'][$i];
423        }
424
425        // 消費税
426        $arrVal['tax'] = $totaltax;
427        // 小計
428        $arrVal['subtotal'] = $subtotal;
429        // 合計
430        $arrVal['total'] = $subtotal - $arrVal['discount'] + $arrVal['deliv_fee'] + $arrVal['charge'];
431        // お支払い合計
432        $arrVal['payment_total'] = $arrVal['total'] - ($arrVal['use_point'] * POINT_VALUE);
433
434        // 加算ポイント
435        $arrVal['add_point'] = SC_Utils_Ex::sfGetAddPoint($totalpoint, $arrVal['use_point'], $arrInfo);
436
437        list($arrVal['point'], $arrVal['total_point']) = $objDb->sfGetCustomerPoint($_POST['order_id'], $arrVal['use_point'], $arrVal['add_point']);
438
439        if($arrVal['total'] < 0) {
440            $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />';
441        }
442
443        if($arrVal['payment_total'] < 0) {
444            $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />';
445        }
446
447        if($arrVal['total_point'] < 0) {
448            $arrErr['total_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />';
449        }
450
451        $this->objFormParam->setParam($arrVal);
452        return $arrErr;
453    }
454
455    function lfReCheek($arrData, $arrInfo) {
456        // 情報上書き
457        $this->objFormParam->setParam($arrData);
458        // 入力値の変換
459        $this->objFormParam->convParam();
460        #if(count($this->arrErr) == 0) {
461            $this->arrErr = $this->lfCheek($arrInfo);
462        #}
463        $this->arrErr = $this->lfCheckError();
464    }
465
466    /* DB登録処理 */
467    function lfRegistData($order_id) {
468        $objQuery = new SC_Query();
469
470        $objQuery->begin();
471
472        // 入力データを渡す。
473        $arrRet =  $this->objFormParam->getHashArray();
474        foreach($arrRet as $key => $val) {
475            // 配列は登録しない
476            if(!is_array($val)) {
477                $sqlval[$key] = $val;
478            }
479        }
480
481        unset($sqlval['total_point']);
482        unset($sqlval['point']);
483
484        $where = "order_id = ?";
485
486        // 受注ステータスの判定
487        if ($sqlval['status'] == ODERSTATUS_COMMIT) {
488            // 受注テーブルの発送済み日を更新する
489            $addcol['commit_date'] = "Now()";
490        }
491
492        /*
493         * XXX 本来なら配列だが, update 関数を string として
494         *     チェックしているため...
495         */
496        if (!isset($addcol)) $addcol = "";
497
498        // 受注テーブルの更新
499        $objQuery->update("dtb_order", $sqlval, $where, array($order_id), $addcol);
500
501        $sql = "";
502        $sql .= " UPDATE";
503        $sql .= "     dtb_order";
504        $sql .= " SET";
505        $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)";
506        $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))";
507        $sql .= " WHERE order_id = ?";
508
509        if ($arrRet['deliv_time_id'] == "") {
510            $deliv_time_id = 0;
511        }else{
512            $deliv_time_id = $arrRet['deliv_time_id'];
513        }
514        $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id);
515        $objQuery->query($sql, $arrUpdData);
516
517        // 受注詳細データの更新
518        $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2"));
519        $objQuery->delete("dtb_order_detail", $where, array($order_id));
520
521        $max = count($arrDetail);
522        for($i = 0; $i < $max; $i++) {
523            $sqlval = array();
524            $sqlval['order_id'] = $order_id;
525            $sqlval['product_id']  = $arrDetail[$i]['product_id'];
526            $sqlval['product_code']  = $arrDetail[$i]['product_code'];
527            $sqlval['product_name']  = $arrDetail[$i]['product_name'];
528            $sqlval['price']  = $arrDetail[$i]['price'];
529            $sqlval['quantity']  = $arrDetail[$i]['quantity'];
530            $sqlval['point_rate']  = $arrDetail[$i]['point_rate'];
531            $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1'];
532            $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2'];
533            $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1'];
534            $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2'];
535            $objQuery->insert("dtb_order_detail", $sqlval);
536        }
537        $objQuery->commit();
538    }
539
540    /* DB登録処理(追加) */
541    function lfRegistNewData() {
542        $objQuery = new SC_Query();
543
544        $objQuery->begin();
545
546        // 入力データを渡す。
547        $arrRet =  $this->objFormParam->getHashArray();
548        foreach($arrRet as $key => $val) {
549            // 配列は登録しない
550            if(!is_array($val)) {
551                $sqlval[$key] = $val;
552            }
553        }
554        $order_id = $objQuery->nextval('dtb_order', 'order_id');
555        $sqlval['order_id'] = $order_id;
556        $sqlval['create_date'] = "Now()";
557
558        // 注文ステータス:指定が無ければ新規受付に設定
559        if($sqlval["status"] == ""){
560            $sqlval['status'] = '1';
561        }
562
563        // customer_id
564        if($sqlval["customer_id"] == ""){
565            $sqlval['customer_id'] = '0';
566        }
567
568        unset($sqlval['total_point']);
569        unset($sqlval['point']);
570
571        $where = "order_id = ?";
572
573        // 受注ステータスの判定
574        if ($sqlval['status'] == ODERSTATUS_COMMIT) {
575            // 受注テーブルの発送済み日を更新する
576            $sqlval['commit_date'] = "Now()";
577        }
578
579        // 受注テーブルの登録
580        $objQuery->insert("dtb_order", $sqlval);
581
582        $sql = "";
583        $sql .= " UPDATE";
584        $sql .= "     dtb_order";
585        $sql .= " SET";
586        $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)";
587        $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))";
588        $sql .= " WHERE order_id = ?";
589
590        if ($arrRet['deliv_time_id'] == "") {
591            $deliv_time_id = 0;
592        }else{
593            $deliv_time_id = $arrRet['deliv_time_id'];
594        }
595        $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id);
596        $objQuery->query($sql, $arrUpdData);
597
598        // 受注詳細データの更新
599        $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2"));
600        $objQuery->delete("dtb_order_detail", $where, array($order_id));
601
602        $max = count($arrDetail);
603        for($i = 0; $i < $max; $i++) {
604            $sqlval = array();
605            $sqlval['order_id'] = $order_id;
606            $sqlval['product_id']  = $arrDetail[$i]['product_id'];
607            $sqlval['product_code']  = $arrDetail[$i]['product_code'];
608            $sqlval['product_name']  = $arrDetail[$i]['product_name'];
609            $sqlval['price']  = $arrDetail[$i]['price'];
610            $sqlval['quantity']  = $arrDetail[$i]['quantity'];
611            $sqlval['point_rate']  = $arrDetail[$i]['point_rate'];
612            $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1'];
613            $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2'];
614            $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1'];
615            $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2'];
616            $objQuery->insert("dtb_order_detail", $sqlval);
617        }
618        $objQuery->commit();
619    }
620
621
622    function lfInsertProduct($product_id, $classcategory_id1, $classcategory_id2) {
623        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2);
624        $this->arrForm = $this->objFormParam->getFormParamList();
625        $this->lfSetProductData($arrProduct);
626    }
627
628    function lfUpdateProduct($product_id, $classcategory_id1, $classcategory_id2, $no) {
629        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2);
630        $this->arrForm = $this->objFormParam->getFormParamList();
631        $this->lfSetProductData($arrProduct, $no);
632    }
633
634    function lfSetProductData($arrProduct, $no = null) {
635        foreach ($arrProduct AS $key=>$val) {
636            if (!is_array($this->arrForm[$key]['value'])) {
637                unset($this->arrForm[$key]['value']);
638            }
639            if ($no === null) {
640                $this->arrForm[$key]['value'][] = $arrProduct[$key];
641            } else {
642                $this->arrForm[$key]['value'][$no] = $arrProduct[$key];
643            }
644        }
645    }
646
647    function lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2) {
648        $objDb = new SC_Helper_DB_Ex();
649        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
650        $arrRet = $objDb->sfGetProductsClass(array($product_id, $classcategory_id1, $classcategory_id2));
651
652        $arrProduct['price'] = $arrRet['price02'];
653        $arrProduct['quantity'] = 1;
654        $arrProduct['product_id'] = $arrRet['product_id'];
655        $arrProduct['point_rate'] = $arrRet['point_rate'];
656        $arrProduct['product_code'] = $arrRet['product_code'];
657        $arrProduct['product_name'] = $arrRet['name'];
658        $arrProduct['classcategory_id1'] = $arrRet['classcategory_id1'];
659        $arrProduct['classcategory_id2'] = $arrRet['classcategory_id2'];
660        $arrProduct['classcategory_name1'] = $arrClassCatName[$arrRet['classcategory_id1']];
661        $arrProduct['classcategory_name2'] = $arrClassCatName[$arrRet['classcategory_id2']];
662
663        return $arrProduct;
664    }
665}
666?>
Note: See TracBrowser for help on using the repository browser.