Ignore:
Timestamp:
2009/02/13 22:05:12 (15 years ago)
Author:
zeniya
Message:

EC-CUBE2.4改修 #292

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_4/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php

    r17395 r17773  
    2727/* GMO決済モジュール連携用 */ 
    2828if (file_exists(MODULE_PATH . 'mdl_gmopg/inc/include.php') === TRUE) { 
    29     require_once(MODULE_PATH . 'mdl_gmopg/inc/include.php'); 
     29  require_once(MODULE_PATH . 'mdl_gmopg/inc/include.php'); 
    3030} 
    3131 
    3232/* ペイジェント決済モジュール連携用 */ 
    3333if (file_exists(MODULE_PATH . 'mdl_paygent/include.php') === TRUE) { 
    34     require_once(MODULE_PATH . 'mdl_paygent/include.php'); 
     34    require_once(MODULE_PATH . 'mdl_paygent/include.php'); 
    3535} 
    3636 
     
    7171        parent::init(); 
    7272        $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 = '受注管理'; 
     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        } 
    7782 
    7883        $masterData = new SC_DB_MasterData_Ex(); 
    79         $this->arrPref = $masterData->getMasterData("mtb_pref", 
     84        $this->arrPref = $masterData->getMasterData("mtb_pref", 
    8085                                 array("pref_id", "pref_name", "rank")); 
    81         $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status"); 
     86        $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status"); 
    8287 
    8388        /* ペイジェント決済モジュール連携用 */ 
    8489        if(function_exists("sfPaygentOrderPage")) { 
    85             $this->arrDispKind = sfPaygentOrderPage(); 
     90            $this->arrFormKind = sfPaygentOrderPage(); 
    8691        } 
    8792 
     
    141146            break; 
    142147        case 'edit': 
     148        case 'add': 
    143149            // POST情報で上書き 
    144150            $this->objFormParam->setParam($_POST); 
     
    146152            // 入力値の変換 
    147153            $this->objFormParam->convParam(); 
     154            $this->arrErr = $this->lfCheek($arrInfo); 
    148155            $this->arrErr = $this->lfCheckError(); 
    149156            if(count($this->arrErr) == 0) { 
    150                 $this->arrErr = $this->lfCheek($arrInfo); 
    151                 if(count($this->arrErr) == 0) { 
    152                     $this->lfRegistData($_POST['order_id']); 
     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                    } 
    153165                    // DBから受注情報を再読込 
    154166                    $this->lfGetOrderData($order_id); 
    155                     $this->tpl_onload = "window.alert('受注履歴を編集しました。');"; 
    156                 } 
     167                    $this->tpl_onload = "window.alert(".$text.");"; 
     168                #} 
    157169            } 
    158170            break; 
     
    171183        case 'paygent_order': 
    172184            $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); 
    173220            break; 
    174221        /* F-REGI決済モジュール連携用 */ 
     
    218265 
    219266        $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; 
    220276 
    221277        $this->arrInfo = $arrInfo; 
     
    254310    /* パラメータ情報の初期化 */ 
    255311    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("EXIST_CHECK", "NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); 
     319        $this->objFormParam->addParam("郵便番号1", "order_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK")); 
     320        $this->objFormParam->addParam("郵便番号2", "order_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK")); 
     321        $this->objFormParam->addParam("都道府県", "order_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
     322        $this->objFormParam->addParam("住所1", "order_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     323        $this->objFormParam->addParam("住所2", "order_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     324        $this->objFormParam->addParam("電話番号1", "order_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
     325        $this->objFormParam->addParam("電話番号2", "order_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
     326        $this->objFormParam->addParam("電話番号3", "order_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
     327 
    256328        // 配送先情報 
    257329        $this->objFormParam->addParam("お名前1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
     
    267339        $this->objFormParam->addParam("電話番号2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
    268340        $this->objFormParam->addParam("電話番号3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
     341 
     342 
    269343        // 受注商品情報 
    270344        $this->objFormParam->addParam("値引き", "discount", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); 
    271         $this->objFormParam->addParam("送料", "deliv_fee", 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")); 
    272346        $this->objFormParam->addParam("手数料", "charge", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    273347        $this->objFormParam->addParam("利用ポイント", "use_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
     
    301375        $this->objFormParam->addParam("顧客ID", "customer_id"); 
    302376        $this->objFormParam->addParam("現在のポイント", "point"); 
     377        $this->objFormParam->addParam("受注番号", "order_id"); 
     378        $this->objFormParam->addParam("受注日", "create_date"); 
    303379    } 
    304380 
     
    314390            $this->objFormParam->setValue('total_point', $total_point); 
    315391            $this->objFormParam->setValue('point', $point); 
    316             $this->arrDisp = $arrRet[0]; 
     392            $this->arrForm = $arrRet[0]; 
    317393            // 受注詳細データの取得 
    318394            $arrRet = $this->lfGetOrderDetail($order_id); 
    319395            $arrRet = SC_Utils_Ex::sfSwapArray($arrRet); 
    320             $this->arrDisp = array_merge($this->arrDisp, $arrRet); 
     396            $this->arrForm = array_merge($this->arrForm, $arrRet); 
    321397            $this->objFormParam->setParam($arrRet); 
    322398 
    323399            // その他支払い情報を表示 
    324             if($this->arrDisp["memo02"] != "") $this->arrDisp["payment_info"] = unserialize($this->arrDisp["memo02"]); 
    325             if($this->arrDisp["memo01"] == PAYMENT_CREDIT_ID){ 
    326                 $this->arrDisp["payment_type"] = "クレジット決済"; 
    327             }elseif($this->arrDisp["memo01"] == PAYMENT_CONVENIENCE_ID){ 
    328                 $this->arrDisp["payment_type"] = "コンビニ決済"; 
     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"] = "コンビニ決済"; 
    329405            }else{ 
    330                 $this->arrDisp["payment_type"] = "お支払い"; 
     406                $this->arrForm["payment_type"] = "お支払い"; 
    331407            } 
    332408        } 
     
    403479    } 
    404480 
     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    } 
    405491    /* DB登録処理 */ 
    406492    function lfRegistData($order_id) { 
     
    476562        $objQuery->commit(); 
    477563    } 
     564 
     565    /* DB登録処理(追加) */ 
     566    function lfRegistNewData() { 
     567        $objQuery = new SC_Query(); 
     568 
     569        $objQuery->begin(); 
     570 
     571        // 入力データを渡す。 
     572        $arrRet =  $this->objFormParam->getHashArray(); 
     573        foreach($arrRet as $key => $val) { 
     574            // 配列は登録しない 
     575            if(!is_array($val)) { 
     576                $sqlval[$key] = $val; 
     577            } 
     578        } 
     579        $order_id = $objQuery->nextval('dtb_order', 'order_id'); 
     580        $sqlval['order_id'] = $order_id; 
     581        $sqlval['create_date'] = "Now()"; 
     582 
     583        // 注文ステータス:指定が無ければ新規受付に設定 
     584        if($sqlval["status"] == ""){ 
     585            $sqlval['status'] = '1'; 
     586        } 
     587 
     588        // customer_id 
     589        if($sqlval["customer_id"] == ""){ 
     590            $sqlval['customer_id'] = '0'; 
     591        } 
     592 
     593        unset($sqlval['total_point']); 
     594        unset($sqlval['point']); 
     595 
     596        $where = "order_id = ?"; 
     597 
     598        // 受注ステータスの判定 
     599        if ($sqlval['status'] == ODERSTATUS_COMMIT) { 
     600            // 受注テーブルの発送済み日を更新する 
     601            $sqlval['commit_date'] = "Now()"; 
     602        } 
     603 
     604        // 受注テーブルの登録 
     605        $objQuery->insert("dtb_order", $sqlval); 
     606 
     607        $sql = ""; 
     608        $sql .= " UPDATE"; 
     609        $sql .= "     dtb_order"; 
     610        $sql .= " SET"; 
     611        $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)"; 
     612        $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))"; 
     613        $sql .= " WHERE order_id = ?"; 
     614 
     615        if ($arrRet['deliv_time_id'] == "") { 
     616            $deliv_time_id = 0; 
     617        } else { 
     618            $deliv_time_id = $arrRet['deliv_time_id']; 
     619        } 
     620        $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id); 
     621        $objQuery->query($sql, $arrUpdData); 
     622 
     623        // 受注詳細データの更新 
     624        $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2")); 
     625        $objQuery->delete("dtb_order_detail", $where, array($order_id)); 
     626 
     627        $max = count($arrDetail); 
     628        for($i = 0; $i < $max; $i++) { 
     629            $sqlval = array(); 
     630            $sqlval['order_id'] = $order_id; 
     631            $sqlval['product_id']  = $arrDetail[$i]['product_id']; 
     632            $sqlval['product_code']  = $arrDetail[$i]['product_code']; 
     633            $sqlval['product_name']  = $arrDetail[$i]['product_name']; 
     634            $sqlval['price']  = $arrDetail[$i]['price']; 
     635            $sqlval['quantity']  = $arrDetail[$i]['quantity']; 
     636            $sqlval['point_rate']  = $arrDetail[$i]['point_rate']; 
     637            $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1']; 
     638            $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2']; 
     639            $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1']; 
     640            $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2']; 
     641            $objQuery->insert("dtb_order_detail", $sqlval); 
     642        } 
     643        $objQuery->commit(); 
     644    } 
     645 
     646    function lfInsertProduct($product_id, $classcategory_id1, $classcategory_id2) { 
     647        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2); 
     648        $this->arrForm = $this->objFormParam->getFormParamList(); 
     649        $this->lfSetProductData($arrProduct); 
     650    } 
     651 
     652    function lfUpdateProduct($product_id, $classcategory_id1, $classcategory_id2, $no) { 
     653        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2); 
     654        $this->arrForm = $this->objFormParam->getFormParamList(); 
     655        $this->lfSetProductData($arrProduct, $no); 
     656    } 
     657 
     658    function lfSetProductData($arrProduct, $no = null) { 
     659        foreach ($arrProduct AS $key=>$val) { 
     660            if (!is_array($this->arrForm[$key]['value'])) { 
     661                unset($this->arrForm[$key]['value']); 
     662            } 
     663            if ($no === null) { 
     664                $this->arrForm[$key]['value'][] = $arrProduct[$key]; 
     665            } else { 
     666                $this->arrForm[$key]['value'][$no] = $arrProduct[$key]; 
     667            } 
     668        } 
     669    } 
     670 
     671    function lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2) { 
     672        $objDb = new SC_Helper_DB_Ex(); 
     673        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
     674        $arrRet = $objDb->sfGetProductsClass(array($product_id, $classcategory_id1, $classcategory_id2)); 
     675 
     676        $arrProduct['price'] = $arrRet['price02']; 
     677        $arrProduct['quantity'] = 1; 
     678        $arrProduct['product_id'] = $arrRet['product_id']; 
     679        $arrProduct['point_rate'] = $arrRet['point_rate']; 
     680        $arrProduct['product_code'] = $arrRet['product_code']; 
     681        $arrProduct['product_name'] = $arrRet['name']; 
     682        $arrProduct['classcategory_id1'] = $arrRet['classcategory_id1']; 
     683        $arrProduct['classcategory_id2'] = $arrRet['classcategory_id2']; 
     684        $arrProduct['classcategory_name1'] = $arrClassCatName[$arrRet['classcategory_id1']]; 
     685        $arrProduct['classcategory_name2'] = $arrClassCatName[$arrRet['classcategory_id2']]; 
     686 
     687        return $arrProduct; 
     688    } 
    478689} 
    479690?> 
Note: See TracChangeset for help on using the changeset viewer.