Changeset 15594


Ignore:
Timestamp:
2007/09/04 17:18:38 (13 years ago)
Author:
nanasess
Message:

クラス化に伴う修正

Location:
branches/feature-module-update
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/html/admin/order/edit.php

    r15532 r15594  
    55 * http://www.lockon.co.jp/ 
    66 */ 
    7 require_once("../require.php"); 
    87 
    9 class LC_Page { 
    10     function LC_Page() { 
    11         $this->tpl_mainpage = 'order/edit.tpl'; 
    12         $this->tpl_subnavi = 'order/subnavi.tpl'; 
    13         $this->tpl_mainno = 'order';         
    14         $this->tpl_subno = 'index'; 
    15         $this->tpl_subtitle = '受注管理'; 
    16         global $arrPref; 
    17         $this->arrPref = $arrPref; 
    18         global $arrORDERSTATUS; 
    19         $this->arrORDERSTATUS = $arrORDERSTATUS; 
    20     } 
    21 } 
     8// {{{ requires 
     9require_once("../../require.php"); 
     10require_once(CLASS_PATH . "page_extends/admin/order/LC_Page_Admin_Order_Edit_Ex.php"); 
    2211 
    23 $conn = new SC_DBConn(); 
    24 $objPage = new LC_Page(); 
    25 $objView = new SC_AdminView(); 
    26 $objSess = new SC_Session(); 
    27 $objSiteInfo = new SC_SiteInfo(); 
    28 $arrInfo = $objSiteInfo->data; 
     12// }}} 
     13// {{{ generate page 
    2914 
    30 // パラメータ管理クラス 
    31 $objFormParam = new SC_FormParam(); 
    32 // パラメータ情報の初期化 
    33 lfInitParam(); 
    34  
    35 // 認証可否の判定 
    36 sfIsSuccess($objSess); 
    37  
    38 // 検索パラメータの引き継ぎ 
    39 foreach ($_POST as $key => $val) { 
    40     if (ereg("^search_", $key)) { 
    41         $objPage->arrSearchHidden[$key] = $val; 
    42     } 
    43 } 
    44  
    45 // 表示モード判定 
    46 if(sfIsInt($_GET['order_id'])) { 
    47     $objPage->disp_mode = true; 
    48     $order_id = $_GET['order_id']; 
    49 } else { 
    50     $order_id = $_POST['order_id']; 
    51 } 
    52 $objPage->tpl_order_id = $order_id; 
    53  
    54 // DBから受注情報を読み込む 
    55 lfGetOrderData($order_id); 
    56  
    57 switch($_POST['mode']) { 
    58 case 'pre_edit': 
    59 case 'order_id': 
    60     break; 
    61 case 'edit': 
    62     // POST情報で上書き 
    63     $objFormParam->setParam($_POST); 
    64      
    65     // 入力値の変換 
    66     $objFormParam->convParam(); 
    67     $objPage->arrErr = lfCheckError($arrRet); 
    68     if(count($objPage->arrErr) == 0) { 
    69         $objPage->arrErr = lfCheek($arrInfo); 
    70         if(count($objPage->arrErr) == 0) { 
    71             lfRegistData($_POST['order_id']); 
    72             // DBから受注情報を再読込 
    73             lfGetOrderData($order_id); 
    74             $objPage->tpl_onload = "window.alert('受注履歴を編集しました。');"; 
    75         } 
    76     } 
    77     break; 
    78 // 再計算 
    79 case 'cheek': 
    80     // POST情報で上書き 
    81     $objFormParam->setParam($_POST); 
    82     // 入力値の変換 
    83     $objFormParam->convParam(); 
    84     $objPage->arrErr = lfCheckError($arrRet); 
    85     if(count($objPage->arrErr) == 0) { 
    86         $objPage->arrErr = lfCheek($arrInfo); 
    87     } 
    88     break; 
    89 default: 
    90     break; 
    91 } 
    92  
    93 // 支払い方法の取得 
    94 $objPage->arrPayment = sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); 
    95 // 配送時間の取得 
    96 $arrRet = sfGetDelivTime($objFormParam->getValue('payment_id')); 
    97 $objPage->arrDelivTime = sfArrKeyValue($arrRet, 'time_id', 'deliv_time'); 
    98  
    99 $objPage->arrForm = $objFormParam->getFormParamList(); 
    100  
    101 $objPage->arrInfo = $arrInfo; 
    102  
    103 $objView->assignobj($objPage); 
    104 // 表示モード判定 
    105 if(!$objPage->disp_mode) { 
    106     $objView->display(MAIN_FRAME); 
    107 } else { 
    108     $objView->display('order/disp.tpl'); 
    109 } 
    110 //----------------------------------------------------------------------------------------------------------------------------------- 
    111 /* パラメータ情報の初期化 */ 
    112 function lfInitParam() { 
    113     global $objFormParam; 
    114     // 配送先情報 
    115     $objFormParam->addParam("お名前1", "deliv_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    116     $objFormParam->addParam("お名前2", "deliv_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    117     $objFormParam->addParam("フリガナ1", "deliv_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    118     $objFormParam->addParam("フリガナ2", "deliv_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    119     $objFormParam->addParam("郵便番号1", "deliv_zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK")); 
    120     $objFormParam->addParam("郵便番号2", "deliv_zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "NUM_COUNT_CHECK")); 
    121     $objFormParam->addParam("都道府県", "deliv_pref", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    122     $objFormParam->addParam("住所1", "deliv_addr01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    123     $objFormParam->addParam("住所2", "deliv_addr02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    124     $objFormParam->addParam("電話番号1", "deliv_tel01", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
    125     $objFormParam->addParam("電話番号2", "deliv_tel02", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
    126     $objFormParam->addParam("電話番号3", "deliv_tel03", TEL_ITEM_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK" ,"NUM_CHECK")); 
    127     // 受注商品情報 
    128     $objFormParam->addParam("値引き", "discount", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); 
    129     $objFormParam->addParam("送料", "deliv_fee", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); 
    130     $objFormParam->addParam("手数料", "charge", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    131     $objFormParam->addParam("利用ポイント", "use_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    132     $objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    133     $objFormParam->addParam("配送時間ID", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
    134     $objFormParam->addParam("対応状況", "status", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    135     $objFormParam->addParam("配達日", "deliv_date", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); 
    136     $objFormParam->addParam("お支払方法名称", "payment_method"); 
    137     $objFormParam->addParam("配送時間", "deliv_time"); 
    138      
    139     // 受注詳細情報 
    140     $objFormParam->addParam("単価", "price", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); 
    141     $objFormParam->addParam("個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); 
    142     $objFormParam->addParam("商品ID", "product_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); 
    143     $objFormParam->addParam("ポイント付与率", "point_rate"); 
    144     $objFormParam->addParam("商品コード", "product_code"); 
    145     $objFormParam->addParam("商品名", "product_name"); 
    146     $objFormParam->addParam("規格1", "classcategory_id1"); 
    147     $objFormParam->addParam("規格2", "classcategory_id2"); 
    148     $objFormParam->addParam("規格名1", "classcategory_name1"); 
    149     $objFormParam->addParam("規格名2", "classcategory_name2"); 
    150     $objFormParam->addParam("メモ", "note", MTEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); 
    151     // DB読込用 
    152     $objFormParam->addParam("小計", "subtotal"); 
    153     $objFormParam->addParam("合計", "total"); 
    154     $objFormParam->addParam("支払い合計", "payment_total"); 
    155     $objFormParam->addParam("加算ポイント", "add_point"); 
    156     $objFormParam->addParam("お誕生日ポイント", "birth_point"); 
    157     $objFormParam->addParam("消費税合計", "tax"); 
    158     $objFormParam->addParam("最終保持ポイント", "total_point"); 
    159     $objFormParam->addParam("顧客ID", "customer_id"); 
    160     $objFormParam->addParam("現在のポイント", "point"); 
    161 } 
    162  
    163 function lfGetOrderData($order_id) { 
    164     global $objFormParam; 
    165     global $objPage; 
    166     if(sfIsInt($order_id)) { 
    167         // DBから受注情報を読み込む 
    168         $objQuery = new SC_Query(); 
    169         $where = "order_id = ?"; 
    170         $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); 
    171         $objFormParam->setParam($arrRet[0]); 
    172         list($point, $total_point) = sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']); 
    173         $objFormParam->setValue('total_point', $total_point); 
    174         $objFormParam->setValue('point', $point); 
    175         $objPage->arrDisp = $arrRet[0]; 
    176         // 受注詳細データの取得 
    177         $arrRet = lfGetOrderDetail($order_id); 
    178         $arrRet = sfSwapArray($arrRet); 
    179         $objPage->arrDisp = array_merge($objPage->arrDisp, $arrRet); 
    180         $objFormParam->setParam($arrRet); 
    181          
    182         // その他支払い情報を表示 
    183         if($objPage->arrDisp["memo02"] != "") $objPage->arrDisp["payment_info"] = unserialize($objPage->arrDisp["memo02"]); 
    184         if($objPage->arrDisp["memo01"] == PAYMENT_CREDIT_ID){ 
    185             $objPage->arrDisp["payment_type"] = "クレジット決済"; 
    186         }elseif($objPage->arrDisp["memo01"] == PAYMENT_CONVENIENCE_ID){ 
    187             $objPage->arrDisp["payment_type"] = "コンビニ決済"; 
    188         }else{ 
    189             $objPage->arrDisp["payment_type"] = "お支払い"; 
    190         } 
    191     } 
    192 } 
    193  
    194 // 受注詳細データの取得 
    195 function lfGetOrderDetail($order_id) { 
    196     $objQuery = new SC_Query(); 
    197     $col = "product_id, classcategory_id1, classcategory_id2, product_code, product_name, classcategory_name1, classcategory_name2, price, quantity, point_rate"; 
    198     $where = "order_id = ?"; 
    199     $objQuery->setorder("classcategory_id1, classcategory_id2"); 
    200     $arrRet = $objQuery->select($col, "dtb_order_detail", $where, array($order_id)); 
    201     return $arrRet; 
    202 } 
    203  
    204 /* 入力内容のチェック */ 
    205 function lfCheckError() { 
    206     global $objFormParam; 
    207     // 入力データを渡す。 
    208     $arrRet =  $objFormParam->getHashArray(); 
    209     $objErr = new SC_CheckError($arrRet); 
    210     $objErr->arrErr = $objFormParam->checkError(); 
    211      
    212     return $objErr->arrErr; 
    213 } 
    214  
    215 /* 計算処理 */ 
    216 function lfCheek($arrInfo) { 
    217     global $objFormParam; 
    218          
    219     $arrVal = $objFormParam->getHashArray(); 
    220              
    221     // 商品の種類数 
    222     $max = count($arrVal['quantity']); 
    223     $subtotal = 0; 
    224     $totalpoint = 0; 
    225     $totaltax = 0; 
    226     for($i = 0; $i < $max; $i++) { 
    227         // 小計の計算 
    228         $subtotal += sfPreTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i]; 
    229         // 小計の計算 
    230         $totaltax += sfTax($arrVal['price'][$i], $arrInfo['tax'], $arrInfo['tax_rule']) * $arrVal['quantity'][$i]; 
    231         // 加算ポイントの計算 
    232         $totalpoint += sfPrePoint($arrVal['price'][$i], $arrVal['point_rate'][$i]) * $arrVal['quantity'][$i]; 
    233     } 
    234      
    235     // 消費税 
    236     $arrVal['tax'] = $totaltax;  
    237     // 小計 
    238     $arrVal['subtotal'] = $subtotal; 
    239     // 合計 
    240     $arrVal['total'] = $subtotal - $arrVal['discount'] + $arrVal['deliv_fee'] + $arrVal['charge']; 
    241     // お支払い合計 
    242     $arrVal['payment_total'] = $arrVal['total'] - ($arrVal['use_point'] * POINT_VALUE); 
    243      
    244     // 加算ポイント 
    245     $arrVal['add_point'] = sfGetAddPoint($totalpoint, $arrVal['use_point'], $arrInfo); 
    246          
    247     list($arrVal['point'], $arrVal['total_point']) = sfGetCustomerPoint($_POST['order_id'], $arrVal['use_point'], $arrVal['add_point']); 
    248          
    249     if($arrVal['total'] < 0) { 
    250         $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; 
    251     } 
    252      
    253     if($arrVal['payment_total'] < 0) { 
    254         $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; 
    255     } 
    256  
    257     if($arrVal['total_point'] < 0) { 
    258         $arrErr['total_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; 
    259     } 
    260  
    261     $objFormParam->setParam($arrVal); 
    262     return $arrErr; 
    263 } 
    264  
    265 /* DB登録処理 */ 
    266 function lfRegistData($order_id) { 
    267     global $objFormParam; 
    268     $objQuery = new SC_Query(); 
    269      
    270     $objQuery->begin(); 
    271  
    272     // 入力データを渡す。 
    273     $arrRet =  $objFormParam->getHashArray(); 
    274      
    275     foreach($arrRet as $key => $val) { 
    276         // 配列は登録しない 
    277         if(!is_array($val)) { 
    278             $sqlval[$key] = $val; 
    279         } 
    280     } 
    281      
    282     unset($sqlval['total_point']); 
    283     unset($sqlval['point']); 
    284              
    285     $where = "order_id = ?"; 
    286      
    287     // 受注ステータスの判定 
    288     if ($sqlval['status'] == ODERSTATUS_COMMIT) { 
    289         // 受注テーブルの発送済み日を更新する 
    290         $addcol['commit_date'] = "Now()"; 
    291     } 
    292      
    293     // 受注テーブルの更新 
    294     $objQuery->update("dtb_order", $sqlval, $where, array($order_id), $addcol); 
    295  
    296     $sql = ""; 
    297     $sql .= " UPDATE"; 
    298     $sql .= "     dtb_order"; 
    299     $sql .= " SET"; 
    300     $sql .= "     payment_method = (SELECT payment_method FROM dtb_payment WHERE payment_id = ?)"; 
    301     $sql .= "     ,deliv_time = (SELECT deliv_time FROM dtb_delivtime WHERE time_id = ? AND deliv_id = (SELECT deliv_id FROM dtb_payment WHERE payment_id = ? ))"; 
    302     $sql .= " WHERE order_id = ?"; 
    303      
    304     if ($arrRet['deliv_time_id'] == "") { 
    305         $deliv_time_id = 0; 
    306     }else{ 
    307         $deliv_time_id = $arrRet['deliv_time_id']; 
    308     } 
    309     $arrUpdData = array($arrRet['payment_id'], $deliv_time_id, $arrRet['payment_id'], $order_id); 
    310     $objQuery->query($sql, $arrUpdData); 
    311  
    312     // 受注詳細データの更新 
    313     $arrDetail = $objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2")); 
    314     $objQuery->delete("dtb_order_detail", $where, array($order_id)); 
    315      
    316     $max = count($arrDetail); 
    317     for($i = 0; $i < $max; $i++) { 
    318         $sqlval = array(); 
    319         $sqlval['order_id'] = $order_id; 
    320         $sqlval['product_id']  = $arrDetail[$i]['product_id']; 
    321         $sqlval['product_code']  = $arrDetail[$i]['product_code']; 
    322         $sqlval['product_name']  = $arrDetail[$i]['product_name']; 
    323         $sqlval['price']  = $arrDetail[$i]['price']; 
    324         $sqlval['quantity']  = $arrDetail[$i]['quantity']; 
    325         $sqlval['point_rate']  = $arrDetail[$i]['point_rate']; 
    326         $sqlval['classcategory_id1'] = $arrDetail[$i]['classcategory_id1']; 
    327         $sqlval['classcategory_id2'] = $arrDetail[$i]['classcategory_id2']; 
    328         $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1']; 
    329         $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2'];      
    330         $objQuery->insert("dtb_order_detail", $sqlval); 
    331     } 
    332     $objQuery->commit(); 
    333 } 
     15$objPage = new LC_Page_Admin_Order_Edit_Ex(); 
     16$objPage->init(); 
     17$objPage->process(); 
     18register_shutdown_function(array($objPage, "destroy")); 
    33419?> 
Note: See TracChangeset for help on using the changeset viewer.