/PhpOnAzure.Web/data/class/pages/shopping/LC_Page_Shopping_Deliv.php
PHP | 223 lines | 112 code | 24 blank | 87 comment | 10 complexity | acb7231aca27fa824c90b9b4500c0370 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
- <?php
- /*
- * This file is part of EC-CUBE
- *
- * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
- *
- * http://www.lockon.co.jp/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- // {{{ requires
- require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
- /**
- * ??????? ???????.
- *
- * @package Page
- * @author LOCKON CO.,LTD.
- * @version $Id$
- */
- class LC_Page_Shopping_Deliv extends LC_Page_Ex {
- // }}}
- // {{{ functions
- /**
- * Page ??????.
- *
- * @return void
- */
- function init() {
- parent::init();
- $masterData = new SC_DB_MasterData();
- $this->arrPref = $masterData->getMasterData('mtb_pref');
- $this->tpl_title = "???????";
- $this->httpCacheControl('nocache');
- }
- /**
- * Page ?????.
- *
- * @return void
- */
- function process() {
- parent::process();
- $this->action();
- $this->sendResponse();
- }
- /**
- * Page ?????.
- *
- * @return void
- */
- function action() {
- $objSiteSess = new SC_SiteSession_Ex();
- $objCartSess = new SC_CartSession_Ex();
- $objCustomer = new SC_Customer_Ex();
- $objPurchase = new SC_Helper_Purchase_Ex();
- $objFormParam = new SC_FormParam_Ex();
- $objCookie = new SC_Cookie_Ex(COOKIE_EXPIRE);
- $this->tpl_uniqid = $objSiteSess->getUniqId();
- $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
- $this->cartKey = $objCartSess->getKey();
- // ????????
- if (!$objCustomer->isLoginSuccess(true)) {
- SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
- }
- // ??????????????????????
- if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
- $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
- $objPurchase->saveShippingTemp($sqlval);
- $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
- $objSiteSess->setRegistFlag();
- SC_Response_Ex::sendRedirect('payment.php');
- exit;
- }
- $this->lfInitParam($objFormParam);
- $objFormParam->setParam($_POST);
- $objFormParam->convParam();
- $arrErr = $objFormParam->checkError();
- if (!SC_Utils_Ex::isBlank($arrErr)) {
- SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
- exit;
- }
- $arrForm = $objFormParam->getHashArray();
- switch($this->getMode()) {
- // ??
- case 'delete':
- $this->doDelete($arrForm['other_deliv_id']);
- break;
- // ?????????
- case 'customer_addr':
- $objPurchase->unsetShippingTemp();
- if ($this->registerDeliv($arrForm['deliv_check'], $this->tpl_uniqid,
- $objPurchase, $objCustomer)) {
- $objSiteSess->setRegistFlag();
- SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
- exit;
- } else {
- SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
- }
- break;
- // ????????
- case 'return':
- // ????????
- SC_Response_Ex::sendRedirect(CART_URLPATH);
- exit;
- break;
- // ????????
- case 'multiple':
- SC_Response_Ex::sendRedirect('multiple.php');
- exit;
- break;
- }
- // ?????????
- $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
- $this->tpl_addrmax = count($this->arrAddr);
- }
- /**
- * ??????.
- *
- * @return void
- */
- function destroy() {
- parent::destroy();
- }
- /**
- * ???????????????.
- *
- * @param SC_FormParam $objFormParam SC_FormParam ??????
- * @return void
- */
- function lfInitParam(&$objFormParam) {
- $objFormParam->addParam("????????ID", "other_deliv_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
- $objFormParam->addParam("????????", "deliv_check", INT_LEN, 'n', array("MAX_LENGTH_CHECK"));
- }
- /**
- * ???????????????.
- *
- * @param integer $other_deliv_id ????????ID
- * @return void
- */
- function doDelete($other_deliv_id) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $where = "other_deliv_id = ?";
- $objQuery->delete("dtb_other_deliv", $where, array($other_deliv_id));
- }
- /**
- * ??????????????, ???????????.
- *
- * ?????????????????, ???????????????.
- * ?????????????????????, ???????????????????.
- * ????????????????? false ???.
- *
- * @param integer $deliv_check ????????
- * @param string $uniqid ?????????????ID
- * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase ??????
- * @param SC_Customer $objCustomer SC_Customer ??????
- * @return boolean ???????????????? true
- */
- function registerDeliv($deliv_check, $uniqid, &$objPurchase, &$objCustomer) {
- $this->log("register deliv. deliv_check=" . $deliv_check, "Debug");
- $arrValues = array();
- // ??????????????????
- if ($deliv_check == '-1') {
- $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
- $objPurchase->saveShippingTemp($arrValues);
- $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
- return true;
- }
- // ??????????????????
- elseif ($deliv_check >= 1) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $arrOtherDeliv = $objQuery->getRow("*", "dtb_other_deliv",
- "customer_id = ? AND other_deliv_id = ?",
- array($objCustomer->getValue('customer_id'), $deliv_check));
- if (SC_Utils_Ex::isBlank($arrOtherDeliv)) {
- return false;
- }
- $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
- $objPurchase->saveShippingTemp($arrValues);
- $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
- return true;
- }
- // ??????????????
- else {
- return false;
- }
- }
- }
- ?>