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

Revision 18037, 32.8 KB checked in by Seasoft, 15 years ago (diff)

merge r17773, r17777, r17823, r17952, r18028
・取得元: version-2_4, version-2
r17773 による不具合 #478(受注管理で受注日と更新日のエラー文言が表示されない) に対応。
【取得元のログメッセージ】

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