Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Shopping_Deliv.php

Documentation is available at LC_Page_Shopping_Deliv.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 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_EX_REALDIR 'page_extends/LC_Page_Ex.php';
  26.  
  27. /**
  28.  * お届け先の指定 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Shopping_Deliv.php 21190 2011-08-15 02:37:23Z shutta $
  33.  */
  34. class LC_Page_Shopping_Deliv extends LC_Page_Ex {
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init({
  45.         parent::init();
  46.         $masterData new SC_DB_MasterData();
  47.         $this->arrPref $masterData->getMasterData('mtb_pref');
  48.         $this->tpl_title "お届け先の指定";
  49.         $this->httpCacheControl('nocache');
  50.     }
  51.  
  52.     /**
  53.      * Page のプロセス.
  54.      *
  55.      * @return void 
  56.      */
  57.     function process({
  58.         parent::process();
  59.         $this->action();
  60.         $this->sendResponse();
  61.     }
  62.  
  63.     /**
  64.      * Page のプロセス.
  65.      *
  66.      * @return void 
  67.      */
  68.     function action({
  69.         $objSiteSess new SC_SiteSession_Ex();
  70.         $objCartSess new SC_CartSession_Ex();
  71.         $objCustomer new SC_Customer_Ex();
  72.         $objPurchase new SC_Helper_Purchase_Ex();
  73.         $objFormParam new SC_FormParam_Ex();
  74.         $objCookie new SC_Cookie_Ex(COOKIE_EXPIRE);
  75.  
  76.         $this->tpl_uniqid $objSiteSess->getUniqId();
  77.         $objPurchase->verifyChangeCart($this->tpl_uniqid$objCartSess);
  78.  
  79.         $this->cartKey $objCartSess->getKey();
  80.  
  81.         // ログインチェック
  82.         if (!$objCustomer->isLoginSuccess(true)) {
  83.             SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  84.         }
  85.  
  86.         // ダウンロード商品の場合は、支払方法画面に転送
  87.         if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD{
  88.             $objPurchase->copyFromCustomer($sqlval$objCustomer'shipping');
  89.             $objPurchase->saveShippingTemp($sqlval);
  90.             $objPurchase->saveOrderTemp($this->tpl_uniqid$sqlval$objCustomer);
  91.             $objSiteSess->setRegistFlag();
  92.             SC_Response_Ex::sendRedirect('payment.php');
  93.             exit;
  94.         }
  95.  
  96.         $this->lfInitParam($objFormParam);
  97.         $objFormParam->setParam($_POST);
  98.         $objFormParam->convParam();
  99.         $arrErr $objFormParam->checkError();
  100.         if (!SC_Utils_Ex::isBlank($arrErr)) {
  101.             SC_Utils_Ex::sfDispSiteError(PAGE_ERROR""true);
  102.             exit;
  103.         }
  104.  
  105.         $arrForm $objFormParam->getHashArray();
  106.  
  107.         switch($this->getMode()) {
  108.         // 削除
  109.         case 'delete':
  110.             $this->doDelete($arrForm['other_deliv_id']);
  111.             break;
  112.  
  113.         // 会員登録住所に送る
  114.         case 'customer_addr':
  115.             $objPurchase->unsetShippingTemp();
  116.  
  117.             if ($this->registerDeliv($arrForm['deliv_check']$this->tpl_uniqid,
  118.                                      $objPurchase$objCustomer)) {
  119.                 $objSiteSess->setRegistFlag();
  120.                 SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
  121.                 exit;
  122.  
  123.             else {
  124.                 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR""true);
  125.             }
  126.             break;
  127.  
  128.         // 前のページに戻る
  129.         case 'return':
  130.             // 確認ページへ移動
  131.             SC_Response_Ex::sendRedirect(CART_URLPATH);
  132.             exit;
  133.             break;
  134.  
  135.         // お届け先複数指定
  136.         case 'multiple':
  137.             SC_Response_Ex::sendRedirect('multiple.php');
  138.             exit;
  139.             break;
  140.         }
  141.  
  142.         // 登録済み住所を取得
  143.         $this->arrAddr $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
  144.         $this->tpl_addrmax count($this->arrAddr);
  145.     }
  146.  
  147.     /**
  148.      * デストラクタ.
  149.      *
  150.      * @return void 
  151.      */
  152.     function destroy({
  153.         parent::destroy();
  154.     }
  155.  
  156.     /**
  157.      * パラメーター情報の初期化を行う.
  158.      *
  159.      * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  160.      * @return void 
  161.      */
  162.     function lfInitParam(&$objFormParam{
  163.         $objFormParam->addParam("その他のお届け先ID""other_deliv_id"INT_LEN'n'array("NUM_CHECK""MAX_LENGTH_CHECK"));
  164.         $objFormParam->addParam("お届け先チェック""deliv_check"INT_LEN'n'array("MAX_LENGTH_CHECK"));
  165.     }
  166.  
  167.     /**
  168.      * その他のお届け先情報を削除する.
  169.      *
  170.      * @param integer $other_deliv_id その他のお届け先ID
  171.      * @return void 
  172.      */
  173.     function doDelete($other_deliv_id{
  174.         $objQuery =SC_Query_Ex::getSingletonInstance();
  175.         $where "other_deliv_id = ?";
  176.         $objQuery->delete("dtb_other_deliv"$wherearray($other_deliv_id));
  177.     }
  178.  
  179.     /**
  180.      * お届け先チェックの値に応じて, お届け先情報を保存する.
  181.      *
  182.      * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
  183.      * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
  184.      * お届け先チェックの値が不正な場合は false を返す.
  185.      *
  186.      * @param integer $deliv_check お届け先チェック
  187.      * @param string $uniqid 受注一時テーブルのユニークID
  188.      * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
  189.      * @param SC_Customer $objCustomer SC_Customer インスタンス
  190.      * @return boolean お届け先チェックの値が妥当な場合 true
  191.      */
  192.     function registerDeliv($deliv_check$uniqid&$objPurchase&$objCustomer{
  193.         $this->log("register deliv. deliv_check=" $deliv_check"Debug");
  194.         $arrValues array();
  195.         // 会員登録住所がチェックされている場合
  196.         if ($deliv_check == '-1'{
  197.             $objPurchase->copyFromCustomer($arrValues$objCustomer'shipping');
  198.             $objPurchase->saveShippingTemp($arrValues);
  199.             $objPurchase->saveOrderTemp($uniqid$arrValues$objCustomer);
  200.             return true;
  201.         }
  202.         // 別のお届け先がチェックされている場合
  203.         elseif ($deliv_check >= 1{
  204.             $objQuery =SC_Query_Ex::getSingletonInstance();
  205.             $arrOtherDeliv $objQuery->getRow("*""dtb_other_deliv",
  206.                                                "customer_id = ? AND other_deliv_id = ?",
  207.                                                array($objCustomer->getValue('customer_id')$deliv_check));
  208.             if (SC_Utils_Ex::isBlank($arrOtherDeliv)) {
  209.                 return false;
  210.             }
  211.  
  212.             $objPurchase->copyFromOrder($arrValues$arrOtherDeliv'shipping''');
  213.             $objPurchase->saveShippingTemp($arrValues);
  214.             $objPurchase->saveOrderTemp($uniqid$arrValues$objCustomer);
  215.             return true;
  216.         }
  217.         // お届け先チェックが不正な場合
  218.         else {
  219.             return false;
  220.         }
  221.     }
  222. }
  223. ?>

Documentation generated on Fri, 24 Feb 2012 14:02:18 +0900 by Seasoft