Changeset 20072
- Timestamp:
- 2011/02/02 22:23:30 (13 years ago)
- bzr:base-revision:
- ohkouchi@loop-az.jp-20110202115525-9evoy1y4rcpgsrr5
- bzr:committer:
- Kentaro Ohkouchi <ohkouchi@loop-az.jp>
- bzr:file-ids:
data/class/pages/shopping/LC_Page_Shopping_Multiple.php lc_page_shopping_mul-20110109122547-u3fq5xmi1b4jn5n4-2- bzr:mapping-version:
- v4
- bzr:merge:
ohkouchi@loop-az.jp-20110202132209-n26h48j46zrl35rt- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- ohkouchi@loop-az.jp-20110202132320-fl3fzc278nuak5xx
- bzr:revno:
- 2800
- bzr:revprop:branch-nick:
- branches/version-2_5-dev
- bzr:root:
- branches/version-2_5-dev
- bzr:text-revisions:
data/class/pages/shopping/LC_Page_Shopping_Multiple.php ohkouchi@loop-az.jp-20110202132209-n26h48j46zrl35rt- bzr:timestamp:
- 2011-02-02 22:23:20.190999985 +0900
- bzr:user-agent:
- bzr2.2.1+bzr-svn1.0.4
- svn:original-date:
- 2011-02-02T13:23:20.191000Z
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Multiple.php
r20041 r20072 44 44 function init() { 45 45 parent::init(); 46 $masterData = new SC_DB_MasterData();47 $this->arrPref = $masterData->getMasterData('mtb_pref');48 46 $this->tpl_title = "お届け先の複数指定"; 49 47 $this->httpCacheControl('nocache'); … … 70 68 $objPurchase = new SC_Helper_Purchase_Ex(); 71 69 $objCustomer = new SC_Customer(); 72 $obj Query = SC_Query::getSingletonInstance();73 $this->objFormParam = new SC_FormParam(); 74 75 $uniqid = $objSiteSess->getUniqId(); 76 77 $this->addrs = $this->getDelivAddrs($objCustomer, $objPurchase, $uniqid);70 $objFormParam = new SC_FormParam(); 71 72 $this->tpl_uniqid = $objSiteSess->getUniqId(); 73 74 $this->addrs = $this->getDelivAddrs($objCustomer, $objPurchase, 75 $this->tpl_uniqid); 78 76 $this->items = $this->splitItems($objCartSess); 79 77 80 $this->lfInitParam($this->items); 81 $this->objFormParam->setParam($_POST); 82 83 $objPurchase->verifyChangeCart($uniqid, $objCartSess); 84 85 $this->tpl_uniqid = $uniqid; 86 87 $this->cartKey = $objCartSess->getKey(); 78 $this->lfInitParam($this->items, $objFormParam); 79 $objFormParam->setParam($_POST); 80 $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); 81 88 82 if ($_SERVER["REQUEST_METHOD"] == "POST") { 89 83 if (!SC_Helper_Session_Ex::isValidToken()) { 90 84 SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); 85 exit; 91 86 } 92 87 } 93 88 94 89 switch ($this->getMode()) { 95 case 'delete':96 // TODO97 break;98 99 90 case 'confirm': 100 $this->arrErr = $this->lfCheckError($ this->objFormParam);91 $this->arrErr = $this->lfCheckError($objFormParam); 101 92 if (SC_Utils_Ex::isBlank($this->arrErr)) { 102 // TODO リファクタリング 103 $params = $this->objFormParam->getHashArray(); 104 $i = 0; 105 while ($params['cart_no' . $i] != null) { 106 $other_deliv_id = $params['shipping' . $i]; 107 if ($objCustomer->isLoginSuccess(true)) { 108 if ($other_deliv_id != 0) { 109 $otherDeliv = $objQuery->select("*", "dtb_other_deliv", 110 "other_deliv_id = ?", 111 array($other_deliv_id)); 112 foreach ($otherDeliv[0] as $key => $val) { 113 $sqlval[$other_deliv_id]['shipping_' . $key] = $val; 114 } 115 } else { 116 $objPurchase->copyFromCustomer($sqlval[0], $objCustomer, 117 "shipping"); 118 } 119 } 120 $sqlval[$other_deliv_id]['deliv_id'] = $objPurchase->getDeliv($this->cartKey); 121 $objPurchase->setShipmentItemTemp($other_deliv_id, $params['product_class_id' . $i], $params['quantity' . $i]); 122 $i++; 123 } 124 125 foreach ($sqlval as $shipping_id => $val) { 126 $objPurchase->saveShippingTemp($val, $shipping_id); 127 } 128 129 $objPurchase->shippingItemTempToCart($objCartSess); 130 $objPurchase->saveOrderTemp($uniqid, $sqlval[0], $objCustomer); 93 $this->saveMultipleShippings($this->tpl_uniqid, $objFormParam, 94 $objCustomer, $objPurchase, 95 $objCartSess); 131 96 $objSiteSess->setRegistFlag(); 132 97 SC_Response_Ex::sendRedirect("payment.php"); … … 138 103 } 139 104 140 $this->arrForm = $ this->objFormParam->getFormParamList();105 $this->arrForm = $objFormParam->getFormParamList(); 141 106 $this->transactionid = SC_Helper_Session_Ex::getToken(); 142 107 } … … 153 118 /** 154 119 * フォームを初期化する. 155 */ 156 function lfInitParam($items) { 157 for ($i = 0; $i < count($items); $i++) { 158 $this->objFormParam->addParam("商品規格ID", "product_class_id" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 159 $this->objFormParam->addParam("数量", "quantity" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); 160 $this->objFormParam->addParam("配送先住所", "shipping" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 161 $this->objFormParam->addParam("カート番号", "cart_no" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 162 } 163 } 164 120 * 121 * @param array $arrItems 数量ごとに分割した, カートの商品情報の配列 122 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 123 * @return void 124 */ 125 function lfInitParam($arrItems, $objFormParam) { 126 for ($i = 0; $i < count($arrItems); $i++) { 127 $objFormParam->addParam("商品規格ID", "product_class_id" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 128 $objFormParam->addParam("数量", "quantity" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); 129 $objFormParam->addParam("配送先住所", "shipping" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 130 $objFormParam->addParam("カート番号", "cart_no" . $i, INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 131 } 132 } 165 133 166 134 /** 167 135 * カートの商品を数量ごとに分割する 136 * 137 * @param SC_CartSession $objCartSess SC_CartSession インスタンス 138 * @return array 数量ごとに分割した, カートの商品情報の配列 168 139 */ 169 140 function splitItems(&$objCartSess) { … … 182 153 * 会員ログイン済みの場合は, 会員登録住所及び追加登録住所を取得する. 183 154 * 非会員の場合は, 「お届け先の指定」画面で入力した住所を取得する. 155 * 156 * @param SC_Customer $objCustomer SC_Customer インスタンス 157 * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス 158 * @param integer $uniqid 受注一時テーブルのユニークID 159 * @return array 配送住所のプルダウン用連想配列 184 160 */ 185 161 function getDelivAddrs(&$objCustomer, &$objPurchase, $uniqid) { 162 $masterData = new SC_DB_MasterData(); 163 $arrPref = $masterData->getMasterData('mtb_pref'); 164 165 // 会員ログイン時 186 166 if ($objCustomer->isLoginSuccess(true)) { 187 $a ddrs = $objCustomer->getCustomerAddress($_SESSION['customer']['customer_id']);188 $ results = array();189 foreach ($a ddrs as $key =>$val) {167 $arrAddrs = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id')); 168 $arrResults = array(); 169 foreach ($arrAddrs as $val) { 190 170 $other_deliv_id = SC_Utils_Ex::isBlank($val['other_deliv_id']) ? 0 : $val['other_deliv_id']; 191 $results[$other_deliv_id] = $val['name01'] . $val['name02'] 192 . " " . $this->arrPref[$val['pref']] . $val['addr01'] . $val['addr02']; 193 } 194 } else { 195 $shipping = $objPurchase->getShippingTemp(); 196 foreach ($shipping as $shipping_id => $val) { 197 $results[$shipping_id] = $val['shipping_name01'] . $val['shipping_name02'] 198 . " " . $this->arrPref[$val['shipping_pref']] 171 $arrResults[$other_deliv_id] = $val['name01'] . $val['name02'] 172 . " " . $arrPref[$val['pref']] . $val['addr01'] . $val['addr02']; 173 } 174 } 175 // 非会員 176 else { 177 $arrShippings = $objPurchase->getShippingTemp(); 178 foreach ($arrShippings as $shipping_id => $val) { 179 $arrResults[$shipping_id] = $val['shipping_name01'] . $val['shipping_name02'] 180 . " " . $arrPref[$val['shipping_pref']] 199 181 . $val['shipping_addr01'] . $val['shipping_addr02']; 200 182 } 201 183 } 202 return $results; 203 } 204 184 return $arrResults; 185 } 186 187 /** 188 * 入力チェックを行う. 189 * 190 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 191 * @return array エラー情報の配列 192 */ 205 193 function lfCheckError(&$objFormParam) { 206 194 $objFormParam->convParam(); 207 195 return $objFormParam->checkError(); 208 196 } 197 198 /** 199 * 複数配送情報を一時保存する. 200 * 201 * 会員ログインしている場合は, その他のお届け先から住所情報を取得する. 202 * 203 * @param integer $uniqid 一時受注テーブルのユニークID 204 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 205 * @param SC_Customer $objCustomer SC_Customer インスタンス 206 * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス 207 * @param SC_CartSession $objCartSess SC_CartSession インスタンス 208 * @return void 209 */ 210 function saveMultipleShippings($uniqid, &$objFormParam, &$objCustomer, 211 &$objPurchase, &$objCartSess) { 212 $objQuery =& SC_Query::getSingletonInstance(); 213 214 $arrParams = $objFormParam->getHashArray(); 215 $i = 0; 216 while ($arrParams['cart_no' . $i] != null) { 217 $other_deliv_id = $arrParams['shipping' . $i]; 218 219 if ($objCustomer->isLoginSuccess(true)) { 220 if ($other_deliv_id != 0) { 221 $otherDeliv = $objQuery->select("*", "dtb_other_deliv", 222 "other_deliv_id = ?", 223 array($other_deliv_id)); 224 foreach ($otherDeliv[0] as $key => $val) { 225 $arrValues[$other_deliv_id]['shipping_' . $key] = $val; 226 } 227 } else { 228 $objPurchase->copyFromCustomer($arrValues[0], $objCustomer, 229 "shipping"); 230 } 231 } 232 233 $objPurchase->setShipmentItemTemp($other_deliv_id, 234 $arrParams['product_class_id' . $i], 235 $arrParams['quantity' . $i]); 236 $i++; 237 } 238 239 foreach ($arrValues as $shipping_id => $val) { 240 $objPurchase->saveShippingTemp($val, $shipping_id); 241 } 242 243 $objPurchase->shippingItemTempToCart($objCartSess); 244 // $arrValues[0] には, 購入者の情報が格納されている 245 $objPurchase->saveOrderTemp($uniqid, $arrValues[0], $objCustomer); 246 } 209 247 } 210 248 ?>
Note: See TracChangeset
for help on using the changeset viewer.