PageRenderTime 35ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/PhpOnAzure.Web/data/class/pages/shopping/LC_Page_Shopping_Deliv.php

http://eccubeonwaz.codeplex.com
PHP | 223 lines | 112 code | 24 blank | 87 comment | 10 complexity | acb7231aca27fa824c90b9b4500c0370 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  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. // {{{ requires
  24. require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
  25. /**
  26. * ??????? ???????.
  27. *
  28. * @package Page
  29. * @author LOCKON CO.,LTD.
  30. * @version $Id$
  31. */
  32. class LC_Page_Shopping_Deliv extends LC_Page_Ex {
  33. // }}}
  34. // {{{ functions
  35. /**
  36. * Page ??????.
  37. *
  38. * @return void
  39. */
  40. function init() {
  41. parent::init();
  42. $masterData = new SC_DB_MasterData();
  43. $this->arrPref = $masterData->getMasterData('mtb_pref');
  44. $this->tpl_title = "???????";
  45. $this->httpCacheControl('nocache');
  46. }
  47. /**
  48. * Page ?????.
  49. *
  50. * @return void
  51. */
  52. function process() {
  53. parent::process();
  54. $this->action();
  55. $this->sendResponse();
  56. }
  57. /**
  58. * Page ?????.
  59. *
  60. * @return void
  61. */
  62. function action() {
  63. $objSiteSess = new SC_SiteSession_Ex();
  64. $objCartSess = new SC_CartSession_Ex();
  65. $objCustomer = new SC_Customer_Ex();
  66. $objPurchase = new SC_Helper_Purchase_Ex();
  67. $objFormParam = new SC_FormParam_Ex();
  68. $objCookie = new SC_Cookie_Ex(COOKIE_EXPIRE);
  69. $this->tpl_uniqid = $objSiteSess->getUniqId();
  70. $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
  71. $this->cartKey = $objCartSess->getKey();
  72. // ????????
  73. if (!$objCustomer->isLoginSuccess(true)) {
  74. SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
  75. }
  76. // ??????????????????????
  77. if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
  78. $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
  79. $objPurchase->saveShippingTemp($sqlval);
  80. $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
  81. $objSiteSess->setRegistFlag();
  82. SC_Response_Ex::sendRedirect('payment.php');
  83. exit;
  84. }
  85. $this->lfInitParam($objFormParam);
  86. $objFormParam->setParam($_POST);
  87. $objFormParam->convParam();
  88. $arrErr = $objFormParam->checkError();
  89. if (!SC_Utils_Ex::isBlank($arrErr)) {
  90. SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
  91. exit;
  92. }
  93. $arrForm = $objFormParam->getHashArray();
  94. switch($this->getMode()) {
  95. // ??
  96. case 'delete':
  97. $this->doDelete($arrForm['other_deliv_id']);
  98. break;
  99. // ?????????
  100. case 'customer_addr':
  101. $objPurchase->unsetShippingTemp();
  102. if ($this->registerDeliv($arrForm['deliv_check'], $this->tpl_uniqid,
  103. $objPurchase, $objCustomer)) {
  104. $objSiteSess->setRegistFlag();
  105. SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
  106. exit;
  107. } else {
  108. SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
  109. }
  110. break;
  111. // ????????
  112. case 'return':
  113. // ????????
  114. SC_Response_Ex::sendRedirect(CART_URLPATH);
  115. exit;
  116. break;
  117. // ????????
  118. case 'multiple':
  119. SC_Response_Ex::sendRedirect('multiple.php');
  120. exit;
  121. break;
  122. }
  123. // ?????????
  124. $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
  125. $this->tpl_addrmax = count($this->arrAddr);
  126. }
  127. /**
  128. * ??????.
  129. *
  130. * @return void
  131. */
  132. function destroy() {
  133. parent::destroy();
  134. }
  135. /**
  136. * ???????????????.
  137. *
  138. * @param SC_FormParam $objFormParam SC_FormParam ??????
  139. * @return void
  140. */
  141. function lfInitParam(&$objFormParam) {
  142. $objFormParam->addParam("????????ID", "other_deliv_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
  143. $objFormParam->addParam("????????", "deliv_check", INT_LEN, 'n', array("MAX_LENGTH_CHECK"));
  144. }
  145. /**
  146. * ???????????????.
  147. *
  148. * @param integer $other_deliv_id ????????ID
  149. * @return void
  150. */
  151. function doDelete($other_deliv_id) {
  152. $objQuery =& SC_Query_Ex::getSingletonInstance();
  153. $where = "other_deliv_id = ?";
  154. $objQuery->delete("dtb_other_deliv", $where, array($other_deliv_id));
  155. }
  156. /**
  157. * ??????????????, ???????????.
  158. *
  159. * ?????????????????, ???????????????.
  160. * ?????????????????????, ???????????????????.
  161. * ????????????????? false ???.
  162. *
  163. * @param integer $deliv_check ????????
  164. * @param string $uniqid ?????????????ID
  165. * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase ??????
  166. * @param SC_Customer $objCustomer SC_Customer ??????
  167. * @return boolean ???????????????? true
  168. */
  169. function registerDeliv($deliv_check, $uniqid, &$objPurchase, &$objCustomer) {
  170. $this->log("register deliv. deliv_check=" . $deliv_check, "Debug");
  171. $arrValues = array();
  172. // ??????????????????
  173. if ($deliv_check == '-1') {
  174. $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
  175. $objPurchase->saveShippingTemp($arrValues);
  176. $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
  177. return true;
  178. }
  179. // ??????????????????
  180. elseif ($deliv_check >= 1) {
  181. $objQuery =& SC_Query_Ex::getSingletonInstance();
  182. $arrOtherDeliv = $objQuery->getRow("*", "dtb_other_deliv",
  183. "customer_id = ? AND other_deliv_id = ?",
  184. array($objCustomer->getValue('customer_id'), $deliv_check));
  185. if (SC_Utils_Ex::isBlank($arrOtherDeliv)) {
  186. return false;
  187. }
  188. $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
  189. $objPurchase->saveShippingTemp($arrValues);
  190. $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
  191. return true;
  192. }
  193. // ??????????????
  194. else {
  195. return false;
  196. }
  197. }
  198. }
  199. ?>