Source for file LC_Page_Shopping.php

Documentation is available at LC_Page_Shopping.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.php 15532 2007-08-31 14:39:46Z nanasess $
  33.  */
  34. class LC_Page_Shopping extends LC_Page {
  35.  
  36.     // {{{ properties
  37.  
  38.     /** フォームパラメータ */
  39.     var $objFormParam;
  40.  
  41.     /** 年 */
  42.     var $year;
  43.  
  44.     // }}}
  45.     // {{{ functions
  46.  
  47.     /**
  48.      * Page を初期化する.
  49.      *
  50.      * @return void 
  51.      */
  52.     function init({
  53.         parent::init();
  54.         $this->tpl_mainpage = 'shopping/index.tpl';
  55.         $this->tpl_column_num = 1;
  56.         $this->tpl_title = 'ログイン';
  57.         $masterData new SC_DB_MasterData();
  58.         $this->arrPref $masterData->getMasterData("mtb_pref"array("pref_id""pref_name""rank"));
  59.         $this->arrSex $masterData->getMasterData("mtb_sex");
  60.         $this->arrJob $masterData->getMasterData("mtb_job");
  61.         $this->tpl_onload = 'fnCheckInputDeliv();';
  62.         $this->allowClientCache();
  63.     }
  64.  
  65.     /**
  66.      * Page のプロセス.
  67.      *
  68.      * @return void 
  69.      */
  70.     function process({
  71.         global $objCampaignSess;
  72.  
  73.         $conn new SC_DBConn();
  74.         $objView new SC_SiteView();
  75.         $objSiteSess new SC_SiteSession();
  76.         $objCartSess new SC_CartSession();
  77.         $objCampaignSess new SC_CampaignSession();
  78.         $objCustomer new SC_Customer();
  79.         $objCookie new SC_Cookie();
  80.         $this->objFormParam = new SC_FormParam();            // フォーム用
  81.         $this->lfInitParam();                                // パラメータ情報の初期化
  82.         $this->objFormParam->setParam($_POST);            // POST値の取得
  83.  
  84.         // ユーザユニークIDの取得と購入状態の正当性をチェック
  85.         $uniqid SC_Utils_Ex::sfCheckNormalAccess($objSiteSess$objCartSess);
  86.         $this->tpl_uniqid $uniqid;
  87.  
  88.         // ログインチェック
  89.         if($objCustomer->isLoginSuccess()) {
  90.             // すでにログインされている場合は、お届け先設定画面に転送
  91.             $this->sendRedirect($this->getLocation("./deliv.php")array());
  92.             exit;
  93.         }
  94.  
  95.         if ($_SERVER["REQUEST_METHOD"== "POST"{
  96.             if (!$this->isValidToken()) {
  97.                 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR""true);
  98.             }
  99.         }
  100.  
  101.         if (!isset($_POST['mode'])) $_POST['mode'"";
  102.  
  103.         switch($_POST['mode']{
  104.         case 'nonmember_confirm':
  105.             $this->lfSetNonMember($this);
  106.             // ※breakなし
  107.         case 'confirm':
  108.             // 入力値の変換
  109.             $this->objFormParam->convParam();
  110.             $this->objFormParam->toLower('order_mail');
  111.             $this->objFormParam->toLower('order_mail_check');
  112.  
  113.             $this->arrErr $this->lfCheckError();
  114.  
  115.             // 入力エラーなし
  116.             if(count($this->arrErr== 0{
  117.                 // DBへのデータ登録
  118.                 $this->lfRegistData($uniqid);
  119.  
  120.                 // お届け先のコピー
  121.                 $this->lfCopyDeliv($uniqid$_POST);
  122.  
  123.                 // 正常に登録されたことを記録しておく
  124.                 $objSiteSess->setRegistFlag();
  125.                 // お支払い方法選択ページへ移動
  126.                 $this->sendRedirect($this->getLocation(URL_SHOP_PAYMENT));
  127.                 exit;
  128.             }
  129.  
  130.             break;
  131.         // 前のページに戻る
  132.         case 'return':
  133.             // 確認ページへ移動
  134.             $this->sendRedirect($this->getLocation(URL_CART_TOP));
  135.             exit;
  136.             break;
  137.         case 'nonmember':
  138.             $this->lfSetNonMember($this);
  139.             // ※breakなし
  140.         default:
  141.             if(isset($_GET['from']&& $_GET['from'== 'nonmember'{
  142.                 $this->lfSetNonMember($this);
  143.             }
  144.             // ユーザユニークIDの取得
  145.             $uniqid $objSiteSess->getUniqId();
  146.             $objQuery new SC_Query();
  147.             $where "order_temp_id = ?";
  148.             $arrRet $objQuery->select("*""dtb_order_temp"$wherearray($uniqid));
  149.             if (empty($arrRet)) $arrRet array(
  150.                                                 array('order_email' => "",
  151.                                                       'order_birth' => ""));
  152.  
  153.             // DB値の取得
  154.             $this->objFormParam->setParam($arrRet[0]);
  155.             $this->objFormParam->setValue('order_email02'$arrRet[0]['order_email']);
  156.             $this->objFormParam->setDBDate($arrRet[0]['order_birth']);
  157.             break;
  158.         }
  159.  
  160.         // クッキー判定
  161.         $this->tpl_login_email = $objCookie->getCookie('login_email');
  162.         if($this->tpl_login_email != ""{
  163.             $this->tpl_login_memory "1";
  164.         }
  165.  
  166.         // 生年月日選択肢の取得
  167.         $objDate new SC_Date(START_BIRTH_YEARdate("Y",strtotime("now")));
  168.         $this->arrYear $objDate->getYear(''1950'');
  169.         $this->arrMonth $objDate->getMonth(true);
  170.         $this->arrDay $objDate->getDay(true);
  171.  
  172.         // 入力値の取得
  173.         $this->arrForm $this->objFormParam->getFormParamList();
  174.  
  175.         $this->transactionid = $this->getToken();
  176.         $objView->assignobj($this);
  177.         // フレームを選択(キャンペーンページから遷移なら変更)
  178.         $objCampaignSess->pageView($objView);
  179.     }
  180.  
  181.     /**
  182.      * モバイルページを初期化する.
  183.      *
  184.      * @return void 
  185.      */
  186.     function mobileInit({
  187.         $this->init();
  188.         $this->tpl_mainpage = MOBILE_TEMPLATE_DIR 'shopping/index.tpl';
  189.     }
  190.  
  191.     /**
  192.      * Page のプロセス(モバイル).
  193.      *
  194.      * @return void 
  195.      */
  196.     function mobileProcess({
  197.         $conn new SC_DBConn();
  198.         $objView new SC_MobileView();
  199.         $objSiteSess new SC_SiteSession();
  200.         $objCartSess new SC_CartSession();
  201.         $objCustomer new SC_Customer();
  202.         $objCookie new SC_Cookie();
  203.         $this->objFormParam = new SC_FormParam();            // フォーム用
  204.         $helperMobile new SC_Helper_Mobile_Ex();
  205.         $this->lfInitParam();                                // パラメータ情報の初期化
  206.         $this->objFormParam->setParam($_POST);            // POST値の取得
  207.  
  208.         // ユーザユニークIDの取得と購入状態の正当性をチェック
  209.         $uniqid SC_Utils_Ex::sfCheckNormalAccess($objSiteSess$objCartSess);
  210.  
  211.         $this->tpl_uniqid $uniqid;
  212.  
  213.         // ログインチェック
  214.         if($objCustomer->isLoginSuccess(true)) {
  215.             // すでにログインされている場合は、お届け先設定画面に転送
  216.             $this->sendRedirect($this->getLocation('./deliv.php')true);
  217.             exit;
  218.         }
  219.  
  220.         // 携帯端末IDが一致する会員が存在するかどうかをチェックする。
  221.         $this->tpl_valid_phone_id $objCustomer->checkMobilePhoneId();
  222.  
  223.         // クッキー判定
  224.         $this->tpl_login_email = $objCookie->getCookie('login_email');
  225.         if($this->tpl_login_email != ""{
  226.             $this->tpl_login_memory "1";
  227.         }
  228.  
  229.         $objView->assignobj($this);
  230.         $objView->display(SITE_FRAME);
  231.     }
  232.  
  233.     /**
  234.      * デストラクタ.
  235.      *
  236.      * @return void 
  237.      */
  238.     function destroy({
  239.         parent::destroy();
  240.     }
  241.  
  242.     /* 非会員入力ページのセット */
  243.     function lfSetNonMember(&$objPage{
  244.         $objPage->tpl_mainpage 'shopping/nonmember_input.tpl';
  245.         $this->tpl_title = 'お客様情報入力';
  246.     }
  247.  
  248.     /* パラメータ情報の初期化 */
  249.     function lfInitParam({
  250.         $this->objFormParam->addParam("お名前(姓)""order_name01"STEXT_LEN"KVa"array("EXIST_CHECK""SPTAB_CHECK""MAX_LENGTH_CHECK"));
  251.         $this->objFormParam->addParam("お名前(名)""order_name02"STEXT_LEN"KVa"array("EXIST_CHECK""SPTAB_CHECK""MAX_LENGTH_CHECK"));
  252.         $this->objFormParam->addParam("フリガナ(セイ)""order_kana01"STEXT_LEN"KVCa"array("EXIST_CHECK""SPTAB_CHECK""MAX_LENGTH_CHECK"));
  253.         $this->objFormParam->addParam("フリガナ(メイ)""order_kana02"STEXT_LEN"KVCa"array("EXIST_CHECK""SPTAB_CHECK""MAX_LENGTH_CHECK"));
  254.         $this->objFormParam->addParam("郵便番号1""order_zip01"ZIP01_LEN"n"array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  255.         $this->objFormParam->addParam("郵便番号2""order_zip02"ZIP02_LEN"n"array("EXIST_CHECK""NUM_CHECK""NUM_COUNT_CHECK"));
  256.         $this->objFormParam->addParam("都道府県""order_pref"INT_LEN"n"array("EXIST_CHECK""MAX_LENGTH_CHECK""NUM_CHECK"));
  257.         $this->objFormParam->addParam("住所1""order_addr01"STEXT_LEN"KVa"array("EXIST_CHECK""SPTAB_CHECK""MAX_LENGTH_CHECK"));
  258.         $this->objFormParam->addParam("住所2""order_addr02"STEXT_LEN"KVa"array("EXIST_CHECK""SPTAB_CHECK""MAX_LENGTH_CHECK"));
  259.         $this->objFormParam->addParam("電話番号1""order_tel01"TEL_ITEM_LEN"n"array("EXIST_CHECK""MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  260.         $this->objFormParam->addParam("電話番号2""order_tel02"TEL_ITEM_LEN"n"array("EXIST_CHECK""MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  261.         $this->objFormParam->addParam("電話番号3""order_tel03"TEL_ITEM_LEN"n"array("EXIST_CHECK""MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  262.         $this->objFormParam->addParam("FAX番号1""order_fax01"TEL_ITEM_LEN"n"array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  263.         $this->objFormParam->addParam("FAX番号2""order_fax02"TEL_ITEM_LEN"n"array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  264.         $this->objFormParam->addParam("FAX番号3""order_fax03"TEL_ITEM_LEN"n"array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  265.         $this->objFormParam->addParam("メールアドレス""order_email"STEXT_LEN"KVa"array("EXIST_CHECK""SPTAB_CHECK""NO_SPTAB""MAX_LENGTH_CHECK""EMAIL_CHECK""EMAIL_CHAR_CHECK"));
  266.         $this->objFormParam->addParam("メールアドレス(確認)""order_email02"STEXT_LEN"KVa"array("EXIST_CHECK""SPTAB_CHECK""NO_SPTAB""MAX_LENGTH_CHECK""EMAIL_CHECK""EMAIL_CHAR_CHECK")""false);
  267.         $this->objFormParam->addParam("年""year"INT_LEN"n"array("MAX_LENGTH_CHECK")""false);
  268.         $this->objFormParam->addParam("月""month"INT_LEN"n"array("MAX_LENGTH_CHECK")""false);
  269.         $this->objFormParam->addParam("日""day"INT_LEN"n"array("MAX_LENGTH_CHECK")""false);
  270.         $this->objFormParam->addParam("性別""order_sex"INT_LEN"n"array("EXIST_CHECK""MAX_LENGTH_CHECK""NUM_CHECK"));
  271.         $this->objFormParam->addParam("職業""order_job"INT_LEN"n"array("MAX_LENGTH_CHECK""NUM_CHECK"));
  272.         $this->objFormParam->addParam("別のお届け先""deliv_check"INT_LEN"n"array("MAX_LENGTH_CHECK""NUM_CHECK"));
  273.         $this->objFormParam->addParam("お名前(姓)""deliv_name01"STEXT_LEN"KVa"array("SPTAB_CHECK""MAX_LENGTH_CHECK"));
  274.         $this->objFormParam->addParam("お名前(名)""deliv_name02"STEXT_LEN"KVa"array("SPTAB_CHECK""MAX_LENGTH_CHECK"));
  275.         $this->objFormParam->addParam("フリガナ(セイ)""deliv_kana01"STEXT_LEN"KVCa"array("SPTAB_CHECK""MAX_LENGTH_CHECK"));
  276.         $this->objFormParam->addParam("フリガナ(メイ)""deliv_kana02"STEXT_LEN"KVCa"array("SPTAB_CHECK""MAX_LENGTH_CHECK"));
  277.         $this->objFormParam->addParam("郵便番号1""deliv_zip01"ZIP01_LEN"n"array("NUM_CHECK""NUM_COUNT_CHECK"));
  278.         $this->objFormParam->addParam("郵便番号2""deliv_zip02"ZIP02_LEN"n"array("NUM_CHECK""NUM_COUNT_CHECK"));
  279.         $this->objFormParam->addParam("都道府県""deliv_pref"INT_LEN"n"array("MAX_LENGTH_CHECK""NUM_CHECK"));
  280.         $this->objFormParam->addParam("住所1""deliv_addr01"STEXT_LEN"KVa"array("SPTAB_CHECK""MAX_LENGTH_CHECK"));
  281.         $this->objFormParam->addParam("住所2""deliv_addr02"STEXT_LEN"KVa"array("SPTAB_CHECK""MAX_LENGTH_CHECK"));
  282.         $this->objFormParam->addParam("電話番号1""deliv_tel01"TEL_ITEM_LEN"n"array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  283.         $this->objFormParam->addParam("電話番号2""deliv_tel02"TEL_ITEM_LEN"n"array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  284.         $this->objFormParam->addParam("電話番号3""deliv_tel03"TEL_ITEM_LEN"n"array("MAX_LENGTH_CHECK" ,"NUM_CHECK"));
  285.         $this->objFormParam->addParam("メールマガジン""mail_flag"INT_LEN"n"array("MAX_LENGTH_CHECK""NUM_CHECK")1);
  286.     }
  287.  
  288.     /* DBへデータの登録 */
  289.     function lfRegistData($uniqid{
  290.         $arrRet $this->objFormParam->getHashArray();
  291.         $sqlval $this->objFormParam->getDbArray();
  292.         // 登録データの作成
  293.         $sqlval['order_temp_id'$uniqid;
  294.         $sqlval['order_birth'SC_Utils_Ex::sfGetTimestamp($arrRet['year']$arrRet['month']$arrRet['day']);
  295.         $sqlval['update_date''Now()';
  296.         $sqlval['customer_id''0';
  297.  
  298.         // 既存データのチェック
  299.         $objQuery new SC_Query();
  300.         $where "order_temp_id = ?";
  301.         $cnt $objQuery->count("dtb_order_temp"$wherearray($uniqid));
  302.         // 既存データがない場合
  303.         if ($cnt == 0{
  304.             $sqlval['create_date''Now()';
  305.             $objQuery->insert("dtb_order_temp"$sqlval);
  306.         else {
  307.             $objQuery->update("dtb_order_temp"$sqlval$wherearray($uniqid));
  308.         }
  309.  
  310.     }
  311.  
  312.     /* 入力内容のチェック */
  313.     function lfCheckError({
  314.         // 入力データを渡す。
  315.         $arrRet $this->objFormParam->getHashArray();
  316.         $objErr new SC_CheckError($arrRet);
  317.         $objErr->arrErr $this->objFormParam->checkError();
  318.  
  319.         // 別のお届け先チェック
  320.         if(isset($_POST['deliv_check']&& $_POST['deliv_check'== "1"{
  321.             $objErr->doFunc(array("お名前(姓)""deliv_name01")array("EXIST_CHECK"));
  322.             $objErr->doFunc(array("お名前(名)""deliv_name02")array("EXIST_CHECK"));
  323.             $objErr->doFunc(array("フリガナ(セイ)""deliv_kana01")array("EXIST_CHECK"));
  324.             $objErr->doFunc(array("フリガナ(メイ)""deliv_kana02")array("EXIST_CHECK"));
  325.             $objErr->doFunc(array("郵便番号1""deliv_zip01")array("EXIST_CHECK"));
  326.             $objErr->doFunc(array("郵便番号2""deliv_zip02")array("EXIST_CHECK"));
  327.             $objErr->doFunc(array("都道府県""deliv_pref")array("EXIST_CHECK"));
  328.             $objErr->doFunc(array("住所1""deliv_addr01")array("EXIST_CHECK"));
  329.             $objErr->doFunc(array("住所2""deliv_addr02")array("EXIST_CHECK"));
  330.             $objErr->doFunc(array("電話番号1""deliv_tel01")array("EXIST_CHECK"));
  331.             $objErr->doFunc(array("電話番号2""deliv_tel02")array("EXIST_CHECK"));
  332.             $objErr->doFunc(array("電話番号3""deliv_tel03")array("EXIST_CHECK"));
  333.         }
  334.  
  335.         // 複数項目チェック
  336.         $objErr->doFunc(array("TEL""order_tel01""order_tel02""order_tel03"TEL_ITEM_LEN)array("TEL_CHECK"));
  337.         $objErr->doFunc(array("FAX""order_fax01""order_fax02""order_fax03"TEL_ITEM_LEN)array("TEL_CHECK"));
  338.         $objErr->doFunc(array("郵便番号""order_zip01""order_zip02")array("ALL_EXIST_CHECK"));
  339.         $objErr->doFunc(array("TEL""deliv_tel01""deliv_tel02""deliv_tel03"TEL_ITEM_LEN)array("TEL_CHECK"));
  340.         $objErr->doFunc(array("FAX""deliv_fax01""deliv_fax02""deliv_fax03"TEL_ITEM_LEN)array("TEL_CHECK"));
  341.         $objErr->doFunc(array("郵便番号""deliv_zip01""deliv_zip02")array("ALL_EXIST_CHECK"));
  342.         $objErr->doFunc(array("生年月日""year""month""day")array("CHECK_BIRTHDAY"));
  343.         $objErr->doFunc(array("メールアドレス""メールアドレス(確認)""order_email""order_email02")array("EQUAL_CHECK"));
  344.  
  345.         return $objErr->arrErr;
  346.     }
  347.  
  348.     // 受注一時テーブルのお届け先をコピーする
  349.     function lfCopyDeliv($uniqid$arrData{
  350.         $objQuery new SC_Query();
  351.  
  352.         // 別のお届け先を指定していない場合、配送先に登録住所をコピーする。
  353.         if($arrData["deliv_check"!= "1"{
  354.             $sqlval['deliv_name01'$arrData['order_name01'];
  355.             $sqlval['deliv_name02'$arrData['order_name02'];
  356.             $sqlval['deliv_kana01'$arrData['order_kana01'];
  357.             $sqlval['deliv_kana02'$arrData['order_kana02'];
  358.             $sqlval['deliv_pref'$arrData['order_pref'];
  359.             $sqlval['deliv_zip01'$arrData['order_zip01'];
  360.             $sqlval['deliv_zip02'$arrData['order_zip02'];
  361.             $sqlval['deliv_addr01'$arrData['order_addr01'];
  362.             $sqlval['deliv_addr02'$arrData['order_addr02'];
  363.             $sqlval['deliv_tel01'$arrData['order_tel01'];
  364.             $sqlval['deliv_tel02'$arrData['order_tel02'];
  365.             $sqlval['deliv_tel03'$arrData['order_tel03'];
  366.             $where "order_temp_id = ?";
  367.             $objQuery->update("dtb_order_temp"$sqlval$wherearray($uniqid));
  368.         }
  369.     }
  370. }
  371. ?>

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