Source for file LC_Page_Shopping_DelivAddr.php

Documentation is available at LC_Page_Shopping_DelivAddr.php

  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
  25. require_once(CLASS_PATH "pages/LC_Page.php");
  26.  
  27. /**
  28.  * 配送先追加のページクラス
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Shopping_DelivAddr.php 17969 2009-04-10 14:20:10Z Seasoft $
  33.  */
  34.  
  35.     // }}}
  36.     // {{{ functions
  37.  
  38.     /**
  39.      * Page を初期化する.
  40.      *
  41.      * @return void 
  42.      */
  43.     function init({
  44.         parent::init();
  45.     }
  46.  
  47.     /**
  48.      * Page のプロセス.
  49.      *
  50.      * @return void 
  51.      */
  52.     function process({
  53.     }
  54.  
  55.     /**
  56.      * モバイルページを初期化する.
  57.      *
  58.      * @return void 
  59.      */
  60.     function mobileInit({
  61.         $this->tpl_mainpage = 'shopping/deliv_addr.tpl';
  62.         $this->tpl_title = "新しいお届け先の追加";
  63.         $masterData new SC_DB_MasterData_Ex();
  64.         $this->arrPref $masterData->getMasterData("mtb_pref"array("pref_id""pref_name""rank"));
  65.     }
  66.  
  67.     /**
  68.      * Page のプロセス(モバイル).
  69.      *
  70.      * @return void 
  71.      */
  72.     function mobileProcess({
  73.         $objView new SC_MobileView(false);
  74.         $objQuery new SC_Query();
  75.         $objCustomer new SC_Customer();
  76.         $objSiteSess new SC_SiteSession();
  77.         $objCartSess new SC_CartSession();
  78.  
  79.         //ログイン判定
  80.         if (!$objCustomer->isLoginSuccess(true)){
  81.             SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR""false""true);
  82.         }
  83.  
  84.         $this->arrForm $_POST;
  85.  
  86.         //-- データ設定
  87.         foreach($_POST as $key => $val{
  88.             if ($key != "mode" && $key != "return" && $key != "submit" && $key != session_name()) {
  89.                 $this->list_data$key $val;
  90.             }
  91.         }
  92.         // ユーザユニークIDの取得と購入状態の正当性をチェック
  93.         $uniqid SC_Utils_Ex::sfCheckNormalAccess($objSiteSess$objCartSess);
  94.  
  95.         //別のお届け先DB登録用カラム配列
  96.         $arrRegistColumn array(
  97.                                  array(  "column" => "name01",        "convert" => "aKV" ),
  98.                                  array(  "column" => "name02",        "convert" => "aKV" ),
  99.                                  array(  "column" => "kana01",        "convert" => "CKV" ),
  100.                                  array(  "column" => "kana02",        "convert" => "CKV" ),
  101.                                  array(  "column" => "zip01",        "convert" => "n" ),
  102.                                  array(  "column" => "zip02",        "convert" => "n" ),
  103.                                  array(  "column" => "pref",        "convert" => "n" ),
  104.                                  array(  "column" => "addr01",        "convert" => "aKV" ),
  105.                                  array(  "column" => "addr02",        "convert" => "aKV" ),
  106.                                  array(  "column" => "tel01",        "convert" => "n" ),
  107.                                  array(  "column" => "tel02",        "convert" => "n" ),
  108.                                  array(  "column" => "tel03",        "convert" => "n" ),
  109.                                  );
  110.  
  111.         // 戻るボタン用処理
  112.         if (!empty($_POST["return"])) {
  113.             switch ($_POST["mode"]{
  114.             case 'complete':
  115.                 $_POST["mode""set2";
  116.                 break;
  117.             case 'set2':
  118.                 $_POST["mode""set1";
  119.                 break;
  120.             default:
  121.                 $this->sendRedirect($this->getLocation("./deliv.php")true);
  122.                 exit;
  123.             }
  124.         }
  125.  
  126.         switch ($_POST['mode']){
  127.         case 'set1':
  128.             $this->arrErr $this->lfErrorCheck1($this->arrForm);
  129.             if (count($this->arrErr== && empty($_POST["return"])) {
  130.                 $this->tpl_mainpage = 'shopping/set1.tpl';
  131.  
  132.                 $checkVal array("pref""addr01""addr02""addr03""tel01""tel02""tel03");
  133.                 foreach($checkVal as $key{
  134.                     unset($this->list_data[$key]);
  135.                 }
  136.  
  137.                 // 郵便番号から住所の取得
  138.                 if (@$this->arrForm['pref'== "" && @$this->arrForm['addr01'== "" && @$this->arrForm['addr02'== ""{
  139.                     $address $this->lfGetAddress($_REQUEST['zip01'].$_REQUEST['zip02']);
  140.                     $this->arrForm['pref'@$address[0]['state'];
  141.                     $this->arrForm['addr01'@$address[0]['city'@$address[0]['town'];
  142.                 }
  143.             else {
  144.                 $checkVal array("name01""name02""kana01""kana02""zip01""zip02");
  145.                 foreach($checkVal as $key{
  146.                     unset($this->list_data[$key]);
  147.                 }
  148.             }
  149.             break;
  150.         case 'set2':
  151.             $this->arrErr $this->lfErrorCheck2($this->arrForm);
  152.             if (count($this->arrErr== && empty($_POST["return"])) {
  153.                 $this->tpl_mainpage = 'shopping/set2.tpl';
  154.             else {
  155.                 $this->tpl_mainpage = 'shopping/set1.tpl';
  156.  
  157.                 $checkVal array("pref""addr01""addr02""addr03""tel01""tel02""tel03");
  158.                 foreach($checkVal as $key{
  159.                     unset($this->list_data[$key]);
  160.                 }
  161.             }
  162.             break;
  163.         case 'complete':
  164.             $this->arrErr $this->lfErrorCheck($this->arrForm);
  165.             if (count($this->arrErr== 0{
  166.                 // 登録
  167.                 $other_deliv_id $this->lfRegistData($_POST,$arrRegistColumn$objCustomer);
  168.  
  169.                 // 登録済みの別のお届け先を受注一時テーブルに書き込む
  170.                 $this->lfRegistOtherDelivData($uniqid$objCustomer$other_deliv_id);
  171.  
  172.                 // 正常に登録されたことを記録しておく
  173.                 $objSiteSess->setRegistFlag();
  174.                 // お支払い方法選択ページへ移動
  175.                 $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_PAYMENT)true);
  176.                 exit;
  177.             else {
  178.                 SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR""false""true);
  179.             }
  180.             break;
  181.         default:
  182.             $deliv_count $objQuery->count("dtb_other_deliv""customer_id=?"array($objCustomer->getValue('customer_id')));
  183.             if ($deliv_count >= DELIV_ADDR_MAX){
  184.                 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG""false"最大登録件数を超えています。");
  185.             }
  186.         }
  187.  
  188.         $objView->assignobj($this);
  189.         $objView->display(SITE_FRAME);
  190.     }
  191.  
  192.     /* エラーチェック */
  193.     function lfErrorCheck({
  194.         $objErr new SC_CheckError();
  195.  
  196.         $objErr->doFunc(array("お名前(姓)"'name01'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  197.         $objErr->doFunc(array("お名前(名)"'name02'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK"));
  198.         $objErr->doFunc(array("お名前(カナ/姓)"'kana01'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK""KANA_CHECK"));
  199.         $objErr->doFunc(array("お名前(カナ/名)"'kana02'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK""KANA_CHECK"));
  200.         $objErr->doFunc(array("郵便番号1""zip01"ZIP01_LEN ,array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  201.         $objErr->doFunc(array("郵便番号2""zip02"ZIP02_LEN ,array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  202.         $objErr->doFunc(array("郵便番号""zip01""zip02")array("ALL_EXIST_CHECK"));
  203.         $objErr->doFunc(array("都道府県"'pref')array("SELECT_CHECK","NUM_CHECK"));
  204.         $objErr->doFunc(array("市区町村""addr01"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  205.         $objErr->doFunc(array("番地""addr02"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  206.         $objErr->doFunc(array("電話番号1"'tel01')array("EXIST_CHECK","NUM_CHECK"));
  207.         $objErr->doFunc(array("電話番号2"'tel02')array("EXIST_CHECK","NUM_CHECK"));
  208.         $objErr->doFunc(array("電話番号3"'tel03')array("EXIST_CHECK","NUM_CHECK"));
  209.         $objErr->doFunc(array("電話番号""tel01""tel02""tel03"TEL_LEN,array("TEL_CHECK"));
  210.         return $objErr->arrErr;
  211.  
  212.     }
  213.  
  214.     /* エラーチェック */
  215.     function lfErrorCheck1({
  216.         $objErr new SC_CheckError();
  217.  
  218.         $objErr->doFunc(array("お名前(姓)"'name01'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  219.         $objErr->doFunc(array("お名前(名)"'name02'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK"));
  220.         $objErr->doFunc(array("お名前(カナ/姓)"'kana01'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK""KANA_CHECK"));
  221.         $objErr->doFunc(array("お名前(カナ/名)"'kana02'STEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK""MAX_LENGTH_CHECK""KANA_CHECK"));
  222.         $objErr->doFunc(array("郵便番号1""zip01"ZIP01_LEN ,array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  223.         $objErr->doFunc(array("郵便番号2""zip02"ZIP02_LEN ,array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  224.         $objErr->doFunc(array("郵便番号""zip01""zip02")array("ALL_EXIST_CHECK"));
  225.         return $objErr->arrErr;
  226.  
  227.     }
  228.  
  229.     /* エラーチェック */
  230.     function lfErrorCheck2({
  231.         $objErr new SC_CheckError();
  232.  
  233.         $objErr->doFunc(array("都道府県"'pref')array("SELECT_CHECK","NUM_CHECK"));
  234.         $objErr->doFunc(array("市区町村""addr01"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  235.         $objErr->doFunc(array("番地""addr02"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  236.         $objErr->doFunc(array("電話番号1"'tel01')array("EXIST_CHECK","NUM_CHECK"));
  237.         $objErr->doFunc(array("電話番号2"'tel02')array("EXIST_CHECK","NUM_CHECK"));
  238.         $objErr->doFunc(array("電話番号3"'tel03')array("EXIST_CHECK","NUM_CHECK"));
  239.         $objErr->doFunc(array("電話番号""tel01""tel02""tel03"TEL_LEN,array("TEL_CHECK"));
  240.         return $objErr->arrErr;
  241.  
  242.     }
  243.  
  244.  
  245.  
  246.     /* 登録実行 */
  247.     function lfRegistData($array$arrRegistColumn&$objCustomer{
  248.  
  249.         $objConn new SC_DBConn();
  250.         foreach ($arrRegistColumn as $data{
  251.             if (strlen($array$data["column"] ]0{
  252.                 $arrRegist$data["column"] ] $array$data["column"] ];
  253.             }
  254.         }
  255.  
  256.         $arrRegist['customer_id'$objCustomer->getvalue('customer_id');
  257.  
  258.         //-- 編集登録実行
  259.         $objConn->query("BEGIN");
  260.         if ($array['other_deliv_id'!= ""){
  261.             $objConn->autoExecute("dtb_other_deliv"$arrRegist"other_deliv_id="  SC_Utils_Ex::sfQuoteSmart($array["other_deliv_id"]));
  262.         }else{
  263.             $objConn->autoExecute("dtb_other_deliv"$arrRegist);
  264.  
  265.             $sqlse "SELECT max(other_deliv_id) FROM dtb_other_deliv WHERE customer_id = ?";
  266.             $array['other_deliv_id'$objConn->getOne($sqlsearray($arrRegist['customer_id']));
  267.         }
  268.  
  269.         $objConn->query("COMMIT");
  270.  
  271.         return $array['other_deliv_id'];
  272.     }
  273.  
  274.     //---- 取得文字列の変換
  275.     function lfConvertParam($array$arrRegistColumn{
  276.         /*
  277.          *    文字列の変換
  278.          *    K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
  279.          *    C :  「全角ひら仮名」を「全角かた仮名」に変換
  280.          *    V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
  281.          *    n :  「全角」数字を「半角(ハンカク)」に変換
  282.          *  a :  全角英数字を半角英数字に変換する
  283.          */
  284.         // カラム名とコンバート情報
  285.         foreach ($arrRegistColumn as $data{
  286.             $arrConvList$data["column"] ] $data["convert"];
  287.         }
  288.  
  289.         // 文字変換
  290.         foreach ($arrConvList as $key => $val{
  291.             // POSTされてきた値のみ変換する。
  292.             if(strlen(($array[$key])) 0{
  293.                 $array[$keymb_convert_kana($array[$key,$val);
  294.             }
  295.         }
  296.         return $array;
  297.     }
  298.  
  299.     // 郵便番号から住所の取得
  300.     function lfGetAddress($zipcode{
  301.  
  302.         $conn new SC_DBconn(ZIP_DSN);
  303.  
  304.         // 郵便番号検索文作成
  305.         $zipcode mb_convert_kana($zipcode ,"n");
  306.         $sqlse "SELECT state, city, town FROM mtb_zip WHERE zipcode = ?";
  307.  
  308.         $data_list $conn->getAll($sqlsearray($zipcode));
  309.  
  310.         // インデックスと値を反転させる。
  311.         $arrREV_PREF array_flip($this->arrPref);
  312.  
  313.         /*
  314.           総務省からダウンロードしたデータをそのままインポートすると
  315.           以下のような文字列が入っているので    対策する。
  316.           ・(1・19丁目)
  317.           ・以下に掲載がない場合
  318.         */
  319.         $town =  $data_list[0]['town'];
  320.         $town ereg_replace("(.*)$","",$town);
  321.         $town ereg_replace("以下に掲載がない場合","",$town);
  322.         $data_list[0]['town'$town;
  323.         $data_list[0]['state'$arrREV_PREF[$data_list[0]['state']];
  324.  
  325.         return $data_list;
  326.     }
  327.  
  328.     /* 別のお届け先住所を一時受注テーブルへ */
  329.     function lfRegistOtherDelivData($uniqid$objCustomer$other_deliv_id{
  330.         // 登録データの作成
  331.         $sqlval['order_temp_id'$uniqid;
  332.         $sqlval['update_date''Now()';
  333.         $sqlval['customer_id'$objCustomer->getValue('customer_id');
  334.         $sqlval['order_birth'$objCustomer->getValue('birth');
  335.  
  336.         $objQuery new SC_Query();
  337.         $where "other_deliv_id = ?";
  338.         $arrRet $objQuery->select("*""dtb_other_deliv"$wherearray($other_deliv_id));
  339.  
  340.         $sqlval['deliv_check''1';
  341.         $sqlval['deliv_name01'$arrRet[0]['name01'];
  342.         $sqlval['deliv_name02'$arrRet[0]['name02'];
  343.         $sqlval['deliv_kana01'$arrRet[0]['kana01'];
  344.         $sqlval['deliv_kana02'$arrRet[0]['kana02'];
  345.         $sqlval['deliv_zip01'$arrRet[0]['zip01'];
  346.         $sqlval['deliv_zip02'$arrRet[0]['zip02'];
  347.         $sqlval['deliv_pref'$arrRet[0]['pref'];
  348.         $sqlval['deliv_addr01'$arrRet[0]['addr01'];
  349.         $sqlval['deliv_addr02'$arrRet[0]['addr02'];
  350.         $sqlval['deliv_tel01'$arrRet[0]['tel01'];
  351.         $sqlval['deliv_tel02'$arrRet[0]['tel02'];
  352.         $sqlval['deliv_tel03'$arrRet[0]['tel03'];
  353.         $objDb new SC_Helper_DB_Ex();
  354.         $objDb->sfRegistTempOrder($uniqid$sqlval);
  355.     }
  356.  
  357.     /**
  358.      * デストラクタ.
  359.      *
  360.      * @return void 
  361.      */
  362.     function destroy({
  363.         parent::destroy();
  364.     }
  365. }
  366. ?>

Documentation generated on Tue, 28 Apr 2009 18:12:57 +0900 by phpDocumentor 1.4.2